@saptools/service-flow 0.1.59 → 0.1.60

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/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  stripQuotes,
18
18
  substituteVariables,
19
19
  trace
20
- } from "./chunk-GLZSDBRG.js";
20
+ } from "./chunk-BGD7UYJN.js";
21
21
 
22
22
  // src/parsers/generated-constants-parser.ts
23
23
  import fs from "fs/promises";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saptools/service-flow",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
4
4
  "description": "Trace SAP CAP service-to-service flows across multi-repository workspaces with runtime-aware graph resolution",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -57,18 +57,6 @@ function queryRunEvidence(
57
57
  } : {}),
58
58
  };
59
59
  }
60
- function extractQueryEntity(expr: string): string | undefined {
61
- const source = ts.createSourceFile('query.ts', `const __query = (${expr});`, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
62
- const initializers = variableInitializers(source);
63
- let found: string | undefined;
64
- const visit = (node: ts.Node): void => {
65
- if (found) return;
66
- if (ts.isParenthesizedExpression(node)) found = queryEntityFromAst(node.expression, initializers);
67
- ts.forEachChild(node, visit);
68
- };
69
- visit(source);
70
- return found;
71
- }
72
60
  function queryWarning(expr: string): string {
73
61
  if (/^\s*[`'"]/.test(expr)) return 'raw_sql_or_cql_expression';
74
62
  if (/^\s*\w+\s*$/.test(expr)) return 'query_variable_without_static_initializer';
@@ -387,7 +375,7 @@ export function classifyOutboundCallsInSource(source: ts.SourceFile, filePath: s
387
375
  const objectArg = node.arguments[0];
388
376
  if (objectArg && ts.isObjectLiteralExpression(objectArg)) {
389
377
  const receiver = receiverName(expr.expression);
390
- const query = objectPropertyText(objectArg, 'query');
378
+ const queryExpression = propertyInitializer(objectArg, 'query');
391
379
  const method = stripQuotes(resolveExpression(propertyInitializer(objectArg, 'method'), node, 'literal').value ?? objectPropertyText(objectArg, 'method') ?? 'POST');
392
380
  const pathExpr = propertyInitializer(objectArg, 'path') ?? propertyInitializer(objectArg, 'event');
393
381
  const pathAnalysis = analyzeOperationPath(pathExpr, node, method);
@@ -398,8 +386,13 @@ export function classifyOutboundCallsInSource(source: ts.SourceFile, filePath: s
398
386
  const entityCallTypes: Record<string, OutboundCallFact['callType']> = { entity_mutation: 'remote_entity_mutation', entity_delete: 'remote_entity_delete', entity_media: 'remote_entity_media', entity_candidate: 'remote_entity_candidate' };
399
387
  const entityCallType = entityCallTypes[intent.kind];
400
388
  const isODataQueryRead = method.toUpperCase() === 'GET' && ['entity_query', 'entity_key_read', 'entity_navigation_query'].includes(intent.kind);
401
- const unresolvedReason = !query && pathExpr ? pathUnresolvedReason(pathAnalysis) : undefined;
402
- add(node, { callType: query ? 'remote_query' : entityCallType ?? (isODataQueryRead ? 'remote_query' : 'remote_action'), serviceVariableName: receiver, method, operationPathExpr, queryEntity: query ? extractQueryEntity(query) : isODataQueryRead ? intent.entitySegment : undefined, payloadSummary: summarizeExpression(objectArg.getText(source)), confidence: op || query ? 0.8 : 0.4, unresolvedReason }, { receiver, classifier: 'service_client_send_object', operationPathExpression: shorthandPath ? op : undefined, rawPathExpression: pathAnalysis.rawExpression, literalPathSource: literalPathSource(pathAnalysis), odataPathIntent: operationPathExpr ? intent : undefined, pathAnalysis, staticPathCandidates: legacyPathCandidates(pathAnalysis), parserWarning: unresolvedReason });
389
+ const queryEntity = queryExpression
390
+ ? queryEntityFromAst(queryExpression, initializers)
391
+ : isODataQueryRead ? intent.entitySegment : undefined;
392
+ const unresolvedReason = queryExpression
393
+ ? queryEntity ? undefined : queryWarning(queryExpression.getText(source))
394
+ : pathExpr ? pathUnresolvedReason(pathAnalysis) : undefined;
395
+ add(node, { callType: queryExpression ? 'remote_query' : entityCallType ?? (isODataQueryRead ? 'remote_query' : 'remote_action'), serviceVariableName: receiver, method, operationPathExpr, queryEntity, payloadSummary: summarizeExpression(objectArg.getText(source)), confidence: op || queryExpression ? 0.8 : 0.4, unresolvedReason }, { receiver, classifier: 'service_client_send_object', operationPathExpression: shorthandPath ? op : undefined, rawPathExpression: pathAnalysis.rawExpression, literalPathSource: literalPathSource(pathAnalysis), odataPathIntent: operationPathExpr ? intent : undefined, pathAnalysis, staticPathCandidates: legacyPathCandidates(pathAnalysis), parserWarning: unresolvedReason });
403
396
  } else {
404
397
  const receiver = receiverName(expr.expression);
405
398
  const rootReceiver = rootReceiverName(expr.expression);