@temporal-contract/client 0.0.4 → 0.0.5

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
@@ -1,5 +1,5 @@
1
1
  let __temporalio_client = require("@temporalio/client");
2
- let __swan_io_boxed = require("@swan-io/boxed");
2
+ let __temporal_contract_boxed = require("@temporal-contract/boxed");
3
3
 
4
4
  //#region src/errors.ts
5
5
  /**
@@ -93,7 +93,7 @@ var TypedClient = class TypedClient {
93
93
  * const result = await client.executeWorkflow('processOrder', {
94
94
  * workflowId: 'order-123',
95
95
  * args: { ... },
96
- * }).toPromise();
96
+ * });
97
97
  *
98
98
  * result.match({
99
99
  * Ok: (output) => console.log('Success:', output),
@@ -114,11 +114,11 @@ var TypedClient = class TypedClient {
114
114
  * args: { orderId: 'ORD-123' },
115
115
  * workflowExecutionTimeout: '1 day',
116
116
  * retry: { maximumAttempts: 3 },
117
- * }).toPromise();
117
+ * });
118
118
  *
119
119
  * handleResult.match({
120
120
  * Ok: async (handle) => {
121
- * const result = await handle.result().toPromise();
121
+ * const result = await handle.result();
122
122
  * // ... handle result
123
123
  * },
124
124
  * Error: (error) => console.error('Failed to start:', error),
@@ -126,16 +126,16 @@ var TypedClient = class TypedClient {
126
126
  * ```
127
127
  */
128
128
  startWorkflow(workflowName, { args, ...temporalOptions }) {
129
- return __swan_io_boxed.Future.make((resolve) => {
129
+ return __temporal_contract_boxed.Future.make((resolve) => {
130
130
  const definition = this.contract.workflows[workflowName];
131
131
  if (!definition) {
132
- resolve(__swan_io_boxed.Result.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
132
+ resolve(__temporal_contract_boxed.Result.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
133
133
  return;
134
134
  }
135
135
  (async () => {
136
136
  const inputResult = await definition.input["~standard"].validate(args);
137
137
  if (inputResult.issues) {
138
- resolve(__swan_io_boxed.Result.Error(new WorkflowValidationError(String(workflowName), "input", inputResult.issues)));
138
+ resolve(__temporal_contract_boxed.Result.Error(new WorkflowValidationError(String(workflowName), "input", inputResult.issues)));
139
139
  return;
140
140
  }
141
141
  const validatedInput = inputResult.value;
@@ -146,9 +146,9 @@ var TypedClient = class TypedClient {
146
146
  args: [validatedInput]
147
147
  });
148
148
  const typedHandle = this.createTypedHandle(handle, definition);
149
- resolve(__swan_io_boxed.Result.Ok(typedHandle));
149
+ resolve(__temporal_contract_boxed.Result.Ok(typedHandle));
150
150
  } catch (error) {
151
- resolve(__swan_io_boxed.Result.Error(new TypedClientError(`Failed to start workflow: ${error instanceof Error ? error.message : String(error)}`)));
151
+ resolve(__temporal_contract_boxed.Result.Error(new TypedClientError(`Failed to start workflow: ${error instanceof Error ? error.message : String(error)}`)));
152
152
  }
153
153
  })();
154
154
  });
@@ -163,7 +163,7 @@ var TypedClient = class TypedClient {
163
163
  * args: { orderId: 'ORD-123' },
164
164
  * workflowExecutionTimeout: '1 day',
165
165
  * retry: { maximumAttempts: 3 },
166
- * }).toPromise();
166
+ * });
167
167
  *
