@fluidgrids/cli 2026.1114.2 → 2026.1115.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/dist/cli.js +467 -155
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1008,6 +1008,22 @@ var DURABLE_RUN_FIELDS2 = `
|
|
|
1008
1008
|
groupsTruncated
|
|
1009
1009
|
}
|
|
1010
1010
|
}
|
|
1011
|
+
`, CF_RUNS_COUNT_BY_ATTRIBUTE = `
|
|
1012
|
+
query FluidgridsCodeRunsCountByAttribute(
|
|
1013
|
+
$filter: ListWorkflowRunsInput
|
|
1014
|
+
$groupBy: [RunGroupBy!]
|
|
1015
|
+
$groupBySearchAttributes: [String!]
|
|
1016
|
+
) {
|
|
1017
|
+
workflowRunsCount(
|
|
1018
|
+
filter: $filter
|
|
1019
|
+
groupBy: $groupBy
|
|
1020
|
+
groupBySearchAttributes: $groupBySearchAttributes
|
|
1021
|
+
) {
|
|
1022
|
+
total
|
|
1023
|
+
groups { key values count }
|
|
1024
|
+
groupsTruncated
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1011
1027
|
`, CF_SIGNAL_RUN_BY_TARGET = `
|
|
1012
1028
|
mutation FluidgridsCodeSignalRunByTarget(
|
|
1013
1029
|
$target: RunTargetInput!
|
|
@@ -1187,6 +1203,51 @@ var init_test_suite_operations = __esm(() => {
|
|
|
1187
1203
|
`;
|
|
1188
1204
|
});
|
|
1189
1205
|
|
|
1206
|
+
// src/code-first/environment-operations.ts
|
|
1207
|
+
var PROMOTION_FIELDS = `
|
|
1208
|
+
id workflowKey version fromEnvironment toEnvironment status autoApplied note reviewNote
|
|
1209
|
+
requestedAt requestedById reviewedAt reviewedById appliedAt
|
|
1210
|
+
`, ENVIRONMENTS_FIELDS, CF_WORKFLOW_ENVIRONMENTS, CF_DEPLOY_WORKFLOW_VERSION_TO_DEV, CF_REQUEST_WORKFLOW_PROMOTION, CF_WORKFLOW_PROMOTION_REQUESTS;
|
|
1211
|
+
var init_environment_operations = __esm(() => {
|
|
1212
|
+
ENVIRONMENTS_FIELDS = `
|
|
1213
|
+
workflowKey
|
|
1214
|
+
environments {
|
|
1215
|
+
environment version workflowDefinitionId available deployedAt deployedById promotedFrom
|
|
1216
|
+
promotionRequestId outOfBand
|
|
1217
|
+
}
|
|
1218
|
+
pendingPromotions { ${PROMOTION_FIELDS} }
|
|
1219
|
+
policy { requireStagingApproval requireProdApproval allowSelfApproval lockDirectActivation }
|
|
1220
|
+
`;
|
|
1221
|
+
CF_WORKFLOW_ENVIRONMENTS = `
|
|
1222
|
+
query FluidgridsCodeWorkflowEnvironments($workflowKey: String!) {
|
|
1223
|
+
workflowEnvironments(workflowKey: $workflowKey) { ${ENVIRONMENTS_FIELDS} }
|
|
1224
|
+
}
|
|
1225
|
+
`;
|
|
1226
|
+
CF_DEPLOY_WORKFLOW_VERSION_TO_DEV = `
|
|
1227
|
+
mutation FluidgridsCodeDeployWorkflowVersionToDev($workflowKey: String!, $version: String!) {
|
|
1228
|
+
deployWorkflowVersionToDev(workflowKey: $workflowKey, version: $version) {
|
|
1229
|
+
${ENVIRONMENTS_FIELDS}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
`;
|
|
1233
|
+
CF_REQUEST_WORKFLOW_PROMOTION = `
|
|
1234
|
+
mutation FluidgridsCodeRequestWorkflowPromotion($input: RequestWorkflowPromotionInput!) {
|
|
1235
|
+
requestWorkflowPromotion(input: $input) { ${PROMOTION_FIELDS} }
|
|
1236
|
+
}
|
|
1237
|
+
`;
|
|
1238
|
+
CF_WORKFLOW_PROMOTION_REQUESTS = `
|
|
1239
|
+
query FluidgridsCodeWorkflowPromotionRequests(
|
|
1240
|
+
$workflowKey: String!
|
|
1241
|
+
$status: WorkflowPromotionStatus
|
|
1242
|
+
$limit: Int
|
|
1243
|
+
) {
|
|
1244
|
+
workflowPromotionRequests(workflowKey: $workflowKey, status: $status, limit: $limit) {
|
|
1245
|
+
${PROMOTION_FIELDS}
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
`;
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1190
1251
|
// src/code-first/api.ts
|
|
1191
1252
|
import { CliAuthError as CliAuthError3, CliUserError as CliUserError8 } from "@burdenoff/cli-sdk/core";
|
|
1192
1253
|
function isParityStart(input) {
|
|
@@ -1503,10 +1564,15 @@ function createCodeFirstApi(ctx) {
|
|
|
1503
1564
|
throw new CliUserError8(`Run ${runId} not found (NOT_FOUND)`);
|
|
1504
1565
|
return data.workflowRun;
|
|
1505
1566
|
},
|
|
1506
|
-
async countRuns(filter, groupBy) {
|
|
1507
|
-
const
|
|
1567
|
+
async countRuns(filter, groupBy, groupBySearchAttributes = []) {
|
|
1568
|
+
const columns = groupBy.length > 0 ? groupBy : null;
|
|
1569
|
+
const data = groupBySearchAttributes.length > 0 ? await request(CF_RUNS_COUNT_BY_ATTRIBUTE, {
|
|
1508
1570
|
filter,
|
|
1509
|
-
groupBy:
|
|
1571
|
+
groupBy: columns,
|
|
1572
|
+
groupBySearchAttributes
|
|
1573
|
+
}) : await request(CF_RUNS_COUNT, {
|
|
1574
|
+
filter,
|
|
1575
|
+
groupBy: columns
|
|
1510
1576
|
});
|
|
1511
1577
|
return data.workflowRunsCount;
|
|
1512
1578
|
},
|
|
@@ -1572,6 +1638,22 @@ function createCodeFirstApi(ctx) {
|
|
|
1572
1638
|
reason: reason ?? null
|
|
1573
1639
|
});
|
|
1574
1640
|
return data.setWorkflowRunVersioningOverride;
|
|
1641
|
+
},
|
|
1642
|
+
async workflowEnvironments(workflowKey) {
|
|
1643
|
+
const data = await request(CF_WORKFLOW_ENVIRONMENTS, { workflowKey });
|
|
1644
|
+
return data.workflowEnvironments;
|
|
1645
|
+
},
|
|
1646
|
+
async deployVersionToDev(workflowKey, version) {
|
|
1647
|
+
const data = await request(CF_DEPLOY_WORKFLOW_VERSION_TO_DEV, { workflowKey, version });
|
|
1648
|
+
return data.deployWorkflowVersionToDev;
|
|
1649
|
+
},
|
|
1650
|
+
async requestPromotion(workflowKey, toEnvironment, note) {
|
|
1651
|
+
const data = await request(CF_REQUEST_WORKFLOW_PROMOTION, { input: { workflowKey, toEnvironment, ...note !== undefined ? { note } : {} } });
|
|
1652
|
+
return data.requestWorkflowPromotion;
|
|
1653
|
+
},
|
|
1654
|
+
async promotionRequests(workflowKey, limit) {
|
|
1655
|
+
const data = await request(CF_WORKFLOW_PROMOTION_REQUESTS, { workflowKey, status: null, limit });
|
|
1656
|
+
return data.workflowPromotionRequests;
|
|
1575
1657
|
}
|
|
1576
1658
|
};
|
|
1577
1659
|
}
|
|
@@ -1583,6 +1665,7 @@ var init_api = __esm(() => {
|
|
|
1583
1665
|
init_durable_operations();
|
|
1584
1666
|
init_parity_operations();
|
|
1585
1667
|
init_test_suite_operations();
|
|
1668
|
+
init_environment_operations();
|
|
1586
1669
|
PARITY_START_FIELDS = [
|
|
1587
1670
|
"workflowId",
|
|
1588
1671
|
"idReusePolicy",
|
|
@@ -5340,6 +5423,17 @@ function parseGroupBy(raw) {
|
|
|
5340
5423
|
throw new CliUserError30("--group-by takes at most two columns.");
|
|
5341
5424
|
return distinct;
|
|
5342
5425
|
}
|
|
5426
|
+
function parseGroupByAttributes(raw, columns) {
|
|
5427
|
+
if (raw === undefined)
|
|
5428
|
+
return [];
|
|
5429
|
+
const names = [...new Set(raw.split(",").map((part) => part.trim()))].filter((name) => name !== "");
|
|
5430
|
+
if (names.length === 0)
|
|
5431
|
+
throw new CliUserError30("--group-by-attribute needs a search attribute name.");
|
|
5432
|
+
if (names.length + columns > 2) {
|
|
5433
|
+
throw new CliUserError30("--group-by and --group-by-attribute take at most two columns together.");
|
|
5434
|
+
}
|
|
5435
|
+
return names;
|
|
5436
|
+
}
|
|
5343
5437
|
function parseDuration(raw, flag) {
|
|
5344
5438
|
if (raw === undefined)
|
|
5345
5439
|
return;
|
|
@@ -5941,7 +6035,8 @@ async function runCount(env, options) {
|
|
|
5941
6035
|
if (memo)
|
|
5942
6036
|
filter.memo = memo;
|
|
5943
6037
|
const groupBy = parseGroupBy(options.groupBy);
|
|
5944
|
-
const
|
|
6038
|
+
const attributes = parseGroupByAttributes(options.groupByAttribute, groupBy.length);
|
|
6039
|
+
const counted = attributes.length > 0 ? await env.api.countRuns(filter, groupBy, attributes) : await env.api.countRuns(filter, groupBy);
|
|
5945
6040
|
const details = [`Total: ${counted.total}`];
|
|
5946
6041
|
if (counted.groupsTruncated)
|
|
5947
6042
|
details.push("More than 1000 groups: the smallest were left out.");
|
|
@@ -7040,6 +7135,214 @@ var init_versions = __esm(() => {
|
|
|
7040
7135
|
ENVIRONMENTS = ["PROD", "STAGING", "DEV"];
|
|
7041
7136
|
});
|
|
7042
7137
|
|
|
7138
|
+
// src/code-first/commands/deploy.ts
|
|
7139
|
+
import { CliUserError as CliUserError36 } from "@burdenoff/cli-sdk/core";
|
|
7140
|
+
function parseEnvironment(raw) {
|
|
7141
|
+
const value = raw?.trim().toUpperCase();
|
|
7142
|
+
const match = ENVIRONMENTS2.find((environment) => environment === value);
|
|
7143
|
+
if (match === undefined) {
|
|
7144
|
+
throw new CliUserError36(raw === undefined ? "deploy needs --env dev, staging or prod." : `Invalid value '${raw}' for --env. Allowed: dev, staging, prod`);
|
|
7145
|
+
}
|
|
7146
|
+
return match;
|
|
7147
|
+
}
|
|
7148
|
+
function parseRamp(raw) {
|
|
7149
|
+
if (raw === undefined)
|
|
7150
|
+
return;
|
|
7151
|
+
const trimmed = raw.trim();
|
|
7152
|
+
if (!/^\d{1,3}$/.test(trimmed) || Number(trimmed) > 100) {
|
|
7153
|
+
throw new CliUserError36(`Invalid value '${raw}' for --ramp: expected 0 to 100.`);
|
|
7154
|
+
}
|
|
7155
|
+
return Number(trimmed);
|
|
7156
|
+
}
|
|
7157
|
+
function stateOf(view, environment) {
|
|
7158
|
+
return view.environments.find((state) => state.environment === environment);
|
|
7159
|
+
}
|
|
7160
|
+
function holds(state, version) {
|
|
7161
|
+
return state !== undefined && state.available && state.version === version;
|
|
7162
|
+
}
|
|
7163
|
+
function promotionRows(promotion) {
|
|
7164
|
+
return [
|
|
7165
|
+
["Request", promotion.id],
|
|
7166
|
+
["From", promotion.fromEnvironment],
|
|
7167
|
+
["Status", promotion.status],
|
|
7168
|
+
["Requested", promotion.requestedAt],
|
|
7169
|
+
...promotion.reviewedAt ? [["Reviewed", promotion.reviewedAt]] : [],
|
|
7170
|
+
...promotion.reviewNote ? [["Review note", promotion.reviewNote]] : []
|
|
7171
|
+
];
|
|
7172
|
+
}
|
|
7173
|
+
function notice(env, options, level, message) {
|
|
7174
|
+
const { output } = env.ctx;
|
|
7175
|
+
if (output.getFormat(options) !== "table") {
|
|
7176
|
+
console.error(message);
|
|
7177
|
+
} else if (level === "warning") {
|
|
7178
|
+
output.printWarning(message);
|
|
7179
|
+
} else {
|
|
7180
|
+
output.printInfo(message);
|
|
7181
|
+
}
|
|
7182
|
+
}
|
|
7183
|
+
function report(env, options, result, details) {
|
|
7184
|
+
const rows = [
|
|
7185
|
+
["Workflow", result.workflowKey],
|
|
7186
|
+
["Environment", result.environment],
|
|
7187
|
+
["Version", result.version],
|
|
7188
|
+
["Result", result.action],
|
|
7189
|
+
...result.promotion ? promotionRows(result.promotion) : [],
|
|
7190
|
+
...result.rollout ? [
|
|
7191
|
+
["Rollout", `${result.rollout.fromVersion} -> ${result.rollout.toVersion}`],
|
|
7192
|
+
["Percent", `${result.rollout.percent}%`],
|
|
7193
|
+
["Verified", `${result.rollout.verifiedPercent}%`]
|
|
7194
|
+
] : []
|
|
7195
|
+
];
|
|
7196
|
+
emit(env, options, result, { headers: ["Field", "Value"], rows }, details);
|
|
7197
|
+
return result;
|
|
7198
|
+
}
|
|
7199
|
+
async function runDeploy(env, workflowKey, options) {
|
|
7200
|
+
const environment = parseEnvironment(options.env);
|
|
7201
|
+
const ramp = parseRamp(options.ramp);
|
|
7202
|
+
if (ramp !== undefined && environment !== "PROD") {
|
|
7203
|
+
throw new CliUserError36("--ramp applies to --env prod only (rollouts split PROD starts).");
|
|
7204
|
+
}
|
|
7205
|
+
if (options.note !== undefined && environment === "DEV") {
|
|
7206
|
+
throw new CliUserError36("--note is for promotion requests (--env staging or prod).");
|
|
7207
|
+
}
|
|
7208
|
+
const timeoutMs = parsePositiveInt(options.timeout, "--timeout") ?? DEFAULT_DEPLOY_TIMEOUT_MS;
|
|
7209
|
+
const intervalMs = parsePositiveInt(options.pollInterval, "--poll-interval") ?? DEFAULT_DEPLOY_POLL_INTERVAL_MS;
|
|
7210
|
+
if (environment === "DEV")
|
|
7211
|
+
return deployToDev(env, workflowKey, options);
|
|
7212
|
+
return promote(env, workflowKey, environment, {
|
|
7213
|
+
...options,
|
|
7214
|
+
ramp,
|
|
7215
|
+
timeoutMs,
|
|
7216
|
+
intervalMs
|
|
7217
|
+
});
|
|
7218
|
+
}
|
|
7219
|
+
async function deployToDev(env, workflowKey, options) {
|
|
7220
|
+
const wanted = options.wfVersion ?? "latest";
|
|
7221
|
+
const versions = await env.api.workflowVersions(workflowKey);
|
|
7222
|
+
const picked = pickVersion(versions, wanted);
|
|
7223
|
+
if (!picked) {
|
|
7224
|
+
throw new CliUserError36(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
|
+
}
|
|
7226
|
+
const before = await env.api.workflowEnvironments(workflowKey);
|
|
7227
|
+
const base = { workflowKey, environment: "DEV", version: picked.version };
|
|
7228
|
+
const next = `Promote it with: fluidgrids deploy ${workflowKey} --env staging`;
|
|
7229
|
+
if (holds(stateOf(before, "DEV"), picked.version)) {
|
|
7230
|
+
return report(env, options, { ...base, action: "UNCHANGED", promotion: null, rollout: null }, [
|
|
7231
|
+
`DEV already runs ${picked.version} of ${workflowKey}; nothing changed.`,
|
|
7232
|
+
next
|
|
7233
|
+
]);
|
|
7234
|
+
}
|
|
7235
|
+
await env.api.deployVersionToDev(workflowKey, picked.version);
|
|
7236
|
+
return report(env, options, { ...base, action: "DEPLOYED", promotion: null, rollout: null }, [
|
|
7237
|
+
`${picked.version} of ${workflowKey} is deployed to DEV.`,
|
|
7238
|
+
next
|
|
7239
|
+
]);
|
|
7240
|
+
}
|
|
7241
|
+
async function promote(env, workflowKey, target, options) {
|
|
7242
|
+
const sourceName = PROMOTION_SOURCE[target];
|
|
7243
|
+
const view = await env.api.workflowEnvironments(workflowKey);
|
|
7244
|
+
const source = stateOf(view, sourceName);
|
|
7245
|
+
if (!source?.version) {
|
|
7246
|
+
throw new CliUserError36(`Nothing is deployed to ${sourceName} for ${workflowKey}.`, {
|
|
7247
|
+
hint: `Deploy there first: fluidgrids deploy ${workflowKey} --env ${sourceName.toLowerCase()}${sourceName === "DEV" ? " --wf-version <version>" : ""}`
|
|
7248
|
+
});
|
|
7249
|
+
}
|
|
7250
|
+
if (!source.available) {
|
|
7251
|
+
throw new CliUserError36(`${sourceName} holds ${source.version} of ${workflowKey}, which has since been deleted.`, { hint: `Deploy another version to ${sourceName} first.` });
|
|
7252
|
+
}
|
|
7253
|
+
if (options.wfVersion !== undefined && options.wfVersion !== source.version) {
|
|
7254
|
+
throw new CliUserError36(`${sourceName} holds ${source.version} of ${workflowKey}, not ${options.wfVersion}; ${target} is promoted from ${sourceName}.`, {
|
|
7255
|
+
hint: `Deploy ${options.wfVersion} to ${sourceName} first: fluidgrids deploy ${workflowKey} --env ${sourceName.toLowerCase()} --wf-version ${options.wfVersion}`
|
|
7256
|
+
});
|
|
7257
|
+
}
|
|
7258
|
+
const version = source.version;
|
|
7259
|
+
const base = { workflowKey, environment: target, version };
|
|
7260
|
+
if (holds(stateOf(view, target), version)) {
|
|
7261
|
+
return report(env, options, { ...base, action: "UNCHANGED", promotion: null, rollout: null }, [
|
|
7262
|
+
`${target} already runs ${version} of ${workflowKey}; nothing changed.`
|
|
7263
|
+
]);
|
|
7264
|
+
}
|
|
7265
|
+
if (options.ramp !== undefined && options.ramp < 100) {
|
|
7266
|
+
if (view.policy.lockDirectActivation) {
|
|
7267
|
+
throw new CliUserError36(`The workspace locks PROD to approved promotions, so ${workflowKey} cannot be ramped.`, { hint: `Promote it in full instead: fluidgrids deploy ${workflowKey} --env prod` });
|
|
7268
|
+
}
|
|
7269
|
+
const rollout = await env.api.setWorkflowRollout(workflowKey, {
|
|
7270
|
+
toVersion: version,
|
|
7271
|
+
percent: options.ramp,
|
|
7272
|
+
environment: "PROD"
|
|
7273
|
+
});
|
|
7274
|
+
const check = rollout.activationCheck;
|
|
7275
|
+
return report(env, options, { ...base, action: "RAMPED", promotion: null, rollout }, [
|
|
7276
|
+
`${rollout.percent}% of new automatic starts of ${workflowKey} run ${version}; the rest run ${rollout.fromVersion}.`,
|
|
7277
|
+
...check && check.status !== "REPLACED" && check.status !== "REJECTED" ? [
|
|
7278
|
+
`Open auto-upgrade runs move only after replay check ${check.id} (${check.status}) passes.`
|
|
7279
|
+
] : [],
|
|
7280
|
+
`Finish with: fluidgrids deploy ${workflowKey} --env prod --ramp 100`
|
|
7281
|
+
]);
|
|
7282
|
+
}
|
|
7283
|
+
const pending = view.pendingPromotions.find((request) => request.toEnvironment === target);
|
|
7284
|
+
if (pending && pending.version !== version) {
|
|
7285
|
+
throw new CliUserError36(`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
|
+
}
|
|
7287
|
+
if (pending && options.note !== undefined) {
|
|
7288
|
+
notice(env, options, "warning", `Request ${pending.id} for ${version} is already open; --note was not added to it.`);
|
|
7289
|
+
}
|
|
7290
|
+
let promotion = pending ?? await env.api.requestPromotion(workflowKey, target, options.note);
|
|
7291
|
+
if (promotion.status === "PENDING" && options.wait !== false) {
|
|
7292
|
+
notice(env, options, "info", `Promotion ${promotion.id} of ${version} to ${target} waits for an approver (Environments panel of the workflow).`);
|
|
7293
|
+
promotion = await waitForPromotion(env, promotion, options);
|
|
7294
|
+
}
|
|
7295
|
+
return finish(env, options, base, promotion);
|
|
7296
|
+
}
|
|
7297
|
+
function finish(env, options, base, promotion) {
|
|
7298
|
+
const { workflowKey, environment, version } = base;
|
|
7299
|
+
switch (promotion.status) {
|
|
7300
|
+
case "APPLIED":
|
|
7301
|
+
return report(env, options, { ...base, action: "APPLIED", promotion, rollout: null }, [
|
|
7302
|
+
`${version} of ${workflowKey} is deployed to ${environment}${promotion.autoApplied ? " (no approval was required)" : ""}.`,
|
|
7303
|
+
...environment === "PROD" ? [] : [`Next: fluidgrids deploy ${workflowKey} --env prod`]
|
|
7304
|
+
]);
|
|
7305
|
+
case "PENDING":
|
|
7306
|
+
return report(env, options, { ...base, action: "PENDING", promotion, rollout: null }, [
|
|
7307
|
+
`Promotion ${promotion.id} waits for an approver. Run the same command to wait for it.`
|
|
7308
|
+
]);
|
|
7309
|
+
case "REJECTED":
|
|
7310
|
+
case "CANCELED":
|
|
7311
|
+
throw new CliUserError36(`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
|
+
}
|
|
7313
|
+
}
|
|
7314
|
+
async function waitForPromotion(env, promotion, options) {
|
|
7315
|
+
const deadline = Date.now() + options.timeoutMs;
|
|
7316
|
+
let slept = 0;
|
|
7317
|
+
let current = promotion;
|
|
7318
|
+
while (current.status === "PENDING") {
|
|
7319
|
+
if (slept >= options.timeoutMs || Date.now() >= deadline) {
|
|
7320
|
+
throw new CliUserError36(`Promotion ${current.id} of ${current.version} to ${current.toEnvironment} still waits for an approver after ${Math.round(options.timeoutMs / 1000)} s.`, {
|
|
7321
|
+
hint: "The request stays open; run the same command again to keep waiting, or pass --no-wait."
|
|
7322
|
+
});
|
|
7323
|
+
}
|
|
7324
|
+
await env.sleep(options.intervalMs);
|
|
7325
|
+
slept += options.intervalMs;
|
|
7326
|
+
const history = await env.api.promotionRequests(current.workflowKey, PROMOTION_HISTORY_LIMIT);
|
|
7327
|
+
const found = history.find((request) => request.id === current.id);
|
|
7328
|
+
if (!found) {
|
|
7329
|
+
throw new CliUserError36(`Promotion ${current.id} is no longer in the promotion history of ${current.workflowKey}.`);
|
|
7330
|
+
}
|
|
7331
|
+
current = found;
|
|
7332
|
+
}
|
|
7333
|
+
return current;
|
|
7334
|
+
}
|
|
7335
|
+
var DEFAULT_DEPLOY_TIMEOUT_MS = 900000, DEFAULT_DEPLOY_POLL_INTERVAL_MS = 5000, PROMOTION_HISTORY_LIMIT = 200, ENVIRONMENTS2, PROMOTION_SOURCE;
|
|
7336
|
+
var init_deploy = __esm(() => {
|
|
7337
|
+
init_remote();
|
|
7338
|
+
init_shared();
|
|
7339
|
+
ENVIRONMENTS2 = ["DEV", "STAGING", "PROD"];
|
|
7340
|
+
PROMOTION_SOURCE = {
|
|
7341
|
+
STAGING: "DEV",
|
|
7342
|
+
PROD: "STAGING"
|
|
7343
|
+
};
|
|
7344
|
+
});
|
|
7345
|
+
|
|
7043
7346
|
// src/phase-c/operations.ts
|
|
7044
7347
|
function hierarchyChildren(depth) {
|
|
7045
7348
|
if (depth === 0)
|
|
@@ -7544,7 +7847,7 @@ var init_operations3 = __esm(() => {
|
|
|
7544
7847
|
});
|
|
7545
7848
|
|
|
7546
7849
|
// src/phase-c/api.ts
|
|
7547
|
-
import { CliAuthError as CliAuthError6, CliUserError as
|
|
7850
|
+
import { CliAuthError as CliAuthError6, CliUserError as CliUserError38 } from "@burdenoff/cli-sdk/core";
|
|
7548
7851
|
function runVariables(run) {
|
|
7549
7852
|
return run.runId !== undefined ? { runId: run.runId } : { target: run.target };
|
|
7550
7853
|
}
|
|
@@ -7564,7 +7867,7 @@ function createPhaseCApi(ctx) {
|
|
|
7564
7867
|
function context() {
|
|
7565
7868
|
const workspaceId = ctx.auth.read()?.workspaceId;
|
|
7566
7869
|
if (!workspaceId) {
|
|
7567
|
-
throw new
|
|
7870
|
+
throw new CliUserError38("No workspace is selected.", {
|
|
7568
7871
|
hint: `Run \`${ctx.productName} workspace set <id>\` or set FLUIDGRIDS_WORKSPACE_ID.`
|
|
7569
7872
|
});
|
|
7570
7873
|
}
|
|
@@ -7697,7 +8000,7 @@ function createPhaseCApi(ctx) {
|
|
|
7697
8000
|
});
|
|
7698
8001
|
const found = data.workflowRunByWorkflowId;
|
|
7699
8002
|
if (!found) {
|
|
7700
|
-
throw new
|
|
8003
|
+
throw new CliUserError38(`No run with workflow id ${run.target.workflowId} of ${run.target.workflowKey} (NOT_FOUND)`);
|
|
7701
8004
|
}
|
|
7702
8005
|
return found.id;
|
|
7703
8006
|
},
|
|
@@ -7832,7 +8135,7 @@ function createPhaseCApi(ctx) {
|
|
|
7832
8135
|
if (!pagination?.hasMore || jobs.length === 0)
|
|
7833
8136
|
return all;
|
|
7834
8137
|
}
|
|
7835
|
-
throw new
|
|
8138
|
+
throw new CliUserError38(`The schedule listing did not end after ${MAX_SCHEDULE_PAGES} pages; refusing to continue.`);
|
|
7836
8139
|
},
|
|
7837
8140
|
async describeSchedule(workflowKey, triggerNodeId) {
|
|
7838
8141
|
const data = await request(PC_SCHEDULE_DESCRIBE, { workflowKey, triggerNodeId }, P);
|
|
@@ -7866,17 +8169,17 @@ var init_api3 = __esm(() => {
|
|
|
7866
8169
|
});
|
|
7867
8170
|
|
|
7868
8171
|
// src/phase-c/commands/queues.ts
|
|
7869
|
-
import { CliUserError as
|
|
7870
|
-
function
|
|
7871
|
-
return parseEnumOption(raw, "--environment",
|
|
8172
|
+
import { CliUserError as CliUserError39 } from "@burdenoff/cli-sdk/core";
|
|
8173
|
+
function parseEnvironment2(raw) {
|
|
8174
|
+
return parseEnumOption(raw, "--environment", ENVIRONMENTS3);
|
|
7872
8175
|
}
|
|
7873
8176
|
function checkQueueName(name) {
|
|
7874
8177
|
const value = name.trim();
|
|
7875
8178
|
if (value === "managed") {
|
|
7876
|
-
throw new
|
|
8179
|
+
throw new CliUserError39("`managed` is the platform queue; it cannot be created or changed.");
|
|
7877
8180
|
}
|
|
7878
8181
|
if (!QUEUE_NAME.test(value)) {
|
|
7879
|
-
throw new
|
|
8182
|
+
throw new CliUserError39(`Invalid queue name '${name}': lower-case letters, digits and dashes, at most 63, starting with a letter or digit.`);
|
|
7880
8183
|
}
|
|
7881
8184
|
return value;
|
|
7882
8185
|
}
|
|
@@ -7887,13 +8190,13 @@ function checkWorkerQueue(raw) {
|
|
|
7887
8190
|
return checkQueueName(value);
|
|
7888
8191
|
const name = checkQueueName(value.slice(0, at));
|
|
7889
8192
|
const environment = value.slice(at + 1).toLowerCase();
|
|
7890
|
-
if (!
|
|
7891
|
-
throw new
|
|
8193
|
+
if (!ENVIRONMENTS3.some((allowed) => allowed.toLowerCase() === environment)) {
|
|
8194
|
+
throw new CliUserError39(`Invalid queue '${raw}': the environment after @ must be dev, staging or prod.`);
|
|
7892
8195
|
}
|
|
7893
8196
|
return `${name}@${environment}`;
|
|
7894
8197
|
}
|
|
7895
8198
|
function bindWorkerQueues(queues, raw) {
|
|
7896
|
-
const environment =
|
|
8199
|
+
const environment = parseEnvironment2(raw)?.toLowerCase();
|
|
7897
8200
|
if (environment === undefined)
|
|
7898
8201
|
return [...new Set(queues)];
|
|
7899
8202
|
const out = queues.map((queue) => {
|
|
@@ -7901,7 +8204,7 @@ function bindWorkerQueues(queues, raw) {
|
|
|
7901
8204
|
if (at < 0)
|
|
7902
8205
|
return `${queue}@${environment}`;
|
|
7903
8206
|
if (queue.slice(at + 1) !== environment) {
|
|
7904
|
-
throw new
|
|
8207
|
+
throw new CliUserError39(`Queue '${queue}' is bound to ${queue.slice(at + 1)}, but --environment is ${environment}.`);
|
|
7905
8208
|
}
|
|
7906
8209
|
return queue;
|
|
7907
8210
|
});
|
|
@@ -7917,11 +8220,11 @@ async function findQueue(env, name, environment) {
|
|
|
7917
8220
|
if (found)
|
|
7918
8221
|
return found;
|
|
7919
8222
|
if (environment === undefined && rows.length > 0) {
|
|
7920
|
-
throw new
|
|
8223
|
+
throw new CliUserError39(`Queue ${name} has only environment-scoped rows.`, {
|
|
7921
8224
|
hint: `Pass --environment (one of ${rows.map((queue) => queue.environment ?? "-").join(", ")}).`
|
|
7922
8225
|
});
|
|
7923
8226
|
}
|
|
7924
|
-
throw new
|
|
8227
|
+
throw new CliUserError39(`The workspace has no task queue ${environment ? `${name}@${environment}` : name}.`, { hint: "List them with `fluidgrids queues list`." });
|
|
7925
8228
|
}
|
|
7926
8229
|
async function runQueuesList(env, options) {
|
|
7927
8230
|
const queues = await env.pc.taskQueues();
|
|
@@ -7939,7 +8242,7 @@ async function runQueuesList(env, options) {
|
|
|
7939
8242
|
return queues;
|
|
7940
8243
|
}
|
|
7941
8244
|
async function runQueuesDescribe(env, name, options) {
|
|
7942
|
-
const environment =
|
|
8245
|
+
const environment = parseEnvironment2(options.environment);
|
|
7943
8246
|
const stats = await env.pc.taskQueueStats(name, environment);
|
|
7944
8247
|
const workers = name === "managed" ? [] : await env.pc.taskQueueWorkers(name);
|
|
7945
8248
|
const result = { stats, workers };
|
|
@@ -7962,7 +8265,7 @@ async function runQueuesDescribe(env, name, options) {
|
|
|
7962
8265
|
return result;
|
|
7963
8266
|
}
|
|
7964
8267
|
async function runQueuesCreate(env, name, options) {
|
|
7965
|
-
const environment =
|
|
8268
|
+
const environment = parseEnvironment2(options.environment);
|
|
7966
8269
|
const maxTasksPerSecond = parseNumberOption(options.maxTasksPerSecond, "--max-tasks-per-second");
|
|
7967
8270
|
const timeout = parseNonNegativeInt(options.workerUnavailableTimeout, "--worker-unavailable-timeout");
|
|
7968
8271
|
const queue = await env.pc.createTaskQueue({
|
|
@@ -7979,10 +8282,10 @@ async function runQueuesCreate(env, name, options) {
|
|
|
7979
8282
|
return queue;
|
|
7980
8283
|
}
|
|
7981
8284
|
async function runQueuesUpdate(env, name, options) {
|
|
7982
|
-
const environment =
|
|
8285
|
+
const environment = parseEnvironment2(options.environment);
|
|
7983
8286
|
const maxTasksPerSecond = parseNumberOption(options.maxTasksPerSecond, "--max-tasks-per-second");
|
|
7984
8287
|
if (maxTasksPerSecond !== undefined && options.clearMaxTasksPerSecond) {
|
|
7985
|
-
throw new
|
|
8288
|
+
throw new CliUserError39("Give --max-tasks-per-second or --clear-max-tasks-per-second, not both.");
|
|
7986
8289
|
}
|
|
7987
8290
|
const timeout = parseNonNegativeInt(options.workerUnavailableTimeout, "--worker-unavailable-timeout");
|
|
7988
8291
|
const input = {
|
|
@@ -7992,7 +8295,7 @@ async function runQueuesUpdate(env, name, options) {
|
|
|
7992
8295
|
...timeout !== undefined ? { workerUnavailableTimeoutSeconds: timeout } : {}
|
|
7993
8296
|
};
|
|
7994
8297
|
if (Object.keys(input).length === 0) {
|
|
7995
|
-
throw new
|
|
8298
|
+
throw new CliUserError39("Nothing to change.", {
|
|
7996
8299
|
hint: "Give --description, --max-tasks-per-second, --clear-max-tasks-per-second or --worker-unavailable-timeout."
|
|
7997
8300
|
});
|
|
7998
8301
|
}
|
|
@@ -8012,7 +8315,7 @@ async function runQueuesUpdate(env, name, options) {
|
|
|
8012
8315
|
return updated;
|
|
8013
8316
|
}
|
|
8014
8317
|
async function runQueuesDelete(env, name, options) {
|
|
8015
|
-
const environment =
|
|
8318
|
+
const environment = parseEnvironment2(options.environment);
|
|
8016
8319
|
const queue = await findQueue(env, checkQueueName(name), environment);
|
|
8017
8320
|
await requireConfirmation(env, `Delete task queue ${queueLabel(queue)}?`, options.force);
|
|
8018
8321
|
const deleted = await env.pc.deleteTaskQueue(queue.id);
|
|
@@ -8050,11 +8353,11 @@ async function runQueuesBuilds(env, name, options) {
|
|
|
8050
8353
|
}, rows.length === 0 ? [`No worker serving ${name} reported a build id.`] : []);
|
|
8051
8354
|
return rows;
|
|
8052
8355
|
}
|
|
8053
|
-
var
|
|
8356
|
+
var ENVIRONMENTS3, QUEUE_NAME;
|
|
8054
8357
|
var init_queues = __esm(() => {
|
|
8055
8358
|
init_shared();
|
|
8056
8359
|
init_shared3();
|
|
8057
|
-
|
|
8360
|
+
ENVIRONMENTS3 = ["DEV", "STAGING", "PROD"];
|
|
8058
8361
|
QUEUE_NAME = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
8059
8362
|
});
|
|
8060
8363
|
|
|
@@ -8071,7 +8374,7 @@ import { existsSync as existsSync13 } from "fs";
|
|
|
8071
8374
|
import { hostname } from "os";
|
|
8072
8375
|
import { extname as extname3, isAbsolute as isAbsolute3, join as join11, resolve as resolve11 } from "path";
|
|
8073
8376
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
8074
|
-
import { CliUserError as
|
|
8377
|
+
import { CliUserError as CliUserError40 } from "@burdenoff/cli-sdk/core";
|
|
8075
8378
|
function isRecord18(value) {
|
|
8076
8379
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8077
8380
|
}
|
|
@@ -8082,11 +8385,11 @@ function bridgeUrlFor(env, explicit, issued) {
|
|
|
8082
8385
|
try {
|
|
8083
8386
|
url = new URL(raw);
|
|
8084
8387
|
} catch {
|
|
8085
|
-
throw new
|
|
8388
|
+
throw new CliUserError40(`Invalid bridge URL '${raw}'.`);
|
|
8086
8389
|
}
|
|
8087
8390
|
const local = url.hostname === "localhost" || url.hostname === "127.0.0.1";
|
|
8088
8391
|
if (url.protocol !== "wss:" && !(url.protocol === "ws:" && local)) {
|
|
8089
|
-
throw new
|
|
8392
|
+
throw new CliUserError40(`The bridge URL must be wss:// (ws:// only to this machine): ${raw}`);
|
|
8090
8393
|
}
|
|
8091
8394
|
return url.toString();
|
|
8092
8395
|
}
|
|
@@ -8102,18 +8405,18 @@ function bridgeHeaders(env) {
|
|
|
8102
8405
|
const id = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_ID")?.trim();
|
|
8103
8406
|
const secret = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET")?.trim();
|
|
8104
8407
|
if ((id === undefined || id === "") !== (secret === undefined || secret === "")) {
|
|
8105
|
-
throw new
|
|
8408
|
+
throw new CliUserError40("Set both FLUIDGRIDS_CF_ACCESS_CLIENT_ID and FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET, or neither.");
|
|
8106
8409
|
}
|
|
8107
8410
|
return id && secret ? { "CF-Access-Client-Id": id, "CF-Access-Client-Secret": secret } : {};
|
|
8108
8411
|
}
|
|
8109
8412
|
function workerToken(env, tokenEnv) {
|
|
8110
8413
|
const variable = tokenEnv?.trim() || WORKER_TOKEN_ENV;
|
|
8111
8414
|
if (!ENV_NAME2.test(variable)) {
|
|
8112
|
-
throw new
|
|
8415
|
+
throw new CliUserError40("Invalid environment variable name for --token-env.");
|
|
8113
8416
|
}
|
|
8114
8417
|
const token = env.getEnv(variable)?.trim() ?? "";
|
|
8115
8418
|
if (!WORKER_TOKEN.test(token)) {
|
|
8116
|
-
throw new
|
|
8419
|
+
throw new CliUserError40(`${variable} must hold a worker token (fgr_ and 43 characters).`, {
|
|
8117
8420
|
hint: "Issue one with `fluidgrids workers tokens create <name> --queue <queue>`."
|
|
8118
8421
|
});
|
|
8119
8422
|
}
|
|
@@ -8126,7 +8429,7 @@ async function buildWorkerBundle(project) {
|
|
|
8126
8429
|
explainUnresolved: (names) => [...names]
|
|
8127
8430
|
});
|
|
8128
8431
|
if (!lowered.workflows.some((workflow) => workflow.durable)) {
|
|
8129
|
-
throw new
|
|
8432
|
+
throw new CliUserError40("The project defines no durable functions for a worker to serve.");
|
|
8130
8433
|
}
|
|
8131
8434
|
await prepareProjectBundle(project, lowered);
|
|
8132
8435
|
return bundlePathOf(project);
|
|
@@ -8140,23 +8443,23 @@ function activitiesFor(project, raw) {
|
|
|
8140
8443
|
return;
|
|
8141
8444
|
const value = raw.trim();
|
|
8142
8445
|
if (value === "")
|
|
8143
|
-
throw new
|
|
8446
|
+
throw new CliUserError40("--activities cannot be empty.");
|
|
8144
8447
|
if (project.config.language === "py") {
|
|
8145
8448
|
if (!/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(value)) {
|
|
8146
|
-
throw new
|
|
8449
|
+
throw new CliUserError40(`--activities for a Python project is a module name importable from the project (for example activities), not '${raw}'.`);
|
|
8147
8450
|
}
|
|
8148
8451
|
return value;
|
|
8149
8452
|
}
|
|
8150
8453
|
const path = isAbsolute3(value) ? value : resolve11(project.root, value);
|
|
8151
8454
|
if (!existsSync13(path))
|
|
8152
|
-
throw new
|
|
8455
|
+
throw new CliUserError40(`--activities: ${raw} not found.`);
|
|
8153
8456
|
return path;
|
|
8154
8457
|
}
|
|
8155
8458
|
function launchOf(settings) {
|
|
8156
8459
|
const { project, options } = settings;
|
|
8157
8460
|
const activities = activitiesFor(project, options.activities);
|
|
8158
8461
|
if (!settings.bundlePath && !activities) {
|
|
8159
|
-
throw new
|
|
8462
|
+
throw new CliUserError40("The worker would serve nothing: give workflows, --activities or both.");
|
|
8160
8463
|
}
|
|
8161
8464
|
const maxActivities = parsePositiveInt(options.maxConcurrentActivities, "--max-concurrent-activities");
|
|
8162
8465
|
const maxWorkflowTasks = parsePositiveInt(options.maxConcurrentWorkflowTasks, "--max-concurrent-workflow-tasks");
|
|
@@ -8189,7 +8492,7 @@ async function workflowBundle(project, options, build) {
|
|
|
8189
8492
|
if (!existsSync13(path)) {
|
|
8190
8493
|
if (options.activities !== undefined)
|
|
8191
8494
|
return;
|
|
8192
|
-
throw new
|
|
8495
|
+
throw new CliUserError40(`No workflow bundle at ${path}.`, {
|
|
8193
8496
|
hint: "Run `fluidgrids push` first, or pass --build to build it now (or --no-workflows)."
|
|
8194
8497
|
});
|
|
8195
8498
|
}
|
|
@@ -8198,7 +8501,7 @@ async function workflowBundle(project, options, build) {
|
|
|
8198
8501
|
async function runWorkerRun(env, options) {
|
|
8199
8502
|
const queues = bindWorkerQueues(parseList(options.queue).map(checkWorkerQueue), options.environment);
|
|
8200
8503
|
if (queues.length === 0)
|
|
8201
|
-
throw new
|
|
8504
|
+
throw new CliUserError40("Name the task queue(s) to serve with --queue.");
|
|
8202
8505
|
const project = loadProject(options.project, env.cwd());
|
|
8203
8506
|
const token = workerToken(env, options.tokenEnv);
|
|
8204
8507
|
const launch = launchOf({
|
|
@@ -8221,7 +8524,7 @@ function devQueueName() {
|
|
|
8221
8524
|
async function runDev(env, options) {
|
|
8222
8525
|
const project = loadProject(options.project, env.cwd());
|
|
8223
8526
|
if (options.lang !== undefined && options.lang !== project.config.language) {
|
|
8224
|
-
throw new
|
|
8527
|
+
throw new CliUserError40(`--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 …`)." });
|
|
8225
8528
|
}
|
|
8226
8529
|
const bundlePath = await workflowBundle(project, options, options.workflows !== false);
|
|
8227
8530
|
const queueName = devQueueName();
|
|
@@ -8324,7 +8627,7 @@ async function loadTypeScriptActivities(root, path) {
|
|
|
8324
8627
|
}
|
|
8325
8628
|
}
|
|
8326
8629
|
if (found.length === 0) {
|
|
8327
|
-
throw new
|
|
8630
|
+
throw new CliUserError40(`${path} exports no activity implementations.`, {
|
|
8328
8631
|
hint: "Export `implementActivity(...)` or `defineActivity(...)` values from it."
|
|
8329
8632
|
});
|
|
8330
8633
|
}
|
|
@@ -8350,21 +8653,21 @@ async function runTypeScriptWorker(launch) {
|
|
|
8350
8653
|
}
|
|
8351
8654
|
function pythonWorkerExitError(python, code, signal) {
|
|
8352
8655
|
if (signal)
|
|
8353
|
-
return new
|
|
8656
|
+
return new CliUserError40(`The Python worker was stopped by ${signal}.`);
|
|
8354
8657
|
const status = String(code);
|
|
8355
8658
|
switch (code) {
|
|
8356
8659
|
case PYTHON_EXIT_NO_WORKER:
|
|
8357
|
-
return new
|
|
8660
|
+
return new CliUserError40(`The Python worker could not import fluidgrids_workflows.worker (status ${status}).`, {
|
|
8358
8661
|
hint: `Install the worker extra: \`${python} -m pip install 'fluidgrids-workflows[worker]'\`.`
|
|
8359
8662
|
});
|
|
8360
8663
|
case PYTHON_EXIT_NO_ACTIVITIES:
|
|
8361
|
-
return new
|
|
8664
|
+
return new CliUserError40(`The Python worker exited with status ${status}: the activities module defines no activities.`, {
|
|
8362
8665
|
hint: "Decorate the activities with @define_activity in the module --activities names, or pass the module that defines them."
|
|
8363
8666
|
});
|
|
8364
8667
|
case PYTHON_EXIT_BRIDGE_CLOSED:
|
|
8365
|
-
return new
|
|
8668
|
+
return new CliUserError40(`The Python worker exited with status ${status}: the worker bridge closed the connection (the close code and its meaning are above).`);
|
|
8366
8669
|
default:
|
|
8367
|
-
return new
|
|
8670
|
+
return new CliUserError40(`The Python worker exited with status ${status}.`);
|
|
8368
8671
|
}
|
|
8369
8672
|
}
|
|
8370
8673
|
function pythonWorkerSpec(launch) {
|
|
@@ -8408,7 +8711,7 @@ function runPythonWorker(launch) {
|
|
|
8408
8711
|
};
|
|
8409
8712
|
child.on("error", (error) => {
|
|
8410
8713
|
done();
|
|
8411
|
-
reject(error.code === "ENOENT" ? new
|
|
8714
|
+
reject(error.code === "ENOENT" ? new CliUserError40(`Python interpreter "${python}" was not found.`) : new CliUserError40(`Could not start ${python}: ${error.message}`));
|
|
8412
8715
|
});
|
|
8413
8716
|
child.on("close", (code, signal) => {
|
|
8414
8717
|
done();
|
|
@@ -8491,7 +8794,7 @@ except BridgeClosedError as error:
|
|
|
8491
8794
|
|
|
8492
8795
|
// src/phase-c/shared.ts
|
|
8493
8796
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
8494
|
-
import { CliUserError as
|
|
8797
|
+
import { CliUserError as CliUserError41 } from "@burdenoff/cli-sdk/core";
|
|
8495
8798
|
async function confirmOnTerminal(question) {
|
|
8496
8799
|
const rl = createInterface3({ input: process.stdin, output: process.stderr });
|
|
8497
8800
|
try {
|
|
@@ -8513,32 +8816,32 @@ async function requireConfirmation(env, question, force) {
|
|
|
8513
8816
|
if (force)
|
|
8514
8817
|
return;
|
|
8515
8818
|
if (!env.interactive()) {
|
|
8516
|
-
throw new
|
|
8819
|
+
throw new CliUserError41(`${question} needs confirmation.`, {
|
|
8517
8820
|
hint: "Pass --force to go ahead without a prompt."
|
|
8518
8821
|
});
|
|
8519
8822
|
}
|
|
8520
8823
|
if (!await env.confirm(question))
|
|
8521
|
-
throw new
|
|
8824
|
+
throw new CliUserError41("Aborted: nothing was changed.");
|
|
8522
8825
|
}
|
|
8523
8826
|
function runSelectorOf(runId, flags) {
|
|
8524
8827
|
const targeted = flags.workflowId !== undefined || flags.key !== undefined || flags.firstRunId !== undefined;
|
|
8525
8828
|
if (!targeted) {
|
|
8526
8829
|
if (runId === undefined || runId.trim() === "") {
|
|
8527
|
-
throw new
|
|
8830
|
+
throw new CliUserError41("Give a run id, or --workflow-id with --key.");
|
|
8528
8831
|
}
|
|
8529
8832
|
return { runId: runId.trim() };
|
|
8530
8833
|
}
|
|
8531
8834
|
if (runId !== undefined) {
|
|
8532
|
-
throw new
|
|
8835
|
+
throw new CliUserError41("Give a run id or --workflow-id with --key, not both.");
|
|
8533
8836
|
}
|
|
8534
8837
|
const workflowId = flags.workflowId?.trim() ?? "";
|
|
8535
8838
|
const key = flags.key?.trim() ?? "";
|
|
8536
8839
|
if (workflowId === "" || key === "") {
|
|
8537
|
-
throw new
|
|
8840
|
+
throw new CliUserError41("--workflow-id and --key go together (the workflow id of that key).");
|
|
8538
8841
|
}
|
|
8539
8842
|
const firstRunId = flags.firstRunId?.trim();
|
|
8540
8843
|
if (flags.firstRunId !== undefined && !firstRunId) {
|
|
8541
|
-
throw new
|
|
8844
|
+
throw new CliUserError41("--first-run-id cannot be empty.");
|
|
8542
8845
|
}
|
|
8543
8846
|
return {
|
|
8544
8847
|
target: { workflowKey: key, workflowId, ...firstRunId ? { firstRunId } : {} }
|
|
@@ -8554,7 +8857,7 @@ function parseEnumOption(raw, flag, allowed) {
|
|
|
8554
8857
|
const match = allowed.find((value) => value === normal);
|
|
8555
8858
|
if (match === undefined) {
|
|
8556
8859
|
const shown = allowed.map((value) => value.toLowerCase().replace(/_/g, "-"));
|
|
8557
|
-
throw new
|
|
8860
|
+
throw new CliUserError41(`Invalid value '${raw}' for ${flag}. Allowed: ${shown.join(", ")}`);
|
|
8558
8861
|
}
|
|
8559
8862
|
return match;
|
|
8560
8863
|
}
|
|
@@ -8563,7 +8866,7 @@ function parseNonNegativeInt(raw, flag) {
|
|
|
8563
8866
|
return;
|
|
8564
8867
|
const value = raw.trim();
|
|
8565
8868
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
8566
|
-
throw new
|
|
8869
|
+
throw new CliUserError41(`Invalid value '${raw}' for ${flag}: expected a whole number.`);
|
|
8567
8870
|
}
|
|
8568
8871
|
return Number(value);
|
|
8569
8872
|
}
|
|
@@ -8572,14 +8875,14 @@ function parseNumberOption(raw, flag) {
|
|
|
8572
8875
|
return;
|
|
8573
8876
|
const value = Number(raw.trim());
|
|
8574
8877
|
if (raw.trim() === "" || !Number.isFinite(value)) {
|
|
8575
|
-
throw new
|
|
8878
|
+
throw new CliUserError41(`Invalid value '${raw}' for ${flag}: expected a number.`);
|
|
8576
8879
|
}
|
|
8577
8880
|
return value;
|
|
8578
8881
|
}
|
|
8579
8882
|
function requireText(raw, flag) {
|
|
8580
8883
|
const value = raw?.trim() ?? "";
|
|
8581
8884
|
if (value === "")
|
|
8582
|
-
throw new
|
|
8885
|
+
throw new CliUserError41(`${flag} is required.`);
|
|
8583
8886
|
return value;
|
|
8584
8887
|
}
|
|
8585
8888
|
function parseList(raw) {
|
|
@@ -8609,7 +8912,7 @@ function parseInstant(raw, flag) {
|
|
|
8609
8912
|
const value = raw.trim();
|
|
8610
8913
|
const ms = Date.parse(value);
|
|
8611
8914
|
if (value === "" || !Number.isFinite(ms) || !/^\d{4}-\d{2}-\d{2}/.test(value)) {
|
|
8612
|
-
throw new
|
|
8915
|
+
throw new CliUserError41(`Invalid value '${raw}' for ${flag}: expected an ISO-8601 date and time such as 2026-10-01T00:00:00Z.`);
|
|
8613
8916
|
}
|
|
8614
8917
|
return new Date(ms).toISOString();
|
|
8615
8918
|
}
|
|
@@ -8618,7 +8921,7 @@ var init_shared3 = __esm(() => {
|
|
|
8618
8921
|
});
|
|
8619
8922
|
|
|
8620
8923
|
// src/config/commands.ts
|
|
8621
|
-
import { CliUserError as
|
|
8924
|
+
import { CliUserError as CliUserError42 } from "@burdenoff/cli-sdk/core";
|
|
8622
8925
|
function output(env, options, data, rows, headers) {
|
|
8623
8926
|
env.ctx.output.formatAndOutput(options, data, { headers, rows });
|
|
8624
8927
|
}
|
|
@@ -8634,7 +8937,7 @@ function isLocal(url) {
|
|
|
8634
8937
|
function checkProfileValue(key, value, profile) {
|
|
8635
8938
|
const trimmed = value.trim();
|
|
8636
8939
|
if (trimmed === "" || trimmed.length > 2048) {
|
|
8637
|
-
throw new
|
|
8940
|
+
throw new CliUserError42(`${key} must be 1 to 2048 characters.`);
|
|
8638
8941
|
}
|
|
8639
8942
|
switch (key) {
|
|
8640
8943
|
case "apiUrl":
|
|
@@ -8643,20 +8946,20 @@ function checkProfileValue(key, value, profile) {
|
|
|
8643
8946
|
try {
|
|
8644
8947
|
url = new URL(trimmed);
|
|
8645
8948
|
} catch {
|
|
8646
|
-
throw new
|
|
8949
|
+
throw new CliUserError42(`${key} must be a URL.`);
|
|
8647
8950
|
}
|
|
8648
8951
|
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLocal(url))) {
|
|
8649
|
-
throw new
|
|
8952
|
+
throw new CliUserError42(`${key} must use https (http only for localhost).`);
|
|
8650
8953
|
}
|
|
8651
8954
|
if (url.username || url.password) {
|
|
8652
|
-
throw new
|
|
8955
|
+
throw new CliUserError42(`${key} must not carry credentials.`);
|
|
8653
8956
|
}
|
|
8654
8957
|
return trimmed;
|
|
8655
8958
|
}
|
|
8656
8959
|
case "environment": {
|
|
8657
8960
|
const upper = trimmed.toUpperCase();
|
|
8658
|
-
if (!
|
|
8659
|
-
throw new
|
|
8961
|
+
if (!ENVIRONMENTS4.includes(upper)) {
|
|
8962
|
+
throw new CliUserError42(`environment must be one of ${ENVIRONMENTS4.join(", ")}.`);
|
|
8660
8963
|
}
|
|
8661
8964
|
return upper;
|
|
8662
8965
|
}
|
|
@@ -8670,15 +8973,15 @@ function checkProfileValue(key, value, profile) {
|
|
|
8670
8973
|
async function readToken(env, fromEnv) {
|
|
8671
8974
|
if (fromEnv !== undefined) {
|
|
8672
8975
|
if (!ENV_NAME3.test(fromEnv))
|
|
8673
|
-
throw new
|
|
8976
|
+
throw new CliUserError42("Invalid environment variable name for --from-env.");
|
|
8674
8977
|
const value = env.env[fromEnv]?.trim() ?? "";
|
|
8675
8978
|
if (value === "")
|
|
8676
|
-
throw new
|
|
8979
|
+
throw new CliUserError42(`The environment variable ${fromEnv} is empty or unset.`);
|
|
8677
8980
|
return value;
|
|
8678
8981
|
}
|
|
8679
8982
|
const piped = (await env.readStdin()).trim();
|
|
8680
8983
|
if (piped === "") {
|
|
8681
|
-
throw new
|
|
8984
|
+
throw new CliUserError42("Pipe the token on standard input, or pass --from-env <VAR>.", {
|
|
8682
8985
|
hint: 'For example: `printf %s "$TOKEN" | fluidgrids config set token --profile prod`.'
|
|
8683
8986
|
});
|
|
8684
8987
|
}
|
|
@@ -8698,7 +9001,7 @@ async function runConfigSet(env, key, value, options) {
|
|
|
8698
9001
|
const profile = profileName(env, options);
|
|
8699
9002
|
if (key === "token") {
|
|
8700
9003
|
if (value !== undefined) {
|
|
8701
|
-
throw new
|
|
9004
|
+
throw new CliUserError42("A token is never given on the command line.", {
|
|
8702
9005
|
hint: "Pipe it on standard input, or pass --from-env <VAR>."
|
|
8703
9006
|
});
|
|
8704
9007
|
}
|
|
@@ -8715,12 +9018,12 @@ async function runConfigSet(env, key, value, options) {
|
|
|
8715
9018
|
return out;
|
|
8716
9019
|
}
|
|
8717
9020
|
if (!isProfileKey(key)) {
|
|
8718
|
-
throw new
|
|
9021
|
+
throw new CliUserError42(`Unknown profile key ${key}.`, {
|
|
8719
9022
|
hint: `Keys: ${PROFILE_KEYS.join(", ")}, token, defaultProfile.`
|
|
8720
9023
|
});
|
|
8721
9024
|
}
|
|
8722
9025
|
if (value === undefined)
|
|
8723
|
-
throw new
|
|
9026
|
+
throw new CliUserError42(`Give a value for ${key}.`);
|
|
8724
9027
|
const checked = checkProfileValue(key, value, profile);
|
|
8725
9028
|
updateConfig(file, (document) => {
|
|
8726
9029
|
const table = profileTable(document, profile, true);
|
|
@@ -8736,7 +9039,7 @@ async function runConfigGet(env, key, options) {
|
|
|
8736
9039
|
const config = readConfig(file);
|
|
8737
9040
|
const resolved = resolveProfile(config, env.env, options.profile, file);
|
|
8738
9041
|
if (key !== undefined && !isProfileKey(key)) {
|
|
8739
|
-
throw new
|
|
9042
|
+
throw new CliUserError42(`Unknown profile key ${key}.`, {
|
|
8740
9043
|
hint: `Keys: ${PROFILE_KEYS.join(", ")}.`
|
|
8741
9044
|
});
|
|
8742
9045
|
}
|
|
@@ -8781,10 +9084,10 @@ async function runConfigDelete(env, key, options) {
|
|
|
8781
9084
|
const profile = profileName(env, options);
|
|
8782
9085
|
const existing = readConfig(file).profiles[profile];
|
|
8783
9086
|
if (existing === undefined)
|
|
8784
|
-
throw new
|
|
9087
|
+
throw new CliUserError42(`There is no profile ${profile} in ${file}.`);
|
|
8785
9088
|
if (key !== undefined) {
|
|
8786
9089
|
if (!isProfileKey(key))
|
|
8787
|
-
throw new
|
|
9090
|
+
throw new CliUserError42(`Unknown profile key ${key}.`);
|
|
8788
9091
|
updateConfig(file, (document) => {
|
|
8789
9092
|
const table = profileTable(document, profile, false);
|
|
8790
9093
|
if (table)
|
|
@@ -8821,7 +9124,7 @@ async function runConfigMigrate(env, options) {
|
|
|
8821
9124
|
values.workspace = workspace;
|
|
8822
9125
|
if (options.tokenEnv !== undefined) {
|
|
8823
9126
|
if (!ENV_NAME3.test(options.tokenEnv))
|
|
8824
|
-
throw new
|
|
9127
|
+
throw new CliUserError42("Invalid environment variable name for --token-env.");
|
|
8825
9128
|
values.tokenRef = `env:${options.tokenEnv}`;
|
|
8826
9129
|
}
|
|
8827
9130
|
updateConfig(file, (document) => {
|
|
@@ -8838,15 +9141,15 @@ async function runConfigMigrate(env, options) {
|
|
|
8838
9141
|
}
|
|
8839
9142
|
return out;
|
|
8840
9143
|
}
|
|
8841
|
-
var ENV_NAME3,
|
|
9144
|
+
var ENV_NAME3, ENVIRONMENTS4;
|
|
8842
9145
|
var init_commands = __esm(() => {
|
|
8843
9146
|
init_profiles();
|
|
8844
9147
|
ENV_NAME3 = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
8845
|
-
|
|
9148
|
+
ENVIRONMENTS4 = ["DEV", "STAGING", "PROD"];
|
|
8846
9149
|
});
|
|
8847
9150
|
|
|
8848
9151
|
// src/phase-c/commands/workers.ts
|
|
8849
|
-
import { CliUserError as
|
|
9152
|
+
import { CliUserError as CliUserError43 } from "@burdenoff/cli-sdk/core";
|
|
8850
9153
|
function workerRows(workers) {
|
|
8851
9154
|
return workers.map((worker) => [
|
|
8852
9155
|
worker.identity,
|
|
@@ -8860,7 +9163,7 @@ function workerRows(workers) {
|
|
|
8860
9163
|
}
|
|
8861
9164
|
async function runWorkersList(env, options) {
|
|
8862
9165
|
if (options.stale && options.notStale) {
|
|
8863
|
-
throw new
|
|
9166
|
+
throw new CliUserError43("Give --stale or --not-stale, not both.");
|
|
8864
9167
|
}
|
|
8865
9168
|
const filter = {
|
|
8866
9169
|
...options.queue ? { taskQueue: checkWorkerQueue(options.queue) } : {},
|
|
@@ -8903,7 +9206,7 @@ function connectionNames(raw) {
|
|
|
8903
9206
|
const names = parseList(raw);
|
|
8904
9207
|
for (const name of names) {
|
|
8905
9208
|
if (!CONNECTION_NAME.test(name)) {
|
|
8906
|
-
throw new
|
|
9209
|
+
throw new CliUserError43(`Invalid connection name '${name}'.`);
|
|
8907
9210
|
}
|
|
8908
9211
|
}
|
|
8909
9212
|
return names;
|
|
@@ -8918,10 +9221,10 @@ function issued(env, options, result) {
|
|
|
8918
9221
|
async function runTokensCreate(env, name, options) {
|
|
8919
9222
|
const tokenName = name.trim();
|
|
8920
9223
|
if (tokenName === "")
|
|
8921
|
-
throw new
|
|
9224
|
+
throw new CliUserError43("A worker token needs a name.");
|
|
8922
9225
|
const taskQueues = parseList(options.queue).map(checkWorkerQueue);
|
|
8923
9226
|
if (taskQueues.length === 0) {
|
|
8924
|
-
throw new
|
|
9227
|
+
throw new CliUserError43("A worker token needs at least one --queue.", {
|
|
8925
9228
|
hint: "Create the queue first with `fluidgrids queues create <name>`."
|
|
8926
9229
|
});
|
|
8927
9230
|
}
|
|
@@ -8950,10 +9253,10 @@ async function runTokensDelete(env, id, options) {
|
|
|
8950
9253
|
async function runTokensAllowConnections(env, id, names, options) {
|
|
8951
9254
|
const list = connectionNames(names);
|
|
8952
9255
|
if (list.length === 0 && !options.clear) {
|
|
8953
|
-
throw new
|
|
9256
|
+
throw new CliUserError43("Name the connections to allow, or pass --clear to allow none.");
|
|
8954
9257
|
}
|
|
8955
9258
|
if (list.length > 0 && options.clear) {
|
|
8956
|
-
throw new
|
|
9259
|
+
throw new CliUserError43("Give connection names or --clear, not both.");
|
|
8957
9260
|
}
|
|
8958
9261
|
const token = await env.pc.setWorkerTokenConnectionAllowlist(id, list);
|
|
8959
9262
|
emit(env, options, token, { headers: TOKEN_HEADERS, rows: [tokenRow(token)] }, [
|
|
@@ -8973,17 +9276,17 @@ var init_workers = __esm(() => {
|
|
|
8973
9276
|
|
|
8974
9277
|
// src/phase-c/commands/run-control.ts
|
|
8975
9278
|
import { randomUUID } from "crypto";
|
|
8976
|
-
import { CliUserError as
|
|
9279
|
+
import { CliUserError as CliUserError44 } from "@burdenoff/cli-sdk/core";
|
|
8977
9280
|
function runAndName(first, second, flags) {
|
|
8978
9281
|
const targeted = flags.workflowId !== undefined || flags.key !== undefined;
|
|
8979
9282
|
if (targeted) {
|
|
8980
9283
|
if (second !== undefined) {
|
|
8981
|
-
throw new
|
|
9284
|
+
throw new CliUserError44("With --workflow-id, give only the name: `<name> --workflow-id <id> --key <key>`.");
|
|
8982
9285
|
}
|
|
8983
9286
|
return { run: runSelectorOf(undefined, flags), name: first };
|
|
8984
9287
|
}
|
|
8985
9288
|
if (second === undefined) {
|
|
8986
|
-
throw new
|
|
9289
|
+
throw new CliUserError44("Give the run id and the name: `<runId> <name>`.");
|
|
8987
9290
|
}
|
|
8988
9291
|
return { run: runSelectorOf(first, flags), name: second };
|
|
8989
9292
|
}
|
|
@@ -8997,7 +9300,7 @@ async function runQuery(env, first, second, options) {
|
|
|
8997
9300
|
rows: [[result.name, String(result.rejected), JSON.stringify(result.value ?? null)]]
|
|
8998
9301
|
}, result.error ? [`error: ${result.error}`] : []);
|
|
8999
9302
|
if (result.rejected) {
|
|
9000
|
-
throw new
|
|
9303
|
+
throw new CliUserError44(`The query ${name} was refused: ${result.error ?? "no reason given"}`);
|
|
9001
9304
|
}
|
|
9002
9305
|
return result;
|
|
9003
9306
|
}
|
|
@@ -9039,13 +9342,13 @@ async function runUpdate(env, first, second, options) {
|
|
|
9039
9342
|
rows: [[result.updateId, result.name, result.status, JSON.stringify(result.result ?? null)]]
|
|
9040
9343
|
});
|
|
9041
9344
|
if (!reached(result.status, waitFor)) {
|
|
9042
|
-
throw new
|
|
9345
|
+
throw new CliUserError44(`The update ${name} is still ${result.status} after ${timeoutMs} ms (waiting for ${waitFor}); check it later with \`fluidgrids runs update-status ${result.runId} ${updateId}\`.`);
|
|
9043
9346
|
}
|
|
9044
9347
|
if (result.status === "REJECTED") {
|
|
9045
|
-
throw new
|
|
9348
|
+
throw new CliUserError44(`The update ${name} was rejected: ${failureMessage(result.failure)}`);
|
|
9046
9349
|
}
|
|
9047
9350
|
if (result.status === "COMPLETED" && result.failure !== null && result.failure !== undefined) {
|
|
9048
|
-
throw new
|
|
9351
|
+
throw new CliUserError44(`The update handler of ${name} failed: ${failureMessage(result.failure)}`);
|
|
9049
9352
|
}
|
|
9050
9353
|
return result;
|
|
9051
9354
|
}
|
|
@@ -9061,33 +9364,33 @@ async function runUpdateStatus(env, first, second, options) {
|
|
|
9061
9364
|
function parseResetTo(raw, buildId) {
|
|
9062
9365
|
const value = raw?.trim() ?? "";
|
|
9063
9366
|
if (value === "") {
|
|
9064
|
-
throw new
|
|
9367
|
+
throw new CliUserError44("--to is required: a history seq, first-task, last-task, last-continue-as-new, build-id or last-clean-task.");
|
|
9065
9368
|
}
|
|
9066
9369
|
if (/^\d+$/.test(value)) {
|
|
9067
9370
|
if (buildId !== undefined)
|
|
9068
|
-
throw new
|
|
9371
|
+
throw new CliUserError44("--build-id goes with --to build-id only.");
|
|
9069
9372
|
const seq = Number(value);
|
|
9070
9373
|
if (!Number.isSafeInteger(seq) || seq <= 0) {
|
|
9071
|
-
throw new
|
|
9374
|
+
throw new CliUserError44(`Invalid value '${raw}' for --to: a seq is a positive integer.`);
|
|
9072
9375
|
}
|
|
9073
9376
|
return { seq };
|
|
9074
9377
|
}
|
|
9075
9378
|
const normal = value.toUpperCase().replace(/-/g, "_");
|
|
9076
9379
|
if (normal === "LAST_CLEAN_TASK") {
|
|
9077
9380
|
if (buildId !== undefined)
|
|
9078
|
-
throw new
|
|
9381
|
+
throw new CliUserError44("--build-id goes with --to build-id only.");
|
|
9079
9382
|
return "LAST_CLEAN_TASK";
|
|
9080
9383
|
}
|
|
9081
9384
|
const type = parseEnumOption(normal === "LAST_CONTINUE_AS_NEW" ? "LAST_CONTINUED_AS_NEW" : normal, "--to", RESET_TYPES);
|
|
9082
9385
|
if (type === "BUILD_ID") {
|
|
9083
9386
|
const id = buildId?.trim() ?? "";
|
|
9084
9387
|
if (!/^sha256:[0-9a-f]{64}$/.test(id)) {
|
|
9085
|
-
throw new
|
|
9388
|
+
throw new CliUserError44("--to build-id needs --build-id sha256:<64 hex>.");
|
|
9086
9389
|
}
|
|
9087
9390
|
return { type, buildId: id };
|
|
9088
9391
|
}
|
|
9089
9392
|
if (buildId !== undefined)
|
|
9090
|
-
throw new
|
|
9393
|
+
throw new CliUserError44("--build-id goes with --to build-id only.");
|
|
9091
9394
|
return { type };
|
|
9092
9395
|
}
|
|
9093
9396
|
async function runReset(env, runId, options) {
|
|
@@ -9146,7 +9449,7 @@ async function runTrace(env, runIdArg, options) {
|
|
|
9146
9449
|
const runId = await env.pc.runIdOf(runSelectorOf(runIdArg, options));
|
|
9147
9450
|
const hierarchy = await env.pc.runHierarchy(runId);
|
|
9148
9451
|
if (!hierarchy)
|
|
9149
|
-
throw new
|
|
9452
|
+
throw new CliUserError44(`Run ${runId} not found (NOT_FOUND)`);
|
|
9150
9453
|
const entries = flatten(hierarchy);
|
|
9151
9454
|
const open = entries.filter((entry) => OPEN_STATUSES.includes(entry.run.status));
|
|
9152
9455
|
const read = new Map;
|
|
@@ -9186,32 +9489,32 @@ var init_run_control = __esm(() => {
|
|
|
9186
9489
|
});
|
|
9187
9490
|
|
|
9188
9491
|
// src/phase-c/commands/activities.ts
|
|
9189
|
-
import { CliUserError as
|
|
9492
|
+
import { CliUserError as CliUserError45 } from "@burdenoff/cli-sdk/core";
|
|
9190
9493
|
import { durationMs as durationMs2 } from "@fluidgrids/workflows/ir";
|
|
9191
9494
|
function completionOf(env, first, second, options) {
|
|
9192
9495
|
if (options.taskTokenEnv !== undefined) {
|
|
9193
9496
|
if (first !== undefined || options.workflowId !== undefined || options.key !== undefined) {
|
|
9194
|
-
throw new
|
|
9497
|
+
throw new CliUserError45("Give --task-token-env, or the run and activity id, not both.");
|
|
9195
9498
|
}
|
|
9196
9499
|
const variable = options.taskTokenEnv.trim();
|
|
9197
9500
|
if (!ENV_NAME4.test(variable)) {
|
|
9198
|
-
throw new
|
|
9501
|
+
throw new CliUserError45("Invalid environment variable name for --task-token-env.");
|
|
9199
9502
|
}
|
|
9200
9503
|
const taskToken = env.getEnv(variable)?.trim() ?? "";
|
|
9201
9504
|
if (taskToken === "") {
|
|
9202
|
-
throw new
|
|
9505
|
+
throw new CliUserError45(`The environment variable ${variable} (--task-token-env) is empty or unset.`);
|
|
9203
9506
|
}
|
|
9204
9507
|
return { kind: "token", taskToken };
|
|
9205
9508
|
}
|
|
9206
9509
|
const targeted = options.workflowId !== undefined || options.key !== undefined;
|
|
9207
9510
|
if (targeted) {
|
|
9208
9511
|
if (first === undefined || second !== undefined) {
|
|
9209
|
-
throw new
|
|
9512
|
+
throw new CliUserError45("With --workflow-id, give only the activity id.");
|
|
9210
9513
|
}
|
|
9211
9514
|
return { kind: "id", run: runSelectorOf(undefined, options), activityId: first };
|
|
9212
9515
|
}
|
|
9213
9516
|
if (first === undefined || second === undefined) {
|
|
9214
|
-
throw new
|
|
9517
|
+
throw new CliUserError45("Give `<runId> <activityId>`, `<activityId> --workflow-id <id> --key <key>`, or --task-token-env.");
|
|
9215
9518
|
}
|
|
9216
9519
|
return { kind: "id", run: runSelectorOf(first, options), activityId: second };
|
|
9217
9520
|
}
|
|
@@ -9269,7 +9572,7 @@ function selectorOf(options) {
|
|
|
9269
9572
|
options.all === true
|
|
9270
9573
|
];
|
|
9271
9574
|
if (given.filter(Boolean).length !== 1) {
|
|
9272
|
-
throw new
|
|
9575
|
+
throw new CliUserError45("Choose the activities with exactly one of --activity-id, --type or --all.");
|
|
9273
9576
|
}
|
|
9274
9577
|
if (options.activityId !== undefined) {
|
|
9275
9578
|
return { activityId: requireText(options.activityId, "--activity-id") };
|
|
@@ -9310,18 +9613,18 @@ function parseMs(raw, flag) {
|
|
|
9310
9613
|
const value = raw.trim();
|
|
9311
9614
|
const ms = /^\d+$/.test(value) ? Number(value) : value === "" ? undefined : durationMs2(value, "ms");
|
|
9312
9615
|
if (ms === undefined || !Number.isFinite(ms) || ms <= 0 || !Number.isSafeInteger(Math.round(ms))) {
|
|
9313
|
-
throw new
|
|
9616
|
+
throw new CliUserError45(`Invalid value '${raw}' for ${flag}: expected milliseconds or a duration such as 1.5s, 5m or PT2H.`);
|
|
9314
9617
|
}
|
|
9315
9618
|
return Math.round(ms);
|
|
9316
9619
|
}
|
|
9317
9620
|
function activityOptionsOf(options) {
|
|
9318
9621
|
const maxRetries = options.maxRetries === undefined ? undefined : /^\d+$/.test(options.maxRetries.trim()) ? Number(options.maxRetries.trim()) : NaN;
|
|
9319
9622
|
if (Number.isNaN(maxRetries)) {
|
|
9320
|
-
throw new
|
|
9623
|
+
throw new CliUserError45(`Invalid value '${options.maxRetries}' for --max-retries.`);
|
|
9321
9624
|
}
|
|
9322
9625
|
const backoff = options.backoff === undefined ? undefined : Number(options.backoff.trim());
|
|
9323
9626
|
if (backoff !== undefined && (!Number.isFinite(backoff) || backoff < 1)) {
|
|
9324
|
-
throw new
|
|
9627
|
+
throw new CliUserError45(`Invalid value '${options.backoff}' for --backoff: at least 1.`);
|
|
9325
9628
|
}
|
|
9326
9629
|
const retryOn = [];
|
|
9327
9630
|
for (const value of parseList(options.retryOn)) {
|
|
@@ -9345,7 +9648,7 @@ function activityOptionsOf(options) {
|
|
|
9345
9648
|
};
|
|
9346
9649
|
const out = { ...timeouts, ...Object.keys(retry).length > 0 ? { retry } : {} };
|
|
9347
9650
|
if (Object.keys(out).length === 0) {
|
|
9348
|
-
throw new
|
|
9651
|
+
throw new CliUserError45("Nothing to change: give a retry option or a timeout.");
|
|
9349
9652
|
}
|
|
9350
9653
|
return out;
|
|
9351
9654
|
}
|
|
@@ -9372,10 +9675,10 @@ async function runPauseRulesList(env, options) {
|
|
|
9372
9675
|
}
|
|
9373
9676
|
async function runPauseRulesCreate(env, options) {
|
|
9374
9677
|
if (options.activityType === undefined && options.nodeType === undefined && options.workflowKey === undefined) {
|
|
9375
|
-
throw new
|
|
9678
|
+
throw new CliUserError45("A pause rule needs --activity-type, --node-type or --workflow-key.");
|
|
9376
9679
|
}
|
|
9377
9680
|
if (options.expiresAt !== undefined && options.expiresIn !== undefined) {
|
|
9378
|
-
throw new
|
|
9681
|
+
throw new CliUserError45("Give --expires-at or --expires-in, not both.");
|
|
9379
9682
|
}
|
|
9380
9683
|
const expiresIn = parseMs(options.expiresIn, "--expires-in");
|
|
9381
9684
|
const expiresAt = expiresIn !== undefined ? new Date(Date.now() + expiresIn).toISOString() : parseInstant(options.expiresAt, "--expires-at");
|
|
@@ -9413,7 +9716,7 @@ var init_activities = __esm(() => {
|
|
|
9413
9716
|
});
|
|
9414
9717
|
|
|
9415
9718
|
// src/phase-c/commands/batch.ts
|
|
9416
|
-
import { CliUserError as
|
|
9719
|
+
import { CliUserError as CliUserError46 } from "@burdenoff/cli-sdk/core";
|
|
9417
9720
|
function isBatchType(name) {
|
|
9418
9721
|
return Object.hasOwn(BATCH_TYPES, name);
|
|
9419
9722
|
}
|
|
@@ -9426,7 +9729,7 @@ function batchSelection(options) {
|
|
|
9426
9729
|
if (options.filter !== undefined) {
|
|
9427
9730
|
const raw = parseJsonOption(options.filter, "--filter");
|
|
9428
9731
|
if (!isRecord19(raw))
|
|
9429
|
-
throw new
|
|
9732
|
+
throw new CliUserError46("--filter must be a JSON object (ListWorkflowRunsInput).");
|
|
9430
9733
|
Object.assign(filter, raw);
|
|
9431
9734
|
delete filter["limit"];
|
|
9432
9735
|
delete filter["offset"];
|
|
@@ -9446,19 +9749,19 @@ function batchSelection(options) {
|
|
|
9446
9749
|
if (options.searchAttributes !== undefined) {
|
|
9447
9750
|
const query = parseJsonOption(options.searchAttributes, "--search-attributes");
|
|
9448
9751
|
if (!isRecord19(query)) {
|
|
9449
|
-
throw new
|
|
9752
|
+
throw new CliUserError46("--search-attributes must be a JSON object ({and, or, text}).");
|
|
9450
9753
|
}
|
|
9451
9754
|
filter["searchAttributes"] = query;
|
|
9452
9755
|
}
|
|
9453
9756
|
const filtered = Object.keys(filter).length > 0;
|
|
9454
9757
|
if (runIds.length > 0 && filtered) {
|
|
9455
|
-
throw new
|
|
9758
|
+
throw new CliUserError46("Choose the runs with --run-id or with filter options, not both.");
|
|
9456
9759
|
}
|
|
9457
9760
|
if (runIds.length > MAX_BATCH_RUN_IDS) {
|
|
9458
|
-
throw new
|
|
9761
|
+
throw new CliUserError46(`At most ${MAX_BATCH_RUN_IDS} --run-id values; use a filter for more.`);
|
|
9459
9762
|
}
|
|
9460
9763
|
if (runIds.length === 0 && !filtered) {
|
|
9461
|
-
throw new
|
|
9764
|
+
throw new CliUserError46("Choose the runs: --run-id, or a filter (--key, --status, --kind, --workflow-id, --search-attributes, --filter).");
|
|
9462
9765
|
}
|
|
9463
9766
|
const rate = parsePositiveInt(options.rate, "--rate");
|
|
9464
9767
|
return {
|
|
@@ -9520,7 +9823,7 @@ function batchPayload(type, options) {
|
|
|
9520
9823
|
options.clearOverride === true
|
|
9521
9824
|
];
|
|
9522
9825
|
if (chosen.filter(Boolean).length !== 1) {
|
|
9523
|
-
throw new
|
|
9826
|
+
throw new CliUserError46("Give exactly one of --pin <version>, --auto-upgrade or --clear-override.");
|
|
9524
9827
|
}
|
|
9525
9828
|
if (options.clearOverride)
|
|
9526
9829
|
return { clearVersioningOverride: true };
|
|
@@ -9554,7 +9857,7 @@ function refuseUnused(type, options) {
|
|
|
9554
9857
|
unused.push("--activity-id/--type/--all");
|
|
9555
9858
|
}
|
|
9556
9859
|
if (unused.length > 0) {
|
|
9557
|
-
throw new
|
|
9860
|
+
throw new CliUserError46(`${unused.join(", ")} do not apply to a ${type} batch.`);
|
|
9558
9861
|
}
|
|
9559
9862
|
}
|
|
9560
9863
|
function jobRow(job) {
|
|
@@ -9582,7 +9885,7 @@ function jobDetails(job) {
|
|
|
9582
9885
|
}
|
|
9583
9886
|
async function runBatchStart(env, typeName, options) {
|
|
9584
9887
|
if (!isBatchType(typeName)) {
|
|
9585
|
-
throw new
|
|
9888
|
+
throw new CliUserError46(`Unknown batch type '${typeName}'. Allowed: ${Object.keys(BATCH_TYPES).join(", ")}`);
|
|
9586
9889
|
}
|
|
9587
9890
|
const type = BATCH_TYPES[typeName];
|
|
9588
9891
|
refuseUnused(type, options);
|
|
@@ -9632,10 +9935,10 @@ async function runBatchDescribe(env, id, options) {
|
|
|
9632
9935
|
}
|
|
9633
9936
|
emit(env, options, job, { headers: JOB_HEADERS, rows: [jobRow(job)] }, jobDetails(job));
|
|
9634
9937
|
if (options.watch && !TERMINAL_JOB.includes(job.status)) {
|
|
9635
|
-
throw new
|
|
9938
|
+
throw new CliUserError46(`Batch job ${id} is still ${job.status} after ${timeout} ms.`);
|
|
9636
9939
|
}
|
|
9637
9940
|
if (options.watch && (job.status === "FAILED" || job.status === "CANCELLED")) {
|
|
9638
|
-
throw new
|
|
9941
|
+
throw new CliUserError46(`Batch job ${id} ended ${job.status}${job.failureMessage ? `: ${job.failureMessage}` : ""}.`);
|
|
9639
9942
|
}
|
|
9640
9943
|
return job;
|
|
9641
9944
|
}
|
|
@@ -9679,7 +9982,7 @@ var init_batch = __esm(() => {
|
|
|
9679
9982
|
});
|
|
9680
9983
|
|
|
9681
9984
|
// src/phase-d/duration.ts
|
|
9682
|
-
import { CliUserError as
|
|
9985
|
+
import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
|
|
9683
9986
|
import { toMs } from "@fluidgrids/workflows";
|
|
9684
9987
|
function parseDurationOption(raw, flag) {
|
|
9685
9988
|
if (raw === undefined)
|
|
@@ -9689,7 +9992,7 @@ function parseDurationOption(raw, flag) {
|
|
|
9689
9992
|
try {
|
|
9690
9993
|
toMs(sent, flag);
|
|
9691
9994
|
} catch {
|
|
9692
|
-
throw new
|
|
9995
|
+
throw new CliUserError47(`Invalid value '${raw}' for ${flag}: expected a duration such as 1500 (milliseconds), 30s, 5m, 2h or PT2H.`);
|
|
9693
9996
|
}
|
|
9694
9997
|
return sent;
|
|
9695
9998
|
}
|
|
@@ -9698,14 +10001,14 @@ var init_duration = () => {};
|
|
|
9698
10001
|
// src/phase-d/commands/activity-start.ts
|
|
9699
10002
|
import { existsSync as existsSync14, readFileSync as readFileSync12 } from "fs";
|
|
9700
10003
|
import { resolve as resolve12 } from "path";
|
|
9701
|
-
import { CliUserError as
|
|
10004
|
+
import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
|
|
9702
10005
|
function retryPolicy(raw, maxAttempts, readFile) {
|
|
9703
10006
|
const parsed = parseJsonObjectArg(raw, "--retry", readFile);
|
|
9704
10007
|
const policy = {};
|
|
9705
10008
|
if (parsed !== undefined) {
|
|
9706
10009
|
for (const key of Object.keys(parsed)) {
|
|
9707
10010
|
if (!RETRY_KEYS.some((known) => known === key)) {
|
|
9708
|
-
throw new
|
|
10011
|
+
throw new CliUserError48(`--retry: unknown field ${key}. Allowed: ${RETRY_KEYS.join(", ")}`);
|
|
9709
10012
|
}
|
|
9710
10013
|
}
|
|
9711
10014
|
const text = (key) => {
|
|
@@ -9713,7 +10016,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
9713
10016
|
if (value === undefined)
|
|
9714
10017
|
return;
|
|
9715
10018
|
if (typeof value !== "string")
|
|
9716
|
-
throw new
|
|
10019
|
+
throw new CliUserError48(`--retry: ${key} must be a duration.`);
|
|
9717
10020
|
policy[key] = parseDurationOption(value, `--retry ${key}`);
|
|
9718
10021
|
};
|
|
9719
10022
|
text("initialInterval");
|
|
@@ -9721,21 +10024,21 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
9721
10024
|
const backoff = parsed["backoffCoefficient"];
|
|
9722
10025
|
if (backoff !== undefined) {
|
|
9723
10026
|
if (typeof backoff !== "number" || !Number.isFinite(backoff) || backoff < 1) {
|
|
9724
|
-
throw new
|
|
10027
|
+
throw new CliUserError48("--retry: backoffCoefficient must be a number of at least 1.");
|
|
9725
10028
|
}
|
|
9726
10029
|
policy.backoffCoefficient = backoff;
|
|
9727
10030
|
}
|
|
9728
10031
|
const attempts = parsed["maximumAttempts"];
|
|
9729
10032
|
if (attempts !== undefined) {
|
|
9730
10033
|
if (typeof attempts !== "number" || !Number.isSafeInteger(attempts) || attempts < 0) {
|
|
9731
|
-
throw new
|
|
10034
|
+
throw new CliUserError48("--retry: maximumAttempts must be a whole number (0 = unlimited).");
|
|
9732
10035
|
}
|
|
9733
10036
|
policy.maximumAttempts = attempts;
|
|
9734
10037
|
}
|
|
9735
10038
|
const types = parsed["nonRetryableErrorTypes"];
|
|
9736
10039
|
if (types !== undefined) {
|
|
9737
10040
|
if (!Array.isArray(types) || types.some((type) => typeof type !== "string")) {
|
|
9738
|
-
throw new
|
|
10041
|
+
throw new CliUserError48("--retry: nonRetryableErrorTypes must be a list of strings.");
|
|
9739
10042
|
}
|
|
9740
10043
|
policy.nonRetryableErrorTypes = types.filter((type) => typeof type === "string");
|
|
9741
10044
|
}
|
|
@@ -9743,7 +10046,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
9743
10046
|
if (maxAttempts !== undefined) {
|
|
9744
10047
|
const value = maxAttempts.trim();
|
|
9745
10048
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
9746
|
-
throw new
|
|
10049
|
+
throw new CliUserError48(`Invalid value '${maxAttempts}' for --max-attempts: expected a whole number (0 = unlimited).`);
|
|
9747
10050
|
}
|
|
9748
10051
|
policy.maximumAttempts = Number(value);
|
|
9749
10052
|
}
|
|
@@ -9752,29 +10055,29 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
9752
10055
|
function requireName(raw, what) {
|
|
9753
10056
|
const value = raw.trim();
|
|
9754
10057
|
if (value === "")
|
|
9755
|
-
throw new
|
|
10058
|
+
throw new CliUserError48(`The ${what} is empty.`);
|
|
9756
10059
|
return value;
|
|
9757
10060
|
}
|
|
9758
10061
|
async function runActivityStart(env, nodeType, operation, options) {
|
|
9759
10062
|
const readFile = (path) => {
|
|
9760
10063
|
const absolute = resolve12(env.cwd(), path);
|
|
9761
10064
|
if (!existsSync14(absolute))
|
|
9762
|
-
throw new
|
|
10065
|
+
throw new CliUserError48(`${path} does not exist.`);
|
|
9763
10066
|
return readFileSync12(absolute, "utf8");
|
|
9764
10067
|
};
|
|
9765
10068
|
if (options.args === undefined) {
|
|
9766
|
-
throw new
|
|
10069
|
+
throw new CliUserError48("--args is required: the operation arguments as a JSON object.", {
|
|
9767
10070
|
hint: `For example --args '{"url":"https://example.com"}', or --args @args.json.`
|
|
9768
10071
|
});
|
|
9769
10072
|
}
|
|
9770
10073
|
const args = parseJsonObjectArg(options.args, "--args", readFile) ?? {};
|
|
9771
10074
|
const summary = options.summary?.trim();
|
|
9772
10075
|
if (summary !== undefined && (summary === "" || summary.length > MAX_SUMMARY_CHARS)) {
|
|
9773
|
-
throw new
|
|
10076
|
+
throw new CliUserError48(`--summary is 1 to ${MAX_SUMMARY_CHARS} characters.`);
|
|
9774
10077
|
}
|
|
9775
10078
|
const key = options.idempotencyKey?.trim();
|
|
9776
10079
|
if (key !== undefined && !IDEMPOTENCY_KEY.test(key)) {
|
|
9777
|
-
throw new
|
|
10080
|
+
throw new CliUserError48(`--idempotency-key is 1 to ${MAX_IDEMPOTENCY_KEY_CHARS} letters, digits, dots, underscores, colons or dashes.`);
|
|
9778
10081
|
}
|
|
9779
10082
|
const retry = retryPolicy(options.retry, options.maxAttempts, readFile);
|
|
9780
10083
|
const nodeVersion = options.nodeVersion?.trim();
|
|
@@ -9818,7 +10121,7 @@ async function runActivityStart(env, nodeType, operation, options) {
|
|
|
9818
10121
|
rows: [[result.run.id, finalStatus, started.existing ? "yes" : "no"]]
|
|
9819
10122
|
}, details);
|
|
9820
10123
|
if (options.wait && finalStatus !== "COMPLETED") {
|
|
9821
|
-
throw new
|
|
10124
|
+
throw new CliUserError48(`Run ${started.run.id} ended ${finalStatus}.`);
|
|
9822
10125
|
}
|
|
9823
10126
|
return result;
|
|
9824
10127
|
}
|
|
@@ -9839,7 +10142,7 @@ var init_activity_start = __esm(() => {
|
|
|
9839
10142
|
});
|
|
9840
10143
|
|
|
9841
10144
|
// src/phase-c/commands/signal-tokens.ts
|
|
9842
|
-
import { CliUserError as
|
|
10145
|
+
import { CliUserError as CliUserError49 } from "@burdenoff/cli-sdk/core";
|
|
9843
10146
|
function row(token) {
|
|
9844
10147
|
return [
|
|
9845
10148
|
token.id,
|
|
@@ -9856,12 +10159,12 @@ async function runSignalTokenCreate(env, runId, options) {
|
|
|
9856
10159
|
const signalName = requireText(options.signal, "--signal");
|
|
9857
10160
|
const ttlMs = parseMs(options.ttl, "--ttl");
|
|
9858
10161
|
if (ttlMs !== undefined && ttlMs % 1000 !== 0) {
|
|
9859
|
-
throw new
|
|
10162
|
+
throw new CliUserError49("--ttl is counted in whole seconds.");
|
|
9860
10163
|
}
|
|
9861
10164
|
const ipAllowlist = parseList(options.allowIp);
|
|
9862
10165
|
for (const entry of ipAllowlist) {
|
|
9863
10166
|
if (!IPV4_OR_CIDR.test(entry)) {
|
|
9864
|
-
throw new
|
|
10167
|
+
throw new CliUserError49(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
|
|
9865
10168
|
}
|
|
9866
10169
|
}
|
|
9867
10170
|
const created = await env.pc.createSignalToken({
|
|
@@ -9897,7 +10200,7 @@ var init_signal_tokens = __esm(() => {
|
|
|
9897
10200
|
});
|
|
9898
10201
|
|
|
9899
10202
|
// src/phase-c/commands/search-attributes.ts
|
|
9900
|
-
import { CliUserError as
|
|
10203
|
+
import { CliUserError as CliUserError50 } from "@burdenoff/cli-sdk/core";
|
|
9901
10204
|
function row2(attribute) {
|
|
9902
10205
|
return [
|
|
9903
10206
|
attribute.name,
|
|
@@ -9914,11 +10217,11 @@ async function runSearchAttributesList(env, options) {
|
|
|
9914
10217
|
}
|
|
9915
10218
|
async function runSearchAttributesCreate(env, name, options) {
|
|
9916
10219
|
if (!NAME.test(name)) {
|
|
9917
|
-
throw new
|
|
10220
|
+
throw new CliUserError50(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
|
|
9918
10221
|
}
|
|
9919
10222
|
const type = parseEnumOption(options.type, "--type", SEARCH_ATTRIBUTE_TYPES);
|
|
9920
10223
|
if (type === undefined) {
|
|
9921
|
-
throw new
|
|
10224
|
+
throw new CliUserError50(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
|
|
9922
10225
|
}
|
|
9923
10226
|
const attribute = await env.pc.createSearchAttribute({
|
|
9924
10227
|
name,
|
|
@@ -9931,7 +10234,7 @@ async function runSearchAttributesCreate(env, name, options) {
|
|
|
9931
10234
|
async function runSearchAttributesDelete(env, name, options) {
|
|
9932
10235
|
const attribute = (await env.pc.searchAttributes()).find((entry) => entry.name === name);
|
|
9933
10236
|
if (!attribute) {
|
|
9934
|
-
throw new
|
|
10237
|
+
throw new CliUserError50(`The workspace has no search attribute ${name}.`, {
|
|
9935
10238
|
hint: "List them with `fluidgrids search-attributes list`."
|
|
9936
10239
|
});
|
|
9937
10240
|
}
|
|
@@ -9959,7 +10262,7 @@ var init_search_attributes = __esm(() => {
|
|
|
9959
10262
|
});
|
|
9960
10263
|
|
|
9961
10264
|
// src/phase-c/commands/schedules.ts
|
|
9962
|
-
import { CliUserError as
|
|
10265
|
+
import { CliUserError as CliUserError51 } from "@burdenoff/cli-sdk/core";
|
|
9963
10266
|
function isRecord20(value) {
|
|
9964
10267
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9965
10268
|
}
|
|
@@ -10084,9 +10387,9 @@ async function runSchedulesBackfill(env, workflowKey, triggerNodeId, options) {
|
|
|
10084
10387
|
const from = parseInstant(requireText(options.from, "--from"), "--from") ?? "";
|
|
10085
10388
|
const to = parseInstant(requireText(options.to, "--to"), "--to") ?? "";
|
|
10086
10389
|
if (from >= to)
|
|
10087
|
-
throw new
|
|
10390
|
+
throw new CliUserError51("--from must be before --to.");
|
|
10088
10391
|
if (Date.parse(to) > Date.now())
|
|
10089
|
-
throw new
|
|
10392
|
+
throw new CliUserError51("--to must be in the past.");
|
|
10090
10393
|
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);
|
|
10091
10394
|
const overlapPolicy = parseOverlap(options.overlapPolicy);
|
|
10092
10395
|
const result = await env.pc.backfillSchedule({
|
|
@@ -10138,7 +10441,7 @@ init_json_contract();
|
|
|
10138
10441
|
import { readFileSync as readFileSync13 } from "fs";
|
|
10139
10442
|
import { join as join12, dirname as dirname6 } from "path";
|
|
10140
10443
|
import { fileURLToPath } from "url";
|
|
10141
|
-
import { CliUserError as
|
|
10444
|
+
import { CliUserError as CliUserError52, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
|
|
10142
10445
|
|
|
10143
10446
|
// src/output/run-envelope.ts
|
|
10144
10447
|
init_json_contract();
|
|
@@ -10567,7 +10870,7 @@ import healthModule from "@burdenoff/cli-sdk/modules/health";
|
|
|
10567
10870
|
|
|
10568
10871
|
// src/code-first/register.ts
|
|
10569
10872
|
init_shared();
|
|
10570
|
-
import { CliUserError as
|
|
10873
|
+
import { CliUserError as CliUserError37 } from "@burdenoff/cli-sdk/core";
|
|
10571
10874
|
var PROJECT_OPTION = [
|
|
10572
10875
|
"--project <dir>",
|
|
10573
10876
|
"Project directory (default: nearest fluidgrids.config.json)"
|
|
@@ -10625,7 +10928,7 @@ function registerImport(program, env) {
|
|
|
10625
10928
|
return;
|
|
10626
10929
|
}
|
|
10627
10930
|
if (resolved.preview) {
|
|
10628
|
-
throw new
|
|
10931
|
+
throw new CliUserError37("--preview needs --from <tool>.");
|
|
10629
10932
|
}
|
|
10630
10933
|
await Promise.resolve().then(() => init_import());
|
|
10631
10934
|
await runImport(env, file, resolved);
|
|
@@ -10697,7 +11000,7 @@ function registerDurable(program, env) {
|
|
|
10697
11000
|
await Promise.resolve().then(() => init_runs());
|
|
10698
11001
|
await runResult(env, runId, withGlobalFormat(options, command));
|
|
10699
11002
|
});
|
|
10700
|
-
runs.command("count").description("How many runs match, in total and per group (durable-function parity)").option("--key <workflowKey>", "Only runs of this workflow key").option("--status <status>", "Only runs with this status").option("--kind <kind>", "Only GRAPH or DURABLE_FN runs").option("--workflow-id <id>", "Only runs with this workflow id").option("--first-run-id <id>", "Only the chain that started with this run").option("--root-run-id <id>", "Only runs under this root run").option("--memo <json>", "Only runs whose memo contains this JSON object").option("--group-by <columns>", "Up to two of status, workflow-key, execution-kind, task-queue (comma separated)").option(...OUTPUT_OPTION).action(async (options, command) => {
|
|
11003
|
+
runs.command("count").description("How many runs match, in total and per group (durable-function parity)").option("--key <workflowKey>", "Only runs of this workflow key").option("--status <status>", "Only runs with this status").option("--kind <kind>", "Only GRAPH or DURABLE_FN runs").option("--workflow-id <id>", "Only runs with this workflow id").option("--first-run-id <id>", "Only the chain that started with this run").option("--root-run-id <id>", "Only runs under this root run").option("--memo <json>", "Only runs whose memo contains this JSON object").option("--group-by <columns>", "Up to two of status, workflow-key, execution-kind, task-queue (comma separated)").option("--group-by-attribute <names>", "Search attributes to group by after --group-by, two columns in all (needs fluidgrids.search-attributes)").option(...OUTPUT_OPTION).action(async (options, command) => {
|
|
10701
11004
|
await Promise.resolve().then(() => init_runs());
|
|
10702
11005
|
await runCount(env, withGlobalFormat(options, command));
|
|
10703
11006
|
});
|
|
@@ -10751,6 +11054,12 @@ function registerDurable(program, env) {
|
|
|
10751
11054
|
await runOverride(env, runId, withGlobalFormat(options, command));
|
|
10752
11055
|
});
|
|
10753
11056
|
}
|
|
11057
|
+
function registerDeploy(program, env) {
|
|
11058
|
+
program.command("deploy <workflowKey>").description("Deploy a version to DEV, or promote it to STAGING or PROD (waits for an approver; --ramp sets a gradual PROD rollout)").option("--env <env>", "dev, staging or prod").option("--wf-version <version>", "dev: the version to deploy (default: the newest; `active` names the ACTIVE one). staging/prod: refuse unless the source environment holds it").option("--ramp <n>", "prod only: 0 to 99 sends n% of new automatic starts to the STAGING version (durable functions); 100 promotes it in full").option("--note <text>", "Context for the approver of a promotion request").option("--no-wait", "Return once the promotion request is made instead of waiting for it").option("--timeout <ms>", "Give up waiting for an approver after this many milliseconds (the request stays open)", "900000").option("--poll-interval <ms>", "Delay between polls of the request in milliseconds", "5000").option(...OUTPUT_OPTION).action(async (workflowKey, options, command) => {
|
|
11059
|
+
await Promise.resolve().then(() => init_deploy());
|
|
11060
|
+
await runDeploy(env, workflowKey, withGlobalFormat(options, command));
|
|
11061
|
+
});
|
|
11062
|
+
}
|
|
10754
11063
|
|
|
10755
11064
|
// src/code-first/index.ts
|
|
10756
11065
|
init_shared();
|
|
@@ -10771,6 +11080,7 @@ var codeFirstModule = {
|
|
|
10771
11080
|
registerGenerate(program, env);
|
|
10772
11081
|
registerInterface(program, env);
|
|
10773
11082
|
registerDurable(program, env);
|
|
11083
|
+
registerDeploy(program, env);
|
|
10774
11084
|
}
|
|
10775
11085
|
};
|
|
10776
11086
|
var code_first_default = codeFirstModule;
|
|
@@ -11159,6 +11469,8 @@ var HELP_EXAMPLES = [
|
|
|
11159
11469
|
"$ fluidgrids push --dry-run # What a push would change",
|
|
11160
11470
|
"$ FLUIDGRIDS_TOKEN=... fluidgrids diff --exit-code # CI: non-interactive auth",
|
|
11161
11471
|
"$ fluidgrids test <key> --junit junit.xml # CI: run the saved test cases",
|
|
11472
|
+
"$ fluidgrids deploy <key> --env staging # Promote the DEV version (waits for approval)",
|
|
11473
|
+
"$ fluidgrids deploy <key> --env prod --ramp 10 # 10% of new PROD starts run the STAGING version",
|
|
11162
11474
|
"",
|
|
11163
11475
|
"$ fluidgrids config set apiUrl <url> --profile alpha # Client profile (~/.fluidgrids/config.toml)",
|
|
11164
11476
|
"",
|
|
@@ -11224,7 +11536,7 @@ try {
|
|
|
11224
11536
|
}
|
|
11225
11537
|
} catch (error) {
|
|
11226
11538
|
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
11227
|
-
if (error instanceof
|
|
11539
|
+
if (error instanceof CliUserError52 && error.hint)
|
|
11228
11540
|
console.error(`ℹ ${error.hint}`);
|
|
11229
|
-
process.exitCode = error instanceof
|
|
11541
|
+
process.exitCode = error instanceof CliUserError52 ? error.exitCode : 1;
|
|
11230
11542
|
}
|