@saptools/service-flow 0.1.60 → 0.1.62

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saptools/service-flow",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
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": {
@@ -1,16 +1,21 @@
1
1
  import type { TraceResult } from '../types.js';
2
- function safe(value: string): string {
3
- return value.replace(/[^\w-]/g, '_').slice(0, 60);
4
- }
5
2
  function label(trace: TraceResult, idOrLabel: string): string {
6
3
  const node = trace.nodes.find((item) => item.id === idOrLabel || item.label === idOrLabel);
7
4
  return String(node?.label ?? idOrLabel);
8
5
  }
9
6
  export function renderMermaid(trace: TraceResult): string {
7
+ const ids = new Map<string, string>();
8
+ const nodeId = (value: string): string => {
9
+ const existing = ids.get(value);
10
+ if (existing) return existing;
11
+ const id = `n${ids.size}`;
12
+ ids.set(value, id);
13
+ return id;
14
+ };
10
15
  const lines = ['flowchart TD'];
11
16
  for (const e of trace.edges)
12
17
  lines.push(
13
- ` ${safe(e.from)}["${label(trace, e.from)}"] -->|${e.type}| ${safe(e.to)}["${label(trace, e.to)}"]`
18
+ ` ${nodeId(e.from)}["${label(trace, e.from)}"] -->|${e.type}| ${nodeId(e.to)}["${label(trace, e.to)}"]`
14
19
  );
15
20
  return `${lines.join('\n')}\n`;
16
21
  }
@@ -242,7 +242,17 @@ export async function parseExecutableSymbols(
242
242
  if (localName) addSymbol('method', localName, node, parentClass);
243
243
  } else if (ts.isPropertyDeclaration(node) && parentClass && node.initializer && (ts.isArrowFunction(node.initializer) || ts.isFunctionExpression(node.initializer))) {
244
244
  const localName = nameOf(node.name);
245
- if (localName) addSymbol('method', localName, node.initializer, parentClass, undefined, { source: 'class_property_function', memberKind: ts.isArrowFunction(node.initializer) ? 'arrow_function_property' : 'function_expression_property' });
245
+ if (localName) {
246
+ const flags = ts.getCombinedModifierFlags(node);
247
+ const staticPublicExported = exportedClasses.has(parentClass) && (flags & ts.ModifierFlags.Static) !== 0 && (flags & ts.ModifierFlags.Private) === 0 && (flags & ts.ModifierFlags.Protected) === 0;
248
+ const isArrow = ts.isArrowFunction(node.initializer);
249
+ const memberKind = isArrow
250
+ ? (staticPublicExported ? 'static_arrow_function' : 'arrow_function_property')
251
+ : (staticPublicExported ? 'static_function_expression' : 'function_expression_property');
252
+ addSymbol('method', localName, node.initializer, parentClass, staticPublicExported ? `${parentClass}.${localName}` : undefined, staticPublicExported
253
+ ? { source: 'exported_class_member', exportedClass: parentClass, memberKind }
254
+ : { source: 'class_property_function', memberKind });
255
+ }
246
256
  } else if (ts.isFunctionDeclaration(node) && node.name) addSymbol('function', node.name.text, node, undefined, exported(node) ? node.name.text : undefined);
247
257
  else if (ts.isVariableStatement(node)) {
248
258
  for (const d of node.declarationList.declarations) {