@saptools/service-flow 0.1.67 → 0.1.69
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 +20 -0
- package/README.md +27 -9
- package/TECHNICAL-NOTE.md +36 -0
- package/dist/chunk-3N3B5KHV.js +19596 -0
- package/dist/chunk-3N3B5KHV.js.map +1 -0
- package/dist/cli.js +2645 -521
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +67 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/cli/001-index-summary.ts +22 -0
- package/src/cli/003-doctor-package-resolution.ts +68 -0
- package/src/cli/doctor.ts +25 -14
- package/src/cli.ts +151 -87
- package/src/db/000-call-fact-repository.ts +499 -340
- package/src/db/001-fact-lifecycle.ts +60 -30
- package/src/db/002-fact-json-inventory.ts +169 -0
- package/src/db/003-current-fact-semantics.ts +699 -0
- package/src/db/004-package-target-invalidation.ts +183 -0
- package/src/db/005-schema-structure.ts +201 -0
- package/src/db/006-relative-symbol-resolution.ts +464 -0
- package/src/db/007-package-fact-semantics.ts +573 -0
- package/src/db/008-relative-fact-semantics.ts +210 -0
- package/src/db/009-binding-fact-semantics.ts +352 -0
- package/src/db/010-package-symbol-surface-semantics.ts +320 -0
- package/src/db/011-symbol-call-semantics.ts +144 -0
- package/src/db/012-binding-reference-proof.ts +268 -0
- package/src/db/013-index-publication-failure.ts +91 -0
- package/src/db/014-binding-helper-provenance.ts +17 -0
- package/src/db/migrations.ts +16 -3
- package/src/db/repositories.ts +130 -6
- package/src/db/schema.ts +4 -2
- package/src/index.ts +12 -0
- package/src/indexer/cds-extension-resolver.ts +27 -3
- package/src/indexer/repository-indexer.ts +135 -13
- package/src/indexer/workspace-indexer.ts +237 -34
- package/src/linker/003-package-import-symbol-resolver.ts +363 -131
- package/src/linker/004-event-subscription-handler-linker.ts +34 -11
- package/src/linker/005-odata-path-structure.ts +371 -0
- package/src/linker/006-event-template-link.ts +72 -0
- package/src/linker/007-call-edge-insertion.ts +568 -0
- package/src/linker/cross-repo-linker.ts +4 -166
- package/src/linker/odata-path-normalizer.ts +273 -180
- package/src/linker/service-resolver.ts +197 -77
- package/src/parsers/000-direct-query-execution.ts +11 -0
- package/src/parsers/002-symbol-import-bindings.ts +516 -0
- package/src/parsers/003-package-public-surface.ts +661 -0
- package/src/parsers/004-fact-identity.ts +108 -0
- package/src/parsers/005-event-subscription-facts.ts +281 -0
- package/src/parsers/006-binding-identity.ts +348 -0
- package/src/parsers/007-source-fact-reconciliation.ts +105 -0
- package/src/parsers/008-package-surface-publication.ts +82 -0
- package/src/parsers/009-symbol-call-facts.ts +528 -0
- package/src/parsers/010-package-public-surface-analysis.ts +352 -0
- package/src/parsers/011-binding-lexical-scope.ts +583 -0
- package/src/parsers/012-package-fact-contract.ts +306 -0
- package/src/parsers/013-executable-body-eligibility.ts +35 -0
- package/src/parsers/014-service-binding-helper-flow.ts +306 -0
- package/src/parsers/015-service-binding-collector.ts +693 -0
- package/src/parsers/016-local-symbol-reference.ts +261 -0
- package/src/parsers/017-symbol-derived-contexts.ts +268 -0
- package/src/parsers/018-package-commonjs-syntax.ts +142 -0
- package/src/parsers/019-binding-assignment-targets.ts +76 -0
- package/src/parsers/020-stable-local-value.ts +217 -0
- package/src/parsers/021-binding-visibility.ts +168 -0
- package/src/parsers/022-outbound-expression-analysis.ts +700 -0
- package/src/parsers/023-outbound-call-classifier.ts +692 -0
- package/src/parsers/operation-path-analysis.ts +6 -1
- package/src/parsers/outbound-call-parser.ts +162 -512
- package/src/parsers/package-json-parser.ts +45 -3
- package/src/parsers/service-binding-parser-helpers.ts +86 -15
- package/src/parsers/service-binding-parser.ts +147 -597
- package/src/parsers/symbol-parser.ts +513 -352
- package/src/trace/002-trace-diagnostics.ts +36 -1
- package/src/trace/007-implementation-start-diagnostic.ts +1 -0
- package/src/trace/011-event-subscriber-traversal.ts +100 -8
- package/src/trace/013-trace-root-scopes.ts +2 -3
- package/src/trace/014-compact-contract.ts +6 -0
- package/src/trace/015-trace-edge-recorder.ts +61 -4
- package/src/trace/016-compact-projector.ts +15 -17
- package/src/trace/019-trace-edge-semantics.ts +6 -10
- package/src/trace/020-compact-field-projection.ts +122 -38
- package/src/trace/021-compact-decision-normalization.ts +171 -0
- package/src/trace/022-trace-fact-preflight.ts +21 -0
- package/src/trace/023-nested-event-scopes.ts +23 -0
- package/src/trace/024-compact-observation-decision.ts +81 -0
- package/src/trace/025-trace-implementation-scope.ts +123 -0
- package/src/trace/026-trace-start-scope.ts +336 -0
- package/src/trace/027-trace-scope-execution.ts +566 -0
- package/src/trace/028-trace-operation-execution.ts +336 -0
- package/src/trace/029-trace-start-implementation.ts +172 -0
- package/src/trace/030-event-runtime-resolution.ts +151 -0
- package/src/trace/031-local-call-expansion.ts +37 -0
- package/src/trace/implementation-hints.ts +9 -6
- package/src/trace/selectors.ts +1 -0
- package/src/trace/trace-engine.ts +122 -624
- package/src/types.ts +57 -0
- package/src/utils/001-placeholders.ts +188 -10
- package/src/version.ts +1 -1
- package/dist/chunk-ZQABU7MR.js +0 -12151
- package/dist/chunk-ZQABU7MR.js.map +0 -1
|
@@ -7,11 +7,49 @@ interface ParsePackageJsonOptions {
|
|
|
7
7
|
}
|
|
8
8
|
export interface PackageJsonSnapshot {
|
|
9
9
|
facts: PackageFacts;
|
|
10
|
+
manifest: PackageEntrypointManifest;
|
|
10
11
|
rawText: string;
|
|
11
12
|
}
|
|
13
|
+
export interface PackageEntrypointManifest {
|
|
14
|
+
mainPresent: boolean;
|
|
15
|
+
main: string | null;
|
|
16
|
+
modulePresent: boolean;
|
|
17
|
+
module: string | null;
|
|
18
|
+
exportsPresent: boolean;
|
|
19
|
+
exportsValue: unknown;
|
|
20
|
+
}
|
|
21
|
+
function emptyManifest(): PackageEntrypointManifest {
|
|
22
|
+
return {
|
|
23
|
+
mainPresent: false,
|
|
24
|
+
main: null,
|
|
25
|
+
modulePresent: false,
|
|
26
|
+
module: null,
|
|
27
|
+
exportsPresent: false,
|
|
28
|
+
exportsValue: null,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function entrypointManifest(
|
|
32
|
+
json: Record<string, unknown>,
|
|
33
|
+
): PackageEntrypointManifest {
|
|
34
|
+
const mainPresent = Object.hasOwn(json, 'main');
|
|
35
|
+
const modulePresent = Object.hasOwn(json, 'module');
|
|
36
|
+
const exportsPresent = Object.hasOwn(json, 'exports');
|
|
37
|
+
return {
|
|
38
|
+
mainPresent,
|
|
39
|
+
main: typeof json.main === 'string' ? json.main : null,
|
|
40
|
+
modulePresent,
|
|
41
|
+
module: typeof json.module === 'string' ? json.module : null,
|
|
42
|
+
exportsPresent,
|
|
43
|
+
exportsValue: exportsPresent ? json.exports : null,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
12
46
|
function emptyPackageFacts(): PackageFacts {
|
|
13
47
|
return { dependencies: {}, cdsRequires: [], scripts: {} };
|
|
14
48
|
}
|
|
49
|
+
function isMissingFileError(error: unknown): boolean {
|
|
50
|
+
return typeof error === 'object' && error !== null
|
|
51
|
+
&& 'code' in error && error.code === 'ENOENT';
|
|
52
|
+
}
|
|
15
53
|
function recordOfString(value: unknown): Record<string, string> {
|
|
16
54
|
if (!value || typeof value !== 'object') return {};
|
|
17
55
|
return Object.fromEntries(
|
|
@@ -66,6 +104,7 @@ export async function loadPackageJsonSnapshot(
|
|
|
66
104
|
const json = JSON.parse(raw) as Record<string, unknown>;
|
|
67
105
|
return {
|
|
68
106
|
rawText: raw,
|
|
107
|
+
manifest: entrypointManifest(json),
|
|
69
108
|
facts: {
|
|
70
109
|
packageName: typeof json.name === 'string' ? json.name : undefined,
|
|
71
110
|
packageVersion:
|
|
@@ -79,10 +118,13 @@ export async function loadPackageJsonSnapshot(
|
|
|
79
118
|
},
|
|
80
119
|
};
|
|
81
120
|
} catch (error) {
|
|
82
|
-
const missing =
|
|
83
|
-
&& 'code' in error && error.code === 'ENOENT';
|
|
121
|
+
const missing = isMissingFileError(error);
|
|
84
122
|
if (!options.strict || (options.allowMissing && missing))
|
|
85
|
-
return {
|
|
123
|
+
return {
|
|
124
|
+
facts: emptyPackageFacts(),
|
|
125
|
+
manifest: emptyManifest(),
|
|
126
|
+
rawText: '',
|
|
127
|
+
};
|
|
86
128
|
throw error;
|
|
87
129
|
}
|
|
88
130
|
}
|
|
@@ -47,24 +47,95 @@ function placeholders(value?: string): string[] {
|
|
|
47
47
|
return extractPlaceholderKeys(value);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
type ConnectFact = Omit<
|
|
51
|
+
HelperBinding,
|
|
52
|
+
'exportedName' | 'sourceFile' | 'sourceLine'
|
|
53
|
+
>;
|
|
54
|
+
|
|
55
|
+
function connectMethod(
|
|
56
|
+
call: ts.CallExpression,
|
|
57
|
+
): 'to' | 'messaging' | undefined {
|
|
58
|
+
const expression = call.expression;
|
|
59
|
+
if (!ts.isPropertyAccessExpression(expression)
|
|
60
|
+
|| !['to', 'messaging'].includes(expression.name.text)) return undefined;
|
|
61
|
+
const receiver = expression.expression;
|
|
62
|
+
if (!ts.isPropertyAccessExpression(receiver)
|
|
63
|
+
|| receiver.name.text !== 'connect'
|
|
64
|
+
|| receiver.expression.getText() !== 'cds') return undefined;
|
|
65
|
+
return expression.name.text === 'messaging' ? 'messaging' : 'to';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function connectObject(
|
|
69
|
+
first: ts.Expression,
|
|
70
|
+
second: ts.Expression | undefined,
|
|
71
|
+
): ts.ObjectLiteralExpression | undefined {
|
|
72
|
+
if (ts.isObjectLiteralExpression(first)) return first;
|
|
73
|
+
return second && ts.isObjectLiteralExpression(second)
|
|
74
|
+
? second
|
|
75
|
+
: undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function connectNames(
|
|
79
|
+
method: 'to' | 'messaging',
|
|
80
|
+
first: ts.Expression,
|
|
81
|
+
): { alias?: string; aliasExpr?: string } {
|
|
82
|
+
if (ts.isStringLiteralLike(first)
|
|
83
|
+
|| ts.isNoSubstitutionTemplateLiteral(first))
|
|
84
|
+
return { alias: first.text };
|
|
85
|
+
if (ts.isObjectLiteralExpression(first))
|
|
86
|
+
return method === 'messaging' ? { alias: 'messaging' } : {};
|
|
87
|
+
return { aliasExpr: stringValue(first) };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function literalConnectFact(
|
|
91
|
+
first: ts.Expression,
|
|
92
|
+
object: ts.ObjectLiteralExpression | undefined,
|
|
93
|
+
): ConnectFact | undefined {
|
|
94
|
+
if (object || (!ts.isStringLiteralLike(first)
|
|
95
|
+
&& !ts.isNoSubstitutionTemplateLiteral(first))) return undefined;
|
|
96
|
+
return { alias: first.text, isDynamic: false, placeholders: [] };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function dynamicConnectFact(
|
|
100
|
+
placeholdersFound: readonly string[],
|
|
101
|
+
expressions: { destinationExpr?: string; servicePathExpr?: string },
|
|
102
|
+
): boolean {
|
|
103
|
+
return placeholdersFound.length > 0
|
|
104
|
+
|| (!expressions.destinationExpr && !expressions.servicePathExpr);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function connectFactFromCall(
|
|
108
|
+
call: ts.CallExpression,
|
|
109
|
+
): ConnectFact | undefined {
|
|
110
|
+
const method = connectMethod(call);
|
|
111
|
+
if (!method) return undefined;
|
|
55
112
|
const first = call.arguments[0];
|
|
56
|
-
if (!first)
|
|
113
|
+
if (!first)
|
|
114
|
+
return method === 'messaging'
|
|
115
|
+
? { alias: 'messaging', isDynamic: false, placeholders: [] }
|
|
116
|
+
: undefined;
|
|
57
117
|
const second = call.arguments[1];
|
|
58
|
-
const objectArg =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
118
|
+
const objectArg = connectObject(first, second);
|
|
119
|
+
const names = connectNames(method, first);
|
|
120
|
+
const literal = literalConnectFact(first, objectArg);
|
|
121
|
+
if (literal) return literal;
|
|
122
|
+
if (!objectArg && names.aliasExpr) return {
|
|
123
|
+
aliasExpr: names.aliasExpr,
|
|
124
|
+
isDynamic: true,
|
|
125
|
+
placeholders: placeholders(names.aliasExpr),
|
|
126
|
+
};
|
|
65
127
|
const expressions = objectArg ? objectExpressions(objectArg) : {};
|
|
66
|
-
const ph = [
|
|
67
|
-
|
|
128
|
+
const ph = [
|
|
129
|
+
...placeholders(names.aliasExpr ?? names.alias),
|
|
130
|
+
...placeholders(expressions.destinationExpr),
|
|
131
|
+
...placeholders(expressions.servicePathExpr),
|
|
132
|
+
];
|
|
133
|
+
return {
|
|
134
|
+
...names,
|
|
135
|
+
...expressions,
|
|
136
|
+
isDynamic: dynamicConnectFact(ph, expressions),
|
|
137
|
+
placeholders: ph,
|
|
138
|
+
};
|
|
68
139
|
}
|
|
69
140
|
|
|
70
141
|
function objectExpressions(objectArg: ts.ObjectLiteralExpression): { destinationExpr?: string; servicePathExpr?: string } {
|