@temporal-contract/client 2.3.1 → 3.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["TemporalWorkflowNotFoundError","TemporalWorkflowFailedError","TemporalWorkflowFailedError","TemporalWorkflowNotFoundError"],"sources":["../src/errors.ts","../src/internal.ts","../src/schedule.ts","../src/client.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { summarizeIssues } from \"@temporal-contract/contract\";\nimport type {\n ActivityFailure,\n ApplicationFailure,\n CancelledFailure,\n ChildWorkflowFailure,\n ServerFailure,\n TerminatedFailure,\n TimeoutFailure,\n} from \"@temporalio/common\";\n\n/**\n * Union of the actionable Temporal failure types that can surface as the\n * `cause` of a `WorkflowFailedError`. These all extend Temporal's internal\n * `TemporalFailure` base class — we list them by leaf type rather than by\n * the base class so consumer code can use a single `switch (true)` over\n * `instanceof` discriminants without an exhaustiveness escape hatch.\n *\n * Re-exported from the package entry point so consumers can import it\n * directly: `import type { TemporalFailure } from \"@temporal-contract/client\"`.\n */\nexport type TemporalFailure =\n | ApplicationFailure\n | CancelledFailure\n | TerminatedFailure\n | TimeoutFailure\n | ChildWorkflowFailure\n | ServerFailure\n | ActivityFailure;\n\n/**\n * Base class for all typed client errors.\n */\nabstract class TypedClientError extends Error {\n protected constructor(message: string) {\n super(message);\n this.name = this.constructor.name;\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Generic runtime failure wrapper when no specific error type applies\n */\nexport class RuntimeClientError extends TypedClientError {\n constructor(\n public readonly operation: string,\n public override readonly cause?: unknown,\n ) {\n super(\n `Operation \"${operation}\" failed: ${\n cause instanceof Error ? cause.message : String(cause ?? \"unknown error\")\n }`,\n );\n }\n}\n\n/**\n * Thrown when a workflow is not found in the contract\n */\nexport class WorkflowNotFoundError extends TypedClientError {\n constructor(\n public readonly workflowName: string,\n public readonly availableWorkflows: string[],\n ) {\n super(\n `Workflow \"${workflowName}\" not found in contract. Available workflows: ${availableWorkflows.join(\", \")}`,\n );\n }\n}\n\n/**\n * Discriminated variant of {@link RuntimeClientError} surfaced when starting\n * a workflow collides with an existing execution — Temporal's\n * `WorkflowExecutionAlreadyStartedError`. The most common cause is a\n * workflowId reuse policy that rejects duplicates while a previous run is\n * still in retention.\n *\n * Distinguishing this from `RuntimeClientError` lets idempotent callers\n * branch on it explicitly (e.g. fetch the existing handle and continue)\n * without inspecting `error.cause` against a Temporal SDK class.\n */\nexport class WorkflowAlreadyStartedError extends TypedClientError {\n constructor(\n public readonly workflowType: string,\n public readonly workflowId: string,\n public override readonly cause?: unknown,\n ) {\n super(`Workflow \"${workflowType}\" with ID \"${workflowId}\" is already started or in retention.`);\n }\n}\n\n/**\n * Discriminated variant of {@link RuntimeClientError} surfaced when an\n * operation targets a workflow execution that doesn't exist in the\n * namespace — Temporal's `WorkflowNotFoundError` (distinct from this\n * package's contract-level {@link WorkflowNotFoundError}).\n *\n * Returned from:\n * - handle methods: `signal`, `query`, `executeUpdate`, `result`,\n * `terminate`, `cancel`, `describe`, `fetchHistory`\n * - `executeWorkflow` (when the underlying execute call hits a missing\n * execution mid-flight)\n */\nexport class WorkflowExecutionNotFoundError extends TypedClientError {\n constructor(\n public readonly workflowId: string,\n public readonly runId?: string,\n public override readonly cause?: unknown,\n ) {\n super(\n `Workflow execution \"${workflowId}\"${runId ? ` (run \"${runId}\")` : \"\"} not found in namespace.`,\n );\n }\n}\n\n/**\n * Discriminated variant of {@link RuntimeClientError} surfaced when waiting\n * on a workflow's result and the workflow completes with a failure —\n * Temporal's `WorkflowFailedError`.\n *\n * `cause` is the *unwrapped* underlying {@link TemporalFailure} (typically an\n * `ApplicationFailure`, `CancelledFailure`, `TerminatedFailure`, or\n * `TimeoutFailure`) lifted from Temporal's wrapper, so callers can branch\n * on the failure category in one step (`err.cause instanceof\n * ApplicationFailure`) instead of unwrapping twice via the SDK wrapper. The\n * SDK declares `WorkflowFailedError.cause` as the wider `Error | undefined`\n * (since `cause` lives on `Error`), but the runtime guarantee — driven by\n * Temporal's wire format — is that it is always a `TemporalFailure` subclass\n * when the wrapper is surfaced. `classifyResultError` narrows that wider\n * static type to the public {@link TemporalFailure} union with a cast, so\n * consumers see the precise leaf-failure typing instead of a bare `Error`.\n *\n * Returned from `executeWorkflow` and `handle.result()`.\n */\nexport class WorkflowFailedError extends TypedClientError {\n constructor(\n public readonly workflowId: string,\n public override readonly cause?: TemporalFailure,\n ) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? \"unknown failure\");\n super(`Workflow \"${workflowId}\" completed with failure: ${causeMessage}`);\n }\n}\n\n// Validation-message formatters live in `@temporal-contract/contract` so\n// client and worker share a single source of truth. The previous local\n// copies have been removed in favor of the shared `summarizeIssues` import\n// at the top of this module.\n\n/**\n * Thrown when workflow input or output validation fails\n */\nexport class WorkflowValidationError extends TypedClientError {\n constructor(\n public readonly workflowName: string,\n public readonly direction: \"input\" | \"output\",\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n super(\n `Validation failed for workflow \"${workflowName}\" ${direction}: ${summarizeIssues(issues)}`,\n );\n }\n}\n\n/**\n * Thrown when query input or output validation fails\n */\nexport class QueryValidationError extends TypedClientError {\n constructor(\n public readonly queryName: string,\n public readonly direction: \"input\" | \"output\",\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n super(`Validation failed for query \"${queryName}\" ${direction}: ${summarizeIssues(issues)}`);\n }\n}\n\n/**\n * Thrown when signal input validation fails\n */\nexport class SignalValidationError extends TypedClientError {\n constructor(\n public readonly signalName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n super(`Validation failed for signal \"${signalName}\": ${summarizeIssues(issues)}`);\n }\n}\n\n/**\n * Thrown when update input or output validation fails\n */\nexport class UpdateValidationError extends TypedClientError {\n constructor(\n public readonly updateName: string,\n public readonly direction: \"input\" | \"output\",\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n super(`Validation failed for update \"${updateName}\" ${direction}: ${summarizeIssues(issues)}`);\n }\n}\n","/**\n * Internal helpers shared across the client package's modules.\n *\n * Not part of the public API — this module is not listed in the package's\n * `exports` map, so consumers can't import from `@temporal-contract/client/internal`.\n * In-package modules and tests import it directly via relative path.\n */\nimport { WorkflowExecutionAlreadyStartedError } from \"@temporalio/client\";\nimport { WorkflowFailedError as TemporalWorkflowFailedError } from \"@temporalio/client\";\nimport {\n defineSearchAttributeKey,\n type SearchAttributePair,\n TypedSearchAttributes,\n WorkflowNotFoundError as TemporalWorkflowNotFoundError,\n} from \"@temporalio/common\";\nimport type { AnyWorkflowDefinition, SearchAttributeDefinition } from \"@temporal-contract/contract\";\nimport { _internal_makeResultAsync } from \"@temporal-contract/contract/result-async\";\nimport { ok, err, type ResultAsync, type Result } from \"neverthrow\";\nimport {\n RuntimeClientError,\n type TemporalFailure,\n WorkflowAlreadyStartedError,\n WorkflowExecutionNotFoundError,\n WorkflowFailedError,\n} from \"./errors.js\";\n\n/**\n * Translate the contract's typed `searchAttributes` map (declared\n * name → value) into a Temporal `TypedSearchAttributes` instance, so the\n * Temporal client honours indexing when starting the workflow.\n *\n * Workflows without a `searchAttributes` block (or callers passing no\n * values) resolve to `ok(undefined)`, matching the Temporal SDK's\n * \"absent ≠ empty\" semantics.\n *\n * Returns `err(RuntimeClientError)` on unknown keys. The TypeScript\n * surface already gates the happy path; the runtime check catches typed\n * escape hatches (`as never`, `as any`, raw-call interop) where a typo\n * would otherwise silently drop the attribute, leaving the workflow\n * unindexed without any signal to the caller.\n */\nexport function toTypedSearchAttributes(\n workflowDef: AnyWorkflowDefinition,\n workflowName: string,\n values: Record<string, unknown> | undefined,\n): Result<TypedSearchAttributes | undefined, RuntimeClientError> {\n if (!values) return ok(undefined);\n // Workflows that omit the `searchAttributes` block declare none. Treat\n // that as an empty declared map so a caller passing values still hits\n // the per-key \"undeclared\" check below — silently dropping them would\n // re-introduce the escape-hatch gap this helper was designed to close.\n const declared = (workflowDef.searchAttributes ?? {}) as Record<\n string,\n SearchAttributeDefinition\n >;\n const pairs: SearchAttributePair[] = [];\n for (const [name, value] of Object.entries(values)) {\n if (value === undefined) continue;\n const def = declared[name];\n if (!def) {\n return err(\n new RuntimeClientError(\n \"searchAttributes\",\n new Error(\n `Search attribute \"${name}\" is not declared on workflow \"${workflowName}\". ` +\n `Declared attributes: ${Object.keys(declared).join(\", \") || \"none\"}.`,\n ),\n ),\n );\n }\n const key = defineSearchAttributeKey(name, def.kind);\n pairs.push({ key, value } as SearchAttributePair);\n }\n return ok(pairs.length > 0 ? new TypedSearchAttributes(pairs) : undefined);\n}\n\n/**\n * Wrap an async result-producing function in a `ResultAsync`, catching any\n * unhandled rejection as a `RuntimeClientError(\"unexpected\", error)`.\n *\n * The work function is expected to handle its own domain errors and return\n * an `err(...)` for them; the catch here is a safety net for thrown\n * exceptions the work didn't anticipate.\n *\n * Used by `client.ts` (workflow operations) and `schedule.ts` (schedule\n * operations) so the unexpected-rejection shape is identical across the\n * typed client surface. Delegates to `_internal_makeResultAsync` from\n * `@temporal-contract/contract` so the same wrapper is shared between the\n * client and worker packages.\n */\nexport function makeResultAsync<T, E>(\n work: () => Promise<Result<T, E>>,\n): ResultAsync<T, E | RuntimeClientError> {\n return _internal_makeResultAsync<T, E | RuntimeClientError>(\n work,\n (e) => new RuntimeClientError(\"unexpected\", e),\n );\n}\n\n/**\n * Map a thrown error from `client.workflow.start` / `signalWithStart` into\n * the discriminated union surfaced by the typed client. Specifically\n * recognizes Temporal's `WorkflowExecutionAlreadyStartedError`; everything\n * else falls through to {@link RuntimeClientError}.\n */\nexport function classifyStartError(\n operation: string,\n error: unknown,\n): WorkflowAlreadyStartedError | RuntimeClientError {\n if (error instanceof WorkflowExecutionAlreadyStartedError) {\n return new WorkflowAlreadyStartedError(error.workflowType, error.workflowId, error);\n }\n return new RuntimeClientError(operation, error);\n}\n\n/**\n * Map a thrown error from a workflow handle method (signal, query,\n * executeUpdate, terminate, cancel, describe, fetchHistory) into the\n * discriminated union surfaced by the typed client. Recognizes Temporal's\n * `WorkflowNotFoundError`; everything else falls through to\n * {@link RuntimeClientError}.\n *\n * `fallbackWorkflowId` is used when Temporal's error carries an empty\n * `workflowId` (it normalizes missing IDs to the empty string), so the\n * surfaced error always identifies the targeted execution.\n */\nexport function classifyHandleError(\n operation: string,\n error: unknown,\n fallbackWorkflowId: string,\n): WorkflowExecutionNotFoundError | RuntimeClientError {\n if (error instanceof TemporalWorkflowNotFoundError) {\n return new WorkflowExecutionNotFoundError(\n error.workflowId || fallbackWorkflowId,\n error.runId,\n error,\n );\n }\n return new RuntimeClientError(operation, error);\n}\n\n/**\n * Map a thrown error from `handle.result()` / `client.workflow.execute()`\n * (the latter when waiting on the result phase). Recognizes Temporal's\n * `WorkflowFailedError` and `WorkflowNotFoundError`; everything else falls\n * through to {@link RuntimeClientError}.\n *\n * Temporal's `WorkflowFailedError` is itself a wrapper — the actionable\n * failure (ApplicationFailure, CancelledFailure, TerminatedFailure, etc.)\n * lives on its `cause` field. We forward that inner cause directly so\n * consumers can match `err.cause` against the underlying failure class\n * without an extra unwrap step. (If Temporal's cause is `undefined`, our\n * `cause` is too — same shape as before.)\n */\nexport function classifyResultError(\n operation: string,\n error: unknown,\n workflowId: string,\n): WorkflowFailedError | WorkflowExecutionNotFoundError | RuntimeClientError {\n if (error instanceof TemporalWorkflowFailedError) {\n // Temporal types `cause` as `Error | undefined`, but the SDK only ever\n // populates it with a `TemporalFailure` subclass when surfacing a\n // workflow result failure. Narrow with the public union so consumers\n // can branch on the leaf failure types without an extra cast.\n return new WorkflowFailedError(workflowId, error.cause as TemporalFailure | undefined);\n }\n if (error instanceof TemporalWorkflowNotFoundError) {\n return new WorkflowExecutionNotFoundError(error.workflowId || workflowId, error.runId, error);\n }\n return new RuntimeClientError(operation, error);\n}\n","import type {\n ScheduleClient,\n ScheduleDescription,\n ScheduleHandle,\n ScheduleOptions,\n ScheduleOptionsStartWorkflowAction,\n ScheduleOverlapPolicy,\n ScheduleSpec,\n} from \"@temporalio/client\";\nimport type { ContractDefinition } from \"@temporal-contract/contract\";\nimport { ResultAsync, type Result, ok, err } from \"neverthrow\";\nimport type { TypedSearchAttributeMap } from \"./client.js\";\nimport type { ClientInferInput } from \"./types.js\";\nimport { RuntimeClientError, WorkflowNotFoundError, WorkflowValidationError } from \"./errors.js\";\nimport { makeResultAsync, toTypedSearchAttributes } from \"./internal.js\";\n\n/**\n * Workflow-action–level overrides forwarded to Temporal's\n * `ScheduleOptionsStartWorkflowAction`. These live under a nested `action`\n * field so the workflow-level `memo` (per-action workflow metadata) can be\n * set independently from the schedule-level `memo` (metadata on the\n * schedule itself) — Temporal honours both, and they have separate\n * lifecycles.\n *\n * `workflowType` and `taskQueue` are owned by the contract and not exposed.\n */\nexport type TypedScheduleActionOverrides = Pick<\n ScheduleOptionsStartWorkflowAction<never>,\n | \"workflowId\"\n | \"workflowExecutionTimeout\"\n | \"workflowRunTimeout\"\n | \"workflowTaskTimeout\"\n | \"retry\"\n | \"memo\"\n | \"staticDetails\"\n | \"staticSummary\"\n>;\n\n/**\n * Options for {@link TypedScheduleClient.create}.\n *\n * `scheduleId` and `spec` come from Temporal's `ScheduleOptions`. `args` is\n * typed against the destination workflow's input schema. `policies`,\n * `state`, and `memo` mirror Temporal's own schedule-level options.\n * Workflow-action–level overrides nest under {@link action} so memo and\n * other fields with the same name don't collide between the two scopes.\n */\nexport type TypedScheduleCreateOptions<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = {\n /** Schedule ID. Recommended to use a meaningful business identifier. */\n scheduleId: string;\n /** When the schedule should fire (cron, interval, calendar). */\n spec: ScheduleSpec;\n /** Workflow input — validated against the contract's input schema. */\n args: ClientInferInput<TContract[\"workflows\"][TWorkflowName]>;\n /**\n * Indexed search attributes for each workflow run spawned by this\n * schedule. Keys and value types are constrained to those declared on\n * the destination workflow's contract via `defineSearchAttribute`.\n * Translated to Temporal's `typedSearchAttributes` and attached to the\n * schedule's `startWorkflow` action so each spawned run is indexed\n * identically to one started directly via `client.startWorkflow`.\n */\n searchAttributes?: TypedSearchAttributeMap<TContract[\"workflows\"][TWorkflowName]>;\n /** Temporal schedule policies (overlap, catchupWindow, pauseOnFailure, etc.). */\n policies?: ScheduleOptions[\"policies\"];\n /** Temporal schedule state (paused, note, limited, etc.). */\n state?: ScheduleOptions[\"state\"];\n /** Schedule-level memo (non-indexed metadata on the schedule itself). */\n memo?: ScheduleOptions[\"memo\"];\n /**\n * Workflow-action–level overrides. `workflowType` and `taskQueue` are\n * derived from the contract, so they don't appear here. Note that\n * `action.memo` is a *workflow-level* memo applied to each spawned run,\n * distinct from the top-level `memo` (which is metadata on the schedule\n * itself).\n */\n action?: TypedScheduleActionOverrides;\n};\n\n/**\n * Typed handle to a schedule. Mirrors Temporal's `ScheduleHandle` lifecycle\n * methods (`pause`, `unpause`, `trigger`, `describe`, `delete`) wrapped in\n * the neverthrow ResultAsync pattern so call sites match the rest of the\n * typed client.\n */\nexport type TypedScheduleHandle = {\n /** This schedule's identifier. */\n readonly scheduleId: string;\n /** Pause the schedule. Optional note becomes part of the audit trail. */\n pause: (note?: string) => ResultAsync<void, RuntimeClientError>;\n /** Resume a paused schedule. */\n unpause: (note?: string) => ResultAsync<void, RuntimeClientError>;\n /** Fire the schedule's action immediately. */\n trigger: (overlap?: ScheduleOverlapPolicy) => ResultAsync<void, RuntimeClientError>;\n /** Delete the schedule. */\n delete: () => ResultAsync<void, RuntimeClientError>;\n /** Fetch the schedule's current description from the server. */\n describe: () => ResultAsync<ScheduleDescription, RuntimeClientError>;\n};\n\n/**\n * Typed wrapper around Temporal's `ScheduleClient`. Exposed as\n * `typedClient.schedule` — keeps the typed-client surface organized the\n * same way Temporal's own `Client.schedule` does.\n */\nexport class TypedScheduleClient<TContract extends ContractDefinition> {\n constructor(\n private readonly contract: TContract,\n private readonly scheduleClient: ScheduleClient,\n ) {}\n\n /**\n * Create a new schedule that, on each fire, starts the named contract\n * workflow with validated args.\n *\n * Validates `args` against the workflow's input schema before dispatching\n * the create request to Temporal. The workflow's `taskQueue` and\n * `workflowType` are pulled from the contract automatically; the typed\n * options shape omits them so call sites don't have to repeat themselves.\n */\n create<TWorkflowName extends keyof TContract[\"workflows\"] & string>(\n workflowName: TWorkflowName,\n options: TypedScheduleCreateOptions<TContract, TWorkflowName>,\n ): ResultAsync<\n TypedScheduleHandle,\n WorkflowNotFoundError | WorkflowValidationError | RuntimeClientError\n > {\n type Ok = TypedScheduleHandle;\n type Err = WorkflowNotFoundError | WorkflowValidationError | RuntimeClientError;\n const work = async (): Promise<Result<Ok, Err>> => {\n const definition = this.contract.workflows[workflowName];\n if (!definition) {\n return err(new WorkflowNotFoundError(workflowName, Object.keys(this.contract.workflows)));\n }\n\n const inputResult = await definition.input[\"~standard\"].validate(options.args);\n if (inputResult.issues) {\n return err(new WorkflowValidationError(workflowName, \"input\", inputResult.issues));\n }\n\n // Translate typed search attributes for the spawned workflow runs.\n // Lives on the schedule's `startWorkflow` action (workflow-level\n // indexing), not on the schedule itself. Mirrors what\n // `client.startWorkflow` does for direct starts so schedule-spawned\n // runs share visibility with their direct-start counterparts.\n const searchAttributesResult = toTypedSearchAttributes(\n definition,\n workflowName,\n options.searchAttributes as Record<string, unknown> | undefined,\n );\n if (searchAttributesResult.isErr()) return err(searchAttributesResult.error);\n const typedSearchAttributes = searchAttributesResult.value;\n\n try {\n const overrides = options.action ?? {};\n const action: ScheduleOptionsStartWorkflowAction<never> = {\n type: \"startWorkflow\",\n workflowType: workflowName,\n taskQueue: this.contract.taskQueue,\n args: [inputResult.value] as never,\n ...(typedSearchAttributes ? { typedSearchAttributes } : {}),\n ...(overrides.workflowId !== undefined ? { workflowId: overrides.workflowId } : {}),\n ...(overrides.workflowExecutionTimeout !== undefined\n ? { workflowExecutionTimeout: overrides.workflowExecutionTimeout }\n : {}),\n ...(overrides.workflowRunTimeout !== undefined\n ? { workflowRunTimeout: overrides.workflowRunTimeout }\n : {}),\n ...(overrides.workflowTaskTimeout !== undefined\n ? { workflowTaskTimeout: overrides.workflowTaskTimeout }\n : {}),\n ...(overrides.retry !== undefined ? { retry: overrides.retry } : {}),\n ...(overrides.memo !== undefined ? { memo: overrides.memo } : {}),\n ...(overrides.staticDetails !== undefined\n ? { staticDetails: overrides.staticDetails }\n : {}),\n ...(overrides.staticSummary !== undefined\n ? { staticSummary: overrides.staticSummary }\n : {}),\n };\n\n const handle = await this.scheduleClient.create({\n scheduleId: options.scheduleId,\n spec: options.spec,\n action,\n ...(options.policies !== undefined ? { policies: options.policies } : {}),\n ...(options.state !== undefined ? { state: options.state } : {}),\n ...(options.memo !== undefined ? { memo: options.memo } : {}),\n });\n return ok(wrapScheduleHandle(handle));\n } catch (error) {\n return err(new RuntimeClientError(\"schedule.create\", error));\n }\n };\n return makeResultAsync(work);\n }\n\n /**\n * Get a typed handle to an existing schedule. Does not validate that the\n * schedule exists — handle methods (`describe`, `pause`, etc.) will\n * surface a `RuntimeClientError` if the underlying ID is unknown.\n */\n getHandle(scheduleId: string): TypedScheduleHandle {\n return wrapScheduleHandle(this.scheduleClient.getHandle(scheduleId));\n }\n}\n\nfunction wrapScheduleHandle(handle: ScheduleHandle): TypedScheduleHandle {\n return {\n scheduleId: handle.scheduleId,\n pause: (note) =>\n ResultAsync.fromPromise(\n handle.pause(note),\n (error) => new RuntimeClientError(\"schedule.pause\", error),\n ).map(() => undefined),\n unpause: (note) =>\n ResultAsync.fromPromise(\n handle.unpause(note),\n (error) => new RuntimeClientError(\"schedule.unpause\", error),\n ).map(() => undefined),\n trigger: (overlap) =>\n ResultAsync.fromPromise(\n handle.trigger(overlap),\n (error) => new RuntimeClientError(\"schedule.trigger\", error),\n ).map(() => undefined),\n delete: () =>\n ResultAsync.fromPromise(\n handle.delete(),\n (error) => new RuntimeClientError(\"schedule.delete\", error),\n ).map(() => undefined),\n describe: () =>\n ResultAsync.fromPromise(\n handle.describe(),\n (error) => new RuntimeClientError(\"schedule.describe\", error),\n ),\n };\n}\n","import { Client, WorkflowHandle } from \"@temporalio/client\";\nimport type { WorkflowSignalWithStartOptions, WorkflowStartOptions } from \"@temporalio/client\";\nimport { defineSearchAttributeKey, TypedSearchAttributes } from \"@temporalio/common\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type {\n AnyWorkflowDefinition,\n ContractDefinition,\n SearchAttributeDefinition,\n SearchAttributeKindToType,\n SignalDefinition,\n SignalNamesOf,\n} from \"@temporal-contract/contract\";\nimport type {\n ClientInferInput,\n ClientInferOutput,\n ClientInferWorkflowQueries,\n ClientInferWorkflowSignals,\n ClientInferWorkflowUpdates,\n} from \"./types.js\";\nimport { ResultAsync, type Result, ok, err } from \"neverthrow\";\nimport {\n type TemporalFailure,\n WorkflowAlreadyStartedError,\n WorkflowExecutionNotFoundError,\n WorkflowFailedError,\n WorkflowNotFoundError,\n WorkflowValidationError,\n QueryValidationError,\n SignalValidationError,\n UpdateValidationError,\n RuntimeClientError,\n} from \"./errors.js\";\nimport { TypedScheduleClient } from \"./schedule.js\";\nimport {\n classifyHandleError,\n classifyResultError,\n classifyStartError,\n makeResultAsync,\n toTypedSearchAttributes,\n} from \"./internal.js\";\nimport { WorkflowExecutionAlreadyStartedError } from \"@temporalio/client\";\nimport { WorkflowFailedError as TemporalWorkflowFailedError } from \"@temporalio/client\";\nimport { WorkflowNotFoundError as TemporalWorkflowNotFoundError } from \"@temporalio/common\";\n\n/**\n * Typed `searchAttributes` map for a workflow, derived from the workflow's\n * declared `searchAttributes`. Each key is constrained to a declared\n * attribute name; each value's type is determined by the attribute's `kind`\n * (e.g. `KEYWORD` → `string`, `INT` → `number`, `DATETIME` → `Date`,\n * `KEYWORD_LIST` → `string[]`).\n *\n * If the workflow declares no search attributes, this resolves to `never`,\n * meaning the `searchAttributes` field is effectively absent from the start\n * options for that workflow.\n */\nexport type TypedSearchAttributeMap<TWorkflow extends AnyWorkflowDefinition> =\n TWorkflow[\"searchAttributes\"] extends Record<string, SearchAttributeDefinition>\n ? {\n [K in keyof TWorkflow[\"searchAttributes\"]]?: SearchAttributeKindToType<\n TWorkflow[\"searchAttributes\"][K][\"kind\"]\n >;\n }\n : never;\n\n/**\n * Read declared search attributes off a `TypedSearchAttributes` instance —\n * the read-side counterpart to the write-side `searchAttributes` option on\n * `startWorkflow` / `signalWithStart` / `executeWorkflow` /\n * `schedule.create`.\n *\n * Use it on the result of `handle.describe()` (or a schedule's describe) to\n * recover the typed shape of indexed attributes. The Temporal SDK only\n * exposes a `.get(key)` accessor on `TypedSearchAttributes` and requires\n * the caller to reconstruct each `SearchAttributeKey` from the contract's\n * declared `kind` — this helper does that lookup once for every declared\n * attribute, returning a `Partial<TypedSearchAttributeMap<TWorkflow>>`\n * (each declared key may or may not have been set on the workflow).\n *\n * Workflows without declared `searchAttributes` get an empty object back.\n *\n * @example\n * ```ts\n * const description = await handle.describe();\n * if (description.isOk()) {\n * const attrs = readTypedSearchAttributes(\n * myContract.workflows.processOrder,\n * description.value.typedSearchAttributes,\n * );\n * // attrs.customerId: string | undefined\n * // attrs.priority: number | undefined\n * }\n * ```\n */\nexport function readTypedSearchAttributes<TWorkflow extends AnyWorkflowDefinition>(\n workflowDef: TWorkflow,\n instance: TypedSearchAttributes,\n): Partial<TypedSearchAttributeMap<TWorkflow>> {\n const declared = workflowDef.searchAttributes as\n | Record<string, SearchAttributeDefinition>\n | undefined;\n if (!declared) return {} as Partial<TypedSearchAttributeMap<TWorkflow>>;\n\n const result: Record<string, unknown> = {};\n for (const [name, def] of Object.entries(declared)) {\n const key = defineSearchAttributeKey(name, def.kind);\n const value = instance.get(key);\n if (value !== undefined) {\n result[name] = value;\n }\n }\n return result as Partial<TypedSearchAttributeMap<TWorkflow>>;\n}\n\nexport type TypedWorkflowStartOptions<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = Omit<\n WorkflowStartOptions,\n \"taskQueue\" | \"args\" | \"searchAttributes\" | \"typedSearchAttributes\"\n> & {\n args: ClientInferInput<TContract[\"workflows\"][TWorkflowName]>;\n /**\n * Indexed search attributes for the started workflow. Keys and value types\n * are constrained to those declared on the workflow's contract via\n * `defineSearchAttribute`. Translated to Temporal's `typedSearchAttributes`\n * before the start request is dispatched.\n */\n searchAttributes?: TypedSearchAttributeMap<TContract[\"workflows\"][TWorkflowName]>;\n};\n\n/**\n * Options for {@link TypedClient.signalWithStart} — typed against both the\n * workflow's input schema and the named signal's input schema.\n */\nexport type TypedSignalWithStartOptions<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n TSignalName extends SignalNamesOf<TContract[\"workflows\"][TWorkflowName]>,\n> = Omit<\n WorkflowSignalWithStartOptions,\n \"taskQueue\" | \"args\" | \"signal\" | \"signalArgs\" | \"searchAttributes\" | \"typedSearchAttributes\"\n> & {\n args: ClientInferInput<TContract[\"workflows\"][TWorkflowName]>;\n signalName: TSignalName;\n signalArgs: TContract[\"workflows\"][TWorkflowName][\"signals\"][TSignalName] extends SignalDefinition\n ? ClientInferInput<TContract[\"workflows\"][TWorkflowName][\"signals\"][TSignalName]>\n : never;\n /**\n * Indexed search attributes for the started workflow. Keys and value types\n * are constrained to those declared on the workflow's contract via\n * `defineSearchAttribute`. Translated to Temporal's `typedSearchAttributes`\n * before the signalWithStart request is dispatched.\n */\n searchAttributes?: TypedSearchAttributeMap<TContract[\"workflows\"][TWorkflowName]>;\n};\n\n/**\n * Typed workflow handle returned by `signalWithStart`. Adds `signaledRunId`\n * to the standard handle so callers can correlate the signal with the\n * (possibly pre-existing) workflow execution chain.\n */\nexport type TypedWorkflowHandleWithSignaledRunId<TWorkflow extends AnyWorkflowDefinition> =\n TypedWorkflowHandle<TWorkflow> & {\n /**\n * The Run Id of the bound Workflow at the time of `signalWithStart`. Since\n * `signalWithStart` may have signaled an existing Workflow Chain, this is\n * not necessarily the `firstExecutionRunId`.\n */\n readonly signaledRunId: string;\n };\n\n/**\n * Typed workflow handle with validated results using neverthrow Result/ResultAsync\n */\nexport type TypedWorkflowHandle<TWorkflow extends AnyWorkflowDefinition> = {\n workflowId: string;\n\n /**\n * Type-safe queries based on workflow definition with Result pattern\n * Each query returns ResultAsync<T, Error> instead of Promise<T>\n */\n queries: {\n [K in keyof ClientInferWorkflowQueries<TWorkflow>]: ClientInferWorkflowQueries<TWorkflow>[K] extends (\n ...args: infer Args\n ) => ResultAsync<infer R, Error>\n ? (\n ...args: Args\n ) => ResultAsync<\n R,\n QueryValidationError | WorkflowExecutionNotFoundError | RuntimeClientError\n >\n : never;\n };\n\n /**\n * Type-safe signals based on workflow definition with Result pattern\n * Each signal returns ResultAsync<void, Error> instead of Promise<void>\n */\n signals: {\n [K in keyof ClientInferWorkflowSignals<TWorkflow>]: ClientInferWorkflowSignals<TWorkflow>[K] extends (\n ...args: infer Args\n ) => ResultAsync<void, Error>\n ? (\n ...args: Args\n ) => ResultAsync<\n void,\n SignalValidationError | WorkflowExecutionNotFoundError | RuntimeClientError\n >\n : never;\n };\n\n /**\n * Type-safe updates based on workflow definition with Result pattern\n * Each update returns ResultAsync<T, Error> instead of Promise<T>\n */\n updates: {\n [K in keyof ClientInferWorkflowUpdates<TWorkflow>]: ClientInferWorkflowUpdates<TWorkflow>[K] extends (\n ...args: infer Args\n ) => ResultAsync<infer R, Error>\n ? (\n ...args: Args\n ) => ResultAsync<\n R,\n UpdateValidationError | WorkflowExecutionNotFoundError | RuntimeClientError\n >\n : never;\n };\n\n /**\n * Get workflow result with Result pattern\n */\n result: () => ResultAsync<\n ClientInferOutput<TWorkflow>,\n | WorkflowValidationError\n | WorkflowFailedError\n | WorkflowExecutionNotFoundError\n | RuntimeClientError\n >;\n\n /**\n * Terminate workflow with Result pattern\n */\n terminate: (\n reason?: string,\n ) => ResultAsync<void, WorkflowExecutionNotFoundError | RuntimeClientError>;\n\n /**\n * Cancel workflow with Result pattern\n */\n cancel: () => ResultAsync<void, WorkflowExecutionNotFoundError | RuntimeClientError>;\n\n /**\n * Get workflow execution description including status and metadata\n */\n describe: () => ResultAsync<\n Awaited<ReturnType<WorkflowHandle[\"describe\"]>>,\n WorkflowExecutionNotFoundError | RuntimeClientError\n >;\n\n /**\n * Fetch the workflow execution history\n */\n fetchHistory: () => ResultAsync<\n Awaited<ReturnType<WorkflowHandle[\"fetchHistory\"]>>,\n WorkflowExecutionNotFoundError | RuntimeClientError\n >;\n};\n\n/**\n * Result of {@link resolveDefinitionAndValidateInput} — the contract-side\n * pre-call ritual the start/signal-with-start/execute methods share. Holds\n * the resolved workflow definition, the schema-validated input, and the\n * translated typed search attributes (or `undefined` when the workflow\n * declared none / the caller passed none).\n */\ntype ResolvedWorkflow<TWorkflow extends AnyWorkflowDefinition> = {\n definition: TWorkflow;\n validatedInput: unknown;\n typedSearchAttributes: TypedSearchAttributes | undefined;\n};\n\n/**\n * Shared pre-call ritual for the three contract-driven entry points that\n * actually start a workflow (`startWorkflow`, `signalWithStart`,\n * `executeWorkflow`):\n *\n * 1. Look up the workflow definition on the contract.\n * 2. Surface a `WorkflowNotFoundError` if absent.\n * 3. Validate `args` against the workflow's input schema.\n * 4. Surface a `WorkflowValidationError` if validation fails.\n * 5. Translate any caller-supplied `searchAttributes` into Temporal's\n * `TypedSearchAttributes` shape (or `undefined`).\n *\n * `getHandle` deliberately keeps its own three-line lookup — it doesn't\n * accept `args` or `searchAttributes`, so it can't share this helper. The\n * call-specific extras (signal validation, post-call output validation,\n * extended error classification) stay at the call site — those are the\n * differentiators that make each method distinct.\n */\nasync function resolveDefinitionAndValidateInput<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n>(\n contract: TContract,\n workflowName: TWorkflowName,\n args: unknown,\n searchAttributes: Record<string, unknown> | undefined,\n): Promise<\n Result<\n ResolvedWorkflow<TContract[\"workflows\"][TWorkflowName]>,\n WorkflowNotFoundError | WorkflowValidationError | RuntimeClientError\n >\n> {\n const definition = contract.workflows[workflowName];\n if (!definition) {\n return err(createWorkflowNotFoundError(workflowName, contract));\n }\n\n const inputResult = await definition.input[\"~standard\"].validate(args);\n if (inputResult.issues) {\n return err(createWorkflowValidationError(workflowName, \"input\", inputResult.issues));\n }\n\n const searchAttributesResult = toTypedSearchAttributes(\n definition,\n workflowName,\n searchAttributes,\n );\n if (searchAttributesResult.isErr()) return err(searchAttributesResult.error);\n const typedSearchAttributes = searchAttributesResult.value;\n\n return ok({\n definition: definition as TContract[\"workflows\"][TWorkflowName],\n validatedInput: inputResult.value,\n typedSearchAttributes,\n });\n}\n\n/**\n * Typed Temporal client with neverthrow Result/ResultAsync pattern based on a contract\n *\n * Provides type-safe methods to start and execute workflows\n * defined in the contract, with explicit error handling using Result pattern.\n */\nexport class TypedClient<TContract extends ContractDefinition> {\n /**\n * Typed wrapper around Temporal's `client.schedule.create(...)` and\n * related lifecycle methods. Fires the underlying `startWorkflow` action\n * with args validated against the contract's input schema.\n *\n * **Requires `@temporalio/client` 1.16+.** The Schedule API was added in\n * 1.16; on older versions this property is unset and any access throws.\n * The package's peer dep allows the whole `^1` range to stay permissive\n * about the installed Temporal version, so consumers on < 1.16 who never\n * touch schedules keep working — the constructor below fails fast with a\n * clear message for anyone who does reach for the Schedule API too early.\n *\n * @example\n * ```ts\n * const result = await client.schedule.create(\"processOrder\", {\n * scheduleId: \"daily-sweep\",\n * spec: { cronExpressions: [\"0 2 * * *\"] },\n * args: { orderId: \"sweep\" },\n * });\n *\n * result.match(\n * async (handle) => { await handle.pause(\"maintenance\"); },\n * (error) => console.error(\"schedule create failed\", error),\n * );\n * ```\n */\n readonly schedule: TypedScheduleClient<TContract>;\n\n private constructor(\n private readonly contract: TContract,\n private readonly client: Client,\n ) {\n // `client.schedule` is the ScheduleClient wired into Temporal's\n // top-level `Client` since 1.16. The peer dep allows all of `^1`, so a\n // consumer can be on an older version — fail early with a clear message\n // rather than crashing later with a confusing\n // `Cannot read properties of undefined`.\n if (!client.schedule) {\n throw new Error(\n \"TypedClient requires @temporalio/client >= 1.16 (the Schedule API was added in 1.16). \" +\n \"Found a Client instance without a `schedule` property — please upgrade.\",\n );\n }\n this.schedule = new TypedScheduleClient(contract, client.schedule);\n }\n\n /**\n * Create a typed Temporal client with neverthrow pattern from a contract\n *\n * @example\n * ```ts\n * const connection = await Connection.connect();\n * const temporalClient = new Client({ connection });\n * const client = TypedClient.create(myContract, temporalClient);\n *\n * const result = await client.executeWorkflow('processOrder', {\n * workflowId: 'order-123',\n * args: { ... },\n * });\n *\n * result.match(\n * (output) => console.log('Success:', output),\n * (error) => console.error('Failed:', error),\n * );\n * ```\n */\n static create<TContract extends ContractDefinition>(\n contract: TContract,\n client: Client,\n ): TypedClient<TContract> {\n return new TypedClient(contract, client);\n }\n\n /**\n * Start a workflow and return a typed handle with ResultAsync pattern\n *\n * @example\n * ```ts\n * const handleResult = await client.startWorkflow('processOrder', {\n * workflowId: 'order-123',\n * args: { orderId: 'ORD-123' },\n * workflowExecutionTimeout: '1 day',\n * retry: { maximumAttempts: 3 },\n * });\n *\n * handleResult.match(\n * async (handle) => {\n * const result = await handle.result();\n * // ... handle result\n * },\n * (error) => console.error('Failed to start:', error),\n * );\n * ```\n */\n startWorkflow<TWorkflowName extends keyof TContract[\"workflows\"] & string>(\n workflowName: TWorkflowName,\n {\n args,\n searchAttributes,\n ...temporalOptions\n }: TypedWorkflowStartOptions<TContract, TWorkflowName>,\n ): ResultAsync<\n TypedWorkflowHandle<TContract[\"workflows\"][TWorkflowName]>,\n | WorkflowNotFoundError\n | WorkflowValidationError\n | WorkflowAlreadyStartedError\n | RuntimeClientError\n > {\n type Ok = TypedWorkflowHandle<TContract[\"workflows\"][TWorkflowName]>;\n type Err =\n | WorkflowNotFoundError\n | WorkflowValidationError\n | WorkflowAlreadyStartedError\n | RuntimeClientError;\n const work = async (): Promise<Result<Ok, Err>> => {\n const resolved = await resolveDefinitionAndValidateInput(\n this.contract,\n workflowName,\n args,\n searchAttributes as Record<string, unknown> | undefined,\n );\n if (resolved.isErr()) return err(resolved.error);\n const { definition, validatedInput, typedSearchAttributes } = resolved.value;\n\n try {\n const handle = await this.client.workflow.start(workflowName, {\n ...temporalOptions,\n taskQueue: this.contract.taskQueue,\n args: [validatedInput],\n ...(typedSearchAttributes ? { typedSearchAttributes } : {}),\n });\n return ok(this.createTypedHandle(handle, definition) as Ok);\n } catch (error) {\n return err(classifyStartError(\"startWorkflow\", error));\n }\n };\n return makeResultAsync(work);\n }\n\n /**\n * Send a signal to a workflow, starting it first if it doesn't already exist.\n *\n * Validates both halves of the call against the contract:\n * - `args` against the workflow's input schema\n * - `signalArgs` against the named signal's input schema\n *\n * Returns a `TypedWorkflowHandleWithSignaledRunId` — the same shape as\n * `startWorkflow`'s handle, plus a `signaledRunId` field for correlating\n * the signal with the (possibly pre-existing) workflow execution chain.\n *\n * @example\n * ```ts\n * const result = await client.signalWithStart('processOrder', {\n * workflowId: 'order-123',\n * args: { orderId: 'ORD-123', customerId: 'CUST-1' },\n * signalName: 'cancel',\n * signalArgs: { reason: 'duplicate' },\n * });\n *\n * result.match(\n * (handle) => console.log('signaled run', handle.signaledRunId),\n * (error) => console.error('signalWithStart failed', error),\n * );\n * ```\n */\n signalWithStart<\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n TSignalName extends SignalNamesOf<TContract[\"workflows\"][TWorkflowName]>,\n >(\n workflowName: TWorkflowName,\n {\n args,\n signalName,\n signalArgs,\n searchAttributes,\n ...temporalOptions\n }: TypedSignalWithStartOptions<TContract, TWorkflowName, TSignalName>,\n ): ResultAsync<\n TypedWorkflowHandleWithSignaledRunId<TContract[\"workflows\"][TWorkflowName]>,\n | WorkflowNotFoundError\n | WorkflowValidationError\n | SignalValidationError\n | WorkflowAlreadyStartedError\n | RuntimeClientError\n > {\n type Ok = TypedWorkflowHandleWithSignaledRunId<TContract[\"workflows\"][TWorkflowName]>;\n type Err =\n | WorkflowNotFoundError\n | WorkflowValidationError\n | SignalValidationError\n | WorkflowAlreadyStartedError\n | RuntimeClientError;\n\n const work = async (): Promise<Result<Ok, Err>> => {\n const resolved = await resolveDefinitionAndValidateInput(\n this.contract,\n workflowName,\n args,\n searchAttributes as Record<string, unknown> | undefined,\n );\n if (resolved.isErr()) return err(resolved.error);\n const { definition, validatedInput, typedSearchAttributes } = resolved.value;\n\n // Validate signal input — call-site-specific, kept inline.\n const signalDef = (definition.signals as Record<string, SignalDefinition> | undefined)?.[\n signalName\n ];\n if (!signalDef) {\n // Type-level constraint should already prevent this; defensive for\n // raw-call / union-typed-name corner cases.\n return err(\n new SignalValidationError(signalName, [\n {\n message: `Signal \"${signalName}\" is not declared on workflow \"${workflowName}\".`,\n },\n ]),\n );\n }\n const signalInputResult = await signalDef.input[\"~standard\"].validate(signalArgs);\n if (signalInputResult.issues) {\n return err(new SignalValidationError(signalName, signalInputResult.issues));\n }\n\n try {\n const handle = await this.client.workflow.signalWithStart(workflowName, {\n ...temporalOptions,\n taskQueue: this.contract.taskQueue,\n args: [validatedInput],\n signal: signalName,\n signalArgs: [signalInputResult.value],\n ...(typedSearchAttributes ? { typedSearchAttributes } : {}),\n });\n const typed = this.createTypedHandle(handle, definition) as TypedWorkflowHandle<\n TContract[\"workflows\"][TWorkflowName]\n >;\n return ok({ ...typed, signaledRunId: handle.signaledRunId } as Ok);\n } catch (error) {\n return err(classifyStartError(\"signalWithStart\", error));\n }\n };\n return makeResultAsync(work);\n }\n\n /**\n * Execute a workflow (start and wait for result) with ResultAsync pattern\n *\n * @example\n * ```ts\n * const result = await client.executeWorkflow('processOrder', {\n * workflowId: 'order-123',\n * args: { orderId: 'ORD-123' },\n * workflowExecutionTimeout: '1 day',\n * retry: { maximumAttempts: 3 },\n * });\n *\n * result.match(\n * (output) => console.log('Order processed:', output.status),\n * (error) => console.error('Processing failed:', error),\n * );\n * ```\n */\n executeWorkflow<TWorkflowName extends keyof TContract[\"workflows\"] & string>(\n workflowName: TWorkflowName,\n {\n args,\n searchAttributes,\n ...temporalOptions\n }: TypedWorkflowStartOptions<TContract, TWorkflowName>,\n ): ResultAsync<\n ClientInferOutput<TContract[\"workflows\"][TWorkflowName]>,\n | WorkflowNotFoundError\n | WorkflowValidationError\n | WorkflowAlreadyStartedError\n | WorkflowFailedError\n | WorkflowExecutionNotFoundError\n | RuntimeClientError\n > {\n type Ok = ClientInferOutput<TContract[\"workflows\"][TWorkflowName]>;\n type Err =\n | WorkflowNotFoundError\n | WorkflowValidationError\n | WorkflowAlreadyStartedError\n | WorkflowFailedError\n | WorkflowExecutionNotFoundError\n | RuntimeClientError;\n const work = async (): Promise<Result<Ok, Err>> => {\n const resolved = await resolveDefinitionAndValidateInput(\n this.contract,\n workflowName,\n args,\n searchAttributes as Record<string, unknown> | undefined,\n );\n if (resolved.isErr()) return err(resolved.error);\n const { definition, validatedInput, typedSearchAttributes } = resolved.value;\n\n try {\n const result = await this.client.workflow.execute(workflowName, {\n ...temporalOptions,\n taskQueue: this.contract.taskQueue,\n args: [validatedInput],\n ...(typedSearchAttributes ? { typedSearchAttributes } : {}),\n });\n\n // Output validation runs *after* the Temporal call returns — kept\n // inline because it's specific to executeWorkflow's start-and-wait\n // shape; the helper only handles pre-call concerns.\n const outputResult = await definition.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n return err(createWorkflowValidationError(workflowName, \"output\", outputResult.issues));\n }\n\n return ok(outputResult.value as Ok);\n } catch (error) {\n // executeWorkflow combines start + result, so it can surface any of\n // the discriminated kinds. Inline the three checks rather than\n // routing through a dedicated helper — this is the only call site\n // that needs the full union.\n if (error instanceof WorkflowExecutionAlreadyStartedError) {\n return err(new WorkflowAlreadyStartedError(error.workflowType, error.workflowId, error));\n }\n if (error instanceof TemporalWorkflowFailedError) {\n // Forward Temporal's nested cause directly — see\n // {@link classifyResultError} for the same rationale: Temporal's\n // `WorkflowFailedError` is a wrapper, and the actionable failure\n // (ApplicationFailure, CancelledFailure, etc.) lives on `.cause`.\n // Temporal types `cause` as `Error | undefined`, but the SDK only\n // ever populates it with a `TemporalFailure` subclass here; narrow\n // with the public union so the typed `cause` lines up with the\n // surfaced `WorkflowFailedError`.\n return err(\n new WorkflowFailedError(\n temporalOptions.workflowId,\n error.cause as TemporalFailure | undefined,\n ),\n );\n }\n if (error instanceof TemporalWorkflowNotFoundError) {\n return err(\n new WorkflowExecutionNotFoundError(\n error.workflowId || temporalOptions.workflowId,\n error.runId,\n error,\n ),\n );\n }\n return err(createRuntimeClientError(\"executeWorkflow\", error));\n }\n };\n return makeResultAsync(work);\n }\n\n /**\n * Get a handle to an existing workflow with ResultAsync pattern\n *\n * @example\n * ```ts\n * const handleResult = await client.getHandle('processOrder', 'order-123');\n * handleResult.match(\n * async (handle) => {\n * const result = await handle.result();\n * // ... handle result\n * },\n * (error) => console.error('Failed to get handle:', error),\n * );\n * ```\n */\n getHandle<TWorkflowName extends keyof TContract[\"workflows\"] & string>(\n workflowName: TWorkflowName,\n workflowId: string,\n ): ResultAsync<\n TypedWorkflowHandle<TContract[\"workflows\"][TWorkflowName]>,\n WorkflowNotFoundError | RuntimeClientError\n > {\n type Ok = TypedWorkflowHandle<TContract[\"workflows\"][TWorkflowName]>;\n type Err = WorkflowNotFoundError | RuntimeClientError;\n const work = async (): Promise<Result<Ok, Err>> => {\n const definition = this.contract.workflows[workflowName];\n if (!definition) {\n return err(createWorkflowNotFoundError(workflowName, this.contract));\n }\n\n try {\n const handle = this.client.workflow.getHandle(workflowId);\n return ok(this.createTypedHandle(handle, definition) as Ok);\n } catch (error) {\n return err(createRuntimeClientError(\"getHandle\", error));\n }\n };\n return makeResultAsync(work);\n }\n\n private createTypedHandle<TWorkflow extends AnyWorkflowDefinition>(\n workflowHandle: WorkflowHandle,\n definition: TWorkflow,\n ): TypedWorkflowHandle<TWorkflow> {\n const queries = buildValidatedProxy({\n defs: definition.queries,\n operation: \"query\",\n workflowId: workflowHandle.workflowId,\n makeValidationError: (name, direction, issues) =>\n new QueryValidationError(name, direction, issues),\n invoke: (name, validated) => workflowHandle.query(name, validated),\n validateOutput: (def) => def.output,\n }) as TypedWorkflowHandle<TWorkflow>[\"queries\"];\n\n const signals = buildValidatedProxy({\n defs: definition.signals,\n operation: \"signal\",\n workflowId: workflowHandle.workflowId,\n makeValidationError: (name, _direction, issues) => new SignalValidationError(name, issues),\n invoke: async (name, validated) => {\n await workflowHandle.signal(name, validated);\n return undefined;\n },\n validateOutput: () => null,\n }) as TypedWorkflowHandle<TWorkflow>[\"signals\"];\n\n const updates = buildValidatedProxy({\n defs: definition.updates,\n operation: \"update\",\n workflowId: workflowHandle.workflowId,\n makeValidationError: (name, direction, issues) =>\n new UpdateValidationError(name, direction, issues),\n invoke: (name, validated) => workflowHandle.executeUpdate(name, { args: [validated] }),\n validateOutput: (def) => def.output,\n }) as TypedWorkflowHandle<TWorkflow>[\"updates\"];\n\n return {\n workflowId: workflowHandle.workflowId,\n queries,\n signals,\n updates,\n result: (): ResultAsync<\n ClientInferOutput<TWorkflow>,\n | WorkflowValidationError\n | WorkflowFailedError\n | WorkflowExecutionNotFoundError\n | RuntimeClientError\n > => {\n type Ok = ClientInferOutput<TWorkflow>;\n type Err =\n | WorkflowValidationError\n | WorkflowFailedError\n | WorkflowExecutionNotFoundError\n | RuntimeClientError;\n const work = async (): Promise<Result<Ok, Err>> => {\n try {\n const result = await workflowHandle.result();\n const outputResult = await definition.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n return err(\n new WorkflowValidationError(\n workflowHandle.workflowId,\n \"output\",\n outputResult.issues,\n ),\n );\n }\n return ok(outputResult.value as Ok);\n } catch (error) {\n return err(classifyResultError(\"result\", error, workflowHandle.workflowId));\n }\n };\n return makeResultAsync(work);\n },\n terminate: (\n reason?: string,\n ): ResultAsync<void, WorkflowExecutionNotFoundError | RuntimeClientError> =>\n ResultAsync.fromPromise(workflowHandle.terminate(reason), (error) =>\n classifyHandleError(\"terminate\", error, workflowHandle.workflowId),\n ).map(() => undefined),\n cancel: (): ResultAsync<void, WorkflowExecutionNotFoundError | RuntimeClientError> =>\n ResultAsync.fromPromise(workflowHandle.cancel(), (error) =>\n classifyHandleError(\"cancel\", error, workflowHandle.workflowId),\n ).map(() => undefined),\n describe: (): ResultAsync<\n Awaited<ReturnType<WorkflowHandle[\"describe\"]>>,\n WorkflowExecutionNotFoundError | RuntimeClientError\n > =>\n ResultAsync.fromPromise(workflowHandle.describe(), (error) =>\n classifyHandleError(\"describe\", error, workflowHandle.workflowId),\n ),\n fetchHistory: (): ResultAsync<\n Awaited<ReturnType<WorkflowHandle[\"fetchHistory\"]>>,\n WorkflowExecutionNotFoundError | RuntimeClientError\n > =>\n ResultAsync.fromPromise(workflowHandle.fetchHistory(), (error) =>\n classifyHandleError(\"fetchHistory\", error, workflowHandle.workflowId),\n ),\n };\n }\n}\n\nfunction createRuntimeClientError(operation: string, error: unknown): RuntimeClientError {\n return new RuntimeClientError(operation, error);\n}\n\nfunction createWorkflowNotFoundError(\n workflowName: string | number | symbol,\n contract: ContractDefinition,\n): WorkflowNotFoundError {\n return new WorkflowNotFoundError(String(workflowName), Object.keys(contract.workflows));\n}\n\nfunction createWorkflowValidationError(\n workflowName: string | number | symbol,\n direction: \"input\" | \"output\",\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n): WorkflowValidationError {\n return new WorkflowValidationError(String(workflowName), direction, issues);\n}\n\ntype DefWithInput = { readonly input: StandardSchemaV1 };\n\ntype ProxyOptions<TDef extends DefWithInput, TValidationError extends Error> = {\n readonly defs: Record<string, TDef> | undefined;\n readonly operation: string;\n /**\n * Workflow ID of the handle these proxies bind to. Used by\n * {@link classifyHandleError} to surface\n * {@link WorkflowExecutionNotFoundError} with the targeted ID even when\n * Temporal's error doesn't carry it.\n */\n readonly workflowId: string;\n readonly makeValidationError: (\n name: string,\n direction: \"input\" | \"output\",\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) => TValidationError;\n readonly invoke: (name: string, validatedInput: unknown) => Promise<unknown>;\n /**\n * Returns the schema to validate the invoke result against, or `null` to skip\n * output validation (used by signals, which don't return a value).\n */\n readonly validateOutput: (def: TDef) => StandardSchemaV1 | null;\n};\n\n/**\n * Build a `{ name: (args) => ResultAsync<...> }` proxy for a contract's\n * queries/signals/updates. The three call sites differ only in how they\n * invoke Temporal and whether they validate output, so the shared\n * input-validate → invoke → output-validate → wrap-Result pipeline lives\n * here once.\n */\nfunction buildValidatedProxy<TDef extends DefWithInput, TValidationError extends Error>({\n defs,\n operation,\n workflowId,\n makeValidationError,\n invoke,\n validateOutput,\n}: ProxyOptions<TDef, TValidationError>): Record<\n string,\n (\n args: unknown,\n ) => ResultAsync<unknown, TValidationError | WorkflowExecutionNotFoundError | RuntimeClientError>\n> {\n const proxy: Record<\n string,\n (\n args: unknown,\n ) => ResultAsync<\n unknown,\n TValidationError | WorkflowExecutionNotFoundError | RuntimeClientError\n >\n > = {};\n if (!defs) return proxy;\n\n for (const [name, def] of Object.entries(defs)) {\n proxy[name] = (args) => {\n const work = async (): Promise<\n Result<unknown, TValidationError | WorkflowExecutionNotFoundError | RuntimeClientError>\n > => {\n const inputResult = await def.input[\"~standard\"].validate(args);\n if (inputResult.issues) {\n return err(makeValidationError(name, \"input\", inputResult.issues));\n }\n\n try {\n const result = await invoke(name, inputResult.value);\n const outputSchema = validateOutput(def);\n if (!outputSchema) {\n return ok(result);\n }\n const outputResult = await outputSchema[\"~standard\"].validate(result);\n if (outputResult.issues) {\n return err(makeValidationError(name, \"output\", outputResult.issues));\n }\n return ok(outputResult.value);\n } catch (error) {\n return err(classifyHandleError(operation, error, workflowId));\n }\n };\n return makeResultAsync(work);\n };\n }\n\n return proxy;\n}\n"],"mappings":";;;;;;;;;AAkCA,IAAe,mBAAf,cAAwC,MAAM;CAC5C,YAAsB,SAAiB;EACrC,MAAM,OAAO;EACb,KAAK,OAAO,KAAK,YAAY;EAC7B,IAAI,MAAM,mBACR,MAAM,kBAAkB,MAAM,KAAK,WAAW;CAElD;AACF;;;;AAKA,IAAa,qBAAb,cAAwC,iBAAiB;CAErC;CACS;CAF3B,YACE,WACA,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Aa,QACf,OAAO,IAAI,oBAAoB,MAAM,UAAU,aAAa,MAAM,CAAC;IAErE,OAAO,GAAG,aAAa,KAAK;GAC9B,SAAS,OAAO;IACd,OAAO,IAAI,oBAAoB,WAAW,OAAO,UAAU,CAAC;GAC9D;EACF;EACA,OAAO,gBAAgB,IAAI;CAC7B;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"index.mjs","names":["TemporalWorkflowNotFoundError","TemporalWorkflowFailedError","TemporalWorkflowFailedError","TemporalWorkflowNotFoundError"],"sources":["../src/errors.ts","../src/internal.ts","../src/schedule.ts","../src/client.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { summarizeIssues } from \"@temporal-contract/contract\";\nimport { TaggedError } from \"unthrown\";\nimport type {\n ActivityFailure,\n ApplicationFailure,\n CancelledFailure,\n ChildWorkflowFailure,\n ServerFailure,\n TerminatedFailure,\n TimeoutFailure,\n} from \"@temporalio/common\";\n\n/**\n * Union of the actionable Temporal failure types that can surface as the\n * `cause` of a `WorkflowFailedError`. These all extend Temporal's internal\n * `TemporalFailure` base class — we list them by leaf type rather than by\n * the base class so consumer code can use a single `switch (true)` over\n * `instanceof` discriminants without an exhaustiveness escape hatch.\n *\n * Re-exported from the package entry point so consumers can import it\n * directly: `import type { TemporalFailure } from \"@temporal-contract/client\"`.\n */\nexport type TemporalFailure =\n | ApplicationFailure\n | CancelledFailure\n | TerminatedFailure\n | TimeoutFailure\n | ChildWorkflowFailure\n | ServerFailure\n | ActivityFailure;\n\n/**\n * Generic runtime failure wrapper when no specific error type applies\n */\nexport class RuntimeClientError extends TaggedError(\"@temporal-contract/RuntimeClientError\", {\n name: \"RuntimeClientError\",\n})<{\n operation: string;\n cause?: unknown;\n message: string;\n}> {\n constructor(operation: string, cause?: unknown) {\n super({\n operation,\n cause,\n message: `Operation \"${operation}\" failed: ${\n cause instanceof Error ? cause.message : String(cause ?? \"unknown error\")\n }`,\n });\n // only on `_tag`.\n }\n}\n\n/**\n * Thrown when a workflow is not found in the contract\n */\nexport class WorkflowNotFoundError extends TaggedError(\"@temporal-contract/WorkflowNotFoundError\", {\n name: \"WorkflowNotFoundError\",\n})<{\n workflowName: string;\n availableWorkflows: string[];\n message: string;\n}> {\n constructor(workflowName: string, availableWorkflows: string[]) {\n super({\n workflowName,\n availableWorkflows,\n message: `Workflow \"${workflowName}\" not found in contract. Available workflows: ${availableWorkflows.join(\", \")}`,\n });\n }\n}\n\n/**\n * Discriminated variant of {@link RuntimeClientError} surfaced when starting\n * a workflow collides with an existing execution — Temporal's\n * `WorkflowExecutionAlreadyStartedError`. The most common cause is a\n * workflowId reuse policy that rejects duplicates while a previous run is\n * still in retention.\n *\n * Distinguishing this from `RuntimeClientError` lets idempotent callers\n * branch on it explicitly (e.g. fetch the existing handle and continue)\n * without inspecting `error.cause` against a Temporal SDK class.\n */\nexport class WorkflowAlreadyStartedError extends TaggedError(\n \"@temporal-contract/WorkflowAlreadyStartedError\",\n { name: \"WorkflowAlreadyStartedError\" },\n)<{\n workflowType: string;\n workflowId: string;\n cause?: unknown;\n message: string;\n}> {\n constructor(workflowType: string, workflowId: string, cause?: unknown) {\n super({\n workflowType,\n workflowId,\n cause,\n message: `Workflow \"${workflowType}\" with ID \"${workflowId}\" is already started or in retention.`,\n });\n }\n}\n\n/**\n * Discriminated variant of {@link RuntimeClientError} surfaced when an\n * operation targets a workflow execution that doesn't exist in the\n * namespace — Temporal's `WorkflowNotFoundError` (distinct from this\n * package's contract-level {@link WorkflowNotFoundError}).\n *\n * Returned from:\n * - handle methods: `signal`, `query`, `executeUpdate`, `result`,\n * `terminate`, `cancel`, `describe`, `fetchHistory`\n * - `executeWorkflow` (when the underlying execute call hits a missing\n * execution mid-flight)\n */\nexport class WorkflowExecutionNotFoundError extends TaggedError(\n \"@temporal-contract/WorkflowExecutionNotFoundError\",\n { name: \"WorkflowExecutionNotFoundError\" },\n)<{\n workflowId: string;\n runId?: string | undefined;\n cause?: unknown;\n message: string;\n}> {\n constructor(workflowId: string, runId?: string, cause?: unknown) {\n super({\n workflowId,\n runId,\n cause,\n message: `Workflow execution \"${workflowId}\"${runId ? ` (run \"${runId}\")` : \"\"} not found in namespace.`,\n });\n }\n}\n\n/**\n * Discriminated variant of {@link RuntimeClientError} surfaced when waiting\n * on a workflow's result and the workflow completes with a failure —\n * Temporal's `WorkflowFailedError`.\n *\n * `cause` is the *unwrapped* underlying {@link TemporalFailure} (typically an\n * `ApplicationFailure`, `CancelledFailure`, `TerminatedFailure`, or\n * `TimeoutFailure`) lifted from Temporal's wrapper, so callers can branch\n * on the failure category in one step (`err.cause instanceof\n * ApplicationFailure`) instead of unwrapping twice via the SDK wrapper. The\n * SDK declares `WorkflowFailedError.cause` as the wider `Error | undefined`\n * (since `cause` lives on `Error`), but the runtime guarantee — driven by\n * Temporal's wire format — is that it is always a `TemporalFailure` subclass\n * when the wrapper is surfaced. `classifyResultError` narrows that wider\n * static type to the public {@link TemporalFailure} union with a cast, so\n * consumers see the precise leaf-failure typing instead of a bare `Error`.\n *\n * Returned from `executeWorkflow` and `handle.result()`.\n */\nexport class WorkflowFailedError extends TaggedError(\"@temporal-contract/WorkflowFailedError\", {\n name: \"WorkflowFailedError\",\n})<{\n workflowId: string;\n cause?: TemporalFailure | undefined;\n message: string;\n}> {\n constructor(workflowId: string, cause?: TemporalFailure) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? \"unknown failure\");\n super({\n workflowId,\n cause,\n message: `Workflow \"${workflowId}\" completed with failure: ${causeMessage}`,\n });\n }\n}\n\n// Validation-message formatters live in `@temporal-contract/contract` so\n// client and worker share a single source of truth. The previous local\n// copies have been removed in favor of the shared `summarizeIssues` import\n// at the top of this module.\n\n/**\n * Thrown when workflow input or output validation fails\n */\nexport class WorkflowValidationError extends TaggedError(\n \"@temporal-contract/WorkflowValidationError\",\n { name: \"WorkflowValidationError\" },\n)<{\n workflowName: string;\n direction: \"input\" | \"output\";\n issues: ReadonlyArray<StandardSchemaV1.Issue>;\n message: string;\n}> {\n constructor(\n workflowName: string,\n direction: \"input\" | \"output\",\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n super({\n workflowName,\n direction,\n issues,\n message: `Validation failed for workflow \"${workflowName}\" ${direction}: ${summarizeIssues(issues)}`,\n });\n }\n}\n\n/**\n * Thrown when query input or output validation fails\n */\nexport class QueryValidationError extends TaggedError(\"@temporal-contract/QueryValidationError\", {\n name: \"QueryValidationError\",\n})<{\n queryName: string;\n direction: \"input\" | \"output\";\n issues: ReadonlyArray<StandardSchemaV1.Issue>;\n message: string;\n}> {\n constructor(\n queryName: string,\n direction: \"input\" | \"output\",\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n super({\n queryName,\n direction,\n issues,\n message: `Validation failed for query \"${queryName}\" ${direction}: ${summarizeIssues(issues)}`,\n });\n }\n}\n\n/**\n * Thrown when signal input validation fails\n */\nexport class SignalValidationError extends TaggedError(\"@temporal-contract/SignalValidationError\", {\n name: \"SignalValidationError\",\n})<{\n signalName: string;\n issues: ReadonlyArray<StandardSchemaV1.Issue>;\n message: string;\n}> {\n constructor(signalName: string, issues: ReadonlyArray<StandardSchemaV1.Issue>) {\n super({\n signalName,\n issues,\n message: `Validation failed for signal \"${signalName}\": ${summarizeIssues(issues)}`,\n });\n }\n}\n\n/**\n * Thrown when update input or output validation fails\n */\nexport class UpdateValidationError extends TaggedError(\"@temporal-contract/UpdateValidationError\", {\n name: \"UpdateValidationError\",\n})<{\n updateName: string;\n direction: \"input\" | \"output\";\n issues: ReadonlyArray<StandardSchemaV1.Issue>;\n message: string;\n}> {\n constructor(\n updateName: string,\n direction: \"input\" | \"output\",\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n super({\n updateName,\n direction,\n issues,\n message: `Validation failed for update \"${updateName}\" ${direction}: ${summarizeIssues(issues)}`,\n });\n }\n}\n","/**\n * Internal helpers shared across the client package's modules.\n *\n * Not part of the public API — this module is not listed in the package's\n * `exports` map, so consumers can't import from `@temporal-contract/client/internal`.\n * In-package modules and tests import it directly via relative path.\n */\nimport { WorkflowExecutionAlreadyStartedError } from \"@temporalio/client\";\nimport { WorkflowFailedError as TemporalWorkflowFailedError } from \"@temporalio/client\";\nimport {\n defineSearchAttributeKey,\n type SearchAttributePair,\n TypedSearchAttributes,\n WorkflowNotFoundError as TemporalWorkflowNotFoundError,\n} from \"@temporalio/common\";\nimport type { AnyWorkflowDefinition, SearchAttributeDefinition } from \"@temporal-contract/contract\";\nimport { _internal_makeAsyncResult } from \"@temporal-contract/contract/result-async\";\nimport { ok, err, type AsyncResult, type Result } from \"unthrown\";\n\n// `assertNoDefect` narrows an internally-built `Result` (known to carry only\n// ok/err) to `Ok | Err`, re-throwing a stray defect's cause — so call sites\n// reach `.value` / `.error` without a manual \"impossible defect\" guard.\nexport { _internal_assertNoDefect as assertNoDefect } from \"@temporal-contract/contract/result-async\";\nimport {\n RuntimeClientError,\n type TemporalFailure,\n WorkflowAlreadyStartedError,\n WorkflowExecutionNotFoundError,\n WorkflowFailedError,\n} from \"./errors.js\";\n\n/**\n * Translate the contract's typed `searchAttributes` map (declared\n * name → value) into a Temporal `TypedSearchAttributes` instance, so the\n * Temporal client honours indexing when starting the workflow.\n *\n * Workflows without a `searchAttributes` block (or callers passing no\n * values) resolve to `ok(undefined)`, matching the Temporal SDK's\n * \"absent ≠ empty\" semantics.\n *\n * Returns `err(RuntimeClientError)` on unknown keys. The TypeScript\n * surface already gates the happy path; the runtime check catches typed\n * escape hatches (`as never`, `as any`, raw-call interop) where a typo\n * would otherwise silently drop the attribute, leaving the workflow\n * unindexed without any signal to the caller.\n */\nexport function toTypedSearchAttributes(\n workflowDef: AnyWorkflowDefinition,\n workflowName: string,\n values: Record<string, unknown> | undefined,\n): Result<TypedSearchAttributes | undefined, RuntimeClientError> {\n if (!values) return ok(undefined);\n // Workflows that omit the `searchAttributes` block declare none. Treat\n // that as an empty declared map so a caller passing values still hits\n // the per-key \"undeclared\" check below — silently dropping them would\n // re-introduce the escape-hatch gap this helper was designed to close.\n const declared = (workflowDef.searchAttributes ?? {}) as Record<\n string,\n SearchAttributeDefinition\n >;\n const pairs: SearchAttributePair[] = [];\n for (const [name, value] of Object.entries(values)) {\n if (value === undefined) continue;\n const def = declared[name];\n if (!def) {\n return err(\n new RuntimeClientError(\n \"searchAttributes\",\n new Error(\n `Search attribute \"${name}\" is not declared on workflow \"${workflowName}\". ` +\n `Declared attributes: ${Object.keys(declared).join(\", \") || \"none\"}.`,\n ),\n ),\n );\n }\n const key = defineSearchAttributeKey(name, def.kind);\n pairs.push({ key, value } as SearchAttributePair);\n }\n return ok(pairs.length > 0 ? new TypedSearchAttributes(pairs) : undefined);\n}\n\n/**\n * Wrap an async result-producing function in an `AsyncResult`, routing any\n * unanticipated rejection through unthrown's `defect` channel.\n *\n * The work function is expected to handle its own domain errors and return\n * an `err(...)` for them; a thrown exception the work didn't anticipate is an\n * *unmodeled* failure and surfaces as a defect (inspectable via\n * `result.isDefect()` / `result.cause`, re-thrown at the edge) rather than a\n * manufactured `RuntimeClientError`.\n *\n * Used by `client.ts` (workflow operations) and `schedule.ts` (schedule\n * operations) so the unexpected-rejection shape is identical across the\n * typed client surface. Delegates to `_internal_makeAsyncResult` from\n * `@temporal-contract/contract` so the same wrapper is shared between the\n * client and worker packages.\n */\nexport function makeAsyncResult<T, E>(work: () => Promise<Result<T, E>>): AsyncResult<T, E> {\n return _internal_makeAsyncResult(work);\n}\n\n/**\n * Map a thrown error from `client.workflow.start` / `signalWithStart` into\n * the discriminated union surfaced by the typed client. Specifically\n * recognizes Temporal's `WorkflowExecutionAlreadyStartedError`; everything\n * else falls through to {@link RuntimeClientError}.\n */\nexport function classifyStartError(\n operation: string,\n error: unknown,\n): WorkflowAlreadyStartedError | RuntimeClientError {\n if (error instanceof WorkflowExecutionAlreadyStartedError) {\n return new WorkflowAlreadyStartedError(error.workflowType, error.workflowId, error);\n }\n return new RuntimeClientError(operation, error);\n}\n\n/**\n * Map a thrown error from a workflow handle method (signal, query,\n * executeUpdate, terminate, cancel, describe, fetchHistory) into the\n * discriminated union surfaced by the typed client. Recognizes Temporal's\n * `WorkflowNotFoundError`; everything else falls through to\n * {@link RuntimeClientError}.\n *\n * `fallbackWorkflowId` is used when Temporal's error carries an empty\n * `workflowId` (it normalizes missing IDs to the empty string), so the\n * surfaced error always identifies the targeted execution.\n */\nexport function classifyHandleError(\n operation: string,\n error: unknown,\n fallbackWorkflowId: string,\n): WorkflowExecutionNotFoundError | RuntimeClientError {\n if (error instanceof TemporalWorkflowNotFoundError) {\n return new WorkflowExecutionNotFoundError(\n error.workflowId || fallbackWorkflowId,\n error.runId,\n error,\n );\n }\n return new RuntimeClientError(operation, error);\n}\n\n/**\n * Map a thrown error from `handle.result()` / `client.workflow.execute()`\n * (the latter when waiting on the result phase). Recognizes Temporal's\n * `WorkflowFailedError` and `WorkflowNotFoundError`; everything else falls\n * through to {@link RuntimeClientError}.\n *\n * Temporal's `WorkflowFailedError` is itself a wrapper — the actionable\n * failure (ApplicationFailure, CancelledFailure, TerminatedFailure, etc.)\n * lives on its `cause` field. We forward that inner cause directly so\n * consumers can match `err.cause` against the underlying failure class\n * without an extra unwrap step. (If Temporal's cause is `undefined`, our\n * `cause` is too — same shape as before.)\n */\nexport function classifyResultError(\n operation: string,\n error: unknown,\n workflowId: string,\n): WorkflowFailedError | WorkflowExecutionNotFoundError | RuntimeClientError {\n if (error instanceof TemporalWorkflowFailedError) {\n // Temporal types `cause` as `Error | undefined`, but the SDK only ever\n // populates it with a `TemporalFailure` subclass when surfacing a\n // workflow result failure. Narrow with the public union so consumers\n // can branch on the leaf failure types without an extra cast.\n return new WorkflowFailedError(workflowId, error.cause as TemporalFailure | undefined);\n }\n if (error instanceof TemporalWorkflowNotFoundError) {\n return new WorkflowExecutionNotFoundError(error.workflowId || workflowId, error.runId, error);\n }\n return new RuntimeClientError(operation, error);\n}\n","import type {\n ScheduleClient,\n ScheduleDescription,\n ScheduleHandle,\n ScheduleOptions,\n ScheduleOptionsStartWorkflowAction,\n ScheduleOverlapPolicy,\n ScheduleSpec,\n} from \"@temporalio/client\";\nimport type { ContractDefinition } from \"@temporal-contract/contract\";\nimport { type AsyncResult, type Result, ok, err, fromPromise } from \"unthrown\";\nimport type { TypedSearchAttributeMap } from \"./client.js\";\nimport type { ClientInferInput } from \"./types.js\";\nimport { RuntimeClientError, WorkflowNotFoundError, WorkflowValidationError } from \"./errors.js\";\nimport { assertNoDefect, makeAsyncResult, toTypedSearchAttributes } from \"./internal.js\";\n\n/**\n * Workflow-action–level overrides forwarded to Temporal's\n * `ScheduleOptionsStartWorkflowAction`. These live under a nested `action`\n * field so the workflow-level `memo` (per-action workflow metadata) can be\n * set independently from the schedule-level `memo` (metadata on the\n * schedule itself) — Temporal honours both, and they have separate\n * lifecycles.\n *\n * `workflowType` and `taskQueue` are owned by the contract and not exposed.\n */\nexport type TypedScheduleActionOverrides = Pick<\n ScheduleOptionsStartWorkflowAction<never>,\n | \"workflowId\"\n | \"workflowExecutionTimeout\"\n | \"workflowRunTimeout\"\n | \"workflowTaskTimeout\"\n | \"retry\"\n | \"memo\"\n | \"staticDetails\"\n | \"staticSummary\"\n>;\n\n/**\n * Options for {@link TypedScheduleClient.create}.\n *\n * `scheduleId` and `spec` come from Temporal's `ScheduleOptions`. `args` is\n * typed against the destination workflow's input schema. `policies`,\n * `state`, and `memo` mirror Temporal's own schedule-level options.\n * Workflow-action–level overrides nest under {@link action} so memo and\n * other fields with the same name don't collide between the two scopes.\n */\nexport type TypedScheduleCreateOptions<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = {\n /** Schedule ID. Recommended to use a meaningful business identifier. */\n scheduleId: string;\n /** When the schedule should fire (cron, interval, calendar). */\n spec: ScheduleSpec;\n /** Workflow input — validated against the contract's input schema. */\n args: ClientInferInput<TContract[\"workflows\"][TWorkflowName]>;\n /**\n * Indexed search attributes for each workflow run spawned by this\n * schedule. Keys and value types are constrained to those declared on\n * the destination workflow's contract via `defineSearchAttribute`.\n * Translated to Temporal's `typedSearchAttributes` and attached to the\n * schedule's `startWorkflow` action so each spawned run is indexed\n * identically to one started directly via `client.startWorkflow`.\n */\n searchAttributes?: TypedSearchAttributeMap<TContract[\"workflows\"][TWorkflowName]>;\n /** Temporal schedule policies (overlap, catchupWindow, pauseOnFailure, etc.). */\n policies?: ScheduleOptions[\"policies\"];\n /** Temporal schedule state (paused, note, limited, etc.). */\n state?: ScheduleOptions[\"state\"];\n /** Schedule-level memo (non-indexed metadata on the schedule itself). */\n memo?: ScheduleOptions[\"memo\"];\n /**\n * Workflow-action–level overrides. `workflowType` and `taskQueue` are\n * derived from the contract, so they don't appear here. Note that\n * `action.memo` is a *workflow-level* memo applied to each spawned run,\n * distinct from the top-level `memo` (which is metadata on the schedule\n * itself).\n */\n action?: TypedScheduleActionOverrides;\n};\n\n/**\n * Typed handle to a schedule. Mirrors Temporal's `ScheduleHandle` lifecycle\n * methods (`pause`, `unpause`, `trigger`, `describe`, `delete`) wrapped in\n * the unthrown AsyncResult pattern so call sites match the rest of the\n * typed client.\n */\nexport type TypedScheduleHandle = {\n /** This schedule's identifier. */\n readonly scheduleId: string;\n /** Pause the schedule. Optional note becomes part of the audit trail. */\n pause: (note?: string) => AsyncResult<void, RuntimeClientError>;\n /** Resume a paused schedule. */\n unpause: (note?: string) => AsyncResult<void, RuntimeClientError>;\n /** Fire the schedule's action immediately. */\n trigger: (overlap?: ScheduleOverlapPolicy) => AsyncResult<void, RuntimeClientError>;\n /** Delete the schedule. */\n delete: () => AsyncResult<void, RuntimeClientError>;\n /** Fetch the schedule's current description from the server. */\n describe: () => AsyncResult<ScheduleDescription, RuntimeClientError>;\n};\n\n/**\n * Typed wrapper around Temporal's `ScheduleClient`. Exposed as\n * `typedClient.schedule` — keeps the typed-client surface organized the\n * same way Temporal's own `Client.schedule` does.\n */\nexport class TypedScheduleClient<TContract extends ContractDefinition> {\n constructor(\n private readonly contract: TContract,\n private readonly scheduleClient: ScheduleClient,\n ) {}\n\n /**\n * Create a new schedule that, on each fire, starts the named contract\n * workflow with validated args.\n *\n * Validates `args` against the workflow's input schema before dispatching\n * the create request to Temporal. The workflow's `taskQueue` and\n * `workflowType` are pulled from the contract automatically; the typed\n * options shape omits them so call sites don't have to repeat themselves.\n */\n create<TWorkflowName extends keyof TContract[\"workflows\"] & string>(\n workflowName: TWorkflowName,\n options: TypedScheduleCreateOptions<TContract, TWorkflowName>,\n ): AsyncResult<\n TypedScheduleHandle,\n WorkflowNotFoundError | WorkflowValidationError | RuntimeClientError\n > {\n type Ok = TypedScheduleHandle;\n type Err = WorkflowNotFoundError | WorkflowValidationError | RuntimeClientError;\n const work = async (): Promise<Result<Ok, Err>> => {\n const definition = this.contract.workflows[workflowName];\n if (!definition) {\n return err(new WorkflowNotFoundError(workflowName, Object.keys(this.contract.workflows)));\n }\n\n const inputResult = await definition.input[\"~standard\"].validate(options.args);\n if (inputResult.issues) {\n return err(new WorkflowValidationError(workflowName, \"input\", inputResult.issues));\n }\n\n // Translate typed search attributes for the spawned workflow runs.\n // Lives on the schedule's `startWorkflow` action (workflow-level\n // indexing), not on the schedule itself. Mirrors what\n // `client.startWorkflow` does for direct starts so schedule-spawned\n // runs share visibility with their direct-start counterparts.\n const searchAttributesResult = toTypedSearchAttributes(\n definition,\n workflowName,\n options.searchAttributes as Record<string, unknown> | undefined,\n );\n // `toTypedSearchAttributes` only ever builds ok/err; assert away the\n // impossible defect so `.error` / `.value` narrow cleanly.\n assertNoDefect(searchAttributesResult);\n if (searchAttributesResult.isErr()) return err(searchAttributesResult.error);\n const typedSearchAttributes = searchAttributesResult.value;\n\n try {\n const overrides = options.action ?? {};\n const action: ScheduleOptionsStartWorkflowAction<never> = {\n type: \"startWorkflow\",\n workflowType: workflowName,\n taskQueue: this.contract.taskQueue,\n args: [inputResult.value] as never,\n ...(typedSearchAttributes ? { typedSearchAttributes } : {}),\n ...(overrides.workflowId !== undefined ? { workflowId: overrides.workflowId } : {}),\n ...(overrides.workflowExecutionTimeout !== undefined\n ? { workflowExecutionTimeout: overrides.workflowExecutionTimeout }\n : {}),\n ...(overrides.workflowRunTimeout !== undefined\n ? { workflowRunTimeout: overrides.workflowRunTimeout }\n : {}),\n ...(overrides.workflowTaskTimeout !== undefined\n ? { workflowTaskTimeout: overrides.workflowTaskTimeout }\n : {}),\n ...(overrides.retry !== undefined ? { retry: overrides.retry } : {}),\n ...(overrides.memo !== undefined ? { memo: overrides.memo } : {}),\n ...(overrides.staticDetails !== undefined\n ? { staticDetails: overrides.staticDetails }\n : {}),\n ...(overrides.staticSummary !== undefined\n ? { staticSummary: overrides.staticSummary }\n : {}),\n };\n\n const handle = await this.scheduleClient.create({\n scheduleId: options.scheduleId,\n spec: options.spec,\n action,\n ...(options.policies !== undefined ? { policies: options.policies } : {}),\n ...(options.state !== undefined ? { state: options.state } : {}),\n ...(options.memo !== undefined ? { memo: options.memo } : {}),\n });\n return ok(wrapScheduleHandle(handle));\n } catch (error) {\n return err(new RuntimeClientError(\"schedule.create\", error));\n }\n };\n return makeAsyncResult(work);\n }\n\n /**\n * Get a typed handle to an existing schedule. Does not validate that the\n * schedule exists — handle methods (`describe`, `pause`, etc.) will\n * surface a `RuntimeClientError` if the underlying ID is unknown.\n */\n getHandle(scheduleId: string): TypedScheduleHandle {\n return wrapScheduleHandle(this.scheduleClient.getHandle(scheduleId));\n }\n}\n\nfunction wrapScheduleHandle(handle: ScheduleHandle): TypedScheduleHandle {\n return {\n scheduleId: handle.scheduleId,\n pause: (note) =>\n fromPromise(\n handle.pause(note),\n (error) => new RuntimeClientError(\"schedule.pause\", error),\n ).map(() => undefined),\n unpause: (note) =>\n fromPromise(\n handle.unpause(note),\n (error) => new RuntimeClientError(\"schedule.unpause\", error),\n ).map(() => undefined),\n trigger: (overlap) =>\n fromPromise(\n handle.trigger(overlap),\n (error) => new RuntimeClientError(\"schedule.trigger\", error),\n ).map(() => undefined),\n delete: () =>\n fromPromise(handle.delete(), (error) => new RuntimeClientError(\"schedule.delete\", error)).map(\n () => undefined,\n ),\n describe: () =>\n fromPromise(handle.describe(), (error) => new RuntimeClientError(\"schedule.describe\", error)),\n };\n}\n","import { Client, WorkflowHandle } from \"@temporalio/client\";\nimport type { WorkflowSignalWithStartOptions, WorkflowStartOptions } from \"@temporalio/client\";\nimport { defineSearchAttributeKey, TypedSearchAttributes } from \"@temporalio/common\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type {\n AnyWorkflowDefinition,\n ContractDefinition,\n SearchAttributeDefinition,\n SearchAttributeKindToType,\n SignalDefinition,\n SignalNamesOf,\n} from \"@temporal-contract/contract\";\nimport type {\n ClientInferInput,\n ClientInferOutput,\n ClientInferWorkflowQueries,\n ClientInferWorkflowSignals,\n ClientInferWorkflowUpdates,\n} from \"./types.js\";\nimport { type AsyncResult, type Result, ok, err, fromPromise } from \"unthrown\";\nimport {\n type TemporalFailure,\n WorkflowAlreadyStartedError,\n WorkflowExecutionNotFoundError,\n WorkflowFailedError,\n WorkflowNotFoundError,\n WorkflowValidationError,\n QueryValidationError,\n SignalValidationError,\n UpdateValidationError,\n RuntimeClientError,\n} from \"./errors.js\";\nimport { TypedScheduleClient } from \"./schedule.js\";\nimport {\n assertNoDefect,\n classifyHandleError,\n classifyResultError,\n classifyStartError,\n makeAsyncResult,\n toTypedSearchAttributes,\n} from \"./internal.js\";\nimport { WorkflowExecutionAlreadyStartedError } from \"@temporalio/client\";\nimport { WorkflowFailedError as TemporalWorkflowFailedError } from \"@temporalio/client\";\nimport { WorkflowNotFoundError as TemporalWorkflowNotFoundError } from \"@temporalio/common\";\n\n/**\n * Typed `searchAttributes` map for a workflow, derived from the workflow's\n * declared `searchAttributes`. Each key is constrained to a declared\n * attribute name; each value's type is determined by the attribute's `kind`\n * (e.g. `KEYWORD` → `string`, `INT` → `number`, `DATETIME` → `Date`,\n * `KEYWORD_LIST` → `string[]`).\n *\n * If the workflow declares no search attributes, this resolves to `never`,\n * meaning the `searchAttributes` field is effectively absent from the start\n * options for that workflow.\n */\nexport type TypedSearchAttributeMap<TWorkflow extends AnyWorkflowDefinition> =\n TWorkflow[\"searchAttributes\"] extends Record<string, SearchAttributeDefinition>\n ? {\n [K in keyof TWorkflow[\"searchAttributes\"]]?: SearchAttributeKindToType<\n TWorkflow[\"searchAttributes\"][K][\"kind\"]\n >;\n }\n : never;\n\n/**\n * Read declared search attributes off a `TypedSearchAttributes` instance —\n * the read-side counterpart to the write-side `searchAttributes` option on\n * `startWorkflow` / `signalWithStart` / `executeWorkflow` /\n * `schedule.create`.\n *\n * Use it on the result of `handle.describe()` (or a schedule's describe) to\n * recover the typed shape of indexed attributes. The Temporal SDK only\n * exposes a `.get(key)` accessor on `TypedSearchAttributes` and requires\n * the caller to reconstruct each `SearchAttributeKey` from the contract's\n * declared `kind` — this helper does that lookup once for every declared\n * attribute, returning a `Partial<TypedSearchAttributeMap<TWorkflow>>`\n * (each declared key may or may not have been set on the workflow).\n *\n * Workflows without declared `searchAttributes` get an empty object back.\n *\n * @example\n * ```ts\n * const description = await handle.describe();\n * if (description.isOk()) {\n * const attrs = readTypedSearchAttributes(\n * myContract.workflows.processOrder,\n * description.value.typedSearchAttributes,\n * );\n * // attrs.customerId: string | undefined\n * // attrs.priority: number | undefined\n * }\n * ```\n */\nexport function readTypedSearchAttributes<TWorkflow extends AnyWorkflowDefinition>(\n workflowDef: TWorkflow,\n instance: TypedSearchAttributes,\n): Partial<TypedSearchAttributeMap<TWorkflow>> {\n const declared = workflowDef.searchAttributes as\n | Record<string, SearchAttributeDefinition>\n | undefined;\n if (!declared) return {} as Partial<TypedSearchAttributeMap<TWorkflow>>;\n\n const result: Record<string, unknown> = {};\n for (const [name, def] of Object.entries(declared)) {\n const key = defineSearchAttributeKey(name, def.kind);\n const value = instance.get(key);\n if (value !== undefined) {\n result[name] = value;\n }\n }\n return result as Partial<TypedSearchAttributeMap<TWorkflow>>;\n}\n\nexport type TypedWorkflowStartOptions<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = Omit<\n WorkflowStartOptions,\n \"taskQueue\" | \"args\" | \"searchAttributes\" | \"typedSearchAttributes\"\n> & {\n args: ClientInferInput<TContract[\"workflows\"][TWorkflowName]>;\n /**\n * Indexed search attributes for the started workflow. Keys and value types\n * are constrained to those declared on the workflow's contract via\n * `defineSearchAttribute`. Translated to Temporal's `typedSearchAttributes`\n * before the start request is dispatched.\n */\n searchAttributes?: TypedSearchAttributeMap<TContract[\"workflows\"][TWorkflowName]>;\n};\n\n/**\n * Options for {@link TypedClient.signalWithStart} — typed against both the\n * workflow's input schema and the named signal's input schema.\n */\nexport type TypedSignalWithStartOptions<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n TSignalName extends SignalNamesOf<TContract[\"workflows\"][TWorkflowName]>,\n> = Omit<\n WorkflowSignalWithStartOptions,\n \"taskQueue\" | \"args\" | \"signal\" | \"signalArgs\" | \"searchAttributes\" | \"typedSearchAttributes\"\n> & {\n args: ClientInferInput<TContract[\"workflows\"][TWorkflowName]>;\n signalName: TSignalName;\n signalArgs: TContract[\"workflows\"][TWorkflowName][\"signals\"][TSignalName] extends SignalDefinition\n ? ClientInferInput<TContract[\"workflows\"][TWorkflowName][\"signals\"][TSignalName]>\n : never;\n /**\n * Indexed search attributes for the started workflow. Keys and value types\n * are constrained to those declared on the workflow's contract via\n * `defineSearchAttribute`. Translated to Temporal's `typedSearchAttributes`\n * before the signalWithStart request is dispatched.\n */\n searchAttributes?: TypedSearchAttributeMap<TContract[\"workflows\"][TWorkflowName]>;\n};\n\n/**\n * Typed workflow handle returned by `signalWithStart`. Adds `signaledRunId`\n * to the standard handle so callers can correlate the signal with the\n * (possibly pre-existing) workflow execution chain.\n */\nexport type TypedWorkflowHandleWithSignaledRunId<TWorkflow extends AnyWorkflowDefinition> =\n TypedWorkflowHandle<TWorkflow> & {\n /**\n * The Run Id of the bound Workflow at the time of `signalWithStart`. Since\n * `signalWithStart` may have signaled an existing Workflow Chain, this is\n * not necessarily the `firstExecutionRunId`.\n */\n readonly signaledRunId: string;\n };\n\n/**\n * Typed workflow handle with validated results using unthrown Result/AsyncResult\n */\nexport type TypedWorkflowHandle<TWorkflow extends AnyWorkflowDefinition> = {\n workflowId: string;\n\n /**\n * Type-safe queries based on workflow definition with Result pattern\n * Each query returns AsyncResult<T, Error> instead of Promise<T>\n */\n queries: {\n [K in keyof ClientInferWorkflowQueries<TWorkflow>]: ClientInferWorkflowQueries<TWorkflow>[K] extends (\n ...args: infer Args\n ) => AsyncResult<infer R, Error>\n ? (\n ...args: Args\n ) => AsyncResult<\n R,\n QueryValidationError | WorkflowExecutionNotFoundError | RuntimeClientError\n >\n : never;\n };\n\n /**\n * Type-safe signals based on workflow definition with Result pattern\n * Each signal returns AsyncResult<void, Error> instead of Promise<void>\n */\n signals: {\n [K in keyof ClientInferWorkflowSignals<TWorkflow>]: ClientInferWorkflowSignals<TWorkflow>[K] extends (\n ...args: infer Args\n ) => AsyncResult<void, Error>\n ? (\n ...args: Args\n ) => AsyncResult<\n void,\n SignalValidationError | WorkflowExecutionNotFoundError | RuntimeClientError\n >\n : never;\n };\n\n /**\n * Type-safe updates based on workflow definition with Result pattern\n * Each update returns AsyncResult<T, Error> instead of Promise<T>\n */\n updates: {\n [K in keyof ClientInferWorkflowUpdates<TWorkflow>]: ClientInferWorkflowUpdates<TWorkflow>[K] extends (\n ...args: infer Args\n ) => AsyncResult<infer R, Error>\n ? (\n ...args: Args\n ) => AsyncResult<\n R,\n UpdateValidationError | WorkflowExecutionNotFoundError | RuntimeClientError\n >\n : never;\n };\n\n /**\n * Get workflow result with Result pattern\n */\n result: () => AsyncResult<\n ClientInferOutput<TWorkflow>,\n | WorkflowValidationError\n | WorkflowFailedError\n | WorkflowExecutionNotFoundError\n | RuntimeClientError\n >;\n\n /**\n * Terminate workflow with Result pattern\n */\n terminate: (\n reason?: string,\n ) => AsyncResult<void, WorkflowExecutionNotFoundError | RuntimeClientError>;\n\n /**\n * Cancel workflow with Result pattern\n */\n cancel: () => AsyncResult<void, WorkflowExecutionNotFoundError | RuntimeClientError>;\n\n /**\n * Get workflow execution description including status and metadata\n */\n describe: () => AsyncResult<\n Awaited<ReturnType<WorkflowHandle[\"describe\"]>>,\n WorkflowExecutionNotFoundError | RuntimeClientError\n >;\n\n /**\n * Fetch the workflow execution history\n */\n fetchHistory: () => AsyncResult<\n Awaited<ReturnType<WorkflowHandle[\"fetchHistory\"]>>,\n WorkflowExecutionNotFoundError | RuntimeClientError\n >;\n};\n\n/**\n * Result of {@link resolveDefinitionAndValidateInput} — the contract-side\n * pre-call ritual the start/signal-with-start/execute methods share. Holds\n * the resolved workflow definition, the schema-validated input, and the\n * translated typed search attributes (or `undefined` when the workflow\n * declared none / the caller passed none).\n */\ntype ResolvedWorkflow<TWorkflow extends AnyWorkflowDefinition> = {\n definition: TWorkflow;\n validatedInput: unknown;\n typedSearchAttributes: TypedSearchAttributes | undefined;\n};\n\n/**\n * Shared pre-call ritual for the three contract-driven entry points that\n * actually start a workflow (`startWorkflow`, `signalWithStart`,\n * `executeWorkflow`):\n *\n * 1. Look up the workflow definition on the contract.\n * 2. Surface a `WorkflowNotFoundError` if absent.\n * 3. Validate `args` against the workflow's input schema.\n * 4. Surface a `WorkflowValidationError` if validation fails.\n * 5. Translate any caller-supplied `searchAttributes` into Temporal's\n * `TypedSearchAttributes` shape (or `undefined`).\n *\n * `getHandle` deliberately keeps its own three-line lookup — it doesn't\n * accept `args` or `searchAttributes`, so it can't share this helper. The\n * call-specific extras (signal validation, post-call output validation,\n * extended error classification) stay at the call site — those are the\n * differentiators that make each method distinct.\n */\nasync function resolveDefinitionAndValidateInput<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n>(\n contract: TContract,\n workflowName: TWorkflowName,\n args: unknown,\n searchAttributes: Record<string, unknown> | undefined,\n): Promise<\n Result<\n ResolvedWorkflow<TContract[\"workflows\"][TWorkflowName]>,\n WorkflowNotFoundError | WorkflowValidationError | RuntimeClientError\n >\n> {\n const definition = contract.workflows[workflowName];\n if (!definition) {\n return err(createWorkflowNotFoundError(workflowName, contract));\n }\n\n const inputResult = await definition.input[\"~standard\"].validate(args);\n if (inputResult.issues) {\n return err(createWorkflowValidationError(workflowName, \"input\", inputResult.issues));\n }\n\n const searchAttributesResult = toTypedSearchAttributes(\n definition,\n workflowName,\n searchAttributes,\n );\n // `toTypedSearchAttributes` only ever builds ok/err; assert away the\n // impossible defect so `.error` / `.value` narrow cleanly.\n assertNoDefect(searchAttributesResult);\n if (searchAttributesResult.isErr()) return err(searchAttributesResult.error);\n const typedSearchAttributes = searchAttributesResult.value;\n\n return ok({\n definition: definition as TContract[\"workflows\"][TWorkflowName],\n validatedInput: inputResult.value,\n typedSearchAttributes,\n });\n}\n\n/**\n * Typed Temporal client with unthrown Result/AsyncResult pattern based on a contract\n *\n * Provides type-safe methods to start and execute workflows\n * defined in the contract, with explicit error handling using Result pattern.\n */\nexport class TypedClient<TContract extends ContractDefinition> {\n /**\n * Typed wrapper around Temporal's `client.schedule.create(...)` and\n * related lifecycle methods. Fires the underlying `startWorkflow` action\n * with args validated against the contract's input schema.\n *\n * **Requires `@temporalio/client` 1.16+.** The Schedule API was added in\n * 1.16; on older versions this property is unset and any access throws.\n * The package's peer dep allows the whole `^1` range to stay permissive\n * about the installed Temporal version, so consumers on < 1.16 who never\n * touch schedules keep working — the constructor below fails fast with a\n * clear message for anyone who does reach for the Schedule API too early.\n *\n * @example\n * ```ts\n * const result = await client.schedule.create(\"processOrder\", {\n * scheduleId: \"daily-sweep\",\n * spec: { cronExpressions: [\"0 2 * * *\"] },\n * args: { orderId: \"sweep\" },\n * });\n *\n * await result.match({\n * ok: async (handle) => { await handle.pause(\"maintenance\"); },\n * err: (error) => console.error(\"schedule create failed\", error),\n * defect: (cause) => console.error(\"unexpected failure\", cause),\n * });\n * ```\n */\n readonly schedule: TypedScheduleClient<TContract>;\n\n private constructor(\n private readonly contract: TContract,\n private readonly client: Client,\n ) {\n // `client.schedule` is the ScheduleClient wired into Temporal's\n // top-level `Client` since 1.16. The peer dep allows all of `^1`, so a\n // consumer can be on an older version — fail early with a clear message\n // rather than crashing later with a confusing\n // `Cannot read properties of undefined`.\n if (!client.schedule) {\n throw new Error(\n \"TypedClient requires @temporalio/client >= 1.16 (the Schedule API was added in 1.16). \" +\n \"Found a Client instance without a `schedule` property — please upgrade.\",\n );\n }\n this.schedule = new TypedScheduleClient(contract, client.schedule);\n }\n\n /**\n * Create a typed Temporal client with unthrown pattern from a contract\n *\n * @example\n * ```ts\n * const connection = await Connection.connect();\n * const temporalClient = new Client({ connection });\n * const client = TypedClient.create(myContract, temporalClient);\n *\n * const result = await client.executeWorkflow('processOrder', {\n * workflowId: 'order-123',\n * args: { ... },\n * });\n *\n * await result.match({\n * ok: (output) => console.log('Success:', output),\n * err: (error) => console.error('Failed:', error),\n * defect: (cause) => console.error('Unexpected failure:', cause),\n * });\n * ```\n */\n static create<TContract extends ContractDefinition>(\n contract: TContract,\n client: Client,\n ): TypedClient<TContract> {\n return new TypedClient(contract, client);\n }\n\n /**\n * Start a workflow and return a typed handle with AsyncResult pattern\n *\n * @example\n * ```ts\n * const handleResult = await client.startWorkflow('processOrder', {\n * workflowId: 'order-123',\n * args: { orderId: 'ORD-123' },\n * workflowExecutionTimeout: '1 day',\n * retry: { maximumAttempts: 3 },\n * });\n *\n * await handleResult.match({\n * ok: async (handle) => {\n * const result = await handle.result();\n * // ... handle result\n * },\n * err: (error) => console.error('Failed to start:', error),\n * defect: (cause) => console.error('Unexpected failure:', cause),\n * });\n * ```\n */\n startWorkflow<TWorkflowName extends keyof TContract[\"workflows\"] & string>(\n workflowName: TWorkflowName,\n {\n args,\n searchAttributes,\n ...temporalOptions\n }: TypedWorkflowStartOptions<TContract, TWorkflowName>,\n ): AsyncResult<\n TypedWorkflowHandle<TContract[\"workflows\"][TWorkflowName]>,\n | WorkflowNotFoundError\n | WorkflowValidationError\n | WorkflowAlreadyStartedError\n | RuntimeClientError\n > {\n type Ok = TypedWorkflowHandle<TContract[\"workflows\"][TWorkflowName]>;\n type Err =\n | WorkflowNotFoundError\n | WorkflowValidationError\n | WorkflowAlreadyStartedError\n | RuntimeClientError;\n const work = async (): Promise<Result<Ok, Err>> => {\n const resolved = await resolveDefinitionAndValidateInput(\n this.contract,\n workflowName,\n args,\n searchAttributes as Record<string, unknown> | undefined,\n );\n // The resolver only ever builds ok/err; assert away the impossible defect.\n assertNoDefect(resolved);\n if (resolved.isErr()) return err(resolved.error);\n const { definition, validatedInput, typedSearchAttributes } = resolved.value;\n\n try {\n const handle = await this.client.workflow.start(workflowName, {\n ...temporalOptions,\n taskQueue: this.contract.taskQueue,\n args: [validatedInput],\n ...(typedSearchAttributes ? { typedSearchAttributes } : {}),\n });\n return ok(this.createTypedHandle(handle, definition) as Ok);\n } catch (error) {\n return err(classifyStartError(\"startWorkflow\", error));\n }\n };\n return makeAsyncResult(work);\n }\n\n /**\n * Send a signal to a workflow, starting it first if it doesn't already exist.\n *\n * Validates both halves of the call against the contract:\n * - `args` against the workflow's input schema\n * - `signalArgs` against the named signal's input schema\n *\n * Returns a `TypedWorkflowHandleWithSignaledRunId` — the same shape as\n * `startWorkflow`'s handle, plus a `signaledRunId` field for correlating\n * the signal with the (possibly pre-existing) workflow execution chain.\n *\n * @example\n * ```ts\n * const result = await client.signalWithStart('processOrder', {\n * workflowId: 'order-123',\n * args: { orderId: 'ORD-123', customerId: 'CUST-1' },\n * signalName: 'cancel',\n * signalArgs: { reason: 'duplicate' },\n * });\n *\n * await result.match({\n * ok: (handle) => console.log('signaled run', handle.signaledRunId),\n * err: (error) => console.error('signalWithStart failed', error),\n * defect: (cause) => console.error('unexpected failure', cause),\n * });\n * ```\n */\n signalWithStart<\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n TSignalName extends SignalNamesOf<TContract[\"workflows\"][TWorkflowName]>,\n >(\n workflowName: TWorkflowName,\n {\n args,\n signalName,\n signalArgs,\n searchAttributes,\n ...temporalOptions\n }: TypedSignalWithStartOptions<TContract, TWorkflowName, TSignalName>,\n ): AsyncResult<\n TypedWorkflowHandleWithSignaledRunId<TContract[\"workflows\"][TWorkflowName]>,\n | WorkflowNotFoundError\n | WorkflowValidationError\n | SignalValidationError\n | WorkflowAlreadyStartedError\n | RuntimeClientError\n > {\n type Ok = TypedWorkflowHandleWithSignaledRunId<TContract[\"workflows\"][TWorkflowName]>;\n type Err =\n | WorkflowNotFoundError\n | WorkflowValidationError\n | SignalValidationError\n | WorkflowAlreadyStartedError\n | RuntimeClientError;\n\n const work = async (): Promise<Result<Ok, Err>> => {\n const resolved = await resolveDefinitionAndValidateInput(\n this.contract,\n workflowName,\n args,\n searchAttributes as Record<string, unknown> | undefined,\n );\n // The resolver only ever builds ok/err; assert away the impossible defect.\n assertNoDefect(resolved);\n if (resolved.isErr()) return err(resolved.error);\n const { definition, validatedInput, typedSearchAttributes } = resolved.value;\n\n // Validate signal input — call-site-specific, kept inline.\n const signalDef = (definition.signals as Record<string, SignalDefinition> | undefined)?.[\n signalName\n ];\n if (!signalDef) {\n // Type-level constraint should already prevent this; defensive for\n // raw-call / union-typed-name corner cases.\n return err(\n new SignalValidationError(signalName, [\n {\n message: `Signal \"${signalName}\" is not declared on workflow \"${workflowName}\".`,\n },\n ]),\n );\n }\n const signalInputResult = await signalDef.input[\"~standard\"].validate(signalArgs);\n if (signalInputResult.issues) {\n return err(new SignalValidationError(signalName, signalInputResult.issues));\n }\n\n try {\n const handle = await this.client.workflow.signalWithStart(workflowName, {\n ...temporalOptions,\n taskQueue: this.contract.taskQueue,\n args: [validatedInput],\n signal: signalName,\n signalArgs: [signalInputResult.value],\n ...(typedSearchAttributes ? { typedSearchAttributes } : {}),\n });\n const typed = this.createTypedHandle(handle, definition) as TypedWorkflowHandle<\n TContract[\"workflows\"][TWorkflowName]\n >;\n return ok({ ...typed, signaledRunId: handle.signaledRunId } as Ok);\n } catch (error) {\n return err(classifyStartError(\"signalWithStart\", error));\n }\n };\n return makeAsyncResult(work);\n }\n\n /**\n * Execute a workflow (start and wait for result) with AsyncResult pattern\n *\n * @example\n * ```ts\n * const result = await client.executeWorkflow('processOrder', {\n * workflowId: 'order-123',\n * args: { orderId: 'ORD-123' },\n * workflowExecutionTimeout: '1 day',\n * retry: { maximumAttempts: 3 },\n * });\n *\n * await result.match({\n * ok: (output) => console.log('Order processed:', output.status),\n * err: (error) => console.error('Processing failed:', error),\n * defect: (cause) => console.error('Unexpected failure:', cause),\n * });\n * ```\n */\n executeWorkflow<TWorkflowName extends keyof TContract[\"workflows\"] & string>(\n workflowName: TWorkflowName,\n {\n args,\n searchAttributes,\n ...temporalOptions\n }: TypedWorkflowStartOptions<TContract, TWorkflowName>,\n ): AsyncResult<\n ClientInferOutput<TContract[\"workflows\"][TWorkflowName]>,\n | WorkflowNotFoundError\n | WorkflowValidationError\n | WorkflowAlreadyStartedError\n | WorkflowFailedError\n | WorkflowExecutionNotFoundError\n | RuntimeClientError\n > {\n type Ok = ClientInferOutput<TContract[\"workflows\"][TWorkflowName]>;\n type Err =\n | WorkflowNotFoundError\n | WorkflowValidationError\n | WorkflowAlreadyStartedError\n | WorkflowFailedError\n | WorkflowExecutionNotFoundError\n | RuntimeClientError;\n const work = async (): Promise<Result<Ok, Err>> => {\n const resolved = await resolveDefinitionAndValidateInput(\n this.contract,\n workflowName,\n args,\n searchAttributes as Record<string, unknown> | undefined,\n );\n // The resolver only ever builds ok/err; assert away the impossible defect.\n assertNoDefect(resolved);\n if (resolved.isErr()) return err(resolved.error);\n const { definition, validatedInput, typedSearchAttributes } = resolved.value;\n\n try {\n const result = await this.client.workflow.execute(workflowName, {\n ...temporalOptions,\n taskQueue: this.contract.taskQueue,\n args: [validatedInput],\n ...(typedSearchAttributes ? { typedSearchAttributes } : {}),\n });\n\n // Output validation runs *after* the Temporal call returns — kept\n // inline because it's specific to executeWorkflow's start-and-wait\n // shape; the helper only handles pre-call concerns.\n const outputResult = await definition.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n return err(createWorkflowValidationError(workflowName, \"output\", outputResult.issues));\n }\n\n return ok(outputResult.value as Ok);\n } catch (error) {\n // executeWorkflow combines start + result, so it can surface any of\n // the discriminated kinds. Inline the three checks rather than\n // routing through a dedicated helper — this is the only call site\n // that needs the full union.\n if (error instanceof WorkflowExecutionAlreadyStartedError) {\n return err(new WorkflowAlreadyStartedError(error.workflowType, error.workflowId, error));\n }\n if (error instanceof TemporalWorkflowFailedError) {\n // Forward Temporal's nested cause directly — see\n // {@link classifyResultError} for the same rationale: Temporal's\n // `WorkflowFailedError` is a wrapper, and the actionable failure\n // (ApplicationFailure, CancelledFailure, etc.) lives on `.cause`.\n // Temporal types `cause` as `Error | undefined`, but the SDK only\n // ever populates it with a `TemporalFailure` subclass here; narrow\n // with the public union so the typed `cause` lines up with the\n // surfaced `WorkflowFailedError`.\n return err(\n new WorkflowFailedError(\n temporalOptions.workflowId,\n error.cause as TemporalFailure | undefined,\n ),\n );\n }\n if (error instanceof TemporalWorkflowNotFoundError) {\n return err(\n new WorkflowExecutionNotFoundError(\n error.workflowId || temporalOptions.workflowId,\n error.runId,\n error,\n ),\n );\n }\n return err(createRuntimeClientError(\"executeWorkflow\", error));\n }\n };\n return makeAsyncResult(work);\n }\n\n /**\n * Get a handle to an existing workflow with AsyncResult pattern\n *\n * @example\n * ```ts\n * const handleResult = await client.getHandle('processOrder', 'order-123');\n * handleResult.match(\n * async (handle) => {\n * const result = await handle.result();\n * // ... handle result\n * },\n * (error) => console.error('Failed to get handle:', error),\n * );\n * ```\n */\n getHandle<TWorkflowName extends keyof TContract[\"workflows\"] & string>(\n workflowName: TWorkflowName,\n workflowId: string,\n ): AsyncResult<\n TypedWorkflowHandle<TContract[\"workflows\"][TWorkflowName]>,\n WorkflowNotFoundError | RuntimeClientError\n > {\n type Ok = TypedWorkflowHandle<TContract[\"workflows\"][TWorkflowName]>;\n type Err = WorkflowNotFoundError | RuntimeClientError;\n const work = async (): Promise<Result<Ok, Err>> => {\n const definition = this.contract.workflows[workflowName];\n if (!definition) {\n return err(createWorkflowNotFoundError(workflowName, this.contract));\n }\n\n try {\n const handle = this.client.workflow.getHandle(workflowId);\n return ok(this.createTypedHandle(handle, definition) as Ok);\n } catch (error) {\n return err(createRuntimeClientError(\"getHandle\", error));\n }\n };\n return makeAsyncResult(work);\n }\n\n private createTypedHandle<TWorkflow extends AnyWorkflowDefinition>(\n workflowHandle: WorkflowHandle,\n definition: TWorkflow,\n ): TypedWorkflowHandle<TWorkflow> {\n const queries = buildValidatedProxy({\n defs: definition.queries,\n operation: \"query\",\n workflowId: workflowHandle.workflowId,\n makeValidationError: (name, direction, issues) =>\n new QueryValidationError(name, direction, issues),\n invoke: (name, validated) => workflowHandle.query(name, validated),\n validateOutput: (def) => def.output,\n }) as TypedWorkflowHandle<TWorkflow>[\"queries\"];\n\n const signals = buildValidatedProxy({\n defs: definition.signals,\n operation: \"signal\",\n workflowId: workflowHandle.workflowId,\n makeValidationError: (name, _direction, issues) => new SignalValidationError(name, issues),\n invoke: async (name, validated) => {\n await workflowHandle.signal(name, validated);\n return undefined;\n },\n validateOutput: () => null,\n }) as TypedWorkflowHandle<TWorkflow>[\"signals\"];\n\n const updates = buildValidatedProxy({\n defs: definition.updates,\n operation: \"update\",\n workflowId: workflowHandle.workflowId,\n makeValidationError: (name, direction, issues) =>\n new UpdateValidationError(name, direction, issues),\n invoke: (name, validated) => workflowHandle.executeUpdate(name, { args: [validated] }),\n validateOutput: (def) => def.output,\n }) as TypedWorkflowHandle<TWorkflow>[\"updates\"];\n\n return {\n workflowId: workflowHandle.workflowId,\n queries,\n signals,\n updates,\n result: (): AsyncResult<\n ClientInferOutput<TWorkflow>,\n | WorkflowValidationError\n | WorkflowFailedError\n | WorkflowExecutionNotFoundError\n | RuntimeClientError\n > => {\n type Ok = ClientInferOutput<TWorkflow>;\n type Err =\n | WorkflowValidationError\n | WorkflowFailedError\n | WorkflowExecutionNotFoundError\n | RuntimeClientError;\n const work = async (): Promise<Result<Ok, Err>> => {\n try {\n const result = await workflowHandle.result();\n const outputResult = await definition.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n return err(\n new WorkflowValidationError(\n workflowHandle.workflowId,\n \"output\",\n outputResult.issues,\n ),\n );\n }\n return ok(outputResult.value as Ok);\n } catch (error) {\n return err(classifyResultError(\"result\", error, workflowHandle.workflowId));\n }\n };\n return makeAsyncResult(work);\n },\n terminate: (\n reason?: string,\n ): AsyncResult<void, WorkflowExecutionNotFoundError | RuntimeClientError> =>\n fromPromise(workflowHandle.terminate(reason), (error) =>\n classifyHandleError(\"terminate\", error, workflowHandle.workflowId),\n ).map(() => undefined),\n cancel: (): AsyncResult<void, WorkflowExecutionNotFoundError | RuntimeClientError> =>\n fromPromise(workflowHandle.cancel(), (error) =>\n classifyHandleError(\"cancel\", error, workflowHandle.workflowId),\n ).map(() => undefined),\n describe: (): AsyncResult<\n Awaited<ReturnType<WorkflowHandle[\"describe\"]>>,\n WorkflowExecutionNotFoundError | RuntimeClientError\n > =>\n fromPromise(workflowHandle.describe(), (error) =>\n classifyHandleError(\"describe\", error, workflowHandle.workflowId),\n ),\n fetchHistory: (): AsyncResult<\n Awaited<ReturnType<WorkflowHandle[\"fetchHistory\"]>>,\n WorkflowExecutionNotFoundError | RuntimeClientError\n > =>\n fromPromise(workflowHandle.fetchHistory(), (error) =>\n classifyHandleError(\"fetchHistory\", error, workflowHandle.workflowId),\n ),\n };\n }\n}\n\nfunction createRuntimeClientError(operation: string, error: unknown): RuntimeClientError {\n return new RuntimeClientError(operation, error);\n}\n\nfunction createWorkflowNotFoundError(\n workflowName: string | number | symbol,\n contract: ContractDefinition,\n): WorkflowNotFoundError {\n return new WorkflowNotFoundError(String(workflowName), Object.keys(contract.workflows));\n}\n\nfunction createWorkflowValidationError(\n workflowName: string | number | symbol,\n direction: \"input\" | \"output\",\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n): WorkflowValidationError {\n return new WorkflowValidationError(String(workflowName), direction, issues);\n}\n\ntype DefWithInput = { readonly input: StandardSchemaV1 };\n\ntype ProxyOptions<TDef extends DefWithInput, TValidationError extends Error> = {\n readonly defs: Record<string, TDef> | undefined;\n readonly operation: string;\n /**\n * Workflow ID of the handle these proxies bind to. Used by\n * {@link classifyHandleError} to surface\n * {@link WorkflowExecutionNotFoundError} with the targeted ID even when\n * Temporal's error doesn't carry it.\n */\n readonly workflowId: string;\n readonly makeValidationError: (\n name: string,\n direction: \"input\" | \"output\",\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) => TValidationError;\n readonly invoke: (name: string, validatedInput: unknown) => Promise<unknown>;\n /**\n * Returns the schema to validate the invoke result against, or `null` to skip\n * output validation (used by signals, which don't return a value).\n */\n readonly validateOutput: (def: TDef) => StandardSchemaV1 | null;\n};\n\n/**\n * Build a `{ name: (args) => AsyncResult<...> }` proxy for a contract's\n * queries/signals/updates. The three call sites differ only in how they\n * invoke Temporal and whether they validate output, so the shared\n * input-validate → invoke → output-validate → wrap-Result pipeline lives\n * here once.\n */\nfunction buildValidatedProxy<TDef extends DefWithInput, TValidationError extends Error>({\n defs,\n operation,\n workflowId,\n makeValidationError,\n invoke,\n validateOutput,\n}: ProxyOptions<TDef, TValidationError>): Record<\n string,\n (\n args: unknown,\n ) => AsyncResult<unknown, TValidationError | WorkflowExecutionNotFoundError | RuntimeClientError>\n> {\n const proxy: Record<\n string,\n (\n args: unknown,\n ) => AsyncResult<\n unknown,\n TValidationError | WorkflowExecutionNotFoundError | RuntimeClientError\n >\n > = {};\n if (!defs) return proxy;\n\n for (const [name, def] of Object.entries(defs)) {\n proxy[name] = (args) => {\n const work = async (): Promise<\n Result<unknown, TValidationError | WorkflowExecutionNotFoundError | RuntimeClientError>\n > => {\n const inputResult = await def.input[\"~standard\"].validate(args);\n if (inputResult.issues) {\n return err(makeValidationError(name, \"input\", inputResult.issues));\n }\n\n try {\n const result = await invoke(name, inputResult.value);\n const outputSchema = validateOutput(def);\n if (!outputSchema) {\n return ok(result);\n }\n const outputResult = await outputSchema[\"~standard\"].validate(result);\n if (outputResult.issues) {\n return err(makeValidationError(name, \"output\", outputResult.issues));\n }\n return ok(outputResult.value);\n } catch (error) {\n return err(classifyHandleError(operation, error, workflowId));\n }\n };\n return makeAsyncResult(work);\n };\n }\n\n return proxy;\n}\n"],"mappings":";;;;;;;;;AAmCA,IAAa,qBAAb,cAAwC,YAAY,yCAAyC,EAC3F,MAAM,qBACR,CAAC,CAAC,CAIC;CACD,YAAY,WAAmB,OAAiB;EAC9C,MAAM;GACJ;GACA;GACA,SAAS,cAAc,UAAU,YAC/B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,SAAS,eAAe;EAE5E,CAAC;CAEH;AACF;;;;AAKA,IAAa,wBAAb,cAA2C,YAAY,4CAA4C,EACjG,MAAM,wBACR,CAAC,CAAC,CAIC;CACD,YAAY,cAAsB,oBAA8B;EAC9D,MAAM;GACJ;GACA;GACA,SAAS,aAAa,aAAa,gDAAgD,mBAAmB,KAAK,IAAI;EACjH,CAAC;CACH;AACF;;;;;;;;;;;;AAaA,IAAa,8BAAb,cAAiD,YAC/C,kDACA,EAAE,MAAM,8BAA8B,CACxC,CAAC,CAKE;CACD,YAAY,cAAsB,YAAoB,OAAiB;EACrE,MAAM;GACJ;GACA;GACA;GACA,SAAS,aAAa,aAAa,aAAa,WAAW;EAC7D,CAAC;CACH;AACF;;;;;;;;;;;;;AAcA,IAAa,iCAAb,cAAoD,YAClD,qDACA,EAAE,MAAM,iCAAiC,CAC3C,CAAC,CAKE;CACD,YAAY,YAAoB,OAAgB,OAAiB;EAC/D,MAAM;GACJ;GACA;GACA;GACA,SAAS,uBAAuB,WAAW,GAAG,QAAQ,UAAU,MAAM,MAAM,GAAG;EACjF,CAAC;CACH;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,sBAAb,cAAyC,YAAY,0CAA0C,EAC7F,MAAM,sBACR,CAAC,CAAC,CAIC;CACD,YAAY,YAAoB,OAAyB;EACvD,MAAM,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,OAAO;CAElB,KAAK,MAAM,CAAC,MAAM,QAAQ,OAAO,QAAQ,IAAI,GAC3C,MAAM,SAAS,SAAS;EACtB,MAAM,OAAO,YAER;GACH,MAAM,cAAc,MAAM,IAAI,MAAM,YAAY,CAAC,SAAS,IAAI;GAC9D,IAAI,YAAY,QACd,OAAO,IAAI,oBAAoB,MAAM,SAAS,YAAY,MAAM,CAAC;GAGnE,IAAI;IACF,MAAM,SAAS,MAAM,OAAO,MAAM,YAAY,KAAK;IACnD,MAAM,eAAe,eAAe,GAAG;IACvC,IAAI,CAAC,cACH,OAAO,GAAG,MAAM;IAElB,MAAM,eAAe,MAAM,aAAa,YAAY,CAAC,SAAS,MAAM;IACpE,IAAI,aAAa,QACf,OAAO,IAAI,oBAAoB,MAAM,UAAU,aAAa,MAAM,CAAC;IAErE,OAAO,GAAG,aAAa,KAAK;GAC9B,SAAS,OAAO;IACd,OAAO,IAAI,oBAAoB,WAAW,OAAO,UAAU,CAAC;GAC9D;EACF;EACA,OAAO,gBAAgB,IAAI;CAC7B;CAGF,OAAO;AACT"}
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@temporal-contract/client",
3
- "version": "2.3.1",
4
- "description": "Client utilities with neverthrow Result/ResultAsync for consuming temporal-contract workflows",
3
+ "version": "3.0.0",
4
+ "description": "Client utilities with unthrown Result/AsyncResult for consuming temporal-contract workflows",
5
5
  "keywords": [
6
6
  "client",
7
7
  "contract",
8
- "neverthrow",
9
8
  "result",
10
9
  "temporal",
11
- "typescript"
10
+ "typescript",
11
+ "unthrown"
12
12
  ],
