@fluidgrids/cli 2026.1115.1 → 2026.1115.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.
- package/README.md +13 -0
- package/dist/cli.js +529 -266
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -895,7 +895,13 @@ var PRESIGNED_PUT_FIELDS = "url method headers expiresAt alreadyStored", CF_PREP
|
|
|
895
895
|
query FluidgridsCodeWorkflowRunHistory($runId: ID!, $after: Int, $limit: Int) {
|
|
896
896
|
workflowRunHistory(runId: $runId, after: $after, limit: $limit) {
|
|
897
897
|
events { runId seq type taskId payload payloadUrl createdAt }
|
|
898
|
-
nextAfter hasMore historyLength historyBytes
|
|
898
|
+
nextAfter hasMore historyLength historyBytes archived archiveRef archiveReadError
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
`, CF_WORKFLOW_RUN_ARCHIVE = `
|
|
902
|
+
query FluidgridsCodeWorkflowRunArchive($runId: ID!) {
|
|
903
|
+
workflowRunArchive(runId: $runId) {
|
|
904
|
+
runId workflowKey version executionKind status archivedAt archiveRef includePayloads eventCount
|
|
899
905
|
}
|
|
900
906
|
}
|
|
901
907
|
`, CF_SIGNAL_WORKFLOW_RUN = `
|
|
@@ -1471,6 +1477,10 @@ function createCodeFirstApi(ctx) {
|
|
|
1471
1477
|
throw new CliUserError8(`Run ${runId} not found (NOT_FOUND)`);
|
|
1472
1478
|
return data.workflowRun;
|
|
1473
1479
|
},
|
|
1480
|
+
async runArchive(runId) {
|
|
1481
|
+
const data = await request(CF_WORKFLOW_RUN_ARCHIVE, { runId });
|
|
1482
|
+
return data.workflowRunArchive;
|
|
1483
|
+
},
|
|
1474
1484
|
async runHistoryPage(runId, after, limit) {
|
|
1475
1485
|
const data = await request(CF_WORKFLOW_RUN_HISTORY, {
|
|
1476
1486
|
runId,
|
|
@@ -3674,13 +3684,24 @@ async function offloadedPayload(env, event, runId) {
|
|
|
3674
3684
|
}
|
|
3675
3685
|
return objectPayload(parsed, where);
|
|
3676
3686
|
}
|
|
3687
|
+
function assertArchiveReadable(runId, page) {
|
|
3688
|
+
if (!page.archived || page.archiveReadError === null)
|
|
3689
|
+
return;
|
|
3690
|
+
const where = page.archiveRef ? ` (${page.archiveRef})` : "";
|
|
3691
|
+
throw new CliUserError19(`Run ${runId} was archived${where}, but its history could not be read back: ${page.archiveReadError}`, {
|
|
3692
|
+
hint: [
|
|
3693
|
+
"The archive destination must grant s3:GetObject on the archive prefix to the archive role.",
|
|
3694
|
+
`You can also download history.jsonl.gz from the archive yourself and run \`fluidgrids replay <path>/history.jsonl.gz\`.`
|
|
3695
|
+
].join(`
|
|
3696
|
+
`)
|
|
3697
|
+
});
|
|
3698
|
+
}
|
|
3677
3699
|
async function fetchRunEvents(env, runId) {
|
|
3678
3700
|
const events = [];
|
|
3679
3701
|
let after = 0;
|
|
3680
|
-
let historyBytes = 0;
|
|
3681
3702
|
for (let page = 0;page < MAX_PAGES; page++) {
|
|
3682
3703
|
const result = await env.api.runHistoryPage(runId, after, HISTORY_PAGE_SIZE);
|
|
3683
|
-
|
|
3704
|
+
assertArchiveReadable(runId, result);
|
|
3684
3705
|
for (const event of result.events) {
|
|
3685
3706
|
const payload = event.payloadUrl ? await offloadedPayload(env, event, runId) : objectPayload(event.payload, `Run ${runId} event ${event.seq}`);
|
|
3686
3707
|
events.push({
|
|
@@ -3692,8 +3713,15 @@ async function fetchRunEvents(env, runId) {
|
|
|
3692
3713
|
});
|
|
3693
3714
|
}
|
|
3694
3715
|
const last = result.events[result.events.length - 1];
|
|
3695
|
-
if (!result.hasMore || !last)
|
|
3696
|
-
return {
|
|
3716
|
+
if (!result.hasMore || !last) {
|
|
3717
|
+
return {
|
|
3718
|
+
events,
|
|
3719
|
+
historyBytes: result.historyBytes,
|
|
3720
|
+
archived: result.archived === true,
|
|
3721
|
+
archiveRef: result.archiveRef ?? null,
|
|
3722
|
+
historyLength: result.historyLength
|
|
3723
|
+
};
|
|
3724
|
+
}
|
|
3697
3725
|
after = result.nextAfter ?? last.seq;
|
|
3698
3726
|
}
|
|
3699
3727
|
throw new CliUserError19(`The history of run ${runId} did not end after ${MAX_PAGES} pages; refusing to continue.`);
|
|
@@ -3703,12 +3731,70 @@ function assertDurable(run) {
|
|
|
3703
3731
|
throw new CliUserError19(`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.` });
|
|
3704
3732
|
}
|
|
3705
3733
|
}
|
|
3734
|
+
function workflowFnOf(run, events) {
|
|
3735
|
+
if (run?.workflowFn)
|
|
3736
|
+
return run.workflowFn;
|
|
3737
|
+
const started = events[0]?.type === "WORKFLOW_STARTED" ? events[0].payload : undefined;
|
|
3738
|
+
return started && typeof started["workflowFn"] === "string" ? started["workflowFn"] : undefined;
|
|
3739
|
+
}
|
|
3740
|
+
function validated(file, runId) {
|
|
3741
|
+
try {
|
|
3742
|
+
return parseHistoryFile(file);
|
|
3743
|
+
} catch (error) {
|
|
3744
|
+
if (error instanceof HistoryFileError) {
|
|
3745
|
+
throw new CliUserError19(`The history of run ${runId} is not a valid history file.`, {
|
|
3746
|
+
hint: [error.message, ...error.issues].join(`
|
|
3747
|
+
`)
|
|
3748
|
+
});
|
|
3749
|
+
}
|
|
3750
|
+
throw error;
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
async function fetchArchivedHistory(env, runId) {
|
|
3754
|
+
const archive = await env.api.runArchive(runId);
|
|
3755
|
+
if (!archive)
|
|
3756
|
+
throw new CliUserError19(`Run ${runId} not found (NOT_FOUND)`);
|
|
3757
|
+
const where = `Run ${runId} was archived (${archive.archiveRef})`;
|
|
3758
|
+
if (archive.executionKind !== "DURABLE_FN") {
|
|
3759
|
+
throw new CliUserError19(`${where} as a ${archive.executionKind} run; only durable-function runs have an event history.`, { hint: "A canvas run keeps its node executions in nodes.jsonl.gz next to the archive." });
|
|
3760
|
+
}
|
|
3761
|
+
if (!archive.includePayloads) {
|
|
3762
|
+
throw new CliUserError19(`${where} without its payloads (includePayloads: false), so its history cannot be replayed.`);
|
|
3763
|
+
}
|
|
3764
|
+
const fetched = await fetchRunEvents(env, runId);
|
|
3765
|
+
if (fetched.events.length === 0) {
|
|
3766
|
+
throw new CliUserError19(`${where} with no history events.`);
|
|
3767
|
+
}
|
|
3768
|
+
const workflowFn = workflowFnOf(null, fetched.events);
|
|
3769
|
+
if (!workflowFn)
|
|
3770
|
+
throw new CliUserError19(`Run ${runId} records no workflow function.`);
|
|
3771
|
+
const workspaceId = env.ctx.auth.read()?.workspaceId ?? "unknown";
|
|
3772
|
+
const file = createHistoryFile(workflowFn, fetched.events, {
|
|
3773
|
+
name: runId,
|
|
3774
|
+
info: { runId, workspaceId, workflowKey: archive.workflowKey, version: archive.version }
|
|
3775
|
+
});
|
|
3776
|
+
return {
|
|
3777
|
+
run: null,
|
|
3778
|
+
file: validated(file, runId),
|
|
3779
|
+
historyBytes: fetched.historyBytes,
|
|
3780
|
+
archive: { archiveRef: archive.archiveRef }
|
|
3781
|
+
};
|
|
3782
|
+
}
|
|
3783
|
+
function isRunNotFound(error) {
|
|
3784
|
+
return error instanceof CliUserError19 && /\(NOT_FOUND\)/.test(error.message);
|
|
3785
|
+
}
|
|
3706
3786
|
async function fetchHistory(env, runId) {
|
|
3707
|
-
|
|
3787
|
+
let run;
|
|
3788
|
+
try {
|
|
3789
|
+
run = await env.api.describeRun(runId);
|
|
3790
|
+
} catch (error) {
|
|
3791
|
+
if (isRunNotFound(error))
|
|
3792
|
+
return fetchArchivedHistory(env, runId);
|
|
3793
|
+
throw error;
|
|
3794
|
+
}
|
|
3708
3795
|
assertDurable(run);
|
|
3709
3796
|
const { events, historyBytes } = await fetchRunEvents(env, runId);
|
|
3710
|
-
const
|
|
3711
|
-
const workflowFn = run.workflowFn ?? (started && typeof started["workflowFn"] === "string" ? started["workflowFn"] : undefined);
|
|
3797
|
+
const workflowFn = workflowFnOf(run, events);
|
|
3712
3798
|
if (!workflowFn) {
|
|
3713
3799
|
throw new CliUserError19(`Run ${runId} records no workflow function.`);
|
|
3714
3800
|
}
|
|
@@ -3726,17 +3812,7 @@ async function fetchHistory(env, runId) {
|
|
|
3726
3812
|
rootRunId: run.rootRunId
|
|
3727
3813
|
}
|
|
3728
3814
|
});
|
|
3729
|
-
|
|
3730
|
-
return { run, file: parseHistoryFile(file), historyBytes };
|
|
3731
|
-
} catch (error) {
|
|
3732
|
-
if (error instanceof HistoryFileError) {
|
|
3733
|
-
throw new CliUserError19(`The history of run ${runId} is not a valid history file.`, {
|
|
3734
|
-
hint: [error.message, ...error.issues].join(`
|
|
3735
|
-
`)
|
|
3736
|
-
});
|
|
3737
|
-
}
|
|
3738
|
-
throw error;
|
|
3739
|
-
}
|
|
3815
|
+
return { run, file: validated(file, runId), historyBytes, archive: null };
|
|
3740
3816
|
}
|
|
3741
3817
|
function parseHistoryText(text, path) {
|
|
3742
3818
|
try {
|
|
@@ -5843,14 +5919,18 @@ async function runDescribe(env, runId, options) {
|
|
|
5843
5919
|
}
|
|
5844
5920
|
async function runHistory(env, runIdArg, options) {
|
|
5845
5921
|
const runId = await resolveRunId(env, runRefOf(runIdArg, options));
|
|
5846
|
-
const { file, historyBytes } = await fetchHistory(env, runId);
|
|
5922
|
+
const { file, historyBytes, archive } = await fetchHistory(env, runId);
|
|
5847
5923
|
const result = {
|
|
5848
5924
|
runId,
|
|
5849
5925
|
workflowFn: file.workflowFn,
|
|
5850
5926
|
events: file.events.length,
|
|
5851
5927
|
historyBytes,
|
|
5852
|
-
out: null
|
|
5928
|
+
out: null,
|
|
5929
|
+
archiveRef: archive ? archive.archiveRef : null
|
|
5853
5930
|
};
|
|
5931
|
+
const archivedNote = archive ? [
|
|
5932
|
+
`Run ${runId} was archived and purged; its history was read back from ${archive.archiveRef}.`
|
|
5933
|
+
] : [];
|
|
5854
5934
|
if (options.out) {
|
|
5855
5935
|
const target = resolve7(env.cwd(), options.out);
|
|
5856
5936
|
writeFileSync6(target, serializeHistoryFile2(file), "utf8");
|
|
@@ -5858,7 +5938,7 @@ async function runHistory(env, runIdArg, options) {
|
|
|
5858
5938
|
emit(env, options, result, {
|
|
5859
5939
|
headers: ["Run", "Function", "Events", "File"],
|
|
5860
5940
|
rows: [[runId, file.workflowFn, String(result.events), target]]
|
|
5861
|
-
});
|
|
5941
|
+
}, archivedNote);
|
|
5862
5942
|
return result;
|
|
5863
5943
|
}
|
|
5864
5944
|
emit(env, options, file, {
|
|
@@ -5869,7 +5949,7 @@ async function runHistory(env, runIdArg, options) {
|
|
|
5869
5949
|
event.taskId ?? "-",
|
|
5870
5950
|
event.createdAt
|
|
5871
5951
|
])
|
|
5872
|
-
});
|
|
5952
|
+
}, archivedNote);
|
|
5873
5953
|
return result;
|
|
5874
5954
|
}
|
|
5875
5955
|
function isTargeted(options) {
|
|
@@ -6169,13 +6249,194 @@ var init_runs = __esm(() => {
|
|
|
6169
6249
|
];
|
|
6170
6250
|
});
|
|
6171
6251
|
|
|
6172
|
-
// src/code-first/
|
|
6173
|
-
import { existsSync as existsSync11,
|
|
6174
|
-
import {
|
|
6252
|
+
// src/code-first/archive-file.ts
|
|
6253
|
+
import { existsSync as existsSync11, readFileSync as readFileSync10 } from "fs";
|
|
6254
|
+
import { dirname as dirname6, join as join10 } from "path";
|
|
6255
|
+
import { gunzipSync } from "zlib";
|
|
6175
6256
|
import { CliUserError as CliUserError32 } from "@burdenoff/cli-sdk/core";
|
|
6257
|
+
import {
|
|
6258
|
+
createHistoryFile as createHistoryFile2,
|
|
6259
|
+
HistoryFileError as HistoryFileError2,
|
|
6260
|
+
parseHistoryFile as parseHistoryFile2
|
|
6261
|
+
} from "@fluidgrids/workflows/history";
|
|
6176
6262
|
function isRecord17(value) {
|
|
6177
6263
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6178
6264
|
}
|
|
6265
|
+
function isGzip(bytes) {
|
|
6266
|
+
return bytes.length >= 2 && bytes[0] === GZIP_MAGIC[0] && bytes[1] === GZIP_MAGIC[1];
|
|
6267
|
+
}
|
|
6268
|
+
function looksLikeHistoryPath(target) {
|
|
6269
|
+
return /[\\/]|\.json$|\.jsonl$|\.gz$/.test(target);
|
|
6270
|
+
}
|
|
6271
|
+
function optionalString2(value) {
|
|
6272
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
6273
|
+
}
|
|
6274
|
+
function nullableString(value) {
|
|
6275
|
+
if (value === null)
|
|
6276
|
+
return null;
|
|
6277
|
+
return optionalString2(value);
|
|
6278
|
+
}
|
|
6279
|
+
function parseRunDocument(text, display) {
|
|
6280
|
+
let value;
|
|
6281
|
+
try {
|
|
6282
|
+
value = JSON.parse(text);
|
|
6283
|
+
} catch {
|
|
6284
|
+
throw new CliUserError32(`${display} is not JSON.`);
|
|
6285
|
+
}
|
|
6286
|
+
if (!isRecord17(value) || value["format"] !== RUN_ARCHIVE_FORMAT) {
|
|
6287
|
+
throw new CliUserError32(`${display} is not a run archive's run.json (format ${RUN_ARCHIVE_FORMAT}).`);
|
|
6288
|
+
}
|
|
6289
|
+
const runId = optionalString2(value["runId"]);
|
|
6290
|
+
const workspaceId = optionalString2(value["workspaceId"]);
|
|
6291
|
+
if (!runId || !workspaceId) {
|
|
6292
|
+
throw new CliUserError32(`${display} does not name the run and its workspace.`);
|
|
6293
|
+
}
|
|
6294
|
+
const doc = { runId, workspaceId };
|
|
6295
|
+
const workflowKey = optionalString2(value["workflowKey"]);
|
|
6296
|
+
if (workflowKey)
|
|
6297
|
+
doc.workflowKey = workflowKey;
|
|
6298
|
+
const version = optionalString2(value["version"]);
|
|
6299
|
+
if (version)
|
|
6300
|
+
doc.version = version;
|
|
6301
|
+
const kind = optionalString2(value["executionKind"]);
|
|
6302
|
+
if (kind)
|
|
6303
|
+
doc.executionKind = kind;
|
|
6304
|
+
for (const field of ["parentRunId", "rootRunId", "firstRunId", "businessId"]) {
|
|
6305
|
+
const id = nullableString(value[field]);
|
|
6306
|
+
if (id !== undefined)
|
|
6307
|
+
doc[field] = id;
|
|
6308
|
+
}
|
|
6309
|
+
if (typeof value["includePayloads"] === "boolean")
|
|
6310
|
+
doc.includePayloads = value["includePayloads"];
|
|
6311
|
+
return doc;
|
|
6312
|
+
}
|
|
6313
|
+
function archivedEvent(line, lineNumber, display) {
|
|
6314
|
+
const where = `${display} line ${lineNumber}`;
|
|
6315
|
+
let value;
|
|
6316
|
+
try {
|
|
6317
|
+
value = JSON.parse(line);
|
|
6318
|
+
} catch {
|
|
6319
|
+
throw new CliUserError32(`${where} is not JSON.`);
|
|
6320
|
+
}
|
|
6321
|
+
if (!isRecord17(value))
|
|
6322
|
+
throw new CliUserError32(`${where} is not a history event.`);
|
|
6323
|
+
const { seq, type, taskId, payload, createdAt } = value;
|
|
6324
|
+
if (typeof seq !== "number" || typeof type !== "string" || typeof createdAt !== "string") {
|
|
6325
|
+
throw new CliUserError32(`${where} is not a history event (it needs seq, type and createdAt).`);
|
|
6326
|
+
}
|
|
6327
|
+
if (payload === undefined) {
|
|
6328
|
+
throw new CliUserError32(`${display} was archived without its payloads (includePayloads: false), so it cannot be replayed.`);
|
|
6329
|
+
}
|
|
6330
|
+
if (!isRecord17(payload))
|
|
6331
|
+
throw new CliUserError32(`${where}: the payload is not a JSON object.`);
|
|
6332
|
+
return {
|
|
6333
|
+
seq,
|
|
6334
|
+
type,
|
|
6335
|
+
...typeof taskId === "string" && taskId !== "" ? { taskId } : {},
|
|
6336
|
+
payload,
|
|
6337
|
+
createdAt
|
|
6338
|
+
};
|
|
6339
|
+
}
|
|
6340
|
+
function infoOf(doc, fallbackRunId) {
|
|
6341
|
+
if (!doc)
|
|
6342
|
+
return { runId: fallbackRunId, workspaceId: "unknown" };
|
|
6343
|
+
return {
|
|
6344
|
+
runId: doc.runId,
|
|
6345
|
+
workspaceId: doc.workspaceId,
|
|
6346
|
+
...doc.workflowKey ? { workflowKey: doc.workflowKey } : {},
|
|
6347
|
+
...doc.version ? { version: doc.version } : {},
|
|
6348
|
+
...doc.businessId ? { businessId: doc.businessId, workflowId: doc.businessId } : {},
|
|
6349
|
+
...doc.parentRunId !== undefined ? { parentRunId: doc.parentRunId } : {},
|
|
6350
|
+
...doc.rootRunId !== undefined ? { rootRunId: doc.rootRunId } : {},
|
|
6351
|
+
...doc.firstRunId !== undefined ? { firstRunId: doc.firstRunId } : {}
|
|
6352
|
+
};
|
|
6353
|
+
}
|
|
6354
|
+
function parseArchivedHistory(text, display, doc = null) {
|
|
6355
|
+
if (doc?.executionKind !== undefined && doc.executionKind !== "DURABLE_FN") {
|
|
6356
|
+
throw new CliUserError32(`${display} is the archive of a ${doc.executionKind} run; only durable-function runs have an event history to replay.`);
|
|
6357
|
+
}
|
|
6358
|
+
if (doc?.includePayloads === false) {
|
|
6359
|
+
throw new CliUserError32(`${display} was archived without its payloads (includePayloads: false), so it cannot be replayed.`);
|
|
6360
|
+
}
|
|
6361
|
+
const events = [];
|
|
6362
|
+
let lineNumber = 0;
|
|
6363
|
+
for (const line of text.split(`
|
|
6364
|
+
`)) {
|
|
6365
|
+
lineNumber += 1;
|
|
6366
|
+
if (line.trim() === "")
|
|
6367
|
+
continue;
|
|
6368
|
+
events.push(archivedEvent(line, lineNumber, display));
|
|
6369
|
+
}
|
|
6370
|
+
if (events.length === 0) {
|
|
6371
|
+
throw new CliUserError32(`${display} holds no history events.`, {
|
|
6372
|
+
hint: "A canvas (graph) run archives no history events; its node executions are in nodes.jsonl.gz."
|
|
6373
|
+
});
|
|
6374
|
+
}
|
|
6375
|
+
const started = events[0];
|
|
6376
|
+
const workflowFn = started?.type === "WORKFLOW_STARTED" && typeof started.payload["workflowFn"] === "string" ? started.payload["workflowFn"] : undefined;
|
|
6377
|
+
if (!workflowFn) {
|
|
6378
|
+
throw new CliUserError32(`${display} does not start with a WORKFLOW_STARTED event naming its function.`);
|
|
6379
|
+
}
|
|
6380
|
+
const file = createHistoryFile2(workflowFn, events, {
|
|
6381
|
+
name: doc?.runId ?? display,
|
|
6382
|
+
info: infoOf(doc, display)
|
|
6383
|
+
});
|
|
6384
|
+
try {
|
|
6385
|
+
return parseHistoryFile2(file);
|
|
6386
|
+
} catch (error) {
|
|
6387
|
+
if (error instanceof HistoryFileError2) {
|
|
6388
|
+
throw new CliUserError32(`${display} is not a valid run history: ${error.message}`, {
|
|
6389
|
+
...error.issues.length > 0 ? { hint: error.issues.join(`
|
|
6390
|
+
`) } : {}
|
|
6391
|
+
});
|
|
6392
|
+
}
|
|
6393
|
+
throw error;
|
|
6394
|
+
}
|
|
6395
|
+
}
|
|
6396
|
+
function gunzip(bytes, display) {
|
|
6397
|
+
try {
|
|
6398
|
+
return gunzipSync(bytes, { maxOutputLength: MAX_ARCHIVE_HISTORY_BYTES }).toString("utf8");
|
|
6399
|
+
} catch (error) {
|
|
6400
|
+
const code = isRecord17(error) ? error["code"] : undefined;
|
|
6401
|
+
if (code === "ERR_BUFFER_TOO_LARGE") {
|
|
6402
|
+
throw new CliUserError32(`${display} decompresses to more than ${MAX_ARCHIVE_HISTORY_BYTES} bytes; it is not a run archive's history.`);
|
|
6403
|
+
}
|
|
6404
|
+
throw new CliUserError32(`${display} is not a readable gzip file.`);
|
|
6405
|
+
}
|
|
6406
|
+
}
|
|
6407
|
+
function siblingRunDocument(path, display) {
|
|
6408
|
+
const runJson = join10(dirname6(path), "run.json");
|
|
6409
|
+
if (!existsSync11(runJson))
|
|
6410
|
+
return null;
|
|
6411
|
+
return parseRunDocument(readFileSync10(runJson, "utf8"), join10(dirname6(display), "run.json"));
|
|
6412
|
+
}
|
|
6413
|
+
function readHistoryFromDisk(path, display) {
|
|
6414
|
+
const bytes = readFileSync10(path);
|
|
6415
|
+
if (isGzip(bytes)) {
|
|
6416
|
+
return parseArchivedHistory(gunzip(bytes, display), display, siblingRunDocument(path, display));
|
|
6417
|
+
}
|
|
6418
|
+
const text = bytes.toString("utf8");
|
|
6419
|
+
if (path.endsWith(".jsonl")) {
|
|
6420
|
+
return parseArchivedHistory(text, display, siblingRunDocument(path, display));
|
|
6421
|
+
}
|
|
6422
|
+
if (path.endsWith(".gz"))
|
|
6423
|
+
throw new CliUserError32(`${display} is not a readable gzip file.`);
|
|
6424
|
+
return parseHistoryText(text, display);
|
|
6425
|
+
}
|
|
6426
|
+
var RUN_ARCHIVE_FORMAT = "fluidgrids.run-archive", MAX_ARCHIVE_HISTORY_BYTES, GZIP_MAGIC;
|
|
6427
|
+
var init_archive_file = __esm(() => {
|
|
6428
|
+
init_history();
|
|
6429
|
+
MAX_ARCHIVE_HISTORY_BYTES = 1024 * 1024 * 1024;
|
|
6430
|
+
GZIP_MAGIC = [31, 139];
|
|
6431
|
+
});
|
|
6432
|
+
|
|
6433
|
+
// src/code-first/commands/replay.ts
|
|
6434
|
+
import { existsSync as existsSync12, readdirSync as readdirSync2, readFileSync as readFileSync11, statSync as statSync4 } from "fs";
|
|
6435
|
+
import { join as join11, relative as relative3, resolve as resolve8, sep as sep3 } from "path";
|
|
6436
|
+
import { CliUserError as CliUserError33 } from "@burdenoff/cli-sdk/core";
|
|
6437
|
+
function isRecord18(value) {
|
|
6438
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6439
|
+
}
|
|
6179
6440
|
async function lowerOffline(project) {
|
|
6180
6441
|
return lowerProject(project, {
|
|
6181
6442
|
connections: placeholderRef,
|
|
@@ -6187,10 +6448,10 @@ function durableExportNames(lowered) {
|
|
|
6187
6448
|
const names = new Set;
|
|
6188
6449
|
for (const workflow of lowered.workflows) {
|
|
6189
6450
|
const code = workflow.definition["code"];
|
|
6190
|
-
if (!
|
|
6451
|
+
if (!isRecord18(code) || !isRecord18(code["exports"]))
|
|
6191
6452
|
continue;
|
|
6192
6453
|
const workflows = code["exports"]["workflows"];
|
|
6193
|
-
if (
|
|
6454
|
+
if (isRecord18(workflows))
|
|
6194
6455
|
for (const name of Object.keys(workflows))
|
|
6195
6456
|
names.add(name);
|
|
6196
6457
|
}
|
|
@@ -6198,7 +6459,7 @@ function durableExportNames(lowered) {
|
|
|
6198
6459
|
}
|
|
6199
6460
|
function requireBundle(lowered) {
|
|
6200
6461
|
if (!lowered.bundle || !lowered.buildId || durableExportNames(lowered).length === 0) {
|
|
6201
|
-
throw new
|
|
6462
|
+
throw new CliUserError33("The project defines no durable functions to replay.", {
|
|
6202
6463
|
hint: "Durable functions are `workflow()` exports in workflows/*.ts."
|
|
6203
6464
|
});
|
|
6204
6465
|
}
|
|
@@ -6207,7 +6468,7 @@ function requireBundle(lowered) {
|
|
|
6207
6468
|
async function openReplayer(project, lowered, isolate) {
|
|
6208
6469
|
if (project.config.language === "py") {
|
|
6209
6470
|
if (!lowered.buildId || durableExportNames(lowered).length === 0) {
|
|
6210
|
-
throw new
|
|
6471
|
+
throw new CliUserError33("The project defines no durable functions to replay.", {
|
|
6211
6472
|
hint: "Durable functions are `@workflow` functions in workflows/*.py."
|
|
6212
6473
|
});
|
|
6213
6474
|
}
|
|
@@ -6221,7 +6482,7 @@ async function openReplayer(project, lowered, isolate) {
|
|
|
6221
6482
|
}
|
|
6222
6483
|
function requireExport(file, exported, name) {
|
|
6223
6484
|
if (!exported.includes(file.workflowFn)) {
|
|
6224
|
-
throw new
|
|
6485
|
+
throw new CliUserError33(`${name} runs ${file.workflowFn}, which this project does not export.`, {
|
|
6225
6486
|
hint: `Exported durable functions: ${exported.join(", ")}`
|
|
6226
6487
|
});
|
|
6227
6488
|
}
|
|
@@ -6244,11 +6505,11 @@ async function runReplay(env, target, options) {
|
|
|
6244
6505
|
const path = resolve8(env.cwd(), target);
|
|
6245
6506
|
let file;
|
|
6246
6507
|
let name;
|
|
6247
|
-
if (
|
|
6248
|
-
file =
|
|
6508
|
+
if (existsSync12(path) && statSync4(path).isFile()) {
|
|
6509
|
+
file = readHistoryFromDisk(path, target);
|
|
6249
6510
|
name = target;
|
|
6250
|
-
} else if (
|
|
6251
|
-
throw new
|
|
6511
|
+
} else if (looksLikeHistoryPath(target)) {
|
|
6512
|
+
throw new CliUserError33(`History file not found: ${target}`);
|
|
6252
6513
|
} else {
|
|
6253
6514
|
file = (await fetchHistory(env, target)).file;
|
|
6254
6515
|
name = target;
|
|
@@ -6258,7 +6519,7 @@ async function runReplay(env, target, options) {
|
|
|
6258
6519
|
requireBundle(lowered);
|
|
6259
6520
|
requireExport(file, durableExportNames(lowered), name);
|
|
6260
6521
|
if (file.replay === false) {
|
|
6261
|
-
throw new
|
|
6522
|
+
throw new CliUserError33(`${name} is marked "replay": false (it uses Phase C features).`);
|
|
6262
6523
|
}
|
|
6263
6524
|
const { replayer, buildId } = await openReplayer(project, lowered, options.isolate);
|
|
6264
6525
|
let outcome;
|
|
@@ -6288,7 +6549,7 @@ async function runReplay(env, target, options) {
|
|
|
6288
6549
|
]
|
|
6289
6550
|
}, details);
|
|
6290
6551
|
if (!outcome.ok) {
|
|
6291
|
-
throw new
|
|
6552
|
+
throw new CliUserError33(outcome.cause === "NON_DETERMINISM" ? `The local code does not replay ${name}: determinism violation.` : `Replaying ${name} failed (${outcome.cause ?? "INTERNAL"}).`, { hint: describeOutcome(outcome) });
|
|
6292
6553
|
}
|
|
6293
6554
|
return outcome;
|
|
6294
6555
|
}
|
|
@@ -6296,7 +6557,7 @@ function historyFiles(dir) {
|
|
|
6296
6557
|
const out = [];
|
|
6297
6558
|
const walk = (current) => {
|
|
6298
6559
|
for (const entry of readdirSync2(current, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
|
|
6299
|
-
const full =
|
|
6560
|
+
const full = join11(current, entry.name);
|
|
6300
6561
|
if (entry.isDirectory()) {
|
|
6301
6562
|
if (entry.name !== "node_modules" && !entry.name.startsWith("."))
|
|
6302
6563
|
walk(full);
|
|
@@ -6309,23 +6570,23 @@ function historyFiles(dir) {
|
|
|
6309
6570
|
return out;
|
|
6310
6571
|
}
|
|
6311
6572
|
function testScript(root) {
|
|
6312
|
-
const manifestPath =
|
|
6313
|
-
if (!
|
|
6573
|
+
const manifestPath = join11(root, "package.json");
|
|
6574
|
+
if (!existsSync12(manifestPath))
|
|
6314
6575
|
return null;
|
|
6315
6576
|
let manifest;
|
|
6316
6577
|
try {
|
|
6317
|
-
manifest = JSON.parse(
|
|
6578
|
+
manifest = JSON.parse(readFileSync11(manifestPath, "utf8"));
|
|
6318
6579
|
} catch {
|
|
6319
|
-
throw new
|
|
6580
|
+
throw new CliUserError33("package.json is not valid JSON.");
|
|
6320
6581
|
}
|
|
6321
|
-
const scripts =
|
|
6322
|
-
if (!
|
|
6582
|
+
const scripts = isRecord18(manifest) ? manifest["scripts"] : undefined;
|
|
6583
|
+
if (!isRecord18(scripts) || typeof scripts["test"] !== "string")
|
|
6323
6584
|
return null;
|
|
6324
|
-
const runner =
|
|
6585
|
+
const runner = existsSync12(join11(root, "bun.lock")) || existsSync12(join11(root, "bun.lockb")) ? "bun" : "npm";
|
|
6325
6586
|
return { command: runner, args: ["run", "test"] };
|
|
6326
6587
|
}
|
|
6327
6588
|
function pythonTestScript(project) {
|
|
6328
|
-
if (!
|
|
6589
|
+
if (!existsSync12(join11(project.root, "tests")))
|
|
6329
6590
|
return null;
|
|
6330
6591
|
return {
|
|
6331
6592
|
command: resolvePythonInterpreter(project.root, project.config.python),
|
|
@@ -6342,7 +6603,7 @@ async function runTest(env, options) {
|
|
|
6342
6603
|
const exitCode = await env.exec(script.command, script.args, project.root);
|
|
6343
6604
|
result.script = { command: `${script.command} ${script.args.join(" ")}`, exitCode };
|
|
6344
6605
|
if (exitCode !== 0) {
|
|
6345
|
-
throw new
|
|
6606
|
+
throw new CliUserError33(`The project tests failed (\`${result.script.command}\` exited ${exitCode}).`);
|
|
6346
6607
|
}
|
|
6347
6608
|
} else {
|
|
6348
6609
|
details.push(project.config.language === "py" ? "No tests/ directory; skipped." : 'No "test" script in package.json; skipped.');
|
|
@@ -6351,12 +6612,12 @@ async function runTest(env, options) {
|
|
|
6351
6612
|
const outcomes = [];
|
|
6352
6613
|
if (options.replay !== undefined) {
|
|
6353
6614
|
const dir = resolve8(env.cwd(), options.replay);
|
|
6354
|
-
if (!
|
|
6355
|
-
throw new
|
|
6615
|
+
if (!existsSync12(dir) || !statSync4(dir).isDirectory()) {
|
|
6616
|
+
throw new CliUserError33(`--replay: ${options.replay} is not a directory.`);
|
|
6356
6617
|
}
|
|
6357
6618
|
const files = historyFiles(dir);
|
|
6358
6619
|
if (files.length === 0) {
|
|
6359
|
-
throw new
|
|
6620
|
+
throw new CliUserError33(`--replay: no *.history.json files under ${options.replay}.`);
|
|
6360
6621
|
}
|
|
6361
6622
|
const lowered = await lowerOffline(project);
|
|
6362
6623
|
const exported = durableExportNames(lowered);
|
|
@@ -6364,7 +6625,7 @@ async function runTest(env, options) {
|
|
|
6364
6625
|
try {
|
|
6365
6626
|
for (const path of files) {
|
|
6366
6627
|
const name = relative3(env.cwd(), path).split(sep3).join("/");
|
|
6367
|
-
const file = parseHistoryText(
|
|
6628
|
+
const file = parseHistoryText(readFileSync11(path, "utf8"), name);
|
|
6368
6629
|
if (file.replay === false) {
|
|
6369
6630
|
details.push(`${name}: skipped ("replay": false)`);
|
|
6370
6631
|
continue;
|
|
@@ -6389,7 +6650,7 @@ async function runTest(env, options) {
|
|
|
6389
6650
|
}, details);
|
|
6390
6651
|
const failed = outcomes.filter((outcome) => !outcome.ok);
|
|
6391
6652
|
if (failed.length > 0) {
|
|
6392
|
-
throw new
|
|
6653
|
+
throw new CliUserError33(`${failed.length} of ${outcomes.length} histories failed to replay.`, {
|
|
6393
6654
|
hint: failed.map(describeOutcome).join(`
|
|
6394
6655
|
`)
|
|
6395
6656
|
});
|
|
@@ -6397,6 +6658,7 @@ async function runTest(env, options) {
|
|
|
6397
6658
|
return result;
|
|
6398
6659
|
}
|
|
6399
6660
|
var init_replay2 = __esm(() => {
|
|
6661
|
+
init_archive_file();
|
|
6400
6662
|
init_connections();
|
|
6401
6663
|
init_history();
|
|
6402
6664
|
init_lowering();
|
|
@@ -6413,10 +6675,10 @@ function breakAtMismatch() {
|
|
|
6413
6675
|
}
|
|
6414
6676
|
|
|
6415
6677
|
// src/phase-d/commands/replay-debug.ts
|
|
6416
|
-
import { existsSync as
|
|
6678
|
+
import { existsSync as existsSync13, statSync as statSync5 } from "fs";
|
|
6417
6679
|
import { resolve as resolve9 } from "path";
|
|
6418
6680
|
import { pathToFileURL } from "url";
|
|
6419
|
-
import { CliUserError as
|
|
6681
|
+
import { CliUserError as CliUserError34 } from "@burdenoff/cli-sdk/core";
|
|
6420
6682
|
import { SDK_VERSION as SDK_VERSION4 } from "@fluidgrids/workflows";
|
|
6421
6683
|
import {
|
|
6422
6684
|
buildDebugScript,
|
|
@@ -6441,10 +6703,10 @@ function inspectAddress(raw) {
|
|
|
6441
6703
|
const host = portOnly ? "127.0.0.1" : value.slice(0, at);
|
|
6442
6704
|
const port = portOnly ? value : value.slice(at + 1);
|
|
6443
6705
|
if (!portOnly && at <= 0 || !/^\d{1,5}$/.test(port) || Number(port) > 65535) {
|
|
6444
|
-
throw new
|
|
6706
|
+
throw new CliUserError34(`Invalid value '${value}' for --inspect: expected host:port or a port, such as ${DEFAULT_INSPECT_ADDRESS}.`, { hint: "Give the history or run id before --inspect, or write --inspect=<host:port>." });
|
|
6445
6707
|
}
|
|
6446
6708
|
if (!LOOPBACK.has(host)) {
|
|
6447
|
-
throw new
|
|
6709
|
+
throw new CliUserError34(`--inspect listens on loopback only; ${host} is not.`, {
|
|
6448
6710
|
hint: "An inspector on another interface lets anyone who reaches it run code as you."
|
|
6449
6711
|
});
|
|
6450
6712
|
}
|
|
@@ -6487,24 +6749,24 @@ function inspectMatches(raw, address) {
|
|
|
6487
6749
|
async function reexecUnderInspector(env, options, facts) {
|
|
6488
6750
|
const address = inspectAddress(options.inspect ?? true);
|
|
6489
6751
|
if (!facts.node) {
|
|
6490
|
-
throw new
|
|
6752
|
+
throw new CliUserError34("--inspect needs the CLI to run on Node.", {
|
|
6491
6753
|
hint: "Run it as `node <path to fluidgrids>/dist/cli.js replay … --inspect`."
|
|
6492
6754
|
});
|
|
6493
6755
|
}
|
|
6494
6756
|
const script = facts.argv[1];
|
|
6495
6757
|
if (script === undefined)
|
|
6496
|
-
throw new
|
|
6758
|
+
throw new CliUserError34("--inspect: the CLI script path is unknown.");
|
|
6497
6759
|
console.error(`Debugger listening on ${address}; attach to continue (the replay stops at the mismatch).`);
|
|
6498
6760
|
const status = await env.exec(facts.execPath, [`--inspect-brk=${address}`, script, ...childArgs(facts.argv, address)], env.cwd(), { stdout: "inherit" });
|
|
6499
6761
|
throw new DelegatedExit(status);
|
|
6500
6762
|
}
|
|
6501
6763
|
async function loadHistory(env, target) {
|
|
6502
6764
|
const path = resolve9(env.cwd(), target);
|
|
6503
|
-
if (
|
|
6504
|
-
return { file:
|
|
6765
|
+
if (existsSync13(path) && statSync5(path).isFile()) {
|
|
6766
|
+
return { file: readHistoryFromDisk(path, target), name: target };
|
|
6505
6767
|
}
|
|
6506
|
-
if (
|
|
6507
|
-
throw new
|
|
6768
|
+
if (looksLikeHistoryPath(target))
|
|
6769
|
+
throw new CliUserError34(`History file not found: ${target}`);
|
|
6508
6770
|
return { file: (await fetchHistory(env, target)).file, name: target };
|
|
6509
6771
|
}
|
|
6510
6772
|
async function remoteScript(env, file, name) {
|
|
@@ -6512,17 +6774,17 @@ async function remoteScript(env, file, name) {
|
|
|
6512
6774
|
const version = file.info?.version;
|
|
6513
6775
|
const buildId = file.info?.buildId;
|
|
6514
6776
|
if (!key || version === undefined || version === "" || !buildId) {
|
|
6515
|
-
throw new
|
|
6777
|
+
throw new CliUserError34(`${name} does not say which workflow version and build it ran (info.workflowKey, info.version, info.buildId).`, { hint: "Replay a run id, or a history file from `fluidgrids history <runId> --out`." });
|
|
6516
6778
|
}
|
|
6517
6779
|
const archive = await env.pd.workflowCodeArchive(key, String(version));
|
|
6518
6780
|
if (archive === null) {
|
|
6519
|
-
throw new
|
|
6781
|
+
throw new CliUserError34(`${key} ${String(version)} has no stored source archive.`);
|
|
6520
6782
|
}
|
|
6521
6783
|
if (archive.buildId !== buildId) {
|
|
6522
6784
|
throw new CliDiagnosticsError(`The stored archive of ${key} ${String(version)} builds ${archive.buildId}, but the run used ${buildId}; the debugger only debugs the exact code that ran.`, "debug.buildIdMismatch", []);
|
|
6523
6785
|
}
|
|
6524
6786
|
if (archive.sdkVersion !== SDK_VERSION4) {
|
|
6525
|
-
throw new
|
|
6787
|
+
throw new CliUserError34(`The run was built with @fluidgrids/workflows ${archive.sdkVersion}; this CLI has ${SDK_VERSION4}.`, {
|
|
6526
6788
|
hint: `Use a CLI release that bundles @fluidgrids/workflows ${archive.sdkVersion} to rebuild the exact bundle.`
|
|
6527
6789
|
});
|
|
6528
6790
|
}
|
|
@@ -6532,17 +6794,17 @@ async function remoteScript(env, file, name) {
|
|
|
6532
6794
|
try {
|
|
6533
6795
|
response = await env.fetch(archive.url, { method: "GET" });
|
|
6534
6796
|
} catch (error) {
|
|
6535
|
-
throw new
|
|
6797
|
+
throw new CliUserError34(`Fetching the source archive failed: ${describeError(error)}`);
|
|
6536
6798
|
}
|
|
6537
6799
|
if (!response.ok) {
|
|
6538
|
-
throw new
|
|
6800
|
+
throw new CliUserError34(`Fetching the source archive failed with HTTP ${response.status}.`);
|
|
6539
6801
|
}
|
|
6540
|
-
const bytes = await readCapped(response, MAX_SOURCE_ARCHIVE_BYTES, () => new
|
|
6802
|
+
const bytes = await readCapped(response, MAX_SOURCE_ARCHIVE_BYTES, () => new CliUserError34(`The source archive is larger than ${MAX_SOURCE_ARCHIVE_BYTES} bytes; refusing to read it.`));
|
|
6541
6803
|
let sources;
|
|
6542
6804
|
try {
|
|
6543
6805
|
sources = unpackSources(bytes, { maxBytes: MAX_SOURCE_ARCHIVE_BYTES });
|
|
6544
6806
|
} catch (error) {
|
|
6545
|
-
throw new
|
|
6807
|
+
throw new CliUserError34(`The source archive could not be read: ${describeError(error)}`);
|
|
6546
6808
|
}
|
|
6547
6809
|
try {
|
|
6548
6810
|
return await buildDebugScript(new Map(Object.entries(sources.files)), {
|
|
@@ -6554,13 +6816,13 @@ async function remoteScript(env, file, name) {
|
|
|
6554
6816
|
if (error instanceof DebugBuildMismatchError) {
|
|
6555
6817
|
throw new CliDiagnosticsError(error.message, error.code, []);
|
|
6556
6818
|
}
|
|
6557
|
-
throw new
|
|
6819
|
+
throw new CliUserError34(`Rebuilding the run's code failed: ${describeError(error)}`);
|
|
6558
6820
|
}
|
|
6559
6821
|
}
|
|
6560
6822
|
async function localScript(env, options, file, name) {
|
|
6561
6823
|
const project = loadProject(options.project, env.cwd());
|
|
6562
6824
|
if (project.config.language === "py") {
|
|
6563
|
-
throw new
|
|
6825
|
+
throw new CliUserError34("The replay debugger needs a TypeScript project.", {
|
|
6564
6826
|
hint: "Python projects replay with plain `fluidgrids replay` (no --trace or --break-on-mismatch)."
|
|
6565
6827
|
});
|
|
6566
6828
|
}
|
|
@@ -6571,12 +6833,12 @@ async function localScript(env, options, file, name) {
|
|
|
6571
6833
|
});
|
|
6572
6834
|
const exported = durableExportNames(lowered);
|
|
6573
6835
|
if (!lowered.sourceFiles || exported.length === 0) {
|
|
6574
|
-
throw new
|
|
6836
|
+
throw new CliUserError34("The project defines no durable functions to replay.", {
|
|
6575
6837
|
hint: "Durable functions are `workflow()` exports in workflows/*.ts."
|
|
6576
6838
|
});
|
|
6577
6839
|
}
|
|
6578
6840
|
if (!exported.includes(file.workflowFn)) {
|
|
6579
|
-
throw new
|
|
6841
|
+
throw new CliUserError34(`${name} runs ${file.workflowFn}, which this project does not export.`, {
|
|
6580
6842
|
hint: `Exported durable functions: ${exported.join(", ")}`
|
|
6581
6843
|
});
|
|
6582
6844
|
}
|
|
@@ -6587,7 +6849,7 @@ async function localScript(env, options, file, name) {
|
|
|
6587
6849
|
sourceRoot: `${pathToFileURL(project.root).href}/`
|
|
6588
6850
|
});
|
|
6589
6851
|
} catch (error) {
|
|
6590
|
-
throw new
|
|
6852
|
+
throw new CliUserError34(`Building the debug script failed: ${describeError(error)}`);
|
|
6591
6853
|
}
|
|
6592
6854
|
}
|
|
6593
6855
|
function where(location) {
|
|
@@ -6608,13 +6870,13 @@ function failureDiagnostics(result) {
|
|
|
6608
6870
|
}
|
|
6609
6871
|
async function runDebugReplay(env, target, options, facts = currentProcess()) {
|
|
6610
6872
|
if (options.isolate) {
|
|
6611
|
-
throw new
|
|
6873
|
+
throw new CliUserError34("--isolate does not combine with --trace, --break-on-mismatch, --inspect or --remote-code.", { hint: "The replay debugger runs in a Node vm; replay without them to use the isolate." });
|
|
6612
6874
|
}
|
|
6613
6875
|
if (options.inspect !== undefined)
|
|
6614
6876
|
return reexecUnderInspector(env, options, facts);
|
|
6615
6877
|
const { file, name } = await loadHistory(env, target);
|
|
6616
6878
|
if (file.replay === false) {
|
|
6617
|
-
throw new
|
|
6879
|
+
throw new CliUserError34(`${name} is marked "replay": false (it uses Phase C features).`);
|
|
6618
6880
|
}
|
|
6619
6881
|
const remote = options.remoteCode === true;
|
|
6620
6882
|
const script = remote ? await remoteScript(env, file, name) : await localScript(env, options, file, name);
|
|
@@ -6671,6 +6933,7 @@ var init_replay_debug = __esm(() => {
|
|
|
6671
6933
|
init_code_upload();
|
|
6672
6934
|
init_replay2();
|
|
6673
6935
|
init_connections();
|
|
6936
|
+
init_archive_file();
|
|
6674
6937
|
init_history();
|
|
6675
6938
|
init_lowering();
|
|
6676
6939
|
init_presigned();
|
|
@@ -6811,7 +7074,7 @@ var REPLACEMENT_CHARACTER = "�";
|
|
|
6811
7074
|
// src/code-first/commands/suite.ts
|
|
6812
7075
|
import { writeFileSync as writeFileSync7 } from "fs";
|
|
6813
7076
|
import { resolve as resolve10 } from "path";
|
|
6814
|
-
import { CliAuthError as CliAuthError5, CliUserError as
|
|
7077
|
+
import { CliAuthError as CliAuthError5, CliUserError as CliUserError35 } from "@burdenoff/cli-sdk/core";
|
|
6815
7078
|
function testSuiteOptions(options) {
|
|
6816
7079
|
const misplaced = [
|
|
6817
7080
|
options.replay !== undefined ? "--replay" : null,
|
|
@@ -6820,7 +7083,7 @@ function testSuiteOptions(options) {
|
|
|
6820
7083
|
options.project !== undefined ? "--project" : null
|
|
6821
7084
|
].filter((flag) => flag !== null);
|
|
6822
7085
|
if (misplaced.length > 0) {
|
|
6823
|
-
throw new
|
|
7086
|
+
throw new CliUserError35(`${misplaced.join(", ")} ${misplaced.length === 1 ? "applies" : "apply"} to the code-first tests, not to a workflow's test suite.`, { hint: "Run `fluidgrids test` without a workflow key in a code-first project for those." });
|
|
6824
7087
|
}
|
|
6825
7088
|
return {
|
|
6826
7089
|
...options.format !== undefined ? { format: options.format } : {},
|
|
@@ -6840,7 +7103,7 @@ function codeFirstTestOptions(options) {
|
|
|
6840
7103
|
options.pollInterval !== undefined ? "--poll-interval" : null
|
|
6841
7104
|
].filter((flag) => flag !== null);
|
|
6842
7105
|
if (misplaced.length > 0) {
|
|
6843
|
-
throw new
|
|
7106
|
+
throw new CliUserError35(`${misplaced.join(", ")} ${misplaced.length === 1 ? "needs" : "need"} a workflow key: \`fluidgrids test <workflowKey>\`.`);
|
|
6844
7107
|
}
|
|
6845
7108
|
return {
|
|
6846
7109
|
...options.format !== undefined ? { format: options.format } : {},
|
|
@@ -6855,7 +7118,7 @@ function caseIds(raw) {
|
|
|
6855
7118
|
return;
|
|
6856
7119
|
const ids = [...new Set(raw.map((id) => id.trim()))];
|
|
6857
7120
|
if (ids.some((id) => id === ""))
|
|
6858
|
-
throw new
|
|
7121
|
+
throw new CliUserError35("--case needs a test case id.");
|
|
6859
7122
|
return ids;
|
|
6860
7123
|
}
|
|
6861
7124
|
function finished(suite) {
|
|
@@ -6883,7 +7146,7 @@ async function waitForSuite(env, started, timeoutMs, intervalMs) {
|
|
|
6883
7146
|
continue;
|
|
6884
7147
|
}
|
|
6885
7148
|
if (!next) {
|
|
6886
|
-
throw new
|
|
7149
|
+
throw new CliUserError35(`Suite run ${suite.id} is no longer visible (NOT_FOUND).`);
|
|
6887
7150
|
}
|
|
6888
7151
|
suite = next;
|
|
6889
7152
|
if (finished(suite) !== reported) {
|
|
@@ -6918,7 +7181,7 @@ function detailLines(suite, timedOut, junit) {
|
|
|
6918
7181
|
async function runTestSuite(env, workflowKey, options) {
|
|
6919
7182
|
const key = workflowKey.trim();
|
|
6920
7183
|
if (key === "")
|
|
6921
|
-
throw new
|
|
7184
|
+
throw new CliUserError35("The workflow key is empty.");
|
|
6922
7185
|
const timeoutMs = parsePositiveInt(options.timeout, "--timeout") ?? DEFAULT_SUITE_TIMEOUT_MS;
|
|
6923
7186
|
const intervalMs = parsePositiveInt(options.pollInterval, "--poll-interval") ?? DEFAULT_SUITE_POLL_INTERVAL_MS;
|
|
6924
7187
|
const ids = caseIds(options.case);
|
|
@@ -6937,7 +7200,7 @@ async function runTestSuite(env, workflowKey, options) {
|
|
|
6937
7200
|
try {
|
|
6938
7201
|
writeFileSync7(path, suiteToJUnit(suite), "utf8");
|
|
6939
7202
|
} catch (error) {
|
|
6940
|
-
throw new
|
|
7203
|
+
throw new CliUserError35(`Could not write the JUnit report to ${options.junit}: ${error instanceof Error ? error.message : String(error)}`);
|
|
6941
7204
|
}
|
|
6942
7205
|
result.junit = options.junit;
|
|
6943
7206
|
}
|
|
@@ -6951,16 +7214,16 @@ async function runTestSuite(env, workflowKey, options) {
|
|
|
6951
7214
|
])
|
|
6952
7215
|
}, detailLines(suite, timedOut, result.junit));
|
|
6953
7216
|
if (timedOut) {
|
|
6954
|
-
throw new
|
|
7217
|
+
throw new CliUserError35(`Suite ${suite.id} was still ${suite.status} after ${timeoutMs} ms (${finished(suite)}/${suite.summary.total} cases finished).`, {
|
|
6955
7218
|
exitCode: SUITE_TIMEOUT_EXIT_CODE,
|
|
6956
7219
|
hint: "It keeps running on the service. Raise --timeout to wait longer."
|
|
6957
7220
|
});
|
|
6958
7221
|
}
|
|
6959
7222
|
if (suite.status === "FAILED") {
|
|
6960
|
-
throw new
|
|
7223
|
+
throw new CliUserError35(`${suite.summary.failed} of ${suite.summary.total} test cases of ${suite.workflowKey} failed.`);
|
|
6961
7224
|
}
|
|
6962
7225
|
if (suite.status === "ERROR") {
|
|
6963
|
-
throw new
|
|
7226
|
+
throw new CliUserError35(`${suite.summary.errored} of ${suite.summary.total} test cases of ${suite.workflowKey} could not run.`);
|
|
6964
7227
|
}
|
|
6965
7228
|
return result;
|
|
6966
7229
|
}
|
|
@@ -6973,7 +7236,7 @@ var init_suite = __esm(() => {
|
|
|
6973
7236
|
|
|
6974
7237
|
// src/code-first/commands/versions.ts
|
|
6975
7238
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
6976
|
-
import { CliUserError as
|
|
7239
|
+
import { CliUserError as CliUserError36 } from "@burdenoff/cli-sdk/core";
|
|
6977
7240
|
async function runVersionsList(env, workflowKey, options) {
|
|
6978
7241
|
const versions = sortVersions(await env.api.workflowVersions(workflowKey));
|
|
6979
7242
|
const rows = [];
|
|
@@ -7013,7 +7276,7 @@ function checkLine(check, what) {
|
|
|
7013
7276
|
}
|
|
7014
7277
|
function parsePercent(raw) {
|
|
7015
7278
|
if (raw === undefined || !/^\d{1,3}$/.test(raw.trim()) || Number(raw) > 100) {
|
|
7016
|
-
throw new
|
|
7279
|
+
throw new CliUserError36(`Invalid value '${raw ?? ""}' for --percent: expected 0 to 100.`);
|
|
7017
7280
|
}
|
|
7018
7281
|
return Number(raw.trim());
|
|
7019
7282
|
}
|
|
@@ -7025,7 +7288,7 @@ async function runRollout(env, workflowKey, options) {
|
|
|
7025
7288
|
return rollouts;
|
|
7026
7289
|
}
|
|
7027
7290
|
if (options.to === undefined || options.to.trim() === "") {
|
|
7028
|
-
throw new
|
|
7291
|
+
throw new CliUserError36("--percent needs --to <version>.");
|
|
7029
7292
|
}
|
|
7030
7293
|
const input = {
|
|
7031
7294
|
toVersion: options.to,
|
|
@@ -7047,14 +7310,14 @@ async function runRollout(env, workflowKey, options) {
|
|
|
7047
7310
|
function rolloutDeleteOptions(options, parent) {
|
|
7048
7311
|
for (const flag of ["to", "percent", "from"]) {
|
|
7049
7312
|
if (parent[flag] !== undefined) {
|
|
7050
|
-
throw new
|
|
7313
|
+
throw new CliUserError36(`--${flag} does not apply to \`versions rollout delete\`.`);
|
|
7051
7314
|
}
|
|
7052
7315
|
}
|
|
7053
7316
|
const inherited = parent["environment"];
|
|
7054
7317
|
if (typeof inherited !== "string")
|
|
7055
7318
|
return options;
|
|
7056
7319
|
if (options.environment !== undefined && options.environment !== inherited) {
|
|
7057
|
-
throw new
|
|
7320
|
+
throw new CliUserError36(`Conflicting --environment values '${inherited}' and '${options.environment}'.`);
|
|
7058
7321
|
}
|
|
7059
7322
|
return { ...options, environment: inherited };
|
|
7060
7323
|
}
|
|
@@ -7071,12 +7334,12 @@ async function runRolloutDelete(env, workflowKey, options) {
|
|
|
7071
7334
|
const environment = parseChoice(options.environment?.toUpperCase(), "--environment", ENVIRONMENTS);
|
|
7072
7335
|
if (!options.force) {
|
|
7073
7336
|
if (!env.interactive()) {
|
|
7074
|
-
throw new
|
|
7337
|
+
throw new CliUserError36(`Removing the rollout of ${workflowKey} needs confirmation.`, {
|
|
7075
7338
|
hint: "Pass --force to remove it without a prompt."
|
|
7076
7339
|
});
|
|
7077
7340
|
}
|
|
7078
7341
|
if (!await confirm2(`Remove the rollout of ${workflowKey}? New starts run the ACTIVE version.`)) {
|
|
7079
|
-
throw new
|
|
7342
|
+
throw new CliUserError36("Aborted: nothing was changed.");
|
|
7080
7343
|
}
|
|
7081
7344
|
}
|
|
7082
7345
|
const removed = await env.api.deleteWorkflowRollout(workflowKey, environment);
|
|
@@ -7102,12 +7365,12 @@ async function runDrainage(env, workflowKey, version, options) {
|
|
|
7102
7365
|
async function runOverride(env, runId, options) {
|
|
7103
7366
|
const chosen = [options.pin !== undefined, options.autoUpgrade === true, options.clear === true];
|
|
7104
7367
|
if (chosen.filter(Boolean).length !== 1) {
|
|
7105
|
-
throw new
|
|
7368
|
+
throw new CliUserError36("Give exactly one of --pin <version>, --auto-upgrade or --clear.");
|
|
7106
7369
|
}
|
|
7107
7370
|
let override = null;
|
|
7108
7371
|
if (options.pin !== undefined) {
|
|
7109
7372
|
if (options.pin.trim() === "")
|
|
7110
|
-
throw new
|
|
7373
|
+
throw new CliUserError36("--pin needs a version.");
|
|
7111
7374
|
override = { behavior: "PINNED", version: options.pin };
|
|
7112
7375
|
} else if (options.autoUpgrade) {
|
|
7113
7376
|
override = { behavior: "AUTO_UPGRADE" };
|
|
@@ -7136,12 +7399,12 @@ var init_versions = __esm(() => {
|
|
|
7136
7399
|
});
|
|
7137
7400
|
|
|
7138
7401
|
// src/code-first/commands/deploy.ts
|
|
7139
|
-
import { CliUserError as
|
|
7402
|
+
import { CliUserError as CliUserError37 } from "@burdenoff/cli-sdk/core";
|
|
7140
7403
|
function parseEnvironment(raw) {
|
|
7141
7404
|
const value = raw?.trim().toUpperCase();
|
|
7142
7405
|
const match = ENVIRONMENTS2.find((environment) => environment === value);
|
|
7143
7406
|
if (match === undefined) {
|
|
7144
|
-
throw new
|
|
7407
|
+
throw new CliUserError37(raw === undefined ? "deploy needs --env dev, staging or prod." : `Invalid value '${raw}' for --env. Allowed: dev, staging, prod`);
|
|
7145
7408
|
}
|
|
7146
7409
|
return match;
|
|
7147
7410
|
}
|
|
@@ -7150,7 +7413,7 @@ function parseRamp(raw) {
|
|
|
7150
7413
|
return;
|
|
7151
7414
|
const trimmed = raw.trim();
|
|
7152
7415
|
if (!/^\d{1,3}$/.test(trimmed) || Number(trimmed) > 100) {
|
|
7153
|
-
throw new
|
|
7416
|
+
throw new CliUserError37(`Invalid value '${raw}' for --ramp: expected 0 to 100.`);
|
|
7154
7417
|
}
|
|
7155
7418
|
return Number(trimmed);
|
|
7156
7419
|
}
|
|
@@ -7200,10 +7463,10 @@ async function runDeploy(env, workflowKey, options) {
|
|
|
7200
7463
|
const environment = parseEnvironment(options.env);
|
|
7201
7464
|
const ramp = parseRamp(options.ramp);
|
|
7202
7465
|
if (ramp !== undefined && environment !== "PROD") {
|
|
7203
|
-
throw new
|
|
7466
|
+
throw new CliUserError37("--ramp applies to --env prod only (rollouts split PROD starts).");
|
|
7204
7467
|
}
|
|
7205
7468
|
if (options.note !== undefined && environment === "DEV") {
|
|
7206
|
-
throw new
|
|
7469
|
+
throw new CliUserError37("--note is for promotion requests (--env staging or prod).");
|
|
7207
7470
|
}
|
|
7208
7471
|
const timeoutMs = parsePositiveInt(options.timeout, "--timeout") ?? DEFAULT_DEPLOY_TIMEOUT_MS;
|
|
7209
7472
|
const intervalMs = parsePositiveInt(options.pollInterval, "--poll-interval") ?? DEFAULT_DEPLOY_POLL_INTERVAL_MS;
|
|
@@ -7221,7 +7484,7 @@ async function deployToDev(env, workflowKey, options) {
|
|
|
7221
7484
|
const versions = await env.api.workflowVersions(workflowKey);
|
|
7222
7485
|
const picked = pickVersion(versions, wanted);
|
|
7223
7486
|
if (!picked) {
|
|
7224
|
-
throw new
|
|
7487
|
+
throw new CliUserError37(versions.length === 0 ? `${workflowKey} has no stored version.` : `${workflowKey} has no version ${wanted}.`, versions.length === 0 ? { hint: "Push one first: fluidgrids push " + workflowKey } : { hint: `Stored: ${versions.map((version) => version.version).join(", ")}` });
|
|
7225
7488
|
}
|
|
7226
7489
|
const before = await env.api.workflowEnvironments(workflowKey);
|
|
7227
7490
|
const base = { workflowKey, environment: "DEV", version: picked.version };
|
|
@@ -7243,15 +7506,15 @@ async function promote(env, workflowKey, target, options) {
|
|
|
7243
7506
|
const view = await env.api.workflowEnvironments(workflowKey);
|
|
7244
7507
|
const source = stateOf(view, sourceName);
|
|
7245
7508
|
if (!source?.version) {
|
|
7246
|
-
throw new
|
|
7509
|
+
throw new CliUserError37(`Nothing is deployed to ${sourceName} for ${workflowKey}.`, {
|
|
7247
7510
|
hint: `Deploy there first: fluidgrids deploy ${workflowKey} --env ${sourceName.toLowerCase()}${sourceName === "DEV" ? " --wf-version <version>" : ""}`
|
|
7248
7511
|
});
|
|
7249
7512
|
}
|
|
7250
7513
|
if (!source.available) {
|
|
7251
|
-
throw new
|
|
7514
|
+
throw new CliUserError37(`${sourceName} holds ${source.version} of ${workflowKey}, which has since been deleted.`, { hint: `Deploy another version to ${sourceName} first.` });
|
|
7252
7515
|
}
|
|
7253
7516
|
if (options.wfVersion !== undefined && options.wfVersion !== source.version) {
|
|
7254
|
-
throw new
|
|
7517
|
+
throw new CliUserError37(`${sourceName} holds ${source.version} of ${workflowKey}, not ${options.wfVersion}; ${target} is promoted from ${sourceName}.`, {
|
|
7255
7518
|
hint: `Deploy ${options.wfVersion} to ${sourceName} first: fluidgrids deploy ${workflowKey} --env ${sourceName.toLowerCase()} --wf-version ${options.wfVersion}`
|
|
7256
7519
|
});
|
|
7257
7520
|
}
|
|
@@ -7264,7 +7527,7 @@ async function promote(env, workflowKey, target, options) {
|
|
|
7264
7527
|
}
|
|
7265
7528
|
if (options.ramp !== undefined && options.ramp < 100) {
|
|
7266
7529
|
if (view.policy.lockDirectActivation) {
|
|
7267
|
-
throw new
|
|
7530
|
+
throw new CliUserError37(`The workspace locks PROD to approved promotions, so ${workflowKey} cannot be ramped.`, { hint: `Promote it in full instead: fluidgrids deploy ${workflowKey} --env prod` });
|
|
7268
7531
|
}
|
|
7269
7532
|
const rollout = await env.api.setWorkflowRollout(workflowKey, {
|
|
7270
7533
|
toVersion: version,
|
|
@@ -7282,7 +7545,7 @@ async function promote(env, workflowKey, target, options) {
|
|
|
7282
7545
|
}
|
|
7283
7546
|
const pending = view.pendingPromotions.find((request) => request.toEnvironment === target);
|
|
7284
7547
|
if (pending && pending.version !== version) {
|
|
7285
|
-
throw new
|
|
7548
|
+
throw new CliUserError37(`A promotion of ${pending.version} to ${target} (request ${pending.id}) is already waiting for an approver.`, { hint: "An approver decides it, or its requester cancels it, before another can be made." });
|
|
7286
7549
|
}
|
|
7287
7550
|
if (pending && options.note !== undefined) {
|
|
7288
7551
|
notice(env, options, "warning", `Request ${pending.id} for ${version} is already open; --note was not added to it.`);
|
|
@@ -7308,7 +7571,7 @@ function finish(env, options, base, promotion) {
|
|
|
7308
7571
|
]);
|
|
7309
7572
|
case "REJECTED":
|
|
7310
7573
|
case "CANCELED":
|
|
7311
|
-
throw new
|
|
7574
|
+
throw new CliUserError37(`The promotion of ${version} of ${workflowKey} to ${environment} was ${promotion.status === "REJECTED" ? "rejected" : "canceled"}${promotion.reviewNote ? `: ${promotion.reviewNote}` : "."}`, { hint: `Request ${promotion.id}; ${environment} is unchanged.` });
|
|
7312
7575
|
}
|
|
7313
7576
|
}
|
|
7314
7577
|
async function waitForPromotion(env, promotion, options) {
|
|
@@ -7317,7 +7580,7 @@ async function waitForPromotion(env, promotion, options) {
|
|
|
7317
7580
|
let current = promotion;
|
|
7318
7581
|
while (current.status === "PENDING") {
|
|
7319
7582
|
if (slept >= options.timeoutMs || Date.now() >= deadline) {
|
|
7320
|
-
throw new
|
|
7583
|
+
throw new CliUserError37(`Promotion ${current.id} of ${current.version} to ${current.toEnvironment} still waits for an approver after ${Math.round(options.timeoutMs / 1000)} s.`, {
|
|
7321
7584
|
hint: "The request stays open; run the same command again to keep waiting, or pass --no-wait."
|
|
7322
7585
|
});
|
|
7323
7586
|
}
|
|
@@ -7326,7 +7589,7 @@ async function waitForPromotion(env, promotion, options) {
|
|
|
7326
7589
|
const history = await env.api.promotionRequests(current.workflowKey, PROMOTION_HISTORY_LIMIT);
|
|
7327
7590
|
const found = history.find((request) => request.id === current.id);
|
|
7328
7591
|
if (!found) {
|
|
7329
|
-
throw new
|
|
7592
|
+
throw new CliUserError37(`Promotion ${current.id} is no longer in the promotion history of ${current.workflowKey}.`);
|
|
7330
7593
|
}
|
|
7331
7594
|
current = found;
|
|
7332
7595
|
}
|
|
@@ -7847,7 +8110,7 @@ var init_operations3 = __esm(() => {
|
|
|
7847
8110
|
});
|
|
7848
8111
|
|
|
7849
8112
|
// src/phase-c/api.ts
|
|
7850
|
-
import { CliAuthError as CliAuthError6, CliUserError as
|
|
8113
|
+
import { CliAuthError as CliAuthError6, CliUserError as CliUserError39 } from "@burdenoff/cli-sdk/core";
|
|
7851
8114
|
function runVariables(run) {
|
|
7852
8115
|
return run.runId !== undefined ? { runId: run.runId } : { target: run.target };
|
|
7853
8116
|
}
|
|
@@ -7867,7 +8130,7 @@ function createPhaseCApi(ctx) {
|
|
|
7867
8130
|
function context() {
|
|
7868
8131
|
const workspaceId = ctx.auth.read()?.workspaceId;
|
|
7869
8132
|
if (!workspaceId) {
|
|
7870
|
-
throw new
|
|
8133
|
+
throw new CliUserError39("No workspace is selected.", {
|
|
7871
8134
|
hint: `Run \`${ctx.productName} workspace set <id>\` or set FLUIDGRIDS_WORKSPACE_ID.`
|
|
7872
8135
|
});
|
|
7873
8136
|
}
|
|
@@ -8000,7 +8263,7 @@ function createPhaseCApi(ctx) {
|
|
|
8000
8263
|
});
|
|
8001
8264
|
const found = data.workflowRunByWorkflowId;
|
|
8002
8265
|
if (!found) {
|
|
8003
|
-
throw new
|
|
8266
|
+
throw new CliUserError39(`No run with workflow id ${run.target.workflowId} of ${run.target.workflowKey} (NOT_FOUND)`);
|
|
8004
8267
|
}
|
|
8005
8268
|
return found.id;
|
|
8006
8269
|
},
|
|
@@ -8135,7 +8398,7 @@ function createPhaseCApi(ctx) {
|
|
|
8135
8398
|
if (!pagination?.hasMore || jobs.length === 0)
|
|
8136
8399
|
return all;
|
|
8137
8400
|
}
|
|
8138
|
-
throw new
|
|
8401
|
+
throw new CliUserError39(`The schedule listing did not end after ${MAX_SCHEDULE_PAGES} pages; refusing to continue.`);
|
|
8139
8402
|
},
|
|
8140
8403
|
async describeSchedule(workflowKey, triggerNodeId) {
|
|
8141
8404
|
const data = await request(PC_SCHEDULE_DESCRIBE, { workflowKey, triggerNodeId }, P);
|
|
@@ -8169,17 +8432,17 @@ var init_api3 = __esm(() => {
|
|
|
8169
8432
|
});
|
|
8170
8433
|
|
|
8171
8434
|
// src/phase-c/commands/queues.ts
|
|
8172
|
-
import { CliUserError as
|
|
8435
|
+
import { CliUserError as CliUserError40 } from "@burdenoff/cli-sdk/core";
|
|
8173
8436
|
function parseEnvironment2(raw) {
|
|
8174
8437
|
return parseEnumOption(raw, "--environment", ENVIRONMENTS3);
|
|
8175
8438
|
}
|
|
8176
8439
|
function checkQueueName(name) {
|
|
8177
8440
|
const value = name.trim();
|
|
8178
8441
|
if (value === "managed") {
|
|
8179
|
-
throw new
|
|
8442
|
+
throw new CliUserError40("`managed` is the platform queue; it cannot be created or changed.");
|
|
8180
8443
|
}
|
|
8181
8444
|
if (!QUEUE_NAME.test(value)) {
|
|
8182
|
-
throw new
|
|
8445
|
+
throw new CliUserError40(`Invalid queue name '${name}': lower-case letters, digits and dashes, at most 63, starting with a letter or digit.`);
|
|
8183
8446
|
}
|
|
8184
8447
|
return value;
|
|
8185
8448
|
}
|
|
@@ -8191,7 +8454,7 @@ function checkWorkerQueue(raw) {
|
|
|
8191
8454
|
const name = checkQueueName(value.slice(0, at));
|
|
8192
8455
|
const environment = value.slice(at + 1).toLowerCase();
|
|
8193
8456
|
if (!ENVIRONMENTS3.some((allowed) => allowed.toLowerCase() === environment)) {
|
|
8194
|
-
throw new
|
|
8457
|
+
throw new CliUserError40(`Invalid queue '${raw}': the environment after @ must be dev, staging or prod.`);
|
|
8195
8458
|
}
|
|
8196
8459
|
return `${name}@${environment}`;
|
|
8197
8460
|
}
|
|
@@ -8204,7 +8467,7 @@ function bindWorkerQueues(queues, raw) {
|
|
|
8204
8467
|
if (at < 0)
|
|
8205
8468
|
return `${queue}@${environment}`;
|
|
8206
8469
|
if (queue.slice(at + 1) !== environment) {
|
|
8207
|
-
throw new
|
|
8470
|
+
throw new CliUserError40(`Queue '${queue}' is bound to ${queue.slice(at + 1)}, but --environment is ${environment}.`);
|
|
8208
8471
|
}
|
|
8209
8472
|
return queue;
|
|
8210
8473
|
});
|
|
@@ -8220,11 +8483,11 @@ async function findQueue(env, name, environment) {
|
|
|
8220
8483
|
if (found)
|
|
8221
8484
|
return found;
|
|
8222
8485
|
if (environment === undefined && rows.length > 0) {
|
|
8223
|
-
throw new
|
|
8486
|
+
throw new CliUserError40(`Queue ${name} has only environment-scoped rows.`, {
|
|
8224
8487
|
hint: `Pass --environment (one of ${rows.map((queue) => queue.environment ?? "-").join(", ")}).`
|
|
8225
8488
|
});
|
|
8226
8489
|
}
|
|
8227
|
-
throw new
|
|
8490
|
+
throw new CliUserError40(`The workspace has no task queue ${environment ? `${name}@${environment}` : name}.`, { hint: "List them with `fluidgrids queues list`." });
|
|
8228
8491
|
}
|
|
8229
8492
|
async function runQueuesList(env, options) {
|
|
8230
8493
|
const queues = await env.pc.taskQueues();
|
|
@@ -8285,7 +8548,7 @@ async function runQueuesUpdate(env, name, options) {
|
|
|
8285
8548
|
const environment = parseEnvironment2(options.environment);
|
|
8286
8549
|
const maxTasksPerSecond = parseNumberOption(options.maxTasksPerSecond, "--max-tasks-per-second");
|
|
8287
8550
|
if (maxTasksPerSecond !== undefined && options.clearMaxTasksPerSecond) {
|
|
8288
|
-
throw new
|
|
8551
|
+
throw new CliUserError40("Give --max-tasks-per-second or --clear-max-tasks-per-second, not both.");
|
|
8289
8552
|
}
|
|
8290
8553
|
const timeout = parseNonNegativeInt(options.workerUnavailableTimeout, "--worker-unavailable-timeout");
|
|
8291
8554
|
const input = {
|
|
@@ -8295,7 +8558,7 @@ async function runQueuesUpdate(env, name, options) {
|
|
|
8295
8558
|
...timeout !== undefined ? { workerUnavailableTimeoutSeconds: timeout } : {}
|
|
8296
8559
|
};
|
|
8297
8560
|
if (Object.keys(input).length === 0) {
|
|
8298
|
-
throw new
|
|
8561
|
+
throw new CliUserError40("Nothing to change.", {
|
|
8299
8562
|
hint: "Give --description, --max-tasks-per-second, --clear-max-tasks-per-second or --worker-unavailable-timeout."
|
|
8300
8563
|
});
|
|
8301
8564
|
}
|
|
@@ -8370,12 +8633,12 @@ __export(exports_worker_run, {
|
|
|
8370
8633
|
});
|
|
8371
8634
|
import { spawn as spawn3 } from "child_process";
|
|
8372
8635
|
import { randomBytes } from "crypto";
|
|
8373
|
-
import { existsSync as
|
|
8636
|
+
import { existsSync as existsSync14 } from "fs";
|
|
8374
8637
|
import { hostname } from "os";
|
|
8375
|
-
import { extname as extname3, isAbsolute as isAbsolute3, join as
|
|
8638
|
+
import { extname as extname3, isAbsolute as isAbsolute3, join as join12, resolve as resolve11 } from "path";
|
|
8376
8639
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
8377
|
-
import { CliUserError as
|
|
8378
|
-
function
|
|
8640
|
+
import { CliUserError as CliUserError41 } from "@burdenoff/cli-sdk/core";
|
|
8641
|
+
function isRecord19(value) {
|
|
8379
8642
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8380
8643
|
}
|
|
8381
8644
|
function bridgeUrlFor(env, explicit, issued) {
|
|
@@ -8385,11 +8648,11 @@ function bridgeUrlFor(env, explicit, issued) {
|
|
|
8385
8648
|
try {
|
|
8386
8649
|
url = new URL(raw);
|
|
8387
8650
|
} catch {
|
|
8388
|
-
throw new
|
|
8651
|
+
throw new CliUserError41(`Invalid bridge URL '${raw}'.`);
|
|
8389
8652
|
}
|
|
8390
8653
|
const local = url.hostname === "localhost" || url.hostname === "127.0.0.1";
|
|
8391
8654
|
if (url.protocol !== "wss:" && !(url.protocol === "ws:" && local)) {
|
|
8392
|
-
throw new
|
|
8655
|
+
throw new CliUserError41(`The bridge URL must be wss:// (ws:// only to this machine): ${raw}`);
|
|
8393
8656
|
}
|
|
8394
8657
|
return url.toString();
|
|
8395
8658
|
}
|
|
@@ -8405,18 +8668,18 @@ function bridgeHeaders(env) {
|
|
|
8405
8668
|
const id = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_ID")?.trim();
|
|
8406
8669
|
const secret = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET")?.trim();
|
|
8407
8670
|
if ((id === undefined || id === "") !== (secret === undefined || secret === "")) {
|
|
8408
|
-
throw new
|
|
8671
|
+
throw new CliUserError41("Set both FLUIDGRIDS_CF_ACCESS_CLIENT_ID and FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET, or neither.");
|
|
8409
8672
|
}
|
|
8410
8673
|
return id && secret ? { "CF-Access-Client-Id": id, "CF-Access-Client-Secret": secret } : {};
|
|
8411
8674
|
}
|
|
8412
8675
|
function workerToken(env, tokenEnv) {
|
|
8413
8676
|
const variable = tokenEnv?.trim() || WORKER_TOKEN_ENV;
|
|
8414
8677
|
if (!ENV_NAME2.test(variable)) {
|
|
8415
|
-
throw new
|
|
8678
|
+
throw new CliUserError41("Invalid environment variable name for --token-env.");
|
|
8416
8679
|
}
|
|
8417
8680
|
const token = env.getEnv(variable)?.trim() ?? "";
|
|
8418
8681
|
if (!WORKER_TOKEN.test(token)) {
|
|
8419
|
-
throw new
|
|
8682
|
+
throw new CliUserError41(`${variable} must hold a worker token (fgr_ and 43 characters).`, {
|
|
8420
8683
|
hint: "Issue one with `fluidgrids workers tokens create <name> --queue <queue>`."
|
|
8421
8684
|
});
|
|
8422
8685
|
}
|
|
@@ -8429,37 +8692,37 @@ async function buildWorkerBundle(project) {
|
|
|
8429
8692
|
explainUnresolved: (names) => [...names]
|
|
8430
8693
|
});
|
|
8431
8694
|
if (!lowered.workflows.some((workflow) => workflow.durable)) {
|
|
8432
|
-
throw new
|
|
8695
|
+
throw new CliUserError41("The project defines no durable functions for a worker to serve.");
|
|
8433
8696
|
}
|
|
8434
8697
|
await prepareProjectBundle(project, lowered);
|
|
8435
8698
|
return bundlePathOf(project);
|
|
8436
8699
|
}
|
|
8437
8700
|
function bundlePathOf(project) {
|
|
8438
8701
|
const relative = project.config.language === "py" ? PYTHON_BUNDLE_PATH : TYPESCRIPT_BUNDLE_PATH;
|
|
8439
|
-
return
|
|
8702
|
+
return join12(project.root, ...relative.split("/"));
|
|
8440
8703
|
}
|
|
8441
8704
|
function activitiesFor(project, raw) {
|
|
8442
8705
|
if (raw === undefined)
|
|
8443
8706
|
return;
|
|
8444
8707
|
const value = raw.trim();
|
|
8445
8708
|
if (value === "")
|
|
8446
|
-
throw new
|
|
8709
|
+
throw new CliUserError41("--activities cannot be empty.");
|
|
8447
8710
|
if (project.config.language === "py") {
|
|
8448
8711
|
if (!/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(value)) {
|
|
8449
|
-
throw new
|
|
8712
|
+
throw new CliUserError41(`--activities for a Python project is a module name importable from the project (for example activities), not '${raw}'.`);
|
|
8450
8713
|
}
|
|
8451
8714
|
return value;
|
|
8452
8715
|
}
|
|
8453
8716
|
const path = isAbsolute3(value) ? value : resolve11(project.root, value);
|
|
8454
|
-
if (!
|
|
8455
|
-
throw new
|
|
8717
|
+
if (!existsSync14(path))
|
|
8718
|
+
throw new CliUserError41(`--activities: ${raw} not found.`);
|
|
8456
8719
|
return path;
|
|
8457
8720
|
}
|
|
8458
8721
|
function launchOf(settings) {
|
|
8459
8722
|
const { project, options } = settings;
|
|
8460
8723
|
const activities = activitiesFor(project, options.activities);
|
|
8461
8724
|
if (!settings.bundlePath && !activities) {
|
|
8462
|
-
throw new
|
|
8725
|
+
throw new CliUserError41("The worker would serve nothing: give workflows, --activities or both.");
|
|
8463
8726
|
}
|
|
8464
8727
|
const maxActivities = parsePositiveInt(options.maxConcurrentActivities, "--max-concurrent-activities");
|
|
8465
8728
|
const maxWorkflowTasks = parsePositiveInt(options.maxConcurrentWorkflowTasks, "--max-concurrent-workflow-tasks");
|
|
@@ -8489,10 +8752,10 @@ async function workflowBundle(project, options, build) {
|
|
|
8489
8752
|
if (build)
|
|
8490
8753
|
return buildWorkerBundle(project);
|
|
8491
8754
|
const path = bundlePathOf(project);
|
|
8492
|
-
if (!
|
|
8755
|
+
if (!existsSync14(path)) {
|
|
8493
8756
|
if (options.activities !== undefined)
|
|
8494
8757
|
return;
|
|
8495
|
-
throw new
|
|
8758
|
+
throw new CliUserError41(`No workflow bundle at ${path}.`, {
|
|
8496
8759
|
hint: "Run `fluidgrids push` first, or pass --build to build it now (or --no-workflows)."
|
|
8497
8760
|
});
|
|
8498
8761
|
}
|
|
@@ -8501,7 +8764,7 @@ async function workflowBundle(project, options, build) {
|
|
|
8501
8764
|
async function runWorkerRun(env, options) {
|
|
8502
8765
|
const queues = bindWorkerQueues(parseList(options.queue).map(checkWorkerQueue), options.environment);
|
|
8503
8766
|
if (queues.length === 0)
|
|
8504
|
-
throw new
|
|
8767
|
+
throw new CliUserError41("Name the task queue(s) to serve with --queue.");
|
|
8505
8768
|
const project = loadProject(options.project, env.cwd());
|
|
8506
8769
|
const token = workerToken(env, options.tokenEnv);
|
|
8507
8770
|
const launch = launchOf({
|
|
@@ -8524,7 +8787,7 @@ function devQueueName() {
|
|
|
8524
8787
|
async function runDev(env, options) {
|
|
8525
8788
|
const project = loadProject(options.project, env.cwd());
|
|
8526
8789
|
if (options.lang !== undefined && options.lang !== project.config.language) {
|
|
8527
|
-
throw new
|
|
8790
|
+
throw new CliUserError41(`--lang ${options.lang} does not match the project language (${project.config.language}).`, { hint: "Run `fluidgrids dev` in a project of that language (`fluidgrids init --lang …`)." });
|
|
8528
8791
|
}
|
|
8529
8792
|
const bundlePath = await workflowBundle(project, options, options.workflows !== false);
|
|
8530
8793
|
const queueName = devQueueName();
|
|
@@ -8595,7 +8858,7 @@ async function loadTypeScriptActivities(root, path) {
|
|
|
8595
8858
|
let target = path;
|
|
8596
8859
|
if ([".ts", ".mts", ".cts", ".tsx"].includes(extname3(path))) {
|
|
8597
8860
|
const { build } = await import("esbuild");
|
|
8598
|
-
const outfile =
|
|
8861
|
+
const outfile = join12(root, ...ACTIVITIES_BUILD_PATH.split("/"));
|
|
8599
8862
|
await build({
|
|
8600
8863
|
entryPoints: [path],
|
|
8601
8864
|
outfile,
|
|
@@ -8617,9 +8880,9 @@ async function loadTypeScriptActivities(root, path) {
|
|
|
8617
8880
|
else if (Array.isArray(value))
|
|
8618
8881
|
value.forEach(visit);
|
|
8619
8882
|
};
|
|
8620
|
-
if (
|
|
8883
|
+
if (isRecord19(module)) {
|
|
8621
8884
|
for (const [name, value] of Object.entries(module)) {
|
|
8622
|
-
if (name === "default" &&
|
|
8885
|
+
if (name === "default" && isRecord19(value) && !isActivityImplementation(value)) {
|
|
8623
8886
|
Object.values(value).forEach(visit);
|
|
8624
8887
|
} else {
|
|
8625
8888
|
visit(value);
|
|
@@ -8627,7 +8890,7 @@ async function loadTypeScriptActivities(root, path) {
|
|
|
8627
8890
|
}
|
|
8628
8891
|
}
|
|
8629
8892
|
if (found.length === 0) {
|
|
8630
|
-
throw new
|
|
8893
|
+
throw new CliUserError41(`${path} exports no activity implementations.`, {
|
|
8631
8894
|
hint: "Export `implementActivity(...)` or `defineActivity(...)` values from it."
|
|
8632
8895
|
});
|
|
8633
8896
|
}
|
|
@@ -8653,21 +8916,21 @@ async function runTypeScriptWorker(launch) {
|
|
|
8653
8916
|
}
|
|
8654
8917
|
function pythonWorkerExitError(python, code, signal) {
|
|
8655
8918
|
if (signal)
|
|
8656
|
-
return new
|
|
8919
|
+
return new CliUserError41(`The Python worker was stopped by ${signal}.`);
|
|
8657
8920
|
const status = String(code);
|
|
8658
8921
|
switch (code) {
|
|
8659
8922
|
case PYTHON_EXIT_NO_WORKER:
|
|
8660
|
-
return new
|
|
8923
|
+
return new CliUserError41(`The Python worker could not import fluidgrids_workflows.worker (status ${status}).`, {
|
|
8661
8924
|
hint: `Install the worker extra: \`${python} -m pip install 'fluidgrids-workflows[worker]'\`.`
|
|
8662
8925
|
});
|
|
8663
8926
|
case PYTHON_EXIT_NO_ACTIVITIES:
|
|
8664
|
-
return new
|
|
8927
|
+
return new CliUserError41(`The Python worker exited with status ${status}: the activities module defines no activities.`, {
|
|
8665
8928
|
hint: "Decorate the activities with @define_activity in the module --activities names, or pass the module that defines them."
|
|
8666
8929
|
});
|
|
8667
8930
|
case PYTHON_EXIT_BRIDGE_CLOSED:
|
|
8668
|
-
return new
|
|
8931
|
+
return new CliUserError41(`The Python worker exited with status ${status}: the worker bridge closed the connection (the close code and its meaning are above).`);
|
|
8669
8932
|
default:
|
|
8670
|
-
return new
|
|
8933
|
+
return new CliUserError41(`The Python worker exited with status ${status}.`);
|
|
8671
8934
|
}
|
|
8672
8935
|
}
|
|
8673
8936
|
function pythonWorkerSpec(launch) {
|
|
@@ -8711,7 +8974,7 @@ function runPythonWorker(launch) {
|
|
|
8711
8974
|
};
|
|
8712
8975
|
child.on("error", (error) => {
|
|
8713
8976
|
done();
|
|
8714
|
-
reject(error.code === "ENOENT" ? new
|
|
8977
|
+
reject(error.code === "ENOENT" ? new CliUserError41(`Python interpreter "${python}" was not found.`) : new CliUserError41(`Could not start ${python}: ${error.message}`));
|
|
8715
8978
|
});
|
|
8716
8979
|
child.on("close", (code, signal) => {
|
|
8717
8980
|
done();
|
|
@@ -8794,7 +9057,7 @@ except BridgeClosedError as error:
|
|
|
8794
9057
|
|
|
8795
9058
|
// src/phase-c/shared.ts
|
|
8796
9059
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
8797
|
-
import { CliUserError as
|
|
9060
|
+
import { CliUserError as CliUserError42 } from "@burdenoff/cli-sdk/core";
|
|
8798
9061
|
async function confirmOnTerminal(question) {
|
|
8799
9062
|
const rl = createInterface3({ input: process.stdin, output: process.stderr });
|
|
8800
9063
|
try {
|
|
@@ -8816,32 +9079,32 @@ async function requireConfirmation(env, question, force) {
|
|
|
8816
9079
|
if (force)
|
|
8817
9080
|
return;
|
|
8818
9081
|
if (!env.interactive()) {
|
|
8819
|
-
throw new
|
|
9082
|
+
throw new CliUserError42(`${question} needs confirmation.`, {
|
|
8820
9083
|
hint: "Pass --force to go ahead without a prompt."
|
|
8821
9084
|
});
|
|
8822
9085
|
}
|
|
8823
9086
|
if (!await env.confirm(question))
|
|
8824
|
-
throw new
|
|
9087
|
+
throw new CliUserError42("Aborted: nothing was changed.");
|
|
8825
9088
|
}
|
|
8826
9089
|
function runSelectorOf(runId, flags) {
|
|
8827
9090
|
const targeted = flags.workflowId !== undefined || flags.key !== undefined || flags.firstRunId !== undefined;
|
|
8828
9091
|
if (!targeted) {
|
|
8829
9092
|
if (runId === undefined || runId.trim() === "") {
|
|
8830
|
-
throw new
|
|
9093
|
+
throw new CliUserError42("Give a run id, or --workflow-id with --key.");
|
|
8831
9094
|
}
|
|
8832
9095
|
return { runId: runId.trim() };
|
|
8833
9096
|
}
|
|
8834
9097
|
if (runId !== undefined) {
|
|
8835
|
-
throw new
|
|
9098
|
+
throw new CliUserError42("Give a run id or --workflow-id with --key, not both.");
|
|
8836
9099
|
}
|
|
8837
9100
|
const workflowId = flags.workflowId?.trim() ?? "";
|
|
8838
9101
|
const key = flags.key?.trim() ?? "";
|
|
8839
9102
|
if (workflowId === "" || key === "") {
|
|
8840
|
-
throw new
|
|
9103
|
+
throw new CliUserError42("--workflow-id and --key go together (the workflow id of that key).");
|
|
8841
9104
|
}
|
|
8842
9105
|
const firstRunId = flags.firstRunId?.trim();
|
|
8843
9106
|
if (flags.firstRunId !== undefined && !firstRunId) {
|
|
8844
|
-
throw new
|
|
9107
|
+
throw new CliUserError42("--first-run-id cannot be empty.");
|
|
8845
9108
|
}
|
|
8846
9109
|
return {
|
|
8847
9110
|
target: { workflowKey: key, workflowId, ...firstRunId ? { firstRunId } : {} }
|
|
@@ -8857,7 +9120,7 @@ function parseEnumOption(raw, flag, allowed) {
|
|
|
8857
9120
|
const match = allowed.find((value) => value === normal);
|
|
8858
9121
|
if (match === undefined) {
|
|
8859
9122
|
const shown = allowed.map((value) => value.toLowerCase().replace(/_/g, "-"));
|
|
8860
|
-
throw new
|
|
9123
|
+
throw new CliUserError42(`Invalid value '${raw}' for ${flag}. Allowed: ${shown.join(", ")}`);
|
|
8861
9124
|
}
|
|
8862
9125
|
return match;
|
|
8863
9126
|
}
|
|
@@ -8866,7 +9129,7 @@ function parseNonNegativeInt(raw, flag) {
|
|
|
8866
9129
|
return;
|
|
8867
9130
|
const value = raw.trim();
|
|
8868
9131
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
8869
|
-
throw new
|
|
9132
|
+
throw new CliUserError42(`Invalid value '${raw}' for ${flag}: expected a whole number.`);
|
|
8870
9133
|
}
|
|
8871
9134
|
return Number(value);
|
|
8872
9135
|
}
|
|
@@ -8875,14 +9138,14 @@ function parseNumberOption(raw, flag) {
|
|
|
8875
9138
|
return;
|
|
8876
9139
|
const value = Number(raw.trim());
|
|
8877
9140
|
if (raw.trim() === "" || !Number.isFinite(value)) {
|
|
8878
|
-
throw new
|
|
9141
|
+
throw new CliUserError42(`Invalid value '${raw}' for ${flag}: expected a number.`);
|
|
8879
9142
|
}
|
|
8880
9143
|
return value;
|
|
8881
9144
|
}
|
|
8882
9145
|
function requireText(raw, flag) {
|
|
8883
9146
|
const value = raw?.trim() ?? "";
|
|
8884
9147
|
if (value === "")
|
|
8885
|
-
throw new
|
|
9148
|
+
throw new CliUserError42(`${flag} is required.`);
|
|
8886
9149
|
return value;
|
|
8887
9150
|
}
|
|
8888
9151
|
function parseList(raw) {
|
|
@@ -8912,7 +9175,7 @@ function parseInstant(raw, flag) {
|
|
|
8912
9175
|
const value = raw.trim();
|
|
8913
9176
|
const ms = Date.parse(value);
|
|
8914
9177
|
if (value === "" || !Number.isFinite(ms) || !/^\d{4}-\d{2}-\d{2}/.test(value)) {
|
|
8915
|
-
throw new
|
|
9178
|
+
throw new CliUserError42(`Invalid value '${raw}' for ${flag}: expected an ISO-8601 date and time such as 2026-10-01T00:00:00Z.`);
|
|
8916
9179
|
}
|
|
8917
9180
|
return new Date(ms).toISOString();
|
|
8918
9181
|
}
|
|
@@ -8921,7 +9184,7 @@ var init_shared3 = __esm(() => {
|
|
|
8921
9184
|
});
|
|
8922
9185
|
|
|
8923
9186
|
// src/config/commands.ts
|
|
8924
|
-
import { CliUserError as
|
|
9187
|
+
import { CliUserError as CliUserError43 } from "@burdenoff/cli-sdk/core";
|
|
8925
9188
|
function output(env, options, data, rows, headers) {
|
|
8926
9189
|
env.ctx.output.formatAndOutput(options, data, { headers, rows });
|
|
8927
9190
|
}
|
|
@@ -8937,7 +9200,7 @@ function isLocal(url) {
|
|
|
8937
9200
|
function checkProfileValue(key, value, profile) {
|
|
8938
9201
|
const trimmed = value.trim();
|
|
8939
9202
|
if (trimmed === "" || trimmed.length > 2048) {
|
|
8940
|
-
throw new
|
|
9203
|
+
throw new CliUserError43(`${key} must be 1 to 2048 characters.`);
|
|
8941
9204
|
}
|
|
8942
9205
|
switch (key) {
|
|
8943
9206
|
case "apiUrl":
|
|
@@ -8946,20 +9209,20 @@ function checkProfileValue(key, value, profile) {
|
|
|
8946
9209
|
try {
|
|
8947
9210
|
url = new URL(trimmed);
|
|
8948
9211
|
} catch {
|
|
8949
|
-
throw new
|
|
9212
|
+
throw new CliUserError43(`${key} must be a URL.`);
|
|
8950
9213
|
}
|
|
8951
9214
|
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLocal(url))) {
|
|
8952
|
-
throw new
|
|
9215
|
+
throw new CliUserError43(`${key} must use https (http only for localhost).`);
|
|
8953
9216
|
}
|
|
8954
9217
|
if (url.username || url.password) {
|
|
8955
|
-
throw new
|
|
9218
|
+
throw new CliUserError43(`${key} must not carry credentials.`);
|
|
8956
9219
|
}
|
|
8957
9220
|
return trimmed;
|
|
8958
9221
|
}
|
|
8959
9222
|
case "environment": {
|
|
8960
9223
|
const upper = trimmed.toUpperCase();
|
|
8961
9224
|
if (!ENVIRONMENTS4.includes(upper)) {
|
|
8962
|
-
throw new
|
|
9225
|
+
throw new CliUserError43(`environment must be one of ${ENVIRONMENTS4.join(", ")}.`);
|
|
8963
9226
|
}
|
|
8964
9227
|
return upper;
|
|
8965
9228
|
}
|
|
@@ -8973,15 +9236,15 @@ function checkProfileValue(key, value, profile) {
|
|
|
8973
9236
|
async function readToken(env, fromEnv) {
|
|
8974
9237
|
if (fromEnv !== undefined) {
|
|
8975
9238
|
if (!ENV_NAME3.test(fromEnv))
|
|
8976
|
-
throw new
|
|
9239
|
+
throw new CliUserError43("Invalid environment variable name for --from-env.");
|
|
8977
9240
|
const value = env.env[fromEnv]?.trim() ?? "";
|
|
8978
9241
|
if (value === "")
|
|
8979
|
-
throw new
|
|
9242
|
+
throw new CliUserError43(`The environment variable ${fromEnv} is empty or unset.`);
|
|
8980
9243
|
return value;
|
|
8981
9244
|
}
|
|
8982
9245
|
const piped = (await env.readStdin()).trim();
|
|
8983
9246
|
if (piped === "") {
|
|
8984
|
-
throw new
|
|
9247
|
+
throw new CliUserError43("Pipe the token on standard input, or pass --from-env <VAR>.", {
|
|
8985
9248
|
hint: 'For example: `printf %s "$TOKEN" | fluidgrids config set token --profile prod`.'
|
|
8986
9249
|
});
|
|
8987
9250
|
}
|
|
@@ -9001,7 +9264,7 @@ async function runConfigSet(env, key, value, options) {
|
|
|
9001
9264
|
const profile = profileName(env, options);
|
|
9002
9265
|
if (key === "token") {
|
|
9003
9266
|
if (value !== undefined) {
|
|
9004
|
-
throw new
|
|
9267
|
+
throw new CliUserError43("A token is never given on the command line.", {
|
|
9005
9268
|
hint: "Pipe it on standard input, or pass --from-env <VAR>."
|
|
9006
9269
|
});
|
|
9007
9270
|
}
|
|
@@ -9018,12 +9281,12 @@ async function runConfigSet(env, key, value, options) {
|
|
|
9018
9281
|
return out;
|
|
9019
9282
|
}
|
|
9020
9283
|
if (!isProfileKey(key)) {
|
|
9021
|
-
throw new
|
|
9284
|
+
throw new CliUserError43(`Unknown profile key ${key}.`, {
|
|
9022
9285
|
hint: `Keys: ${PROFILE_KEYS.join(", ")}, token, defaultProfile.`
|
|
9023
9286
|
});
|
|
9024
9287
|
}
|
|
9025
9288
|
if (value === undefined)
|
|
9026
|
-
throw new
|
|
9289
|
+
throw new CliUserError43(`Give a value for ${key}.`);
|
|
9027
9290
|
const checked = checkProfileValue(key, value, profile);
|
|
9028
9291
|
updateConfig(file, (document) => {
|
|
9029
9292
|
const table = profileTable(document, profile, true);
|
|
@@ -9039,7 +9302,7 @@ async function runConfigGet(env, key, options) {
|
|
|
9039
9302
|
const config = readConfig(file);
|
|
9040
9303
|
const resolved = resolveProfile(config, env.env, options.profile, file);
|
|
9041
9304
|
if (key !== undefined && !isProfileKey(key)) {
|
|
9042
|
-
throw new
|
|
9305
|
+
throw new CliUserError43(`Unknown profile key ${key}.`, {
|
|
9043
9306
|
hint: `Keys: ${PROFILE_KEYS.join(", ")}.`
|
|
9044
9307
|
});
|
|
9045
9308
|
}
|
|
@@ -9084,10 +9347,10 @@ async function runConfigDelete(env, key, options) {
|
|
|
9084
9347
|
const profile = profileName(env, options);
|
|
9085
9348
|
const existing = readConfig(file).profiles[profile];
|
|
9086
9349
|
if (existing === undefined)
|
|
9087
|
-
throw new
|
|
9350
|
+
throw new CliUserError43(`There is no profile ${profile} in ${file}.`);
|
|
9088
9351
|
if (key !== undefined) {
|
|
9089
9352
|
if (!isProfileKey(key))
|
|
9090
|
-
throw new
|
|
9353
|
+
throw new CliUserError43(`Unknown profile key ${key}.`);
|
|
9091
9354
|
updateConfig(file, (document) => {
|
|
9092
9355
|
const table = profileTable(document, profile, false);
|
|
9093
9356
|
if (table)
|
|
@@ -9124,7 +9387,7 @@ async function runConfigMigrate(env, options) {
|
|
|
9124
9387
|
values.workspace = workspace;
|
|
9125
9388
|
if (options.tokenEnv !== undefined) {
|
|
9126
9389
|
if (!ENV_NAME3.test(options.tokenEnv))
|
|
9127
|
-
throw new
|
|
9390
|
+
throw new CliUserError43("Invalid environment variable name for --token-env.");
|
|
9128
9391
|
values.tokenRef = `env:${options.tokenEnv}`;
|
|
9129
9392
|
}
|
|
9130
9393
|
updateConfig(file, (document) => {
|
|
@@ -9149,7 +9412,7 @@ var init_commands = __esm(() => {
|
|
|
9149
9412
|
});
|
|
9150
9413
|
|
|
9151
9414
|
// src/phase-c/commands/workers.ts
|
|
9152
|
-
import { CliUserError as
|
|
9415
|
+
import { CliUserError as CliUserError44 } from "@burdenoff/cli-sdk/core";
|
|
9153
9416
|
function workerRows(workers) {
|
|
9154
9417
|
return workers.map((worker) => [
|
|
9155
9418
|
worker.identity,
|
|
@@ -9163,7 +9426,7 @@ function workerRows(workers) {
|
|
|
9163
9426
|
}
|
|
9164
9427
|
async function runWorkersList(env, options) {
|
|
9165
9428
|
if (options.stale && options.notStale) {
|
|
9166
|
-
throw new
|
|
9429
|
+
throw new CliUserError44("Give --stale or --not-stale, not both.");
|
|
9167
9430
|
}
|
|
9168
9431
|
const filter = {
|
|
9169
9432
|
...options.queue ? { taskQueue: checkWorkerQueue(options.queue) } : {},
|
|
@@ -9206,7 +9469,7 @@ function connectionNames(raw) {
|
|
|
9206
9469
|
const names = parseList(raw);
|
|
9207
9470
|
for (const name of names) {
|
|
9208
9471
|
if (!CONNECTION_NAME.test(name)) {
|
|
9209
|
-
throw new
|
|
9472
|
+
throw new CliUserError44(`Invalid connection name '${name}'.`);
|
|
9210
9473
|
}
|
|
9211
9474
|
}
|
|
9212
9475
|
return names;
|
|
@@ -9221,10 +9484,10 @@ function issued(env, options, result) {
|
|
|
9221
9484
|
async function runTokensCreate(env, name, options) {
|
|
9222
9485
|
const tokenName = name.trim();
|
|
9223
9486
|
if (tokenName === "")
|
|
9224
|
-
throw new
|
|
9487
|
+
throw new CliUserError44("A worker token needs a name.");
|
|
9225
9488
|
const taskQueues = parseList(options.queue).map(checkWorkerQueue);
|
|
9226
9489
|
if (taskQueues.length === 0) {
|
|
9227
|
-
throw new
|
|
9490
|
+
throw new CliUserError44("A worker token needs at least one --queue.", {
|
|
9228
9491
|
hint: "Create the queue first with `fluidgrids queues create <name>`."
|
|
9229
9492
|
});
|
|
9230
9493
|
}
|
|
@@ -9253,10 +9516,10 @@ async function runTokensDelete(env, id, options) {
|
|
|
9253
9516
|
async function runTokensAllowConnections(env, id, names, options) {
|
|
9254
9517
|
const list = connectionNames(names);
|
|
9255
9518
|
if (list.length === 0 && !options.clear) {
|
|
9256
|
-
throw new
|
|
9519
|
+
throw new CliUserError44("Name the connections to allow, or pass --clear to allow none.");
|
|
9257
9520
|
}
|
|
9258
9521
|
if (list.length > 0 && options.clear) {
|
|
9259
|
-
throw new
|
|
9522
|
+
throw new CliUserError44("Give connection names or --clear, not both.");
|
|
9260
9523
|
}
|
|
9261
9524
|
const token = await env.pc.setWorkerTokenConnectionAllowlist(id, list);
|
|
9262
9525
|
emit(env, options, token, { headers: TOKEN_HEADERS, rows: [tokenRow(token)] }, [
|
|
@@ -9276,17 +9539,17 @@ var init_workers = __esm(() => {
|
|
|
9276
9539
|
|
|
9277
9540
|
// src/phase-c/commands/run-control.ts
|
|
9278
9541
|
import { randomUUID } from "crypto";
|
|
9279
|
-
import { CliUserError as
|
|
9542
|
+
import { CliUserError as CliUserError45 } from "@burdenoff/cli-sdk/core";
|
|
9280
9543
|
function runAndName(first, second, flags) {
|
|
9281
9544
|
const targeted = flags.workflowId !== undefined || flags.key !== undefined;
|
|
9282
9545
|
if (targeted) {
|
|
9283
9546
|
if (second !== undefined) {
|
|
9284
|
-
throw new
|
|
9547
|
+
throw new CliUserError45("With --workflow-id, give only the name: `<name> --workflow-id <id> --key <key>`.");
|
|
9285
9548
|
}
|
|
9286
9549
|
return { run: runSelectorOf(undefined, flags), name: first };
|
|
9287
9550
|
}
|
|
9288
9551
|
if (second === undefined) {
|
|
9289
|
-
throw new
|
|
9552
|
+
throw new CliUserError45("Give the run id and the name: `<runId> <name>`.");
|
|
9290
9553
|
}
|
|
9291
9554
|
return { run: runSelectorOf(first, flags), name: second };
|
|
9292
9555
|
}
|
|
@@ -9300,7 +9563,7 @@ async function runQuery(env, first, second, options) {
|
|
|
9300
9563
|
rows: [[result.name, String(result.rejected), JSON.stringify(result.value ?? null)]]
|
|
9301
9564
|
}, result.error ? [`error: ${result.error}`] : []);
|
|
9302
9565
|
if (result.rejected) {
|
|
9303
|
-
throw new
|
|
9566
|
+
throw new CliUserError45(`The query ${name} was refused: ${result.error ?? "no reason given"}`);
|
|
9304
9567
|
}
|
|
9305
9568
|
return result;
|
|
9306
9569
|
}
|
|
@@ -9342,13 +9605,13 @@ async function runUpdate(env, first, second, options) {
|
|
|
9342
9605
|
rows: [[result.updateId, result.name, result.status, JSON.stringify(result.result ?? null)]]
|
|
9343
9606
|
});
|
|
9344
9607
|
if (!reached(result.status, waitFor)) {
|
|
9345
|
-
throw new
|
|
9608
|
+
throw new CliUserError45(`The update ${name} is still ${result.status} after ${timeoutMs} ms (waiting for ${waitFor}); check it later with \`fluidgrids runs update-status ${result.runId} ${updateId}\`.`);
|
|
9346
9609
|
}
|
|
9347
9610
|
if (result.status === "REJECTED") {
|
|
9348
|
-
throw new
|
|
9611
|
+
throw new CliUserError45(`The update ${name} was rejected: ${failureMessage(result.failure)}`);
|
|
9349
9612
|
}
|
|
9350
9613
|
if (result.status === "COMPLETED" && result.failure !== null && result.failure !== undefined) {
|
|
9351
|
-
throw new
|
|
9614
|
+
throw new CliUserError45(`The update handler of ${name} failed: ${failureMessage(result.failure)}`);
|
|
9352
9615
|
}
|
|
9353
9616
|
return result;
|
|
9354
9617
|
}
|
|
@@ -9364,33 +9627,33 @@ async function runUpdateStatus(env, first, second, options) {
|
|
|
9364
9627
|
function parseResetTo(raw, buildId) {
|
|
9365
9628
|
const value = raw?.trim() ?? "";
|
|
9366
9629
|
if (value === "") {
|
|
9367
|
-
throw new
|
|
9630
|
+
throw new CliUserError45("--to is required: a history seq, first-task, last-task, last-continue-as-new, build-id or last-clean-task.");
|
|
9368
9631
|
}
|
|
9369
9632
|
if (/^\d+$/.test(value)) {
|
|
9370
9633
|
if (buildId !== undefined)
|
|
9371
|
-
throw new
|
|
9634
|
+
throw new CliUserError45("--build-id goes with --to build-id only.");
|
|
9372
9635
|
const seq = Number(value);
|
|
9373
9636
|
if (!Number.isSafeInteger(seq) || seq <= 0) {
|
|
9374
|
-
throw new
|
|
9637
|
+
throw new CliUserError45(`Invalid value '${raw}' for --to: a seq is a positive integer.`);
|
|
9375
9638
|
}
|
|
9376
9639
|
return { seq };
|
|
9377
9640
|
}
|
|
9378
9641
|
const normal = value.toUpperCase().replace(/-/g, "_");
|
|
9379
9642
|
if (normal === "LAST_CLEAN_TASK") {
|
|
9380
9643
|
if (buildId !== undefined)
|
|
9381
|
-
throw new
|
|
9644
|
+
throw new CliUserError45("--build-id goes with --to build-id only.");
|
|
9382
9645
|
return "LAST_CLEAN_TASK";
|
|
9383
9646
|
}
|
|
9384
9647
|
const type = parseEnumOption(normal === "LAST_CONTINUE_AS_NEW" ? "LAST_CONTINUED_AS_NEW" : normal, "--to", RESET_TYPES);
|
|
9385
9648
|
if (type === "BUILD_ID") {
|
|
9386
9649
|
const id = buildId?.trim() ?? "";
|
|
9387
9650
|
if (!/^sha256:[0-9a-f]{64}$/.test(id)) {
|
|
9388
|
-
throw new
|
|
9651
|
+
throw new CliUserError45("--to build-id needs --build-id sha256:<64 hex>.");
|
|
9389
9652
|
}
|
|
9390
9653
|
return { type, buildId: id };
|
|
9391
9654
|
}
|
|
9392
9655
|
if (buildId !== undefined)
|
|
9393
|
-
throw new
|
|
9656
|
+
throw new CliUserError45("--build-id goes with --to build-id only.");
|
|
9394
9657
|
return { type };
|
|
9395
9658
|
}
|
|
9396
9659
|
async function runReset(env, runId, options) {
|
|
@@ -9449,7 +9712,7 @@ async function runTrace(env, runIdArg, options) {
|
|
|
9449
9712
|
const runId = await env.pc.runIdOf(runSelectorOf(runIdArg, options));
|
|
9450
9713
|
const hierarchy = await env.pc.runHierarchy(runId);
|
|
9451
9714
|
if (!hierarchy)
|
|
9452
|
-
throw new
|
|
9715
|
+
throw new CliUserError45(`Run ${runId} not found (NOT_FOUND)`);
|
|
9453
9716
|
const entries = flatten(hierarchy);
|
|
9454
9717
|
const open = entries.filter((entry) => OPEN_STATUSES.includes(entry.run.status));
|
|
9455
9718
|
const read = new Map;
|
|
@@ -9489,32 +9752,32 @@ var init_run_control = __esm(() => {
|
|
|
9489
9752
|
});
|
|
9490
9753
|
|
|
9491
9754
|
// src/phase-c/commands/activities.ts
|
|
9492
|
-
import { CliUserError as
|
|
9755
|
+
import { CliUserError as CliUserError46 } from "@burdenoff/cli-sdk/core";
|
|
9493
9756
|
import { durationMs as durationMs2 } from "@fluidgrids/workflows/ir";
|
|
9494
9757
|
function completionOf(env, first, second, options) {
|
|
9495
9758
|
if (options.taskTokenEnv !== undefined) {
|
|
9496
9759
|
if (first !== undefined || options.workflowId !== undefined || options.key !== undefined) {
|
|
9497
|
-
throw new
|
|
9760
|
+
throw new CliUserError46("Give --task-token-env, or the run and activity id, not both.");
|
|
9498
9761
|
}
|
|
9499
9762
|
const variable = options.taskTokenEnv.trim();
|
|
9500
9763
|
if (!ENV_NAME4.test(variable)) {
|
|
9501
|
-
throw new
|
|
9764
|
+
throw new CliUserError46("Invalid environment variable name for --task-token-env.");
|
|
9502
9765
|
}
|
|
9503
9766
|
const taskToken = env.getEnv(variable)?.trim() ?? "";
|
|
9504
9767
|
if (taskToken === "") {
|
|
9505
|
-
throw new
|
|
9768
|
+
throw new CliUserError46(`The environment variable ${variable} (--task-token-env) is empty or unset.`);
|
|
9506
9769
|
}
|
|
9507
9770
|
return { kind: "token", taskToken };
|
|
9508
9771
|
}
|
|
9509
9772
|
const targeted = options.workflowId !== undefined || options.key !== undefined;
|
|
9510
9773
|
if (targeted) {
|
|
9511
9774
|
if (first === undefined || second !== undefined) {
|
|
9512
|
-
throw new
|
|
9775
|
+
throw new CliUserError46("With --workflow-id, give only the activity id.");
|
|
9513
9776
|
}
|
|
9514
9777
|
return { kind: "id", run: runSelectorOf(undefined, options), activityId: first };
|
|
9515
9778
|
}
|
|
9516
9779
|
if (first === undefined || second === undefined) {
|
|
9517
|
-
throw new
|
|
9780
|
+
throw new CliUserError46("Give `<runId> <activityId>`, `<activityId> --workflow-id <id> --key <key>`, or --task-token-env.");
|
|
9518
9781
|
}
|
|
9519
9782
|
return { kind: "id", run: runSelectorOf(first, options), activityId: second };
|
|
9520
9783
|
}
|
|
@@ -9572,7 +9835,7 @@ function selectorOf(options) {
|
|
|
9572
9835
|
options.all === true
|
|
9573
9836
|
];
|
|
9574
9837
|
if (given.filter(Boolean).length !== 1) {
|
|
9575
|
-
throw new
|
|
9838
|
+
throw new CliUserError46("Choose the activities with exactly one of --activity-id, --type or --all.");
|
|
9576
9839
|
}
|
|
9577
9840
|
if (options.activityId !== undefined) {
|
|
9578
9841
|
return { activityId: requireText(options.activityId, "--activity-id") };
|
|
@@ -9613,18 +9876,18 @@ function parseMs(raw, flag) {
|
|
|
9613
9876
|
const value = raw.trim();
|
|
9614
9877
|
const ms = /^\d+$/.test(value) ? Number(value) : value === "" ? undefined : durationMs2(value, "ms");
|
|
9615
9878
|
if (ms === undefined || !Number.isFinite(ms) || ms <= 0 || !Number.isSafeInteger(Math.round(ms))) {
|
|
9616
|
-
throw new
|
|
9879
|
+
throw new CliUserError46(`Invalid value '${raw}' for ${flag}: expected milliseconds or a duration such as 1.5s, 5m or PT2H.`);
|
|
9617
9880
|
}
|
|
9618
9881
|
return Math.round(ms);
|
|
9619
9882
|
}
|
|
9620
9883
|
function activityOptionsOf(options) {
|
|
9621
9884
|
const maxRetries = options.maxRetries === undefined ? undefined : /^\d+$/.test(options.maxRetries.trim()) ? Number(options.maxRetries.trim()) : NaN;
|
|
9622
9885
|
if (Number.isNaN(maxRetries)) {
|
|
9623
|
-
throw new
|
|
9886
|
+
throw new CliUserError46(`Invalid value '${options.maxRetries}' for --max-retries.`);
|
|
9624
9887
|
}
|
|
9625
9888
|
const backoff = options.backoff === undefined ? undefined : Number(options.backoff.trim());
|
|
9626
9889
|
if (backoff !== undefined && (!Number.isFinite(backoff) || backoff < 1)) {
|
|
9627
|
-
throw new
|
|
9890
|
+
throw new CliUserError46(`Invalid value '${options.backoff}' for --backoff: at least 1.`);
|
|
9628
9891
|
}
|
|
9629
9892
|
const retryOn = [];
|
|
9630
9893
|
for (const value of parseList(options.retryOn)) {
|
|
@@ -9648,7 +9911,7 @@ function activityOptionsOf(options) {
|
|
|
9648
9911
|
};
|
|
9649
9912
|
const out = { ...timeouts, ...Object.keys(retry).length > 0 ? { retry } : {} };
|
|
9650
9913
|
if (Object.keys(out).length === 0) {
|
|
9651
|
-
throw new
|
|
9914
|
+
throw new CliUserError46("Nothing to change: give a retry option or a timeout.");
|
|
9652
9915
|
}
|
|
9653
9916
|
return out;
|
|
9654
9917
|
}
|
|
@@ -9675,10 +9938,10 @@ async function runPauseRulesList(env, options) {
|
|
|
9675
9938
|
}
|
|
9676
9939
|
async function runPauseRulesCreate(env, options) {
|
|
9677
9940
|
if (options.activityType === undefined && options.nodeType === undefined && options.workflowKey === undefined) {
|
|
9678
|
-
throw new
|
|
9941
|
+
throw new CliUserError46("A pause rule needs --activity-type, --node-type or --workflow-key.");
|
|
9679
9942
|
}
|
|
9680
9943
|
if (options.expiresAt !== undefined && options.expiresIn !== undefined) {
|
|
9681
|
-
throw new
|
|
9944
|
+
throw new CliUserError46("Give --expires-at or --expires-in, not both.");
|
|
9682
9945
|
}
|
|
9683
9946
|
const expiresIn = parseMs(options.expiresIn, "--expires-in");
|
|
9684
9947
|
const expiresAt = expiresIn !== undefined ? new Date(Date.now() + expiresIn).toISOString() : parseInstant(options.expiresAt, "--expires-at");
|
|
@@ -9716,11 +9979,11 @@ var init_activities = __esm(() => {
|
|
|
9716
9979
|
});
|
|
9717
9980
|
|
|
9718
9981
|
// src/phase-c/commands/batch.ts
|
|
9719
|
-
import { CliUserError as
|
|
9982
|
+
import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
|
|
9720
9983
|
function isBatchType(name) {
|
|
9721
9984
|
return Object.hasOwn(BATCH_TYPES, name);
|
|
9722
9985
|
}
|
|
9723
|
-
function
|
|
9986
|
+
function isRecord20(value) {
|
|
9724
9987
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9725
9988
|
}
|
|
9726
9989
|
function batchSelection(options) {
|
|
@@ -9728,8 +9991,8 @@ function batchSelection(options) {
|
|
|
9728
9991
|
const filter = {};
|
|
9729
9992
|
if (options.filter !== undefined) {
|
|
9730
9993
|
const raw = parseJsonOption(options.filter, "--filter");
|
|
9731
|
-
if (!
|
|
9732
|
-
throw new
|
|
9994
|
+
if (!isRecord20(raw))
|
|
9995
|
+
throw new CliUserError47("--filter must be a JSON object (ListWorkflowRunsInput).");
|
|
9733
9996
|
Object.assign(filter, raw);
|
|
9734
9997
|
delete filter["limit"];
|
|
9735
9998
|
delete filter["offset"];
|
|
@@ -9748,20 +10011,20 @@ function batchSelection(options) {
|
|
|
9748
10011
|
filter["firstRunId"] = requireText(options.firstRunId, "--first-run-id");
|
|
9749
10012
|
if (options.searchAttributes !== undefined) {
|
|
9750
10013
|
const query = parseJsonOption(options.searchAttributes, "--search-attributes");
|
|
9751
|
-
if (!
|
|
9752
|
-
throw new
|
|
10014
|
+
if (!isRecord20(query)) {
|
|
10015
|
+
throw new CliUserError47("--search-attributes must be a JSON object ({and, or, text}).");
|
|
9753
10016
|
}
|
|
9754
10017
|
filter["searchAttributes"] = query;
|
|
9755
10018
|
}
|
|
9756
10019
|
const filtered = Object.keys(filter).length > 0;
|
|
9757
10020
|
if (runIds.length > 0 && filtered) {
|
|
9758
|
-
throw new
|
|
10021
|
+
throw new CliUserError47("Choose the runs with --run-id or with filter options, not both.");
|
|
9759
10022
|
}
|
|
9760
10023
|
if (runIds.length > MAX_BATCH_RUN_IDS) {
|
|
9761
|
-
throw new
|
|
10024
|
+
throw new CliUserError47(`At most ${MAX_BATCH_RUN_IDS} --run-id values; use a filter for more.`);
|
|
9762
10025
|
}
|
|
9763
10026
|
if (runIds.length === 0 && !filtered) {
|
|
9764
|
-
throw new
|
|
10027
|
+
throw new CliUserError47("Choose the runs: --run-id, or a filter (--key, --status, --kind, --workflow-id, --search-attributes, --filter).");
|
|
9765
10028
|
}
|
|
9766
10029
|
const rate = parsePositiveInt(options.rate, "--rate");
|
|
9767
10030
|
return {
|
|
@@ -9823,7 +10086,7 @@ function batchPayload(type, options) {
|
|
|
9823
10086
|
options.clearOverride === true
|
|
9824
10087
|
];
|
|
9825
10088
|
if (chosen.filter(Boolean).length !== 1) {
|
|
9826
|
-
throw new
|
|
10089
|
+
throw new CliUserError47("Give exactly one of --pin <version>, --auto-upgrade or --clear-override.");
|
|
9827
10090
|
}
|
|
9828
10091
|
if (options.clearOverride)
|
|
9829
10092
|
return { clearVersioningOverride: true };
|
|
@@ -9857,7 +10120,7 @@ function refuseUnused(type, options) {
|
|
|
9857
10120
|
unused.push("--activity-id/--type/--all");
|
|
9858
10121
|
}
|
|
9859
10122
|
if (unused.length > 0) {
|
|
9860
|
-
throw new
|
|
10123
|
+
throw new CliUserError47(`${unused.join(", ")} do not apply to a ${type} batch.`);
|
|
9861
10124
|
}
|
|
9862
10125
|
}
|
|
9863
10126
|
function jobRow(job) {
|
|
@@ -9885,7 +10148,7 @@ function jobDetails(job) {
|
|
|
9885
10148
|
}
|
|
9886
10149
|
async function runBatchStart(env, typeName, options) {
|
|
9887
10150
|
if (!isBatchType(typeName)) {
|
|
9888
|
-
throw new
|
|
10151
|
+
throw new CliUserError47(`Unknown batch type '${typeName}'. Allowed: ${Object.keys(BATCH_TYPES).join(", ")}`);
|
|
9889
10152
|
}
|
|
9890
10153
|
const type = BATCH_TYPES[typeName];
|
|
9891
10154
|
refuseUnused(type, options);
|
|
@@ -9935,10 +10198,10 @@ async function runBatchDescribe(env, id, options) {
|
|
|
9935
10198
|
}
|
|
9936
10199
|
emit(env, options, job, { headers: JOB_HEADERS, rows: [jobRow(job)] }, jobDetails(job));
|
|
9937
10200
|
if (options.watch && !TERMINAL_JOB.includes(job.status)) {
|
|
9938
|
-
throw new
|
|
10201
|
+
throw new CliUserError47(`Batch job ${id} is still ${job.status} after ${timeout} ms.`);
|
|
9939
10202
|
}
|
|
9940
10203
|
if (options.watch && (job.status === "FAILED" || job.status === "CANCELLED")) {
|
|
9941
|
-
throw new
|
|
10204
|
+
throw new CliUserError47(`Batch job ${id} ended ${job.status}${job.failureMessage ? `: ${job.failureMessage}` : ""}.`);
|
|
9942
10205
|
}
|
|
9943
10206
|
return job;
|
|
9944
10207
|
}
|
|
@@ -9982,7 +10245,7 @@ var init_batch = __esm(() => {
|
|
|
9982
10245
|
});
|
|
9983
10246
|
|
|
9984
10247
|
// src/phase-d/duration.ts
|
|
9985
|
-
import { CliUserError as
|
|
10248
|
+
import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
|
|
9986
10249
|
import { toMs } from "@fluidgrids/workflows";
|
|
9987
10250
|
function parseDurationOption(raw, flag) {
|
|
9988
10251
|
if (raw === undefined)
|
|
@@ -9992,23 +10255,23 @@ function parseDurationOption(raw, flag) {
|
|
|
9992
10255
|
try {
|
|
9993
10256
|
toMs(sent, flag);
|
|
9994
10257
|
} catch {
|
|
9995
|
-
throw new
|
|
10258
|
+
throw new CliUserError48(`Invalid value '${raw}' for ${flag}: expected a duration such as 1500 (milliseconds), 30s, 5m, 2h or PT2H.`);
|
|
9996
10259
|
}
|
|
9997
10260
|
return sent;
|
|
9998
10261
|
}
|
|
9999
10262
|
var init_duration = () => {};
|
|
10000
10263
|
|
|
10001
10264
|
// src/phase-d/commands/activity-start.ts
|
|
10002
|
-
import { existsSync as
|
|
10265
|
+
import { existsSync as existsSync15, readFileSync as readFileSync12 } from "fs";
|
|
10003
10266
|
import { resolve as resolve12 } from "path";
|
|
10004
|
-
import { CliUserError as
|
|
10267
|
+
import { CliUserError as CliUserError49 } from "@burdenoff/cli-sdk/core";
|
|
10005
10268
|
function retryPolicy(raw, maxAttempts, readFile) {
|
|
10006
10269
|
const parsed = parseJsonObjectArg(raw, "--retry", readFile);
|
|
10007
10270
|
const policy = {};
|
|
10008
10271
|
if (parsed !== undefined) {
|
|
10009
10272
|
for (const key of Object.keys(parsed)) {
|
|
10010
10273
|
if (!RETRY_KEYS.some((known) => known === key)) {
|
|
10011
|
-
throw new
|
|
10274
|
+
throw new CliUserError49(`--retry: unknown field ${key}. Allowed: ${RETRY_KEYS.join(", ")}`);
|
|
10012
10275
|
}
|
|
10013
10276
|
}
|
|
10014
10277
|
const text = (key) => {
|
|
@@ -10016,7 +10279,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10016
10279
|
if (value === undefined)
|
|
10017
10280
|
return;
|
|
10018
10281
|
if (typeof value !== "string")
|
|
10019
|
-
throw new
|
|
10282
|
+
throw new CliUserError49(`--retry: ${key} must be a duration.`);
|
|
10020
10283
|
policy[key] = parseDurationOption(value, `--retry ${key}`);
|
|
10021
10284
|
};
|
|
10022
10285
|
text("initialInterval");
|
|
@@ -10024,21 +10287,21 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10024
10287
|
const backoff = parsed["backoffCoefficient"];
|
|
10025
10288
|
if (backoff !== undefined) {
|
|
10026
10289
|
if (typeof backoff !== "number" || !Number.isFinite(backoff) || backoff < 1) {
|
|
10027
|
-
throw new
|
|
10290
|
+
throw new CliUserError49("--retry: backoffCoefficient must be a number of at least 1.");
|
|
10028
10291
|
}
|
|
10029
10292
|
policy.backoffCoefficient = backoff;
|
|
10030
10293
|
}
|
|
10031
10294
|
const attempts = parsed["maximumAttempts"];
|
|
10032
10295
|
if (attempts !== undefined) {
|
|
10033
10296
|
if (typeof attempts !== "number" || !Number.isSafeInteger(attempts) || attempts < 0) {
|
|
10034
|
-
throw new
|
|
10297
|
+
throw new CliUserError49("--retry: maximumAttempts must be a whole number (0 = unlimited).");
|
|
10035
10298
|
}
|
|
10036
10299
|
policy.maximumAttempts = attempts;
|
|
10037
10300
|
}
|
|
10038
10301
|
const types = parsed["nonRetryableErrorTypes"];
|
|
10039
10302
|
if (types !== undefined) {
|
|
10040
10303
|
if (!Array.isArray(types) || types.some((type) => typeof type !== "string")) {
|
|
10041
|
-
throw new
|
|
10304
|
+
throw new CliUserError49("--retry: nonRetryableErrorTypes must be a list of strings.");
|
|
10042
10305
|
}
|
|
10043
10306
|
policy.nonRetryableErrorTypes = types.filter((type) => typeof type === "string");
|
|
10044
10307
|
}
|
|
@@ -10046,7 +10309,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10046
10309
|
if (maxAttempts !== undefined) {
|
|
10047
10310
|
const value = maxAttempts.trim();
|
|
10048
10311
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
10049
|
-
throw new
|
|
10312
|
+
throw new CliUserError49(`Invalid value '${maxAttempts}' for --max-attempts: expected a whole number (0 = unlimited).`);
|
|
10050
10313
|
}
|
|
10051
10314
|
policy.maximumAttempts = Number(value);
|
|
10052
10315
|
}
|
|
@@ -10055,29 +10318,29 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10055
10318
|
function requireName(raw, what) {
|
|
10056
10319
|
const value = raw.trim();
|
|
10057
10320
|
if (value === "")
|
|
10058
|
-
throw new
|
|
10321
|
+
throw new CliUserError49(`The ${what} is empty.`);
|
|
10059
10322
|
return value;
|
|
10060
10323
|
}
|
|
10061
10324
|
async function runActivityStart(env, nodeType, operation, options) {
|
|
10062
10325
|
const readFile = (path) => {
|
|
10063
10326
|
const absolute = resolve12(env.cwd(), path);
|
|
10064
|
-
if (!
|
|
10065
|
-
throw new
|
|
10327
|
+
if (!existsSync15(absolute))
|
|
10328
|
+
throw new CliUserError49(`${path} does not exist.`);
|
|
10066
10329
|
return readFileSync12(absolute, "utf8");
|
|
10067
10330
|
};
|
|
10068
10331
|
if (options.args === undefined) {
|
|
10069
|
-
throw new
|
|
10332
|
+
throw new CliUserError49("--args is required: the operation arguments as a JSON object.", {
|
|
10070
10333
|
hint: `For example --args '{"url":"https://example.com"}', or --args @args.json.`
|
|
10071
10334
|
});
|
|
10072
10335
|
}
|
|
10073
10336
|
const args = parseJsonObjectArg(options.args, "--args", readFile) ?? {};
|
|
10074
10337
|
const summary = options.summary?.trim();
|
|
10075
10338
|
if (summary !== undefined && (summary === "" || summary.length > MAX_SUMMARY_CHARS)) {
|
|
10076
|
-
throw new
|
|
10339
|
+
throw new CliUserError49(`--summary is 1 to ${MAX_SUMMARY_CHARS} characters.`);
|
|
10077
10340
|
}
|
|
10078
10341
|
const key = options.idempotencyKey?.trim();
|
|
10079
10342
|
if (key !== undefined && !IDEMPOTENCY_KEY.test(key)) {
|
|
10080
|
-
throw new
|
|
10343
|
+
throw new CliUserError49(`--idempotency-key is 1 to ${MAX_IDEMPOTENCY_KEY_CHARS} letters, digits, dots, underscores, colons or dashes.`);
|
|
10081
10344
|
}
|
|
10082
10345
|
const retry = retryPolicy(options.retry, options.maxAttempts, readFile);
|
|
10083
10346
|
const nodeVersion = options.nodeVersion?.trim();
|
|
@@ -10121,7 +10384,7 @@ async function runActivityStart(env, nodeType, operation, options) {
|
|
|
10121
10384
|
rows: [[result.run.id, finalStatus, started.existing ? "yes" : "no"]]
|
|
10122
10385
|
}, details);
|
|
10123
10386
|
if (options.wait && finalStatus !== "COMPLETED") {
|
|
10124
|
-
throw new
|
|
10387
|
+
throw new CliUserError49(`Run ${started.run.id} ended ${finalStatus}.`);
|
|
10125
10388
|
}
|
|
10126
10389
|
return result;
|
|
10127
10390
|
}
|
|
@@ -10142,7 +10405,7 @@ var init_activity_start = __esm(() => {
|
|
|
10142
10405
|
});
|
|
10143
10406
|
|
|
10144
10407
|
// src/phase-c/commands/signal-tokens.ts
|
|
10145
|
-
import { CliUserError as
|
|
10408
|
+
import { CliUserError as CliUserError50 } from "@burdenoff/cli-sdk/core";
|
|
10146
10409
|
function row(token) {
|
|
10147
10410
|
return [
|
|
10148
10411
|
token.id,
|
|
@@ -10159,12 +10422,12 @@ async function runSignalTokenCreate(env, runId, options) {
|
|
|
10159
10422
|
const signalName = requireText(options.signal, "--signal");
|
|
10160
10423
|
const ttlMs = parseMs(options.ttl, "--ttl");
|
|
10161
10424
|
if (ttlMs !== undefined && ttlMs % 1000 !== 0) {
|
|
10162
|
-
throw new
|
|
10425
|
+
throw new CliUserError50("--ttl is counted in whole seconds.");
|
|
10163
10426
|
}
|
|
10164
10427
|
const ipAllowlist = parseList(options.allowIp);
|
|
10165
10428
|
for (const entry of ipAllowlist) {
|
|
10166
10429
|
if (!IPV4_OR_CIDR.test(entry)) {
|
|
10167
|
-
throw new
|
|
10430
|
+
throw new CliUserError50(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
|
|
10168
10431
|
}
|
|
10169
10432
|
}
|
|
10170
10433
|
const created = await env.pc.createSignalToken({
|
|
@@ -10200,7 +10463,7 @@ var init_signal_tokens = __esm(() => {
|
|
|
10200
10463
|
});
|
|
10201
10464
|
|
|
10202
10465
|
// src/phase-c/commands/search-attributes.ts
|
|
10203
|
-
import { CliUserError as
|
|
10466
|
+
import { CliUserError as CliUserError51 } from "@burdenoff/cli-sdk/core";
|
|
10204
10467
|
function row2(attribute) {
|
|
10205
10468
|
return [
|
|
10206
10469
|
attribute.name,
|
|
@@ -10217,11 +10480,11 @@ async function runSearchAttributesList(env, options) {
|
|
|
10217
10480
|
}
|
|
10218
10481
|
async function runSearchAttributesCreate(env, name, options) {
|
|
10219
10482
|
if (!NAME.test(name)) {
|
|
10220
|
-
throw new
|
|
10483
|
+
throw new CliUserError51(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
|
|
10221
10484
|
}
|
|
10222
10485
|
const type = parseEnumOption(options.type, "--type", SEARCH_ATTRIBUTE_TYPES);
|
|
10223
10486
|
if (type === undefined) {
|
|
10224
|
-
throw new
|
|
10487
|
+
throw new CliUserError51(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
|
|
10225
10488
|
}
|
|
10226
10489
|
const attribute = await env.pc.createSearchAttribute({
|
|
10227
10490
|
name,
|
|
@@ -10234,7 +10497,7 @@ async function runSearchAttributesCreate(env, name, options) {
|
|
|
10234
10497
|
async function runSearchAttributesDelete(env, name, options) {
|
|
10235
10498
|
const attribute = (await env.pc.searchAttributes()).find((entry) => entry.name === name);
|
|
10236
10499
|
if (!attribute) {
|
|
10237
|
-
throw new
|
|
10500
|
+
throw new CliUserError51(`The workspace has no search attribute ${name}.`, {
|
|
10238
10501
|
hint: "List them with `fluidgrids search-attributes list`."
|
|
10239
10502
|
});
|
|
10240
10503
|
}
|
|
@@ -10262,12 +10525,12 @@ var init_search_attributes = __esm(() => {
|
|
|
10262
10525
|
});
|
|
10263
10526
|
|
|
10264
10527
|
// src/phase-c/commands/schedules.ts
|
|
10265
|
-
import { CliUserError as
|
|
10266
|
-
function
|
|
10528
|
+
import { CliUserError as CliUserError52 } from "@burdenoff/cli-sdk/core";
|
|
10529
|
+
function isRecord21(value) {
|
|
10267
10530
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10268
10531
|
}
|
|
10269
10532
|
function triggerNodeOf(job) {
|
|
10270
|
-
if (
|
|
10533
|
+
if (isRecord21(job.config) && typeof job.config["triggerNodeId"] === "string") {
|
|
10271
10534
|
return job.config["triggerNodeId"];
|
|
10272
10535
|
}
|
|
10273
10536
|
const prefix = `${job.workflowKey}:`;
|
|
@@ -10387,9 +10650,9 @@ async function runSchedulesBackfill(env, workflowKey, triggerNodeId, options) {
|
|
|
10387
10650
|
const from = parseInstant(requireText(options.from, "--from"), "--from") ?? "";
|
|
10388
10651
|
const to = parseInstant(requireText(options.to, "--to"), "--to") ?? "";
|
|
10389
10652
|
if (from >= to)
|
|
10390
|
-
throw new
|
|
10653
|
+
throw new CliUserError52("--from must be before --to.");
|
|
10391
10654
|
if (Date.parse(to) > Date.now())
|
|
10392
|
-
throw new
|
|
10655
|
+
throw new CliUserError52("--to must be in the past.");
|
|
10393
10656
|
await requireConfirmation(env, `Backfill ${workflowKey} ${triggerNodeId} from ${from} to ${to}? Each fire time starts a run (at most ${MAX_BACKFILL_FIRES}) and counts toward the monthly runs.`, options.force);
|
|
10394
10657
|
const overlapPolicy = parseOverlap(options.overlapPolicy);
|
|
10395
10658
|
const result = await env.pc.backfillSchedule({
|
|
@@ -10439,9 +10702,9 @@ var init_schedules = __esm(() => {
|
|
|
10439
10702
|
// src/cli.ts
|
|
10440
10703
|
init_json_contract();
|
|
10441
10704
|
import { readFileSync as readFileSync13 } from "fs";
|
|
10442
|
-
import { join as
|
|
10705
|
+
import { join as join13, dirname as dirname7 } from "path";
|
|
10443
10706
|
import { fileURLToPath } from "url";
|
|
10444
|
-
import { CliUserError as
|
|
10707
|
+
import { CliUserError as CliUserError53, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
|
|
10445
10708
|
|
|
10446
10709
|
// src/output/run-envelope.ts
|
|
10447
10710
|
init_json_contract();
|
|
@@ -10870,7 +11133,7 @@ import healthModule from "@burdenoff/cli-sdk/modules/health";
|
|
|
10870
11133
|
|
|
10871
11134
|
// src/code-first/register.ts
|
|
10872
11135
|
init_shared();
|
|
10873
|
-
import { CliUserError as
|
|
11136
|
+
import { CliUserError as CliUserError38 } from "@burdenoff/cli-sdk/core";
|
|
10874
11137
|
var PROJECT_OPTION = [
|
|
10875
11138
|
"--project <dir>",
|
|
10876
11139
|
"Project directory (default: nearest fluidgrids.config.json)"
|
|
@@ -10928,7 +11191,7 @@ function registerImport(program, env) {
|
|
|
10928
11191
|
return;
|
|
10929
11192
|
}
|
|
10930
11193
|
if (resolved.preview) {
|
|
10931
|
-
throw new
|
|
11194
|
+
throw new CliUserError38("--preview needs --from <tool>.");
|
|
10932
11195
|
}
|
|
10933
11196
|
await Promise.resolve().then(() => init_import());
|
|
10934
11197
|
await runImport(env, file, resolved);
|
|
@@ -11006,7 +11269,7 @@ function registerDurable(program, env) {
|
|
|
11006
11269
|
});
|
|
11007
11270
|
addHistory(program, env, "history");
|
|
11008
11271
|
addSignal(program, env, "signal");
|
|
11009
|
-
program.command("replay <history>").description("Replay a history file
|
|
11272
|
+
program.command("replay <history>").description("Replay a history file, a run archive's history.jsonl.gz or a run id against the local code; fails on non-determinism").option("--isolate", "Replay in the QuickJS isolate the managed workers use").option("--debug", "Print the full task result (commands, logs, stack)").option("--trace", "Print every step: the command, the recorded event and the source line").option("--break-on-mismatch", "Stop in an attached debugger where the code diverges").option("--inspect [address]", "Re-run under node --inspect-brk (loopback host:port, default 127.0.0.1:9229); implies --break-on-mismatch").option("--remote-code", "Rebuild the run's exact code from its source archive instead of the local project").option(...PROJECT_OPTION).option(...OUTPUT_OPTION).action(async (history, options, command) => {
|
|
11010
11273
|
const resolved = withGlobalFormat(options, command);
|
|
11011
11274
|
if (resolved.trace || resolved.breakOnMismatch || resolved.inspect !== undefined || resolved.remoteCode) {
|
|
11012
11275
|
await Promise.resolve().then(() => init_replay_debug());
|
|
@@ -11514,10 +11777,10 @@ function createCli(options) {
|
|
|
11514
11777
|
|
|
11515
11778
|
// src/cli.ts
|
|
11516
11779
|
var __filename2 = fileURLToPath(import.meta.url);
|
|
11517
|
-
var __dirname2 =
|
|
11780
|
+
var __dirname2 = dirname7(__filename2);
|
|
11518
11781
|
var version = "0.0.0-dev";
|
|
11519
11782
|
try {
|
|
11520
|
-
const packageJson = JSON.parse(readFileSync13(
|
|
11783
|
+
const packageJson = JSON.parse(readFileSync13(join13(__dirname2, "../package.json"), "utf8"));
|
|
11521
11784
|
if (packageJson.version)
|
|
11522
11785
|
version = packageJson.version;
|
|
11523
11786
|
} catch {}
|
|
@@ -11536,7 +11799,7 @@ try {
|
|
|
11536
11799
|
}
|
|
11537
11800
|
} catch (error) {
|
|
11538
11801
|
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
11539
|
-
if (error instanceof
|
|
11802
|
+
if (error instanceof CliUserError53 && error.hint)
|
|
11540
11803
|
console.error(`ℹ ${error.hint}`);
|
|
11541
|
-
process.exitCode = error instanceof
|
|
11804
|
+
process.exitCode = error instanceof CliUserError53 ? error.exitCode : 1;
|
|
11542
11805
|
}
|