@saptools/service-flow 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/discovery/discover-repositories.ts","../src/utils/path-utils.ts","../src/parsers/package-json-parser.ts","../src/parsers/cds-parser.ts","../src/parsers/decorator-parser.ts","../src/parsers/ts-project.ts","../src/parsers/handler-registration-parser.ts","../src/utils/redaction.ts","../src/parsers/outbound-call-parser.ts","../src/parsers/service-binding-parser.ts","../src/linker/dynamic-edge-resolver.ts","../src/linker/service-resolver.ts","../src/linker/helper-package-linker.ts","../src/linker/cross-repo-linker.ts","../src/trace/traversal.ts","../src/trace/trace-engine.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { DiscoveredRepository } from '../types.js';\nimport { relativePath } from '../utils/path-utils.js';\nexport async function discoverRepositories(\n rootPath: string,\n ignore: readonly string[]\n): Promise<DiscoveredRepository[]> {\n const root = path.resolve(rootPath);\n const ignored = new Set(ignore);\n const found: DiscoveredRepository[] = [];\n async function walk(dir: string): Promise<void> {\n const rel = relativePath(root, dir);\n if (rel !== '.' && rel.split('/').some((part) => ignored.has(part))) return;\n let entries: Array<{ name: string; isDirectory: () => boolean }>;\n try {\n entries = await fs.readdir(dir, { withFileTypes: true });\n } catch {\n return;\n }\n if (entries.some((e) => e.name === '.git' || e.name === '.git-fixture')) {\n found.push({\n name: path.basename(dir),\n absolutePath: dir,\n relativePath: relativePath(root, dir),\n isGitRepo: true\n });\n return;\n }\n for (const entry of entries)\n if (entry.isDirectory() && !ignore.includes(entry.name))\n await walk(path.join(dir, entry.name));\n }\n await walk(root);\n return found.sort((a, b) => a.relativePath.localeCompare(b.relativePath));\n}\n","import path from 'node:path';\nexport function normalizePath(value: string): string {\n return value.split(path.sep).join('/');\n}\nexport function relativePath(root: string, value: string): string {\n return normalizePath(path.relative(root, value) || '.');\n}\nexport function ensureLeadingSlash(value: string): string {\n return value.startsWith('/') ? value : `/${value}`;\n}\nexport function stripQuotes(value: string): string {\n return value.replace(/^['\"`]|['\"`]$/g, '');\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { CdsRequire, PackageFacts } from '../types.js';\nfunction recordOfString(value: unknown): Record<string, string> {\n if (!value || typeof value !== 'object') return {};\n return Object.fromEntries(\n Object.entries(value).filter(([, v]) => typeof v === 'string')\n ) as Record<string, string>;\n}\nfunction readRequires(cds: unknown): CdsRequire[] {\n const requires =\n cds && typeof cds === 'object' && 'requires' in cds\n ? (cds as { requires?: unknown }).requires\n : undefined;\n if (!requires || typeof requires !== 'object') return [];\n return Object.entries(requires).flatMap(([alias, raw]) => {\n if (!raw || typeof raw !== 'object') return [];\n const obj = raw as Record<string, unknown>;\n const credentials =\n obj.credentials && typeof obj.credentials === 'object'\n ? (obj.credentials as Record<string, unknown>)\n : {};\n return [\n {\n alias,\n kind: typeof obj.kind === 'string' ? obj.kind : undefined,\n model: typeof obj.model === 'string' ? obj.model : undefined,\n destination:\n typeof credentials.destination === 'string'\n ? credentials.destination\n : undefined,\n servicePath:\n typeof credentials.path === 'string' ? credentials.path : undefined,\n requestTimeout:\n typeof credentials.requestTimeout === 'number'\n ? credentials.requestTimeout\n : undefined,\n rawJson: JSON.stringify(raw)\n }\n ];\n });\n}\nexport async function parsePackageJson(\n repoPath: string\n): Promise<PackageFacts> {\n try {\n const raw = await fs.readFile(path.join(repoPath, 'package.json'), 'utf8');\n const json = JSON.parse(raw) as Record<string, unknown>;\n return {\n packageName: typeof json.name === 'string' ? json.name : undefined,\n packageVersion:\n typeof json.version === 'string' ? json.version : undefined,\n dependencies: {\n ...recordOfString(json.dependencies),\n ...recordOfString(json.devDependencies)\n },\n cdsRequires: readRequires(json.cds),\n scripts: recordOfString(json.scripts)\n };\n } catch {\n return { dependencies: {}, cdsRequires: [], scripts: {} };\n }\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { CdsServiceFact } from '../types.js';\nimport { ensureLeadingSlash, normalizePath } from '../utils/path-utils.js';\nfunction lineOf(text: string, index: number): number {\n return text.slice(0, index).split('\\n').length;\n}\nfunction pathAnno(prefix: string): string | undefined {\n return /@\\s*\\(?\\s*path\\s*:\\s*['\"]([^'\"]+)['\"]\\s*\\)?/.exec(prefix)?.[1];\n}\nexport async function parseCdsFile(\n repoPath: string,\n filePath: string\n): Promise<CdsServiceFact[]> {\n const absolute = path.join(repoPath, filePath);\n const text = await fs.readFile(absolute, 'utf8');\n const namespace = /namespace\\s+([\\w.]+)\\s*;/.exec(text)?.[1];\n const services: CdsServiceFact[] = [];\n const serviceRegex =\n /((?:@\\s*\\(?\\s*path\\s*:\\s*['\"][^'\"]+['\"]\\s*\\)?\\s*)?)(extend\\s+)?service\\s+(\\w+)\\s*(?:@\\s*\\(?\\s*path\\s*:\\s*['\"]([^'\"]+)['\"]\\s*\\)?\\s*)?\\{/g;\n let match: RegExpExecArray | null;\n while ((match = serviceRegex.exec(text))) {\n const serviceName = match[3] ?? 'UnknownService';\n const start = match.index + match[0].length;\n let depth = 1;\n let end = start;\n for (; end < text.length; end += 1) {\n const c = text[end];\n if (c === '{') depth += 1;\n if (c === '}') depth -= 1;\n if (depth === 0) break;\n }\n const body = text.slice(start, end);\n const servicePath = ensureLeadingSlash(\n match[4] ?? pathAnno(match[1] ?? '') ?? serviceName\n );\n const ops = [\n ...body.matchAll(\n /\\b(action|function|event)\\s+(\\w+)\\s*(?:\\(([^)]*)\\))?\\s*(?:returns\\s+([^;{]+))?/g\n )\n ].map((m) => ({\n operationType: (m[1] as 'action' | 'function' | 'event') ?? 'action',\n operationName: m[2] ?? 'unknown',\n operationPath: ensureLeadingSlash(m[2] ?? 'unknown'),\n paramsJson: JSON.stringify(\n (m[3] ?? '')\n .split(',')\n .map((p) => p.trim())\n .filter(Boolean)\n ),\n returnType: m[4]?.trim(),\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, start + (m.index ?? 0))\n }));\n services.push({\n namespace,\n serviceName,\n qualifiedName: namespace ? `${namespace}.${serviceName}` : serviceName,\n servicePath,\n isExtend: Boolean(match[2]),\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, match.index),\n operations: ops\n });\n serviceRegex.lastIndex = end;\n }\n return services;\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport ts from 'typescript';\nimport type { HandlerClassFact } from '../types.js';\nimport { createSourceFile } from './ts-project.js';\nimport { normalizePath, stripQuotes } from '../utils/path-utils.js';\nfunction line(sf: ts.SourceFile, pos: number): number {\n return sf.getLineAndCharacterOfPosition(pos).line + 1;\n}\nfunction decs(node: ts.Node): ts.Decorator[] {\n return ts.canHaveDecorators(node) ? [...(ts.getDecorators(node) ?? [])] : [];\n}\nfunction callName(d: ts.Decorator): string {\n const e = d.expression;\n return ts.isCallExpression(e) ? e.expression.getText() : e.getText();\n}\nfunction firstArg(d: ts.Decorator): string {\n const e = d.expression;\n return ts.isCallExpression(e) && e.arguments[0]\n ? e.arguments[0].getText()\n : '';\n}\nexport async function parseDecorators(\n repoPath: string,\n filePath: string\n): Promise<HandlerClassFact[]> {\n const text = await fs.readFile(path.join(repoPath, filePath), 'utf8');\n const sf = createSourceFile(filePath, text);\n const constants = new Map<string, string>();\n const handlers: HandlerClassFact[] = [];\n function visit(node: ts.Node): void {\n if (\n ts.isVariableDeclaration(node) &&\n ts.isIdentifier(node.name) &&\n node.initializer &&\n ts.isStringLiteralLike(node.initializer)\n )\n constants.set(node.name.text, node.initializer.text);\n if (ts.isClassDeclaration(node)) {\n const className = node.name?.text ?? 'AnonymousHandler';\n const hasHandler = decs(node).some((d) => callName(d) === 'Handler');\n const methods = node.members.filter(ts.isMethodDeclaration).flatMap((m) =>\n decs(m)\n .filter((d) =>\n ['Func', 'Action', 'On', 'Event'].includes(callName(d))\n )\n .map((d) => {\n const raw = firstArg(d);\n const value =\n raw.startsWith('\"') || raw.startsWith(\"'\") || raw.startsWith('`')\n ? stripQuotes(raw)\n : (constants.get(raw) ??\n (raw.endsWith('.name') ? raw.split('.').at(-2) : undefined));\n return {\n methodName: m.name.getText(),\n decoratorKind: callName(d),\n decoratorValue: value,\n decoratorRawExpression: raw,\n sourceFile: normalizePath(filePath),\n sourceLine: line(sf, m.getStart())\n };\n })\n );\n if (hasHandler || methods.length > 0)\n handlers.push({\n className,\n sourceFile: normalizePath(filePath),\n sourceLine: line(sf, node.getStart()),\n methods\n });\n }\n ts.forEachChild(node, visit);\n }\n visit(sf);\n return handlers;\n}\n","import ts from 'typescript';\nexport function createSourceFile(\n filePath: string,\n text: string\n): ts.SourceFile {\n return ts.createSourceFile(\n filePath,\n text,\n ts.ScriptTarget.Latest,\n true,\n filePath.endsWith('.js') ? ts.ScriptKind.JS : ts.ScriptKind.TS\n );\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { HandlerRegistrationFact } from '../types.js';\nimport { normalizePath } from '../utils/path-utils.js';\nfunction lineOf(text: string, idx: number): number {\n return text.slice(0, idx).split('\\n').length;\n}\nexport async function parseHandlerRegistrations(\n repoPath: string,\n filePath: string\n): Promise<HandlerRegistrationFact[]> {\n const text = await fs.readFile(path.join(repoPath, filePath), 'utf8');\n const out: HandlerRegistrationFact[] = [];\n for (const m of text.matchAll(\n /createCombinedHandler\\s*\\(|srv\\.prepend\\s*\\(|cds\\.serve\\s*\\(/g\n ))\n out.push({\n registrationFile: normalizePath(filePath),\n registrationLine: lineOf(text, m.index ?? 0),\n registrationKind: m[0].startsWith('cds')\n ? 'cds.serve'\n : 'combined-handler',\n confidence: 0.8\n });\n for (const m of text.matchAll(\n /(?:const|export\\s+const)\\s+handlers\\s*=\\s*\\[([\\s\\S]*?)\\]/g\n ))\n for (const c of (m[1] ?? '').matchAll(/\\b(\\w+Handler)\\b/g))\n out.push({\n className: c[1],\n registrationFile: normalizePath(filePath),\n registrationLine: lineOf(text, (m.index ?? 0) + (c.index ?? 0)),\n registrationKind: 'handler-array',\n confidence: 0.9\n });\n return out;\n}\n","const SENSITIVE = /authorization|cookie|token|secret|password|key|credential/i;\nexport function redactText(text: string): string {\n return text.replace(\n /(authorization|cookie|token|secret|password|key|credential)\\s*[:=]\\s*(['\"`]?)[^,'\"`}\\s]+\\2/gi,\n '$1: [REDACTED]'\n );\n}\nexport function redactValue(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(redactValue);\n if (value && typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value))\n out[k] = SENSITIVE.test(k) ? '[REDACTED]' : redactValue(v);\n return out;\n }\n return typeof value === 'string' ? redactText(value) : value;\n}\nexport function summarizeExpression(text: string): string {\n return redactText(text).slice(0, 240);\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { OutboundCallFact } from '../types.js';\nimport { normalizePath, stripQuotes } from '../utils/path-utils.js';\nimport { summarizeExpression } from '../utils/redaction.js';\nfunction lineOf(text: string, idx: number): number {\n return text.slice(0, idx).split('\\n').length;\n}\nfunction firstArg(body: string, key: string): string | undefined {\n return new RegExp(`${key}\\\\s*:\\\\s*([^,}\\\\n]+)`).exec(body)?.[1]?.trim();\n}\nexport async function parseOutboundCalls(\n repoPath: string,\n filePath: string\n): Promise<OutboundCallFact[]> {\n const text = await fs.readFile(path.join(repoPath, filePath), 'utf8');\n const out: OutboundCallFact[] = [];\n for (const m of text.matchAll(/(\\w+)\\.send\\s*\\(\\s*\\{([\\s\\S]*?)\\}\\s*\\)/g)) {\n const body = m[2] ?? '';\n const query = firstArg(body, 'query');\n const op = firstArg(body, 'path');\n out.push({\n callType: query ? 'remote_query' : 'remote_action',\n serviceVariableName: m[1],\n method: stripQuotes(firstArg(body, 'method') ?? 'POST'),\n operationPathExpr: op ? stripQuotes(op) : undefined,\n queryEntity: /SELECT\\.from\\((\\w+)\\)/.exec(query ?? '')?.[1],\n payloadSummary: summarizeExpression(body),\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0),\n confidence: op || query ? 0.8 : 0.4\n });\n }\n for (const m of text.matchAll(/cds\\.run\\s*\\(([\\s\\S]*?)\\)/g))\n out.push({\n callType: 'local_db_query',\n queryEntity: /(?:SELECT\\.from|INSERT\\.into)\\((\\w+)\\)/.exec(\n m[1] ?? ''\n )?.[1],\n payloadSummary: summarizeExpression(m[1] ?? ''),\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0),\n confidence: 0.85\n });\n for (const m of text.matchAll(\n /(\\w+)\\.(emit|publish|on)\\s*\\(\\s*(['\"`])([^'\"`]+)\\3/g\n ))\n out.push({\n callType: m[2] === 'on' ? 'async_subscribe' : 'async_emit',\n serviceVariableName: m[1],\n eventNameExpr: m[4],\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0),\n confidence: 0.8\n });\n for (const m of text.matchAll(\n /(?:axios\\s*\\(|executeHttpRequest\\s*\\(|useOrFetchDestination\\s*\\()([\\s\\S]*?)\\)/g\n ))\n out.push({\n callType: 'external_http',\n payloadSummary: summarizeExpression(m[1] ?? ''),\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0),\n confidence: 0.7,\n unresolvedReason:\n 'External HTTP destination is outside indexed CAP services'\n });\n for (const m of text.matchAll(\n /cds\\.services(?:\\[['\"]([^'\"]+)['\"]\\]|\\.(\\w+))\\.(\\w+)\\s*\\(/g\n ))\n out.push({\n callType: 'local_service_call',\n operationPathExpr: `/${m[3] ?? ''}`,\n payloadSummary: m[1] ?? m[2],\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0),\n confidence: 0.75\n });\n return out;\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { ServiceBindingFact } from '../types.js';\nimport { normalizePath, stripQuotes } from '../utils/path-utils.js';\nfunction lineOf(text: string, idx: number): number {\n return text.slice(0, idx).split('\\n').length;\n}\nfunction placeholders(value?: string): string[] {\n return [...(value ?? '').matchAll(/\\$\\{\\s*(\\w+)\\s*\\}/g)]\n .map((m) => m[1] ?? '')\n .filter(Boolean);\n}\nexport async function parseServiceBindings(\n repoPath: string,\n filePath: string\n): Promise<ServiceBindingFact[]> {\n const text = await fs.readFile(path.join(repoPath, filePath), 'utf8');\n const out: ServiceBindingFact[] = [];\n for (const m of text.matchAll(\n /(?:const|let|this\\.)\\s*(\\w+)\\s*=\\s*(?:await\\s*)?cds\\.connect\\.to\\((['\"`])([^'\"`]+)\\2\\)/g\n ))\n out.push({\n variableName: m[1] ?? 'service',\n alias: m[3],\n isDynamic: false,\n placeholders: [],\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0)\n });\n for (const m of text.matchAll(\n /(?:const|let|this\\.)\\s*(\\w+)\\s*=\\s*(?:await\\s*)?cds\\.connect\\.to\\(\\{([\\s\\S]*?)\\}\\s*\\)/g\n )) {\n const body = m[2] ?? '';\n const destination = /destination\\s*:\\s*([^,\\n]+)/.exec(body)?.[1];\n const servicePath = /path\\s*:\\s*([^,\\n]+)/.exec(body)?.[1];\n const dest = destination ? stripQuotes(destination.trim()) : undefined;\n const svc = servicePath ? stripQuotes(servicePath.trim()) : undefined;\n const ph = [...placeholders(dest), ...placeholders(svc)];\n out.push({\n variableName: m[1] ?? 'service',\n destinationExpr: dest,\n servicePathExpr: svc,\n isDynamic: ph.length > 0,\n placeholders: ph,\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0)\n });\n }\n for (const m of text.matchAll(\n /function\\s+(\\w+)\\s*\\([^)]*\\)\\s*\\{[\\s\\S]*?return\\s+cds\\.connect\\.to\\((['\"])([^'\"]+)\\2\\)/g\n ))\n out.push({\n variableName: m[1] ?? 'connect',\n alias: m[3],\n isDynamic: false,\n placeholders: [],\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0)\n });\n return out;\n}\n","export function applyVariables(\n template: string | undefined,\n vars: Record<string, string>\n): string | undefined {\n if (!template) return undefined;\n return template.replace(\n /\\$\\{\\s*(\\w+)\\s*\\}/g,\n (_m, key: string) => vars[key] ?? `\\${${key}}`\n );\n}\nexport function extractPlaceholders(template: string | undefined): string[] {\n return [...(template ?? '').matchAll(/\\$\\{\\s*(\\w+)\\s*\\}/g)]\n .map((m) => m[1] ?? '')\n .filter(Boolean);\n}\n","import type { Db } from '../db/connection.js';\nexport interface OperationTarget {\n operationId: number;\n repoName: string;\n servicePath: string;\n operationPath: string;\n operationName: string;\n sourceFile: string;\n sourceLine: number;\n}\nexport function findOperation(\n db: Db,\n servicePath: string | undefined,\n operationPath: string | undefined,\n workspaceId?: number\n): OperationTarget | undefined {\n if (!operationPath) return undefined;\n const row = db\n .prepare(\n `SELECT o.id operationId,r.name repoName,s.service_path servicePath,o.operation_path operationPath,o.operation_name operationName,o.source_file sourceFile,o.source_line sourceLine\n FROM cds_operations o\n JOIN cds_services s ON s.id=o.service_id\n JOIN repositories r ON r.id=s.repo_id\n WHERE (? IS NULL OR r.workspace_id=?)\n AND (? IS NULL OR s.service_path=?)\n AND (o.operation_path=? OR o.operation_name=?)\n ORDER BY CASE WHEN s.service_path=? THEN 0 ELSE 1 END\n LIMIT 1`\n )\n .get(\n workspaceId,\n workspaceId,\n servicePath,\n servicePath,\n operationPath,\n operationPath.replace(/^\\//, ''),\n servicePath\n ) as OperationTarget | undefined;\n return row;\n}\n","import type { Db } from '../db/connection.js';\nexport function linkHelperPackages(db: Db, workspaceId: number): number {\n const repos = db\n .prepare(\n 'SELECT id,name,dependencies_json FROM repositories WHERE workspace_id=?'\n )\n .all(workspaceId) as Array<{\n id: number;\n name: string;\n dependencies_json: string;\n }>;\n let count = 0;\n for (const repo of repos) {\n const deps = JSON.parse(repo.dependencies_json) as Record<string, string>;\n for (const dep of Object.keys(deps)) {\n const helper = repos.find((r) => r.name === dep || dep.endsWith(r.name));\n if (helper) {\n db.prepare(\n 'INSERT INTO graph_edges(workspace_id,edge_type,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic) VALUES(?,?,?,?,?,?,?,?,?)'\n ).run(\n workspaceId,\n 'REPO_IMPORTS_HELPER_PACKAGE',\n 'repo',\n String(repo.id),\n 'repo',\n String(helper.id),\n 0.9,\n JSON.stringify({ dependency: dep }),\n 0\n );\n count += 1;\n }\n }\n }\n return count;\n}\n","import type { Db } from '../db/connection.js';\nimport { applyVariables } from './dynamic-edge-resolver.js';\nimport { findOperation } from './service-resolver.js';\nimport { linkHelperPackages } from './helper-package-linker.js';\nexport function linkWorkspace(\n db: Db,\n workspaceId: number,\n vars: Record<string, string> = {}\n): { edgeCount: number; unresolvedCount: number } {\n db.prepare('DELETE FROM graph_edges WHERE workspace_id=?').run(workspaceId);\n let edges = linkHelperPackages(db, workspaceId);\n let unresolved = 0;\n const calls = db\n .prepare(\n `SELECT c.*,r.name repoName,b.alias,b.destination_expr destinationExpr,b.service_path_expr servicePathExpr,b.is_dynamic isDynamic,b.placeholders_json placeholdersJson,req.service_path requireServicePath,req.destination requireDestination FROM outbound_calls c JOIN repositories r ON r.id=c.repo_id LEFT JOIN service_bindings b ON b.id=c.service_binding_id LEFT JOIN cds_requires req ON req.repo_id=c.repo_id AND req.alias=b.alias WHERE r.workspace_id=?`\n )\n .all(workspaceId) as Array<Record<string, unknown>>;\n for (const call of calls) {\n const callType = String(call.call_type);\n const op = applyVariables(String(call.operation_path_expr ?? ''), vars);\n const servicePath = applyVariables(\n (call.servicePathExpr as string | undefined) ??\n (call.requireServicePath as string | undefined),\n vars\n );\n const target = callType.startsWith('remote')\n ? findOperation(db, servicePath, op, workspaceId)\n : undefined;\n const evidence = {\n sourceFile: call.source_file,\n sourceLine: call.source_line,\n serviceAlias: call.alias,\n destination: call.destinationExpr ?? call.requireDestination,\n servicePath,\n operationPath: op,\n targetRepo: target?.repoName,\n targetOperation: target?.operationName\n };\n if (target) {\n db.prepare(\n 'INSERT INTO graph_edges(workspace_id,edge_type,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic) VALUES(?,?,?,?,?,?,?,?,?)'\n ).run(\n workspaceId,\n 'REMOTE_CALL_RESOLVES_TO_OPERATION',\n 'call',\n String(call.id),\n 'operation',\n String(target.operationId),\n call.isDynamic ? 0.6 : 0.9,\n JSON.stringify(evidence),\n call.isDynamic ? 1 : 0\n );\n edges += 1;\n } else {\n const edgeType =\n callType === 'local_db_query'\n ? 'HANDLER_RUNS_DB_QUERY'\n : callType === 'external_http'\n ? 'HANDLER_CALLS_EXTERNAL_HTTP'\n : callType === 'async_emit'\n ? 'HANDLER_EMITS_EVENT'\n : callType === 'async_subscribe'\n ? 'EVENT_CONSUMED_BY_HANDLER'\n : call.isDynamic\n ? 'DYNAMIC_EDGE_CANDIDATE'\n : 'UNRESOLVED_EDGE';\n db.prepare(\n 'INSERT INTO graph_edges(workspace_id,edge_type,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic,unresolved_reason) VALUES(?,?,?,?,?,?,?,?,?,?)'\n ).run(\n workspaceId,\n edgeType,\n 'call',\n String(call.id),\n callType.startsWith('async_') ? 'event' : 'external',\n String(call.event_name_expr ?? call.query_entity ?? op ?? call.id),\n Number(call.confidence ?? 0.2),\n JSON.stringify(evidence),\n call.isDynamic ? 1 : 0,\n String(call.unresolved_reason ?? 'No indexed target operation matched')\n );\n edges += 1;\n unresolved += edgeType === 'UNRESOLVED_EDGE' ? 1 : 0;\n }\n }\n return { edgeCount: edges, unresolvedCount: unresolved };\n}\n","import type { TraceEdge } from '../types.js';\nexport function limitDepth(edges: TraceEdge[], depth: number): TraceEdge[] {\n return edges.filter((edge) => edge.step <= depth);\n}\n","import type { Db } from '../db/connection.js';\nimport type { TraceResult, TraceStart } from '../types.js';\nimport { applyVariables } from '../linker/dynamic-edge-resolver.js';\nimport { limitDepth } from './traversal.js';\n\ninterface RepoRef {\n id: number;\n name: string;\n}\n\ninterface StartScope {\n repo?: RepoRef;\n sourceFiles?: Set<string>;\n selectorMatched: boolean;\n}\n\nfunction normalizeOperation(value: string | undefined): string | undefined {\n if (!value) return undefined;\n return value.startsWith('/') ? value.slice(1) : value;\n}\n\nfunction positiveDepth(value: number): number {\n return Number.isFinite(value) && value > 0 ? Math.floor(value) : 25;\n}\n\nfunction sourceFilesForStart(\n db: Db,\n repoId: number | undefined,\n start: TraceStart\n): Set<string> | undefined {\n const handler = start.handler;\n const operation = normalizeOperation(start.operation ?? start.operationPath);\n if (!handler && !operation) return undefined;\n\n const rows = db\n .prepare(\n `SELECT DISTINCT hc.source_file sourceFile\n FROM handler_classes hc\n LEFT JOIN handler_methods hm ON hm.handler_class_id=hc.id\n WHERE (? IS NULL OR hc.repo_id=?)\n AND (? IS NULL OR hc.class_name=? OR hm.method_name=?)\n AND (? IS NULL OR hm.decorator_value=? OR hm.method_name=?)`\n )\n .all(\n repoId,\n repoId,\n handler,\n handler,\n handler,\n operation,\n operation,\n operation\n ) as Array<{ sourceFile?: string }>;\n\n if (rows.length === 0) return undefined;\n return new Set(\n rows.map((row) => row.sourceFile).filter(Boolean) as string[]\n );\n}\n\nfunction startScope(db: Db, start: TraceStart): StartScope {\n const repo = start.repo\n ? (db\n .prepare(\n 'SELECT id,name FROM repositories WHERE name=? OR package_name=?'\n )\n .get(start.repo, start.repo) as RepoRef | undefined)\n : undefined;\n if (start.repo && !repo)\n return {\n repo,\n selectorMatched: false\n };\n const sourceFiles = sourceFilesForStart(db, repo?.id, start);\n const hasSelector = Boolean(\n start.handler ?? start.operation ?? start.operationPath\n );\n return {\n repo,\n sourceFiles,\n selectorMatched: !hasSelector || sourceFiles !== undefined\n };\n}\n\nexport function trace(\n db: Db,\n start: TraceStart,\n options: {\n depth: number;\n vars?: Record<string, string>;\n includeExternal?: boolean;\n includeDb?: boolean;\n includeAsync?: boolean;\n }\n): TraceResult {\n const scope = startScope(db, start);\n const calls = db\n .prepare(\n `SELECT c.*,r.name repoName,b.alias,b.destination_expr destinationExpr,b.service_path_expr servicePathExpr,b.is_dynamic isDynamic,req.service_path requireServicePath,req.destination requireDestination FROM outbound_calls c JOIN repositories r ON r.id=c.repo_id LEFT JOIN service_bindings b ON b.id=c.service_binding_id LEFT JOIN cds_requires req ON req.repo_id=c.repo_id AND req.alias=b.alias WHERE (? IS NULL OR c.repo_id=?) ORDER BY c.source_file,c.source_line`\n )\n .all(scope.repo?.id, scope.repo?.id) as Array<Record<string, unknown>>;\n const vars = options.vars ?? {};\n const filtered = calls.filter((c) => {\n if (!scope.selectorMatched) return false;\n if (scope.sourceFiles && !scope.sourceFiles.has(String(c.source_file)))\n return false;\n const type = String(c.call_type);\n if (!options.includeDb && type === 'local_db_query') return false;\n if (!options.includeExternal && type === 'external_http') return false;\n if (!options.includeAsync && type.startsWith('async_')) return false;\n return true;\n });\n const edges = filtered.map((c, index) => {\n const operation = applyVariables(\n c.operation_path_expr as string | undefined,\n vars\n );\n const servicePath = applyVariables(\n (c.servicePathExpr as string | undefined) ??\n (c.requireServicePath as string | undefined),\n vars\n );\n const type = String(c.call_type);\n const to =\n type === 'local_db_query'\n ? `Entity: ${String(c.query_entity ?? 'unknown')}`\n : type === 'async_emit'\n ? `Topic: ${String(c.event_name_expr ?? 'unknown')}`\n : type === 'async_subscribe'\n ? `Topic: ${String(c.event_name_expr ?? 'unknown')}`\n : type === 'external_http'\n ? 'External HTTP destination'\n : `${servicePath ?? ''}${operation ?? ''}` ||\n String(c.event_name_expr ?? 'unknown');\n return {\n step: index + 1,\n type: c.isDynamic ? 'dynamic_action' : type,\n from: `${String(c.repoName)}:${String(c.source_file)}`,\n to,\n evidence: {\n file: c.source_file,\n line: c.source_line,\n alias: c.alias,\n destination: c.destinationExpr ?? c.requireDestination,\n servicePath,\n operationPath: operation,\n method: c.method,\n payloadSummary: c.payload_summary\n },\n confidence: Number(c.confidence ?? 0.5),\n unresolvedReason: c.unresolved_reason as string | undefined\n };\n });\n const diagnostics = db\n .prepare(\n 'SELECT severity,code,message,source_file sourceFile,source_line sourceLine FROM diagnostics WHERE (? IS NULL OR repo_id=?)'\n )\n .all(scope.repo?.id, scope.repo?.id) as Array<Record<string, unknown>>;\n if (!scope.selectorMatched)\n diagnostics.unshift({\n severity: 'warning',\n code: 'trace_start_not_found',\n message: 'No handler source matched the requested trace start selector'\n });\n return {\n start,\n nodes: [],\n edges: limitDepth(edges, positiveDepth(options.depth)),\n diagnostics\n };\n}\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAOA,WAAU;;;ACDjB,OAAO,UAAU;AACV,SAAS,cAAc,OAAuB;AACnD,SAAO,MAAM,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG;AACvC;AACO,SAAS,aAAa,MAAc,OAAuB;AAChE,SAAO,cAAc,KAAK,SAAS,MAAM,KAAK,KAAK,GAAG;AACxD;AACO,SAAS,mBAAmB,OAAuB;AACxD,SAAO,MAAM,WAAW,GAAG,IAAI,QAAQ,IAAI,KAAK;AAClD;AACO,SAAS,YAAY,OAAuB;AACjD,SAAO,MAAM,QAAQ,kBAAkB,EAAE;AAC3C;;;ADRA,eAAsB,qBACpB,UACA,QACiC;AACjC,QAAM,OAAOC,MAAK,QAAQ,QAAQ;AAClC,QAAM,UAAU,IAAI,IAAI,MAAM;AAC9B,QAAM,QAAgC,CAAC;AACvC,iBAAe,KAAK,KAA4B;AAC9C,UAAM,MAAM,aAAa,MAAM,GAAG;AAClC,QAAI,QAAQ,OAAO,IAAI,MAAM,GAAG,EAAE,KAAK,CAAC,SAAS,QAAQ,IAAI,IAAI,CAAC,EAAG;AACrE,QAAI;AACJ,QAAI;AACF,gBAAU,MAAM,GAAG,QAAQ,KAAK,EAAE,eAAe,KAAK,CAAC;AAAA,IACzD,QAAQ;AACN;AAAA,IACF;AACA,QAAI,QAAQ,KAAK,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,SAAS,cAAc,GAAG;AACvE,YAAM,KAAK;AAAA,QACT,MAAMA,MAAK,SAAS,GAAG;AAAA,QACvB,cAAc;AAAA,QACd,cAAc,aAAa,MAAM,GAAG;AAAA,QACpC,WAAW;AAAA,MACb,CAAC;AACD;AAAA,IACF;AACA,eAAW,SAAS;AAClB,UAA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vC,MAAM,GAAG,OAAO,EAAE,QAAQ,CAAC,IAAI,OAAO,EAAE,WAAW,CAAC;AAAA,MACpD;AAAA,MACA,UAAU;AAAA,QACR,MAAM,EAAE;AAAA,QACR,MAAM,EAAE;AAAA,QACR,OAAO,EAAE;AAAA,QACT,aAAa,EAAE,mBAAmB,EAAE;AAAA,QACpC;AAAA,QACA,eAAe;AAAA,QACf,QAAQ,EAAE;AAAA,QACV,gBAAgB,EAAE;AAAA,MACpB;AAAA,MACA,YAAY,OAAO,EAAE,cAAc,GAAG;AAAA,MACtC,kBAAkB,EAAE;AAAA,IACtB;AAAA,EACF,CAAC;AACD,QAAM,cAAc,GACjB;AAAA,IACC;AAAA,EACF,EACC,IAAI,MAAM,MAAM,IAAI,MAAM,MAAM,EAAE;AACrC,MAAI,CAAC,MAAM;AACT,gBAAY,QAAQ;AAAA,MAClB,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AACH,SAAO;AAAA,IACL;AAAA,IACA,OAAO,CAAC;AAAA,IACR,OAAO,WAAW,OAAO,cAAc,QAAQ,KAAK,CAAC;AAAA,IACrD;AAAA,EACF;AACF;","names":["path","path","fs","path","fs","path","path","fs","fs","path","ts","ts","fs","path","fs","path","lineOf","fs","path","fs","path","lineOf","firstArg","fs","path","fs","path","lineOf","fs","path"]}