@zalosai/zalos-cli 0.2.35 → 0.2.37
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 +7 -1
- package/dist/client.js +7 -0
- package/dist/commands/execution.js +96 -0
- package/dist/commands/file.js +23 -10
- package/dist/commands/workflow.js +201 -13
- package/dist/workflow-payload.js +167 -0
- package/package.json +1 -1
- package/skills/zl-ops/SKILL.md +55 -3
package/README.md
CHANGED
|
@@ -139,6 +139,9 @@ zl page create --input /tmp/month-end-close.md --apply
|
|
|
139
139
|
zl page update <page-id> --input /tmp/month-end-close.md --apply
|
|
140
140
|
zl workflow run <id> --dry-run
|
|
141
141
|
zl workflow run <id>
|
|
142
|
+
zl workflow run <id> --json '{"period":"2026-11"}' --file bankReport=./jpm.xlsx
|
|
143
|
+
zl execution respond <execution-id> --dry-run
|
|
144
|
+
zl execution respond <execution-id> --json '{"approved":true}' --file ./reviewed.xlsx
|
|
142
145
|
zl template list
|
|
143
146
|
zl credential list
|
|
144
147
|
zl file list
|
|
@@ -163,7 +166,10 @@ zl close registry import-baseline --team-id <team-ref> --expected-version <versi
|
|
|
163
166
|
```
|
|
164
167
|
|
|
165
168
|
Workflow import/update/publish require `--apply`; without it they validate and print a preview.
|
|
166
|
-
`workflow run
|
|
169
|
+
`workflow run --file <field>=<path>` uploads a local file to Team Files and passes it to that form
|
|
170
|
+
file field, exactly like choosing a Team File in the web form. `execution respond` completes the
|
|
171
|
+
form step a run is waiting on (review/wait nodes), with optional `--file` uploads; `--dry-run` shows
|
|
172
|
+
the fields it expects. `workflow run` executes unless `--dry-run` is supplied. Product authorization comes
|
|
167
173
|
from the signed-in human's team membership, role, and token scopes. Credential reads
|
|
168
174
|
return metadata only. No product command loads database credentials.
|
|
169
175
|
|
package/dist/client.js
CHANGED
|
@@ -61,6 +61,10 @@ async function request(options, tokenOverride) {
|
|
|
61
61
|
}
|
|
62
62
|
throw new AuthError('Unauthorized. Check your API token.');
|
|
63
63
|
}
|
|
64
|
+
if (options.textResponse && !response.ok) {
|
|
65
|
+
const message = (await response.text()).trim().slice(0, 500);
|
|
66
|
+
throw new ApiError(response.status, message || response.statusText);
|
|
67
|
+
}
|
|
64
68
|
if (response.status === 404) {
|
|
65
69
|
throw new NotFoundError('resource', path);
|
|
66
70
|
}
|
|
@@ -70,6 +74,8 @@ async function request(options, tokenOverride) {
|
|
|
70
74
|
}
|
|
71
75
|
if (response.status === 204)
|
|
72
76
|
return undefined;
|
|
77
|
+
if (options.textResponse)
|
|
78
|
+
return (await response.text());
|
|
73
79
|
if (options.binaryResponse) {
|
|
74
80
|
return {
|
|
75
81
|
body: Buffer.from(await response.arrayBuffer()),
|
|
@@ -82,6 +88,7 @@ export const client = {
|
|
|
82
88
|
get: (path, query) => request({ method: 'GET', path, query }),
|
|
83
89
|
post: (path, body, options) => request({ method: 'POST', path, body, ...options }),
|
|
84
90
|
postForm: (path, body, options) => request({ method: 'POST', path, body, ...options }),
|
|
91
|
+
postFormText: (path, body, options) => request({ method: 'POST', path, body, textResponse: true, ...options }),
|
|
85
92
|
postBinary: (path, body, options) => request({ method: 'POST', path, body, ...options }),
|
|
86
93
|
/** POST a binary body and return the raw response, e.g. a streamed NDJSON result. */
|
|
87
94
|
postBinaryRaw: (path, body, options) => request({ method: 'POST', path, body, binaryResponse: true, ...options }),
|
|
@@ -7,6 +7,8 @@ import { currentEnvironment } from '../environments.js';
|
|
|
7
7
|
import { downloadToNewFile } from '../utils/download-file.js';
|
|
8
8
|
import { ApiError, ValidationError } from '../utils/errors.js';
|
|
9
9
|
import { filterFields, filterSingle, printJson } from '../utils/output.js';
|
|
10
|
+
import { parseJson } from '../utils/validate.js';
|
|
11
|
+
import { readLocalUploadFile, UPLOAD_TIMEOUT_MS } from './file.js';
|
|
10
12
|
import { action, dataRow, fields, integer, isRow, resourceId, } from '../utils/product-api.js';
|
|
11
13
|
function isReplayBundleArtifact(value) {
|
|
12
14
|
if (!isRow(value))
|
|
@@ -198,6 +200,93 @@ export async function listExecutionsAction(options) {
|
|
|
198
200
|
export async function viewExecutionAction(id, options, summary = false) {
|
|
199
201
|
printJson(filterSingle(dataRow(await client.get(`/executions/${resourceId(id)}${summary ? '/summary' : ''}`)), options.fields));
|
|
200
202
|
}
|
|
203
|
+
// Mirrors the server's wait-form multer limits (routes.ts WAIT_FORM_UPLOAD_MAX_BYTES).
|
|
204
|
+
const WAIT_FORM_MAX_FILE_BYTES = 100 * 1024 * 1024;
|
|
205
|
+
const WAIT_FORM_MAX_FILES = 10;
|
|
206
|
+
function waitFormTarget(submitUrl) {
|
|
207
|
+
if (typeof submitUrl !== 'string')
|
|
208
|
+
throw new ApiError(502, 'Waiting form has no submit URL');
|
|
209
|
+
const url = new URL(submitUrl, 'http://zl.invalid');
|
|
210
|
+
const match = /^\/api\/executions\/([^/]+)\/wait-form$/.exec(url.pathname);
|
|
211
|
+
const token = url.searchParams.get('token');
|
|
212
|
+
if (!match || !token)
|
|
213
|
+
throw new ApiError(502, 'Unexpected waiting form submit URL');
|
|
214
|
+
return { executionId: decodeURIComponent(match[1]), token };
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Completes a paused form step (wait/review node), uploading local files the same
|
|
218
|
+
* way the web form does. The resume token stays in memory and is never printed.
|
|
219
|
+
*/
|
|
220
|
+
export async function respondToExecutionFormAction(id, options) {
|
|
221
|
+
const executionId = resourceId(id);
|
|
222
|
+
const values = parseJson(options.json ?? '{}');
|
|
223
|
+
if (!isRow(values))
|
|
224
|
+
throw new ValidationError('json', 'Form values must be an object');
|
|
225
|
+
const response = await client.get(`/executions/${executionId}/wait-form-config`);
|
|
226
|
+
const config = isRow(response) && isRow(response.data) ? response.data : response;
|
|
227
|
+
if (!isRow(config))
|
|
228
|
+
throw new ApiError(502, 'Invalid waiting form response');
|
|
229
|
+
const target = waitFormTarget(config.submitUrl);
|
|
230
|
+
const files = options.file ?? [];
|
|
231
|
+
const fileField = typeof config.fileUploadFieldName === 'string' && config.fileUploadFieldName
|
|
232
|
+
? config.fileUploadFieldName
|
|
233
|
+
: 'uploadedFiles';
|
|
234
|
+
const problems = [];
|
|
235
|
+
if (files.length > 0 && config.allowFileUpload !== true)
|
|
236
|
+
problems.push('This form step does not accept file uploads');
|
|
237
|
+
if (files.length === 0 && config.fileUploadRequired === true)
|
|
238
|
+
problems.push('This form step requires a file: pass --file <path>');
|
|
239
|
+
// A dry run is how users discover what the form needs, so report problems instead.
|
|
240
|
+
if (problems.length > 0 && !options.dryRun)
|
|
241
|
+
throw new ValidationError('file', problems[0]);
|
|
242
|
+
if (files.length > WAIT_FORM_MAX_FILES)
|
|
243
|
+
throw new ValidationError('file', `A form step accepts at most ${WAIT_FORM_MAX_FILES} files`);
|
|
244
|
+
const uploads = [];
|
|
245
|
+
for (const path of files)
|
|
246
|
+
uploads.push(await readLocalUploadFile(path, undefined, {
|
|
247
|
+
bytes: WAIT_FORM_MAX_FILE_BYTES,
|
|
248
|
+
label: 'the 100 MiB form upload limit',
|
|
249
|
+
}));
|
|
250
|
+
const summary = {
|
|
251
|
+
executionId: target.executionId,
|
|
252
|
+
waitNodeName: config.waitNodeName ?? null,
|
|
253
|
+
formTitle: config.formTitle ?? null,
|
|
254
|
+
formFields: config.formFields ?? [],
|
|
255
|
+
allowFileUpload: config.allowFileUpload === true,
|
|
256
|
+
fileUploadRequired: config.fileUploadRequired === true,
|
|
257
|
+
...(config.allowFileUpload === true ? { fileUploadFieldName: fileField } : {}),
|
|
258
|
+
};
|
|
259
|
+
if (options.dryRun) {
|
|
260
|
+
printJson({
|
|
261
|
+
dryRun: true,
|
|
262
|
+
form: summary,
|
|
263
|
+
values,
|
|
264
|
+
files: uploads.map((upload) => ({ name: upload.name, size: upload.size })),
|
|
265
|
+
...(problems.length > 0 ? { problems } : {}),
|
|
266
|
+
});
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const form = new FormData();
|
|
270
|
+
for (const [key, value] of Object.entries(values)) {
|
|
271
|
+
if (key === fileField || value === null || value === undefined)
|
|
272
|
+
continue;
|
|
273
|
+
const items = Array.isArray(value) ? value : [value];
|
|
274
|
+
for (const item of items)
|
|
275
|
+
form.append(key, typeof item === 'object' ? JSON.stringify(item) : String(item));
|
|
276
|
+
}
|
|
277
|
+
for (const upload of uploads)
|
|
278
|
+
form.append(fileField, upload.file, upload.name);
|
|
279
|
+
await client.postFormText(`/executions/${encodeURIComponent(target.executionId)}/wait-form`, form, {
|
|
280
|
+
query: { token: target.token },
|
|
281
|
+
timeoutMs: UPLOAD_TIMEOUT_MS,
|
|
282
|
+
});
|
|
283
|
+
printJson({
|
|
284
|
+
executionId: target.executionId,
|
|
285
|
+
waitNodeName: summary.waitNodeName,
|
|
286
|
+
submitted: true,
|
|
287
|
+
files: uploads.length,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
201
290
|
export async function stopExecutionAction(id) {
|
|
202
291
|
const executionId = resourceId(id);
|
|
203
292
|
const result = await client.post(`/executions/${executionId}/stop`);
|
|
@@ -218,6 +307,13 @@ export function registerExecutionCommand(program) {
|
|
|
218
307
|
cmd
|
|
219
308
|
.command(`${verb} <id>`)
|
|
220
309
|
.action(async (id) => action(() => viewExecutionAction(id, fields(program), verb === 'summary')));
|
|
310
|
+
cmd
|
|
311
|
+
.command('respond <execution-id>')
|
|
312
|
+
.description('Complete the form step an execution is waiting on; --dry-run shows the fields it expects')
|
|
313
|
+
.option('--json <values>', 'Form values as JSON')
|
|
314
|
+
.option('--file <path>', 'Upload a local file with the response (repeatable)', (value, previous) => [...previous, value], [])
|
|
315
|
+
.option('--dry-run', 'Show the waiting form and planned response without submitting')
|
|
316
|
+
.action(async (id, options) => action(() => respondToExecutionFormAction(id, options)));
|
|
221
317
|
cmd
|
|
222
318
|
.command('stop <execution-id>')
|
|
223
319
|
.description('Stop a running execution and its downstream work')
|
package/dist/commands/file.js
CHANGED
|
@@ -12,7 +12,7 @@ const FOLDER_FIELDS = 'id,name,parentFolderId,createdAt,updatedAt';
|
|
|
12
12
|
// Team Files folders live in the `files` folder scope; workflow folders use `workflows`.
|
|
13
13
|
const FILES_FOLDER_SCOPE = 'files';
|
|
14
14
|
const MAX_FILE_SIZE_BYTES = 500 * 1024 * 1024;
|
|
15
|
-
const UPLOAD_TIMEOUT_MS = 15 * 60_000;
|
|
15
|
+
export const UPLOAD_TIMEOUT_MS = 15 * 60_000;
|
|
16
16
|
const MIME_TYPES = {
|
|
17
17
|
'.csv': 'text/csv',
|
|
18
18
|
'.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
@@ -94,9 +94,12 @@ export async function downloadFileAction(idOrPath, options) {
|
|
|
94
94
|
allowDataUrl: options.allowDataUrl,
|
|
95
95
|
}));
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
/** Validates a local file against the Team Files limits and opens it for multipart upload. */
|
|
98
|
+
export async function readLocalUploadFile(localPath, mimeTypeOverride, limit = {
|
|
99
|
+
bytes: MAX_FILE_SIZE_BYTES,
|
|
100
|
+
label: 'the 500 MiB Team Files limit',
|
|
101
|
+
}) {
|
|
102
|
+
const mimeType = mimeTypeOverride ?? MIME_TYPES[extname(localPath).toLowerCase()] ?? 'application/octet-stream';
|
|
100
103
|
if (!/^[\w.+-]+\/[\w.+-]+$/.test(mimeType)) {
|
|
101
104
|
throw new ValidationError('mimeType', 'Invalid MIME type');
|
|
102
105
|
}
|
|
@@ -109,21 +112,31 @@ export async function uploadFileAction(localPath, options) {
|
|
|
109
112
|
}
|
|
110
113
|
if (!fileStat.isFile())
|
|
111
114
|
throw new ValidationError('file', 'Local path must be a regular file');
|
|
112
|
-
if (fileStat.size >
|
|
113
|
-
throw new ValidationError('file',
|
|
115
|
+
if (fileStat.size > limit.bytes) {
|
|
116
|
+
throw new ValidationError('file', `${basename(localPath)} exceeds ${limit.label}`);
|
|
114
117
|
}
|
|
115
|
-
let file;
|
|
116
118
|
try {
|
|
117
|
-
|
|
119
|
+
return {
|
|
120
|
+
file: await openAsBlob(localPath, { type: mimeType }),
|
|
121
|
+
name: basename(localPath),
|
|
122
|
+
size: fileStat.size,
|
|
123
|
+
};
|
|
118
124
|
}
|
|
119
125
|
catch {
|
|
120
126
|
throw new ValidationError('file', `Unable to read local file: ${localPath}`);
|
|
121
127
|
}
|
|
128
|
+
}
|
|
129
|
+
export async function uploadLocalTeamFile(localPath, options) {
|
|
130
|
+
const folderId = options.folderId ? resourceId(options.folderId) : 'root';
|
|
131
|
+
const upload = await readLocalUploadFile(localPath, options.mimeType);
|
|
122
132
|
const form = new FormData();
|
|
123
133
|
form.append('folderId', folderId);
|
|
124
134
|
form.append('collisionStrategy', options.overwrite ? 'overwrite' : 'create_unique_name');
|
|
125
|
-
form.append('file', file,
|
|
126
|
-
|
|
135
|
+
form.append('file', upload.file, upload.name);
|
|
136
|
+
return dataRow(await client.postForm('/team-files/upload', form, { timeoutMs: UPLOAD_TIMEOUT_MS }));
|
|
137
|
+
}
|
|
138
|
+
export async function uploadFileAction(localPath, options) {
|
|
139
|
+
printJson(await uploadLocalTeamFile(localPath, options));
|
|
127
140
|
}
|
|
128
141
|
export async function listFoldersAction(options) {
|
|
129
142
|
const parentFolderId = options.parentFolderId ? resourceId(options.parentFolderId) : 'root';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { writeFile, stat } from 'node:fs/promises';
|
|
1
|
+
import { readFile, writeFile, stat } from 'node:fs/promises';
|
|
2
2
|
import { resolve, join } from 'node:path';
|
|
3
3
|
import { client } from '../client.js';
|
|
4
|
+
import { auditWorkflowPayload, projectWorkflowPayload } from '../workflow-payload.js';
|
|
4
5
|
import { parseWorkflowFile, readWorkflowFile, serializeWorkflow } from '../workflow-file.js';
|
|
5
|
-
import { ApiError, ValidationError } from '../utils/errors.js';
|
|
6
|
+
import { ApiError, NotFoundError, ValidationError } from '../utils/errors.js';
|
|
6
7
|
import { filterSingle, printJson } from '../utils/output.js';
|
|
7
8
|
import { action, dataRow, dataRows, fields, isRow, printPage, resourceId, } from '../utils/product-api.js';
|
|
8
9
|
import { parseJson } from '../utils/validate.js';
|
|
10
|
+
import { readLocalUploadFile, uploadLocalTeamFile } from './file.js';
|
|
9
11
|
import { registerWorkflowScheduleCommand } from './workflow-schedule.js';
|
|
10
12
|
import { registerWorkflowEvalCommand } from './workflow-eval.js';
|
|
11
13
|
async function readWorkflow(id, options) {
|
|
@@ -128,12 +130,31 @@ export async function exportWorkflowAction(id, options) {
|
|
|
128
130
|
else
|
|
129
131
|
process.stdout.write(serialized);
|
|
130
132
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
async function readJsonFile(path, field) {
|
|
134
|
+
try {
|
|
135
|
+
return JSON.parse(await readFile(path, 'utf8'));
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
throw new ValidationError(field, 'Cannot read a valid JSON file');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export async function validateWorkflowAction(path, options = {}) {
|
|
142
|
+
let value = await readWorkflowFile(path);
|
|
143
|
+
if (options.fix || options.output) {
|
|
144
|
+
if (!options.fix || !options.output)
|
|
145
|
+
throw new ValidationError('fix', 'Use --fix <field-maps.json> with --output <new-workflow.json>');
|
|
146
|
+
value = projectWorkflowPayload(value, await readJsonFile(options.fix, 'fix'));
|
|
147
|
+
await writeFile(resolve(options.output), serializeWorkflow(value, true), {
|
|
148
|
+
flag: 'wx',
|
|
149
|
+
mode: 0o600,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
133
152
|
printJson({
|
|
134
153
|
valid: true,
|
|
135
154
|
id: value.id,
|
|
136
155
|
nodeCount: value.nodes.length,
|
|
156
|
+
payloadAudit: auditWorkflowPayload(value),
|
|
157
|
+
...(options.output ? { output: resolve(options.output) } : {}),
|
|
137
158
|
});
|
|
138
159
|
}
|
|
139
160
|
export async function importWorkflowAction(path, options) {
|
|
@@ -180,16 +201,67 @@ async function saveWorkflowDraft(id, draft, options) {
|
|
|
180
201
|
return;
|
|
181
202
|
}
|
|
182
203
|
const saved = await putWorkflowDraft(id, draft);
|
|
183
|
-
|
|
204
|
+
const payloadAudit = auditWorkflowPayload(saved);
|
|
205
|
+
printJson({
|
|
206
|
+
workflow: saved,
|
|
207
|
+
publication: publicationStatus(saved),
|
|
208
|
+
...(payloadAudit.requiredNodes.length ? { payloadAudit } : {}),
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function rehearsalRequest(draft, fixture) {
|
|
212
|
+
if (typeof draft.checksum !== 'string' || !/^sha256:[a-f0-9]{64}$/.test(draft.checksum))
|
|
213
|
+
throw new ValidationError('checksum', 'The API must return a draft checksum to rehearse this workflow');
|
|
214
|
+
return {
|
|
215
|
+
expectedChecksum: draft.checksum,
|
|
216
|
+
fixture,
|
|
217
|
+
requiredNodes: auditWorkflowPayload(draft).requiredNodes,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
export async function rehearseWorkflowAction(id, options) {
|
|
221
|
+
const draft = await readWorkflow(id, {});
|
|
222
|
+
const fixture = await readJsonFile(options.fixture, 'fixture');
|
|
223
|
+
const report = dataRow(await client.post(`/workflows/${id}/rehearse`, rehearsalRequest(draft, fixture), {
|
|
224
|
+
timeoutMs: 30_000,
|
|
225
|
+
}));
|
|
226
|
+
printJson(report);
|
|
227
|
+
if (report.passed !== true)
|
|
228
|
+
process.exitCode = 1;
|
|
184
229
|
}
|
|
185
230
|
export async function publishWorkflowAction(id, options) {
|
|
186
|
-
const path = `/workflows/${resourceId(id)}
|
|
231
|
+
const path = `/workflows/${resourceId(id)}/${options.fixture ? 'rehearse-and-publish' : 'publish'}`;
|
|
232
|
+
const draft = await readWorkflow(id, {});
|
|
233
|
+
const payloadAudit = auditWorkflowPayload(draft);
|
|
234
|
+
const requiresRehearsal = payloadAudit.requiredNodes.length > 0 &&
|
|
235
|
+
(draft.versionId === undefined || draft.versionId !== draft.publishedVersionId);
|
|
236
|
+
const body = options.fixture
|
|
237
|
+
? rehearsalRequest(draft, await readJsonFile(options.fixture, 'fixture'))
|
|
238
|
+
: undefined;
|
|
239
|
+
if (!options.apply || options.dryRun) {
|
|
240
|
+
printJson({ dryRun: true, method: 'POST', path, payloadAudit, requiresRehearsal });
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (requiresRehearsal && !body)
|
|
244
|
+
throw new ValidationError('fixture', 'This draft needs a simulated rehearsal. Run workflow publish with --fixture <cases.json> --apply');
|
|
245
|
+
const response = body
|
|
246
|
+
? await client.post(path, body, { timeoutMs: 30_000 })
|
|
247
|
+
: await client.post(path);
|
|
248
|
+
const published = dataRow(response);
|
|
249
|
+
if (body && (!isRow(response.rehearsal) || response.rehearsal.passed !== true))
|
|
250
|
+
throw new ApiError(502, 'The API did not return a passing rehearsal result');
|
|
251
|
+
printJson({
|
|
252
|
+
workflow: published,
|
|
253
|
+
publication: publicationStatus(published, true),
|
|
254
|
+
...(response.rehearsal ? { rehearsal: response.rehearsal } : {}),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
export async function protectWorkflowAction(id, options) {
|
|
258
|
+
const path = `/workflows/${resourceId(id)}/protect`;
|
|
187
259
|
if (!options.apply || options.dryRun) {
|
|
188
260
|
printJson({ dryRun: true, method: 'POST', path });
|
|
189
261
|
return;
|
|
190
262
|
}
|
|
191
|
-
const
|
|
192
|
-
printJson({ workflow
|
|
263
|
+
const workflow = dataRow(await client.post(path));
|
|
264
|
+
printJson({ workflow, publication: publicationStatus(workflow) });
|
|
193
265
|
}
|
|
194
266
|
export async function activateWorkflowAction(id, options) {
|
|
195
267
|
const path = `/workflows/${resourceId(id)}/activate`;
|
|
@@ -217,17 +289,119 @@ export async function deleteWorkflowAction(id, options) {
|
|
|
217
289
|
await client.delete(path);
|
|
218
290
|
printJson({ deleted: true, workflowId });
|
|
219
291
|
}
|
|
292
|
+
function parseFileInputs(entries) {
|
|
293
|
+
const seen = new Set();
|
|
294
|
+
return entries.map((entry) => {
|
|
295
|
+
const separator = entry.indexOf('=');
|
|
296
|
+
const field = entry.slice(0, separator).trim();
|
|
297
|
+
const path = entry.slice(separator + 1);
|
|
298
|
+
if (separator <= 0 || !field || !path)
|
|
299
|
+
throw new ValidationError('file', 'Use --file <field>=<local-path>');
|
|
300
|
+
if (seen.has(field))
|
|
301
|
+
throw new ValidationError('file', `Only one file per field is supported: ${field}`);
|
|
302
|
+
seen.add(field);
|
|
303
|
+
return { field, path };
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/** Form file field keys as the server names them, or null when there is no form trigger. */
|
|
307
|
+
function formFileFields(workflow) {
|
|
308
|
+
const nodes = Array.isArray(workflow.nodes) ? workflow.nodes.filter(isRow) : [];
|
|
309
|
+
const trigger = nodes.find((node) => typeof node.type === 'string' && node.type.endsWith('.formTrigger'));
|
|
310
|
+
if (!trigger)
|
|
311
|
+
return null;
|
|
312
|
+
const raw = isRow(trigger.parameters) ? trigger.parameters.formFields : undefined;
|
|
313
|
+
let values = isRow(raw) ? raw.values : undefined;
|
|
314
|
+
// Older workflows store the field list as a JSON string.
|
|
315
|
+
if (typeof raw === 'string') {
|
|
316
|
+
try {
|
|
317
|
+
values = JSON.parse(raw);
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
values = [];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (!Array.isArray(values))
|
|
324
|
+
return [];
|
|
325
|
+
// A missing or blank fieldName is keyed by position, as the server's form readers do.
|
|
326
|
+
return values.flatMap((field, index) => isRow(field) && field.fieldType === 'file'
|
|
327
|
+
? [
|
|
328
|
+
typeof field.fieldName === 'string' && field.fieldName.trim()
|
|
329
|
+
? field.fieldName
|
|
330
|
+
: `field_${index}`,
|
|
331
|
+
]
|
|
332
|
+
: []);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Internal workflows are hidden from a plain read but still runnable, so retry the read with
|
|
336
|
+
* includeInternal. A 404 there means no such workflow (the server checks existence before the
|
|
337
|
+
* internal permission), so fail before uploading; only a refused internal read skips the check.
|
|
338
|
+
*/
|
|
339
|
+
async function runnableFormFileFields(workflowId) {
|
|
340
|
+
try {
|
|
341
|
+
return formFileFields(dataRow(await client.get(`/workflows/${workflowId}`)));
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
if (!(error instanceof NotFoundError))
|
|
345
|
+
throw error;
|
|
346
|
+
}
|
|
347
|
+
try {
|
|
348
|
+
return formFileFields(dataRow(await client.get(`/workflows/${workflowId}`, { includeInternal: 'true' })));
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
if (error instanceof NotFoundError)
|
|
352
|
+
throw error;
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
220
356
|
export async function runWorkflowAction(id, options) {
|
|
221
|
-
const
|
|
357
|
+
const workflowId = resourceId(id);
|
|
358
|
+
const path = `/workflows/${workflowId}/run`;
|
|
222
359
|
const triggerData = parseJson(options.json ?? '{}');
|
|
223
360
|
if (!isRow(triggerData))
|
|
224
361
|
throw new ValidationError('json', 'Trigger inputs must be an object');
|
|
225
|
-
const
|
|
362
|
+
const files = parseFileInputs(options.file ?? []);
|
|
363
|
+
for (const { field } of files) {
|
|
364
|
+
if (Object.hasOwn(triggerData, field))
|
|
365
|
+
throw new ValidationError('file', `Field ${field} is set both in --json and --file`);
|
|
366
|
+
}
|
|
367
|
+
if (files.length > 0) {
|
|
368
|
+
const accepted = await runnableFormFileFields(workflowId);
|
|
369
|
+
for (const { field } of files) {
|
|
370
|
+
if (accepted && !accepted.includes(field)) {
|
|
371
|
+
throw new ValidationError('file', `The form has no file field ${field}. File fields: ${accepted.join(', ') || 'none'}`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// Validate every local file before uploading any, so a typo uploads nothing.
|
|
375
|
+
for (const file of files)
|
|
376
|
+
await readLocalUploadFile(file.path);
|
|
377
|
+
}
|
|
226
378
|
if (options.dryRun) {
|
|
227
|
-
printJson({
|
|
379
|
+
printJson({
|
|
380
|
+
dryRun: true,
|
|
381
|
+
method: 'POST',
|
|
382
|
+
path,
|
|
383
|
+
payload: { triggerData },
|
|
384
|
+
uploads: files.map(({ field, path: localPath }) => ({
|
|
385
|
+
field,
|
|
386
|
+
localPath,
|
|
387
|
+
to: 'Team Files root, then passed as mesh://team-files/<id>',
|
|
388
|
+
})),
|
|
389
|
+
});
|
|
228
390
|
return;
|
|
229
391
|
}
|
|
230
|
-
|
|
392
|
+
const fileInputsMeta = {};
|
|
393
|
+
for (const { field, path: localPath } of files) {
|
|
394
|
+
const uploaded = await uploadLocalTeamFile(localPath, {});
|
|
395
|
+
if (typeof uploaded.id !== 'string')
|
|
396
|
+
throw new ApiError(502, 'Team Files upload response did not include a file ID');
|
|
397
|
+
triggerData[field] = `mesh://team-files/${uploaded.id}`;
|
|
398
|
+
fileInputsMeta[field] = {
|
|
399
|
+
fileId: uploaded.id,
|
|
400
|
+
name: typeof uploaded.name === 'string' ? uploaded.name : localPath,
|
|
401
|
+
size: typeof uploaded.fileSize === 'number' ? uploaded.fileSize : 0,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
printJson(dataRow(await client.post(path, files.length > 0 ? { triggerData, fileInputsMeta } : { triggerData })));
|
|
231
405
|
}
|
|
232
406
|
function propertyContainer(draft, pointer, target) {
|
|
233
407
|
if (!pointer.startsWith('/') || /~(?![01])/.test(pointer))
|
|
@@ -376,7 +550,9 @@ export function registerWorkflowCommand(program) {
|
|
|
376
550
|
.action(async (id, o) => action(() => exportWorkflowAction(id, { ...o, ...fields(program) })));
|
|
377
551
|
cmd
|
|
378
552
|
.command('validate <file>')
|
|
379
|
-
.
|
|
553
|
+
.option('--fix <file>', 'Project explicit Set output fields from a JSON field map')
|
|
554
|
+
.option('--output <file>', 'Write repaired workflow to a new file')
|
|
555
|
+
.action(async (file, o) => action(() => validateWorkflowAction(file, o)));
|
|
380
556
|
cmd
|
|
381
557
|
.command('import <file>')
|
|
382
558
|
.option('--apply', 'Create workflow')
|
|
@@ -388,10 +564,21 @@ export function registerWorkflowCommand(program) {
|
|
|
388
564
|
.option('--apply', 'Apply update')
|
|
389
565
|
.option('--dry-run', 'Preview update')
|
|
390
566
|
.action(async (id, o) => action(() => updateWorkflowAction(id, o)));
|
|
567
|
+
cmd
|
|
568
|
+
.command('rehearse <id>')
|
|
569
|
+
.requiredOption('--fixture <file>', 'Simulated inputs, node outputs, and coverage assertions')
|
|
570
|
+
.action(async (id, o) => action(() => rehearseWorkflowAction(id, o)));
|
|
571
|
+
cmd
|
|
572
|
+
.command('protect <id>')
|
|
573
|
+
.description('Keep runs on the published version while editing drafts')
|
|
574
|
+
.option('--apply', 'Protect the current workflow version')
|
|
575
|
+
.option('--dry-run', 'Preview protection')
|
|
576
|
+
.action(async (id, o) => action(() => protectWorkflowAction(id, o)));
|
|
391
577
|
cmd
|
|
392
578
|
.command('publish <id>')
|
|
393
579
|
.option('--apply', 'Publish workflow')
|
|
394
580
|
.option('--dry-run', 'Preview publish')
|
|
581
|
+
.option('--fixture <file>', 'Run a simulated rehearsal of the draft before publishing')
|
|
395
582
|
.action(async (id, o) => action(() => publishWorkflowAction(id, o)));
|
|
396
583
|
cmd
|
|
397
584
|
.command('activate <id>')
|
|
@@ -411,6 +598,7 @@ export function registerWorkflowCommand(program) {
|
|
|
411
598
|
cmd
|
|
412
599
|
.command('run <id>')
|
|
413
600
|
.option('--json <inputs>', 'Trigger inputs as JSON')
|
|
601
|
+
.option('--file <field=path>', 'Upload a local file for a form file field (repeatable)', (value, previous) => [...previous, value], [])
|
|
414
602
|
.option('--dry-run', 'Preview execution')
|
|
415
603
|
.action(async (id, o) => action(() => runWorkflowAction(id, o)));
|
|
416
604
|
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { ValidationError } from './utils/errors.js';
|
|
2
|
+
import { isRow } from './utils/product-api.js';
|
|
3
|
+
const bulkField = /\b(?:rows|values|items|currentSheetValues|currentTransactionValues|queryReadback|transactionReadback|runtimeProvider|originalJournalRequests)\b/;
|
|
4
|
+
const wholeNode = /\$\(\s*(['"])(.*?)\1\s*\)\s*\.\s*(?:first\(\)|last\(\)|item)\s*\.\s*json(?!\w|\s*(?:\.|\?\.|\[))/g;
|
|
5
|
+
const wholeInput = /\$json(?!\w|\s*(?:\.|\?\.|\[))|\$input\s*\.\s*all\(|\*\*\s*(?:item|state)\b|\.\.\.\s*(?:item|state|\$json)\b/;
|
|
6
|
+
function kind(node, type) {
|
|
7
|
+
return node.type === `mesh-nodes-base.${type}`;
|
|
8
|
+
}
|
|
9
|
+
function bulkRead(node) {
|
|
10
|
+
return ((kind(node, 'googleSheets') && node.parameters.operation === 'getValues') ||
|
|
11
|
+
node.parameters.returnAll === true ||
|
|
12
|
+
kind(node, 'financialAgent') ||
|
|
13
|
+
kind(node, 'computerUse'));
|
|
14
|
+
}
|
|
15
|
+
function graphNodes(workflow) {
|
|
16
|
+
return (Array.isArray(workflow.nodes) ? workflow.nodes : []).flatMap((node) => isRow(node) && typeof node.name === 'string' && typeof node.type === 'string'
|
|
17
|
+
? [
|
|
18
|
+
{
|
|
19
|
+
name: node.name,
|
|
20
|
+
type: node.type,
|
|
21
|
+
parameters: isRow(node.parameters) ? node.parameters : {},
|
|
22
|
+
},
|
|
23
|
+
]
|
|
24
|
+
: []);
|
|
25
|
+
}
|
|
26
|
+
export function auditWorkflowPayload(workflow) {
|
|
27
|
+
const nodes = graphNodes(workflow);
|
|
28
|
+
const names = new Set(nodes.map((node) => node.name));
|
|
29
|
+
const edges = new Map();
|
|
30
|
+
const incoming = new Map();
|
|
31
|
+
for (const [name, outputs] of Object.entries(isRow(workflow.connections) ? workflow.connections : {})) {
|
|
32
|
+
if (!isRow(outputs) || !Array.isArray(outputs.main))
|
|
33
|
+
continue;
|
|
34
|
+
const targets = outputs.main
|
|
35
|
+
.flat()
|
|
36
|
+
.flatMap((edge) => isRow(edge) && typeof edge.node === 'string' && names.has(edge.node) ? [edge.node] : []);
|
|
37
|
+
edges.set(name, targets);
|
|
38
|
+
for (const target of targets)
|
|
39
|
+
incoming.set(target, [...(incoming.get(target) ?? []), name]);
|
|
40
|
+
}
|
|
41
|
+
function reachable(starts) {
|
|
42
|
+
const seen = new Set();
|
|
43
|
+
for (const queue = [...starts]; queue.length;) {
|
|
44
|
+
const name = queue.pop();
|
|
45
|
+
if (seen.has(name))
|
|
46
|
+
continue;
|
|
47
|
+
seen.add(name);
|
|
48
|
+
queue.push(...(edges.get(name) ?? []));
|
|
49
|
+
}
|
|
50
|
+
return seen;
|
|
51
|
+
}
|
|
52
|
+
const sources = nodes.filter(bulkRead);
|
|
53
|
+
const inlineFields = new Set([
|
|
54
|
+
'rows',
|
|
55
|
+
'values',
|
|
56
|
+
'items',
|
|
57
|
+
'runtimeProvider',
|
|
58
|
+
'originalJournalRequests',
|
|
59
|
+
]);
|
|
60
|
+
for (const node of sources) {
|
|
61
|
+
if (node.parameters.outputMode === 'file')
|
|
62
|
+
continue;
|
|
63
|
+
if (typeof node.parameters.outputFieldName === 'string')
|
|
64
|
+
inlineFields.add(node.parameters.outputFieldName);
|
|
65
|
+
}
|
|
66
|
+
const downstream = reachable(sources.map((node) => node.name));
|
|
67
|
+
const carriesBulk = new Set(sources
|
|
68
|
+
.filter((node) => node.parameters.outputMode !== 'file')
|
|
69
|
+
.map((node) => node.name));
|
|
70
|
+
const payloads = nodes.map((node) => {
|
|
71
|
+
const params = Object.values(node.parameters)
|
|
72
|
+
.map((value) => (typeof value === 'string' ? value : (JSON.stringify(value) ?? '')))
|
|
73
|
+
.join('\n');
|
|
74
|
+
const copiesInput = wholeInput.test(params);
|
|
75
|
+
const referencedNodes = [...params.matchAll(wholeNode)].map((match) => match[2]);
|
|
76
|
+
const mappedFields = [...params.matchAll(/\.([a-zA-Z_$][\w$]*)\s*\}\}/g)];
|
|
77
|
+
const selectsBulkField = mappedFields.some((match) => inlineFields.has(match[1]) || bulkField.test(match[1]));
|
|
78
|
+
const inheritsInput = (kind(node, 'set') && (node.parameters.includeInputFields !== false || selectsBulkField)) ||
|
|
79
|
+
(kind(node, 'googleSheets') &&
|
|
80
|
+
['getValues', 'batchUpdate', 'listSheets'].includes(String(node.parameters.operation))) ||
|
|
81
|
+
['if', 'wait', 'merge', 'splitInBatches'].some((type) => kind(node, type));
|
|
82
|
+
const returnsInput = inheritsInput || ((kind(node, 'set') || kind(node, 'pythonCode')) && copiesInput);
|
|
83
|
+
return { node, params, copiesInput, referencedNodes, returnsInput };
|
|
84
|
+
});
|
|
85
|
+
const receivesBulk = (name) => (incoming.get(name) ?? []).some((parent) => carriesBulk.has(parent));
|
|
86
|
+
const referencesBulk = (refs) => refs.some((ref) => carriesBulk.has(ref));
|
|
87
|
+
let previousSize = -1;
|
|
88
|
+
while (previousSize !== carriesBulk.size) {
|
|
89
|
+
previousSize = carriesBulk.size;
|
|
90
|
+
for (const { node, returnsInput, referencedNodes } of payloads) {
|
|
91
|
+
if ((returnsInput && receivesBulk(node.name)) ||
|
|
92
|
+
(kind(node, 'set') && referencesBulk(referencedNodes)))
|
|
93
|
+
carriesBulk.add(node.name);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const findings = [];
|
|
97
|
+
const required = new Set();
|
|
98
|
+
for (const { node, params, copiesInput, referencedNodes } of payloads) {
|
|
99
|
+
const { name, type, parameters } = node;
|
|
100
|
+
const wholeProducer = referencesBulk(referencedNodes);
|
|
101
|
+
if (wholeProducer || (receivesBulk(name) && copiesInput)) {
|
|
102
|
+
findings.push({
|
|
103
|
+
code: 'WHOLE_BULK_OUTPUT',
|
|
104
|
+
node: name,
|
|
105
|
+
message: 'Select individual fields or pass a run-scoped artifact reference.',
|
|
106
|
+
});
|
|
107
|
+
required.add(name);
|
|
108
|
+
}
|
|
109
|
+
if (receivesBulk(name) && kind(node, 'set') && parameters.includeInputFields !== false) {
|
|
110
|
+
findings.push({
|
|
111
|
+
code: 'BULK_PASSTHROUGH',
|
|
112
|
+
node: name,
|
|
113
|
+
message: 'Project the required fields with includeInputFields disabled.',
|
|
114
|
+
});
|
|
115
|
+
required.add(name);
|
|
116
|
+
}
|
|
117
|
+
const successors = reachable(edges.get(name) ?? []);
|
|
118
|
+
const loopEntry = successors.has(name) &&
|
|
119
|
+
(incoming.get(name) ?? []).some((parent) => !successors.has(parent));
|
|
120
|
+
const boundary = /\.(?:wait|executeWorkflow|splitInBatches)$/.test(type) || loopEntry;
|
|
121
|
+
if (boundary && downstream.has(name))
|
|
122
|
+
required.add(name);
|
|
123
|
+
if (boundary && (carriesBulk.has(name) || wholeProducer)) {
|
|
124
|
+
findings.push({
|
|
125
|
+
code: 'INLINE_BULK_BOUNDARY',
|
|
126
|
+
node: name,
|
|
127
|
+
message: 'Persist bulk data before the loop, wait, or sub-workflow and load it at the consumer.',
|
|
128
|
+
});
|
|
129
|
+
required.add(name);
|
|
130
|
+
}
|
|
131
|
+
else if (boundary && bulkField.test(params) && wholeInput.test(params)) {
|
|
132
|
+
findings.push({
|
|
133
|
+
code: 'INLINE_BULK_BOUNDARY',
|
|
134
|
+
node: name,
|
|
135
|
+
message: 'Pass a compact manifest with counts, hashes, or artifact references at this boundary.',
|
|
136
|
+
});
|
|
137
|
+
required.add(name);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { findings, requiredNodes: [...required].sort() };
|
|
141
|
+
}
|
|
142
|
+
export function projectWorkflowPayload(workflow, projections) {
|
|
143
|
+
if (!isRow(projections) || !Object.keys(projections).length)
|
|
144
|
+
throw new ValidationError('fix', 'Provide an object mapping Set node names to their complete output field maps');
|
|
145
|
+
const nodes = Array.isArray(workflow.nodes) ? workflow.nodes : [];
|
|
146
|
+
for (const [name, values] of Object.entries(projections)) {
|
|
147
|
+
const matches = nodes.filter((node) => isRow(node) && node.name === name);
|
|
148
|
+
if (matches.length !== 1 || matches[0].type !== 'mesh-nodes-base.set' || !isRow(values))
|
|
149
|
+
throw new ValidationError('fix', `Projection for "${name}" needs a unique Set node and an explicit field map`);
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
...workflow,
|
|
153
|
+
nodes: nodes.map((node) => {
|
|
154
|
+
if (!isRow(node) || typeof node.name !== 'string' || !Object.hasOwn(projections, node.name))
|
|
155
|
+
return node;
|
|
156
|
+
return {
|
|
157
|
+
...node,
|
|
158
|
+
parameters: {
|
|
159
|
+
...(isRow(node.parameters) ? node.parameters : {}),
|
|
160
|
+
includeInputFields: false,
|
|
161
|
+
values: JSON.stringify(projections[node.name]),
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=workflow-payload.js.map
|
package/package.json
CHANGED
package/skills/zl-ops/SKILL.md
CHANGED
|
@@ -71,11 +71,10 @@ command with `--apply` only when the intended team, object, and paths are confir
|
|
|
71
71
|
```bash
|
|
72
72
|
zl --environment <us-prod|eu-prod> workflow update <workflow-id> --input /tmp/workflow.json --dry-run
|
|
73
73
|
zl --environment <us-prod|eu-prod> workflow update <workflow-id> --input /tmp/workflow.json --apply
|
|
74
|
-
zl --environment <us-prod|eu-prod> workflow publish <workflow-id> --apply
|
|
74
|
+
zl --environment <us-prod|eu-prod> workflow publish <workflow-id> --fixture ./cases.json --apply
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
live-version response; executions continue using the published version until then.
|
|
77
|
+
For an unprotected workflow that needs guarded publishing, use `zl --environment <us-prod|eu-prod> workflow protect <workflow-id> --apply` before editing. On a protected workflow, an update saves a draft and executions continue using the published version. Review the draft and rehearsal result before publishing.
|
|
79
78
|
|
|
80
79
|
For Team Files seeding, preview first, then use exactly the checksum returned by that
|
|
81
80
|
preview:
|
|
@@ -85,6 +84,59 @@ zl --environment <us-prod|eu-prod> file seed --source-team-id <source-team-ref>
|
|
|
85
84
|
zl --environment <us-prod|eu-prod> file seed --source-team-id <source-team-ref> --source-path /Fixtures --target-path /Rehearsal --apply --expected-checksum <sha256>
|
|
86
85
|
```
|
|
87
86
|
|
|
87
|
+
## Keep workflow step outputs small
|
|
88
|
+
|
|
89
|
+
When authoring or reviewing a workflow that reads worksheets, loops over rows, or waits for review:
|
|
90
|
+
|
|
91
|
+
1. Save bulk rows, write plans, and readback evidence once as run-scoped file artifacts. Pass references and only the fields the next step uses, such as worksheet ID, row count, and verification status. Resolve an artifact at the step that consumes it.
|
|
92
|
+
2. At projection steps, set `includeInputFields: false` on Set nodes and map the required fields explicitly. In Python Code, emit only those fields in each returned item. Check expressions for whole-node reads such as `$('Read Rows').first().json`, especially in loops and before Wait nodes.
|
|
93
|
+
3. Carry a compact review manifest across a Wait. Preserve the locked environment, the artifact reference and hash, and approved action IDs and hashes where the flow uses them. After a write, retain the verification result and its evidence reference.
|
|
94
|
+
4. Validate the definition, then run a dedicated test workflow with representative test data and sandbox or mocked write integrations. Exercise approval, resume, and post-write verification. Inspect the largest step outputs and confirm the worksheet data appears only where consumed. `workflow run --dry-run` previews invocation. Measure outputs from the test run.
|
|
95
|
+
|
|
96
|
+
For a workbook verification → journal-source planning handoff, pass the readback artifact reference, worksheet ID, row count, and verification result. The planning node can read the artifact when it needs the rows.
|
|
97
|
+
|
|
98
|
+
Use the payload audit when building or changing a workflow that handles bulk inputs:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
zl --environment <us-prod|eu-prod> workflow validate ./draft.json
|
|
102
|
+
zl --environment <us-prod|eu-prod> workflow validate ./draft.json --fix ./fields.json --output ./projected.json
|
|
103
|
+
zl --environment <us-prod|eu-prod> workflow rehearse <workflow-id> --fixture ./cases.json
|
|
104
|
+
zl --environment <us-prod|eu-prod> workflow publish <workflow-id> --fixture ./cases.json --apply
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Each entry in `fields.json` maps a Set node name to its complete output field map. Include every field its consumers need. A map such as
|
|
108
|
+
`{"Prepare Review":{"period":"{{ $json.period }}","fileRef":"{{ $json.rowsFile.fileRef }}"}}`
|
|
109
|
+
sets `includeInputFields` to false and writes a separate workflow file. Review the diff and apply it as a draft update before rehearsing. Use Sheets file output and update downstream file inputs when a consumer needs the full rows.
|
|
110
|
+
|
|
111
|
+
Rehearsal runs in isolation in the workflow’s region. The rehearsal file has a `cases` array. Each case names a trigger in `start`, supplies trigger JSON items in `input`, and maps node names to `mocks`. Each mock has an `outputs` array of ports, each containing an array of JSON items. Set `mergeInput: true` when the real connector includes its incoming fields. Set, If, Merge, and Split In Batches run as defined. Supply a mock for every other node the case reaches, including connectors, waits, sub-workflows, and custom code. For a Wait, a mock can return synthetic approval data on the port leading to the resume path.
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"cases": [
|
|
116
|
+
{
|
|
117
|
+
"name": "Month-end approval",
|
|
118
|
+
"start": "Form",
|
|
119
|
+
"input": [{ "period": "October" }],
|
|
120
|
+
"mocks": {
|
|
121
|
+
"Read Rows": {
|
|
122
|
+
"mergeInput": true,
|
|
123
|
+
"outputs": [[{ "rows": [[1, "sample"]], "rowsFile": { "fileRef": "synthetic-rows" } }]]
|
|
124
|
+
},
|
|
125
|
+
"Approve": { "mergeInput": true, "outputs": [[{ "approved": true }]] },
|
|
126
|
+
"Write": { "outputs": [[{ "status": "verified" }]] }
|
|
127
|
+
},
|
|
128
|
+
"expect": {
|
|
129
|
+
"Read Rows": { "minBytes": 500000 },
|
|
130
|
+
"Prepare Review": { "maxBytes": 8192 },
|
|
131
|
+
"Write": { "minAttempts": 1 }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Replace the sample row with representative synthetic month-end data before running this case. For a file-output connector, simulate the actual reference and metadata shape. Set the size minimum on a node that handles inline rows. Adjust assertions to the workflow's expected payloads and iteration counts. The report shows the mocked nodes, attempts, maximum bytes per attempt, and cumulative bytes for each node. Check both approval outcomes in separate cases when both affect control flow. The guarded publish command reruns the fixture on the current protected draft and rejects failed coverage, exceeded budgets, and edits that change the draft checksum before publish.
|
|
139
|
+
|
|
88
140
|
## Pages and Motion work
|
|
89
141
|
|
|
90
142
|
Pages use Markdown files with a revision marker. Export before editing, then preview
|