@abinnovision/nestjs-hatchet 0.2.1 → 0.2.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.3](https://github.com/abinnovision/nestjs-commons/compare/nestjs-hatchet-v0.2.2...nestjs-hatchet-v0.2.3) (2025-12-16)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * align exports in package.json ([#70](https://github.com/abinnovision/nestjs-commons/issues/70)) ([58956c5](https://github.com/abinnovision/nestjs-commons/commit/58956c5ea55394b65c6af405f4c6ac45555dc94a))
9
+
10
+ ## [0.2.2](https://github.com/abinnovision/nestjs-commons/compare/nestjs-hatchet-v0.2.1...nestjs-hatchet-v0.2.2) (2025-12-15)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * resolve interceptor using ModuleRef ([#67](https://github.com/abinnovision/nestjs-commons/issues/67)) ([aedb022](https://github.com/abinnovision/nestjs-commons/commit/aedb0223d4b8aa99a967420bf211c176da04a293))
16
+
3
17
  ## [0.2.1](https://github.com/abinnovision/nestjs-commons/compare/nestjs-hatchet-v0.2.0...nestjs-hatchet-v0.2.1) (2025-12-15)
4
18
 
5
19
 
@@ -1,9 +1,12 @@
1
1
  import { TaskWorkflowDeclaration, WorkflowDeclaration } from "@hatchet-dev/typescript-sdk";
2
- import { Interceptor } from "../interceptor";
2
+ import { ModuleRef } from "@nestjs/core";
3
+ import { InterceptorRegistration } from "../internal";
3
4
  import { AnyHost } from "../ref";
4
5
  export declare class DeclarationBuilderService {
5
- private readonly interceptors?;
6
- constructor(interceptors?: Interceptor[] | undefined);
6
+ private readonly moduleRef;
7
+ private readonly interceptorRegistration?;
8
+ private readonly interceptors;
9
+ constructor(moduleRef: ModuleRef, interceptorRegistration?: InterceptorRegistration | undefined);
7
10
  /**
8
11
  * Creates a WorkflowDeclaration or TaskWorkflowDeclaration from the given host.
9
12
  *
@@ -15,16 +15,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.DeclarationBuilderService = void 0;
16
16
  const typescript_sdk_1 = require("@hatchet-dev/typescript-sdk");
17
17
  const common_1 = require("@nestjs/common");
18
+ const core_1 = require("@nestjs/core");
18
19
  const directed_graph_typed_1 = require("directed-graph-typed");
19
20
  const abstracts_1 = require("../abstracts");
20
21
  const accessor_1 = require("../accessor");
21
22
  const context_factory_1 = require("../context/context-factory");
22
23
  const events_1 = require("../events");
23
- const interceptor_1 = require("../interceptor");
24
+ const internal_1 = require("../internal");
24
25
  let DeclarationBuilderService = class DeclarationBuilderService {
26
+ moduleRef;
27
+ interceptorRegistration;
25
28
  interceptors;
26
- constructor(interceptors) {
27
- this.interceptors = interceptors;
29
+ constructor(moduleRef, interceptorRegistration) {
30
+ this.moduleRef = moduleRef;
31
+ this.interceptorRegistration = interceptorRegistration;
32
+ // Try to resolve the refs to the instances.
33
+ const resolvedRefs = this.interceptorRegistration?.refs.map((token) => this.moduleRef.get(token, { strict: false }));
34
+ this.interceptors = resolvedRefs ?? [];
28
35
  }
29
36
  /**
30
37
  * Creates a WorkflowDeclaration or TaskWorkflowDeclaration from the given host.
@@ -227,7 +234,7 @@ let DeclarationBuilderService = class DeclarationBuilderService {
227
234
  * @returns The result of the function.
228
235
  */
229
236
  async executeWithInterceptors(ctx, fn) {
230
- if (!this.interceptors?.length) {
237
+ if (!this.interceptors.length) {
231
238
  return await fn();
232
239
  }
233
240
  // Chain from last to first (first interceptor is outermost)
@@ -243,7 +250,8 @@ let DeclarationBuilderService = class DeclarationBuilderService {
243
250
  exports.DeclarationBuilderService = DeclarationBuilderService;
244
251
  exports.DeclarationBuilderService = DeclarationBuilderService = __decorate([
245
252
  (0, common_1.Injectable)(),
246
- __param(0, (0, common_1.Optional)()),
247
- __param(0, (0, common_1.Inject)(interceptor_1.INTERCEPTORS)),
248
- __metadata("design:paramtypes", [Array])
253
+ __param(1, (0, common_1.Optional)()),
254
+ __param(1, (0, common_1.Inject)(internal_1.InterceptorRegistration)),
255
+ __metadata("design:paramtypes", [core_1.ModuleRef,
256
+ internal_1.InterceptorRegistration])
249
257
  ], DeclarationBuilderService);
@@ -12,7 +12,6 @@ const client_1 = require("./client");
12
12
  const declaration_builder_service_1 = require("./explorer/declaration-builder.service");
13
13
  const worker_management_service_1 = require("./explorer/worker-management.service");
14
14
  const hatchet_module_config_1 = require("./hatchet.module-config");
15
- const interceptor_1 = require("./interceptor");
16
15
  const internal_1 = require("./internal");
17
16
  const sdk_1 = require("./sdk");
18
17
  const { ConfigurableModuleClass } = new common_1.ConfigurableModuleBuilder({
@@ -20,23 +19,22 @@ const { ConfigurableModuleClass } = new common_1.ConfigurableModuleBuilder({
20
19
  moduleName: "HatchetModule",
21
20
  })
22
21
  .setClassMethodName("forRoot")
23
- .setExtras({ interceptors: undefined }, (definition, extras) => {
24
- const interceptorProviders = extras.interceptors?.length
25
- ? [
26
- ...extras.interceptors,
27
- {
28
- provide: interceptor_1.INTERCEPTORS,
29
- useFactory: (...interceptors) => interceptors,
30
- inject: extras.interceptors,
31
- },
32
- ]
33
- : [];
34
- return {
35
- ...definition,
36
- global: true,
37
- providers: [...(definition.providers ?? []), ...interceptorProviders],
38
- };
39
- })
22
+ .setExtras({ interceptors: undefined }, (definition, extras) => ({
23
+ ...definition,
24
+ global: true,
25
+ providers: [
26
+ ...(definition.providers ?? []),
27
+ // Store interceptor class references for later resolution via ModuleRef
28
+ ...(extras.interceptors?.length
29
+ ? [
30
+ {
31
+ provide: internal_1.InterceptorRegistration,
32
+ useValue: new internal_1.InterceptorRegistration(extras.interceptors),
33
+ },
34
+ ]
35
+ : []),
36
+ ],
37
+ }))
40
38
  .build();
41
39
  /**
42
40
  * Module for feature registration.
@@ -1,4 +1,6 @@
1
+ import type { Interceptor } from "../interceptor";
1
2
  import type { AnyHostCtor } from "../ref";
3
+ import type { Type } from "@nestjs/common";
2
4
  export declare const METADATA_KEY_HOST_OPTS = "hatchet:host:opts";
3
5
  export declare const METADATA_KEY_TASK_OPTS = "hatchet:task:opts";
4
6
  export declare const METADATA_KEY_WORKFLOW_TASK_OPTS = "hatchet:workflow:task:opts";
@@ -10,3 +12,11 @@ export declare class HatchetFeatureRegistration {
10
12
  readonly refs: AnyHostCtor[];
11
13
  constructor(refs: AnyHostCtor[]);
12
14
  }
15
+ /**
16
+ * Token class for interceptor registration.
17
+ * Stores interceptor class references for later resolution via ModuleRef.
18
+ */
19
+ export declare class InterceptorRegistration {
20
+ readonly refs: Type<Interceptor>[];
21
+ constructor(refs: Type<Interceptor>[]);
22
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HatchetFeatureRegistration = exports.METADATA_KEY_WORKFLOW_TASK_OPTS = exports.METADATA_KEY_TASK_OPTS = exports.METADATA_KEY_HOST_OPTS = void 0;
3
+ exports.InterceptorRegistration = exports.HatchetFeatureRegistration = exports.METADATA_KEY_WORKFLOW_TASK_OPTS = exports.METADATA_KEY_TASK_OPTS = exports.METADATA_KEY_HOST_OPTS = void 0;
4
4
  exports.METADATA_KEY_HOST_OPTS = "hatchet:host:opts";
5
5
  exports.METADATA_KEY_TASK_OPTS = "hatchet:task:opts";
6
6
  exports.METADATA_KEY_WORKFLOW_TASK_OPTS = "hatchet:workflow:task:opts";
@@ -15,3 +15,14 @@ class HatchetFeatureRegistration {
15
15
  }
16
16
  }
17
17
  exports.HatchetFeatureRegistration = HatchetFeatureRegistration;
18
+ /**
19
+ * Token class for interceptor registration.
20
+ * Stores interceptor class references for later resolution via ModuleRef.
21
+ */
22
+ class InterceptorRegistration {
23
+ refs;
24
+ constructor(refs) {
25
+ this.refs = refs;
26
+ }
27
+ }
28
+ exports.InterceptorRegistration = InterceptorRegistration;
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@abinnovision/nestjs-hatchet",
4
- "version": "0.2.1",
4
+ "version": "0.2.4",
5
5
  "keywords": [
6
6
  "nestjs",
7
7
  "hatchet"
8
8
  ],
9
9
  "repository": {
10
- "url": "https://github.com/abinnovision/nestjs-commons"
10
+ "type": "git",
11
+ "url": "https://github.com/abinnovision/nestjs-commons.git",
12
+ "directory": "packages/hatchet"
11
13
  },
12
14
  "license": "Apache-2.0",
13
15
  "author": {
@@ -18,11 +20,14 @@
18
20
  "exports": {
19
21
  ".": {
20
22
  "types": "./dist/index.d.ts",
21
- "require": "./dist/index.js"
23
+ "require": "./dist/index.js",
24
+ "default": "./dist/index.js"
22
25
  }
23
26
  },
24
27
  "files": [
25
- "dist"
28
+ "dist",
29
+ "LICENSE",
30
+ "README.md"
26
31
  ],
27
32
  "scripts": {
28
33
  "build": "tsc --project tsconfig.build.json",