@lostgradient/weft 0.12.0 → 0.14.0
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 +1 -1
- package/dist/cli/api.d.ts +2 -0
- package/dist/cli/api.js +3 -4
- package/dist/cli/generated/operation-catalog.snapshot.json +508 -12
- package/dist/cli/generated/operation-client.generated.d.ts +118 -10
- package/dist/cli/generated/operation-client.generated.js +74 -1
- package/dist/cli/help-text.d.ts +3 -3
- package/dist/cli/help-text.js +4 -4
- package/dist/cli/operation-catalog-snapshot.d.ts +12 -3
- package/dist/cli/operation-catalog-snapshot.js +14 -5
- package/dist/cli/operation-client-runtime.d.ts +29 -0
- package/dist/cli/schedule.js +1 -3
- package/dist/cli/serve-registrations.d.ts +3 -3
- package/dist/cli/serve-registrations.js +2 -2
- package/dist/cli/shutdown.d.ts +11 -0
- package/dist/cli/shutdown.js +25 -0
- package/dist/cli/validate.d.ts +1 -1
- package/dist/cli/version-check.d.ts +1 -1
- package/dist/cli/version-check.js +1 -1
- package/dist/cli-main.js +10 -29
- package/dist/client/client-storage.d.ts +24 -0
- package/dist/client/client-storage.js +14 -0
- package/dist/client/handle-delegation.d.ts +3 -3
- package/dist/client/handle-delegation.js +2 -2
- package/dist/client/http-client-requests.d.ts +5 -3
- package/dist/client/http-client-requests.js +20 -2
- package/dist/client/http-client-storage.d.ts +3 -0
- package/dist/client/http-client-storage.js +82 -0
- package/dist/client/http-client.d.ts +9 -6
- package/dist/client/http-client.js +13 -18
- package/dist/client/http-operations.d.ts +3 -1
- package/dist/client/http-operations.js +77 -1
- package/dist/client/http-request.d.ts +20 -14
- package/dist/client/http-request.js +21 -31
- package/dist/client/in-process-operations.d.ts +2 -2
- package/dist/client/in-process-operations.js +2 -2
- package/dist/client/index.d.ts +5 -1
- package/dist/client/index.js +13 -2
- package/dist/client/interface.d.ts +26 -26
- package/dist/client/local.d.ts +9 -6
- package/dist/client/local.js +9 -4
- package/dist/client/search-params.js +10 -6
- package/dist/client/start-body.d.ts +3 -1
- package/dist/client/start-body.js +9 -0
- package/dist/core/bulk-workflow-filter.d.ts +2 -1
- package/dist/core/bulk-workflow-filter.js +5 -1
- package/dist/core/context/parallel-operations.d.ts +0 -2
- package/dist/core/context/parallel-operations.js +0 -7
- package/dist/core/engine/async-activity-records.d.ts +12 -1
- package/dist/core/engine/async-activity-records.js +81 -2
- package/dist/core/engine/bulk-operations-purge.js +16 -1
- package/dist/core/engine/bulk-operations-shared.js +2 -0
- package/dist/core/engine/callback-checkpoint-persistence.d.ts +2 -0
- package/dist/core/engine/callback-checkpoint-persistence.js +6 -3
- package/dist/core/engine/callback-creators-schedule.d.ts +2 -1
- package/dist/core/engine/callback-creators-schedule.js +3 -3
- package/dist/core/engine/callback-creators.js +4 -22
- package/dist/core/engine/checkpoint-io.d.ts +1 -1
- package/dist/core/engine/checkpoint-reads.js +11 -1
- package/dist/core/engine/child-workflow.js +15 -6
- package/dist/core/engine/construction.js +3 -0
- package/dist/core/engine/disposal.js +2 -0
- package/dist/core/engine/engine-internal-types.d.ts +4 -1
- package/dist/core/engine/fenced-write.d.ts +5 -3
- package/dist/core/engine/finalizer-status.d.ts +10 -0
- package/dist/core/engine/finalizer-status.js +82 -0
- package/dist/core/engine/index.d.ts +26 -2
- package/dist/core/engine/index.js +71 -8
- package/dist/core/engine/internals.d.ts +3 -0
- package/dist/core/engine/lease-health.d.ts +64 -0
- package/dist/core/engine/lease-health.js +0 -0
- package/dist/core/engine/lease-manager.d.ts +4 -2
- package/dist/core/engine/lease-manager.js +32 -4
- package/dist/core/engine/lifecycle/recovered-services.js +0 -2
- package/dist/core/engine/lifecycle/shared.d.ts +11 -8
- package/dist/core/engine/lifecycle/start-batch.js +12 -0
- package/dist/core/engine/lifecycle/start.d.ts +1 -1
- package/dist/core/engine/lifecycle/start.js +34 -5
- package/dist/core/engine/operations-coordination.d.ts +1 -12
- package/dist/core/engine/operations-coordination.js +58 -11
- package/dist/core/engine/operations-speculate.d.ts +1 -1
- package/dist/core/engine/operations-speculate.js +19 -5
- package/dist/core/engine/parallel-dispatch.d.ts +1 -1
- package/dist/core/engine/parallel-dispatch.js +1 -1
- package/dist/core/engine/registration.js +14 -0
- package/dist/core/engine/review-list-entries.d.ts +1 -1
- package/dist/core/engine/review-list-entries.js +6 -30
- package/dist/core/engine/schedule-handle.d.ts +4 -4
- package/dist/core/engine/schedule-handle.js +2 -2
- package/dist/core/engine/schedule-overlap.d.ts +11 -0
- package/dist/core/engine/schedule-overlap.js +50 -0
- package/dist/core/engine/schedule-run.d.ts +11 -3
- package/dist/core/engine/schedule-run.js +27 -4
- package/dist/core/engine/schedule-timer.js +10 -1
- package/dist/core/engine/schedules.d.ts +5 -4
- package/dist/core/engine/schedules.js +62 -56
- package/dist/core/engine/state-utilities.js +1 -1
- package/dist/core/engine/storage-io.d.ts +12 -0
- package/dist/core/engine/storage-io.js +49 -10
- package/dist/core/engine/termination/finalizer-claim.d.ts +8 -6
- package/dist/core/engine/termination/finalizer-claim.js +2 -1
- package/dist/core/engine/termination/finalizer.js +10 -14
- package/dist/core/engine/timeline-coordinator-constants.d.ts +3 -0
- package/dist/core/engine/timeline-coordinator-constants.js +1 -0
- package/dist/core/engine/timeline-coordinator-detail.d.ts +13 -0
- package/dist/core/engine/timeline-coordinator-detail.js +76 -0
- package/dist/core/engine/validation/schedule-options.d.ts +8 -1
- package/dist/core/engine/validation/schedule-options.js +18 -0
- package/dist/core/engine/validation/schedule.d.ts +1 -1
- package/dist/core/engine/validation/schedule.js +27 -3
- package/dist/core/engine/validation.js +66 -2
- package/dist/core/engine/workflow-state-stream.d.ts +5 -1
- package/dist/core/engine/workflow-state-stream.js +37 -14
- package/dist/core/events/schedule-events.d.ts +3 -4
- package/dist/core/events/workflow-events.d.ts +2 -1
- package/dist/core/list-filter-validation.d.ts +3 -0
- package/dist/core/list-filter-validation.js +11 -0
- package/dist/core/registry-snapshot.d.ts +32 -0
- package/dist/core/registry-snapshot.js +28 -0
- package/dist/core/review/index.d.ts +91 -4
- package/dist/core/review/index.js +29 -0
- package/dist/core/types/activity.d.ts +52 -5
- package/dist/core/types/bulk.d.ts +1 -0
- package/dist/core/types/list-options.d.ts +6 -0
- package/dist/core/types/options.d.ts +6 -5
- package/dist/core/types/reviews.d.ts +2 -2
- package/dist/core/types/schedules.d.ts +45 -2
- package/dist/core/types/services-resolution.d.ts +5 -5
- package/dist/core/types/state.d.ts +64 -0
- package/dist/core/types/workflow-log.d.ts +3 -2
- package/dist/core/types/workflow-observability.d.ts +50 -0
- package/dist/core/types/workflow-observability.js +0 -0
- package/dist/core/types/workflow-registry.d.ts +7 -0
- package/dist/core/types.d.ts +1 -0
- package/dist/core/types.js +1 -0
- package/dist/diagnostics/validate.d.ts +9 -30
- package/dist/diagnostics/validate.js +83 -21
- package/dist/diagnostics/version-check.d.ts +2 -2
- package/dist/http.js +2 -2
- package/dist/index.d.ts +4 -3
- package/dist/indexeddb.js +1 -1
- package/dist/server/access-policy-metadata.d.ts +92 -0
- package/dist/server/access-policy-metadata.js +78 -0
- package/dist/server/fault-to-http.d.ts +3 -7
- package/dist/server/fault-to-http.js +2 -34
- package/dist/server/handler/index.js +1 -1
- package/dist/server/handler/route-dispatch.d.ts +10 -3
- package/dist/server/handler/route-dispatch.js +19 -4
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/interactive-operations.js +2 -0
- package/dist/server/openapi-error-responses.js +41 -4
- package/dist/server/openapi.d.ts +3 -1
- package/dist/server/openapi.js +4 -0
- package/dist/server/openrpc-document-schema.d.ts +64 -0
- package/dist/server/openrpc-document-schema.js +6 -26
- package/dist/server/openrpc.d.ts +4 -0
- package/dist/server/openrpc.js +9 -33
- package/dist/server/operation-catalog/index.d.ts +1 -1
- package/dist/server/operation-catalog/raise-fault.d.ts +2 -1
- package/dist/server/operation-catalog/types.d.ts +2 -1
- package/dist/server/operation-fault.d.ts +22 -8
- package/dist/server/operation-fault.js +65 -13
- package/dist/server/operation-registry.d.ts +1 -1
- package/dist/server/operations/aggregate-workflows.d.ts +6 -0
- package/dist/server/operations/aggregate-workflows.js +3 -2
- package/dist/server/operations/async-activity.d.ts +14 -0
- package/dist/server/operations/async-activity.js +88 -4
- package/dist/server/operations/bulk-filter-helpers.d.ts +3 -0
- package/dist/server/operations/bulk-filter-helpers.js +27 -3
- package/dist/server/operations/bulk-mutate-workflow-tags.d.ts +6 -0
- package/dist/server/operations/bulk-signal-workflows.d.ts +6 -0
- package/dist/server/operations/get-stream-chunks.js +2 -7
- package/dist/server/operations/get-system-lease.d.ts +19 -0
- package/dist/server/operations/get-system-lease.js +48 -0
- package/dist/server/operations/get-workflow-observability.d.ts +24 -0
- package/dist/server/operations/get-workflow-observability.js +80 -0
- package/dist/server/operations/get-workflow-result.js +2 -2
- package/dist/server/operations/get-workflow.d.ts +2 -2
- package/dist/server/operations/list-filter-query-extractor.js +15 -0
- package/dist/server/operations/list-reviews.js +2 -19
- package/dist/server/operations/list-workflows.d.ts +6 -0
- package/dist/server/operations/list-workflows.js +12 -3
- package/dist/server/operations/operation-helpers.d.ts +9 -18
- package/dist/server/operations/operation-helpers.js +5 -23
- package/dist/server/operations/purge-workflows.d.ts +3 -0
- package/dist/server/operations/recover-all.js +1 -9
- package/dist/server/operations/single-workflow-control-operation.d.ts +2 -1
- package/dist/server/operations/single-workflow-tag-mutation.js +2 -2
- package/dist/server/operations/sse-stream.js +2 -7
- package/dist/server/operations/storage-capabilities.d.ts +34 -0
- package/dist/server/operations/storage-capabilities.js +38 -0
- package/dist/server/operations/storage.js +8 -17
- package/dist/server/operations/stream-workflow-sse.js +3 -9
- package/dist/server/operations/update-schedule.d.ts +8 -0
- package/dist/server/operations/update-schedule.js +70 -7
- package/dist/server/operations/workflow-events-sse.js +2 -2
- package/dist/server/rest-binding.d.ts +7 -6
- package/dist/server/rest-bindings.d.ts +2 -13
- package/dist/server/rest-bindings.js +19 -10
- package/dist/server/task-queue.d.ts +7 -5
- package/dist/storage/bounded-ndjson-response.d.ts +5 -0
- package/dist/storage/bounded-ndjson-response.js +33 -0
- package/dist/storage/capabilities.d.ts +1 -1
- package/dist/storage/cloudflare-value-codec.d.ts +5 -3
- package/dist/storage/cloudflare-value-codec.js +1 -1
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/http.js +5 -37
- package/dist/storage/index.d.ts +7 -1
- package/dist/storage/interface.d.ts +16 -4
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +4 -0
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon.d.ts +3 -16
- package/dist/storage/neon.js +4 -4
- package/dist/storage/postgres.js +4 -4
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/testing.js +1 -1
- package/dist/storage/turso.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/web-extension.js +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import type { PendingAsyncActivityPage } from '../../core/types.ts';
|
|
2
3
|
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
3
4
|
declare const completeAsyncActivityInput: z.ZodObject<{
|
|
4
5
|
token: z.ZodString;
|
|
5
6
|
result: z.ZodOptional<z.ZodUnknown>;
|
|
6
7
|
}, z.core.$strip>;
|
|
8
|
+
declare const listPendingAsyncActivitiesInput: z.ZodObject<{
|
|
9
|
+
workflowId: z.ZodString;
|
|
10
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
7
13
|
/**
|
|
8
14
|
* The failure payload is a *serializable* error description, not a live `Error`.
|
|
9
15
|
* The engine already reduces an async-activity failure to `message` + `name`
|
|
@@ -24,6 +30,13 @@ declare const okOutput: z.ZodObject<{
|
|
|
24
30
|
export type CompleteAsyncActivityInput = z.infer<typeof completeAsyncActivityInput>;
|
|
25
31
|
export type FailAsyncActivityInput = z.infer<typeof failAsyncActivityInput>;
|
|
26
32
|
export type AsyncActivityOutput = z.infer<typeof okOutput>;
|
|
33
|
+
export type ListPendingAsyncActivitiesInput = z.infer<typeof listPendingAsyncActivitiesInput>;
|
|
34
|
+
export type ListPendingAsyncActivitiesOutput = PendingAsyncActivityPage;
|
|
35
|
+
export declare const listPendingAsyncActivitiesOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
36
|
+
workflowId: string;
|
|
37
|
+
limit: number;
|
|
38
|
+
cursor?: string | undefined;
|
|
39
|
+
}, PendingAsyncActivityPage, unknown>;
|
|
27
40
|
export declare const completeAsyncActivityOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
28
41
|
token: string;
|
|
29
42
|
result?: unknown;
|
|
@@ -39,6 +52,7 @@ export declare const failAsyncActivityOperation: import("../operation-catalog.ts
|
|
|
39
52
|
}, {
|
|
40
53
|
ok: true;
|
|
41
54
|
}, unknown>;
|
|
55
|
+
export declare const listPendingAsyncActivitiesRestBinding: UnknownRestBinding;
|
|
42
56
|
export declare const completeAsyncActivityRestBinding: UnknownRestBinding;
|
|
43
57
|
export declare const failAsyncActivityRestBinding: UnknownRestBinding;
|
|
44
58
|
export {};
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { AsyncActivityTokenNotFoundError } from "../../core/engine.js";
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_PENDING_ASYNC_ACTIVITY_LIMIT,
|
|
5
|
+
isPendingAsyncActivityCursor,
|
|
6
|
+
isPendingAsyncActivityCursorForWorkflow,
|
|
7
|
+
MAX_PENDING_ASYNC_ACTIVITY_CURSOR_LENGTH,
|
|
8
|
+
MAX_PENDING_ASYNC_ACTIVITY_LIMIT
|
|
9
|
+
} from "../../core/engine/async-activity-records.js";
|
|
3
10
|
import { PayloadSizeExceededError } from "../../core/payload-size.js";
|
|
4
11
|
import { raiseFault } from "../operation-catalog.js";
|
|
5
12
|
import { defineOperation } from "../operation-registry.js";
|
|
6
13
|
import { readRestJsonBody } from "../rest-body.js";
|
|
7
14
|
import { invalidParamsFault, isOperationFault, shapeRestFault } from "./operation-helpers.js";
|
|
8
|
-
const
|
|
15
|
+
const asyncActivityReadAccess = {
|
|
16
|
+
kind: "scoped",
|
|
17
|
+
scopes: { kind: "anyOf", scopes: ["workflows:read"] }
|
|
18
|
+
}, asyncActivityWriteAccess = {
|
|
19
|
+
kind: "scoped",
|
|
20
|
+
scopes: { kind: "anyOf", scopes: ["workflows:write"] }
|
|
21
|
+
}, httpAndJsonRpcTransports = {
|
|
9
22
|
http: !0,
|
|
10
23
|
jsonRpcHttp: !0,
|
|
11
24
|
jsonRpcStdio: !0,
|
|
@@ -13,13 +26,56 @@ const asyncActivityAccess = { kind: "public" }, httpAndJsonRpcTransports = {
|
|
|
13
26
|
}, completeAsyncActivityInput = z.object({
|
|
14
27
|
token: z.string().min(1),
|
|
15
28
|
result: z.unknown().optional()
|
|
16
|
-
}),
|
|
29
|
+
}), pendingAsyncActivityItemSchema = z.object({
|
|
30
|
+
token: z.string(),
|
|
31
|
+
operationId: z.string(),
|
|
32
|
+
activityName: z.string(),
|
|
33
|
+
step: z.number().int().nonnegative(),
|
|
34
|
+
attempt: z.number().int().positive(),
|
|
35
|
+
createdAt: z.number()
|
|
36
|
+
}).strict(), listPendingAsyncActivitiesInput = z.object({
|
|
37
|
+
workflowId: z.string().min(1),
|
|
38
|
+
limit: z.number().int().min(1).max(MAX_PENDING_ASYNC_ACTIVITY_LIMIT).default(DEFAULT_PENDING_ASYNC_ACTIVITY_LIMIT),
|
|
39
|
+
cursor: z.string().max(MAX_PENDING_ASYNC_ACTIVITY_CURSOR_LENGTH).refine(isPendingAsyncActivityCursor, { message: "Invalid cursor" }).optional()
|
|
40
|
+
}), listPendingAsyncActivitiesOutput = z.object({
|
|
41
|
+
items: z.array(pendingAsyncActivityItemSchema),
|
|
42
|
+
nextCursor: z.string().optional()
|
|
43
|
+
}).strict(), failAsyncActivityInput = z.object({
|
|
17
44
|
token: z.string().min(1),
|
|
18
45
|
error: z.object({
|
|
19
46
|
message: z.string(),
|
|
20
47
|
name: z.string().optional()
|
|
21
48
|
})
|
|
22
49
|
}), okOutput = z.object({ ok: z.literal(!0) });
|
|
50
|
+
export const listPendingAsyncActivitiesOperation = defineOperation({
|
|
51
|
+
name: "weft.workflows.activities.pending.list",
|
|
52
|
+
mcpExposable: !1,
|
|
53
|
+
summary: "List pending async activities for a workflow",
|
|
54
|
+
description: "Read a bounded, deterministic page of durable activity task tokens awaiting out-of-band completion. The cursor is opaque and scoped to the selected workflow. A listed token may be consumed concurrently, so a later completion can return NotFound.",
|
|
55
|
+
destructive: !1,
|
|
56
|
+
tags: ["Activities"],
|
|
57
|
+
inputSchema: listPendingAsyncActivitiesInput,
|
|
58
|
+
outputSchema: listPendingAsyncActivitiesOutput,
|
|
59
|
+
access: asyncActivityReadAccess,
|
|
60
|
+
producibleFaults: ["NotFound", "InvalidParams"],
|
|
61
|
+
transports: httpAndJsonRpcTransports,
|
|
62
|
+
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
63
|
+
invoke: async ({ input, engine }) => {
|
|
64
|
+
const liveEngine = engine;
|
|
65
|
+
if (input.cursor !== void 0 && !isPendingAsyncActivityCursorForWorkflow(input.cursor, input.workflowId))
|
|
66
|
+
raiseFault(listPendingAsyncActivitiesOperation, invalidParamsFault("Cursor does not belong to this workflow."));
|
|
67
|
+
if (await liveEngine.get(input.workflowId) === null)
|
|
68
|
+
raiseFault(listPendingAsyncActivitiesOperation, {
|
|
69
|
+
code: "NotFound",
|
|
70
|
+
message: `Workflow "${input.workflowId}" not found`,
|
|
71
|
+
data: { resource: "workflow", identifier: input.workflowId }
|
|
72
|
+
});
|
|
73
|
+
return liveEngine.listPendingAsyncActivities(input.workflowId, {
|
|
74
|
+
limit: input.limit,
|
|
75
|
+
...input.cursor === void 0 ? {} : { cursor: input.cursor }
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
23
79
|
function errorFromFailInput(input) {
|
|
24
80
|
const error = Error(input.error.message);
|
|
25
81
|
if (input.error.name !== void 0)
|
|
@@ -46,7 +102,7 @@ export const completeAsyncActivityOperation = defineOperation({
|
|
|
46
102
|
tags: ["Activities"],
|
|
47
103
|
inputSchema: completeAsyncActivityInput,
|
|
48
104
|
outputSchema: okOutput,
|
|
49
|
-
access:
|
|
105
|
+
access: asyncActivityWriteAccess,
|
|
50
106
|
producibleFaults: ["NotFound", "InvalidParams"],
|
|
51
107
|
transports: httpAndJsonRpcTransports,
|
|
52
108
|
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
@@ -68,7 +124,7 @@ export const completeAsyncActivityOperation = defineOperation({
|
|
|
68
124
|
tags: ["Activities"],
|
|
69
125
|
inputSchema: failAsyncActivityInput,
|
|
70
126
|
outputSchema: okOutput,
|
|
71
|
-
access:
|
|
127
|
+
access: asyncActivityWriteAccess,
|
|
72
128
|
producibleFaults: ["NotFound", "InvalidParams"],
|
|
73
129
|
transports: httpAndJsonRpcTransports,
|
|
74
130
|
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
@@ -88,6 +144,34 @@ function shapeAsyncActivitySuccess(output) {
|
|
|
88
144
|
headers: { "Content-Type": "application/json" }
|
|
89
145
|
});
|
|
90
146
|
}
|
|
147
|
+
function shapePendingAsyncActivitiesSuccess(output) {
|
|
148
|
+
return new Response(JSON.stringify(output), {
|
|
149
|
+
status: 200,
|
|
150
|
+
headers: { "Content-Type": "application/json" }
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
export const listPendingAsyncActivitiesRestBinding = {
|
|
154
|
+
method: "GET",
|
|
155
|
+
path: "/v1/workflows/:id/pending-async-activities",
|
|
156
|
+
pathParamNames: ["id"],
|
|
157
|
+
operationName: "weft.workflows.activities.pending.list",
|
|
158
|
+
inputSources: {
|
|
159
|
+
workflowId: { kind: "path", pathParam: "id" },
|
|
160
|
+
limit: { kind: "query", queryParam: "limit" },
|
|
161
|
+
cursor: { kind: "query", queryParam: "cursor" }
|
|
162
|
+
},
|
|
163
|
+
extractInput: async (request, pathParams) => {
|
|
164
|
+
const search = new URL(request.url).searchParams, limit = search.get("limit"), cursor = search.get("cursor");
|
|
165
|
+
return {
|
|
166
|
+
workflowId: pathParams.id ?? "",
|
|
167
|
+
...limit === null ? {} : { limit: Number(limit) },
|
|
168
|
+
...cursor === null ? {} : { cursor }
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
success: { kind: "json", status: 200 },
|
|
172
|
+
shapeSuccess: (output) => shapePendingAsyncActivitiesSuccess(output),
|
|
173
|
+
shapeFault: shapeRestFault
|
|
174
|
+
};
|
|
91
175
|
async function readJsonObjectBody(request, context) {
|
|
92
176
|
const body = await readRestJsonBody(request, context).catch((error) => {
|
|
93
177
|
if (isOperationFault(error))
|
|
@@ -6,6 +6,9 @@ import type { RestInputContext } from '../rest-binding.ts';
|
|
|
6
6
|
export declare const bulkListFilterInputSchema: z.ZodObject<{
|
|
7
7
|
status: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<WorkflowStatus, WorkflowStatus>, z.ZodArray<z.ZodCustom<WorkflowStatus, WorkflowStatus>>]>>;
|
|
8
8
|
type: z.ZodOptional<z.ZodString>;
|
|
9
|
+
scheduleId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
parentWorkflowId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
parentWorkflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
9
12
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
13
|
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
11
14
|
key: z.ZodString;
|
|
@@ -29,6 +29,9 @@ const workflowStatusSchema = z.custom((value) => typeof value === "string"), sea
|
|
|
29
29
|
export const bulkListFilterInputSchema = z.object({
|
|
30
30
|
status: z.union([workflowStatusSchema, z.array(workflowStatusSchema)]).optional(),
|
|
31
31
|
type: z.string().optional(),
|
|
32
|
+
scheduleId: z.string().min(1).optional(),
|
|
33
|
+
parentWorkflowId: z.string().min(1).optional(),
|
|
34
|
+
parentWorkflowExecutionToken: z.string().min(1).optional(),
|
|
32
35
|
tags: z.array(z.string()).optional(),
|
|
33
36
|
attributes: z.array(attributeFilterSchema).optional(),
|
|
34
37
|
limit: z.number().int().min(0).optional(),
|
|
@@ -117,12 +120,12 @@ function parseFilterStatus(value) {
|
|
|
117
120
|
return value;
|
|
118
121
|
throw Error('Field "filter.status" must be a string or an array of strings');
|
|
119
122
|
}
|
|
120
|
-
function
|
|
123
|
+
function parseOptionalFilterString(value, fieldName) {
|
|
121
124
|
if (value === void 0)
|
|
122
125
|
return;
|
|
123
126
|
if (typeof value === "string")
|
|
124
127
|
return value;
|
|
125
|
-
throw Error(
|
|
128
|
+
throw Error(`Field "filter.${fieldName}" must be a string`);
|
|
126
129
|
}
|
|
127
130
|
function parseOptionalFilterTags(value) {
|
|
128
131
|
if (value === void 0)
|
|
@@ -143,10 +146,25 @@ const BULK_FILTER_DIMENSION_PARSERS = [
|
|
|
143
146
|
filter.status = status;
|
|
144
147
|
},
|
|
145
148
|
(filter, record) => {
|
|
146
|
-
const type =
|
|
149
|
+
const type = parseOptionalFilterString(record.type, "type");
|
|
147
150
|
if (type !== void 0)
|
|
148
151
|
filter.type = type;
|
|
149
152
|
},
|
|
153
|
+
(filter, record) => {
|
|
154
|
+
const scheduleId = parseOptionalFilterString(record.scheduleId, "scheduleId");
|
|
155
|
+
if (scheduleId !== void 0)
|
|
156
|
+
filter.scheduleId = scheduleId;
|
|
157
|
+
},
|
|
158
|
+
(filter, record) => {
|
|
159
|
+
const parentWorkflowId = parseOptionalFilterString(record.parentWorkflowId, "parentWorkflowId");
|
|
160
|
+
if (parentWorkflowId !== void 0)
|
|
161
|
+
filter.parentWorkflowId = parentWorkflowId;
|
|
162
|
+
},
|
|
163
|
+
(filter, record) => {
|
|
164
|
+
const parentWorkflowExecutionToken = parseOptionalFilterString(record.parentWorkflowExecutionToken, "parentWorkflowExecutionToken");
|
|
165
|
+
if (parentWorkflowExecutionToken !== void 0)
|
|
166
|
+
filter.parentWorkflowExecutionToken = parentWorkflowExecutionToken;
|
|
167
|
+
},
|
|
150
168
|
(filter, record) => {
|
|
151
169
|
const tags = parseOptionalFilterTags(record.tags);
|
|
152
170
|
if (tags !== void 0)
|
|
@@ -272,6 +290,12 @@ function copyAttributeRangeBound(value, property) {
|
|
|
272
290
|
return value;
|
|
273
291
|
}
|
|
274
292
|
function applyExtendedBulkFilterFields(filter, input) {
|
|
293
|
+
if (input.scheduleId !== void 0)
|
|
294
|
+
filter.scheduleId = input.scheduleId;
|
|
295
|
+
if (input.parentWorkflowId !== void 0)
|
|
296
|
+
filter.parentWorkflowId = input.parentWorkflowId;
|
|
297
|
+
if (input.parentWorkflowExecutionToken !== void 0)
|
|
298
|
+
filter.parentWorkflowExecutionToken = input.parentWorkflowExecutionToken;
|
|
275
299
|
if (input.idPrefix !== void 0)
|
|
276
300
|
filter.idPrefix = input.idPrefix;
|
|
277
301
|
if (input.failureCategory !== void 0)
|
|
@@ -5,6 +5,9 @@ declare const bulkMutateWorkflowTagsInput: z.ZodObject<{
|
|
|
5
5
|
filter: z.ZodOptional<z.ZodObject<{
|
|
6
6
|
status: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<import("../../index.ts").WorkflowStatus, import("../../index.ts").WorkflowStatus>, z.ZodArray<z.ZodCustom<import("../../index.ts").WorkflowStatus, import("../../index.ts").WorkflowStatus>>]>>;
|
|
7
7
|
type: z.ZodOptional<z.ZodString>;
|
|
8
|
+
scheduleId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
parentWorkflowId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
parentWorkflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
8
11
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9
12
|
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
10
13
|
key: z.ZodString;
|
|
@@ -55,6 +58,9 @@ export declare const bulkMutateWorkflowTagsOperation: import("../operation-catal
|
|
|
55
58
|
filter?: {
|
|
56
59
|
status?: import("../../index.ts").WorkflowStatus | import("../../index.ts").WorkflowStatus[] | undefined;
|
|
57
60
|
type?: string | undefined;
|
|
61
|
+
scheduleId?: string | undefined;
|
|
62
|
+
parentWorkflowId?: string | undefined;
|
|
63
|
+
parentWorkflowExecutionToken?: string | undefined;
|
|
58
64
|
tags?: string[] | undefined;
|
|
59
65
|
attributes?: {
|
|
60
66
|
key: string;
|
|
@@ -4,6 +4,9 @@ import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
|
4
4
|
declare const bulkSignalWorkflowsInput: z.ZodObject<{
|
|
5
5
|
status: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<import("../../index.ts").WorkflowStatus, import("../../index.ts").WorkflowStatus>, z.ZodArray<z.ZodCustom<import("../../index.ts").WorkflowStatus, import("../../index.ts").WorkflowStatus>>]>>;
|
|
6
6
|
type: z.ZodOptional<z.ZodString>;
|
|
7
|
+
scheduleId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
parentWorkflowId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
parentWorkflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
7
10
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
8
11
|
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
9
12
|
key: z.ZodString;
|
|
@@ -48,6 +51,9 @@ export declare const bulkSignalWorkflowsOperation: import("../operation-catalog.
|
|
|
48
51
|
name: string;
|
|
49
52
|
status?: import("../../index.ts").WorkflowStatus | import("../../index.ts").WorkflowStatus[] | undefined;
|
|
50
53
|
type?: string | undefined;
|
|
54
|
+
scheduleId?: string | undefined;
|
|
55
|
+
parentWorkflowId?: string | undefined;
|
|
56
|
+
parentWorkflowExecutionToken?: string | undefined;
|
|
51
57
|
tags?: string[] | undefined;
|
|
52
58
|
attributes?: {
|
|
53
59
|
key: string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { FAULT_CODE_TO_HTTP_STATUS } from "../operation-fault.js";
|
|
3
2
|
import { defineOperation } from "../operation-registry.js";
|
|
4
3
|
import { parseOptionalSequenceCursor } from "../sequence-cursor.js";
|
|
5
|
-
import { invalidParamsFault,
|
|
4
|
+
import { invalidParamsFault, shapeRestFault } from "./operation-helpers.js";
|
|
6
5
|
import { createStoredChunkSSEStream, SSE_RESPONSE_HEADERS } from "./sse-stream.js";
|
|
7
6
|
const getStreamChunksInput = z.object({
|
|
8
7
|
workflowId: z.string().min(1),
|
|
@@ -33,11 +32,7 @@ export const getStreamChunksOperation = defineOperation({
|
|
|
33
32
|
}
|
|
34
33
|
});
|
|
35
34
|
function shapeGetStreamChunksFault(fault) {
|
|
36
|
-
|
|
37
|
-
return jsonErrorResponse(fault.message, 400);
|
|
38
|
-
if (fault.code === "EngineFailure")
|
|
39
|
-
return jsonErrorResponse("Internal server error", 500);
|
|
40
|
-
return jsonErrorResponse(fault.message, FAULT_CODE_TO_HTTP_STATUS[fault.code]);
|
|
35
|
+
return shapeRestFault(fault);
|
|
41
36
|
}
|
|
42
37
|
function shapeGetStreamChunksSuccess(output, request) {
|
|
43
38
|
if ((request.headers.get("Accept") ?? "").includes("text/event-stream"))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weft.system.lease` operation + REST binding.
|
|
3
|
+
*
|
|
4
|
+
* Returns the serving engine process's last-known ownership-lease state. This
|
|
5
|
+
* is deliberately separate from anonymous `GET /v1/health`: load balancers need
|
|
6
|
+
* a stable liveness probe, while holder identifiers and fencing state are scoped
|
|
7
|
+
* operator diagnostics that require `system:read`.
|
|
8
|
+
*
|
|
9
|
+
* @module server/operations/get-system-lease
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { type EngineLeaseHealth } from '../../core/engine.ts';
|
|
13
|
+
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
14
|
+
declare const getSystemLeaseInput: z.ZodObject<{}, z.core.$strip>;
|
|
15
|
+
export type GetSystemLeaseInput = z.infer<typeof getSystemLeaseInput>;
|
|
16
|
+
export type GetSystemLeaseOutput = EngineLeaseHealth;
|
|
17
|
+
export declare const getSystemLeaseOperation: import("../operation-catalog.ts").OperationDefinition<Record<string, never>, EngineLeaseHealth, unknown>;
|
|
18
|
+
export declare const getSystemLeaseRestBinding: UnknownRestBinding;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineOperation } from "../operation-registry.js";
|
|
3
|
+
import { shapeRestFault } from "./operation-helpers.js";
|
|
4
|
+
const getSystemLeaseInput = z.object({}), getSystemLeaseOutput = z.object({
|
|
5
|
+
mode: z.enum(["none", "lease"]),
|
|
6
|
+
status: z.enum(["disabled", "healthy", "no-lease", "contested"]),
|
|
7
|
+
holdsLease: z.boolean(),
|
|
8
|
+
holderId: z.string().min(1).optional(),
|
|
9
|
+
heldSince: z.number().int().nonnegative().optional(),
|
|
10
|
+
expiresAt: z.number().int().nonnegative().optional(),
|
|
11
|
+
lastRenewedAt: z.number().int().nonnegative().optional(),
|
|
12
|
+
fencingEpoch: z.number().int().positive().safe().optional(),
|
|
13
|
+
lossReason: z.enum(["deposed", "renewal-unconfirmable"]).optional()
|
|
14
|
+
}).strict();
|
|
15
|
+
export const getSystemLeaseOperation = defineOperation({
|
|
16
|
+
name: "weft.system.lease",
|
|
17
|
+
mcpExposable: !1,
|
|
18
|
+
summary: "Get ownership-lease health for this engine process",
|
|
19
|
+
description: "Reports whether lease ownership is disabled, not yet held, healthy, or contested. Contested results preserve the confirmed deposed or renewal-unconfirmable reason.",
|
|
20
|
+
destructive: !1,
|
|
21
|
+
tags: ["System"],
|
|
22
|
+
inputSchema: getSystemLeaseInput,
|
|
23
|
+
outputSchema: getSystemLeaseOutput,
|
|
24
|
+
access: {
|
|
25
|
+
kind: "scoped",
|
|
26
|
+
scopes: { kind: "anyOf", scopes: ["system:read"] }
|
|
27
|
+
},
|
|
28
|
+
producibleFaults: [],
|
|
29
|
+
discoverable: !0,
|
|
30
|
+
transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
|
|
31
|
+
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
32
|
+
invoke: async ({ engine }) => {
|
|
33
|
+
return engine.getLeaseHealth();
|
|
34
|
+
}
|
|
35
|
+
}), getSystemLeaseRestBinding = {
|
|
36
|
+
method: "GET",
|
|
37
|
+
path: "/v1/system/lease",
|
|
38
|
+
pathParamNames: [],
|
|
39
|
+
operationName: "weft.system.lease",
|
|
40
|
+
inputSources: {},
|
|
41
|
+
extractInput: async () => ({}),
|
|
42
|
+
success: { kind: "json", status: 200 },
|
|
43
|
+
shapeSuccess: (output) => new Response(JSON.stringify(output), {
|
|
44
|
+
status: 200,
|
|
45
|
+
headers: { "Content-Type": "application/json" }
|
|
46
|
+
}),
|
|
47
|
+
shapeFault: shapeRestFault
|
|
48
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { WorkflowFinalizerStatus, WorkflowScheduleProvenance } from '../../core/types.ts';
|
|
3
|
+
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
4
|
+
declare const workflowObservabilityInput: z.ZodObject<{
|
|
5
|
+
workflowId: z.ZodString;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export type GetWorkflowObservabilityInput = z.infer<typeof workflowObservabilityInput>;
|
|
8
|
+
export type GetWorkflowScheduleProvenanceOutput = WorkflowScheduleProvenance | null;
|
|
9
|
+
export type GetWorkflowFinalizerOutput = WorkflowFinalizerStatus | null;
|
|
10
|
+
export declare const getWorkflowScheduleProvenanceOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
11
|
+
workflowId: string;
|
|
12
|
+
}, GetWorkflowScheduleProvenanceOutput, unknown>;
|
|
13
|
+
export declare const getWorkflowFinalizerOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
14
|
+
workflowId: string;
|
|
15
|
+
}, GetWorkflowFinalizerOutput, unknown>;
|
|
16
|
+
export declare const getWorkflowScheduleProvenanceRestBinding: UnknownRestBinding;
|
|
17
|
+
export declare const getWorkflowFinalizerRestBinding: UnknownRestBinding;
|
|
18
|
+
export declare const workflowObservabilityRestBindings: readonly [UnknownRestBinding, UnknownRestBinding];
|
|
19
|
+
export declare const workflowObservabilityOperations: readonly [import("../operation-catalog.ts").OperationDefinition<{
|
|
20
|
+
workflowId: string;
|
|
21
|
+
}, GetWorkflowScheduleProvenanceOutput, unknown>, import("../operation-catalog.ts").OperationDefinition<{
|
|
22
|
+
workflowId: string;
|
|
23
|
+
}, GetWorkflowFinalizerOutput, unknown>];
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineOperation } from "../operation-registry.js";
|
|
3
|
+
import { shapeRestFault } from "./operation-helpers.js";
|
|
4
|
+
const workflowObservabilityInput = z.object({
|
|
5
|
+
workflowId: z.string().min(1)
|
|
6
|
+
}), scheduleProvenanceOutput = z.object({
|
|
7
|
+
scheduleId: z.string(),
|
|
8
|
+
occurrence: z.number().optional()
|
|
9
|
+
}).nullable(), finalizerStatusOutput = z.discriminatedUnion("status", [
|
|
10
|
+
z.object({ status: z.literal("pending"), attempts: z.number().int().nonnegative() }),
|
|
11
|
+
z.object({
|
|
12
|
+
status: z.literal("running"),
|
|
13
|
+
attempts: z.number().int().positive(),
|
|
14
|
+
startedAt: z.number().nonnegative()
|
|
15
|
+
}),
|
|
16
|
+
z.object({
|
|
17
|
+
status: z.literal("succeeded"),
|
|
18
|
+
attempts: z.number().int().positive(),
|
|
19
|
+
completedAt: z.number().nonnegative()
|
|
20
|
+
}),
|
|
21
|
+
z.object({
|
|
22
|
+
status: z.literal("failed"),
|
|
23
|
+
attempts: z.number().int().nonnegative(),
|
|
24
|
+
failedAt: z.number().nonnegative(),
|
|
25
|
+
error: z.string()
|
|
26
|
+
})
|
|
27
|
+
]).nullable();
|
|
28
|
+
export const getWorkflowScheduleProvenanceOperation = defineOperation({
|
|
29
|
+
name: "weft.workflows.scheduleprovenance.get",
|
|
30
|
+
mcpExposable: !1,
|
|
31
|
+
summary: "Get the schedule occurrence that launched a workflow",
|
|
32
|
+
description: "Read the durable schedule id and optional occurrence timestamp that launched a workflow. Returns null for runs that were not launched by a schedule or whose workflow history was purged.",
|
|
33
|
+
destructive: !1,
|
|
34
|
+
tags: ["Workflows"],
|
|
35
|
+
inputSchema: workflowObservabilityInput,
|
|
36
|
+
outputSchema: scheduleProvenanceOutput,
|
|
37
|
+
access: { kind: "public" },
|
|
38
|
+
producibleFaults: [],
|
|
39
|
+
transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
|
|
40
|
+
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
41
|
+
invoke: async ({ input, engine }) => engine.getScheduleProvenance(input.workflowId)
|
|
42
|
+
}), getWorkflowFinalizerOperation = defineOperation({
|
|
43
|
+
name: "weft.workflows.finalizer.get",
|
|
44
|
+
mcpExposable: !1,
|
|
45
|
+
summary: "Get workflow finalizer progress and outcome",
|
|
46
|
+
description: "Read durable post-terminal finalizer progress or its succeeded or failed outcome. Returns null when the workflow did not record finalizer work.",
|
|
47
|
+
destructive: !1,
|
|
48
|
+
tags: ["Workflows"],
|
|
49
|
+
inputSchema: workflowObservabilityInput,
|
|
50
|
+
outputSchema: finalizerStatusOutput,
|
|
51
|
+
access: { kind: "public" },
|
|
52
|
+
producibleFaults: [],
|
|
53
|
+
transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
|
|
54
|
+
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
55
|
+
invoke: async ({ input, engine }) => engine.getFinalizerStatus(input.workflowId)
|
|
56
|
+
}), getWorkflowScheduleProvenanceRestBinding = {
|
|
57
|
+
method: "GET",
|
|
58
|
+
path: "/v1/workflows/:id/schedule-provenance",
|
|
59
|
+
pathParamNames: ["id"],
|
|
60
|
+
operationName: "weft.workflows.scheduleprovenance.get",
|
|
61
|
+
inputSources: { workflowId: { kind: "path", pathParam: "id" } },
|
|
62
|
+
extractInput: async (_request, pathParams) => ({ workflowId: pathParams.id ?? "" }),
|
|
63
|
+
success: { kind: "json", status: 200 },
|
|
64
|
+
shapeFault: shapeRestFault
|
|
65
|
+
}, getWorkflowFinalizerRestBinding = {
|
|
66
|
+
method: "GET",
|
|
67
|
+
path: "/v1/workflows/:id/finalizer",
|
|
68
|
+
pathParamNames: ["id"],
|
|
69
|
+
operationName: "weft.workflows.finalizer.get",
|
|
70
|
+
inputSources: { workflowId: { kind: "path", pathParam: "id" } },
|
|
71
|
+
extractInput: async (_request, pathParams) => ({ workflowId: pathParams.id ?? "" }),
|
|
72
|
+
success: { kind: "json", status: 200 },
|
|
73
|
+
shapeFault: shapeRestFault
|
|
74
|
+
}, workflowObservabilityRestBindings = [
|
|
75
|
+
getWorkflowScheduleProvenanceRestBinding,
|
|
76
|
+
getWorkflowFinalizerRestBinding
|
|
77
|
+
], workflowObservabilityOperations = [
|
|
78
|
+
getWorkflowScheduleProvenanceOperation,
|
|
79
|
+
getWorkflowFinalizerOperation
|
|
80
|
+
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineOperation } from "../operation-registry.js";
|
|
3
|
-
import {
|
|
3
|
+
import { shapeRestFault } from "./operation-helpers.js";
|
|
4
4
|
const getWorkflowResultInput = z.object({
|
|
5
5
|
workflowId: z.string().min(1)
|
|
6
6
|
}), getWorkflowResultOutput = z.unknown();
|
|
@@ -75,7 +75,7 @@ function shapeGetWorkflowResultSuccess(result) {
|
|
|
75
75
|
}
|
|
76
76
|
function shapeGetWorkflowResultFault(fault) {
|
|
77
77
|
if (fault.code === "Timeout")
|
|
78
|
-
return
|
|
78
|
+
return shapeRestFault(fault, { message: "Timeout waiting for workflow result", status: 408 });
|
|
79
79
|
return shapeRestFault(fault);
|
|
80
80
|
}
|
|
81
81
|
export const getWorkflowResultRestBinding = {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* `weft.workflows.get` operation + REST binding.
|
|
3
3
|
*
|
|
4
4
|
* Returns a workflow's state by id. REST response shape preserves the
|
|
5
|
-
* historical format: 200 with the serialized `WorkflowState`, or a
|
|
6
|
-
*
|
|
5
|
+
* historical format: 200 with the serialized `WorkflowState`, or a 4xx/5xx
|
|
6
|
+
* with the string `error` plus audited structured `data`, as emitted by
|
|
7
7
|
* `shapeFault` below.
|
|
8
8
|
*
|
|
9
9
|
* @module server/operations/get-workflow
|
|
@@ -11,6 +11,18 @@ function parseType(params) {
|
|
|
11
11
|
const type = params.get("type");
|
|
12
12
|
return type === null ? void 0 : type;
|
|
13
13
|
}
|
|
14
|
+
function parseScheduleId(params) {
|
|
15
|
+
const scheduleId = params.get("schedule_id");
|
|
16
|
+
return scheduleId === null ? void 0 : scheduleId;
|
|
17
|
+
}
|
|
18
|
+
function parseParentWorkflowId(params) {
|
|
19
|
+
const parentWorkflowId = params.get("parent_workflow_id");
|
|
20
|
+
return parentWorkflowId === null ? void 0 : parentWorkflowId;
|
|
21
|
+
}
|
|
22
|
+
function parseParentWorkflowExecutionToken(params) {
|
|
23
|
+
const parentWorkflowExecutionToken = params.get("parent_workflow_execution_token");
|
|
24
|
+
return parentWorkflowExecutionToken === null ? void 0 : parentWorkflowExecutionToken;
|
|
25
|
+
}
|
|
14
26
|
function parseTags(params) {
|
|
15
27
|
const tags = params.getAll("tag");
|
|
16
28
|
return tags.length > 0 ? tags : void 0;
|
|
@@ -52,6 +64,9 @@ function parseExecutionDeadline(params) {
|
|
|
52
64
|
const LIST_FILTER_QUERY_PARSERS = {
|
|
53
65
|
status: parseStatus,
|
|
54
66
|
type: parseType,
|
|
67
|
+
scheduleId: parseScheduleId,
|
|
68
|
+
parentWorkflowId: parseParentWorkflowId,
|
|
69
|
+
parentWorkflowExecutionToken: parseParentWorkflowExecutionToken,
|
|
55
70
|
tags: parseTags,
|
|
56
71
|
attributes: parseAttributes,
|
|
57
72
|
idPrefix: parseIdPrefix,
|
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { reviewListEntrySchema } from "../../core/review/index.js";
|
|
2
3
|
import { shapeOperationFaultAsJson } from "../operation-fault.js";
|
|
3
4
|
import { defineOperation } from "../operation-registry.js";
|
|
4
5
|
const reviewStatusSchema = z.enum(["pending", "completed"]), listReviewsInput = z.object({
|
|
5
6
|
status: reviewStatusSchema.optional(),
|
|
6
7
|
workflowId: z.string().min(1).optional(),
|
|
7
8
|
reviewType: z.string().min(1).optional()
|
|
8
|
-
}),
|
|
9
|
-
status: z.literal("pending"),
|
|
10
|
-
reviewId: z.string(),
|
|
11
|
-
workflowId: z.string(),
|
|
12
|
-
artifact: z.unknown().nonoptional(),
|
|
13
|
-
reviewType: z.string(),
|
|
14
|
-
reviewers: z.array(z.string()),
|
|
15
|
-
allowPartial: z.boolean(),
|
|
16
|
-
timeout: z.number().optional(),
|
|
17
|
-
webhookUrl: z.string().optional(),
|
|
18
|
-
createdAt: z.number()
|
|
19
|
-
}), completedReviewEntrySchema = pendingReviewEntrySchema.extend({
|
|
20
|
-
status: z.literal("completed"),
|
|
21
|
-
decision: z.enum(["approved", "rejected", "needs-changes"]),
|
|
22
|
-
reviewer: z.string(),
|
|
23
|
-
feedback: z.string().optional(),
|
|
24
|
-
sectionDecisions: z.record(z.string(), z.enum(["approved", "rejected"])).optional(),
|
|
25
|
-
timestamp: z.number()
|
|
26
|
-
}), reviewListEntrySchema = z.union([pendingReviewEntrySchema, completedReviewEntrySchema]), listReviewsOutput = z.object({
|
|
9
|
+
}), listReviewsOutput = z.object({
|
|
27
10
|
items: z.array(reviewListEntrySchema)
|
|
28
11
|
});
|
|
29
12
|
export const listReviewsOperation = defineOperation({
|
|
@@ -4,6 +4,9 @@ import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
|
4
4
|
declare const listWorkflowsInput: z.ZodObject<{
|
|
5
5
|
status: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<WorkflowStatus, WorkflowStatus>, z.ZodArray<z.ZodCustom<WorkflowStatus, WorkflowStatus>>]>>;
|
|
6
6
|
type: z.ZodOptional<z.ZodString>;
|
|
7
|
+
scheduleId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
parentWorkflowId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
parentWorkflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
7
10
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
8
11
|
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
9
12
|
key: z.ZodString;
|
|
@@ -42,6 +45,9 @@ export type ListWorkflowsOutput = PaginatedResult<WorkflowSummary>;
|
|
|
42
45
|
export declare const listWorkflowsOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
43
46
|
status?: WorkflowStatus | WorkflowStatus[] | undefined;
|
|
44
47
|
type?: string | undefined;
|
|
48
|
+
scheduleId?: string | undefined;
|
|
49
|
+
parentWorkflowId?: string | undefined;
|
|
50
|
+
parentWorkflowExecutionToken?: string | undefined;
|
|
45
51
|
tags?: string[] | undefined;
|
|
46
52
|
attributes?: {
|
|
47
53
|
key: string;
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { coerceStartWorkflowTags } from "../../core/start-workflow-validation.js";
|
|
8
8
|
import { defineOperation } from "../operation-registry.js";
|
|
9
9
|
import { extractListFilterFromQuery } from "./list-filter-query-extractor.js";
|
|
10
|
-
import {
|
|
10
|
+
import { shapeRestFault } from "./operation-helpers.js";
|
|
11
11
|
const workflowStatusSchema = z.custom((value) => typeof value === "string"), failureCategorySchema = z.custom((value) => typeof value === "string"), searchAttributeValueSchema = z.custom((value) => {
|
|
12
12
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
13
13
|
return !0;
|
|
@@ -27,6 +27,9 @@ const workflowStatusSchema = z.custom((value) => typeof value === "string"), fai
|
|
|
27
27
|
}), listIncludeSchema = z.union([z.string(), z.array(z.string()).min(1)]).refine((value) => Array.isArray(value) ? value.every((entry) => entry === "failureCategory") : value === "failureCategory", { message: 'include must be "failureCategory"' }), listWorkflowsInput = z.object({
|
|
28
28
|
status: z.union([workflowStatusSchema, z.array(workflowStatusSchema)]).optional(),
|
|
29
29
|
type: z.string().optional(),
|
|
30
|
+
scheduleId: z.string().min(1).optional(),
|
|
31
|
+
parentWorkflowId: z.string().min(1).optional(),
|
|
32
|
+
parentWorkflowExecutionToken: z.string().min(1).optional(),
|
|
30
33
|
tags: z.array(z.string()).optional(),
|
|
31
34
|
attributes: z.array(attributeFilterSchema).optional(),
|
|
32
35
|
limit: z.number().int().min(1).max(1000).optional(),
|
|
@@ -42,7 +45,7 @@ export const listWorkflowsOperation = defineOperation({
|
|
|
42
45
|
name: "weft.workflows.list",
|
|
43
46
|
mcpExposable: !1,
|
|
44
47
|
summary: "List workflows",
|
|
45
|
-
description: "List workflows visible to the caller, optionally filtered by status, type, tags, id prefix, failure category, and time range, with pagination via `limit`/`offset`. Read-only. Returns the matching workflow summaries in the engine default ordering.",
|
|
48
|
+
description: "List workflows visible to the caller, optionally filtered by status, type, originating schedule, direct parent run, tags, id prefix, failure category, and time range, with pagination via `limit`/`offset`. Read-only. Returns the matching workflow summaries in the engine default ordering.",
|
|
46
49
|
destructive: !1,
|
|
47
50
|
tags: ["Workflows"],
|
|
48
51
|
inputSchema: listWorkflowsInput,
|
|
@@ -113,7 +116,7 @@ function shapeListWorkflowsSuccess(result) {
|
|
|
113
116
|
}
|
|
114
117
|
function shapeListWorkflowsFault(fault) {
|
|
115
118
|
if (fault.code === "Unprocessable")
|
|
116
|
-
return
|
|
119
|
+
return shapeRestFault(fault, { status: 400 });
|
|
117
120
|
return shapeRestFault(fault);
|
|
118
121
|
}
|
|
119
122
|
export const listWorkflowsRestBinding = {
|
|
@@ -124,6 +127,12 @@ export const listWorkflowsRestBinding = {
|
|
|
124
127
|
inputSources: {
|
|
125
128
|
status: { kind: "query", queryParam: "status", repeating: !0 },
|
|
126
129
|
type: { kind: "query", queryParam: "type" },
|
|
130
|
+
scheduleId: { kind: "query", queryParam: "schedule_id" },
|
|
131
|
+
parentWorkflowId: { kind: "query", queryParam: "parent_workflow_id" },
|
|
132
|
+
parentWorkflowExecutionToken: {
|
|
133
|
+
kind: "query",
|
|
134
|
+
queryParam: "parent_workflow_execution_token"
|
|
135
|
+
},
|
|
127
136
|
tags: { kind: "query", queryParam: "tag", repeating: !0 },
|
|
128
137
|
limit: { kind: "query", queryParam: "limit" },
|
|
129
138
|
offset: { kind: "query", queryParam: "offset" },
|