@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,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clean Graph API for visualization
|
|
3
|
+
* Reads everything directly from RFDB (no caches)
|
|
4
|
+
*/
|
|
5
|
+
import { createServer } from 'http';
|
|
6
|
+
import { parse as parseUrl } from 'url';
|
|
7
|
+
// Node type constants
|
|
8
|
+
const NODE_TYPES = {
|
|
9
|
+
SERVICE: 2,
|
|
10
|
+
FUNCTION: 3,
|
|
11
|
+
CLASS: 4,
|
|
12
|
+
MODULE: 8,
|
|
13
|
+
};
|
|
14
|
+
// Edge type constants
|
|
15
|
+
const EDGE_TYPES = {
|
|
16
|
+
CONTAINS: 1,
|
|
17
|
+
DEPENDS_ON: 2,
|
|
18
|
+
CALLS: 3,
|
|
19
|
+
IMPORTS: 8,
|
|
20
|
+
};
|
|
21
|
+
export class GraphAPI {
|
|
22
|
+
backend;
|
|
23
|
+
port;
|
|
24
|
+
server;
|
|
25
|
+
constructor(backend, port = 3000) {
|
|
26
|
+
this.backend = backend;
|
|
27
|
+
this.port = port;
|
|
28
|
+
this.server = null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Start API server
|
|
32
|
+
*/
|
|
33
|
+
start() {
|
|
34
|
+
this.server = createServer((req, res) => {
|
|
35
|
+
this.handleRequest(req, res);
|
|
36
|
+
});
|
|
37
|
+
this.server.listen(this.port, () => {
|
|
38
|
+
console.log(`\n🚀 Graph API Server started`);
|
|
39
|
+
console.log(`📊 http://localhost:${this.port}`);
|
|
40
|
+
console.log(`\nEndpoints:`);
|
|
41
|
+
console.log(` GET /api/services - List all services`);
|
|
42
|
+
console.log(` GET /api/node/:id - Get node by ID`);
|
|
43
|
+
console.log(` GET /api/node/:id/children - Get node children (via CONTAINS edges)`);
|
|
44
|
+
console.log(` GET /api/node/:id/edges - Get all edges from node`);
|
|
45
|
+
console.log(`\nPress Ctrl+C to stop\n`);
|
|
46
|
+
});
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Stop server
|
|
51
|
+
*/
|
|
52
|
+
stop() {
|
|
53
|
+
if (this.server) {
|
|
54
|
+
this.server.close();
|
|
55
|
+
console.log('Graph API Server stopped');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Handle HTTP request
|
|
60
|
+
*/
|
|
61
|
+
async handleRequest(req, res) {
|
|
62
|
+
const { pathname } = parseUrl(req.url || '', true);
|
|
63
|
+
// CORS headers
|
|
64
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
65
|
+
res.setHeader('Content-Type', 'application/json');
|
|
66
|
+
try {
|
|
67
|
+
// GET /api/services
|
|
68
|
+
if (pathname === '/api/services') {
|
|
69
|
+
await this.handleGetServices(req, res);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// GET /api/node/:id
|
|
73
|
+
const nodeMatch = pathname?.match(/^\/api\/node\/([^\/]+)$/);
|
|
74
|
+
if (nodeMatch) {
|
|
75
|
+
await this.handleGetNode(req, res, decodeURIComponent(nodeMatch[1]));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// GET /api/node/:id/children
|
|
79
|
+
const childrenMatch = pathname?.match(/^\/api\/node\/([^\/]+)\/children$/);
|
|
80
|
+
if (childrenMatch) {
|
|
81
|
+
await this.handleGetChildren(req, res, decodeURIComponent(childrenMatch[1]));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// GET /api/node/:id/edges
|
|
85
|
+
const edgesMatch = pathname?.match(/^\/api\/node\/([^\/]+)\/edges$/);
|
|
86
|
+
if (edgesMatch) {
|
|
87
|
+
await this.handleGetEdges(req, res, decodeURIComponent(edgesMatch[1]));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// 404
|
|
91
|
+
res.writeHead(404);
|
|
92
|
+
res.end(JSON.stringify({ error: 'Endpoint not found' }));
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error('API error:', error);
|
|
96
|
+
res.writeHead(500);
|
|
97
|
+
res.end(JSON.stringify({ error: error.message }));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* GET /api/services
|
|
102
|
+
* Returns all SERVICE nodes
|
|
103
|
+
*/
|
|
104
|
+
async handleGetServices(req, res) {
|
|
105
|
+
// Find all SERVICE nodes from RFDB
|
|
106
|
+
const serviceIds = this.backend.engine.findByType(NODE_TYPES.SERVICE);
|
|
107
|
+
const services = serviceIds.map(id => {
|
|
108
|
+
const node = this.backend.engine.getNode(id);
|
|
109
|
+
if (!node)
|
|
110
|
+
return null;
|
|
111
|
+
return {
|
|
112
|
+
id: this.backend._bigIntToId(node.id),
|
|
113
|
+
type: 'SERVICE',
|
|
114
|
+
name: this.getNodeName(node),
|
|
115
|
+
exported: node.exported,
|
|
116
|
+
version: node.version,
|
|
117
|
+
};
|
|
118
|
+
}).filter(Boolean);
|
|
119
|
+
res.writeHead(200);
|
|
120
|
+
res.end(JSON.stringify(services));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* GET /api/node/:id
|
|
124
|
+
* Returns single node by ID
|
|
125
|
+
*/
|
|
126
|
+
async handleGetNode(req, res, nodeId) {
|
|
127
|
+
const node = this.backend.engine.getNode(this.backend._idToBigInt(nodeId));
|
|
128
|
+
if (!node) {
|
|
129
|
+
res.writeHead(404);
|
|
130
|
+
res.end(JSON.stringify({ error: 'Node not found' }));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
res.writeHead(200);
|
|
134
|
+
res.end(JSON.stringify({
|
|
135
|
+
id: this.backend._bigIntToId(node.id),
|
|
136
|
+
type: this.backend._numberToNodeType(node.kind),
|
|
137
|
+
name: this.getNodeName(node),
|
|
138
|
+
exported: node.exported,
|
|
139
|
+
version: node.version,
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* GET /api/node/:id/children
|
|
144
|
+
* Returns children via CONTAINS edges
|
|
145
|
+
*/
|
|
146
|
+
async handleGetChildren(req, res, nodeId) {
|
|
147
|
+
const nodeIdBigInt = this.backend._idToBigInt(nodeId);
|
|
148
|
+
// Check node exists
|
|
149
|
+
if (!this.backend.engine.nodeExists(nodeIdBigInt)) {
|
|
150
|
+
res.writeHead(404);
|
|
151
|
+
res.end(JSON.stringify({ error: 'Node not found' }));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
// Get outgoing CONTAINS edges
|
|
155
|
+
const edges = this.backend.engine.getOutgoingEdges(nodeIdBigInt, [EDGE_TYPES.CONTAINS]);
|
|
156
|
+
const children = edges.map(edge => {
|
|
157
|
+
const childNode = this.backend.engine.getNode(edge.dst);
|
|
158
|
+
if (!childNode)
|
|
159
|
+
return null;
|
|
160
|
+
return {
|
|
161
|
+
id: this.backend._bigIntToId(childNode.id),
|
|
162
|
+
type: this.backend._numberToNodeType(childNode.kind),
|
|
163
|
+
name: this.getNodeName(childNode),
|
|
164
|
+
exported: childNode.exported,
|
|
165
|
+
version: childNode.version,
|
|
166
|
+
};
|
|
167
|
+
}).filter(Boolean);
|
|
168
|
+
res.writeHead(200);
|
|
169
|
+
res.end(JSON.stringify({
|
|
170
|
+
nodeId,
|
|
171
|
+
childCount: children.length,
|
|
172
|
+
children
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* GET /api/node/:id/edges
|
|
177
|
+
* Returns all outgoing edges from node
|
|
178
|
+
*/
|
|
179
|
+
async handleGetEdges(req, res, nodeId) {
|
|
180
|
+
const nodeIdBigInt = this.backend._idToBigInt(nodeId);
|
|
181
|
+
// Check node exists
|
|
182
|
+
if (!this.backend.engine.nodeExists(nodeIdBigInt)) {
|
|
183
|
+
res.writeHead(404);
|
|
184
|
+
res.end(JSON.stringify({ error: 'Node not found' }));
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
// Get all outgoing edges
|
|
188
|
+
const edges = this.backend.engine.getOutgoingEdges(nodeIdBigInt, null);
|
|
189
|
+
const formattedEdges = edges.map(edge => ({
|
|
190
|
+
src: this.backend._bigIntToId(edge.src),
|
|
191
|
+
dst: this.backend._bigIntToId(edge.dst),
|
|
192
|
+
type: this.backend._numberToEdgeType(edge.etype),
|
|
193
|
+
version: edge.version,
|
|
194
|
+
}));
|
|
195
|
+
res.writeHead(200);
|
|
196
|
+
res.end(JSON.stringify({
|
|
197
|
+
nodeId,
|
|
198
|
+
edgeCount: formattedEdges.length,
|
|
199
|
+
edges: formattedEdges
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get node name from name_offset (TODO: implement string table lookup)
|
|
204
|
+
*/
|
|
205
|
+
getNodeName(node) {
|
|
206
|
+
// TODO: Lookup in string table
|
|
207
|
+
// For now return placeholder
|
|
208
|
+
return `Node_${node.id.toString().substring(0, 8)}`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GuaranteeAPI - CRUD API for contract-based guarantees
|
|
3
|
+
*
|
|
4
|
+
* Contract-based guarantees use JSON schema validation instead of Datalog rules.
|
|
5
|
+
* They have namespaced types: guarantee:queue, guarantee:api, guarantee:permission
|
|
6
|
+
*
|
|
7
|
+
* This API complements GuaranteeManager which handles Datalog-based GUARANTEE nodes.
|
|
8
|
+
*/
|
|
9
|
+
import { type GuaranteeNodeRecord, type GuaranteePriority, type GuaranteeStatus, type GuaranteeType } from '../core/nodes/GuaranteeNode.js';
|
|
10
|
+
/**
|
|
11
|
+
* Graph interface for GuaranteeAPI
|
|
12
|
+
*/
|
|
13
|
+
export interface GuaranteeGraphBackend {
|
|
14
|
+
addNode(node: Record<string, unknown>): Promise<void>;
|
|
15
|
+
getNode(id: string): Promise<Record<string, unknown> | null>;
|
|
16
|
+
deleteNode(id: string): Promise<void>;
|
|
17
|
+
queryNodes(filter: {
|
|
18
|
+
type: string;
|
|
19
|
+
}): AsyncIterable<Record<string, unknown>>;
|
|
20
|
+
addEdge(edge: {
|
|
21
|
+
type: string;
|
|
22
|
+
src: string;
|
|
23
|
+
dst: string;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
deleteEdge(src: string, dst: string, type: string): Promise<void>;
|
|
26
|
+
getOutgoingEdges(nodeId: string, types: string[]): Promise<Array<{
|
|
27
|
+
src: string;
|
|
28
|
+
dst: string;
|
|
29
|
+
type: string;
|
|
30
|
+
}>>;
|
|
31
|
+
getIncomingEdges(nodeId: string, types: string[]): Promise<Array<{
|
|
32
|
+
src: string;
|
|
33
|
+
dst: string;
|
|
34
|
+
type: string;
|
|
35
|
+
}>>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Input for creating a guarantee
|
|
39
|
+
*/
|
|
40
|
+
export interface CreateGuaranteeInput {
|
|
41
|
+
type: 'guarantee:queue' | 'guarantee:api' | 'guarantee:permission';
|
|
42
|
+
name: string;
|
|
43
|
+
priority?: GuaranteePriority;
|
|
44
|
+
status?: GuaranteeStatus;
|
|
45
|
+
owner?: string;
|
|
46
|
+
schema?: Record<string, unknown>;
|
|
47
|
+
condition?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
governs?: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Input for updating a guarantee
|
|
53
|
+
*/
|
|
54
|
+
export interface UpdateGuaranteeInput {
|
|
55
|
+
priority?: GuaranteePriority;
|
|
56
|
+
status?: GuaranteeStatus;
|
|
57
|
+
owner?: string;
|
|
58
|
+
schema?: Record<string, unknown>;
|
|
59
|
+
condition?: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Filter for finding guarantees
|
|
64
|
+
*/
|
|
65
|
+
export interface GuaranteeFilter {
|
|
66
|
+
type?: GuaranteeType | GuaranteeType[];
|
|
67
|
+
priority?: GuaranteePriority | GuaranteePriority[];
|
|
68
|
+
status?: GuaranteeStatus | GuaranteeStatus[];
|
|
69
|
+
owner?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Result of checking a guarantee
|
|
73
|
+
*/
|
|
74
|
+
export interface CheckGuaranteeResult {
|
|
75
|
+
id: string;
|
|
76
|
+
name: string;
|
|
77
|
+
passed: boolean;
|
|
78
|
+
errors: string[];
|
|
79
|
+
validatedCount: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* GuaranteeAPI - CRUD operations for contract-based guarantees
|
|
83
|
+
*/
|
|
84
|
+
export declare class GuaranteeAPI {
|
|
85
|
+
private graph;
|
|
86
|
+
private schemaCache;
|
|
87
|
+
constructor(graph: GuaranteeGraphBackend);
|
|
88
|
+
/**
|
|
89
|
+
* Create a new contract-based guarantee
|
|
90
|
+
*/
|
|
91
|
+
createGuarantee(input: CreateGuaranteeInput): Promise<GuaranteeNodeRecord>;
|
|
92
|
+
/**
|
|
93
|
+
* Get a guarantee by ID
|
|
94
|
+
*/
|
|
95
|
+
getGuarantee(id: string): Promise<GuaranteeNodeRecord | null>;
|
|
96
|
+
/**
|
|
97
|
+
* Find guarantees matching filter
|
|
98
|
+
*/
|
|
99
|
+
findGuarantees(filter?: GuaranteeFilter): Promise<GuaranteeNodeRecord[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Update a guarantee
|
|
102
|
+
*/
|
|
103
|
+
updateGuarantee(id: string, updates: UpdateGuaranteeInput): Promise<GuaranteeNodeRecord>;
|
|
104
|
+
/**
|
|
105
|
+
* Delete a guarantee
|
|
106
|
+
*/
|
|
107
|
+
deleteGuarantee(id: string): Promise<boolean>;
|
|
108
|
+
/**
|
|
109
|
+
* Add GOVERNS edge from guarantee to a node
|
|
110
|
+
*/
|
|
111
|
+
addGoverns(guaranteeId: string, nodeId: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Remove GOVERNS edge
|
|
114
|
+
*/
|
|
115
|
+
removeGoverns(guaranteeId: string, nodeId: string): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Get nodes governed by a guarantee
|
|
118
|
+
*/
|
|
119
|
+
getGoverned(guaranteeId: string): Promise<string[]>;
|
|
120
|
+
/**
|
|
121
|
+
* Get guarantees governing a node
|
|
122
|
+
*/
|
|
123
|
+
getGoverningGuarantees(nodeId: string): Promise<GuaranteeNodeRecord[]>;
|
|
124
|
+
/**
|
|
125
|
+
* Check a guarantee using JSON schema validation
|
|
126
|
+
* Returns validation results for governed nodes
|
|
127
|
+
*/
|
|
128
|
+
checkGuarantee(id: string): Promise<CheckGuaranteeResult>;
|
|
129
|
+
/**
|
|
130
|
+
* Check all guarantees
|
|
131
|
+
*/
|
|
132
|
+
checkAllGuarantees(): Promise<{
|
|
133
|
+
total: number;
|
|
134
|
+
passed: number;
|
|
135
|
+
failed: number;
|
|
136
|
+
results: CheckGuaranteeResult[];
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Normalize type filter to array of types
|
|
140
|
+
*/
|
|
141
|
+
private normalizeTypeFilter;
|
|
142
|
+
/**
|
|
143
|
+
* Clear schema cache (useful after schema updates)
|
|
144
|
+
*/
|
|
145
|
+
clearSchemaCache(): void;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=GuaranteeAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GuaranteeAPI.d.ts","sourceRoot":"","sources":["../../src/api/GuaranteeAPI.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GuaranteeAPI - CRUD API for contract-based guarantees
|
|
3
|
+
*
|
|
4
|
+
* Contract-based guarantees use JSON schema validation instead of Datalog rules.
|
|
5
|
+
* They have namespaced types: guarantee:queue, guarantee:api, guarantee:permission
|
|
6
|
+
*
|
|
7
|
+
* This API complements GuaranteeManager which handles Datalog-based GUARANTEE nodes.
|
|
8
|
+
*/
|
|
9
|
+
import { GuaranteeNode } from '../core/nodes/GuaranteeNode.js';
|
|
10
|
+
// Lazy-loaded Ajv instance to avoid import issues
|
|
11
|
+
let ajvInstance = null;
|
|
12
|
+
async function getAjv() {
|
|
13
|
+
if (!ajvInstance) {
|
|
14
|
+
const AjvModule = await import('ajv');
|
|
15
|
+
// Handle both ESM default export and CJS module.exports
|
|
16
|
+
const AjvClass = AjvModule.default || AjvModule;
|
|
17
|
+
// Use Function constructor pattern to avoid TS2351
|
|
18
|
+
const createAjv = AjvClass;
|
|
19
|
+
ajvInstance = new createAjv({ allErrors: true });
|
|
20
|
+
}
|
|
21
|
+
return ajvInstance;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* GuaranteeAPI - CRUD operations for contract-based guarantees
|
|
25
|
+
*/
|
|
26
|
+
export class GuaranteeAPI {
|
|
27
|
+
graph;
|
|
28
|
+
schemaCache;
|
|
29
|
+
constructor(graph) {
|
|
30
|
+
this.graph = graph;
|
|
31
|
+
this.schemaCache = new Map();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a new contract-based guarantee
|
|
35
|
+
*/
|
|
36
|
+
async createGuarantee(input) {
|
|
37
|
+
// Parse type to get namespace
|
|
38
|
+
const parsed = GuaranteeNode.parseId(`${input.type}#${input.name}`);
|
|
39
|
+
if (!parsed) {
|
|
40
|
+
throw new Error(`Invalid guarantee type: ${input.type}`);
|
|
41
|
+
}
|
|
42
|
+
// Create the guarantee node
|
|
43
|
+
const node = GuaranteeNode.create(parsed.namespace, input.name, {
|
|
44
|
+
priority: input.priority,
|
|
45
|
+
status: input.status,
|
|
46
|
+
owner: input.owner,
|
|
47
|
+
schema: input.schema,
|
|
48
|
+
condition: input.condition,
|
|
49
|
+
description: input.description,
|
|
50
|
+
});
|
|
51
|
+
// Validate before saving
|
|
52
|
+
const errors = GuaranteeNode.validate(node);
|
|
53
|
+
if (errors.length > 0) {
|
|
54
|
+
throw new Error(`Invalid guarantee: ${errors.join(', ')}`);
|
|
55
|
+
}
|
|
56
|
+
// Save to graph
|
|
57
|
+
await this.graph.addNode(node);
|
|
58
|
+
// Create GOVERNS edges if specified
|
|
59
|
+
if (input.governs && input.governs.length > 0) {
|
|
60
|
+
for (const targetId of input.governs) {
|
|
61
|
+
await this.addGoverns(node.id, targetId);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return node;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get a guarantee by ID
|
|
68
|
+
*/
|
|
69
|
+
async getGuarantee(id) {
|
|
70
|
+
const node = await this.graph.getNode(id);
|
|
71
|
+
if (!node)
|
|
72
|
+
return null;
|
|
73
|
+
// Verify it's a guarantee type
|
|
74
|
+
if (!GuaranteeNode.isGuaranteeType(node.type)) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return node;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Find guarantees matching filter
|
|
81
|
+
*/
|
|
82
|
+
async findGuarantees(filter = {}) {
|
|
83
|
+
const guarantees = [];
|
|
84
|
+
const types = this.normalizeTypeFilter(filter.type);
|
|
85
|
+
for (const type of types) {
|
|
86
|
+
for await (const node of this.graph.queryNodes({ type })) {
|
|
87
|
+
const g = node;
|
|
88
|
+
// Apply additional filters
|
|
89
|
+
if (filter.priority) {
|
|
90
|
+
const priorities = Array.isArray(filter.priority) ? filter.priority : [filter.priority];
|
|
91
|
+
if (!priorities.includes(g.priority))
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (filter.status) {
|
|
95
|
+
const statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
|
|
96
|
+
if (!statuses.includes(g.status))
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (filter.owner && g.owner !== filter.owner)
|
|
100
|
+
continue;
|
|
101
|
+
guarantees.push(g);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return guarantees;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Update a guarantee
|
|
108
|
+
*/
|
|
109
|
+
async updateGuarantee(id, updates) {
|
|
110
|
+
const existing = await this.getGuarantee(id);
|
|
111
|
+
if (!existing) {
|
|
112
|
+
throw new Error(`Guarantee not found: ${id}`);
|
|
113
|
+
}
|
|
114
|
+
// Apply updates
|
|
115
|
+
const updated = {
|
|
116
|
+
...existing,
|
|
117
|
+
...updates,
|
|
118
|
+
updatedAt: Date.now(),
|
|
119
|
+
};
|
|
120
|
+
// Validate
|
|
121
|
+
const errors = GuaranteeNode.validate(updated);
|
|
122
|
+
if (errors.length > 0) {
|
|
123
|
+
throw new Error(`Invalid guarantee after update: ${errors.join(', ')}`);
|
|
124
|
+
}
|
|
125
|
+
// Delete old and add new (upsert)
|
|
126
|
+
await this.graph.deleteNode(id);
|
|
127
|
+
await this.graph.addNode(updated);
|
|
128
|
+
return updated;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Delete a guarantee
|
|
132
|
+
*/
|
|
133
|
+
async deleteGuarantee(id) {
|
|
134
|
+
const existing = await this.getGuarantee(id);
|
|
135
|
+
if (!existing) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
// Delete GOVERNS edges
|
|
139
|
+
const edges = await this.graph.getOutgoingEdges(id, ['GOVERNS']);
|
|
140
|
+
for (const edge of edges) {
|
|
141
|
+
await this.graph.deleteEdge(edge.src, edge.dst, 'GOVERNS');
|
|
142
|
+
}
|
|
143
|
+
// Delete the node
|
|
144
|
+
await this.graph.deleteNode(id);
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Add GOVERNS edge from guarantee to a node
|
|
149
|
+
*/
|
|
150
|
+
async addGoverns(guaranteeId, nodeId) {
|
|
151
|
+
// Verify guarantee exists
|
|
152
|
+
const guarantee = await this.getGuarantee(guaranteeId);
|
|
153
|
+
if (!guarantee) {
|
|
154
|
+
throw new Error(`Guarantee not found: ${guaranteeId}`);
|
|
155
|
+
}
|
|
156
|
+
// Verify target node exists
|
|
157
|
+
const targetNode = await this.graph.getNode(nodeId);
|
|
158
|
+
if (!targetNode) {
|
|
159
|
+
throw new Error(`Target node not found: ${nodeId}`);
|
|
160
|
+
}
|
|
161
|
+
// Create GOVERNS edge
|
|
162
|
+
await this.graph.addEdge({
|
|
163
|
+
type: 'GOVERNS',
|
|
164
|
+
src: guaranteeId,
|
|
165
|
+
dst: nodeId,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Remove GOVERNS edge
|
|
170
|
+
*/
|
|
171
|
+
async removeGoverns(guaranteeId, nodeId) {
|
|
172
|
+
await this.graph.deleteEdge(guaranteeId, nodeId, 'GOVERNS');
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get nodes governed by a guarantee
|
|
176
|
+
*/
|
|
177
|
+
async getGoverned(guaranteeId) {
|
|
178
|
+
const edges = await this.graph.getOutgoingEdges(guaranteeId, ['GOVERNS']);
|
|
179
|
+
return edges.map(e => e.dst);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get guarantees governing a node
|
|
183
|
+
*/
|
|
184
|
+
async getGoverningGuarantees(nodeId) {
|
|
185
|
+
const edges = await this.graph.getIncomingEdges(nodeId, ['GOVERNS']);
|
|
186
|
+
const guarantees = [];
|
|
187
|
+
for (const edge of edges) {
|
|
188
|
+
const g = await this.getGuarantee(edge.src);
|
|
189
|
+
if (g)
|
|
190
|
+
guarantees.push(g);
|
|
191
|
+
}
|
|
192
|
+
return guarantees;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Check a guarantee using JSON schema validation
|
|
196
|
+
* Returns validation results for governed nodes
|
|
197
|
+
*/
|
|
198
|
+
async checkGuarantee(id) {
|
|
199
|
+
const guarantee = await this.getGuarantee(id);
|
|
200
|
+
if (!guarantee) {
|
|
201
|
+
throw new Error(`Guarantee not found: ${id}`);
|
|
202
|
+
}
|
|
203
|
+
const result = {
|
|
204
|
+
id,
|
|
205
|
+
name: guarantee.name,
|
|
206
|
+
passed: true,
|
|
207
|
+
errors: [],
|
|
208
|
+
validatedCount: 0,
|
|
209
|
+
};
|
|
210
|
+
// If no schema defined, consider it passing
|
|
211
|
+
if (!guarantee.schema) {
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
// Get or compile schema validator
|
|
215
|
+
let validate = this.schemaCache.get(id);
|
|
216
|
+
if (!validate) {
|
|
217
|
+
try {
|
|
218
|
+
const ajv = await getAjv();
|
|
219
|
+
validate = ajv.compile(guarantee.schema);
|
|
220
|
+
this.schemaCache.set(id, validate);
|
|
221
|
+
}
|
|
222
|
+
catch (e) {
|
|
223
|
+
result.passed = false;
|
|
224
|
+
result.errors.push(`Invalid schema: ${e.message}`);
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// Get governed nodes and validate them
|
|
229
|
+
const governedIds = await this.getGoverned(id);
|
|
230
|
+
// At this point validate is guaranteed to be defined (we returned if compile failed)
|
|
231
|
+
const validator = validate;
|
|
232
|
+
for (const nodeId of governedIds) {
|
|
233
|
+
const node = await this.graph.getNode(nodeId);
|
|
234
|
+
if (!node)
|
|
235
|
+
continue;
|
|
236
|
+
result.validatedCount++;
|
|
237
|
+
const valid = validator(node);
|
|
238
|
+
if (!valid) {
|
|
239
|
+
result.passed = false;
|
|
240
|
+
const errors = validator.errors;
|
|
241
|
+
if (errors) {
|
|
242
|
+
for (const err of errors) {
|
|
243
|
+
result.errors.push(`${nodeId}: ${err.instancePath} ${err.message}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Check all guarantees
|
|
252
|
+
*/
|
|
253
|
+
async checkAllGuarantees() {
|
|
254
|
+
const guarantees = await this.findGuarantees();
|
|
255
|
+
const results = [];
|
|
256
|
+
let passed = 0;
|
|
257
|
+
let failed = 0;
|
|
258
|
+
for (const g of guarantees) {
|
|
259
|
+
const result = await this.checkGuarantee(g.id);
|
|
260
|
+
results.push(result);
|
|
261
|
+
if (result.passed)
|
|
262
|
+
passed++;
|
|
263
|
+
else
|
|
264
|
+
failed++;
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
total: guarantees.length,
|
|
268
|
+
passed,
|
|
269
|
+
failed,
|
|
270
|
+
results,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Normalize type filter to array of types
|
|
275
|
+
*/
|
|
276
|
+
normalizeTypeFilter(type) {
|
|
277
|
+
if (!type) {
|
|
278
|
+
return GuaranteeNode.getTypes();
|
|
279
|
+
}
|
|
280
|
+
return Array.isArray(type) ? type : [type];
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Clear schema cache (useful after schema updates)
|
|
284
|
+
*/
|
|
285
|
+
clearSchemaCache() {
|
|
286
|
+
this.schemaCache.clear();
|
|
287
|
+
}
|
|
288
|
+
}
|