import ts from 'typescript'; interface SourceFileSnapshot { repoPath: string; filePath: string; text: string; sizeBytes: number; sourceFile: () => ts.SourceFile; } interface RepositorySourceContext { get: (filePath: string) => SourceFileSnapshot | undefined; entries: () => SourceFileSnapshot[]; } type EventEnvironmentTransform = 'toUpperCase' | 'toLowerCase'; interface EventEnvironmentReference { status: 'resolved' | 'refused'; sourceKey: string; environmentKey?: string; transforms: EventEnvironmentTransform[]; sourceFile?: string; startOffset?: number; endOffset?: number; reason?: string; } declare const EVENT_SKELETON_SCHEMA = "service-flow/event-skeleton@1"; interface EventSkeletonFact { schema: typeof EVENT_SKELETON_SCHEMA; status: 'complete' | 'malformed' | 'too_large'; signature: string | null; literalSpans: string[]; holeCount: number; sourceKeys: string[]; canonicalKeys: string[]; candidateEligible: boolean; environmentBindings: EventEnvironmentReference[]; reason?: string; } type CallType = 'remote_action' | 'remote_query' | 'remote_entity_read' | 'remote_entity_mutation' | 'remote_entity_delete' | 'remote_entity_media' | 'remote_entity_candidate' | 'local_db_query' | 'external_http' | 'async_emit' | 'async_subscribe' | 'local_service_call' | 'unknown'; type EdgeType = 'REPO_HAS_SERVICE' | 'SERVICE_HAS_OPERATION' | 'OPERATION_IMPLEMENTED_BY_HANDLER' | 'HANDLER_REGISTERED_BY_SERVER' | 'HANDLER_CALLS_LOCAL_FUNCTION' | 'HANDLER_USES_SERVICE_ALIAS' | 'HANDLER_CALLS_REMOTE_OPERATION' | 'REMOTE_CALL_RESOLVES_TO_OPERATION' | 'LOCAL_CALL_RESOLVES_TO_OPERATION' | 'HANDLER_RUNS_DB_QUERY' | 'HANDLER_RUNS_REMOTE_QUERY' | 'HANDLER_ACCESSES_REMOTE_ENTITY' | 'HANDLER_CALLS_EXTERNAL_HTTP' | 'HANDLER_CALLS_TRANSPORT_METHOD' | 'HANDLER_EMITS_EVENT' | 'EVENT_CONSUMED_BY_HANDLER' | 'EVENT_SUBSCRIPTION_HANDLED_BY' | 'EVENT_SHAPE_CANDIDATE_SUBSCRIBER' | 'REPO_IMPORTS_HELPER_PACKAGE' | 'HELPER_PACKAGE_PROVIDES_HANDLER' | 'DYNAMIC_EDGE_CANDIDATE' | 'UNRESOLVED_EDGE'; interface DiscoveredRepository { name: string; absolutePath: string; relativePath: string; isGitRepo: boolean; } interface CdsRequire { alias: string; kind?: string; model?: string; destination?: string; servicePath?: string; requestTimeout?: number; rawJson: string; } interface PackageFacts { packageName?: string; packageVersion?: string; dependencies: Record; cdsRequires: CdsRequire[]; scripts: Record; } interface CdsServiceFact { namespace?: string; serviceName: string; qualifiedName: string; servicePath: string; isExtend: boolean; sourceFile: string; sourceLine: number; operations: CdsOperationFact[]; extension?: CdsExtensionFact; } interface CdsExtensionFact { localReference: string; importedSymbol?: string; localAlias?: string; moduleSpecifier?: string; importKind?: 'relative' | 'package' | 'none'; } interface CdsOperationFact { operationType: 'action' | 'function' | 'event'; operationName: string; operationPath: string; paramsJson: string; returnType?: string; sourceFile: string; sourceLine: number; provenance?: 'direct' | 'inherited'; baseOperationId?: number; } interface HandlerClassFact { className: string; sourceFile: string; sourceLine: number; methods: HandlerMethodFact[]; hasHandlerDecorator?: boolean; classDecoratorNames?: string[]; observedDecoratorNames?: string[]; unsupportedDecoratorNames?: string[]; } type HandlerMethodKind = 'operation' | 'entity_lifecycle' | 'event' | 'unsupported_lifecycle' | 'unsupported_decorator'; type HandlerLifecyclePhase = 'on' | 'before' | 'after'; type HandlerLifecycleEvent = 'CREATE' | 'READ' | 'UPDATE' | 'DELETE'; interface HandlerMethodFact { methodName: string; decoratorKind: string; decoratorValue?: string; decoratorRawExpression: string; handlerKind?: HandlerMethodKind; executable?: boolean; lifecyclePhase?: HandlerLifecyclePhase; lifecycleEvent?: HandlerLifecycleEvent; decoratorResolution: { rawExpression: string; decoratorExpression?: string; argumentExpression?: string; resolvedDecoratorKind?: string; decoratorImportSource?: string; resolvedValue?: string; resolutionKind: 'literal' | 'const_identifier' | 'enum_member' | 'const_object_property' | 'generated_constant_name' | 'lifecycle_implicit' | 'unresolved'; unresolvedReason?: string; handlerKind?: HandlerMethodKind; executable?: boolean; lifecyclePhase?: HandlerLifecyclePhase; lifecycleEvent?: HandlerLifecycleEvent; }; sourceFile: string; sourceLine: number; } interface HandlerRegistrationFact { className?: string; importSource?: string; registrationFile: string; registrationLine: number; registrationKind: string; confidence: number; } interface ServiceBindingFact { variableName: string; alias?: string; aliasExpr?: string; destinationExpr?: string; servicePathExpr?: string; isDynamic: boolean; placeholders: string[]; sourceFile: string; sourceLine: number; bindingSiteStartOffset?: number; bindingSiteEndOffset?: number; sourceSymbolQualifiedName?: string; ownerResolution?: ServiceBindingOwnerResolution; helperChain?: Array>; } type ServiceBindingOwnerResolution = 'owned_exact' | 'ownerless_file_scope' | 'legacy_unknown'; type ServiceBindingReferenceStatus = 'resolved_exact' | 'ambiguous' | 'unresolved' | 'not_applicable'; type ServiceBindingReferenceReason = 'binding_not_found' | 'binding_declared_after_call' | 'binding_scope_ambiguous' | 'scope_chain_limit_exceeded' | 'unsupported_reaching_assignment' | 'unsupported_var_binding' | 'binding_flow_unsupported'; interface LexicalScopeFact { kind: 'source_file' | 'module_block' | 'function' | 'class' | 'loop' | 'case_block' | 'block' | 'catch'; startOffset: number; endOffset: number; } interface ServiceBindingReference { status: ServiceBindingReferenceStatus; variableName?: string; bindingSourceFile?: string; bindingSiteStartOffset?: number; bindingSiteEndOffset?: number; resolutionStrategy?: 'lexical_declaration' | 'lexical_alias_declaration' | 'deterministic_reaching_assignment' | 'single_hop_helper_return'; lexicalScopeChain?: LexicalScopeFact[]; bindingScopeIndex?: number; scopeChainTotal: number; scopeChainShown: number; scopeChainOmitted: number; reason?: ServiceBindingReferenceReason; } interface OutboundCallFact { callType: CallType; sourceSymbolQualifiedName?: string; localServiceName?: string; localServiceLookup?: string; aliasChain?: string[]; serviceVariableName?: string; method?: string; operationPathExpr?: string; queryEntity?: string; eventNameExpr?: string; eventSkeleton?: EventSkeletonFact; payloadSummary?: string; sourceFile: string; sourceLine: number; callSiteStartOffset?: number; callSiteEndOffset?: number; serviceBindingReference?: ServiceBindingReference; confidence: number; unresolvedReason?: string; evidence?: Record; externalTarget?: { kind: string; stableId: string; label: string; dynamic: boolean; }; } interface ExecutableSymbolFact { kind: string; localName: string; exportedName?: string; qualifiedName: string; sourceFile: string; startLine: number; endLine: number; startOffset: number; endOffset: number; exported: boolean; importExportEvidence?: Record; } type SymbolCallRole = 'ordinary_call' | 'event_subscribe_handler' | 'legacy_unknown'; interface SymbolCallFact { callerQualifiedName: string; calleeExpression: string; calleeLocalName?: string; receiverLocalName?: string; importSource?: string; sourceFile: string; sourceLine: number; callSiteStartOffset?: number; callSiteEndOffset?: number; callRole: Exclude; evidence: Record; } interface GeneratedConstantFact { name: string; value?: string; sourceFile: string; sourceLine: number; containerName?: string; memberName?: string; constantKind: 'const_identifier' | 'enum_member' | 'const_object_property'; exported: boolean; stable: boolean; resolutionStatus: 'resolved' | 'refused'; unresolvedReason?: 'event_name_constant_member_not_string' | 'event_name_constant_container_mutable' | 'event_name_constant_container_unsafe_reference' | 'event_name_constant_container_unsupported_shape'; declarationStartOffset: number; declarationEndOffset: number; valueStartOffset: number; valueEndOffset: number; } interface TraceStart { repo?: string; servicePath?: string; operation?: string; operationPath?: string; handler?: string; } interface ImplementationHint { servicePath?: string; operationPath?: string; packageName?: string; repositoryName?: string; candidateFamily?: string; implementationRepo: string; } type DynamicMode = 'strict' | 'candidates' | 'infer'; interface TraceOptions { depth: number; workspaceId?: number; vars?: Record; includeExternal?: boolean; includeDb?: boolean; includeAsync?: boolean; implementationRepo?: string; implementationHints?: ImplementationHint[]; dynamicMode?: DynamicMode; maxDynamicCandidates?: number; } interface TraceEdge { step: number; type: string; from: string; to: string; fromNodeId?: string; toNodeId?: string; evidence: Record; confidence: number; unresolvedReason?: string; } interface TraceResult { start: TraceStart; nodes: Array>; edges: TraceEdge[]; diagnostics: Array>; } declare function discoverRepositories(rootPath: string, ignore: readonly string[]): Promise; interface ParsePackageJsonOptions { strict?: boolean; allowMissing?: boolean; } declare function parsePackageJson(repoPath: string, options?: ParsePackageJsonOptions): Promise; declare function parseCdsFile(repoPath: string, filePath: string, context?: RepositorySourceContext): Promise; declare function parseDecorators(repoPath: string, filePath: string, context?: RepositorySourceContext): Promise; declare function parseHandlerRegistrations(repoPath: string, filePath: string, context?: RepositorySourceContext): Promise; declare function parseServiceBindings(repoPath: string, filePath: string, context?: RepositorySourceContext): Promise; interface ClassifiedOutboundCall { fact: OutboundCallFact; node: ts.CallExpression; } declare function parseOutboundCalls(repoPath: string, filePath: string, context?: RepositorySourceContext, classified?: readonly ClassifiedOutboundCall[], preparedBindings?: readonly ServiceBindingFact[]): Promise; declare function parseGeneratedConstants(repoPath: string, filePath: string): Promise; interface Statement { run: (...params: unknown[]) => { changes: number; }; get: (...params: unknown[]) => Record | undefined; all: (...params: unknown[]) => Array>; } interface Db { path: string; readonly: boolean; exec: (sql: string) => void; prepare: (sql: string) => Statement; pragma: (sql: string) => Array>; transaction: (fn: () => T) => T; close: () => void; } interface LinkWorkspaceResult { edgeCount: number; unresolvedCount: number; resolvedCount: number; remoteResolvedCount: number; localResolvedCount: number; ambiguousCount: number; dynamicCount: number; terminalCount: number; dependencyResolvedCount: number; dependencyAmbiguousCount: number; implementationResolvedCount: number; implementationAmbiguousCount: number; implementationUnresolvedCount: number; subscriptionHandlerResolvedCount: number; subscriptionHandlerAmbiguousCount: number; subscriptionHandlerUnresolvedCount: number; subscriptionHandlerMissingAssociationCount: number; eventShapeCandidateCount: number; eventShapeCandidateOmittedCount: number; } declare function linkWorkspace(db: Db, workspaceId: number, vars?: Record): LinkWorkspaceResult; interface RuntimeSubstitution { original?: string; effective?: string; placeholders: string[]; missing: string[]; supplied: string[]; changed: boolean; } declare function applyVariables(template: string | undefined, vars: Record): string | undefined; declare function extractPlaceholders(template: string | undefined): string[]; declare function substituteVariables(template: string | undefined, vars: Record): RuntimeSubstitution; type CompactStatus = 'resolved' | 'terminal' | 'inferred' | 'dynamic' | 'ambiguous' | 'unresolved' | 'cycle'; interface CompactSourceContext { schemaVersion: number; analyzerVersion: string; graphGeneration: number; } interface CompactHintV1 { servicePath: string | null; operationPath: string | null; packageName: string | null; repositoryName: string | null; candidateFamily: string | null; implementationRepo: string | null; } interface CompactStartV1 { repo: string | null; servicePath: string | null; operation: string | null; operationPath: string | null; handler: string | null; } interface CompactQueryV1 { depth: number; includeAsync: boolean; includeDb: boolean; includeExternal: boolean; dynamicMode: DynamicMode; maxDynamicCandidates: number; suppliedVariableNames: string[]; runtimeValuesOmitted: true; implementationRepo: string | null; implementationHints: CompactHintV1[]; } interface CompactReferenceGroupV1 { values: Array; total: number; shown: number; omitted: number; } interface CompactReferencesV1 { graphEdgeIds?: CompactReferenceGroupV1; outboundCallIds?: CompactReferenceGroupV1; subscribeCallIds?: CompactReferenceGroupV1; symbolCallIds?: CompactReferenceGroupV1; operationIds?: CompactReferenceGroupV1; symbolIds?: CompactReferenceGroupV1; handlerMethodIds?: CompactReferenceGroupV1; } interface CompactDecisionV1 { effectiveResolutionStatus?: string; effectiveTarget?: string; persistedResolutionStatus?: string; persistedTarget?: string; missingVariableNames?: string[]; missingVariableCount?: number; shownMissingVariableCount?: number; omittedMissingVariableCount?: number; dynamicMode?: DynamicMode; candidateCount?: number; viableCandidateCount?: number; rejectedCandidateCount?: number; omittedCandidateCount?: number; implementationStrategy?: string; selectionBasis?: string; implementationGuided?: boolean; implementationContextual?: boolean; tiedCandidateRepos?: CompactReferenceGroupV1; eventMatchStrategy?: string; dispatchCertainty?: string; eventSubscriptionCount?: number; associationStatus?: string; associationBasis?: string; eventScope?: string; callRole?: string; factOrigin?: string; roleSiteMatchCount?: number; bodyExpansion?: string; reasonCode?: string; remediationHint?: string; omittedRemediationHintCount?: number; } interface CompactEdgeDetailsV1 { decision: CompactDecisionV1; refs: CompactReferencesV1; } interface CompactDiagnosticDetailsV1 { reasonCode?: string; multiplicity?: number; tiedCandidateRepos?: CompactReferenceGroupV1; selectorKind?: string; selectorSuggestions?: CompactReferenceGroupV1; invalidFactCategories?: CompactReferenceGroupV1; missingVariableNames?: string[]; missingVariableCount?: number; shownMissingVariableCount?: number; omittedMissingVariableCount?: number; candidateCount?: number; shownCandidateCount?: number; omittedCandidateCount?: number; maxDynamicCandidates?: number; viableCandidateCount?: number; rejectedCandidateCount?: number; remediationHint?: string; omittedHintCount?: number; } type CompactNodeRowV1 = [ id: string, kind: string, label: string, repo: number | null, file: number | null, line: number | null ]; type CompactEdgeRowV1 = [ id: string, traceOrdinals: number[], step: number, type: string, from: string, to: string, status: CompactStatus, confidence: number, count: number, details: CompactEdgeDetailsV1 | null ]; type CompactDiagnosticRowV1 = [ fullDiagnosticIndex: number, severity: 'error' | 'warning' | 'info', code: string, message: string, file: number | null, line: number | null, details: CompactDiagnosticDetailsV1 | null ]; interface CompactStatusCountsV1 { resolved: number; terminal: number; inferred: number; dynamic: number; ambiguous: number; unresolved: number; cycle: number; } interface CompactGraphV1 { schema: 'service-flow/compact-graph@1'; start: CompactStartV1; query: CompactQueryV1; source: CompactSourceContext; summary: { completeness: 'complete' | 'partial' | 'blocked'; fullTraceNodes: number; fullTraceEdges: number; fullTraceDiagnostics: number; nodes: number; edges: number; collapsedEdges: number; statusCounts: CompactStatusCountsV1; projection: { evidence: 'summary-only'; syntheticEndpoints: number; omittedUnreferencedFullNodes: number; }; }; repos: string[]; files: string[]; nodeColumns: ['id', 'kind', 'label', 'repo', 'file', 'line']; nodes: CompactNodeRowV1[]; edgeColumns: [ 'id', 'traceOrdinals', 'step', 'type', 'from', 'to', 'status', 'confidence', 'count', 'details' ]; edges: CompactEdgeRowV1[]; diagnosticColumns: [ 'fullDiagnosticIndex', 'severity', 'code', 'message', 'file', 'line', 'details' ]; diagnostics: CompactDiagnosticRowV1[]; } declare function trace(db: Db, start: TraceStart, options: TraceOptions): TraceResult; interface CompactTraceExecution { trace: TraceResult; compact: CompactGraphV1; } declare function compactTrace(db: Db, start: TraceStart, options: TraceOptions): CompactGraphV1; declare function traceAndCompact(db: Db, start: TraceStart, options: TraceOptions): CompactTraceExecution; declare function parseImplementationHint(value: string): ImplementationHint; declare const DETAILED_TRACE_SCHEMA = "service-flow/detailed-trace@3"; declare function redactText(text: string): string; declare function redactValue(value: unknown): unknown; export { type CallType, type CompactDecisionV1, type CompactDiagnosticDetailsV1, type CompactDiagnosticRowV1, type CompactEdgeDetailsV1, type CompactEdgeRowV1, type CompactGraphV1, type CompactHintV1, type CompactNodeRowV1, type CompactQueryV1, type CompactReferenceGroupV1, type CompactReferencesV1, type CompactSourceContext, type CompactStartV1, type CompactStatus, type CompactStatusCountsV1, type CompactTraceExecution, DETAILED_TRACE_SCHEMA, type Db, type DynamicMode, type EdgeType, type ExecutableSymbolFact, type ImplementationHint, type OutboundCallFact, type RuntimeSubstitution, type SymbolCallFact, type SymbolCallRole, type TraceEdge, type TraceOptions, type TraceResult, type TraceStart, applyVariables, compactTrace, discoverRepositories, extractPlaceholders, linkWorkspace, parseCdsFile, parseDecorators, parseGeneratedConstants, parseHandlerRegistrations, parseImplementationHint, parseOutboundCalls, parsePackageJson, parseServiceBindings, redactText, redactValue, substituteVariables, trace, traceAndCompact };