@abinnovision/nestjs-hatchet 0.3.1 → 0.4.0-beta.7

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.
Files changed (214) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/__fixtures__/test-hosts.d.cts +76 -0
  3. package/dist/__fixtures__/test-hosts.d.ts +6 -6
  4. package/dist/abstracts/hosts.cjs +58 -0
  5. package/dist/abstracts/hosts.d.cts +66 -0
  6. package/dist/abstracts/hosts.d.ts +2 -2
  7. package/dist/abstracts/hosts.mjs +55 -0
  8. package/dist/abstracts/index.d.cts +1 -0
  9. package/dist/abstracts/index.d.ts +1 -1
  10. package/dist/client/client.cjs +80 -0
  11. package/dist/client/{client.service.d.ts → client.d.cts} +8 -18
  12. package/dist/client/client.d.ts +7 -10
  13. package/dist/client/client.mjs +75 -0
  14. package/dist/client/index.cjs +1 -0
  15. package/dist/client/index.d.cts +1 -0
  16. package/dist/client/index.d.ts +1 -1
  17. package/dist/client/index.mjs +2 -0
  18. package/dist/events/event-definition.cjs +61 -0
  19. package/dist/events/event-definition.d.cts +71 -0
  20. package/dist/events/event-definition.mjs +59 -0
  21. package/dist/events/index.d.cts +2 -0
  22. package/dist/events/index.d.ts +2 -2
  23. package/dist/execution/context/factory.cjs +56 -0
  24. package/dist/{context/context-factory.d.ts → execution/context/factory.d.cts} +1 -1
  25. package/dist/execution/context/factory.d.ts +1 -1
  26. package/dist/execution/context/factory.mjs +55 -0
  27. package/dist/execution/context/index.d.cts +4 -0
  28. package/dist/execution/context/index.d.ts +4 -4
  29. package/dist/execution/context/types.cjs +4 -0
  30. package/dist/{context/context.d.ts → execution/context/types.d.cts} +4 -4
  31. package/dist/execution/context/types.d.ts +4 -4
  32. package/dist/execution/context/types.mjs +4 -0
  33. package/dist/execution/host-run/adapter-factory.cjs +34 -0
  34. package/dist/{interaction/host-run/adapter-factory.d.ts → execution/host-run/adapter-factory.d.cts} +1 -1
  35. package/dist/execution/host-run/adapter-factory.d.ts +1 -1
  36. package/dist/execution/host-run/adapter-factory.mjs +33 -0
  37. package/dist/{interaction/host-run/function-type.d.ts → execution/host-run/function-type.d.cts} +2 -2
  38. package/dist/execution/host-run/function-type.d.ts +2 -2
  39. package/dist/execution/host-run/index.d.cts +2 -0
  40. package/dist/execution/host-run/index.d.ts +2 -2
  41. package/dist/execution/index.d.cts +2 -0
  42. package/dist/execution/index.d.ts +2 -2
  43. package/dist/explorer/declaration-builder.service.cjs +217 -0
  44. package/dist/explorer/declaration-builder.service.d.cts +70 -0
  45. package/dist/explorer/declaration-builder.service.d.ts +2 -2
  46. package/dist/explorer/declaration-builder.service.mjs +212 -0
  47. package/dist/explorer/worker-management.service.cjs +126 -0
  48. package/dist/explorer/worker-management.service.d.cts +34 -0
  49. package/dist/explorer/worker-management.service.d.ts +13 -2
  50. package/dist/explorer/worker-management.service.mjs +121 -0
  51. package/dist/hatchet.module-config.cjs +4 -0
  52. package/dist/hatchet.module-config.d.cts +31 -0
  53. package/dist/hatchet.module-config.d.ts +8 -2
  54. package/dist/hatchet.module-config.mjs +4 -0
  55. package/dist/hatchet.module.cjs +63 -0
  56. package/dist/hatchet.module.d.cts +23 -0
  57. package/dist/hatchet.module.d.ts +3 -3
  58. package/dist/hatchet.module.mjs +58 -0
  59. package/dist/index.cjs +36 -0
  60. package/dist/index.d.cts +9 -0
  61. package/dist/index.d.ts +9 -9
  62. package/dist/index.mjs +12 -0
  63. package/dist/interceptor/index.d.cts +1 -0
  64. package/dist/interceptor/index.d.ts +1 -1
  65. package/dist/interceptor/interceptor.cjs +7 -0
  66. package/dist/interceptor/{interceptor.js → interceptor.d.cts} +4 -6
  67. package/dist/interceptor/interceptor.d.ts +1 -1
  68. package/dist/interceptor/interceptor.mjs +7 -0
  69. package/dist/internal/registrations.cjs +22 -0
  70. package/dist/internal/{consts.d.ts → registrations.d.cts} +2 -2
  71. package/dist/internal/registrations.d.ts +2 -2
  72. package/dist/internal/registrations.mjs +21 -0
  73. package/dist/metadata/accessor.cjs +55 -0
  74. package/dist/{accessor/host-accessor.d.ts → metadata/accessor.d.cts} +3 -3
  75. package/dist/metadata/accessor.d.ts +3 -3
  76. package/dist/metadata/accessor.mjs +54 -0
  77. package/dist/metadata/decorators/host.decorator.cjs +14 -0
  78. package/dist/{decorators/host.decorator.d.ts → metadata/decorators/host.decorator.d.cts} +1 -1
  79. package/dist/metadata/decorators/host.decorator.d.ts +1 -1
  80. package/dist/metadata/decorators/host.decorator.mjs +14 -0
  81. package/dist/metadata/decorators/index.d.cts +6 -0
  82. package/dist/metadata/decorators/index.d.ts +6 -6
  83. package/dist/metadata/decorators/task.decorator.cjs +12 -0
  84. package/dist/metadata/decorators/task.decorator.mjs +12 -0
  85. package/dist/metadata/decorators/workflow-task.decorator.cjs +12 -0
  86. package/dist/{decorators/workflow-task.decorators.d.ts → metadata/decorators/workflow-task.decorator.d.cts} +3 -3
  87. package/dist/metadata/decorators/workflow-task.decorator.d.ts +3 -3
  88. package/dist/metadata/decorators/workflow-task.decorator.mjs +12 -0
  89. package/dist/metadata/index.cjs +3 -0
  90. package/dist/metadata/index.d.cts +6 -0
  91. package/dist/metadata/index.d.ts +6 -6
  92. package/dist/metadata/index.mjs +4 -0
  93. package/dist/metadata/keys.cjs +8 -0
  94. package/dist/metadata/keys.d.cts +3 -0
  95. package/dist/metadata/keys.mjs +6 -0
  96. package/dist/metadata/translator.cjs +20 -0
  97. package/dist/{accessor/opts-translator.d.ts → metadata/translator.d.cts} +1 -1
  98. package/dist/metadata/translator.d.ts +1 -1
  99. package/dist/metadata/translator.mjs +20 -0
  100. package/dist/references/helpers.cjs +27 -0
  101. package/dist/{ref/helpers.d.ts → references/helpers.d.cts} +6 -6
  102. package/dist/references/helpers.d.ts +6 -6
  103. package/dist/references/helpers.mjs +25 -0
  104. package/dist/references/index.d.cts +3 -0
  105. package/dist/references/index.d.ts +3 -3
  106. package/dist/{ref/refs.d.ts → references/refs.d.cts} +1 -1
  107. package/dist/references/refs.d.ts +1 -1
  108. package/dist/{ref/shared.d.ts → references/shared.d.cts} +2 -2
  109. package/dist/references/shared.d.ts +2 -2
  110. package/dist/sdk/hatchet-client.factory.cjs +46 -0
  111. package/dist/sdk/hatchet-client.factory.d.cts +5 -0
  112. package/dist/sdk/hatchet-client.factory.mjs +46 -0
  113. package/dist/sdk/index.cjs +1 -0
  114. package/dist/sdk/index.d.cts +1 -0
  115. package/dist/sdk/index.d.ts +1 -1
  116. package/dist/sdk/index.mjs +2 -0
  117. package/dist/sdk/types.d.cts +7 -0
  118. package/dist/sdk/types.d.ts +7 -0
  119. package/package.json +22 -11
  120. package/dist/__fixtures__/test-hosts.js +0 -100
  121. package/dist/__mocks__/hatchet-client.mock.d.ts +0 -5
  122. package/dist/__mocks__/hatchet-client.mock.js +0 -9
  123. package/dist/__mocks__/sdk-context.mock.d.ts +0 -5
  124. package/dist/__mocks__/sdk-context.mock.js +0 -14
  125. package/dist/abstracts/hosts.js +0 -69
  126. package/dist/abstracts/index.js +0 -17
  127. package/dist/accessor/host-accessor.js +0 -65
  128. package/dist/accessor/host-opts-translator.d.ts +0 -14
  129. package/dist/accessor/host-opts-translator.js +0 -25
  130. package/dist/accessor/host-opts.d.ts +0 -31
  131. package/dist/accessor/host-opts.js +0 -27
  132. package/dist/accessor/index.d.ts +0 -2
  133. package/dist/accessor/index.js +0 -6
  134. package/dist/accessor/opts-translator.js +0 -26
  135. package/dist/client/client.js +0 -77
  136. package/dist/client/client.service.js +0 -76
  137. package/dist/client/index.js +0 -17
  138. package/dist/context/context-factory.js +0 -70
  139. package/dist/context/context.js +0 -4
  140. package/dist/context/index.d.ts +0 -1
  141. package/dist/context/index.js +0 -2
  142. package/dist/context/test-narrowing.d.ts +0 -5
  143. package/dist/context/test-narrowing.js +0 -17
  144. package/dist/context/trigger-guards.d.ts +0 -22
  145. package/dist/context/trigger-guards.js +0 -2
  146. package/dist/decorator-utils/accessors.d.ts +0 -20
  147. package/dist/decorator-utils/accessors.js +0 -33
  148. package/dist/decorator-utils/index.d.ts +0 -1
  149. package/dist/decorator-utils/index.js +0 -17
  150. package/dist/decorators/host-opts.d.ts +0 -19
  151. package/dist/decorators/host-opts.js +0 -2
  152. package/dist/decorators/host.decorator.js +0 -18
  153. package/dist/decorators/index.d.ts +0 -3
  154. package/dist/decorators/index.js +0 -19
  155. package/dist/decorators/task.decorator.js +0 -15
  156. package/dist/decorators/workflow-task.decorators.js +0 -14
  157. package/dist/events/event-definition.js +0 -82
  158. package/dist/events/index.js +0 -6
  159. package/dist/execution/context/factory.js +0 -70
  160. package/dist/execution/context/index.js +0 -8
  161. package/dist/execution/context/types.js +0 -4
  162. package/dist/execution/host-run/adapter-factory.js +0 -45
  163. package/dist/execution/host-run/function-type.js +0 -2
  164. package/dist/execution/host-run/index.js +0 -6
  165. package/dist/execution/index.js +0 -2
  166. package/dist/execution-wrapper/execution-wrapper.d.ts +0 -13
  167. package/dist/execution-wrapper/execution-wrapper.js +0 -15
  168. package/dist/execution-wrapper/index.d.ts +0 -1
  169. package/dist/execution-wrapper/index.js +0 -17
  170. package/dist/explorer/declaration-builder.service.js +0 -298
  171. package/dist/explorer/exceptions/index.js +0 -2
  172. package/dist/explorer/index.js +0 -2
  173. package/dist/explorer/utils.d.ts +0 -19
  174. package/dist/explorer/utils.js +0 -44
  175. package/dist/explorer/worker-management.service.js +0 -90
  176. package/dist/hatchet.module-config.js +0 -4
  177. package/dist/hatchet.module.js +0 -79
  178. package/dist/index.js +0 -24
  179. package/dist/interaction/host-run/adapter-factory.js +0 -45
  180. package/dist/interaction/host-run/function-type.js +0 -2
  181. package/dist/interaction/host-run/index.d.ts +0 -1
  182. package/dist/interaction/host-run/index.js +0 -2
  183. package/dist/interaction/index.d.ts +0 -1
  184. package/dist/interaction/index.js +0 -2
  185. package/dist/interceptor/index.js +0 -5
  186. package/dist/internal/consts.js +0 -25
  187. package/dist/internal/index.d.ts +0 -1
  188. package/dist/internal/index.js +0 -17
  189. package/dist/internal/registrations.js +0 -25
  190. package/dist/internal/shared-consts.d.ts +0 -19
  191. package/dist/internal/shared-consts.js +0 -25
  192. package/dist/internal/shared-decorators.d.ts +0 -1
  193. package/dist/internal/shared-decorators.js +0 -5
  194. package/dist/metadata/accessor.js +0 -65
  195. package/dist/metadata/decorators/host.decorator.js +0 -18
  196. package/dist/metadata/decorators/index.js +0 -9
  197. package/dist/metadata/decorators/task.decorator.js +0 -15
  198. package/dist/metadata/decorators/workflow-task.decorator.js +0 -14
  199. package/dist/metadata/index.js +0 -10
  200. package/dist/metadata/keys.js +0 -6
  201. package/dist/metadata/translator.js +0 -26
  202. package/dist/ref/helpers.js +0 -31
  203. package/dist/ref/index.d.ts +0 -3
  204. package/dist/ref/index.js +0 -7
  205. package/dist/ref/refs.js +0 -2
  206. package/dist/ref/shared.js +0 -2
  207. package/dist/references/helpers.js +0 -31
  208. package/dist/references/index.js +0 -7
  209. package/dist/references/refs.js +0 -2
  210. package/dist/references/shared.js +0 -2
  211. package/dist/sdk/hatchet-client.factory.js +0 -44
  212. package/dist/sdk/index.js +0 -17
  213. /package/dist/explorer/{exceptions/index.d.ts → index.d.cts} +0 -0
  214. /package/dist/{decorators/task.decorator.d.ts → metadata/decorators/task.decorator.d.cts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.2](https://github.com/abinnovision/nestjs-commons/compare/nestjs-hatchet-v0.3.1...nestjs-hatchet-v0.3.2) (2026-01-28)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * pass task options through to TaskWorkflowDeclaration ([#89](https://github.com/abinnovision/nestjs-commons/issues/89)) ([e45d19b](https://github.com/abinnovision/nestjs-commons/commit/e45d19bb7812755f3108c99900d897eeab7e24d5))
9
+
3
10
  ## [0.3.1](https://github.com/abinnovision/nestjs-commons/compare/nestjs-hatchet-v0.3.0...nestjs-hatchet-v0.3.1) (2026-01-10)
4
11
 
5
12
 
@@ -0,0 +1,76 @@
1
+ import type { TaskCtx, WorkflowCtx } from "../execution/index.js";
2
+ declare const TestTask_base: {
3
+ new (): {
4
+ readonly __task_host_brand: void;
5
+ readonly __task_host_input: {
6
+ data: string;
7
+ };
8
+ readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk/index.js").JsonObject, {
9
+ data: string;
10
+ }> | undefined;
11
+ };
12
+ };
13
+ /** Standard TaskHost with string data schema */
14
+ export declare class TestTask extends TestTask_base {
15
+ execute(ctx: TaskCtx<typeof this>): {
16
+ result: string;
17
+ };
18
+ }
19
+ declare const NoMethodsTask_base: {
20
+ new (): {
21
+ readonly __task_host_brand: void;
22
+ readonly __task_host_input: unknown;
23
+ readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk/index.js").JsonObject, unknown> | undefined;
24
+ };
25
+ };
26
+ /** TaskHost without any decorated methods (invalid) */
27
+ export declare class NoMethodsTask extends NoMethodsTask_base {
28
+ notDecorated(): {};
29
+ }
30
+ declare const NoSchemaTask_base: {
31
+ new (): {
32
+ readonly __task_host_brand: void;
33
+ readonly __task_host_input: unknown;
34
+ readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk/index.js").JsonObject, unknown> | undefined;
35
+ };
36
+ };
37
+ /** TaskHost without input schema */
38
+ export declare class NoSchemaTask extends NoSchemaTask_base {
39
+ execute(_ctx: TaskCtx<typeof this>): {
40
+ result: string;
41
+ };
42
+ }
43
+ declare const TestWorkflow_base: {
44
+ new (): {
45
+ readonly __workflow_host_brand: void;
46
+ readonly __workflow_host_input: {
47
+ id: string;
48
+ };
49
+ readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk/index.js").JsonObject, {
50
+ id: string;
51
+ }> | undefined;
52
+ };
53
+ };
54
+ /** Standard WorkflowHost with two-step DAG */
55
+ export declare class TestWorkflow extends TestWorkflow_base {
56
+ step1(_ctx: WorkflowCtx<typeof this>): {
57
+ step: number;
58
+ };
59
+ step2(_ctx: WorkflowCtx<typeof this>): {
60
+ step: number;
61
+ };
62
+ }
63
+ declare const NoMethodsWorkflow_base: {
64
+ new (): {
65
+ readonly __workflow_host_brand: void;
66
+ readonly __workflow_host_input: unknown;
67
+ readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk/index.js").JsonObject, unknown> | undefined;
68
+ };
69
+ };
70
+ /** WorkflowHost without any decorated methods (invalid) */
71
+ export declare class NoMethodsWorkflow extends NoMethodsWorkflow_base {
72
+ notDecorated(): {};
73
+ }
74
+ /** Sets design:paramtypes metadata for a method (needed in vitest) */
75
+ export declare function setParamTypes(target: object, method: string, types: unknown[]): void;
76
+ export {};
@@ -1,11 +1,11 @@
1
- import type { TaskCtx, WorkflowCtx } from "../execution";
1
+ import type { TaskCtx, WorkflowCtx } from "../execution/index.js";
2
2
  declare const TestTask_base: {
3
3
  new (): {
4
4
  readonly __task_host_brand: void;
5
5
  readonly __task_host_input: {
6
6
  data: string;
7
7
  };
8
- readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk").JsonObject, {
8
+ readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk/index.js").JsonObject, {
9
9
  data: string;
10
10
  }> | undefined;
11
11
  };
