@ontemper/sdk 0.11.0 → 0.12.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.
Files changed (72) hide show
  1. package/README.md +134 -12
  2. package/dist/Contract/Manifest.d.ts +3 -2
  3. package/dist/Contract/Manifest.d.ts.map +1 -1
  4. package/dist/Contract/Manifest.js +2 -0
  5. package/dist/Contract/Manifest.js.map +1 -1
  6. package/dist/Contract/RuntimeApi.d.ts +8 -33
  7. package/dist/Contract/RuntimeApi.d.ts.map +1 -1
  8. package/dist/Contract/RuntimeApi.js +8 -32
  9. package/dist/Contract/RuntimeApi.js.map +1 -1
  10. package/dist/Contract/StaticGraph.d.ts +96 -0
  11. package/dist/Contract/StaticGraph.d.ts.map +1 -0
  12. package/dist/Contract/StaticGraph.js +92 -0
  13. package/dist/Contract/StaticGraph.js.map +1 -0
  14. package/dist/Contract/index.d.ts +1 -0
  15. package/dist/Contract/index.d.ts.map +1 -1
  16. package/dist/Contract/index.js +1 -0
  17. package/dist/Contract/index.js.map +1 -1
  18. package/dist/Manifest.d.ts +1 -1
  19. package/dist/Manifest.d.ts.map +1 -1
  20. package/dist/Manifest.js +17 -75
  21. package/dist/Manifest.js.map +1 -1
  22. package/dist/ResourcesToken.js +2 -2
  23. package/dist/ResourcesToken.js.map +1 -1
  24. package/dist/RuntimeResources.d.ts +3 -9
  25. package/dist/RuntimeResources.d.ts.map +1 -1
  26. package/dist/RuntimeResources.js +13 -53
  27. package/dist/RuntimeResources.js.map +1 -1
  28. package/dist/StaticGraph.d.ts +87 -0
  29. package/dist/StaticGraph.d.ts.map +1 -0
  30. package/dist/StaticGraph.js +237 -0
  31. package/dist/StaticGraph.js.map +1 -0
  32. package/dist/StaticGraphAnalyzer.d.ts +7 -0
  33. package/dist/StaticGraphAnalyzer.d.ts.map +1 -0
  34. package/dist/StaticGraphAnalyzer.js +162 -0
  35. package/dist/StaticGraphAnalyzer.js.map +1 -0
  36. package/dist/StaticGraphCalls.d.ts +15 -0
  37. package/dist/StaticGraphCalls.d.ts.map +1 -0
  38. package/dist/StaticGraphCalls.js +1028 -0
  39. package/dist/StaticGraphCalls.js.map +1 -0
  40. package/dist/StaticGraphDeclarations.d.ts +43 -0
  41. package/dist/StaticGraphDeclarations.d.ts.map +1 -0
  42. package/dist/StaticGraphDeclarations.js +443 -0
  43. package/dist/StaticGraphDeclarations.js.map +1 -0
  44. package/dist/StaticGraphProcess.d.ts +2 -0
  45. package/dist/StaticGraphProcess.d.ts.map +1 -0
  46. package/dist/StaticGraphProcess.js +55 -0
  47. package/dist/StaticGraphProcess.js.map +1 -0
  48. package/dist/StaticGraphProject.d.ts +65 -0
  49. package/dist/StaticGraphProject.d.ts.map +1 -0
  50. package/dist/StaticGraphProject.js +303 -0
  51. package/dist/StaticGraphProject.js.map +1 -0
  52. package/dist/StaticGraphProtocol.d.ts +82 -0
  53. package/dist/StaticGraphProtocol.d.ts.map +1 -0
  54. package/dist/StaticGraphProtocol.js +36 -0
  55. package/dist/StaticGraphProtocol.js.map +1 -0
  56. package/dist/StaticGraphRuntime.d.ts +25 -0
  57. package/dist/StaticGraphRuntime.d.ts.map +1 -0
  58. package/dist/StaticGraphRuntime.js +60 -0
  59. package/dist/StaticGraphRuntime.js.map +1 -0
  60. package/dist/StaticGraphValues.d.ts +243 -0
  61. package/dist/StaticGraphValues.d.ts.map +1 -0
  62. package/dist/StaticGraphValues.js +845 -0
  63. package/dist/StaticGraphValues.js.map +1 -0
  64. package/dist/StepCatalogRules.d.ts +33 -0
  65. package/dist/StepCatalogRules.d.ts.map +1 -0
  66. package/dist/StepCatalogRules.js +64 -0
  67. package/dist/StepCatalogRules.js.map +1 -0
  68. package/dist/cli.d.ts +1 -1
  69. package/dist/cli.d.ts.map +1 -1
  70. package/dist/cli.js +67 -9
  71. package/dist/cli.js.map +1 -1
  72. package/package.json +13 -4
