@tstdl/base 0.93.100 → 0.93.102

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 (84) hide show
  1. package/authentication/client/authentication.service.d.ts +1 -1
  2. package/authentication/client/authentication.service.js +23 -11
  3. package/notification/api/index.d.ts +1 -0
  4. package/notification/api/index.js +1 -0
  5. package/notification/api/notification.api.d.ts +8 -16
  6. package/notification/api/notification.api.js +13 -26
  7. package/notification/index.d.ts +1 -1
  8. package/notification/index.js +1 -1
  9. package/notification/models/in-app-notification.model.d.ts +9 -4
  10. package/notification/models/in-app-notification.model.js +25 -10
  11. package/notification/models/index.d.ts +1 -1
  12. package/notification/models/index.js +1 -1
  13. package/notification/models/notification-log.model.d.ts +42 -5
  14. package/notification/models/notification-log.model.js +34 -20
  15. package/notification/models/notification-preference.model.d.ts +2 -2
  16. package/notification/models/notification-preference.model.js +9 -9
  17. package/notification/models/notification-type.model.d.ts +17 -0
  18. package/notification/models/{notification-category.model.js → notification-type.model.js} +12 -13
  19. package/notification/models/web-push-subscription.model.d.ts +2 -2
  20. package/notification/models/web-push-subscription.model.js +8 -7
  21. package/notification/server/api/notification.api-controller.d.ts +2 -2
  22. package/notification/server/api/notification.api-controller.js +4 -3
  23. package/notification/server/drizzle/{0000_glorious_randall.sql → 0000_shiny_the_anarchist.sql} +27 -32
  24. package/notification/server/drizzle/meta/0000_snapshot.json +179 -179
  25. package/notification/server/drizzle/meta/_journal.json +2 -2
  26. package/notification/server/module.d.ts +2 -0
  27. package/notification/server/module.js +1 -0
  28. package/notification/server/providers/channel-provider.d.ts +4 -3
  29. package/notification/server/providers/channel-provider.js +2 -1
  30. package/notification/server/providers/email-channel-provider.d.ts +3 -3
  31. package/notification/server/providers/email-channel-provider.js +7 -9
  32. package/notification/server/providers/in-app-channel-provider.d.ts +5 -5
  33. package/notification/server/providers/in-app-channel-provider.js +15 -16
  34. package/notification/server/providers/index.d.ts +1 -1
  35. package/notification/server/providers/index.js +1 -1
  36. package/notification/server/providers/web-push-channel-provider.d.ts +5 -4
  37. package/notification/server/providers/web-push-channel-provider.js +8 -7
  38. package/notification/server/schemas.d.ts +3 -3
  39. package/notification/server/schemas.js +3 -4
  40. package/notification/server/services/index.d.ts +2 -4
  41. package/notification/server/services/index.js +2 -4
  42. package/notification/server/services/notification-delivery.worker.d.ts +7 -1
  43. package/notification/server/services/notification-delivery.worker.js +49 -37
  44. package/notification/server/services/notification-sse.service.d.ts +4 -7
  45. package/notification/server/services/notification-sse.service.js +4 -11
  46. package/notification/server/services/notification-template.d.ts +2 -2
  47. package/notification/server/services/notification-template.js +3 -1
  48. package/notification/server/services/notification-template.service.d.ts +1 -1
  49. package/notification/server/services/notification-template.service.js +7 -3
  50. package/notification/server/services/notification-type.service.d.ts +11 -0
  51. package/notification/server/services/notification-type.service.js +41 -0
  52. package/notification/server/services/notification.service.d.ts +4 -5
  53. package/notification/server/services/notification.service.js +44 -27
  54. package/notification/tests/notification-api.test.js +95 -0
  55. package/notification/tests/notification-flow.test.js +174 -28
  56. package/notification/tests/notification-type.service.test.d.ts +1 -0
  57. package/notification/tests/notification-type.service.test.js +35 -0
  58. package/package.json +1 -1
  59. package/rate-limit/postgres/postgres-rate-limiter.d.ts +9 -4
  60. package/rate-limit/postgres/postgres-rate-limiter.js +17 -10
  61. package/rate-limit/rate-limiter.d.ts +6 -6
  62. package/rate-limit/tests/postgres-rate-limiter.test.js +1 -1
  63. package/task-queue/postgres/task-queue.js +1 -1
  64. package/task-queue/task-context.d.ts +1 -14
  65. package/task-queue/task-context.js +0 -30
  66. package/task-queue/task-queue.d.ts +4 -12
  67. package/task-queue/task-queue.js +38 -89
  68. package/task-queue/tests/extensive-dependencies.test.d.ts +1 -0
  69. package/task-queue/tests/extensive-dependencies.test.js +234 -0
  70. package/task-queue/tests/worker.test.js +0 -21
  71. package/task-queue/types.d.ts +1 -8
  72. package/notification/enums.d.ts +0 -22
  73. package/notification/enums.js +0 -19
  74. package/notification/models/notification-category.model.d.ts +0 -17
  75. package/notification/server/services/notification-category.service.d.ts +0 -11
  76. package/notification/server/services/notification-category.service.js +0 -41
  77. package/notification/server/services/notification-delivery.task.d.ts +0 -9
  78. package/notification/server/services/notification-delivery.task.js +0 -1
  79. package/notification/server/services/singleton.d.ts +0 -3
  80. package/notification/server/services/singleton.js +0 -10
  81. package/notification/tests/notification-category.service.test.js +0 -36
  82. package/notification/tests/test-notification.model.d.ts +0 -4
  83. package/notification/tests/test-notification.model.js +0 -25
  84. /package/notification/tests/{notification-category.service.test.d.ts → notification-api.test.d.ts} +0 -0
