@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 @@
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/code-first/commands/diff.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,EAA0B,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAE5F,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC;IACnC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACnF;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,wBAAsB,OAAO,CAC3B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CA6ErB"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * `fluidgrids diff [key…] [--against latest|active|<version>]`: the IR diff of
3
+ * the local workflows against a stored version (spec 07 §7). Both sides are
4
+ * compared after normalisation, without `authoring`, with the stored pinned
5
+ * data carried over exactly as `push` would.
6
+ */
7
+ import { CliUserError } from '@burdenoff/cli-sdk/core';
8
+ import { diffDefinitions } from '@fluidgrids/workflows/ir';
9
+ import { explainUnresolved } from '../connections.js';
10
+ import { lowerProject } from '../lowering.js';
11
+ import { assertProjectWorkspace, loadProject } from '../project.js';
12
+ import { comparableRemote, outgoingDefinition, projectConnectionIndex, RemoteWorkflows, } from '../remote.js';
13
+ import { emit, requireKnownKeys } from '../shared.js';
14
+ export async function runDiff(env, keys, options) {
15
+ const project = loadProject(options.project, env.cwd());
16
+ assertProjectWorkspace(env, project);
17
+ const against = options.against ?? 'latest';
18
+ const latest = new RemoteWorkflows(env.api, 'latest');
19
+ const remote = against === 'latest' ? latest : new RemoteWorkflows(env.api, against);
20
+ const index = await projectConnectionIndex(env.api, project, keys, latest);
21
+ const lowered = await lowerProject(project, {
22
+ connections: (name) => (Object.hasOwn(index.refs, name) ? index.refs[name] : undefined),
23
+ connectionNames: Object.keys(index.refs),
24
+ explainUnresolved: (names) => explainUnresolved(names, index),
25
+ });
26
+ requireKnownKeys(keys, lowered.workflows.map((workflow) => workflow.key));
27
+ const selected = keys.length > 0
28
+ ? lowered.workflows.filter((workflow) => keys.includes(workflow.key))
29
+ : lowered.workflows;
30
+ const items = [];
31
+ for (const workflow of selected) {
32
+ const stored = await remote.get(workflow.key);
33
+ if (!stored.export) {
34
+ items.push({ key: workflow.key, against: null, status: 'new', changes: [] });
35
+ continue;
36
+ }
37
+ const base = comparableRemote(stored.export.definitionJson, workflow.key);
38
+ const changes = diffDefinitions(base, outgoingDefinition(workflow.definition, base)).map((change) => ({
39
+ kind: change.kind,
40
+ path: change.path,
41
+ ...(change.before !== undefined ? { before: change.before } : {}),
42
+ ...(change.after !== undefined ? { after: change.after } : {}),
43
+ }));
44
+ items.push({
45
+ key: workflow.key,
46
+ against: stored.export.version,
47
+ status: changes.length === 0 ? 'same' : 'changed',
48
+ changes,
49
+ });
50
+ }
51
+ const result = { against, workflows: items };
52
+ const details = [...lowered.warnings];
53
+ details.push(...items.flatMap((item) => item.changes.map((change) => {
54
+ const values = change.kind === 'changed'
55
+ ? `: ${JSON.stringify(change.before)} -> ${JSON.stringify(change.after)}`
56
+ : '';
57
+ return `${item.key}: ${change.kind} ${change.path}${values}`;
58
+ })));
59
+ emit(env, options, result, {
60
+ headers: ['Workflow', 'Against', 'Status', 'Changes'],
61
+ rows: items.map((item) => [
62
+ item.key,
63
+ item.against ?? '-',
64
+ item.status,
65
+ String(item.changes.length),
66
+ ]),
67
+ }, details);
68
+ if (options.exitCode && items.some((item) => item.status !== 'same')) {
69
+ throw new CliUserError('The local workflows differ from the workspace.', { exitCode: 1 });
70
+ }
71
+ return result;
72
+ }
73
+ //# sourceMappingURL=diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/code-first/commands/diff.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,IAA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,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;SAC5B,CAAC;KACH,EACD,OAAO,CACR,CAAC;IACF,IAAI,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,YAAY,CAAC,gDAAgD,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * `fluidgrids push --hotfix <version> [key]`: replace the code bundle of an
3
+ * existing version (spec 06 §2, decision DB10) instead of creating a version.
4
+ *
5
+ * 1. The local lowering of the workflow must equal the stored version except
6
+ * for its code: a hotfix fixes code, it never changes the graph, the
7
+ * exported functions or their interfaces.
8
+ * 2. `--replay-sample N` first replays the N most recent durable runs of that
9
+ * version locally in the QuickJS isolate, and refuses on a violation. It
10
+ * scans the newest runs of the key up to a bound, warns when it found fewer
11
+ * than N and refuses when it found none.
12
+ * 3. The bundle is uploaded as for a push, `replaceWorkflowVersionCode` starts
13
+ * the service's job, and the CLI polls `workflowCodeReplace` until the job
14
+ * ends REPLACED or REJECTED (the service replays up to 50 open and 50
15
+ * completed runs; `--no-verify-replay` skips that and is audited). The
16
+ * result is emitted before a REJECTED job or a timeout exits non-zero.
17
+ */
18
+ import type { CodeReplaceResult } from '../api.js';
19
+ import { type ReplayOutcome } from '../replay.js';
20
+ import { type CommandEnv } from '../shared.js';
21
+ import { type PushOptions } from './push.js';
22
+ /** Poll interval of the replacement job. */
23
+ export declare const HOTFIX_POLL_MS = 2000;
24
+ /** Default wait for the replacement job (the service replays up to 100 runs). */
25
+ export declare const HOTFIX_DEFAULT_TIMEOUT_MS: number;
26
+ export interface HotfixResult {
27
+ key: string;
28
+ version: string;
29
+ buildId: string;
30
+ previousBuildId: string;
31
+ status: CodeReplaceResult['status'];
32
+ /** True when `--timeout` passed before the job ended; `status` is its last state. */
33
+ timedOut: boolean;
34
+ jobId: string;
35
+ verifiedRuns: number;
36
+ bundleUploaded: boolean;
37
+ verifyReplay: boolean;
38
+ /** What `--replay-sample` found and replayed; null without it. */
39
+ replaySample: ReplaySample | null;
40
+ localReplays: Array<Omit<ReplayOutcome, 'result'>>;
41
+ violations: CodeReplaceResult['violations'];
42
+ }
43
+ /** Runs of the key scanned for a `--replay-sample` (newest first). */
44
+ export declare const HOTFIX_SAMPLE_SCAN_LIMIT = 500;
45
+ /** What `--replay-sample` replayed. */
46
+ export interface ReplaySample {
47
+ requested: number;
48
+ /** Durable runs of the version found among the newest runs of the key. */
49
+ found: number;
50
+ /** Runs of the key that were scanned. */
51
+ scanned: number;
52
+ }
53
+ export declare function runHotfix(env: CommandEnv, keys: readonly string[], options: PushOptions): Promise<HotfixResult>;
54
+ //# sourceMappingURL=hotfix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hotfix.d.ts","sourceRoot":"","sources":["../../../src/code-first/commands/hotfix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAMnD,OAAO,EAAmC,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7D,4CAA4C;AAC5C,eAAO,MAAM,cAAc,OAAQ,CAAC;AACpC,iFAAiF;AACjF,eAAO,MAAM,yBAAyB,QAAc,CAAC;AAErD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACpC,qFAAqF;IACrF,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,kEAAkE;IAClE,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;IACnD,UAAU,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;CAC7C;AAuDD,sEAAsE;AACtE,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,uCAAuC;AACvC,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AAoDD,wBAAsB,SAAS,CAC7B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,YAAY,CAAC,CAgBvB"}
@@ -0,0 +1,225 @@
1
+ /**
2
+ * `fluidgrids push --hotfix <version> [key]`: replace the code bundle of an
3
+ * existing version (spec 06 §2, decision DB10) instead of creating a version.
4
+ *
5
+ * 1. The local lowering of the workflow must equal the stored version except
6
+ * for its code: a hotfix fixes code, it never changes the graph, the
7
+ * exported functions or their interfaces.
8
+ * 2. `--replay-sample N` first replays the N most recent durable runs of that
9
+ * version locally in the QuickJS isolate, and refuses on a violation. It
10
+ * scans the newest runs of the key up to a bound, warns when it found fewer
11
+ * than N and refuses when it found none.
12
+ * 3. The bundle is uploaded as for a push, `replaceWorkflowVersionCode` starts
13
+ * the service's job, and the CLI polls `workflowCodeReplace` until the job
14
+ * ends REPLACED or REJECTED (the service replays up to 50 open and 50
15
+ * completed runs; `--no-verify-replay` skips that and is audited). The
16
+ * result is emitted before a REJECTED job or a timeout exits non-zero.
17
+ */
18
+ import { CliUserError } from '@burdenoff/cli-sdk/core';
19
+ import { canonicalJson } from '@fluidgrids/workflows/ir';
20
+ import { bundleCodeBlock, codeBundleInput, prepareBundle, uploadBundle } from '../code-upload.js';
21
+ import { fetchHistory } from '../history.js';
22
+ import { writeLock } from '../project.js';
23
+ import { comparableRemote, outgoingDefinition, sameContent } from '../remote.js';
24
+ import { createReplayer, describeOutcome } from '../replay.js';
25
+ import { emit, parsePositiveInt } from '../shared.js';
26
+ import { loadPushInputs } from './push.js';
27
+ /** Poll interval of the replacement job. */
28
+ export const HOTFIX_POLL_MS = 2_000;
29
+ /** Default wait for the replacement job (the service replays up to 100 runs). */
30
+ export const HOTFIX_DEFAULT_TIMEOUT_MS = 10 * 60_000;
31
+ function isRecord(value) {
32
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
33
+ }
34
+ /** The definition without the parts a hotfix may change (`code.buildId`, provenance). */
35
+ function withoutCode(definition) {
36
+ const copy = { ...definition };
37
+ delete copy['code'];
38
+ delete copy['authoring'];
39
+ return copy;
40
+ }
41
+ function exportsOf(definition) {
42
+ const code = definition['code'];
43
+ return canonicalJson(isRecord(code) ? (code['exports'] ?? null) : null);
44
+ }
45
+ function pickWorkflow(selected, keys) {
46
+ const durable = selected.filter((workflow) => workflow.durable);
47
+ if (keys.length > 1) {
48
+ throw new CliUserError('`--hotfix` replaces the code of one version; name one workflow key.');
49
+ }
50
+ const [only, ...rest] = keys.length === 1 ? selected : durable;
51
+ if (!only || rest.length > 0) {
52
+ throw new CliUserError(durable.length === 0
53
+ ? 'The project defines no durable-function workflow to hotfix.'
54
+ : '`--hotfix` replaces the code of one version; name the workflow key.', durable.length > 1
55
+ ? { hint: `Durable workflows: ${durable.map((w) => w.key).join(', ')}` }
56
+ : undefined);
57
+ }
58
+ if (!only.durable) {
59
+ throw new CliUserError(`${only.key} does not run code; there is no bundle to hotfix.`);
60
+ }
61
+ return only;
62
+ }
63
+ /** An outcome without the raw task result, for output. */
64
+ function summarize(outcome) {
65
+ return {
66
+ name: outcome.name,
67
+ workflowFn: outcome.workflowFn,
68
+ events: outcome.events,
69
+ engine: outcome.engine,
70
+ ok: outcome.ok,
71
+ cause: outcome.cause,
72
+ message: outcome.message,
73
+ seq: outcome.seq,
74
+ };
75
+ }
76
+ /** Runs of the key scanned for a `--replay-sample` (newest first). */
77
+ export const HOTFIX_SAMPLE_SCAN_LIMIT = 500;
78
+ async function localReplays(env, key, version, sample, bundle, buildId) {
79
+ // Newest first. The list has no version or kind filter, so it is scanned up
80
+ // to a bound: other versions and canvas runs of the same key are skipped.
81
+ const scanned = await env.api.listRuns(key, Math.max(HOTFIX_SAMPLE_SCAN_LIMIT, sample));
82
+ const runs = scanned
83
+ .filter((run) => run.version === version && run.executionKind === 'DURABLE_FN')
84
+ .slice(0, sample);
85
+ const found = { requested: sample, found: runs.length, scanned: scanned.length };
86
+ if (runs.length === 0) {
87
+ throw new CliUserError(`--replay-sample ${sample} found no durable runs of ${key} ${version} among the newest ${scanned.length} runs; nothing was replaced.`, { hint: "Drop --replay-sample to rely on the service's replay verification alone." });
88
+ }
89
+ const replayer = await createReplayer(bundle, buildId, 'quickjs');
90
+ try {
91
+ const outcomes = [];
92
+ for (const run of runs) {
93
+ const { file } = await fetchHistory(env, run.id);
94
+ outcomes.push(await replayer.replay(file, run.id));
95
+ }
96
+ return { outcomes, sample: found };
97
+ }
98
+ finally {
99
+ await replayer.close();
100
+ }
101
+ }
102
+ /** The job once it ended, or its last state when the wait timed out. */
103
+ async function waitForJob(env, started, timeoutMs) {
104
+ const deadline = Date.now() + timeoutMs;
105
+ let job = started;
106
+ while (job.status === 'PENDING' || job.status === 'VERIFYING') {
107
+ if (Date.now() > deadline)
108
+ return { job, timedOut: true };
109
+ await env.sleep(HOTFIX_POLL_MS);
110
+ job = await env.api.codeReplace(job.id);
111
+ }
112
+ return { job, timedOut: false };
113
+ }
114
+ export async function runHotfix(env, keys, options) {
115
+ const version = options.hotfix;
116
+ if (version === undefined || version.trim() === '') {
117
+ throw new CliUserError('`--hotfix` needs the version to replace, for example `--hotfix v3`.');
118
+ }
119
+ if (options.dryRun)
120
+ throw new CliUserError('`--hotfix` and `--dry-run` cannot be combined.');
121
+ const sample = parsePositiveInt(options.replaySample, '--replay-sample') ?? 0;
122
+ const timeoutMs = parsePositiveInt(options.timeout, '--timeout') ?? HOTFIX_DEFAULT_TIMEOUT_MS;
123
+ const inputs = await loadPushInputs(env, keys, options);
124
+ return hotfixWorkflow(env, inputs.project, inputs.lowered, pickWorkflow(inputs.selected, keys), {
125
+ version,
126
+ sample,
127
+ timeoutMs,
128
+ verifyReplay: options.verifyReplay !== false,
129
+ format: options.format,
130
+ });
131
+ }
132
+ async function hotfixWorkflow(env, project, lowered, workflow, settings) {
133
+ const { version } = settings;
134
+ // The local refusals (no bundle, size caps, a buildId mismatch) come first.
135
+ const prepared = prepareBundle(project, lowered);
136
+ bundleCodeBlock(workflow, prepared);
137
+ const stored = await env.api.exportWorkflow(workflow.key, version);
138
+ const storedDefinition = comparableRemote(stored.definitionJson, workflow.key);
139
+ if (!isRecord(storedDefinition['code'])) {
140
+ throw new CliUserError(`${workflow.key} ${version} has no code bundle; push a new version.`);
141
+ }
142
+ // Aligned the way push compares, so data pinned on the canvas is no change.
143
+ const outgoing = outgoingDefinition(workflow.definition, storedDefinition);
144
+ if (!sameContent(withoutCode(outgoing), withoutCode(storedDefinition))) {
145
+ throw new CliUserError(`The workflow graph of ${workflow.key} differs from ${version}; a hotfix replaces only code.`, { hint: 'Push a new version instead (`fluidgrids push`).' });
146
+ }
147
+ if (exportsOf(workflow.definition) !== exportsOf(storedDefinition)) {
148
+ throw new CliUserError(`The exported functions or interfaces of ${workflow.key} differ from ${version}; a hotfix replaces only code.`, { hint: 'Push a new version instead (`fluidgrids push`).' });
149
+ }
150
+ const previous = storedDefinition['code']['buildId'];
151
+ if (previous === prepared.buildId) {
152
+ throw new CliUserError(`${workflow.key} ${version} already runs ${prepared.buildId}.`);
153
+ }
154
+ const sampled = settings.sample > 0
155
+ ? await localReplays(env, workflow.key, version, settings.sample, lowered.bundle ?? '', prepared.buildId)
156
+ : undefined;
157
+ const outcomes = sampled?.outcomes ?? [];
158
+ const failed = outcomes.filter((outcome) => !outcome.ok);
159
+ if (failed.length > 0) {
160
+ throw new CliUserError(`The new code fails to replay ${failed.length} of ${outcomes.length} sampled runs; nothing was replaced.`, { hint: failed.map(describeOutcome).join('\n') });
161
+ }
162
+ const upload = await uploadBundle(env, prepared, workflow.key);
163
+ const started = await env.api.replaceVersionCode(workflow.key, version, codeBundleInput(upload.uploadId, workflow, prepared), settings.verifyReplay);
164
+ const { job, timedOut } = await waitForJob(env, started, settings.timeoutMs);
165
+ const result = {
166
+ key: workflow.key,
167
+ version,
168
+ buildId: job.buildId,
169
+ previousBuildId: job.previousBuildId,
170
+ status: job.status,
171
+ timedOut,
172
+ jobId: job.id,
173
+ verifiedRuns: job.verifiedRuns,
174
+ bundleUploaded: upload.bundleSent,
175
+ verifyReplay: settings.verifyReplay,
176
+ replaySample: sampled?.sample ?? null,
177
+ localReplays: outcomes.map(summarize),
178
+ violations: job.violations,
179
+ };
180
+ const replaced = job.status === 'REPLACED';
181
+ if (replaced) {
182
+ const tracked = project.lock.workflows[workflow.key];
183
+ if (tracked && tracked.version === version) {
184
+ project.lock.workflows[workflow.key] = { ...tracked, buildId: prepared.buildId };
185
+ }
186
+ project.lock.bundle = {
187
+ buildId: prepared.buildId,
188
+ sourceHash: prepared.sourceHash,
189
+ sdkVersion: prepared.sdkVersion,
190
+ };
191
+ writeLock(project);
192
+ }
193
+ const details = [
194
+ `${workflow.key} ${version}: ${result.previousBuildId} -> ${result.buildId}`,
195
+ ...outcomes.map(describeOutcome),
196
+ ];
197
+ const sample = sampled?.sample;
198
+ if (sample && sample.found < sample.requested) {
199
+ const warning = `--replay-sample ${sample.requested}: only ${sample.found} durable run(s) of ${version} among the newest ${sample.scanned} runs were replayed locally.`;
200
+ // stderr, so a `--format json` caller's stdout stays one document.
201
+ env.ctx.output.printWarning(warning);
202
+ }
203
+ if (!settings.verifyReplay)
204
+ details.push('Replay verification was skipped (audited).');
205
+ // The result goes out first, so `--format json` gets the job even when it failed.
206
+ emit(env, { ...(settings.format !== undefined ? { format: settings.format } : {}) }, result, {
207
+ headers: ['Workflow', 'Version', 'Status', 'Verified runs', 'Build'],
208
+ rows: [[result.key, version, result.status, String(result.verifiedRuns), result.buildId]],
209
+ }, details);
210
+ if (timedOut) {
211
+ throw new CliUserError(`The code replacement ${job.id} is still ${job.status} after ${settings.timeoutMs} ms.`, { hint: 'It keeps running on the service; check it again with `fluidgrids versions list`.' });
212
+ }
213
+ if (job.status === 'REJECTED') {
214
+ throw new CliUserError(`The service rejected the new code for ${workflow.key} ${version}: ${job.violations.length} replay violation(s).`, {
215
+ hint: job.violations
216
+ .map((v) => `run ${v.runId}${v.seq !== null ? ` event ${v.seq}` : ''}: ${v.message}`)
217
+ .join('\n'),
218
+ });
219
+ }
220
+ if (!replaced) {
221
+ throw new CliUserError(`The code replacement ${job.id} ended ${job.status}; the version keeps its code.`);
222
+ }
223
+ return result;
224
+ }
225
+ //# sourceMappingURL=hotfix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hotfix.js","sourceRoot":"","sources":["../../../src/code-first/commands/hotfix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAgB,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,WAAW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[--key k] [--name n]`: create a NEW workflow (a
3
+ * DRAFT) from one file, the way the builder's import dialog does (spec 07 §1,
4
+ * §8), through `importWorkflow`:
5
+ *
6
+ * - `.json`: an export envelope or a bare definition, sent as
7
+ * `source: { format: JSON }` so the service reads it exactly as Git restore does;
8
+ * - `.ts`: a tier-1 module of a project, sent as `source: { format: TYPESCRIPT }`
9
+ * with the files it imports and the connection names resolved, so the service
10
+ * lowers it in its own isolate;
11
+ * - `.py`: lowered by the installed `fluidgrids-workflows` Python package and sent
12
+ * as `definitionJson` (the service does not run Python).
13
+ *
14
+ * The file is lowered locally first as well, and the stored version's `irHash`
15
+ * is compared with the local one, so a disagreement between the CLI and the
16
+ * service's lowering shows up immediately. An existing workflow key is refused
17
+ * by the service; `fluidgrids push` creates new versions of existing workflows.
18
+ */
19
+ import { type CommandEnv, type OutputOptions } from '../shared.js';
20
+ export interface ImportOptions extends OutputOptions {
21
+ key?: string;
22
+ name?: string;
23
+ description?: string;
24
+ allowMissingNodes?: boolean;
25
+ }
26
+ export interface ImportResult {
27
+ file: string;
28
+ format: 'JSON' | 'TYPESCRIPT' | 'PYTHON';
29
+ workflowKey: string;
30
+ version: string;
31
+ status: string;
32
+ /** `irHash` of the local reading or lowering of the file. */
33
+ irHash: string;
34
+ /** `irHash` of the version the service stored. */
35
+ storedIrHash: string;
36
+ matches: boolean;
37
+ warnings: string[];
38
+ }
39
+ export declare function runImport(env: CommandEnv, file: string, options: ImportOptions): Promise<ImportResult>;
40
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../../src/code-first/commands/import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA+BH,OAAO,EAAQ,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAEzE,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,QAAQ,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAuMD,wBAAsB,SAAS,CAC7B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CA6DvB"}