@@ -0,0 +1,87 @@
1
+ import { type BuiltWorkflowManifest, TriggerMetadata, type WorkflowSteps } from './Contract/Manifest.js';
2
+ import type { FlowStaticGraph } from './Contract/StaticGraph.js';
3
+ /** The bounds of one extraction (FLOW-10). Past one of them the graph is omitted whole, never cut. */
4
+ export interface FlowExtractionLimits {
5
+ /** Deadline of the analyzer process; the parent kills it then. */
6
+ readonly timeoutMs: number;
7
+ /** Named calls followed inside one another. */
8
+ readonly maxDepth: number;
9
+ /** Nodes of all endpoints together. */
10
+ readonly maxNodes: number;
11
+ /** Bytes of the serialized `staticGraph`. */
12
+ readonly maxGraphBytes: number;
13
+ /** The V8 heap of the analyzer process. */
14
+ readonly maxMemoryMb: number;
15
+ /** Expressions the analyzer walks. */
16
+ readonly maxWork: number;
17
+ readonly maxFiles: number;
18
+ readonly maxSourceBytes: number;
19
+ }
20
+ export declare const DEFAULT_FLOW_EXTRACTION_LIMITS: FlowExtractionLimits;
21
+ export interface FlowExtractionOptions {
22
+ /** The workflow project folder, which holds `tsconfig.json`. Defaults to the working directory. */
23
+ readonly project?: string | undefined;
24
+ /** The workflow entrypoint, relative to the project. Defaults to `src/index.ts`. */
25
+ readonly entrypoint?: string | undefined;
26
+ readonly limits?: Partial<FlowExtractionLimits> | undefined;
27
+ }
28
+ /**
29
+ * `ok`: every part was derived. `incomplete`: the endpoints were read, and the steps or their calls were not.
30
+ * `unavailable`: nothing was read. A part that was not derived is `null`, never an empty list.
31
+ */
32
+ export type FlowExtractionStatus = 'ok' | 'incomplete' | 'unavailable';
33
+ /** One endpoint of the source; `trigger` is `null` when its annotation is not written as literals. */
34
+ export interface FlowExtractionEndpoint {
35
+ readonly group: string;
36
+ readonly name: string;
37
+ readonly method: string;
38
+ readonly path: string;
39
+ readonly trigger: TriggerMetadata | null;
40
+ }
41
+ /**
42
+ * Why nothing was read. `source`: the analyzer ran, and the source or a budget stopped it, such as a syntax error.
43
+ * `runtime`: the analyzer gave no answer, such as a missing `node` or `typescript`, the deadline, or a crash.
44
+ */
45
+ export type FlowExtractionFailureKind = 'runtime' | 'source';
46
+ /** The Flow of workflow source, read without running it. The bundle build stays the check that loads the code. */
47
+ export interface FlowExtraction {
48
+ readonly status: FlowExtractionStatus;
49
+ readonly sdkVersion: string;
50
+ readonly endpoints: ReadonlyArray<FlowExtractionEndpoint> | null;
51
+ /** The declared steps by the FLOW-2 catalog rules; `[]` only when the source declares none. */
52
+ readonly steps: WorkflowSteps | null;
53
+ /** The possible Step calls of each endpoint. A step it names can be absent from `steps` for a problem in `stepProblems`. */
54
+ readonly staticGraph: FlowStaticGraph | null;
55
+ /** The step problems that the source alone shows, worded as the build words them. */
56
+ readonly stepProblems: ReadonlyArray<string> | null;
57
+ readonly warnings: ReadonlyArray<string>;
58
+ /** Present only when `status` is `unavailable`; a reader branches on it, never on the text of `warnings`. */
59
+ readonly failureKind?: FlowExtractionFailureKind;
60
+ }
61
+ /**
62
+ * Reads the endpoints, the declared steps, their static problems, and the possible Step calls from workflow
63
+ * source. It never runs workflow code and never rejects: a timeout, a crash, or a bound gives a status and a warning.
64
+ */
65
+ export declare const extractWorkflowFlow: (options?: FlowExtractionOptions) => Promise<FlowExtraction>;
66
+ /** What the build adds to a manifest: a graph, nothing for a workflow without steps, or nothing with a warning. */
67
+ export type ManifestStaticGraph = {
68
+ readonly state: 'derived';
69
+ readonly staticGraph: FlowStaticGraph;
70
+ } | {
71
+ readonly state: 'none';
72
+ } | {
73
+ readonly state: 'omitted';
74
+ readonly warning: string;
75
+ };
76
+ /**
77
+ * What the build adds to `manifest`, given what the source of the same workflow gave. The loaded manifest
78
+ * decides: a graph that names other endpoints or a step outside its catalog is omitted with a warning.
79
+ */
80
+ export declare const staticGraphFor: (manifest: BuiltWorkflowManifest, extraction: FlowExtraction) => ManifestStaticGraph;
81
+ /**
82
+ * The `staticGraph` that the build writes beside the `steps` of `manifest` (FLOW-10). A manifest without steps
83
+ * gets none, keeps its bytes, and starts no analyzer. A failed, bounded, or mismatched derivation gives a
84
+ * warning and no graph: it never fails the build, and it never changes `manifest`.
85
+ */
86
+ export declare const deriveStaticGraph: (manifest: BuiltWorkflowManifest, options?: FlowExtractionOptions) => Promise<ManifestStaticGraph>;
87
+ //# sourceMappingURL=StaticGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StaticGraph.d.ts","sourceRoot":"","sources":["../src/StaticGraph.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,qBAAqB,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,2BAA2B,CAAC;AAWjF,sGAAsG;AACtG,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,uCAAuC;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,eAAO,MAAM,8BAA8B,EAAE,oBAS5C,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,mGAAmG;IACnG,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,oFAAoF;IACpF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,SAAS,CAAC;CAC7D;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG,YAAY,GAAG,aAAa,CAAC;AAEvE,sGAAs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,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAuC5D;;;GAGG;AACH,eAAO,MAAM,cAAc,aAAc,qBAAqB,cAAc,cAAc,KAAG,mBAU5F,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,aAClB,qBAAqB,YACtB,qBAAqB,KAC7B,OAAO,CAAC,mBAAmB,CAG7B,CAAC"}
@@ -0,0 +1,237 @@
1
+ // Static Step call graph extraction (FLOW-10, FLOW-11). An analyzer process, which this module kills at a
2
+ // deadline, parses the TypeScript source of a workflow into an AST and resolves its calls with a static resolver:
3
+ // no type checker runs. This module loads no `typescript` and imports no workflow code; only that process loads the parser.
4
+ import { spawn } from 'node:child_process';
5
+ import { resolve } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { Option, Schema } from 'effect';
8
+ import { TriggerMetadata } from './Contract/Manifest.js';
9
+ import { SDK_VERSION } from './Manifest.js';
10
+ import { AnalyzerOutput, } from './StaticGraphProtocol.js';
11
+ import { analyzerRuntimes } from './StaticGraphRuntime.js';
12
+ import { catalogOf, resourceProblem } from './StepCatalogRules.js';
13
+ export const DEFAULT_FLOW_EXTRACTION_LIMITS = {
14
+ timeoutMs: 5_000,
15
+ maxDepth: 24,
16
+ maxNodes: 600,
17
+ maxGraphBytes: 256 * 1024,
18
+ maxMemoryMb: 512,
19
+ maxWork: 2_000_000,
20
+ maxFiles: 400,
21
+ maxSourceBytes: 4 * 1024 * 1024,
22
+ };
23
+ // The analyzer script beside this module: TypeScript source in the repository, compiled JavaScript in the package.
24
+ const ANALYZER = fileURLToPath(new URL(import.meta.url.endsWith('.ts') ? './StaticGraphProcess.ts' : './StaticGraphProcess.js', import.meta.url));
25
+ // The analyzer prints endpoints, steps, and a bounded graph; more output than this is a defect.
26
+ const MAX_OUTPUT_BYTES = 4 * 1024 * 1024;
27
+ const MAX_DIAGNOSTIC_BYTES = 8 * 1024;
28
+ // The error line of an uncaught exception in the analyzer's stderr, such as `Error: EACCES …`; a crash dump has none.
29
+ const errorLine = (stderr) => /^\w*Error: .*$/m.exec(stderr)?.[0].slice(0, 200) ?? '';
30
+ const decodeOutput = Schema.decodeUnknownOption(Schema.fromJsonString(AnalyzerOutput));
31
+ const decodeTrigger = Schema.decodeUnknownOption(TriggerMetadata);
32
+ const runAnalyzer = (runtime, args, limits) => {
33
+ const done = Promise.withResolvers();
34
+ const child = spawn(runtime.command, [`--max-old-space-size=${limits.maxMemoryMb}`, ANALYZER, ...args], {
35
+ cwd: runtime.cwd,
36
+ env: runtime.env,
37
+ stdio: ['ignore', 'pipe', 'pipe'],
38
+ });
39
+ const stdout = [];
40
+ let printed = 0;
41
+ let diagnostic = '';
42
+ let stopped;
43
+ const stop = (reason) => {
44
+ stopped ??= reason;
45
+ child.kill('SIGKILL');
46
+ };
47
+ // The deadline holds outside the analyzer, so a parse or a walk that never returns still ends.
48
+ const deadline = setTimeout(() => stop(`the analyzer did not finish in ${limits.timeoutMs} ms`), limits.timeoutMs);
49
+ child.stdout.on('data', (chunk) => {
50
+ printed += chunk.byteLength;
51
+ if (printed > MAX_OUTPUT_BYTES)
52
+ stop(`the analyzer printed more than ${MAX_OUTPUT_BYTES} bytes`);
53
+ else
54
+ stdout.push(chunk);
55
+ });
56
+ child.stderr.on('data', (chunk) => {
57
+ if (diagnostic.length < MAX_DIAGNOSTIC_BYTES)
58
+ diagnostic += chunk.toString('utf8');
59
+ });
60
+ child.once('error', (cause) => {
61
+ clearTimeout(deadline);
62
+ done.resolve(cause.code === 'ENOENT'
63
+ ? { outcome: 'missing' }
64
+ : { outcome: 'failed', reason: `the analyzer did not start (${cause.message})` });
65
+ });
66
+ child.once('close', (code, signal) => {
67
+ clearTimeout(deadline);
68
+ if (stopped !== undefined) {
69
+ done.resolve({ outcome: 'failed', reason: stopped });
70
+ }
71
+ else if (code === 0) {
72
+ done.resolve({ outcome: 'printed', stdout: Buffer.concat(stdout).toString('utf8') });
73
+ }
74
+ else {
75
+ // A heap past the memory limit ends the process with a signal; an uncaught exception ends it with a code.
76
+ const how = signal === null ? `exit code ${String(code)}` : `signal ${signal}`;
77
+ const detail = errorLine(diagnostic);
78
+ done.resolve({
79
+ outcome: 'failed',
80
+ reason: `the analyzer stopped with ${how}${detail === '' ? '' : ` (${detail})`}`,
81
+ });
82
+ }
83
+ });
84
+ return done.promise;
85
+ };
86
+ const unavailable = (reason, failureKind) => ({
87
+ status: 'unavailable',
88
+ sdkVersion: SDK_VERSION,
89
+ endpoints: null,
90
+ steps: null,
91
+ staticGraph: null,
92
+ stepProblems: null,
93
+ warnings: [`The workflow source was not read: ${reason}.`],
94
+ failureKind,
95
+ });
96
+ const describeEndpoint = (endpoint) => `${endpoint.group}.${endpoint.name} (${endpoint.method} ${endpoint.path})`;
97
+ const endpointOf = (endpoint, warnings) => {
98
+ const { group, name, method, path } = endpoint;
99
+ const trigger = Option.getOrNull(decodeTrigger(endpoint.trigger));
100
+ if (trigger === null) {
101
+ warnings.push(`Endpoint ${describeEndpoint(endpoint)} has no Trigger annotation that the source writes as literals.`);
102
+ }
103
+ return { group, name, method, path, trigger };
104
+ };
105
+ const namedResource = (stepId, resource) => {
106
+ switch (resource.state) {
107
+ case 'declared':
108
+ return { identity: resource.identity };
109
+ case 'undeclared':
110
+ return { problem: resourceProblem.noEndpoint(stepId, resource.identity) };
111
+ case 'second':
112
+ return { problem: resourceProblem.secondDeclaration(stepId, resource.identity) };
113
+ case 'foreign':
114
+ return { problem: resourceProblem.notADeclaration(stepId) };
115
+ }
116
+ };
117
+ // The catalog and the step problems of the `Step.make` calls, by the rules the runtime build follows (FLOW-2).
118
+ const catalogOfSource = (steps) => catalogOf(steps, (step) => ({
119
+ id: step.id,
120
+ title: step.title,
121
+ kind: step.kind,
122
+ summary: step.summary,
123
+ resources: () => step.resources.map((resource) => namedResource(step.id, resource)),
124
+ }));
125
+ const toExtraction = (output, limits) => {
126
+ const [reason] = output.warnings;
127
+ if (output.endpoints === null) {
128
+ return unavailable(reason ?? 'the analyzer gave no reason', output.failureKind ?? 'runtime');
129
+ }
130
+ const warnings = [...output.warnings];
131
+ const endpoints = output.endpoints.map((endpoint) => endpointOf(endpoint, warnings));
132
+ const catalog = output.steps === null ? null : catalogOfSource(output.steps);
133
+ // The endpoints passed the contract schema when the output was decoded.
134
+ const graph = output.graph === null ? null : { version: 1, endpoints: output.graph };
135
+ const fits = graph === null || Buffer.byteLength(JSON.stringify(graph)) <= limits.maxGraphBytes;
136
+ if (!fits)
137
+ warnings.push(`The step calls were not derived: the graph is larger than ${limits.maxGraphBytes} bytes.`);
138
+ const staticGraph = fits ? graph : null;
139
+ return {
140
+ status: catalog === null || staticGraph === null ? 'incomplete' : 'ok',
141
+ sdkVersion: SDK_VERSION,
142
+ endpoints,
143
+ steps: catalog === null ? null : catalog.steps,
144
+ staticGraph,
145
+ stepProblems: catalog === null ? null : catalog.problems,
146
+ warnings,
147
+ };
148
+ };
149
+ /**
150
+ * Reads the endpoints, the declared steps, their static problems, and the possible Step calls from workflow
151
+ * source. It never runs workflow code and never rejects: a timeout, a crash, or a bound gives a status and a warning.
152
+ */
153
+ export const extractWorkflowFlow = async (options = {}) => {
154
+ const limits = { ...DEFAULT_FLOW_EXTRACTION_LIMITS, ...options.limits };
155
+ const project = resolve(options.project ?? process.cwd());
156
+ const args = [
157
+ project,
158
+ options.entrypoint ?? 'src/index.ts',
159
+ limits.maxDepth,
160
+ limits.maxNodes,
161
+ limits.maxWork,
162
+ limits.maxFiles,
163
+ limits.maxSourceBytes,
164
+ ].map(String);
165
+ for (const runtime of analyzerRuntimes(project)) {
166
+ const run = await runAnalyzer(runtime, args, limits);
167
+ if (run.outcome === 'missing')
168
+ continue;
169
+ if (run.outcome === 'failed')
170
+ return unavailable(run.reason, 'runtime');
171
+ const output = decodeOutput(run.stdout);
172
+ return Option.isNone(output)
173
+ ? unavailable('the analyzer printed no valid result', 'runtime')
174
+ : toExtraction(output.value, limits);
175
+ }
176
+ return unavailable('no node on PATH outside the project could start the analyzer', 'runtime');
177
+ };
178
+ const stepIdsOf = (nodes, ids) => {
179
+ for (const node of nodes) {
180
+ if (node.kind === 'step') {
181
+ ids.add(node.stepId);
182
+ stepIdsOf(node.body, ids);
183
+ }
184
+ else if (node.kind === 'loop')
185
+ stepIdsOf(node.body, ids);
186
+ else if (node.kind === 'branch')
187
+ for (const arm of node.arms)
188
+ stepIdsOf(arm.nodes, ids);
189
+ else if (node.kind === 'parallel')
190
+ for (const lane of node.lanes)
191
+ stepIdsOf(lane, ids);
192
+ }
193
+ };
194
+ const endpointIdentity = (endpoint) => JSON.stringify([endpoint.group, endpoint.name, endpoint.method, endpoint.path]);
195
+ // Why the graph of the source does not describe the built `manifest`, or `undefined`. The loaded bundle decides.
196
+ const mismatch = (manifest, steps, graph) => {
197
+ const built = manifest.endpoints.map(endpointIdentity).join('\n');
198
+ if (graph.endpoints.map(endpointIdentity).join('\n') !== built) {
199
+ return 'the endpoints in the source differ from the endpoints of the built workflow';
200
+ }
201
+ const called = new Set();
202
+ for (const endpoint of graph.endpoints)
203
+ stepIdsOf(endpoint.nodes, called);
204
+ const declared = new Set(steps.map((step) => step.id));
205
+ const unknown = [...called].find((id) => !declared.has(id));
206
+ return unknown === undefined
207
+ ? undefined
208
+ : `the source calls step ${unknown}, which the built workflow does not declare`;
209
+ };
210
+ /**
211
+ * What the build adds to `manifest`, given what the source of the same workflow gave. The loaded manifest
212
+ * decides: a graph that names other endpoints or a step outside its catalog is omitted with a warning.
213
+ */
214
+ export const staticGraphFor = (manifest, extraction) => {
215
+ const steps = manifest.steps ?? [];
216
+ if (steps.length === 0)
217
+ return { state: 'none' };
218
+ const omitted = (reason) => ({
219
+ state: 'omitted',
220
+ warning: `Static step graph omitted from the workflow manifest: ${reason}`,
221
+ });
222
+ if (extraction.staticGraph === null)
223
+ return omitted(extraction.warnings.join(' ') || 'the analyzer gave no reason.');
224
+ const reason = mismatch(manifest, steps, extraction.staticGraph);
225
+ return reason === undefined ? { state: 'derived', staticGraph: extraction.staticGraph } : omitted(`${reason}.`);
226
+ };
227
+ /**
228
+ * The `staticGraph` that the build writes beside the `steps` of `manifest` (FLOW-10). A manifest without steps
229
+ * gets none, keeps its bytes, and starts no analyzer. A failed, bounded, or mismatched derivation gives a
230
+ * warning and no graph: it never fails the build, and it never changes `manifest`.
231
+ */
232
+ export const deriveStaticGraph = async (manifest, options = {}) => {
233
+ if ((manifest.steps ?? []).length === 0)
234
+ return { state: 'none' };
235
+ return staticGraphFor(manifest, await extractWorkflowFlow(options));
236
+ };
237
+ //# sourceMappingURL=StaticGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StaticGraph.js","sourceRoot":"","sources":["../src/StaticGraph.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,kHAAkH;AAClH,4HAA4H;AAC5H,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAA8B,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAEzG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,cAAc,GAIf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAwB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAsB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAoBvF,MAAM,CAAC,MAAM,8BAA8B,GAAyB;IAClE,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,GAAG;IACb,aAAa,EAAE,GAAG,GAAG,IAAI;IACzB,WAAW,EAAE,GAAG;IAChB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,GAAG;IACb,cAAc,EAAE,CAA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,CAAC,CAAC;AACtE,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { AnalyzerLimits, AnalyzerOutput } from './StaticGraphProtocol.js';
2
+ /**
3
+ * Derives the endpoints, the declared steps, and the possible Step calls of a workflow from its source. A part
4
+ * that cannot be derived is `null` with a warning; the graph is `null` whenever the steps are.
5
+ */
6
+ export declare const analyzeWorkflowSource: (root: string, entrypoint: string, limits: AnalyzerLimits) => AnalyzerOutput;
7
+ //# sourceMappingURL=StaticGraphAnalyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StaticGraphAnalyzer.d.ts","sourceRoot":"","sources":["../src/StaticGraphAnalyzer.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAIV,cAAc,EACd,cAAc,EACf,MAAM,0BAA0B,CAAC;AAsHlC;;;GAGG;AACH,eAAO,MAAM,qBAAqB,SAAU,MAAM,cAAc,MAAM,UAAU,cAAc,KAAG,cA0DhG,CAAC"}
@@ -0,0 +1,162 @@
1
+ // The static Step call graph analyzer (FLOW-10). It reads workflow source and tsconfig.json inside the project folder
2
+ // as data: the TypeScript parser gives the AST, a static resolver follows its calls, and no type checker runs. It
3
+ // imports no workflow module, no tsconfig plugin, and only analyzer modules by their .ts name, so Node runs it as written.
4
+ import ts from 'typescript';
5
+ import { assertNodeBudget, callFunction, countNodes, unresolved } from './StaticGraphCalls.js';
6
+ import { collectLayer, collectSteps, compareEndpoints, declaredResource, endpointKey, evaluateModel, registerProvider, } from './StaticGraphDeclarations.js';
7
+ import { LimitReached, Unreadable, loadProject } from './StaticGraphProject.js';
8
+ import { ROOT_ENV, UNKNOWN, apiOf, evaluate, exported, isEffectApi, lookup, propertyExpression, unwrap, } from './StaticGraphValues.js';
9
+ // The `api` and `handlers` of the `workflow({ … })` call that the entrypoint exports as default.
10
+ const findWorkflow = (ctx, entry) => {
11
+ const exportedValue = exported(ctx, entry, 'default', new Set());
12
+ const call = exportedValue.t === 'expression' ? unwrap(exportedValue.node) : undefined;
13
+ const callee = call !== undefined && ts.isCallExpression(call) ? evaluate(ctx, call.expression, ROOT_ENV) : UNKNOWN;
14
+ const first = call !== undefined && ts.isCallExpression(call) ? call.arguments[0] : undefined;
15
+ const options = first === undefined ? UNKNOWN : evaluate(ctx, first, ROOT_ENV);
16
+ const isWorkflow = callee.t === 'lib' && apiOf(callee).sdk && apiOf(callee).name === 'workflow';
17
+ const api = options.t === 'object' ? propertyExpression(options.node, 'api') : undefined;
18
+ const handlers = options.t === 'object' ? propertyExpression(options.node, 'handlers') : undefined;
19
+ if (!isWorkflow || options.t !== 'object' || api === undefined || handlers === undefined) {
20
+ throw new Unreadable('the entrypoint does not export default workflow({ api, handlers }) from @temper/workflow');
21
+ }
22
+ return { api, handlers, env: options.env };
23
+ };
24
+ // The layer of `Effect.provide(layer, options?)` or `Effect.provide(self, layer, options?)`; a record is the options.
25
+ const providedLayer = (ctx, given) => {
26
+ const last = given.at(-1);
27
+ const options = given.length >= 2 && last !== undefined && evaluate(ctx, last, ROOT_ENV).t === 'object';
28
+ const rest = options ? given.slice(0, -1) : given;
29
+ return rest.length >= 2 ? rest[1] : rest[0];
30
+ };
31
+ const SERVICE_OVERRIDES = ['provideService', 'provideServiceEffect', 'updateService'];
32
+ const OVERRIDES = ['provide', ...SERVICE_OVERRIDES];
33
+ // `Effect.map(Effect.context(), (clients) => …)`: the parameter holds the context that the wired layers made, which
34
+ // replaces no service when a handler provides it again.
35
+ const isCapturedContext = (ctx, parameter) => {
36
+ const call = parameter.parent.parent;
37
+ if (!ts.isCallExpression(call) || call.arguments[1] !== parameter.parent)
38
+ return false;
39
+ const made = call.arguments[0] === undefined ? undefined : unwrap(call.arguments[0]);
40
+ return (isEffectApi(evaluate(ctx, call.expression, ROOT_ENV), 'Effect', ['map', 'flatMap', 'andThen']) &&
41
+ made !== undefined &&
42
+ ts.isCallExpression(made) &&
43
+ isEffectApi(evaluate(ctx, made.expression, ROOT_ENV), 'Effect', ['context']));
44
+ };
45
+ // `Effect.provide`, `Effect.provideService`, `Effect.provideServiceEffect`, and `Effect.updateService` calls in
46
+ // the workflow code replace a service where they run. Each one counts as one more implementation, so a service
47
+ // it replaces reads as ambiguous, never as the wired one. A layer that the scan cannot read can replace any service.
48
+ const collectOverrides = (ctx) => {
49
+ const visit = (node) => {
50
+ ts.forEachChild(node, visit);
51
+ const callee = ts.isCallExpression(node) ? unwrap(node.expression) : undefined;
52
+ if (!ts.isCallExpression(node) || callee === undefined || !ts.isPropertyAccessExpression(callee))
53
+ return;
54
+ const name = callee.name.text;
55
+ if (!OVERRIDES.includes(name) || !isEffectApi(evaluate(ctx, callee, ROOT_ENV), 'Effect', OVERRIDES))
56
+ return;
57
+ const given = node.arguments;
58
+ if (name === 'provide') {
59
+ const layer = providedLayer(ctx, given);
60
+ const named = layer === undefined ? undefined : unwrap(layer);
61
+ const declaration = named !== undefined && ts.isIdentifier(named) ? lookup(ctx, named) : undefined;
62
+ // A layer from a parameter is not followed to the calls of its function, so it can be any layer.
63
+ if (declaration?.kind === 'parameter')
64
+ ctx.unknownLayer ||= !isCapturedContext(ctx, declaration.node);
65
+ else if (layer !== undefined)
66
+ collectLayer(ctx, layer, ROOT_ENV);
67
+ return;
68
+ }
69
+ const [key, implementation] = given.length >= 3 ? [given[1], given[2]] : [given[0], given[1]];
70
+ const tag = key === undefined ? UNKNOWN : evaluate(ctx, key, ROOT_ENV);
71
+ if (key === undefined || (tag.t !== 'class' && !(tag.t === 'expression' && tag.lib)))
72
+ return;
73
+ // `updateService` computes the implementation at run time, and the curried `provideService(key)` names none:
74
+ // the call then stands for the implementation. It is no record, so the service reads as ambiguous.
75
+ const named = name === 'updateService' ? undefined : implementation;
76
+ registerProvider(ctx, name === 'provideServiceEffect' ? 'effect' : 'value', key, named ?? node, ROOT_ENV);
77
+ };
78
+ for (const file of ctx.project.order)
79
+ visit(file);
80
+ };
81
+ // The calls of every endpoint, or a budget error: a graph past a budget is withheld whole, never cut (FLOW-10).
82
+ const graphOf = (ctx, wiring, endpoints) => {
83
+ collectLayer(ctx, wiring.handlers, wiring.env);
84
+ collectOverrides(ctx);
85
+ const graph = [];
86
+ let total = 0;
87
+ for (const { group, name, method, path } of endpoints) {
88
+ const handler = ctx.handlers.get(endpointKey(group, name));
89
+ const value = handler === undefined ? UNKNOWN : evaluate(ctx, handler.expression, handler.env);
90
+ // A handler the source does not name can run any step, so the endpoint holds one dynamic call.
91
+ const nodes = value.t === 'function' ? callFunction(ctx, value, [], 'strict') : [unresolved('dynamic-call', 'handler')];
92
+ total += countNodes(nodes);
93
+ assertNodeBudget(ctx, total);
94
+ graph.push({ group, name, method, path, nodes });
95
+ }
96
+ return graph;
97
+ };
98
+ const failureText = (cause) => (cause instanceof Error ? cause.message : String(cause));
99
+ /**
100
+ * Derives the endpoints, the declared steps, and the possible Step calls of a workflow from its source. A part
101
+ * that cannot be derived is `null` with a warning; the graph is `null` whenever the steps are.
102
+ */
103
+ export const analyzeWorkflowSource = (root, entrypoint, limits) => {
104
+ const warnings = [];
105
+ let endpoints = null;
106
+ let steps = null;
107
+ try {
108
+ const { project, entry } = loadProject(root, entrypoint, limits);
109
+ const ctx = {
110
+ project,
111
+ limits,
112
+ scopes: new Map(),
113
+ stepIds: new Map(),
114
+ providers: new Map(),
115
+ handlers: new Map(),
116
+ memo: new Map(),
117
+ stack: [],
118
+ depth: 0,
119
+ dependent: [],
120
+ lastDependent: false,
121
+ recursions: new WeakMap(),
122
+ evaluating: new Set(),
123
+ layersSeen: new Set(),
124
+ warnings,
125
+ unknownLayer: false,
126
+ work: 0,
127
+ };
128
+ const wiring = findWorkflow(ctx, entry);
129
+ const model = evaluateModel(ctx, wiring.api, wiring.env, 0);
130
+ if (model === undefined || model.kind !== 'api') {
131
+ throw new Unreadable('the API is not written as HttpApi, HttpApiGroup, and HttpApiEndpoint calls with literal names and paths');
132
+ }
133
+ const declared = [];
134
+ for (const endpoint of model.endpoints) {
135
+ for (const middleware of endpoint.middleware) {
136
+ const resource = declaredResource(ctx, middleware);
137
+ if (resource !== undefined && resource !== 'foreign')
138
+ declared.push(resource);
139
+ }
140
+ }
141
+ endpoints = model.endpoints
142
+ .map(({ group, name, method, path, trigger }) => trigger === undefined ? { group, name, method, path } : { group, name, method, path, trigger })
143
+ .toSorted(compareEndpoints);
144
+ steps = collectSteps(ctx, declared);
145
+ if (steps === null)
146
+ return { endpoints, steps, graph: null, warnings };
147
+ return { endpoints, steps, graph: graphOf(ctx, wiring, endpoints), warnings };
148
+ }
149
+ catch (cause) {
150
+ // The analyzer fails open (FLOW-10): a budget, source it cannot read, or its own defect, such as a stack that
151
+ // overflows on deep code, withholds the part it was reading and keeps the parts already read.
152
+ const expected = cause instanceof Unreadable || cause instanceof LimitReached;
153
+ const reason = expected ? cause.message : `the analyzer failed (${failureText(cause)})`;
154
+ // The parent reads the first warning as the reason that nothing was read.
155
+ const failureKind = expected ? 'source' : 'runtime';
156
+ if (endpoints === null)
157
+ return { endpoints, steps, graph: null, warnings: [reason, ...warnings], failureKind };
158
+ warnings.push(`The ${steps === null ? 'steps were not read' : 'step calls were not derived'}: ${reason}.`);
159
+ return { endpoints, steps, graph: null, warnings };
160
+ }
161
+ };
162
+ //# sourceMappingURL=StaticGraphAnalyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StaticGraphAnalyzer.js","sourceRoot":"","sources":["../src/StaticGraphAnalyzer.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,kHAAkH;AAClH,2HAA2H;AAC3H,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAEL,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,gBAAgB,GACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC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AAK,KAAK,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,6BAA6B,KAAK,MAAM,GAAG,CAAC,CAAC;QAC3G,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACrD,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { StaticFlowNode } from './Contract/StaticGraph.js';
2
+ import { type Analysis, type Binding, type FunctionValue } from './StaticGraphValues.ts';
3
+ type Nodes = Array<StaticFlowNode>;
4
+ type Variant = 'strict' | 'lenient' | 'evaluate';
5
+ export declare const unresolved: (reason: 'dynamic-call' | 'ambiguous-layer' | 'external-module' | 'recursion', label: string | undefined) => StaticFlowNode;
6
+ export declare const countNodes: (nodes: ReadonlyArray<StaticFlowNode>) => number;
7
+ /** Past the node budget the graph is withheld whole, never cut (FLOW-10). */
8
+ export declare const assertNodeBudget: (ctx: Analysis, count: number) => void;
9
+ /**
10
+ * The calls of one call of a workflow function, with its body in place of the call. A function already
11
+ * being walked is a recursion: the graph marks it and does not unroll it (FLOW-10).
12
+ */
13
+ export declare function callFunction(ctx: Analysis, fn: FunctionValue, bindings: ReadonlyArray<Binding | undefined>, variant: Variant): Nodes;
14
+ export {};
15
+ //# sourceMappingURL=StaticGraphCalls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StaticGraphCalls.d.ts","sourceRoot":"","sources":["../src/StaticGraphCalls.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAwC,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEtG,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,OAAO,EAKZ,KAAK,aAAa,EA4BnB,MAAM,wBAAwB,CAAC;AAEhC,KAAK,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;AAkBnC,KAAK,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAkBjD,eAAO,MAAM,UAAU,WACb,cAAc,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,WAAW,SACrE,MAAM,GAAG,SAAS,KACxB,cAG0E,CAAC;AAm0B9E,eAAO,MAAM,UAAU,UAAW,aAAa,CAAC,cAAc,CAAC,KAAG,MAQjE,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,QAAS,QAAQ,SAAS,MAAM,KAAG,IAE/D,CAAC;AA0BF;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,QAAQ,EACb,EAAE,EAAE,aAAa,EACjB,QAAQ,EAAE,aAAa,CAAC,OAAO,GAAG,SAAS,CAAC,EAC5C,OAAO,EAAE,OAAO,GACf,KAAK,CAmBP"}