@diagonal-hq/cli 0.42.3 → 0.42.5
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 +3 -3
- package/dist/check-data.json +1 -1
- package/dist/{cli-assets-cli-WEGERBBR.mjs → cli-assets-cli-LXLBKDDH.mjs} +1 -1
- package/dist/{cli-check-data-YU3CH43A.mjs → cli-check-data-VZ52XV3R.mjs} +1 -1
- package/dist/{cli-chunk-TDGR3ENO.mjs → cli-chunk-4A3XCNXP.mjs} +2 -1
- package/dist/cli.mjs +75 -7
- package/dist/index.d.ts +17 -6
- package/package.json +4 -4
|
@@ -25,6 +25,7 @@ var WORKFLOWS_USAGE = "Usage: diagonal workflows [--json]";
|
|
|
25
25
|
var RUN_USAGE = "Usage: diagonal run <path> [--input '<json object>'] [--json]";
|
|
26
26
|
var LOGS_USAGE = "Usage: diagonal logs [path | execution id] [--status <success|error|exception|started|pending>] [--limit <1-100>] [--json]";
|
|
27
27
|
var SUCCESS = "execution.success";
|
|
28
|
+
var PENDING = "execution.pending";
|
|
28
29
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
29
30
|
var STATUSES = ["success", "error", "exception", "started", "pending"];
|
|
30
31
|
function credentials(env, stderr) {
|
|
@@ -205,7 +206,7 @@ ${RUN_USAGE}
|
|
|
205
206
|
if (body === null) {
|
|
206
207
|
return 1;
|
|
207
208
|
}
|
|
208
|
-
const succeeded = body.status === SUCCESS;
|
|
209
|
+
const succeeded = body.status === SUCCESS || body.status === PENDING;
|
|
209
210
|
if (parsed.json) {
|
|
210
211
|
stdout.write(`${JSON.stringify(body, null, 2)}
|
|
211
212
|
`);
|
package/dist/cli.mjs
CHANGED
|
@@ -96,7 +96,7 @@ import {
|
|
|
96
96
|
takesAssetReference,
|
|
97
97
|
writeAssetCatalog,
|
|
98
98
|
writeAssetEntry
|
|
99
|
-
} from "./cli-chunk-
|
|
99
|
+
} from "./cli-chunk-4A3XCNXP.mjs";
|
|
100
100
|
import {
|
|
101
101
|
ASSETS_EXPORT,
|
|
102
102
|
GENERATED_ASSETS_MODULE,
|
|
@@ -7160,6 +7160,46 @@ function writeWholePageFile(path, file, options, resources, keep = [], { branchP
|
|
|
7160
7160
|
return { ok: false, diagnostic: diagnosticFromError(path, error) };
|
|
7161
7161
|
}
|
|
7162
7162
|
}
|
|
7163
|
+
function writePagePaused(path, source, paused, resources, { branchPaths = null, permissions = [] } = {}) {
|
|
7164
|
+
try {
|
|
7165
|
+
const ast = parseSource(source, { jsx: true });
|
|
7166
|
+
const exportStatement = ast.program.body.find(
|
|
7167
|
+
(statement) => statement.type === "ExportDefaultDeclaration"
|
|
7168
|
+
);
|
|
7169
|
+
if (exportStatement === void 0) {
|
|
7170
|
+
throw new SourceError(
|
|
7171
|
+
"A page file must export default definePage(options, function Page() { ... })",
|
|
7172
|
+
ast.program
|
|
7173
|
+
);
|
|
7174
|
+
}
|
|
7175
|
+
const [optionsNode] = expectDefineCall(exportStatement.declaration, "definePage", 2);
|
|
7176
|
+
if (optionsNode.type !== "ObjectExpression") {
|
|
7177
|
+
throw new SourceError(
|
|
7178
|
+
"The options of definePage must be an object literal to pause the page in the app. Edit the file in Files.",
|
|
7179
|
+
optionsNode
|
|
7180
|
+
);
|
|
7181
|
+
}
|
|
7182
|
+
const written = applySourceEdits(
|
|
7183
|
+
source,
|
|
7184
|
+
objectPatchEdits(
|
|
7185
|
+
source,
|
|
7186
|
+
optionsNode,
|
|
7187
|
+
{ paused: paused ? true : null },
|
|
7188
|
+
"definePage options",
|
|
7189
|
+
0
|
|
7190
|
+
)
|
|
7191
|
+
);
|
|
7192
|
+
return checkedPage(
|
|
7193
|
+
path,
|
|
7194
|
+
written,
|
|
7195
|
+
branchResourceNames(resources),
|
|
7196
|
+
branchPaths,
|
|
7197
|
+
declaredPermissionEntries(permissions)
|
|
7198
|
+
);
|
|
7199
|
+
} catch (error) {
|
|
7200
|
+
return { ok: false, diagnostic: diagnosticFromError(path, error) };
|
|
7201
|
+
}
|
|
7202
|
+
}
|
|
7163
7203
|
function writeParts(path, options, parts, { previous, readPath: readPath2, names, permissionEntries, keep, branchPaths, sourceOptions, addsCodeImports }) {
|
|
7164
7204
|
options = migrateOptionValues(options);
|
|
7165
7205
|
if (options.layout !== void 0 && !keep.includes("layout")) {
|
|
@@ -7601,6 +7641,24 @@ function writeFile({ path, data, context }) {
|
|
|
7601
7641
|
})
|
|
7602
7642
|
).source;
|
|
7603
7643
|
}
|
|
7644
|
+
function writePaused({ path, source, data, context }) {
|
|
7645
|
+
if (typeof data.paused !== "boolean") {
|
|
7646
|
+
throw new SourceTransformRequestError("paused must be a boolean.");
|
|
7647
|
+
}
|
|
7648
|
+
if (data.options !== void 0 || data.code !== void 0 || data.file !== void 0) {
|
|
7649
|
+
throw new SourceTransformRequestError("A pause write sends only paused.");
|
|
7650
|
+
}
|
|
7651
|
+
if (typeof source !== "string") {
|
|
7652
|
+
throw new SourceTransformRequestError("A pause write edits an existing page file.");
|
|
7653
|
+
}
|
|
7654
|
+
const { resources, branchPaths, permissions } = contextOf(context);
|
|
7655
|
+
return checked(
|
|
7656
|
+
writePagePaused(path, source, data.paused, resources, {
|
|
7657
|
+
branchPaths,
|
|
7658
|
+
permissions
|
|
7659
|
+
})
|
|
7660
|
+
).source;
|
|
7661
|
+
}
|
|
7604
7662
|
function checked(result) {
|
|
7605
7663
|
if (!result.ok) {
|
|
7606
7664
|
throw new SourceTransformDiagnostic(result.diagnostic);
|
|
@@ -7611,8 +7669,8 @@ var pageAdapter = Object.freeze({
|
|
|
7611
7669
|
contextFields: ["resources", "resource_slugs", "branch_paths", "permissions", "keep", "previous_path"],
|
|
7612
7670
|
// `code` is the factory body of the page function, with `options`. `file` is
|
|
7613
7671
|
// the whole file, as the page builder edits it: it is written as it is, or
|
|
7614
|
-
// with `options` in place of its own.
|
|
7615
|
-
writeFields: ["options", "code", "file"],
|
|
7672
|
+
// with `options` in place of its own. `paused` alone writes only that option.
|
|
7673
|
+
writeFields: ["options", "code", "file", "paused"],
|
|
7616
7674
|
accepts: (path) => /^pages\/.+\.tsx$/.test(path),
|
|
7617
7675
|
read({ path, source, context }) {
|
|
7618
7676
|
const { resources, branchPaths, permissions } = contextOf(context);
|
|
@@ -7620,6 +7678,9 @@ var pageAdapter = Object.freeze({
|
|
|
7620
7678
|
return { options, code, imports };
|
|
7621
7679
|
},
|
|
7622
7680
|
write({ path, source, data, context }) {
|
|
7681
|
+
if (data.paused !== void 0) {
|
|
7682
|
+
return writePaused({ path, source, data, context });
|
|
7683
|
+
}
|
|
7623
7684
|
if (data.file !== void 0) {
|
|
7624
7685
|
return writeFile({ path, data, context });
|
|
7625
7686
|
}
|
|
@@ -9175,6 +9236,7 @@ var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
|
9175
9236
|
var RECORD_EVENTS = ["created", "updated", "deleted", "restored", "saved"];
|
|
9176
9237
|
var LIFECYCLE_HOOKS = ["creating", "updating", "saving", "deleting", "restoring"];
|
|
9177
9238
|
var WORKFLOW_EVENTS = ["execution.success", "execution.error", "execution.exception"];
|
|
9239
|
+
var EXECUTION_MODES = ["sync", "async"];
|
|
9178
9240
|
function isWorkflowConfigPath(path) {
|
|
9179
9241
|
return WORKFLOW_PATH.test(path) && !path.endsWith(".test.ts") && !path.endsWith(".d.ts");
|
|
9180
9242
|
}
|
|
@@ -9393,6 +9455,12 @@ function optionsOf2(changes, properties, references2) {
|
|
|
9393
9455
|
}
|
|
9394
9456
|
options.authorizer = changes.authorizer;
|
|
9395
9457
|
}
|
|
9458
|
+
if (changes.execution_mode !== void 0) {
|
|
9459
|
+
if (changes.execution_mode !== null && !EXECUTION_MODES.includes(changes.execution_mode)) {
|
|
9460
|
+
throw new SourceError(`"execution_mode" must be 'sync', 'async', or null.`);
|
|
9461
|
+
}
|
|
9462
|
+
options.executionMode = changes.execution_mode;
|
|
9463
|
+
}
|
|
9396
9464
|
return options;
|
|
9397
9465
|
}
|
|
9398
9466
|
function routeEdits(source, properties, changes) {
|
|
@@ -9471,7 +9539,7 @@ function writeWorkflowConfigFile(path, source, changes, resources = []) {
|
|
|
9471
9539
|
// scripts/lib/runtime-build/source-adapters/workflow-config.mjs
|
|
9472
9540
|
var workflowConfigAdapter = Object.freeze({
|
|
9473
9541
|
contextFields: ["resources", "resource_slugs"],
|
|
9474
|
-
writeFields: ["name", "slug", "description", "trigger", "route", "run_as", "authorizer"],
|
|
9542
|
+
writeFields: ["name", "slug", "description", "trigger", "route", "run_as", "authorizer", "execution_mode"],
|
|
9475
9543
|
accepts: isWorkflowConfigPath,
|
|
9476
9544
|
identity: (data) => data.uid,
|
|
9477
9545
|
read({ path, source }) {
|
|
@@ -10914,7 +10982,7 @@ async function checkSources() {
|
|
|
10914
10982
|
if (existsSync4(DATA_FILE) && existsSync4(SDK_FILE)) {
|
|
10915
10983
|
return { dataFile: DATA_FILE, sdkFile: SDK_FILE };
|
|
10916
10984
|
}
|
|
10917
|
-
const { checkData, scriptSdk } = await import("./cli-check-data-
|
|
10985
|
+
const { checkData, scriptSdk } = await import("./cli-check-data-VZ52XV3R.mjs");
|
|
10918
10986
|
return { data: checkData(), sdk: scriptSdk() };
|
|
10919
10987
|
}
|
|
10920
10988
|
function isScriptTestPath(path) {
|
|
@@ -11020,9 +11088,9 @@ async function main(argv, io) {
|
|
|
11020
11088
|
case "assets": {
|
|
11021
11089
|
const [subcommand, ...assetArgs] = args;
|
|
11022
11090
|
if (subcommand === "upload")
|
|
11023
|
-
return (await import("./cli-assets-cli-
|
|
11091
|
+
return (await import("./cli-assets-cli-LXLBKDDH.mjs")).uploadAsset(assetArgs, io);
|
|
11024
11092
|
if (subcommand === "list")
|
|
11025
|
-
return (await import("./cli-assets-cli-
|
|
11093
|
+
return (await import("./cli-assets-cli-LXLBKDDH.mjs")).listAssets(assetArgs, io);
|
|
11026
11094
|
io.stderr.write(`${ASSETS_UPLOAD_USAGE}
|
|
11027
11095
|
${ASSETS_LIST_USAGE}
|
|
11028
11096
|
`);
|
package/dist/index.d.ts
CHANGED
|
@@ -1083,6 +1083,15 @@ type WorkflowLabel =
|
|
|
1083
1083
|
/** A migration config takes this type too, but the build refuses its `slug`: a migration's file name is its identity. */
|
|
1084
1084
|
type ConfigBase = UidOption & SlugOption & WorkflowLabel & { description?: string | null };
|
|
1085
1085
|
|
|
1086
|
+
/**
|
|
1087
|
+
* How a manual or request workflow runs. `'sync'` (the default) runs the
|
|
1088
|
+
* workflow while the caller waits for its output, with a 55-second time limit.
|
|
1089
|
+
* `'async'` puts the run in the queue and answers at once without the output.
|
|
1090
|
+
* The other triggers always run in the background, and a record lifecycle
|
|
1091
|
+
* workflow always runs inside the record write.
|
|
1092
|
+
*/
|
|
1093
|
+
type ExecutionModeOption = { executionMode?: 'sync' | 'async' };
|
|
1094
|
+
|
|
1086
1095
|
/**
|
|
1087
1096
|
* The config of a `workflows/<name>.ts` or migration file: the first argument of
|
|
1088
1097
|
* `export default defineWorkflow(config, handler)` from `@diagonal/workflow`, which adds the
|
|
@@ -1092,16 +1101,18 @@ type ConfigBase = UidOption & SlugOption & WorkflowLabel & { description?: strin
|
|
|
1092
1101
|
* as the caller (`'session'`) by default.
|
|
1093
1102
|
*/
|
|
1094
1103
|
export type WorkflowConfig =
|
|
1095
|
-
| (ConfigBase &
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1104
|
+
| (ConfigBase &
|
|
1105
|
+
ExecutionModeOption & {
|
|
1106
|
+
trigger: RequestTrigger;
|
|
1107
|
+
runAs?: WorkflowRunAs;
|
|
1108
|
+
authorizer?: 'authenticated';
|
|
1109
|
+
})
|
|
1100
1110
|
| (ConfigBase & {
|
|
1101
1111
|
trigger: RecordEventTrigger | RecordScheduleTrigger | ScheduledTrigger | WorkflowEventTrigger;
|
|
1102
1112
|
runAs: Exclude<WorkflowRunAs, 'session'>;
|
|
1103
1113
|
})
|
|
1104
|
-
| (ConfigBase &
|
|
1114
|
+
| (ConfigBase &
|
|
1115
|
+
ExecutionModeOption & { trigger: ManualTrigger; runAs?: Exclude<WorkflowRunAs, 'session'> })
|
|
1105
1116
|
| (ConfigBase & { trigger: RecordLifecycleTrigger });
|
|
1106
1117
|
|
|
1107
1118
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diagonal-hq/cli",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.5",
|
|
4
4
|
"description": "The diagonal CLI and the configuration helpers for file-based Diagonal workspaces.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"bun": "1.4.4"
|
|
52
52
|
},
|
|
53
53
|
"optionalDependencies": {
|
|
54
|
-
"@diagonal-hq/workflow-script-compiler-darwin-arm64": "0.1.0-
|
|
55
|
-
"@diagonal-hq/workflow-script-compiler-linux-x64": "0.1.0-
|
|
56
|
-
"@diagonal-hq/workflow-script-compiler-linux-arm64": "0.1.0-
|
|
54
|
+
"@diagonal-hq/workflow-script-compiler-darwin-arm64": "0.1.0-h1dd92aff7825",
|
|
55
|
+
"@diagonal-hq/workflow-script-compiler-linux-x64": "0.1.0-h1dd92aff7825",
|
|
56
|
+
"@diagonal-hq/workflow-script-compiler-linux-arm64": "0.1.0-h1dd92aff7825"
|
|
57
57
|
}
|
|
58
58
|
}
|