@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,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImportExportVisitor - handles import and export declarations
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - ImportDeclaration: import { foo } from './module'
|
|
6
|
+
* - ExportDefaultDeclaration: export default foo
|
|
7
|
+
* - ExportNamedDeclaration: export { foo, bar }
|
|
8
|
+
* - ExportAllDeclaration: export * from './module'
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
ImportDeclaration,
|
|
13
|
+
ExportDefaultDeclaration,
|
|
14
|
+
ExportNamedDeclaration,
|
|
15
|
+
ExportAllDeclaration,
|
|
16
|
+
ImportSpecifier,
|
|
17
|
+
ImportDefaultSpecifier,
|
|
18
|
+
ImportNamespaceSpecifier,
|
|
19
|
+
ExportSpecifier,
|
|
20
|
+
VariableDeclaration,
|
|
21
|
+
FunctionDeclaration,
|
|
22
|
+
ClassDeclaration,
|
|
23
|
+
Identifier,
|
|
24
|
+
Node
|
|
25
|
+
} from '@babel/types';
|
|
26
|
+
import type { NodePath } from '@babel/traverse';
|
|
27
|
+
import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers } from './ASTVisitor.js';
|
|
28
|
+
import type { VariableInfo } from './VariableVisitor.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Callback type for extracting variable names from patterns
|
|
32
|
+
*/
|
|
33
|
+
export type ExtractVariableNamesCallback = (pattern: Node) => VariableInfo[];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Import specifier info
|
|
37
|
+
*/
|
|
38
|
+
interface ImportSpecifierInfo {
|
|
39
|
+
imported: string;
|
|
40
|
+
local: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Import info
|
|
45
|
+
*/
|
|
46
|
+
interface ImportInfo {
|
|
47
|
+
source: string;
|
|
48
|
+
specifiers: ImportSpecifierInfo[];
|
|
49
|
+
line: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Export specifier info
|
|
54
|
+
*/
|
|
55
|
+
interface ExportSpecifierInfo {
|
|
56
|
+
exported: string;
|
|
57
|
+
local: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Export info
|
|
62
|
+
*/
|
|
63
|
+
interface ExportInfo {
|
|
64
|
+
type: 'default' | 'named' | 'all';
|
|
65
|
+
line: number;
|
|
66
|
+
declaration?: Node;
|
|
67
|
+
specifiers?: ExportSpecifierInfo[];
|
|
68
|
+
source?: string;
|
|
69
|
+
name?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export class ImportExportVisitor extends ASTVisitor {
|
|
73
|
+
private extractVariableNamesFromPattern: ExtractVariableNamesCallback;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param module - Current module being analyzed
|
|
77
|
+
* @param collections - Must contain 'imports' and 'exports' arrays
|
|
78
|
+
* @param extractVariableNamesFromPattern - Helper from JSASTAnalyzer
|
|
79
|
+
*/
|
|
80
|
+
constructor(
|
|
81
|
+
module: VisitorModule,
|
|
82
|
+
collections: VisitorCollections,
|
|
83
|
+
extractVariableNamesFromPattern: ExtractVariableNamesCallback
|
|
84
|
+
) {
|
|
85
|
+
super(module, collections);
|
|
86
|
+
this.extractVariableNamesFromPattern = extractVariableNamesFromPattern;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
getImportHandlers(): VisitorHandlers {
|
|
90
|
+
const { imports } = this.collections;
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
ImportDeclaration: (path: NodePath) => {
|
|
94
|
+
const node = path.node as ImportDeclaration;
|
|
95
|
+
const source = node.source.value;
|
|
96
|
+
|
|
97
|
+
// Collect imported names
|
|
98
|
+
const specifiers: ImportSpecifierInfo[] = [];
|
|
99
|
+
node.specifiers.forEach((spec) => {
|
|
100
|
+
if (spec.type === 'ImportSpecifier') {
|
|
101
|
+
// import { foo, bar } from './module'
|
|
102
|
+
const importSpec = spec as ImportSpecifier;
|
|
103
|
+
const importedName = importSpec.imported.type === 'Identifier'
|
|
104
|
+
? importSpec.imported.name
|
|
105
|
+
: importSpec.imported.value;
|
|
106
|
+
specifiers.push({
|
|
107
|
+
imported: importedName,
|
|
108
|
+
local: importSpec.local.name
|
|
109
|
+
});
|
|
110
|
+
} else if (spec.type === 'ImportDefaultSpecifier') {
|
|
111
|
+
// import foo from './module'
|
|
112
|
+
const defaultSpec = spec as ImportDefaultSpecifier;
|
|
113
|
+
specifiers.push({
|
|
114
|
+
imported: 'default',
|
|
115
|
+
local: defaultSpec.local.name
|
|
116
|
+
});
|
|
117
|
+
} else if (spec.type === 'ImportNamespaceSpecifier') {
|
|
118
|
+
// import * as foo from './module'
|
|
119
|
+
const namespaceSpec = spec as ImportNamespaceSpecifier;
|
|
120
|
+
specifiers.push({
|
|
121
|
+
imported: '*',
|
|
122
|
+
local: namespaceSpec.local.name
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
(imports as ImportInfo[]).push({
|
|
128
|
+
source,
|
|
129
|
+
specifiers,
|
|
130
|
+
line: node.loc!.start.line
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
getExportHandlers(): VisitorHandlers {
|
|
137
|
+
const { exports } = this.collections;
|
|
138
|
+
const extractVariableNamesFromPattern = this.extractVariableNamesFromPattern;
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
ExportDefaultDeclaration: (path: NodePath) => {
|
|
142
|
+
const node = path.node as ExportDefaultDeclaration;
|
|
143
|
+
|
|
144
|
+
(exports as ExportInfo[]).push({
|
|
145
|
+
type: 'default',
|
|
146
|
+
line: node.loc!.start.line,
|
|
147
|
+
declaration: node.declaration
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
ExportNamedDeclaration: (path: NodePath) => {
|
|
152
|
+
const node = path.node as ExportNamedDeclaration;
|
|
153
|
+
|
|
154
|
+
// export { foo, bar } from './module'
|
|
155
|
+
if (node.source) {
|
|
156
|
+
const specifiers: ExportSpecifierInfo[] = node.specifiers.map((spec) => {
|
|
157
|
+
const exportSpec = spec as ExportSpecifier;
|
|
158
|
+
const exportedName = exportSpec.exported.type === 'Identifier'
|
|
159
|
+
? exportSpec.exported.name
|
|
160
|
+
: exportSpec.exported.value;
|
|
161
|
+
const localName = exportSpec.local.type === 'Identifier'
|
|
162
|
+
? exportSpec.local.name
|
|
163
|
+
: exportedName;
|
|
164
|
+
return {
|
|
165
|
+
exported: exportedName,
|
|
166
|
+
local: localName
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
(exports as ExportInfo[]).push({
|
|
171
|
+
type: 'named',
|
|
172
|
+
line: node.loc!.start.line,
|
|
173
|
+
specifiers,
|
|
174
|
+
source: node.source.value
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// export { foo, bar }
|
|
178
|
+
else if (node.specifiers.length > 0) {
|
|
179
|
+
const specifiers: ExportSpecifierInfo[] = node.specifiers.map((spec) => {
|
|
180
|
+
const exportSpec = spec as ExportSpecifier;
|
|
181
|
+
const exportedName = exportSpec.exported.type === 'Identifier'
|
|
182
|
+
? exportSpec.exported.name
|
|
183
|
+
: exportSpec.exported.value;
|
|
184
|
+
return {
|
|
185
|
+
exported: exportedName,
|
|
186
|
+
local: exportSpec.local.name
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
(exports as ExportInfo[]).push({
|
|
191
|
+
type: 'named',
|
|
192
|
+
line: node.loc!.start.line,
|
|
193
|
+
specifiers
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// export const foo = 42 or export function bar() {}
|
|
197
|
+
else if (node.declaration) {
|
|
198
|
+
const declaration = node.declaration;
|
|
199
|
+
|
|
200
|
+
// export function foo() {}
|
|
201
|
+
if (declaration.type === 'FunctionDeclaration') {
|
|
202
|
+
const funcDecl = declaration as FunctionDeclaration;
|
|
203
|
+
if (funcDecl.id) {
|
|
204
|
+
(exports as ExportInfo[]).push({
|
|
205
|
+
type: 'named',
|
|
206
|
+
line: node.loc!.start.line,
|
|
207
|
+
name: funcDecl.id.name
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// export const foo = 42, bar = 43
|
|
212
|
+
else if (declaration.type === 'VariableDeclaration') {
|
|
213
|
+
const varDecl = declaration as VariableDeclaration;
|
|
214
|
+
varDecl.declarations.forEach((declarator) => {
|
|
215
|
+
// Handle destructuring: export const { a, b } = obj
|
|
216
|
+
const variables = extractVariableNamesFromPattern(declarator.id);
|
|
217
|
+
variables.forEach((varInfo: VariableInfo) => {
|
|
218
|
+
(exports as ExportInfo[]).push({
|
|
219
|
+
type: 'named',
|
|
220
|
+
line: node.loc!.start.line,
|
|
221
|
+
name: varInfo.name
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
// export class Foo {}
|
|
227
|
+
else if (declaration.type === 'ClassDeclaration') {
|
|
228
|
+
const classDecl = declaration as ClassDeclaration;
|
|
229
|
+
if (classDecl.id) {
|
|
230
|
+
(exports as ExportInfo[]).push({
|
|
231
|
+
type: 'named',
|
|
232
|
+
line: node.loc!.start.line,
|
|
233
|
+
name: classDecl.id.name
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
ExportAllDeclaration: (path: NodePath) => {
|
|
241
|
+
const node = path.node as ExportAllDeclaration;
|
|
242
|
+
|
|
243
|
+
// export * from './module'
|
|
244
|
+
(exports as ExportInfo[]).push({
|
|
245
|
+
type: 'all',
|
|
246
|
+
line: node.loc!.start.line,
|
|
247
|
+
source: node.source.value
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
getHandlers(): VisitorHandlers {
|
|
254
|
+
return {
|
|
255
|
+
...this.getImportHandlers(),
|
|
256
|
+
...this.getExportHandlers()
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScriptVisitor - handles TypeScript-specific AST nodes
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - TSInterfaceDeclaration
|
|
6
|
+
* - TSTypeAliasDeclaration
|
|
7
|
+
* - TSEnumDeclaration
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
TSInterfaceDeclaration,
|
|
12
|
+
TSTypeAliasDeclaration,
|
|
13
|
+
TSEnumDeclaration,
|
|
14
|
+
TSPropertySignature,
|
|
15
|
+
TSMethodSignature,
|
|
16
|
+
Identifier,
|
|
17
|
+
Expression,
|
|
18
|
+
TSExpressionWithTypeArguments
|
|
19
|
+
} from '@babel/types';
|
|
20
|
+
import type { NodePath } from '@babel/traverse';
|
|
21
|
+
import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers } from './ASTVisitor.js';
|
|
22
|
+
import type {
|
|
23
|
+
InterfaceDeclarationInfo,
|
|
24
|
+
InterfacePropertyInfo,
|
|
25
|
+
TypeAliasInfo,
|
|
26
|
+
EnumDeclarationInfo,
|
|
27
|
+
EnumMemberInfo
|
|
28
|
+
} from '../types.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Extracts a string representation of a TypeScript type node
|
|
32
|
+
*/
|
|
33
|
+
function typeNodeToString(node: unknown): string {
|
|
34
|
+
if (!node || typeof node !== 'object') return 'unknown';
|
|
35
|
+
|
|
36
|
+
const typeNode = node as { type: string; [key: string]: unknown };
|
|
37
|
+
|
|
38
|
+
switch (typeNode.type) {
|
|
39
|
+
case 'TSStringKeyword':
|
|
40
|
+
return 'string';
|
|
41
|
+
case 'TSNumberKeyword':
|
|
42
|
+
return 'number';
|
|
43
|
+
case 'TSBooleanKeyword':
|
|
44
|
+
return 'boolean';
|
|
45
|
+
case 'TSAnyKeyword':
|
|
46
|
+
return 'any';
|
|
47
|
+
case 'TSUnknownKeyword':
|
|
48
|
+
return 'unknown';
|
|
49
|
+
case 'TSVoidKeyword':
|
|
50
|
+
return 'void';
|
|
51
|
+
case 'TSNullKeyword':
|
|
52
|
+
return 'null';
|
|
53
|
+
case 'TSUndefinedKeyword':
|
|
54
|
+
return 'undefined';
|
|
55
|
+
case 'TSNeverKeyword':
|
|
56
|
+
return 'never';
|
|
57
|
+
case 'TSObjectKeyword':
|
|
58
|
+
return 'object';
|
|
59
|
+
case 'TSSymbolKeyword':
|
|
60
|
+
return 'symbol';
|
|
61
|
+
case 'TSBigIntKeyword':
|
|
62
|
+
return 'bigint';
|
|
63
|
+
case 'TSTypeReference':
|
|
64
|
+
const typeName = typeNode.typeName as { type: string; name?: string };
|
|
65
|
+
if (typeName?.type === 'Identifier') {
|
|
66
|
+
return typeName.name || 'unknown';
|
|
67
|
+
}
|
|
68
|
+
return 'unknown';
|
|
69
|
+
case 'TSArrayType':
|
|
70
|
+
return `${typeNodeToString(typeNode.elementType)}[]`;
|
|
71
|
+
case 'TSUnionType':
|
|
72
|
+
const unionTypes = typeNode.types as unknown[];
|
|
73
|
+
return unionTypes.map(t => typeNodeToString(t)).join(' | ');
|
|
74
|
+
case 'TSIntersectionType':
|
|
75
|
+
const intersectionTypes = typeNode.types as unknown[];
|
|
76
|
+
return intersectionTypes.map(t => typeNodeToString(t)).join(' & ');
|
|
77
|
+
case 'TSLiteralType':
|
|
78
|
+
const literal = typeNode.literal as { value?: unknown; type: string };
|
|
79
|
+
if (literal?.type === 'StringLiteral') {
|
|
80
|
+
return `'${literal.value}'`;
|
|
81
|
+
} else if (literal?.type === 'NumericLiteral') {
|
|
82
|
+
return String(literal.value);
|
|
83
|
+
} else if (literal?.type === 'BooleanLiteral') {
|
|
84
|
+
return String(literal.value);
|
|
85
|
+
}
|
|
86
|
+
return 'unknown';
|
|
87
|
+
case 'TSFunctionType':
|
|
88
|
+
return 'function';
|
|
89
|
+
case 'TSTupleType':
|
|
90
|
+
const tupleTypes = typeNode.elementTypes as unknown[];
|
|
91
|
+
return `[${tupleTypes.map(t => typeNodeToString(t)).join(', ')}]`;
|
|
92
|
+
case 'TSTypeLiteral':
|
|
93
|
+
return 'object';
|
|
94
|
+
default:
|
|
95
|
+
return 'unknown';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class TypeScriptVisitor extends ASTVisitor {
|
|
100
|
+
constructor(module: VisitorModule, collections: VisitorCollections) {
|
|
101
|
+
super(module, collections);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getHandlers(): VisitorHandlers {
|
|
105
|
+
const { module } = this;
|
|
106
|
+
const {
|
|
107
|
+
interfaces,
|
|
108
|
+
typeAliases,
|
|
109
|
+
enums
|
|
110
|
+
} = this.collections;
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
TSInterfaceDeclaration: (path: NodePath) => {
|
|
114
|
+
const node = path.node as TSInterfaceDeclaration;
|
|
115
|
+
if (!node.id) return;
|
|
116
|
+
|
|
117
|
+
const interfaceName = node.id.name;
|
|
118
|
+
const interfaceId = `INTERFACE#${interfaceName}#${module.file}#${node.loc!.start.line}`;
|
|
119
|
+
|
|
120
|
+
// Extract extends
|
|
121
|
+
const extendsNames: string[] = [];
|
|
122
|
+
if (node.extends && node.extends.length > 0) {
|
|
123
|
+
for (const ext of node.extends) {
|
|
124
|
+
if (ext.expression.type === 'Identifier') {
|
|
125
|
+
extendsNames.push((ext.expression as Identifier).name);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Extract properties
|
|
131
|
+
const properties: InterfacePropertyInfo[] = [];
|
|
132
|
+
if (node.body && node.body.body) {
|
|
133
|
+
for (const member of node.body.body) {
|
|
134
|
+
if (member.type === 'TSPropertySignature') {
|
|
135
|
+
const prop = member as TSPropertySignature;
|
|
136
|
+
if (prop.key.type === 'Identifier') {
|
|
137
|
+
properties.push({
|
|
138
|
+
name: (prop.key as Identifier).name,
|
|
139
|
+
type: prop.typeAnnotation ? typeNodeToString(prop.typeAnnotation.typeAnnotation) : undefined,
|
|
140
|
+
optional: prop.optional || false,
|
|
141
|
+
readonly: prop.readonly || false
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
} else if (member.type === 'TSMethodSignature') {
|
|
145
|
+
const method = member as TSMethodSignature;
|
|
146
|
+
if (method.key.type === 'Identifier') {
|
|
147
|
+
properties.push({
|
|
148
|
+
name: (method.key as Identifier).name,
|
|
149
|
+
type: 'function',
|
|
150
|
+
optional: method.optional || false,
|
|
151
|
+
readonly: false
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
(interfaces as InterfaceDeclarationInfo[]).push({
|
|
159
|
+
id: interfaceId,
|
|
160
|
+
type: 'INTERFACE',
|
|
161
|
+
name: interfaceName,
|
|
162
|
+
file: module.file,
|
|
163
|
+
line: node.loc!.start.line,
|
|
164
|
+
column: node.loc!.start.column,
|
|
165
|
+
extends: extendsNames.length > 0 ? extendsNames : undefined,
|
|
166
|
+
properties
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
TSTypeAliasDeclaration: (path: NodePath) => {
|
|
171
|
+
const node = path.node as TSTypeAliasDeclaration;
|
|
172
|
+
if (!node.id) return;
|
|
173
|
+
|
|
174
|
+
const typeName = node.id.name;
|
|
175
|
+
const typeId = `TYPE#${typeName}#${module.file}#${node.loc!.start.line}`;
|
|
176
|
+
|
|
177
|
+
// Extract the type being aliased
|
|
178
|
+
const aliasOf = typeNodeToString(node.typeAnnotation);
|
|
179
|
+
|
|
180
|
+
(typeAliases as TypeAliasInfo[]).push({
|
|
181
|
+
id: typeId,
|
|
182
|
+
type: 'TYPE',
|
|
183
|
+
name: typeName,
|
|
184
|
+
file: module.file,
|
|
185
|
+
line: node.loc!.start.line,
|
|
186
|
+
column: node.loc!.start.column,
|
|
187
|
+
aliasOf
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
TSEnumDeclaration: (path: NodePath) => {
|
|
192
|
+
const node = path.node as TSEnumDeclaration;
|
|
193
|
+
if (!node.id) return;
|
|
194
|
+
|
|
195
|
+
const enumName = node.id.name;
|
|
196
|
+
const enumId = `ENUM#${enumName}#${module.file}#${node.loc!.start.line}`;
|
|
197
|
+
|
|
198
|
+
// Extract members
|
|
199
|
+
const members: EnumMemberInfo[] = [];
|
|
200
|
+
if (node.members) {
|
|
201
|
+
for (const member of node.members) {
|
|
202
|
+
if (member.id.type === 'Identifier') {
|
|
203
|
+
const memberInfo: EnumMemberInfo = {
|
|
204
|
+
name: (member.id as Identifier).name
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// Extract value if present
|
|
208
|
+
if (member.initializer) {
|
|
209
|
+
const init = member.initializer as Expression;
|
|
210
|
+
if (init.type === 'StringLiteral') {
|
|
211
|
+
memberInfo.value = (init as { value: string }).value;
|
|
212
|
+
} else if (init.type === 'NumericLiteral') {
|
|
213
|
+
memberInfo.value = (init as { value: number }).value;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
members.push(memberInfo);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
(enums as EnumDeclarationInfo[]).push({
|
|
223
|
+
id: enumId,
|
|
224
|
+
type: 'ENUM',
|
|
225
|
+
name: enumName,
|
|
226
|
+
file: module.file,
|
|
227
|
+
line: node.loc!.start.line,
|
|
228
|
+
column: node.loc!.start.column,
|
|
229
|
+
isConst: node.const || false,
|
|
230
|
+
members
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|