@fluidgrids/cli 2026.1028.2 → 2026.1029.1

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 (50) hide show
  1. package/README.md +48 -3
  2. package/dist/code-first/api.d.ts +193 -0
  3. package/dist/code-first/api.d.ts.map +1 -1
  4. package/dist/code-first/api.js +137 -4
  5. package/dist/code-first/api.js.map +1 -1
  6. package/dist/code-first/code-upload.d.ts +2 -1
  7. package/dist/code-first/code-upload.d.ts.map +1 -1
  8. package/dist/code-first/code-upload.js +5 -1
  9. package/dist/code-first/code-upload.js.map +1 -1
  10. package/dist/code-first/commands/runs.d.ts +80 -14
  11. package/dist/code-first/commands/runs.d.ts.map +1 -1
  12. package/dist/code-first/commands/runs.js +281 -20
  13. package/dist/code-first/commands/runs.js.map +1 -1
  14. package/dist/code-first/commands/versions.d.ts +52 -3
  15. package/dist/code-first/commands/versions.d.ts.map +1 -1
  16. package/dist/code-first/commands/versions.js +177 -3
  17. package/dist/code-first/commands/versions.js.map +1 -1
  18. package/dist/code-first/durable-operations.d.ts +1 -2
  19. package/dist/code-first/durable-operations.d.ts.map +1 -1
  20. package/dist/code-first/durable-operations.js +1 -2
  21. package/dist/code-first/durable-operations.js.map +1 -1
  22. package/dist/code-first/lowering.d.ts +13 -0
  23. package/dist/code-first/lowering.d.ts.map +1 -1
  24. package/dist/code-first/lowering.js +24 -1
  25. package/dist/code-first/lowering.js.map +1 -1
  26. package/dist/code-first/operations.d.ts +1 -3
  27. package/dist/code-first/operations.d.ts.map +1 -1
  28. package/dist/code-first/operations.js +1 -3
  29. package/dist/code-first/operations.js.map +1 -1
  30. package/dist/code-first/parity-operations.d.ts +44 -0
  31. package/dist/code-first/parity-operations.d.ts.map +1 -0
  32. package/dist/code-first/parity-operations.js +211 -0
  33. package/dist/code-first/parity-operations.js.map +1 -0
  34. package/dist/code-first/parity.d.ts +83 -0
  35. package/dist/code-first/parity.d.ts.map +1 -0
  36. package/dist/code-first/parity.js +301 -0
  37. package/dist/code-first/parity.js.map +1 -0
  38. package/dist/code-first/redact.d.ts +31 -0
  39. package/dist/code-first/redact.d.ts.map +1 -0
  40. package/dist/code-first/redact.js +150 -0
  41. package/dist/code-first/redact.js.map +1 -0
  42. package/dist/code-first/register.d.ts +7 -0
  43. package/dist/code-first/register.d.ts.map +1 -1
  44. package/dist/code-first/register.js +147 -18
  45. package/dist/code-first/register.js.map +1 -1
  46. package/dist/code-first/shared.d.ts +2 -0
  47. package/dist/code-first/shared.d.ts.map +1 -1
  48. package/dist/code-first/shared.js +1 -0
  49. package/dist/code-first/shared.js.map +1 -1
  50. package/package.json +2 -2
