@tstdl/base 0.93.99 → 0.93.101

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.
Files changed (85) hide show
  1. package/authentication/client/authentication.service.d.ts +1 -1
  2. package/authentication/client/authentication.service.js +23 -11
  3. package/file/mime-type.d.ts +2 -2
  4. package/file/mime-type.js +2 -3
  5. package/file/server/index.d.ts +1 -0
  6. package/file/server/index.js +1 -0
  7. package/file/server/mime-type.d.ts +2 -0
  8. package/file/server/mime-type.js +5 -0
  9. package/notification/api/index.d.ts +1 -0
  10. package/notification/api/index.js +1 -0
  11. package/notification/api/notification.api.d.ts +8 -16
  12. package/notification/api/notification.api.js +13 -26
  13. package/notification/index.d.ts +1 -1
  14. package/notification/index.js +1 -1
  15. package/notification/models/in-app-notification.model.d.ts +9 -4
  16. package/notification/models/in-app-notification.model.js +25 -10
  17. package/notification/models/index.d.ts +1 -1
  18. package/notification/models/index.js +1 -1
  19. package/notification/models/notification-log.model.d.ts +42 -5
  20. package/notification/models/notification-log.model.js +34 -20
  21. package/notification/models/notification-preference.model.d.ts +2 -2
  22. package/notification/models/notification-preference.model.js +9 -9
  23. package/notification/models/notification-type.model.d.ts +17 -0
  24. package/notification/models/{notification-category.model.js → notification-type.model.js} +12 -13
  25. package/notification/models/web-push-subscription.model.d.ts +2 -2
  26. package/notification/models/web-push-subscription.model.js +8 -7
  27. package/notification/server/api/notification.api-controller.d.ts +2 -2
  28. package/notification/server/api/notification.api-controller.js +4 -3
  29. package/notification/server/drizzle/{0000_glorious_randall.sql → 0000_shiny_the_anarchist.sql} +27 -32
  30. package/notification/server/drizzle/meta/0000_snapshot.json +179 -179
  31. package/notification/server/drizzle/meta/_journal.json +2 -2
  32. package/notification/server/module.d.ts +2 -0
  33. package/notification/server/module.js +1 -0
  34. package/notification/server/providers/channel-provider.d.ts +4 -3
  35. package/notification/server/providers/channel-provider.js +2 -1
  36. package/notification/server/providers/email-channel-provider.d.ts +3 -3
  37. package/notification/server/providers/email-channel-provider.js +7 -9
  38. package/notification/server/providers/in-app-channel-provider.d.ts +5 -5
  39. package/notification/server/providers/in-app-channel-provider.js +15 -16
  40. package/notification/server/providers/index.d.ts +1 -1
  41. package/notification/server/providers/index.js +1 -1
  42. package/notification/server/providers/web-push-channel-provider.d.ts +5 -4
  43. package/notification/server/providers/web-push-channel-provider.js +8 -7
  44. package/notification/server/schemas.d.ts +3 -3
  45. package/notification/server/schemas.js +3 -4
  46. package/notification/server/services/index.d.ts +2 -4
  47. package/notification/server/services/index.js +2 -4
  48. package/notification/server/services/notification-delivery.worker.d.ts +7 -1
  49. package/notification/server/services/notification-delivery.worker.js +49 -37
  50. package/notification/server/services/notification-sse.service.d.ts +4 -7
  51. package/notification/server/services/notification-sse.service.js +4 -11
  52. package/notification/server/services/notification-template.d.ts +2 -2
  53. package/notification/server/services/notification-template.js +3 -1
  54. package/notification/server/services/notification-template.service.d.ts +1 -1
  55. package/notification/server/services/notification-template.service.js +7 -3
  56. package/notification/server/services/notification-type.service.d.ts +11 -0
  57. package/notification/server/services/notification-type.service.js +41 -0
  58. package/notification/server/services/notification.service.d.ts +4 -5
  59. package/notification/server/services/notification.service.js +44 -27
  60. package/notification/tests/notification-api.test.js +95 -0
  61. package/notification/tests/notification-flow.test.js +174 -28
  62. package/notification/tests/notification-type.service.test.d.ts +1 -0
  63. package/notification/tests/notification-type.service.test.js +35 -0
  64. package/package.json +2 -2
  65. package/rate-limit/postgres/postgres-rate-limiter.d.ts +9 -4
  66. package/rate-limit/postgres/postgres-rate-limiter.js +17 -10
  67. package/rate-limit/rate-limiter.d.ts +6 -6
  68. package/rate-limit/tests/postgres-rate-limiter.test.js +1 -1
  69. package/task-queue/postgres/task-queue.js +1 -1
  70. package/task-queue/task-queue.d.ts +3 -3
  71. package/task-queue/tests/extensive-dependencies.test.d.ts +1 -0
  72. package/task-queue/tests/extensive-dependencies.test.js +234 -0
  73. package/notification/enums.d.ts +0 -22
  74. package/notification/enums.js +0 -19
  75. package/notification/models/notification-category.model.d.ts +0 -17
  76. package/notification/server/services/notification-category.service.d.ts +0 -11
  77. package/notification/server/services/notification-category.service.js +0 -41
  78. package/notification/server/services/notification-delivery.task.d.ts +0 -9
  79. package/notification/server/services/notification-delivery.task.js +0 -1
  80. package/notification/server/services/singleton.d.ts +0 -3
  81. package/notification/server/services/singleton.js +0 -10
  82. package/notification/tests/notification-category.service.test.js +0 -36
  83. package/notification/tests/test-notification.model.d.ts +0 -4
  84. package/notification/tests/test-notification.model.js +0 -25
  85. /package/notification/tests/{notification-category.service.test.d.ts → notification-api.test.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "id": "270350fd-bfb6-488b-8b07-1e4e937e4f19",
2
+ "id": "8f352123-edd8-491f-a4ad-008d09531722",
3
3
  "prevId": "00000000-0000-0000-0000-000000000000",
4
4
  "version": "7",
5
5
  "dialect": "postgresql",
@@ -33,51 +33,54 @@
33
33
  "primaryKey": false,
34
34
  "notNull": true
35
35
  },
