@abinnovision/nestjs-hatchet 0.2.0 → 0.2.2
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 +14 -0
- package/dist/explorer/declaration-builder.service.d.ts +6 -3
- package/dist/explorer/declaration-builder.service.js +15 -7
- package/dist/hatchet.module.js +18 -22
- package/dist/internal/shared-consts.d.ts +10 -0
- package/dist/internal/shared-consts.js +12 -1
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.2](https://github.com/abinnovision/nestjs-commons/compare/nestjs-hatchet-v0.2.1...nestjs-hatchet-v0.2.2) (2025-12-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* resolve interceptor using ModuleRef ([#67](https://github.com/abinnovision/nestjs-commons/issues/67)) ([aedb022](https://github.com/abinnovision/nestjs-commons/commit/aedb0223d4b8aa99a967420bf211c176da04a293))
|
|
9
|
+
|
|
10
|
+
## [0.2.1](https://github.com/abinnovision/nestjs-commons/compare/nestjs-hatchet-v0.2.0...nestjs-hatchet-v0.2.1) (2025-12-15)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* remove dual registration of host providers ([#64](https://github.com/abinnovision/nestjs-commons/issues/64)) ([2c262f2](https://github.com/abinnovision/nestjs-commons/commit/2c262f2877a7676854324ac841ae5f58f9dbd97f))
|
|
16
|
+
|
|
3
17
|
## [0.2.0](https://github.com/abinnovision/nestjs-commons/compare/nestjs-hatchet-v0.1.0...nestjs-hatchet-v0.2.0) (2025-12-15)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { TaskWorkflowDeclaration, WorkflowDeclaration } from "@hatchet-dev/typescript-sdk";
|
|
2
|
-
import {
|
|
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
|
|
6
|
-
|
|
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
|
|
24
|
+
const internal_1 = require("../internal");
|
|
24
25
|
let DeclarationBuilderService = class DeclarationBuilderService {
|
|
26
|
+
moduleRef;
|
|
27
|
+
interceptorRegistration;
|
|
25
28
|
interceptors;
|
|
26
|
-
constructor(
|
|
27
|
-
this.
|
|
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
|
|
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(
|
|
247
|
-
__param(
|
|
248
|
-
__metadata("design:paramtypes", [
|
|
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);
|
package/dist/hatchet.module.js
CHANGED
|
@@ -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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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.
|
|
@@ -54,17 +52,15 @@ let HatchetModule = class HatchetModule extends ConfigurableModuleClass {
|
|
|
54
52
|
*/
|
|
55
53
|
static forFeature(...refs) {
|
|
56
54
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-return
|
|
57
|
-
const
|
|
55
|
+
const hostRefs = refs.map((ref) => ref.host);
|
|
58
56
|
return {
|
|
59
57
|
module: HatchetFeatureModule,
|
|
60
58
|
providers: [
|
|
61
|
-
...hostProviders,
|
|
62
59
|
{
|
|
63
60
|
provide: internal_1.HatchetFeatureRegistration,
|
|
64
|
-
useValue: new internal_1.HatchetFeatureRegistration(
|
|
61
|
+
useValue: new internal_1.HatchetFeatureRegistration(hostRefs),
|
|
65
62
|
},
|
|
66
63
|
],
|
|
67
|
-
exports: hostProviders,
|
|
68
64
|
};
|
|
69
65
|
}
|
|
70
66
|
};
|
|
@@ -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,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@abinnovision/nestjs-hatchet",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nestjs",
|
|
7
7
|
"hatchet"
|
|
8
8
|
],
|
|
9
9
|
"repository": {
|
|
10
|
+
"type": "git",
|
|
10
11
|
"url": "https://github.com/abinnovision/nestjs-commons"
|
|
11
12
|
},
|
|
12
13
|
"license": "Apache-2.0",
|
|
@@ -64,5 +65,10 @@
|
|
|
64
65
|
"peerDependencies": {
|
|
65
66
|
"@nestjs/common": "^11.0.0",
|
|
66
67
|
"@nestjs/core": "^11.0.0"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"ghpr": true,
|
|
71
|
+
"npm": true,
|
|
72
|
+
"npmAccess": "public"
|
|
67
73
|
}
|
|
68
74
|
}
|