@temporal-contract/worker 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,22 +15,19 @@ pnpm add @temporal-contract/worker @temporal-contract/contract @temporalio/workf
15
15
  ```typescript
16
16
  // activities.ts
17
17
  import { declareActivitiesHandler, ApplicationFailure } from "@temporal-contract/worker/activity";
18
- import { Future, Result } from "@swan-io/boxed";
18
+ import { ResultAsync } from "neverthrow";
19
19
 
20
20
  export const activities = declareActivitiesHandler({
21
21
  contract: myContract,
22
22
  activities: {
23
- sendEmail: ({ to, body }) => {
24
- return Future.fromPromise(emailService.send({ to, body }))
25
- .mapError((error) =>
26
- ApplicationFailure.create({
27
- type: "EMAIL_FAILED",
28
- message: error instanceof Error ? error.message : "Failed to send email",
29
- cause: error,
30
- }),
31
- )
32
- .mapOk(() => ({ sent: true }));
33
- },
23
+ sendEmail: ({ to, body }) =>
24
+ ResultAsync.fromPromise(emailService.send({ to, body }), (error) =>
25
+ ApplicationFailure.create({
26
+ type: "EMAIL_FAILED",
27
+ message: error instanceof Error ? error.message : "Failed to send email",
28
+ cause: error,
29
+ }),
30
+ ).map(() => ({ sent: true })),
34
31
  },
35
32
  });
36
33
 
@@ -68,7 +65,7 @@ run().catch(console.error);
68
65
 
69
66
  ### Child Workflows
70
67
 
71
- Execute child workflows with type-safe Future/Result pattern. Supports both same-contract and cross-contract child workflows:
68
+ Execute child workflows with type-safe `ResultAsync`. Supports both same-contract and cross-contract child workflows:
72
69
 
73
70
  ```typescript
74
71
  // workflows.ts
@@ -85,10 +82,10 @@ export const parentWorkflow = declareWorkflow({
85
82
  args: { amount: input.totalAmount },
86
83
  });
87
84
 
88
- childResult.match({
89
- Ok: (output) => console.log("Payment processed:", output),
90
- Error: (error) => console.error("Payment failed:", error),
91
- });
85
+ childResult.match(
86
+ (output) => console.log("Payment processed:", output),
87
+ (error) => console.error("Payment failed:", error),
88
+ );
92
89
 
93
90
  // Execute child workflow from another contract (another worker)