@@ -0,0 +1,211 @@
1
+ /**
2
+ * GraphQL documents for durable-function parity (BOFF-9905 B19, spec code-first
3
+ * 11): workflow ids and their policies, the other parity start options, run
4
+ * targets (`{ workflowKey, workflowId }`), pending state, run counts, the
5
+ * `__metadata` stack trace, completion callbacks, rollouts, drainage and
6
+ * per-run versioning overrides.
7
+ *
8
+ * Every document targets the WORKSPACE gateway (wspace-workflow-svc releases
9
+ * S3 to S6). The service refuses each of them with FEATURE_DISABLED unless the
10
+ * workspace has fluidgrids.code-first, fluidgrids.durable-functions and
11
+ * fluidgrids.durable-parity; the CLI never decides the flag itself. They are
12
+ * separate from the Phase B documents in `durable-operations.ts`, so a command
13
+ * run without a parity option sends exactly what it sent before.
14
+ *
15
+ * `tests/code-first/parity-operations.test.ts` validates them against the
16
+ * vendored supergraph, which carries the parity releases S3 to S6.
17
+ */
18
+ const DURABLE_RUN_FIELDS = `
19
+ id workflowId workflowKey version status mode triggerNodeId
20
+ executionKind workflowFn taskQueue buildId historyLength parentClosePolicy
21
+ parentRunId rootRunId cancelRequestedAt
22
+ createdAt startedAt completedAt errorMessage errorType
23
+ determinism { failing cause attempts since lastFailureSeq message }
24
+ `;
25
+ /** The chain fields `runs result --follow-runs` and the run header need (never refused per field). */
26
+ const CHAIN_FIELDS = `
27
+ businessId runAttempt firstRunId continuedFromRunId continuedToRunId priority
28
+ summary details currentDetails memo startDelayUntil runTimeoutAt executionTimeoutAt
29
+ `;
30
+ const CODE_REPLACE_FIELDS = `
31
+ id kind status buildId previousBuildId targetVersion runId force verifiedRuns
32
+ violations { runId seq message }
33
+ `;
34
+ /** A run with every parity field `runs describe` prints. */
35
+ const PARITY_RUN_FIELDS = `
36
+ ${DURABLE_RUN_FIELDS}
37
+ ${CHAIN_FIELDS}
38
+ completionCallback {
39
+ url status attempts lastStatusCode lastError lastAttemptAt deliveredAt nextAttemptAt
40
+ }
41
+ versioning {
42
+ behavior startBehavior servingVersion buildId heldFromVersion
43
+ override { behavior version }
44
+ pendingOverride { ${CODE_REPLACE_FIELDS} }
45
+ }
46
+ `;
47
+ const PENDING_FIELDS = `
48
+ activities {
49
+ activityId activityType state attempt maxAttempts scheduledAt lastStartedAt
50
+ lastHeartbeatAt heartbeatDetails lastFailure nextAttemptAt summary
51
+ }
52
+ children { runId workflowKey version status startedAt }
53
+ timers { timerId fireAt summary }
54
+ bufferedSignals
55
+ workflowTask { state attempt startedAt failureCause }
56
+ `;
57
+ /** startWorkflow with parity options. */
58
+ export const CF_START_WORKFLOW_PARITY = `
59
+ mutation FluidgridsCodeStartWorkflowParity($input: StartWorkflowInput!) {
60
+ startWorkflow(input: $input) {
61
+ existing
62
+ run { ${DURABLE_RUN_FIELDS} ${CHAIN_FIELDS} }
63
+ }
64
+ }
65
+ `;
66
+ /** TERMINATE_EXISTING: needs the workflow-run delete permission (BP22). */
67
+ export const CF_START_WORKFLOW_TERMINATE_EXISTING = `
68
+ mutation FluidgridsCodeStartWorkflowTerminateExisting($input: StartWorkflowInput!) {
69
+ startWorkflowTerminateExisting(input: $input) {
70
+ existing
71
+ run { ${DURABLE_RUN_FIELDS} ${CHAIN_FIELDS} }
72
+ }
73
+ }
74
+ `;
75
+ /** A run by id with every parity field. */
76
+ export const CF_DESCRIBE_RUN_PARITY = `
77
+ query FluidgridsCodeDescribeRunParity($id: ID!) {
78
+ workflowRun(id: $id) { ${PARITY_RUN_FIELDS} }
79
+ }
80
+ `;
81
+ /** A run by id with its chain fields only (`runs result --follow-runs`). */
82
+ export const CF_RUN_CHAIN = `
83
+ query FluidgridsCodeRunChain($id: ID!) {
84
+ workflowRun(id: $id) { ${DURABLE_RUN_FIELDS} ${CHAIN_FIELDS} }
85
+ }
86
+ `;
87
+ /** The latest run of a workflow id, followed along continue-as-new. */
88
+ export const CF_RUN_BY_WORKFLOW_ID = `
89
+ query FluidgridsCodeRunByWorkflowId($workflowKey: String!, $workflowId: String!, $firstRunId: ID) {
90
+ workflowRunByWorkflowId(
91
+ workflowKey: $workflowKey
92
+ workflowId: $workflowId
93
+ firstRunId: $firstRunId
94
+ ) { ${PARITY_RUN_FIELDS} }
95
+ }
96
+ `;
97
+ /** What a run is waiting on. */
98
+ export const CF_RUN_PENDING = `
99
+ query FluidgridsCodeRunPending($id: ID!) {
100
+ workflowRun(id: $id) { id status pending { ${PENDING_FIELDS} } }
101
+ }
102
+ `;
103
+ /** How many runs the list returns for a filter, in total and per group. */
104
+ export const CF_RUNS_COUNT = `
105
+ query FluidgridsCodeRunsCount($filter: ListWorkflowRunsInput, $groupBy: [RunGroupBy!]) {
106
+ workflowRunsCount(filter: $filter, groupBy: $groupBy) {
107
+ total
108
+ groups { key values count }
109
+ groupsTruncated
110
+ }
111
+ }
112
+ `;
113
+ export const CF_SIGNAL_RUN_BY_TARGET = `
114
+ mutation FluidgridsCodeSignalRunByTarget(
115
+ $target: RunTargetInput!
116
+ $name: String!
117
+ $payload: JSON
118
+ $idempotencyKey: String
119
+ ) {
120
+ signalWorkflowRun(
121
+ target: $target
122
+ name: $name
123
+ payload: $payload
124
+ idempotencyKey: $idempotencyKey
125
+ ) {
126
+ accepted delivered buffered forwardedToRunId seq duplicate
127
+ }
128
+ }
129
+ `;
130
+ export const CF_TERMINATE_RUN_BY_TARGET = `
131
+ mutation FluidgridsCodeTerminateRunByTarget($target: RunTargetInput!, $reason: String) {
132
+ terminateWorkflowRun(target: $target, reason: $reason) { id status completedAt errorMessage }
133
+ }
134
+ `;
135
+ /** `runs cancel <runId>`: the existing cancelWorkflowRun. */
136
+ export const CF_CANCEL_RUN = `
137
+ mutation FluidgridsCodeCancelRun($id: ID!) {
138
+ cancelWorkflowRun(id: $id) { id status completedAt errorMessage }
139
+ }
140
+ `;
141
+ export const CF_CANCEL_RUN_BY_TARGET = `
142
+ mutation FluidgridsCodeCancelRunByTarget($target: RunTargetInput!) {
143
+ cancelWorkflowRunByTarget(target: $target) { id status completedAt errorMessage }
144
+ }
145
+ `;
146
+ /** The stack trace by run id or target, optionally with `__metadata`. */
147
+ export const CF_STACK_TRACE_PARITY = `
148
+ query FluidgridsCodeStackTraceParity(
149
+ $runId: ID
150
+ $target: RunTargetInput
151
+ $enhanced: Boolean
152
+ $metadata: Boolean
153
+ ) {
154
+ workflowRunStackTrace(
155
+ runId: $runId
156
+ target: $target
157
+ enhanced: $enhanced
158
+ metadata: $metadata
159
+ ) {
160
+ trace
161
+ enhanced
162
+ metadata { definition currentDetails }
163
+ }
164
+ }
165
+ `;
166
+ const ROLLOUT_FIELDS = `
167
+ id workflowKey environment fromVersion toVersion percent verifiedPercent promoted
168
+ activationCheck { ${CODE_REPLACE_FIELDS} }
169
+ createdAt updatedAt
170
+ `;
171
+ export const CF_WORKFLOW_ROLLOUTS = `
172
+ query FluidgridsCodeWorkflowRollouts($workflowKey: String!) {
173
+ workflowRollouts(workflowKey: $workflowKey) { ${ROLLOUT_FIELDS} }
174
+ }
175
+ `;
176
+ export const CF_SET_WORKFLOW_ROLLOUT = `
177
+ mutation FluidgridsCodeSetWorkflowRollout($workflowKey: String!, $input: WorkflowRolloutInput!) {
178
+ setWorkflowRollout(workflowKey: $workflowKey, input: $input) { ${ROLLOUT_FIELDS} }
179
+ }
180
+ `;
181
+ export const CF_DELETE_WORKFLOW_ROLLOUT = `
182
+ mutation FluidgridsCodeDeleteWorkflowRollout(
183
+ $workflowKey: String!
184
+ $environment: WorkflowEnvironment
185
+ ) {
186
+ deleteWorkflowRollout(workflowKey: $workflowKey, environment: $environment)
187
+ }
188
+ `;
189
+ export const CF_WORKFLOW_VERSION_DRAINAGE = `
190
+ query FluidgridsCodeWorkflowVersionDrainage($workflowKey: String!, $version: String!) {
191
+ workflowVersionDrainage(workflowKey: $workflowKey, version: $version) {
192
+ workflowKey version status openRuns lastRunStartedAt rolloutTarget
193
+ }
194
+ }
195
+ `;
196
+ export const CF_SET_RUN_VERSIONING_OVERRIDE = `
197
+ mutation FluidgridsCodeSetRunVersioningOverride(
198
+ $runId: ID
199
+ $target: RunTargetInput
200
+ $override: VersioningOverrideInput
201
+ $reason: String
202
+ ) {
203
+ setWorkflowRunVersioningOverride(
204
+ runId: $runId
205
+ target: $target
206
+ override: $override
207
+ reason: $reason
208
+ ) { ${PARITY_RUN_FIELDS} }
209
+ }
210
+ `;
211
+ //# sourceMappingURL=parity-operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parity-operations.js","sourceRoot":"","sources":["../../src/code-first/parity-operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,kBAAkB,GAAG;;;;;;CAM1B,CAAC;AAEF,sGAAsG;AACtG,MAAM,YAAY,GAAG;;;CAGpB,CAAC;AAEF,MAAM,mBAAmB,GAAG;;;CAG3B,CAAC;AAEF,4DAA4D;AAC5D,MAAM,iBAAiB,GAAG;IACtB,kBAAkB;IAClB,YAAY;;;;;;;wBAOQ,mBAAmB;;CAE1C,CAAC;AAEF,MAAM,cAAc,GAAG;;;;;;;;;CAStB,CAAC;AAEF,yCAAyC;AACzC,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;cAI1B,kBAAkB,IAAI,YAAY;;;CAG/C,CAAC;AAEF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,oCAAoC,GAAG;;;;cAItC,kBAAkB,IAAI,YAAY;;;CAG/C,CAAC;AAEF,2CAA2C;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG;;6BAET,iBAAiB;;CAE7C,CAAC;AAEF,4EAA4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG;;6BAEC,kBAAkB,IAAI,YAAY;;CAE9D,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;UAM3B,iBAAiB;;CAE1B,CAAC;AAEF,gCAAgC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG;;iDAEmB,cAAc;;CAE9D,CAAC;AAEF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;CAQ5B,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;CAgBtC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;CAIzC,CAAC;AAEF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,aAAa,GAAG;;;;CAI5B,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;CAItC,CAAC;AAEF,yEAAyE;AACzE,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;CAkBpC,CAAC;AAEF,MAAM,cAAc,GAAG;;sBAED,mBAAmB;;CAExC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;;oDAEgB,cAAc;;CAEjE,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG;;qEAE8B,cAAc;;CAElF,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;CAOzC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;CAM3C,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;UAYpC,iBAAiB;;CAE1B,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Option parsing shared by the durable-function parity commands (BOFF-9905
3
+ * B19, spec code-first 11): run targets (`--workflow-id` with `--key`), the
4
+ * workflow-id policies, durations, the completion callback and the start
5
+ * options of `runs start`.
6
+ *
7
+ * The service is the authority on every value (it refuses with VALIDATION or,
8
+ * without fluidgrids.durable-parity, FEATURE_DISABLED); the CLI only checks
9
+ * what it can say better up front, and never takes a secret from argv.
10
+ */
11
+ import type { DurableRun, IdConflictPolicy, IdReusePolicy, RunGroupBy, RunRef, RunTarget, StartWorkflowInput, VersioningBehavior } from './api.js';
12
+ import { type CommandEnv } from './shared.js';
13
+ /** `--workflow-id <id> --key <workflowKey> [--first-run-id <id>]`. */
14
+ export interface TargetOptions {
15
+ workflowId?: string;
16
+ key?: string;
17
+ firstRunId?: string;
18
+ }
19
+ /**
20
+ * The run a command acts on: the positional run id, or the latest run of a
21
+ * workflow id. Exactly one of the two forms.
22
+ */
23
+ export declare function runRefOf(runId: string | undefined, options: TargetOptions): RunRef;
24
+ export declare function describeTarget(target: RunTarget): string;
25
+ /** The latest run of a target with its parity fields, or NOT_FOUND. */
26
+ export declare function resolveTarget(env: CommandEnv, target: RunTarget): Promise<DurableRun>;
27
+ /** The run id of a reference (a target resolves to its latest run). */
28
+ export declare function resolveRunId(env: CommandEnv, ref: RunRef): Promise<string>;
29
+ export declare const ID_REUSE_POLICIES: readonly IdReusePolicy[];
30
+ export declare const ID_CONFLICT_POLICIES: readonly IdConflictPolicy[];
31
+ export declare const VERSIONING_BEHAVIORS: readonly VersioningBehavior[];
32
+ export declare const RUN_GROUP_BY: readonly RunGroupBy[];
33
+ export declare function parseIdReuse(raw: string | undefined): IdReusePolicy | undefined;
34
+ export declare function parseIdConflict(raw: string | undefined): IdConflictPolicy | undefined;
35
+ export declare function parseVersioning(raw: string | undefined, flag: string): VersioningBehavior | undefined;
36
+ /** `--group-by status,task-queue`: at most two distinct columns. */
37
+ export declare function parseGroupBy(raw: string | undefined): RunGroupBy[];
38
+ /**
39
+ * A duration as the service takes it: a whole number of milliseconds, or what the workflow IR's
40
+ * `durationMs` reads (`1.5s`, `5m`, `2h`, `7d`, `2w`, ISO 8601 `PT2H` or `P1W`). This is the same
41
+ * check the service runs (`parseDurationMs` in wspace-workflow-svc), so the CLI neither refuses a
42
+ * value the service takes nor sends one it refuses. The service checks the limits (30 days for a
43
+ * start delay, 120 s for a task timeout).
44
+ */
45
+ export declare function parseDuration(raw: string | undefined, flag: string): string | undefined;
46
+ /** `--priority 1..5` (1 is the highest). */
47
+ export declare function parsePriority(raw: string | undefined): number | undefined;
48
+ /**
49
+ * `--callback-header 'Name: value'` (repeatable) and `--callback-header-env 'Name=ENV_VAR'`
50
+ * (repeatable; the value is read from the environment, so a credential stays out of argv).
51
+ * Errors name the option and its position, never the argument: a malformed entry usually still
52
+ * holds a bearer token.
53
+ */
54
+ export declare function parseHeaders(raw: readonly string[] | undefined, fromEnv?: {
55
+ env: CommandEnv;
56
+ entries: readonly string[] | undefined;
57
+ }): Record<string, string> | undefined;
58
+ /** The callback signing secret, read from the named environment variable (never from argv). */
59
+ export declare function readSecretEnv(env: CommandEnv, name: string | undefined): string | undefined;
60
+ /** A JSON object option (`--memo`). */
61
+ export declare function parseJsonObject(raw: string | undefined, flag: string): Record<string, unknown> | undefined;
62
+ /** The parity options of `runs start`. */
63
+ export interface ParityStartOptions {
64
+ workflowId?: string;
65
+ idReuse?: string;
66
+ idConflict?: string;
67
+ delay?: string;
68
+ runTimeout?: string;
69
+ executionTimeout?: string;
70
+ taskTimeout?: string;
71
+ summary?: string;
72
+ detailsFile?: string;
73
+ memo?: string;
74
+ callback?: string;
75
+ callbackHeader?: string[];
76
+ callbackHeaderEnv?: string[];
77
+ callbackSecretEnv?: string;
78
+ priority?: string;
79
+ versioningBehavior?: string;
80
+ }
81
+ /** The parity fields of a StartWorkflowInput from `runs start` options; empty without any. */
82
+ export declare function parityStartFields(env: CommandEnv, options: ParityStartOptions): Partial<StartWorkflowInput>;
83
+ //# sourceMappingURL=parity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parity.d.ts","sourceRoot":"","sources":["../../src/code-first/parity.ts"],"names":[],"mapp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AAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CAgE7B"}
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Option parsing shared by the durable-function parity commands (BOFF-9905
3
+ * B19, spec code-first 11): run targets (`--workflow-id` with `--key`), the
4
+ * workflow-id policies, durations, the completion callback and the start
5
+ * options of `runs start`.
6
+ *
7
+ * The service is the authority on every value (it refuses with VALIDATION or,
8
+ * without fluidgrids.durable-parity, FEATURE_DISABLED); the CLI only checks
9
+ * what it can say better up front, and never takes a secret from argv.
10
+ */
11
+ import { readFileSync } from 'fs';
12
+ import { resolve } from 'path';
13
+ import { CliUserError } from '@burdenoff/cli-sdk/core';
14
+ import { durationMs } from '@fluidgrids/workflows/ir';
15
+ import { describeError, parseJsonOption } from './shared.js';
16
+ /**
17
+ * The run a command acts on: the positional run id, or the latest run of a
18
+ * workflow id. Exactly one of the two forms.
19
+ */
20
+ export function runRefOf(runId, options) {
21
+ const targeted = options.workflowId !== undefined ||
22
+ options.key !== undefined ||
23
+ options.firstRunId !== undefined;
24
+ if (!targeted) {
25
+ if (runId === undefined || runId.trim() === '') {
26
+ throw new CliUserError('Give a run id, or --workflow-id with --key.');
27
+ }
28
+ return { runId };
29
+ }
30
+ if (runId !== undefined) {
31
+ throw new CliUserError('Give a run id or --workflow-id with --key, not both.');
32
+ }
33
+ const workflowId = options.workflowId?.trim() ?? '';
34
+ const key = options.key?.trim() ?? '';
35
+ if (workflowId === '' || key === '') {
36
+ throw new CliUserError('--workflow-id and --key go together (the workflow id of that key).');
37
+ }
38
+ const target = { workflowKey: key, workflowId };
39
+ if (options.firstRunId !== undefined) {
40
+ if (options.firstRunId.trim() === '')
41
+ throw new CliUserError('--first-run-id cannot be empty.');
42
+ target.firstRunId = options.firstRunId;
43
+ }
44
+ return { target };
45
+ }
46
+ export function describeTarget(target) {
47
+ return `workflow id ${target.workflowId} of ${target.workflowKey}`;
48
+ }
49
+ /** The latest run of a target with its parity fields, or NOT_FOUND. */
50
+ export async function resolveTarget(env, target) {
51
+ const run = await env.api.runByWorkflowId(target);
52
+ if (!run)
53
+ throw new CliUserError(`No run with ${describeTarget(target)} (NOT_FOUND)`);
54
+ return run;
55
+ }
56
+ /** The run id of a reference (a target resolves to its latest run). */
57
+ export async function resolveRunId(env, ref) {
58
+ return 'runId' in ref ? ref.runId : (await resolveTarget(env, ref.target)).id;
59
+ }
60
+ /** An enum option given as `use-existing`, `USE_EXISTING` or `use_existing`. */
61
+ function parseEnum(raw, flag, allowed) {
62
+ if (raw === undefined)
63
+ return undefined;
64
+ const normal = raw.trim().toUpperCase().replace(/-/g, '_');
65
+ const match = allowed.find((value) => value === normal);
66
+ if (match === undefined) {
67
+ const shown = allowed.map((value) => value.toLowerCase().replace(/_/g, '-'));
68
+ throw new CliUserError(`Invalid value '${raw}' for ${flag}. Allowed: ${shown.join(', ')}`);
69
+ }
70
+ return match;
71
+ }
72
+ export const ID_REUSE_POLICIES = [
73
+ 'ALLOW_DUPLICATE',
74
+ 'ALLOW_DUPLICATE_FAILED_ONLY',
75
+ 'REJECT_DUPLICATE',
76
+ ];
77
+ export const ID_CONFLICT_POLICIES = [
78
+ 'FAIL',
79
+ 'USE_EXISTING',
80
+ 'TERMINATE_EXISTING',
81
+ ];
82
+ export const VERSIONING_BEHAVIORS = ['PINNED', 'AUTO_UPGRADE'];
83
+ export const RUN_GROUP_BY = [
84
+ 'STATUS',
85
+ 'WORKFLOW_KEY',
86
+ 'EXECUTION_KIND',
87
+ 'TASK_QUEUE',
88
+ ];
89
+ export function parseIdReuse(raw) {
90
+ return parseEnum(raw, '--id-reuse', ID_REUSE_POLICIES);
91
+ }
92
+ export function parseIdConflict(raw) {
93
+ return parseEnum(raw, '--id-conflict', ID_CONFLICT_POLICIES);
94
+ }
95
+ export function parseVersioning(raw, flag) {
96
+ return parseEnum(raw, flag, VERSIONING_BEHAVIORS);
97
+ }
98
+ /** `--group-by status,task-queue`: at most two distinct columns. */
99
+ export function parseGroupBy(raw) {
100
+ if (raw === undefined)
101
+ return [];
102
+ const columns = [];
103
+ for (const part of raw.split(',')) {
104
+ const column = parseEnum(part.trim() === '' ? undefined : part, '--group-by', RUN_GROUP_BY);
105
+ if (column)
106
+ columns.push(column);
107
+ }
108
+ const distinct = [...new Set(columns)];
109
+ if (distinct.length === 0)
110
+ throw new CliUserError('--group-by needs a column.');
111
+ if (distinct.length > 2)
112
+ throw new CliUserError('--group-by takes at most two columns.');
113
+ return distinct;
114
+ }
115
+ /**
116
+ * A duration as the service takes it: a whole number of milliseconds, or what the workflow IR's
117
+ * `durationMs` reads (`1.5s`, `5m`, `2h`, `7d`, `2w`, ISO 8601 `PT2H` or `P1W`). This is the same
118
+ * check the service runs (`parseDurationMs` in wspace-workflow-svc), so the CLI neither refuses a
119
+ * value the service takes nor sends one it refuses. The service checks the limits (30 days for a
120
+ * start delay, 120 s for a task timeout).
121
+ */
122
+ export function parseDuration(raw, flag) {
123
+ if (raw === undefined)
124
+ return undefined;
125
+ const value = raw.trim();
126
+ if (/^\d+$/.test(value))
127
+ return value;
128
+ const ms = value === '' ? undefined : durationMs(value, 'ms');
129
+ if (ms === undefined || !Number.isFinite(ms)) {
130
+ throw new CliUserError(`Invalid value '${raw}' for ${flag}: expected milliseconds or a duration such as 1.5s, 5m, 2h, 2w or PT2H.`);
131
+ }
132
+ return value;
133
+ }
134
+ /** `--priority 1..5` (1 is the highest). */
135
+ export function parsePriority(raw) {
136
+ if (raw === undefined)
137
+ return undefined;
138
+ if (!/^[1-5]$/.test(raw.trim())) {
139
+ throw new CliUserError(`Invalid value '${raw}' for --priority: expected 1 (highest) to 5.`);
140
+ }
141
+ return Number(raw.trim());
142
+ }
143
+ /** Header names the callback cannot set (the service refuses them too). */
144
+ const RESERVED_HEADER = /^(host|content-.*|user-agent|x-fluidgrids-.*|connection|keep-alive|transfer-encoding|te|trailer|upgrade|proxy-.*)$/i;
145
+ const HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
146
+ const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
147
+ function addHeader(headers, name, value) {
148
+ if (RESERVED_HEADER.test(name)) {
149
+ throw new CliUserError(`--callback-header cannot set ${name}.`);
150
+ }
151
+ const lower = name.toLowerCase();
152
+ if (Object.keys(headers).some((existing) => existing.toLowerCase() === lower)) {
153
+ throw new CliUserError(`--callback-header ${name} is given twice.`);
154
+ }
155
+ Object.defineProperty(headers, name, {
156
+ value,
157
+ enumerable: true,
158
+ writable: true,
159
+ configurable: true,
160
+ });
161
+ }
162
+ /**
163
+ * `--callback-header 'Name: value'` (repeatable) and `--callback-header-env 'Name=ENV_VAR'`
164
+ * (repeatable; the value is read from the environment, so a credential stays out of argv).
165
+ * Errors name the option and its position, never the argument: a malformed entry usually still
166
+ * holds a bearer token.
167
+ */
168
+ export function parseHeaders(raw, fromEnv) {
169
+ const envEntries = fromEnv?.entries ?? [];
170
+ if ((raw === undefined || raw.length === 0) && envEntries.length === 0)
171
+ return undefined;
172
+ const headers = {};
173
+ (raw ?? []).forEach((entry, index) => {
174
+ const at = entry.indexOf(':');
175
+ const name = (at < 0 ? '' : entry.slice(0, at)).trim();
176
+ if (!HEADER_NAME.test(name)) {
177
+ throw new CliUserError(`Invalid --callback-header #${index + 1}: expected 'Name: value' with a header name before the colon (the argument is not printed).`);
178
+ }
179
+ addHeader(headers, name, entry.slice(at + 1).trim());
180
+ });
181
+ envEntries.forEach((entry, index) => {
182
+ const at = entry.indexOf('=');
183
+ const name = (at < 0 ? '' : entry.slice(0, at)).trim();
184
+ const variable = at < 0 ? '' : entry.slice(at + 1).trim();
185
+ if (!HEADER_NAME.test(name) || !ENV_NAME.test(variable)) {
186
+ throw new CliUserError(`Invalid --callback-header-env #${index + 1}: expected 'Name=ENV_VAR' (the argument is not printed).`);
187
+ }
188
+ const value = fromEnv?.env.getEnv(variable);
189
+ if (value === undefined || value.trim() === '') {
190
+ throw new CliUserError(`The environment variable ${variable} (--callback-header-env ${name}) is empty or unset.`);
191
+ }
192
+ addHeader(headers, name, value.trim());
193
+ });
194
+ return headers;
195
+ }
196
+ /** The callback signing secret, read from the named environment variable (never from argv). */
197
+ export function readSecretEnv(env, name) {
198
+ if (name === undefined)
199
+ return undefined;
200
+ if (!ENV_NAME.test(name)) {
201
+ throw new CliUserError(`Invalid environment variable name for --callback-secret-env.`);
202
+ }
203
+ const value = env.getEnv(name);
204
+ if (value === undefined || value.trim() === '') {
205
+ throw new CliUserError(`The environment variable ${name} (--callback-secret-env) is empty or unset.`);
206
+ }
207
+ if (value.length < 16 || value.length > 512) {
208
+ throw new CliUserError(`The signing secret in ${name} must be 16 to 512 characters long (it has ${value.length}).`);
209
+ }
210
+ return value;
211
+ }
212
+ /** A JSON object option (`--memo`). */
213
+ export function parseJsonObject(raw, flag) {
214
+ const value = parseJsonOption(raw, flag);
215
+ if (value === undefined)
216
+ return undefined;
217
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
218
+ throw new CliUserError(`${flag} must be a JSON object.`);
219
+ }
220
+ // Checked above to be a plain JSON object.
221
+ return value;
222
+ }
223
+ /** The parity fields of a StartWorkflowInput from `runs start` options; empty without any. */
224
+ export function parityStartFields(env, options) {
225
+ const fields = {};
226
+ if (options.workflowId !== undefined) {
227
+ if (options.workflowId.trim() === '')
228
+ throw new CliUserError('--workflow-id cannot be empty.');
229
+ fields.workflowId = options.workflowId;
230
+ }
231
+ const reuse = parseIdReuse(options.idReuse);
232
+ if (reuse)
233
+ fields.idReusePolicy = reuse;
234
+ const conflict = parseIdConflict(options.idConflict);
235
+ if (conflict)
236
+ fields.idConflictPolicy = conflict;
237
+ if (conflict === 'TERMINATE_EXISTING' && fields.workflowId === undefined) {
238
+ throw new CliUserError('--id-conflict terminate-existing needs --workflow-id.');
239
+ }
240
+ const delay = parseDuration(options.delay, '--delay');
241
+ if (delay)
242
+ fields.startDelay = delay;
243
+ const runTimeout = parseDuration(options.runTimeout, '--run-timeout');
244
+ if (runTimeout)
245
+ fields.runTimeout = runTimeout;
246
+ const executionTimeout = parseDuration(options.executionTimeout, '--execution-timeout');
247
+ if (executionTimeout)
248
+ fields.executionTimeout = executionTimeout;
249
+ const taskTimeout = parseDuration(options.taskTimeout, '--task-timeout');
250
+ if (taskTimeout)
251
+ fields.workflowTaskTimeout = taskTimeout;
252
+ if (options.summary !== undefined)
253
+ fields.summary = options.summary;
254
+ if (options.detailsFile !== undefined) {
255
+ const path = resolve(env.cwd(), options.detailsFile);
256
+ try {
257
+ fields.details = readFileSync(path, 'utf8');
258
+ }
259
+ catch (error) {
260
+ throw new CliUserError(`Cannot read --details-file ${options.detailsFile}: ${describeError(error)}`);
261
+ }
262
+ }
263
+ const memo = parseJsonObject(options.memo, '--memo');
264
+ if (memo)
265
+ fields.context = memo;
266
+ const headers = parseHeaders(options.callbackHeader, {
267
+ env,
268
+ entries: options.callbackHeaderEnv,
269
+ });
270
+ const secret = readSecretEnv(env, options.callbackSecretEnv);
271
+ if (options.callback === undefined) {
272
+ if (headers || secret !== undefined) {
273
+ throw new CliUserError('--callback-header, --callback-header-env and --callback-secret-env need --callback <url>.');
274
+ }
275
+ }
276
+ else {
277
+ let url;
278
+ try {
279
+ url = new URL(options.callback);
280
+ }
281
+ catch {
282
+ throw new CliUserError(`--callback must be an http(s) URL.`);
283
+ }
284
+ if (url.protocol !== 'https:' && url.protocol !== 'http:') {
285
+ throw new CliUserError(`--callback must be an http(s) URL.`);
286
+ }
287
+ fields.completionCallbackUrl = options.callback;
288
+ if (headers)
289
+ fields.completionCallbackHeaders = headers;
290
+ if (secret !== undefined)
291
+ fields.completionCallbackSigningSecret = secret;
292
+ }
293
+ const priority = parsePriority(options.priority);
294
+ if (priority !== undefined)
295
+ fields.priority = priority;
296
+ const versioning = parseVersioning(options.versioningBehavior, '--versioning-behavior');
297
+ if (versioning)
298
+ fields.versioningBehavior = versioning;
299
+ return fields;
300
+ }
301
+ //# sourceMappingURL=parity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parity.js","sourceRoot":"","sources":["../../src/code-first/parity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAYtD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAS9E;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAyB,EAAE,OAAsB;IACxE,MAAM,QAAQ,GACZ,OAAO,CAAC,UAAU,KAAK,SAAS;QAChC,OAAO,CAAC,GAAG,KAAK,SAAS;QACzB,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC;IACnC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC/C,MAAM,IAAI,YAAY,CAAC,6CAA6C,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,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AC,CAAC;QAC/D,CAAC;QACD,MAAM,CAAC,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;QAChD,IAAI,OAAO;YAAE,MAAM,CAAC,yBAAyB,GAAG,OAAO,CAAC;QACxD,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,CAAC,+BAA+B,GAAG,MAAM,CAAC;IAC5E,CAAC;IACD,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,QAAQ,KAAK,SAAS;QAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACvD,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,CAAC;IACxF,IAAI,UAAU;QAAE,MAAM,CAAC,kBAAkB,GAAG,UAAU,CAAC;IACvD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Keep credentials that travel in GraphQL variables out of anything the CLI prints.
3
+ *
4
+ * graphql-request's ClientError builds its `message` from
5
+ * `JSON.stringify({ response, request: { query, variables } })`, and the cli-sdk error printer
6
+ * falls back to that message whenever the response carries no GraphQL error (a 413 from the
7
+ * gateway's body limit, a 502 from a load balancer, a WAF page). Parity starts carry the
8
+ * completion-callback signing secret and headers in their variables, so without this the CLI
9
+ * printed them on stderr (BOFF-9905 B19-P8).
10
+ */
11
+ export declare const REDACTED = "[REDACTED]";
12
+ /** Deep copy of `value` with every credential value replaced by {@link REDACTED}. */
13
+ export declare function redactVariables(value: unknown): unknown;
14
+ /** Every credential string inside `value` (the values {@link redactVariables} replaces). */
15
+ export declare function collectSecrets(value: unknown, into?: string[]): string[];
16
+ /** Replace every occurrence of each secret (and its JSON-escaped form) in `text`. */
17
+ export declare function scrubSecrets(text: string, secrets: readonly string[]): string;
18
+ /**
19
+ * Strip the request variables out of a gateway error before anything prints it.
20
+ *
21
+ * - An error whose message is a graphql-request ClientError dump (cli-sdk rethrows the
22
+ * ClientError message as a plain Error) keeps only the part before the dump. When that is
23
+ * `GraphQL Error (Code: N)`, the response had no GraphQL error (an HTML 413 or 502 page), and
24
+ * the error becomes a CliUserError, or a CliAuthError for 401/403, naming the status only.
25
+ * - A raw ClientError (an Error with `response` and `request`) is handled the same way from its
26
+ * `response`; with a GraphQL error it keeps its class, its message becomes that error alone and
27
+ * its `request.variables` are redacted.
28
+ * - Every message and stack left has the secrets in `variables` scrubbed.
29
+ */
30
+ export declare function sanitizeGatewayError(err: unknown, variables: Record<string, unknown>): unknown;
31
+ //# sourceMappingURL=redact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/code-first/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,eAAO,MAAM,QAAQ,eAAe,CAAC;AAYrC,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAcvD;AAED,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE,CAgB5E;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAQ7E;AAsCD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAyB9F"}