@lostgradient/weft 0.13.0 → 0.15.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 +3 -8
- package/dist/cli/generated/operation-catalog.snapshot.json +977 -77
- package/dist/cli/generated/operation-client.generated.d.ts +14 -21
- 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 +1 -1
- 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/http-client-storage.js +7 -35
- package/dist/client/http-request.d.ts +8 -9
- package/dist/client/http-request.js +3 -25
- package/dist/core/aggregate-validation.d.ts +2 -5
- package/dist/core/aggregate-validation.js +2 -10
- package/dist/core/atomic-state.js +21 -24
- package/dist/core/context/parallel-operations.d.ts +0 -2
- package/dist/core/context/parallel-operations.js +0 -7
- 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.js +4 -22
- package/dist/core/engine/checkpoint-io.d.ts +1 -1
- package/dist/core/engine/operations-coordination.js +1 -1
- package/dist/core/engine/parallel-dispatch.d.ts +1 -1
- package/dist/core/engine/parallel-dispatch.js +1 -1
- 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/schedules.js +4 -1
- package/dist/core/engine/timeline-coordinator-detail.d.ts +1 -1
- package/dist/core/inline-execution-strategy.js +8 -46
- package/dist/core/list-filter-validation.d.ts +2 -5
- package/dist/core/list-filter-validation.js +2 -10
- package/dist/core/review/index.d.ts +87 -0
- package/dist/core/review/index.js +29 -0
- package/dist/core/types/schedules.d.ts +13 -31
- package/dist/core/validation-issues.d.ts +13 -0
- package/dist/core/validation-issues.js +9 -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/indexeddb.js +1 -1
- package/dist/mcp/session.js +2 -10
- package/dist/mcp/tools.js +2 -10
- package/dist/mcp/tuple-list-equality.d.ts +1 -0
- package/dist/mcp/tuple-list-equality.js +12 -0
- package/dist/server/openapi-error-responses.js +0 -14
- 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 +3 -2
- package/dist/server/operation-fault.d.ts +1 -4
- package/dist/server/operation-fault.js +1 -1
- package/dist/server/operation-registry.d.ts +2 -31
- package/dist/server/operations/bulk-filter-helpers.d.ts +17 -17
- package/dist/server/operations/bulk-filter-helpers.js +16 -37
- package/dist/server/operations/bulk-mutate-workflow-tags.d.ts +27 -27
- package/dist/server/operations/bulk-signal-workflows.d.ts +26 -26
- package/dist/server/operations/create-schedule.js +7 -19
- package/dist/server/operations/event-stream-contracts.d.ts +20 -0
- package/dist/server/operations/event-stream-contracts.js +67 -0
- package/dist/server/operations/fleet-events-sse.js +21 -50
- package/dist/server/operations/fleet-events-subscription.js +8 -12
- package/dist/server/operations/list-reviews.js +2 -19
- package/dist/server/operations/list-workflows.d.ts +43 -43
- package/dist/server/operations/list-workflows.js +9 -30
- package/dist/server/operations/purge-workflows.d.ts +11 -11
- package/dist/server/operations/recover-all.js +1 -10
- package/dist/server/operations/schedule-rest-body.d.ts +11 -0
- package/dist/server/operations/schedule-rest-body.js +28 -0
- package/dist/server/operations/single-workflow-control-operation.d.ts +2 -1
- package/dist/server/operations/update-schedule.js +7 -19
- package/dist/server/operations/workflow-events-sse.js +29 -67
- package/dist/server/operations/workflow-events-subscription.js +9 -27
- package/dist/server/runtime/task-polling.js +3 -5
- package/dist/server/task-state.d.ts +2 -8
- package/dist/server/task-state.js +10 -7
- package/dist/storage/bounded-ndjson-response.d.ts +5 -0
- package/dist/storage/bounded-ndjson-response.js +33 -0
- package/dist/storage/bun-sql.js +52 -49
- package/dist/storage/conditional-batch-body.d.ts +7 -0
- package/dist/storage/conditional-batch-body.js +14 -0
- package/dist/storage/http.js +5 -37
- 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 +2 -2
- package/dist/storage/node-sqlite-loader.d.ts +2 -2
- package/dist/storage/node-sqlite.js +32 -17
- package/dist/storage/postgres.js +1 -1
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/turso.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/web-extension.js +1 -1
- package/dist/worker/execute-with-interceptors.d.ts +1 -1
- package/dist/worker/execute-with-interceptors.js +2 -2
- package/dist/worker/index.js +5 -5
- package/dist/worker/long-poll.js +3 -4
- package/dist/worker/protocol-messages.d.ts +11 -19
- package/dist/worker/protocol-schemas.d.ts +8 -8
- package/dist/worker/protocol-schemas.js +4 -4
- package/dist/worker/protocol-task-result.d.ts +1 -0
- package/dist/worker/protocol-task-result.js +1 -3
- package/dist/worker/protocol.js +1 -1
- package/dist/worker/registry/types.d.ts +2 -7
- package/dist/worker/registry.d.ts +3 -9
- package/dist/worker/registry.js +2 -5
- package/package.json +1 -1
|
@@ -3,43 +3,43 @@ import type { BulkOperationDryRunResult, BulkTagResult } from '../../core/types.
|
|
|
3
3
|
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
4
4
|
declare const bulkMutateWorkflowTagsInput: z.ZodObject<{
|
|
5
5
|
filter: z.ZodOptional<z.ZodObject<{
|
|
6
|
-
status: z.ZodOptional<z.ZodUnion<readonly [z.
|
|
6
|
+
status: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<import("../../index.ts").WorkflowStatus, unknown, z.core.$ZodTypeInternals<import("../../index.ts").WorkflowStatus, unknown>>, z.ZodArray<z.ZodType<import("../../index.ts").WorkflowStatus, unknown, z.core.$ZodTypeInternals<import("../../index.ts").WorkflowStatus, unknown>>>]>>;
|
|
7
7
|
type: z.ZodOptional<z.ZodString>;
|
|
8
8
|
scheduleId: z.ZodOptional<z.ZodString>;
|
|
9
9
|
parentWorkflowId: z.ZodOptional<z.ZodString>;
|
|
10
10
|
parentWorkflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
11
11
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
12
|
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
13
|
-
key: z.ZodString
|
|
14
|
-
value: z.ZodOptional<z.
|
|
15
|
-
gt: z.ZodOptional<z.
|
|
16
|
-
lt: z.ZodOptional<z.
|
|
17
|
-
gte: z.ZodOptional<z.
|
|
18
|
-
lte: z.ZodOptional<z.
|
|
13
|
+
key: z.ZodUnion<readonly [z.ZodString, z.ZodAny]>;
|
|
14
|
+
value: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
15
|
+
gt: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
16
|
+
lt: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
17
|
+
gte: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
18
|
+
lte: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
19
19
|
}, z.core.$strip>>>;
|
|
20
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
21
20
|
offset: z.ZodOptional<z.ZodNumber>;
|
|
22
21
|
idPrefix: z.ZodOptional<z.ZodString>;
|
|
23
|
-
failureCategory: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<import("../../index.ts").FailureCategory, import("../../index.ts").FailureCategory>, z.ZodArray<z.ZodCustom<import("../../index.ts").FailureCategory, import("../../index.ts").FailureCategory>>]>>;
|
|
24
22
|
createdAt: z.ZodOptional<z.ZodObject<{
|
|
25
23
|
gte: z.ZodOptional<z.ZodNumber>;
|
|
26
|
-
gt: z.ZodOptional<z.ZodNumber>;
|
|
27
24
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
28
26
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
29
|
-
}, z.core.$
|
|
27
|
+
}, z.core.$strict>>;
|
|
30
28
|
updatedAt: z.ZodOptional<z.ZodObject<{
|
|
31
29
|
gte: z.ZodOptional<z.ZodNumber>;
|
|
32
|
-
gt: z.ZodOptional<z.ZodNumber>;
|
|
33
30
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
34
32
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
35
|
-
}, z.core.$
|
|
33
|
+
}, z.core.$strict>>;
|
|
36
34
|
executionDeadline: z.ZodOptional<z.ZodObject<{
|
|
37
35
|
gte: z.ZodOptional<z.ZodNumber>;
|
|
38
|
-
gt: z.ZodOptional<z.ZodNumber>;
|
|
39
36
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
40
38
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
41
|
-
}, z.core.$
|
|
42
|
-
|
|
39
|
+
}, z.core.$strict>>;
|
|
40
|
+
failureCategory: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<import("../../index.ts").FailureCategory, unknown, z.core.$ZodTypeInternals<import("../../index.ts").FailureCategory, unknown>>, z.ZodArray<z.ZodType<import("../../index.ts").FailureCategory, unknown, z.core.$ZodTypeInternals<import("../../index.ts").FailureCategory, unknown>>>]>>;
|
|
41
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
}, z.core.$strict>>;
|
|
43
43
|
tags: z.ZodArray<z.ZodString>;
|
|
44
44
|
operation: z.ZodEnum<{
|
|
45
45
|
add: "add";
|
|
@@ -63,35 +63,35 @@ export declare const bulkMutateWorkflowTagsOperation: import("../operation-catal
|
|
|
63
63
|
parentWorkflowExecutionToken?: string | undefined;
|
|
64
64
|
tags?: string[] | undefined;
|
|
65
65
|
attributes?: {
|
|
66
|
-
key:
|
|
67
|
-
value?:
|
|
68
|
-
gt?:
|
|
69
|
-
lt?:
|
|
70
|
-
gte?:
|
|
71
|
-
lte?:
|
|
66
|
+
key: any;
|
|
67
|
+
value?: unknown;
|
|
68
|
+
gt?: unknown;
|
|
69
|
+
lt?: unknown;
|
|
70
|
+
gte?: unknown;
|
|
71
|
+
lte?: unknown;
|
|
72
72
|
}[] | undefined;
|
|
73
|
-
limit?: number | undefined;
|
|
74
73
|
offset?: number | undefined;
|
|
75
74
|
idPrefix?: string | undefined;
|
|
76
|
-
failureCategory?: import("../../index.ts").FailureCategory | import("../../index.ts").FailureCategory[] | undefined;
|
|
77
75
|
createdAt?: {
|
|
78
76
|
gte?: number | undefined;
|
|
79
|
-
gt?: number | undefined;
|
|
80
77
|
lte?: number | undefined;
|
|
78
|
+
gt?: number | undefined;
|
|
81
79
|
lt?: number | undefined;
|
|
82
80
|
} | undefined;
|
|
83
81
|
updatedAt?: {
|
|
84
82
|
gte?: number | undefined;
|
|
85
|
-
gt?: number | undefined;
|
|
86
83
|
lte?: number | undefined;
|
|
84
|
+
gt?: number | undefined;
|
|
87
85
|
lt?: number | undefined;
|
|
88
86
|
} | undefined;
|
|
89
87
|
executionDeadline?: {
|
|
90
88
|
gte?: number | undefined;
|
|
91
|
-
gt?: number | undefined;
|
|
92
89
|
lte?: number | undefined;
|
|
90
|
+
gt?: number | undefined;
|
|
93
91
|
lt?: number | undefined;
|
|
94
92
|
} | undefined;
|
|
93
|
+
failureCategory?: import("../../index.ts").FailureCategory | import("../../index.ts").FailureCategory[] | undefined;
|
|
94
|
+
limit?: number | undefined;
|
|
95
95
|
} | undefined;
|
|
96
96
|
dryRun?: boolean | undefined;
|
|
97
97
|
confirmationToken?: string | undefined;
|
|
@@ -2,42 +2,42 @@ import { z } from 'zod';
|
|
|
2
2
|
import type { BulkOperationDryRunResult, BulkSignalResult } from '../../core/types.ts';
|
|
3
3
|
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
4
4
|
declare const bulkSignalWorkflowsInput: z.ZodObject<{
|
|
5
|
-
status: z.ZodOptional<z.ZodUnion<readonly [z.
|
|
5
|
+
status: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<import("../../index.ts").WorkflowStatus, unknown, z.core.$ZodTypeInternals<import("../../index.ts").WorkflowStatus, unknown>>, z.ZodArray<z.ZodType<import("../../index.ts").WorkflowStatus, unknown, z.core.$ZodTypeInternals<import("../../index.ts").WorkflowStatus, unknown>>>]>>;
|
|
6
6
|
type: z.ZodOptional<z.ZodString>;
|
|
7
7
|
scheduleId: z.ZodOptional<z.ZodString>;
|
|
8
8
|
parentWorkflowId: z.ZodOptional<z.ZodString>;
|
|
9
9
|
parentWorkflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
10
10
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
11
11
|
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
12
|
-
key: z.ZodString
|
|
13
|
-
value: z.ZodOptional<z.
|
|
14
|
-
gt: z.ZodOptional<z.
|
|
15
|
-
lt: z.ZodOptional<z.
|
|
16
|
-
gte: z.ZodOptional<z.
|
|
17
|
-
lte: z.ZodOptional<z.
|
|
12
|
+
key: z.ZodUnion<readonly [z.ZodString, z.ZodAny]>;
|
|
13
|
+
value: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
14
|
+
gt: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
15
|
+
lt: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
16
|
+
gte: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
17
|
+
lte: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
18
18
|
}, z.core.$strip>>>;
|
|
19
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
20
19
|
offset: z.ZodOptional<z.ZodNumber>;
|
|
21
20
|
idPrefix: z.ZodOptional<z.ZodString>;
|
|
22
|
-
failureCategory: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<import("../../index.ts").FailureCategory, import("../../index.ts").FailureCategory>, z.ZodArray<z.ZodCustom<import("../../index.ts").FailureCategory, import("../../index.ts").FailureCategory>>]>>;
|
|
23
21
|
createdAt: z.ZodOptional<z.ZodObject<{
|
|
24
22
|
gte: z.ZodOptional<z.ZodNumber>;
|
|
25
|
-
gt: z.ZodOptional<z.ZodNumber>;
|
|
26
23
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
27
25
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
28
|
-
}, z.core.$
|
|
26
|
+
}, z.core.$strict>>;
|
|
29
27
|
updatedAt: z.ZodOptional<z.ZodObject<{
|
|
30
28
|
gte: z.ZodOptional<z.ZodNumber>;
|
|
31
|
-
gt: z.ZodOptional<z.ZodNumber>;
|
|
32
29
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
33
31
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
34
|
-
}, z.core.$
|
|
32
|
+
}, z.core.$strict>>;
|
|
35
33
|
executionDeadline: z.ZodOptional<z.ZodObject<{
|
|
36
34
|
gte: z.ZodOptional<z.ZodNumber>;
|
|
37
|
-
gt: z.ZodOptional<z.ZodNumber>;
|
|
38
35
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
39
37
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
40
|
-
}, z.core.$
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
failureCategory: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<import("../../index.ts").FailureCategory, unknown, z.core.$ZodTypeInternals<import("../../index.ts").FailureCategory, unknown>>, z.ZodArray<z.ZodType<import("../../index.ts").FailureCategory, unknown, z.core.$ZodTypeInternals<import("../../index.ts").FailureCategory, unknown>>>]>>;
|
|
40
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
41
41
|
name: z.ZodString;
|
|
42
42
|
payload: z.ZodOptional<z.ZodUnknown>;
|
|
43
43
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -56,35 +56,35 @@ export declare const bulkSignalWorkflowsOperation: import("../operation-catalog.
|
|
|
56
56
|
parentWorkflowExecutionToken?: string | undefined;
|
|
57
57
|
tags?: string[] | undefined;
|
|
58
58
|
attributes?: {
|
|
59
|
-
key:
|
|
60
|
-
value?:
|
|
61
|
-
gt?:
|
|
62
|
-
lt?:
|
|
63
|
-
gte?:
|
|
64
|
-
lte?:
|
|
59
|
+
key: any;
|
|
60
|
+
value?: unknown;
|
|
61
|
+
gt?: unknown;
|
|
62
|
+
lt?: unknown;
|
|
63
|
+
gte?: unknown;
|
|
64
|
+
lte?: unknown;
|
|
65
65
|
}[] | undefined;
|
|
66
|
-
limit?: number | undefined;
|
|
67
66
|
offset?: number | undefined;
|
|
68
67
|
idPrefix?: string | undefined;
|
|
69
|
-
failureCategory?: import("../../index.ts").FailureCategory | import("../../index.ts").FailureCategory[] | undefined;
|
|
70
68
|
createdAt?: {
|
|
71
69
|
gte?: number | undefined;
|
|
72
|
-
gt?: number | undefined;
|
|
73
70
|
lte?: number | undefined;
|
|
71
|
+
gt?: number | undefined;
|
|
74
72
|
lt?: number | undefined;
|
|
75
73
|
} | undefined;
|
|
76
74
|
updatedAt?: {
|
|
77
75
|
gte?: number | undefined;
|
|
78
|
-
gt?: number | undefined;
|
|
79
76
|
lte?: number | undefined;
|
|
77
|
+
gt?: number | undefined;
|
|
80
78
|
lt?: number | undefined;
|
|
81
79
|
} | undefined;
|
|
82
80
|
executionDeadline?: {
|
|
83
81
|
gte?: number | undefined;
|
|
84
|
-
gt?: number | undefined;
|
|
85
82
|
lte?: number | undefined;
|
|
83
|
+
gt?: number | undefined;
|
|
86
84
|
lt?: number | undefined;
|
|
87
85
|
} | undefined;
|
|
86
|
+
failureCategory?: import("../../index.ts").FailureCategory | import("../../index.ts").FailureCategory[] | undefined;
|
|
87
|
+
limit?: number | undefined;
|
|
88
88
|
payload?: unknown;
|
|
89
89
|
dryRun?: boolean | undefined;
|
|
90
90
|
confirmationToken?: string | undefined;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineOperation } from "../operation-registry.js";
|
|
3
|
-
import {
|
|
4
|
-
import { invalidParamsFault, isOperationFault, shapeRestFault } from "./operation-helpers.js";
|
|
3
|
+
import { invalidParamsFault, shapeRestFault } from "./operation-helpers.js";
|
|
5
4
|
import { mapScheduleErrorToFault, validateScheduleInputCadence } from "./schedule-faults.js";
|
|
5
|
+
import {
|
|
6
|
+
extractSharedScheduleRestFields,
|
|
7
|
+
parseScheduleRestBodyRequestRecord
|
|
8
|
+
} from "./schedule-rest-body.js";
|
|
6
9
|
const VALID_SCHEDULE_OVERLAP_POLICIES = new Set([
|
|
7
10
|
"skip",
|
|
8
11
|
"queue",
|
|
@@ -117,27 +120,12 @@ export const createScheduleRestBinding = {
|
|
|
117
120
|
jitter: { kind: "body-field", bodyField: "jitter" }
|
|
118
121
|
},
|
|
119
122
|
extractInput: async (request, _pathParams, context) => {
|
|
120
|
-
|
|
121
|
-
try {
|
|
122
|
-
body = await readRestJsonBody(request, context);
|
|
123
|
-
} catch (error) {
|
|
124
|
-
if (isOperationFault(error))
|
|
125
|
-
throw error;
|
|
126
|
-
throw invalidParamsFault("Invalid JSON body");
|
|
127
|
-
}
|
|
128
|
-
if (typeof body !== "object" || body === null)
|
|
129
|
-
throw invalidParamsFault("Request body must be a JSON object");
|
|
130
|
-
const record = body;
|
|
123
|
+
const record = await parseScheduleRestBodyRequestRecord(request, context);
|
|
131
124
|
return {
|
|
132
125
|
type: record.type,
|
|
133
|
-
cronExpression: Object.hasOwn(record, "cronExpression") ? record.cronExpression : void 0,
|
|
134
|
-
every: Object.hasOwn(record, "every") ? record.every : void 0,
|
|
135
126
|
input: record.input,
|
|
136
127
|
id: record.id,
|
|
137
|
-
|
|
138
|
-
overlap: record.overlap,
|
|
139
|
-
backfill: record.backfill,
|
|
140
|
-
jitter: record.jitter
|
|
128
|
+
...extractSharedScheduleRestFields(record)
|
|
141
129
|
};
|
|
142
130
|
},
|
|
143
131
|
success: { kind: "json", status: 201 },
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { FleetEventEnvelope } from '../fleet-event-feed.ts';
|
|
3
|
+
import type { ParameterizedAccessHint } from '../operation-catalog/types.ts';
|
|
4
|
+
import type { EventEnvelope } from '../workflow-event-feed.ts';
|
|
5
|
+
export declare const fleetEventEnvelopeSchema: z.ZodType<FleetEventEnvelope>;
|
|
6
|
+
export declare const workflowEventEnvelopeSchema: z.ZodType<EventEnvelope>;
|
|
7
|
+
export declare const workflowEventParameterizedAccess: ParameterizedAccessHint;
|
|
8
|
+
export type ClosableAsyncIterable<T> = AsyncIterable<T> & {
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
export type ReplayAwareClosableIterable<T> = ClosableAsyncIterable<T> & {
|
|
12
|
+
readonly replayComplete: Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
type ReplayAwareClosableIterableOptions = {
|
|
15
|
+
readonly close: () => void | Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
export declare function createReplayAwareClosableIterable<T>(createSource: (onReplayComplete: () => void) => AsyncIterable<T>, options: ReplayAwareClosableIterableOptions): ReplayAwareClosableIterable<T>;
|
|
18
|
+
export declare function isClosableAsyncIterable<T>(value: unknown): value is ClosableAsyncIterable<T>;
|
|
19
|
+
export declare function isReplayAwareClosableIterable<T>(value: unknown): value is ReplayAwareClosableIterable<T>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const fleetEventEnvelopeSchema = z.object({
|
|
3
|
+
kind: z.string(),
|
|
4
|
+
workflowId: z.string().optional(),
|
|
5
|
+
sequence: z.number(),
|
|
6
|
+
cursor: z.string(),
|
|
7
|
+
emittedAtMs: z.number(),
|
|
8
|
+
payload: z.unknown()
|
|
9
|
+
}), workflowEventEnvelopeSchema = z.object({
|
|
10
|
+
kind: z.string(),
|
|
11
|
+
workflowId: z.string(),
|
|
12
|
+
selector: z.enum(["events", "tokens"]),
|
|
13
|
+
sequence: z.number(),
|
|
14
|
+
cursor: z.string(),
|
|
15
|
+
emittedAtMs: z.number(),
|
|
16
|
+
payload: z.unknown()
|
|
17
|
+
}), workflowEventParameterizedAccess = {
|
|
18
|
+
discriminator: "selector",
|
|
19
|
+
defaultValue: "events",
|
|
20
|
+
variants: [
|
|
21
|
+
{
|
|
22
|
+
value: "events",
|
|
23
|
+
access: { kind: "scoped", scopes: { kind: "anyOf", scopes: ["events:read"] } }
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
value: "tokens",
|
|
27
|
+
access: { kind: "scoped", scopes: { kind: "anyOf", scopes: ["streams:read"] } }
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
};
|
|
31
|
+
export function createReplayAwareClosableIterable(createSource, options) {
|
|
32
|
+
const replayComplete = Promise.withResolvers();
|
|
33
|
+
let closePromise;
|
|
34
|
+
const close = () => {
|
|
35
|
+
if (closePromise !== void 0)
|
|
36
|
+
return closePromise;
|
|
37
|
+
closePromise = Promise.resolve().then(options.close);
|
|
38
|
+
return closePromise;
|
|
39
|
+
};
|
|
40
|
+
let source;
|
|
41
|
+
try {
|
|
42
|
+
source = createSource(() => replayComplete.resolve());
|
|
43
|
+
} catch (error) {
|
|
44
|
+
close();
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
async* [Symbol.asyncIterator]() {
|
|
49
|
+
try {
|
|
50
|
+
for await (const value of source)
|
|
51
|
+
yield value;
|
|
52
|
+
} finally {
|
|
53
|
+
await close();
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
replayComplete: replayComplete.promise,
|
|
57
|
+
close
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function isClosableAsyncIterable(value) {
|
|
61
|
+
if (typeof value !== "object" || value === null)
|
|
62
|
+
return !1;
|
|
63
|
+
return typeof value.close === "function";
|
|
64
|
+
}
|
|
65
|
+
export function isReplayAwareClosableIterable(value) {
|
|
66
|
+
return isClosableAsyncIterable(value) && "replayComplete" in value && value.replayComplete instanceof Promise;
|
|
67
|
+
}
|
|
@@ -4,6 +4,12 @@ import { EVENTS_READ_EVENT_TYPES } from "../runtime/client-visible-events.js";
|
|
|
4
4
|
import {
|
|
5
5
|
decodeCursor
|
|
6
6
|
} from "../workflow-event-feed.js";
|
|
7
|
+
import {
|
|
8
|
+
createReplayAwareClosableIterable,
|
|
9
|
+
fleetEventEnvelopeSchema,
|
|
10
|
+
isClosableAsyncIterable,
|
|
11
|
+
isReplayAwareClosableIterable
|
|
12
|
+
} from "./event-stream-contracts.js";
|
|
7
13
|
import { invalidParamsFault } from "./operation-helpers.js";
|
|
8
14
|
import {
|
|
9
15
|
createEventEnvelopeSSEStream,
|
|
@@ -19,14 +25,7 @@ const INITIAL_CURSOR = "-1", MAX_FLEET_SSE_REPLAY_EVENTS = 1000, cursorSchema =
|
|
|
19
25
|
kind: fleetEventKindSchema.optional(),
|
|
20
26
|
fromCursor: cursorSchema.optional(),
|
|
21
27
|
lastEventId: cursorSchema.optional()
|
|
22
|
-
}), fleetEventsSseOutputSchema = z.custom(isAsyncIterable, "Expected async iterable fleet event stream")
|
|
23
|
-
kind: z.string(),
|
|
24
|
-
workflowId: z.string().optional(),
|
|
25
|
-
sequence: z.number(),
|
|
26
|
-
cursor: z.string(),
|
|
27
|
-
emittedAtMs: z.number(),
|
|
28
|
-
payload: z.unknown()
|
|
29
|
-
});
|
|
28
|
+
}), fleetEventsSseOutputSchema = z.custom(isAsyncIterable, "Expected async iterable fleet event stream");
|
|
30
29
|
export const fleetEventsSseOperation = defineOperation({
|
|
31
30
|
name: "weft.events.sse",
|
|
32
31
|
mcpExposable: !1,
|
|
@@ -67,12 +66,6 @@ function isAsyncIterable(value) {
|
|
|
67
66
|
return !1;
|
|
68
67
|
return typeof value[Symbol.asyncIterator] === "function";
|
|
69
68
|
}
|
|
70
|
-
function isClosableFleetEventsIterable(value) {
|
|
71
|
-
return "close" in value && typeof value.close === "function";
|
|
72
|
-
}
|
|
73
|
-
function isReplayAwareFleetEventsIterable(value) {
|
|
74
|
-
return isClosableFleetEventsIterable(value) && "replayComplete" in value && value.replayComplete instanceof Promise;
|
|
75
|
-
}
|
|
76
69
|
function matchesFleetEventFilter(envelope, input) {
|
|
77
70
|
if (input.workflowId !== void 0 && envelope.workflowId !== input.workflowId)
|
|
78
71
|
return !1;
|
|
@@ -84,49 +77,27 @@ function createFleetEventsIterable(input, context) {
|
|
|
84
77
|
const feed = context.fleetEventFeed;
|
|
85
78
|
if (feed === void 0)
|
|
86
79
|
throw unsupportedEventStreamContextFault("fleet event SSE requires a fleet event feed");
|
|
87
|
-
const controller = new AbortController,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
onReplayComplete: () => replayComplete.resolve(),
|
|
100
|
-
createReplayLimitError: (count, limit) => invalidParamsFault(`Fleet event replay window is ${count} matching events; maximum is ${limit}. Supply a more recent fromCursor.`)
|
|
101
|
-
};
|
|
102
|
-
let source;
|
|
103
|
-
try {
|
|
104
|
-
source = feed.subscribe(subscribeOptions);
|
|
105
|
-
} catch (error) {
|
|
106
|
-
close();
|
|
107
|
-
throw error;
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
async* [Symbol.asyncIterator]() {
|
|
111
|
-
try {
|
|
112
|
-
for await (const envelope of source)
|
|
113
|
-
yield envelope;
|
|
114
|
-
} finally {
|
|
115
|
-
await close();
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
replayComplete: replayComplete.promise,
|
|
119
|
-
close
|
|
120
|
-
};
|
|
80
|
+
const controller = new AbortController, fromCursor = input.lastEventId ?? input.fromCursor ?? INITIAL_CURSOR;
|
|
81
|
+
return createReplayAwareClosableIterable((onReplayComplete) => {
|
|
82
|
+
const subscribeOptions = {
|
|
83
|
+
fromCursor,
|
|
84
|
+
signal: controller.signal,
|
|
85
|
+
replayLimit: MAX_FLEET_SSE_REPLAY_EVENTS,
|
|
86
|
+
filterEnvelope: (envelope) => matchesFleetEventFilter(envelope, input),
|
|
87
|
+
onReplayComplete,
|
|
88
|
+
createReplayLimitError: (count, limit) => invalidParamsFault(`Fleet event replay window is ${count} matching events; maximum is ${limit}. Supply a more recent fromCursor.`)
|
|
89
|
+
};
|
|
90
|
+
return feed.subscribe(subscribeOptions);
|
|
91
|
+
}, { close: () => controller.abort() });
|
|
121
92
|
}
|
|
122
93
|
function shapeFleetEventsSseSuccess(output, request) {
|
|
123
|
-
const close =
|
|
94
|
+
const close = isClosableAsyncIterable(output) ? () => output.close() : async () => {
|
|
124
95
|
return;
|
|
125
96
|
};
|
|
126
97
|
return new Response(createEventEnvelopeSSEStream({
|
|
127
98
|
iterable: output,
|
|
128
99
|
close,
|
|
129
|
-
...
|
|
100
|
+
...isReplayAwareClosableIterable(output) ? { ready: output.replayComplete } : {},
|
|
130
101
|
signal: request.signal
|
|
131
102
|
}), {
|
|
132
103
|
status: 200,
|
|
@@ -3,6 +3,10 @@ import { raiseFault } from "../operation-catalog/raise-fault.js";
|
|
|
3
3
|
import { defineOperation } from "../operation-registry.js";
|
|
4
4
|
import { EVENTS_READ_EVENT_TYPES } from "../runtime/client-visible-events.js";
|
|
5
5
|
import { decodeCursor } from "../workflow-event-feed.js";
|
|
6
|
+
import {
|
|
7
|
+
createReplayAwareClosableIterable,
|
|
8
|
+
fleetEventEnvelopeSchema
|
|
9
|
+
} from "./event-stream-contracts.js";
|
|
6
10
|
import { invalidParamsFault } from "./operation-helpers.js";
|
|
7
11
|
const INITIAL_SUBSCRIPTION_CURSOR = "-1", MAX_FLEET_SUBSCRIPTION_REPLAY_EVENTS = 1000, fleetEventKindSchema = z.enum(EVENTS_READ_EVENT_TYPES), fleetCursorSchema = z.string().regex(/^(?:-1|\d+)$/, "Invalid cursor").refine((cursor) => decodeCursor(cursor) !== null, {
|
|
8
12
|
message: "Invalid cursor"
|
|
@@ -13,13 +17,6 @@ const INITIAL_SUBSCRIPTION_CURSOR = "-1", MAX_FLEET_SUBSCRIPTION_REPLAY_EVENTS =
|
|
|
13
17
|
}), fleetEventsSubscriptionEnvelope = z.object({
|
|
14
18
|
subscriptionId: z.string(),
|
|
15
19
|
cursor: z.string()
|
|
16
|
-
}), fleetEventEnvelopeSchema = z.object({
|
|
17
|
-
kind: z.string(),
|
|
18
|
-
workflowId: z.string().optional(),
|
|
19
|
-
sequence: z.number(),
|
|
20
|
-
cursor: z.string(),
|
|
21
|
-
emittedAtMs: z.number(),
|
|
22
|
-
payload: z.unknown()
|
|
23
20
|
});
|
|
24
21
|
export const fleetEventsSubscriptionOperation = defineOperation({
|
|
25
22
|
name: "weft.events.subscribe",
|
|
@@ -44,19 +41,18 @@ export const fleetEventsSubscriptionOperation = defineOperation({
|
|
|
44
41
|
const startingCursor = input.fromCursor ?? INITIAL_SUBSCRIPTION_CURSOR;
|
|
45
42
|
if (decodeCursor(startingCursor) === null)
|
|
46
43
|
raiseFault(fleetEventsSubscriptionOperation, invalidParamsFault("Invalid cursor"));
|
|
47
|
-
const fleetFeed = getFleetEventFeed(engine, transport), controller = new AbortController, iterable = fleetFeed.subscribe({
|
|
44
|
+
const fleetFeed = getFleetEventFeed(engine, transport), controller = new AbortController, iterable = createReplayAwareClosableIterable((onReplayComplete) => fleetFeed.subscribe({
|
|
48
45
|
...input.fromCursor === void 0 ? {} : { fromCursor: input.fromCursor },
|
|
49
46
|
signal: controller.signal,
|
|
50
47
|
replayLimit: MAX_FLEET_SUBSCRIPTION_REPLAY_EVENTS,
|
|
51
48
|
filterEnvelope: (envelope) => matchesFleetEventFilter(envelope, input),
|
|
49
|
+
onReplayComplete,
|
|
52
50
|
createReplayLimitError: (count, limit) => fleetReplayLimitFault(count, limit)
|
|
53
|
-
});
|
|
51
|
+
}), { close: () => controller.abort() });
|
|
54
52
|
return {
|
|
55
53
|
envelope: { subscriptionId: `sub_${crypto.randomUUID()}`, cursor: startingCursor },
|
|
56
54
|
iterable,
|
|
57
|
-
close:
|
|
58
|
-
controller.abort();
|
|
59
|
-
}
|
|
55
|
+
close: () => iterable.close()
|
|
60
56
|
};
|
|
61
57
|
}
|
|
62
58
|
});
|
|
@@ -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({
|