36
- "read_at": {
37
- "name": "read_at",
36
+ "read_timestamp": {
37
+ "name": "read_timestamp",
38
38
  "type": "timestamp with time zone",
39
39
  "primaryKey": false,
40
40
  "notNull": false
41
41
  },
42
- "archived_at": {
43
- "name": "archived_at",
42
+ "archive_timestamp": {
43
+ "name": "archive_timestamp",
44
44
  "type": "timestamp with time zone",
45
45
  "primaryKey": false,
46
46
  "notNull": false
47
- },
48
- "revision": {
49
- "name": "revision",
50
- "type": "integer",
51
- "primaryKey": false,
52
- "notNull": true
53
- },
54
- "revision_timestamp": {
55
- "name": "revision_timestamp",
56
- "type": "timestamp with time zone",
57
- "primaryKey": false,
58
- "notNull": true
59
- },
60
- "create_timestamp": {
61
- "name": "create_timestamp",
62
- "type": "timestamp with time zone",
63
- "primaryKey": false,
64
- "notNull": true
65
- },
66
- "delete_timestamp": {
67
- "name": "delete_timestamp",
68
- "type": "timestamp with time zone",
69
- "primaryKey": false,
70
- "notNull": false
71
- },
72
- "attributes": {
73
- "name": "attributes",
74
- "type": "jsonb",
75
- "primaryKey": false,
76
- "notNull": true,
77
- "default": "'{}'::jsonb"
78
47
  }
79
48
  },
80
- "indexes": {},
49
+ "indexes": {
50
+ "in_app_tenant_id_user_id_read_timestamp_archive_timestamp_idx": {
51
+ "name": "in_app_tenant_id_user_id_read_timestamp_archive_timestamp_idx",
52
+ "columns": [
53
+ {
54
+ "expression": "tenant_id",
55
+ "isExpression": false,
56
+ "asc": true,
57
+ "nulls": "last"
58
+ },
59
+ {
60
+ "expression": "user_id",
61
+ "isExpression": false,
62
+ "asc": true,
63
+ "nulls": "last"
64
+ },
65
+ {
66
+ "expression": "read_timestamp",
67
+ "isExpression": false,
68
+ "asc": true,
69
+ "nulls": "last"
70
+ },
71
+ {
72
+ "expression": "archive_timestamp",
73
+ "isExpression": false,
74
+ "asc": true,
75
+ "nulls": "last"
76
+ }
77
+ ],
78
+ "isUnique": false,
79
+ "concurrently": false,
80
+ "method": "btree",
81
+ "with": {}
82
+ }
83
+ },
81
84
  "foreignKeys": {
82
85
  "in_app_id_user_fkey": {
83
86
  "name": "in_app_id_user_fkey",
@@ -95,18 +98,20 @@
95
98
  "onDelete": "no action",
96
99
  "onUpdate": "no action"
97
100
  },
98
- "in_app_id_log_fkey": {
99
- "name": "in_app_id_log_fkey",
101
+ "in_app_tenantId_logId_userId_log_fkey": {
102
+ "name": "in_app_tenantId_logId_userId_log_fkey",
100
103
  "tableFrom": "in_app",
101
104
  "tableTo": "log",
102
105
  "schemaTo": "notification",
103
106
  "columnsFrom": [
104
107
  "tenant_id",
105
- "log_id"
108
+ "log_id",
109
+ "user_id"
106
110
  ],
107
111
  "columnsTo": [
108
112
  "tenant_id",
109
- "id"
113
+ "id",
114
+ "user_id"
110
115
  ],
111
116
  "onDelete": "no action",
112
117
  "onUpdate": "no action"
@@ -126,104 +131,6 @@
126
131
  "checkConstraints": {},
127
132
  "isRLSEnabled": false
128
133
  },
129
- "notification.category": {
130
- "name": "category",
131
- "schema": "notification",
132
- "columns": {
133
- "id": {
134
- "name": "id",
135
- "type": "uuid",
136
- "primaryKey": false,
137
- "notNull": true,
138
- "default": "gen_random_uuid()"
139
- },
140
- "tenant_id": {
141
- "name": "tenant_id",
142
- "type": "uuid",
143
- "primaryKey": false,
144
- "notNull": true
145
- },
146
- "label": {
147
- "name": "label",
148
- "type": "text",
149
- "primaryKey": false,
150
- "notNull": true
151
- },
152
- "key": {
153
- "name": "key",
154
- "type": "text",
155
- "primaryKey": false,
156
- "notNull": true
157
- },
158
- "throttling": {
159
- "name": "throttling",
160
- "type": "jsonb",
161
- "primaryKey": false,
162
- "notNull": false
163
- },
164
- "escalations": {
165
- "name": "escalations",
166
- "type": "jsonb",
167
- "primaryKey": false,
168
- "notNull": false
169
- },
170
- "revision": {
171
- "name": "revision",
172
- "type": "integer",
173
- "primaryKey": false,
174
- "notNull": true
175
- },
176
- "revision_timestamp": {
177
- "name": "revision_timestamp",
178
- "type": "timestamp with time zone",
179
- "primaryKey": false,
180
- "notNull": true
181
- },
182
- "create_timestamp": {
183
- "name": "create_timestamp",
184
- "type": "timestamp with time zone",
185
- "primaryKey": false,
186
- "notNull": true
187
- },
188
- "delete_timestamp": {
189
- "name": "delete_timestamp",
190
- "type": "timestamp with time zone",
191
- "primaryKey": false,
192
- "notNull": false
193
- },
194
- "attributes": {
195
- "name": "attributes",
196
- "type": "jsonb",
197
- "primaryKey": false,
198
- "notNull": true,
199
- "default": "'{}'::jsonb"
200
- }
201
- },
202
- "indexes": {},
203
- "foreignKeys": {},
204
- "compositePrimaryKeys": {
205
- "category_tenant_id_id_pk": {
206
- "name": "category_tenant_id_id_pk",
207
- "columns": [
208
- "tenant_id",
209
- "id"
210
- ]
211
- }
212
- },
213
- "uniqueConstraints": {
214
- "category_tenant_id_key_unique": {
215
- "name": "category_tenant_id_key_unique",
216
- "nullsNotDistinct": false,
217
- "columns": [
218
- "tenant_id",
219
- "key"
220
- ]
221
- }
222
- },
223
- "policies": {},
224
- "checkConstraints": {},
225
- "isRLSEnabled": false
226
- },
227
134
  "notification.log": {
228
135
  "name": "log",
229
136
  "schema": "notification",
@@ -247,12 +154,6 @@
247
154
  "primaryKey": false,
248
155
  "notNull": true
249
156
  },
250
- "category_id": {
251
- "name": "category_id",
252
- "type": "uuid",
253
- "primaryKey": false,
254
- "notNull": true
255
- },
256
157
  "type": {
257
158
  "name": "type",
258
159
  "type": "text",
@@ -319,30 +220,28 @@
319
220
  },
320
221
  "indexes": {},
321
222
  "foreignKeys": {
322
- "log_id_user_fkey": {
323
- "name": "log_id_user_fkey",
223
+ "log_type_type_key_fk": {
224
+ "name": "log_type_type_key_fk",
324
225
  "tableFrom": "log",
325
- "tableTo": "user",
326
- "schemaTo": "authentication",
226
+ "tableTo": "type",
227
+ "schemaTo": "notification",
327
228
  "columnsFrom": [
328
- "tenant_id",
329
- "user_id"
229
+ "type"
330
230
  ],
331
231
  "columnsTo": [
332
- "tenant_id",
333
- "id"
232
+ "key"
334
233
  ],
335
234
  "onDelete": "no action",
336
235
  "onUpdate": "no action"
337
236
  },
338
- "log_id_category_fkey": {
339
- "name": "log_id_category_fkey",
237
+ "log_id_user_fkey": {
238
+ "name": "log_id_user_fkey",
340
239
  "tableFrom": "log",
341
- "tableTo": "category",
342
- "schemaTo": "notification",
240
+ "tableTo": "user",
241
+ "schemaTo": "authentication",
343
242
  "columnsFrom": [
344
243
  "tenant_id",
345
- "category_id"
244
+ "user_id"
346
245
  ],
347
246
  "columnsTo": [
348
247
  "tenant_id",
@@ -361,7 +260,17 @@
361
260
  ]
362
261
  }
363
262
  },
364
- "uniqueConstraints": {},
263
+ "uniqueConstraints": {
264
+ "log_tenant_id_id_user_id_unique": {
265
+ "name": "log_tenant_id_id_user_id_unique",
266
+ "nullsNotDistinct": false,
267
+ "columns": [
268
+ "tenant_id",
269
+ "id",
270
+ "user_id"
271
+ ]
272
+ }
273
+ },
365
274
  "policies": {},
366
275
  "checkConstraints": {},
367
276
  "isRLSEnabled": false
@@ -389,9 +298,9 @@
389
298
  "primaryKey": false,
390
299
  "notNull": true
391
300
  },
392
- "category_id": {
393
- "name": "category_id",
394
- "type": "uuid",
301
+ "type": {
302
+ "name": "type",
303
+ "type": "text",
395
304
  "primaryKey": false,
396
305
  "notNull": true
397
306
  },
@@ -442,30 +351,28 @@
442
351
  },
443
352
  "indexes": {},
444
353
  "foreignKeys": {
445
- "preference_id_user_fkey": {
446
- "name": "preference_id_user_fkey",
354
+ "preference_type_type_key_fk": {
355
+ "name": "preference_type_type_key_fk",
447
356
  "tableFrom": "preference",
448
- "tableTo": "user",
449
- "schemaTo": "authentication",
357
+ "tableTo": "type",
358
+ "schemaTo": "notification",
450
359
  "columnsFrom": [
451
- "tenant_id",
452
- "user_id"
360
+ "type"
453
361
  ],
454
362
  "columnsTo": [
455
- "tenant_id",
456
- "id"
363
+ "key"
457
364
  ],
458
365
  "onDelete": "no action",
459
366
  "onUpdate": "no action"
460
367
  },
461
- "preference_id_category_fkey": {
462
- "name": "preference_id_category_fkey",
368
+ "preference_id_user_fkey": {
369
+ "name": "preference_id_user_fkey",
463
370
  "tableFrom": "preference",
464
- "tableTo": "category",
465
- "schemaTo": "notification",
371
+ "tableTo": "user",
372
+ "schemaTo": "authentication",
466
373
  "columnsFrom": [
467
374
  "tenant_id",
468
- "category_id"
375
+ "user_id"
469
376
  ],
470
377
  "columnsTo": [
471
378
  "tenant_id",
@@ -485,13 +392,13 @@
485
392
  }
486
393
  },
487
394
  "uniqueConstraints": {
488
- "preference_tenant_id_user_id_category_id_channel_unique": {
489
- "name": "preference_tenant_id_user_id_category_id_channel_unique",
395
+ "preference_tenant_id_user_id_type_channel_unique": {
396
+ "name": "preference_tenant_id_user_id_type_channel_unique",
490
397
  "nullsNotDistinct": false,
491
398
  "columns": [
492
399
  "tenant_id",
493
400
  "user_id",
494
- "category_id",
401
+ "type",
495
402
  "channel"
496
403
  ]
497
404
  }
@@ -500,6 +407,89 @@
500
407
  "checkConstraints": {},
501
408
  "isRLSEnabled": false
502
409
  },
410
+ "notification.type": {
411
+ "name": "type",
412
+ "schema": "notification",
413
+ "columns": {
414
+ "id": {
415
+ "name": "id",
416
+ "type": "uuid",
417
+ "primaryKey": true,
418
+ "notNull": true,
419
+ "default": "gen_random_uuid()"
420
+ },
421
+ "label": {
422
+ "name": "label",
423
+ "type": "text",
424
+ "primaryKey": false,
425
+ "notNull": true
426
+ },
427
+ "key": {
428
+ "name": "key",
429
+ "type": "text",
430
+ "primaryKey": false,
431
+ "notNull": true
432
+ },
433
+ "throttling": {
434
+ "name": "throttling",
435
+ "type": "jsonb",
436
+ "primaryKey": false,
437
+ "notNull": false
438
+ },
439
+ "escalations": {
440
+ "name": "escalations",
441
+ "type": "jsonb",
442
+ "primaryKey": false,
443
+ "notNull": false
444
+ },
445
+ "revision": {
446
+ "name": "revision",
447
+ "type": "integer",
448
+ "primaryKey": false,
449
+ "notNull": true
450
+ },
451
+ "revision_timestamp": {
452
+ "name": "revision_timestamp",
453
+ "type": "timestamp with time zone",
454
+ "primaryKey": false,
455
+ "notNull": true
456
+ },
457
+ "create_timestamp": {
458
+ "name": "create_timestamp",
459
+ "type": "timestamp with time zone",
460
+ "primaryKey": false,
461
+ "notNull": true
462
+ },
463
+ "delete_timestamp": {
464
+ "name": "delete_timestamp",
465
+ "type": "timestamp with time zone",
466
+ "primaryKey": false,
467
+ "notNull": false
468
+ },
469
+ "attributes": {
470
+ "name": "attributes",
471
+ "type": "jsonb",
472
+ "primaryKey": false,
473
+ "notNull": true,
474
+ "default": "'{}'::jsonb"
475
+ }
476
+ },
477
+ "indexes": {},
478
+ "foreignKeys": {},
479
+ "compositePrimaryKeys": {},
480
+ "uniqueConstraints": {
481
+ "type_key_unique": {
482
+ "name": "type_key_unique",
483
+ "nullsNotDistinct": false,
484
+ "columns": [
485
+ "key"
486
+ ]
487
+ }
488
+ },
489
+ "policies": {},
490
+ "checkConstraints": {},
491
+ "isRLSEnabled": false
492
+ },
503
493
  "notification.web_push_subscription": {
504
494
  "name": "web_push_subscription",
505
495
  "schema": "notification",
@@ -601,7 +591,17 @@
601
591
  ]
602
592
  }
603
593
  },
604
- "uniqueConstraints": {},
594
+ "uniqueConstraints": {
595
+ "web_push_subscription_tenant_id_user_id_endpoint_unique": {
596
+ "name": "web_push_subscription_tenant_id_user_id_endpoint_unique",
597
+ "nullsNotDistinct": false,
598
+ "columns": [
599
+ "tenant_id",
600
+ "user_id",
601
+ "endpoint"
602
+ ]
603
+ }
604
+ },
605
605
  "policies": {},
606
606
  "checkConstraints": {},
607
607
  "isRLSEnabled": false
@@ -5,8 +5,8 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "7",
8
- "when": 1769475703872,
9
- "tag": "0000_glorious_randall",
8
+ "when": 1769546272361,
9
+ "tag": "0000_shiny_the_anarchist",
10
10
  "breakpoints": true
11
11
  }
12
12
  ]
@@ -1,7 +1,9 @@
1
1
  import { Injector } from '../../injector/index.js';
2
2
  import { type DatabaseConfig } from '../../orm/server/index.js';
3
+ import type { NotificationChannel } from '../models/index.js';
3
4
  export declare class NotificationConfiguration {
4
5
  database?: DatabaseConfig;
6
+ defaultChannels?: NotificationChannel[];
5
7
  }
6
8
  export declare function configureNotification({ injector, ...config }: NotificationConfiguration & {
7
9
  injector?: Injector;
@@ -2,6 +2,7 @@ import { inject, Injector } from '../../injector/index.js';
2
2
  import { Database, migrate } from '../../orm/server/index.js';
3
3
  export class NotificationConfiguration {
4
4
  database;
5
+ defaultChannels;
5
6
  }
6
7
  export function configureNotification({ injector, ...config }) {
7
8
  const targetInjector = injector ?? Injector;
@@ -1,4 +1,5 @@
1
- import { NotificationLog } from '../../models/notification-log.model.js';
2
- export interface ChannelProvider {
3
- send(notification: NotificationLog): Promise<void>;
1
+ import type { Transaction } from '../../../orm/server/index.js';
2
+ import type { NotificationLog } from '../../models/notification-log.model.js';
3
+ export declare abstract class ChannelProvider {
4
+ abstract send(notification: NotificationLog, tx?: Transaction): Promise<void>;
4
5
  }
@@ -1 +1,2 @@
1
- import { NotificationLog } from '../../models/notification-log.model.js';
1
+ export class ChannelProvider {
2
+ }
@@ -1,6 +1,6 @@
1
- import { NotificationLog } from '../../models/index.js';
2
- import type { ChannelProvider } from './channel-provider.js';
3
- export declare class EmailChannelProvider implements ChannelProvider {
1
+ import type { NotificationLog } from '../../models/index.js';
2
+ import { ChannelProvider } from './channel-provider.js';
3
+ export declare class EmailChannelProvider extends ChannelProvider {
4
4
  #private;
5
5
  send(notification: NotificationLog): Promise<void>;
6
6
  }
@@ -4,19 +4,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { inject } from '../../../injector/index.js';
7
+ import { SubjectService } from '../../../authentication/server/subject.service.js';
8
+ import { inject, Singleton } from '../../../injector/index.js';
8
9
  import { MailService } from '../../../mail/mail.service.js';
9
- import { User } from '../../../authentication/models/user.model.js';
10
- import { injectRepository } from '../../../orm/server/index.js';
11
- import { NotificationLog } from '../../models/index.js';
12
- import { NotificationSingleton } from '../services/singleton.js';
13
10
  import { NotificationTemplateService } from '../services/notification-template.service.js';
14
- let EmailChannelProvider = class EmailChannelProvider {
11
+ import { ChannelProvider } from './channel-provider.js';
12
+ let EmailChannelProvider = class EmailChannelProvider extends ChannelProvider {
15
13
  #mailService = inject(MailService);
16
- #userRepository = injectRepository(User);
14
+ #subjectService = inject(SubjectService);
17
15
  #templateService = inject(NotificationTemplateService);
18
16
  async send(notification) {
19
- const user = await this.#userRepository.loadByQuery({ tenantId: notification.tenantId, id: notification.userId });
17
+ const user = await this.#subjectService.getUser(notification.tenantId, notification.userId);
20
18
  const content = await this.#templateService.render(notification, 'en'); // TODO: get user language
21
19
  await this.#mailService.send({
22
20
  to: user.email,
@@ -29,6 +27,6 @@ let EmailChannelProvider = class EmailChannelProvider {
29
27
  }
30
28
  };
31
29
  EmailChannelProvider = __decorate([
32
- NotificationSingleton()
30
+ Singleton()
33
31
  ], EmailChannelProvider);
34
32
  export { EmailChannelProvider };
@@ -1,7 +1,7 @@
1
- import { Transactional } from '../../../orm/server/index.js';
2
- import { NotificationLog } from '../../models/index.js';
3
- import type { ChannelProvider } from './channel-provider.js';
4
- export declare class InAppChannelProvider extends Transactional implements ChannelProvider {
1
+ import { type Transaction } from '../../../orm/server/index.js';
2
+ import { type NotificationLog } from '../../models/index.js';
3
+ import { ChannelProvider } from './channel-provider.js';
4
+ export declare class InAppChannelProvider extends ChannelProvider {
5
5
  #private;
6
- send(notification: NotificationLog): Promise<void>;
6
+ send(notification: NotificationLog, tx?: Transaction): Promise<void>;
7
7
  }
@@ -4,28 +4,27 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { inject } from '../../../injector/index.js';
8
- import { injectRepository, Transactional } from '../../../orm/server/index.js';
9
- import { InAppNotification, NotificationLog } from '../../models/index.js';
10
- import { NotificationSingleton } from '../services/singleton.js';
7
+ import { inject, Singleton } from '../../../injector/index.js';
8
+ import { injectRepository } from '../../../orm/server/index.js';
9
+ import { InAppNotification, toInAppNotificationView } from '../../models/index.js';
11
10
  import { NotificationSseService } from '../services/notification-sse.service.js';
12
- let InAppChannelProvider = class InAppChannelProvider extends Transactional {
11
+ import { ChannelProvider } from './channel-provider.js';
12
+ let InAppChannelProvider = class InAppChannelProvider extends ChannelProvider {
13
13
  #inAppRepository = injectRepository(InAppNotification);
14
14
  #sseService = inject(NotificationSseService);
15
- async send(notification) {
16
- const inApp = await this.transaction(async (tx) => {
17
- return await this.#inAppRepository.withTransaction(tx).insert({
18
- tenantId: notification.tenantId,
19
- userId: notification.userId,
20
- logId: notification.id,
21
- readAt: null,
22
- archivedAt: null,
23
- });
15
+ async send(notification, tx) {
16
+ const inApp = await this.#inAppRepository.withOptionalTransaction(tx).insert({
17
+ tenantId: notification.tenantId,
18
+ userId: notification.userId,
19
+ logId: notification.id,
20
+ readTimestamp: null,
21
+ archiveTimestamp: null,
24
22
  });
25
- await this.#sseService.send({ ...inApp, log: notification });
23
+ const inAppNotificationView = toInAppNotificationView(inApp, notification);
24
+ await this.#sseService.send(inAppNotificationView);
26
25
  }
27
26
  };
28
27
  InAppChannelProvider = __decorate([
29
- NotificationSingleton()
28
+ Singleton()
30
29
  ], InAppChannelProvider);
31
30
  export { InAppChannelProvider };
@@ -1,4 +1,4 @@
1
+ export * from './channel-provider.js';
1
2
  export * from './email-channel-provider.js';
2
3
  export * from './in-app-channel-provider.js';
3
4
  export * from './web-push-channel-provider.js';
4
- export * from './channel-provider.js';
@@ -1,4 +1,4 @@
1
+ export * from './channel-provider.js';
1
2
  export * from './email-channel-provider.js';
2
3
  export * from './in-app-channel-provider.js';
3
4
  export * from './web-push-channel-provider.js';
4
- export * from './channel-provider.js';
@@ -1,6 +1,7 @@
1
- import { NotificationLog } from '../../models/index.js';
2
- import type { ChannelProvider } from './channel-provider.js';
3
- export declare class WebPushChannelProvider implements ChannelProvider {
1
+ import { type Transaction } from '../../../orm/server/index.js';
2
+ import { type NotificationLog } from '../../models/index.js';
3
+ import { ChannelProvider } from './channel-provider.js';
4
+ export declare class WebPushChannelProvider extends ChannelProvider {
4
5
  #private;
5
- send(notification: NotificationLog): Promise<void>;
6
+ send(notification: NotificationLog, tx?: Transaction): Promise<void>;
6
7
  }