@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.
- package/authentication/client/authentication.service.d.ts +1 -1
- package/authentication/client/authentication.service.js +23 -11
- package/notification/api/index.d.ts +1 -0
- package/notification/api/index.js +1 -0
- package/notification/api/notification.api.d.ts +8 -16
- package/notification/api/notification.api.js +13 -26
- package/notification/index.d.ts +1 -1
- package/notification/index.js +1 -1
- package/notification/models/in-app-notification.model.d.ts +9 -4
- package/notification/models/in-app-notification.model.js +25 -10
- package/notification/models/index.d.ts +1 -1
- package/notification/models/index.js +1 -1
- package/notification/models/notification-log.model.d.ts +42 -5
- package/notification/models/notification-log.model.js +34 -20
- package/notification/models/notification-preference.model.d.ts +2 -2
- package/notification/models/notification-preference.model.js +9 -9
- package/notification/models/notification-type.model.d.ts +17 -0
- package/notification/models/{notification-category.model.js → notification-type.model.js} +12 -13
- package/notification/models/web-push-subscription.model.d.ts +2 -2
- package/notification/models/web-push-subscription.model.js +8 -7
- package/notification/server/api/notification.api-controller.d.ts +2 -2
- package/notification/server/api/notification.api-controller.js +4 -3
- package/notification/server/drizzle/{0000_glorious_randall.sql → 0000_shiny_the_anarchist.sql} +27 -32
- package/notification/server/drizzle/meta/0000_snapshot.json +179 -179
- package/notification/server/drizzle/meta/_journal.json +2 -2
- package/notification/server/module.d.ts +2 -0
- package/notification/server/module.js +1 -0
- package/notification/server/providers/channel-provider.d.ts +4 -3
- package/notification/server/providers/channel-provider.js +2 -1
- package/notification/server/providers/email-channel-provider.d.ts +3 -3
- package/notification/server/providers/email-channel-provider.js +7 -9
- package/notification/server/providers/in-app-channel-provider.d.ts +5 -5
- package/notification/server/providers/in-app-channel-provider.js +15 -16
- package/notification/server/providers/index.d.ts +1 -1
- package/notification/server/providers/index.js +1 -1
- package/notification/server/providers/web-push-channel-provider.d.ts +5 -4
- package/notification/server/providers/web-push-channel-provider.js +8 -7
- package/notification/server/schemas.d.ts +3 -3
- package/notification/server/schemas.js +3 -4
- package/notification/server/services/index.d.ts +2 -4
- package/notification/server/services/index.js +2 -4
- package/notification/server/services/notification-delivery.worker.d.ts +7 -1
- package/notification/server/services/notification-delivery.worker.js +49 -37
- package/notification/server/services/notification-sse.service.d.ts +4 -7
- package/notification/server/services/notification-sse.service.js +4 -11
- package/notification/server/services/notification-template.d.ts +2 -2
- package/notification/server/services/notification-template.js +3 -1
- package/notification/server/services/notification-template.service.d.ts +1 -1
- package/notification/server/services/notification-template.service.js +7 -3
- package/notification/server/services/notification-type.service.d.ts +11 -0
- package/notification/server/services/notification-type.service.js +41 -0
- package/notification/server/services/notification.service.d.ts +4 -5
- package/notification/server/services/notification.service.js +44 -27
- package/notification/tests/notification-api.test.js +95 -0
- package/notification/tests/notification-flow.test.js +174 -28
- package/notification/tests/notification-type.service.test.d.ts +1 -0
- package/notification/tests/notification-type.service.test.js +35 -0
- package/package.json +1 -1
- package/rate-limit/postgres/postgres-rate-limiter.d.ts +9 -4
- package/rate-limit/postgres/postgres-rate-limiter.js +17 -10
- package/rate-limit/rate-limiter.d.ts +6 -6
- package/rate-limit/tests/postgres-rate-limiter.test.js +1 -1
- package/task-queue/postgres/task-queue.js +1 -1
- package/task-queue/task-context.d.ts +1 -14
- package/task-queue/task-context.js +0 -30
- package/task-queue/task-queue.d.ts +4 -12
- package/task-queue/task-queue.js +38 -89
- package/task-queue/tests/extensive-dependencies.test.d.ts +1 -0
- package/task-queue/tests/extensive-dependencies.test.js +234 -0
- package/task-queue/tests/worker.test.js +0 -21
- package/task-queue/types.d.ts +1 -8
- package/notification/enums.d.ts +0 -22
- package/notification/enums.js +0 -19
- package/notification/models/notification-category.model.d.ts +0 -17
- package/notification/server/services/notification-category.service.d.ts +0 -11
- package/notification/server/services/notification-category.service.js +0 -41
- package/notification/server/services/notification-delivery.task.d.ts +0 -9
- package/notification/server/services/notification-delivery.task.js +0 -1
- package/notification/server/services/singleton.d.ts +0 -3
- package/notification/server/services/singleton.js +0 -10
- package/notification/tests/notification-category.service.test.js +0 -36
- package/notification/tests/test-notification.model.d.ts +0 -4
- package/notification/tests/test-notification.model.js +0 -25
- /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 +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,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 };
|
/package/notification/tests/{notification-category.service.test.d.ts → notification-api.test.d.ts}
RENAMED
|
File without changes
|