@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
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
analyzeODataPathStructure,
|
|
3
|
+
type ODataPathStructure,
|
|
4
|
+
} from './005-odata-path-structure.js';
|
|
5
|
+
|
|
1
6
|
export interface NormalizedODataOperationPath {
|
|
2
7
|
rawOperationPath: string;
|
|
3
8
|
normalizedOperationPath: string;
|
|
@@ -33,207 +38,295 @@ export interface ODataPathIntent {
|
|
|
33
38
|
reason: string;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
interface NavigationEvidence {
|
|
42
|
+
readonly navigation: boolean;
|
|
43
|
+
readonly suffix?: string;
|
|
44
|
+
readonly navigationSuffix?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface OperationEvidence {
|
|
48
|
+
readonly invocation: boolean;
|
|
49
|
+
readonly name?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function normalizeODataOperationInvocationPath(
|
|
53
|
+
path: string | undefined,
|
|
54
|
+
): NormalizedODataOperationPath | undefined {
|
|
37
55
|
if (path === undefined) return undefined;
|
|
38
56
|
const raw = path.trim();
|
|
39
57
|
if (!raw) return undefined;
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
if (close === undefined) return rejected('top_level_invocation_parenthesis_is_unbalanced');
|
|
49
|
-
if (raw.slice(close + 1).trim().length > 0) return rejected('top_level_invocation_does_not_cover_remaining_path');
|
|
50
|
-
const operationSegment = raw.slice(0, open).trim();
|
|
51
|
-
if (operationSegment.length <= 1) return rejected('operation_segment_is_empty');
|
|
58
|
+
const structure = analyzeODataPathStructure(raw);
|
|
59
|
+
const rejection = normalizationRejection(raw, structure);
|
|
60
|
+
if (rejection) return rejectedNormalization(raw, rejection);
|
|
61
|
+
const operationSegment = raw.slice(
|
|
62
|
+
0, structure.firstParenthesisOpen ?? 0,
|
|
63
|
+
).trim();
|
|
64
|
+
if (operationSegment.length <= 1)
|
|
65
|
+
return rejectedNormalization(raw, 'operation_segment_is_empty');
|
|
52
66
|
return {
|
|
53
67
|
rawOperationPath: raw,
|
|
54
68
|
normalizedOperationPath: operationSegment,
|
|
55
69
|
wasInvocation: true,
|
|
56
|
-
invocationArguments:
|
|
57
|
-
invocationArgumentPlaceholderKeys:
|
|
70
|
+
invocationArguments: structure.firstParenthesisArguments,
|
|
71
|
+
invocationArgumentPlaceholderKeys:
|
|
72
|
+
structure.firstParenthesisPlaceholderKeys,
|
|
58
73
|
normalizationReason: 'balanced_top_level_operation_invocation',
|
|
59
74
|
};
|
|
60
75
|
}
|
|
61
76
|
|
|
62
|
-
|
|
77
|
+
function normalizationRejection(
|
|
78
|
+
raw: string,
|
|
79
|
+
structure: ODataPathStructure,
|
|
80
|
+
): string | undefined {
|
|
81
|
+
if (structure.status === 'malformed')
|
|
82
|
+
return structure.reason ?? 'path_structure_is_malformed';
|
|
83
|
+
if (structure.firstParenthesisOpen === undefined)
|
|
84
|
+
return 'no_top_level_parenthesis';
|
|
85
|
+
if (structure.queryIndex !== undefined)
|
|
86
|
+
return 'query_string_paths_are_not_operation_invocations';
|
|
87
|
+
if (!raw.startsWith('/')) return 'path_is_not_absolute';
|
|
88
|
+
if (structure.segments.length !== 1)
|
|
89
|
+
return 'operation_segment_contains_navigation_separator';
|
|
90
|
+
if (structure.firstSegmentHeadRuntimeDependent)
|
|
91
|
+
return 'operation_segment_is_runtime_dependent';
|
|
92
|
+
if (structure.firstParenthesisClose === undefined)
|
|
93
|
+
return 'top_level_invocation_parenthesis_is_unbalanced';
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function rejectedNormalization(
|
|
98
|
+
raw: string,
|
|
99
|
+
reason: string,
|
|
100
|
+
): NormalizedODataOperationPath {
|
|
101
|
+
return {
|
|
102
|
+
rawOperationPath: raw, normalizedOperationPath: raw,
|
|
103
|
+
wasInvocation: false, invocationArgumentPlaceholderKeys: [],
|
|
104
|
+
normalizationRejectedReason: reason,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function classifyODataPathIntent(
|
|
109
|
+
path: string | undefined,
|
|
110
|
+
method: string | undefined,
|
|
111
|
+
): ODataPathIntent {
|
|
63
112
|
const rawPath = (path ?? '').trim();
|
|
64
113
|
const normalizedMethod = (method ?? 'GET').trim().toUpperCase() || 'GET';
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const keyPredicatePlaceholderKeys = topLevelOperationInvocation ? [] : rawKeyPredicatePlaceholderKeys;
|
|
86
|
-
const topLevelOperationNameCandidate = Boolean(topLevelOperationName && !hasNavigationSegments && !firstSegment.includes('('));
|
|
87
|
-
const base = { rawPath, method: normalizedMethod, pathWithoutQuery, queryString, hasQueryString: queryIndex >= 0, entitySegment, placeholderKeys, keyPredicatePlaceholderKeys, invocationArguments: invocation?.invocationArguments, invocationArgumentPlaceholderKeys: invocation?.invocationArgumentPlaceholderKeys ?? [], navigationSuffix, mediaOrPropertySuffix, hasEntityKeyPredicate: firstOpen >= 0 && firstClose !== undefined, hasNavigationSuffix: hasNavigationSegments, hasMediaOrPropertySuffix: Boolean(mediaOrPropertySuffix && isMediaOrPropertySuffix(mediaOrPropertySuffix)), topLevelOperationName, topLevelOperationNameCandidate, topLevelOperationInvocation };
|
|
88
|
-
if (!rawPath || !rawPath.startsWith('/')) return { ...base, kind: 'unknown', reason: 'path_missing_or_not_absolute' };
|
|
89
|
-
const upperEntityLike = /^[A-Z][A-Za-z0-9_]*$/.test(entitySegment ?? firstSegment);
|
|
90
|
-
const mediaLike = isMediaOrPropertySuffix(segments.at(-1) ?? '');
|
|
91
|
-
if (normalizedMethod !== 'GET') {
|
|
92
|
-
if (invocation?.wasInvocation && looksLikeLowerCamelInvocation(firstSegment)) return { ...base, kind: 'operation_invocation', reason: 'non_get_balanced_top_level_operation_invocation' };
|
|
93
|
-
if (mediaLike) return { ...base, kind: 'entity_media', reason: 'non_get_entity_media_stream_path' };
|
|
94
|
-
if (hasNavigationSegments || firstSegment.includes('(')) return { ...base, kind: normalizedMethod === 'DELETE' ? 'entity_delete' : 'entity_mutation', reason: firstSegment.includes('(') ? 'non_get_entity_key_or_navigation_path_shape' : 'non_get_entity_navigation_path_shape' };
|
|
95
|
-
if (upperEntityLike) return { ...base, kind: normalizedMethod === 'DELETE' ? 'entity_delete' : 'entity_mutation', reason: 'non_get_entity_path_shape' };
|
|
96
|
-
return { ...base, kind: 'operation_invocation', reason: 'non_get_lowercase_path_may_be_operation' };
|
|
97
|
-
}
|
|
98
|
-
if (queryIndex >= 0) {
|
|
99
|
-
if (hasNavigationSegments) return { ...base, kind: 'entity_navigation_query', reason: 'get_path_has_navigation_and_query_string' };
|
|
100
|
-
if (looksLikeLowerCamelInvocation(firstSegment)) return { ...base, kind: 'unknown', reason: 'get_invocation_with_query_string_requires_indexed_operation_evidence' };
|
|
101
|
-
return { ...base, kind: 'entity_query', reason: 'get_collection_path_has_query_string' };
|
|
102
|
-
}
|
|
103
|
-
if (hasNavigationSegments) return mediaLike ? { ...base, kind: 'entity_media', reason: 'get_entity_media_stream_path' } : { ...base, kind: 'entity_navigation_query', reason: 'get_path_has_navigation_segments' };
|
|
104
|
-
if (firstSegment.includes('(')) {
|
|
105
|
-
if (invocation?.wasInvocation && looksLikeLowerCamelInvocation(firstSegment)) return { ...base, kind: 'operation_invocation', reason: 'get_balanced_top_level_operation_invocation' };
|
|
106
|
-
return looksLikeLowerCamelInvocation(firstSegment)
|
|
107
|
-
? { ...base, kind: 'operation_invocation', reason: 'get_single_lower_camel_segment_has_top_level_invocation' }
|
|
108
|
-
: { ...base, kind: 'entity_key_read', reason: 'get_entity_segment_has_key_predicate' };
|
|
109
|
-
}
|
|
110
|
-
if (/^[A-Z][A-Za-z0-9_]*$/.test(firstSegment)) return { ...base, kind: 'entity_candidate', reason: 'uppercase_collection_segment_without_indexed_entity_evidence' };
|
|
111
|
-
return { ...base, kind: 'unknown', reason: 'get_path_has_no_query_key_or_navigation_signal' };
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function entitySegmentFromPath(path: string): string | undefined {
|
|
115
|
-
const first = path.replace(/^\//, '').split('/')[0]?.trim();
|
|
116
|
-
if (!first) return undefined;
|
|
117
|
-
const open = first.indexOf('(');
|
|
118
|
-
const entity = (open >= 0 ? first.slice(0, open) : first).trim();
|
|
119
|
-
return entity || undefined;
|
|
114
|
+
const structure = analyzeODataPathStructure(rawPath);
|
|
115
|
+
const invocation = normalizeODataOperationInvocationPath(
|
|
116
|
+
structure.pathWithoutQuery,
|
|
117
|
+
);
|
|
118
|
+
const base = intentBase(structure, normalizedMethod, invocation);
|
|
119
|
+
if (!rawPath || !rawPath.startsWith('/'))
|
|
120
|
+
return { ...base, kind: 'unknown', reason: 'path_missing_or_not_absolute' };
|
|
121
|
+
if (structure.status === 'malformed')
|
|
122
|
+
return {
|
|
123
|
+
...base, kind: 'unknown',
|
|
124
|
+
reason: structure.reason ?? 'path_structure_is_malformed',
|
|
125
|
+
};
|
|
126
|
+
if (structure.firstSegmentHeadRuntimeDependent)
|
|
127
|
+
return {
|
|
128
|
+
...base, kind: 'unknown',
|
|
129
|
+
reason: 'path_classification_head_is_runtime_dependent',
|
|
130
|
+
};
|
|
131
|
+
return normalizedMethod === 'GET'
|
|
132
|
+
? classifyGet(structure, base, invocation)
|
|
133
|
+
: classifyMutation(structure, base, invocation, normalizedMethod);
|
|
120
134
|
}
|
|
121
135
|
|
|
122
|
-
function
|
|
123
|
-
|
|
136
|
+
function intentBase(
|
|
137
|
+
structure: ODataPathStructure,
|
|
138
|
+
method: string,
|
|
139
|
+
invocation: NormalizedODataOperationPath | undefined,
|
|
140
|
+
): Omit<ODataPathIntent, 'kind' | 'reason'> {
|
|
141
|
+
const segments = structure.segments;
|
|
142
|
+
const navigation = navigationEvidence(segments);
|
|
143
|
+
const operation = operationEvidence(structure, invocation, navigation.navigation);
|
|
144
|
+
return {
|
|
145
|
+
rawPath: structure.rawPath, method,
|
|
146
|
+
pathWithoutQuery: structure.pathWithoutQuery,
|
|
147
|
+
queryString: structure.queryString,
|
|
148
|
+
hasQueryString: structure.queryIndex !== undefined,
|
|
149
|
+
entitySegment: structure.firstSegmentHead,
|
|
150
|
+
placeholderKeys: structure.placeholderKeys,
|
|
151
|
+
keyPredicatePlaceholderKeys: operation.invocation
|
|
152
|
+
? [] : structure.firstParenthesisPlaceholderKeys,
|
|
153
|
+
invocationArgumentPlaceholderKeys:
|
|
154
|
+
invocation?.invocationArgumentPlaceholderKeys ?? [],
|
|
155
|
+
invocationArguments: invocation?.invocationArguments,
|
|
156
|
+
navigationSuffix: navigation.navigationSuffix,
|
|
157
|
+
mediaOrPropertySuffix: navigation.suffix,
|
|
158
|
+
hasEntityKeyPredicate: structure.firstParenthesisOpen !== undefined,
|
|
159
|
+
hasNavigationSuffix: navigation.navigation,
|
|
160
|
+
hasMediaOrPropertySuffix: Boolean(
|
|
161
|
+
navigation.suffix && isMediaOrPropertySuffix(navigation.suffix),
|
|
162
|
+
),
|
|
163
|
+
topLevelOperationName: operation.name,
|
|
164
|
+
topLevelOperationNameCandidate:
|
|
165
|
+
operationNameIsCandidate(operation, structure, navigation.navigation),
|
|
166
|
+
topLevelOperationInvocation: operation.invocation,
|
|
167
|
+
};
|
|
124
168
|
}
|
|
125
169
|
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return
|
|
170
|
+
function navigationEvidence(
|
|
171
|
+
segments: readonly { text: string }[],
|
|
172
|
+
): NavigationEvidence {
|
|
173
|
+
if (segments.length <= 1) return { navigation: false };
|
|
174
|
+
return {
|
|
175
|
+
navigation: true,
|
|
176
|
+
suffix: segments.at(-1)?.text,
|
|
177
|
+
navigationSuffix: segments.slice(1).map((item) => item.text).join('/'),
|
|
178
|
+
};
|
|
131
179
|
}
|
|
132
180
|
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function matchingClose(text: string, openIndex: number): number | undefined {
|
|
147
|
-
let depth = 0;
|
|
148
|
-
let quote: 'single' | 'double' | 'template' | undefined;
|
|
149
|
-
for (let index = openIndex; index < text.length; index += 1) {
|
|
150
|
-
const char = text[index];
|
|
151
|
-
const prev = text[index - 1];
|
|
152
|
-
if (quote) {
|
|
153
|
-
if (prev === '\\') continue;
|
|
154
|
-
if (quote === 'template' && char === '$' && text[index + 1] === '{') {
|
|
155
|
-
const close = matchingPlaceholderClose(text, index + 1);
|
|
156
|
-
if (close === undefined) return undefined;
|
|
157
|
-
index = close;
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
if ((quote === 'single' && char === "'") || (quote === 'double' && char === '"') || (quote === 'template' && char === '`')) quote = undefined;
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
if (char === '$' && text[index + 1] === '{') {
|
|
164
|
-
const close = matchingPlaceholderClose(text, index + 1);
|
|
165
|
-
if (close === undefined) return undefined;
|
|
166
|
-
index = close;
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
if (char === "'") { quote = 'single'; continue; }
|
|
170
|
-
if (char === '"') { quote = 'double'; continue; }
|
|
171
|
-
if (char === '`') { quote = 'template'; continue; }
|
|
172
|
-
if (char === '(') depth += 1;
|
|
173
|
-
if (char === ')') {
|
|
174
|
-
depth -= 1;
|
|
175
|
-
if (depth === 0) return index;
|
|
176
|
-
if (depth < 0) return undefined;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return undefined;
|
|
181
|
+
function operationEvidence(
|
|
182
|
+
structure: ODataPathStructure,
|
|
183
|
+
normalized: NormalizedODataOperationPath | undefined,
|
|
184
|
+
navigation: boolean,
|
|
185
|
+
): OperationEvidence {
|
|
186
|
+
if (normalized?.wasInvocation)
|
|
187
|
+
return {
|
|
188
|
+
invocation: looksLikeLowerCamelHead(structure.firstSegmentHead),
|
|
189
|
+
name: simpleName(normalized.normalizedOperationPath),
|
|
190
|
+
};
|
|
191
|
+
if (!navigation && structure.firstParenthesisOpen === undefined)
|
|
192
|
+
return { invocation: false, name: structure.firstSegmentHead };
|
|
193
|
+
return { invocation: false };
|
|
180
194
|
}
|
|
181
195
|
|
|
182
|
-
function
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return
|
|
196
|
+
function operationNameIsCandidate(
|
|
197
|
+
operation: OperationEvidence,
|
|
198
|
+
structure: ODataPathStructure,
|
|
199
|
+
navigation: boolean,
|
|
200
|
+
): boolean {
|
|
201
|
+
return Boolean(
|
|
202
|
+
operation.name && !navigation
|
|
203
|
+
&& structure.firstParenthesisOpen === undefined,
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function classifyGet(
|
|
208
|
+
structure: ODataPathStructure,
|
|
209
|
+
base: Omit<ODataPathIntent, 'kind' | 'reason'>,
|
|
210
|
+
invocation: NormalizedODataOperationPath | undefined,
|
|
211
|
+
): ODataPathIntent {
|
|
212
|
+
if (structure.queryIndex !== undefined) return classifyGetQuery(base);
|
|
213
|
+
if (base.hasNavigationSuffix)
|
|
214
|
+
return classifyGetNavigation(base);
|
|
215
|
+
if (structure.firstParenthesisOpen !== undefined)
|
|
216
|
+
return classifyGetParenthesis(base, invocation);
|
|
217
|
+
if (isUpperEntity(base.entitySegment))
|
|
218
|
+
return {
|
|
219
|
+
...base, kind: 'entity_candidate',
|
|
220
|
+
reason: 'uppercase_collection_segment_without_indexed_entity_evidence',
|
|
221
|
+
};
|
|
222
|
+
return {
|
|
223
|
+
...base, kind: 'unknown',
|
|
224
|
+
reason: 'get_path_has_no_query_key_or_navigation_signal',
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function classifyGetQuery(
|
|
229
|
+
base: Omit<ODataPathIntent, 'kind' | 'reason'>,
|
|
230
|
+
): ODataPathIntent {
|
|
231
|
+
if (base.hasNavigationSuffix)
|
|
232
|
+
return {
|
|
233
|
+
...base, kind: 'entity_navigation_query',
|
|
234
|
+
reason: 'get_path_has_navigation_and_query_string',
|
|
235
|
+
};
|
|
236
|
+
if (base.topLevelOperationInvocation)
|
|
237
|
+
return {
|
|
238
|
+
...base, kind: 'unknown',
|
|
239
|
+
reason: 'get_invocation_with_query_string_requires_indexed_operation_evidence',
|
|
240
|
+
};
|
|
241
|
+
return {
|
|
242
|
+
...base, kind: 'entity_query',
|
|
243
|
+
reason: 'get_collection_path_has_query_string',
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function classifyGetNavigation(
|
|
248
|
+
base: Omit<ODataPathIntent, 'kind' | 'reason'>,
|
|
249
|
+
): ODataPathIntent {
|
|
250
|
+
return base.hasMediaOrPropertySuffix
|
|
251
|
+
? { ...base, kind: 'entity_media', reason: 'get_entity_media_stream_path' }
|
|
252
|
+
: {
|
|
253
|
+
...base, kind: 'entity_navigation_query',
|
|
254
|
+
reason: 'get_path_has_navigation_segments',
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function classifyGetParenthesis(
|
|
259
|
+
base: Omit<ODataPathIntent, 'kind' | 'reason'>,
|
|
260
|
+
invocation: NormalizedODataOperationPath | undefined,
|
|
261
|
+
): ODataPathIntent {
|
|
262
|
+
if (invocation?.wasInvocation && base.topLevelOperationInvocation)
|
|
263
|
+
return {
|
|
264
|
+
...base, kind: 'operation_invocation',
|
|
265
|
+
reason: 'get_balanced_top_level_operation_invocation',
|
|
266
|
+
};
|
|
267
|
+
return {
|
|
268
|
+
...base, kind: 'entity_key_read',
|
|
269
|
+
reason: 'get_entity_segment_has_key_predicate',
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function classifyMutation(
|
|
274
|
+
structure: ODataPathStructure,
|
|
275
|
+
base: Omit<ODataPathIntent, 'kind' | 'reason'>,
|
|
276
|
+
invocation: NormalizedODataOperationPath | undefined,
|
|
277
|
+
method: string,
|
|
278
|
+
): ODataPathIntent {
|
|
279
|
+
if (invocation?.wasInvocation && base.topLevelOperationInvocation)
|
|
280
|
+
return {
|
|
281
|
+
...base, kind: 'operation_invocation',
|
|
282
|
+
reason: 'non_get_balanced_top_level_operation_invocation',
|
|
283
|
+
};
|
|
284
|
+
if (base.hasMediaOrPropertySuffix)
|
|
285
|
+
return {
|
|
286
|
+
...base, kind: 'entity_media',
|
|
287
|
+
reason: 'non_get_entity_media_stream_path',
|
|
288
|
+
};
|
|
289
|
+
if (base.hasNavigationSuffix || structure.firstParenthesisOpen !== undefined)
|
|
290
|
+
return mutationEntityIntent(base, method,
|
|
291
|
+
structure.firstParenthesisOpen !== undefined
|
|
292
|
+
? 'non_get_entity_key_or_navigation_path_shape'
|
|
293
|
+
: 'non_get_entity_navigation_path_shape');
|
|
294
|
+
if (isUpperEntity(base.entitySegment))
|
|
295
|
+
return mutationEntityIntent(base, method, 'non_get_entity_path_shape');
|
|
296
|
+
return {
|
|
297
|
+
...base, kind: 'operation_invocation',
|
|
298
|
+
reason: 'non_get_lowercase_path_may_be_operation',
|
|
299
|
+
};
|
|
209
300
|
}
|
|
210
301
|
|
|
211
|
-
function
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
302
|
+
function mutationEntityIntent(
|
|
303
|
+
base: Omit<ODataPathIntent, 'kind' | 'reason'>,
|
|
304
|
+
method: string,
|
|
305
|
+
reason: string,
|
|
306
|
+
): ODataPathIntent {
|
|
307
|
+
return {
|
|
308
|
+
...base,
|
|
309
|
+
kind: method === 'DELETE' ? 'entity_delete' : 'entity_mutation',
|
|
310
|
+
reason,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function simpleName(path: string): string {
|
|
315
|
+
const value = path.replace(/^\//, '');
|
|
316
|
+
return value.split('.').at(-1) ?? value;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function isUpperEntity(value: string | undefined): boolean {
|
|
320
|
+
return Boolean(value && /^[A-Z][A-Za-z0-9_]*$/.test(value));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function looksLikeLowerCamelHead(value: string | undefined): boolean {
|
|
324
|
+
if (!value) return false;
|
|
325
|
+
const name = value.split('.').at(-1) ?? value;
|
|
326
|
+
return /^[a-z][A-Za-z0-9_]*$/.test(name);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function isMediaOrPropertySuffix(segment: string): boolean {
|
|
330
|
+
return ['file', 'content', '$value', 'metadata', 'items']
|
|
331
|
+
.includes(segment.toLowerCase());
|
|
239
332
|
}
|