@saptools/service-flow 0.1.0

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 ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - Initial `@saptools/service-flow` CLI package for indexing and tracing SAP CAP service flows.
package/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # @saptools/service-flow
2
+
3
+ `service-flow` is a standalone npm CLI for SAP CAP/CDS TypeScript workspaces made of many independent Git repositories. It statically indexes repositories, stores CAP facts in SQLite, links service-to-service calls across repository boundaries, and traces one exposed operation through handlers, helper packages, database access, remote OData calls, external HTTP calls, and async channels.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @saptools/service-flow
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```bash
14
+ service-flow init /path/to/workspace
15
+ service-flow index --workspace /path/to/workspace
16
+ service-flow link --workspace /path/to/workspace
17
+ service-flow trace --workspace /path/to/workspace --repo facade-service --operation doWork
18
+ service-flow graph --workspace /path/to/workspace --service /FacadeService --path /doWork --format mermaid
19
+ service-flow doctor --workspace /path/to/workspace
20
+ ```
21
+
22
+ ## Phases
23
+
24
+ - **init** discovers nested Git repositories, creates `.service-flow/service-flow.db`, saves workspace configuration, and records repository metadata.
25
+ - **index** parses each repository independently. It extracts `package.json#cds.requires`, CDS services and operations, decorator handlers, handler registrations, service bindings, outbound calls, async topics, external HTTP calls, and local database queries.
26
+ - **link** resolves indexed calls after every repository has been indexed. It creates graph edges for resolved remote operations, helper package imports, dynamic candidates, async topics, local DB calls, external destinations, and unresolved calls.
27
+ - **trace** starts from a repository, service path, operation, operation path, or handler selector and renders table, JSON, or Mermaid output.
28
+
29
+ ## Supported CAP patterns
30
+
31
+ The indexer supports CAP projects with `.cds` models, `@sap/cds` package metadata, `cds-routing-handlers` decorators, `cds.connect.to("alias")`, `remote.send({ method, path })`, `remote.send({ query })`, `cds.run(SELECT...)`, `cds.services.Service.operation()`, Event Mesh-style `emit`, `publish`, and `on`, Cloud SDK-style HTTP calls, generated constants, and thin service wrappers that import helper packages.
32
+
33
+ ## Dynamic edges
34
+
35
+ Dynamic destinations and service paths are preserved as parameterized edges:
36
+
37
+ ```text
38
+ destination: svc_${objectCode}_process
39
+ servicePath: /${objectType}ProcessService
40
+ operationPath: /getPaths
41
+ ```
42
+
43
+ Pass runtime values during trace:
44
+
45
+ ```bash
46
+ service-flow trace --repo facade-service --operation doWork --var objectCode=xx --var objectType=Thing
47
+ ```
48
+
49
+ The trace shows both the parameterized evidence and the concrete value used for matching when a target operation exists.
50
+
51
+ ## SQLite database location
52
+
53
+ By default, state is stored below the selected workspace:
54
+
55
+ ```text
56
+ /path/to/workspace/.service-flow/service-flow.db
57
+ ```
58
+
59
+ Use `service-flow init /path/to/workspace --db /custom/path/service-flow.db` to override it.
60
+
61
+ ## Security and redaction
62
+
63
+ The tool stores static source evidence and expression summaries only. It does not execute applications and does not persist runtime payload bodies. Keys matching `authorization`, `cookie`, `token`, `secret`, `password`, `key`, or `credential` are redacted in persisted summaries and CLI output.
64
+
65
+ ## Output examples
66
+
67
+ ```text
68
+ Start: facade-service /FacadeService doWork
69
+
70
+ Step Type From To Evidence
71
+ 1 local_db_query facade-service:srv/functions/Entry Entity: Template srv/functions/EntryHandler.ts:8
72
+ 2 remote_action facade-service:srv/functions/Entry /IdentityService/resolveAccess srv/functions/EntryHandler.ts:10
73
+ ```
74
+
75
+ ```json
76
+ {
77
+ "start": {
78
+ "repo": "facade-service",
79
+ "servicePath": "/FacadeService",
80
+ "operation": "doWork"
81
+ },
82
+ "nodes": [],
83
+ "edges": [],
84
+ "diagnostics": []
85
+ }
86
+ ```
87
+
88
+ ```mermaid
89
+ flowchart TD
90
+ EntryHandler -->|remote_action| IdentityService
91
+ ```
92
+
93
+ ## Limitations
94
+
95
+ - Static analysis cannot know all runtime branches.
96
+ - Dynamic service names may need `--var` values.
97
+ - Unsupported custom frameworks may appear as unresolved edges.
98
+ - Parse failures are stored as diagnostics and reported by `service-flow doctor`.
99
+ - The analysis favors explainable evidence and confidence scores over speculative resolution.
100
+
101
+ ## Troubleshooting
102
+
103
+ - Run `service-flow doctor --workspace /path/to/workspace` to inspect parse errors and unresolved diagnostics.
104
+ - Run `service-flow list repos --workspace /path/to/workspace` to confirm repository discovery.
105
+ - Run `service-flow list services --repo facade-service` and `service-flow list calls --repo facade-service` to inspect indexed facts.
106
+ - Use `service-flow clean --workspace /path/to/workspace --db-only` and re-run `init`, `index`, and `link` if the database becomes stale.