@jdevel/tnest 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -11
- package/dist/handlers/__tests__/typed-event-pattern.spec.js +6 -5
- package/dist/handlers/__tests__/typed-event-pattern.spec.js.map +1 -1
- package/dist/handlers/__tests__/typed-message-pattern.spec.js +9 -8
- package/dist/handlers/__tests__/typed-message-pattern.spec.js.map +1 -1
- package/dist/handlers/typed-event-pattern.decorator.d.ts +1 -1
- package/dist/handlers/typed-event-pattern.decorator.js +4 -2
- package/dist/handlers/typed-event-pattern.decorator.js.map +1 -1
- package/dist/handlers/typed-message-pattern.decorator.d.ts +1 -1
- package/dist/handlers/typed-message-pattern.decorator.js +4 -2
- package/dist/handlers/typed-message-pattern.decorator.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -259,24 +259,24 @@ this.users.send('user.created', { userId: '1', email: 'a@b.com' });
|
|
|
259
259
|
// ~~~~~~~~~~~~~~ ERROR: 'user.created' is an event, use emit()
|
|
260
260
|
```
|
|
261
261
|
|
|
262
|
-
|
|
262
|
+
The typed handler decorators also catch handler signature mismatches:
|
|
263
263
|
|
|
264
264
|
```ts
|
|
265
|
-
|
|
265
|
+
const MessagePattern = TypedMessagePattern<UserContracts>();
|
|
266
|
+
|
|
267
|
+
@MessagePattern('user.create')
|
|
266
268
|
async create(payload: { wrong: number }) {
|
|
267
269
|
// ~~~~~~~~~~~~~~~~ ERROR: expects { email: string; name: string }
|
|
268
270
|
return { id: '1' };
|
|
269
271
|
}
|
|
270
272
|
|
|
271
|
-
@
|
|
273
|
+
@MessagePattern('user.get')
|
|
272
274
|
async get(payload: { id: string }): Promise<{ wrong: boolean }> {
|
|
273
275
|
// ~~~~~~~~~~~~~~~~~ ERROR: must return User
|
|
274
276
|
return { wrong: true };
|
|
275
277
|
}
|
|
276
278
|
```
|
|
277
279
|
|
|
278
|
-
> **Note:** Omitting the second type parameter preserves the existing behavior — the decorator validates the pattern string but does not constrain the method signature.
|
|
279
|
-
|
|
280
280
|
### 4. Handle messages (consumer)
|
|
281
281
|
|
|
282
282
|
#### Using decorators
|
|
@@ -287,21 +287,24 @@ import { Controller } from '@nestjs/common';
|
|
|
287
287
|
import { TypedMessagePattern, TypedEventPattern } from '@jdevel/tnest';
|
|
288
288
|
import type { UserContracts } from './contracts/user.contracts';
|
|
289
289
|
|
|
290
|
+
// Bind the registry type once — pattern is specified only at the call site
|
|
291
|
+
const MessagePattern = TypedMessagePattern<UserContracts>();
|
|
292
|
+
const EventPattern = TypedEventPattern<UserContracts>();
|
|
293
|
+
|
|
290
294
|
@Controller()
|
|
291
295
|
export class UserController {
|
|
292
|
-
//
|
|
293
|
-
|
|
294
|
-
@TypedMessagePattern<UserContracts, 'user.create'>('user.create')
|
|
296
|
+
// The compiler enforces that payload and return type match the contract
|
|
297
|
+
@MessagePattern('user.create')
|
|
295
298
|
async create(payload: { email: string; name: string }) {
|
|
296
299
|
return { id: crypto.randomUUID(), ...payload };
|
|
297
300
|
}
|
|
298
301
|
|
|
299
|
-
@
|
|
302
|
+
@MessagePattern('user.get')
|
|
300
303
|
async get(payload: { id: string }) {
|
|
301
304
|
return { id: payload.id, email: 'user@example.com', name: 'Example' };
|
|
302
305
|
}
|
|
303
306
|
|
|
304
|
-
@
|
|
307
|
+
@EventPattern('user.created')
|
|
305
308
|
async handleCreated(payload: { userId: string; email: string }) {
|
|
306
309
|
console.log(`User created: ${payload.userId}`);
|
|
307
310
|
}
|
|
@@ -414,7 +417,9 @@ class ZodValidator implements ContractValidator {
|
|
|
414
417
|
{ provide: CONTRACT_VALIDATOR, useClass: ZodValidator }
|
|
415
418
|
|
|
416
419
|
// Apply to handlers — validation runs before the handler method
|
|
417
|
-
|
|
420
|
+
const MessagePattern = TypedMessagePattern<UserContracts>();
|
|
421
|
+
|
|
422
|
+
@MessagePattern('user.create')
|
|
418
423
|
@ValidateContract()
|
|
419
424
|
async create(payload: CreateUserDto) {
|
|
420
425
|
// payload has been validated at runtime
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
require("reflect-metadata");
|
|
13
13
|
const constants_1 = require("@nestjs/microservices/constants");
|
|
14
14
|
const typed_event_pattern_decorator_1 = require("../typed-event-pattern.decorator");
|
|
15
|
+
const EventPatternDecorator = (0, typed_event_pattern_decorator_1.TypedEventPattern)();
|
|
15
16
|
describe('TypedEventPattern', () => {
|
|
16
17
|
it('applies @EventPattern metadata with the given pattern', () => {
|
|
17
18
|
class TestHandler {
|
|
@@ -19,7 +20,7 @@ describe('TypedEventPattern', () => {
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
__decorate([
|
|
22
|
-
(
|
|
23
|
+
EventPatternDecorator('user.created'),
|
|
23
24
|
__metadata("design:type", Function),
|
|
24
25
|
__metadata("design:paramtypes", [Object]),
|
|
25
26
|
__metadata("design:returntype", void 0)
|
|
@@ -29,13 +30,13 @@ describe('TypedEventPattern', () => {
|
|
|
29
30
|
expect(metadata).toEqual(['user.created']);
|
|
30
31
|
expect(handlerType).toBe(2);
|
|
31
32
|
});
|
|
32
|
-
it('enforces method signature
|
|
33
|
+
it('enforces method signature', () => {
|
|
33
34
|
class TestHandler {
|
|
34
35
|
handle(_payload) {
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
__decorate([
|
|
38
|
-
(
|
|
39
|
+
EventPatternDecorator('user.created'),
|
|
39
40
|
__metadata("design:type", Function),
|
|
40
41
|
__metadata("design:paramtypes", [Object]),
|
|
41
42
|
__metadata("design:returntype", void 0)
|
|
@@ -43,13 +44,13 @@ describe('TypedEventPattern', () => {
|
|
|
43
44
|
const metadata = Reflect.getMetadata(constants_1.PATTERN_METADATA, TestHandler.prototype.handle);
|
|
44
45
|
expect(metadata).toEqual(['user.created']);
|
|
45
46
|
});
|
|
46
|
-
it('enforces async method signature
|
|
47
|
+
it('enforces async method signature', () => {
|
|
47
48
|
class TestHandler {
|
|
48
49
|
async handle(_payload) {
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
__decorate([
|
|
52
|
-
(
|
|
53
|
+
EventPatternDecorator('user.created'),
|
|
53
54
|
__metadata("design:type", Function),
|
|
54
55
|
__metadata("design:paramtypes", [Object]),
|
|
55
56
|
__metadata("design:returntype", Promise)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-event-pattern.spec.js","sourceRoot":"","sources":["../../../src/handlers/__tests__/typed-event-pattern.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAA0B;AAC1B,+DAA6F;AAC7F,oFAAqE;AAQrE,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,WAAW;YAEf,MAAM,CAAC,QAA4B;YAEnC,CAAC;SACF;QAHC;YADC,
|
|
1
|
+
{"version":3,"file":"typed-event-pattern.spec.js","sourceRoot":"","sources":["../../../src/handlers/__tests__/typed-event-pattern.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAA0B;AAC1B,+DAA6F;AAC7F,oFAAqE;AAQrE,MAAM,qBAAqB,GAAG,IAAA,iDAAiB,GAAgB,CAAC;AAEhE,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,WAAW;YAEf,MAAM,CAAC,QAA4B;YAEnC,CAAC;SACF;QAHC;YADC,qBAAqB,CAAC,cAAc,CAAC;;;;iDAGrC;QAIH,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,4BAAgB,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAErF,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,oCAAwB,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEhG,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;QAC3C,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACnC,MAAM,WAAW;YAEf,MAAM,CAAC,QAA4B;YAEnC,CAAC;SACF;QAHC;YADC,qBAAqB,CAAC,cAAc,CAAC;;;;iDAGrC;QAIH,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,4BAAgB,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAErF,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,WAAW;YAET,AAAN,KAAK,CAAC,MAAM,CAAC,QAA4B;YAEzC,CAAC;SACF;QAHO;YADL,qBAAqB,CAAC,cAAc,CAAC;;;;iDAGrC;QAIH,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,4BAAgB,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAErF,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
require("reflect-metadata");
|
|
13
13
|
const constants_1 = require("@nestjs/microservices/constants");
|
|
14
14
|
const typed_message_pattern_decorator_1 = require("../typed-message-pattern.decorator");
|
|
15
|
+
const MessagePattern = (0, typed_message_pattern_decorator_1.TypedMessagePattern)();
|
|
15
16
|
describe('TypedMessagePattern', () => {
|
|
16
17
|
it('applies @MessagePattern metadata with the given pattern', () => {
|
|
17
18
|
class TestHandler {
|
|
@@ -20,7 +21,7 @@ describe('TypedMessagePattern', () => {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
__decorate([
|
|
23
|
-
(
|
|
24
|
+
MessagePattern('user.create'),
|
|
24
25
|
__metadata("design:type", Function),
|
|
25
26
|
__metadata("design:paramtypes", [Object]),
|
|
26
27
|
__metadata("design:returntype", Object)
|
|
@@ -37,7 +38,7 @@ describe('TypedMessagePattern', () => {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
__decorate([
|
|
40
|
-
(
|
|
41
|
+
MessagePattern('user.get'),
|
|
41
42
|
__metadata("design:type", Function),
|
|
42
43
|
__metadata("design:paramtypes", [Object]),
|
|
43
44
|
__metadata("design:returntype", Object)
|
|
@@ -45,14 +46,14 @@ describe('TypedMessagePattern', () => {
|
|
|
45
46
|
const metadata = Reflect.getMetadata(constants_1.PATTERN_METADATA, TestHandler.prototype.handle);
|
|
46
47
|
expect(metadata).toEqual(['user.get']);
|
|
47
48
|
});
|
|
48
|
-
it('enforces method signature
|
|
49
|
+
it('enforces method signature for command patterns', () => {
|
|
49
50
|
class TestHandler {
|
|
50
51
|
handle(_payload) {
|
|
51
52
|
return { id: '1' };
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
__decorate([
|
|
55
|
-
(
|
|
56
|
+
MessagePattern('user.create'),
|
|
56
57
|
__metadata("design:type", Function),
|
|
57
58
|
__metadata("design:paramtypes", [Object]),
|
|
58
59
|
__metadata("design:returntype", Object)
|
|
@@ -60,14 +61,14 @@ describe('TypedMessagePattern', () => {
|
|
|
60
61
|
const metadata = Reflect.getMetadata(constants_1.PATTERN_METADATA, TestHandler.prototype.handle);
|
|
61
62
|
expect(metadata).toEqual(['user.create']);
|
|
62
63
|
});
|
|
63
|
-
it('enforces
|
|
64
|
+
it('enforces method signature for query patterns', () => {
|
|
64
65
|
class TestHandler {
|
|
65
66
|
handle(_payload) {
|
|
66
67
|
return { name: 'Alice' };
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
__decorate([
|
|
70
|
-
(
|
|
71
|
+
MessagePattern('user.get'),
|
|
71
72
|
__metadata("design:type", Function),
|
|
72
73
|
__metadata("design:paramtypes", [Object]),
|
|
73
74
|
__metadata("design:returntype", Object)
|
|
@@ -75,14 +76,14 @@ describe('TypedMessagePattern', () => {
|
|
|
75
76
|
const metadata = Reflect.getMetadata(constants_1.PATTERN_METADATA, TestHandler.prototype.handle);
|
|
76
77
|
expect(metadata).toEqual(['user.get']);
|
|
77
78
|
});
|
|
78
|
-
it('enforces async method signature
|
|
79
|
+
it('enforces async method signature', () => {
|
|
79
80
|
class TestHandler {
|
|
80
81
|
async handle(_payload) {
|
|
81
82
|
return { id: '1' };
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
__decorate([
|
|
85
|
-
(
|
|
86
|
+
MessagePattern('user.create'),
|
|
86
87
|
__metadata("design:type", Function),
|
|
87
88
|
__metadata("design:paramtypes", [Object]),
|
|
88
89
|
__metadata("design:returntype", Promise)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-message-pattern.spec.js","sourceRoot":"","sources":["../../../src/handlers/__tests__/typed-message-pattern.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAA0B;AAC1B,+DAA6F;AAC7F,wFAAyE;AAUzE,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,WAAW;YAEf,MAAM,CAAC,QAA0B;gBAC/B,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC;YACrB,CAAC;SACF;QAHC;YADC,
|
|
1
|
+
{"version":3,"file":"typed-message-pattern.spec.js","sourceRoot":"","sources":["../../../src/handlers/__tests__/typed-message-pattern.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAA0B;AAC1B,+DAA6F;AAC7F,wFAAyE;AAUzE,MAAM,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Decorator<TRegistry extends ContractRegistry, P extends string & keyof TRegistry> = (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<(data: PayloadOf<TRegistry[P]>) => void> | TypedPropertyDescriptor<(data: PayloadOf<TRegistry[P]>) => Promise<void>>) => void;
|
|
3
|
-
export declare function TypedEventPattern<TRegistry extends ContractRegistry
|
|
3
|
+
export declare function TypedEventPattern<TRegistry extends ContractRegistry>(): <P extends EventPatterns<TRegistry>>(pattern: P) => EventMethodDecorator<TRegistry, P>;
|
|
4
4
|
export {};
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypedEventPattern = TypedEventPattern;
|
|
4
4
|
const microservices_1 = require("@nestjs/microservices");
|
|
5
|
-
function TypedEventPattern(
|
|
6
|
-
return (
|
|
5
|
+
function TypedEventPattern() {
|
|
6
|
+
return (pattern) => {
|
|
7
|
+
return (0, microservices_1.EventPattern)(pattern);
|
|
8
|
+
};
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=typed-event-pattern.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-event-pattern.decorator.js","sourceRoot":"","sources":["../../src/handlers/typed-event-pattern.decorator.ts"],"names":[],"mappings":";;AAgBA,
|
|
1
|
+
{"version":3,"file":"typed-event-pattern.decorator.js","sourceRoot":"","sources":["../../src/handlers/typed-event-pattern.decorator.ts"],"names":[],"mappings":";;AAgBA,8CAKC;AArBD,yDAAqD;AAgBrD,SAAgB,iBAAiB;IAC/B,OAAO,CAAqC,OAAU,EAAsC,EAAE;QAE5F,OAAO,IAAA,4BAAY,EAAC,OAAiB,CAAQ,CAAC;IAChD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
2
|
import type { ContractRegistry, CommandPatterns, QueryPatterns, PayloadOf, ResponseOf } from '../contracts';
|
|
3
3
|
type MessageMethodDecorator<TRegistry extends ContractRegistry, P extends string & keyof TRegistry> = (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<(data: PayloadOf<TRegistry[P]>) => ResponseOf<TRegistry[P]>> | TypedPropertyDescriptor<(data: PayloadOf<TRegistry[P]>) => Promise<ResponseOf<TRegistry[P]>>> | TypedPropertyDescriptor<(data: PayloadOf<TRegistry[P]>) => Observable<ResponseOf<TRegistry[P]>>>) => void;
|
|
4
|
-
export declare function TypedMessagePattern<TRegistry extends ContractRegistry
|
|
4
|
+
export declare function TypedMessagePattern<TRegistry extends ContractRegistry>(): <P extends CommandPatterns<TRegistry> | QueryPatterns<TRegistry>>(pattern: P) => MessageMethodDecorator<TRegistry, P>;
|
|
5
5
|
export {};
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypedMessagePattern = TypedMessagePattern;
|
|
4
4
|
const microservices_1 = require("@nestjs/microservices");
|
|
5
|
-
function TypedMessagePattern(
|
|
6
|
-
return (
|
|
5
|
+
function TypedMessagePattern() {
|
|
6
|
+
return (pattern) => {
|
|
7
|
+
return (0, microservices_1.MessagePattern)(pattern);
|
|
8
|
+
};
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=typed-message-pattern.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-message-pattern.decorator.js","sourceRoot":"","sources":["../../src/handlers/typed-message-pattern.decorator.ts"],"names":[],"mappings":";;AA0BA,
|
|
1
|
+
{"version":3,"file":"typed-message-pattern.decorator.js","sourceRoot":"","sources":["../../src/handlers/typed-message-pattern.decorator.ts"],"names":[],"mappings":";;AA0BA,kDAOC;AAjCD,yDAAuD;AA0BvD,SAAgB,mBAAmB;IACjC,OAAO,CACL,OAAU,EAC4B,EAAE;QAExC,OAAO,IAAA,8BAAc,EAAC,OAAiB,CAAQ,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC"}
|