@saptools/service-flow 0.1.68 → 0.1.70
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/CHANGELOG.md +14 -0
- package/README.md +11 -5
- package/TECHNICAL-NOTE.md +13 -0
- package/dist/{chunk-AEM4JY22.js → chunk-GSLFY6J2.js} +6986 -5503
- package/dist/chunk-GSLFY6J2.js.map +1 -0
- package/dist/cli.js +334 -122
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/cli/{002-doctor-lifecycle.ts → doctor-lifecycle.ts} +1 -1
- package/src/cli/{001-doctor-projection.ts → doctor-projection.ts} +1 -1
- package/src/cli/doctor.ts +5 -5
- package/src/cli/index-summary.ts +22 -0
- package/src/cli.ts +155 -91
- package/src/db/{009-binding-fact-semantics.ts → binding-fact-semantics.ts} +6 -1
- package/src/db/binding-helper-provenance.ts +17 -0
- package/src/db/{012-binding-reference-proof.ts → binding-reference-proof.ts} +4 -0
- package/src/db/{000-call-fact-repository.ts → call-fact-repository.ts} +49 -23
- package/src/db/{003-current-fact-semantics.ts → current-fact-semantics.ts} +5 -4
- package/src/db/{001-fact-lifecycle.ts → fact-lifecycle.ts} +3 -3
- package/src/db/index-publication-failure.ts +91 -0
- package/src/db/{007-package-fact-semantics.ts → package-fact-semantics.ts} +6 -6
- package/src/db/{010-package-symbol-surface-semantics.ts → package-symbol-surface-semantics.ts} +2 -2
- package/src/db/{004-package-target-invalidation.ts → package-target-invalidation.ts} +11 -1
- package/src/db/{008-relative-fact-semantics.ts → relative-fact-semantics.ts} +9 -6
- package/src/db/{006-relative-symbol-resolution.ts → relative-symbol-resolution.ts} +28 -7
- package/src/db/repositories.ts +24 -7
- package/src/db/{011-symbol-call-semantics.ts → symbol-call-semantics.ts} +1 -1
- package/src/index.ts +3 -3
- package/src/indexer/cds-extension-resolver.ts +27 -3
- package/src/indexer/repository-indexer.ts +70 -9
- package/src/indexer/workspace-indexer.ts +142 -30
- package/src/linker/call-edge-insertion.ts +568 -0
- package/src/linker/{002-call-evidence.ts → call-evidence.ts} +2 -2
- package/src/linker/cross-repo-linker.ts +6 -169
- package/src/linker/dynamic-edge-resolver.ts +1 -1
- package/src/linker/{004-event-subscription-handler-linker.ts → event-subscription-handler-linker.ts} +32 -11
- package/src/linker/event-template-link.ts +72 -0
- package/src/linker/external-http-target.ts +1 -1
- package/src/linker/helper-package-linker.ts +1 -1
- package/src/linker/{000-implementation-candidates.ts → implementation-candidates.ts} +1 -1
- package/src/linker/{001-implementation-evidence-projection.ts → implementation-evidence-projection.ts} +1 -1
- package/src/linker/odata-path-normalizer.ts +1 -1
- package/src/linker/{005-odata-path-structure.ts → odata-path-structure.ts} +1 -1
- package/src/linker/{003-package-import-symbol-resolver.ts → package-import-symbol-resolver.ts} +3 -3
- package/src/linker/service-resolver.ts +2 -2
- package/src/output/{001-compact-json-output.ts → compact-json-output.ts} +1 -1
- package/src/parsers/{006-binding-identity.ts → binding-identity.ts} +9 -4
- package/src/parsers/{011-binding-lexical-scope.ts → binding-lexical-scope.ts} +1 -1
- package/src/parsers/{021-binding-visibility.ts → binding-visibility.ts} +18 -2
- package/src/parsers/{000-direct-query-execution.ts → direct-query-execution.ts} +11 -0
- package/src/parsers/{005-event-subscription-facts.ts → event-subscription-facts.ts} +2 -2
- package/src/parsers/{016-local-symbol-reference.ts → local-symbol-reference.ts} +2 -2
- package/src/parsers/operation-path-analysis.ts +1 -1
- package/src/parsers/outbound-call-classifier.ts +692 -0
- package/src/parsers/outbound-call-parser.ts +146 -509
- package/src/parsers/outbound-expression-analysis.ts +700 -0
- package/src/parsers/{018-package-commonjs-syntax.ts → package-commonjs-syntax.ts} +1 -1
- package/src/parsers/{012-package-fact-contract.ts → package-fact-contract.ts} +3 -3
- package/src/parsers/{010-package-public-surface-analysis.ts → package-public-surface-analysis.ts} +2 -2
- package/src/parsers/{003-package-public-surface.ts → package-public-surface.ts} +3 -3
- package/src/parsers/{008-package-surface-publication.ts → package-surface-publication.ts} +1 -1
- package/src/parsers/{001-query-entity-resolution.ts → query-entity-resolution.ts} +1 -1
- package/src/parsers/{015-service-binding-collector.ts → service-binding-collector.ts} +3 -3
- package/src/parsers/{014-service-binding-helper-flow.ts → service-binding-helper-flow.ts} +72 -6
- package/src/parsers/service-binding-parser-helpers.ts +1 -1
- package/src/parsers/service-binding-parser.ts +2 -2
- package/src/parsers/{007-source-fact-reconciliation.ts → source-fact-reconciliation.ts} +3 -3
- package/src/parsers/{020-stable-local-value.ts → stable-local-value.ts} +2 -2
- package/src/parsers/{009-symbol-call-facts.ts → symbol-call-facts.ts} +3 -3
- package/src/parsers/{017-symbol-derived-contexts.ts → symbol-derived-contexts.ts} +2 -2
- package/src/parsers/symbol-parser.ts +43 -11
- package/src/trace/{014-compact-contract.ts → compact-contract.ts} +6 -0
- package/src/trace/{021-compact-decision-normalization.ts → compact-decision-normalization.ts} +77 -11
- package/src/trace/{020-compact-field-projection.ts → compact-field-projection.ts} +77 -4
- package/src/trace/{024-compact-observation-decision.ts → compact-observation-decision.ts} +10 -5
- package/src/trace/{016-compact-projector.ts → compact-projector.ts} +6 -7
- package/src/trace/{018-compact-trace.ts → compact-trace.ts} +3 -3
- package/src/trace/{006-contextual-projection.ts → contextual-projection.ts} +1 -1
- package/src/trace/{008-contextual-runtime-state.ts → contextual-runtime-state.ts} +1 -1
- package/src/trace/{001-dynamic-identity.ts → dynamic-identity.ts} +2 -2
- package/src/trace/{003-dynamic-references.ts → dynamic-references.ts} +2 -2
- package/src/trace/dynamic-targets.ts +6 -6
- package/src/trace/event-runtime-resolution.ts +151 -0
- package/src/trace/{011-event-subscriber-traversal.ts → event-subscriber-traversal.ts} +101 -9
- package/src/trace/evidence.ts +2 -2
- package/src/trace/implementation-hints.ts +10 -7
- package/src/trace/{005-implementation-selection.ts → implementation-selection.ts} +2 -2
- package/src/trace/{007-implementation-start-diagnostic.ts → implementation-start-diagnostic.ts} +1 -0
- package/src/trace/local-call-expansion.ts +37 -0
- package/src/trace/{009-selected-handler-provenance.ts → selected-handler-provenance.ts} +1 -1
- package/src/trace/selectors.ts +2 -1
- package/src/trace/{017-trace-context.ts → trace-context.ts} +2 -2
- package/src/trace/{015-trace-edge-recorder.ts → trace-edge-recorder.ts} +62 -5
- package/src/trace/{019-trace-edge-semantics.ts → trace-edge-semantics.ts} +9 -13
- package/src/trace/trace-engine.ts +10 -10
- package/src/trace/{022-trace-fact-preflight.ts → trace-fact-preflight.ts} +2 -2
- package/src/trace/{025-trace-implementation-scope.ts → trace-implementation-scope.ts} +1 -1
- package/src/trace/{028-trace-operation-execution.ts → trace-operation-execution.ts} +10 -10
- package/src/trace/{013-trace-root-scopes.ts → trace-root-scopes.ts} +5 -6
- package/src/trace/{027-trace-scope-execution.ts → trace-scope-execution.ts} +44 -44
- package/src/trace/{029-trace-start-implementation.ts → trace-start-implementation.ts} +7 -7
- package/src/trace/{026-trace-start-scope.ts → trace-start-scope.ts} +6 -5
- package/src/trace/{010-traversal-scope.ts → traversal-scope.ts} +1 -1
- package/src/types.ts +2 -1
- package/src/version.ts +1 -1
- package/dist/chunk-AEM4JY22.js.map +0 -1
- /package/src/cli/{000-clean.ts → clean.ts} +0 -0
- /package/src/cli/{003-doctor-package-resolution.ts → doctor-package-resolution.ts} +0 -0
- /package/src/db/{002-fact-json-inventory.ts → fact-json-inventory.ts} +0 -0
- /package/src/db/{005-schema-structure.ts → schema-structure.ts} +0 -0
- /package/src/output/{000-stdout-policy.ts → stdout-policy.ts} +0 -0
- /package/src/parsers/{019-binding-assignment-targets.ts → binding-assignment-targets.ts} +0 -0
- /package/src/parsers/{013-executable-body-eligibility.ts → executable-body-eligibility.ts} +0 -0
- /package/src/parsers/{004-fact-identity.ts → fact-identity.ts} +0 -0
- /package/src/parsers/{002-symbol-import-bindings.ts → symbol-import-bindings.ts} +0 -0
- /package/src/trace/{004-dynamic-candidate-sources.ts → dynamic-candidate-sources.ts} +0 -0
- /package/src/trace/{000-dynamic-target-types.ts → dynamic-target-types.ts} +0 -0
- /package/src/trace/{023-nested-event-scopes.ts → nested-event-scopes.ts} +0 -0
- /package/src/trace/{002-trace-diagnostics.ts → trace-diagnostics.ts} +0 -0
- /package/src/trace/{012-trace-graph-lookups.ts → trace-graph-lookups.ts} +0 -0
- /package/src/utils/{000-bounded-projection.ts → bounded-projection.ts} +0 -0
- /package/src/utils/{001-placeholders.ts → placeholders.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -130,7 +130,7 @@ interface ServiceBindingReference {
|
|
|
130
130
|
bindingSourceFile?: string;
|
|
131
131
|
bindingSiteStartOffset?: number;
|
|
132
132
|
bindingSiteEndOffset?: number;
|
|
133
|
-
resolutionStrategy?: 'lexical_declaration' | 'lexical_alias_declaration' | 'deterministic_reaching_assignment';
|
|
133
|
+
resolutionStrategy?: 'lexical_declaration' | 'lexical_alias_declaration' | 'deterministic_reaching_assignment' | 'single_hop_helper_return';
|
|
134
134
|
lexicalScopeChain?: LexicalScopeFact[];
|
|
135
135
|
bindingScopeIndex?: number;
|
|
136
136
|
scopeChainTotal: number;
|
|
@@ -274,6 +274,7 @@ interface ClassifiedOutboundCall {
|
|
|
274
274
|
fact: OutboundCallFact;
|
|
275
275
|
node: ts.CallExpression;
|
|
276
276
|
}
|
|
277
|
+
|
|
277
278
|
declare function parseOutboundCalls(repoPath: string, filePath: string, context?: RepositorySourceContext, classified?: readonly ClassifiedOutboundCall[], preparedBindings?: readonly ServiceBindingFact[]): Promise<OutboundCallFact[]>;
|
|
278
279
|
|
|
279
280
|
declare function parseGeneratedConstants(repoPath: string, filePath: string): Promise<GeneratedConstantFact[]>;
|
|
@@ -393,6 +394,7 @@ interface CompactDecisionV1 {
|
|
|
393
394
|
implementationStrategy?: string;
|
|
394
395
|
implementationGuided?: boolean;
|
|
395
396
|
implementationContextual?: boolean;
|
|
397
|
+
tiedCandidateRepos?: CompactReferenceGroupV1;
|
|
396
398
|
eventMatchStrategy?: string;
|
|
397
399
|
dispatchCertainty?: string;
|
|
398
400
|
eventSubscriptionCount?: number;
|
|
@@ -413,6 +415,10 @@ interface CompactEdgeDetailsV1 {
|
|
|
413
415
|
}
|
|
414
416
|
interface CompactDiagnosticDetailsV1 {
|
|
415
417
|
reasonCode?: string;
|
|
418
|
+
tiedCandidateRepos?: CompactReferenceGroupV1;
|
|
419
|
+
selectorKind?: string;
|
|
420
|
+
selectorSuggestions?: CompactReferenceGroupV1;
|
|
421
|
+
invalidFactCategories?: CompactReferenceGroupV1;
|
|
416
422
|
missingVariableNames?: string[];
|
|
417
423
|
missingVariableCount?: number;
|
|
418
424
|
shownMissingVariableCount?: number;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Db } from '../db/connection.js';
|
|
2
|
-
import { factLifecycleDiagnostic } from '../db/
|
|
2
|
+
import { factLifecycleDiagnostic } from '../db/fact-lifecycle.js';
|
|
3
3
|
import { ANALYZER_VERSION } from '../version.js';
|
|
4
4
|
|
|
5
5
|
type Diagnostic = Record<string, unknown>;
|
package/src/cli/doctor.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { Db } from '../db/connection.js';
|
|
2
2
|
import { classifyODataPathIntent, normalizeODataOperationInvocationPath } from '../linker/odata-path-normalizer.js';
|
|
3
3
|
import { implementationHintSuggestions } from '../trace/implementation-hints.js';
|
|
4
|
-
import { boundDoctorDiagnostics } from './
|
|
5
|
-
import { factLifecycleDiagnostic } from '../db/
|
|
4
|
+
import { boundDoctorDiagnostics } from './doctor-projection.js';
|
|
5
|
+
import { factLifecycleDiagnostic } from '../db/fact-lifecycle.js';
|
|
6
6
|
import {
|
|
7
7
|
analyzerVersionDiagnostics,
|
|
8
8
|
schemaDriftDiagnostics,
|
|
9
|
-
} from './
|
|
9
|
+
} from './doctor-lifecycle.js';
|
|
10
10
|
import {
|
|
11
11
|
packagePendingDiagnostics,
|
|
12
12
|
symbolCallQuality,
|
|
13
|
-
} from './
|
|
14
|
-
export { linkUpgradeWarnings } from './
|
|
13
|
+
} from './doctor-package-resolution.js';
|
|
14
|
+
export { linkUpgradeWarnings } from './doctor-lifecycle.js';
|
|
15
15
|
|
|
16
16
|
type Diagnostic = Record<string, unknown>;
|
|
17
17
|
interface DoctorOptions {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IndexWorkspaceSummary,
|
|
3
|
+
} from '../indexer/workspace-indexer.js';
|
|
4
|
+
|
|
5
|
+
export interface IndexCommandOutcome {
|
|
6
|
+
stdout: string;
|
|
7
|
+
exitCode: 0 | 1;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function indexCommandOutcome(
|
|
11
|
+
summary: IndexWorkspaceSummary,
|
|
12
|
+
): IndexCommandOutcome {
|
|
13
|
+
const failed = summary.failedCount > 0
|
|
14
|
+
? `, failed ${summary.failedCount} (${
|
|
15
|
+
summary.failedRepos.map(({ name, code }) => `${name}: ${code}`).join(', ')
|
|
16
|
+
})`
|
|
17
|
+
: '';
|
|
18
|
+
return {
|
|
19
|
+
stdout: `Indexed ${summary.indexedCount} repositories, skipped ${summary.skippedCount}${failed}, ${summary.fileCount} files, ${summary.diagnosticCount} diagnostics\n`,
|
|
20
|
+
exitCode: summary.failedCount > 0 ? 1 : 0,
|
|
21
|
+
};
|
|
22
|
+
}
|
package/src/cli.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { indexWorkspace } from './indexer/workspace-indexer.js';
|
|
|
21
21
|
import { linkWorkspace } from './linker/cross-repo-linker.js';
|
|
22
22
|
import { doctorDiagnostics, linkUpgradeWarnings } from './cli/doctor.js';
|
|
23
23
|
import { trace } from './trace/trace-engine.js';
|
|
24
|
-
import { compactTrace } from './trace/
|
|
24
|
+
import { compactTrace } from './trace/compact-trace.js';
|
|
25
25
|
import {
|
|
26
26
|
parseVars,
|
|
27
27
|
selectorRepoAmbiguousDiagnostic,
|
|
@@ -31,8 +31,8 @@ import { renderTraceTable } from './output/table-output.js';
|
|
|
31
31
|
import { renderTraceJson, renderJson } from './output/json-output.js';
|
|
32
32
|
import { renderDoctorDiagnostics } from './output/doctor-output.js';
|
|
33
33
|
import { renderMermaid } from './output/mermaid-output.js';
|
|
34
|
-
import { createStdoutWriter } from './output/
|
|
35
|
-
import { renderCompactJson } from './output/
|
|
34
|
+
import { createStdoutWriter } from './output/stdout-policy.js';
|
|
35
|
+
import { renderCompactJson } from './output/compact-json-output.js';
|
|
36
36
|
import { VERSION } from './version.js';
|
|
37
37
|
import type {
|
|
38
38
|
DynamicMode,
|
|
@@ -40,7 +40,8 @@ import type {
|
|
|
40
40
|
TraceResult,
|
|
41
41
|
TraceStart,
|
|
42
42
|
} from './types.js';
|
|
43
|
-
import { cleanWorkspaceState } from './cli/
|
|
43
|
+
import { cleanWorkspaceState } from './cli/clean.js';
|
|
44
|
+
import { indexCommandOutcome } from './cli/index-summary.js';
|
|
44
45
|
|
|
45
46
|
const stdout = createStdoutWriter(process.stdout, fail);
|
|
46
47
|
const TRACE_FORMATS = ['table', 'json', 'mermaid', 'compact-json'] as const;
|
|
@@ -245,14 +246,16 @@ function runGraphCommand(opts: GraphCommandOptions): Promise<void> {
|
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
248
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
program
|
|
249
|
+
function configuredProgram(): Command {
|
|
250
|
+
return new Command()
|
|
251
251
|
.name('service-flow')
|
|
252
252
|
.description(
|
|
253
253
|
'Trace SAP CAP service-to-service flows across multi-repository workspaces',
|
|
254
254
|
)
|
|
255
255
|
.version(VERSION);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function registerInitCommand(program: Command): void {
|
|
256
259
|
program
|
|
257
260
|
.command('init')
|
|
258
261
|
.argument('<workspace>')
|
|
@@ -262,6 +265,9 @@ export function createProgram(): Command {
|
|
|
262
265
|
(workspace: string, opts: { db?: string; ignore?: string[] }) =>
|
|
263
266
|
void init(workspace, opts).catch(fail),
|
|
264
267
|
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function registerIndexCommand(program: Command): void {
|
|
265
271
|
program
|
|
266
272
|
.command('index')
|
|
267
273
|
.option('--workspace <path>')
|
|
@@ -274,11 +280,14 @@ export function createProgram(): Command {
|
|
|
274
280
|
repo: opts.repo,
|
|
275
281
|
force: Boolean(opts.force),
|
|
276
282
|
});
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
);
|
|
283
|
+
const outcome = indexCommandOutcome(r);
|
|
284
|
+
writeStdout(outcome.stdout);
|
|
285
|
+
if (outcome.exitCode !== 0) process.exitCode = outcome.exitCode;
|
|
280
286
|
}).catch(fail),
|
|
281
287
|
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function registerLinkCommand(program: Command): void {
|
|
282
291
|
program
|
|
283
292
|
.command('link')
|
|
284
293
|
.option('--workspace <path>')
|
|
@@ -293,6 +302,9 @@ export function createProgram(): Command {
|
|
|
293
302
|
);
|
|
294
303
|
}).catch(fail),
|
|
295
304
|
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function registerTraceCommand(program: Command): void {
|
|
296
308
|
program
|
|
297
309
|
.command('trace')
|
|
298
310
|
.option('--workspace <path>')
|
|
@@ -312,23 +324,91 @@ export function createProgram(): Command {
|
|
|
312
324
|
.option('--dynamic-mode <mode>', 'strict|candidates|infer', 'strict')
|
|
313
325
|
.option('--max-dynamic-candidates <n>', 'maximum dynamic candidates to show', '5')
|
|
314
326
|
.action((opts: TraceCommandOptions) => void runTraceCommand(opts).catch(fail));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function listRepositoriesCommand(
|
|
330
|
+
opts: { workspace?: string },
|
|
331
|
+
): Promise<void> {
|
|
332
|
+
return withReadOnlyWorkspace(opts.workspace, (db, workspaceId) =>
|
|
333
|
+
writeStdout(
|
|
334
|
+
renderJson(
|
|
335
|
+
listRepositories(db, workspaceId).map((repo) => ({
|
|
336
|
+
name: repo.name,
|
|
337
|
+
kind: repo.kind,
|
|
338
|
+
packageName: repo.package_name,
|
|
339
|
+
})),
|
|
340
|
+
),
|
|
341
|
+
));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function listServicesCommand(
|
|
345
|
+
opts: { workspace?: string; repo?: string },
|
|
346
|
+
): Promise<void> {
|
|
347
|
+
return withReadOnlyWorkspace(opts.workspace, (db, workspaceId) => {
|
|
348
|
+
const selection = opts.repo
|
|
349
|
+
? selectRepository(db, opts.repo, workspaceId) : {};
|
|
350
|
+
if (selection.diagnostic) {
|
|
351
|
+
writeStdout(renderJson([selection.diagnostic]));
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
const repo = selection.repo;
|
|
355
|
+
const rows = db.prepare(
|
|
356
|
+
'SELECT r.name repo,s.service_path servicePath,s.qualified_name qualifiedName FROM cds_services s JOIN repositories r ON r.id=s.repo_id WHERE r.workspace_id=? AND (? IS NULL OR s.repo_id=?) ORDER BY r.name,s.service_path',
|
|
357
|
+
).all(workspaceId, repo?.id, repo?.id);
|
|
358
|
+
writeStdout(renderJson(rows));
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function listOperationsCommand(
|
|
363
|
+
opts: { workspace?: string; repo?: string; service?: string },
|
|
364
|
+
): Promise<void> {
|
|
365
|
+
return withReadOnlyWorkspace(opts.workspace, (db, workspaceId) => {
|
|
366
|
+
const selection = opts.repo
|
|
367
|
+
? selectRepository(db, opts.repo, workspaceId) : {};
|
|
368
|
+
if (selection.diagnostic) {
|
|
369
|
+
writeStdout(renderJson([selection.diagnostic]));
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
const repo = selection.repo;
|
|
373
|
+
const rows = db.prepare(
|
|
374
|
+
'SELECT r.name repo,s.service_path servicePath,o.operation_name operation,o.operation_path path FROM cds_operations o JOIN cds_services s ON s.id=o.service_id JOIN repositories r ON r.id=s.repo_id WHERE r.workspace_id=? AND (? IS NULL OR s.repo_id=?) AND (? IS NULL OR s.service_path=?)',
|
|
375
|
+
).all(
|
|
376
|
+
workspaceId, repo?.id, repo?.id, opts.service, opts.service,
|
|
377
|
+
);
|
|
378
|
+
writeStdout(renderJson(rows));
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function listCallsCommand(
|
|
383
|
+
opts: { workspace?: string; repo?: string; operation?: string },
|
|
384
|
+
): Promise<void> {
|
|
385
|
+
return withReadOnlyWorkspace(opts.workspace, (db, workspaceId) => {
|
|
386
|
+
const selection = opts.repo
|
|
387
|
+
? selectRepository(db, opts.repo, workspaceId) : {};
|
|
388
|
+
if (selection.diagnostic) {
|
|
389
|
+
writeStdout(renderJson([selection.diagnostic]));
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const repo = selection.repo;
|
|
393
|
+
const rows = db.prepare(
|
|
394
|
+
'SELECT r.name repo,c.call_type type,c.operation_path_expr path,c.source_file file,c.source_line line FROM outbound_calls c JOIN repositories r ON r.id=c.repo_id WHERE r.workspace_id=? AND (? IS NULL OR c.repo_id=?) AND (? IS NULL OR c.operation_path_expr=? OR c.operation_path_expr=? OR c.payload_summary LIKE ?)',
|
|
395
|
+
).all(
|
|
396
|
+
workspaceId, repo?.id, repo?.id, opts.operation, opts.operation,
|
|
397
|
+
opts.operation ? `/${opts.operation}` : undefined,
|
|
398
|
+
opts.operation ? `%${opts.operation}%` : undefined,
|
|
399
|
+
);
|
|
400
|
+
writeStdout(renderJson(rows));
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function registerListCommands(program: Command): void {
|
|
315
405
|
const list = program.command('list');
|
|
316
406
|
list
|
|
317
407
|
.command('repos')
|
|
318
408
|
.option('--workspace <path>')
|
|
319
409
|
.action(
|
|
320
410
|
(opts: { workspace?: string }) =>
|
|
321
|
-
void
|
|
322
|
-
writeStdout(
|
|
323
|
-
renderJson(
|
|
324
|
-
listRepositories(db, workspaceId).map((r) => ({
|
|
325
|
-
name: r.name,
|
|
326
|
-
kind: r.kind,
|
|
327
|
-
packageName: r.package_name,
|
|
328
|
-
})),
|
|
329
|
-
),
|
|
330
|
-
),
|
|
331
|
-
).catch(fail),
|
|
411
|
+
void listRepositoriesCommand(opts).catch(fail),
|
|
332
412
|
);
|
|
333
413
|
list
|
|
334
414
|
.command('services')
|
|
@@ -336,22 +416,7 @@ export function createProgram(): Command {
|
|
|
336
416
|
.option('--repo <name>')
|
|
337
417
|
.action(
|
|
338
418
|
(opts: { workspace?: string; repo?: string }) =>
|
|
339
|
-
void
|
|
340
|
-
const selection = opts.repo
|
|
341
|
-
? selectRepository(db, opts.repo, workspaceId)
|
|
342
|
-
: {};
|
|
343
|
-
if (selection.diagnostic) {
|
|
344
|
-
writeStdout(renderJson([selection.diagnostic]));
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
const repo = selection.repo;
|
|
348
|
-
const rows = db
|
|
349
|
-
.prepare(
|
|
350
|
-
'SELECT r.name repo,s.service_path servicePath,s.qualified_name qualifiedName FROM cds_services s JOIN repositories r ON r.id=s.repo_id WHERE r.workspace_id=? AND (? IS NULL OR s.repo_id=?) ORDER BY r.name,s.service_path',
|
|
351
|
-
)
|
|
352
|
-
.all(workspaceId, repo?.id, repo?.id);
|
|
353
|
-
writeStdout(renderJson(rows));
|
|
354
|
-
}).catch(fail),
|
|
419
|
+
void listServicesCommand(opts).catch(fail),
|
|
355
420
|
);
|
|
356
421
|
list
|
|
357
422
|
.command('operations')
|
|
@@ -360,22 +425,7 @@ export function createProgram(): Command {
|
|
|
360
425
|
.option('--service <path>')
|
|
361
426
|
.action(
|
|
362
427
|
(opts: { workspace?: string; repo?: string; service?: string }) =>
|
|
363
|
-
void
|
|
364
|
-
const selection = opts.repo
|
|
365
|
-
? selectRepository(db, opts.repo, workspaceId)
|
|
366
|
-
: {};
|
|
367
|
-
if (selection.diagnostic) {
|
|
368
|
-
writeStdout(renderJson([selection.diagnostic]));
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const repo = selection.repo;
|
|
372
|
-
const rows = db
|
|
373
|
-
.prepare(
|
|
374
|
-
'SELECT r.name repo,s.service_path servicePath,o.operation_name operation,o.operation_path path FROM cds_operations o JOIN cds_services s ON s.id=o.service_id JOIN repositories r ON r.id=s.repo_id WHERE r.workspace_id=? AND (? IS NULL OR s.repo_id=?) AND (? IS NULL OR s.service_path=?)',
|
|
375
|
-
)
|
|
376
|
-
.all(workspaceId, repo?.id, repo?.id, opts.service, opts.service);
|
|
377
|
-
writeStdout(renderJson(rows));
|
|
378
|
-
}).catch(fail),
|
|
428
|
+
void listOperationsCommand(opts).catch(fail),
|
|
379
429
|
);
|
|
380
430
|
list
|
|
381
431
|
.command('calls')
|
|
@@ -384,31 +434,11 @@ export function createProgram(): Command {
|
|
|
384
434
|
.option('--operation <name>')
|
|
385
435
|
.action(
|
|
386
436
|
(opts: { workspace?: string; repo?: string; operation?: string }) =>
|
|
387
|
-
void
|
|
388
|
-
const selection = opts.repo
|
|
389
|
-
? selectRepository(db, opts.repo, workspaceId)
|
|
390
|
-
: {};
|
|
391
|
-
if (selection.diagnostic) {
|
|
392
|
-
writeStdout(renderJson([selection.diagnostic]));
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
const repo = selection.repo;
|
|
396
|
-
const rows = db
|
|
397
|
-
.prepare(
|
|
398
|
-
'SELECT r.name repo,c.call_type type,c.operation_path_expr path,c.source_file file,c.source_line line FROM outbound_calls c JOIN repositories r ON r.id=c.repo_id WHERE r.workspace_id=? AND (? IS NULL OR c.repo_id=?) AND (? IS NULL OR c.operation_path_expr=? OR c.operation_path_expr=? OR c.payload_summary LIKE ?)',
|
|
399
|
-
)
|
|
400
|
-
.all(
|
|
401
|
-
workspaceId,
|
|
402
|
-
repo?.id,
|
|
403
|
-
repo?.id,
|
|
404
|
-
opts.operation,
|
|
405
|
-
opts.operation,
|
|
406
|
-
opts.operation ? `/${opts.operation}` : undefined,
|
|
407
|
-
opts.operation ? `%${opts.operation}%` : undefined,
|
|
408
|
-
);
|
|
409
|
-
writeStdout(renderJson(rows));
|
|
410
|
-
}).catch(fail),
|
|
437
|
+
void listCallsCommand(opts).catch(fail),
|
|
411
438
|
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function registerGraphCommand(program: Command): void {
|
|
412
442
|
program
|
|
413
443
|
.command('graph')
|
|
414
444
|
.option('--workspace <path>')
|
|
@@ -423,6 +453,33 @@ export function createProgram(): Command {
|
|
|
423
453
|
.option('--dynamic-mode <mode>', 'strict|candidates|infer', 'strict')
|
|
424
454
|
.option('--max-dynamic-candidates <n>', 'maximum dynamic candidates to show', '5')
|
|
425
455
|
.action((opts: GraphCommandOptions) => void runGraphCommand(opts).catch(fail));
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function inspectRepositoryCommand(
|
|
459
|
+
name: string,
|
|
460
|
+
opts: { workspace?: string },
|
|
461
|
+
): Promise<void> {
|
|
462
|
+
return withReadOnlyWorkspace(opts.workspace, (db, workspaceId) => {
|
|
463
|
+
const selection = selectRepository(db, name, workspaceId);
|
|
464
|
+
writeStdout(renderJson(
|
|
465
|
+
selection.repo ?? selection.diagnostic ?? { error: 'repo not found' },
|
|
466
|
+
));
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function inspectOperationCommand(
|
|
471
|
+
selector: string,
|
|
472
|
+
opts: { workspace?: string },
|
|
473
|
+
): Promise<void> {
|
|
474
|
+
return withReadOnlyWorkspace(opts.workspace, (db, workspaceId) => {
|
|
475
|
+
const rows = db.prepare(
|
|
476
|
+
'SELECT o.* FROM cds_operations o JOIN cds_services s ON s.id=o.service_id JOIN repositories r ON r.id=s.repo_id WHERE r.workspace_id=? AND (o.operation_name=? OR o.operation_path=?)',
|
|
477
|
+
).all(workspaceId, selector, selector);
|
|
478
|
+
writeStdout(renderJson(rows));
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function registerInspectCommands(program: Command): void {
|
|
426
483
|
const inspect = program.command('inspect');
|
|
427
484
|
inspect
|
|
428
485
|
.command('repo')
|
|
@@ -430,12 +487,7 @@ export function createProgram(): Command {
|
|
|
430
487
|
.option('--workspace <path>')
|
|
431
488
|
.action(
|
|
432
489
|
(name: string, opts: { workspace?: string }) =>
|
|
433
|
-
void
|
|
434
|
-
const selection = selectRepository(db, name, workspaceId);
|
|
435
|
-
writeStdout(renderJson(
|
|
436
|
-
selection.repo ?? selection.diagnostic ?? { error: 'repo not found' },
|
|
437
|
-
));
|
|
438
|
-
}).catch(fail),
|
|
490
|
+
void inspectRepositoryCommand(name, opts).catch(fail),
|
|
439
491
|
);
|
|
440
492
|
inspect
|
|
441
493
|
.command('operation')
|
|
@@ -443,15 +495,11 @@ export function createProgram(): Command {
|
|
|
443
495
|
.option('--workspace <path>')
|
|
444
496
|
.action(
|
|
445
497
|
(selector: string, opts: { workspace?: string }) =>
|
|
446
|
-
void
|
|
447
|
-
const rows = db
|
|
448
|
-
.prepare(
|
|
449
|
-
'SELECT o.* FROM cds_operations o JOIN cds_services s ON s.id=o.service_id JOIN repositories r ON r.id=s.repo_id WHERE r.workspace_id=? AND (o.operation_name=? OR o.operation_path=?)',
|
|
450
|
-
)
|
|
451
|
-
.all(workspaceId, selector, selector);
|
|
452
|
-
writeStdout(renderJson(rows));
|
|
453
|
-
}).catch(fail),
|
|
498
|
+
void inspectOperationCommand(selector, opts).catch(fail),
|
|
454
499
|
);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function registerDoctorCommand(program: Command): void {
|
|
455
503
|
program
|
|
456
504
|
.command('doctor')
|
|
457
505
|
.option('--workspace <path>')
|
|
@@ -467,6 +515,9 @@ export function createProgram(): Command {
|
|
|
467
515
|
writeStdout(renderDoctorDiagnostics(allDiagnostics, opts.format));
|
|
468
516
|
}).catch(fail),
|
|
469
517
|
);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function registerCleanCommand(program: Command): void {
|
|
470
521
|
program
|
|
471
522
|
.command('clean')
|
|
472
523
|
.option('--workspace <path>')
|
|
@@ -479,6 +530,19 @@ export function createProgram(): Command {
|
|
|
479
530
|
writeStdout('Cleaned service-flow state\n');
|
|
480
531
|
})().catch(fail),
|
|
481
532
|
);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export function createProgram(): Command {
|
|
536
|
+
const program = configuredProgram();
|
|
537
|
+
registerInitCommand(program);
|
|
538
|
+
registerIndexCommand(program);
|
|
539
|
+
registerLinkCommand(program);
|
|
540
|
+
registerTraceCommand(program);
|
|
541
|
+
registerListCommands(program);
|
|
542
|
+
registerGraphCommand(program);
|
|
543
|
+
registerInspectCommands(program);
|
|
544
|
+
registerDoctorCommand(program);
|
|
545
|
+
registerCleanCommand(program);
|
|
482
546
|
return program;
|
|
483
547
|
}
|
|
484
548
|
function collect(value: string, previous: string[]): string[] {
|
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
resolvedBindingReferenceProofValid,
|
|
9
9
|
validBindingLexicalScope,
|
|
10
10
|
type BindingProofTarget,
|
|
11
|
-
} from './
|
|
11
|
+
} from './binding-reference-proof.js';
|
|
12
|
+
import {
|
|
13
|
+
hasSingleHopHelperReturn,
|
|
14
|
+
} from './binding-helper-provenance.js';
|
|
12
15
|
|
|
13
16
|
export interface BindingFactCategoryCount {
|
|
14
17
|
category: string;
|
|
@@ -114,6 +117,7 @@ function bindingTargets(
|
|
|
114
117
|
binding.binding_site_start_offset startOffset,
|
|
115
118
|
binding.binding_site_end_offset endOffset,
|
|
116
119
|
binding.owner_resolution ownerResolution,
|
|
120
|
+
binding.helper_chain_json helperChainJson,
|
|
117
121
|
owner.start_offset ownerStartOffset,owner.end_offset ownerEndOffset
|
|
118
122
|
FROM service_bindings binding
|
|
119
123
|
JOIN repositories repo ON repo.id=binding.repo_id
|
|
@@ -140,6 +144,7 @@ function bindingTarget(
|
|
|
140
144
|
ownerResolution: row.ownerResolution,
|
|
141
145
|
ownerStartOffset: row.ownerStartOffset,
|
|
142
146
|
ownerEndOffset: row.ownerEndOffset,
|
|
147
|
+
singleHopHelperReturn: hasSingleHopHelperReturn(row.helperChainJson),
|
|
143
148
|
}];
|
|
144
149
|
}
|
|
145
150
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function record(value: unknown): value is Record<string, unknown> {
|
|
2
|
+
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function parsed(value: string): unknown {
|
|
6
|
+
try {
|
|
7
|
+
return JSON.parse(value) as unknown;
|
|
8
|
+
} catch {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function hasSingleHopHelperReturn(value: unknown): boolean {
|
|
14
|
+
const chain = typeof value === 'string' ? parsed(value) : value;
|
|
15
|
+
return Array.isArray(chain) && chain.some((step) =>
|
|
16
|
+
record(step) && step.bindingOrigin === 'single_hop_helper_return');
|
|
17
|
+
}
|
|
@@ -23,6 +23,7 @@ export interface BindingProofTarget {
|
|
|
23
23
|
ownerResolution: string;
|
|
24
24
|
ownerStartOffset: number | null;
|
|
25
25
|
ownerEndOffset: number | null;
|
|
26
|
+
singleHopHelperReturn: boolean;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
interface ResolvedBindingProof {
|
|
@@ -45,6 +46,7 @@ const strategies = new Set([
|
|
|
45
46
|
'lexical_declaration',
|
|
46
47
|
'lexical_alias_declaration',
|
|
47
48
|
'deterministic_reaching_assignment',
|
|
49
|
+
'single_hop_helper_return',
|
|
48
50
|
]);
|
|
49
51
|
|
|
50
52
|
function record(value: unknown): Record<string, unknown> | undefined {
|
|
@@ -242,6 +244,8 @@ function targetMatches(
|
|
|
242
244
|
target: BindingProofTarget | undefined,
|
|
243
245
|
): boolean {
|
|
244
246
|
if (!target || call.bindingId !== target.id) return false;
|
|
247
|
+
if (reference.resolutionStrategy === 'single_hop_helper_return'
|
|
248
|
+
&& !target.singleHopHelperReturn) return false;
|
|
245
249
|
return all([
|
|
246
250
|
target.repoId === call.repoId,
|
|
247
251
|
target.sourceFile === call.sourceFile,
|