@lostgradient/weft 0.19.0 → 0.21.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 +2 -2
- package/dist/cli/generated/operation-catalog.snapshot.json +1334 -0
- package/dist/cli/generated/operation-client.generated.d.ts +9 -2
- package/dist/cli/generated/operation-client.generated.js +2 -0
- package/dist/core/engine/activity-reconciliation.d.ts +2 -2
- package/dist/core/engine/activity-reconciliation.js +12 -8
- package/dist/core/engine/async-activity-completion.js +12 -4
- package/dist/core/engine/async-activity-records.d.ts +11 -1
- package/dist/core/engine/async-activity-records.js +4 -3
- package/dist/core/engine/attributes-tags.d.ts +11 -1
- package/dist/core/engine/attributes-tags.js +4 -3
- package/dist/core/engine/bulk-operations-purge.js +5 -2
- package/dist/core/engine/bulk-operations.js +17 -5
- package/dist/core/engine/callback-creators-bundles.js +1 -1
- package/dist/core/engine/callback-creators-core.js +4 -2
- package/dist/core/engine/checkpoint-io.js +1 -1
- package/dist/core/engine/child-workflow.js +2 -1
- package/dist/core/engine/completed-review-storage.js +1 -1
- package/dist/core/engine/condition-waiters.d.ts +45 -3
- package/dist/core/engine/condition-waiters.js +12 -3
- package/dist/core/engine/disposal.js +6 -0
- package/dist/core/engine/engine-internal-types.d.ts +12 -4
- package/dist/core/engine/fenced-write.d.ts +46 -15
- package/dist/core/engine/fenced-write.js +39 -6
- package/dist/core/engine/finalizer-state.d.ts +3 -1
- package/dist/core/engine/handle-result.d.ts +49 -1
- package/dist/core/engine/handle-result.js +95 -20
- package/dist/core/engine/index.d.ts +13 -5
- package/dist/core/engine/index.js +155 -5
- package/dist/core/engine/inline-launch-queue.js +9 -0
- package/dist/core/engine/internals.d.ts +73 -0
- package/dist/core/engine/invoke-update-handler.d.ts +19 -0
- package/dist/core/engine/invoke-update-handler.js +7 -0
- package/dist/core/engine/lease-deposition.d.ts +132 -0
- package/dist/core/engine/lease-deposition.js +31 -0
- package/dist/core/engine/lease-errors.d.ts +80 -9
- package/dist/core/engine/lease-errors.js +28 -2
- package/dist/core/engine/lifecycle/resume.js +3 -1
- package/dist/core/engine/lifecycle/standalone-claim-acquire.d.ts +33 -0
- package/dist/core/engine/lifecycle/standalone-claim-acquire.js +25 -0
- package/dist/core/engine/lifecycle/start-commit.js +20 -6
- package/dist/core/engine/lifecycle/transition.d.ts +15 -1
- package/dist/core/engine/lifecycle/transition.js +6 -3
- package/dist/core/engine/operations-activity.js +1 -1
- package/dist/core/engine/operations-time.js +21 -7
- package/dist/core/engine/owner-side-signal-poll.d.ts +132 -0
- package/dist/core/engine/owner-side-signal-poll.js +22 -0
- package/dist/core/engine/owner-side-update-poll.d.ts +116 -0
- package/dist/core/engine/owner-side-update-poll.js +22 -0
- package/dist/core/engine/ownership-bootstrap.d.ts +280 -0
- package/dist/core/engine/ownership-bootstrap.js +89 -0
- package/dist/core/engine/ownership-mode-marker.d.ts +82 -0
- package/dist/core/engine/ownership-mode-marker.js +52 -0
- package/dist/core/engine/ownership-options.d.ts +22 -6
- package/dist/core/engine/ownership-options.js +42 -12
- package/dist/core/engine/pending-updates.js +35 -24
- package/dist/core/engine/queries.d.ts +70 -0
- package/dist/core/engine/queries.js +58 -4
- package/dist/core/engine/schedules.js +1 -1
- package/dist/core/engine/signals.d.ts +11 -1
- package/dist/core/engine/signals.js +11 -7
- package/dist/core/engine/sleep-timer-acknowledgements.d.ts +68 -0
- package/dist/core/engine/sleep-timer-acknowledgements.js +19 -0
- package/dist/core/engine/storage-io.d.ts +58 -10
- package/dist/core/engine/storage-io.js +27 -9
- package/dist/core/engine/termination/cleanup.d.ts +5 -4
- package/dist/core/engine/termination/complete.js +23 -4
- package/dist/core/engine/termination/finalizer-claim.js +4 -4
- package/dist/core/engine/termination/state-commit-callbacks.d.ts +15 -0
- package/dist/core/engine/termination/state-commit-callbacks.js +0 -0
- package/dist/core/engine/termination/suspend.js +1 -1
- package/dist/core/engine/update-validation.d.ts +28 -0
- package/dist/core/engine/update-validation.js +37 -0
- package/dist/core/engine/updates.d.ts +17 -16
- package/dist/core/engine/updates.js +24 -47
- package/dist/core/engine/wake-ownership-check.d.ts +86 -0
- package/dist/core/engine/wake-ownership-check.js +19 -0
- package/dist/core/engine/wake-ownership-guard.d.ts +46 -0
- package/dist/core/engine/wake-ownership-guard.js +23 -0
- package/dist/core/engine/workflow-claim-codec.d.ts +64 -0
- package/dist/core/engine/workflow-claim-codec.js +44 -0
- package/dist/core/engine/workflow-claim-cooldown.d.ts +60 -0
- package/dist/core/engine/workflow-claim-cooldown.js +17 -0
- package/dist/core/engine/workflow-claim-fold.d.ts +82 -0
- package/dist/core/engine/workflow-claim-fold.js +53 -0
- package/dist/core/engine/workflow-claim-metrics.d.ts +131 -0
- package/dist/core/engine/workflow-claim-metrics.js +62 -0
- package/dist/core/engine/workflow-claim-reclaim-scan.d.ts +96 -0
- package/dist/core/engine/workflow-claim-reclaim-scan.js +66 -0
- package/dist/core/engine/workflow-claim-reclaim-target.d.ts +107 -0
- package/dist/core/engine/workflow-claim-reclaim-target.js +155 -0
- package/dist/core/engine/workflow-claim-registry.d.ts +227 -0
- package/dist/core/engine/workflow-claim-registry.js +198 -0
- package/dist/core/engine/workflow-claim-renewal-interval.d.ts +50 -0
- package/dist/core/engine/workflow-claim-renewal-interval.js +132 -0
- package/dist/core/engine/workflow-claim-renewal-subpasses.d.ts +265 -0
- package/dist/core/engine/workflow-claim-renewal-subpasses.js +104 -0
- package/dist/core/engine/workflow-claim-renewal-task.d.ts +159 -0
- package/dist/core/engine/workflow-claim-renewal-task.js +65 -0
- package/dist/core/engine/workflow-claim-transitions.d.ts +186 -0
- package/dist/core/engine/workflow-claim-transitions.js +120 -0
- package/dist/core/inline-execution-strategy.d.ts +20 -0
- package/dist/core/inline-execution-strategy.js +15 -4
- package/dist/core/scheduler/scheduler-class.js +3 -3
- package/dist/core/scheduler/timer-sources.d.ts +13 -0
- package/dist/core/scheduler/timer-sources.js +1 -1
- package/dist/core/types/options.d.ts +17 -1
- package/dist/core/weft-error.d.ts +1 -1
- package/dist/core/weft-error.js +2 -1
- package/dist/http.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -0
- package/dist/indexeddb.js +1 -1
- package/dist/json-schema.js +3 -3
- package/dist/observability/index.js +2 -2
- 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/static-registrations.js +3 -0
- package/dist/storage/auto.js +1 -1
- package/dist/storage/bun-sql.js +113 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/index.d.ts +38 -35
- package/dist/storage/interface.d.ts +87 -125
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-encoding.d.ts +51 -0
- package/dist/storage/key-encoding.js +13 -0
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +3 -0
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon.js +2 -2
- package/dist/storage/node-sqlite.js +113 -0
- package/dist/storage/ownership-keys.d.ts +55 -0
- package/dist/storage/ownership-keys.js +6 -0
- package/dist/storage/postgres.js +2 -2
- 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/dist/worker/protocol.js +1 -1
- package/package.json +1 -1
package/dist/json-schema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
`)}function
|
|
4
|
-
${
|
|
2
|
+
var F=import.meta.require;class K extends Error{code;constructor(j,q,z){super(q,z);this.code=j,this.name=j}}var Y={WorkflowAlreadyExistsError:!0,BulkDeleteRequiresTerminalWorkflowsError:!0,BulkOperationConfirmationError:!0,WorkflowTypeNotRegisteredForRecoveryError:!0,EngineCreateNameMismatchError:!0,EngineDisposedError:!0,EngineDisposalError:!0,WorkflowNotFoundError:!0,WorkflowNotRegisteredError:!0,WorkflowConcurrencyLimitExceededError:!0,WorkflowSuspendNotSupportedError:!0,ActivityResolutionError:!0,BranchTopologyChangedError:!0,PersistedDataIncompatibleError:!0,WorkflowTimeoutError:!0,HttpClientError:!0,WorkerProtocolIncompatibleError:!0,UpdateTimeoutError:!0,UpdateValidationError:!0,WorkflowTerminalError:!0,WorkflowBuilderError:!0,VersionMismatchError:!0,EffectReplayConflictError:!0,ReviewTimeoutError:!0,AtomicStateConflictError:!0,StandardSchemaValidationError:!0,ActivityReconciliationCapabilityError:!0,ActivityReconciliationConflictError:!0,ActivityReconciliationIndeterminateError:!0,DurableActivityScopeError:!0,DurableActivityUnsupportedError:!0,AsyncActivityTokenNotFoundError:!0,ActivityScheduleToCloseTimeoutError:!0,ActivityPerAttemptTimeoutError:!0,PayloadSizeExceededError:!0,StartOrSignalConflictError:!0,WorkflowTeardownPendingError:!0,IdempotencyKeyPurgedError:!0,WorkerManifestBuildError:!0,OwnershipModeMismatchError:!0},M=new Set(Object.keys(Y));class A extends K{fieldName;operation;issues;constructor(j){super("StandardSchemaValidationError",w(j.fieldName,j.operation,j.issues));this.fieldName=j.fieldName,this.operation=j.operation,this.issues=j.issues}}async function X(j,q,z){let G=j["~standard"];if(!Z(G))throw TypeError(`Schema for ${z.fieldName} does not provide runtime validation. Attach a Standard Schema validator (Zod, Valibot, or another vendor) or supply a runtime-validating schema at this boundary.`);let H=await G.validate(q);if(H.issues===void 0)return H.value;throw new A({fieldName:z.fieldName,operation:z.operation,issues:H.issues.map($)})}function Q(j){return j.map((q)=>q.path===""?q.message:`${q.path}: ${q.message}`).join(`
|
|
3
|
+
`)}function Z(j){return typeof j.validate==="function"}function $(j){return{message:j.message,path:B(j.path)}}function B(j){if(j===void 0||j.length===0)return"";let q="";for(let z of j)q+="/",q+=D(z);return q}function D(j){let q=U(j)?j.key:j;return b(String(q))}function U(j){return j!==null&&typeof j==="object"&&"key"in j}function b(j){return j.replace(/~/g,"~0").replace(/\//g,"~1")}function w(j,q,z){return`Validation failed for ${q===void 0?j:`${q} ${j}`}:
|
|
4
|
+
${Q(z)}`}var R=Q,_=A,C=X;export{C as validateStandardSchema,R as formatStandardSchemaIssues,_ as StandardSchemaValidationError};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var Jn=import.meta.require
|
|
2
|
+
var Jn=import.meta.require;var h={traceId:"0".repeat(32),spanId:"0".repeat(16),traceFlags:0},R={setAttribute(){},setStatus(){},recordException(){},end(){},spanContext(){return h}},q={setAttribute:(...n)=>R.setAttribute(...n),setStatus:(...n)=>R.setStatus(...n),recordException:(...n)=>R.recordException(...n),end:(...n)=>R.end(...n)},l={startSpan(){return R}},P={record(){},add(){}},t={createHistogram(){return P},createCounter(){return P},createUpDownCounter(){return P}},r=Symbol("ROOT_CONTEXT"),a={trace:{getTracer(){return l},setSpan(n){return n}},metrics:{getMeter(){return t}},context:{ROOT_CONTEXT:r,with(n,w){return w()}},SpanStatusCode:{OK:1,ERROR:2,UNSET:0}},G;function s(){let n=globalThis.require;if(typeof n==="function")return(w)=>n(w);return()=>{return}}function e(n){return n?.trace?.getTracer!=null&&n.SpanStatusCode!=null}function nn(n=s()){try{let w=n("@opentelemetry/api");if(e(w))return w}catch{}return}function o(n){if(G)return G;let w=nn(n);if(w)return G=w,G;return G=a,G}function H(n){let w=new Uint8Array(n);return crypto.getRandomValues(w),Array.from(w,(i)=>i.toString(16).padStart(2,"0")).join("")}var Y="traceparent",wn=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/,Sn="00000000000000000000000000000000",kn="0000000000000000";function Z(n){let w=wn.exec(n);if(!w)return null;let[,i,S,k,v]=w;if(S===Sn)return null;if(k===kn)return null;return{version:i,traceId:S,spanId:k,traceFlags:parseInt(v,16)}}function M(n){let w=n.traceFlags.toString(16).padStart(2,"0");return`${n.version}-${n.traceId}-${n.spanId}-${w}`}function T(n){let w=n.get(Y);if(!w)return null;return Z(w)}function U(n,w){n.set(Y,M(w))}function fn(){return H(16)}function vn(){return H(8)}var O=1024;function K(n,w){let i;try{i=JSON.stringify(n)}catch{i=String(n)}if(i.length>w)return i.slice(0,w)+"...";return i}function yn(n){return n instanceof Error?n.message:String(n)}function Wn(n){return n instanceof Error?n:Error(String(n))}function J(n,w){let i=n.spanContext();U(w,{version:"00",traceId:i.traceId,spanId:i.spanId,traceFlags:i.traceFlags})}function C(n,w,i){let S=n.attributeExtractor;if(!S)return;let k=S(i);for(let[v,y]of Object.entries(k))w.setAttribute(v,y)}function Q(n,w){let i=n.workflowSpans.get(w);return i?n.trace.setSpan(n.api.context.ROOT_CONTEXT,i.span):n.api.context.ROOT_CONTEXT}function V(n,w,i){w.setStatus({code:n.SpanStatusCode.ERROR,message:yn(i)}),w.recordException(Wn(i))}function _(n,w,i,S){try{let k=i();return w.setStatus({code:n.SpanStatusCode.OK}),S?.(k),k}catch(k){throw V(n,w,k),k}finally{w.end()}}async function j(n,w,i,S){try{let k=await i();return w.setStatus({code:n.SpanStatusCode.OK}),S?.(k),k}catch(k){throw V(n,w,k),k}finally{w.end()}}function*x(n,w,i,S){try{let k=yield*i();return w.setStatus({code:n.SpanStatusCode.OK}),S?.(k),k}catch(k){throw V(n,w,k),k}finally{w.end()}}function g(n){return{async execute(w,i){let S=T(w.headers),k=n.api.context.ROOT_CONTEXT;if(S){let y={...q,spanContext(){return{traceId:S.traceId,spanId:S.spanId,traceFlags:S.traceFlags}}};k=n.trace.setSpan(n.api.context.ROOT_CONTEXT,y)}let v=n.tracer.startSpan(`activity:execute:${w.activityName}`,{attributes:{"weft.activity.name":w.activityName,"weft.activity.attempt":w.attempt,...S?{"weft.parent.trace_id":S.traceId}:{}}},k);if(n.recordPayloads&&w.input!==void 0)v.setAttribute("weft.payload.input",K(w.input,n.maxPayloadSize));return j(n,v,()=>i(w))}}}var A={workflowDuration:{name:"weft.workflow.duration",description:"Duration of workflow execution in milliseconds",unit:"ms",type:"histogram"},activityDuration:{name:"weft.activity.duration",description:"Duration of activity execution in milliseconds",unit:"ms",type:"histogram"},activityAttempts:{name:"weft.activity.attempts",description:"Total activity execution attempts",unit:"attempts",type:"counter"},workflowActive:{name:"weft.workflow.active",description:"Number of currently active workflows",unit:"workflows",type:"gauge"},workflowStarted:{name:"weft.workflow.started",description:"Total workflows started",unit:"workflows",type:"counter"},workflowCompleted:{name:"weft.workflow.completed",description:"Total workflows completed",unit:"workflows",type:"counter"},workflowFailed:{name:"weft.workflow.failed",description:"Total workflows failed",unit:"workflows",type:"counter"},promptCacheHits:{name:"weft.prompt_cache.hits",description:"Total prompt prefix cache hits",unit:"hits",type:"counter"},promptCacheMisses:{name:"weft.prompt_cache.misses",description:"Total prompt prefix cache misses",unit:"misses",type:"counter"},dpmoDefects:{name:"weft.dpmo.defects",description:"Total failed workflows (DPMO numerator)",unit:"workflows",type:"counter"},dpmoOperations:{name:"weft.dpmo.operations",description:"Total started workflows (DPMO denominator)",unit:"workflows",type:"counter"},taskBacklog:{name:"weft.task.backlog",description:"Number of queued tasks waiting for workers",unit:"tasks",type:"gauge"},taskQueueLatency:{name:"weft.task.queue_latency",description:"Time tasks spend queued before dispatch in milliseconds",unit:"ms",type:"histogram"},taskExecutionLatency:{name:"weft.task.execution_latency",description:"Time tasks spend executing after worker start in milliseconds",unit:"ms",type:"histogram"},taskRetries:{name:"weft.task.retries",description:"Total task retry attempts after the first dispatch attempt",unit:"retries",type:"counter"},taskRequeues:{name:"weft.task.requeues",description:"Total visibility-timeout or disconnect task requeues",unit:"requeues",type:"counter"},taskStaleHeartbeats:{name:"weft.task.stale_heartbeats",description:"Number of in-flight tasks whose heartbeat age exceeds the diagnostic threshold",unit:"tasks",type:"gauge"},workerCapacitySaturation:{name:"weft.worker.capacity_saturation",description:"Ratio of in-flight worker slots to total worker concurrency",unit:"ratio",type:"gauge"}};var dn=1e4;class z{#n;#i=0;#w=0;constructor(n){this.#n=new Float64Array(n)}push(n){if(this.#n[this.#i]=n,this.#i=(this.#i+1)%this.#n.length,this.#w<this.#n.length)this.#w++}toArray(){if(this.#w<this.#n.length)return Array.from(this.#n.subarray(0,this.#w));let n=Array.from({length:this.#w});for(let w=0;w<this.#w;w++)n[w]=this.#n[(this.#i+w)%this.#n.length];return n}}class B{#n;#i;#w;constructor(){this.#n=new Map,this.#i=new Map,this.#w=new Map}increment(n,w=1){this.#n.set(n,(this.#n.get(n)??0)+w)}record(n,w){let i=this.#i.get(n);if(!i)i=new z(dn),this.#i.set(n,i);i.push(w)}gauge(n,w){this.#w.set(n,w)}snapshot(){let n={};for(let[w,i]of this.#n)n[w]={type:"counter",value:i};for(let[w,i]of this.#i){let S=i.toArray(),k=In(S);n[w]={type:"histogram",count:S.length,sum:Fn(S),p50:k[Math.floor(k.length*0.5)]??0,p99:k[Math.floor(k.length*0.99)]??0,min:k[0]??0,max:k[k.length-1]??0}}for(let[w,i]of this.#w)n[w]={type:"gauge",value:i};return n}reset(){this.#n.clear(),this.#i.clear(),this.#w.clear()}}function pn(n){let w;if(typeof n==="string")w=o().metrics.getMeter(n);else if(n)w=n;else w=o().metrics.getMeter("weft");return{workflowDuration:w.createHistogram("weft.workflow.duration",{unit:"ms"}),activityDuration:w.createHistogram("weft.activity.duration",{unit:"ms"}),activityAttempts:w.createCounter("weft.activity.attempts"),activeWorkflows:w.createUpDownCounter("weft.workflow.active")}}function In(n){let w=[...n];return w.sort((i,S)=>i-S),w}function Fn(n){let w=0;for(let i of n)w+=i;return w}function Ln(n,w){let i=w?.type==="histogram"?w.count:0,S=w?.type==="histogram"?w.sum:0;return[`# TYPE ${n} histogram`,`${n}_count ${i}`,`${n}_sum ${S}`]}function $n(n,w){let i=w?.type==="counter"?w.value:0;return[`# TYPE ${n} counter`,`${n}_total ${i}`]}function Gn(n,w){let i=w?.type==="gauge"?w.value:0;return[`# TYPE ${n} gauge`,`${n} ${i}`]}var on={histogram:Ln,counter:$n,gauge:Gn};function Kn(n,w){let i=n.name.replace(/\./g,"_"),S=w[n.name];return[`# HELP ${i} ${n.description}`,...on[n.type](i,S)]}function Cn(n){let w=n[A.dpmoDefects.name],i=n[A.dpmoOperations.name],S=w?.type==="counter"?w.value:0,k=i?.type==="counter"?i.value:0,v=k===0?0:S*1e6/k,y="weft_dpmo";return["# HELP weft_dpmo Defects per million operations (failed workflows / started workflows * 1e6)","# TYPE weft_dpmo gauge",`weft_dpmo ${v}`]}function b(n){let w=[];for(let i of Object.values(A))w.push(...Kn(i,n));return w.push(...Cn(n)),w.join(`
|
|
3
3
|
`)+`
|
|
4
|
-
`}function An(n){return{serialize(){let w=n?.snapshot()??{};return b(w)}}}class
|
|
4
|
+
`}function An(n){return{serialize(){let w=n?.snapshot()??{};return b(w)}}}class p extends Event{static type="workflow:completed";workflowId;result;duration;constructor(n,w,i){super(p.type);this.workflowId=n,this.result=w,this.duration=i}}class I extends Event{static type="workflow:failed";workflowId;error;constructor(n,w){super(I.type);this.workflowId=n,this.error=w}}class F extends Event{static type="workflow:cancelled";workflowId;constructor(n){super(F.type);this.workflowId=n}}class L extends Event{static type="workflow:timed-out";workflowId;timeoutType;elapsed;reason;constructor(n,w,i,S){super(L.type);if(this.workflowId=n,this.timeoutType=w,this.elapsed=i,S!==void 0)this.reason=S}}var _n=new Set([p.type,I.type,F.type,L.type]);var Xn=3600000,E=1e4,Rn=3600000;function c(n){let w=Date.now();for(let[i,S]of n.workflowSpans)if(w-S.createdAt>Xn)S.span.end(),n.workflowSpans.delete(i);if(n.workflowSpans.size>E){let i=n.workflowSpans.size-E,S=0;for(let[k,v]of n.workflowSpans){if(S>=i)break;v.span.end(),n.workflowSpans.delete(k),S++}}}function N(n,w){let i=n.workflowSpans.get(w);if(i)i.span.end(),n.workflowSpans.delete(w)}function u(n){function w(f,$,W){let d=n.workflowSpans.get(f);if(!d)return;if($==="error")d.span.setStatus({code:n.SpanStatusCode.ERROR,...W?{message:W}:{}});else d.span.setStatus({code:n.SpanStatusCode.OK});d.span.end(),n.workflowSpans.delete(f)}let i=(f)=>{if(!(f instanceof p))return;w(f.workflowId,"ok")},S=(f)=>{if(!(f instanceof I))return;w(f.workflowId,"error",f.error.message),n.metrics.increment("weft.dpmo.defects")},k=(f)=>{if(!(f instanceof F))return;w(f.workflowId,"error","Workflow cancelled")},v=(f)=>{if(!(f instanceof L))return;w(f.workflowId,"error",`Workflow timed out (${f.timeoutType}) after ${f.elapsed}ms`),n.metrics.increment("weft.dpmo.defects")};if(n.eventTarget)n.eventTarget.addEventListener(p.type,i),n.eventTarget.addEventListener(I.type,S),n.eventTarget.addEventListener(F.type,k),n.eventTarget.addEventListener(L.type,v);function y(f=Rn){let $=Date.now()-f,W=0;for(let[d,X]of n.workflowSpans)if(X.createdAt<=$)X.span.setStatus({code:n.SpanStatusCode.ERROR,message:"span evicted (stale)"}),X.span.end(),n.workflowSpans.delete(d),W++;return W}function D(){if(n.eventTarget)n.eventTarget.removeEventListener(p.type,i),n.eventTarget.removeEventListener(I.type,S),n.eventTarget.removeEventListener(F.type,k),n.eventTarget.removeEventListener(L.type,v);for(let f of n.workflowSpans.values())f.span.setStatus({code:n.SpanStatusCode.ERROR,message:"Observability disposed"}),f.span.end();n.workflowSpans.clear()}return{endWorkflowSpan:w,evictStaleSpans:y,dispose:D}}function m(n){return{workflowStart(w,i){c(n);let S=n.workflowSpans.get(w.workflowId);if(S)S.span.setStatus({code:n.SpanStatusCode.OK}),N(n,w.workflowId);let k=n.tracer.startSpan(`workflow:${w.workflowType}`,{attributes:{"weft.workflow.id":w.workflowId,"weft.workflow.type":w.workflowType}});if(n.workflowSpans.set(w.workflowId,{span:k,createdAt:Date.now()}),J(k,w.headers),n.recordPayloads&&w.input!==void 0)k.setAttribute("weft.payload.input",K(w.input,n.maxPayloadSize));C(n,k,w),n.metrics.increment("weft.workflow.started"),n.metrics.increment("weft.dpmo.operations"),i(w)},*activity(w,i){let S=n.tracer.startSpan(`activity:${w.activityName}`,{attributes:{"weft.activity.name":w.activityName,"weft.activity.attempt":w.attempt}},Q(n,w.workflowId));if(J(S,w.headers),n.recordPayloads&&w.input!==void 0)S.setAttribute("weft.payload.input",K(w.input,n.maxPayloadSize));C(n,S,w);let k=Date.now();return yield*x(n,S,()=>i(w),()=>{n.metrics.record("weft.activity.duration",Date.now()-k),n.metrics.increment("weft.activity.attempts")})},*sleep(w,i){let S=n.tracer.startSpan("sleep",{attributes:{"weft.sleep.duration":w.duration}},Q(n,w.workflowId));C(n,S,w),yield*x(n,S,()=>i(w))},*waitForSignal(w,i){let S=n.tracer.startSpan("waitForSignal",{attributes:{"weft.signal.name":w.signalName}},Q(n,w.workflowId));return C(n,S,w),yield*x(n,S,()=>i(w))},async childWorkflow(w,i){let S=[],k=T(w.parentHeaders);if(k)S.push({context:{traceId:k.traceId,spanId:k.spanId,traceFlags:k.traceFlags}});let v=n.tracer.startSpan(`childWorkflow:${w.workflowType}`,{attributes:{"weft.child_workflow.type":w.workflowType,"weft.child_workflow.id":w.childWorkflowId,"weft.child_workflow.parent_id":w.workflowId},links:S},n.api.context.ROOT_CONTEXT);if(J(v,w.headers),n.recordPayloads&&w.input!==void 0)v.setAttribute("weft.payload.input",K(w.input,n.maxPayloadSize));return n.metrics.increment("weft.child_workflow.started"),j(n,v,()=>i(w))},signalReceived(w,i){let S=n.tracer.startSpan(`signal:received:${w.signalName}`,{attributes:{"weft.signal.name":w.signalName,"weft.signal.workflow_id":w.workflowId}});C(n,S,w),_(n,S,()=>i(w))}}}function Tn(n){let{attributeExtractor:w,eventTarget:i,maxPayloadSize:S=O,metrics:k=new B,openTelemetryApi:v=o(),recordPayloads:y=!1,tracerName:D="weft",tracerVersion:f}=n??{},$=v,{trace:W,SpanStatusCode:d}=$,X=W.getTracer(D,f);return{api:$,trace:W,SpanStatusCode:d,tracer:X,recordPayloads:y,maxPayloadSize:S,attributeExtractor:w,eventTarget:i,metrics:k,workflowSpans:new Map}}function sn(n){let w=Tn(n),i=m(w),S=g(w),k={...i,...S},v=u(w);return{interceptor:k,metrics:w.metrics,...v}}export{b as serializeMetricsSnapshotForPrometheus,Z as parseTraceParent,U as injectTraceParent,o as getOpenTelemetryApi,fn as generateTraceId,vn as generateSpanId,M as formatTraceParent,T as extractTraceParent,pn as createOpenTelemetryMetrics,sn as createObservabilityInterceptors,An as createMetricsCollectorExporter,B as MetricsCollector,A as METRICS};
|
|
@@ -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
|
+
]);
|