import type { EventSkeletonFact } from './utils/event-skeleton.js'; export type RepoKind = | 'cap-service' | 'cap-db-model' | 'helper-package' | 'mixed' | 'unknown'; export 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'; export 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'; export interface DiscoveredRepository { name: string; absolutePath: string; relativePath: string; isGitRepo: boolean; } export interface CdsRequire { alias: string; kind?: string; model?: string; destination?: string; servicePath?: string; requestTimeout?: number; rawJson: string; } export interface PackageFacts { packageName?: string; packageVersion?: string; dependencies: Record; cdsRequires: CdsRequire[]; scripts: Record; } export interface CdsServiceFact { namespace?: string; serviceName: string; qualifiedName: string; servicePath: string; isExtend: boolean; sourceFile: string; sourceLine: number; operations: CdsOperationFact[]; extension?: CdsExtensionFact; } export interface CdsExtensionFact { localReference: string; importedSymbol?: string; localAlias?: string; moduleSpecifier?: string; importKind?: 'relative' | 'package' | 'none'; } export interface CdsOperationFact { operationType: 'action' | 'function' | 'event'; operationName: string; operationPath: string; paramsJson: string; returnType?: string; sourceFile: string; sourceLine: number; provenance?: 'direct' | 'inherited'; baseOperationId?: number; } export interface HandlerClassFact { className: string; sourceFile: string; sourceLine: number; methods: HandlerMethodFact[]; hasHandlerDecorator?: boolean; classDecoratorNames?: string[]; observedDecoratorNames?: string[]; unsupportedDecoratorNames?: string[]; } export type HandlerMethodKind = | 'operation' | 'entity_lifecycle' | 'event' | 'unsupported_lifecycle' | 'unsupported_decorator'; export type HandlerLifecyclePhase = 'on' | 'before' | 'after'; export type HandlerLifecycleEvent = 'CREATE' | 'READ' | 'UPDATE' | 'DELETE'; export 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; } export interface HandlerRegistrationFact { className?: string; importSource?: string; registrationFile: string; registrationLine: number; registrationKind: string; confidence: number; } export 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>; } export type ServiceBindingOwnerResolution = | 'owned_exact' | 'ownerless_file_scope' | 'legacy_unknown'; export type ServiceBindingReferenceStatus = | 'resolved_exact' | 'ambiguous' | 'unresolved' | 'not_applicable'; export 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'; export interface LexicalScopeFact { kind: 'source_file' | 'module_block' | 'function' | 'class' | 'loop' | 'case_block' | 'block' | 'catch'; startOffset: number; endOffset: number; } export 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; } export type HandlerReferenceStatus = | 'role_required' | 'unsupported_inline' | 'unsupported_wrapper' | 'unsupported_reference_shape' | 'missing_argument'; export 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 }; } export interface ExecutableSymbolFact { kind: string; localName: string; exportedName?: string; qualifiedName: string; sourceFile: string; startLine: number; endLine: number; startOffset: number; endOffset: number; exported: boolean; importExportEvidence?: Record; } export type SymbolCallRole = | 'ordinary_call' | 'event_subscribe_handler' | 'legacy_unknown'; export interface SymbolCallFact { callerQualifiedName: string; calleeExpression: string; calleeLocalName?: string; receiverLocalName?: string; importSource?: string; sourceFile: string; sourceLine: number; callSiteStartOffset?: number; callSiteEndOffset?: number; callRole: Exclude; evidence: Record; } export 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; } export interface TraceStart { repo?: string; servicePath?: string; operation?: string; operationPath?: string; handler?: string; } export interface ImplementationHint { servicePath?: string; operationPath?: string; packageName?: string; repositoryName?: string; candidateFamily?: string; implementationRepo: string; } export type DynamicMode = 'strict' | 'candidates' | 'infer'; export interface TraceOptions { depth: number; workspaceId?: number; vars?: Record; includeExternal?: boolean; includeDb?: boolean; includeAsync?: boolean; implementationRepo?: string; implementationHints?: ImplementationHint[]; dynamicMode?: DynamicMode; maxDynamicCandidates?: number; } export interface TraceEdge { step: number; type: string; from: string; to: string; fromNodeId?: string; toNodeId?: string; evidence: Record; confidence: number; unresolvedReason?: string; } export interface TraceResult { start: TraceStart; nodes: Array>; edges: TraceEdge[]; diagnostics: Array>; }