Files
graphify/tests/fixtures/dynamic_import.ts
Yalkowni 563ee80494 fix(extract): skip dynamic template literals in import() args
import(`./handlers/${name}`) previously produced a garbage edge to a
path containing the unresolved ${name} expression. Now detects
template_substitution child nodes and breaks without emitting an edge.
Static template literals (no interpolation) still resolve correctly.

Adds 2 new tests: one asserting dynamic templates produce no edge,
one asserting static templates resolve like plain strings.
2026-04-27 16:41:19 -07:00

33 lines
1.0 KiB
TypeScript

import { logger } from './logger';
async function processInbound(orgId: string, phone: string) {
const { shouldHandle, processMessage } = await import('./mayaEngine.js');
const handle = await shouldHandle(orgId, phone);
if (handle.sessionId) {
await processMessage({ orgId, phone }, handle.sessionId);
}
}
async function pollMessages(orgId: string) {
const { commsQueue } = await import('./queue.js');
await commsQueue.add('check-inbound', { orgId });
}
async function loadHandler(handlerName: string) {
// dynamic template literal — path not statically resolvable, should produce no edge
const mod = await import(`./handlers/${handlerName}`);
return mod.default;
}
async function loadStatic() {
// static template literal (no interpolation) — should resolve like a plain string
const { helper } = await import(`./staticHelper`);
return helper;
}
function syncOnly() {
logger.info('no dynamic imports here');
}
export { processInbound, pollMessages, loadHandler, loadStatic, syncOnly };