94
91
  const notificationResult = await context.executeChildWorkflow(
@@ -106,14 +103,14 @@ export const parentWorkflow = declareWorkflow({
106
103
  args: { to: "user@example.com", body: "Order received" },
107
104
  });
108
105
 
109
- handleResult.match({
110
- Ok: async (handle) => {
106
+ handleResult.match(
107
+ async (handle) => {
111
108
  // Can wait for result later
112
109
  const result = await handle.result();
113
110
  // ...
114
111
  },
115
- Error: (error) => console.error("Failed to start:", error),
116
- });
112
+ (error) => console.error("Failed to start:", error),
113
+ );
117
114
 
118
115
  return { success: true };
119
116
  },
package/dist/activity.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_internal = require("./internal-Tj4m4f_K.cjs");
2
+ const require_internal = require("./internal-C8MB-kez.cjs");
3
3
  let _temporalio_common = require("@temporalio/common");
4
4
  //#region src/activity.ts
5
5
  /**
@@ -7,7 +7,7 @@ let _temporalio_common = require("@temporalio/common");
7
7
  *
8
8
  * This wraps all activity implementations with:
9
9
  * - Validation at network boundaries
10
- * - `Result<T, ApplicationFailure>` pattern for explicit error handling
10
+ * - `ResultAsync<T, ApplicationFailure>` pattern for explicit error handling
11
11
  * - Automatic conversion from Result to Promise (throwing on Error)
12
12
  *
13
13
  * TypeScript ensures ALL activities (global + workflow-specific) are implemented.
@@ -17,33 +17,27 @@ let _temporalio_common = require("@temporalio/common");
17
17
  * @example
18
18
  * ```ts
19
19
  * import { declareActivitiesHandler, ApplicationFailure } from '@temporal-contract/worker/activity';
20
- * import { Result, Future } from '@swan-io/boxed';
20
+ * import { ResultAsync, errAsync, okAsync } from 'neverthrow';
21
21
  * import myContract from './contract';
22
22
  *
23
23
  * export const activities = declareActivitiesHandler({
24
24
  * contract: myContract,
25
25
  * activities: {
26
- * // Activity returns Result instead of throwing.
27
- * sendEmail: (args) => {
28
- * return Future.make(async (resolve) => {
29
- * try {
30
- * await emailService.send(args);
31
- * resolve(Result.Ok({ sent: true }));
32
- * } catch (error) {
26
+ * // Activity returns ResultAsync instead of throwing.
27
+ * sendEmail: (args) =>
28
+ * ResultAsync.fromPromise(
29
+ * emailService.send(args),
30
+ * (error) =>
33
31
  * // Wrap technical errors in ApplicationFailure. `nonRetryable`
34
32
  * // is per-instance: set it to true on permanent failures so
35
33
  * // Temporal stops retrying immediately.
36
- * resolve(Result.Error(
37
- * ApplicationFailure.create({
38
- * type: 'EMAIL_SEND_FAILED',
39
- * message: 'Failed to send email',
40
- * nonRetryable: false,
41
- * cause: error instanceof Error ? error : undefined,
42
- * }),
43
- * ));
44
- * }
45
- * });
46
- * },
34
+ * ApplicationFailure.create({
35
+ * type: 'EMAIL_SEND_FAILED',
36
+ * message: 'Failed to send email',
37
+ * nonRetryable: false,
38
+ * cause: error instanceof Error ? error : undefined,
39
+ * }),
40
+ * ).map(() => ({ sent: true })),
47
41
  * },
48
42
  * });
49
43
  *
@@ -59,9 +53,9 @@ let _temporalio_common = require("@temporalio/common");
59
53
  *
60
54
  * @remarks
61
55
  * The wrapper accepts implementations in the
62
- * `Future<Result<T, ApplicationFailure>>` shape and produces ordinary
63
- * Promise-returning Temporal handlers (Result.Error → thrown
64
- * `ApplicationFailure`; Result.Ok → output validated against the
56
+ * `ResultAsync<T, ApplicationFailure>` shape and produces ordinary
57
+ * Promise-returning Temporal handlers (`err(...)` → thrown
58
+ * `ApplicationFailure`; `ok(...)` → output validated against the
65
59
  * contract and resolved). It does **not** hide Temporal's
66
60
  * `@temporalio/activity` runtime: inside the body you can still call
67
61
  * `Context.current()` from `@temporalio/activity` to access heartbeats
@@ -1,30 +1,30 @@
1
- import { _ as WorkerInferOutput, g as WorkerInferInput, n as ActivityInputValidationError, r as ActivityOutputValidationError, t as ActivityDefinitionNotFoundError } from "./errors-CG1y7SHO.cjs";
1
+ import { _ as WorkerInferOutput, g as WorkerInferInput, n as ActivityInputValidationError, r as ActivityOutputValidationError, t as ActivityDefinitionNotFoundError } from "./errors-BeIXtRJe.cjs";
2
2
  import { ActivityDefinition, ContractDefinition } from "@temporal-contract/contract";
3
- import { Future, Result } from "@swan-io/boxed";
3
+ import { ResultAsync } from "neverthrow";
4
4
  import { ApplicationFailure, ApplicationFailure as ApplicationFailure$1 } from "@temporalio/common";
5
5
 
6
6
  //#region src/activity.d.ts
7
7
  /**
8
- * Activity implementation using Future/Result pattern.
8
+ * Activity implementation using neverthrow's `ResultAsync`.
9
9
  *
10
- * Returns `Future<Result<Output, ApplicationFailure>>` for explicit error
11
- * handling instead of throwing. The wrapper rethrows `Result.Error`
12
- * payloads at the activity boundary; Temporal recognizes
13
- * `ApplicationFailure` natively and applies the configured retry policy
14
- * (with `nonRetryable: true` opting an instance out per-call).
10
+ * Returns `ResultAsync<Output, ApplicationFailure>` for explicit error
11
+ * handling instead of throwing. The wrapper rethrows `err()` payloads at
12
+ * the activity boundary; Temporal recognizes `ApplicationFailure` natively
13
+ * and applies the configured retry policy (with `nonRetryable: true`
14
+ * opting an instance out per-call).
15
15
  */
16
- type BoxedActivityImplementation<TActivity extends ActivityDefinition> = (args: WorkerInferInput<TActivity>) => Future<Result<WorkerInferOutput<TActivity>, ApplicationFailure$1>>;
16
+ type ResultActivityImplementation<TActivity extends ActivityDefinition> = (args: WorkerInferInput<TActivity>) => ResultAsync<WorkerInferOutput<TActivity>, ApplicationFailure$1>;
17
17
  /**
18
18
  * Map of all activity implementations for a contract (global + all workflow-specific)
19
19
  */
20
- type ContractBoxedActivitiesImplementations<TContract extends ContractDefinition> = (TContract["activities"] extends Record<string, ActivityDefinition> ? BoxedActivitiesImplementations<TContract["activities"]> : {}) & { [TWorkflow in keyof TContract["workflows"]]: TContract["workflows"][TWorkflow]["activities"] extends Record<string, ActivityDefinition> ? BoxedActivitiesImplementations<TContract["workflows"][TWorkflow]["activities"]> : {} };
21
- type BoxedActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = { [K in keyof TActivities]: BoxedActivityImplementation<TActivities[K]> };
20
+ type ContractResultActivitiesImplementations<TContract extends ContractDefinition> = (TContract["activities"] extends Record<string, ActivityDefinition> ? ResultActivitiesImplementations<TContract["activities"]> : {}) & { [TWorkflow in keyof TContract["workflows"]]: TContract["workflows"][TWorkflow]["activities"] extends Record<string, ActivityDefinition> ? ResultActivitiesImplementations<TContract["workflows"][TWorkflow]["activities"]> : {} };
21
+ type ResultActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = { [K in keyof TActivities]: ResultActivityImplementation<TActivities[K]> };
22
22
  /**
23
23
  * Options for creating activities handler
24
24
  */
25
25
  type DeclareActivitiesHandlerOptions<TContract extends ContractDefinition> = {
26
26
  contract: TContract;
27
- activities: ContractBoxedActivitiesImplementations<TContract>;
27
+ activities: ContractResultActivitiesImplementations<TContract>;
28
28
  };
29
29
  type ActivityImplementation<TActivity extends ActivityDefinition> = (args: WorkerInferInput<TActivity>) => Promise<WorkerInferOutput<TActivity>>;
30
30
  type ActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = { [K in keyof TActivities]: ActivityImplementation<TActivities[K]> };
@@ -40,7 +40,7 @@ type ActivitiesHandler<TContract extends ContractDefinition> = (TContract["activ
40
40
  *
41
41
  * This wraps all activity implementations with:
42
42
  * - Validation at network boundaries
43
- * - `Result<T, ApplicationFailure>` pattern for explicit error handling
43
+ * - `ResultAsync<T, ApplicationFailure>` pattern for explicit error handling
44
44
  * - Automatic conversion from Result to Promise (throwing on Error)
45
45
  *
46
46
  * TypeScript ensures ALL activities (global + workflow-specific) are implemented.
@@ -50,33 +50,27 @@ type ActivitiesHandler<TContract extends ContractDefinition> = (TContract["activ
50
50
  * @example
51
51
  * ```ts
52
52
  * import { declareActivitiesHandler, ApplicationFailure } from '@temporal-contract/worker/activity';
53
- * import { Result, Future } from '@swan-io/boxed';
53
+ * import { ResultAsync, errAsync, okAsync } from 'neverthrow';
54
54
  * import myContract from './contract';
55
55
  *
56
56
  * export const activities = declareActivitiesHandler({
57
57
  * contract: myContract,
58
58
  * activities: {
59
- * // Activity returns Result instead of throwing.
60
- * sendEmail: (args) => {
61
- * return Future.make(async (resolve) => {
62
- * try {
63
- * await emailService.send(args);
64
- * resolve(Result.Ok({ sent: true }));
65
- * } catch (error) {
59
+ * // Activity returns ResultAsync instead of throwing.
60
+ * sendEmail: (args) =>
61
+ * ResultAsync.fromPromise(
62
+ * emailService.send(args),
63
+ * (error) =>
66
64
  * // Wrap technical errors in ApplicationFailure. `nonRetryable`
67
65
  * // is per-instance: set it to true on permanent failures so
68
66
  * // Temporal stops retrying immediately.
69
- * resolve(Result.Error(
70
- * ApplicationFailure.create({
71
- * type: 'EMAIL_SEND_FAILED',
72
- * message: 'Failed to send email',
73
- * nonRetryable: false,
74
- * cause: error instanceof Error ? error : undefined,
75
- * }),
76
- * ));
77
- * }
78
- * });
79
- * },
67
+ * ApplicationFailure.create({
68
+ * type: 'EMAIL_SEND_FAILED',
69
+ * message: 'Failed to send email',
70
+ * nonRetryable: false,
71
+ * cause: error instanceof Error ? error : undefined,
72
+ * }),
73
+ * ).map(() => ({ sent: true })),
80
74
  * },
81
75
  * });
82
76
  *
@@ -92,9 +86,9 @@ type ActivitiesHandler<TContract extends ContractDefinition> = (TContract["activ
92
86
  *
93
87
  * @remarks
94
88
  * The wrapper accepts implementations in the
95
- * `Future<Result<T, ApplicationFailure>>` shape and produces ordinary
96
- * Promise-returning Temporal handlers (Result.Error → thrown
97
- * `ApplicationFailure`; Result.Ok → output validated against the
89
+ * `ResultAsync<T, ApplicationFailure>` shape and produces ordinary
90
+ * Promise-returning Temporal handlers (`err(...)` → thrown
91
+ * `ApplicationFailure`; `ok(...)` → output validated against the
98
92
  * contract and resolved). It does **not** hide Temporal's
99
93
  * `@temporalio/activity` runtime: inside the body you can still call
100
94
  * `Context.current()` from `@temporalio/activity` to access heartbeats
@@ -1 +1 @@
1
- {"version":3,"file":"activity.d.cts","names":[],"sources":["../src/activity.ts"],"mappings":";;;;;;AAgCwD;;;;;;;;;AAAA,KAWnD,2BAAA,mBAA8C,kBAAA,K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jD4D;;;;;;;;;;;;;;;;;;;;;AAKJ;;;;;;;;;;;;;;;;;;AAQP;;iBAqG/C,wBAAA,mBAA2C,kBAAA,CAAA,CACzD,OAAA,EAAS,+BAAA,CAAgC,SAAA,IACxC,iBAAA,CAAkB,SAAA"}
@@ -1,30 +1,30 @@
1
- import { _ as WorkerInferOutput, g as WorkerInferInput, n as ActivityInputValidationError, r as ActivityOutputValidationError, t as ActivityDefinitionNotFoundError } from "./errors-DZhaNhwr.mjs";
1
+ import { _ as WorkerInferOutput, g as WorkerInferInput, n as ActivityInputValidationError, r as ActivityOutputValidationError, t as ActivityDefinitionNotFoundError } from "./errors-BjNG_jUi.mjs";
2
2
  import { ApplicationFailure, ApplicationFailure as ApplicationFailure$1 } from "@temporalio/common";
3
+ import { ResultAsync } from "neverthrow";
3
4
  import { ActivityDefinition, ContractDefinition } from "@temporal-contract/contract";
4
- import { Future, Result } from "@swan-io/boxed";
5
5
 
6
6
  //#region src/activity.d.ts
7
7
  /**
8
- * Activity implementation using Future/Result pattern.
8
+ * Activity implementation using neverthrow's `ResultAsync`.
9
9
  *
10
- * Returns `Future<Result<Output, ApplicationFailure>>` for explicit error
11
- * handling instead of throwing. The wrapper rethrows `Result.Error`
12
- * payloads at the activity boundary; Temporal recognizes
13
- * `ApplicationFailure` natively and applies the configured retry policy
14
- * (with `nonRetryable: true` opting an instance out per-call).
10
+ * Returns `ResultAsync<Output, ApplicationFailure>` for explicit error
11
+ * handling instead of throwing. The wrapper rethrows `err()` payloads at
12
+ * the activity boundary; Temporal recognizes `ApplicationFailure` natively
13
+ * and applies the configured retry policy (with `nonRetryable: true`
14
+ * opting an instance out per-call).
15
15
  */
16
- type BoxedActivityImplementation<TActivity extends ActivityDefinition> = (args: WorkerInferInput<TActivity>) => Future<Result<WorkerInferOutput<TActivity>, ApplicationFailure$1>>;
16
+ type ResultActivityImplementation<TActivity extends ActivityDefinition> = (args: WorkerInferInput<TActivity>) => ResultAsync<WorkerInferOutput<TActivity>, ApplicationFailure$1>;
17
17
  /**
18
18
  * Map of all activity implementations for a contract (global + all workflow-specific)
19
19
  */
20
- type ContractBoxedActivitiesImplementations<TContract extends ContractDefinition> = (TContract["activities"] extends Record<string, ActivityDefinition> ? BoxedActivitiesImplementations<TContract["activities"]> : {}) & { [TWorkflow in keyof TContract["workflows"]]: TContract["workflows"][TWorkflow]["activities"] extends Record<string, ActivityDefinition> ? BoxedActivitiesImplementations<TContract["workflows"][TWorkflow]["activities"]> : {} };
21
- type BoxedActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = { [K in keyof TActivities]: BoxedActivityImplementation<TActivities[K]> };
20
+ type ContractResultActivitiesImplementations<TContract extends ContractDefinition> = (TContract["activities"] extends Record<string, ActivityDefinition> ? ResultActivitiesImplementations<TContract["activities"]> : {}) & { [TWorkflow in keyof TContract["workflows"]]: TContract["workflows"][TWorkflow]["activities"] extends Record<string, ActivityDefinition> ? ResultActivitiesImplementations<TContract["workflows"][TWorkflow]["activities"]> : {} };
21
+ type ResultActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = { [K in keyof TActivities]: ResultActivityImplementation<TActivities[K]> };
22
22
  /**
23
23
  * Options for creating activities handler
24
24
  */
25
25
  type DeclareActivitiesHandlerOptions<TContract extends ContractDefinition> = {
26
26
  contract: TContract;
27
- activities: ContractBoxedActivitiesImplementations<TContract>;
27
+ activities: ContractResultActivitiesImplementations<TContract>;
28
28
  };
29
29
  type ActivityImplementation<TActivity extends ActivityDefinition> = (args: WorkerInferInput<TActivity>) => Promise<WorkerInferOutput<TActivity>>;
30
30
  type ActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = { [K in keyof TActivities]: ActivityImplementation<TActivities[K]> };
@@ -40,7 +40,7 @@ type ActivitiesHandler<TContract extends ContractDefinition> = (TContract["activ
40
40
  *
41
41
  * This wraps all activity implementations with:
42
42
  * - Validation at network boundaries
43
- * - `Result<T, ApplicationFailure>` pattern for explicit error handling
43
+ * - `ResultAsync<T, ApplicationFailure>` pattern for explicit error handling
44
44
  * - Automatic conversion from Result to Promise (throwing on Error)
45
45
  *
46
46
  * TypeScript ensures ALL activities (global + workflow-specific) are implemented.
@@ -50,33 +50,27 @@ type ActivitiesHandler<TContract extends ContractDefinition> = (TContract["activ
50
50
  * @example
51
51
  * ```ts
52
52
  * import { declareActivitiesHandler, ApplicationFailure } from '@temporal-contract/worker/activity';
53
- * import { Result, Future } from '@swan-io/boxed';
53
+ * import { ResultAsync, errAsync, okAsync } from 'neverthrow';
54
54
  * import myContract from './contract';
55
55
  *
56
56
  * export const activities = declareActivitiesHandler({
57
57
  * contract: myContract,
58
58
  * activities: {
59
- * // Activity returns Result instead of throwing.
60
- * sendEmail: (args) => {
61
- * return Future.make(async (resolve) => {
62
- * try {
63
- * await emailService.send(args);
64
- * resolve(Result.Ok({ sent: true }));
65
- * } catch (error) {
59
+ * // Activity returns ResultAsync instead of throwing.
60
+ * sendEmail: (args) =>
61
+ * ResultAsync.fromPromise(
62
+ * emailService.send(args),
63
+ * (error) =>
66
64
  * // Wrap technical errors in ApplicationFailure. `nonRetryable`
67
65
  * // is per-instance: set it to true on permanent failures so
68
66
  * // Temporal stops retrying immediately.
69
- * resolve(Result.Error(
70
- * ApplicationFailure.create({
71
- * type: 'EMAIL_SEND_FAILED',
72
- * message: 'Failed to send email',
73
- * nonRetryable: false,
74
- * cause: error instanceof Error ? error : undefined,
75
- * }),
76
- * ));
77
- * }
78
- * });
79
- * },
67
+ * ApplicationFailure.create({
68
+ * type: 'EMAIL_SEND_FAILED',
69
+ * message: 'Failed to send email',
70
+ * nonRetryable: false,
71
+ * cause: error instanceof Error ? error : undefined,
72
+ * }),
73
+ * ).map(() => ({ sent: true })),
80
74
  * },
81
75
  * });
82
76
  *
@@ -92,9 +86,9 @@ type ActivitiesHandler<TContract extends ContractDefinition> = (TContract["activ
92
86
  *
93
87
  * @remarks
94
88
  * The wrapper accepts implementations in the
95
- * `Future<Result<T, ApplicationFailure>>` shape and produces ordinary
96
- * Promise-returning Temporal handlers (Result.Error → thrown
97
- * `ApplicationFailure`; Result.Ok → output validated against the
89
+ * `ResultAsync<T, ApplicationFailure>` shape and produces ordinary
90
+ * Promise-returning Temporal handlers (`err(...)` → thrown
91
+ * `ApplicationFailure`; `ok(...)` → output validated against the
98
92
  * contract and resolved). It does **not** hide Temporal's
99
93
  * `@temporalio/activity` runtime: inside the body you can still call
100
94
  * `Context.current()` from `@temporalio/activity` to access heartbeats
@@ -1 +1 @@
1
- {"version":3,"file":"activity.d.mts","names":[],"sources":["../src/activity.ts"],"mappings":";;;;;;AAgCwD;;;;;;;;;AAAA,KAWnD,2BAAA,mBAA8C,kBAAA,KACjD,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,MAAA,CAAO,MAAA,CAAO,iBAAA,CAAkB,SAAA,GAAY,oBAAA;;;;KAK5C,sCAAA,mBAAyD,kBAAA,KAE3D,SAAA,uBAAgC,MAAA,SAAe,kBAAA,IAC5C,8BAAA,CAA+B,SAAA,8CAIX,SAAA,gBAAyB,SAAA,cAAuB,SAAA,wBAAiC,MAAA,SAEnG,kBAAA,IAEE,8BAAA,CAA+B,SAAA,cAAuB,SAAA;AAAA,KAI3D,8BAAA,qBAAmD,MAAA,SAAe,kBAAA,mBACzD,WAAA,GAAc,2BAAA,CAA4B,WAAA,CAAY,CAAA;;;;KAM/D,+BAAA,mBAAkD,kBAAA;EACrD,QAAA,EAAU,SAAA;EACV,UAAA,EAAY,sCAAA,CAAuC,SAAA;AAAA;AAAA,KAGhD,sBAAA,mBAAyC,kBAAA,KAC5C,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;AAAA,KAE1B,yBAAA,qBAA8C,MAAA,SAAe,kBAAA,mBACpD,WAAA,GAAc,sBAAA,CAAuB,WAAA,CAAY,CAAA;AAAA,KAG1D,mBAAA,OAA0B,CAAA,oBAAqB,CAAA,EAAG,CAAA,6BACrD,CAAA,sBAEE,CAAA;;;;;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mBACpD,WAAA,GAAc,sBAAA,CAAuB,WAAA,CAAY,CAAA;AAAA,KAG1D,mBAAA,OAA0B,CAAA,oBAAqB,CAAA,EAAG,CAAA,6BACrD,CAAA,sBAEE,CAAA;;;;;;KAQQ,iBAAA,mBAAoC,kBAAA,KAE7C,SAAA,uBAAgC,MAAA,SAAe,kBAAA,IAC5C,yBAAA,CAA0B,SAAA,wBAG5B,mBAAA,uBAEwB,SAAA,gBAAyB,SAAA,cAAuB,SAAA,wBAAiC,MAAA,SAEnG,kBAAA,IAEE,yBAAA,CAA0B,SAAA,cAAuB,SAAA,8BAE/C,SAAA;;;;;;;;;;;;;;;;;;;;;;AAjD4D;;;;;;;;;;;;;;;;;;;;;AAKJ;;;;;;;;;;;;;;;;;;AAQP;;iBAqG/C,wBAAA,mBAA2C,kBAAA,CAAA,CACzD,OAAA,EAAS,+BAAA,CAAgC,SAAA,IACxC,iBAAA,CAAkB,SAAA"}
package/dist/activity.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ActivityInputValidationError, i as ActivityDefinitionNotFoundError, o as ActivityOutputValidationError, r as extractHandlerInput } from "./internal-BoNcEtYh.mjs";
1
+ import { a as ActivityInputValidationError, i as ActivityDefinitionNotFoundError, o as ActivityOutputValidationError, r as extractHandlerInput } from "./internal--45IXCxX.mjs";
2
2
  import { ApplicationFailure } from "@temporalio/common";
3
3
  //#region src/activity.ts
4
4
  /**
@@ -6,7 +6,7 @@ import { ApplicationFailure } from "@temporalio/common";
6
6
  *
7
7
  * This wraps all activity implementations with:
8
8
  * - Validation at network boundaries
9
- * - `Result<T, ApplicationFailure>` pattern for explicit error handling
9
+ * - `ResultAsync<T, ApplicationFailure>` pattern for explicit error handling
10
10
  * - Automatic conversion from Result to Promise (throwing on Error)
11
11
  *
12
12
  * TypeScript ensures ALL activities (global + workflow-specific) are implemented.
@@ -16,33 +16,27 @@ import { ApplicationFailure } from "@temporalio/common";
16
16
  * @example
17
17
  * ```ts
18
18
  * import { declareActivitiesHandler, ApplicationFailure } from '@temporal-contract/worker/activity';
19
- * import { Result, Future } from '@swan-io/boxed';
19
+ * import { ResultAsync, errAsync, okAsync } from 'neverthrow';
20
20
  * import myContract from './contract';
21
21
  *
22
22
  * export const activities = declareActivitiesHandler({
23
23
  * contract: myContract,
24
24
  * activities: {
25
- * // Activity returns Result instead of throwing.
26
- * sendEmail: (args) => {
27
- * return Future.make(async (resolve) => {
28
- * try {
29
- * await emailService.send(args);
30
- * resolve(Result.Ok({ sent: true }));
31
- * } catch (error) {
25
+ * // Activity returns ResultAsync instead of throwing.
26
+ * sendEmail: (args) =>
27
+ * ResultAsync.fromPromise(
28
+ * emailService.send(args),
29
+ * (error) =>
32
30
  * // Wrap technical errors in ApplicationFailure. `nonRetryable`
33
31
  * // is per-instance: set it to true on permanent failures so
34
32
  * // Temporal stops retrying immediately.
35
- * resolve(Result.Error(
36
- * ApplicationFailure.create({
37
- * type: 'EMAIL_SEND_FAILED',
38
- * message: 'Failed to send email',
39
- * nonRetryable: false,
40
- * cause: error instanceof Error ? error : undefined,
41
- * }),
42
- * ));
43
- * }
44
- * });
45
- * },
33
+ * ApplicationFailure.create({
34
+ * type: 'EMAIL_SEND_FAILED',
35
+ * message: 'Failed to send email',
36
+ * nonRetryable: false,
37
+ * cause: error instanceof Error ? error : undefined,
38
+ * }),
39
+ * ).map(() => ({ sent: true })),
46
40
  * },
47
41
  * });
48
42
  *
@@ -58,9 +52,9 @@ import { ApplicationFailure } from "@temporalio/common";
58
52
  *
59
53
  * @remarks
60
54
  * The wrapper accepts implementations in the
61
- * `Future<Result<T, ApplicationFailure>>` shape and produces ordinary
62
- * Promise-returning Temporal handlers (Result.Error → thrown
63
- * `ApplicationFailure`; Result.Ok → output validated against the
55
+ * `ResultAsync<T, ApplicationFailure>` shape and produces ordinary
56
+ * Promise-returning Temporal handlers (`err(...)` → thrown
57
+ * `ApplicationFailure`; `ok(...)` → output validated against the
64
58
  * contract and resolved). It does **not** hide Temporal's
65
59
  * `@temporalio/activity` runtime: inside the body you can still call
66
60
  * `Context.current()` from `@temporalio/activity` to access heartbeats
@@ -1 +1 @@
1
- {"version":3,"file":"activity.mjs","names":[],"sources":["../src/activity.ts"],"sourcesContent":["// Entry point for activity implementations.\n//\n// Activities run *outside* the workflow sandbox, so they can use any\n// implementation of the Result/Future pattern — we standardize on\n// `@swan-io/boxed` here for its richer API. Workflow code (see workflow.ts)\n// must use `@temporal-contract/boxed` instead, since it's compatible with\n// Temporal's deterministic replay machinery.\n//\n// Errors flow through Temporal's `ApplicationFailure` (re-exported from\n// `@temporalio/common`) — it's the SDK's first-class failure shape, so we\n// don't wrap it in a custom class. `ApplicationFailure` exposes\n// `nonRetryable`, `type`, `details`, and `category` natively, and survives\n// the activity → workflow serialization boundary unchanged.\nimport { ActivityDefinition, ContractDefinition } from \"@temporal-contract/contract\";\nimport { Future, Result } from \"@swan-io/boxed\";\nimport { ApplicationFailure } from \"@temporalio/common\";\nimport { WorkerInferInput, WorkerInferOutput } from \"./types.js\";\nimport {\n ActivityDefinitionNotFoundError,\n ActivityInputValidationError,\n ActivityOutputValidationError,\n} from \"./errors.js\";\nimport { extractHandlerInput } from \"./internal.js\";\n\nexport {\n ActivityDefinitionNotFoundError,\n ActivityInputValidationError,\n ActivityOutputValidationError,\n} from \"./errors.js\";\n\n// Re-export the canonical activity-failure class so consumers don't need\n// a separate `@temporalio/common` import to construct one.\nexport { ApplicationFailure } from \"@temporalio/common\";\n\n/**\n * Activity implementation using Future/Result pattern.\n *\n * Returns `Future<Result<Output, ApplicationFailure>>` for explicit error\n * handling instead of throwing. The wrapper rethrows `Result.Error`\n * payloads at the activity boundary; Temporal recognizes\n * `ApplicationFailure` natively and applies the configured retry policy\n * (with `nonRetryable: true` opting an instance out per-call).\n */\ntype BoxedActivityImplementation<TActivity extends ActivityDefinition> = (\n args: WorkerInferInput<TActivity>,\n) => Future<Result<WorkerInferOutput<TActivity>, ApplicationFailure>>;\n\n/**\n * Map of all activity implementations for a contract (global + all workflow-specific)\n */\ntype ContractBoxedActivitiesImplementations<TContract extends ContractDefinition> =\n // Global activities\n (TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? BoxedActivitiesImplementations<TContract[\"activities\"]>\n : {}) &\n // All workflow-specific activities merged\n {\n [TWorkflow in keyof TContract[\"workflows\"]]: TContract[\"workflows\"][TWorkflow][\"activities\"] extends Record<\n string,\n ActivityDefinition\n >\n ? BoxedActivitiesImplementations<TContract[\"workflows\"][TWorkflow][\"activities\"]>\n : {};\n };\n\ntype BoxedActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = {\n [K in keyof TActivities]: BoxedActivityImplementation<TActivities[K]>;\n};\n\n/**\n * Options for creating activities handler\n */\ntype DeclareActivitiesHandlerOptions<TContract extends ContractDefinition> = {\n contract: TContract;\n activities: ContractBoxedActivitiesImplementations<TContract>;\n};\n\ntype ActivityImplementation<TActivity extends ActivityDefinition> = (\n args: WorkerInferInput<TActivity>,\n) => Promise<WorkerInferOutput<TActivity>>;\n\ntype ActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = {\n [K in keyof TActivities]: ActivityImplementation<TActivities[K]>;\n};\n\ntype UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\n/**\n * Activities handler ready for Temporal Worker\n *\n * Flat structure: all activities (global + all workflow-specific) are at the root level\n */\nexport type ActivitiesHandler<TContract extends ContractDefinition> =\n // Global activities\n (TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? ActivitiesImplementations<TContract[\"activities\"]>\n : {}) &\n // All workflow-specific activities merged at root level (flat)\n UnionToIntersection<\n {\n [TWorkflow in keyof TContract[\"workflows\"]]: TContract[\"workflows\"][TWorkflow][\"activities\"] extends Record<\n string,\n ActivityDefinition\n >\n ? ActivitiesImplementations<TContract[\"workflows\"][TWorkflow][\"activities\"]>\n : {};\n }[keyof TContract[\"workflows\"]]\n >;\n\n/**\n * Create a typed activities handler with automatic validation and Result pattern.\n *\n * This wraps all activity implementations with:\n * - Validation at network boundaries\n * - `Result<T, ApplicationFailure>` pattern for explicit error handling\n * - Automatic conversion from Result to Promise (throwing on Error)\n *\n * TypeScript ensures ALL activities (global + workflow-specific) are implemented.\n *\n * Use this to create the activities object for the Temporal Worker.\n *\n * @example\n * ```ts\n * import { declareActivitiesHandler, ApplicationFailure } from '@temporal-contract/worker/activity';\n * import { Result, Future } from '@swan-io/boxed';\n * import myContract from './contract';\n *\n * export const activities = declareActivitiesHandler({\n * contract: myContract,\n * activities: {\n * // Activity returns Result instead of throwing.\n * sendEmail: (args) => {\n * return Future.make(async (resolve) => {\n * try {\n * await emailService.send(args);\n * resolve(Result.Ok({ sent: true }));\n * } catch (error) {\n * // Wrap technical errors in ApplicationFailure. `nonRetryable`\n * // is per-instance: set it to true on permanent failures so\n * // Temporal stops retrying immediately.\n * resolve(Result.Error(\n * ApplicationFailure.create({\n * type: 'EMAIL_SEND_FAILED',\n * message: 'Failed to send email',\n * nonRetryable: false,\n * cause: error instanceof Error ? error : undefined,\n * }),\n * ));\n * }\n * });\n * },\n * },\n * });\n *\n * // Use with Temporal Worker\n * import { Worker } from '@temporalio/worker';\n *\n * const worker = await Worker.create({\n * workflowsPath: require.resolve('./workflows'),\n * activities: activities,\n * taskQueue: contract.taskQueue,\n * });\n * ```\n *\n * @remarks\n * The wrapper accepts implementations in the\n * `Future<Result<T, ApplicationFailure>>` shape and produces ordinary\n * Promise-returning Temporal handlers (Result.Error → thrown\n * `ApplicationFailure`; Result.Ok → output validated against the\n * contract and resolved). It does **not** hide Temporal's\n * `@temporalio/activity` runtime: inside the body you can still call\n * `Context.current()` from `@temporalio/activity` to access heartbeats\n * (`heartbeat(details)`, `heartbeatDetails`), activity info (attempt\n * number, workflow IDs), and the async-completion task token. See the\n * \"Working with the Activity Context\" section of the worker\n * implementation guide for end-to-end examples.\n */\nexport function declareActivitiesHandler<TContract extends ContractDefinition>(\n options: DeclareActivitiesHandlerOptions<TContract>,\n): ActivitiesHandler<TContract> {\n const { contract, activities } = options;\n\n // Prepare Temporal-compatible activities with validation and Result unwrapping\n const wrappedActivities = {} as ActivitiesHandler<TContract>;\n\n // Helper to create a wrapped implementation from a definition and impl\n function makeWrapped(\n activityName: string,\n activityDef: ActivityDefinition,\n activityImpl: (args: unknown) => Future<Result<unknown, ApplicationFailure>>,\n ) {\n return async (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n\n // Validate input\n const inputResult = await activityDef.input[\"~standard\"].validate(input);\n if (inputResult.issues) {\n throw new ActivityInputValidationError(activityName, inputResult.issues);\n }\n\n // Execute boxed activity (returns Future<Result<T, ApplicationFailure>>)\n const futureResult = activityImpl(inputResult.value);\n\n // Await Future and unwrap Result\n const result = await futureResult;\n\n // Process result: validate output or throw error\n if (result.isOk()) {\n // Validate output on success\n const outputResult = await activityDef.output[\"~standard\"].validate(result.value);\n if (outputResult.issues) {\n throw new ActivityOutputValidationError(activityName, outputResult.issues);\n }\n return outputResult.value;\n } else {\n // Convert Result.Error to thrown ApplicationFailure for Temporal.\n // Temporal recognizes this class natively and applies the\n // configured retry policy (honoring `nonRetryable: true`).\n throw result.error;\n }\n };\n }\n\n // 1) Wrap global activities defined directly under contract.activities\n if (contract.activities) {\n for (const [activityName, impl] of Object.entries(activities)) {\n // Skip workflow namespaces if present at root\n if (contract.workflows && activityName in contract.workflows) {\n continue;\n }\n\n const activityDef = contract.activities[activityName];\n if (!activityDef) {\n throw new ActivityDefinitionNotFoundError(activityName, Object.keys(contract.activities));\n }\n\n // Assign wrapped global activity\n (wrappedActivities as Record<string, unknown>)[activityName] = makeWrapped(\n activityName,\n activityDef,\n impl as (args: unknown) => Future<Result<unknown, ApplicationFailure>>,\n );\n }\n }\n\n // 2) Wrap workflow-scoped activities at root level (flat)\n if (contract.workflows) {\n for (const [workflowName, workflowDef] of Object.entries(contract.workflows)) {\n const wfActivitiesImpl = (activities as Record<string, unknown>)[workflowName] as\n | Record<string, unknown>\n | undefined;\n if (!wfActivitiesImpl) {\n // If no implementations provided for this workflow, skip (TypeScript typing should enforce completeness for declared ones)\n continue;\n }\n\n const wfDefs = workflowDef.activities ?? {};\n\n for (const [activityName, impl] of Object.entries(wfActivitiesImpl)) {\n const activityDef = wfDefs[activityName];\n if (!activityDef) {\n throw new ActivityDefinitionNotFoundError(\n `${workflowName}.${activityName}`,\n Object.keys(wfDefs),\n );\n }\n\n // Assign workflow activity directly at root level (flat structure)\n (wrappedActivities as Record<string, unknown>)[activityName] = makeWrapped(\n `${workflowName}.${activityName}`,\n activityDef,\n impl as (args: unknown) => Future<Result<unknown, ApplicationFailure>>,\n );\n }\n }\n }\n\n return wrappedActivities;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqLA,SAAgB,yBACd,SAC8B;CAC9B,MAAM,EAAE,UAAU,eAAe;CAGjC,MAAM,oBAAoB,EAAE;CAG5B,SAAS,YACP,cACA,aACA,cACA;AACA,SAAO,OAAO,GAAG,SAAoB;GACnC,MAAM,QAAQ,oBAAoB,KAAK;GAGvC,MAAM,cAAc,MAAM,YAAY,MAAM,aAAa,SAAS,MAAM;AACxE,OAAI,YAAY,OACd,OAAM,IAAI,6BAA6B,cAAc,YAAY,OAAO;GAO1E,MAAM,SAAS,MAHM,aAAa,YAAY,MAGb;AAGjC,OAAI,OAAO,MAAM,EAAE;IAEjB,MAAM,eAAe,MAAM,YAAY,OAAO,aAAa,SAAS,OAAO,MAAM;AACjF,QAAI,aAAa,OACf,OAAM,IAAI,8BAA8B,cAAc,aAAa,OAAO;AAE5E,WAAO,aAAa;SAKpB,OAAM,OAAO;;;AAMnB,KAAI,SAAS,WACX,MAAK,MAAM,CAAC,cAAc,SAAS,OAAO,QAAQ,WAAW,EAAE;AAE7D,MAAI,SAAS,aAAa,gBAAgB,SAAS,UACjD;EAGF,MAAM,cAAc,SAAS,WAAW;AACxC,MAAI,CAAC,YACH,OAAM,IAAI,gCAAgC,cAAc,OAAO,KAAK,SAAS,WAAW,CAAC;AAI1F,oBAA8C,gBAAgB,YAC7D,cACA,aACA,KACD;;AAKL,KAAI,SAAS,UACX,MAAK,MAAM,CAAC,cAAc,gBAAgB,OAAO,QAAQ,SAAS,UAAU,EAAE;EAC5E,MAAM,mBAAoB,WAAuC;AAGjE,MAAI,CAAC,iBAEH;EAGF,MAAM,SAAS,YAAY,cAAc,EAAE;AAE3C,OAAK,MAAM,CAAC,cAAc,SAAS,OAAO,QAAQ,iBAAiB,EAAE;GACnE,MAAM,cAAc,OAAO;AAC3B,OAAI,CAAC,YACH,OAAM,IAAI,gCACR,GAAG,aAAa,GAAG,gBACnB,OAAO,KAAK,OAAO,CACpB;AAIF,qBAA8C,gBAAgB,YAC7D,GAAG,aAAa,GAAG,gBACnB,aACA,KACD;;;AAKP,QAAO"}
1
+ {"version":3,"file":"activity.mjs","names":[],"sources":["../src/activity.ts"],"sourcesContent":["// Entry point for activity implementations.\n//\n// Activities run *outside* the workflow sandbox, so they use neverthrow's\n// `ResultAsync` directly. Workflow code (see workflow.ts) uses the same\n// neverthrow API — neverthrow's evaluation is compatible with Temporal's\n// deterministic replay machinery.\n//\n// Errors flow through Temporal's `ApplicationFailure` (re-exported from\n// `@temporalio/common`) — it's the SDK's first-class failure shape, so we\n// don't wrap it in a custom class. `ApplicationFailure` exposes\n// `nonRetryable`, `type`, `details`, and `category` natively, and survives\n// the activity → workflow serialization boundary unchanged.\nimport { ActivityDefinition, ContractDefinition } from \"@temporal-contract/contract\";\nimport type { ResultAsync } from \"neverthrow\";\nimport { ApplicationFailure } from \"@temporalio/common\";\nimport { WorkerInferInput, WorkerInferOutput } from \"./types.js\";\nimport {\n ActivityDefinitionNotFoundError,\n ActivityInputValidationError,\n ActivityOutputValidationError,\n} from \"./errors.js\";\nimport { extractHandlerInput } from \"./internal.js\";\n\nexport {\n ActivityDefinitionNotFoundError,\n ActivityInputValidationError,\n ActivityOutputValidationError,\n} from \"./errors.js\";\n\n// Re-export the canonical activity-failure class so consumers don't need\n// a separate `@temporalio/common` import to construct one.\nexport { ApplicationFailure } from \"@temporalio/common\";\n\n/**\n * Activity implementation using neverthrow's `ResultAsync`.\n *\n * Returns `ResultAsync<Output, ApplicationFailure>` for explicit error\n * handling instead of throwing. The wrapper rethrows `err()` payloads at\n * the activity boundary; Temporal recognizes `ApplicationFailure` natively\n * and applies the configured retry policy (with `nonRetryable: true`\n * opting an instance out per-call).\n */\ntype ResultActivityImplementation<TActivity extends ActivityDefinition> = (\n args: WorkerInferInput<TActivity>,\n) => ResultAsync<WorkerInferOutput<TActivity>, ApplicationFailure>;\n\n/**\n * Map of all activity implementations for a contract (global + all workflow-specific)\n */\ntype ContractResultActivitiesImplementations<TContract extends ContractDefinition> =\n // Global activities\n (TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? ResultActivitiesImplementations<TContract[\"activities\"]>\n : {}) &\n // All workflow-specific activities merged\n {\n [TWorkflow in keyof TContract[\"workflows\"]]: TContract[\"workflows\"][TWorkflow][\"activities\"] extends Record<\n string,\n ActivityDefinition\n >\n ? ResultActivitiesImplementations<TContract[\"workflows\"][TWorkflow][\"activities\"]>\n : {};\n };\n\ntype ResultActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = {\n [K in keyof TActivities]: ResultActivityImplementation<TActivities[K]>;\n};\n\n/**\n * Options for creating activities handler\n */\ntype DeclareActivitiesHandlerOptions<TContract extends ContractDefinition> = {\n contract: TContract;\n activities: ContractResultActivitiesImplementations<TContract>;\n};\n\ntype ActivityImplementation<TActivity extends ActivityDefinition> = (\n args: WorkerInferInput<TActivity>,\n) => Promise<WorkerInferOutput<TActivity>>;\n\ntype ActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = {\n [K in keyof TActivities]: ActivityImplementation<TActivities[K]>;\n};\n\ntype UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\n/**\n * Activities handler ready for Temporal Worker\n *\n * Flat structure: all activities (global + all workflow-specific) are at the root level\n */\nexport type ActivitiesHandler<TContract extends ContractDefinition> =\n // Global activities\n (TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? ActivitiesImplementations<TContract[\"activities\"]>\n : {}) &\n // All workflow-specific activities merged at root level (flat)\n UnionToIntersection<\n {\n [TWorkflow in keyof TContract[\"workflows\"]]: TContract[\"workflows\"][TWorkflow][\"activities\"] extends Record<\n string,\n ActivityDefinition\n >\n ? ActivitiesImplementations<TContract[\"workflows\"][TWorkflow][\"activities\"]>\n : {};\n }[keyof TContract[\"workflows\"]]\n >;\n\n/**\n * Create a typed activities handler with automatic validation and Result pattern.\n *\n * This wraps all activity implementations with:\n * - Validation at network boundaries\n * - `ResultAsync<T, ApplicationFailure>` pattern for explicit error handling\n * - Automatic conversion from Result to Promise (throwing on Error)\n *\n * TypeScript ensures ALL activities (global + workflow-specific) are implemented.\n *\n * Use this to create the activities object for the Temporal Worker.\n *\n * @example\n * ```ts\n * import { declareActivitiesHandler, ApplicationFailure } from '@temporal-contract/worker/activity';\n * import { ResultAsync, errAsync, okAsync } from 'neverthrow';\n * import myContract from './contract';\n *\n * export const activities = declareActivitiesHandler({\n * contract: myContract,\n * activities: {\n * // Activity returns ResultAsync instead of throwing.\n * sendEmail: (args) =>\n * ResultAsync.fromPromise(\n * emailService.send(args),\n * (error) =>\n * // Wrap technical errors in ApplicationFailure. `nonRetryable`\n * // is per-instance: set it to true on permanent failures so\n * // Temporal stops retrying immediately.\n * ApplicationFailure.create({\n * type: 'EMAIL_SEND_FAILED',\n * message: 'Failed to send email',\n * nonRetryable: false,\n * cause: error instanceof Error ? error : undefined,\n * }),\n * ).map(() => ({ sent: true })),\n * },\n * });\n *\n * // Use with Temporal Worker\n * import { Worker } from '@temporalio/worker';\n *\n * const worker = await Worker.create({\n * workflowsPath: require.resolve('./workflows'),\n * activities: activities,\n * taskQueue: contract.taskQueue,\n * });\n * ```\n *\n * @remarks\n * The wrapper accepts implementations in the\n * `ResultAsync<T, ApplicationFailure>` shape and produces ordinary\n * Promise-returning Temporal handlers (`err(...)` → thrown\n * `ApplicationFailure`; `ok(...)` → output validated against the\n * contract and resolved). It does **not** hide Temporal's\n * `@temporalio/activity` runtime: inside the body you can still call\n * `Context.current()` from `@temporalio/activity` to access heartbeats\n * (`heartbeat(details)`, `heartbeatDetails`), activity info (attempt\n * number, workflow IDs), and the async-completion task token. See the\n * \"Working with the Activity Context\" section of the worker\n * implementation guide for end-to-end examples.\n */\nexport function declareActivitiesHandler<TContract extends ContractDefinition>(\n options: DeclareActivitiesHandlerOptions<TContract>,\n): ActivitiesHandler<TContract> {\n const { contract, activities } = options;\n\n // Prepare Temporal-compatible activities with validation and Result unwrapping\n const wrappedActivities = {} as ActivitiesHandler<TContract>;\n\n // Helper to create a wrapped implementation from a definition and impl\n function makeWrapped(\n activityName: string,\n activityDef: ActivityDefinition,\n activityImpl: (args: unknown) => ResultAsync<unknown, ApplicationFailure>,\n ) {\n return async (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n\n // Validate input\n const inputResult = await activityDef.input[\"~standard\"].validate(input);\n if (inputResult.issues) {\n throw new ActivityInputValidationError(activityName, inputResult.issues);\n }\n\n // Execute neverthrow activity (returns ResultAsync<T, ApplicationFailure>);\n // awaiting yields a Result<T, ApplicationFailure>.\n const result = await activityImpl(inputResult.value);\n\n // Process result: validate output or throw error\n if (result.isOk()) {\n // Validate output on success\n const outputResult = await activityDef.output[\"~standard\"].validate(result.value);\n if (outputResult.issues) {\n throw new ActivityOutputValidationError(activityName, outputResult.issues);\n }\n return outputResult.value;\n } else {\n // Convert err(...) payload to thrown ApplicationFailure for Temporal.\n // Temporal recognizes this class natively and applies the\n // configured retry policy (honoring `nonRetryable: true`).\n throw result.error;\n }\n };\n }\n\n // 1) Wrap global activities defined directly under contract.activities\n if (contract.activities) {\n for (const [activityName, impl] of Object.entries(activities)) {\n // Skip workflow namespaces if present at root\n if (contract.workflows && activityName in contract.workflows) {\n continue;\n }\n\n const activityDef = contract.activities[activityName];\n if (!activityDef) {\n throw new ActivityDefinitionNotFoundError(activityName, Object.keys(contract.activities));\n }\n\n // Assign wrapped global activity\n (wrappedActivities as Record<string, unknown>)[activityName] = makeWrapped(\n activityName,\n activityDef,\n impl as (args: unknown) => ResultAsync<unknown, ApplicationFailure>,\n );\n }\n }\n\n // 2) Wrap workflow-scoped activities at root level (flat)\n if (contract.workflows) {\n for (const [workflowName, workflowDef] of Object.entries(contract.workflows)) {\n const wfActivitiesImpl = (activities as Record<string, unknown>)[workflowName] as\n | Record<string, unknown>\n | undefined;\n if (!wfActivitiesImpl) {\n // If no implementations provided for this workflow, skip (TypeScript typing should enforce completeness for declared ones)\n continue;\n }\n\n const wfDefs = workflowDef.activities ?? {};\n\n for (const [activityName, impl] of Object.entries(wfActivitiesImpl)) {\n const activityDef = wfDefs[activityName];\n if (!activityDef) {\n throw new ActivityDefinitionNotFoundError(\n `${workflowName}.${activityName}`,\n Object.keys(wfDefs),\n );\n }\n\n // Assign workflow activity directly at root level (flat structure)\n (wrappedActivities as Record<string, unknown>)[activityName] = makeWrapped(\n `${workflowName}.${activityName}`,\n activityDef,\n impl as (args: unknown) => ResultAsync<unknown, ApplicationFailure>,\n );\n }\n }\n }\n\n return wrappedActivities;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8KA,SAAgB,yBACd,SAC8B;CAC9B,MAAM,EAAE,UAAU,eAAe;CAGjC,MAAM,oBAAoB,EAAE;CAG5B,SAAS,YACP,cACA,aACA,cACA;AACA,SAAO,OAAO,GAAG,SAAoB;GACnC,MAAM,QAAQ,oBAAoB,KAAK;GAGvC,MAAM,cAAc,MAAM,YAAY,MAAM,aAAa,SAAS,MAAM;AACxE,OAAI,YAAY,OACd,OAAM,IAAI,6BAA6B,cAAc,YAAY,OAAO;GAK1E,MAAM,SAAS,MAAM,aAAa,YAAY,MAAM;AAGpD,OAAI,OAAO,MAAM,EAAE;IAEjB,MAAM,eAAe,MAAM,YAAY,OAAO,aAAa,SAAS,OAAO,MAAM;AACjF,QAAI,aAAa,OACf,OAAM,IAAI,8BAA8B,cAAc,aAAa,OAAO;AAE5E,WAAO,aAAa;SAKpB,OAAM,OAAO;;;AAMnB,KAAI,SAAS,WACX,MAAK,MAAM,CAAC,cAAc,SAAS,OAAO,QAAQ,WAAW,EAAE;AAE7D,MAAI,SAAS,aAAa,gBAAgB,SAAS,UACjD;EAGF,MAAM,cAAc,SAAS,WAAW;AACxC,MAAI,CAAC,YACH,OAAM,IAAI,gCAAgC,cAAc,OAAO,KAAK,SAAS,WAAW,CAAC;AAI1F,oBAA8C,gBAAgB,YAC7D,cACA,aACA,KACD;;AAKL,KAAI,SAAS,UACX,MAAK,MAAM,CAAC,cAAc,gBAAgB,OAAO,QAAQ,SAAS,UAAU,EAAE;EAC5E,MAAM,mBAAoB,WAAuC;AAGjE,MAAI,CAAC,iBAEH;EAGF,MAAM,SAAS,YAAY,cAAc,EAAE;AAE3C,OAAK,MAAM,CAAC,cAAc,SAAS,OAAO,QAAQ,iBAAiB,EAAE;GACnE,MAAM,cAAc,OAAO;AAC3B,OAAI,CAAC,YACH,OAAM,IAAI,gCACR,GAAG,aAAa,GAAG,gBACnB,OAAO,KAAK,OAAO,CACpB;AAIF,qBAA8C,gBAAgB,YAC7D,GAAG,aAAa,GAAG,gBACnB,aACA,KACD;;;AAKP,QAAO"}
@@ -133,17 +133,17 @@ declare class ChildWorkflowError extends WorkerError {
133
133
  constructor(message: string, cause?: unknown);
134
134
  }
135
135
  /**
136
- * Error returned in the `Result.Error` branch when a typed cancellation
137
- * scope is cancelled via Temporal's cancellation propagation. Returned by
138
- * both `context.cancellableScope` (when the workflow or an ancestor scope
139
- * cancels) and `context.nonCancellableScope` (when cancellation is raised
140
- * from inside the scope). Distinct from arbitrary thrown errors so call
141
- * sites can branch on cancellation explicitly while still surfacing
142
- * non-cancellation errors as Future rejections.
136
+ * Error surfaced in the `err(...)` branch of a `ResultAsync` when a typed
137
+ * cancellation scope is cancelled via Temporal's cancellation propagation.
138
+ * Returned by both `context.cancellableScope` (when the workflow or an
139
+ * ancestor scope cancels) and `context.nonCancellableScope` (when
140
+ * cancellation is raised from inside the scope). Distinct from arbitrary
141
+ * thrown errors so call sites can branch on cancellation explicitly while
142
+ * still surfacing non-cancellation errors as ResultAsync rejections.
143
143
  */
144
144
  declare class WorkflowCancelledError extends WorkerError {
145
145
  constructor(cause?: unknown);
146
146
  }
147
147
  //#endregion
148
148
  export { WorkerInferOutput as _, ChildWorkflowNotFoundError as a, SignalInputValidationError as c, WorkflowCancelledError as d, WorkflowInputValidationError as f, WorkerInferInput as g, ClientInferOutput as h, ChildWorkflowError as i, UpdateInputValidationError as l, ClientInferInput as m, ActivityInputValidationError as n, QueryInputValidationError as o, WorkflowOutputValidationError as p, ActivityOutputValidationError as r, QueryOutputValidationError as s, ActivityDefinitionNotFoundError as t, UpdateOutputValidationError as u };
149
- //# sourceMappingURL=errors-CG1y7SHO.d.cts.map
149
+ //# sourceMappingURL=errors-BeIXtRJe.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-CG1y7SHO.d.cts","names":[],"sources":["../src/types.ts","../src/errors.ts"],"mappings":";;;;;;AAOA;;KAAY,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAChF,CAAA;;;;;KAOU,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;;;;;;uBC1Ba,WAAA,SAAoB,KAAA;EAAA,UACxB,WAAA,CAAa,OAAA,UAAiB,KA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AAiB,KAAA;cADvC,SAAA,UACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;AAAA;AA3HG;;;AAAA,cAsIjD,0BAAA,SAAmC,WAAA;EAAA,SAE5B,UAAA;EAAA,SACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;cADvC,UAAA,UACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;AAAA;;;AArH3D;cAgIa,2BAAA,SAAoC,WAAA;EAAA,SAE7B,UAAA;EAAA,SACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;cADvC,UAAA,UACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;AAAA;;;;cAW9C,0BAAA,SAAmC,WAAA;EAAA,SAE5B,YAAA;EAAA,SACA,kBAAA;cADA,YAAA,UACA,kBAAA;AAAA;;;;cAWP,kBAAA,SAA2B,WAAA;cAC1B,OAAA,UAAiB,KAAA;AAAA;;;;;;;;;;cAelB,sBAAA,SAA+B,WAAA;cAC9B,KAAA;AAAA"}
@@ -133,17 +133,17 @@ declare class ChildWorkflowError extends WorkerError {
133
133
  constructor(message: string, cause?: unknown);
134
134
  }
135
135
  /**
136
- * Error returned in the `Result.Error` branch when a typed cancellation
137
- * scope is cancelled via Temporal's cancellation propagation. Returned by
138
- * both `context.cancellableScope` (when the workflow or an ancestor scope
139
- * cancels) and `context.nonCancellableScope` (when cancellation is raised
140
- * from inside the scope). Distinct from arbitrary thrown errors so call
141
- * sites can branch on cancellation explicitly while still surfacing
142
- * non-cancellation errors as Future rejections.
136
+ * Error surfaced in the `err(...)` branch of a `ResultAsync` when a typed
137
+ * cancellation scope is cancelled via Temporal's cancellation propagation.
138
+ * Returned by both `context.cancellableScope` (when the workflow or an
139
+ * ancestor scope cancels) and `context.nonCancellableScope` (when
140
+ * cancellation is raised from inside the scope). Distinct from arbitrary
141
+ * thrown errors so call sites can branch on cancellation explicitly while
142
+ * still surfacing non-cancellation errors as ResultAsync rejections.
143
143
  */
144
144
  declare class WorkflowCancelledError extends WorkerError {
145
145
  constructor(cause?: unknown);
146
146
  }
147
147
  //#endregion
148
148
  export { WorkerInferOutput as _, ChildWorkflowNotFoundError as a, SignalInputValidationError as c, WorkflowCancelledError as d, WorkflowInputValidationError as f, WorkerInferInput as g, ClientInferOutput as h, ChildWorkflowError as i, UpdateInputValidationError as l, ClientInferInput as m, ActivityInputValidationError as n, QueryInputValidationError as o, WorkflowOutputValidationError as p, ActivityOutputValidationError as r, QueryOutputValidationError as s, ActivityDefinitionNotFoundError as t, UpdateOutputValidationError as u };
149
- //# sourceMappingURL=errors-DZhaNhwr.d.mts.map
149
+ //# sourceMappingURL=errors-BjNG_jUi.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-DZhaNhwr.d.mts","names":[],"sources":["../src/types.ts","../src/errors.ts"],"mappings":";;;;;;AAOA;;KAAY,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAChF,CAAA;;;;;KAOU,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;;;;;;uBC1Ba,WAAA,SAAoB,KAAA;EAAA,UACxB,WAAA,CAAa,OAAA,UAAiB,KAAA;AAAA;;;;cAa5B,+BAAA,SAAwC,WAAA;EAAA,SAEjC,YAAA;EAAA,SACA,oBAAA;cADA,YAAA,UACA,oBAAA;AAAA;;;;cAaP,4BAAA,SAAqC,WAAA;EAAA,SAE9B,YAAA;EAAA,SACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;cADvC,YAAA,UACA,MAAA,EAAQ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