@fluidgrids/cli 2026.1021.1 → 2026.1028.2

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 (134) hide show
  1. package/README.md +157 -5
  2. package/dist/auth/device-login.d.ts +31 -0
  3. package/dist/auth/device-login.d.ts.map +1 -0
  4. package/dist/auth/device-login.js +75 -0
  5. package/dist/auth/device-login.js.map +1 -0
  6. package/dist/auth/token-auth.d.ts +49 -0
  7. package/dist/auth/token-auth.d.ts.map +1 -0
  8. package/dist/auth/token-auth.js +279 -0
  9. package/dist/auth/token-auth.js.map +1 -0
  10. package/dist/cli.d.ts +4 -5
  11. package/dist/cli.d.ts.map +1 -1
  12. package/dist/cli.js +18 -32
  13. package/dist/cli.js.map +1 -1
  14. package/dist/code-first/api.d.ts +357 -0
  15. package/dist/code-first/api.d.ts.map +1 -0
  16. package/dist/code-first/api.js +288 -0
  17. package/dist/code-first/api.js.map +1 -0
  18. package/dist/code-first/code-upload.d.ts +52 -0
  19. package/dist/code-first/code-upload.d.ts.map +1 -0
  20. package/dist/code-first/code-upload.js +161 -0
  21. package/dist/code-first/code-upload.js.map +1 -0
  22. package/dist/code-first/commands/codegen.d.ts +20 -0
  23. package/dist/code-first/commands/codegen.d.ts.map +1 -0
  24. package/dist/code-first/commands/codegen.js +50 -0
  25. package/dist/code-first/commands/codegen.js.map +1 -0
  26. package/dist/code-first/commands/diff.d.ts +28 -0
  27. package/dist/code-first/commands/diff.d.ts.map +1 -0
  28. package/dist/code-first/commands/diff.js +73 -0
  29. package/dist/code-first/commands/diff.js.map +1 -0
  30. package/dist/code-first/commands/hotfix.d.ts +54 -0
  31. package/dist/code-first/commands/hotfix.d.ts.map +1 -0
  32. package/dist/code-first/commands/hotfix.js +225 -0
  33. package/dist/code-first/commands/hotfix.js.map +1 -0
  34. package/dist/code-first/commands/import.d.ts +40 -0
  35. package/dist/code-first/commands/import.d.ts.map +1 -0
  36. package/dist/code-first/commands/import.js +235 -0
  37. package/dist/code-first/commands/import.js.map +1 -0
  38. package/dist/code-first/commands/init.d.ts +33 -0
  39. package/dist/code-first/commands/init.d.ts.map +1 -0
  40. package/dist/code-first/commands/init.js +177 -0
  41. package/dist/code-first/commands/init.js.map +1 -0
  42. package/dist/code-first/commands/interface.d.ts +12 -0
  43. package/dist/code-first/commands/interface.d.ts.map +1 -0
  44. package/dist/code-first/commands/interface.js +21 -0
  45. package/dist/code-first/commands/interface.js.map +1 -0
  46. package/dist/code-first/commands/pull.d.ts +63 -0
  47. package/dist/code-first/commands/pull.d.ts.map +1 -0
  48. package/dist/code-first/commands/pull.js +266 -0
  49. package/dist/code-first/commands/pull.js.map +1 -0
  50. package/dist/code-first/commands/push.d.ts +97 -0
  51. package/dist/code-first/commands/push.d.ts.map +1 -0
  52. package/dist/code-first/commands/push.js +313 -0
  53. package/dist/code-first/commands/push.js.map +1 -0
  54. package/dist/code-first/commands/replay.d.ts +44 -0
  55. package/dist/code-first/commands/replay.d.ts.map +1 -0
  56. package/dist/code-first/commands/replay.js +238 -0
  57. package/dist/code-first/commands/replay.js.map +1 -0
  58. package/dist/code-first/commands/runs.d.ts +94 -0
  59. package/dist/code-first/commands/runs.d.ts.map +1 -0
  60. package/dist/code-first/commands/runs.js +304 -0
  61. package/dist/code-first/commands/runs.js.map +1 -0
  62. package/dist/code-first/commands/validate.d.ts +38 -0
  63. package/dist/code-first/commands/validate.d.ts.map +1 -0
  64. package/dist/code-first/commands/validate.js +140 -0
  65. package/dist/code-first/commands/validate.js.map +1 -0
  66. package/dist/code-first/commands/versions.d.ts +14 -0
  67. package/dist/code-first/commands/versions.d.ts.map +1 -0
  68. package/dist/code-first/commands/versions.js +30 -0
  69. package/dist/code-first/commands/versions.js.map +1 -0
  70. package/dist/code-first/connections.d.ts +55 -0
  71. package/dist/code-first/connections.d.ts.map +1 -0
  72. package/dist/code-first/connections.js +180 -0
  73. package/dist/code-first/connections.js.map +1 -0
  74. package/dist/code-first/durable-operations.d.ts +42 -0
  75. package/dist/code-first/durable-operations.d.ts.map +1 -0
  76. package/dist/code-first/durable-operations.js +136 -0
  77. package/dist/code-first/durable-operations.js.map +1 -0
  78. package/dist/code-first/history.d.ts +30 -0
  79. package/dist/code-first/history.d.ts.map +1 -0
  80. package/dist/code-first/history.js +139 -0
  81. package/dist/code-first/history.js.map +1 -0
  82. package/dist/code-first/imports.d.ts +22 -0
  83. package/dist/code-first/imports.d.ts.map +1 -0
  84. package/dist/code-first/imports.js +67 -0
  85. package/dist/code-first/imports.js.map +1 -0
  86. package/dist/code-first/index.d.ts +17 -0
  87. package/dist/code-first/index.d.ts.map +1 -0
  88. package/dist/code-first/index.js +35 -0
  89. package/dist/code-first/index.js.map +1 -0
  90. package/dist/code-first/lowering.d.ts +81 -0
  91. package/dist/code-first/lowering.d.ts.map +1 -0
  92. package/dist/code-first/lowering.js +225 -0
  93. package/dist/code-first/lowering.js.map +1 -0
  94. package/dist/code-first/operations.d.ts +57 -0
  95. package/dist/code-first/operations.d.ts.map +1 -0
  96. package/dist/code-first/operations.js +167 -0
  97. package/dist/code-first/operations.js.map +1 -0
  98. package/dist/code-first/presigned.d.ts +21 -0
  99. package/dist/code-first/presigned.d.ts.map +1 -0
  100. package/dist/code-first/presigned.js +85 -0
  101. package/dist/code-first/presigned.js.map +1 -0
  102. package/dist/code-first/project.d.ts +123 -0
  103. package/dist/code-first/project.d.ts.map +1 -0
  104. package/dist/code-first/project.js +301 -0
  105. package/dist/code-first/project.js.map +1 -0
  106. package/dist/code-first/python.d.ts +81 -0
  107. package/dist/code-first/python.d.ts.map +1 -0
  108. package/dist/code-first/python.js +249 -0
  109. package/dist/code-first/python.js.map +1 -0
  110. package/dist/code-first/register.d.ts +27 -0
  111. package/dist/code-first/register.d.ts.map +1 -0
  112. package/dist/code-first/register.js +270 -0
  113. package/dist/code-first/register.js.map +1 -0
  114. package/dist/code-first/remote.d.ts +58 -0
  115. package/dist/code-first/remote.d.ts.map +1 -0
  116. package/dist/code-first/remote.js +126 -0
  117. package/dist/code-first/remote.js.map +1 -0
  118. package/dist/code-first/replay.d.ts +36 -0
  119. package/dist/code-first/replay.d.ts.map +1 -0
  120. package/dist/code-first/replay.js +52 -0
  121. package/dist/code-first/replay.js.map +1 -0
  122. package/dist/code-first/shared.d.ts +51 -0
  123. package/dist/code-first/shared.d.ts.map +1 -0
  124. package/dist/code-first/shared.js +93 -0
  125. package/dist/code-first/shared.js.map +1 -0
  126. package/dist/modules.d.ts +4 -0
  127. package/dist/modules.d.ts.map +1 -1
  128. package/dist/modules.js +6 -0
  129. package/dist/modules.js.map +1 -1
  130. package/dist/program.d.ts +20 -0
  131. package/dist/program.d.ts.map +1 -0
  132. package/dist/program.js +43 -0
  133. package/dist/program.js.map +1 -0
  134. package/package.json +3 -1
