@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
@@ -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 { JsonProperty, TenantEntity, Unique } from '../../orm/index.js';
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 NotificationCategory = class NotificationCategory extends TenantEntity {
15
- static entityName = 'NotificationCategory';
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
- ], NotificationCategory.prototype, "label", void 0);
23
+ ], NotificationType.prototype, "label", void 0);
25
24
  __decorate([
26
25
  StringProperty(),
27
26
  __metadata("design:type", String)
28
- ], NotificationCategory.prototype, "key", void 0);
27
+ ], NotificationType.prototype, "key", void 0);
29
28
  __decorate([
30
29
  JsonProperty({ nullable: true }),
31
30
  __metadata("design:type", Object)
32
- ], NotificationCategory.prototype, "throttling", void 0);
31
+ ], NotificationType.prototype, "throttling", void 0);
33
32
  __decorate([
34
33
  JsonProperty({ nullable: true }),
35
34
  __metadata("design:type", Object)
36
- ], NotificationCategory.prototype, "escalations", void 0);
37
- NotificationCategory = __decorate([
38
- NotificationTable({ name: 'category' }),
39
- Unique(['tenantId', 'key'])
40
- ], NotificationCategory);
41
- export { NotificationCategory };
35
+ ], NotificationType.prototype, "escalations", void 0);
36
+ NotificationType = __decorate([
37
+ NotificationTable({ name: 'type' }),
38
+ Unique(['key'])
39
+ ], NotificationType);
40
+ export { NotificationType };
@@ -3,6 +3,6 @@ export declare class WebPushSubscription extends TenantEntity {
3
3
  static readonly entityName = "WebPushSubscription";
4
4
  userId: Uuid;
5
5
  endpoint: string;
6
- p256dh: string;
7
- auth: string;
6
+ p256dh: Uint8Array<ArrayBuffer>;
7
+ auth: Uint8Array<ArrayBuffer>;
8
8
  }
@@ -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
- StringProperty(),
32
- __metadata("design:type", String)
31
+ Uint8ArrayProperty(),
32
+ __metadata("design:type", Uint8Array)
33
33
  ], WebPushSubscription.prototype, "p256dh", void 0);
34
34
  __decorate([
35
- StringProperty(),
36
- __metadata("design:type", String)
35
+ Uint8ArrayProperty(),
36
+ __metadata("design:type", Uint8Array)
37
37
  ], WebPushSubscription.prototype, "auth", void 0);
38
38
  WebPushSubscription = __decorate([
39
- NotificationTable({ name: 'web_push_subscription' })
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 type { ServerSentEventsSource } from '../../../sse/server-sent-events-source.js';
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.categoryId, parameters.channel, parameters.enabled);
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.p256dh, parameters.keys.auth);
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
  };
@@ -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
- "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,
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
- "category_id" uuid NOT NULL,
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 "preference_tenant_id_user_id_category_id_channel_unique" UNIQUE("tenant_id","user_id","category_id","channel")
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 "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
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"."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
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"."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;
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");