@saptools/service-flow 0.1.66 → 0.1.68

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +20 -8
  3. package/TECHNICAL-NOTE.md +27 -0
  4. package/dist/{chunk-TOVX4WYH.js → chunk-AEM4JY22.js} +12676 -6714
  5. package/dist/chunk-AEM4JY22.js.map +1 -0
  6. package/dist/cli.js +2325 -413
  7. package/dist/cli.js.map +1 -1
  8. package/dist/index.d.ts +61 -2
  9. package/dist/index.js +1 -1
  10. package/package.json +1 -1
  11. package/src/cli/003-doctor-package-resolution.ts +68 -0
  12. package/src/cli/doctor.ts +25 -14
  13. package/src/db/000-call-fact-repository.ts +475 -342
  14. package/src/db/001-fact-lifecycle.ts +60 -30
  15. package/src/db/002-fact-json-inventory.ts +169 -0
  16. package/src/db/003-current-fact-semantics.ts +698 -0
  17. package/src/db/004-package-target-invalidation.ts +173 -0
  18. package/src/db/005-schema-structure.ts +201 -0
  19. package/src/db/006-relative-symbol-resolution.ts +443 -0
  20. package/src/db/007-package-fact-semantics.ts +573 -0
  21. package/src/db/008-relative-fact-semantics.ts +207 -0
  22. package/src/db/009-binding-fact-semantics.ts +347 -0
  23. package/src/db/010-package-symbol-surface-semantics.ts +320 -0
  24. package/src/db/011-symbol-call-semantics.ts +144 -0
  25. package/src/db/012-binding-reference-proof.ts +264 -0
  26. package/src/db/migrations.ts +16 -3
  27. package/src/db/repositories.ts +113 -6
  28. package/src/db/schema.ts +4 -2
  29. package/src/index.ts +12 -0
  30. package/src/indexer/repository-indexer.ts +72 -11
  31. package/src/indexer/workspace-indexer.ts +123 -32
  32. package/src/linker/003-package-import-symbol-resolver.ts +363 -131
  33. package/src/linker/004-event-subscription-handler-linker.ts +2 -0
  34. package/src/linker/005-odata-path-structure.ts +371 -0
  35. package/src/linker/cross-repo-linker.ts +2 -1
  36. package/src/linker/odata-path-normalizer.ts +273 -180
  37. package/src/linker/service-resolver.ts +197 -77
  38. package/src/parsers/002-symbol-import-bindings.ts +516 -0
  39. package/src/parsers/003-package-public-surface.ts +661 -0
  40. package/src/parsers/004-fact-identity.ts +108 -0
  41. package/src/parsers/005-event-subscription-facts.ts +281 -0
  42. package/src/parsers/006-binding-identity.ts +343 -0
  43. package/src/parsers/007-source-fact-reconciliation.ts +105 -0
  44. package/src/parsers/008-package-surface-publication.ts +82 -0
  45. package/src/parsers/009-symbol-call-facts.ts +528 -0
  46. package/src/parsers/010-package-public-surface-analysis.ts +352 -0
  47. package/src/parsers/011-binding-lexical-scope.ts +583 -0
  48. package/src/parsers/012-package-fact-contract.ts +306 -0
  49. package/src/parsers/013-executable-body-eligibility.ts +35 -0
  50. package/src/parsers/014-service-binding-helper-flow.ts +240 -0
  51. package/src/parsers/015-service-binding-collector.ts +693 -0
  52. package/src/parsers/016-local-symbol-reference.ts +261 -0
  53. package/src/parsers/017-symbol-derived-contexts.ts +268 -0
  54. package/src/parsers/018-package-commonjs-syntax.ts +142 -0
  55. package/src/parsers/019-binding-assignment-targets.ts +76 -0
  56. package/src/parsers/020-stable-local-value.ts +217 -0
  57. package/src/parsers/021-binding-visibility.ts +152 -0
  58. package/src/parsers/operation-path-analysis.ts +6 -1
  59. package/src/parsers/outbound-call-parser.ts +19 -6
  60. package/src/parsers/package-json-parser.ts +45 -3
  61. package/src/parsers/service-binding-parser-helpers.ts +86 -15
  62. package/src/parsers/service-binding-parser.ts +147 -597
  63. package/src/parsers/symbol-parser.ts +482 -353
  64. package/src/trace/002-trace-diagnostics.ts +36 -1
  65. package/src/trace/016-compact-projector.ts +16 -17
  66. package/src/trace/020-compact-field-projection.ts +48 -37
  67. package/src/trace/021-compact-decision-normalization.ts +105 -0
  68. package/src/trace/022-trace-fact-preflight.ts +21 -0
  69. package/src/trace/023-nested-event-scopes.ts +23 -0
  70. package/src/trace/024-compact-observation-decision.ts +76 -0
  71. package/src/trace/025-trace-implementation-scope.ts +123 -0
  72. package/src/trace/026-trace-start-scope.ts +335 -0
  73. package/src/trace/027-trace-scope-execution.ts +566 -0
  74. package/src/trace/028-trace-operation-execution.ts +336 -0
  75. package/src/trace/029-trace-start-implementation.ts +172 -0
  76. package/src/trace/trace-engine.ts +122 -624
  77. package/src/types.ts +56 -0
  78. package/src/utils/001-placeholders.ts +188 -10
  79. package/src/version.ts +1 -1
  80. package/dist/chunk-TOVX4WYH.js.map +0 -1
@@ -47,24 +47,95 @@ function placeholders(value?: string): string[] {
47
47
  return extractPlaceholderKeys(value);
48
48
  }
49
49
 
50
- export function connectFactFromCall(call: ts.CallExpression): Omit<HelperBinding, 'exportedName' | 'sourceFile' | 'sourceLine'> | undefined {
51
- const expr = call.expression;
52
- if (!ts.isPropertyAccessExpression(expr) || expr.name.text !== 'to') return undefined;
53
- const inner = expr.expression;
54
- if (!ts.isPropertyAccessExpression(inner) || inner.name.text !== 'connect' || inner.expression.getText() !== 'cds') return undefined;
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) return undefined;
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 = ts.isObjectLiteralExpression(first) ? first : second && ts.isObjectLiteralExpression(second) ? second : undefined;
59
- let alias: string | undefined;
60
- let aliasExpr: string | undefined;
61
- if (ts.isStringLiteralLike(first) || ts.isNoSubstitutionTemplateLiteral(first)) alias = first.text;
62
- else if (!ts.isObjectLiteralExpression(first)) aliasExpr = stringValue(first);
63
- if ((ts.isStringLiteralLike(first) || ts.isNoSubstitutionTemplateLiteral(first)) && !objectArg) return { alias: first.text, isDynamic: false, placeholders: [] };
64
- if (!objectArg && aliasExpr) return { aliasExpr, isDynamic: true, placeholders: placeholders(aliasExpr) };
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 = [...placeholders(aliasExpr ?? alias), ...placeholders(expressions.destinationExpr), ...placeholders(expressions.servicePathExpr)];
67
- return { alias, aliasExpr, ...expressions, isDynamic: ph.length > 0 || (!expressions.destinationExpr && !expressions.servicePathExpr), placeholders: ph };
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 } {