@lostgradient/weft 0.18.0 → 0.20.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 -1
- package/dist/cli/conformance.js +14 -18
- package/dist/cli/generated/operation-catalog.snapshot.json +1597 -21
- package/dist/cli/generated/operation-client.generated.d.ts +37 -6
- package/dist/cli/generated/operation-client.generated.js +6 -0
- package/dist/core/context/child-workflow-pipe.d.ts +1 -1
- package/dist/core/context/child-workflow-pipe.js +1 -1
- package/dist/core/engine/construction.d.ts +2 -0
- package/dist/core/engine/construction.js +3 -0
- package/dist/core/engine/index.js +1 -0
- package/dist/core/engine/listing.d.ts +1 -0
- package/dist/core/engine/listing.js +6 -4
- package/dist/core/weft-error.d.ts +1 -1
- package/dist/core/weft-error.js +2 -1
- package/dist/core/worker-execution-dispatcher.d.ts +8 -0
- package/dist/core/worker-execution-dispatcher.js +4 -0
- package/dist/core/worker-execution-strategy-options.d.ts +16 -0
- package/dist/core/worker-execution-strategy.js +71 -89
- package/dist/core/worker-fault-handling.d.ts +45 -0
- package/dist/core/worker-fault-handling.js +88 -0
- package/dist/core/worker-protocol.d.ts +18 -1
- package/dist/core/worker-protocol.js +1 -1
- package/dist/core/worker-realm-readiness.d.ts +78 -0
- package/dist/core/worker-realm-readiness.js +127 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +28 -1
- package/dist/json-schema.js +1 -1
- package/dist/runtime/portable.d.ts +14 -0
- package/dist/runtime/portable.js +10 -0
- package/dist/server/index.d.ts +71 -8
- package/dist/server/index.js +7 -3
- package/dist/server/operations/get-task-detail-schema.d.ts +341 -0
- package/dist/server/operations/get-task-detail-schema.js +118 -0
- package/dist/server/operations/get-task-detail.d.ts +346 -0
- package/dist/server/operations/get-task-detail.js +215 -0
- package/dist/server/operations/get-task-diagnostics.d.ts +43 -18
- package/dist/server/operations/get-task-diagnostics.js +87 -126
- package/dist/server/operations/get-worker-diagnostics.d.ts +177 -0
- package/dist/server/operations/get-worker-diagnostics.js +117 -0
- package/dist/server/operations/list-worker-registration-rejections.d.ts +79 -0
- package/dist/server/operations/list-worker-registration-rejections.js +60 -0
- package/dist/server/operations/list-workers.js +1 -3
- package/dist/server/operations/static-registrations.js +8 -20
- package/dist/server/rest-bindings.js +31 -2
- package/dist/server/runtime/authentication-bridge.js +6 -14
- package/dist/server/runtime/context.d.ts +23 -0
- package/dist/server/runtime/task-dispatch.d.ts +7 -1
- package/dist/server/runtime/task-dispatch.js +126 -55
- package/dist/server/runtime/task-ledger-completion.d.ts +68 -0
- package/dist/server/runtime/task-ledger-completion.js +72 -0
- package/dist/server/runtime/task-ledger-recovery.d.ts +55 -0
- package/dist/server/runtime/task-ledger-recovery.js +73 -0
- package/dist/server/runtime/task-ledger-runtime.d.ts +64 -0
- package/dist/server/runtime/task-ledger-runtime.js +34 -0
- package/dist/server/runtime/task-metrics.d.ts +6 -4
- package/dist/server/runtime/task-polling.d.ts +14 -12
- package/dist/server/runtime/task-polling.js +106 -82
- package/dist/server/runtime/task-reconciliation.d.ts +35 -8
- package/dist/server/runtime/task-reconciliation.js +75 -74
- package/dist/server/runtime/task-result-resolution.d.ts +2 -10
- package/dist/server/runtime/task-result-resolution.js +0 -67
- package/dist/server/runtime/task-result-view.d.ts +82 -0
- package/dist/server/runtime/task-result-view.js +48 -0
- package/dist/server/runtime/websocket-worker-messaging.d.ts +16 -0
- package/dist/server/runtime/websocket-worker-messaging.js +32 -0
- package/dist/server/runtime/websocket-worker-registration.d.ts +41 -0
- package/dist/server/runtime/websocket-worker-registration.js +134 -0
- package/dist/server/runtime/websocket-worker.d.ts +0 -1
- package/dist/server/runtime/websocket-worker.js +64 -116
- package/dist/server/serve-internals.d.ts +9 -6
- package/dist/server/serve-internals.js +14 -40
- package/dist/server/task-ledger-codec.d.ts +40 -0
- package/dist/server/task-ledger-codec.js +195 -0
- package/dist/server/task-ledger-keys.d.ts +13 -0
- package/dist/server/task-ledger-keys.js +5 -0
- package/dist/server/task-ledger-limits.d.ts +34 -0
- package/dist/server/task-ledger-limits.js +5 -0
- package/dist/server/task-ledger-transition-helpers.d.ts +38 -0
- package/dist/server/task-ledger-transition-helpers.js +42 -0
- package/dist/server/task-ledger-transitions-cancellation.d.ts +31 -0
- package/dist/server/task-ledger-transitions-cancellation.js +73 -0
- package/dist/server/task-ledger-transitions.d.ts +129 -0
- package/dist/server/task-ledger-transitions.js +162 -0
- package/dist/server/task-ledger-types.d.ts +220 -0
- package/dist/server/task-ledger-types.js +1 -0
- package/dist/server/task-ledger.d.ts +17 -0
- package/dist/server/task-ledger.js +24 -0
- package/dist/server/task-state.d.ts +25 -152
- package/dist/server/task-state.js +0 -188
- package/dist/server/worker-admission-policy.d.ts +70 -0
- package/dist/server/worker-admission-policy.js +0 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/interface.d.ts +0 -2
- package/dist/storage/interface.js +1 -1
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon.js +1 -1
- 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/testing.js +1 -1
- package/dist/storage/turso.js +1 -1
- package/dist/storage/web-extension.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/web-extension.js +1 -1
- package/dist/worker/index.d.ts +2 -0
- package/dist/worker/index.js +30 -4
- package/dist/worker/manifest/canonical-json.d.ts +20 -0
- package/dist/worker/manifest/canonical-json.js +13 -0
- package/dist/worker/manifest/capabilities.d.ts +24 -0
- package/dist/worker/manifest/capabilities.js +74 -0
- package/dist/worker/manifest/content-digest.d.ts +20 -0
- package/dist/worker/manifest/content-digest.js +13 -0
- package/dist/worker/manifest/declared-shape-digest.d.ts +14 -0
- package/dist/worker/manifest/declared-shape-digest.js +4 -0
- package/dist/worker/manifest/digest.d.ts +82 -0
- package/dist/worker/manifest/digest.js +9 -0
- package/dist/worker/manifest/execution-identity.d.ts +92 -0
- package/dist/worker/manifest/execution-identity.js +36 -0
- package/dist/worker/manifest/failure.d.ts +59 -0
- package/dist/worker/manifest/failure.js +4 -0
- package/dist/worker/manifest/index.d.ts +22 -0
- package/dist/worker/manifest/index.js +23 -0
- package/dist/worker/manifest/internal-realm.d.ts +50 -0
- package/dist/worker/manifest/internal-realm.js +39 -0
- package/dist/worker/manifest/is-record.d.ts +12 -0
- package/dist/worker/manifest/is-record.js +6 -0
- package/dist/worker/manifest/json-scan.d.ts +26 -0
- package/dist/worker/manifest/json-scan.js +88 -0
- package/dist/worker/manifest/limits.d.ts +138 -0
- package/dist/worker/manifest/limits.js +1 -0
- package/dist/worker/manifest/normalize.d.ts +63 -0
- package/dist/worker/manifest/normalize.js +73 -0
- package/dist/worker/manifest/parse-json.d.ts +24 -0
- package/dist/worker/manifest/parse-json.js +15 -0
- package/dist/worker/manifest/parse.d.ts +86 -0
- package/dist/worker/manifest/parse.js +188 -0
- package/dist/worker/manifest/registry-contract-builder.d.ts +120 -0
- package/dist/worker/manifest/registry-contract-builder.js +65 -0
- package/dist/worker/manifest/types.d.ts +263 -0
- package/dist/worker/manifest/types.js +1 -0
- package/dist/worker/manifest/utf8.d.ts +13 -0
- package/dist/worker/manifest/utf8.js +7 -0
- package/dist/worker/options.d.ts +55 -8
- package/dist/worker/options.js +65 -9
- package/dist/worker/protocol-internals.d.ts +1 -2
- package/dist/worker/protocol-internals.js +0 -5
- package/dist/worker/protocol-messages.d.ts +33 -17
- package/dist/worker/protocol-schemas.d.ts +36 -74
- package/dist/worker/protocol-schemas.js +25 -18
- package/dist/worker/protocol-version.d.ts +18 -14
- package/dist/worker/protocol-version.js +1 -1
- package/dist/worker/protocol.js +1 -1
- package/dist/worker/registry/deployment-consistency.d.ts +78 -0
- package/dist/worker/registry/deployment-consistency.js +27 -0
- package/dist/worker/registry/drain.d.ts +14 -0
- package/dist/worker/registry/drain.js +24 -0
- package/dist/worker/registry/rejections.d.ts +31 -0
- package/dist/worker/registry/rejections.js +10 -0
- package/dist/worker/registry/summary.d.ts +0 -3
- package/dist/worker/registry/summary.js +2 -5
- package/dist/worker/registry/types.d.ts +10 -3
- package/dist/worker/registry.d.ts +47 -2
- package/dist/worker/registry.js +45 -32
- package/dist/workers/workflow-worker-entry.d.ts +12 -7
- package/dist/workers/workflow-worker-entry.js +9 -2
- package/package.json +3 -3
- package/dist/server/task-resolved-record.d.ts +0 -12
- package/dist/server/task-resolved-record.js +0 -35
package/dist/server/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { requireStorageCapability } from "../storage/interface.js";
|
|
1
2
|
import { WorkerRegistry } from "../worker/registry.js";
|
|
2
3
|
import {
|
|
3
4
|
createDashboardAssetRoute,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
} from "./runtime/shutdown.js";
|
|
14
15
|
import { stopBunServerForShutdown } from "./runtime/stop-server.js";
|
|
15
16
|
import { cancelTask, dispatchTaskImpl } from "./runtime/task-dispatch.js";
|
|
17
|
+
import { adoptTaskResultImpl, getTaskResultViewImpl } from "./runtime/task-result-view.js";
|
|
16
18
|
import { publishTokenMessage, publishWatchMessage } from "./runtime/websocket-stream.js";
|
|
17
19
|
import {
|
|
18
20
|
buildBunServeConfig,
|
|
@@ -20,8 +22,7 @@ import {
|
|
|
20
22
|
buildServerContext,
|
|
21
23
|
cleanupWorkflowIndex,
|
|
22
24
|
registerStackDisposers,
|
|
23
|
-
resolveNetworkConfig
|
|
24
|
-
restoreInflightTasks
|
|
25
|
+
resolveNetworkConfig
|
|
25
26
|
} from "./serve-internals.js";
|
|
26
27
|
import { TaskQueue } from "./task-queue.js";
|
|
27
28
|
export {
|
|
@@ -53,6 +54,7 @@ export const DASHBOARD_PAGE_ROUTES = [
|
|
|
53
54
|
"/system"
|
|
54
55
|
];
|
|
55
56
|
export function serve(options) {
|
|
57
|
+
requireStorageCapability(options.engine.storage, "conditionalBatch", "Remote task ledger (durable dispatch, claim, heartbeat, completion, and requeue)");
|
|
56
58
|
const dashboardAssets = options.dashboardAssets === void 0 ? void 0 : resolveDashboardAssets(options.dashboardAssets, DASHBOARD_PAGE_ROUTES), { port, hostname, development, tlsOptions, serverOptions, serverMetricsCollector } = resolveNetworkConfig(options), context = buildServerContext(serverOptions, serverMetricsCollector), boundCleanup = (operationId) => cleanupWorkflowIndex(context, operationId), routes = {};
|
|
57
59
|
if (options.dashboard != null)
|
|
58
60
|
for (const path of DASHBOARD_PAGE_ROUTES)
|
|
@@ -79,7 +81,6 @@ export function serve(options) {
|
|
|
79
81
|
throw error;
|
|
80
82
|
}
|
|
81
83
|
registerStackDisposers(stack, context, options, broadcastingHandle, boundCleanup);
|
|
82
|
-
restoreInflightTasks(context, options);
|
|
83
84
|
const resolvedPort = server.port ?? port, resolvedHostname = server.hostname ?? hostname;
|
|
84
85
|
return {
|
|
85
86
|
port: resolvedPort,
|
|
@@ -87,10 +88,13 @@ export function serve(options) {
|
|
|
87
88
|
url: `${tlsOptions ? "https" : "http"}://${resolvedHostname}:${resolvedPort}`,
|
|
88
89
|
registry: context.registry,
|
|
89
90
|
taskQueue: context.taskQueue,
|
|
91
|
+
ready: context.taskLedgerRecovery.ready,
|
|
90
92
|
async stop() {
|
|
91
93
|
await stack[Symbol.asyncDispose]();
|
|
92
94
|
},
|
|
93
95
|
dispatchTask: (task) => dispatchTaskImpl(context, options, task),
|
|
96
|
+
getTaskResult: (operationId) => getTaskResultViewImpl(options.engine.storage, operationId),
|
|
97
|
+
adoptTaskResult: (operationId, resultDigest) => adoptTaskResultImpl(options.engine.storage, operationId, resultDigest),
|
|
94
98
|
shutdownWorker: (workerId, shutdownOptions) => shutdownWorkerImpl(context, workerId, shutdownOptions),
|
|
95
99
|
shutdownAllWorkers: (shutdownOptions) => shutdownAllWorkersImpl(context, shutdownOptions),
|
|
96
100
|
cancelTask: (operationId) => cancelTask(context, operationId),
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema definitions for `weft.tasks.get` (WFT-92), split out of
|
|
3
|
+
* `get-task-detail.ts` purely to stay under this repo's 500-line-per-file
|
|
4
|
+
* ceiling — see `task-ledger-transitions.ts`/`task-ledger-transitions-cancellation.ts`
|
|
5
|
+
* for the identical precedent. `get-task-detail.ts` re-exports everything a
|
|
6
|
+
* consumer needs, so callers import from one canonical module.
|
|
7
|
+
*
|
|
8
|
+
* @module server/operations/get-task-detail-schema
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
export declare const getTaskDetailInput: z.ZodObject<{
|
|
12
|
+
operationId: z.ZodString;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const retryPolicySchema: z.ZodObject<{
|
|
15
|
+
maxAttempts: z.ZodNumber;
|
|
16
|
+
initialBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
17
|
+
backoffMultiplier: z.ZodNumber;
|
|
18
|
+
maxBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
19
|
+
nonRetryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
export declare const executionRequirementSchema: z.ZodObject<{
|
|
22
|
+
deploymentName: z.ZodOptional<z.ZodString>;
|
|
23
|
+
buildId: z.ZodOptional<z.ZodString>;
|
|
24
|
+
artifactDigest: z.ZodOptional<z.ZodString>;
|
|
25
|
+
workflowRevision: z.ZodOptional<z.ZodString>;
|
|
26
|
+
activityContractHash: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
/** Exported for direct schema-level tests; the operation itself uses this via `outputSchema`. */
|
|
29
|
+
export declare const getTaskDetailOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
30
|
+
state: z.ZodLiteral<"queued">;
|
|
31
|
+
availableAt: z.ZodNumber;
|
|
32
|
+
firstQueuedAt: z.ZodNumber;
|
|
33
|
+
lastQueuedAt: z.ZodNumber;
|
|
34
|
+
lastDispatchedAt: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
retryCount: z.ZodNumber;
|
|
37
|
+
requeueCount: z.ZodNumber;
|
|
38
|
+
lastRequeueReason: z.ZodOptional<z.ZodString>;
|
|
39
|
+
operationId: z.ZodString;
|
|
40
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
41
|
+
workflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
42
|
+
workflowType: z.ZodString;
|
|
43
|
+
activityName: z.ZodString;
|
|
44
|
+
queue: z.ZodString;
|
|
45
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
headerKeys: z.ZodArray<z.ZodString>;
|
|
47
|
+
visibilityTimeoutMilliseconds: z.ZodNumber;
|
|
48
|
+
retryPolicy: z.ZodOptional<z.ZodObject<{
|
|
49
|
+
maxAttempts: z.ZodNumber;
|
|
50
|
+
initialBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
51
|
+
backoffMultiplier: z.ZodNumber;
|
|
52
|
+
maxBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
53
|
+
nonRetryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
54
|
+
}, z.core.$strict>>;
|
|
55
|
+
scheduleToCloseDeadline: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
executionRequirement: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
deploymentName: z.ZodOptional<z.ZodString>;
|
|
58
|
+
buildId: z.ZodOptional<z.ZodString>;
|
|
59
|
+
artifactDigest: z.ZodOptional<z.ZodString>;
|
|
60
|
+
workflowRevision: z.ZodOptional<z.ZodString>;
|
|
61
|
+
activityContractHash: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strict>>;
|
|
63
|
+
fairShareKey: z.ZodOptional<z.ZodString>;
|
|
64
|
+
stickyWorkflowId: z.ZodOptional<z.ZodString>;
|
|
65
|
+
createdAt: z.ZodNumber;
|
|
66
|
+
attempt: z.ZodNumber;
|
|
67
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
68
|
+
leaseDeadline: z.ZodNumber;
|
|
69
|
+
firstQueuedAt: z.ZodNumber;
|
|
70
|
+
lastQueuedAt: z.ZodNumber;
|
|
71
|
+
startedAt: z.ZodNumber;
|
|
72
|
+
lastHeartbeatAt: z.ZodNumber;
|
|
73
|
+
state: z.ZodLiteral<"leased">;
|
|
74
|
+
retryCount: z.ZodNumber;
|
|
75
|
+
requeueCount: z.ZodNumber;
|
|
76
|
+
lastRequeueReason: z.ZodOptional<z.ZodString>;
|
|
77
|
+
operationId: z.ZodString;
|
|
78
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
79
|
+
workflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
80
|
+
workflowType: z.ZodString;
|
|
81
|
+
activityName: z.ZodString;
|
|
82
|
+
queue: z.ZodString;
|
|
83
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
headerKeys: z.ZodArray<z.ZodString>;
|
|
85
|
+
visibilityTimeoutMilliseconds: z.ZodNumber;
|
|
86
|
+
retryPolicy: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
maxAttempts: z.ZodNumber;
|
|
88
|
+
initialBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
89
|
+
backoffMultiplier: z.ZodNumber;
|
|
90
|
+
maxBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
91
|
+
nonRetryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
92
|
+
}, z.core.$strict>>;
|
|
93
|
+
scheduleToCloseDeadline: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
executionRequirement: z.ZodOptional<z.ZodObject<{
|
|
95
|
+
deploymentName: z.ZodOptional<z.ZodString>;
|
|
96
|
+
buildId: z.ZodOptional<z.ZodString>;
|
|
97
|
+
artifactDigest: z.ZodOptional<z.ZodString>;
|
|
98
|
+
workflowRevision: z.ZodOptional<z.ZodString>;
|
|
99
|
+
activityContractHash: z.ZodOptional<z.ZodString>;
|
|
100
|
+
}, z.core.$strict>>;
|
|
101
|
+
fairShareKey: z.ZodOptional<z.ZodString>;
|
|
102
|
+
stickyWorkflowId: z.ZodOptional<z.ZodString>;
|
|
103
|
+
createdAt: z.ZodNumber;
|
|
104
|
+
attempt: z.ZodNumber;
|
|
105
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
106
|
+
pendingStatus: z.ZodEnum<{
|
|
107
|
+
completed: "completed";
|
|
108
|
+
failed: "failed";
|
|
109
|
+
}>;
|
|
110
|
+
resultDigest: z.ZodString;
|
|
111
|
+
leaseDeadline: z.ZodNumber;
|
|
112
|
+
firstQueuedAt: z.ZodNumber;
|
|
113
|
+
lastQueuedAt: z.ZodNumber;
|
|
114
|
+
startedAt: z.ZodNumber;
|
|
115
|
+
lastHeartbeatAt: z.ZodNumber;
|
|
116
|
+
state: z.ZodLiteral<"completing">;
|
|
117
|
+
retryCount: z.ZodNumber;
|
|
118
|
+
requeueCount: z.ZodNumber;
|
|
119
|
+
lastRequeueReason: z.ZodOptional<z.ZodString>;
|
|
120
|
+
operationId: z.ZodString;
|
|
121
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
122
|
+
workflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
123
|
+
workflowType: z.ZodString;
|
|
124
|
+
activityName: z.ZodString;
|
|
125
|
+
queue: z.ZodString;
|
|
126
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
127
|
+
headerKeys: z.ZodArray<z.ZodString>;
|
|
128
|
+
visibilityTimeoutMilliseconds: z.ZodNumber;
|
|
129
|
+
retryPolicy: z.ZodOptional<z.ZodObject<{
|
|
130
|
+
maxAttempts: z.ZodNumber;
|
|
131
|
+
initialBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
132
|
+
backoffMultiplier: z.ZodNumber;
|
|
133
|
+
maxBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
134
|
+
nonRetryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
135
|
+
}, z.core.$strict>>;
|
|
136
|
+
scheduleToCloseDeadline: z.ZodOptional<z.ZodNumber>;
|
|
137
|
+
executionRequirement: z.ZodOptional<z.ZodObject<{
|
|
138
|
+
deploymentName: z.ZodOptional<z.ZodString>;
|
|
139
|
+
buildId: z.ZodOptional<z.ZodString>;
|
|
140
|
+
artifactDigest: z.ZodOptional<z.ZodString>;
|
|
141
|
+
workflowRevision: z.ZodOptional<z.ZodString>;
|
|
142
|
+
activityContractHash: z.ZodOptional<z.ZodString>;
|
|
143
|
+
}, z.core.$strict>>;
|
|
144
|
+
fairShareKey: z.ZodOptional<z.ZodString>;
|
|
145
|
+
stickyWorkflowId: z.ZodOptional<z.ZodString>;
|
|
146
|
+
createdAt: z.ZodNumber;
|
|
147
|
+
attempt: z.ZodNumber;
|
|
148
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
149
|
+
cancellationReason: z.ZodString;
|
|
150
|
+
cancellationRequestedAt: z.ZodNumber;
|
|
151
|
+
leaseDeadline: z.ZodNumber;
|
|
152
|
+
firstQueuedAt: z.ZodNumber;
|
|
153
|
+
lastQueuedAt: z.ZodNumber;
|
|
154
|
+
startedAt: z.ZodNumber;
|
|
155
|
+
lastHeartbeatAt: z.ZodNumber;
|
|
156
|
+
state: z.ZodLiteral<"cancelling">;
|
|
157
|
+
retryCount: z.ZodNumber;
|
|
158
|
+
requeueCount: z.ZodNumber;
|
|
159
|
+
lastRequeueReason: z.ZodOptional<z.ZodString>;
|
|
160
|
+
operationId: z.ZodString;
|
|
161
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
162
|
+
workflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
163
|
+
workflowType: z.ZodString;
|
|
164
|
+
activityName: z.ZodString;
|
|
165
|
+
queue: z.ZodString;
|
|
166
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
headerKeys: z.ZodArray<z.ZodString>;
|
|
168
|
+
visibilityTimeoutMilliseconds: z.ZodNumber;
|
|
169
|
+
retryPolicy: z.ZodOptional<z.ZodObject<{
|
|
170
|
+
maxAttempts: z.ZodNumber;
|
|
171
|
+
initialBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
172
|
+
backoffMultiplier: z.ZodNumber;
|
|
173
|
+
maxBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
174
|
+
nonRetryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
175
|
+
}, z.core.$strict>>;
|
|
176
|
+
scheduleToCloseDeadline: z.ZodOptional<z.ZodNumber>;
|
|
177
|
+
executionRequirement: z.ZodOptional<z.ZodObject<{
|
|
178
|
+
deploymentName: z.ZodOptional<z.ZodString>;
|
|
179
|
+
buildId: z.ZodOptional<z.ZodString>;
|
|
180
|
+
artifactDigest: z.ZodOptional<z.ZodString>;
|
|
181
|
+
workflowRevision: z.ZodOptional<z.ZodString>;
|
|
182
|
+
activityContractHash: z.ZodOptional<z.ZodString>;
|
|
183
|
+
}, z.core.$strict>>;
|
|
184
|
+
fairShareKey: z.ZodOptional<z.ZodString>;
|
|
185
|
+
stickyWorkflowId: z.ZodOptional<z.ZodString>;
|
|
186
|
+
createdAt: z.ZodNumber;
|
|
187
|
+
attempt: z.ZodNumber;
|
|
188
|
+
}, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
189
|
+
disposition: z.ZodLiteral<"resolved">;
|
|
190
|
+
resultDigest: z.ZodString;
|
|
191
|
+
resultStatus: z.ZodEnum<{
|
|
192
|
+
completed: "completed";
|
|
193
|
+
failed: "failed";
|
|
194
|
+
}>;
|
|
195
|
+
error: z.ZodOptional<z.ZodString>;
|
|
196
|
+
state: z.ZodLiteral<"terminal">;
|
|
197
|
+
terminalAt: z.ZodNumber;
|
|
198
|
+
adopted: z.ZodBoolean;
|
|
199
|
+
adoptedAt: z.ZodOptional<z.ZodNumber>;
|
|
200
|
+
operationId: z.ZodString;
|
|
201
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
202
|
+
workflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
203
|
+
workflowType: z.ZodString;
|
|
204
|
+
activityName: z.ZodString;
|
|
205
|
+
queue: z.ZodString;
|
|
206
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
207
|
+
headerKeys: z.ZodArray<z.ZodString>;
|
|
208
|
+
visibilityTimeoutMilliseconds: z.ZodNumber;
|
|
209
|
+
retryPolicy: z.ZodOptional<z.ZodObject<{
|
|
210
|
+
maxAttempts: z.ZodNumber;
|
|
211
|
+
initialBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
212
|
+
backoffMultiplier: z.ZodNumber;
|
|
213
|
+
maxBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
214
|
+
nonRetryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
215
|
+
}, z.core.$strict>>;
|
|
216
|
+
scheduleToCloseDeadline: z.ZodOptional<z.ZodNumber>;
|
|
217
|
+
executionRequirement: z.ZodOptional<z.ZodObject<{
|
|
218
|
+
deploymentName: z.ZodOptional<z.ZodString>;
|
|
219
|
+
buildId: z.ZodOptional<z.ZodString>;
|
|
220
|
+
artifactDigest: z.ZodOptional<z.ZodString>;
|
|
221
|
+
workflowRevision: z.ZodOptional<z.ZodString>;
|
|
222
|
+
activityContractHash: z.ZodOptional<z.ZodString>;
|
|
223
|
+
}, z.core.$strict>>;
|
|
224
|
+
fairShareKey: z.ZodOptional<z.ZodString>;
|
|
225
|
+
stickyWorkflowId: z.ZodOptional<z.ZodString>;
|
|
226
|
+
createdAt: z.ZodNumber;
|
|
227
|
+
attempt: z.ZodNumber;
|
|
228
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
229
|
+
disposition: z.ZodLiteral<"cancelled">;
|
|
230
|
+
cancellationReason: z.ZodString;
|
|
231
|
+
state: z.ZodLiteral<"terminal">;
|
|
232
|
+
terminalAt: z.ZodNumber;
|
|
233
|
+
adopted: z.ZodBoolean;
|
|
234
|
+
adoptedAt: z.ZodOptional<z.ZodNumber>;
|
|
235
|
+
operationId: z.ZodString;
|
|
236
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
237
|
+
workflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
238
|
+
workflowType: z.ZodString;
|
|
239
|
+
activityName: z.ZodString;
|
|
240
|
+
queue: z.ZodString;
|
|
241
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
242
|
+
headerKeys: z.ZodArray<z.ZodString>;
|
|
243
|
+
visibilityTimeoutMilliseconds: z.ZodNumber;
|
|
244
|
+
retryPolicy: z.ZodOptional<z.ZodObject<{
|
|
245
|
+
maxAttempts: z.ZodNumber;
|
|
246
|
+
initialBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
247
|
+
backoffMultiplier: z.ZodNumber;
|
|
248
|
+
maxBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
249
|
+
nonRetryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
250
|
+
}, z.core.$strict>>;
|
|
251
|
+
scheduleToCloseDeadline: z.ZodOptional<z.ZodNumber>;
|
|
252
|
+
executionRequirement: z.ZodOptional<z.ZodObject<{
|
|
253
|
+
deploymentName: z.ZodOptional<z.ZodString>;
|
|
254
|
+
buildId: z.ZodOptional<z.ZodString>;
|
|
255
|
+
artifactDigest: z.ZodOptional<z.ZodString>;
|
|
256
|
+
workflowRevision: z.ZodOptional<z.ZodString>;
|
|
257
|
+
activityContractHash: z.ZodOptional<z.ZodString>;
|
|
258
|
+
}, z.core.$strict>>;
|
|
259
|
+
fairShareKey: z.ZodOptional<z.ZodString>;
|
|
260
|
+
stickyWorkflowId: z.ZodOptional<z.ZodString>;
|
|
261
|
+
createdAt: z.ZodNumber;
|
|
262
|
+
attempt: z.ZodNumber;
|
|
263
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
264
|
+
disposition: z.ZodLiteral<"retryExhausted">;
|
|
265
|
+
error: z.ZodString;
|
|
266
|
+
state: z.ZodLiteral<"terminal">;
|
|
267
|
+
terminalAt: z.ZodNumber;
|
|
268
|
+
adopted: z.ZodBoolean;
|
|
269
|
+
adoptedAt: z.ZodOptional<z.ZodNumber>;
|
|
270
|
+
operationId: z.ZodString;
|
|
271
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
272
|
+
workflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
273
|
+
workflowType: z.ZodString;
|
|
274
|
+
activityName: z.ZodString;
|
|
275
|
+
queue: z.ZodString;
|
|
276
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
277
|
+
headerKeys: z.ZodArray<z.ZodString>;
|
|
278
|
+
visibilityTimeoutMilliseconds: z.ZodNumber;
|
|
279
|
+
retryPolicy: z.ZodOptional<z.ZodObject<{
|
|
280
|
+
maxAttempts: z.ZodNumber;
|
|
281
|
+
initialBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
282
|
+
backoffMultiplier: z.ZodNumber;
|
|
283
|
+
maxBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
284
|
+
nonRetryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
285
|
+
}, z.core.$strict>>;
|
|
286
|
+
scheduleToCloseDeadline: z.ZodOptional<z.ZodNumber>;
|
|
287
|
+
executionRequirement: z.ZodOptional<z.ZodObject<{
|
|
288
|
+
deploymentName: z.ZodOptional<z.ZodString>;
|
|
289
|
+
buildId: z.ZodOptional<z.ZodString>;
|
|
290
|
+
artifactDigest: z.ZodOptional<z.ZodString>;
|
|
291
|
+
workflowRevision: z.ZodOptional<z.ZodString>;
|
|
292
|
+
activityContractHash: z.ZodOptional<z.ZodString>;
|
|
293
|
+
}, z.core.$strict>>;
|
|
294
|
+
fairShareKey: z.ZodOptional<z.ZodString>;
|
|
295
|
+
stickyWorkflowId: z.ZodOptional<z.ZodString>;
|
|
296
|
+
createdAt: z.ZodNumber;
|
|
297
|
+
attempt: z.ZodNumber;
|
|
298
|
+
}, z.core.$strict>], "disposition">, z.ZodObject<{
|
|
299
|
+
state: z.ZodLiteral<"deadLettered">;
|
|
300
|
+
pendingStatus: z.ZodEnum<{
|
|
301
|
+
completed: "completed";
|
|
302
|
+
failed: "failed";
|
|
303
|
+
}>;
|
|
304
|
+
resultDigest: z.ZodString;
|
|
305
|
+
deadLetteredAt: z.ZodNumber;
|
|
306
|
+
persistenceFailureReason: z.ZodString;
|
|
307
|
+
error: z.ZodOptional<z.ZodString>;
|
|
308
|
+
retryCount: z.ZodNumber;
|
|
309
|
+
requeueCount: z.ZodNumber;
|
|
310
|
+
lastRequeueReason: z.ZodOptional<z.ZodString>;
|
|
311
|
+
operationId: z.ZodString;
|
|
312
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
313
|
+
workflowExecutionToken: z.ZodOptional<z.ZodString>;
|
|
314
|
+
workflowType: z.ZodString;
|
|
315
|
+
activityName: z.ZodString;
|
|
316
|
+
queue: z.ZodString;
|
|
317
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
318
|
+
headerKeys: z.ZodArray<z.ZodString>;
|
|
319
|
+
visibilityTimeoutMilliseconds: z.ZodNumber;
|
|
320
|
+
retryPolicy: z.ZodOptional<z.ZodObject<{
|
|
321
|
+
maxAttempts: z.ZodNumber;
|
|
322
|
+
initialBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
323
|
+
backoffMultiplier: z.ZodNumber;
|
|
324
|
+
maxBackoff: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
325
|
+
nonRetryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
326
|
+
}, z.core.$strict>>;
|
|
327
|
+
scheduleToCloseDeadline: z.ZodOptional<z.ZodNumber>;
|
|
328
|
+
executionRequirement: z.ZodOptional<z.ZodObject<{
|
|
329
|
+
deploymentName: z.ZodOptional<z.ZodString>;
|
|
330
|
+
buildId: z.ZodOptional<z.ZodString>;
|
|
331
|
+
artifactDigest: z.ZodOptional<z.ZodString>;
|
|
332
|
+
workflowRevision: z.ZodOptional<z.ZodString>;
|
|
333
|
+
activityContractHash: z.ZodOptional<z.ZodString>;
|
|
334
|
+
}, z.core.$strict>>;
|
|
335
|
+
fairShareKey: z.ZodOptional<z.ZodString>;
|
|
336
|
+
stickyWorkflowId: z.ZodOptional<z.ZodString>;
|
|
337
|
+
createdAt: z.ZodNumber;
|
|
338
|
+
attempt: z.ZodNumber;
|
|
339
|
+
}, z.core.$strict>], "state">;
|
|
340
|
+
export type GetTaskDetailInput = z.infer<typeof getTaskDetailInput>;
|
|
341
|
+
export type GetTaskDetailOutput = z.infer<typeof getTaskDetailOutputSchema>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { MAX_TASK_IDENTIFIER_BYTES, utf8ByteLength } from "../task-ledger.js";
|
|
3
|
+
export const getTaskDetailInput = z.object({
|
|
4
|
+
operationId: z.string().min(1).refine((value) => utf8ByteLength(value) <= MAX_TASK_IDENTIFIER_BYTES, {
|
|
5
|
+
message: `operationId exceeds the ledger's ${MAX_TASK_IDENTIFIER_BYTES}-byte identifier limit`
|
|
6
|
+
})
|
|
7
|
+
});
|
|
8
|
+
const durationSchema = z.union([z.number(), z.string()]);
|
|
9
|
+
export const retryPolicySchema = z.object({
|
|
10
|
+
maxAttempts: z.number(),
|
|
11
|
+
initialBackoff: durationSchema,
|
|
12
|
+
backoffMultiplier: z.number(),
|
|
13
|
+
maxBackoff: durationSchema,
|
|
14
|
+
nonRetryableErrors: z.array(z.string()).optional()
|
|
15
|
+
}).strict(), executionRequirementSchema = z.object({
|
|
16
|
+
deploymentName: z.string().optional(),
|
|
17
|
+
buildId: z.string().optional(),
|
|
18
|
+
artifactDigest: z.string().optional(),
|
|
19
|
+
workflowRevision: z.string().optional(),
|
|
20
|
+
activityContractHash: z.string().optional()
|
|
21
|
+
}).strict();
|
|
22
|
+
const taskDetailBaseFields = {
|
|
23
|
+
operationId: z.string(),
|
|
24
|
+
workflowId: z.string().optional(),
|
|
25
|
+
workflowExecutionToken: z.string().optional(),
|
|
26
|
+
workflowType: z.string(),
|
|
27
|
+
activityName: z.string(),
|
|
28
|
+
queue: z.string(),
|
|
29
|
+
priority: z.number().optional(),
|
|
30
|
+
headerKeys: z.array(z.string()),
|
|
31
|
+
visibilityTimeoutMilliseconds: z.number(),
|
|
32
|
+
retryPolicy: retryPolicySchema.optional(),
|
|
33
|
+
scheduleToCloseDeadline: z.number().optional(),
|
|
34
|
+
executionRequirement: executionRequirementSchema.optional(),
|
|
35
|
+
fairShareKey: z.string().optional(),
|
|
36
|
+
stickyWorkflowId: z.string().optional(),
|
|
37
|
+
createdAt: z.number(),
|
|
38
|
+
attempt: z.number().int().nonnegative()
|
|
39
|
+
}, attemptSchemaFields = {
|
|
40
|
+
retryCount: z.number().int().nonnegative(),
|
|
41
|
+
requeueCount: z.number().int().nonnegative(),
|
|
42
|
+
lastRequeueReason: z.string().optional()
|
|
43
|
+
}, leaseHolderSchemaFields = {
|
|
44
|
+
leaseDeadline: z.number(),
|
|
45
|
+
firstQueuedAt: z.number(),
|
|
46
|
+
lastQueuedAt: z.number(),
|
|
47
|
+
startedAt: z.number(),
|
|
48
|
+
lastHeartbeatAt: z.number()
|
|
49
|
+
}, taskDetailQueuedSchema = z.object({
|
|
50
|
+
...taskDetailBaseFields,
|
|
51
|
+
...attemptSchemaFields,
|
|
52
|
+
state: z.literal("queued"),
|
|
53
|
+
availableAt: z.number(),
|
|
54
|
+
firstQueuedAt: z.number(),
|
|
55
|
+
lastQueuedAt: z.number(),
|
|
56
|
+
lastDispatchedAt: z.number().optional(),
|
|
57
|
+
startedAt: z.number().optional()
|
|
58
|
+
}).strict(), taskDetailLeasedSchema = z.object({
|
|
59
|
+
...taskDetailBaseFields,
|
|
60
|
+
...attemptSchemaFields,
|
|
61
|
+
state: z.literal("leased"),
|
|
62
|
+
...leaseHolderSchemaFields
|
|
63
|
+
}).strict(), taskDetailCompletingSchema = z.object({
|
|
64
|
+
...taskDetailBaseFields,
|
|
65
|
+
...attemptSchemaFields,
|
|
66
|
+
state: z.literal("completing"),
|
|
67
|
+
...leaseHolderSchemaFields,
|
|
68
|
+
pendingStatus: z.enum(["completed", "failed"]),
|
|
69
|
+
resultDigest: z.string()
|
|
70
|
+
}).strict(), taskDetailCancellingSchema = z.object({
|
|
71
|
+
...taskDetailBaseFields,
|
|
72
|
+
...attemptSchemaFields,
|
|
73
|
+
state: z.literal("cancelling"),
|
|
74
|
+
...leaseHolderSchemaFields,
|
|
75
|
+
cancellationReason: z.string(),
|
|
76
|
+
cancellationRequestedAt: z.number()
|
|
77
|
+
}).strict(), terminalCommonFields = {
|
|
78
|
+
...taskDetailBaseFields,
|
|
79
|
+
state: z.literal("terminal"),
|
|
80
|
+
terminalAt: z.number(),
|
|
81
|
+
adopted: z.boolean(),
|
|
82
|
+
adoptedAt: z.number().optional()
|
|
83
|
+
}, taskDetailTerminalResolvedSchema = z.object({
|
|
84
|
+
...terminalCommonFields,
|
|
85
|
+
disposition: z.literal("resolved"),
|
|
86
|
+
resultDigest: z.string(),
|
|
87
|
+
resultStatus: z.enum(["completed", "failed"]),
|
|
88
|
+
error: z.string().optional()
|
|
89
|
+
}).strict(), taskDetailTerminalCancelledSchema = z.object({
|
|
90
|
+
...terminalCommonFields,
|
|
91
|
+
disposition: z.literal("cancelled"),
|
|
92
|
+
cancellationReason: z.string()
|
|
93
|
+
}).strict(), taskDetailTerminalRetryExhaustedSchema = z.object({
|
|
94
|
+
...terminalCommonFields,
|
|
95
|
+
disposition: z.literal("retryExhausted"),
|
|
96
|
+
error: z.string()
|
|
97
|
+
}).strict(), taskDetailTerminalSchema = z.discriminatedUnion("disposition", [
|
|
98
|
+
taskDetailTerminalResolvedSchema,
|
|
99
|
+
taskDetailTerminalCancelledSchema,
|
|
100
|
+
taskDetailTerminalRetryExhaustedSchema
|
|
101
|
+
]), taskDetailDeadLetteredSchema = z.object({
|
|
102
|
+
...taskDetailBaseFields,
|
|
103
|
+
...attemptSchemaFields,
|
|
104
|
+
state: z.literal("deadLettered"),
|
|
105
|
+
pendingStatus: z.enum(["completed", "failed"]),
|
|
106
|
+
resultDigest: z.string(),
|
|
107
|
+
deadLetteredAt: z.number(),
|
|
108
|
+
persistenceFailureReason: z.string(),
|
|
109
|
+
error: z.string().optional()
|
|
110
|
+
}).strict();
|
|
111
|
+
export const getTaskDetailOutputSchema = z.discriminatedUnion("state", [
|
|
112
|
+
taskDetailQueuedSchema,
|
|
113
|
+
taskDetailLeasedSchema,
|
|
114
|
+
taskDetailCompletingSchema,
|
|
115
|
+
taskDetailCancellingSchema,
|
|
116
|
+
taskDetailTerminalSchema,
|
|
117
|
+
taskDetailDeadLetteredSchema
|
|
118
|
+
]);
|