@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,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MethodCallResolver - обогащает METHOD_CALL ноды связями CALLS к определениям методов
|
|
3
|
+
*
|
|
4
|
+
* Находит вызовы методов (CALL с "object" атрибутом) и пытается связать их с:
|
|
5
|
+
* 1. Методами классов в том же файле
|
|
6
|
+
* 2. Методами классов в импортированных модулях
|
|
7
|
+
* 3. Методами объектов переменных
|
|
8
|
+
*
|
|
9
|
+
* СОЗДАЁТ РЁБРА:
|
|
10
|
+
* - METHOD_CALL -> CALLS -> METHOD (для методов классов)
|
|
11
|
+
* - METHOD_CALL -> CALLS -> FUNCTION (для методов объектов)
|
|
12
|
+
*/
|
|
13
|
+
import { Plugin, createSuccessResult } from '../Plugin.js';
|
|
14
|
+
export class MethodCallResolver extends Plugin {
|
|
15
|
+
_containingClassCache;
|
|
16
|
+
get metadata() {
|
|
17
|
+
return {
|
|
18
|
+
name: 'MethodCallResolver',
|
|
19
|
+
phase: 'ENRICHMENT',
|
|
20
|
+
priority: 50,
|
|
21
|
+
creates: {
|
|
22
|
+
nodes: [],
|
|
23
|
+
edges: ['CALLS']
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async execute(context) {
|
|
28
|
+
const { graph, onProgress } = context;
|
|
29
|
+
console.log('[MethodCallResolver] Starting method call resolution...');
|
|
30
|
+
let methodCallsProcessed = 0;
|
|
31
|
+
let edgesCreated = 0;
|
|
32
|
+
let unresolved = 0;
|
|
33
|
+
// Собираем все METHOD_CALL ноды (CALL с object атрибутом)
|
|
34
|
+
const methodCalls = [];
|
|
35
|
+
for await (const node of graph.queryNodes({ nodeType: 'CALL' })) {
|
|
36
|
+
const callNode = node;
|
|
37
|
+
if (callNode.object) {
|
|
38
|
+
methodCalls.push(callNode);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
console.log(`[MethodCallResolver] Found ${methodCalls.length} method calls to resolve`);
|
|
42
|
+
// Собираем все классы и их методы для быстрого поиска
|
|
43
|
+
const classMethodIndex = await this.buildClassMethodIndex(graph);
|
|
44
|
+
console.log(`[MethodCallResolver] Indexed ${classMethodIndex.size} classes`);
|
|
45
|
+
// Собираем переменные и их типы (если известны)
|
|
46
|
+
const variableTypes = await this.buildVariableTypeIndex(graph);
|
|
47
|
+
const startTime = Date.now();
|
|
48
|
+
for (const methodCall of methodCalls) {
|
|
49
|
+
methodCallsProcessed++;
|
|
50
|
+
// Report progress every 50 calls
|
|
51
|
+
if (onProgress && methodCallsProcessed % 50 === 0) {
|
|
52
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
53
|
+
onProgress({
|
|
54
|
+
phase: 'enrichment',
|
|
55
|
+
currentPlugin: 'MethodCallResolver',
|
|
56
|
+
message: `Resolving method calls ${methodCallsProcessed}/${methodCalls.length} (${elapsed}s)`,
|
|
57
|
+
totalFiles: methodCalls.length,
|
|
58
|
+
processedFiles: methodCallsProcessed
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// Log every 10 calls with timing
|
|
62
|
+
if (methodCallsProcessed % 10 === 0) {
|
|
63
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
64
|
+
const avgTime = ((Date.now() - startTime) / methodCallsProcessed).toFixed(0);
|
|
65
|
+
console.log(`[MethodCallResolver] Progress: ${methodCallsProcessed}/${methodCalls.length} (${elapsed}s, avg ${avgTime}ms/call)`);
|
|
66
|
+
}
|
|
67
|
+
// Пропускаем внешние методы (console, Array.prototype, etc.)
|
|
68
|
+
if (this.isExternalMethod(methodCall.object, methodCall.method)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
// Проверяем есть ли уже CALLS ребро
|
|
72
|
+
const existingEdges = await graph.getOutgoingEdges(methodCall.id, ['CALLS']);
|
|
73
|
+
if (existingEdges.length > 0) {
|
|
74
|
+
continue; // Уже есть связь
|
|
75
|
+
}
|
|
76
|
+
// Пытаемся найти определение метода
|
|
77
|
+
const targetMethod = await this.resolveMethodCall(methodCall, classMethodIndex, variableTypes, graph);
|
|
78
|
+
if (targetMethod) {
|
|
79
|
+
await graph.addEdge({
|
|
80
|
+
src: methodCall.id,
|
|
81
|
+
dst: targetMethod.id,
|
|
82
|
+
type: 'CALLS'
|
|
83
|
+
});
|
|
84
|
+
edgesCreated++;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
unresolved++;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const summary = {
|
|
91
|
+
methodCallsProcessed,
|
|
92
|
+
edgesCreated,
|
|
93
|
+
unresolved,
|
|
94
|
+
classesIndexed: classMethodIndex.size
|
|
95
|
+
};
|
|
96
|
+
console.log('[MethodCallResolver] Summary:', summary);
|
|
97
|
+
return createSuccessResult({ nodes: 0, edges: edgesCreated }, summary);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Строит индекс классов и их методов
|
|
101
|
+
*/
|
|
102
|
+
async buildClassMethodIndex(graph) {
|
|
103
|
+
const index = new Map();
|
|
104
|
+
const startTime = Date.now();
|
|
105
|
+
let classCount = 0;
|
|
106
|
+
for await (const classNode of graph.queryNodes({ nodeType: 'CLASS' })) {
|
|
107
|
+
classCount++;
|
|
108
|
+
if (classCount % 50 === 0) {
|
|
109
|
+
console.log(`[MethodCallResolver] Indexing classes: ${classCount}...`);
|
|
110
|
+
}
|
|
111
|
+
const className = classNode.name;
|
|
112
|
+
if (!className)
|
|
113
|
+
continue;
|
|
114
|
+
const classEntry = {
|
|
115
|
+
classNode,
|
|
116
|
+
methods: new Map()
|
|
117
|
+
};
|
|
118
|
+
const containsEdges = await graph.getOutgoingEdges(classNode.id, ['CONTAINS']);
|
|
119
|
+
for (const edge of containsEdges) {
|
|
120
|
+
const childNode = await graph.getNode(edge.dst);
|
|
121
|
+
if (childNode && (childNode.type === 'METHOD' || childNode.type === 'FUNCTION')) {
|
|
122
|
+
if (childNode.name) {
|
|
123
|
+
classEntry.methods.set(childNode.name, childNode);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
index.set(className, classEntry);
|
|
128
|
+
// Также индексируем по файлу для локального резолвинга
|
|
129
|
+
const fileKey = `${classNode.file}:${className}`;
|
|
130
|
+
index.set(fileKey, classEntry);
|
|
131
|
+
}
|
|
132
|
+
const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
133
|
+
console.log(`[MethodCallResolver] Indexed ${index.size} class entries in ${totalTime}s`);
|
|
134
|
+
return index;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Строит индекс переменных и их типов (из INSTANCE_OF рёбер)
|
|
138
|
+
*/
|
|
139
|
+
async buildVariableTypeIndex(graph) {
|
|
140
|
+
const startTime = Date.now();
|
|
141
|
+
const index = new Map();
|
|
142
|
+
for await (const classNode of graph.queryNodes({ nodeType: 'CLASS' })) {
|
|
143
|
+
if (!classNode.name)
|
|
144
|
+
continue;
|
|
145
|
+
const incomingEdges = await graph.getIncomingEdges(classNode.id, ['INSTANCE_OF']);
|
|
146
|
+
for (const edge of incomingEdges) {
|
|
147
|
+
index.set(edge.src.toString(), classNode.name);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
151
|
+
console.log(`[MethodCallResolver] Built variable type index: ${index.size} entries in ${elapsed}s`);
|
|
152
|
+
return index;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Пытается найти определение метода
|
|
156
|
+
*/
|
|
157
|
+
async resolveMethodCall(methodCall, classMethodIndex, variableTypes, graph) {
|
|
158
|
+
const { object, method, file } = methodCall;
|
|
159
|
+
if (!object || !method)
|
|
160
|
+
return null;
|
|
161
|
+
// 1. Проверяем если object - это имя класса напрямую (статический вызов)
|
|
162
|
+
if (classMethodIndex.has(object)) {
|
|
163
|
+
const classEntry = classMethodIndex.get(object);
|
|
164
|
+
if (classEntry.methods.has(method)) {
|
|
165
|
+
return classEntry.methods.get(method);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// 2. Проверяем локальный класс в том же файле
|
|
169
|
+
const localKey = `${file}:${object}`;
|
|
170
|
+
if (classMethodIndex.has(localKey)) {
|
|
171
|
+
const classEntry = classMethodIndex.get(localKey);
|
|
172
|
+
if (classEntry.methods.has(method)) {
|
|
173
|
+
return classEntry.methods.get(method);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// 3. Проверяем если object - это "this" (ссылка на текущий класс)
|
|
177
|
+
if (object === 'this') {
|
|
178
|
+
if (!this._containingClassCache)
|
|
179
|
+
this._containingClassCache = new Map();
|
|
180
|
+
let containingClass = this._containingClassCache.get(methodCall.id);
|
|
181
|
+
if (containingClass === undefined) {
|
|
182
|
+
containingClass = await this.findContainingClass(methodCall, graph);
|
|
183
|
+
this._containingClassCache.set(methodCall.id, containingClass);
|
|
184
|
+
}
|
|
185
|
+
if (containingClass && classMethodIndex.has(containingClass.name)) {
|
|
186
|
+
const classEntry = classMethodIndex.get(containingClass.name);
|
|
187
|
+
if (classEntry.methods.has(method)) {
|
|
188
|
+
return classEntry.methods.get(method);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// 4. Используем variableTypes индекс
|
|
193
|
+
for (const [, className] of variableTypes.entries()) {
|
|
194
|
+
if (className && classMethodIndex.has(className)) {
|
|
195
|
+
const classEntry = classMethodIndex.get(className);
|
|
196
|
+
if (classEntry.methods.has(method)) {
|
|
197
|
+
return classEntry.methods.get(method);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Находит класс, содержащий данный method call
|
|
205
|
+
*/
|
|
206
|
+
async findContainingClass(methodCall, graph) {
|
|
207
|
+
const incomingEdges = await graph.getIncomingEdges(methodCall.id, ['CONTAINS']);
|
|
208
|
+
for (const edge of incomingEdges) {
|
|
209
|
+
const parentNode = await graph.getNode(edge.src);
|
|
210
|
+
if (!parentNode)
|
|
211
|
+
continue;
|
|
212
|
+
if (parentNode.type === 'CLASS') {
|
|
213
|
+
return parentNode;
|
|
214
|
+
}
|
|
215
|
+
const found = await this.findContainingClassRecursive(parentNode, graph, new Set());
|
|
216
|
+
if (found)
|
|
217
|
+
return found;
|
|
218
|
+
}
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
async findContainingClassRecursive(node, graph, visited) {
|
|
222
|
+
if (visited.has(node.id.toString()))
|
|
223
|
+
return null;
|
|
224
|
+
visited.add(node.id.toString());
|
|
225
|
+
const incomingEdges = await graph.getIncomingEdges(node.id, ['CONTAINS']);
|
|
226
|
+
for (const edge of incomingEdges) {
|
|
227
|
+
const parentNode = await graph.getNode(edge.src);
|
|
228
|
+
if (!parentNode)
|
|
229
|
+
continue;
|
|
230
|
+
if (parentNode.type === 'CLASS') {
|
|
231
|
+
return parentNode;
|
|
232
|
+
}
|
|
233
|
+
const found = await this.findContainingClassRecursive(parentNode, graph, visited);
|
|
234
|
+
if (found)
|
|
235
|
+
return found;
|
|
236
|
+
}
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Проверяет является ли метод внешним (console, Array, Promise, etc.)
|
|
241
|
+
*/
|
|
242
|
+
isExternalMethod(object, method) {
|
|
243
|
+
const externalObjects = new Set([
|
|
244
|
+
'console', 'Math', 'JSON', 'Object', 'Array', 'String', 'Number',
|
|
245
|
+
'Boolean', 'Date', 'RegExp', 'Error', 'Promise', 'Set', 'Map',
|
|
246
|
+
'WeakSet', 'WeakMap', 'Symbol', 'Proxy', 'Reflect', 'Intl',
|
|
247
|
+
'process', 'global', 'window', 'document', 'Buffer',
|
|
248
|
+
'fs', 'path', 'http', 'https', 'crypto', 'os', 'url', 'util'
|
|
249
|
+
]);
|
|
250
|
+
return externalObjects.has(object);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MountPointResolver - ENRICHMENT plugin for resolving mount points
|
|
3
|
+
*
|
|
4
|
+
* Updates ENDPOINT nodes by adding fullPath based on MOUNT_POINT prefixes.
|
|
5
|
+
*
|
|
6
|
+
* Graph traversal:
|
|
7
|
+
* MOUNT_POINT --MOUNTS--> MODULE --EXPOSES--> ENDPOINT
|
|
8
|
+
*
|
|
9
|
+
* Updates:
|
|
10
|
+
* endpoint.fullPath = mountPoint.prefix + endpoint.localPath
|
|
11
|
+
*/
|
|
12
|
+
import { Plugin } from '../Plugin.js';
|
|
13
|
+
import type { PluginMetadata, PluginContext, PluginResult } from '@grafema/types';
|
|
14
|
+
export declare class MountPointResolver extends Plugin {
|
|
15
|
+
get metadata(): PluginMetadata;
|
|
16
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Recursively resolve mount point and all nested mount points
|
|
19
|
+
*/
|
|
20
|
+
private resolveMountPoint;
|
|
21
|
+
/**
|
|
22
|
+
* Helper method for finding edges by criteria
|
|
23
|
+
*/
|
|
24
|
+
private findEdges;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=MountPointResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MountPointResolver.d.ts","sourceRoot":"","sources":["../../../src/plugins/enrichment/MountPointResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAuBhG,qBAAa,kBAAmB,SAAQ,MAAM;IAC5C,IAAI,QAAQ,IAAI,cAAc,CAW7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IA6F5D;;OAEG;YACW,iBAAiB;IAsF/B;;OAEG;YACW,SAAS;CA2BxB"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MountPointResolver - ENRICHMENT plugin for resolving mount points
|
|
3
|
+
*
|
|
4
|
+
* Updates ENDPOINT nodes by adding fullPath based on MOUNT_POINT prefixes.
|
|
5
|
+
*
|
|
6
|
+
* Graph traversal:
|
|
7
|
+
* MOUNT_POINT --MOUNTS--> MODULE --EXPOSES--> ENDPOINT
|
|
8
|
+
*
|
|
9
|
+
* Updates:
|
|
10
|
+
* endpoint.fullPath = mountPoint.prefix + endpoint.localPath
|
|
11
|
+
*/
|
|
12
|
+
import { Plugin } from '../Plugin.js';
|
|
13
|
+
import { createSuccessResult, createErrorResult } from '@grafema/types';
|
|
14
|
+
export class MountPointResolver extends Plugin {
|
|
15
|
+
get metadata() {
|
|
16
|
+
return {
|
|
17
|
+
name: 'MountPointResolver',
|
|
18
|
+
phase: 'ENRICHMENT',
|
|
19
|
+
priority: 90, // High priority - one of first enrichment plugins
|
|
20
|
+
creates: {
|
|
21
|
+
nodes: [], // Doesn't create new nodes
|
|
22
|
+
edges: [] // Doesn't create new edges
|
|
23
|
+
},
|
|
24
|
+
dependencies: ['JSModuleIndexer', 'JSASTAnalyzer']
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async execute(context) {
|
|
28
|
+
try {
|
|
29
|
+
const { graph } = context;
|
|
30
|
+
let endpointsUpdated = 0;
|
|
31
|
+
let mountPointsProcessed = 0;
|
|
32
|
+
// Find all MOUNT_POINT nodes
|
|
33
|
+
const allNodes = await graph.getAllNodes();
|
|
34
|
+
const mountPoints = allNodes.filter(node => node.type === 'MOUNT_POINT');
|
|
35
|
+
console.log(`[MountPointResolver] Found ${mountPoints.length} mount points`);
|
|
36
|
+
// For each top-level mount point (from app.use in index.js)
|
|
37
|
+
// apply recursive resolver
|
|
38
|
+
const processedMountPoints = new Set();
|
|
39
|
+
for (const mountPoint of mountPoints) {
|
|
40
|
+
if (!processedMountPoints.has(mountPoint.id)) {
|
|
41
|
+
const updated = await this.resolveMountPoint(graph, mountPoint, '', processedMountPoints);
|
|
42
|
+
endpointsUpdated += updated;
|
|
43
|
+
mountPointsProcessed++;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Fallback: process mount points without recursion (old logic for compatibility)
|
|
47
|
+
for (const mountPoint of mountPoints) {
|
|
48
|
+
if (processedMountPoints.has(mountPoint.id))
|
|
49
|
+
continue;
|
|
50
|
+
// Find MOUNT_POINT --MOUNTS--> MODULE edge
|
|
51
|
+
const mountsEdges = await this.findEdges(graph, {
|
|
52
|
+
type: 'MOUNTS',
|
|
53
|
+
src: mountPoint.id
|
|
54
|
+
});
|
|
55
|
+
for (const mountsEdge of mountsEdges) {
|
|
56
|
+
const targetModuleId = mountsEdge.dst;
|
|
57
|
+
// Find MODULE --EXPOSES--> ENDPOINT edges
|
|
58
|
+
const exposesEdges = await this.findEdges(graph, {
|
|
59
|
+
type: 'EXPOSES',
|
|
60
|
+
src: targetModuleId
|
|
61
|
+
});
|
|
62
|
+
for (const exposesEdge of exposesEdges) {
|
|
63
|
+
const endpointId = exposesEdge.dst;
|
|
64
|
+
const endpoint = await graph.getNode(endpointId);
|
|
65
|
+
if (endpoint && endpoint.type === 'ENDPOINT') {
|
|
66
|
+
// Support multiple mount points for one endpoint
|
|
67
|
+
// Store all prefixes and fullPaths in arrays
|
|
68
|
+
const mountPrefixes = endpoint.mountPrefixes || [];
|
|
69
|
+
const fullPaths = endpoint.fullPaths || [];
|
|
70
|
+
const prefix = mountPoint.prefix;
|
|
71
|
+
const fullPath = prefix + (endpoint.localPath || endpoint.path || '');
|
|
72
|
+
// Only add if not already added (avoid duplicates)
|
|
73
|
+
if (!mountPrefixes.includes(prefix)) {
|
|
74
|
+
mountPrefixes.push(prefix);
|
|
75
|
+
fullPaths.push(fullPath);
|
|
76
|
+
}
|
|
77
|
+
// Update endpoint node
|
|
78
|
+
const updatedEndpoint = {
|
|
79
|
+
...endpoint,
|
|
80
|
+
mountPrefixes,
|
|
81
|
+
fullPaths,
|
|
82
|
+
mountPrefix: endpoint.mountPrefix || prefix,
|
|
83
|
+
fullPath: endpoint.fullPath || fullPath
|
|
84
|
+
};
|
|
85
|
+
await graph.addNode(updatedEndpoint);
|
|
86
|
+
endpointsUpdated++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
mountPointsProcessed++;
|
|
91
|
+
}
|
|
92
|
+
console.log(`[MountPointResolver] Updated ${endpointsUpdated} endpoints from ${mountPointsProcessed} mount points`);
|
|
93
|
+
return createSuccessResult({ nodes: 0, edges: 0 }, { endpointsUpdated, mountPointsProcessed });
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error(`[MountPointResolver] Error:`, error);
|
|
97
|
+
return createErrorResult(error);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Recursively resolve mount point and all nested mount points
|
|
102
|
+
*/
|
|
103
|
+
async resolveMountPoint(graph, mountPoint, parentPrefix, processedMountPoints) {
|
|
104
|
+
let endpointsUpdated = 0;
|
|
105
|
+
// Mark as processed
|
|
106
|
+
processedMountPoints.add(mountPoint.id);
|
|
107
|
+
// Calculate full prefix (parent + current)
|
|
108
|
+
const fullPrefix = parentPrefix + mountPoint.prefix;
|
|
109
|
+
// Find MOUNT_POINT --MOUNTS--> MODULE edge
|
|
110
|
+
const mountsEdges = await this.findEdges(graph, {
|
|
111
|
+
type: 'MOUNTS',
|
|
112
|
+
src: mountPoint.id
|
|
113
|
+
});
|
|
114
|
+
for (const mountsEdge of mountsEdges) {
|
|
115
|
+
const targetModuleId = mountsEdge.dst;
|
|
116
|
+
// 1. Process ENDPOINT in this module
|
|
117
|
+
const exposesEdges = await this.findEdges(graph, {
|
|
118
|
+
type: 'EXPOSES',
|
|
119
|
+
src: targetModuleId
|
|
120
|
+
});
|
|
121
|
+
for (const exposesEdge of exposesEdges) {
|
|
122
|
+
const endpointId = exposesEdge.dst;
|
|
123
|
+
const endpoint = await graph.getNode(endpointId);
|
|
124
|
+
if (endpoint && endpoint.type === 'ENDPOINT') {
|
|
125
|
+
// Support multiple mount points
|
|
126
|
+
const mountPrefixes = endpoint.mountPrefixes || [];
|
|
127
|
+
const fullPaths = endpoint.fullPaths || [];
|
|
128
|
+
const fullPath = fullPrefix + (endpoint.localPath || endpoint.path || '');
|
|
129
|
+
// Only add if not already added
|
|
130
|
+
if (!mountPrefixes.includes(fullPrefix)) {
|
|
131
|
+
mountPrefixes.push(fullPrefix);
|
|
132
|
+
fullPaths.push(fullPath);
|
|
133
|
+
}
|
|
134
|
+
// Update endpoint node with new data
|
|
135
|
+
const updatedEndpoint = {
|
|
136
|
+
...endpoint,
|
|
137
|
+
mountPrefixes,
|
|
138
|
+
fullPaths,
|
|
139
|
+
mountPrefix: endpoint.mountPrefix || fullPrefix,
|
|
140
|
+
fullPath: endpoint.fullPath || fullPath
|
|
141
|
+
};
|
|
142
|
+
await graph.addNode(updatedEndpoint);
|
|
143
|
+
endpointsUpdated++;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// 2. Recursively process nested MOUNT_POINT in this module
|
|
147
|
+
const definesEdges = await this.findEdges(graph, {
|
|
148
|
+
type: 'DEFINES',
|
|
149
|
+
src: targetModuleId
|
|
150
|
+
});
|
|
151
|
+
for (const definesEdge of definesEdges) {
|
|
152
|
+
const nestedMountPointId = definesEdge.dst;
|
|
153
|
+
const nestedMountPoint = await graph.getNode(nestedMountPointId);
|
|
154
|
+
if (nestedMountPoint && nestedMountPoint.type === 'MOUNT_POINT' &&
|
|
155
|
+
!processedMountPoints.has(nestedMountPointId)) {
|
|
156
|
+
// Recursively process nested mount point
|
|
157
|
+
endpointsUpdated += await this.resolveMountPoint(graph, nestedMountPoint, fullPrefix, // Pass accumulated prefix
|
|
158
|
+
processedMountPoints);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return endpointsUpdated;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Helper method for finding edges by criteria
|
|
166
|
+
*/
|
|
167
|
+
async findEdges(graph, criteria) {
|
|
168
|
+
const result = [];
|
|
169
|
+
// Get all edges using RFDBServerBackend API
|
|
170
|
+
if (!graph.getAllEdges) {
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
const allEdges = await graph.getAllEdges();
|
|
174
|
+
for (const edge of allEdges) {
|
|
175
|
+
let matches = true;
|
|
176
|
+
for (const [key, value] of Object.entries(criteria)) {
|
|
177
|
+
const edgeRecord = edge;
|
|
178
|
+
if (edgeRecord[key] !== value) {
|
|
179
|
+
matches = false;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (matches) {
|
|
184
|
+
result.push(edge);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PrefixEvaluator - ENRICHMENT plugin for evaluating dynamic prefixes
|
|
3
|
+
*
|
|
4
|
+
* Resolves placeholders in MOUNT_POINT.prefix:
|
|
5
|
+
* - ${variable} → finds VariableDeclaration in the same module
|
|
6
|
+
* - ${binary} → recursively resolves BinaryExpression
|
|
7
|
+
* - ${template} → resolves TemplateLiteral with variables
|
|
8
|
+
* - ${member} → finds object and its property
|
|
9
|
+
* - ${call} → not supported yet (requires runtime eval)
|
|
10
|
+
* - ${conditional} → not supported yet (requires runtime eval)
|
|
11
|
+
*/
|
|
12
|
+
import { Plugin } from '../Plugin.js';
|
|
13
|
+
import type { PluginMetadata, PluginContext, PluginResult } from '../Plugin.js';
|
|
14
|
+
import type { ParseResult } from '@babel/parser';
|
|
15
|
+
import type { File, Node, MemberExpression, ObjectExpression, ArrayExpression } from '@babel/types';
|
|
16
|
+
import type { NodeRecord } from '@grafema/types';
|
|
17
|
+
interface ModuleNode {
|
|
18
|
+
id: string;
|
|
19
|
+
type: 'MODULE';
|
|
20
|
+
name: string;
|
|
21
|
+
file: string;
|
|
22
|
+
line: number;
|
|
23
|
+
}
|
|
24
|
+
interface Edge {
|
|
25
|
+
type: string;
|
|
26
|
+
fromId: string;
|
|
27
|
+
dst: string;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
interface EdgeCriteria {
|
|
31
|
+
type?: string;
|
|
32
|
+
dst?: string;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
interface Graph {
|
|
36
|
+
nodes: Map<string, NodeRecord> | {
|
|
37
|
+
get(id: string): NodeRecord | undefined;
|
|
38
|
+
values(): Iterable<NodeRecord>;
|
|
39
|
+
};
|
|
40
|
+
edges: Map<string, Edge> | {
|
|
41
|
+
values(): Iterable<Edge>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export declare class PrefixEvaluator extends Plugin {
|
|
45
|
+
get metadata(): PluginMetadata;
|
|
46
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Evaluate prefix based on placeholder type
|
|
49
|
+
*/
|
|
50
|
+
evaluatePrefix(placeholder: string, line: number, ast: ParseResult<File>, _module: ModuleNode): Promise<string | null>;
|
|
51
|
+
/**
|
|
52
|
+
* Resolve ${variable} - find VariableDeclaration
|
|
53
|
+
*/
|
|
54
|
+
evaluateVariable(line: number, ast: ParseResult<File>): string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve ${binary} - BinaryExpression (a + b)
|
|
57
|
+
*/
|
|
58
|
+
evaluateBinary(line: number, ast: ParseResult<File>): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Recursively resolve arbitrary expression
|
|
61
|
+
*/
|
|
62
|
+
resolveExpression(node: Node, ast: ParseResult<File>): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Resolve ${template} - TemplateLiteral with variables
|
|
65
|
+
*/
|
|
66
|
+
evaluateTemplate(line: number, ast: ParseResult<File>): string | null;
|
|
67
|
+
/**
|
|
68
|
+
* Resolve ${member} - MemberExpression (config.apiPrefix)
|
|
69
|
+
*/
|
|
70
|
+
evaluateMember(line: number, ast: ParseResult<File>): string | null;
|
|
71
|
+
/**
|
|
72
|
+
* Recursively resolve MemberExpression
|
|
73
|
+
*/
|
|
74
|
+
resolveMemberExpression(node: MemberExpression, ast: ParseResult<File>): string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Evaluate ObjectExpression to plain JS object
|
|
77
|
+
*/
|
|
78
|
+
evaluateObjectExpression(node: ObjectExpression): Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Evaluate ArrayExpression to plain JS array
|
|
81
|
+
*/
|
|
82
|
+
evaluateArrayExpression(node: ArrayExpression): string[];
|
|
83
|
+
/**
|
|
84
|
+
* Helper method for finding edges
|
|
85
|
+
*/
|
|
86
|
+
findEdges(graph: Graph, criteria: EdgeCriteria): Edge[];
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=PrefixEvaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrefixEvaluator.d.ts","sourceRoot":"","sources":["../../../src/plugins/enrichment/PrefixEvaluator.ts"],"names":[],"mappings":"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"}
|