nesthub 1.0.0 → 1.0.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/README.md +0 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/queue/README.md +1 -1
- package/dist/queue/index.d.ts +4 -9
- package/dist/queue/index.js +5 -1
- package/dist/queue/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/queue/README.md +1 -1
- package/dist/cache/index.spec.d.ts +0 -1
- package/dist/cache/index.spec.js +0 -61
- package/dist/cache/index.spec.js.map +0 -1
- package/dist/excel/excel.module.d.ts +0 -2
- package/dist/excel/excel.module.js +0 -21
- package/dist/excel/excel.module.js.map +0 -1
- package/dist/excel/interfaces.d.ts +0 -19
- package/dist/excel/interfaces.js +0 -3
- package/dist/excel/interfaces.js.map +0 -1
- package/dist/index.spec.d.ts +0 -1
- package/dist/index.spec.js +0 -11
- package/dist/index.spec.js.map +0 -1
- package/dist/notification/email/index.d.ts +0 -62
- package/dist/notification/email/index.js +0 -253
- package/dist/notification/email/index.js.map +0 -1
- package/dist/notification/email/index.spec.d.ts +0 -1
- package/dist/notification/email/index.spec.js +0 -121
- package/dist/notification/email/index.spec.js.map +0 -1
- package/dist/notification/firebase/index.d.ts +0 -52
- package/dist/notification/firebase/index.js +0 -261
- package/dist/notification/firebase/index.js.map +0 -1
- package/dist/notification/firebase/index.spec.d.ts +0 -1
- package/dist/notification/firebase/index.spec.js +0 -114
- package/dist/notification/firebase/index.spec.js.map +0 -1
- package/dist/notification/index.spec.d.ts +0 -1
- package/dist/notification/index.spec.js +0 -336
- package/dist/notification/index.spec.js.map +0 -1
- package/dist/notification/shared.d.ts +0 -48
- package/dist/notification/shared.js +0 -95
- package/dist/notification/shared.js.map +0 -1
- package/dist/notification/sms/index.d.ts +0 -52
- package/dist/notification/sms/index.js +0 -234
- package/dist/notification/sms/index.js.map +0 -1
- package/dist/notification/sms/index.spec.d.ts +0 -1
- package/dist/notification/sms/index.spec.js +0 -123
- package/dist/notification/sms/index.spec.js.map +0 -1
- package/dist/notification/telegram/index.d.ts +0 -50
- package/dist/notification/telegram/index.js +0 -248
- package/dist/notification/telegram/index.js.map +0 -1
- package/dist/notification/telegram/index.spec.d.ts +0 -1
- package/dist/notification/telegram/index.spec.js +0 -108
- package/dist/notification/telegram/index.spec.js.map +0 -1
- package/dist/notification/typeorm-storage.d.ts +0 -28
- package/dist/notification/typeorm-storage.js +0 -56
- package/dist/notification/typeorm-storage.js.map +0 -1
- package/dist/notification/unified.d.ts +0 -47
- package/dist/notification/unified.js +0 -207
- package/dist/notification/unified.js.map +0 -1
- package/dist/queue/index.spec.d.ts +0 -1
- package/dist/queue/index.spec.js +0 -76
- package/dist/queue/index.spec.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/typeorm/index.spec.d.ts +0 -1
- package/dist/typeorm/index.spec.js +0 -109
- package/dist/typeorm/index.spec.js.map +0 -1
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
let nextJobId = 1;
|
|
4
|
-
jest.mock('bullmq', () => ({
|
|
5
|
-
Queue: jest.fn().mockImplementation(() => ({
|
|
6
|
-
add: jest
|
|
7
|
-
.fn()
|
|
8
|
-
.mockImplementation(() => Promise.resolve({ id: `bull-mock-job-${nextJobId++}` })),
|
|
9
|
-
remove: jest.fn().mockResolvedValue(undefined),
|
|
10
|
-
close: jest.fn().mockResolvedValue(undefined),
|
|
11
|
-
})),
|
|
12
|
-
Worker: jest.fn().mockImplementation(() => ({
|
|
13
|
-
close: jest.fn().mockResolvedValue(undefined),
|
|
14
|
-
})),
|
|
15
|
-
}));
|
|
16
|
-
const testing_1 = require("@nestjs/testing");
|
|
17
|
-
const index_1 = require("./index");
|
|
18
|
-
class InMemoryStorage {
|
|
19
|
-
records = new Map();
|
|
20
|
-
byDedup = new Map();
|
|
21
|
-
save(record) {
|
|
22
|
-
this.records.set(record.id, record);
|
|
23
|
-
if (record.dedupId)
|
|
24
|
-
this.byDedup.set(record.dedupId, record.id);
|
|
25
|
-
return Promise.resolve();
|
|
26
|
-
}
|
|
27
|
-
update(recordId, updates) {
|
|
28
|
-
const existing = this.records.get(recordId);
|
|
29
|
-
if (existing) {
|
|
30
|
-
this.records.set(recordId, { ...existing, ...updates });
|
|
31
|
-
}
|
|
32
|
-
return Promise.resolve();
|
|
33
|
-
}
|
|
34
|
-
findByDedupId(dedupId) {
|
|
35
|
-
const id = this.byDedup.get(dedupId);
|
|
36
|
-
if (!id)
|
|
37
|
-
return Promise.resolve(null);
|
|
38
|
-
return Promise.resolve(this.records.get(id) ?? null);
|
|
39
|
-
}
|
|
40
|
-
get(recordId) {
|
|
41
|
-
return this.records.get(recordId);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
describe('@vn.chemgio/nestjs-utilities/notification', () => {
|
|
45
|
-
describe('NotificationModule.forRoot', () => {
|
|
46
|
-
it('should return a DynamicModule with provider and export', () => {
|
|
47
|
-
const mod = index_1.NotificationModule.forRoot({
|
|
48
|
-
sendgrid: { apiKey: 'test-key' },
|
|
49
|
-
});
|
|
50
|
-
expect(mod.module).toBe(index_1.NotificationModule);
|
|
51
|
-
expect(mod.providers).toHaveLength(1);
|
|
52
|
-
expect(mod.exports).toContain(index_1.NOTIFICATION_SERVICE);
|
|
53
|
-
});
|
|
54
|
-
it('should default to empty options', () => {
|
|
55
|
-
const mod = index_1.NotificationModule.forRoot();
|
|
56
|
-
expect(mod.module).toBe(index_1.NotificationModule);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
describe('NotificationService (unified)', () => {
|
|
60
|
-
let service;
|
|
61
|
-
let storage;
|
|
62
|
-
let module;
|
|
63
|
-
afterEach(async () => {
|
|
64
|
-
if (module)
|
|
65
|
-
await module.close();
|
|
66
|
-
});
|
|
67
|
-
async function createModule(options) {
|
|
68
|
-
storage = new InMemoryStorage();
|
|
69
|
-
const opts = {
|
|
70
|
-
...options,
|
|
71
|
-
storage: { provider: options.storage?.provider ?? storage },
|
|
72
|
-
};
|
|
73
|
-
module = await testing_1.Test.createTestingModule({
|
|
74
|
-
imports: [index_1.NotificationModule.forRoot(opts)],
|
|
75
|
-
}).compile();
|
|
76
|
-
await module.init();
|
|
77
|
-
return module.get(index_1.NOTIFICATION_SERVICE);
|
|
78
|
-
}
|
|
79
|
-
describe('sendEmail', () => {
|
|
80
|
-
it('should return success with mock messageId when no sendgrid', async () => {
|
|
81
|
-
service = await createModule({
|
|
82
|
-
defaultFrom: 'test@example.com',
|
|
83
|
-
sendgrid: {},
|
|
84
|
-
});
|
|
85
|
-
const result = await service.sendEmail({
|
|
86
|
-
to: 'user@example.com',
|
|
87
|
-
subject: 'Test',
|
|
88
|
-
html: '<p>Hello</p>',
|
|
89
|
-
});
|
|
90
|
-
expect(result.success).toBe(true);
|
|
91
|
-
expect(result.messageId).toMatch(/^mock-/);
|
|
92
|
-
});
|
|
93
|
-
it('should return error when no content provided', async () => {
|
|
94
|
-
service = await createModule({ sendgrid: {} });
|
|
95
|
-
const result = await service.sendEmail({ to: 'user@example.com' });
|
|
96
|
-
expect(result.success).toBe(false);
|
|
97
|
-
expect(result.error).toBe('No content to send');
|
|
98
|
-
});
|
|
99
|
-
it('should render subject from template in options', async () => {
|
|
100
|
-
service = await createModule({
|
|
101
|
-
defaultFrom: 'test@example.com',
|
|
102
|
-
sendgrid: {},
|
|
103
|
-
templates: {
|
|
104
|
-
templates: {
|
|
105
|
-
welcome: {
|
|
106
|
-
subject: 'Hello {{name}}!',
|
|
107
|
-
html: '<p>Welcome {{name}}</p>',
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
const result = await service.sendEmail({
|
|
113
|
-
to: 'user@example.com',
|
|
114
|
-
template: 'welcome',
|
|
115
|
-
context: { name: 'Alice' },
|
|
116
|
-
});
|
|
117
|
-
expect(result.success).toBe(true);
|
|
118
|
-
});
|
|
119
|
-
describe('with locale-based templates', () => {
|
|
120
|
-
it('should resolve locale-specific template', async () => {
|
|
121
|
-
service = await createModule({
|
|
122
|
-
defaultFrom: 'test@example.com',
|
|
123
|
-
sendgrid: {},
|
|
124
|
-
templates: {
|
|
125
|
-
templates: {
|
|
126
|
-
'greeting.en': {
|
|
127
|
-
subject: 'Hello {{name}}!',
|
|
128
|
-
html: '<p>Hello {{name}}</p>',
|
|
129
|
-
},
|
|
130
|
-
'greeting.vi': {
|
|
131
|
-
subject: 'Xin chào {{name}}!',
|
|
132
|
-
html: '<p>Xin chào {{name}}</p>',
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
const resultEn = await service.sendEmail({
|
|
138
|
-
to: 'user@example.com',
|
|
139
|
-
template: 'greeting',
|
|
140
|
-
context: { name: 'Alice' },
|
|
141
|
-
locale: 'en',
|
|
142
|
-
});
|
|
143
|
-
expect(resultEn.success).toBe(true);
|
|
144
|
-
const resultVi = await service.sendEmail({
|
|
145
|
-
to: 'user@example.com',
|
|
146
|
-
template: 'greeting',
|
|
147
|
-
context: { name: 'Alice' },
|
|
148
|
-
locale: 'vi',
|
|
149
|
-
});
|
|
150
|
-
expect(resultVi.success).toBe(true);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
describe('with attachments', () => {
|
|
154
|
-
it('should pass attachments to send', async () => {
|
|
155
|
-
service = await createModule({
|
|
156
|
-
defaultFrom: 'test@example.com',
|
|
157
|
-
sendgrid: {},
|
|
158
|
-
});
|
|
159
|
-
const result = await service.sendEmail({
|
|
160
|
-
to: 'user@example.com',
|
|
161
|
-
subject: 'With attachment',
|
|
162
|
-
html: '<p>See attached</p>',
|
|
163
|
-
attachments: [
|
|
164
|
-
{
|
|
165
|
-
content: Buffer.from('test').toString('base64'),
|
|
166
|
-
filename: 'test.txt',
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
});
|
|
170
|
-
expect(result.success).toBe(true);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
describe('expiry and cancel', () => {
|
|
174
|
-
it('should cancel a pending job by dedupId', async () => {
|
|
175
|
-
service = await createModule({
|
|
176
|
-
defaultFrom: 'test@example.com',
|
|
177
|
-
sendgrid: {},
|
|
178
|
-
queue: {
|
|
179
|
-
useQueue: true,
|
|
180
|
-
connection: { url: 'redis://localhost:6379' },
|
|
181
|
-
worker: false,
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
const sendResult = await service.sendEmail({
|
|
185
|
-
to: 'user@example.com',
|
|
186
|
-
subject: 'OTP',
|
|
187
|
-
html: '<p>Your OTP is 1234</p>',
|
|
188
|
-
mode: 'queue',
|
|
189
|
-
dedupId: 'otp-user-123',
|
|
190
|
-
});
|
|
191
|
-
expect(sendResult.success).toBe(true);
|
|
192
|
-
expect(sendResult.jobId).toMatch(/^bull-mock-job-/);
|
|
193
|
-
await service.cancelJob('otp-user-123');
|
|
194
|
-
const record = storage.get(sendResult.jobId);
|
|
195
|
-
expect(record?.status).toBe('cancelled');
|
|
196
|
-
});
|
|
197
|
-
it('should leave unrelated jobs untouched when cancelling', async () => {
|
|
198
|
-
service = await createModule({
|
|
199
|
-
defaultFrom: 'test@example.com',
|
|
200
|
-
sendgrid: {},
|
|
201
|
-
queue: {
|
|
202
|
-
useQueue: true,
|
|
203
|
-
connection: { url: 'redis://localhost:6379' },
|
|
204
|
-
worker: false,
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
const result1 = await service.sendEmail({
|
|
208
|
-
to: 'user@example.com',
|
|
209
|
-
subject: 'Keep me',
|
|
210
|
-
html: '<p>Keep</p>',
|
|
211
|
-
mode: 'queue',
|
|
212
|
-
dedupId: 'keep-me',
|
|
213
|
-
});
|
|
214
|
-
await service.sendEmail({
|
|
215
|
-
to: 'user@example.com',
|
|
216
|
-
subject: 'Cancel me',
|
|
217
|
-
html: '<p>Cancel</p>',
|
|
218
|
-
mode: 'queue',
|
|
219
|
-
dedupId: 'cancel-me',
|
|
220
|
-
});
|
|
221
|
-
await service.cancelJob('cancel-me');
|
|
222
|
-
const r1 = storage.get(result1.jobId);
|
|
223
|
-
expect(r1?.status).toBe('pending');
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
describe('queue mode', () => {
|
|
227
|
-
it('should enqueue and save pending record when queue mode', async () => {
|
|
228
|
-
service = await createModule({
|
|
229
|
-
defaultFrom: 'test@example.com',
|
|
230
|
-
sendgrid: {},
|
|
231
|
-
queue: {
|
|
232
|
-
useQueue: true,
|
|
233
|
-
connection: { url: 'redis://localhost:6379' },
|
|
234
|
-
worker: false,
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
const result = await service.sendEmail({
|
|
238
|
-
to: 'user@example.com',
|
|
239
|
-
subject: 'Queued',
|
|
240
|
-
html: '<p>Queued message</p>',
|
|
241
|
-
mode: 'queue',
|
|
242
|
-
});
|
|
243
|
-
expect(result.success).toBe(true);
|
|
244
|
-
expect(result.jobId).toMatch(/^bull-mock-job-/);
|
|
245
|
-
const record = storage.get(result.jobId);
|
|
246
|
-
expect(record).toBeDefined();
|
|
247
|
-
expect(record?.status).toBe('pending');
|
|
248
|
-
expect(record?.subject).toBe('Queued');
|
|
249
|
-
});
|
|
250
|
-
it('should include dedupId in record when provided', async () => {
|
|
251
|
-
service = await createModule({
|
|
252
|
-
defaultFrom: 'test@example.com',
|
|
253
|
-
sendgrid: {},
|
|
254
|
-
queue: {
|
|
255
|
-
useQueue: true,
|
|
256
|
-
connection: { url: 'redis://localhost:6379' },
|
|
257
|
-
worker: false,
|
|
258
|
-
},
|
|
259
|
-
});
|
|
260
|
-
const result = await service.sendEmail({
|
|
261
|
-
to: 'user@example.com',
|
|
262
|
-
subject: 'Dedup test',
|
|
263
|
-
html: '<p>Dedup</p>',
|
|
264
|
-
mode: 'queue',
|
|
265
|
-
dedupId: 'dedup-test-456',
|
|
266
|
-
});
|
|
267
|
-
const record = storage.get(result.jobId);
|
|
268
|
-
expect(record?.dedupId).toBe('dedup-test-456');
|
|
269
|
-
expect(record?.status).toBe('pending');
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
describe('sendSms', () => {
|
|
274
|
-
it('should return not-configured error without twilio config', async () => {
|
|
275
|
-
service = await createModule({});
|
|
276
|
-
const result = await service.sendSms({
|
|
277
|
-
to: '+84123456789',
|
|
278
|
-
body: 'Test',
|
|
279
|
-
});
|
|
280
|
-
expect(result.success).toBe(false);
|
|
281
|
-
expect(result.error).toMatch(/not configured/i);
|
|
282
|
-
});
|
|
283
|
-
it('should send via console fallback with valid config', async () => {
|
|
284
|
-
service = await createModule({
|
|
285
|
-
twilio: { accountSid: 'sid', authToken: 'token' },
|
|
286
|
-
});
|
|
287
|
-
const result = await service.sendSms({
|
|
288
|
-
to: '+84123456789',
|
|
289
|
-
body: 'Hello from SMS',
|
|
290
|
-
});
|
|
291
|
-
expect(result.success).toBe(true);
|
|
292
|
-
expect(result.messageId).toMatch(/^mock-/);
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
describe('sendPush', () => {
|
|
296
|
-
it('should return not-configured error without firebase config', async () => {
|
|
297
|
-
service = await createModule({});
|
|
298
|
-
const result = await service.sendPush({
|
|
299
|
-
token: 'device-token',
|
|
300
|
-
title: 'Hi',
|
|
301
|
-
body: 'Test',
|
|
302
|
-
});
|
|
303
|
-
expect(result.success).toBe(false);
|
|
304
|
-
expect(result.error).toMatch(/not configured/i);
|
|
305
|
-
});
|
|
306
|
-
it('should send via console fallback with valid config', async () => {
|
|
307
|
-
service = await createModule({ firebase: {} });
|
|
308
|
-
const result = await service.sendPush({
|
|
309
|
-
token: 'device-token',
|
|
310
|
-
title: 'Hi',
|
|
311
|
-
body: 'Test',
|
|
312
|
-
});
|
|
313
|
-
expect(result.success).toBe(true);
|
|
314
|
-
expect(result.messageId).toMatch(/^mock-/);
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
describe('sendTelegram', () => {
|
|
318
|
-
it('should return not-configured error without botToken', async () => {
|
|
319
|
-
service = await createModule({});
|
|
320
|
-
const result = await service.sendTelegram({
|
|
321
|
-
chatId: 12345,
|
|
322
|
-
text: 'Hi',
|
|
323
|
-
});
|
|
324
|
-
expect(result.success).toBe(false);
|
|
325
|
-
expect(result.error).toMatch(/not configured/i);
|
|
326
|
-
});
|
|
327
|
-
it('should return no-content error when no text or template', async () => {
|
|
328
|
-
service = await createModule({ botToken: 'test-token' });
|
|
329
|
-
const result = await service.sendTelegram({ chatId: 12345 });
|
|
330
|
-
expect(result.success).toBe(false);
|
|
331
|
-
expect(result.error).toBe('No content to send');
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
//# sourceMappingURL=index.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../src/notification/index.spec.ts"],"names":[],"mappings":";;AAAA,IAAI,SAAS,GAAG,CAAC,CAAC;AAClB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;IACzB,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;QACzC,GAAG,EAAE,IAAI;aACN,EAAE,EAAE;aACJ,kBAAkB,CAAC,GAAG,EAAE,CACvB,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,iBAAiB,SAAS,EAAE,EAAE,EAAE,CAAC,CACxD;QACH,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;QAC9C,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;KAC9C,CAAC,CAAC;IACH,MAAM,EAAE,IAAI,CAAC,EAA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,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;gBAC7D,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACnC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export declare const NOTIFICATION_STORAGE = "NOTIFICATION_STORAGE";
|
|
2
|
-
export type SendMode = 'direct' | 'queue';
|
|
3
|
-
export interface NotificationRecord {
|
|
4
|
-
id: string;
|
|
5
|
-
to: string;
|
|
6
|
-
subject?: string;
|
|
7
|
-
body?: string;
|
|
8
|
-
template?: string;
|
|
9
|
-
channel?: string;
|
|
10
|
-
status: 'pending' | 'sent' | 'failed' | 'cancelled' | 'expired';
|
|
11
|
-
messageId?: string;
|
|
12
|
-
error?: string;
|
|
13
|
-
expiresAt?: string;
|
|
14
|
-
dedupId?: string;
|
|
15
|
-
createdAt: string;
|
|
16
|
-
sentAt?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface NotificationStorage {
|
|
19
|
-
save(record: NotificationRecord): Promise<void>;
|
|
20
|
-
update(recordId: string, updates: Partial<NotificationRecord>): Promise<void>;
|
|
21
|
-
findByDedupId(dedupId: string): Promise<NotificationRecord | null>;
|
|
22
|
-
}
|
|
23
|
-
export interface SendResult {
|
|
24
|
-
success: boolean;
|
|
25
|
-
messageId?: string;
|
|
26
|
-
error?: string;
|
|
27
|
-
jobId?: string;
|
|
28
|
-
}
|
|
29
|
-
export interface NotificationTemplate {
|
|
30
|
-
subject?: string;
|
|
31
|
-
html?: string;
|
|
32
|
-
text?: string;
|
|
33
|
-
body?: string;
|
|
34
|
-
}
|
|
35
|
-
export declare function dynamicImport(name: string): Promise<Record<string, unknown>>;
|
|
36
|
-
export declare class TemplateService {
|
|
37
|
-
private templates;
|
|
38
|
-
loadFromDir(dir: string): Promise<void>;
|
|
39
|
-
loadFromRecord(templates: Record<string, NotificationTemplate>): void;
|
|
40
|
-
resolveName(name: string, locale: string): string;
|
|
41
|
-
hasTemplate(name: string): boolean;
|
|
42
|
-
render(name: string, context: Record<string, unknown>): string;
|
|
43
|
-
}
|
|
44
|
-
export declare class ConsoleNotificationStorage implements NotificationStorage {
|
|
45
|
-
save(record: NotificationRecord): Promise<void>;
|
|
46
|
-
update(recordId: string, updates: Partial<NotificationRecord>): Promise<void>;
|
|
47
|
-
findByDedupId(dedupId: string): Promise<NotificationRecord | null>;
|
|
48
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ConsoleNotificationStorage = exports.TemplateService = exports.NOTIFICATION_STORAGE = void 0;
|
|
7
|
-
exports.dynamicImport = dynamicImport;
|
|
8
|
-
const handlebars_1 = __importDefault(require("handlebars"));
|
|
9
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
10
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
-
exports.NOTIFICATION_STORAGE = 'NOTIFICATION_STORAGE';
|
|
12
|
-
async function dynamicImport(name) {
|
|
13
|
-
try {
|
|
14
|
-
return (await import(name));
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
const _require = eval('require');
|
|
18
|
-
return _require(name);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
async function walkDir(dir) {
|
|
22
|
-
const entries = await promises_1.default.readdir(dir, { withFileTypes: true });
|
|
23
|
-
const files = [];
|
|
24
|
-
for (const entry of entries) {
|
|
25
|
-
const fullPath = node_path_1.default.join(dir, entry.name);
|
|
26
|
-
if (entry.isDirectory()) {
|
|
27
|
-
files.push(...(await walkDir(fullPath)));
|
|
28
|
-
}
|
|
29
|
-
else if (entry.isFile() && entry.name.endsWith('.hbs')) {
|
|
30
|
-
files.push(fullPath);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return files;
|
|
34
|
-
}
|
|
35
|
-
class TemplateService {
|
|
36
|
-
templates = new Map();
|
|
37
|
-
async loadFromDir(dir) {
|
|
38
|
-
const files = await walkDir(dir);
|
|
39
|
-
for (const fullPath of files) {
|
|
40
|
-
const relativePath = node_path_1.default.relative(dir, fullPath);
|
|
41
|
-
const name = relativePath.replace(/\.hbs$/, '').replace(/\\/g, '/');
|
|
42
|
-
const content = await promises_1.default.readFile(fullPath, 'utf-8');
|
|
43
|
-
this.templates.set(name, handlebars_1.default.compile(content));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
loadFromRecord(templates) {
|
|
47
|
-
for (const [name, tmpl] of Object.entries(templates)) {
|
|
48
|
-
if (tmpl.subject)
|
|
49
|
-
this.templates.set(`subject:${name}`, handlebars_1.default.compile(tmpl.subject));
|
|
50
|
-
if (tmpl.html)
|
|
51
|
-
this.templates.set(`html:${name}`, handlebars_1.default.compile(tmpl.html));
|
|
52
|
-
if (tmpl.text)
|
|
53
|
-
this.templates.set(`text:${name}`, handlebars_1.default.compile(tmpl.text));
|
|
54
|
-
if (tmpl.body)
|
|
55
|
-
this.templates.set(`body:${name}`, handlebars_1.default.compile(tmpl.body));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
resolveName(name, locale) {
|
|
59
|
-
const localeKey = `${name}.${locale}`;
|
|
60
|
-
if (this.templates.has(`html:${localeKey}`) ||
|
|
61
|
-
this.templates.has(`body:${localeKey}`))
|
|
62
|
-
return localeKey;
|
|
63
|
-
const dirKey = `${locale}/${name}`;
|
|
64
|
-
if (this.templates.has(`html:${dirKey}`) ||
|
|
65
|
-
this.templates.has(`body:${dirKey}`))
|
|
66
|
-
return dirKey;
|
|
67
|
-
return name;
|
|
68
|
-
}
|
|
69
|
-
hasTemplate(name) {
|
|
70
|
-
return this.templates.has(name);
|
|
71
|
-
}
|
|
72
|
-
render(name, context) {
|
|
73
|
-
const tmpl = this.templates.get(name);
|
|
74
|
-
if (!tmpl)
|
|
75
|
-
return '';
|
|
76
|
-
return tmpl(context);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.TemplateService = TemplateService;
|
|
80
|
-
class ConsoleNotificationStorage {
|
|
81
|
-
save(record) {
|
|
82
|
-
console.log('[NotificationStorage] Save:', JSON.stringify(record));
|
|
83
|
-
return Promise.resolve();
|
|
84
|
-
}
|
|
85
|
-
update(recordId, updates) {
|
|
86
|
-
console.log(`[NotificationStorage] Update ${recordId}:`, JSON.stringify(updates));
|
|
87
|
-
return Promise.resolve();
|
|
88
|
-
}
|
|
89
|
-
findByDedupId(dedupId) {
|
|
90
|
-
void dedupId;
|
|
91
|
-
return Promise.resolve(null);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.ConsoleNotificationStorage = ConsoleNotificationStorage;
|
|
95
|
-
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/notification/shared.ts"],"names":[],"mappings":";;;;;;AA4CA,sCASC;AArDD,4DAAoC;AACpC,gEAAkC;AAClC,0DAA6B;AAEhB,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAwCpD,KAAK,UAAU,aAAa,CACjC,IAAY;IAEZ,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAA4B,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAA4C,CAAC;QAC5E,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,GAAW;IAChC,M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AC,SAAS,CAAC,GAAG,CAAC,QAAQ,MAAM,EAAE,CAAC;YAEpC,OAAO,MAAM,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,IAAY,EAAE,OAAgC;QACnD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;CACF;AAnDD,0CAmDC;AAED,MAAa,0BAA0B;IACrC,IAAI,CAAC,MAA0B;QAC7B,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM,CACJ,QAAgB,EAChB,OAAoC;QAEpC,OAAO,CAAC,GAAG,CACT,gCAAgC,QAAQ,GAAG,EAC3C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CACxB,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,aAAa,CAAC,OAAe;QAC3B,KAAK,OAAO,CAAC;QACb,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AArBD,gEAqBC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { DynamicModule, InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
|
|
2
|
-
import type { SendMode, SendResult, NotificationStorage, NotificationTemplate } from '../shared';
|
|
3
|
-
export declare const SMS_SERVICE = "SMS_SERVICE";
|
|
4
|
-
export interface SendSmsOptions {
|
|
5
|
-
to: string;
|
|
6
|
-
body?: string;
|
|
7
|
-
template?: string;
|
|
8
|
-
context?: Record<string, unknown>;
|
|
9
|
-
locale?: string;
|
|
10
|
-
from?: string;
|
|
11
|
-
mode?: SendMode;
|
|
12
|
-
expiresAt?: Date | string;
|
|
13
|
-
dedupId?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface ISmsService {
|
|
16
|
-
sendSms(options: SendSmsOptions): Promise<SendResult>;
|
|
17
|
-
cancelJob(dedupId: string): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
export interface SmsModuleOptions {
|
|
20
|
-
defaultFrom?: string;
|
|
21
|
-
defaultLocale?: string;
|
|
22
|
-
twilio?: {
|
|
23
|
-
accountSid: string;
|
|
24
|
-
authToken: string;
|
|
25
|
-
from?: string;
|
|
26
|
-
};
|
|
27
|
-
queue?: {
|
|
28
|
-
useQueue?: boolean;
|
|
29
|
-
connection?: {
|
|
30
|
-
url: string;
|
|
31
|
-
};
|
|
32
|
-
prefix?: string;
|
|
33
|
-
defaultJobOptions?: Record<string, unknown>;
|
|
34
|
-
worker?: boolean;
|
|
35
|
-
concurrency?: number;
|
|
36
|
-
};
|
|
37
|
-
templates?: {
|
|
38
|
-
dir?: string;
|
|
39
|
-
templates?: Record<string, NotificationTemplate>;
|
|
40
|
-
};
|
|
41
|
-
storage?: {
|
|
42
|
-
provider?: NotificationStorage;
|
|
43
|
-
typeorm?: boolean;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export declare class SmsModule {
|
|
47
|
-
static forRoot(options?: SmsModuleOptions): DynamicModule;
|
|
48
|
-
static forRootAsync(options: {
|
|
49
|
-
useFactory: (...args: unknown[]) => SmsModuleOptions | Promise<SmsModuleOptions>;
|
|
50
|
-
inject?: (InjectionToken | OptionalFactoryDependency)[];
|
|
51
|
-
}): DynamicModule;
|
|
52
|
-
}
|