@grafema/core 0.1.0-alpha.1
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.
- package/LICENSE +190 -0
- package/README.md +76 -0
- package/dist/Orchestrator.d.ts +142 -0
- package/dist/Orchestrator.d.ts.map +1 -0
- package/dist/Orchestrator.js +481 -0
- package/dist/api/GraphAPI.d.ts +87 -0
- package/dist/api/GraphAPI.d.ts.map +1 -0
- package/dist/api/GraphAPI.js +210 -0
- package/dist/api/GuaranteeAPI.d.ts +147 -0
- package/dist/api/GuaranteeAPI.d.ts.map +1 -0
- package/dist/api/GuaranteeAPI.js +288 -0
- package/dist/core/ASTWorker.d.ts +133 -0
- package/dist/core/ASTWorker.d.ts.map +1 -0
- package/dist/core/ASTWorker.js +352 -0
- package/dist/core/ASTWorkerPool.d.ts +85 -0
- package/dist/core/ASTWorkerPool.d.ts.map +1 -0
- package/dist/core/ASTWorkerPool.js +207 -0
- package/dist/core/AnalysisQueue.d.ts +104 -0
- package/dist/core/AnalysisQueue.d.ts.map +1 -0
- package/dist/core/AnalysisQueue.js +299 -0
- package/dist/core/AnalysisWorker.d.ts +14 -0
- package/dist/core/AnalysisWorker.d.ts.map +1 -0
- package/dist/core/AnalysisWorker.js +307 -0
- package/dist/core/GraphBackend.d.ts +156 -0
- package/dist/core/GraphBackend.d.ts.map +1 -0
- package/dist/core/GraphBackend.js +85 -0
- package/dist/core/GuaranteeManager.d.ts +230 -0
- package/dist/core/GuaranteeManager.d.ts.map +1 -0
- package/dist/core/GuaranteeManager.js +352 -0
- package/dist/core/ManifestStore.d.ts +71 -0
- package/dist/core/ManifestStore.d.ts.map +1 -0
- package/dist/core/ManifestStore.js +146 -0
- package/dist/core/NodeFactory.d.ts +160 -0
- package/dist/core/NodeFactory.d.ts.map +1 -0
- package/dist/core/NodeFactory.js +137 -0
- package/dist/core/NodeId.d.ts +88 -0
- package/dist/core/NodeId.d.ts.map +1 -0
- package/dist/core/NodeId.js +170 -0
- package/dist/core/ParallelAnalyzer.d.ts +120 -0
- package/dist/core/ParallelAnalyzer.d.ts.map +1 -0
- package/dist/core/ParallelAnalyzer.js +331 -0
- package/dist/core/PriorityQueue.d.ts +106 -0
- package/dist/core/PriorityQueue.d.ts.map +1 -0
- package/dist/core/PriorityQueue.js +168 -0
- package/dist/core/Profiler.d.ts +75 -0
- package/dist/core/Profiler.d.ts.map +1 -0
- package/dist/core/Profiler.js +149 -0
- package/dist/core/QueueWorker.d.ts +12 -0
- package/dist/core/QueueWorker.d.ts.map +1 -0
- package/dist/core/QueueWorker.js +567 -0
- package/dist/core/RFDBClient.d.ts +179 -0
- package/dist/core/RFDBClient.d.ts.map +1 -0
- package/dist/core/RFDBClient.js +429 -0
- package/dist/core/Task.d.ts +56 -0
- package/dist/core/Task.d.ts.map +1 -0
- package/dist/core/Task.js +85 -0
- package/dist/core/TaskTypes.d.ts +20 -0
- package/dist/core/TaskTypes.d.ts.map +1 -0
- package/dist/core/TaskTypes.js +10 -0
- package/dist/core/VersionManager.d.ts +166 -0
- package/dist/core/VersionManager.d.ts.map +1 -0
- package/dist/core/VersionManager.js +237 -0
- package/dist/core/WorkerPool.d.ts +82 -0
- package/dist/core/WorkerPool.d.ts.map +1 -0
- package/dist/core/WorkerPool.js +109 -0
- package/dist/core/nodes/CallSiteNode.d.ts +26 -0
- package/dist/core/nodes/CallSiteNode.d.ts.map +1 -0
- package/dist/core/nodes/CallSiteNode.js +44 -0
- package/dist/core/nodes/ClassNode.d.ts +25 -0
- package/dist/core/nodes/ClassNode.d.ts.map +1 -0
- package/dist/core/nodes/ClassNode.js +40 -0
- package/dist/core/nodes/ConstantNode.d.ts +24 -0
- package/dist/core/nodes/ConstantNode.d.ts.map +1 -0
- package/dist/core/nodes/ConstantNode.js +39 -0
- package/dist/core/nodes/DatabaseQueryNode.d.ts +22 -0
- package/dist/core/nodes/DatabaseQueryNode.d.ts.map +1 -0
- package/dist/core/nodes/DatabaseQueryNode.js +37 -0
- package/dist/core/nodes/EntrypointNode.d.ts +102 -0
- package/dist/core/nodes/EntrypointNode.d.ts.map +1 -0
- package/dist/core/nodes/EntrypointNode.js +119 -0
- package/dist/core/nodes/EventListenerNode.d.ts +25 -0
- package/dist/core/nodes/EventListenerNode.d.ts.map +1 -0
- package/dist/core/nodes/EventListenerNode.js +39 -0
- package/dist/core/nodes/ExportNode.d.ts +26 -0
- package/dist/core/nodes/ExportNode.d.ts.map +1 -0
- package/dist/core/nodes/ExportNode.js +40 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts +17 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts.map +1 -0
- package/dist/core/nodes/ExternalStdioNode.js +26 -0
- package/dist/core/nodes/FunctionNode.d.ts +27 -0
- package/dist/core/nodes/FunctionNode.d.ts.map +1 -0
- package/dist/core/nodes/FunctionNode.js +53 -0
- package/dist/core/nodes/GuaranteeNode.d.ts +76 -0
- package/dist/core/nodes/GuaranteeNode.d.ts.map +1 -0
- package/dist/core/nodes/GuaranteeNode.js +117 -0
- package/dist/core/nodes/HttpRequestNode.d.ts +24 -0
- package/dist/core/nodes/HttpRequestNode.d.ts.map +1 -0
- package/dist/core/nodes/HttpRequestNode.js +38 -0
- package/dist/core/nodes/ImportNode.d.ts +27 -0
- package/dist/core/nodes/ImportNode.d.ts.map +1 -0
- package/dist/core/nodes/ImportNode.js +43 -0
- package/dist/core/nodes/LiteralNode.d.ts +26 -0
- package/dist/core/nodes/LiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/LiteralNode.js +40 -0
- package/dist/core/nodes/MethodCallNode.d.ts +29 -0
- package/dist/core/nodes/MethodCallNode.d.ts.map +1 -0
- package/dist/core/nodes/MethodCallNode.js +47 -0
- package/dist/core/nodes/MethodNode.d.ts +29 -0
- package/dist/core/nodes/MethodNode.d.ts.map +1 -0
- package/dist/core/nodes/MethodNode.js +44 -0
- package/dist/core/nodes/ModuleNode.d.ts +29 -0
- package/dist/core/nodes/ModuleNode.d.ts.map +1 -0
- package/dist/core/nodes/ModuleNode.js +49 -0
- package/dist/core/nodes/NodeKind.d.ts +91 -0
- package/dist/core/nodes/NodeKind.d.ts.map +1 -0
- package/dist/core/nodes/NodeKind.js +146 -0
- package/dist/core/nodes/ParameterNode.d.ts +26 -0
- package/dist/core/nodes/ParameterNode.d.ts.map +1 -0
- package/dist/core/nodes/ParameterNode.js +43 -0
- package/dist/core/nodes/ScopeNode.d.ts +32 -0
- package/dist/core/nodes/ScopeNode.d.ts.map +1 -0
- package/dist/core/nodes/ScopeNode.js +47 -0
- package/dist/core/nodes/ServiceNode.d.ts +44 -0
- package/dist/core/nodes/ServiceNode.d.ts.map +1 -0
- package/dist/core/nodes/ServiceNode.js +49 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts +22 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts.map +1 -0
- package/dist/core/nodes/VariableDeclarationNode.js +38 -0
- package/dist/core/nodes/index.d.ts +25 -0
- package/dist/core/nodes/index.d.ts.map +1 -0
- package/dist/core/nodes/index.js +30 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/plugins/Plugin.d.ts +44 -0
- package/dist/plugins/Plugin.d.ts.map +1 -0
- package/dist/plugins/Plugin.js +46 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts +23 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.js +260 -0
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts +19 -0
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ExpressAnalyzer.js +306 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts +17 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.js +308 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts +38 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/FetchAnalyzer.js +344 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts +65 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts.map +1 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.js +472 -0
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts +84 -0
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/JSASTAnalyzer.js +1378 -0
- package/dist/plugins/analysis/ReactAnalyzer.d.ts +90 -0
- package/dist/plugins/analysis/ReactAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ReactAnalyzer.js +1153 -0
- package/dist/plugins/analysis/RustAnalyzer.d.ts +13 -0
- package/dist/plugins/analysis/RustAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/RustAnalyzer.js +259 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts +21 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.js +317 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts +35 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.js +303 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts +33 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.js +283 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts +27 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.js +211 -0
- package/dist/plugins/analysis/ast/ConditionParser.d.ts +85 -0
- package/dist/plugins/analysis/ast/ConditionParser.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/ConditionParser.js +277 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.d.ts +15 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.js +91 -0
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts +77 -0
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/GraphBuilder.js +1077 -0
- package/dist/plugins/analysis/ast/OxcAdapter.d.ts +41 -0
- package/dist/plugins/analysis/ast/OxcAdapter.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/OxcAdapter.js +40 -0
- package/dist/plugins/analysis/ast/types.d.ts +346 -0
- package/dist/plugins/analysis/ast/types.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/types.js +4 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts +93 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.js +24 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts +77 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.js +377 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts +27 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.js +232 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts +25 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.js +172 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts +29 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.js +180 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts +14 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.js +200 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts +45 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.js +150 -0
- package/dist/plugins/analysis/ast/visitors/index.d.ts +17 -0
- package/dist/plugins/analysis/ast/visitors/index.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/index.js +13 -0
- package/dist/plugins/discovery/DiscoveryPlugin.d.ts +34 -0
- package/dist/plugins/discovery/DiscoveryPlugin.d.ts.map +1 -0
- package/dist/plugins/discovery/DiscoveryPlugin.js +26 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts +26 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.js +79 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts +14 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.js +65 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts +19 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.js +204 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts +40 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts.map +1 -0
- package/dist/plugins/enrichment/AliasTracker.js +290 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts +30 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts.map +1 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.js +135 -0
- package/dist/plugins/enrichment/ImportExportLinker.d.ts +30 -0
- package/dist/plugins/enrichment/ImportExportLinker.d.ts.map +1 -0
- package/dist/plugins/enrichment/ImportExportLinker.js +176 -0
- package/dist/plugins/enrichment/InstanceOfResolver.d.ts +21 -0
- package/dist/plugins/enrichment/InstanceOfResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/InstanceOfResolver.js +117 -0
- package/dist/plugins/enrichment/MethodCallResolver.d.ts +41 -0
- package/dist/plugins/enrichment/MethodCallResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/MethodCallResolver.js +252 -0
- package/dist/plugins/enrichment/MountPointResolver.d.ts +26 -0
- package/dist/plugins/enrichment/MountPointResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/MountPointResolver.js +189 -0
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts +89 -0
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts.map +1 -0
- package/dist/plugins/enrichment/PrefixEvaluator.js +415 -0
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts +25 -0
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts.map +1 -0
- package/dist/plugins/enrichment/RustFFIEnricher.js +170 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts +114 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts.map +1 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.js +464 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts +27 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.js +238 -0
- package/dist/plugins/indexing/JSModuleIndexer.d.ts +33 -0
- package/dist/plugins/indexing/JSModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/JSModuleIndexer.js +299 -0
- package/dist/plugins/indexing/RustModuleIndexer.d.ts +28 -0
- package/dist/plugins/indexing/RustModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/RustModuleIndexer.js +140 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts +46 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts.map +1 -0
- package/dist/plugins/indexing/ServiceDetector.js +164 -0
- package/dist/plugins/validation/CallResolverValidator.d.ts +23 -0
- package/dist/plugins/validation/CallResolverValidator.d.ts.map +1 -0
- package/dist/plugins/validation/CallResolverValidator.js +108 -0
- package/dist/plugins/validation/DataFlowValidator.d.ts +24 -0
- package/dist/plugins/validation/DataFlowValidator.d.ts.map +1 -0
- package/dist/plugins/validation/DataFlowValidator.js +148 -0
- package/dist/plugins/validation/EvalBanValidator.d.ts +25 -0
- package/dist/plugins/validation/EvalBanValidator.d.ts.map +1 -0
- package/dist/plugins/validation/EvalBanValidator.js +123 -0
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts +11 -0
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts.map +1 -0
- package/dist/plugins/validation/GraphConnectivityValidator.js +135 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts +43 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts.map +1 -0
- package/dist/plugins/validation/SQLInjectionValidator.js +251 -0
- package/dist/plugins/validation/ShadowingDetector.d.ts +26 -0
- package/dist/plugins/validation/ShadowingDetector.d.ts.map +1 -0
- package/dist/plugins/validation/ShadowingDetector.js +119 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts +21 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts.map +1 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.js +151 -0
- package/dist/plugins/vcs/GitPlugin.d.ts +84 -0
- package/dist/plugins/vcs/GitPlugin.d.ts.map +1 -0
- package/dist/plugins/vcs/GitPlugin.js +295 -0
- package/dist/plugins/vcs/VCSPlugin.d.ts +133 -0
- package/dist/plugins/vcs/VCSPlugin.d.ts.map +1 -0
- package/dist/plugins/vcs/VCSPlugin.js +82 -0
- package/dist/plugins/vcs/index.d.ts +10 -0
- package/dist/plugins/vcs/index.d.ts.map +1 -0
- package/dist/plugins/vcs/index.js +18 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts +258 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -0
- package/dist/storage/backends/RFDBServerBackend.js +565 -0
- package/dist/storage/backends/typeValidation.d.ts +47 -0
- package/dist/storage/backends/typeValidation.d.ts.map +1 -0
- package/dist/storage/backends/typeValidation.js +137 -0
- package/dist/validation/PathValidator.d.ts +81 -0
- package/dist/validation/PathValidator.d.ts.map +1 -0
- package/dist/validation/PathValidator.js +251 -0
- package/package.json +57 -0
- package/src/.rfguard/current-session.txt +1 -0
- package/src/Orchestrator.ts +673 -0
- package/src/api/GraphAPI.ts +305 -0
- package/src/api/GuaranteeAPI.ts +401 -0
- package/src/core/ASTWorker.ts +567 -0
- package/src/core/ASTWorkerPool.ts +299 -0
- package/src/core/AnalysisQueue.ts +447 -0
- package/src/core/AnalysisWorker.ts +410 -0
- package/src/core/GraphBackend.ts +265 -0
- package/src/core/GuaranteeManager.ts +581 -0
- package/src/core/ManifestStore.ts +196 -0
- package/src/core/NodeFactory.ts +274 -0
- package/src/core/NodeId.ts +257 -0
- package/src/core/ParallelAnalyzer.ts +476 -0
- package/src/core/PriorityQueue.ts +227 -0
- package/src/core/Profiler.ts +188 -0
- package/src/core/QueueWorker.ts +780 -0
- package/src/core/Task.ts +107 -0
- package/src/core/TaskTypes.ts +40 -0
- package/src/core/VersionManager.ts +404 -0
- package/src/core/WorkerPool.ts +180 -0
- package/src/core/nodes/CallSiteNode.ts +72 -0
- package/src/core/nodes/ClassNode.ts +69 -0
- package/src/core/nodes/ConstantNode.ts +63 -0
- package/src/core/nodes/DatabaseQueryNode.ts +60 -0
- package/src/core/nodes/EntrypointNode.ts +164 -0
- package/src/core/nodes/EventListenerNode.ts +64 -0
- package/src/core/nodes/ExportNode.ts +71 -0
- package/src/core/nodes/ExternalStdioNode.ts +36 -0
- package/src/core/nodes/FunctionNode.ts +78 -0
- package/src/core/nodes/GuaranteeNode.ts +162 -0
- package/src/core/nodes/HttpRequestNode.ts +63 -0
- package/src/core/nodes/ImportNode.ts +75 -0
- package/src/core/nodes/LiteralNode.ts +67 -0
- package/src/core/nodes/MethodCallNode.ts +79 -0
- package/src/core/nodes/MethodNode.ts +78 -0
- package/src/core/nodes/ModuleNode.ts +74 -0
- package/src/core/nodes/NodeKind.ts +171 -0
- package/src/core/nodes/ParameterNode.ts +73 -0
- package/src/core/nodes/ScopeNode.ts +80 -0
- package/src/core/nodes/ServiceNode.ts +86 -0
- package/src/core/nodes/VariableDeclarationNode.ts +60 -0
- package/src/core/nodes/index.ts +49 -0
- package/src/index.ts +93 -0
- package/src/plugins/Plugin.ts +74 -0
- package/src/plugins/analysis/DatabaseAnalyzer.ts +322 -0
- package/src/plugins/analysis/ExpressAnalyzer.ts +401 -0
- package/src/plugins/analysis/ExpressRouteAnalyzer.ts +414 -0
- package/src/plugins/analysis/FetchAnalyzer.ts +441 -0
- package/src/plugins/analysis/IncrementalAnalysisPlugin.ts +686 -0
- package/src/plugins/analysis/JSASTAnalyzer.ts +1680 -0
- package/src/plugins/analysis/ReactAnalyzer.ts +1368 -0
- package/src/plugins/analysis/RustAnalyzer.ts +438 -0
- package/src/plugins/analysis/SQLiteAnalyzer.ts +388 -0
- package/src/plugins/analysis/ServiceLayerAnalyzer.ts +429 -0
- package/src/plugins/analysis/SocketIOAnalyzer.ts +395 -0
- package/src/plugins/analysis/SystemDbAnalyzer.ts +284 -0
- package/src/plugins/analysis/ast/ConditionParser.ts +333 -0
- package/src/plugins/analysis/ast/ExpressionEvaluator.ts +117 -0
- package/src/plugins/analysis/ast/GraphBuilder.ts +1371 -0
- package/src/plugins/analysis/ast/OxcAdapter.ts +63 -0
- package/src/plugins/analysis/ast/types.ts +400 -0
- package/src/plugins/analysis/ast/visitors/ASTVisitor.ts +137 -0
- package/src/plugins/analysis/ast/visitors/CallExpressionVisitor.ts +528 -0
- package/src/plugins/analysis/ast/visitors/ClassVisitor.ts +339 -0
- package/src/plugins/analysis/ast/visitors/FunctionVisitor.ts +273 -0
- package/src/plugins/analysis/ast/visitors/ImportExportVisitor.ts +259 -0
- package/src/plugins/analysis/ast/visitors/TypeScriptVisitor.ts +235 -0
- package/src/plugins/analysis/ast/visitors/VariableVisitor.ts +268 -0
- package/src/plugins/analysis/ast/visitors/index.ts +36 -0
- package/src/plugins/discovery/DiscoveryPlugin.ts +50 -0
- package/src/plugins/discovery/MonorepoServiceDiscovery.ts +117 -0
- package/src/plugins/discovery/SimpleProjectDiscovery.ts +102 -0
- package/src/plugins/enrichment/AliasTracker.ts +399 -0
- package/src/plugins/enrichment/HTTPConnectionEnricher.ts +192 -0
- package/src/plugins/enrichment/ImportExportLinker.ts +221 -0
- package/src/plugins/enrichment/InstanceOfResolver.ts +165 -0
- package/src/plugins/enrichment/MethodCallResolver.ts +333 -0
- package/src/plugins/enrichment/MountPointResolver.ts +264 -0
- package/src/plugins/enrichment/PrefixEvaluator.ts +527 -0
- package/src/plugins/enrichment/RustFFIEnricher.ts +218 -0
- package/src/plugins/enrichment/ValueDomainAnalyzer.ts +682 -0
- package/src/plugins/indexing/IncrementalModuleIndexer.ts +287 -0
- package/src/plugins/indexing/JSModuleIndexer.ts +374 -0
- package/src/plugins/indexing/RustModuleIndexer.ts +160 -0
- package/src/plugins/indexing/ServiceDetector.ts +230 -0
- package/src/plugins/validation/CallResolverValidator.ts +170 -0
- package/src/plugins/validation/DataFlowValidator.ts +233 -0
- package/src/plugins/validation/EvalBanValidator.ts +175 -0
- package/src/plugins/validation/GraphConnectivityValidator.ts +201 -0
- package/src/plugins/validation/SQLInjectionValidator.ts +363 -0
- package/src/plugins/validation/ShadowingDetector.ts +173 -0
- package/src/plugins/validation/TypeScriptDeadCodeValidator.ts +203 -0
- package/src/plugins/vcs/GitPlugin.ts +344 -0
- package/src/plugins/vcs/VCSPlugin.ts +190 -0
- package/src/plugins/vcs/index.ts +32 -0
- package/src/storage/backends/RFDBServerBackend.ts +687 -0
- package/src/storage/backends/typeValidation.ts +151 -0
- package/src/validation/PathValidator.ts +342 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkerPool - worker pool for parallel task execution
|
|
3
|
+
*
|
|
4
|
+
* Key property: HORIZONTAL SCALING
|
|
5
|
+
* More workers = faster processing (up to CPU/IO limit)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { EventEmitter } from 'events';
|
|
9
|
+
import type { Task, QueueStats } from './PriorityQueue.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Task handler function type
|
|
13
|
+
*/
|
|
14
|
+
export type TaskHandler = (task: Task) => Promise<unknown>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Handler registry
|
|
18
|
+
*/
|
|
19
|
+
export interface TaskHandlers {
|
|
20
|
+
[taskType: string]: TaskHandler;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Queue interface for WorkerPool
|
|
25
|
+
*/
|
|
26
|
+
export interface WorkerQueue {
|
|
27
|
+
isEmpty: boolean;
|
|
28
|
+
next(): Task | null;
|
|
29
|
+
complete(taskId: string, result: unknown): void;
|
|
30
|
+
fail(taskId: string, error: Error): void;
|
|
31
|
+
getStats(): QueueStats;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Worker pool statistics
|
|
36
|
+
*/
|
|
37
|
+
export interface WorkerPoolStats {
|
|
38
|
+
workerCount: number;
|
|
39
|
+
activeWorkers: number;
|
|
40
|
+
running: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// === EVENT PAYLOADS ===
|
|
44
|
+
|
|
45
|
+
export interface WorkerTaskStartEvent {
|
|
46
|
+
workerId: number;
|
|
47
|
+
task: Task;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface WorkerTaskCompletedEvent {
|
|
51
|
+
workerId: number;
|
|
52
|
+
task: Task;
|
|
53
|
+
result: unknown;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface WorkerTaskFailedEvent {
|
|
57
|
+
workerId: number;
|
|
58
|
+
task: Task;
|
|
59
|
+
error: unknown;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class WorkerPool extends EventEmitter {
|
|
63
|
+
private workerCount: number;
|
|
64
|
+
private handlers: TaskHandlers;
|
|
65
|
+
private activeWorkers: number;
|
|
66
|
+
private running: boolean;
|
|
67
|
+
|
|
68
|
+
constructor(workerCount: number = 10, handlers: TaskHandlers = {}) {
|
|
69
|
+
super();
|
|
70
|
+
this.workerCount = workerCount;
|
|
71
|
+
this.handlers = handlers;
|
|
72
|
+
this.activeWorkers = 0;
|
|
73
|
+
this.running = false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Register handler for task type
|
|
78
|
+
*/
|
|
79
|
+
registerHandler(taskType: string, handler: TaskHandler): void {
|
|
80
|
+
this.handlers[taskType] = handler;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Start queue processing
|
|
85
|
+
*/
|
|
86
|
+
async processQueue(queue: WorkerQueue): Promise<void> {
|
|
87
|
+
this.running = true;
|
|
88
|
+
this.emit('pool:started', { workerCount: this.workerCount });
|
|
89
|
+
|
|
90
|
+
// Create workers
|
|
91
|
+
const workers: Promise<void>[] = [];
|
|
92
|
+
for (let i = 0; i < this.workerCount; i++) {
|
|
93
|
+
workers.push(this._worker(i, queue));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Wait for all workers to complete
|
|
97
|
+
await Promise.all(workers);
|
|
98
|
+
|
|
99
|
+
this.running = false;
|
|
100
|
+
this.emit('pool:finished', queue.getStats());
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Worker - picks task from queue and executes
|
|
105
|
+
*/
|
|
106
|
+
private async _worker(workerId: number, queue: WorkerQueue): Promise<void> {
|
|
107
|
+
while (true) {
|
|
108
|
+
// If queue is empty AND no active workers - exit
|
|
109
|
+
if (queue.isEmpty && this.activeWorkers === 0) {
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Get next task
|
|
114
|
+
const task = queue.next();
|
|
115
|
+
|
|
116
|
+
if (!task) {
|
|
117
|
+
// No ready tasks, wait a bit
|
|
118
|
+
await this._sleep(10);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.activeWorkers++;
|
|
123
|
+
this.emit('worker:task:start', { workerId, task });
|
|
124
|
+
this.emit('worker:task:started', task); // For progress tracking
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
// Execute task
|
|
128
|
+
const handler = task.type ? this.handlers[task.type] : undefined;
|
|
129
|
+
if (!handler) {
|
|
130
|
+
throw new Error(`No handler for task type: ${task.type}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
task.start();
|
|
134
|
+
const result = await handler(task);
|
|
135
|
+
|
|
136
|
+
queue.complete(task.id, result);
|
|
137
|
+
this.emit('worker:task:completed', { workerId, task, result });
|
|
138
|
+
} catch (error) {
|
|
139
|
+
queue.fail(task.id, error as Error);
|
|
140
|
+
this.emit('worker:task:failed', { workerId, task, error });
|
|
141
|
+
} finally {
|
|
142
|
+
this.activeWorkers--;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this.emit('worker:stopped', { workerId });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Sleep helper
|
|
151
|
+
*/
|
|
152
|
+
private _sleep(ms: number): Promise<void> {
|
|
153
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Stop pool (graceful shutdown)
|
|
158
|
+
*/
|
|
159
|
+
async stop(): Promise<void> {
|
|
160
|
+
this.running = false;
|
|
161
|
+
|
|
162
|
+
// Wait for all active workers to complete current tasks
|
|
163
|
+
while (this.activeWorkers > 0) {
|
|
164
|
+
await this._sleep(100);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
this.emit('pool:stopped');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Statistics
|
|
172
|
+
*/
|
|
173
|
+
getStats(): WorkerPoolStats {
|
|
174
|
+
return {
|
|
175
|
+
workerCount: this.workerCount,
|
|
176
|
+
activeWorkers: this.activeWorkers,
|
|
177
|
+
running: this.running
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CallSiteNode - contract for CALL_SITE node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { BaseNodeRecord } from '@grafema/types';
|
|
6
|
+
|
|
7
|
+
interface CallSiteNodeRecord extends BaseNodeRecord {
|
|
8
|
+
type: 'CALL_SITE';
|
|
9
|
+
column: number;
|
|
10
|
+
parentScopeId?: string;
|
|
11
|
+
targetFunctionName: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface CallSiteNodeOptions {
|
|
15
|
+
parentScopeId?: string;
|
|
16
|
+
counter?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class CallSiteNode {
|
|
20
|
+
static readonly TYPE = 'CALL_SITE' as const;
|
|
21
|
+
|
|
22
|
+
static readonly REQUIRED = ['name', 'file', 'line'] as const;
|
|
23
|
+
static readonly OPTIONAL = ['column', 'parentScopeId', 'targetFunctionName'] as const;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create CALL_SITE node
|
|
27
|
+
*/
|
|
28
|
+
static create(
|
|
29
|
+
targetName: string,
|
|
30
|
+
file: string,
|
|
31
|
+
line: number,
|
|
32
|
+
column: number,
|
|
33
|
+
options: CallSiteNodeOptions = {}
|
|
34
|
+
): CallSiteNodeRecord {
|
|
35
|
+
if (!targetName) throw new Error('CallSiteNode.create: targetName is required');
|
|
36
|
+
if (!file) throw new Error('CallSiteNode.create: file is required');
|
|
37
|
+
if (line === undefined) throw new Error('CallSiteNode.create: line is required');
|
|
38
|
+
|
|
39
|
+
const counter = options.counter !== undefined ? `:${options.counter}` : '';
|
|
40
|
+
const id = `${file}:CALL_SITE:${targetName}:${line}:${column || 0}${counter}`;
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
id,
|
|
44
|
+
type: this.TYPE,
|
|
45
|
+
name: targetName,
|
|
46
|
+
file,
|
|
47
|
+
line,
|
|
48
|
+
column: column || 0,
|
|
49
|
+
parentScopeId: options.parentScopeId,
|
|
50
|
+
targetFunctionName: targetName
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static validate(node: CallSiteNodeRecord): string[] {
|
|
55
|
+
const errors: string[] = [];
|
|
56
|
+
|
|
57
|
+
if (node.type !== this.TYPE) {
|
|
58
|
+
errors.push(`Expected type ${this.TYPE}, got ${node.type}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const nodeRecord = node as unknown as Record<string, unknown>;
|
|
62
|
+
for (const field of this.REQUIRED) {
|
|
63
|
+
if (nodeRecord[field] === undefined || nodeRecord[field] === null) {
|
|
64
|
+
errors.push(`Missing required field: ${field}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return errors;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type { CallSiteNodeRecord };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClassNode - contract for CLASS node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { BaseNodeRecord } from '@grafema/types';
|
|
6
|
+
|
|
7
|
+
interface ClassNodeRecord extends BaseNodeRecord {
|
|
8
|
+
type: 'CLASS';
|
|
9
|
+
column: number;
|
|
10
|
+
exported: boolean;
|
|
11
|
+
superClass?: string;
|
|
12
|
+
methods: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ClassNodeOptions {
|
|
16
|
+
exported?: boolean;
|
|
17
|
+
superClass?: string;
|
|
18
|
+
methods?: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class ClassNode {
|
|
22
|
+
static readonly TYPE = 'CLASS' as const;
|
|
23
|
+
|
|
24
|
+
static readonly REQUIRED = ['name', 'file', 'line'] as const;
|
|
25
|
+
static readonly OPTIONAL = ['column', 'exported', 'superClass', 'methods'] as const;
|
|
26
|
+
|
|
27
|
+
static create(
|
|
28
|
+
name: string,
|
|
29
|
+
file: string,
|
|
30
|
+
line: number,
|
|
31
|
+
column: number,
|
|
32
|
+
options: ClassNodeOptions = {}
|
|
33
|
+
): ClassNodeRecord {
|
|
34
|
+
if (!name) throw new Error('ClassNode.create: name is required');
|
|
35
|
+
if (!file) throw new Error('ClassNode.create: file is required');
|
|
36
|
+
if (!line) throw new Error('ClassNode.create: line is required');
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
id: `${file}:CLASS:${name}:${line}`,
|
|
40
|
+
type: this.TYPE,
|
|
41
|
+
name,
|
|
42
|
+
file,
|
|
43
|
+
line,
|
|
44
|
+
column: column || 0,
|
|
45
|
+
exported: options.exported || false,
|
|
46
|
+
superClass: options.superClass,
|
|
47
|
+
methods: options.methods || []
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static validate(node: ClassNodeRecord): string[] {
|
|
52
|
+
const errors: string[] = [];
|
|
53
|
+
|
|
54
|
+
if (node.type !== this.TYPE) {
|
|
55
|
+
errors.push(`Expected type ${this.TYPE}, got ${node.type}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const nodeRecord = node as unknown as Record<string, unknown>;
|
|
59
|
+
for (const field of this.REQUIRED) {
|
|
60
|
+
if (!nodeRecord[field]) {
|
|
61
|
+
errors.push(`Missing required field: ${field}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return errors;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type { ClassNodeRecord };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConstantNode - contract for CONSTANT node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { BaseNodeRecord } from '@grafema/types';
|
|
6
|
+
|
|
7
|
+
interface ConstantNodeRecord extends BaseNodeRecord {
|
|
8
|
+
type: 'CONSTANT';
|
|
9
|
+
column: number;
|
|
10
|
+
value?: unknown;
|
|
11
|
+
parentScopeId?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ConstantNodeOptions {
|
|
15
|
+
value?: unknown;
|
|
16
|
+
parentScopeId?: string;
|
|
17
|
+
counter?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class ConstantNode {
|
|
21
|
+
static readonly TYPE = 'CONSTANT' as const;
|
|
22
|
+
|
|
23
|
+
static readonly REQUIRED = ['name', 'file', 'line'] as const;
|
|
24
|
+
static readonly OPTIONAL = ['column', 'value', 'parentScopeId'] as const;
|
|
25
|
+
|
|
26
|
+
static create(
|
|
27
|
+
name: string,
|
|
28
|
+
file: string,
|
|
29
|
+
line: number,
|
|
30
|
+
column: number,
|
|
31
|
+
options: ConstantNodeOptions = {}
|
|
32
|
+
): ConstantNodeRecord {
|
|
33
|
+
if (!name) throw new Error('ConstantNode.create: name is required');
|
|
34
|
+
if (!file) throw new Error('ConstantNode.create: file is required');
|
|
35
|
+
if (line === undefined) throw new Error('ConstantNode.create: line is required');
|
|
36
|
+
|
|
37
|
+
const counter = options.counter !== undefined ? `:${options.counter}` : '';
|
|
38
|
+
const id = `${file}:CONSTANT:${name}:${line}:${column || 0}${counter}`;
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
id,
|
|
42
|
+
type: this.TYPE,
|
|
43
|
+
name,
|
|
44
|
+
file,
|
|
45
|
+
line,
|
|
46
|
+
column: column || 0,
|
|
47
|
+
value: options.value,
|
|
48
|
+
parentScopeId: options.parentScopeId
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static validate(node: ConstantNodeRecord): string[] {
|
|
53
|
+
const errors: string[] = [];
|
|
54
|
+
if (node.type !== this.TYPE) errors.push(`Expected type ${this.TYPE}`);
|
|
55
|
+
const nodeRecord = node as unknown as Record<string, unknown>;
|
|
56
|
+
for (const field of this.REQUIRED) {
|
|
57
|
+
if (nodeRecord[field] === undefined) errors.push(`Missing: ${field}`);
|
|
58
|
+
}
|
|
59
|
+
return errors;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type { ConstantNodeRecord };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DatabaseQueryNode - contract for DATABASE_QUERY node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { BaseNodeRecord } from '@grafema/types';
|
|
6
|
+
|
|
7
|
+
interface DatabaseQueryNodeRecord extends BaseNodeRecord {
|
|
8
|
+
type: 'DATABASE_QUERY';
|
|
9
|
+
query?: string;
|
|
10
|
+
operation: string;
|
|
11
|
+
parentScopeId?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface DatabaseQueryNodeOptions {
|
|
15
|
+
parentScopeId?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class DatabaseQueryNode {
|
|
19
|
+
static readonly TYPE = 'DATABASE_QUERY' as const;
|
|
20
|
+
|
|
21
|
+
static readonly REQUIRED = ['name', 'file', 'line'] as const;
|
|
22
|
+
static readonly OPTIONAL = ['query', 'operation', 'parentScopeId'] as const;
|
|
23
|
+
|
|
24
|
+
static create(
|
|
25
|
+
query: string | undefined,
|
|
26
|
+
operation: string | undefined,
|
|
27
|
+
file: string,
|
|
28
|
+
line: number,
|
|
29
|
+
options: DatabaseQueryNodeOptions = {}
|
|
30
|
+
): DatabaseQueryNodeRecord {
|
|
31
|
+
if (!file) throw new Error('DatabaseQueryNode.create: file is required');
|
|
32
|
+
if (line === undefined) throw new Error('DatabaseQueryNode.create: line is required');
|
|
33
|
+
|
|
34
|
+
const name = query || `${operation || 'QUERY'}`;
|
|
35
|
+
const id = `${file}:DATABASE_QUERY:${name}:${line}`;
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
id,
|
|
39
|
+
type: this.TYPE,
|
|
40
|
+
name,
|
|
41
|
+
query,
|
|
42
|
+
operation: operation || 'UNKNOWN',
|
|
43
|
+
file,
|
|
44
|
+
line,
|
|
45
|
+
parentScopeId: options.parentScopeId
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static validate(node: DatabaseQueryNodeRecord): string[] {
|
|
50
|
+
const errors: string[] = [];
|
|
51
|
+
if (node.type !== this.TYPE) errors.push(`Expected type ${this.TYPE}`);
|
|
52
|
+
const nodeRecord = node as unknown as Record<string, unknown>;
|
|
53
|
+
for (const field of this.REQUIRED) {
|
|
54
|
+
if (nodeRecord[field] === undefined) errors.push(`Missing: ${field}`);
|
|
55
|
+
}
|
|
56
|
+
return errors;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type { DatabaseQueryNodeRecord };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EntrypointNode - represents an executable entry point
|
|
3
|
+
*
|
|
4
|
+
* An ENTRYPOINT is any file that can be executed directly:
|
|
5
|
+
* - service: main app entrypoint (package.json main/bin)
|
|
6
|
+
* - cli: command-line tool
|
|
7
|
+
* - test: test file
|
|
8
|
+
* - script: dev/build script (package.json scripts)
|
|
9
|
+
* - hook: git/tool hook (.husky/*, hooks/*.mjs)
|
|
10
|
+
* - config: build config (*.config.js)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { createHash } from 'crypto';
|
|
14
|
+
import type { BaseNodeRecord } from '@grafema/types';
|
|
15
|
+
|
|
16
|
+
// Entrypoint types
|
|
17
|
+
export const ENTRYPOINT_TYPES = {
|
|
18
|
+
SERVICE: 'service', // Main app entrypoint
|
|
19
|
+
CLI: 'cli', // Command-line tool
|
|
20
|
+
TEST: 'test', // Test file
|
|
21
|
+
SCRIPT: 'script', // Dev/build script
|
|
22
|
+
HOOK: 'hook', // Git/tool hook
|
|
23
|
+
CONFIG: 'config' // Build config file
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
26
|
+
export type EntrypointType = typeof ENTRYPOINT_TYPES[keyof typeof ENTRYPOINT_TYPES];
|
|
27
|
+
|
|
28
|
+
// What triggers execution
|
|
29
|
+
export const ENTRYPOINT_TRIGGERS = {
|
|
30
|
+
RUNTIME: 'runtime', // Production runtime
|
|
31
|
+
BUILD: 'build', // Build process
|
|
32
|
+
DEV: 'dev', // Development
|
|
33
|
+
CI: 'ci', // CI/CD pipeline
|
|
34
|
+
MANUAL: 'manual' // Manual execution
|
|
35
|
+
} as const;
|
|
36
|
+
|
|
37
|
+
export type EntrypointTrigger = typeof ENTRYPOINT_TRIGGERS[keyof typeof ENTRYPOINT_TRIGGERS];
|
|
38
|
+
|
|
39
|
+
// How entrypoint was discovered
|
|
40
|
+
export const ENTRYPOINT_SOURCES = {
|
|
41
|
+
PACKAGE_MAIN: 'package.json:main',
|
|
42
|
+
PACKAGE_BIN: 'package.json:bin',
|
|
43
|
+
PACKAGE_SCRIPT: 'package.json:scripts',
|
|
44
|
+
CONVENTION: 'convention',
|
|
45
|
+
CONFIG: 'config',
|
|
46
|
+
MANUAL: 'manual'
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
export type EntrypointSource = typeof ENTRYPOINT_SOURCES[keyof typeof ENTRYPOINT_SOURCES];
|
|
50
|
+
|
|
51
|
+
interface EntrypointNodeRecord extends BaseNodeRecord {
|
|
52
|
+
type: 'ENTRYPOINT';
|
|
53
|
+
entrypointType: EntrypointType;
|
|
54
|
+
trigger: EntrypointTrigger;
|
|
55
|
+
source: string;
|
|
56
|
+
serviceId: string | null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface EntrypointNodeOptions {
|
|
60
|
+
id?: string;
|
|
61
|
+
name?: string;
|
|
62
|
+
trigger?: EntrypointTrigger;
|
|
63
|
+
source?: string;
|
|
64
|
+
serviceId?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class EntrypointNode {
|
|
68
|
+
static readonly TYPE = 'ENTRYPOINT' as const;
|
|
69
|
+
|
|
70
|
+
static readonly REQUIRED = ['file', 'entrypointType'] as const;
|
|
71
|
+
static readonly OPTIONAL = ['trigger', 'source', 'serviceId', 'name'] as const;
|
|
72
|
+
|
|
73
|
+
static readonly TYPES = ENTRYPOINT_TYPES;
|
|
74
|
+
static readonly TRIGGERS = ENTRYPOINT_TRIGGERS;
|
|
75
|
+
static readonly SOURCES = ENTRYPOINT_SOURCES;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Create ENTRYPOINT node
|
|
79
|
+
*/
|
|
80
|
+
static create(
|
|
81
|
+
file: string,
|
|
82
|
+
entrypointType: EntrypointType,
|
|
83
|
+
options: EntrypointNodeOptions = {}
|
|
84
|
+
): EntrypointNodeRecord {
|
|
85
|
+
if (!file) throw new Error('EntrypointNode.create: file is required');
|
|
86
|
+
if (!entrypointType) throw new Error('EntrypointNode.create: entrypointType is required');
|
|
87
|
+
|
|
88
|
+
const id = options.id || this.generateId(file, entrypointType);
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
id,
|
|
92
|
+
type: this.TYPE,
|
|
93
|
+
file,
|
|
94
|
+
line: 0,
|
|
95
|
+
name: options.name || this.extractName(file),
|
|
96
|
+
entrypointType,
|
|
97
|
+
trigger: options.trigger || this.inferTrigger(entrypointType),
|
|
98
|
+
source: options.source || 'unknown',
|
|
99
|
+
serviceId: options.serviceId || null
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Generate stable ID for entrypoint
|
|
105
|
+
*/
|
|
106
|
+
static generateId(file: string, type: string): string {
|
|
107
|
+
const hash = createHash('md5').update(file).digest('hex').substring(0, 8);
|
|
108
|
+
return `ENTRYPOINT:${type}:${hash}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Extract name from file path
|
|
113
|
+
*/
|
|
114
|
+
static extractName(file: string): string {
|
|
115
|
+
const parts = file.split('/');
|
|
116
|
+
return parts[parts.length - 1];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Infer trigger from entrypoint type
|
|
121
|
+
*/
|
|
122
|
+
static inferTrigger(entrypointType: EntrypointType): EntrypointTrigger {
|
|
123
|
+
switch (entrypointType) {
|
|
124
|
+
case this.TYPES.SERVICE:
|
|
125
|
+
case this.TYPES.CLI:
|
|
126
|
+
return this.TRIGGERS.RUNTIME;
|
|
127
|
+
case this.TYPES.TEST:
|
|
128
|
+
return this.TRIGGERS.CI;
|
|
129
|
+
case this.TYPES.CONFIG:
|
|
130
|
+
return this.TRIGGERS.BUILD;
|
|
131
|
+
case this.TYPES.SCRIPT:
|
|
132
|
+
case this.TYPES.HOOK:
|
|
133
|
+
return this.TRIGGERS.DEV;
|
|
134
|
+
default:
|
|
135
|
+
return this.TRIGGERS.MANUAL;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Validate ENTRYPOINT node
|
|
141
|
+
*/
|
|
142
|
+
static validate(node: EntrypointNodeRecord): string[] {
|
|
143
|
+
const errors: string[] = [];
|
|
144
|
+
|
|
145
|
+
if (node.type !== this.TYPE) {
|
|
146
|
+
errors.push(`Expected type ${this.TYPE}, got ${node.type}`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const nodeRecord = node as unknown as Record<string, unknown>;
|
|
150
|
+
for (const field of this.REQUIRED) {
|
|
151
|
+
if (!nodeRecord[field]) {
|
|
152
|
+
errors.push(`Missing required field: ${field}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (node.entrypointType && !Object.values(this.TYPES).includes(node.entrypointType)) {
|
|
157
|
+
errors.push(`Invalid entrypointType: ${node.entrypointType}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return errors;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export type { EntrypointNodeRecord };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventListenerNode - contract for EVENT_LISTENER node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { BaseNodeRecord } from '@grafema/types';
|
|
6
|
+
|
|
7
|
+
interface EventListenerNodeRecord extends BaseNodeRecord {
|
|
8
|
+
type: 'EVENT_LISTENER';
|
|
9
|
+
object?: string;
|
|
10
|
+
parentScopeId?: string;
|
|
11
|
+
callbackArg?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface EventListenerNodeOptions {
|
|
15
|
+
column?: number;
|
|
16
|
+
parentScopeId?: string;
|
|
17
|
+
callbackArg?: string;
|
|
18
|
+
counter?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class EventListenerNode {
|
|
22
|
+
static readonly TYPE = 'EVENT_LISTENER' as const;
|
|
23
|
+
|
|
24
|
+
static readonly REQUIRED = ['name', 'file', 'line'] as const;
|
|
25
|
+
static readonly OPTIONAL = ['object', 'column', 'parentScopeId', 'callbackArg'] as const;
|
|
26
|
+
|
|
27
|
+
static create(
|
|
28
|
+
eventName: string,
|
|
29
|
+
objectName: string | undefined,
|
|
30
|
+
file: string,
|
|
31
|
+
line: number,
|
|
32
|
+
options: EventListenerNodeOptions = {}
|
|
33
|
+
): EventListenerNodeRecord {
|
|
34
|
+
if (!eventName) throw new Error('EventListenerNode.create: eventName is required');
|
|
35
|
+
if (!file) throw new Error('EventListenerNode.create: file is required');
|
|
36
|
+
if (line === undefined) throw new Error('EventListenerNode.create: line is required');
|
|
37
|
+
|
|
38
|
+
const counter = options.counter !== undefined ? `:${options.counter}` : '';
|
|
39
|
+
const id = `${file}:EVENT_LISTENER:${eventName}:${line}:${options.column || 0}${counter}`;
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
id,
|
|
43
|
+
type: this.TYPE,
|
|
44
|
+
name: eventName,
|
|
45
|
+
object: objectName,
|
|
46
|
+
file,
|
|
47
|
+
line,
|
|
48
|
+
parentScopeId: options.parentScopeId,
|
|
49
|
+
callbackArg: options.callbackArg
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static validate(node: EventListenerNodeRecord): string[] {
|
|
54
|
+
const errors: string[] = [];
|
|
55
|
+
if (node.type !== this.TYPE) errors.push(`Expected type ${this.TYPE}`);
|
|
56
|
+
const nodeRecord = node as unknown as Record<string, unknown>;
|
|
57
|
+
for (const field of this.REQUIRED) {
|
|
58
|
+
if (nodeRecord[field] === undefined) errors.push(`Missing: ${field}`);
|
|
59
|
+
}
|
|
60
|
+
return errors;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type { EventListenerNodeRecord };
|