13
- "homepage": "https://github.com/btravers/temporal-contract#readme",
13
+ "homepage": "https://github.com/btravstack/temporal-contract#readme",
14
14
  "bugs": {
15
- "url": "https://github.com/btravers/temporal-contract/issues"
15
+ "url": "https://github.com/btravstack/temporal-contract/issues"
16
16
  },
17
17
  "license": "MIT",
18
18
  "author": "Benoit TRAVERS <benoit.travers.fr@gmail.com>",
19
19
  "repository": {
20
20
  "type": "git",
21
- "url": "https://github.com/btravers/temporal-contract.git",
21
+ "url": "https://github.com/btravstack/temporal-contract.git",
22
22
  "directory": "packages/client"
23
23
  },
24
24
  "files": [
@@ -43,30 +43,34 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@standard-schema/spec": "1.1.0",
46
- "@temporal-contract/contract": "2.3.1"
46
+ "@temporal-contract/contract": "3.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@temporalio/client": "1.18.0",
50
- "@temporalio/common": "1.18.0",
51
- "@temporalio/worker": "1.18.0",
52
- "@temporalio/workflow": "1.18.0",
53
- "@types/node": "24.13.1",
49
+ "@temporalio/client": "1.18.1",
50
+ "@temporalio/common": "1.18.1",
51
+ "@temporalio/worker": "1.18.1",
52
+ "@temporalio/workflow": "1.18.1",
53
+ "@types/node": "24.13.2",
54
+ "@unthrown/vitest": "0.2.0",
54
55
  "@vitest/coverage-v8": "4.1.8",
55
- "neverthrow": "8.2.0",
56
- "tsdown": "0.22.2",
56
+ "tsdown": "0.22.3",
57
57
  "typedoc": "0.28.19",
58
58
  "typedoc-plugin-markdown": "4.12.0",
59
59
  "typescript": "6.0.3",
60
+ "unthrown": "0.2.0",
60
61
  "vitest": "4.1.8",
61
62
  "zod": "4.4.3",
62
- "@temporal-contract/testing": "2.3.1",
63
- "@temporal-contract/typedoc": "0.1.0",
64
- "@temporal-contract/tsconfig": "1.0.0"
63
+ "@temporal-contract/testing": "3.0.0",
64
+ "@temporal-contract/tsconfig": "1.0.0",
65
+ "@temporal-contract/typedoc": "0.1.0"
65
66
  },
66
67
  "peerDependencies": {
67
68
  "@temporalio/client": "^1",
68
69
  "@temporalio/common": "^1",
69
- "neverthrow": "^8"
70
+ "unthrown": "^0.2"
71
+ },
72
+ "engines": {
73
+ "node": ">=22.19.0"
70
74
  },
71
75
  "scripts": {
72
76
  "build": "tsdown src/index.ts --format cjs,esm --dts --clean",