@temporal-contract/client 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -154,6 +154,37 @@ var UpdateValidationError = class extends TypedClientError {
154
154
  * In-package modules and tests import it directly via relative path.
155
155
  */
156
156
  /**
157
+ * Translate the contract's typed `searchAttributes` map (declared
158
+ * name → value) into a Temporal `TypedSearchAttributes` instance, so the
159
+ * Temporal client honours indexing when starting the workflow.
160
+ *
161
+ * Workflows without a `searchAttributes` block (or callers passing no
162
+ * values) resolve to `ok(undefined)`, matching the Temporal SDK's
163
+ * "absent ≠ empty" semantics.
164
+ *
165
+ * Returns `err(RuntimeClientError)` on unknown keys. The TypeScript
166
+ * surface already gates the happy path; the runtime check catches typed
167
+ * escape hatches (`as never`, `as any`, raw-call interop) where a typo
168
+ * would otherwise silently drop the attribute, leaving the workflow
169
+ * unindexed without any signal to the caller.
170
+ */
171
+ function toTypedSearchAttributes(workflowDef, workflowName, values) {
172
+ if (!values) return (0, neverthrow.ok)(void 0);
173
+ const declared = workflowDef.searchAttributes ?? {};
174
+ const pairs = [];
175
+ for (const [name, value] of Object.entries(values)) {
176
+ if (value === void 0) continue;
177
+ const def = declared[name];
178
+ if (!def) return (0, neverthrow.err)(new RuntimeClientError("searchAttributes", /* @__PURE__ */ new Error(`Search attribute "${name}" is not declared on workflow "${workflowName}". Declared attributes: ${Object.keys(declared).join(", ") || "none"}.`)));
179
+ const key = (0, _temporalio_common.defineSearchAttributeKey)(name, def.kind);
180
+ pairs.push({
181
+ key,
182
+ value
183
+ });
184
+ }
185
+ return (0, neverthrow.ok)(pairs.length > 0 ? new _temporalio_common.TypedSearchAttributes(pairs) : void 0);
186
+ }
187
+ /**
157
188
  * Wrap an async result-producing function in a `ResultAsync`, catching any
158
189
  * unhandled rejection as a `RuntimeClientError("unexpected", error)`.
159
190
  *
@@ -240,6 +271,9 @@ var TypedScheduleClient = class {
240
271
  if (!definition) return (0, neverthrow.err)(new WorkflowNotFoundError(workflowName, Object.keys(this.contract.workflows)));
241
272
  const inputResult = await definition.input["~standard"].validate(options.args);
242
273
  if (inputResult.issues) return (0, neverthrow.err)(new WorkflowValidationError(workflowName, "input", inputResult.issues));
274
+ const searchAttributesResult = toTypedSearchAttributes(definition, workflowName, options.searchAttributes);
275
+ if (searchAttributesResult.isErr()) return (0, neverthrow.err)(searchAttributesResult.error);
276
+ const typedSearchAttributes = searchAttributesResult.value;
243
277
  try {
244
278
  const overrides = options.action ?? {};
245
279
  const action = {
@@ -247,6 +281,7 @@ var TypedScheduleClient = class {
247
281
  workflowType: workflowName,
248
282
  taskQueue: this.contract.taskQueue,
249
283
  args: [inputResult.value],
284
+ ...typedSearchAttributes ? { typedSearchAttributes } : {},
250
285
  ...overrides.workflowId !== void 0 ? { workflowId: overrides.workflowId } : {},
251
286
  ...overrides.workflowExecutionTimeout !== void 0 ? { workflowExecutionTimeout: overrides.workflowExecutionTimeout } : {},
252
287
  ...overrides.workflowRunTimeout !== void 0 ? { workflowRunTimeout: overrides.workflowRunTimeout } : {},
@@ -292,28 +327,44 @@ function wrapScheduleHandle(handle) {
292
327
  //#endregion
293
328
  //#region src/client.ts
294
329
  /**
295
- * Translate the contract's typed `searchAttributes` map (declared
296
- * name value) into a Temporal `TypedSearchAttributes` instance, so the
297
- * Temporal client honours indexing when starting the workflow.
330
+ * Read declared search attributes off a `TypedSearchAttributes` instance
331
+ * the read-side counterpart to the write-side `searchAttributes` option on
332
+ * `startWorkflow` / `signalWithStart` / `executeWorkflow` /
333
+ * `schedule.create`.
298
334
  *
299
- * Workflows without a `searchAttributes` block (or callers passing no
300
- * values) skip the conversion entirely and return `undefined`, matching
301
- * the Temporal SDK's "absent empty" semantics.
335
+ * Use it on the result of `handle.describe()` (or a schedule's describe) to
336
+ * recover the typed shape of indexed attributes. The Temporal SDK only
337
+ * exposes a `.get(key)` accessor on `TypedSearchAttributes` and requires
338
+ * the caller to reconstruct each `SearchAttributeKey` from the contract's
339
+ * declared `kind` — this helper does that lookup once for every declared
340
+ * attribute, returning a `Partial<TypedSearchAttributeMap<TWorkflow>>`
341
+ * (each declared key may or may not have been set on the workflow).
342
+ *
343
+ * Workflows without declared `searchAttributes` get an empty object back.
344
+ *
345
+ * @example
346
+ * ```ts
347
+ * const description = await handle.describe();
348
+ * if (description.isOk()) {
349
+ * const attrs = readTypedSearchAttributes(
350
+ * myContract.workflows.processOrder,
351
+ * description.value.typedSearchAttributes,
352
+ * );
353
+ * // attrs.customerId: string | undefined
354
+ * // attrs.priority: number | undefined
355
+ * }
356
+ * ```
302
357
  */
303
- function toTypedSearchAttributes(workflowDef, values) {
304
- if (!values || !workflowDef.searchAttributes) return void 0;
305
- const pairs = [];
306
- for (const [name, value] of Object.entries(values)) {
307
- if (value === void 0) continue;
308
- const def = workflowDef.searchAttributes[name];
309
- if (!def) continue;
358
+ function readTypedSearchAttributes(workflowDef, instance) {
359
+ const declared = workflowDef.searchAttributes;
360
+ if (!declared) return {};
361
+ const result = {};
362
+ for (const [name, def] of Object.entries(declared)) {
310
363
  const key = (0, _temporalio_common.defineSearchAttributeKey)(name, def.kind);
311
- pairs.push({
312
- key,
313
- value
314
- });
364
+ const value = instance.get(key);
365
+ if (value !== void 0) result[name] = value;
315
366
  }
316
- return pairs.length > 0 ? new _temporalio_common.TypedSearchAttributes(pairs) : void 0;
367
+ return result;
317
368
  }
318
369
  /**
319
370
  * Shared pre-call ritual for the three contract-driven entry points that
@@ -338,7 +389,9 @@ async function resolveDefinitionAndValidateInput(contract, workflowName, args, s
338
389
  if (!definition) return (0, neverthrow.err)(createWorkflowNotFoundError(workflowName, contract));
339
390
  const inputResult = await definition.input["~standard"].validate(args);
340
391
  if (inputResult.issues) return (0, neverthrow.err)(createWorkflowValidationError(workflowName, "input", inputResult.issues));
341
- const typedSearchAttributes = toTypedSearchAttributes(definition, searchAttributes);
392
+ const searchAttributesResult = toTypedSearchAttributes(definition, workflowName, searchAttributes);
393
+ if (searchAttributesResult.isErr()) return (0, neverthrow.err)(searchAttributesResult.error);
394
+ const typedSearchAttributes = searchAttributesResult.value;
342
395
  return (0, neverthrow.ok)({
343
396
  definition,
344
397
  validatedInput: inputResult.value,
@@ -672,3 +725,4 @@ exports.WorkflowExecutionNotFoundError = WorkflowExecutionNotFoundError;
672
725
  exports.WorkflowFailedError = WorkflowFailedError;
673
726
  exports.WorkflowNotFoundError = WorkflowNotFoundError;
674
727
  exports.WorkflowValidationError = WorkflowValidationError;
728
+ exports.readTypedSearchAttributes = readTypedSearchAttributes;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Client, ScheduleClient, ScheduleDescription, ScheduleOptions, ScheduleOptionsStartWorkflowAction, ScheduleOverlapPolicy, ScheduleSpec, WorkflowHandle, WorkflowSignalWithStartOptions, WorkflowStartOptions } from "@temporalio/client";
2
+ import { ActivityFailure, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, ServerFailure, TerminatedFailure, TimeoutFailure, TypedSearchAttributes } from "@temporalio/common";
2
3
  import { ActivityDefinition, AnySchema, AnyWorkflowDefinition, ContractDefinition, QueryDefinition, SearchAttributeDefinition, SearchAttributeKindToType, SignalDefinition, SignalNamesOf, UpdateDefinition } from "@temporal-contract/contract";
3
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
4
5
  import { ResultAsync } from "neverthrow";
5
- import { ActivityFailure, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, ServerFailure, TerminatedFailure, TimeoutFailure } from "@temporalio/common";
6
6
 
7
7
  //#region src/types.d.ts
8
8
  /**
@@ -234,7 +234,16 @@ type TypedScheduleActionOverrides = Pick<ScheduleOptionsStartWorkflowAction<neve
234
234
  type TypedScheduleCreateOptions<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"] & string> = {
235
235
  /** Schedule ID. Recommended to use a meaningful business identifier. */scheduleId: string; /** When the schedule should fire (cron, interval, calendar). */
236
236
  spec: ScheduleSpec; /** Workflow input — validated against the contract's input schema. */
237
- args: ClientInferInput<TContract["workflows"][TWorkflowName]>; /** Temporal schedule policies (overlap, catchupWindow, pauseOnFailure, etc.). */
237
+ args: ClientInferInput<TContract["workflows"][TWorkflowName]>;
238
+ /**
239
+ * Indexed search attributes for each workflow run spawned by this
240
+ * schedule. Keys and value types are constrained to those declared on
241
+ * the destination workflow's contract via `defineSearchAttribute`.
242
+ * Translated to Temporal's `typedSearchAttributes` and attached to the
243
+ * schedule's `startWorkflow` action so each spawned run is indexed
244
+ * identically to one started directly via `client.startWorkflow`.
245
+ */
246
+ searchAttributes?: TypedSearchAttributeMap<TContract["workflows"][TWorkflowName]>; /** Temporal schedule policies (overlap, catchupWindow, pauseOnFailure, etc.). */
238
247
  policies?: ScheduleOptions["policies"]; /** Temporal schedule state (paused, note, limited, etc.). */
239
248
  state?: ScheduleOptions["state"]; /** Schedule-level memo (non-indexed metadata on the schedule itself). */
240
249
  memo?: ScheduleOptions["memo"];
@@ -301,6 +310,36 @@ declare class TypedScheduleClient<TContract extends ContractDefinition> {
301
310
  * options for that workflow.
302
311
  */
303
312
  type TypedSearchAttributeMap<TWorkflow extends AnyWorkflowDefinition> = TWorkflow["searchAttributes"] extends Record<string, SearchAttributeDefinition> ? { [K in keyof TWorkflow["searchAttributes"]]?: SearchAttributeKindToType<TWorkflow["searchAttributes"][K]["kind"]> } : never;
313
+ /**
314
+ * Read declared search attributes off a `TypedSearchAttributes` instance —
315
+ * the read-side counterpart to the write-side `searchAttributes` option on
316
+ * `startWorkflow` / `signalWithStart` / `executeWorkflow` /
317
+ * `schedule.create`.
318
+ *
319
+ * Use it on the result of `handle.describe()` (or a schedule's describe) to
320
+ * recover the typed shape of indexed attributes. The Temporal SDK only
321
+ * exposes a `.get(key)` accessor on `TypedSearchAttributes` and requires
322
+ * the caller to reconstruct each `SearchAttributeKey` from the contract's
323
+ * declared `kind` — this helper does that lookup once for every declared
324
+ * attribute, returning a `Partial<TypedSearchAttributeMap<TWorkflow>>`
325
+ * (each declared key may or may not have been set on the workflow).
326
+ *
327
+ * Workflows without declared `searchAttributes` get an empty object back.
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * const description = await handle.describe();
332
+ * if (description.isOk()) {
333
+ * const attrs = readTypedSearchAttributes(
334
+ * myContract.workflows.processOrder,
335
+ * description.value.typedSearchAttributes,
336
+ * );
337
+ * // attrs.customerId: string | undefined
338
+ * // attrs.priority: number | undefined
339
+ * }
340
+ * ```
341
+ */
342
+ declare function readTypedSearchAttributes<TWorkflow extends AnyWorkflowDefinition>(workflowDef: TWorkflow, instance: TypedSearchAttributes): Partial<TypedSearchAttributeMap<TWorkflow>>;
304
343
  type TypedWorkflowStartOptions<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"] & string> = Omit<WorkflowStartOptions, "taskQueue" | "args" | "searchAttributes" | "typedSearchAttributes"> & {
305
344
  args: ClientInferInput<TContract["workflows"][TWorkflowName]>;
306
345
  /**
@@ -538,5 +577,5 @@ declare class TypedClient<TContract extends ContractDefinition> {
538
577
  private createTypedHandle;
539
578
  }
540
579
  //#endregion
541
- export { type ClientInferActivities, type ClientInferActivity, type ClientInferInput, type ClientInferOutput, type ClientInferQuery, type ClientInferSignal, type ClientInferUpdate, type ClientInferWorkflow, type ClientInferWorkflowActivities, type ClientInferWorkflowContextActivities, type ClientInferWorkflowQueries, type ClientInferWorkflowSignals, type ClientInferWorkflowUpdates, type ClientInferWorkflows, QueryValidationError, RuntimeClientError, SignalValidationError, type TemporalFailure, TypedClient, type TypedScheduleActionOverrides, TypedScheduleClient, type TypedScheduleCreateOptions, type TypedScheduleHandle, type TypedSignalWithStartOptions, type TypedWorkflowHandle, type TypedWorkflowHandleWithSignaledRunId, type TypedWorkflowStartOptions, UpdateValidationError, WorkflowAlreadyStartedError, WorkflowExecutionNotFoundError, WorkflowFailedError, WorkflowNotFoundError, WorkflowValidationError };
580
+ export { type ClientInferActivities, type ClientInferActivity, type ClientInferInput, type ClientInferOutput, type ClientInferQuery, type ClientInferSignal, type ClientInferUpdate, type ClientInferWorkflow, type ClientInferWorkflowActivities, type ClientInferWorkflowContextActivities, type ClientInferWorkflowQueries, type ClientInferWorkflowSignals, type ClientInferWorkflowUpdates, type ClientInferWorkflows, QueryValidationError, RuntimeClientError, SignalValidationError, type TemporalFailure, TypedClient, type TypedScheduleActionOverrides, TypedScheduleClient, type TypedScheduleCreateOptions, type TypedScheduleHandle, type TypedSearchAttributeMap, type TypedSignalWithStartOptions, type TypedWorkflowHandle, type TypedWorkflowHandleWithSignaledRunId, type TypedWorkflowStartOptions, UpdateValidationError, WorkflowAlreadyStartedError, WorkflowExecutionNotFoundError, WorkflowFailedError, WorkflowNotFoundError, WorkflowValidationError, readTypedSearchAttributes };
542
581
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/errors.ts","../src/schedule.ts","../src/client.ts"],"mappings":";;;;;;;;;;;KAgBY,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAChF,CAAA;;;;;;;AADF;;KAaY,mBAAA,mBAAsC,qBAAA,KAChD,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;;;;;KAMnB,mBAAA,mBAAsC,kBAAA,KAChD,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;;;;;KAMnB,iBAAA,iBAAkC,gBAAA,KAC5C,IAAA,EAAM,gBAAA,CAAiB,OAAA,MACpB,WAAA,OAAkB,KAAA;;;;AAlBvB;KAwBY,gBAAA,gBAAgC,eAAA,KAC1C,IAAA,EAAM,gBAAA,CAAiB,MAAA,MACpB,WAAA,CAAY,iBAAA,CAAkB,MAAA,GAAS,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,IAAA;IACA,gBAAA;IAAA,GACG;EAAA,GACF,yBAAA,CAA0B,SAAA,EAAW,aAAA,IACvC,WAAA,CACD,mBAAA,CAAoB,SAAA,cAAuB,aAAA,IACzC,qBAAA,GACA,uBAAA,GACA,2BAAA,GACA,kBAAA;EH5UwC;;;;;AAO9C;;;;;;;;;;;;;;;;;;;;;EGgYE,eAAA,6BAC8B,SAAA,4CACR,aAAA,CAAc,SAAA,cAAuB,aAAA,GAAA,CAEzD,YAAA,EAAc,aAAA;IAEZ,IAAA;IACA,UAAA;IACA,UAAA;IACA,gBAAA;IAAA,GACG;EAAA,GACF,2BAAA,CAA4B,SAAA,EAAW,aAAA,EAAe,WAAA,IACxD,WAAA,CACD,oCAAA,CAAqC,SAAA,cAAuB,aAAA,IAC1D,qBAAA,GACA,uBAAA,GACA,qBAAA,GACA,2BAAA,GACA,kBAAA;EH/YoE;;;AAO1E;;;;;;;;;;;;;;;EGsdE,eAAA,6BAA4C,SAAA,uBAAA,CAC1C,YAAA,EAAc,aAAA;IAEZ,IAAA;IACA,gBAAA;IAAA,GACG;EAAA,GACF,yBAAA,CAA0B,SAAA,EAAW,aAAA,IACvC,WAAA,CACD,iBAAA,CAAkB,SAAA,cAAuB,aAAA,IACvC,qBAAA,GACA,uBAAA,GACA,2BAAA,GACA,mBAAA,GACA,8BAAA,GACA,kBAAA;EHneiB;;;;;;;;;AASvB;;;;;;EGqjBE,SAAA,6BAAsC,SAAA,uBAAA,CACpC,YAAA,EAAc,aAAA,EACd,UAAA,WACC,WAAA,CACD,mBAAA,CAAoB,SAAA,cAAuB,aAAA,IAC3C,qBAAA,GAAwB,kBAAA;EAAA,QAoBlB,iBAAA;AAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/errors.ts","../src/schedule.ts","../src/client.ts"],"mappings":";;;;;;;;;;;KAgBY,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAC9E,CAAA;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oCAAA,CAAqC,SAAA,cAAuB,aAAA,IAC1D,qBAAA,GACA,uBAAA,GACA,qBAAA,GACA,2BAAA,GACA,kBAAA;EHzZ2C;;;;;;;;;;;;;;;;;;EGue/C,eAAA,6BAA4C,SAAA,uBAAA,CAC1C,YAAA,EAAc,aAAA;IAEZ,IAAA;IACA,gBAAA;IAAA,GACG;EAAA,GACF,yBAAA,CAA0B,SAAA,EAAW,aAAA,IACvC,WAAA,CACD,iBAAA,CAAkB,SAAA,cAAuB,aAAA,IACvC,qBAAA,GACA,uBAAA,GACA,2BAAA,GACA,mBAAA,GACA,8BAAA,GACA,kBAAA;EHlf2D;;;AAOjE;;;;;;;;;;;;EGskBE,SAAA,6BAAsC,SAAA,uBAAA,CACpC,YAAA,EAAc,aAAA,EACd,UAAA,WACC,WAAA,CACD,mBAAA,CAAoB,SAAA,cAAuB,aAAA,IAC3C,qBAAA,GAAwB,kBAAA;EAAA,QAoBlB,iBAAA;AAAA"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ActivityFailure, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, ServerFailure, TerminatedFailure, TimeoutFailure } from "@temporalio/common";
1
+ import { ActivityFailure, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, ServerFailure, TerminatedFailure, TimeoutFailure, TypedSearchAttributes } from "@temporalio/common";
2
2
  import { ResultAsync } from "neverthrow";
3
3
  import { ActivityDefinition, AnySchema, AnyWorkflowDefinition, ContractDefinition, QueryDefinition, SearchAttributeDefinition, SearchAttributeKindToType, SignalDefinition, SignalNamesOf, UpdateDefinition } from "@temporal-contract/contract";
4
4
  import { Client, ScheduleClient, ScheduleDescription, ScheduleOptions, ScheduleOptionsStartWorkflowAction, ScheduleOverlapPolicy, ScheduleSpec, WorkflowHandle, WorkflowSignalWithStartOptions, WorkflowStartOptions } from "@temporalio/client";
@@ -234,7 +234,16 @@ type TypedScheduleActionOverrides = Pick<ScheduleOptionsStartWorkflowAction<neve
234
234
  type TypedScheduleCreateOptions<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"] & string> = {
235
235
  /** Schedule ID. Recommended to use a meaningful business identifier. */scheduleId: string; /** When the schedule should fire (cron, interval, calendar). */
236
236
  spec: ScheduleSpec; /** Workflow input — validated against the contract's input schema. */
237
- args: ClientInferInput<TContract["workflows"][TWorkflowName]>; /** Temporal schedule policies (overlap, catchupWindow, pauseOnFailure, etc.). */
237
+ args: ClientInferInput<TContract["workflows"][TWorkflowName]>;
238
+ /**
239
+ * Indexed search attributes for each workflow run spawned by this
240
+ * schedule. Keys and value types are constrained to those declared on
241
+ * the destination workflow's contract via `defineSearchAttribute`.
242
+ * Translated to Temporal's `typedSearchAttributes` and attached to the
243
+ * schedule's `startWorkflow` action so each spawned run is indexed
244
+ * identically to one started directly via `client.startWorkflow`.
245
+ */
246
+ searchAttributes?: TypedSearchAttributeMap<TContract["workflows"][TWorkflowName]>; /** Temporal schedule policies (overlap, catchupWindow, pauseOnFailure, etc.). */
238
247
  policies?: ScheduleOptions["policies"]; /** Temporal schedule state (paused, note, limited, etc.). */
239
248
  state?: ScheduleOptions["state"]; /** Schedule-level memo (non-indexed metadata on the schedule itself). */
240
249
  memo?: ScheduleOptions["memo"];
@@ -301,6 +310,36 @@ declare class TypedScheduleClient<TContract extends ContractDefinition> {
301
310
  * options for that workflow.
302
311
  */
303
312
  type TypedSearchAttributeMap<TWorkflow extends AnyWorkflowDefinition> = TWorkflow["searchAttributes"] extends Record<string, SearchAttributeDefinition> ? { [K in keyof TWorkflow["searchAttributes"]]?: SearchAttributeKindToType<TWorkflow["searchAttributes"][K]["kind"]> } : never;
313
+ /**
314
+ * Read declared search attributes off a `TypedSearchAttributes` instance —
315
+ * the read-side counterpart to the write-side `searchAttributes` option on
316
+ * `startWorkflow` / `signalWithStart` / `executeWorkflow` /
317
+ * `schedule.create`.
318
+ *
319
+ * Use it on the result of `handle.describe()` (or a schedule's describe) to
320
+ * recover the typed shape of indexed attributes. The Temporal SDK only
321
+ * exposes a `.get(key)` accessor on `TypedSearchAttributes` and requires
322
+ * the caller to reconstruct each `SearchAttributeKey` from the contract's
323
+ * declared `kind` — this helper does that lookup once for every declared
324
+ * attribute, returning a `Partial<TypedSearchAttributeMap<TWorkflow>>`
325
+ * (each declared key may or may not have been set on the workflow).
326
+ *
327
+ * Workflows without declared `searchAttributes` get an empty object back.
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * const description = await handle.describe();
332
+ * if (description.isOk()) {
333
+ * const attrs = readTypedSearchAttributes(
334
+ * myContract.workflows.processOrder,
335
+ * description.value.typedSearchAttributes,
336
+ * );
337
+ * // attrs.customerId: string | undefined
338
+ * // attrs.priority: number | undefined
339
+ * }
340
+ * ```
341
+ */
342
+ declare function readTypedSearchAttributes<TWorkflow extends AnyWorkflowDefinition>(workflowDef: TWorkflow, instance: TypedSearchAttributes): Partial<TypedSearchAttributeMap<TWorkflow>>;
304
343
  type TypedWorkflowStartOptions<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"] & string> = Omit<WorkflowStartOptions, "taskQueue" | "args" | "searchAttributes" | "typedSearchAttributes"> & {
305
344
  args: ClientInferInput<TContract["workflows"][TWorkflowName]>;
306
345
  /**
@@ -538,5 +577,5 @@ declare class TypedClient<TContract extends ContractDefinition> {
538
577
  private createTypedHandle;
539
578
  }
540
579
  //#endregion
541
- export { type ClientInferActivities, type ClientInferActivity, type ClientInferInput, type ClientInferOutput, type ClientInferQuery, type ClientInferSignal, type ClientInferUpdate, type ClientInferWorkflow, type ClientInferWorkflowActivities, type ClientInferWorkflowContextActivities, type ClientInferWorkflowQueries, type ClientInferWorkflowSignals, type ClientInferWorkflowUpdates, type ClientInferWorkflows, QueryValidationError, RuntimeClientError, SignalValidationError, type TemporalFailure, TypedClient, type TypedScheduleActionOverrides, TypedScheduleClient, type TypedScheduleCreateOptions, type TypedScheduleHandle, type TypedSignalWithStartOptions, type TypedWorkflowHandle, type TypedWorkflowHandleWithSignaledRunId, type TypedWorkflowStartOptions, UpdateValidationError, WorkflowAlreadyStartedError, WorkflowExecutionNotFoundError, WorkflowFailedError, WorkflowNotFoundError, WorkflowValidationError };
580
+ export { type ClientInferActivities, type ClientInferActivity, type ClientInferInput, type ClientInferOutput, type ClientInferQuery, type ClientInferSignal, type ClientInferUpdate, type ClientInferWorkflow, type ClientInferWorkflowActivities, type ClientInferWorkflowContextActivities, type ClientInferWorkflowQueries, type ClientInferWorkflowSignals, type ClientInferWorkflowUpdates, type ClientInferWorkflows, QueryValidationError, RuntimeClientError, SignalValidationError, type TemporalFailure, TypedClient, type TypedScheduleActionOverrides, TypedScheduleClient, type TypedScheduleCreateOptions, type TypedScheduleHandle, type TypedSearchAttributeMap, type TypedSignalWithStartOptions, type TypedWorkflowHandle, type TypedWorkflowHandleWithSignaledRunId, type TypedWorkflowStartOptions, UpdateValidationError, WorkflowAlreadyStartedError, WorkflowExecutionNotFoundError, WorkflowFailedError, WorkflowNotFoundError, WorkflowValidationError, readTypedSearchAttributes };
542
581
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/errors.ts","../src/schedule.ts","../src/client.ts"],"mappings":";;;;;;;;;;;KAgBY,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAChF,CAAA;;;;;;;AADF;;KAaY,mBAAA,mBAAsC,qBAAA,KAChD,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;;;;;KAMnB,mBAAA,mBAAsC,kBAAA,KAChD,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;;;;;KAMnB,iBAAA,iBAAkC,gBAAA,KAC5C,IAAA,EAAM,gBAA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AAA,GAAA,CAEzD,YAAA,EAAc,aAAA;IAEZ,IAAA;IACA,UAAA;IACA,UAAA;IACA,gBAAA;IAAA,GACG;EAAA,GACF,2BAAA,CAA4B,SAAA,EAAW,aAAA,EAAe,WAAA,IACxD,WAAA,CACD,oCAAA,CAAqC,SAAA,cAAuB,aAAA,IAC1D,qBAAA,GACA,uBAAA,GACA,qBAAA,GACA,2BAAA,GACA,kBAAA;EHzZ2C;;;;;;;;;;;;;;;;;;EGue/C,eAAA,6BAA4C,SAAA,uBAAA,CAC1C,YAAA,EAAc,aAAA;IAEZ,IAAA;IACA,gBAAA;IAAA,GACG;EAAA,GACF,yBAAA,CAA0B,SAAA,EAAW,aAAA,IACvC,WAAA,CACD,iBAAA,CAAkB,SAAA,cAAuB,aAAA,IACvC,qBAAA,GACA,uBAAA,GACA,2BAAA,GACA,mBAAA,GACA,8BAAA,GACA,kBAAA;EHlf2D;;;AAOjE;;;;;;;;;;;;EGskBE,SAAA,6BAAsC,SAAA,uBAAA,CACpC,YAAA,EAAc,aAAA,EACd,UAAA,WACC,WAAA,CACD,mBAAA,CAAoB,SAAA,cAAuB,aAAA,IAC3C,qBAAA,GAAwB,kBAAA;EAAA,QAoBlB,iBAAA;AAAA"}
package/dist/index.mjs CHANGED
@@ -153,6 +153,37 @@ var UpdateValidationError = class extends TypedClientError {
153
153
  * In-package modules and tests import it directly via relative path.
154
154
  */
155
155
  /**
156
+ * Translate the contract's typed `searchAttributes` map (declared
157
+ * name → value) into a Temporal `TypedSearchAttributes` instance, so the
158
+ * Temporal client honours indexing when starting the workflow.
159
+ *
160
+ * Workflows without a `searchAttributes` block (or callers passing no
161
+ * values) resolve to `ok(undefined)`, matching the Temporal SDK's
162
+ * "absent ≠ empty" semantics.
163
+ *
164
+ * Returns `err(RuntimeClientError)` on unknown keys. The TypeScript
165
+ * surface already gates the happy path; the runtime check catches typed
166
+ * escape hatches (`as never`, `as any`, raw-call interop) where a typo
167
+ * would otherwise silently drop the attribute, leaving the workflow
168
+ * unindexed without any signal to the caller.
169
+ */
170
+ function toTypedSearchAttributes(workflowDef, workflowName, values) {
171
+ if (!values) return ok(void 0);
172
+ const declared = workflowDef.searchAttributes ?? {};
173
+ const pairs = [];
174
+ for (const [name, value] of Object.entries(values)) {
175
+ if (value === void 0) continue;
176
+ const def = declared[name];
177
+ if (!def) return err(new RuntimeClientError("searchAttributes", /* @__PURE__ */ new Error(`Search attribute "${name}" is not declared on workflow "${workflowName}". Declared attributes: ${Object.keys(declared).join(", ") || "none"}.`)));
178
+ const key = defineSearchAttributeKey(name, def.kind);
179
+ pairs.push({
180
+ key,
181
+ value
182
+ });
183
+ }
184
+ return ok(pairs.length > 0 ? new TypedSearchAttributes(pairs) : void 0);
185
+ }
186
+ /**
156
187
  * Wrap an async result-producing function in a `ResultAsync`, catching any
157
188
  * unhandled rejection as a `RuntimeClientError("unexpected", error)`.
158
189
  *
@@ -239,6 +270,9 @@ var TypedScheduleClient = class {
239
270
  if (!definition) return err(new WorkflowNotFoundError(workflowName, Object.keys(this.contract.workflows)));
240
271
  const inputResult = await definition.input["~standard"].validate(options.args);
241
272
  if (inputResult.issues) return err(new WorkflowValidationError(workflowName, "input", inputResult.issues));
273
+ const searchAttributesResult = toTypedSearchAttributes(definition, workflowName, options.searchAttributes);
274
+ if (searchAttributesResult.isErr()) return err(searchAttributesResult.error);
275
+ const typedSearchAttributes = searchAttributesResult.value;
242
276
  try {
243
277
  const overrides = options.action ?? {};
244
278
  const action = {
@@ -246,6 +280,7 @@ var TypedScheduleClient = class {
246
280
  workflowType: workflowName,
247
281
  taskQueue: this.contract.taskQueue,
248
282
  args: [inputResult.value],
283
+ ...typedSearchAttributes ? { typedSearchAttributes } : {},
249
284
  ...overrides.workflowId !== void 0 ? { workflowId: overrides.workflowId } : {},
250
285
  ...overrides.workflowExecutionTimeout !== void 0 ? { workflowExecutionTimeout: overrides.workflowExecutionTimeout } : {},
251
286
  ...overrides.workflowRunTimeout !== void 0 ? { workflowRunTimeout: overrides.workflowRunTimeout } : {},
@@ -291,28 +326,44 @@ function wrapScheduleHandle(handle) {
291
326
  //#endregion
292
327
  //#region src/client.ts
293
328
  /**
294
- * Translate the contract's typed `searchAttributes` map (declared
295
- * name value) into a Temporal `TypedSearchAttributes` instance, so the
296
- * Temporal client honours indexing when starting the workflow.
329
+ * Read declared search attributes off a `TypedSearchAttributes` instance
330
+ * the read-side counterpart to the write-side `searchAttributes` option on
331
+ * `startWorkflow` / `signalWithStart` / `executeWorkflow` /
332
+ * `schedule.create`.
297
333
  *
298
- * Workflows without a `searchAttributes` block (or callers passing no
299
- * values) skip the conversion entirely and return `undefined`, matching
300
- * the Temporal SDK's "absent empty" semantics.
334
+ * Use it on the result of `handle.describe()` (or a schedule's describe) to
335
+ * recover the typed shape of indexed attributes. The Temporal SDK only
336
+ * exposes a `.get(key)` accessor on `TypedSearchAttributes` and requires
337
+ * the caller to reconstruct each `SearchAttributeKey` from the contract's
338
+ * declared `kind` — this helper does that lookup once for every declared
339
+ * attribute, returning a `Partial<TypedSearchAttributeMap<TWorkflow>>`
340
+ * (each declared key may or may not have been set on the workflow).
341
+ *
342
+ * Workflows without declared `searchAttributes` get an empty object back.
343
+ *
344
+ * @example
345
+ * ```ts
346
+ * const description = await handle.describe();
347
+ * if (description.isOk()) {
348
+ * const attrs = readTypedSearchAttributes(
349
+ * myContract.workflows.processOrder,
350
+ * description.value.typedSearchAttributes,
351
+ * );
352
+ * // attrs.customerId: string | undefined
353
+ * // attrs.priority: number | undefined
354
+ * }
355
+ * ```
301
356
  */
302
- function toTypedSearchAttributes(workflowDef, values) {
303
- if (!values || !workflowDef.searchAttributes) return void 0;
304
- const pairs = [];
305
- for (const [name, value] of Object.entries(values)) {
306
- if (value === void 0) continue;
307
- const def = workflowDef.searchAttributes[name];
308
- if (!def) continue;
357
+ function readTypedSearchAttributes(workflowDef, instance) {
358
+ const declared = workflowDef.searchAttributes;
359
+ if (!declared) return {};
360
+ const result = {};
361
+ for (const [name, def] of Object.entries(declared)) {
309
362
  const key = defineSearchAttributeKey(name, def.kind);
310
- pairs.push({
311
- key,
312
- value
313
- });
363
+ const value = instance.get(key);
364
+ if (value !== void 0) result[name] = value;
314
365
  }
315
- return pairs.length > 0 ? new TypedSearchAttributes(pairs) : void 0;
366
+ return result;
316
367
  }
317
368
  /**
318
369
  * Shared pre-call ritual for the three contract-driven entry points that
@@ -337,7 +388,9 @@ async function resolveDefinitionAndValidateInput(contract, workflowName, args, s
337
388
  if (!definition) return err(createWorkflowNotFoundError(workflowName, contract));
338
389
  const inputResult = await definition.input["~standard"].validate(args);
339
390
  if (inputResult.issues) return err(createWorkflowValidationError(workflowName, "input", inputResult.issues));
340
- const typedSearchAttributes = toTypedSearchAttributes(definition, searchAttributes);
391
+ const searchAttributesResult = toTypedSearchAttributes(definition, workflowName, searchAttributes);
392
+ if (searchAttributesResult.isErr()) return err(searchAttributesResult.error);
393
+ const typedSearchAttributes = searchAttributesResult.value;
341
394
  return ok({
342
395
  definition,
343
396
  validatedInput: inputResult.value,
@@ -660,6 +713,6 @@ function buildValidatedProxy({ defs, operation, workflowId, makeValidationError,
660
713
  return proxy;
661
714
  }
662
715
  //#endregion
663
- export { QueryValidationError, RuntimeClientError, SignalValidationError, TypedClient, TypedScheduleClient, UpdateValidationError, WorkflowAlreadyStartedError, WorkflowExecutionNotFoundError, WorkflowFailedError, WorkflowNotFoundError, WorkflowValidationError };
716
+ export { QueryValidationError, RuntimeClientError, SignalValidationError, TypedClient, TypedScheduleClient, UpdateValidationError, WorkflowAlreadyStartedError, WorkflowExecutionNotFoundError, WorkflowFailedError, WorkflowNotFoundError, WorkflowValidationError, readTypedSearchAttributes };
664
717
 
665
718
  //# sourceMappingURL=index.mjs.map
@@ -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 with boxed pattern\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 { WorkflowNotFoundError as TemporalWorkflowNotFoundError } from \"@temporalio/common\";\nimport { _internal_makeResultAsync } from \"@temporal-contract/contract/result-async\";\nimport type { ResultAsync, Result } from \"neverthrow\";\nimport {\n RuntimeClientError,\n type TemporalFailure,\n WorkflowAlreadyStartedError,\n WorkflowExecutionNotFoundError,\n WorkflowFailedError,\n} from \"./errors.js\";\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 { ClientInferInput } from \"./types.js\";\nimport { RuntimeClientError, WorkflowNotFoundError, WorkflowValidationError } from \"./errors.js\";\nimport { makeResultAsync } 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 /** 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 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 ...(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 {\n defineSearchAttributeKey,\n type SearchAttributePair,\n TypedSearchAttributes,\n} 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} 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\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 * 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) skip the conversion entirely and return `undefined`, matching\n * the Temporal SDK's \"absent ≠ empty\" semantics.\n */\nfunction toTypedSearchAttributes(\n workflowDef: AnyWorkflowDefinition,\n values: Record<string, unknown> | undefined,\n): TypedSearchAttributes | undefined {\n if (!values || !workflowDef.searchAttributes) return undefined;\n const pairs: SearchAttributePair[] = [];\n for (const [name, value] of Object.entries(values)) {\n if (value === undefined) continue;\n const def = (workflowDef.searchAttributes as Record<string, SearchAttributeDefinition>)[name];\n if (!def) continue;\n const key = defineSearchAttributeKey(name, def.kind);\n pairs.push({ key, value } as SearchAttributePair);\n }\n return pairs.length > 0 ? new TypedSearchAttributes(pairs) : undefined;\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\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 typedSearchAttributes = toTypedSearchAttributes(definition, searchAttributes);\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 is pinned to `^1.16.0` so the standard install\n * paths surface a peer-dependency warning rather than a runtime crash.\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. Fail early with a clear message if a\n // consumer is on an older version (peer dep is pinned to ^1.16, but\n // installs that ignore peer-dep warnings shouldn't crash with a\n // confusing `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;AACrC,QAAM,QAAQ;AACd,OAAK,OAAO,KAAK,YAAY;AAC7B,MAAI,MAAM,kBACR,OAAM,kBAAkB,MAAM,KAAK,YAAY;;;;;;AAQrD,IAAa,qBAAb,cAAwC,iBAAiB;CACvD,YACE,WACA,OACA;AACA,QACE,cAAc,UAAU,YACtB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,SAAS,gBAAgB,GAE5E;AA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AgB,KAAK;;AAIhC,QAAO"}
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 with boxed pattern\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 is pinned to `^1.16.0` so the standard install\n * paths surface a peer-dependency warning rather than a runtime crash.\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. Fail early with a clear message if a\n // consumer is on an older version (peer dep is pinned to ^1.16, but\n // installs that ignore peer-dep warnings shouldn't crash with a\n // confusing `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;AACrC,QAAM,QAAQ;AACd,OAAK,OAAO,KAAK,YAAY;AAC7B,MAAI,MAAM,kBACR,OAAM,kBAAkB,MAAM,KAAK,YAAY;;;;;;AAQrD,IAAa,qBAAb,cAAwC,iBAAiB;CACvD,YACE,WACA,OACA;AACA,QACE,cAAc,UAAU,YACtB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,SAAS,gBAAgB,GAE5E;AAPe,OAAA,YAAA;AACS,OAAA,QAAA;;;;;;AAa7B,IAAa,w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;AACzB,QAAO,IAAI,wBAAwB,OAAO,aAAa,EAAE,WAAW,OAAO;;;;;;;;;AAmC7E,SAAS,oBAA+E,EACtF,MACA,WACA,YACA,qBACA,QACA,kBAMA;CACA,MAAM,QAQF,EAAE;AACN,KAAI,CAAC,KAAM,QAAO;AAElB,MAAK,MAAM,CAAC,MAAM,QAAQ,OAAO,QAAQ,KAAK,CAC5C,OAAM,SAAS,SAAS;EACtB,MAAM,OAAO,YAER;GACH,MAAM,cAAc,MAAM,IAAI,MAAM,aAAa,SAAS,KAAK;AAC/D,OAAI,YAAY,OACd,QAAO,IAAI,oBAAoB,MAAM,SAAS,YAAY,OAAO,CAAC;AAGpE,OAAI;IACF,MAAM,SAAS,MAAM,OAAO,MAAM,YAAY,MAAM;IACpD,MAAM,eAAe,eAAe,IAAI;AACxC,QAAI,CAAC,aACH,QAAO,GAAG,OAAO;IAEnB,MAAM,eAAe,MAAM,aAAa,aAAa,SAAS,OAAO;AACrE,QAAI,aAAa,OACf,QAAO,IAAI,oBAAoB,MAAM,UAAU,aAAa,OAAO,CAAC;AAEtE,WAAO,GAAG,aAAa,MAAM;YACtB,OAAO;AACd,WAAO,IAAI,oBAAoB,WAAW,OAAO,WAAW,CAAC;;;AAGjE,SAAO,gBAAgB,KAAK;;AAIhC,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporal-contract/client",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Client utilities with neverthrow Result/ResultAsync for consuming temporal-contract workflows",
5
5
  "keywords": [
6
6
  "client",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@standard-schema/spec": "1.1.0",
46
- "@temporal-contract/contract": "2.1.0"
46
+ "@temporal-contract/contract": "2.2.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@temporalio/client": "1.17.0",
@@ -59,9 +59,9 @@
59
59
  "typescript": "6.0.3",
60
60
  "vitest": "4.1.5",
61
61
  "zod": "4.4.3",
62
- "@temporal-contract/testing": "2.1.0",
63
- "@temporal-contract/typedoc": "0.1.0",
64
- "@temporal-contract/tsconfig": "1.0.0"
62
+ "@temporal-contract/testing": "2.2.0",
63
+ "@temporal-contract/tsconfig": "1.0.0",
64
+ "@temporal-contract/typedoc": "0.1.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@temporalio/client": "^1.16.0",