@nathapp/nestjs-notify 1.0.0 → 1.2.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/dist/error/permanent-notification.error.d.ts +1 -1
- package/dist/error/permanent-notification.error.js +1 -1
- package/dist/error/permanent-notification.error.js.map +1 -1
- package/dist/processor/notification.processor.js +1 -1
- package/dist/processor/notification.processor.js.map +1 -1
- package/dist/service/default-template.service.d.ts +1 -0
- package/dist/service/default-template.service.js +15 -3
- package/dist/service/default-template.service.js.map +1 -1
- package/dist/template/index.d.ts +2 -0
- package/dist/template/index.js +9 -0
- package/dist/template/index.js.map +1 -1
- package/package.json +9 -9
- package/AGENTS.md +0 -73
- package/CLAUDE.md +0 -71
- package/GEMINI.md +0 -71
- package/codex.md +0 -71
|
@@ -2,4 +2,4 @@ export declare class PermanentNotificationError extends Error {
|
|
|
2
2
|
readonly originalError?: Error | undefined;
|
|
3
3
|
constructor(message: string, originalError?: Error | undefined);
|
|
4
4
|
}
|
|
5
|
-
export declare function isRetryableError(error:
|
|
5
|
+
export declare function isRetryableError(error: unknown): boolean;
|
|
@@ -15,7 +15,7 @@ function isRetryableError(error) {
|
|
|
15
15
|
if (error instanceof PermanentNotificationError) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
|
-
const message = error.message.toLowerCase();
|
|
18
|
+
const message = (error instanceof Error ? error.message : String(error)).toLowerCase();
|
|
19
19
|
const permanentPatterns = [
|
|
20
20
|
'invalid email',
|
|
21
21
|
'invalid phone',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permanent-notification.error.js","sourceRoot":"","sources":["../../lib/error/permanent-notification.error.ts"],"names":[],"mappings":";;;AAgCA,
|
|
1
|
+
{"version":3,"file":"permanent-notification.error.js","sourceRoot":"","sources":["../../lib/error/permanent-notification.error.ts"],"names":[],"mappings":";;;AAgCA,4CAkDC;AA9ED,MAAa,0BAA2B,SAAQ,KAAK;IACnD,YACE,OA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|
48
48
|
catch (error) {
|
|
49
49
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
50
|
-
const isRetryable = (0, error_1.isRetryableError)(
|
|
50
|
+
const isRetryable = (0, error_1.isRetryableError)(err);
|
|
51
51
|
this.logger.warn(`Failed to process notification job ${job.id}: ${err.message}`, err.stack);
|
|
52
52
|
if (isRetryable) {
|
|
53
53
|
const maxAttempts = (_b = (_a = job.opts) === null || _a === void 0 ? void 0 : _a.attempts) !== null && _b !== void 0 ? _b : 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.processor.js","sourceRoot":"","sources":["../../lib/processor/notification.processor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,wDAA2D;AAE3D,0CAIqB;AAGrB,oCAA4C;AAQrC,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAGhC,YAEE,aAA8C,EAE9C,UAAwC;QAFvB,kBAAa,GAAb,aAAa,CAAgB;QAE7B,eAAU,GAAV,UAAU,CAAa;QANzB,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAO9D,CAAC;IAME,AAAN,KAAK,CAAC,WAAW,CAAC,GAAkC;QAClD,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAMK,AAAN,KAAK,CAAC,UAAU,CAAC,GAAkC;QACjD,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAMK,AAAN,KAAK,CAAC,SAAS,CAAC,GAAkC;QAChD,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAMK,AAAN,KAAK,CAAC,aAAa,CAAC,GAAkC;QACpD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,+BAA+B,GAAG,CAAC,EAAE,iBAAiB,OAAO,EAAE,CAChE,CAAC;QACF,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAKO,KAAK,CAAC,mBAAmB,CAC/B,GAAkC;;QAElC,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,+BAA+B,GAAG,CAAC,EAAE,gBAAgB,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CACxE,CAAC;YAEF,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAExC,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,2CAA2C,GAAG,CAAC,EAAE,EAAE,CACpD,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACtE,MAAM,WAAW,GAAG,IAAA,wBAAgB,EAAC,
|
|
1
|
+
{"version":3,"file":"notification.processor.js","sourceRoot":"","sources":["../../lib/processor/notification.processor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,wDAA2D;AAE3D,0CAIqB;AAGrB,oCAA4C;AAQrC,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAGhC,YAEE,aAA8C,EAE9C,UAAwC;QAFvB,kBAAa,GAAb,aAAa,CAAgB;QAE7B,eAAU,GAAV,UAAU,CAAa;QANzB,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAO9D,CAAC;IAME,AAAN,KAAK,CAAC,WAAW,CAAC,GAAkC;QAClD,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAMK,AAAN,KAAK,CAAC,UAAU,CAAC,GAAkC;QACjD,OAAO,IAAI,C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65
65
|
const result = await this.templateRepo.update(id, input);
|
|
66
66
|
if (this.cache) {
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const newKey = (0, template_cache_1.templateCacheKey)(result.code, result.locale, result.tenantId, result.channel);
|
|
68
|
+
const oldKey = (0, template_cache_1.templateCacheKey)(existing.code, existing.locale, existing.tenantId, existing.channel);
|
|
69
|
+
await this.cache.delete(newKey);
|
|
70
|
+
if (oldKey !== newKey) {
|
|
71
|
+
await this.cache.delete(oldKey);
|
|
72
|
+
}
|
|
69
73
|
}
|
|
70
74
|
return result;
|
|
71
75
|
}
|
|
@@ -104,6 +108,9 @@ let DefaultTemplateService = DefaultTemplateService_1 = class DefaultTemplateSer
|
|
|
104
108
|
throw new exception_1.NotifyException(exception_1.NotifyExceptionCode.TEMPLATE_NOT_FOUND);
|
|
105
109
|
}
|
|
106
110
|
await this.templateRepo.delete(id);
|
|
111
|
+
if (this.cache) {
|
|
112
|
+
await this.cache.delete((0, template_cache_1.templateCacheKey)(existing.code, existing.locale, existing.tenantId, existing.channel));
|
|
113
|
+
}
|
|
107
114
|
}
|
|
108
115
|
render(template, data) {
|
|
109
116
|
return this.renderTemplate(template, data);
|
|
@@ -113,7 +120,7 @@ let DefaultTemplateService = DefaultTemplateService_1 = class DefaultTemplateSer
|
|
|
113
120
|
await ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.clear());
|
|
114
121
|
}
|
|
115
122
|
renderTemplate(template, data) {
|
|
116
|
-
const render = this.
|
|
123
|
+
const render = this.contentEngineFor(template.channel).compile(template.content);
|
|
117
124
|
const subjectRender = template.subject
|
|
118
125
|
? this.subjectEngine.compile(template.subject)
|
|
119
126
|
: undefined;
|
|
@@ -122,6 +129,11 @@ let DefaultTemplateService = DefaultTemplateService_1 = class DefaultTemplateSer
|
|
|
122
129
|
content: render(data),
|
|
123
130
|
};
|
|
124
131
|
}
|
|
132
|
+
contentEngineFor(channel) {
|
|
133
|
+
return this.templateEngine instanceof template_1.SimpleTemplateEngine
|
|
134
|
+
? this.templateEngine.forChannel(channel)
|
|
135
|
+
: this.templateEngine;
|
|
136
|
+
}
|
|
125
137
|
validateTemplateSyntax(content) {
|
|
126
138
|
if (!this.templateEngine.validate(content)) {
|
|
127
139
|
throw new exception_1.NotifyException(exception_1.NotifyExceptionCode.TEMPLATE_INVALID_SYNTAX);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-template.service.js","sourceRoot":"","sources":["../../lib/service/default-template.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAKwB;AACxB,0DAAmF;AACnF,0CAAmE;AAUnE,4CAAoE;AACpE,+DAIoC;AACpC,0CAAoE;AAG7D,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAKjC,YAEE,YAAoD,EAEpD,WAA4C,EAE5C,KAAgC,EAEhC,sBAA0D,EAG1D,KAAyC;QATtB,iBAAY,GAAZ,YAAY,CAAqB;QAEjC,gBAAW,GAAX,WAAW,CAAc;QAEzB,UAAK,GAAL,KAAK,CAAQ;QAEb,2BAAsB,GAAtB,sBAAsB,CAAiB;QAGvC,UAAK,GAAL,KAAK,CAAiB;QAfxB,WAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;QAiBlE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,sBAAsB,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,IAAI,+BAAoB,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAyB;;QACpC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;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EvB,WAAA,IAAA,iBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,eAAM,EAAC,+BAAc,CAAC,CAAA;;GAfd,sBAAsB,CAqLlC"}
|
package/dist/template/index.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ export interface SimpleTemplateEngineOptions {
|
|
|
7
7
|
}
|
|
8
8
|
export declare class SimpleTemplateEngine implements ITemplateEngine {
|
|
9
9
|
private readonly escapeHtml;
|
|
10
|
+
private readonly escapeExplicit;
|
|
10
11
|
constructor(options?: SimpleTemplateEngineOptions);
|
|
12
|
+
forChannel(channel?: string): SimpleTemplateEngine;
|
|
11
13
|
compile(template: string): (data: Record<string, unknown>) => string;
|
|
12
14
|
validate(template: string): boolean;
|
|
13
15
|
}
|
package/dist/template/index.js
CHANGED
|
@@ -25,10 +25,19 @@ const HTML_ESCAPE_MAP = {
|
|
|
25
25
|
function escapeHtml(value) {
|
|
26
26
|
return value.replace(/[&<>"']/g, (ch) => HTML_ESCAPE_MAP[ch]);
|
|
27
27
|
}
|
|
28
|
+
const PLAINTEXT_CHANNELS = new Set(['sms', 'push']);
|
|
28
29
|
class SimpleTemplateEngine {
|
|
29
30
|
constructor(options = {}) {
|
|
30
31
|
var _a;
|
|
31
32
|
this.escapeHtml = (_a = options.escapeHtml) !== null && _a !== void 0 ? _a : true;
|
|
33
|
+
this.escapeExplicit = options.escapeHtml !== undefined;
|
|
34
|
+
}
|
|
35
|
+
forChannel(channel) {
|
|
36
|
+
if (this.escapeExplicit) {
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
const escape = channel === undefined || !PLAINTEXT_CHANNELS.has(channel.toLowerCase());
|
|
40
|
+
return escape === this.escapeHtml ? this : new SimpleTemplateEngine({ escapeHtml: escape });
|
|
32
41
|
}
|
|
33
42
|
compile(template) {
|
|
34
43
|
const escape = this.escapeHtml;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/template/index.ts"],"names":[],"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OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;;YAC5C,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;YAC9B,OAAO,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACP,CAAC;IAED,QAAQ,CAAC,QAAgB;QACvB,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QACzD,MAAM,UAAU,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QAC1D,OAAO,SAAS,KAAK,UAAU,CAAC;IAClC,CAAC;CACF;AArCD,oDAqCC;AAED,+DAA6C;AAC7C,mDAAiC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathapp/nestjs-notify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Notification management with templates, preferences and delivery strategies for NestJS",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf dist && tsc -p tsconfig.json",
|
|
@@ -24,23 +24,23 @@
|
|
|
24
24
|
"lib": "lib"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nathapp/nestjs-tenant": "1.
|
|
28
|
-
"@nathapp/nestjs-data": "^3.3.0 || ^4.0.
|
|
29
|
-
"@nathapp/nestjs-common": "^3.3.0 || ^4.0.
|
|
27
|
+
"@nathapp/nestjs-tenant": "1.2.0",
|
|
28
|
+
"@nathapp/nestjs-data": "^3.3.0 || ^4.0.3",
|
|
29
|
+
"@nathapp/nestjs-common": "^3.3.0 || ^4.0.3",
|
|
30
30
|
"handlebars": "^4.7.8",
|
|
31
|
-
"@nathapp/nestjs-queue": "^3.3.0 || ^4.0.
|
|
31
|
+
"@nathapp/nestjs-queue": "^3.3.0 || ^4.0.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@nathapp/nestjs-cache": "^4.0.
|
|
34
|
+
"@nathapp/nestjs-cache": "^4.0.3",
|
|
35
35
|
"eslint": "^8.57.0",
|
|
36
36
|
"typescript": "^5"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@nestjs/common": "^11.0.0 || ^12.1.0",
|
|
40
40
|
"@nestjs/core": "^11.0.0 || ^12.1.0",
|
|
41
|
-
"@nathapp/nestjs-cache": "^3.3.0 || ^4.0.
|
|
42
|
-
"@nathapp/nestjs-common": "^3.3.0 || ^4.0.
|
|
43
|
-
"@nathapp/nestjs-notification": "^3.3.0 || ^4.0.
|
|
41
|
+
"@nathapp/nestjs-cache": "^3.3.0 || ^4.0.3",
|
|
42
|
+
"@nathapp/nestjs-common": "^3.3.0 || ^4.0.3",
|
|
43
|
+
"@nathapp/nestjs-notification": "^3.3.0 || ^4.0.3",
|
|
44
44
|
"@nestjs/event-emitter": "^3.0.0 || ^12.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
package/AGENTS.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# Agent Instructions
|
|
2
|
-
|
|
3
|
-
This file is auto-generated from `.nax/context.md`.
|
|
4
|
-
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
-
|
|
6
|
-
These instructions apply to all AI coding agents in this project.
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## Project Metadata
|
|
11
|
-
|
|
12
|
-
> Auto-injected by `nax generate`
|
|
13
|
-
|
|
14
|
-
**Project:** `@nathapp/nestjs-notify`
|
|
15
|
-
|
|
16
|
-
**Language:** TypeScript
|
|
17
|
-
|
|
18
|
-
**Key dependencies:** typescript
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
# CLAUDE.md — @nathapp/nestjs-notify
|
|
22
|
-
|
|
23
|
-
Notification management with templates, preferences and delivery strategies for NestJS. Management layer on top of `@nathapp/nestjs-notification` (which handles actual sending).
|
|
24
|
-
|
|
25
|
-
## Status: ✅ Complete (ADR-004 adopted)
|
|
26
|
-
|
|
27
|
-
## Directory Structure
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
lib/
|
|
31
|
-
├── constant/tokens.ts — DI tokens
|
|
32
|
-
├── delivery/ — TODO: delivery strategies (immediate, batched, digest, fallback chain)
|
|
33
|
-
├── dto/ — TODO: DTOs for notification operations
|
|
34
|
-
├── event/ — TODO: domain events (NotificationSent, DeliveryFailed, etc.)
|
|
35
|
-
├── exception/ — TODO: NotifyExceptionCode enum
|
|
36
|
-
├── interface/
|
|
37
|
-
│ ├── models/ — TODO: ITemplate, IPreference, IDeliveryLog
|
|
38
|
-
│ ├── repositories/ — TODO: repository interfaces
|
|
39
|
-
│ └── services/ — TODO: service interfaces
|
|
40
|
-
├── module/ — TODO: NotifyModule.register() / registerAsync()
|
|
41
|
-
├── service/ — TODO: DefaultNotifyService, DefaultTemplateService, etc.
|
|
42
|
-
└── template/ — TODO: Handlebars template engine integration
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## DI Tokens
|
|
46
|
-
|
|
47
|
-
**Repositories**: `TEMPLATE_REPOSITORY`, `PREFERENCE_REPOSITORY`, `DELIVERY_LOG_REPOSITORY`
|
|
48
|
-
|
|
49
|
-
**Services**: `NOTIFY_SERVICE`, `TEMPLATE_SERVICE`, `PREFERENCE_SERVICE`, `DELIVERY_SERVICE`, `DELIVERY_TRACKER`
|
|
50
|
-
|
|
51
|
-
## Dependencies
|
|
52
|
-
|
|
53
|
-
- `@nathapp/nestjs-tenant` (workspace) — tenant context
|
|
54
|
-
- `@nathapp/nestjs-common` ^3.0.0 — `AppException`
|
|
55
|
-
- `@nathapp/nestjs-notification` ^3.0.0 — actual email/SMS/push sending
|
|
56
|
-
- `@nestjs/event-emitter` — domain events
|
|
57
|
-
- `handlebars` ^4.7.8 — template rendering
|
|
58
|
-
|
|
59
|
-
## Architecture Notes
|
|
60
|
-
|
|
61
|
-
- **nestjs-notify** = management (templates, preferences, delivery tracking, retry/fallback)
|
|
62
|
-
- **nestjs-notification** (existing) = transport (send email via SES, SMS via Twilio, push via FCM)
|
|
63
|
-
- This package orchestrates WHEN and HOW to send; `nestjs-notification` handles the actual delivery
|
|
64
|
-
- Template rendering uses Handlebars — consumers register templates with variables
|
|
65
|
-
- Preferences: per-user, per-tenant channel preferences (email/SMS/push opt-in/out)
|
|
66
|
-
|
|
67
|
-
## ADR-004 Notes
|
|
68
|
-
|
|
69
|
-
All three repository interfaces (`ITemplateRepository`, `IPreferenceRepository`, `IDeliveryLogRepository`) now extend `IRepository<Domain, string>` from `@nathapp/nestjs-data`. This aligns them with the platform-wide repository contract (tenant, iam, account).
|
|
70
|
-
|
|
71
|
-
The tenant-guard pattern (ensuring tenant context before repository access) lives in `DefaultTemplateService` — it is not a separate guard class.
|
|
72
|
-
|
|
73
|
-
**No transactional flows** are introduced in nestjs-notify. Notification delivery spans external I/O (email/SMS/push providers) which cannot participate in a DB transaction. Failed deliveries are routed through the DLQ (`DefaultDlqService`) and retried via queue (BullMQ/Kafka/RabbitMQ) — a queue-only durability pattern, not a transaction pattern.
|
package/CLAUDE.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Project Context
|
|
2
|
-
|
|
3
|
-
This file is auto-generated from `.nax/context.md`.
|
|
4
|
-
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Project Metadata
|
|
9
|
-
|
|
10
|
-
> Auto-injected by `nax generate`
|
|
11
|
-
|
|
12
|
-
**Project:** `@nathapp/nestjs-notify`
|
|
13
|
-
|
|
14
|
-
**Language:** TypeScript
|
|
15
|
-
|
|
16
|
-
**Key dependencies:** typescript
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
# CLAUDE.md — @nathapp/nestjs-notify
|
|
20
|
-
|
|
21
|
-
Notification management with templates, preferences and delivery strategies for NestJS. Management layer on top of `@nathapp/nestjs-notification` (which handles actual sending).
|
|
22
|
-
|
|
23
|
-
## Status: ✅ Complete (ADR-004 adopted)
|
|
24
|
-
|
|
25
|
-
## Directory Structure
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
lib/
|
|
29
|
-
├── constant/tokens.ts — DI tokens
|
|
30
|
-
├── delivery/ — TODO: delivery strategies (immediate, batched, digest, fallback chain)
|
|
31
|
-
├── dto/ — TODO: DTOs for notification operations
|
|
32
|
-
├── event/ — TODO: domain events (NotificationSent, DeliveryFailed, etc.)
|
|
33
|
-
├── exception/ — TODO: NotifyExceptionCode enum
|
|
34
|
-
├── interface/
|
|
35
|
-
│ ├── models/ — TODO: ITemplate, IPreference, IDeliveryLog
|
|
36
|
-
│ ├── repositories/ — TODO: repository interfaces
|
|
37
|
-
│ └── services/ — TODO: service interfaces
|
|
38
|
-
├── module/ — TODO: NotifyModule.register() / registerAsync()
|
|
39
|
-
├── service/ — TODO: DefaultNotifyService, DefaultTemplateService, etc.
|
|
40
|
-
└── template/ — TODO: Handlebars template engine integration
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## DI Tokens
|
|
44
|
-
|
|
45
|
-
**Repositories**: `TEMPLATE_REPOSITORY`, `PREFERENCE_REPOSITORY`, `DELIVERY_LOG_REPOSITORY`
|
|
46
|
-
|
|
47
|
-
**Services**: `NOTIFY_SERVICE`, `TEMPLATE_SERVICE`, `PREFERENCE_SERVICE`, `DELIVERY_SERVICE`, `DELIVERY_TRACKER`
|
|
48
|
-
|
|
49
|
-
## Dependencies
|
|
50
|
-
|
|
51
|
-
- `@nathapp/nestjs-tenant` (workspace) — tenant context
|
|
52
|
-
- `@nathapp/nestjs-common` ^3.0.0 — `AppException`
|
|
53
|
-
- `@nathapp/nestjs-notification` ^3.0.0 — actual email/SMS/push sending
|
|
54
|
-
- `@nestjs/event-emitter` — domain events
|
|
55
|
-
- `handlebars` ^4.7.8 — template rendering
|
|
56
|
-
|
|
57
|
-
## Architecture Notes
|
|
58
|
-
|
|
59
|
-
- **nestjs-notify** = management (templates, preferences, delivery tracking, retry/fallback)
|
|
60
|
-
- **nestjs-notification** (existing) = transport (send email via SES, SMS via Twilio, push via FCM)
|
|
61
|
-
- This package orchestrates WHEN and HOW to send; `nestjs-notification` handles the actual delivery
|
|
62
|
-
- Template rendering uses Handlebars — consumers register templates with variables
|
|
63
|
-
- Preferences: per-user, per-tenant channel preferences (email/SMS/push opt-in/out)
|
|
64
|
-
|
|
65
|
-
## ADR-004 Notes
|
|
66
|
-
|
|
67
|
-
All three repository interfaces (`ITemplateRepository`, `IPreferenceRepository`, `IDeliveryLogRepository`) now extend `IRepository<Domain, string>` from `@nathapp/nestjs-data`. This aligns them with the platform-wide repository contract (tenant, iam, account).
|
|
68
|
-
|
|
69
|
-
The tenant-guard pattern (ensuring tenant context before repository access) lives in `DefaultTemplateService` — it is not a separate guard class.
|
|
70
|
-
|
|
71
|
-
**No transactional flows** are introduced in nestjs-notify. Notification delivery spans external I/O (email/SMS/push providers) which cannot participate in a DB transaction. Failed deliveries are routed through the DLQ (`DefaultDlqService`) and retried via queue (BullMQ/Kafka/RabbitMQ) — a queue-only durability pattern, not a transaction pattern.
|
package/GEMINI.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Gemini CLI Context
|
|
2
|
-
|
|
3
|
-
This file is auto-generated from `.nax/context.md`.
|
|
4
|
-
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Project Metadata
|
|
9
|
-
|
|
10
|
-
> Auto-injected by `nax generate`
|
|
11
|
-
|
|
12
|
-
**Project:** `@nathapp/nestjs-notify`
|
|
13
|
-
|
|
14
|
-
**Language:** TypeScript
|
|
15
|
-
|
|
16
|
-
**Key dependencies:** typescript
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
# CLAUDE.md — @nathapp/nestjs-notify
|
|
20
|
-
|
|
21
|
-
Notification management with templates, preferences and delivery strategies for NestJS. Management layer on top of `@nathapp/nestjs-notification` (which handles actual sending).
|
|
22
|
-
|
|
23
|
-
## Status: ✅ Complete (ADR-004 adopted)
|
|
24
|
-
|
|
25
|
-
## Directory Structure
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
lib/
|
|
29
|
-
├── constant/tokens.ts — DI tokens
|
|
30
|
-
├── delivery/ — TODO: delivery strategies (immediate, batched, digest, fallback chain)
|
|
31
|
-
├── dto/ — TODO: DTOs for notification operations
|
|
32
|
-
├── event/ — TODO: domain events (NotificationSent, DeliveryFailed, etc.)
|
|
33
|
-
├── exception/ — TODO: NotifyExceptionCode enum
|
|
34
|
-
├── interface/
|
|
35
|
-
│ ├── models/ — TODO: ITemplate, IPreference, IDeliveryLog
|
|
36
|
-
│ ├── repositories/ — TODO: repository interfaces
|
|
37
|
-
│ └── services/ — TODO: service interfaces
|
|
38
|
-
├── module/ — TODO: NotifyModule.register() / registerAsync()
|
|
39
|
-
├── service/ — TODO: DefaultNotifyService, DefaultTemplateService, etc.
|
|
40
|
-
└── template/ — TODO: Handlebars template engine integration
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## DI Tokens
|
|
44
|
-
|
|
45
|
-
**Repositories**: `TEMPLATE_REPOSITORY`, `PREFERENCE_REPOSITORY`, `DELIVERY_LOG_REPOSITORY`
|
|
46
|
-
|
|
47
|
-
**Services**: `NOTIFY_SERVICE`, `TEMPLATE_SERVICE`, `PREFERENCE_SERVICE`, `DELIVERY_SERVICE`, `DELIVERY_TRACKER`
|
|
48
|
-
|
|
49
|
-
## Dependencies
|
|
50
|
-
|
|
51
|
-
- `@nathapp/nestjs-tenant` (workspace) — tenant context
|
|
52
|
-
- `@nathapp/nestjs-common` ^3.0.0 — `AppException`
|
|
53
|
-
- `@nathapp/nestjs-notification` ^3.0.0 — actual email/SMS/push sending
|
|
54
|
-
- `@nestjs/event-emitter` — domain events
|
|
55
|
-
- `handlebars` ^4.7.8 — template rendering
|
|
56
|
-
|
|
57
|
-
## Architecture Notes
|
|
58
|
-
|
|
59
|
-
- **nestjs-notify** = management (templates, preferences, delivery tracking, retry/fallback)
|
|
60
|
-
- **nestjs-notification** (existing) = transport (send email via SES, SMS via Twilio, push via FCM)
|
|
61
|
-
- This package orchestrates WHEN and HOW to send; `nestjs-notification` handles the actual delivery
|
|
62
|
-
- Template rendering uses Handlebars — consumers register templates with variables
|
|
63
|
-
- Preferences: per-user, per-tenant channel preferences (email/SMS/push opt-in/out)
|
|
64
|
-
|
|
65
|
-
## ADR-004 Notes
|
|
66
|
-
|
|
67
|
-
All three repository interfaces (`ITemplateRepository`, `IPreferenceRepository`, `IDeliveryLogRepository`) now extend `IRepository<Domain, string>` from `@nathapp/nestjs-data`. This aligns them with the platform-wide repository contract (tenant, iam, account).
|
|
68
|
-
|
|
69
|
-
The tenant-guard pattern (ensuring tenant context before repository access) lives in `DefaultTemplateService` — it is not a separate guard class.
|
|
70
|
-
|
|
71
|
-
**No transactional flows** are introduced in nestjs-notify. Notification delivery spans external I/O (email/SMS/push providers) which cannot participate in a DB transaction. Failed deliveries are routed through the DLQ (`DefaultDlqService`) and retried via queue (BullMQ/Kafka/RabbitMQ) — a queue-only durability pattern, not a transaction pattern.
|
package/codex.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Codex Instructions
|
|
2
|
-
|
|
3
|
-
This file is auto-generated from `.nax/context.md`.
|
|
4
|
-
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Project Metadata
|
|
9
|
-
|
|
10
|
-
> Auto-injected by `nax generate`
|
|
11
|
-
|
|
12
|
-
**Project:** `@nathapp/nestjs-notify`
|
|
13
|
-
|
|
14
|
-
**Language:** TypeScript
|
|
15
|
-
|
|
16
|
-
**Key dependencies:** typescript
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
# CLAUDE.md — @nathapp/nestjs-notify
|
|
20
|
-
|
|
21
|
-
Notification management with templates, preferences and delivery strategies for NestJS. Management layer on top of `@nathapp/nestjs-notification` (which handles actual sending).
|
|
22
|
-
|
|
23
|
-
## Status: ✅ Complete (ADR-004 adopted)
|
|
24
|
-
|
|
25
|
-
## Directory Structure
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
lib/
|
|
29
|
-
├── constant/tokens.ts — DI tokens
|
|
30
|
-
├── delivery/ — TODO: delivery strategies (immediate, batched, digest, fallback chain)
|
|
31
|
-
├── dto/ — TODO: DTOs for notification operations
|
|
32
|
-
├── event/ — TODO: domain events (NotificationSent, DeliveryFailed, etc.)
|
|
33
|
-
├── exception/ — TODO: NotifyExceptionCode enum
|
|
34
|
-
├── interface/
|
|
35
|
-
│ ├── models/ — TODO: ITemplate, IPreference, IDeliveryLog
|
|
36
|
-
│ ├── repositories/ — TODO: repository interfaces
|
|
37
|
-
│ └── services/ — TODO: service interfaces
|
|
38
|
-
├── module/ — TODO: NotifyModule.register() / registerAsync()
|
|
39
|
-
├── service/ — TODO: DefaultNotifyService, DefaultTemplateService, etc.
|
|
40
|
-
└── template/ — TODO: Handlebars template engine integration
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## DI Tokens
|
|
44
|
-
|
|
45
|
-
**Repositories**: `TEMPLATE_REPOSITORY`, `PREFERENCE_REPOSITORY`, `DELIVERY_LOG_REPOSITORY`
|
|
46
|
-
|
|
47
|
-
**Services**: `NOTIFY_SERVICE`, `TEMPLATE_SERVICE`, `PREFERENCE_SERVICE`, `DELIVERY_SERVICE`, `DELIVERY_TRACKER`
|
|
48
|
-
|
|
49
|
-
## Dependencies
|
|
50
|
-
|
|
51
|
-
- `@nathapp/nestjs-tenant` (workspace) — tenant context
|
|
52
|
-
- `@nathapp/nestjs-common` ^3.0.0 — `AppException`
|
|
53
|
-
- `@nathapp/nestjs-notification` ^3.0.0 — actual email/SMS/push sending
|
|
54
|
-
- `@nestjs/event-emitter` — domain events
|
|
55
|
-
- `handlebars` ^4.7.8 — template rendering
|
|
56
|
-
|
|
57
|
-
## Architecture Notes
|
|
58
|
-
|
|
59
|
-
- **nestjs-notify** = management (templates, preferences, delivery tracking, retry/fallback)
|
|
60
|
-
- **nestjs-notification** (existing) = transport (send email via SES, SMS via Twilio, push via FCM)
|
|
61
|
-
- This package orchestrates WHEN and HOW to send; `nestjs-notification` handles the actual delivery
|
|
62
|
-
- Template rendering uses Handlebars — consumers register templates with variables
|
|
63
|
-
- Preferences: per-user, per-tenant channel preferences (email/SMS/push opt-in/out)
|
|
64
|
-
|
|
65
|
-
## ADR-004 Notes
|
|
66
|
-
|
|
67
|
-
All three repository interfaces (`ITemplateRepository`, `IPreferenceRepository`, `IDeliveryLogRepository`) now extend `IRepository<Domain, string>` from `@nathapp/nestjs-data`. This aligns them with the platform-wide repository contract (tenant, iam, account).
|
|
68
|
-
|
|
69
|
-
The tenant-guard pattern (ensuring tenant context before repository access) lives in `DefaultTemplateService` — it is not a separate guard class.
|
|
70
|
-
|
|
71
|
-
**No transactional flows** are introduced in nestjs-notify. Notification delivery spans external I/O (email/SMS/push providers) which cannot participate in a DB transaction. Failed deliveries are routed through the DLQ (`DefaultDlqService`) and retried via queue (BullMQ/Kafka/RabbitMQ) — a queue-only durability pattern, not a transaction pattern.
|