@tstdl/base 0.93.98 → 0.93.99
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/context/context.d.ts +1 -1
- package/context/context.js +4 -0
- package/document-management/api/document-management.api.d.ts +2 -2
- package/document-management/service-models/document.service-model.d.ts +1 -1
- package/notification/api/notification.api.d.ts +78 -0
- package/notification/api/notification.api.js +81 -0
- package/notification/enums.d.ts +22 -0
- package/notification/enums.js +19 -0
- package/notification/index.d.ts +2 -0
- package/notification/index.js +2 -0
- package/notification/models/in-app-notification.model.d.ts +9 -0
- package/notification/models/in-app-notification.model.js +42 -0
- package/notification/models/index.d.ts +6 -0
- package/notification/models/index.js +6 -0
- package/notification/models/notification-category.model.d.ts +17 -0
- package/notification/models/notification-category.model.js +41 -0
- package/notification/models/notification-log.model.d.ts +13 -0
- package/notification/models/notification-log.model.js +59 -0
- package/notification/models/notification-preference.model.d.ts +9 -0
- package/notification/models/notification-preference.model.js +45 -0
- package/notification/models/notification-table.d.ts +3 -0
- package/notification/models/notification-table.js +4 -0
- package/notification/models/web-push-subscription.model.d.ts +8 -0
- package/notification/models/web-push-subscription.model.js +41 -0
- package/notification/server/api/notification.api-controller.d.ts +16 -0
- package/notification/server/api/notification.api-controller.js +51 -0
- package/notification/server/drizzle/0000_glorious_randall.sql +90 -0
- package/notification/server/drizzle/meta/0000_snapshot.json +652 -0
- package/notification/server/drizzle/meta/_journal.json +13 -0
- package/notification/server/drizzle.config.d.ts +2 -0
- package/notification/server/drizzle.config.js +11 -0
- package/notification/server/index.d.ts +4 -0
- package/notification/server/index.js +4 -0
- package/notification/server/module.d.ts +12 -0
- package/notification/server/module.js +21 -0
- package/notification/server/providers/channel-provider.d.ts +4 -0
- package/notification/server/providers/channel-provider.js +1 -0
- package/notification/server/providers/email-channel-provider.d.ts +6 -0
- package/notification/server/providers/email-channel-provider.js +34 -0
- package/notification/server/providers/in-app-channel-provider.d.ts +7 -0
- package/notification/server/providers/in-app-channel-provider.js +31 -0
- package/notification/server/providers/index.d.ts +4 -0
- package/notification/server/providers/index.js +4 -0
- package/notification/server/providers/web-push-channel-provider.d.ts +6 -0
- package/notification/server/providers/web-push-channel-provider.js +26 -0
- package/notification/server/schemas.d.ts +25 -0
- package/notification/server/schemas.js +12 -0
- package/notification/server/services/index.d.ts +8 -0
- package/notification/server/services/index.js +8 -0
- package/notification/server/services/notification-category.service.d.ts +11 -0
- package/notification/server/services/notification-category.service.js +41 -0
- package/notification/server/services/notification-delivery.task.d.ts +9 -0
- package/notification/server/services/notification-delivery.task.js +1 -0
- package/notification/server/services/notification-delivery.worker.d.ts +12 -0
- package/notification/server/services/notification-delivery.worker.js +108 -0
- package/notification/server/services/notification-sse.service.d.ts +13 -0
- package/notification/server/services/notification-sse.service.js +74 -0
- package/notification/server/services/notification-template.d.ts +12 -0
- package/notification/server/services/notification-template.js +1 -0
- package/notification/server/services/notification-template.service.d.ts +7 -0
- package/notification/server/services/notification-template.service.js +29 -0
- package/notification/server/services/notification.service.d.ts +17 -0
- package/notification/server/services/notification.service.js +80 -0
- package/notification/server/services/singleton.d.ts +3 -0
- package/notification/server/services/singleton.js +10 -0
- package/notification/tests/notification-category.service.test.d.ts +1 -0
- package/notification/tests/notification-category.service.test.js +36 -0
- package/notification/tests/notification-flow.test.d.ts +1 -0
- package/notification/tests/notification-flow.test.js +112 -0
- package/notification/tests/notification-sse.service.test.d.ts +1 -0
- package/notification/tests/notification-sse.service.test.js +20 -0
- package/notification/tests/test-notification.model.d.ts +4 -0
- package/notification/tests/test-notification.model.js +25 -0
- package/orm/server/transactional.d.ts +3 -2
- package/orm/server/transactional.js +3 -2
- package/package.json +4 -2
- package/task-queue/task-queue.d.ts +7 -2
- package/task-queue/task-queue.js +4 -1
- package/unit-test/integration-setup.d.ts +7 -6
- package/unit-test/integration-setup.js +7 -2
|
@@ -0,0 +1,51 @@
|
|
|
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 { apiController } from '../../../api/server/index.js';
|
|
8
|
+
import { inject } from '../../../injector/index.js';
|
|
9
|
+
import { notificationApiDefinition } from '../../api/notification.api.js';
|
|
10
|
+
import { NotificationService } from '../services/notification.service.js';
|
|
11
|
+
import { NotificationSseService } from '../services/notification-sse.service.js';
|
|
12
|
+
let NotificationApiController = class NotificationApiController {
|
|
13
|
+
notificationService = inject(NotificationService);
|
|
14
|
+
sseService = inject(NotificationSseService);
|
|
15
|
+
async stream({ getToken }) {
|
|
16
|
+
const token = await getToken();
|
|
17
|
+
return this.sseService.register(token.payload.tenant, token.payload.subject);
|
|
18
|
+
}
|
|
19
|
+
async listInApp({ parameters, getToken }) {
|
|
20
|
+
const token = await getToken();
|
|
21
|
+
return await this.notificationService.listInApp(token.payload.tenant, token.payload.subject, parameters);
|
|
22
|
+
}
|
|
23
|
+
async markRead({ parameters, getToken }) {
|
|
24
|
+
const token = await getToken();
|
|
25
|
+
await this.notificationService.markRead(token.payload.tenant, token.payload.subject, parameters.id);
|
|
26
|
+
return 'ok';
|
|
27
|
+
}
|
|
28
|
+
async archive({ parameters, getToken }) {
|
|
29
|
+
const token = await getToken();
|
|
30
|
+
await this.notificationService.archive(token.payload.tenant, token.payload.subject, parameters.id);
|
|
31
|
+
return 'ok';
|
|
32
|
+
}
|
|
33
|
+
async getPreferences({ getToken }) {
|
|
34
|
+
const token = await getToken();
|
|
35
|
+
return await this.notificationService.getPreferences(token.payload.tenant, token.payload.subject);
|
|
36
|
+
}
|
|
37
|
+
async updatePreference({ parameters, getToken }) {
|
|
38
|
+
const token = await getToken();
|
|
39
|
+
await this.notificationService.updatePreference(token.payload.tenant, token.payload.subject, parameters.categoryId, parameters.channel, parameters.enabled);
|
|
40
|
+
return 'ok';
|
|
41
|
+
}
|
|
42
|
+
async registerWebPush({ parameters, getToken }) {
|
|
43
|
+
const token = await getToken();
|
|
44
|
+
await this.notificationService.registerWebPush(token.payload.tenant, token.payload.subject, parameters.endpoint, parameters.keys.p256dh, parameters.keys.auth);
|
|
45
|
+
return 'ok';
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
NotificationApiController = __decorate([
|
|
49
|
+
apiController(notificationApiDefinition)
|
|
50
|
+
], NotificationApiController);
|
|
51
|
+
export { NotificationApiController };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
CREATE TYPE "notification"."notification_channel" AS ENUM('in-app', 'email', 'web-push');--> statement-breakpoint
|
|
2
|
+
CREATE TYPE "notification"."notification_priority" AS ENUM('low', 'medium', 'high', 'urgent');--> statement-breakpoint
|
|
3
|
+
CREATE TYPE "notification"."notification_status" AS ENUM('pending', 'sent', 'delivered', 'read', 'failed');--> statement-breakpoint
|
|
4
|
+
CREATE TABLE "notification"."in_app" (
|
|
5
|
+
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
6
|
+
"tenant_id" uuid NOT NULL,
|
|
7
|
+
"user_id" uuid NOT NULL,
|
|
8
|
+
"log_id" uuid NOT NULL,
|
|
9
|
+
"read_at" timestamp with time zone,
|
|
10
|
+
"archived_at" timestamp with time zone,
|
|
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,
|
|
16
|
+
CONSTRAINT "in_app_tenant_id_id_pk" PRIMARY KEY("tenant_id","id")
|
|
17
|
+
);
|
|
18
|
+
--> 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
|
+
CREATE TABLE "notification"."log" (
|
|
36
|
+
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
37
|
+
"tenant_id" uuid NOT NULL,
|
|
38
|
+
"user_id" uuid NOT NULL,
|
|
39
|
+
"category_id" uuid NOT NULL,
|
|
40
|
+
"type" text NOT NULL,
|
|
41
|
+
"priority" "notification"."notification_priority" NOT NULL,
|
|
42
|
+
"status" "notification"."notification_status" NOT NULL,
|
|
43
|
+
"current_step" integer NOT NULL,
|
|
44
|
+
"payload" jsonb,
|
|
45
|
+
"revision" integer NOT NULL,
|
|
46
|
+
"revision_timestamp" timestamp with time zone NOT NULL,
|
|
47
|
+
"create_timestamp" timestamp with time zone NOT NULL,
|
|
48
|
+
"delete_timestamp" timestamp with time zone,
|
|
49
|
+
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
50
|
+
CONSTRAINT "log_tenant_id_id_pk" PRIMARY KEY("tenant_id","id")
|
|
51
|
+
);
|
|
52
|
+
--> statement-breakpoint
|
|
53
|
+
CREATE TABLE "notification"."preference" (
|
|
54
|
+
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
55
|
+
"tenant_id" uuid NOT NULL,
|
|
56
|
+
"user_id" uuid NOT NULL,
|
|
57
|
+
"category_id" uuid NOT NULL,
|
|
58
|
+
"channel" "notification"."notification_channel" NOT NULL,
|
|
59
|
+
"enabled" boolean NOT NULL,
|
|
60
|
+
"revision" integer NOT NULL,
|
|
61
|
+
"revision_timestamp" timestamp with time zone NOT NULL,
|
|
62
|
+
"create_timestamp" timestamp with time zone NOT NULL,
|
|
63
|
+
"delete_timestamp" timestamp with time zone,
|
|
64
|
+
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
65
|
+
CONSTRAINT "preference_tenant_id_id_pk" PRIMARY KEY("tenant_id","id"),
|
|
66
|
+
CONSTRAINT "preference_tenant_id_user_id_category_id_channel_unique" UNIQUE("tenant_id","user_id","category_id","channel")
|
|
67
|
+
);
|
|
68
|
+
--> statement-breakpoint
|
|
69
|
+
CREATE TABLE "notification"."web_push_subscription" (
|
|
70
|
+
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
71
|
+
"tenant_id" uuid NOT NULL,
|
|
72
|
+
"user_id" uuid NOT NULL,
|
|
73
|
+
"endpoint" text NOT NULL,
|
|
74
|
+
"p256dh" text NOT NULL,
|
|
75
|
+
"auth" text NOT NULL,
|
|
76
|
+
"revision" integer NOT NULL,
|
|
77
|
+
"revision_timestamp" timestamp with time zone NOT NULL,
|
|
78
|
+
"create_timestamp" timestamp with time zone NOT NULL,
|
|
79
|
+
"delete_timestamp" timestamp with time zone,
|
|
80
|
+
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
81
|
+
CONSTRAINT "web_push_subscription_tenant_id_id_pk" PRIMARY KEY("tenant_id","id")
|
|
82
|
+
);
|
|
83
|
+
--> statement-breakpoint
|
|
84
|
+
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 "in_app_id_log_fkey" FOREIGN KEY ("tenant_id","log_id") REFERENCES "notification"."log"("tenant_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
86
|
+
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"."log" ADD CONSTRAINT "log_id_category_fkey" FOREIGN KEY ("tenant_id","category_id") REFERENCES "notification"."category"("tenant_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
88
|
+
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"."preference" ADD CONSTRAINT "preference_id_category_fkey" FOREIGN KEY ("tenant_id","category_id") REFERENCES "notification"."category"("tenant_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
90
|
+
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;
|