@@ -20,7 +20,7 @@ declare const NoMethodsTask_base: {
20
20
  new (): {
21
21
  readonly __task_host_brand: void;
22
22
  readonly __task_host_input: unknown;
23
- readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk").JsonObject, unknown> | undefined;
23
+ readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk/index.js").JsonObject, unknown> | undefined;
24
24
  };
25
25
  };
26
26
  /** TaskHost without any decorated methods (invalid) */
@@ -31,7 +31,7 @@ declare const NoSchemaTask_base: {
31
31
  new (): {
32
32
  readonly __task_host_brand: void;
33
33
  readonly __task_host_input: unknown;
34
- readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk").JsonObject, unknown> | undefined;
34
+ readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk/index.js").JsonObject, unknown> | undefined;
35
35
  };
36
36
  };
37
37
  /** TaskHost without input schema */
@@ -46,7 +46,7 @@ declare const TestWorkflow_base: {
46
46
  readonly __workflow_host_input: {
47
47
  id: string;
48
48
  };
49
- readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk").JsonObject, {
49
+ readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk/index.js").JsonObject, {
50
50
  id: string;
51
51
  }> | undefined;
52
52
  };
@@ -64,7 +64,7 @@ declare const NoMethodsWorkflow_base: {
64
64
  new (): {
65
65
  readonly __workflow_host_brand: void;
66
66
  readonly __workflow_host_input: unknown;
67
- readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk").JsonObject, unknown> | undefined;
67
+ readonly inputSchema: () => import("@standard-schema/spec").StandardSchemaV1<import("@hatchet-dev/typescript-sdk/index.js").JsonObject, unknown> | undefined;
68
68
  };
69
69
  };