168
168
  * result.match({
169
169
  * Ok: (output) => console.log('Order processed:', output.status),
@@ -172,16 +172,16 @@ var TypedClient = class TypedClient {
172
172
  * ```
173
173
  */
174
174
  executeWorkflow(workflowName, { args, ...temporalOptions }) {
175
- return __swan_io_boxed.Future.make((resolve) => {
175
+ return __temporal_contract_boxed.Future.make((resolve) => {
176
176
  const definition = this.contract.workflows[workflowName];
177
177
  if (!definition) {
178
- resolve(__swan_io_boxed.Result.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
178
+ resolve(__temporal_contract_boxed.Result.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
179
179
  return;
180
180
  }
181
181
  (async () => {
182
182
  const inputResult = await definition.input["~standard"].validate(args);
183
183
  if (inputResult.issues) {
184
- resolve(__swan_io_boxed.Result.Error(new WorkflowValidationError(String(workflowName), "input", inputResult.issues)));
184
+ resolve(__temporal_contract_boxed.Result.Error(new WorkflowValidationError(String(workflowName), "input", inputResult.issues)));
185
185
  return;
186
186
  }
187
187
  const validatedInput = inputResult.value;
@@ -193,12 +193,12 @@ var TypedClient = class TypedClient {
193
193
  });
194
194
  const outputResult = await definition.output["~standard"].validate(result);
195
195
  if (outputResult.issues) {
196
- resolve(__swan_io_boxed.Result.Error(new WorkflowValidationError(String(workflowName), "output", outputResult.issues)));
196
+ resolve(__temporal_contract_boxed.Result.Error(new WorkflowValidationError(String(workflowName), "output", outputResult.issues)));
197
197
  return;
198
198
  }
199
- resolve(__swan_io_boxed.Result.Ok(outputResult.value));
199
+ resolve(__temporal_contract_boxed.Result.Ok(outputResult.value));
200
200
  } catch (error) {
201
- resolve(__swan_io_boxed.Result.Error(new TypedClientError(`Failed to execute workflow: ${error instanceof Error ? error.message : String(error)}`)));
201
+ resolve(__temporal_contract_boxed.Result.Error(new TypedClientError(`Failed to execute workflow: ${error instanceof Error ? error.message : String(error)}`)));
202
202
  }
203
203
  })();
204
204
  });
@@ -208,10 +208,10 @@ var TypedClient = class TypedClient {
208
208
  *
209
209
  * @example
210
210
  * ```ts
211
- * const handleResult = await client.getHandle('processOrder', 'order-123').toPromise();
211
+ * const handleResult = await client.getHandle('processOrder', 'order-123');
212
212
  * handleResult.match({
213
213
  * Ok: async (handle) => {
214
- * const result = await handle.result().toPromise();
214
+ * const result = await handle.result();
215
215
  * // ... handle result
216
216
  * },
217
217
  * Error: (error) => console.error('Failed to get handle:', error),
@@ -219,82 +219,82 @@ var TypedClient = class TypedClient {
219
219
  * ```
220
220
  */
221
221
  getHandle(workflowName, workflowId) {
222
- return __swan_io_boxed.Future.make((resolve) => {
222
+ return __temporal_contract_boxed.Future.make((resolve) => {
223
223
  const definition = this.contract.workflows[workflowName];
224
224
  if (!definition) {
225
- resolve(__swan_io_boxed.Result.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
225
+ resolve(__temporal_contract_boxed.Result.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
226
226
  return;
227
227
  }
228
228
  try {
229
229
  const handle = this.client.workflow.getHandle(workflowId);
230
230
  const typedHandle = this.createTypedHandle(handle, definition);
231
- resolve(__swan_io_boxed.Result.Ok(typedHandle));
231
+ resolve(__temporal_contract_boxed.Result.Ok(typedHandle));
232
232
  } catch (error) {
233
- resolve(__swan_io_boxed.Result.Error(new TypedClientError(`Failed to get workflow handle: ${error instanceof Error ? error.message : String(error)}`)));
233
+ resolve(__temporal_contract_boxed.Result.Error(new TypedClientError(`Failed to get workflow handle: ${error instanceof Error ? error.message : String(error)}`)));
234
234
  }
235
235
  });
236
236
  }
237
237
  createTypedHandle(handle, definition) {
238
238
  const queries = {};
239
239
  for (const [queryName, queryDef] of Object.entries(definition.queries ?? {})) queries[queryName] = (args) => {
240
- return __swan_io_boxed.Future.make((resolve) => {
240
+ return __temporal_contract_boxed.Future.make((resolve) => {
241
241
  (async () => {
242
242
  const inputResult = await queryDef.input["~standard"].validate(args);
243
243
  if (inputResult.issues) {
244
- resolve(__swan_io_boxed.Result.Error(new QueryValidationError(queryName, "input", inputResult.issues)));
244
+ resolve(__temporal_contract_boxed.Result.Error(new QueryValidationError(queryName, "input", inputResult.issues)));
245
245
  return;
246
246
  }
247
247
  try {
248
248
  const result = await handle.query(queryName, inputResult.value);
249
249
  const outputResult = await queryDef.output["~standard"].validate(result);
250
250
  if (outputResult.issues) {
251
- resolve(__swan_io_boxed.Result.Error(new QueryValidationError(queryName, "output", outputResult.issues)));
251
+ resolve(__temporal_contract_boxed.Result.Error(new QueryValidationError(queryName, "output", outputResult.issues)));
252
252
  return;
253
253
  }
254
- resolve(__swan_io_boxed.Result.Ok(outputResult.value));
254
+ resolve(__temporal_contract_boxed.Result.Ok(outputResult.value));
255
255
  } catch (error) {
256
- resolve(__swan_io_boxed.Result.Error(new TypedClientError(`Query failed: ${error instanceof Error ? error.message : String(error)}`)));
256
+ resolve(__temporal_contract_boxed.Result.Error(new TypedClientError(`Query failed: ${error instanceof Error ? error.message : String(error)}`)));
257
257
  }
258
258
  })();
259
259
  });
260
260
  };
261
261
  const signals = {};
262
262
  for (const [signalName, signalDef] of Object.entries(definition.signals ?? {})) signals[signalName] = (args) => {
263
- return __swan_io_boxed.Future.make((resolve) => {
263
+ return __temporal_contract_boxed.Future.make((resolve) => {
264
264
  (async () => {
265
265
  const inputResult = await signalDef.input["~standard"].validate(args);
266
266
  if (inputResult.issues) {
267
- resolve(__swan_io_boxed.Result.Error(new SignalValidationError(signalName, inputResult.issues)));
267
+ resolve(__temporal_contract_boxed.Result.Error(new SignalValidationError(signalName, inputResult.issues)));
268
268
  return;
269
269
  }
270
270
  try {
271
271
  await handle.signal(signalName, inputResult.value);
272
- resolve(__swan_io_boxed.Result.Ok(void 0));
272
+ resolve(__temporal_contract_boxed.Result.Ok(void 0));
273
273
  } catch (error) {
274
- resolve(__swan_io_boxed.Result.Error(new TypedClientError(`Signal failed: ${error instanceof Error ? error.message : String(error)}`)));
274
+ resolve(__temporal_contract_boxed.Result.Error(new TypedClientError(`Signal failed: ${error instanceof Error ? error.message : String(error)}`)));
275
275
  }
276
276
  })();
277
277
  });
278
278
  };
279
279
  const updates = {};
280
280
  for (const [updateName, updateDef] of Object.entries(definition.updates ?? {})) updates[updateName] = (args) => {
281
- return __swan_io_boxed.Future.make((resolve) => {
281
+ return __temporal_contract_boxed.Future.make((resolve) => {
282
282
  (async () => {
283
283
  const inputResult = await updateDef.input["~standard"].validate(args);
284
284
  if (inputResult.issues) {
285
- resolve(__swan_io_boxed.Result.Error(new UpdateValidationError(updateName, "input", inputResult.issues)));
285
+ resolve(__temporal_contract_boxed.Result.Error(new UpdateValidationError(updateName, "input", inputResult.issues)));
286
286
  return;
287
287
  }
288
288
  try {
289
289
  const result = await handle.executeUpdate(updateName, { args: [inputResult.value] });
290
290
  const outputResult = await updateDef.output["~standard"].validate(result);
291
291
  if (outputResult.issues) {
292
- resolve(__swan_io_boxed.Result.Error(new UpdateValidationError(updateName, "output", outputResult.issues)));
292
+ resolve(__temporal_contract_boxed.Result.Error(new UpdateValidationError(updateName, "output", outputResult.issues)));
293
293
  return;
294
294
  }
295
- resolve(__swan_io_boxed.Result.Ok(outputResult.value));
295
+ resolve(__temporal_contract_boxed.Result.Ok(outputResult.value));
296
296
  } catch (error) {
297
- resolve(__swan_io_boxed.Result.Error(new TypedClientError(`Update failed: ${error instanceof Error ? error.message : String(error)}`)));
297
+ resolve(__temporal_contract_boxed.Result.Error(new TypedClientError(`Update failed: ${error instanceof Error ? error.message : String(error)}`)));
298
298
  }
299
299
  })();
300
300
  });
@@ -305,54 +305,54 @@ var TypedClient = class TypedClient {
305
305
  signals,
306
306
  updates,
307
307
  result: () => {
308
- return __swan_io_boxed.Future.make((resolve) => {
308
+ return __temporal_contract_boxed.Future.make((resolve) => {
309
309
  (async () => {
310
310
  try {
311
311
  const result = await handle.result();
312
312
  const outputResult = await definition.output["~standard"].validate(result);
313
313
  if (outputResult.issues) {
314
- resolve(__swan_io_boxed.Result.Error(new WorkflowValidationError(handle.workflowId, "output", outputResult.issues)));
314
+ resolve(__temporal_contract_boxed.Result.Error(new WorkflowValidationError(handle.workflowId, "output", outputResult.issues)));
315
315
  return;
316
316
  }
317
- resolve(__swan_io_boxed.Result.Ok(outputResult.value));
317
+ resolve(__temporal_contract_boxed.Result.Ok(outputResult.value));
318
318
  } catch (error) {
319
- resolve(__swan_io_boxed.Result.Error(new TypedClientError(`Workflow execution failed: ${error instanceof Error ? error.message : String(error)}`)));
319
+ resolve(__temporal_contract_boxed.Result.Error(new TypedClientError(`Workflow execution failed: ${error instanceof Error ? error.message : String(error)}`)));
320
320
  }
321
321
  })();
322
322
  });
323
323
  },
324
324
  terminate: (reason) => {
325
- return __swan_io_boxed.Future.make((resolve) => {
325
+ return __temporal_contract_boxed.Future.make((resolve) => {
326
326
  (async () => {
327
327
  try {
328
328
  await handle.terminate(reason);
329
- resolve(__swan_io_boxed.Result.Ok(void 0));
329
+ resolve(__temporal_contract_boxed.Result.Ok(void 0));
330
330
  } catch (error) {
331
- resolve(__swan_io_boxed.Result.Error(new TypedClientError(`Terminate failed: ${error instanceof Error ? error.message : String(error)}`)));
331
+ resolve(__temporal_contract_boxed.Result.Error(new TypedClientError(`Terminate failed: ${error instanceof Error ? error.message : String(error)}`)));
332
332
  }
333
333
  })();
334
334
  });
335
335
  },
336
336
  cancel: () => {
337
- return __swan_io_boxed.Future.make((resolve) => {
337
+ return __temporal_contract_boxed.Future.make((resolve) => {
338
338
  (async () => {
339
339
  try {
340
340
  await handle.cancel();
341
- resolve(__swan_io_boxed.Result.Ok(void 0));
341
+ resolve(__temporal_contract_boxed.Result.Ok(void 0));
342
342
  } catch (error) {
343
- resolve(__swan_io_boxed.Result.Error(new TypedClientError(`Cancel failed: ${error instanceof Error ? error.message : String(error)}`)));
343
+ resolve(__temporal_contract_boxed.Result.Error(new TypedClientError(`Cancel failed: ${error instanceof Error ? error.message : String(error)}`)));
344
344
  }
345
345
  })();
346
346
  });
347
347
  },
348
348
  describe: () => {
349
- return __swan_io_boxed.Future.make((resolve) => {
349
+ return __temporal_contract_boxed.Future.make((resolve) => {
350
350
  (async () => {
351
351
  try {
352
352
  const description = await handle.describe();
353
- resolve(__swan_io_boxed.Result.Ok(description));
353
+ resolve(__temporal_contract_boxed.Result.Ok(description));
354
354
  } catch (error) {
355
- resolve(__swan_io_boxed.Result.Error(new TypedClientError(`Describe failed: ${error instanceof Error ? error.message : String(error)}`)));
355
+ resolve(__temporal_contract_boxed.Result.Error(new TypedClientError(`Describe failed: ${error instanceof Error ? error.message : String(error)}`)));
356
356
  }
357
357
  })();
358
358
  });
@@ -363,31 +363,7 @@ var TypedClient = class TypedClient {
363
363
  };
364
364
 
365
365
  //#endregion
366
- Object.defineProperty(exports, 'AsyncData', {
367
- enumerable: true,
368
- get: function () {
369
- return __swan_io_boxed.AsyncData;
370
- }
371
- });
372
- Object.defineProperty(exports, 'Future', {
373
- enumerable: true,
374
- get: function () {
375
- return __swan_io_boxed.Future;
376
- }
377
- });
378
- Object.defineProperty(exports, 'Option', {
379
- enumerable: true,
380
- get: function () {
381
- return __swan_io_boxed.Option;
382
- }
383
- });
384
366
  exports.QueryValidationError = QueryValidationError;
385
- Object.defineProperty(exports, 'Result', {
386
- enumerable: true,
387
- get: function () {
388
- return __swan_io_boxed.Result;
389
- }
390
- });
391
367
  exports.SignalValidationError = SignalValidationError;
392
368
  exports.TypedClient = TypedClient;
393
369
  exports.TypedClientError = TypedClientError;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,86 @@
1
1
  import { ClientOptions, WorkflowHandle, WorkflowOptions, WorkflowStartOptions } from "@temporalio/client";
2
- import { ClientInferInput, ClientInferOutput, ClientInferWorkflowQueries, ClientInferWorkflowSignals, ClientInferWorkflowUpdates, ContractDefinition, WorkflowDefinition } from "@temporal-contract/contract";
3
- import { AsyncData, Future, Future as Future$1, Option, Result, Result as Result$1 } from "@swan-io/boxed";
2
+ import { ActivityDefinition, AnySchema, ContractDefinition, QueryDefinition, SignalDefinition, UpdateDefinition, WorkflowDefinition } from "@temporal-contract/contract";
4
3
  import { StandardSchemaV1 } from "@standard-schema/spec";
4
+ import { Future, Result } from "@temporal-contract/boxed";
5
5
 
6
+ //#region src/types.d.ts
7
+
8
+ /**
9
+ * Infer input type from a definition (client perspective)
10
+ * Client sends the input type (before input schema parsing/transformation)
11
+ */
12
+ type ClientInferInput<T extends {
13
+ input: AnySchema;
14
+ }> = StandardSchemaV1.InferInput<T["input"]>;
15
+ /**
16
+ * Infer output type from a definition (client perspective)
17
+ * Client receives the output type (after output schema parsing/transformation)
18
+ */
19
+ type ClientInferOutput<T extends {
20
+ output: AnySchema;
21
+ }> = StandardSchemaV1.InferOutput<T["output"]>;
22
+ /**
23
+ * CLIENT PERSPECTIVE
24
+ * Client sends z.output and receives z.input
25
+ */
26
+ /**
27
+ * Infer workflow function signature from client perspective
28
+ * Client sends z.output and receives z.input
29
+ */
30
+ type ClientInferWorkflow<TWorkflow extends WorkflowDefinition> = (args: ClientInferInput<TWorkflow>) => Promise<ClientInferOutput<TWorkflow>>;
31
+ /**
32
+ * Infer activity function signature from client perspective
33
+ * Client sends z.output and receives z.input
34
+ */
35
+ type ClientInferActivity<TActivity extends ActivityDefinition> = (args: ClientInferInput<TActivity>) => Promise<ClientInferOutput<TActivity>>;
36
+ /**
37
+ * Infer signal handler signature from client perspective
38
+ * Client sends z.output and returns Future<Result<void, Error>>
39
+ */
40
+ type ClientInferSignal<TSignal extends SignalDefinition> = (args: ClientInferInput<TSignal>) => Future<Result<void, Error>>;
41
+ /**
42
+ * Infer query handler signature from client perspective
43
+ * Client sends z.output and receives z.input wrapped in Future<Result<T, Error>>
44
+ */
45
+ type ClientInferQuery<TQuery extends QueryDefinition> = (args: ClientInferInput<TQuery>) => Future<Result<ClientInferOutput<TQuery>, Error>>;
46
+ /**
47
+ * Infer update handler signature from client perspective
48
+ * Client sends z.output and receives z.input wrapped in Future<Result<T, Error>>
49
+ */
50
+ type ClientInferUpdate<TUpdate extends UpdateDefinition> = (args: ClientInferInput<TUpdate>) => Future<Result<ClientInferOutput<TUpdate>, Error>>;
51
+ /**
52
+ * CLIENT PERSPECTIVE - Contract-level types
53
+ */
54
+ /**
55
+ * Infer all workflows from a contract (client perspective)
56
+ */
57
+ type ClientInferWorkflows<TContract extends ContractDefinition> = { [K in keyof TContract["workflows"]]: ClientInferWorkflow<TContract["workflows"][K]> };
58
+ /**
59
+ * Infer all activities from a contract (client perspective)
60
+ */
61
+ type ClientInferActivities<TContract extends ContractDefinition> = TContract["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof TContract["activities"]]: ClientInferActivity<TContract["activities"][K]> } : {};
62
+ /**
63
+ * Infer activities from a workflow definition (client perspective)
64
+ */
65
+ type ClientInferWorkflowActivities<T extends WorkflowDefinition> = T["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof T["activities"]]: ClientInferActivity<T["activities"][K]> } : {};
66
+ /**
67
+ * Infer signals from a workflow definition (client perspective)
68
+ */
69
+ type ClientInferWorkflowSignals<T extends WorkflowDefinition> = T["signals"] extends Record<string, SignalDefinition> ? { [K in keyof T["signals"]]: ClientInferSignal<T["signals"][K]> } : {};
70
+ /**
71
+ * Infer queries from a workflow definition (client perspective)
72
+ */
73
+ type ClientInferWorkflowQueries<T extends WorkflowDefinition> = T["queries"] extends Record<string, QueryDefinition> ? { [K in keyof T["queries"]]: ClientInferQuery<T["queries"][K]> } : {};
74
+ /**
75
+ * Infer updates from a workflow definition (client perspective)
76
+ */
77
+ type ClientInferWorkflowUpdates<T extends WorkflowDefinition> = T["updates"] extends Record<string, UpdateDefinition> ? { [K in keyof T["updates"]]: ClientInferUpdate<T["updates"][K]> } : {};
78
+ /**
79
+ * Infer all activities available in a workflow context (client perspective)
80
+ * Combines workflow-specific activities with global activities
81
+ */
82
+ type ClientInferWorkflowContextActivities<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"]> = ClientInferWorkflowActivities<TContract["workflows"][TWorkflowName]> & ClientInferActivities<TContract>;
83
+ //#endregion
6
84
  //#region src/errors.d.ts
7
85
  /**
8
86
  * Base class for all typed client errors with boxed pattern
@@ -69,33 +147,33 @@ interface TypedWorkflowHandle<TWorkflow extends WorkflowDefinition> {
69
147
  * Type-safe queries based on workflow definition with Result pattern
70
148
  * Each query returns Future<Result<T, Error>> instead of Promise<T>
71
149
  */
72
- queries: { [K in keyof ClientInferWorkflowQueries<TWorkflow>]: ClientInferWorkflowQueries<TWorkflow>[K] extends ((...args: infer Args) => Promise<infer R>) ? (...args: Args) => Future$1<Result$1<R, TypedClientError>> : never };
150
+ queries: { [K in keyof ClientInferWorkflowQueries<TWorkflow>]: ClientInferWorkflowQueries<TWorkflow>[K] extends ((...args: infer Args) => Future<Result<infer R, Error>>) ? (...args: Args) => Future<Result<R, TypedClientError>> : never };
73
151
  /**
74
152
  * Type-safe signals based on workflow definition with Result pattern
75
153
  * Each signal returns Future<Result<void, Error>> instead of Promise<void>
76
154
  */
77
- signals: { [K in keyof ClientInferWorkflowSignals<TWorkflow>]: ClientInferWorkflowSignals<TWorkflow>[K] extends ((...args: infer Args) => Promise<void>) ? (...args: Args) => Future$1<Result$1<void, TypedClientError>> : never };
155
+ signals: { [K in keyof ClientInferWorkflowSignals<TWorkflow>]: ClientInferWorkflowSignals<TWorkflow>[K] extends ((...args: infer Args) => Future<Result<void, Error>>) ? (...args: Args) => Future<Result<void, TypedClientError>> : never };
78
156
  /**
79
157
  * Type-safe updates based on workflow definition with Result pattern
80
158
  * Each update returns Future<Result<T, Error>> instead of Promise<T>
81
159
  */
82
- updates: { [K in keyof ClientInferWorkflowUpdates<TWorkflow>]: ClientInferWorkflowUpdates<TWorkflow>[K] extends ((...args: infer Args) => Promise<infer R>) ? (...args: Args) => Future$1<Result$1<R, TypedClientError>> : never };
160
+ updates: { [K in keyof ClientInferWorkflowUpdates<TWorkflow>]: ClientInferWorkflowUpdates<TWorkflow>[K] extends ((...args: infer Args) => Future<Result<infer R, Error>>) ? (...args: Args) => Future<Result<R, TypedClientError>> : never };
83
161
  /**
84
162
  * Get workflow result with Result pattern
85
163
  */
86
- result: () => Future$1<Result$1<ClientInferOutput<TWorkflow>, TypedClientError>>;
164
+ result: () => Future<Result<ClientInferOutput<TWorkflow>, TypedClientError>>;
87
165
  /**
88
166
  * Terminate workflow with Result pattern
89
167
  */
90
- terminate: (reason?: string) => Future$1<Result$1<void, TypedClientError>>;
168
+ terminate: (reason?: string) => Future<Result<void, TypedClientError>>;
91
169
  /**
92
170
  * Cancel workflow with Result pattern
93
171
  */
94
- cancel: () => Future$1<Result$1<void, TypedClientError>>;
172
+ cancel: () => Future<Result<void, TypedClientError>>;
95
173
  /**
96
174
  * Get workflow execution description including status and metadata
97
175
  */
98
- describe: () => Future$1<Result$1<Awaited<ReturnType<WorkflowHandle["describe"]>>, TypedClientError>>;
176
+ describe: () => Future<Result<Awaited<ReturnType<WorkflowHandle["describe"]>>, TypedClientError>>;
99
177
  /**
100
178
  * Fetch the workflow execution history
101
179
  */
@@ -125,7 +203,7 @@ declare class TypedClient<TContract extends ContractDefinition> {
125
203
  * const result = await client.executeWorkflow('processOrder', {
126
204
  * workflowId: 'order-123',
127
205
  * args: { ... },
128
- * }).toPromise();
206
+ * });
129
207
  *
130
208
  * result.match({
131
209
  * Ok: (output) => console.log('Success:', output),
@@ -144,11 +222,11 @@ declare class TypedClient<TContract extends ContractDefinition> {
144
222
  * args: { orderId: 'ORD-123' },
145
223
  * workflowExecutionTimeout: '1 day',
146
224
  * retry: { maximumAttempts: 3 },
147
- * }).toPromise();
225
+ * });
148
226
  *
149
227
  * handleResult.match({
150
228
  * Ok: async (handle) => {
151
- * const result = await handle.result().toPromise();
229
+ * const result = await handle.result();
152
230
  * // ... handle result
153
231
  * },
154
232
  * Error: (error) => console.error('Failed to start:', error),
@@ -160,7 +238,7 @@ declare class TypedClient<TContract extends ContractDefinition> {
160
238
  ...temporalOptions
161
239
  }: TypedWorkflowStartOptions & {
162
240
  args: ClientInferInput<TContract["workflows"][TWorkflowName]>;
163
- }): Future$1<Result$1<TypedWorkflowHandle<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
241
+ }): Future<Result<TypedWorkflowHandle<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
164
242
  /**
165
243
  * Execute a workflow (start and wait for result) with Future/Result pattern
166
244
  *
@@ -171,7 +249,7 @@ declare class TypedClient<TContract extends ContractDefinition> {
171
249
  * args: { orderId: 'ORD-123' },
172
250
  * workflowExecutionTimeout: '1 day',
173
251
  * retry: { maximumAttempts: 3 },
174
- * }).toPromise();
252
+ * });
175
253
  *
176
254
  * result.match({
177
255
  * Ok: (output) => console.log('Order processed:', output.status),
@@ -184,24 +262,24 @@ declare class TypedClient<TContract extends ContractDefinition> {
184
262
  ...temporalOptions
185
263
  }: TypedWorkflowStartOptions & {
186
264
  args: ClientInferInput<TContract["workflows"][TWorkflowName]>;
187
- }): Future$1<Result$1<ClientInferOutput<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
265
+ }): Future<Result<ClientInferOutput<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
188
266
  /**
189
267
  * Get a handle to an existing workflow with Future/Result pattern
190
268
  *
191
269
  * @example
192
270
  * ```ts
193
- * const handleResult = await client.getHandle('processOrder', 'order-123').toPromise();
271
+ * const handleResult = await client.getHandle('processOrder', 'order-123');
194
272
  * handleResult.match({
195
273
  * Ok: async (handle) => {
196
- * const result = await handle.result().toPromise();
274
+ * const result = await handle.result();
197
275
  * // ... handle result
198
276
  * },
199
277
  * Error: (error) => console.error('Failed to get handle:', error),
200
278
  * });
201
279
  * ```
202
280
  */
203
- getHandle<TWorkflowName extends keyof TContract["workflows"]>(workflowName: TWorkflowName, workflowId: string): Future$1<Result$1<TypedWorkflowHandle<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
281
+ getHandle<TWorkflowName extends keyof TContract["workflows"]>(workflowName: TWorkflowName, workflowId: string): Future<Result<TypedWorkflowHandle<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
204
282
  private createTypedHandle;
205
283
  }
206
284
  //#endregion
207
- export { AsyncData, Future, Option, QueryValidationError, Result, SignalValidationError, TypedClient, TypedClientError, type TypedWorkflowHandle, type TypedWorkflowStartOptions, UpdateValidationError, WorkflowNotFoundError, WorkflowValidationError };
285
+ 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, SignalValidationError, TypedClient, TypedClientError, type TypedWorkflowHandle, type TypedWorkflowStartOptions, UpdateValidationError, WorkflowNotFoundError, WorkflowValidationError };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,86 @@
1
1
  import { ClientOptions, WorkflowHandle, WorkflowOptions, WorkflowStartOptions } from "@temporalio/client";
2
- import { AsyncData, Future, Future as Future$1, Option, Result, Result as Result$1 } from "@swan-io/boxed";
3
- import { ClientInferInput, ClientInferOutput, ClientInferWorkflowQueries, ClientInferWorkflowSignals, ClientInferWorkflowUpdates, ContractDefinition, WorkflowDefinition } from "@temporal-contract/contract";
2
+ import { Future, Result } from "@temporal-contract/boxed";
3
+ import { ActivityDefinition, AnySchema, ContractDefinition, QueryDefinition, SignalDefinition, UpdateDefinition, WorkflowDefinition } from "@temporal-contract/contract";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
 
6
+ //#region src/types.d.ts
7
+
8
+ /**
9
+ * Infer input type from a definition (client perspective)
10
+ * Client sends the input type (before input schema parsing/transformation)
11
+ */
12
+ type ClientInferInput<T extends {
13
+ input: AnySchema;
14
+ }> = StandardSchemaV1.InferInput<T["input"]>;
15
+ /**
16
+ * Infer output type from a definition (client perspective)
17
+ * Client receives the output type (after output schema parsing/transformation)
18
+ */
19
+ type ClientInferOutput<T extends {
20
+ output: AnySchema;
21
+ }> = StandardSchemaV1.InferOutput<T["output"]>;
22
+ /**
23
+ * CLIENT PERSPECTIVE
24
+ * Client sends z.output and receives z.input
25
+ */
26
+ /**
27
+ * Infer workflow function signature from client perspective
28
+ * Client sends z.output and receives z.input
29
+ */
30
+ type ClientInferWorkflow<TWorkflow extends WorkflowDefinition> = (args: ClientInferInput<TWorkflow>) => Promise<ClientInferOutput<TWorkflow>>;
31
+ /**
32
+ * Infer activity function signature from client perspective
33
+ * Client sends z.output and receives z.input
34
+ */
35
+ type ClientInferActivity<TActivity extends ActivityDefinition> = (args: ClientInferInput<TActivity>) => Promise<ClientInferOutput<TActivity>>;
36
+ /**
37
+ * Infer signal handler signature from client perspective
38
+ * Client sends z.output and returns Future<Result<void, Error>>
39
+ */
40
+ type ClientInferSignal<TSignal extends SignalDefinition> = (args: ClientInferInput<TSignal>) => Future<Result<void, Error>>;
41
+ /**
42
+ * Infer query handler signature from client perspective
43
+ * Client sends z.output and receives z.input wrapped in Future<Result<T, Error>>
44
+ */
45
+ type ClientInferQuery<TQuery extends QueryDefinition> = (args: ClientInferInput<TQuery>) => Future<Result<ClientInferOutput<TQuery>, Error>>;
46
+ /**
47
+ * Infer update handler signature from client perspective
48
+ * Client sends z.output and receives z.input wrapped in Future<Result<T, Error>>
49
+ */
50
+ type ClientInferUpdate<TUpdate extends UpdateDefinition> = (args: ClientInferInput<TUpdate>) => Future<Result<ClientInferOutput<TUpdate>, Error>>;
51
+ /**
52
+ * CLIENT PERSPECTIVE - Contract-level types
53
+ */
54
+ /**
55
+ * Infer all workflows from a contract (client perspective)
56
+ */
57
+ type ClientInferWorkflows<TContract extends ContractDefinition> = { [K in keyof TContract["workflows"]]: ClientInferWorkflow<TContract["workflows"][K]> };
58
+ /**
59
+ * Infer all activities from a contract (client perspective)
60
+ */
61
+ type ClientInferActivities<TContract extends ContractDefinition> = TContract["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof TContract["activities"]]: ClientInferActivity<TContract["activities"][K]> } : {};
62
+ /**
63
+ * Infer activities from a workflow definition (client perspective)
64
+ */
65
+ type ClientInferWorkflowActivities<T extends WorkflowDefinition> = T["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof T["activities"]]: ClientInferActivity<T["activities"][K]> } : {};
66
+ /**
67
+ * Infer signals from a workflow definition (client perspective)
68
+ */
69
+ type ClientInferWorkflowSignals<T extends WorkflowDefinition> = T["signals"] extends Record<string, SignalDefinition> ? { [K in keyof T["signals"]]: ClientInferSignal<T["signals"][K]> } : {};
70
+ /**
71
+ * Infer queries from a workflow definition (client perspective)
72
+ */
73
+ type ClientInferWorkflowQueries<T extends WorkflowDefinition> = T["queries"] extends Record<string, QueryDefinition> ? { [K in keyof T["queries"]]: ClientInferQuery<T["queries"][K]> } : {};
74
+ /**
75
+ * Infer updates from a workflow definition (client perspective)
76
+ */
77
+ type ClientInferWorkflowUpdates<T extends WorkflowDefinition> = T["updates"] extends Record<string, UpdateDefinition> ? { [K in keyof T["updates"]]: ClientInferUpdate<T["updates"][K]> } : {};
78
+ /**
79
+ * Infer all activities available in a workflow context (client perspective)
80
+ * Combines workflow-specific activities with global activities
81
+ */
82
+ type ClientInferWorkflowContextActivities<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"]> = ClientInferWorkflowActivities<TContract["workflows"][TWorkflowName]> & ClientInferActivities<TContract>;
83
+ //#endregion
6
84
  //#region src/errors.d.ts
7
85
  /**
8
86
  * Base class for all typed client errors with boxed pattern
@@ -69,33 +147,33 @@ interface TypedWorkflowHandle<TWorkflow extends WorkflowDefinition> {
69
147
  * Type-safe queries based on workflow definition with Result pattern
70
148
  * Each query returns Future<Result<T, Error>> instead of Promise<T>
71
149
  */
72
- queries: { [K in keyof ClientInferWorkflowQueries<TWorkflow>]: ClientInferWorkflowQueries<TWorkflow>[K] extends ((...args: infer Args) => Promise<infer R>) ? (...args: Args) => Future$1<Result$1<R, TypedClientError>> : never };
150
+ queries: { [K in keyof ClientInferWorkflowQueries<TWorkflow>]: ClientInferWorkflowQueries<TWorkflow>[K] extends ((...args: infer Args) => Future<Result<infer R, Error>>) ? (...args: Args) => Future<Result<R, TypedClientError>> : never };
73
151
  /**
74
152
  * Type-safe signals based on workflow definition with Result pattern
75
153
  * Each signal returns Future<Result<void, Error>> instead of Promise<void>
76
154
  */
77
- signals: { [K in keyof ClientInferWorkflowSignals<TWorkflow>]: ClientInferWorkflowSignals<TWorkflow>[K] extends ((...args: infer Args) => Promise<void>) ? (...args: Args) => Future$1<Result$1<void, TypedClientError>> : never };
155
+ signals: { [K in keyof ClientInferWorkflowSignals<TWorkflow>]: ClientInferWorkflowSignals<TWorkflow>[K] extends ((...args: infer Args) => Future<Result<void, Error>>) ? (...args: Args) => Future<Result<void, TypedClientError>> : never };
78
156
  /**
79
157
  * Type-safe updates based on workflow definition with Result pattern
80
158
  * Each update returns Future<Result<T, Error>> instead of Promise<T>
81
159
  */
82
- updates: { [K in keyof ClientInferWorkflowUpdates<TWorkflow>]: ClientInferWorkflowUpdates<TWorkflow>[K] extends ((...args: infer Args) => Promise<infer R>) ? (...args: Args) => Future$1<Result$1<R, TypedClientError>> : never };
160
+ updates: { [K in keyof ClientInferWorkflowUpdates<TWorkflow>]: ClientInferWorkflowUpdates<TWorkflow>[K] extends ((...args: infer Args) => Future<Result<infer R, Error>>) ? (...args: Args) => Future<Result<R, TypedClientError>> : never };
83
161
  /**
84
162
  * Get workflow result with Result pattern
85
163
  */
86
- result: () => Future$1<Result$1<ClientInferOutput<TWorkflow>, TypedClientError>>;
164
+ result: () => Future<Result<ClientInferOutput<TWorkflow>, TypedClientError>>;
87
165
  /**
88
166
  * Terminate workflow with Result pattern
89
167
  */
90
- terminate: (reason?: string) => Future$1<Result$1<void, TypedClientError>>;
168
+ terminate: (reason?: string) => Future<Result<void, TypedClientError>>;
91
169
  /**
92
170
  * Cancel workflow with Result pattern
93
171
  */
94
- cancel: () => Future$1<Result$1<void, TypedClientError>>;
172
+ cancel: () => Future<Result<void, TypedClientError>>;
95
173
  /**
96
174
  * Get workflow execution description including status and metadata
97
175
  */
98
- describe: () => Future$1<Result$1<Awaited<ReturnType<WorkflowHandle["describe"]>>, TypedClientError>>;
176
+ describe: () => Future<Result<Awaited<ReturnType<WorkflowHandle["describe"]>>, TypedClientError>>;
99
177
  /**
100
178
  * Fetch the workflow execution history
101
179
  */
@@ -125,7 +203,7 @@ declare class TypedClient<TContract extends ContractDefinition> {
125
203
  * const result = await client.executeWorkflow('processOrder', {
126
204
  * workflowId: 'order-123',
127
205
  * args: { ... },
128
- * }).toPromise();
206
+ * });
129
207
  *
130
208
  * result.match({
131
209
  * Ok: (output) => console.log('Success:', output),
@@ -144,11 +222,11 @@ declare class TypedClient<TContract extends ContractDefinition> {
144
222
  * args: { orderId: 'ORD-123' },
145
223
  * workflowExecutionTimeout: '1 day',
146
224
  * retry: { maximumAttempts: 3 },
147
- * }).toPromise();
225
+ * });
148
226
  *
149
227
  * handleResult.match({
150
228
  * Ok: async (handle) => {
151
- * const result = await handle.result().toPromise();
229
+ * const result = await handle.result();
152
230
  * // ... handle result
153
231
  * },
154
232
  * Error: (error) => console.error('Failed to start:', error),
@@ -160,7 +238,7 @@ declare class TypedClient<TContract extends ContractDefinition> {
160
238
  ...temporalOptions
161
239
  }: TypedWorkflowStartOptions & {
162
240
  args: ClientInferInput<TContract["workflows"][TWorkflowName]>;
163
- }): Future$1<Result$1<TypedWorkflowHandle<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
241
+ }): Future<Result<TypedWorkflowHandle<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
164
242
  /**
165
243
  * Execute a workflow (start and wait for result) with Future/Result pattern
166
244
  *
@@ -171,7 +249,7 @@ declare class TypedClient<TContract extends ContractDefinition> {
171
249
  * args: { orderId: 'ORD-123' },
172
250
  * workflowExecutionTimeout: '1 day',
173
251
  * retry: { maximumAttempts: 3 },
174
- * }).toPromise();
252
+ * });
175
253
  *
176
254
  * result.match({
177
255
  * Ok: (output) => console.log('Order processed:', output.status),
@@ -184,24 +262,24 @@ declare class TypedClient<TContract extends ContractDefinition> {
184
262
  ...temporalOptions
185
263
  }: TypedWorkflowStartOptions & {
186
264
  args: ClientInferInput<TContract["workflows"][TWorkflowName]>;
187
- }): Future$1<Result$1<ClientInferOutput<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
265
+ }): Future<Result<ClientInferOutput<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
188
266
  /**
189
267
  * Get a handle to an existing workflow with Future/Result pattern
190
268
  *
191
269
  * @example
192
270
  * ```ts
193
- * const handleResult = await client.getHandle('processOrder', 'order-123').toPromise();
271
+ * const handleResult = await client.getHandle('processOrder', 'order-123');
194
272
  * handleResult.match({
195
273
  * Ok: async (handle) => {
196
- * const result = await handle.result().toPromise();
274
+ * const result = await handle.result();
197
275
  * // ... handle result
198
276
  * },
199
277
  * Error: (error) => console.error('Failed to get handle:', error),
200
278
  * });
201
279
  * ```
202
280
  */
203
- getHandle<TWorkflowName extends keyof TContract["workflows"]>(workflowName: TWorkflowName, workflowId: string): Future$1<Result$1<TypedWorkflowHandle<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
281
+ getHandle<TWorkflowName extends keyof TContract["workflows"]>(workflowName: TWorkflowName, workflowId: string): Future<Result<TypedWorkflowHandle<TContract["workflows"][TWorkflowName]>, TypedClientError>>;
204
282
  private createTypedHandle;
205
283
  }
206
284
  //#endregion
207
- export { AsyncData, Future, Option, QueryValidationError, Result, SignalValidationError, TypedClient, TypedClientError, type TypedWorkflowHandle, type TypedWorkflowStartOptions, UpdateValidationError, WorkflowNotFoundError, WorkflowValidationError };
285
+ 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, SignalValidationError, TypedClient, TypedClientError, type TypedWorkflowHandle, type TypedWorkflowStartOptions, UpdateValidationError, WorkflowNotFoundError, WorkflowValidationError };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Client } from "@temporalio/client";
2
- import { AsyncData, Future, Future as Future$1, Option, Result, Result as Result$1 } from "@swan-io/boxed";
2
+ import { Future, Result } from "@temporal-contract/boxed";
3
3
 
4
4
  //#region src/errors.ts
5
5
  /**
@@ -93,7 +93,7 @@ var TypedClient = class TypedClient {
93
93
  * const result = await client.executeWorkflow('processOrder', {
94
94
  * workflowId: 'order-123',
95
95
  * args: { ... },
96
- * }).toPromise();
96
+ * });
97
97
  *
98
98
  * result.match({
99
99
  * Ok: (output) => console.log('Success:', output),
@@ -114,11 +114,11 @@ var TypedClient = class TypedClient {
114
114
  * args: { orderId: 'ORD-123' },
115
115
  * workflowExecutionTimeout: '1 day',
116
116
  * retry: { maximumAttempts: 3 },
117
- * }).toPromise();
117
+ * });
118
118
  *
119
119
  * handleResult.match({
120
120
  * Ok: async (handle) => {
121
- * const result = await handle.result().toPromise();
121
+ * const result = await handle.result();
122
122
  * // ... handle result
123
123
  * },
124
124
  * Error: (error) => console.error('Failed to start:', error),
@@ -126,16 +126,16 @@ var TypedClient = class TypedClient {
126
126
  * ```
127
127
  */
128
128
  startWorkflow(workflowName, { args, ...temporalOptions }) {
129
- return Future$1.make((resolve) => {
129
+ return Future.make((resolve) => {
130
130
  const definition = this.contract.workflows[workflowName];
131
131
  if (!definition) {
132
- resolve(Result$1.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
132
+ resolve(Result.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
133
133
  return;
134
134
  }
135
135
  (async () => {
136
136
  const inputResult = await definition.input["~standard"].validate(args);
137
137
  if (inputResult.issues) {
138
- resolve(Result$1.Error(new WorkflowValidationError(String(workflowName), "input", inputResult.issues)));
138
+ resolve(Result.Error(new WorkflowValidationError(String(workflowName), "input", inputResult.issues)));
139
139
  return;
140
140
  }
141
141
  const validatedInput = inputResult.value;
@@ -146,9 +146,9 @@ var TypedClient = class TypedClient {
146
146
  args: [validatedInput]
147
147
  });
148
148
  const typedHandle = this.createTypedHandle(handle, definition);
149
- resolve(Result$1.Ok(typedHandle));
149
+ resolve(Result.Ok(typedHandle));
150
150
  } catch (error) {
151
- resolve(Result$1.Error(new TypedClientError(`Failed to start workflow: ${error instanceof Error ? error.message : String(error)}`)));
151
+ resolve(Result.Error(new TypedClientError(`Failed to start workflow: ${error instanceof Error ? error.message : String(error)}`)));
152
152
  }
153
153
  })();
154
154
  });
@@ -163,7 +163,7 @@ var TypedClient = class TypedClient {
163
163
  * args: { orderId: 'ORD-123' },
164
164
  * workflowExecutionTimeout: '1 day',
165
165
  * retry: { maximumAttempts: 3 },
166
- * }).toPromise();
166
+ * });
167
167
  *
168
168
  * result.match({
169
169
  * Ok: (output) => console.log('Order processed:', output.status),
@@ -172,16 +172,16 @@ var TypedClient = class TypedClient {
172
172
  * ```
173
173
  */
174
174
  executeWorkflow(workflowName, { args, ...temporalOptions }) {
175
- return Future$1.make((resolve) => {
175
+ return Future.make((resolve) => {
176
176
  const definition = this.contract.workflows[workflowName];
177
177
  if (!definition) {
178
- resolve(Result$1.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
178
+ resolve(Result.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
179
179
  return;
180
180
  }
181
181
  (async () => {
182
182
  const inputResult = await definition.input["~standard"].validate(args);
183
183
  if (inputResult.issues) {
184
- resolve(Result$1.Error(new WorkflowValidationError(String(workflowName), "input", inputResult.issues)));
184
+ resolve(Result.Error(new WorkflowValidationError(String(workflowName), "input", inputResult.issues)));
185
185
  return;
186
186
  }
187
187
  const validatedInput = inputResult.value;
@@ -193,12 +193,12 @@ var TypedClient = class TypedClient {
193
193
  });
194
194
  const outputResult = await definition.output["~standard"].validate(result);
195
195
  if (outputResult.issues) {
196
- resolve(Result$1.Error(new WorkflowValidationError(String(workflowName), "output", outputResult.issues)));
196
+ resolve(Result.Error(new WorkflowValidationError(String(workflowName), "output", outputResult.issues)));
197
197
  return;
198
198
  }
199
- resolve(Result$1.Ok(outputResult.value));
199
+ resolve(Result.Ok(outputResult.value));
200
200
  } catch (error) {
201
- resolve(Result$1.Error(new TypedClientError(`Failed to execute workflow: ${error instanceof Error ? error.message : String(error)}`)));
201
+ resolve(Result.Error(new TypedClientError(`Failed to execute workflow: ${error instanceof Error ? error.message : String(error)}`)));
202
202
  }
203
203
  })();
204
204
  });
@@ -208,10 +208,10 @@ var TypedClient = class TypedClient {
208
208
  *
209
209
  * @example
210
210
  * ```ts
211
- * const handleResult = await client.getHandle('processOrder', 'order-123').toPromise();
211
+ * const handleResult = await client.getHandle('processOrder', 'order-123');
212
212
  * handleResult.match({
213
213
  * Ok: async (handle) => {
214
- * const result = await handle.result().toPromise();
214
+ * const result = await handle.result();
215
215
  * // ... handle result
216
216
  * },
217
217
  * Error: (error) => console.error('Failed to get handle:', error),
@@ -219,82 +219,82 @@ var TypedClient = class TypedClient {
219
219
  * ```
220
220
  */
221
221
  getHandle(workflowName, workflowId) {
222
- return Future$1.make((resolve) => {
222
+ return Future.make((resolve) => {
223
223
  const definition = this.contract.workflows[workflowName];
224
224
  if (!definition) {
225
- resolve(Result$1.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
225
+ resolve(Result.Error(new WorkflowNotFoundError(String(workflowName), Object.keys(this.contract.workflows))));
226
226
  return;
227
227
  }
228
228
  try {
229
229
  const handle = this.client.workflow.getHandle(workflowId);
230
230
  const typedHandle = this.createTypedHandle(handle, definition);
231
- resolve(Result$1.Ok(typedHandle));
231
+ resolve(Result.Ok(typedHandle));
232
232
  } catch (error) {
233
- resolve(Result$1.Error(new TypedClientError(`Failed to get workflow handle: ${error instanceof Error ? error.message : String(error)}`)));
233
+ resolve(Result.Error(new TypedClientError(`Failed to get workflow handle: ${error instanceof Error ? error.message : String(error)}`)));
234
234
  }
235
235
  });
236
236
  }
237
237
  createTypedHandle(handle, definition) {
238
238
  const queries = {};
239
239
  for (const [queryName, queryDef] of Object.entries(definition.queries ?? {})) queries[queryName] = (args) => {
240
- return Future$1.make((resolve) => {
240
+ return Future.make((resolve) => {
241
241
  (async () => {
242
242
  const inputResult = await queryDef.input["~standard"].validate(args);
243
243
  if (inputResult.issues) {
244
- resolve(Result$1.Error(new QueryValidationError(queryName, "input", inputResult.issues)));
244
+ resolve(Result.Error(new QueryValidationError(queryName, "input", inputResult.issues)));
245
245
  return;
246
246
  }
247
247
  try {
248
248
  const result = await handle.query(queryName, inputResult.value);
249
249
  const outputResult = await queryDef.output["~standard"].validate(result);
250
250
  if (outputResult.issues) {
251
- resolve(Result$1.Error(new QueryValidationError(queryName, "output", outputResult.issues)));
251
+ resolve(Result.Error(new QueryValidationError(queryName, "output", outputResult.issues)));
252
252
  return;
253
253
  }
254
- resolve(Result$1.Ok(outputResult.value));
254
+ resolve(Result.Ok(outputResult.value));
255
255
  } catch (error) {
256
- resolve(Result$1.Error(new TypedClientError(`Query failed: ${error instanceof Error ? error.message : String(error)}`)));
256
+ resolve(Result.Error(new TypedClientError(`Query failed: ${error instanceof Error ? error.message : String(error)}`)));
257
257
  }
258
258
  })();
259
259
  });
260
260
  };
261
261
  const signals = {};
262
262
  for (const [signalName, signalDef] of Object.entries(definition.signals ?? {})) signals[signalName] = (args) => {
263
- return Future$1.make((resolve) => {
263
+ return Future.make((resolve) => {
264
264
  (async () => {
265
265
  const inputResult = await signalDef.input["~standard"].validate(args);
266
266
  if (inputResult.issues) {
267
- resolve(Result$1.Error(new SignalValidationError(signalName, inputResult.issues)));
267
+ resolve(Result.Error(new SignalValidationError(signalName, inputResult.issues)));
268
268
  return;
269
269
  }
270
270
  try {
271
271
  await handle.signal(signalName, inputResult.value);
272
- resolve(Result$1.Ok(void 0));
272
+ resolve(Result.Ok(void 0));
273
273
  } catch (error) {
274
- resolve(Result$1.Error(new TypedClientError(`Signal failed: ${error instanceof Error ? error.message : String(error)}`)));
274
+ resolve(Result.Error(new TypedClientError(`Signal failed: ${error instanceof Error ? error.message : String(error)}`)));
275
275
  }
276
276
  })();
277
277
  });
278
278
  };
279
279
  const updates = {};
280
280
  for (const [updateName, updateDef] of Object.entries(definition.updates ?? {})) updates[updateName] = (args) => {
281
- return Future$1.make((resolve) => {
281
+ return Future.make((resolve) => {
282
282
  (async () => {
283
283
  const inputResult = await updateDef.input["~standard"].validate(args);
284
284
  if (inputResult.issues) {
285
- resolve(Result$1.Error(new UpdateValidationError(updateName, "input", inputResult.issues)));
285
+ resolve(Result.Error(new UpdateValidationError(updateName, "input", inputResult.issues)));
286
286
  return;
287
287
  }
288
288
  try {
289
289
  const result = await handle.executeUpdate(updateName, { args: [inputResult.value] });
290
290
  const outputResult = await updateDef.output["~standard"].validate(result);
291
291
  if (outputResult.issues) {
292
- resolve(Result$1.Error(new UpdateValidationError(updateName, "output", outputResult.issues)));
292
+ resolve(Result.Error(new UpdateValidationError(updateName, "output", outputResult.issues)));
293
293
  return;
294
294
  }
295
- resolve(Result$1.Ok(outputResult.value));
295
+ resolve(Result.Ok(outputResult.value));
296
296
  } catch (error) {
297
- resolve(Result$1.Error(new TypedClientError(`Update failed: ${error instanceof Error ? error.message : String(error)}`)));
297
+ resolve(Result.Error(new TypedClientError(`Update failed: ${error instanceof Error ? error.message : String(error)}`)));
298
298
  }
299
299
  })();
300
300
  });
@@ -305,54 +305,54 @@ var TypedClient = class TypedClient {
305
305
  signals,
306
306
  updates,
307
307
  result: () => {
308
- return Future$1.make((resolve) => {
308
+ return Future.make((resolve) => {
309
309
  (async () => {
310
310
  try {
311
311
  const result = await handle.result();
312
312
  const outputResult = await definition.output["~standard"].validate(result);
313
313
  if (outputResult.issues) {
314
- resolve(Result$1.Error(new WorkflowValidationError(handle.workflowId, "output", outputResult.issues)));
314
+ resolve(Result.Error(new WorkflowValidationError(handle.workflowId, "output", outputResult.issues)));
315
315
  return;
316
316
  }
317
- resolve(Result$1.Ok(outputResult.value));
317
+ resolve(Result.Ok(outputResult.value));
318
318
  } catch (error) {
319
- resolve(Result$1.Error(new TypedClientError(`Workflow execution failed: ${error instanceof Error ? error.message : String(error)}`)));
319
+ resolve(Result.Error(new TypedClientError(`Workflow execution failed: ${error instanceof Error ? error.message : String(error)}`)));
320
320
  }
321
321
  })();
322
322
  });
323
323
  },
324
324
  terminate: (reason) => {
325
- return Future$1.make((resolve) => {
325
+ return Future.make((resolve) => {
326
326
  (async () => {
327
327
  try {
328
328
  await handle.terminate(reason);
329
- resolve(Result$1.Ok(void 0));
329
+ resolve(Result.Ok(void 0));
330
330
  } catch (error) {
331
- resolve(Result$1.Error(new TypedClientError(`Terminate failed: ${error instanceof Error ? error.message : String(error)}`)));
331
+ resolve(Result.Error(new TypedClientError(`Terminate failed: ${error instanceof Error ? error.message : String(error)}`)));
332
332
  }
333
333
  })();
334
334
  });
335
335
  },
336
336
  cancel: () => {
337
- return Future$1.make((resolve) => {
337
+ return Future.make((resolve) => {
338
338
  (async () => {
339
339
  try {
340
340
  await handle.cancel();
341
- resolve(Result$1.Ok(void 0));
341
+ resolve(Result.Ok(void 0));
342
342
  } catch (error) {
343
- resolve(Result$1.Error(new TypedClientError(`Cancel failed: ${error instanceof Error ? error.message : String(error)}`)));
343
+ resolve(Result.Error(new TypedClientError(`Cancel failed: ${error instanceof Error ? error.message : String(error)}`)));
344
344
  }
345
345
  })();
346
346
  });
347
347
  },
348
348
  describe: () => {
349
- return Future$1.make((resolve) => {
349
+ return Future.make((resolve) => {
350
350
  (async () => {
351
351
  try {
352
352
  const description = await handle.describe();
353
- resolve(Result$1.Ok(description));
353
+ resolve(Result.Ok(description));
354
354
  } catch (error) {
355
- resolve(Result$1.Error(new TypedClientError(`Describe failed: ${error instanceof Error ? error.message : String(error)}`)));
355
+ resolve(Result.Error(new TypedClientError(`Describe failed: ${error instanceof Error ? error.message : String(error)}`)));
356
356
  }
357
357
  })();
358
358
  });
@@ -363,4 +363,4 @@ var TypedClient = class TypedClient {
363
363
  };
364
364
 
365
365
  //#endregion
366
- export { AsyncData, Future, Option, QueryValidationError, Result, SignalValidationError, TypedClient, TypedClientError, UpdateValidationError, WorkflowNotFoundError, WorkflowValidationError };
366
+ export { QueryValidationError, SignalValidationError, TypedClient, TypedClientError, UpdateValidationError, WorkflowNotFoundError, WorkflowValidationError };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@temporal-contract/client",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Client utilities with Result/Future pattern for consuming temporal-contract workflows",
5
5
  "keywords": [
6
- "temporal",
7
- "typescript",
8
- "contract",
9
6
  "client",
7
+ "contract",
8
+ "future",
10
9
  "result",
11
- "future"
10
+ "temporal",
11
+ "typescript"
12
12
  ],
13
13
  "homepage": "https://github.com/btravers/temporal-contract#readme",
14
14
  "bugs": {
@@ -42,22 +42,22 @@
42
42
  "dist"
43
43
  ],
44
44
  "dependencies": {
45
- "@standard-schema/spec": "1.0.0",
46
- "@swan-io/boxed": "3.2.1",
47
- "@temporal-contract/contract": "0.0.4"
45
+ "@standard-schema/spec": "1.1.0",
46
+ "@temporal-contract/boxed": "0.0.5",
47
+ "@temporal-contract/contract": "0.0.5"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@temporalio/client": "1.13.2",
51
- "@types/node": "25.0.1",
52
- "@vitest/coverage-v8": "4.0.15",
53
- "tsdown": "0.17.3",
51
+ "@types/node": "25.0.2",
52
+ "@vitest/coverage-v8": "4.0.16",
53
+ "tsdown": "0.18.0",
54
54
  "typescript": "5.9.3",
55
- "vitest": "4.0.15",
56
- "zod": "4.1.13",
57
- "@temporal-contract/tsconfig": "0.0.4"
55
+ "vitest": "4.0.16",
56
+ "zod": "4.2.1",
57
+ "@temporal-contract/tsconfig": "0.0.5"
58
58
  },
59
59
  "peerDependencies": {
60
- "@temporalio/client": ">=1.13.0 <2.0.0"
60
+ "@temporalio/client": "^1"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "tsdown src/index.ts --format cjs,esm --dts --clean",