@grafema/core 0.1.1-alpha → 0.2.0-beta
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/dist/Orchestrator.d.ts +7 -0
- package/dist/Orchestrator.d.ts.map +1 -1
- package/dist/Orchestrator.js +25 -3
- package/dist/config/ConfigLoader.d.ts +18 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -1
- package/dist/config/ConfigLoader.js +65 -3
- package/dist/core/FileExplainer.d.ts +101 -0
- package/dist/core/FileExplainer.d.ts.map +1 -0
- package/dist/core/FileExplainer.js +139 -0
- package/dist/core/NodeFactory.d.ts +44 -5
- package/dist/core/NodeFactory.d.ts.map +1 -1
- package/dist/core/NodeFactory.js +52 -7
- package/dist/core/nodes/ArrayLiteralNode.d.ts.map +1 -1
- package/dist/core/nodes/ArrayLiteralNode.js +4 -2
- package/dist/core/nodes/BranchNode.d.ts +41 -0
- package/dist/core/nodes/BranchNode.d.ts.map +1 -0
- package/dist/core/nodes/BranchNode.js +82 -0
- package/dist/core/nodes/CallSiteNode.d.ts +2 -2
- package/dist/core/nodes/CallSiteNode.d.ts.map +1 -1
- package/dist/core/nodes/CallSiteNode.js +9 -5
- package/dist/core/nodes/CaseNode.d.ts +43 -0
- package/dist/core/nodes/CaseNode.d.ts.map +1 -0
- package/dist/core/nodes/CaseNode.js +81 -0
- package/dist/core/nodes/ClassNode.d.ts +2 -2
- package/dist/core/nodes/ClassNode.d.ts.map +1 -1
- package/dist/core/nodes/ClassNode.js +8 -4
- package/dist/core/nodes/ConstantNode.d.ts +2 -2
- package/dist/core/nodes/ConstantNode.d.ts.map +1 -1
- package/dist/core/nodes/ConstantNode.js +6 -4
- package/dist/core/nodes/ConstructorCallNode.d.ts +51 -0
- package/dist/core/nodes/ConstructorCallNode.d.ts.map +1 -0
- package/dist/core/nodes/ConstructorCallNode.js +171 -0
- package/dist/core/nodes/DatabaseQueryNode.d.ts +3 -2
- package/dist/core/nodes/DatabaseQueryNode.d.ts.map +1 -1
- package/dist/core/nodes/DatabaseQueryNode.js +5 -2
- package/dist/core/nodes/DecoratorNode.d.ts +2 -2
- package/dist/core/nodes/DecoratorNode.d.ts.map +1 -1
- package/dist/core/nodes/DecoratorNode.js +5 -3
- package/dist/core/nodes/EnumNode.d.ts +2 -2
- package/dist/core/nodes/EnumNode.d.ts.map +1 -1
- package/dist/core/nodes/EnumNode.js +5 -3
- package/dist/core/nodes/EventListenerNode.d.ts +4 -4
- package/dist/core/nodes/EventListenerNode.d.ts.map +1 -1
- package/dist/core/nodes/EventListenerNode.js +7 -4
- package/dist/core/nodes/ExportNode.d.ts +2 -2
- package/dist/core/nodes/ExportNode.d.ts.map +1 -1
- package/dist/core/nodes/ExportNode.js +8 -4
- package/dist/core/nodes/ExpressionNode.d.ts +2 -2
- package/dist/core/nodes/ExpressionNode.d.ts.map +1 -1
- package/dist/core/nodes/ExpressionNode.js +6 -4
- package/dist/core/nodes/ExternalModuleNode.d.ts +4 -0
- package/dist/core/nodes/ExternalModuleNode.d.ts.map +1 -1
- package/dist/core/nodes/ExternalModuleNode.js +10 -2
- package/dist/core/nodes/HttpRequestNode.d.ts +4 -4
- package/dist/core/nodes/HttpRequestNode.d.ts.map +1 -1
- package/dist/core/nodes/HttpRequestNode.js +7 -4
- package/dist/core/nodes/ImportNode.d.ts +10 -2
- package/dist/core/nodes/ImportNode.d.ts.map +1 -1
- package/dist/core/nodes/ImportNode.js +21 -4
- package/dist/core/nodes/InterfaceNode.d.ts +2 -2
- package/dist/core/nodes/InterfaceNode.d.ts.map +1 -1
- package/dist/core/nodes/InterfaceNode.js +5 -3
- package/dist/core/nodes/LiteralNode.d.ts +2 -2
- package/dist/core/nodes/LiteralNode.d.ts.map +1 -1
- package/dist/core/nodes/LiteralNode.js +6 -4
- package/dist/core/nodes/MethodCallNode.d.ts +2 -2
- package/dist/core/nodes/MethodCallNode.d.ts.map +1 -1
- package/dist/core/nodes/MethodCallNode.js +9 -5
- package/dist/core/nodes/MethodNode.d.ts +2 -2
- package/dist/core/nodes/MethodNode.d.ts.map +1 -1
- package/dist/core/nodes/MethodNode.js +8 -4
- package/dist/core/nodes/ObjectLiteralNode.d.ts.map +1 -1
- package/dist/core/nodes/ObjectLiteralNode.js +4 -2
- package/dist/core/nodes/ParameterNode.d.ts +2 -2
- package/dist/core/nodes/ParameterNode.d.ts.map +1 -1
- package/dist/core/nodes/ParameterNode.js +5 -3
- package/dist/core/nodes/TypeNode.d.ts +2 -2
- package/dist/core/nodes/TypeNode.d.ts.map +1 -1
- package/dist/core/nodes/TypeNode.js +5 -3
- package/dist/core/nodes/VariableDeclarationNode.d.ts +2 -2
- package/dist/core/nodes/VariableDeclarationNode.d.ts.map +1 -1
- package/dist/core/nodes/VariableDeclarationNode.js +9 -5
- package/dist/core/nodes/index.d.ts +3 -0
- package/dist/core/nodes/index.d.ts.map +1 -1
- package/dist/core/nodes/index.js +3 -0
- package/dist/data/builtins/BuiltinRegistry.d.ts +78 -0
- package/dist/data/builtins/BuiltinRegistry.d.ts.map +1 -0
- package/dist/data/builtins/BuiltinRegistry.js +110 -0
- package/dist/data/builtins/definitions.d.ts +28 -0
- package/dist/data/builtins/definitions.d.ts.map +1 -0
- package/dist/data/builtins/definitions.js +250 -0
- package/dist/data/builtins/index.d.ts +10 -0
- package/dist/data/builtins/index.d.ts.map +1 -0
- package/dist/data/builtins/index.js +8 -0
- package/dist/data/builtins/jsGlobals.d.ts +18 -0
- package/dist/data/builtins/jsGlobals.d.ts.map +1 -0
- package/dist/data/builtins/jsGlobals.js +26 -0
- package/dist/data/builtins/types.d.ts +34 -0
- package/dist/data/builtins/types.d.ts.map +1 -0
- package/dist/data/builtins/types.js +7 -0
- package/dist/data/globals/definitions.d.ts +27 -0
- package/dist/data/globals/definitions.d.ts.map +1 -0
- package/dist/data/globals/definitions.js +117 -0
- package/dist/data/globals/index.d.ts +36 -0
- package/dist/data/globals/index.d.ts.map +1 -0
- package/dist/data/globals/index.js +52 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts +23 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts.map +1 -1
- package/dist/diagnostics/DiagnosticReporter.js +88 -0
- package/dist/diagnostics/index.d.ts +1 -1
- package/dist/diagnostics/index.d.ts.map +1 -1
- package/dist/errors/GrafemaError.d.ts +43 -0
- package/dist/errors/GrafemaError.d.ts.map +1 -1
- package/dist/errors/GrafemaError.js +50 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/DatabaseAnalyzer.js +3 -2
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ExpressAnalyzer.js +3 -1
- package/dist/plugins/analysis/ExpressResponseAnalyzer.d.ts +148 -0
- package/dist/plugins/analysis/ExpressResponseAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ExpressResponseAnalyzer.js +495 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ExpressRouteAnalyzer.js +53 -18
- package/dist/plugins/analysis/FetchAnalyzer.d.ts +40 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/FetchAnalyzer.js +163 -15
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts +157 -26
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/JSASTAnalyzer.js +2418 -191
- package/dist/plugins/analysis/RustAnalyzer.js +4 -4
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SQLiteAnalyzer.js +4 -2
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts +9 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SocketIOAnalyzer.js +91 -7
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts +173 -0
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/GraphBuilder.js +1256 -65
- package/dist/plugins/analysis/ast/types.d.ts +294 -0
- package/dist/plugins/analysis/ast/types.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts +5 -1
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts +1 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.js +12 -1
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts +10 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.js +62 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts +4 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.js +101 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts +16 -1
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.js +233 -39
- package/dist/plugins/discovery/WorkspaceDiscovery.d.ts.map +1 -1
- package/dist/plugins/discovery/WorkspaceDiscovery.js +9 -4
- package/dist/plugins/enrichment/AliasTracker.d.ts.map +1 -1
- package/dist/plugins/enrichment/AliasTracker.js +16 -1
- package/dist/plugins/enrichment/ArgumentParameterLinker.d.ts +32 -0
- package/dist/plugins/enrichment/ArgumentParameterLinker.d.ts.map +1 -0
- package/dist/plugins/enrichment/ArgumentParameterLinker.js +175 -0
- package/dist/plugins/enrichment/ClosureCaptureEnricher.d.ts +51 -0
- package/dist/plugins/enrichment/ClosureCaptureEnricher.d.ts.map +1 -0
- package/dist/plugins/enrichment/ClosureCaptureEnricher.js +205 -0
- package/dist/plugins/enrichment/ExternalCallResolver.d.ts +42 -0
- package/dist/plugins/enrichment/ExternalCallResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/ExternalCallResolver.js +213 -0
- package/dist/plugins/enrichment/FunctionCallResolver.d.ts +58 -0
- package/dist/plugins/enrichment/FunctionCallResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/FunctionCallResolver.js +340 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts +16 -3
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts.map +1 -1
- package/dist/plugins/enrichment/HTTPConnectionEnricher.js +64 -20
- package/dist/plugins/enrichment/MethodCallResolver.d.ts.map +1 -1
- package/dist/plugins/enrichment/MethodCallResolver.js +15 -1
- package/dist/plugins/enrichment/MountPointResolver.d.ts +14 -12
- package/dist/plugins/enrichment/MountPointResolver.d.ts.map +1 -1
- package/dist/plugins/enrichment/MountPointResolver.js +172 -151
- package/dist/plugins/enrichment/NodejsBuiltinsResolver.d.ts +44 -0
- package/dist/plugins/enrichment/NodejsBuiltinsResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/NodejsBuiltinsResolver.js +271 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts +5 -27
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts.map +1 -1
- package/dist/plugins/enrichment/ValueDomainAnalyzer.js +62 -139
- package/dist/plugins/indexing/JSModuleIndexer.d.ts +15 -0
- package/dist/plugins/indexing/JSModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/JSModuleIndexer.js +58 -0
- package/dist/plugins/indexing/RustModuleIndexer.d.ts +1 -1
- package/dist/plugins/indexing/RustModuleIndexer.js +4 -4
- package/dist/plugins/validation/BrokenImportValidator.d.ts +31 -0
- package/dist/plugins/validation/BrokenImportValidator.d.ts.map +1 -0
- package/dist/plugins/validation/BrokenImportValidator.js +249 -0
- package/dist/plugins/validation/CallResolverValidator.d.ts +21 -10
- package/dist/plugins/validation/CallResolverValidator.d.ts.map +1 -1
- package/dist/plugins/validation/CallResolverValidator.js +101 -76
- package/dist/plugins/validation/DataFlowValidator.d.ts.map +1 -1
- package/dist/plugins/validation/DataFlowValidator.js +49 -41
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts.map +1 -1
- package/dist/plugins/validation/GraphConnectivityValidator.js +25 -1
- package/dist/plugins/validation/SQLInjectionValidator.d.ts.map +1 -1
- package/dist/plugins/validation/SQLInjectionValidator.js +2 -3
- package/dist/queries/findCallsInFunction.d.ts +52 -0
- package/dist/queries/findCallsInFunction.d.ts.map +1 -0
- package/dist/queries/findCallsInFunction.js +135 -0
- package/dist/queries/findContainingFunction.d.ts +45 -0
- package/dist/queries/findContainingFunction.d.ts.map +1 -0
- package/dist/queries/findContainingFunction.js +54 -0
- package/dist/queries/index.d.ts +14 -0
- package/dist/queries/index.d.ts.map +1 -0
- package/dist/queries/index.js +11 -0
- package/dist/queries/traceValues.d.ts +70 -0
- package/dist/queries/traceValues.d.ts.map +1 -0
- package/dist/queries/traceValues.js +299 -0
- package/dist/queries/types.d.ts +163 -0
- package/dist/queries/types.d.ts.map +1 -0
- package/dist/queries/types.js +9 -0
- package/dist/schema/GraphSchemaExtractor.d.ts +53 -0
- package/dist/schema/GraphSchemaExtractor.d.ts.map +1 -0
- package/dist/schema/GraphSchemaExtractor.js +124 -0
- package/dist/schema/InterfaceSchemaExtractor.d.ts +73 -0
- package/dist/schema/InterfaceSchemaExtractor.d.ts.map +1 -0
- package/dist/schema/InterfaceSchemaExtractor.js +112 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +2 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts +12 -18
- package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -1
- package/dist/storage/backends/RFDBServerBackend.js +41 -52
- package/dist/storage/backends/typeValidation.d.ts.map +1 -1
- package/dist/storage/backends/typeValidation.js +1 -0
- package/package.json +3 -3
- package/src/Orchestrator.ts +35 -3
- package/src/config/ConfigLoader.ts +94 -3
- package/src/core/FileExplainer.ts +179 -0
- package/src/core/NodeFactory.ts +72 -8
- package/src/core/nodes/ArrayLiteralNode.ts +3 -2
- package/src/core/nodes/BranchNode.ts +113 -0
- package/src/core/nodes/CallSiteNode.ts +7 -5
- package/src/core/nodes/CaseNode.ts +123 -0
- package/src/core/nodes/ClassNode.ts +6 -4
- package/src/core/nodes/ConstantNode.ts +5 -4
- package/src/core/nodes/ConstructorCallNode.ts +217 -0
- package/src/core/nodes/DatabaseQueryNode.ts +5 -1
- package/src/core/nodes/DecoratorNode.ts +4 -3
- package/src/core/nodes/EnumNode.ts +4 -3
- package/src/core/nodes/EventListenerNode.ts +7 -4
- package/src/core/nodes/ExportNode.ts +6 -4
- package/src/core/nodes/ExpressionNode.ts +5 -4
- package/src/core/nodes/ExternalModuleNode.ts +11 -2
- package/src/core/nodes/HttpRequestNode.ts +7 -4
- package/src/core/nodes/ImportNode.ts +31 -4
- package/src/core/nodes/InterfaceNode.ts +4 -3
- package/src/core/nodes/LiteralNode.ts +5 -4
- package/src/core/nodes/MethodCallNode.ts +7 -5
- package/src/core/nodes/MethodNode.ts +6 -4
- package/src/core/nodes/ObjectLiteralNode.ts +3 -2
- package/src/core/nodes/ParameterNode.ts +4 -3
- package/src/core/nodes/TypeNode.ts +4 -3
- package/src/core/nodes/VariableDeclarationNode.ts +7 -5
- package/src/core/nodes/index.ts +3 -0
- package/src/data/builtins/BuiltinRegistry.ts +124 -0
- package/src/data/builtins/definitions.ts +267 -0
- package/src/data/builtins/index.ts +10 -0
- package/src/data/builtins/jsGlobals.ts +28 -0
- package/src/data/builtins/types.ts +36 -0
- package/src/data/globals/definitions.ts +156 -0
- package/src/data/globals/index.ts +66 -0
- package/src/diagnostics/DiagnosticReporter.ts +120 -0
- package/src/diagnostics/index.ts +1 -1
- package/src/errors/GrafemaError.ts +65 -0
- package/src/index.ts +45 -0
- package/src/plugins/analysis/DatabaseAnalyzer.ts +4 -2
- package/src/plugins/analysis/ExpressAnalyzer.ts +5 -1
- package/src/plugins/analysis/ExpressResponseAnalyzer.ts +636 -0
- package/src/plugins/analysis/ExpressRouteAnalyzer.ts +57 -18
- package/src/plugins/analysis/FetchAnalyzer.ts +204 -16
- package/src/plugins/analysis/JSASTAnalyzer.ts +2958 -260
- package/src/plugins/analysis/RustAnalyzer.ts +4 -4
- package/src/plugins/analysis/SQLiteAnalyzer.ts +5 -2
- package/src/plugins/analysis/SocketIOAnalyzer.ts +121 -7
- package/src/plugins/analysis/ast/GraphBuilder.ts +1578 -70
- package/src/plugins/analysis/ast/types.ts +387 -0
- package/src/plugins/analysis/ast/visitors/ASTVisitor.ts +8 -0
- package/src/plugins/analysis/ast/visitors/CallExpressionVisitor.ts +16 -1
- package/src/plugins/analysis/ast/visitors/FunctionVisitor.ts +77 -2
- package/src/plugins/analysis/ast/visitors/ImportExportVisitor.ts +112 -1
- package/src/plugins/analysis/ast/visitors/VariableVisitor.ts +272 -47
- package/src/plugins/discovery/WorkspaceDiscovery.ts +11 -4
- package/src/plugins/enrichment/AliasTracker.ts +22 -1
- package/src/plugins/enrichment/ArgumentParameterLinker.ts +240 -0
- package/src/plugins/enrichment/ClosureCaptureEnricher.ts +267 -0
- package/src/plugins/enrichment/ExternalCallResolver.ts +262 -0
- package/src/plugins/enrichment/FunctionCallResolver.ts +456 -0
- package/src/plugins/enrichment/HTTPConnectionEnricher.ts +70 -20
- package/src/plugins/enrichment/MethodCallResolver.ts +21 -1
- package/src/plugins/enrichment/MountPointResolver.ts +206 -198
- package/src/plugins/enrichment/NodejsBuiltinsResolver.ts +365 -0
- package/src/plugins/enrichment/ValueDomainAnalyzer.ts +67 -184
- package/src/plugins/indexing/JSModuleIndexer.ts +66 -0
- package/src/plugins/indexing/RustModuleIndexer.ts +4 -4
- package/src/plugins/validation/BrokenImportValidator.ts +325 -0
- package/src/plugins/validation/CallResolverValidator.ts +129 -109
- package/src/plugins/validation/DataFlowValidator.ts +75 -58
- package/src/plugins/validation/GraphConnectivityValidator.ts +39 -1
- package/src/plugins/validation/SQLInjectionValidator.ts +2 -5
- package/src/queries/README.md +46 -0
- package/src/queries/findCallsInFunction.ts +206 -0
- package/src/queries/findContainingFunction.ts +83 -0
- package/src/queries/index.ts +23 -0
- package/src/queries/traceValues.ts +398 -0
- package/src/queries/types.ts +187 -0
- package/src/schema/GraphSchemaExtractor.ts +177 -0
- package/src/schema/InterfaceSchemaExtractor.ts +173 -0
- package/src/schema/index.ts +5 -0
- package/src/storage/backends/RFDBServerBackend.ts +58 -70
- package/src/storage/backends/typeValidation.ts +1 -0
|
@@ -136,21 +136,21 @@ interface EdgeToAdd {
|
|
|
136
136
|
[key: string]: unknown;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
// NAPI binding - will be exported from
|
|
139
|
+
// NAPI binding - will be exported from packages/rfdb-server after build
|
|
140
140
|
let parseRustFile: ((code: string) => RustParseResult) | undefined;
|
|
141
141
|
|
|
142
142
|
// Try to load the native binding
|
|
143
|
-
// Path: from dist/plugins/analysis/ go up 5 levels to reach project root, then
|
|
143
|
+
// Path: from dist/plugins/analysis/ go up 5 levels to reach project root, then packages/rfdb-server/
|
|
144
144
|
try {
|
|
145
145
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
|
-
const nativeBinding = await import('../../../../../
|
|
146
|
+
const nativeBinding = await import('../../../../../packages/rfdb-server/grafema-graph-engine.node' as any);
|
|
147
147
|
parseRustFile = nativeBinding.parseRustFile;
|
|
148
148
|
} catch {
|
|
149
149
|
// Fallback: try require
|
|
150
150
|
try {
|
|
151
151
|
const { createRequire } = await import('module');
|
|
152
152
|
const require = createRequire(import.meta.url);
|
|
153
|
-
const nativeBinding = require('../../../../../
|
|
153
|
+
const nativeBinding = require('../../../../../packages/rfdb-server/grafema-graph-engine.node');
|
|
154
154
|
parseRustFile = nativeBinding.parseRustFile;
|
|
155
155
|
} catch {
|
|
156
156
|
// Silent - will be reported during execute if needed
|
|
@@ -16,7 +16,7 @@ import type { NodePath } from '@babel/traverse';
|
|
|
16
16
|
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
17
17
|
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
18
18
|
import type { NodeRecord } from '@grafema/types';
|
|
19
|
-
import { getLine } from './ast/utils/location.js';
|
|
19
|
+
import { getLine, getColumn } from './ast/utils/location.js';
|
|
20
20
|
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
const traverse = (traverseModule as any).default || traverseModule;
|
|
@@ -34,6 +34,7 @@ interface SQLiteQueryNode {
|
|
|
34
34
|
tableName: string | null;
|
|
35
35
|
file: string;
|
|
36
36
|
line: number;
|
|
37
|
+
column: number;
|
|
37
38
|
promiseWrapped?: boolean;
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -181,7 +182,8 @@ export class SQLiteAnalyzer extends Plugin {
|
|
|
181
182
|
operationType: operationType,
|
|
182
183
|
tableName: tableName,
|
|
183
184
|
file: module.file!,
|
|
184
|
-
line: getLine(node)
|
|
185
|
+
line: getLine(node),
|
|
186
|
+
column: getColumn(node)
|
|
185
187
|
});
|
|
186
188
|
}
|
|
187
189
|
}
|
|
@@ -254,6 +256,7 @@ export class SQLiteAnalyzer extends Plugin {
|
|
|
254
256
|
tableName: tableName,
|
|
255
257
|
file: module.file!,
|
|
256
258
|
line: getLine(innerNode),
|
|
259
|
+
column: getColumn(innerNode),
|
|
257
260
|
promiseWrapped: true
|
|
258
261
|
});
|
|
259
262
|
}
|
|
@@ -56,6 +56,7 @@ interface SocketListenerNode {
|
|
|
56
56
|
handlerLine: number;
|
|
57
57
|
file: string;
|
|
58
58
|
line: number;
|
|
59
|
+
column: number;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/**
|
|
@@ -68,6 +69,19 @@ interface SocketRoomNode {
|
|
|
68
69
|
objectName: string;
|
|
69
70
|
file: string;
|
|
70
71
|
line: number;
|
|
72
|
+
column: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Socket event channel node - represents a single event across all emitters/listeners
|
|
77
|
+
*/
|
|
78
|
+
interface SocketEventNode {
|
|
79
|
+
id: string;
|
|
80
|
+
type: 'socketio:event';
|
|
81
|
+
name: string; // Event name (e.g., "slot:booked")
|
|
82
|
+
event: string; // Same as name, for consistency
|
|
83
|
+
file?: string; // Not applicable - event is global
|
|
84
|
+
line?: number; // Not applicable
|
|
71
85
|
}
|
|
72
86
|
|
|
73
87
|
/**
|
|
@@ -86,8 +100,8 @@ export class SocketIOAnalyzer extends Plugin {
|
|
|
86
100
|
phase: 'ANALYSIS',
|
|
87
101
|
priority: 75, // После JSASTAnalyzer (80)
|
|
88
102
|
creates: {
|
|
89
|
-
nodes: ['socketio:emit', 'socketio:on', 'socketio:room'],
|
|
90
|
-
edges: ['CONTAINS', 'EMITS_EVENT', 'LISTENS_TO', 'JOINS_ROOM']
|
|
103
|
+
nodes: ['socketio:emit', 'socketio:on', 'socketio:room', 'socketio:event'],
|
|
104
|
+
edges: ['CONTAINS', 'EMITS_EVENT', 'LISTENS_TO', 'JOINS_ROOM', 'LISTENED_BY']
|
|
91
105
|
},
|
|
92
106
|
dependencies: ['JSModuleIndexer', 'JSASTAnalyzer']
|
|
93
107
|
};
|
|
@@ -108,6 +122,7 @@ export class SocketIOAnalyzer extends Plugin {
|
|
|
108
122
|
let roomsCount = 0;
|
|
109
123
|
const startTime = Date.now();
|
|
110
124
|
|
|
125
|
+
// PHASE 1: Analyze modules and create emit/listener/room nodes
|
|
111
126
|
for (let i = 0; i < modules.length; i++) {
|
|
112
127
|
const module = modules[i];
|
|
113
128
|
const result = await this.analyzeModule(module, graph);
|
|
@@ -128,14 +143,22 @@ export class SocketIOAnalyzer extends Plugin {
|
|
|
128
143
|
}
|
|
129
144
|
}
|
|
130
145
|
|
|
131
|
-
|
|
146
|
+
// PHASE 2: Create event channel nodes and edges
|
|
147
|
+
const eventCount = await this.createEventChannels(graph, logger);
|
|
148
|
+
|
|
149
|
+
logger.info('Analysis complete', {
|
|
150
|
+
emitsCount,
|
|
151
|
+
listenersCount,
|
|
152
|
+
roomsCount,
|
|
153
|
+
eventCount
|
|
154
|
+
});
|
|
132
155
|
|
|
133
156
|
return createSuccessResult(
|
|
134
157
|
{
|
|
135
|
-
nodes: emitsCount + listenersCount + roomsCount,
|
|
158
|
+
nodes: emitsCount + listenersCount + roomsCount + eventCount,
|
|
136
159
|
edges: 0
|
|
137
160
|
},
|
|
138
|
-
{ emitsCount, listenersCount, roomsCount }
|
|
161
|
+
{ emitsCount, listenersCount, roomsCount, eventCount }
|
|
139
162
|
);
|
|
140
163
|
} catch (error) {
|
|
141
164
|
logger.error('Analysis failed', { error });
|
|
@@ -143,6 +166,95 @@ export class SocketIOAnalyzer extends Plugin {
|
|
|
143
166
|
}
|
|
144
167
|
}
|
|
145
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Create event channel nodes and connect them to emits/listeners
|
|
171
|
+
*
|
|
172
|
+
* This runs AFTER all modules are analyzed, so all emit/listener nodes exist.
|
|
173
|
+
* Creates one socketio:event node per unique event name, then connects:
|
|
174
|
+
* - socketio:emit → EMITS_EVENT → socketio:event
|
|
175
|
+
* - socketio:event → LISTENED_BY → socketio:on
|
|
176
|
+
*/
|
|
177
|
+
private async createEventChannels(
|
|
178
|
+
graph: PluginContext['graph'],
|
|
179
|
+
logger: ReturnType<typeof this.log>
|
|
180
|
+
): Promise<number> {
|
|
181
|
+
try {
|
|
182
|
+
// Step 1: Get all emit and listener nodes
|
|
183
|
+
const allEmits = await graph.getAllNodes({ type: 'socketio:emit' });
|
|
184
|
+
const allListeners = await graph.getAllNodes({ type: 'socketio:on' });
|
|
185
|
+
|
|
186
|
+
logger.debug('Creating event channels', {
|
|
187
|
+
emits: allEmits.length,
|
|
188
|
+
listeners: allListeners.length
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// Step 2: Extract unique event names
|
|
192
|
+
const eventNames = new Set<string>();
|
|
193
|
+
|
|
194
|
+
for (const emit of allEmits) {
|
|
195
|
+
if (emit.event && typeof emit.event === 'string') {
|
|
196
|
+
eventNames.add(emit.event);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
for (const listener of allListeners) {
|
|
201
|
+
if (listener.event && typeof listener.event === 'string') {
|
|
202
|
+
eventNames.add(listener.event);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
logger.debug('Unique events found', { count: eventNames.size });
|
|
207
|
+
|
|
208
|
+
// Step 3: Create event channel node for each unique event
|
|
209
|
+
let createdCount = 0;
|
|
210
|
+
for (const eventName of eventNames) {
|
|
211
|
+
const eventNodeId = `socketio:event#${eventName}`;
|
|
212
|
+
|
|
213
|
+
// Create event channel node
|
|
214
|
+
const eventNode: SocketEventNode = {
|
|
215
|
+
id: eventNodeId,
|
|
216
|
+
type: 'socketio:event',
|
|
217
|
+
name: eventName,
|
|
218
|
+
event: eventName
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
await graph.addNode(eventNode as unknown as NodeRecord);
|
|
222
|
+
createdCount++;
|
|
223
|
+
|
|
224
|
+
// Step 4: Connect all emits of this event to the channel
|
|
225
|
+
const matchingEmits = allEmits.filter(e => e.event === eventName);
|
|
226
|
+
for (const emit of matchingEmits) {
|
|
227
|
+
await graph.addEdge({
|
|
228
|
+
type: 'EMITS_EVENT',
|
|
229
|
+
src: emit.id,
|
|
230
|
+
dst: eventNodeId
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Step 5: Connect event channel to all listeners of this event
|
|
235
|
+
const matchingListeners = allListeners.filter(l => l.event === eventName);
|
|
236
|
+
for (const listener of matchingListeners) {
|
|
237
|
+
await graph.addEdge({
|
|
238
|
+
type: 'LISTENED_BY',
|
|
239
|
+
src: eventNodeId,
|
|
240
|
+
dst: listener.id
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
logger.debug('Created event channel', {
|
|
245
|
+
event: eventName,
|
|
246
|
+
emits: matchingEmits.length,
|
|
247
|
+
listeners: matchingListeners.length
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return createdCount;
|
|
252
|
+
} catch (error) {
|
|
253
|
+
logger.error('Failed to create event channels', { error });
|
|
254
|
+
return 0;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
146
258
|
private async analyzeModule(
|
|
147
259
|
module: NodeRecord,
|
|
148
260
|
graph: PluginContext['graph']
|
|
@@ -262,7 +374,8 @@ export class SocketIOAnalyzer extends Plugin {
|
|
|
262
374
|
handlerName: handlerName,
|
|
263
375
|
handlerLine: handlerLine,
|
|
264
376
|
file: module.file!,
|
|
265
|
-
line: line
|
|
377
|
+
line: line,
|
|
378
|
+
column: getColumn(node)
|
|
266
379
|
});
|
|
267
380
|
}
|
|
268
381
|
|
|
@@ -283,7 +396,8 @@ export class SocketIOAnalyzer extends Plugin {
|
|
|
283
396
|
room: roomName,
|
|
284
397
|
objectName: objectName,
|
|
285
398
|
file: module.file!,
|
|
286
|
-
line: line
|
|
399
|
+
line: line,
|
|
400
|
+
column: getColumn(node)
|
|
287
401
|
});
|
|
288
402
|
}
|
|
289
403
|
}
|