@@ -1,41 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { injectRepository, Transactional } from '../../../orm/server/index.js';
8
- import { fromEntries, objectEntries } from '../../../utils/object/index.js';
9
- import { assertDefinedPass, isUndefined } from '../../../utils/type-guards.js';
10
- import { NotificationCategory } from '../../models/index.js';
11
- import { NotificationSingleton } from './singleton.js';
12
- let NotificationCategoryService = class NotificationCategoryService extends Transactional {
13
- repository = injectRepository(NotificationCategory);
14
- async initializeCategories(tenantId, categoryData) {
15
- const categoryEntries = objectEntries(categoryData);
16
- const categoryMap = await this.transaction(async (tx) => {
17
- const dbCategories = await this.repository.withTransaction(tx).loadManyByQuery({ tenantId });
18
- const enumKeyCategoryMap = new Map(dbCategories.map((category) => [category.key, category]));
19
- for (const [key, data] of categoryEntries) {
20
- const category = enumKeyCategoryMap.get(key);
21
- const throttling = data.throttling ?? null;
22
- const escalations = data.escalations ?? null;
23
- if (isUndefined(category)) {
24
- const newCategory = await this.repository.withTransaction(tx).insert({ tenantId, key, label: data.label, throttling, escalations });
25
- enumKeyCategoryMap.set(key, newCategory);
26
- }
27
- else if ((category.label != data.label) || (JSON.stringify(category.throttling) != JSON.stringify(throttling)) || (JSON.stringify(category.escalations) != JSON.stringify(escalations))) {
28
- const updatedCategory = await this.repository.withTransaction(tx).updateByQuery({ tenantId, id: category.id }, { label: data.label, throttling, escalations });
29
- enumKeyCategoryMap.set(key, updatedCategory);
30
- }
31
- }
32
- return enumKeyCategoryMap;
33
- });
34
- const mappedCategories = categoryEntries.map(([key]) => [key, assertDefinedPass(categoryMap.get(key), 'Could not map notification category.')]);
35
- return fromEntries(mappedCategories);
36
- }
37
- };
38
- NotificationCategoryService = __decorate([
39
- NotificationSingleton()
40
- ], NotificationCategoryService);
41
- export { NotificationCategoryService };
@@ -1,9 +0,0 @@
1
- export type NotificationTaskDefinitions = {
2
- 'notification/deliver': {
3
- data: {
4
- notificationId: string;
5
- };
6
- state: void;
7
- result: void;
8
- };
9
- };
@@ -1 +0,0 @@
1
- import { NotificationLog } from '../../models/index.js';
@@ -1,3 +0,0 @@
1
- export declare const notificationDatabaseConfigFactoryProvider: import("../../../injector/provider.js").FactoryProvider<unknown, unknown, import("../../../types/types.js").Record>;
2
- export declare const notificationDatabaseConfigProvider: import("../../../injector/injector.js").ProvidersItem<unknown, unknown, import("../../../types/types.js").Record>;
3
- export declare function NotificationSingleton(): ClassDecorator;
@@ -1,10 +0,0 @@
1
- import { Singleton } from '../../../injector/decorators.js';
2
- import { provide } from '../../../injector/injector.js';
3
- import { factoryProvider } from '../../../injector/provider.js';
4
- import { DatabaseConfig } from '../../../orm/server/index.js';
5
- import { NotificationConfiguration } from '../module.js';
6
- export const notificationDatabaseConfigFactoryProvider = factoryProvider((_, context) => context.resolve(NotificationConfiguration).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: 2 }));
7
- export const notificationDatabaseConfigProvider = provide(DatabaseConfig, notificationDatabaseConfigFactoryProvider);
8
- export function NotificationSingleton() {
9
- return Singleton({ providers: [notificationDatabaseConfigProvider] });
10
- }
@@ -1,36 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { runInInjectionContext } from '../../injector/index.js';
3
- import { setupIntegrationTest, truncateTables } from '../../unit-test/index.js';
4
- import { NotificationCategoryService } from '../server/services/notification-category.service.js';
5
- describe('NotificationCategoryService', () => {
6
- test('should initialize categories correctly', async () => {
7
- const { injector, database } = await setupIntegrationTest({ modules: { notification: true, authentication: true } });
8
- // Cleanup
9
- await truncateTables(database, 'notification', ['category']);
10
- const service = injector.resolve(NotificationCategoryService);
11
- const tenantId = '00000000-0000-0000-0000-000000000001';
12
- const categoryData = {
13
- CAT1: { label: 'Category 1' },
14
- CAT2: { label: 'Category 2', throttling: { limit: 1, intervalMs: 1000 } }
15
- };
16
- await runInInjectionContext(injector, async () => {
17
- const result = await service.initializeCategories(tenantId, categoryData);
18
- expect(result.CAT1.label).toBe('Category 1');
19
- expect(result.CAT2.key).toBe('CAT2');
20
- expect(result.CAT2.throttling?.limit).toBe(1);
21
- // Verify persistence
22
- const dbCategories = await service.repository.loadManyByQuery({ tenantId });
23
- expect(dbCategories).toHaveLength(2);
24
- // Update
25
- const updatedData = {
26
- CAT1: { label: 'Category 1 Updated' },
27
- CAT2: { label: 'Category 2', throttling: { limit: 1, intervalMs: 1000 } }
28
- };
29
- const resultUpdated = await service.initializeCategories(tenantId, updatedData);
30
- expect(resultUpdated.CAT1.label).toBe('Category 1 Updated');
31
- const dbCategoriesUpdated = await service.repository.loadManyByQuery({ tenantId });
32
- expect(dbCategoriesUpdated).toHaveLength(2);
33
- expect(dbCategoriesUpdated.find((c) => c.key == 'CAT1')?.label).toBe('Category 1 Updated');
34
- });
35
- });
36
- });
@@ -1,4 +0,0 @@
1
- import { NotificationLog } from '../models/notification-log.model.js';
2
- export declare class TestNotification extends NotificationLog {
3
- testField: string;
4
- }
@@ -1,25 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { ChildEntity } from '../../orm/index.js';
11
- import { StringProperty } from '../../schema/index.js';
12
- import { NotificationLog } from '../models/notification-log.model.js';
13
- import { NotificationTable } from '../models/notification-table.js';
14
- let TestNotification = class TestNotification extends NotificationLog {
15
- testField;
16
- };
17
- __decorate([
18
- StringProperty(),
19
- __metadata("design:type", String)
20
- ], TestNotification.prototype, "testField", void 0);
21
- TestNotification = __decorate([
22
- NotificationTable({ name: 'test_notification' }),
23
- ChildEntity('test')
24
- ], TestNotification);
25
- export { TestNotification };