70
70
  /** WorkflowHost without any decorated methods (invalid) */
@@ -0,0 +1,58 @@
1
+ //#region src/abstracts/hosts.ts
2
+ /**
3
+ * Marker class for Hatchet workflow host classes.
4
+ */ var WorkflowHost = class {
5
+ inputSchema;
6
+ __workflow_host_brand;
7
+ __workflow_host_input;
8
+ /**
9
+ * Constructor for the WorkflowHost class.
10
+ *
11
+ * @param inputSchema
12
+ * @protected
13
+ */ constructor(inputSchema) {
14
+ this.inputSchema = inputSchema;
15
+ }
16
+ };
17
+ /**
18
+ * Marker class for Hatchet task host classes.
19
+ */ var TaskHost = class {
20
+ inputSchema;
21
+ __task_host_brand;
22
+ __task_host_input;
23
+ /**
24
+ * Constructor for the TaskHost class.
25
+ *
26
+ * @param inputSchema
27
+ * @protected
28
+ */ constructor(inputSchema) {
29
+ this.inputSchema = inputSchema;
30
+ }
31
+ };
32
+ /**
33
+ * Creates a new WorkflowHost class with the provided input schema.
34
+ *
35
+ * @param input The input schema.
36
+ */ function workflowHost(input) {
37
+ return class WorkflowHostIntermediate extends WorkflowHost {
38
+ constructor() {
39
+ super(() => input);
40
+ }
41
+ };
42
+ }
43
+ /**
44
+ * Creates a new TaskHost class with the provided input schema.
45
+ *
46
+ * @param input The input schema.
47
+ */ function taskHost(input) {
48
+ return class TaskHostIntermediate extends TaskHost {
49
+ constructor() {
50
+ super(() => input);
51
+ }
52
+ };
53
+ }
54
+ //#endregion
55
+ exports.TaskHost = TaskHost;
56
+ exports.WorkflowHost = WorkflowHost;
57
+ exports.taskHost = taskHost;
58
+ exports.workflowHost = workflowHost;
@@ -0,0 +1,66 @@
1
+ import type { InputType } from "@hatchet-dev/typescript-sdk";
2
+ import type { StandardSchemaV1 } from "@standard-schema/spec";
3
+ /**
4
+ * Interface for classes that provide a schema for their input.
5
+ */
6
+ export interface InputSchemaProvider<T> {
7
+ /**
8
+ * Returns the schema for the input of the host.
9
+ * If undefined, the input is not validated.
10
+ */
11
+ inputSchema: () => StandardSchemaV1<InputType, T> | undefined;
12
+ }
13
+ /**
14
+ * Marker class for Hatchet workflow host classes.
15
+ */
16
+ export declare abstract class WorkflowHost<I> implements InputSchemaProvider<I> {
17
+ readonly inputSchema: InputSchemaProvider<I>["inputSchema"];
18
+ readonly __workflow_host_brand: void;
19
+ readonly __workflow_host_input: I;
20
+ /**
21
+ * Constructor for the WorkflowHost class.
22
+ *
23
+ * @param inputSchema
24
+ * @protected
25
+ */
26
+ protected constructor(inputSchema: InputSchemaProvider<I>["inputSchema"]);
27
+ }
28
+ /**
29
+ * Marker class for Hatchet task host classes.
30
+ */
31
+ export declare abstract class TaskHost<I> implements InputSchemaProvider<I> {
32
+ readonly inputSchema: InputSchemaProvider<I>["inputSchema"];
33
+ readonly __task_host_brand: void;
34
+ readonly __task_host_input: I;
35
+ /**
36
+ * Constructor for the TaskHost class.
37
+ *
38
+ * @param inputSchema
39
+ * @protected
40
+ */
41
+ protected constructor(inputSchema: InputSchemaProvider<I>["inputSchema"]);
42
+ }
43
+ /**
44
+ * Creates a new WorkflowHost class with the provided input schema.
45
+ *
46
+ * @param input The input schema.
47
+ */
48
+ export declare function workflowHost<I>(input?: ReturnType<InputSchemaProvider<I>["inputSchema"]>): {
49
+ new (): {
50
+ readonly __workflow_host_brand: void;
51
+ readonly __workflow_host_input: I;
52
+ readonly inputSchema: () => StandardSchemaV1<import("@hatchet-dev/typescript-sdk").JsonObject, I> | undefined;
53
+ };
54
+ };
55
+ /**
56
+ * Creates a new TaskHost class with the provided input schema.
57
+ *
58
+ * @param input The input schema.
59
+ */
60
+ export declare function taskHost<I>(input?: ReturnType<InputSchemaProvider<I>["inputSchema"]>): {
61
+ new (): {
62
+ readonly __task_host_brand: void;
63
+ readonly __task_host_input: I;
64
+ readonly inputSchema: () => StandardSchemaV1<import("@hatchet-dev/typescript-sdk").JsonObject, I> | undefined;
65
+ };
66
+ };
@@ -45,7 +45,7 @@ export declare abstract class TaskHost<I> implements InputSchemaProvider<I> {
45
45
  *
46
46
  * @param input The input schema.
47
47
  */
48
- export declare function workflowHost<I>(input?: ReturnType<InputSchemaProvider<I>["inputSchema"]> | undefined): {
48
+ export declare function workflowHost<I>(input?: ReturnType<InputSchemaProvider<I>["inputSchema"]>): {
49
49
  new (): {
50
50
  readonly __workflow_host_brand: void;
51
51
  readonly __workflow_host_input: I;
@@ -57,7 +57,7 @@ export declare function workflowHost<I>(input?: ReturnType<InputSchemaProvider<I
57
57
  *
58
58
  * @param input The input schema.
59
59
  */
60
- export declare function taskHost<I>(input?: ReturnType<InputSchemaProvider<I>["inputSchema"]> | undefined): {
60
+ export declare function taskHost<I>(input?: ReturnType<InputSchemaProvider<I>["inputSchema"]>): {
61
61
  new (): {
62
62
  readonly __task_host_brand: void;
63
63
  readonly __task_host_input: I;
@@ -0,0 +1,55 @@
1
+ //#region src/abstracts/hosts.ts
2
+ /**
3
+ * Marker class for Hatchet workflow host classes.
4
+ */ var WorkflowHost = class {
5
+ inputSchema;
6
+ __workflow_host_brand;
7
+ __workflow_host_input;
8
+ /**
9
+ * Constructor for the WorkflowHost class.
10
+ *
11
+ * @param inputSchema
12
+ * @protected
13
+ */ constructor(inputSchema) {
14
+ this.inputSchema = inputSchema;
15
+ }
16
+ };
17
+ /**
18
+ * Marker class for Hatchet task host classes.
19
+ */ var TaskHost = class {
20
+ inputSchema;
21
+ __task_host_brand;
22
+ __task_host_input;
23
+ /**
24
+ * Constructor for the TaskHost class.
25
+ *
26
+ * @param inputSchema
27
+ * @protected
28
+ */ constructor(inputSchema) {
29
+ this.inputSchema = inputSchema;
30
+ }
31
+ };
32
+ /**
33
+ * Creates a new WorkflowHost class with the provided input schema.
34
+ *
35
+ * @param input The input schema.
36
+ */ function workflowHost(input) {
37
+ return class WorkflowHostIntermediate extends WorkflowHost {
38
+ constructor() {
39
+ super(() => input);
40
+ }
41
+ };
42
+ }
43
+ /**
44
+ * Creates a new TaskHost class with the provided input schema.
45
+ *
46
+ * @param input The input schema.
47
+ */ function taskHost(input) {
48
+ return class TaskHostIntermediate extends TaskHost {
49
+ constructor() {
50
+ super(() => input);
51
+ }
52
+ };
53
+ }
54
+ //#endregion
55
+ export { TaskHost, WorkflowHost, taskHost, workflowHost };
@@ -0,0 +1 @@
1
+ export * from "./hosts.js";
@@ -1 +1 @@
1
- export * from "./hosts";
1
+ export * from "./hosts.js";
@@ -0,0 +1,80 @@
1
+ const require_event_definition = require("../events/event-definition.cjs");
2
+ const require_adapter_factory = require("../execution/host-run/adapter-factory.cjs");
3
+ let _nestjs_common = require("@nestjs/common");
4
+ let _hatchet_dev_typescript_sdk = require("@hatchet-dev/typescript-sdk");
5
+ //#region src/client/client.ts
6
+ function _ts_decorate(decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11
+ }
12
+ function _ts_metadata(k, v) {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
14
+ }
15
+ var Client = class {
16
+ client;
17
+ run;
18
+ constructor(client) {
19
+ this.client = client;
20
+ this.run = require_adapter_factory.createHostRunForAdmin(client);
21
+ }
22
+ /**
23
+ * Access to the underlying HatchetClient SDK.
24
+ * Use for advanced features not wrapped by this library.
25
+ */ get sdk() {
26
+ return this.client;
27
+ }
28
+ /**
29
+ * Emit a single event.
30
+ *
31
+ * @param event The event definition to emit.
32
+ * @param input The event payload (must match the event's schema).
33
+ * @param options Optional emit configuration.
34
+ * @returns The emitted event.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * await client.emit(UserCreatedEvent, { userId: "123", email: "user@example.com" });
39
+ * ```
40
+ */ async emit(event, input, options) {
41
+ return await this.client.events.push(event.name, {
42
+ ...input,
43
+ [require_event_definition.EVENT_MARKER]: event.name
44
+ }, options);
45
+ }
46
+ /**
47
+ * Emit multiple events of the same type.
48
+ *
49
+ * @param event The event definition to emit.
50
+ * @param inputs Array of event payloads.
51
+ * @param options Optional emit configuration.
52
+ * @returns Array of emitted events.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * await client.emitBulk(OrderPlacedEvent, [
57
+ * { orderId: "1", userId: "123", total: 100 },
58
+ * { orderId: "2", userId: "456", total: 200 },
59
+ * ]);
60
+ * ```
61
+ */ async emitBulk(event, inputs, options) {
62
+ if (inputs.length === 0) return [];
63
+ return (await this.client.events.bulkPush(event.name, inputs.map((input) => ({ payload: {
64
+ ...input,
65
+ [require_event_definition.EVENT_MARKER]: event.name
66
+ } })), options)).events;
67
+ }
68
+ };
69
+ Client = _ts_decorate([
70
+ (0, _nestjs_common.Injectable)(),
71
+ _ts_metadata("design:type", Function),
72
+ _ts_metadata("design:paramtypes", [typeof _hatchet_dev_typescript_sdk.HatchetClient === "undefined" ? Object : _hatchet_dev_typescript_sdk.HatchetClient])
73
+ ], Client);
74
+ //#endregion
75
+ Object.defineProperty(exports, "Client", {
76
+ enumerable: true,
77
+ get: function() {
78
+ return Client;
79
+ }
80
+ });
@@ -1,20 +1,9 @@
1
1
  import { HatchetClient } from "@hatchet-dev/typescript-sdk";
2
- import { type AnyEventDefinition, type EventInput } from "../events";
3
- import { HostRunFn } from "../interaction";
4
- import type { Event } from "@hatchet-dev/typescript-sdk/protoc/events";
5
- /**
6
- * Options for emitting events.
7
- */
8
- export interface EmitOptions {
9
- /**
10
- * Additional metadata to attach to the event.
11
- */
12
- additionalMetadata?: Record<string, string>;
13
- /**
14
- * Namespace for the event.
15
- */
16
- namespace?: string;
17
- }
2
+ import type { AnyEventDefinition, EventInput } from "../events/index.js";
3
+ import type { HostRunFn } from "../execution/index.js";
4
+ type EventClient = HatchetClient["events"];
5
+ type EventEmitOptions = Parameters<EventClient["push"]>[2];
6
+ type Event = Awaited<ReturnType<EventClient["push"]>>;
18
7
  export declare class Client {
19
8
  private readonly client;
20
9
  readonly run: HostRunFn;
@@ -37,7 +26,7 @@ export declare class Client {
37
26
  * await client.emit(UserCreatedEvent, { userId: "123", email: "user@example.com" });
38
27
  * ```
39
28
  */
40
- emit<E extends AnyEventDefinition>(event: E, input: EventInput<E>, options?: EmitOptions): Promise<Event>;
29
+ emit<E extends AnyEventDefinition>(event: E, input: EventInput<E>, options?: EventEmitOptions): Promise<Event>;
41
30
  /**
42
31
  * Emit multiple events of the same type.
43
32
  *
@@ -54,5 +43,6 @@ export declare class Client {
54
43
  * ]);
55
44
  * ```
56
45
  */
57
- emitBulk<E extends AnyEventDefinition>(event: E, inputs: EventInput<E>[], options?: EmitOptions): Promise<Event[]>;
46
+ emitBulk<E extends AnyEventDefinition>(event: E, inputs: EventInput<E>[], options?: EventEmitOptions): Promise<Event[]>;
58
47
  }
48
+ export {};
@@ -1,12 +1,9 @@
1
1
  import { HatchetClient } from "@hatchet-dev/typescript-sdk";
2
- import { PushEventOptions } from "@hatchet-dev/typescript-sdk/clients/event/event-client";
3
- import type { AnyEventDefinition, EventInput } from "../events";
4
- import type { HostRunFn } from "../execution";
5
- import type { Event } from "@hatchet-dev/typescript-sdk/protoc/events";
6
- /**
7
- * Options for emitting events.
8
- */
9
- type EmitOptions = PushEventOptions;
2
+ import type { AnyEventDefinition, EventInput } from "../events/index.js";
3
+ import type { HostRunFn } from "../execution/index.js";
4
+ type EventClient = HatchetClient["events"];
5
+ type EventEmitOptions = Parameters<EventClient["push"]>[2];
6
+ type Event = Awaited<ReturnType<EventClient["push"]>>;
10
7
  export declare class Client {
11
8
  private readonly client;
12
9
  readonly run: HostRunFn;
@@ -29,7 +26,7 @@ export declare class Client {
29
26
  * await client.emit(UserCreatedEvent, { userId: "123", email: "user@example.com" });
30
27
  * ```
31
28
  */
32
- emit<E extends AnyEventDefinition>(event: E, input: EventInput<E>, options?: EmitOptions): Promise<Event>;
29
+ emit<E extends AnyEventDefinition>(event: E, input: EventInput<E>, options?: EventEmitOptions): Promise<Event>;
33
30
  /**
34
31
  * Emit multiple events of the same type.
35
32
  *
@@ -46,6 +43,6 @@ export declare class Client {
46
43
  * ]);
47
44
  * ```
48
45
  */
49
- emitBulk<E extends AnyEventDefinition>(event: E, inputs: EventInput<E>[], options?: EmitOptions): Promise<Event[]>;
46
+ emitBulk<E extends AnyEventDefinition>(event: E, inputs: EventInput<E>[], options?: EventEmitOptions): Promise<Event[]>;
50
47
  }
51
48
  export {};
@@ -0,0 +1,75 @@
1
+ import { EVENT_MARKER } from "../events/event-definition.mjs";
2
+ import { createHostRunForAdmin } from "../execution/host-run/adapter-factory.mjs";
3
+ import { Injectable } from "@nestjs/common";
4
+ import { HatchetClient } from "@hatchet-dev/typescript-sdk";
5
+ //#region src/client/client.ts
6
+ function _ts_decorate(decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11
+ }
12
+ function _ts_metadata(k, v) {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
14
+ }
15
+ var Client = class {
16
+ client;
17
+ run;
18
+ constructor(client) {
19
+ this.client = client;
20
+ this.run = createHostRunForAdmin(client);
21
+ }
22
+ /**
23
+ * Access to the underlying HatchetClient SDK.
24
+ * Use for advanced features not wrapped by this library.
25
+ */ get sdk() {
26
+ return this.client;
27
+ }
28
+ /**
29
+ * Emit a single event.
30
+ *
31
+ * @param event The event definition to emit.
32
+ * @param input The event payload (must match the event's schema).
33
+ * @param options Optional emit configuration.
34
+ * @returns The emitted event.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * await client.emit(UserCreatedEvent, { userId: "123", email: "user@example.com" });
39
+ * ```
40
+ */ async emit(event, input, options) {
41
+ return await this.client.events.push(event.name, {
42
+ ...input,
43
+ [EVENT_MARKER]: event.name
44
+ }, options);
45
+ }
46
+ /**
47
+ * Emit multiple events of the same type.
48
+ *
49
+ * @param event The event definition to emit.
50
+ * @param inputs Array of event payloads.
51
+ * @param options Optional emit configuration.
52
+ * @returns Array of emitted events.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * await client.emitBulk(OrderPlacedEvent, [
57
+ * { orderId: "1", userId: "123", total: 100 },
58
+ * { orderId: "2", userId: "456", total: 200 },
59
+ * ]);
60
+ * ```
61
+ */ async emitBulk(event, inputs, options) {
62
+ if (inputs.length === 0) return [];
63
+ return (await this.client.events.bulkPush(event.name, inputs.map((input) => ({ payload: {
64
+ ...input,
65
+ [EVENT_MARKER]: event.name
66
+ } })), options)).events;
67
+ }
68
+ };
69
+ Client = _ts_decorate([
70
+ Injectable(),
71
+ _ts_metadata("design:type", Function),
72
+ _ts_metadata("design:paramtypes", [typeof HatchetClient === "undefined" ? Object : HatchetClient])
73
+ ], Client);
74
+ //#endregion
75
+ export { Client };
@@ -0,0 +1 @@
1
+ require("./client.cjs");
@@ -0,0 +1 @@
1
+ export * from "./client.js";
@@ -1 +1 @@
1
- export * from "./client";
1
+ export * from "./client.js";
@@ -0,0 +1,2 @@
1
+ import "./client.mjs";
2
+ export {};
@@ -0,0 +1,61 @@
1
+ //#region src/events/event-definition.ts
2
+ /**
3
+ * Marker embedded in event payload to identify an event type.
4
+ * Used by isCtx() type guard to determine which event triggered the workflow.
5
+ */ const EVENT_MARKER = "__event_name";
6
+ /**
7
+ * Type-safe event definition.
8
+ * Use with Client.emit() to publish events.
9
+ *
10
+ * @template TName The literal string type of the event name.
11
+ * @template TSchema The StandardSchema type for input validation.
12
+ */ var EventDefinition = class {
13
+ name;
14
+ schema;
15
+ /**
16
+ * Phantom types for input/output inference.
17
+ * Do not access at runtime - will throw.
18
+ */ __types;
19
+ constructor(name, schema) {
20
+ this.name = name;
21
+ this.schema = schema;
22
+ Object.defineProperty(this, "__types", { get() {
23
+ throw new Error("__types is a phantom property for type inference only");
24
+ } });
25
+ }
26
+ /**
27
+ * Type guard: checks if the context was triggered by this event.
28
+ * Validates the input against the event schema and throws if malformed.
29
+ *
30
+ * @param ctx The context to check (TaskCtx, WorkflowCtx, HelperCtx, or SDK Context).
31
+ * @returns True if the context input contains the event marker matching this event.
32
+ * @throws Error if the event marker matches but the payload fails schema validation.
33
+ */ isCtx(ctx) {
34
+ if (typeof ctx.input !== "object" || ctx.input === null || !("__event_name" in ctx.input) || ctx.input["__event_name"] !== this.name) return false;
35
+ const result = this.schema["~standard"].validate(ctx.input);
36
+ if (result instanceof Promise) throw new Error(`Event '${this.name}' schema validation must be synchronous. Use a sync schema.`);
37
+ if ("issues" in result && result.issues) throw new Error(`Event '${this.name}' payload is malformed: ${JSON.stringify(result.issues)}`);
38
+ return true;
39
+ }
40
+ };
41
+ /**
42
+ * Factory function to create a type-safe event definition.
43
+ *
44
+ * @param name The event name (e.g., "user:created").
45
+ * @param schema A StandardSchema-compatible schema (e.g., Zod schema).
46
+ * @returns A new EventDefinition instance.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { z } from "zod";
51
+ *
52
+ * const UserCreatedEvent = defineEvent("user:created", z.object({
53
+ * userId: z.string(),
54
+ * email: z.string().email(),
55
+ * }));
56
+ * ```
57
+ */ const defineEvent = (name, schema) => new EventDefinition(name, schema);
58
+ //#endregion
59
+ exports.EVENT_MARKER = EVENT_MARKER;
60
+ exports.EventDefinition = EventDefinition;
61
+ exports.defineEvent = defineEvent;