@@ -0,0 +1,139 @@
1
+ /**
2
+ * A durable run's history as a `fluidgrids.history` file (C-HIST,
3
+ * `schema/history-file.schema.json` of `@fluidgrids/workflows`): every page of
4
+ * `workflowRunHistory`, with offloaded payloads fetched through their
5
+ * presigned `payloadUrl` and inlined, so the file replays on its own.
6
+ */
7
+ import { CliUserError } from '@burdenoff/cli-sdk/core';
8
+ import { createHistoryFile, HistoryFileError, parseHistoryFile, } from '@fluidgrids/workflows/history';
9
+ import { MAX_PAGES } from './api.js';
10
+ import { presignedUrl, readCapped } from './presigned.js';
11
+ import { describeError } from './shared.js';
12
+ /** Events per `workflowRunHistory` page (the service's default and maximum). */
13
+ export const HISTORY_PAGE_SIZE = 500;
14
+ /** Largest offloaded payload the CLI reads (the service's resolved-bytes cap). */
15
+ export const MAX_OFFLOADED_PAYLOAD_BYTES = 64 * 1024 * 1024;
16
+ function isRecord(value) {
17
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
18
+ }
19
+ /** A JSON object from a parsed value; the history contract has object payloads only. */
20
+ function objectPayload(value, where) {
21
+ if (value === null || value === undefined)
22
+ return {};
23
+ if (!isRecord(value))
24
+ throw new CliUserError(`${where}: the payload is not a JSON object.`);
25
+ // Parsed JSON (from the gateway or the payload object) is JSON by construction.
26
+ return value;
27
+ }
28
+ async function offloadedPayload(env, event, runId) {
29
+ const where = `Run ${runId} event ${event.seq}`;
30
+ const raw = event.payloadUrl ?? '';
31
+ presignedUrl(raw, `offloaded payload of event ${event.seq}`);
32
+ let response;
33
+ try {
34
+ response = await env.fetch(raw, { method: 'GET' });
35
+ }
36
+ catch (error) {
37
+ // The presigned URL carries a signature; it is never printed.
38
+ throw new CliUserError(`${where}: fetching the offloaded payload failed: ${describeError(error)}`);
39
+ }
40
+ if (!response.ok) {
41
+ throw new CliUserError(`${where}: fetching the offloaded payload failed with HTTP ${response.status}.`);
42
+ }
43
+ const tooLarge = () => new CliUserError(`${where}: the offloaded payload is larger than the history cap (${MAX_OFFLOADED_PAYLOAD_BYTES} bytes).`);
44
+ const text = new TextDecoder().decode(await readCapped(response, MAX_OFFLOADED_PAYLOAD_BYTES, tooLarge));
45
+ let parsed;
46
+ try {
47
+ parsed = JSON.parse(text);
48
+ }
49
+ catch {
50
+ throw new CliUserError(`${where}: the offloaded payload is not JSON.`);
51
+ }
52
+ return objectPayload(parsed, where);
53
+ }
54
+ /** The run's events, every page, offloaded payloads inlined. */
55
+ export async function fetchRunEvents(env, runId) {
56
+ const events = [];
57
+ let after = 0;
58
+ let historyBytes = 0;
59
+ for (let page = 0; page < MAX_PAGES; page++) {
60
+ const result = await env.api.runHistoryPage(runId, after, HISTORY_PAGE_SIZE);
61
+ historyBytes = result.historyBytes;
62
+ for (const event of result.events) {
63
+ const payload = event.payloadUrl
64
+ ? await offloadedPayload(env, event, runId)
65
+ : objectPayload(event.payload, `Run ${runId} event ${event.seq}`);
66
+ events.push({
67
+ seq: event.seq,
68
+ // Validated against the event enum by parseHistoryFile below.
69
+ type: event.type,
70
+ ...(event.taskId ? { taskId: event.taskId } : {}),
71
+ payload,
72
+ createdAt: event.createdAt,
73
+ });
74
+ }
75
+ const last = result.events[result.events.length - 1];
76
+ if (!result.hasMore || !last)
77
+ return { events, historyBytes };
78
+ after = result.nextAfter ?? last.seq;
79
+ }
80
+ throw new CliUserError(`The history of run ${runId} did not end after ${MAX_PAGES} pages; refusing to continue.`);
81
+ }
82
+ /** Refuse a run that has no event history (a canvas run). */
83
+ export function assertDurable(run) {
84
+ if (run.executionKind !== 'DURABLE_FN') {
85
+ throw new CliUserError(`Run ${run.id} is a ${run.executionKind} run; only durable-function runs have an event history.`, { hint: `Use \`fluidgrids runs logs ${run.id}\` for a canvas run.` });
86
+ }
87
+ }
88
+ /** Download a durable run's history as a validated history file. */
89
+ export async function fetchHistory(env, runId) {
90
+ const run = await env.api.describeRun(runId);
91
+ assertDurable(run);
92
+ const { events, historyBytes } = await fetchRunEvents(env, runId);
93
+ const started = events[0]?.type === 'WORKFLOW_STARTED' ? events[0].payload : undefined;
94
+ const workflowFn = run.workflowFn ??
95
+ (started && typeof started['workflowFn'] === 'string' ? started['workflowFn'] : undefined);
96
+ if (!workflowFn) {
97
+ throw new CliUserError(`Run ${runId} records no workflow function.`);
98
+ }
99
+ const workspaceId = env.ctx.auth.read()?.workspaceId ?? 'unknown';
100
+ const file = createHistoryFile(workflowFn, events, {
101
+ name: run.id,
102
+ info: {
103
+ runId: run.id,
104
+ workspaceId,
105
+ workflowKey: run.workflowKey,
106
+ version: run.version,
107
+ ...(run.buildId ? { buildId: run.buildId } : {}),
108
+ ...(run.taskQueue ? { taskQueue: run.taskQueue } : {}),
109
+ parentRunId: run.parentRunId,
110
+ rootRunId: run.rootRunId,
111
+ },
112
+ });
113
+ try {
114
+ return { run, file: parseHistoryFile(file), historyBytes };
115
+ }
116
+ catch (error) {
117
+ if (error instanceof HistoryFileError) {
118
+ throw new CliUserError(`The history of run ${runId} is not a valid history file.`, {
119
+ hint: [error.message, ...error.issues].join('\n'),
120
+ });
121
+ }
122
+ throw error;
123
+ }
124
+ }
125
+ /** Read and validate a history file from disk. */
126
+ export function parseHistoryText(text, path) {
127
+ try {
128
+ return parseHistoryFile(text);
129
+ }
130
+ catch (error) {
131
+ if (error instanceof HistoryFileError) {
132
+ throw new CliUserError(`${path} is not a valid history file: ${error.message}`, {
133
+ ...(error.issues.length > 0 ? { hint: error.issues.join('\n') } : {}),
134
+ });
135
+ }
136
+ throw error;
137
+ }
138
+ }
139
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/code-first/history.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GAIjB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAwC,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAE7D,gFAAgF;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAErC,kFAAkF;AAClF,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAQ5D,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,wFAAwF;AACxF,SAAS,aAAa,CAAC,KAAc,EAAE,KAAa;IAClD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACrD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,YAAY,CAAC,GAAG,KAAK,qCAAqC,CAAC,CAAC;IAC5F,gFAAgF;IAChF,OAAO,KAAmB,CAAC;AAC7B,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,GAAe,EACf,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AAE,CAAC;QACf,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;YACtC,MAAM,IAAI,YAAY,CAAC,GAAG,IAAI,iCAAiC,KAAK,CAAC,OAAO,EAAE,EAAE;gBAC9E,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACtE,CAAC,CAAC;QACL,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The project files a set of TypeScript entry modules reaches through
3
+ * relative imports, found by a static scan of the import statements.
4
+ *
5
+ * A durable project's code bundle is built from exactly these files (plus the
6
+ * sidecars), and the source archive carries exactly these files, so the
7
+ * service's rebuild (`buildBundle` over the archive with the SDK's default
8
+ * entries) sees the same modules the CLI bundled. Files no workflow imports,
9
+ * such as co-located `*.spec.ts` tests or Node-only scripts under
10
+ * `activities/`, stay out of both.
11
+ *
12
+ * The scan errs on the side of including a file: a commented-out import adds
13
+ * a file the bundle does not need, which is harmless. A missed import cannot
14
+ * produce a wrong bundle silently: the bundler then fails to resolve it.
15
+ */
16
+ /** The relative specifiers a module imports at runtime (type-only imports excluded). */
17
+ export declare function relativeImports(source: string): string[];
18
+ /** The project file a relative specifier names, the way the bundler resolves it. */
19
+ export declare function resolveRelative(importer: string, specifier: string, files: ReadonlySet<string>): string | undefined;
20
+ /** Every file in `sources` the entries reach, the entries included. */
21
+ export declare function importClosure(sources: ReadonlyMap<string, string>, entries: readonly string[]): Set<string>;
22
+ //# sourceMappingURL=imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../src/code-first/imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAWH,wFAAwF;AACxF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAaxD;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GACzB,MAAM,GAAG,SAAS,CAMpB;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,GAAG,CAAC,MAAM,CAAC,CAab"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The project files a set of TypeScript entry modules reaches through
3
+ * relative imports, found by a static scan of the import statements.
4
+ *
5
+ * A durable project's code bundle is built from exactly these files (plus the
6
+ * sidecars), and the source archive carries exactly these files, so the
7
+ * service's rebuild (`buildBundle` over the archive with the SDK's default
8
+ * entries) sees the same modules the CLI bundled. Files no workflow imports,
9
+ * such as co-located `*.spec.ts` tests or Node-only scripts under
10
+ * `activities/`, stay out of both.
11
+ *
12
+ * The scan errs on the side of including a file: a commented-out import adds
13
+ * a file the bundle does not need, which is harmless. A missed import cannot
14
+ * produce a wrong bundle silently: the bundler then fails to resolve it.
15
+ */
16
+ import { posix } from 'path';
17
+ /** `import … from '…'` and `export … from '…'`, with an optional `type` modifier. */
18
+ const FROM_CLAUSE = /\b(import|export)(\s+type\b)?[^'"`;]*?\bfrom\s*(['"])([^'"\r\n]+)\3/g;
19
+ /** `import '…'` (side effects only). */
20
+ const BARE_IMPORT = /\bimport\s*(['"])([^'"\r\n]+)\1/g;
21
+ /** `import('…')`. */
22
+ const DYNAMIC_IMPORT = /\bimport\s*\(\s*(['"])([^'"\r\n]+)\1\s*\)/g;
23
+ /** The relative specifiers a module imports at runtime (type-only imports excluded). */
24
+ export function relativeImports(source) {
25
+ const found = [];
26
+ for (const match of source.matchAll(FROM_CLAUSE)) {
27
+ const specifier = match[4];
28
+ if (match[2] === undefined && specifier !== undefined)
29
+ found.push(specifier);
30
+ }
31
+ for (const match of source.matchAll(BARE_IMPORT)) {
32
+ if (match[2] !== undefined)
33
+ found.push(match[2]);
34
+ }
35
+ for (const match of source.matchAll(DYNAMIC_IMPORT)) {
36
+ if (match[2] !== undefined)
37
+ found.push(match[2]);
38
+ }
39
+ return found.filter((specifier) => specifier.startsWith('./') || specifier.startsWith('../'));
40
+ }
41
+ /** The project file a relative specifier names, the way the bundler resolves it. */
42
+ export function resolveRelative(importer, specifier, files) {
43
+ const base = posix.normalize(posix.join(posix.dirname(importer), specifier));
44
+ const candidates = [base];
45
+ if (/\.m?js$/.test(base))
46
+ candidates.push(base.replace(/\.(m?)js$/, '.$1ts'));
47
+ candidates.push(`${base}.ts`, `${base}/index.ts`);
48
+ return candidates.find((candidate) => files.has(candidate));
49
+ }
50
+ /** Every file in `sources` the entries reach, the entries included. */
51
+ export function importClosure(sources, entries) {
52
+ const paths = new Set(sources.keys());
53
+ const reached = new Set();
54
+ const pending = entries.filter((entry) => paths.has(entry));
55
+ for (let path = pending.pop(); path !== undefined; path = pending.pop()) {
56
+ if (reached.has(path))
57
+ continue;
58
+ reached.add(path);
59
+ for (const specifier of relativeImports(sources.get(path) ?? '')) {
60
+ const target = resolveRelative(path, specifier, paths);
61
+ if (target !== undefined && !reached.has(target))
62
+ pending.push(target);
63
+ }
64
+ }
65
+ return reached;
66
+ }
67
+ //# sourceMappingURL=imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imports.js","sourceRoot":"","sources":["../../src/code-first/imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,qFAAqF;AACrF,MAAM,WAAW,GAAG,sEAAsE,CAAC;AAC3F,wCAAwC;AACxC,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,qBAAqB;AACrB,MAAM,cAAc,GAAG,4CAA4C,CAAC;AAEpE,wFAAw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ACjB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The code-first commands (spec 07 §7, Phase A): `init`, `codegen`, `pull`,
3
+ * `push`, `diff`, `validate`, plus `import` (a new workflow from one file,
4
+ * through the service's import path) and `interface`; and the durable-function
5
+ * commands of Phase B (`push --hotfix`, `runs start|describe|history|signal|
6
+ * terminate|stack`, `history`, `signal`, `replay`, `test`, `run`,
7
+ * `versions list`).
8
+ *
9
+ * Product-local rather than in `@burdenoff/cli-sdk`: they depend on
10
+ * `@fluidgrids/workflows` (esbuild, Prettier, QuickJS), which the other product
11
+ * CLIs built on cli-sdk must not pull in. The implementations load on first
12
+ * use (see `register.ts`), so the other commands do not pay for them.
13
+ */
14
+ import type { CliModule } from '@burdenoff/cli-sdk/core';
15
+ declare const codeFirstModule: CliModule;
16
+ export default codeFirstModule;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/code-first/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAezD,QAAA,MAAM,eAAe,EAAE,SAiBtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The code-first commands (spec 07 §7, Phase A): `init`, `codegen`, `pull`,
3
+ * `push`, `diff`, `validate`, plus `import` (a new workflow from one file,
4
+ * through the service's import path) and `interface`; and the durable-function
5
+ * commands of Phase B (`push --hotfix`, `runs start|describe|history|signal|
6
+ * terminate|stack`, `history`, `signal`, `replay`, `test`, `run`,
7
+ * `versions list`).
8
+ *
9
+ * Product-local rather than in `@burdenoff/cli-sdk`: they depend on
10
+ * `@fluidgrids/workflows` (esbuild, Prettier, QuickJS), which the other product
11
+ * CLIs built on cli-sdk must not pull in. The implementations load on first
12
+ * use (see `register.ts`), so the other commands do not pay for them.
13
+ */
14
+ import { registerCodegen, registerDiff, registerDurable, registerImport, registerInit, registerInterface, registerPull, registerPush, registerValidate, } from './register.js';
15
+ import { createCommandEnv } from './shared.js';
16
+ const codeFirstModule = {
17
+ id: 'fluidgrids-code-first',
18
+ version: '1.0.0',
19
+ displayName: 'FluidGrids code-first workflows',
20
+ dependsOn: ['auth', 'fluidgrids'],
21
+ register(program, ctx) {
22
+ const env = createCommandEnv(ctx);
23
+ registerInit(program, env);
24
+ registerCodegen(program, env);
25
+ registerPull(program, env);
26
+ registerPush(program, env);
27
+ registerDiff(program, env);
28
+ registerValidate(program, env);
29
+ registerImport(program, env);
30
+ registerInterface(program, env);
31
+ registerDurable(program, env);
32
+ },
33
+ };
34
+ export default codeFirstModule;
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/code-first/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,eAAe,GAAc;IACjC,EAAE,EAAE,uBAAuB;IAC3B,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,iCAAiC;IAC9C,SAAS,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,GAAG;QACnB,MAAM,GAAG,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAClC,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC3B,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC9B,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC3B,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC3B,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC3B,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC/B,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7B,iBAAiB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAChC,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;CACF,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Lower the project's workflows to IR v2 (spec 07 §4, tier 1):
3
+ * - TypeScript: `lower()` from `@fluidgrids/workflows/roundtrip`, with the
4
+ * pinned esbuild and the Node `vm` evaluator (the developer's own code);
5
+ * - Python: `python -m fluidgrids_workflows lower` from the installed
6
+ * `fluidgrids-workflows` package (see `python.ts`);
7
+ * - JSON: canvas workflows kept as the export envelope are read as they are.
8
+ */
9
+ import type { ConnectionRef } from '@fluidgrids/workflows/ir';
10
+ import { type VendoredDeps } from '@fluidgrids/workflows/roundtrip';
11
+ import { type Project, type ProjectFile, type WorkflowFormat } from './project.js';
12
+ export interface LocalWorkflow {
13
+ key: string;
14
+ format: WorkflowFormat;
15
+ /** Project-relative file the workflow is defined in. */
16
+ path: string;
17
+ definition: Record<string, unknown>;
18
+ /** True when the definition runs code (a `code` block: tier-2 functions or `wf.codeWorkflow`). */
19
+ durable: boolean;
20
+ }
21
+ /**
22
+ * A finding in durable-function sources that `push` refuses: `durable.phaseC`
23
+ * (a feature that arrives in Phase C) or `durable.activityTypeNotAllowed`.
24
+ */
25
+ export interface DurableIssue {
26
+ code: string;
27
+ message: string;
28
+ module: string;
29
+ key?: string;
30
+ }
31
+ /** Largest code bundle the service accepts (C-S3, spec 01 §5). */
32
+ export declare const MAX_BUNDLE_BYTES: number;
33
+ export interface LoweredProject {
34
+ /** `buildId` of the TypeScript bundle, when the project has TypeScript workflows. */
35
+ buildId?: string;
36
+ /** `sourceHash` of the lowered sources, when the project has code workflows. */
37
+ sourceHash?: string;
38
+ workflows: LocalWorkflow[];
39
+ /** Notes about the lowering (for example SDK disagreements), one line each. */
40
+ warnings: string[];
41
+ /** The TypeScript bundle (one ES module that serves every code workflow of the push). */
42
+ bundle?: string;
43
+ /** The project files the bundle was built from, by path (the source archive's `files`). */
44
+ sourceFiles?: Record<string, string>;
45
+ /** Pure-ESM packages vendored from the project's `node_modules`. */
46
+ vendored?: VendoredDeps;
47
+ /** Durable-function findings; `push` refuses a project that has any. */
48
+ issues: DurableIssue[];
49
+ }
50
+ export interface LowerProjectOptions {
51
+ /** How connection names resolve. A function is called once per name. */
52
+ connections: (name: string) => ConnectionRef | undefined;
53
+ /** Explains unresolved names; one line each. */
54
+ explainUnresolved: (names: readonly string[]) => string[];
55
+ }
56
+ /**
57
+ * A failure of `lower()` as the CLI reports it: builder mistakes, determinism
58
+ * violations, size limits and esbuild compile errors are the user's to fix;
59
+ * anything else is rethrown as it is.
60
+ */
61
+ export declare function lowerFailure(error: unknown, what: string): unknown;
62
+ /** True when a definition carries a `code` block, so a version of it needs a code bundle. */
63
+ export declare function runsCode(definition: Record<string, unknown>): boolean;
64
+ /**
65
+ * The project's runtime dependencies, vendored for the bundle: only when
66
+ * `package.json` lists `dependencies` besides the SDK itself (which the bundle
67
+ * embeds). Returns undefined when there is nothing to vendor.
68
+ */
69
+ export declare function vendorProjectDependencies(root: string): VendoredDeps | undefined;
70
+ /**
71
+ * The files a durable project's bundle and source archive are built from: the
72
+ * workflow modules, the TypeScript files they import (transitively) and the
73
+ * sidecars. A co-located `*.spec.ts` test, or an `activities/` module no
74
+ * workflow imports, is neither bundled nor archived, so the service's rebuild
75
+ * with the SDK's default entries sees exactly the modules the CLI bundled.
76
+ */
77
+ export declare function durableBundleFiles(files: readonly ProjectFile[], entries: readonly string[]): ProjectFile[];
78
+ export declare function lowerProject(project: Project, options: LowerProjectOptions & {
79
+ connectionNames: readonly string[];
80
+ }): Promise<LoweredProject>;
81
+ //# sourceMappingURL=lowering.d.ts.map
@@ -0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MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;IACzD,gDAAgD;IAChD,iBAAiB,EAAE,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;CAC3D;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKlE;AAgBD,6FAA6F;AAC7F,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAErE;AAID;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAiBhF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,WAAW,EAAE,CAMf;AAyCD,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,mBAAmB,GAAG;IAAE,eAAe,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACpE,OAAO,CAAC,cAAc,CAAC,CAoHzB"}
@@ -0,0 +1,225 @@
1
+ /**
2
+ * Lower the project's workflows to IR v2 (spec 07 §4, tier 1):
3
+ * - TypeScript: `lower()` from `@fluidgrids/workflows/roundtrip`, with the
4
+ * pinned esbuild and the Node `vm` evaluator (the developer's own code);
5
+ * - Python: `python -m fluidgrids_workflows lower` from the installed
6
+ * `fluidgrids-workflows` package (see `python.ts`);
7
+ * - JSON: canvas workflows kept as the export envelope are read as they are.
8
+ */
9
+ import { CliUserError } from '@burdenoff/cli-sdk/core';
10
+ import { BuilderError, UnresolvedConnectionsError } from '@fluidgrids/workflows';
11
+ import { parseWorkflowDocument } from '@fluidgrids/workflows/ir';
12
+ import { defaultEntries, lower, LowerError, vendorDependencies, } from '@fluidgrids/workflows/roundtrip';
13
+ import { existsSync, readFileSync } from 'fs';
14
+ import { join, posix } from 'path';
15
+ import { isJsonWorkflow, isLoweringInput, isWorkflowModule, listSourcePaths, readProjectFiles, } from './project.js';
16
+ import { importClosure } from './imports.js';
17
+ import { lowerPython, PythonUnresolvedConnectionsError, resolvePythonInterpreter, } from './python.js';
18
+ /** Largest code bundle the service accepts (C-S3, spec 01 §5). */
19
+ export const MAX_BUNDLE_BYTES = 8 * 1024 * 1024;
20
+ function isBuildFailure(error) {
21
+ return error instanceof Error && 'errors' in error && Array.isArray(error.errors);
22
+ }
23
+ /**
24
+ * A failure of `lower()` as the CLI reports it: builder mistakes, determinism
25
+ * violations, size limits and esbuild compile errors are the user's to fix;
26
+ * anything else is rethrown as it is.
27
+ */
28
+ export function lowerFailure(error, what) {
29
+ if (error instanceof LowerError || error instanceof BuilderError || isBuildFailure(error)) {
30
+ return new CliUserError(`Lowering ${what} failed: ${error.message}`);
31
+ }
32
+ return error;
33
+ }
34
+ function unresolvedError(names, explain) {
35
+ return new CliUserError(`The code names connections that do not resolve in this workspace: ${[...names].sort().join(', ')}`, { hint: explain(names).join('\n') });
36
+ }
37
+ function isRecord(value) {
38
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
39
+ }
40
+ /** True when a definition carries a `code` block, so a version of it needs a code bundle. */
41
+ export function runsCode(definition) {
42
+ return isRecord(definition['code']);
43
+ }
44
+ const SDK_PACKAGE = '@fluidgrids/workflows';
45
+ /**
46
+ * The project's runtime dependencies, vendored for the bundle: only when
47
+ * `package.json` lists `dependencies` besides the SDK itself (which the bundle
48
+ * embeds). Returns undefined when there is nothing to vendor.
49
+ */
50
+ export function vendorProjectDependencies(root) {
51
+ const manifestPath = join(root, 'package.json');
52
+ if (!existsSync(manifestPath))
53
+ return undefined;
54
+ let manifest;
55
+ try {
56
+ manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
57
+ }
58
+ catch {
59
+ throw new CliUserError('package.json is not valid JSON.');
60
+ }
61
+ const dependencies = isRecord(manifest) ? manifest['dependencies'] : undefined;
62
+ if (!isRecord(dependencies))
63
+ return undefined;
64
+ if (!Object.keys(dependencies).some((name) => name !== SDK_PACKAGE))
65
+ return undefined;
66
+ try {
67
+ return vendorDependencies(root);
68
+ }
69
+ catch (error) {
70
+ throw lowerFailure(error, 'the project dependencies');
71
+ }
72
+ }
73
+ /**
74
+ * The files a durable project's bundle and source archive are built from: the
75
+ * workflow modules, the TypeScript files they import (transitively) and the
76
+ * sidecars. A co-located `*.spec.ts` test, or an `activities/` module no
77
+ * workflow imports, is neither bundled nor archived, so the service's rebuild
78
+ * with the SDK's default entries sees exactly the modules the CLI bundled.
79
+ */
80
+ export function durableBundleFiles(files, entries) {
81
+ const sources = new Map(files.filter((file) => file.path.endsWith('.ts')).map((file) => [file.path, file.content]));
82
+ const reached = importClosure(sources, entries);
83
+ return files.filter((file) => !file.path.endsWith('.ts') || reached.has(file.path));
84
+ }
85
+ function sameList(a, b) {
86
+ return a.length === b.length && a.every((value, index) => value === b[index]);
87
+ }
88
+ function jsonWorkflows(project, paths) {
89
+ return readProjectFiles(project.root, paths).map((file) => {
90
+ const parsed = parseWorkflowDocument(file.content);
91
+ if (!parsed) {
92
+ throw new CliUserError(`${file.path} is not a workflow export or definition.`);
93
+ }
94
+ const stem = posix.basename(file.path, '.json');
95
+ const declared = typeof parsed.definitionJson['key'] === 'string' ? parsed.definitionJson['key'] : null;
96
+ const key = parsed.workflowKey ?? declared ?? stem;
97
+ const definition = parsed.definitionJson;
98
+ return { key, format: 'json', path: file.path, definition, durable: runsCode(definition) };
99
+ });
100
+ }
101
+ /** The full name → reference map a Python lowering receives. */
102
+ function connectionMap(names, resolve) {
103
+ const out = {};
104
+ for (const name of names) {
105
+ const ref = resolve(name);
106
+ if (ref) {
107
+ Object.defineProperty(out, name, {
108
+ value: ref,
109
+ enumerable: true,
110
+ writable: true,
111
+ configurable: true,
112
+ });
113
+ }
114
+ }
115
+ return out;
116
+ }
117
+ export async function lowerProject(project, options) {
118
+ const paths = listSourcePaths(project.root);
119
+ const language = project.config.language;
120
+ const entries = paths.filter((path) => isWorkflowModule(path, language));
121
+ const workflows = jsonWorkflows(project, paths.filter(isJsonWorkflow));
122
+ const result = { workflows, warnings: [], issues: [] };
123
+ if (entries.length > 0) {
124
+ if (language === 'ts') {
125
+ const files = readProjectFiles(project.root, paths.filter((path) => isLoweringInput(path, language)));
126
+ const deps = vendorProjectDependencies(project.root);
127
+ const run = (input, only) => lower(input, {
128
+ ...(only ? { entries: only } : {}),
129
+ connections: options.connections,
130
+ maxBundleBytes: MAX_BUNDLE_BYTES,
131
+ ...(deps ? { deps } : {}),
132
+ });
133
+ try {
134
+ let lowered = await run(files, entries);
135
+ let bundleFiles = files;
136
+ const durable = lowered.workflows.some((workflow) => runsCode(workflow.definition));
137
+ if (durable) {
138
+ bundleFiles = durableBundleFiles(files, entries);
139
+ // The service rebuilds a code bundle from the source archive with
140
+ // the SDK's default entries (`buildWorkflowCode`), so an uploaded
141
+ // bundle must come from those entries over the archived files, or
142
+ // the service's build would get another buildId. Graph-only
143
+ // projects keep their entries and files.
144
+ const paths = bundleFiles.map((file) => file.path);
145
+ if (bundleFiles.length !== files.length || !sameList(defaultEntries(paths), entries)) {
146
+ lowered = await run(bundleFiles);
147
+ }
148
+ }
149
+ result.buildId = lowered.buildId;
150
+ result.sourceHash = lowered.sourceHash;
151
+ result.bundle = lowered.bundle;
152
+ result.sourceFiles = Object.fromEntries(bundleFiles.map((file) => [file.path, file.content]));
153
+ if (deps)
154
+ result.vendored = deps;
155
+ result.issues.push(...lowered.issues);
156
+ for (const workflow of lowered.workflows) {
157
+ const definition = workflow.definition;
158
+ workflows.push({
159
+ key: workflow.key,
160
+ format: 'ts',
161
+ path: workflow.module,
162
+ definition,
163
+ durable: runsCode(definition),
164
+ });
165
+ }
166
+ }
167
+ catch (error) {
168
+ if (error instanceof UnresolvedConnectionsError) {
169
+ throw unresolvedError(error.names, options.explainUnresolved);
170
+ }
171
+ throw lowerFailure(error, 'the TypeScript workflows');
172
+ }
173
+ }
174
+ else {
175
+ try {
176
+ const lowered = await lowerPython({
177
+ python: resolvePythonInterpreter(project.root, project.config.python),
178
+ root: project.root,
179
+ entries,
180
+ connections: connectionMap(options.connectionNames, options.connections),
181
+ });
182
+ result.sourceHash = lowered.sourceHash;
183
+ result.warnings.push(...lowered.warnings);
184
+ result.issues.push(...lowered.issues);
185
+ for (const workflow of lowered.workflows) {
186
+ const durable = runsCode(workflow.definition);
187
+ if (durable) {
188
+ // A Python definition with a code block needs a Python bundle and
189
+ // the Python durable worker, both Phase C (BOFF-9906).
190
+ result.issues.push({
191
+ code: 'durable.phaseC',
192
+ message: `${workflow.module}: Python durable functions (tier 2) arrive in Phase C`,
193
+ module: workflow.module,
194
+ key: workflow.key,
195
+ });
196
+ }
197
+ workflows.push({
198
+ key: workflow.key,
199
+ format: 'py',
200
+ path: workflow.module,
201
+ definition: workflow.definition,
202
+ durable,
203
+ });
204
+ }
205
+ }
206
+ catch (error) {
207
+ if (error instanceof PythonUnresolvedConnectionsError) {
208
+ throw unresolvedError(error.names, options.explainUnresolved);
209
+ }
210
+ throw error;
211
+ }
212
+ }
213
+ }
214
+ const seen = new Map();
215
+ for (const workflow of workflows) {
216
+ const previous = seen.get(workflow.key);
217
+ if (previous) {
218
+ throw new CliUserError(`Workflow key "${workflow.key}" is defined twice (${previous} and ${workflow.path}).`, { hint: 'Delete one of the files; `fluidgrids pull --as` replaces the other format.' });
219
+ }
220
+ seen.set(workflow.key, workflow.path);
221
+ }
222
+ workflows.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
223
+ return result;
224
+ }
225
+ //# sourceMappingURL=lowering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lowering.js","sourceRoot":"","sources":["../../src/code-first/lowering.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,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