@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.
- package/authentication/client/authentication.service.d.ts +1 -1
- package/authentication/client/authentication.service.js +23 -11
- package/file/mime-type.d.ts +2 -2
- package/file/mime-type.js +2 -3
- package/file/server/index.d.ts +1 -0
- package/file/server/index.js +1 -0
- package/file/server/mime-type.d.ts +2 -0
- package/file/server/mime-type.js +5 -0
- 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 +2 -2
- 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-queue.d.ts +3 -3
- package/task-queue/tests/extensive-dependencies.test.d.ts +1 -0
- package/task-queue/tests/extensive-dependencies.test.js +234 -0
- 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
|
@@ -7,12 +7,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { Entity, JsonProperty, Unique } from '../../orm/index.js';
|
|
11
11
|
import { StringProperty } from '../../schema/index.js';
|
|
12
|
-
import { NotificationChannel } from '../enums.js';
|
|
13
12
|
import { NotificationTable } from './notification-table.js';
|
|
14
|
-
let
|
|
15
|
-
static entityName = '
|
|
13
|
+
let NotificationType = class NotificationType extends Entity {
|
|
14
|
+
static entityName = 'NotificationType';
|
|
16
15
|
label;
|
|
17
16
|
key;
|
|
18
17
|
throttling;
|
|
@@ -21,21 +20,21 @@ let NotificationCategory = class NotificationCategory extends TenantEntity {
|
|
|
21
20
|
__decorate([
|
|
22
21
|
StringProperty(),
|
|
23
22
|
__metadata("design:type", String)
|
|
24
|
-
],
|
|
23
|
+
], NotificationType.prototype, "label", void 0);
|
|
25
24
|
__decorate([
|
|
26
25
|
StringProperty(),
|
|
27
26
|
__metadata("design:type", String)
|
|
28
|
-
],
|
|
27
|
+
], NotificationType.prototype, "key", void 0);
|
|
29
28
|
__decorate([
|
|
30
29
|
JsonProperty({ nullable: true }),
|
|
31
30
|
__metadata("design:type", Object)
|
|
32
|
-
],
|
|
31
|
+
], NotificationType.prototype, "throttling", void 0);
|
|
33
32
|
__decorate([
|
|
34
33
|
JsonProperty({ nullable: true }),
|
|
35
34
|
__metadata("design:type", Object)
|
|
36
|
-
],
|
|
37
|
-
|
|
38
|
-
NotificationTable({ name: '
|
|
39
|
-
Unique(['
|
|
40
|
-
],
|
|
41
|
-
export {
|
|
35
|
+
], NotificationType.prototype, "escalations", void 0);
|
|
36
|
+
NotificationType = __decorate([
|
|
37
|
+
NotificationTable({ name: 'type' }),
|
|
38
|
+
Unique(['key'])
|
|
39
|
+
], NotificationType);
|
|
40
|
+
export { NotificationType };
|
|
@@ -8,8 +8,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { User } from '../../authentication/models/user.model.js';
|
|
11
|
-
import { TenantEntity, TenantReference, UuidProperty } from '../../orm/index.js';
|
|
12
|
-
import { StringProperty } from '../../schema/index.js';
|
|
11
|
+
import { TenantEntity, TenantReference, Unique, UuidProperty } from '../../orm/index.js';
|
|
12
|
+
import { StringProperty, Uint8ArrayProperty } from '../../schema/index.js';
|
|
13
13
|
import { NotificationTable } from './notification-table.js';
|
|
14
14
|
let WebPushSubscription = class WebPushSubscription extends TenantEntity {
|
|
15
15
|
static entityName = 'WebPushSubscription';
|
|
@@ -28,14 +28,15 @@ __decorate([
|
|
|
28
28
|
__metadata("design:type", String)
|
|
29
29
|
], WebPushSubscription.prototype, "endpoint", void 0);
|
|
30
30
|
__decorate([
|
|
31
|
-
|
|
32
|
-
__metadata("design:type",
|
|
31
|
+
Uint8ArrayProperty(),
|
|
32
|
+
__metadata("design:type", Uint8Array)
|
|
33
33
|
], WebPushSubscription.prototype, "p256dh", void 0);
|
|
34
34
|
__decorate([
|
|
35
|
-
|
|
36
|
-
__metadata("design:type",
|
|
35
|
+
Uint8ArrayProperty(),
|
|
36
|
+
__metadata("design:type", Uint8Array)
|
|
37
37
|
], WebPushSubscription.prototype, "auth", void 0);
|
|
38
38
|
WebPushSubscription = __decorate([
|
|
39
|
-
NotificationTable(
|
|
39
|
+
NotificationTable(),
|
|
40
|
+
Unique(['tenantId', 'userId', 'endpoint'])
|
|
40
41
|
], WebPushSubscription);
|
|
41
42
|
export { WebPushSubscription };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ApiController, ApiRequestContext } from '../../../api/types.js';
|
|
2
|
+
import type { ServerSentEventsSource } from '../../../sse/server-sent-events-source.js';
|
|
2
3
|
import type { NotificationApiDefinition } from '../../api/notification.api.js';
|
|
3
|
-
import { NotificationService } from '../services/notification.service.js';
|
|
4
4
|
import { NotificationSseService } from '../services/notification-sse.service.js';
|
|
5
|
-
import
|
|
5
|
+
import { NotificationService } from '../services/notification.service.js';
|
|
6
6
|
export declare class NotificationApiController implements ApiController<NotificationApiDefinition> {
|
|
7
7
|
protected readonly notificationService: NotificationService;
|
|
8
8
|
protected readonly sseService: NotificationSseService;
|
|
@@ -6,9 +6,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { apiController } from '../../../api/server/index.js';
|
|
8
8
|
import { inject } from '../../../injector/index.js';
|
|
9
|
+
import { decodeBase64 } from '../../../utils/base64.js';
|
|
9
10
|
import { notificationApiDefinition } from '../../api/notification.api.js';
|
|
10
|
-
import { NotificationService } from '../services/notification.service.js';
|
|
11
11
|
import { NotificationSseService } from '../services/notification-sse.service.js';
|
|
12
|
+
import { NotificationService } from '../services/notification.service.js';
|
|
12
13
|
let NotificationApiController = class NotificationApiController {
|
|
13
14
|
notificationService = inject(NotificationService);
|
|
14
15
|
sseService = inject(NotificationSseService);
|
|
@@ -36,12 +37,12 @@ let NotificationApiController = class NotificationApiController {
|
|
|
36
37
|
}
|
|
37
38
|
async updatePreference({ parameters, getToken }) {
|
|
38
39
|
const token = await getToken();
|
|
39
|
-
await this.notificationService.updatePreference(token.payload.tenant, token.payload.subject, parameters.
|
|
40
|
+
await this.notificationService.updatePreference(token.payload.tenant, token.payload.subject, parameters.type, parameters.channel, parameters.enabled);
|
|
40
41
|
return 'ok';
|
|
41
42
|
}
|
|
42
43
|
async registerWebPush({ parameters, getToken }) {
|
|
43
44
|
const token = await getToken();
|
|
44
|
-
await this.notificationService.registerWebPush(token.payload.tenant, token.payload.subject, parameters.endpoint, parameters.keys.
|
|
45
|
+
await this.notificationService.registerWebPush(token.payload.tenant, token.payload.subject, parameters.endpoint, decodeBase64(parameters.keys.p256dhBase64), decodeBase64(parameters.keys.authBase64));
|
|
45
46
|
return 'ok';
|
|
46
47
|
}
|
|
47
48
|
};
|
package/notification/server/drizzle/{0000_glorious_randall.sql → 0000_shiny_the_anarchist.sql}
RENAMED
|
@@ -6,37 +6,15 @@ CREATE TABLE "notification"."in_app" (
|
|
|
6
6
|
"tenant_id" uuid NOT NULL,
|
|
7
7
|
"user_id" uuid NOT NULL,
|
|
8
8
|
"log_id" uuid NOT NULL,
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"revision" integer NOT NULL,
|
|
12
|
-
"revision_timestamp" timestamp with time zone NOT NULL,
|
|
13
|
-
"create_timestamp" timestamp with time zone NOT NULL,
|
|
14
|
-
"delete_timestamp" timestamp with time zone,
|
|
15
|
-
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
9
|
+
"read_timestamp" timestamp with time zone,
|
|
10
|
+
"archive_timestamp" timestamp with time zone,
|
|
16
11
|
CONSTRAINT "in_app_tenant_id_id_pk" PRIMARY KEY("tenant_id","id")
|
|
17
12
|
);
|
|
18
13
|
--> statement-breakpoint
|
|
19
|
-
CREATE TABLE "notification"."category" (
|
|
20
|
-
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
21
|
-
"tenant_id" uuid NOT NULL,
|
|
22
|
-
"label" text NOT NULL,
|
|
23
|
-
"key" text NOT NULL,
|
|
24
|
-
"throttling" jsonb,
|
|
25
|
-
"escalations" jsonb,
|
|
26
|
-
"revision" integer NOT NULL,
|
|
27
|
-
"revision_timestamp" timestamp with time zone NOT NULL,
|
|
28
|
-
"create_timestamp" timestamp with time zone NOT NULL,
|
|
29
|
-
"delete_timestamp" timestamp with time zone,
|
|
30
|
-
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
31
|
-
CONSTRAINT "category_tenant_id_id_pk" PRIMARY KEY("tenant_id","id"),
|
|
32
|
-
CONSTRAINT "category_tenant_id_key_unique" UNIQUE("tenant_id","key")
|
|
33
|
-
);
|
|
34
|
-
--> statement-breakpoint
|
|
35
14
|
CREATE TABLE "notification"."log" (
|
|
36
15
|
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
37
16
|
"tenant_id" uuid NOT NULL,
|
|
38
17
|
"user_id" uuid NOT NULL,
|
|
39
|
-
"category_id" uuid NOT NULL,
|
|
40
18
|
"type" text NOT NULL,
|
|
41
19
|
"priority" "notification"."notification_priority" NOT NULL,
|
|
42
20
|
"status" "notification"."notification_status" NOT NULL,
|
|
@@ -47,14 +25,15 @@ CREATE TABLE "notification"."log" (
|
|
|
47
25
|
"create_timestamp" timestamp with time zone NOT NULL,
|
|
48
26
|
"delete_timestamp" timestamp with time zone,
|
|
49
27
|
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
50
|
-
CONSTRAINT "log_tenant_id_id_pk" PRIMARY KEY("tenant_id","id")
|
|
28
|
+
CONSTRAINT "log_tenant_id_id_pk" PRIMARY KEY("tenant_id","id"),
|
|
29
|
+
CONSTRAINT "log_tenant_id_id_user_id_unique" UNIQUE("tenant_id","id","user_id")
|
|
51
30
|
);
|
|
52
31
|
--> statement-breakpoint
|
|
53
32
|
CREATE TABLE "notification"."preference" (
|
|
54
33
|
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
55
34
|
"tenant_id" uuid NOT NULL,
|
|
56
35
|
"user_id" uuid NOT NULL,
|
|
57
|
-
"
|
|
36
|
+
"type" text NOT NULL,
|
|
58
37
|
"channel" "notification"."notification_channel" NOT NULL,
|
|
59
38
|
"enabled" boolean NOT NULL,
|
|
60
39
|
"revision" integer NOT NULL,
|
|
@@ -63,7 +42,21 @@ CREATE TABLE "notification"."preference" (
|
|
|
63
42
|
"delete_timestamp" timestamp with time zone,
|
|
64
43
|
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
65
44
|
CONSTRAINT "preference_tenant_id_id_pk" PRIMARY KEY("tenant_id","id"),
|
|
66
|
-
CONSTRAINT "
|
|
45
|
+
CONSTRAINT "preference_tenant_id_user_id_type_channel_unique" UNIQUE("tenant_id","user_id","type","channel")
|
|
46
|
+
);
|
|
47
|
+
--> statement-breakpoint
|
|
48
|
+
CREATE TABLE "notification"."type" (
|
|
49
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
50
|
+
"label" text NOT NULL,
|
|
51
|
+
"key" text NOT NULL,
|
|
52
|
+
"throttling" jsonb,
|
|
53
|
+
"escalations" jsonb,
|
|
54
|
+
"revision" integer NOT NULL,
|
|
55
|
+
"revision_timestamp" timestamp with time zone NOT NULL,
|
|
56
|
+
"create_timestamp" timestamp with time zone NOT NULL,
|
|
57
|
+
"delete_timestamp" timestamp with time zone,
|
|
58
|
+
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
59
|
+
CONSTRAINT "type_key_unique" UNIQUE("key")
|
|
67
60
|
);
|
|
68
61
|
--> statement-breakpoint
|
|
69
62
|
CREATE TABLE "notification"."web_push_subscription" (
|
|
@@ -78,13 +71,15 @@ CREATE TABLE "notification"."web_push_subscription" (
|
|
|
78
71
|
"create_timestamp" timestamp with time zone NOT NULL,
|
|
79
72
|
"delete_timestamp" timestamp with time zone,
|
|
80
73
|
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
81
|
-
CONSTRAINT "web_push_subscription_tenant_id_id_pk" PRIMARY KEY("tenant_id","id")
|
|
74
|
+
CONSTRAINT "web_push_subscription_tenant_id_id_pk" PRIMARY KEY("tenant_id","id"),
|
|
75
|
+
CONSTRAINT "web_push_subscription_tenant_id_user_id_endpoint_unique" UNIQUE("tenant_id","user_id","endpoint")
|
|
82
76
|
);
|
|
83
77
|
--> statement-breakpoint
|
|
84
78
|
ALTER TABLE "notification"."in_app" ADD CONSTRAINT "in_app_id_user_fkey" FOREIGN KEY ("tenant_id","user_id") REFERENCES "authentication"."user"("tenant_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
85
|
-
ALTER TABLE "notification"."in_app" ADD CONSTRAINT "
|
|
79
|
+
ALTER TABLE "notification"."in_app" ADD CONSTRAINT "in_app_tenantId_logId_userId_log_fkey" FOREIGN KEY ("tenant_id","log_id","user_id") REFERENCES "notification"."log"("tenant_id","id","user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
80
|
+
ALTER TABLE "notification"."log" ADD CONSTRAINT "log_type_type_key_fk" FOREIGN KEY ("type") REFERENCES "notification"."type"("key") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
86
81
|
ALTER TABLE "notification"."log" ADD CONSTRAINT "log_id_user_fkey" FOREIGN KEY ("tenant_id","user_id") REFERENCES "authentication"."user"("tenant_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
87
|
-
ALTER TABLE "notification"."
|
|
82
|
+
ALTER TABLE "notification"."preference" ADD CONSTRAINT "preference_type_type_key_fk" FOREIGN KEY ("type") REFERENCES "notification"."type"("key") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
88
83
|
ALTER TABLE "notification"."preference" ADD CONSTRAINT "preference_id_user_fkey" FOREIGN KEY ("tenant_id","user_id") REFERENCES "authentication"."user"("tenant_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
89
|
-
ALTER TABLE "notification"."
|
|
90
|
-
|
|
84
|
+
ALTER TABLE "notification"."web_push_subscription" ADD CONSTRAINT "web_push_subscription_id_user_fkey" FOREIGN KEY ("tenant_id","user_id") REFERENCES "authentication"."user"("tenant_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
85
|
+
CREATE INDEX "in_app_tenant_id_user_id_read_timestamp_archive_timestamp_idx" ON "notification"."in_app" USING btree ("tenant_id","user_id","read_timestamp","archive_timestamp");
|