@lostgradient/weft 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-main.js +77 -77
- package/dist/core/context/index.d.ts +1 -0
- package/dist/core/context/index.js +3 -0
- package/dist/core/context/internals.d.ts +1 -0
- package/dist/core/context/internals.js +2 -1
- package/dist/core/context/speculative-child.js +2 -0
- package/dist/core/context/types.d.ts +6 -0
- package/dist/core/engine/bulk-operations-purge.js +1 -0
- package/dist/core/engine/callback-creators-bundles.js +2 -1
- package/dist/core/engine/callback-creators-core.js +2 -1
- package/dist/core/engine/construction.d.ts +1 -0
- package/dist/core/engine/construction.js +5 -2
- package/dist/core/engine/engine-internal-types.d.ts +5 -0
- package/dist/core/engine/index.d.ts +26 -0
- package/dist/core/engine/index.js +7 -1
- package/dist/core/engine/internals.d.ts +8 -0
- package/dist/core/engine/lifecycle/recovered-services.d.ts +45 -0
- package/dist/core/engine/lifecycle/recovered-services.js +34 -0
- package/dist/core/engine/lifecycle/resume.js +8 -1
- package/dist/core/engine/lifecycle/shared.d.ts +8 -0
- package/dist/core/engine/lifecycle/start-batch.js +23 -12
- package/dist/core/engine/lifecycle/start.js +11 -0
- package/dist/core/engine/operations-data.d.ts +16 -0
- package/dist/core/engine/operations-data.js +6 -0
- package/dist/core/engine/operations-time.d.ts +3 -2
- package/dist/core/engine/operations-time.js +6 -1
- package/dist/core/engine/termination/cleanup.js +2 -0
- package/dist/core/inline-execution-strategy.d.ts +5 -0
- package/dist/core/inline-execution-strategy.js +2 -1
- package/dist/core/types/options.d.ts +89 -0
- package/dist/core/types/workflow-context.d.ts +25 -0
- package/dist/core/weft-error.d.ts +45 -13
- package/dist/core/weft-error.js +9 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +1 -1
- package/dist/json-schema.js +3 -3
- package/dist/mcp/cli.js +17 -17
- package/dist/server/handler.js +12 -12
- package/dist/server/index.js +24 -24
- package/dist/service-worker/index.js +12 -12
- package/dist/storage/http.js +1 -1
- package/dist/storage/index.d.ts +2 -1
- package/dist/storage/indexeddb.js +1 -1
- package/dist/storage/interface.d.ts +14 -0
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +1 -0
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/text-value-store.d.ts +4 -1
- package/dist/storage/turso.js +1 -1
- package/dist/storage/typed-storage.js +1 -1
- package/dist/storage/web-extension.js +1 -1
- package/dist/testing/event-loop.d.ts +36 -2
- package/dist/testing/index.d.ts +31 -1
- package/dist/testing/index.js +17 -17
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -52,6 +52,65 @@ export interface StartOptions {
|
|
|
52
52
|
startAfter?: Duration;
|
|
53
53
|
tags?: string[];
|
|
54
54
|
searchAttributes?: Record<string, SearchAttributeValue>;
|
|
55
|
+
/**
|
|
56
|
+
* Host-supplied, per-run capabilities exposed to the workflow body as
|
|
57
|
+
* `ctx.services` (live clients, closures, tool registries). The value is
|
|
58
|
+
* **never checkpointed**; on a fresh-process recovery it is re-provided by the
|
|
59
|
+
* engine's {@link EngineOptions.resolveWorkflowServices} resolver before the
|
|
60
|
+
* generator advances.
|
|
61
|
+
*
|
|
62
|
+
* Inline execution mode only. Passing `services` under
|
|
63
|
+
* `workflowExecutionMode: 'worker'` throws at `engine.start()`, because a
|
|
64
|
+
* non-serializable value cannot cross to a Worker.
|
|
65
|
+
*/
|
|
66
|
+
services?: unknown;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Result of {@link EngineOptions.resolveWorkflowServices}. An explicit union
|
|
70
|
+
* rather than a nullable return: `'unavailable'` is a deliberate, named outcome
|
|
71
|
+
* (the run's dependencies cannot be rebuilt in this process) that fails just
|
|
72
|
+
* that recovered run — it does not overload the resolved value with a lifecycle
|
|
73
|
+
* signal.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { type WorkflowServicesResolution } from '@lostgradient/weft';
|
|
78
|
+
*
|
|
79
|
+
* const ok: WorkflowServicesResolution = {
|
|
80
|
+
* status: 'available',
|
|
81
|
+
* services: { db: { query: () => [] } },
|
|
82
|
+
* };
|
|
83
|
+
* const no: WorkflowServicesResolution = { status: 'unavailable', reason: 'no config' };
|
|
84
|
+
* void ok;
|
|
85
|
+
* void no;
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export type WorkflowServicesResolution = {
|
|
89
|
+
status: 'available';
|
|
90
|
+
services: unknown;
|
|
91
|
+
} | {
|
|
92
|
+
status: 'unavailable';
|
|
93
|
+
reason: string;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Information passed to {@link EngineOptions.resolveWorkflowServices} for each
|
|
97
|
+
* recovered workflow. `input` is the original durable launch input, available
|
|
98
|
+
* at resume time — typically enough to rebuild the run's dependencies (tenant,
|
|
99
|
+
* model, tool registry) without a side table.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* import { type WorkflowServicesResolverInfo } from '@lostgradient/weft';
|
|
104
|
+
*
|
|
105
|
+
* function describe(info: WorkflowServicesResolverInfo): string {
|
|
106
|
+
* return `${info.workflowType}/${info.workflowId}`;
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export interface WorkflowServicesResolverInfo {
|
|
111
|
+
workflowId: string;
|
|
112
|
+
workflowType: string;
|
|
113
|
+
input: unknown;
|
|
55
114
|
}
|
|
56
115
|
/**
|
|
57
116
|
* Options for {@link Engine.fork}. Controls which checkpoint step to fork
|
|
@@ -197,6 +256,36 @@ export interface EngineOptions {
|
|
|
197
256
|
* after passing it has no effect.
|
|
198
257
|
*/
|
|
199
258
|
interceptors?: readonly Interceptor[];
|
|
259
|
+
/**
|
|
260
|
+
* Re-provide the non-serialized per-run `services` value (see
|
|
261
|
+
* {@link StartOptions.services}) for a workflow recovered in a fresh process.
|
|
262
|
+
* `engine.recoverAll()` and `engine.resume(id)` call this **before** the
|
|
263
|
+
* generator is driven forward (and the delayed-start timer handler calls it
|
|
264
|
+
* for a `startAfter`/`startAt` run that crashed before firing), so the resumed
|
|
265
|
+
* body can read `ctx.services` exactly as it did before the crash.
|
|
266
|
+
*
|
|
267
|
+
* Return `{ status: 'available', services }` to supply the rebuilt
|
|
268
|
+
* capabilities, or `{ status: 'unavailable', reason }` to fail just that one
|
|
269
|
+
* recovered run — the engine and every other recovered run are unaffected.
|
|
270
|
+
* Without a resolver, a recovered inline workflow that reads `ctx.services`
|
|
271
|
+
* sees `undefined`.
|
|
272
|
+
*
|
|
273
|
+
* Contract a fresh integrator must know:
|
|
274
|
+
* - Fires only for recovered inline runs that were launched WITH `services`
|
|
275
|
+
* (those carrying the durable "expects services" marker). A run started
|
|
276
|
+
* without `services` never reaches the resolver, regardless of what it would
|
|
277
|
+
* return — so a fail-closed resolver does not fail innocent no-services runs.
|
|
278
|
+
* - `{ status: 'unavailable' }` permanently fails the run (terminal `failed`,
|
|
279
|
+
* `system` category) with `reason` as the message — not a "retry later"
|
|
280
|
+
* signal. A resolver *throw* is treated identically (error message → reason).
|
|
281
|
+
* - May be called again on a later boot if a prior recovery left the run still
|
|
282
|
+
* recoverable (e.g. the terminal-fail commit faulted), so keep it idempotent.
|
|
283
|
+
* - Inline only; worker-mode runs never invoke it.
|
|
284
|
+
*
|
|
285
|
+
* Engine-scoped: each engine instance carries its own resolver, so two engines
|
|
286
|
+
* in one process never collide on per-run dependency reconstruction.
|
|
287
|
+
*/
|
|
288
|
+
resolveWorkflowServices?: (info: WorkflowServicesResolverInfo) => WorkflowServicesResolution | Promise<WorkflowServicesResolution>;
|
|
200
289
|
}
|
|
201
290
|
/**
|
|
202
291
|
* Filter criteria for {@link Engine.list}. All fields are optional and
|
|
@@ -57,6 +57,31 @@ export interface WorkflowContext<TActivities extends ActivityMap = {}, TSignals
|
|
|
57
57
|
readonly executionTimeRemaining: number;
|
|
58
58
|
readonly startedAt: number;
|
|
59
59
|
readonly state: WorkflowStateNamespace;
|
|
60
|
+
/**
|
|
61
|
+
* Host-supplied, per-run capabilities passed at launch via
|
|
62
|
+
* `engine.start(type, input, { services })` (or `ctx.run`-free closures, live
|
|
63
|
+
* clients, tool registries). The value is **never checkpointed**: it is held
|
|
64
|
+
* only in engine memory for this run, and on a fresh-process recovery it is
|
|
65
|
+
* re-provided by the engine's `resolveWorkflowServices` resolver before the
|
|
66
|
+
* generator advances. `undefined` when no services were supplied (and not yet
|
|
67
|
+
* re-provided on recovery). Inline execution mode only — passing `services`
|
|
68
|
+
* under `workflowExecutionMode: 'worker'` throws at `engine.start()`, since a
|
|
69
|
+
* non-serializable value cannot cross to a Worker.
|
|
70
|
+
*
|
|
71
|
+
* Typed `unknown`: narrow or cast at the call site
|
|
72
|
+
* (`const { db } = ctx.services as MyServices`). A threaded generic is a
|
|
73
|
+
* deliberate follow-on, not part of this surface yet. Optional so existing
|
|
74
|
+
* structural `WorkflowContext` implementors are not source-broken.
|
|
75
|
+
*
|
|
76
|
+
* Separate child *workflows* started from within a workflow (`ctx.startChild()`)
|
|
77
|
+
* do **not** inherit the parent's `services` — each run is its own workflow with
|
|
78
|
+
* its own services, configured the same way (and re-provided on recovery by the
|
|
79
|
+
* engine's `resolveWorkflowServices`). This is distinct from a *speculative
|
|
80
|
+
* child context*, which is the same run advanced in-memory for speculative
|
|
81
|
+
* replay (same `workflowId`) and therefore does carry the run's `services`
|
|
82
|
+
* across.
|
|
83
|
+
*/
|
|
84
|
+
readonly services?: unknown;
|
|
60
85
|
run<TName extends keyof TActivities & string>(name: TName, ...rest: ActivityArgsFor<TActivities[TName]>): WorkflowOperation<ActivityResultFor<TActivities[TName]>>;
|
|
61
86
|
run<TName extends keyof TActivities & string>(name: TName, ...rest: [...ActivityArgsFor<TActivities[TName]>, ActivityCallOptions]): WorkflowOperation<ActivityResultFor<TActivities[TName]>>;
|
|
62
87
|
run<TName extends string>(name: UnknownNameWhenRegistryHasNoKnownNames<TName, keyof TActivities & string>, input?: unknown, options?: ActivityCallOptions): WorkflowOperation<unknown>;
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
* exported from `@lostgradient/weft` carry internal codes that are intentionally absent
|
|
6
6
|
* from this union and may change between releases.
|
|
7
7
|
*
|
|
8
|
-
* Prefer comparing `error.code` (or {@link
|
|
8
|
+
* Prefer comparing `error.code` (or {@link isWeftErrorLike}) over `instanceof`
|
|
9
9
|
* when an error may have crossed a realm or duplicate-module boundary, where
|
|
10
10
|
* `instanceof` is unreliable.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
14
|
-
* import {
|
|
14
|
+
* import { isWeftErrorLike, type WeftErrorCode } from '@lostgradient/weft';
|
|
15
15
|
*
|
|
16
16
|
* function statusFor(error: unknown): number {
|
|
17
|
-
* if (
|
|
17
|
+
* if (isWeftErrorLike(error)) {
|
|
18
18
|
* const code: WeftErrorCode = error.code;
|
|
19
19
|
* return code === 'WorkflowNotFoundError' ? 404 : 400;
|
|
20
20
|
* }
|
|
@@ -50,8 +50,10 @@ export declare abstract class WeftError<TCode extends string = string> extends E
|
|
|
50
50
|
/**
|
|
51
51
|
* Same-realm narrowing: `true` when `value` is a Weft library error instance.
|
|
52
52
|
* Use this for the common case of catching any Weft error. For comparisons
|
|
53
|
-
* that may cross a realm or duplicate-module boundary
|
|
54
|
-
* {@link
|
|
53
|
+
* that may cross a realm or duplicate-module boundary (where `instanceof` is
|
|
54
|
+
* unreliable), use {@link isWeftErrorLike} instead — it narrows the error
|
|
55
|
+
* object structurally. {@link isWeftErrorCode} narrows a bare `code` *string*,
|
|
56
|
+
* not a caught `unknown`.
|
|
55
57
|
*
|
|
56
58
|
* @example
|
|
57
59
|
* ```ts
|
|
@@ -64,19 +66,49 @@ export declare abstract class WeftError<TCode extends string = string> extends E
|
|
|
64
66
|
*/
|
|
65
67
|
export declare function isWeftError(value: unknown): value is WeftError;
|
|
66
68
|
/**
|
|
67
|
-
* Cross-boundary
|
|
68
|
-
* {@link WeftErrorCode} values.
|
|
69
|
-
*
|
|
69
|
+
* Cross-boundary discriminant check: `true` when `value` is one of the public
|
|
70
|
+
* {@link WeftErrorCode} string values. This narrows a `code` *string*; to test
|
|
71
|
+
* a caught `unknown` (the common `catch` case), reach for {@link isWeftErrorLike},
|
|
72
|
+
* which checks the whole error object structurally.
|
|
70
73
|
*
|
|
71
74
|
* @example
|
|
72
75
|
* ```ts
|
|
73
|
-
* import {
|
|
76
|
+
* import { isWeftErrorCode } from '@lostgradient/weft';
|
|
74
77
|
*
|
|
75
|
-
* function
|
|
76
|
-
* return
|
|
77
|
-
* ? error.code === 'WorkflowNotFoundError'
|
|
78
|
-
* : false;
|
|
78
|
+
* function isPublicCode(code: string): boolean {
|
|
79
|
+
* return isWeftErrorCode(code);
|
|
79
80
|
* }
|
|
80
81
|
* ```
|
|
81
82
|
*/
|
|
82
83
|
export declare function isWeftErrorCode(value: unknown): value is WeftErrorCode;
|
|
84
|
+
/**
|
|
85
|
+
* Cross-boundary structural narrowing: `true` when `value` looks like a public
|
|
86
|
+
* Weft error — an object carrying a public {@link WeftErrorCode} `code` and a
|
|
87
|
+
* string `message`. Unlike {@link isWeftError}, this does *not* use `instanceof`,
|
|
88
|
+
* so it stays reliable when the error crossed a realm or duplicate-module
|
|
89
|
+
* boundary — the common case when Weft is a transitive dependency in a monorepo,
|
|
90
|
+
* where two copies of the `WeftError` class make `instanceof` fail.
|
|
91
|
+
*
|
|
92
|
+
* Use this in a `catch` to branch on a caught `unknown` without first proving
|
|
93
|
+
* `instanceof`. It is the structural counterpart to {@link isWeftError}: prefer
|
|
94
|
+
* `isWeftError` for same-realm catches where you want the live class instance,
|
|
95
|
+
* and `isWeftErrorLike` whenever the error may have crossed a module boundary.
|
|
96
|
+
* To match a *specific* code, narrow with this guard then compare `error.code`
|
|
97
|
+
* — TypeScript narrows it to the matched literal in the branch.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { isWeftErrorLike } from '@lostgradient/weft';
|
|
102
|
+
*
|
|
103
|
+
* function statusFor(error: unknown): number {
|
|
104
|
+
* if (isWeftErrorLike(error)) {
|
|
105
|
+
* return error.code === 'WorkflowNotFoundError' ? 404 : 400;
|
|
106
|
+
* }
|
|
107
|
+
* return 500;
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare function isWeftErrorLike(value: unknown): value is {
|
|
112
|
+
code: WeftErrorCode;
|
|
113
|
+
message: string;
|
|
114
|
+
};
|
package/dist/core/weft-error.js
CHANGED
|
@@ -41,3 +41,12 @@ export function isWeftError(value) {
|
|
|
41
41
|
export function isWeftErrorCode(value) {
|
|
42
42
|
return typeof value === "string" && PUBLIC_WEFT_ERROR_CODES.has(value);
|
|
43
43
|
}
|
|
44
|
+
export function isWeftErrorLike(value) {
|
|
45
|
+
if (typeof value !== "object" || value === null)
|
|
46
|
+
return !1;
|
|
47
|
+
try {
|
|
48
|
+
return "code" in value && isWeftErrorCode(value.code) && "message" in value && typeof value.message === "string";
|
|
49
|
+
} catch {
|
|
50
|
+
return !1;
|
|
51
|
+
}
|
|
52
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,17 +8,22 @@
|
|
|
8
8
|
*
|
|
9
9
|
* For end-to-end usage examples see the {@link Engine} class.
|
|
10
10
|
*
|
|
11
|
+
* This is the package's public re-export barrel: it contains only `export`
|
|
12
|
+
* statements, no logic, and grows one line per public symbol. Line count here
|
|
13
|
+
* is semantically meaningless, so it carries a `max-lines: off` override in
|
|
14
|
+
* `.oxlintrc.json` (unlike logic-bearing files, which keep the numeric ceiling).
|
|
15
|
+
*
|
|
11
16
|
* @module weft
|
|
12
17
|
*/
|
|
13
18
|
export { VERSION } from './version.ts';
|
|
14
|
-
export { WeftError, isWeftError, isWeftErrorCode } from './core/weft-error.ts';
|
|
19
|
+
export { WeftError, isWeftError, isWeftErrorCode, isWeftErrorLike } from './core/weft-error.ts';
|
|
15
20
|
export type { WeftErrorCode } from './core/weft-error.ts';
|
|
16
21
|
export { FAULT_CODE_TO_FAILURE_CATEGORY, failureCategoryForFaultCode, isFaultCode, } from './core/fault-code.ts';
|
|
17
22
|
export type { FaultCode } from './core/fault-code.ts';
|
|
18
23
|
export { ActivityReconciliationCapabilityError, ActivityReconciliationConflictError, ActivityReconciliationIndeterminateError, ActivityResolutionError, AsyncActivityTokenNotFoundError, BulkDeleteRequiresTerminalWorkflowsError, BulkOperationConfirmationError, Engine, EngineCreateNameMismatchError, EngineDisposedError, PersistedDataIncompatibleError, ScheduleHandle, WorkflowAlreadyExistsError, WorkflowHandle, WorkflowNotFoundError, WorkflowNotRegisteredError, WorkflowTypeNotRegisteredForRecoveryError, } from './core/engine';
|
|
19
24
|
export type { EngineCreateOptions, EngineStateNamespace, RecoverAllOptions } from './core/engine';
|
|
20
25
|
export { DEFAULT_CHECKPOINT_SIZE_WARNING_THRESHOLD, DEFAULT_MAX_NESTING_DEPTH, DEFAULT_RETRY_POLICY, DEFAULT_VISIBILITY_TIMEOUT_MS, HISTORY_CIRCUIT_BREAKER_REASON, WorkflowBuilderError, query, schedule, signal, update, workflow, } from './core/types';
|
|
21
|
-
export type { ActivityArgsFor, ActivityCallOptions, ActivityCallable, ActivityContext, ActivityDefinition, ActivityEntryInput, ActivityFunction, ActivityMap, ActivityMapInput, ActivityObjectInput, ActivityResultFor, ActivityVerificationContext, ActivityVerificationPhase, ActivityVerificationResult, AnyActivityDefinition, AnyWorkflowDefinition, ArchiveAdapter, BuilderState, BuiltWorkflowDefinition, BulkCancelResult, BulkDeleteResult, BulkOperationAction, BulkOperationAuditEvent, BulkOperationCommitOptions, BulkOperationDryRunOptions, BulkOperationDryRunResult, BulkOperationError, BulkOperationFilterSummary, BulkOperationOptions, BulkOperationPrincipal, BulkOperationScopeSummary, BulkSignalAllCommitOptions, BulkSignalAllDryRunOptions, BulkSignalAllOptions, BulkSignalResult, BulkTagResult, Checkpoint, CheckpointState, CheckpointSummary, CompletedReviewEntry, CoordinatedUpdateResult, DefinitionSchema, Duration, EngineOptions, FailureCategory, ForkLineage, ForkOptions, HistoryPolicy, InferActivityEntries, InferActivityEntry, InferWorkflowEntries, InferWorkflowEntry, InitialBuilderState, ListFilter, ListOptions, MarkBuilderState, NormalizeActivities, NormalizedActivityEntry, NormalizedRetentionPolicy, PaginatedResult, PayloadSizePolicy, PendingReviewEntry, PurgeResult, QueryDefinition, QueryMap, QueryShape, RegisteredWorkflowDefinition, RetentionOverview, RetentionPolicy, RetryPolicy, ReviewListEntry, ReviewListFilter, ReviewStatus, ScheduleDefinition, ScheduleFilter, ScheduleOptions, ScheduleOverlapPolicy, ScheduleSpec, ScheduleState, ScheduleStatus, ScheduleSummary, SearchAttributeDefinition, SearchAttributeHandle, SearchAttributeSchema, SearchAttributeValue, Serializer, SignalDefinition, SignalDeliveryOptions, SignalMap, SignalPayload, StartOptions, SubmitReviewOptions, TerminationReason, UpdateDefinition, UpdateMap, UpdatePayload, WorkerReplayOperationFailure, WorkerReplayOperationSignature, WorkflowAlreadyRegistered, WorkflowAtomicState, WorkflowAtomicStateOptions, WorkflowBuilder, WorkflowBuilderOptions, WorkflowContext, WorkflowDefinition, WorkflowEvent, WorkflowFunction, WorkflowGenerator, WorkflowId, WorkflowRegistry, WorkflowReplay, WorkflowSessionState, WorkflowState, WorkflowStateNamespace, WorkflowStatus, WorkflowSummary, WorkflowTimelineEntry, WorkflowTimelineStatus, WorkflowTypeRetentionPolicy, } from './core/types';
|
|
26
|
+
export type { ActivityArgsFor, ActivityCallOptions, ActivityCallable, ActivityContext, ActivityDefinition, ActivityEntryInput, ActivityFunction, ActivityMap, ActivityMapInput, ActivityObjectInput, ActivityResultFor, ActivityVerificationContext, ActivityVerificationPhase, ActivityVerificationResult, AnyActivityDefinition, AnyWorkflowDefinition, ArchiveAdapter, BuilderState, BuiltWorkflowDefinition, BulkCancelResult, BulkDeleteResult, BulkOperationAction, BulkOperationAuditEvent, BulkOperationCommitOptions, BulkOperationDryRunOptions, BulkOperationDryRunResult, BulkOperationError, BulkOperationFilterSummary, BulkOperationOptions, BulkOperationPrincipal, BulkOperationScopeSummary, BulkSignalAllCommitOptions, BulkSignalAllDryRunOptions, BulkSignalAllOptions, BulkSignalResult, BulkTagResult, Checkpoint, CheckpointState, CheckpointSummary, CompletedReviewEntry, CoordinatedUpdateResult, DefinitionSchema, Duration, EngineOptions, FailureCategory, ForkLineage, ForkOptions, HistoryPolicy, InferActivityEntries, InferActivityEntry, InferWorkflowEntries, InferWorkflowEntry, InitialBuilderState, ListFilter, ListOptions, MarkBuilderState, NormalizeActivities, NormalizedActivityEntry, NormalizedRetentionPolicy, PaginatedResult, PayloadSizePolicy, PendingReviewEntry, PurgeResult, QueryDefinition, QueryMap, QueryShape, RegisteredWorkflowDefinition, RetentionOverview, RetentionPolicy, RetryPolicy, ReviewListEntry, ReviewListFilter, ReviewStatus, ScheduleDefinition, ScheduleFilter, ScheduleOptions, ScheduleOverlapPolicy, ScheduleSpec, ScheduleState, ScheduleStatus, ScheduleSummary, SearchAttributeDefinition, SearchAttributeHandle, SearchAttributeSchema, SearchAttributeValue, Serializer, SignalDefinition, SignalDeliveryOptions, SignalMap, SignalPayload, StartOptions, SubmitReviewOptions, TerminationReason, UpdateDefinition, UpdateMap, UpdatePayload, WorkerReplayOperationFailure, WorkerReplayOperationSignature, WorkflowAlreadyRegistered, WorkflowAtomicState, WorkflowAtomicStateOptions, WorkflowBuilder, WorkflowBuilderOptions, WorkflowContext, WorkflowDefinition, WorkflowEvent, WorkflowFunction, WorkflowGenerator, WorkflowId, WorkflowRegistry, WorkflowReplay, WorkflowServicesResolution, WorkflowServicesResolverInfo, WorkflowSessionState, WorkflowState, WorkflowStateNamespace, WorkflowStatus, WorkflowSummary, WorkflowTimelineEntry, WorkflowTimelineStatus, WorkflowTypeRetentionPolicy, } from './core/types';
|
|
22
27
|
export { AlertManager } from './alerting/index';
|
|
23
28
|
export type { AlertAction, AlertMetric, AlertRule, AlertState, AlertStatus, AlertingOptions, WebhookTarget, } from './alerting/types';
|
|
24
29
|
export { ActivityAsyncPendingEvent, ActivityCompletedEvent, ActivityFailedEvent, ActivityStartedEvent, AlertFiredEvent, AlertResolvedEvent, AttributesChangedEvent, CheckpointSizeWarningEvent, ConstraintViolatedEvent, DevelopmentWarningEvent, SignalDeliveredEvent, SignalReceivedEvent, StorageSizeReportedEvent, UpdateCompletedEvent, UpdateReceivedEvent, WorkflowCancelledEvent, WorkflowCompletedEvent, WorkflowFailedEvent, WorkflowRecoverySkippedEvent, WorkflowResumedEvent, WorkflowStartedEvent, WorkflowTimedOutEvent, } from './core/events';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { VERSION } from "./version.js";
|
|
2
|
-
export { WeftError, isWeftError, isWeftErrorCode } from "./core/weft-error.js";
|
|
2
|
+
export { WeftError, isWeftError, isWeftErrorCode, isWeftErrorLike } from "./core/weft-error.js";
|
|
3
3
|
export {
|
|
4
4
|
FAULT_CODE_TO_FAILURE_CATEGORY,
|
|
5
5
|
failureCategoryForFaultCode,
|
package/dist/json-schema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
`)}function
|
|
4
|
-
${Q(z)}`}var A;var $=X(()=>{Y();A=class A extends K{fieldName;operation;issues;constructor(j){super("StandardSchemaValidationError",
|
|
2
|
+
var w=Object.defineProperty;var y=(j)=>j;function B(j,q){this[j]=y.bind(null,q)}var T=(j,q)=>{for(var z in q)w(j,z,{get:q[z],enumerable:!0,configurable:!0,set:B.bind(q,z)})};var X=(j,q)=>()=>(j&&(q=j(j=0)),q);var K,D,_;var Y=X(()=>{K=class K extends Error{code;constructor(j,q,z){super(q,z);this.code=j,this.name=j}};D={WorkflowAlreadyExistsError:!0,BulkDeleteRequiresTerminalWorkflowsError:!0,BulkOperationConfirmationError:!0,WorkflowTypeNotRegisteredForRecoveryError:!0,EngineCreateNameMismatchError:!0,EngineDisposedError:!0,WorkflowNotFoundError:!0,WorkflowNotRegisteredError:!0,ActivityResolutionError:!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,AsyncActivityTokenNotFoundError:!0,PayloadSizeExceededError:!0},_=new Set(Object.keys(D))});async function Z(j,q,z){let G=j["~standard"];if(!L(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(U)})}function Q(j){return j.map((q)=>q.path===""?q.message:`${q.path}: ${q.message}`).join(`
|
|
3
|
+
`)}function L(j){return typeof j.validate==="function"}function U(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+=F(z);return q}function F(j){let q=J(j)?j.key:j;return M(String(q))}function J(j){return j!==null&&typeof j==="object"&&"key"in j}function M(j){return j.replace(/~/g,"~0").replace(/\//g,"~1")}function O(j,q,z){return`Validation failed for ${q===void 0?j:`${q} ${j}`}:
|
|
4
|
+
${Q(z)}`}var A;var $=X(()=>{Y();A=class A extends K{fieldName;operation;issues;constructor(j){super("StandardSchemaValidationError",O(j.fieldName,j.operation,j.issues));this.fieldName=j.fieldName,this.operation=j.operation,this.issues=j.issues}}});$();var V=Q,P=A,W=Z;export{W as validateStandardSchema,V as formatStandardSchemaIssues,P as StandardSchemaValidationError};
|