@xyne/workflow-sdk 3.2.44 → 3.2.45
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/dist/authz/types.d.ts +8 -2
- package/dist/authz/types.d.ts.map +1 -1
- package/dist/authz/types.js +8 -1
- package/dist/authz/types.js.map +1 -1
- package/dist/client/events-client.d.ts +5 -1
- package/dist/client/events-client.d.ts.map +1 -1
- package/dist/client/events-client.js +6 -2
- package/dist/client/events-client.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +87 -19
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/workflow-client.d.ts.map +1 -1
- package/dist/client/workflow-client.js +102 -32
- package/dist/client/workflow-client.js.map +1 -1
- package/dist/common/credentials.d.ts +5 -0
- package/dist/common/credentials.d.ts.map +1 -1
- package/dist/common/credentials.js.map +1 -1
- package/dist/engine/config-validator.d.ts +15 -0
- package/dist/engine/config-validator.d.ts.map +1 -1
- package/dist/engine/config-validator.js +52 -0
- package/dist/engine/config-validator.js.map +1 -1
- package/dist/events/types.d.ts +37 -4
- package/dist/events/types.d.ts.map +1 -1
- package/dist/events/types.js +11 -1
- package/dist/events/types.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/persistence/in-memory-adapter.d.ts +34 -18
- package/dist/persistence/in-memory-adapter.d.ts.map +1 -1
- package/dist/persistence/in-memory-adapter.js +294 -37
- package/dist/persistence/in-memory-adapter.js.map +1 -1
- package/dist/persistence/types.d.ts +181 -20
- package/dist/persistence/types.d.ts.map +1 -1
- package/dist/router/workflow-router.d.ts.map +1 -1
- package/dist/router/workflow-router.js +154 -58
- package/dist/router/workflow-router.js.map +1 -1
- package/dist/runtime/paging.d.ts +29 -0
- package/dist/runtime/paging.d.ts.map +1 -0
- package/dist/runtime/paging.js +34 -0
- package/dist/runtime/paging.js.map +1 -0
- package/dist/runtime/types.d.ts +59 -9
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/workflow-runtime.d.ts +95 -25
- package/dist/runtime/workflow-runtime.d.ts.map +1 -1
- package/dist/runtime/workflow-runtime.js +350 -147
- package/dist/runtime/workflow-runtime.js.map +1 -1
- package/dist/schema/config-check.d.ts +63 -0
- package/dist/schema/config-check.d.ts.map +1 -0
- package/dist/schema/config-check.js +18 -0
- package/dist/schema/config-check.js.map +1 -0
- package/dist/schema/options.d.ts +6 -6
- package/dist/schema/options.d.ts.map +1 -1
- package/dist/steps/base-step.d.ts +15 -0
- package/dist/steps/base-step.d.ts.map +1 -1
- package/dist/steps/base-step.js.map +1 -1
- package/dist/testing/authz-conformance.d.ts.map +1 -1
- package/dist/testing/authz-conformance.js +10 -5
- package/dist/testing/authz-conformance.js.map +1 -1
- package/dist/triggers/base-trigger.d.ts +15 -0
- package/dist/triggers/base-trigger.d.ts.map +1 -1
- package/dist/triggers/base-trigger.js.map +1 -1
- package/dist/types/approval.d.ts +46 -0
- package/dist/types/approval.d.ts.map +1 -0
- package/dist/types/approval.js +11 -0
- package/dist/types/approval.js.map +1 -0
- package/dist/types/component-ref.d.ts +18 -0
- package/dist/types/component-ref.d.ts.map +1 -0
- package/dist/types/component-ref.js +2 -0
- package/dist/types/component-ref.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/literal.d.ts +19 -0
- package/dist/types/literal.d.ts.map +1 -0
- package/dist/types/literal.js +2 -0
- package/dist/types/literal.js.map +1 -0
- package/dist/types/validation.d.ts +16 -1
- package/dist/types/validation.d.ts.map +1 -1
- package/dist/types/validation.js +15 -0
- package/dist/types/validation.js.map +1 -1
- package/dist/util/approval-gate.d.ts +26 -0
- package/dist/util/approval-gate.d.ts.map +1 -0
- package/dist/util/approval-gate.js +35 -0
- package/dist/util/approval-gate.js.map +1 -0
- package/dist/util/literal-values.d.ts +22 -0
- package/dist/util/literal-values.d.ts.map +1 -0
- package/dist/util/literal-values.js +55 -0
- package/dist/util/literal-values.js.map +1 -0
- package/package.json +1 -1
- package/dist/common/expression-eval.d.ts +0 -35
- package/dist/common/expression-eval.d.ts.map +0 -1
- package/dist/common/expression-eval.js +0 -214
- package/dist/common/expression-eval.js.map +0 -1
- package/dist/common/principal.d.ts +0 -45
- package/dist/common/principal.d.ts.map +0 -1
- package/dist/common/principal.js +0 -9
- package/dist/common/principal.js.map +0 -1
- package/dist/connectors/builtin/steps/repeat.step.d.ts +0 -126
- package/dist/connectors/builtin/steps/repeat.step.d.ts.map +0 -1
- package/dist/connectors/builtin/steps/repeat.step.js +0 -144
- package/dist/connectors/builtin/steps/repeat.step.js.map +0 -1
- package/dist/runtime/execution-event-bus.d.ts +0 -38
- package/dist/runtime/execution-event-bus.d.ts.map +0 -1
- package/dist/runtime/execution-event-bus.js +0 -87
- package/dist/runtime/execution-event-bus.js.map +0 -1
- package/dist/steps/builtin/code.step.d.ts +0 -99
- package/dist/steps/builtin/code.step.d.ts.map +0 -1
- package/dist/steps/builtin/code.step.js +0 -152
- package/dist/steps/builtin/code.step.js.map +0 -1
- package/dist/steps/builtin/conditional.step.d.ts +0 -182
- package/dist/steps/builtin/conditional.step.d.ts.map +0 -1
- package/dist/steps/builtin/conditional.step.js +0 -82
- package/dist/steps/builtin/conditional.step.js.map +0 -1
- package/dist/steps/builtin/dedup.step.d.ts +0 -65
- package/dist/steps/builtin/dedup.step.d.ts.map +0 -1
- package/dist/steps/builtin/dedup.step.js +0 -61
- package/dist/steps/builtin/dedup.step.js.map +0 -1
- package/dist/steps/builtin/http-request.step.d.ts +0 -1020
- package/dist/steps/builtin/http-request.step.d.ts.map +0 -1
- package/dist/steps/builtin/http-request.step.js +0 -491
- package/dist/steps/builtin/http-request.step.js.map +0 -1
- package/dist/steps/builtin/loop.step.d.ts +0 -100
- package/dist/steps/builtin/loop.step.d.ts.map +0 -1
- package/dist/steps/builtin/loop.step.js +0 -73
- package/dist/steps/builtin/loop.step.js.map +0 -1
- package/dist/steps/builtin/map.step.d.ts +0 -148
- package/dist/steps/builtin/map.step.d.ts.map +0 -1
- package/dist/steps/builtin/map.step.js +0 -111
- package/dist/steps/builtin/map.step.js.map +0 -1
- package/dist/steps/builtin/parallel.step.d.ts +0 -246
- package/dist/steps/builtin/parallel.step.d.ts.map +0 -1
- package/dist/steps/builtin/parallel.step.js +0 -175
- package/dist/steps/builtin/parallel.step.js.map +0 -1
- package/dist/steps/builtin/ssrf-guard.d.ts +0 -9
- package/dist/steps/builtin/ssrf-guard.d.ts.map +0 -1
- package/dist/steps/builtin/ssrf-guard.js +0 -115
- package/dist/steps/builtin/ssrf-guard.js.map +0 -1
- package/dist/steps/builtin/switch.step.d.ts +0 -235
- package/dist/steps/builtin/switch.step.d.ts.map +0 -1
- package/dist/steps/builtin/switch.step.js +0 -101
- package/dist/steps/builtin/switch.step.js.map +0 -1
- package/dist/steps/builtin/transform.step.d.ts +0 -247
- package/dist/steps/builtin/transform.step.d.ts.map +0 -1
- package/dist/steps/builtin/transform.step.js +0 -135
- package/dist/steps/builtin/transform.step.js.map +0 -1
- package/dist/steps/builtin/wait.step.d.ts +0 -1072
- package/dist/steps/builtin/wait.step.d.ts.map +0 -1
- package/dist/steps/builtin/wait.step.js +0 -254
- package/dist/steps/builtin/wait.step.js.map +0 -1
- package/dist/steps/step-registry.d.ts +0 -62
- package/dist/steps/step-registry.d.ts.map +0 -1
- package/dist/steps/step-registry.js +0 -103
- package/dist/steps/step-registry.js.map +0 -1
- package/dist/triggers/builtin/default-cron-trigger.d.ts +0 -44
- package/dist/triggers/builtin/default-cron-trigger.d.ts.map +0 -1
- package/dist/triggers/builtin/default-cron-trigger.js +0 -31
- package/dist/triggers/builtin/default-cron-trigger.js.map +0 -1
- package/dist/triggers/builtin/default-event-trigger.d.ts +0 -32
- package/dist/triggers/builtin/default-event-trigger.d.ts.map +0 -1
- package/dist/triggers/builtin/default-event-trigger.js +0 -21
- package/dist/triggers/builtin/default-event-trigger.js.map +0 -1
- package/dist/triggers/builtin/default-manual-trigger.d.ts +0 -45
- package/dist/triggers/builtin/default-manual-trigger.d.ts.map +0 -1
- package/dist/triggers/builtin/default-manual-trigger.js +0 -51
- package/dist/triggers/builtin/default-manual-trigger.js.map +0 -1
- package/dist/triggers/builtin/default-webhook-trigger.d.ts +0 -72
- package/dist/triggers/builtin/default-webhook-trigger.d.ts.map +0 -1
- package/dist/triggers/builtin/default-webhook-trigger.js +0 -91
- package/dist/triggers/builtin/default-webhook-trigger.js.map +0 -1
- package/dist/triggers/builtin/default-webhook-v2-trigger.d.ts +0 -29
- package/dist/triggers/builtin/default-webhook-v2-trigger.d.ts.map +0 -1
- package/dist/triggers/builtin/default-webhook-v2-trigger.js +0 -38
- package/dist/triggers/builtin/default-webhook-v2-trigger.js.map +0 -1
- package/dist/triggers/trigger-registry.d.ts +0 -48
- package/dist/triggers/trigger-registry.d.ts.map +0 -1
- package/dist/triggers/trigger-registry.js +0 -83
- package/dist/triggers/trigger-registry.js.map +0 -1
- package/dist/types/attachment.d.ts +0 -23
- package/dist/types/attachment.d.ts.map +0 -1
- package/dist/types/attachment.js +0 -2
- package/dist/types/attachment.js.map +0 -1
- package/dist/types/resume-payload.d.ts +0 -34
- package/dist/types/resume-payload.d.ts.map +0 -1
- package/dist/types/resume-payload.js +0 -12
- package/dist/types/resume-payload.js.map +0 -1
- package/dist/util/executable-check.d.ts +0 -42
- package/dist/util/executable-check.d.ts.map +0 -1
- package/dist/util/executable-check.js +0 -115
- package/dist/util/executable-check.js.map +0 -1
|
@@ -28,7 +28,7 @@ import { createChatAgentTools } from '../agents/builtin/chat-tools.js';
|
|
|
28
28
|
import { buildWorkflowContext, buildExecutionDataFile, collectExecutionAttachments, EXECUTION_DATA_PATH } from './approval-context.js';
|
|
29
29
|
import { OPERATOR_DESCRIPTORS } from '../types/operators.js';
|
|
30
30
|
import { getAvailableContext } from '../engine/available-context.js';
|
|
31
|
-
import { executionTopic, workflowTopic } from '../events/types.js';
|
|
31
|
+
import { executionTopic, workflowTopic, folderTopic } from '../events/types.js';
|
|
32
32
|
import { isExecutable } from '../common/executable-check.js';
|
|
33
33
|
import { createEventChannel } from '../util/event-channel.js';
|
|
34
34
|
import { AccessDeniedError, ResourceNotFoundError } from '../authz/default.js';
|
|
@@ -182,6 +182,27 @@ function parseIdList(raw) {
|
|
|
182
182
|
}
|
|
183
183
|
return [...ids];
|
|
184
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Read the paging parameters off a query string. `limit` and `cursor` are the
|
|
187
|
+
* only two — there is deliberately no `offset`.
|
|
188
|
+
*
|
|
189
|
+
* Shape only; the runtime's `resolvePage` decides the default and the cap.
|
|
190
|
+
*/
|
|
191
|
+
function readPage(query) {
|
|
192
|
+
const page = {};
|
|
193
|
+
const limit = query['limit'];
|
|
194
|
+
const cursor = query['cursor'];
|
|
195
|
+
if (typeof limit === 'string')
|
|
196
|
+
page.limit = Number(limit);
|
|
197
|
+
if (typeof cursor === 'string' && cursor !== '')
|
|
198
|
+
page.cursor = cursor;
|
|
199
|
+
return page;
|
|
200
|
+
}
|
|
201
|
+
/** Read a repeated/comma query param as a string list, or undefined when absent. */
|
|
202
|
+
function readList(raw) {
|
|
203
|
+
const parsed = parseIdList(raw);
|
|
204
|
+
return parsed.length > 0 ? parsed : undefined;
|
|
205
|
+
}
|
|
185
206
|
// ─── Router Factory ───
|
|
186
207
|
export function createWorkflowRouter(
|
|
187
208
|
// `any` for services: the router never touches TServices, only forwards ctx.
|
|
@@ -200,15 +221,31 @@ _opts) {
|
|
|
200
221
|
path: '/workflows',
|
|
201
222
|
handler: async (req, auth) => {
|
|
202
223
|
const q = req.query;
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
224
|
+
const result = await runtime.listWorkflows(asCtx(auth), {
|
|
225
|
+
...readPage(q),
|
|
226
|
+
...(typeof q['folderId'] === 'string' ? { folderId: q['folderId'] } : {}),
|
|
227
|
+
});
|
|
228
|
+
return ok({ workflows: result.items, nextCursor: result.nextCursor });
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
// Workflows awaiting review. Registered before `/workflows/:id`, for the
|
|
232
|
+
// same reason `counts` is: otherwise "pending" is captured as an :id.
|
|
233
|
+
routes.push({
|
|
234
|
+
method: 'GET',
|
|
235
|
+
path: '/workflows/pending',
|
|
236
|
+
handler: async (req, auth) => ok(await runtime.listPendingWorkflows(asCtx(auth), readPage(req.query))),
|
|
237
|
+
});
|
|
238
|
+
// Registered before `/workflows/:id` so "last-runs" isn't captured as an :id.
|
|
239
|
+
routes.push({
|
|
240
|
+
method: 'GET',
|
|
241
|
+
path: '/workflows/last-runs',
|
|
242
|
+
handler: async (req, auth) => {
|
|
243
|
+
const q = req.query;
|
|
244
|
+
const lastRuns = await runtime.lastRunByWorkflow(asCtx(auth), {
|
|
245
|
+
...(typeof q['folderId'] === 'string' ? { folderId: q['folderId'] } : {}),
|
|
246
|
+
...(readList(q['workflowIds']) ? { workflowIds: readList(q['workflowIds']) } : {}),
|
|
247
|
+
});
|
|
248
|
+
return ok({ lastRuns });
|
|
212
249
|
},
|
|
213
250
|
});
|
|
214
251
|
// Counts for the folder rail (total + per-folder). Registered before
|
|
@@ -301,9 +338,9 @@ _opts) {
|
|
|
301
338
|
routes.push({
|
|
302
339
|
method: 'GET',
|
|
303
340
|
path: '/folders',
|
|
304
|
-
handler: async (
|
|
305
|
-
const
|
|
306
|
-
return ok({ folders });
|
|
341
|
+
handler: async (req, auth) => {
|
|
342
|
+
const result = await runtime.listFolders(asCtx(auth), readPage(req.query));
|
|
343
|
+
return ok({ folders: result.items, nextCursor: result.nextCursor });
|
|
307
344
|
},
|
|
308
345
|
});
|
|
309
346
|
routes.push({
|
|
@@ -428,12 +465,14 @@ _opts) {
|
|
|
428
465
|
routes.push({
|
|
429
466
|
method: 'POST',
|
|
430
467
|
path: '/workflows/validate',
|
|
431
|
-
handler: async (req) => {
|
|
468
|
+
handler: async (req, auth) => {
|
|
432
469
|
const config = req.body;
|
|
433
470
|
if (!config || !config['trigger'] || !config['steps']) {
|
|
434
471
|
return badRequest('Body must be a WorkflowConfig with trigger and steps');
|
|
435
472
|
}
|
|
436
|
-
const
|
|
473
|
+
const raw = req.query['workflowId'];
|
|
474
|
+
const workflowId = typeof raw === 'string' && raw !== '' ? raw : undefined;
|
|
475
|
+
const result = await runtime.validateConfig(asCtx(auth), config, workflowId);
|
|
437
476
|
return ok(result);
|
|
438
477
|
},
|
|
439
478
|
});
|
|
@@ -446,8 +485,9 @@ _opts) {
|
|
|
446
485
|
if (!id)
|
|
447
486
|
return badRequest('Missing workflow ID');
|
|
448
487
|
try {
|
|
449
|
-
|
|
450
|
-
|
|
488
|
+
// The outcome, not a bare acknowledgement: activating can end live or
|
|
489
|
+
// in review, and the caller is told which rather than having to re-read.
|
|
490
|
+
return ok(await runtime.activateWorkflow(asCtx(auth), id, readOrigin(req)));
|
|
451
491
|
}
|
|
452
492
|
catch (err) {
|
|
453
493
|
if (err instanceof AccessDeniedError)
|
|
@@ -474,6 +514,42 @@ _opts) {
|
|
|
474
514
|
}
|
|
475
515
|
},
|
|
476
516
|
});
|
|
517
|
+
routes.push({
|
|
518
|
+
method: 'POST',
|
|
519
|
+
path: '/workflows/:id/approve',
|
|
520
|
+
handler: async (req, auth) => {
|
|
521
|
+
const id = req.params['id'];
|
|
522
|
+
if (!id)
|
|
523
|
+
return badRequest('Missing workflow ID');
|
|
524
|
+
try {
|
|
525
|
+
await runtime.approveWorkflow(asCtx(auth), id, readOrigin(req));
|
|
526
|
+
return ok({ approved: true });
|
|
527
|
+
}
|
|
528
|
+
catch (err) {
|
|
529
|
+
if (err instanceof AccessDeniedError)
|
|
530
|
+
throw err;
|
|
531
|
+
return error(400, err instanceof Error ? err.message : 'Approval failed');
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
});
|
|
535
|
+
routes.push({
|
|
536
|
+
method: 'POST',
|
|
537
|
+
path: '/workflows/:id/reject',
|
|
538
|
+
handler: async (req, auth) => {
|
|
539
|
+
const id = req.params['id'];
|
|
540
|
+
if (!id)
|
|
541
|
+
return badRequest('Missing workflow ID');
|
|
542
|
+
try {
|
|
543
|
+
await runtime.rejectWorkflow(asCtx(auth), id, readOrigin(req));
|
|
544
|
+
return ok({ rejected: true });
|
|
545
|
+
}
|
|
546
|
+
catch (err) {
|
|
547
|
+
if (err instanceof AccessDeniedError)
|
|
548
|
+
throw err;
|
|
549
|
+
return error(400, err instanceof Error ? err.message : 'Rejection failed');
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
});
|
|
477
553
|
// ─── Trigger ───
|
|
478
554
|
routes.push({
|
|
479
555
|
method: 'POST',
|
|
@@ -638,14 +714,35 @@ _opts) {
|
|
|
638
714
|
},
|
|
639
715
|
});
|
|
640
716
|
// ─── Executions ───
|
|
641
|
-
// Specific paths before parameterized :execId routes
|
|
717
|
+
// Specific paths before parameterized :execId routes — otherwise
|
|
718
|
+
// "pending-approvals" is captured as an :execId.
|
|
719
|
+
routes.push({
|
|
720
|
+
method: 'GET',
|
|
721
|
+
path: '/executions/pending-approvals/count',
|
|
722
|
+
handler: async (_req, auth) => ok({ count: await runtime.countPendingApprovals(asCtx(auth)) }),
|
|
723
|
+
});
|
|
724
|
+
// Facets cover the whole visible set, not the page in hand.
|
|
725
|
+
routes.push({
|
|
726
|
+
method: 'GET',
|
|
727
|
+
path: '/executions/pending-approvals/facets',
|
|
728
|
+
handler: async (_req, auth) => ok(await runtime.pendingApprovalFacets(asCtx(auth))),
|
|
729
|
+
});
|
|
642
730
|
routes.push({
|
|
643
731
|
method: 'GET',
|
|
644
732
|
path: '/executions/pending-approvals',
|
|
645
733
|
handler: async (req, auth) => {
|
|
646
|
-
const
|
|
647
|
-
const
|
|
648
|
-
return ok(
|
|
734
|
+
const q = req.query;
|
|
735
|
+
const sort = q['sort'];
|
|
736
|
+
return ok(await runtime.listPendingApprovals(asCtx(auth), {
|
|
737
|
+
...readPage(q),
|
|
738
|
+
...(readList(q['workflowIds']) ? { workflowIds: readList(q['workflowIds']) } : {}),
|
|
739
|
+
...(readList(q['stages']) ? { stages: readList(q['stages']) } : {}),
|
|
740
|
+
...(readList(q['tags']) ? { tags: readList(q['tags']) } : {}),
|
|
741
|
+
...(typeof q['search'] === 'string' && q['search'] !== ''
|
|
742
|
+
? { search: q['search'] }
|
|
743
|
+
: {}),
|
|
744
|
+
...(sort === 'oldest' || sort === 'newest' ? { sort } : {}),
|
|
745
|
+
}));
|
|
649
746
|
},
|
|
650
747
|
});
|
|
651
748
|
routes.push({
|
|
@@ -931,19 +1028,13 @@ _opts) {
|
|
|
931
1028
|
method: 'GET',
|
|
932
1029
|
path: '/executions',
|
|
933
1030
|
handler: async (req, auth) => {
|
|
934
|
-
const
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
params.limit = Number(query['limit']);
|
|
942
|
-
if (typeof query['cursor'] === 'string')
|
|
943
|
-
params.cursor = query['cursor'];
|
|
944
|
-
if (typeof query['folderId'] === 'string')
|
|
945
|
-
params.folderId = query['folderId'];
|
|
946
|
-
const result = await runtime.listExecutions(asCtx(auth), params);
|
|
1031
|
+
const q = req.query;
|
|
1032
|
+
const result = await runtime.listExecutions(asCtx(auth), {
|
|
1033
|
+
...readPage(q),
|
|
1034
|
+
...(typeof q['workflowId'] === 'string' ? { workflowId: q['workflowId'] } : {}),
|
|
1035
|
+
...(typeof q['status'] === 'string' ? { status: q['status'] } : {}),
|
|
1036
|
+
...(typeof q['folderId'] === 'string' ? { folderId: q['folderId'] } : {}),
|
|
1037
|
+
});
|
|
947
1038
|
return ok(result);
|
|
948
1039
|
},
|
|
949
1040
|
});
|
|
@@ -1003,10 +1094,7 @@ _opts) {
|
|
|
1003
1094
|
}
|
|
1004
1095
|
},
|
|
1005
1096
|
});
|
|
1006
|
-
const findCredential = async (auth, name) =>
|
|
1007
|
-
const all = await runtime.listCredentials(asCtx(auth));
|
|
1008
|
-
return all.find((credential) => credential.summary.name === name);
|
|
1009
|
-
};
|
|
1097
|
+
const findCredential = async (auth, name) => (await runtime.getCredentialByName(asCtx(auth), name)) ?? undefined;
|
|
1010
1098
|
// ── GET /credentials ──
|
|
1011
1099
|
// Returns a page of visible credential summaries (ACTIVE and REVOKED).
|
|
1012
1100
|
// Never decrypts or returns stored values.
|
|
@@ -1014,14 +1102,8 @@ _opts) {
|
|
|
1014
1102
|
method: 'GET',
|
|
1015
1103
|
path: '/credentials',
|
|
1016
1104
|
handler: async (req, auth) => {
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1019
|
-
if (typeof q['limit'] === 'string')
|
|
1020
|
-
page.limit = Number(q['limit']);
|
|
1021
|
-
if (typeof q['offset'] === 'string')
|
|
1022
|
-
page.offset = Number(q['offset']);
|
|
1023
|
-
const credentials = await runtime.listCredentials(asCtx(auth), page);
|
|
1024
|
-
return ok({ credentials });
|
|
1105
|
+
const result = await runtime.listCredentials(asCtx(auth), readPage(req.query));
|
|
1106
|
+
return ok({ credentials: result.items, nextCursor: result.nextCursor });
|
|
1025
1107
|
},
|
|
1026
1108
|
});
|
|
1027
1109
|
// ── POST /credentials ──
|
|
@@ -1250,10 +1332,14 @@ _opts) {
|
|
|
1250
1332
|
//
|
|
1251
1333
|
// Frames are notifications, not payloads: `workflow_changed` says *that* a
|
|
1252
1334
|
// workflow changed, and the client re-reads through the ordinary authorized
|
|
1253
|
-
// GET.
|
|
1254
|
-
//
|
|
1255
|
-
//
|
|
1256
|
-
//
|
|
1335
|
+
// GET. `workflows` and `folders` are accepted, and both carry run-level
|
|
1336
|
+
// notifications (`run_changed`) as well as definition changes — that is what
|
|
1337
|
+
// lets a list stay fresh without a timer.
|
|
1338
|
+
//
|
|
1339
|
+
// A live execution keeps its own richer stream at `/executions/:execId/stream`,
|
|
1340
|
+
// which patches step state in place rather than re-reading; duplicating it
|
|
1341
|
+
// here would give it two meanings. The query shape is keyed by entity so
|
|
1342
|
+
// further families slot in unchanged.
|
|
1257
1343
|
routes.push({
|
|
1258
1344
|
method: 'GET',
|
|
1259
1345
|
path: '/events',
|
|
@@ -1262,9 +1348,14 @@ _opts) {
|
|
|
1262
1348
|
if (!eventBus) {
|
|
1263
1349
|
return error(501, 'Event streaming not configured');
|
|
1264
1350
|
}
|
|
1265
|
-
const
|
|
1351
|
+
const workflowIds = parseIdList(req.query['workflows']);
|
|
1352
|
+
const folderIds = parseIdList(req.query['folders']);
|
|
1353
|
+
const requested = [
|
|
1354
|
+
...workflowIds.map((id) => ({ kind: 'workflow', id })),
|
|
1355
|
+
...folderIds.map((id) => ({ kind: 'folder', id })),
|
|
1356
|
+
];
|
|
1266
1357
|
if (requested.length === 0) {
|
|
1267
|
-
return badRequest('Specify at least one id, e.g. ?workflows=a,b');
|
|
1358
|
+
return badRequest('Specify at least one id, e.g. ?workflows=a,b or ?folders=f1');
|
|
1268
1359
|
}
|
|
1269
1360
|
if (requested.length > MAX_STREAM_TOPICS) {
|
|
1270
1361
|
return badRequest(`Too many topics (${String(requested.length)}); the limit is ${String(MAX_STREAM_TOPICS)}`);
|
|
@@ -1277,19 +1368,24 @@ _opts) {
|
|
|
1277
1368
|
// that would take down every other topic the client is watching, and access
|
|
1278
1369
|
// can be lost mid-session. The `ready` frame reports what was accepted, so
|
|
1279
1370
|
// the client is never left believing it is watching something it is not.
|
|
1371
|
+
// Each id authorized through the same read the client would do — a folder
|
|
1372
|
+
// is no more subscribable than it is readable.
|
|
1280
1373
|
const subscribed = [];
|
|
1281
1374
|
const rejected = [];
|
|
1282
|
-
await Promise.all(requested.map(async (
|
|
1375
|
+
await Promise.all(requested.map(async (topic) => {
|
|
1283
1376
|
try {
|
|
1284
|
-
|
|
1285
|
-
|
|
1377
|
+
if (topic.kind === 'workflow')
|
|
1378
|
+
await runtime.getWorkflow(asCtx(auth), topic.id);
|
|
1379
|
+
else
|
|
1380
|
+
await runtime.getFolder(asCtx(auth), topic.id);
|
|
1381
|
+
subscribed.push(topic);
|
|
1286
1382
|
}
|
|
1287
1383
|
catch {
|
|
1288
|
-
rejected.push(id);
|
|
1384
|
+
rejected.push(topic.id);
|
|
1289
1385
|
}
|
|
1290
1386
|
}));
|
|
1291
1387
|
const channel = createEventChannel();
|
|
1292
|
-
const results = await Promise.allSettled(subscribed.map((
|
|
1388
|
+
const results = await Promise.allSettled(subscribed.map((topic) => eventBus.subscribe(topic.kind === 'workflow' ? workflowTopic(topic.id) : folderTopic(topic.id), channel.push)));
|
|
1293
1389
|
const unsubs = results.flatMap((r) => r.status === 'fulfilled' ? [r.value] : []);
|
|
1294
1390
|
if (unsubs.length !== results.length) {
|
|
1295
1391
|
// A partially-subscribed stream is worse than none: it looks live and is
|
|
@@ -1307,7 +1403,7 @@ _opts) {
|
|
|
1307
1403
|
try {
|
|
1308
1404
|
// Sent before anything else so the client knows the subscription is
|
|
1309
1405
|
// live and which topics it actually got.
|
|
1310
|
-
yield formatSSE('ready', { subscribed, rejected });
|
|
1406
|
+
yield formatSSE('ready', { subscribed: subscribed.map((t) => t.id), rejected });
|
|
1311
1407
|
for await (const frame of channel) {
|
|
1312
1408
|
yield frame === KEEPALIVE ? SSE_KEEPALIVE : formatSSE(frame.event, frame.data);
|
|
1313
1409
|
}
|