@tstdl/base 0.93.97 → 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.
Files changed (126) hide show
  1. package/audit/auditor.d.ts +1 -1
  2. package/context/context.d.ts +1 -1
  3. package/context/context.js +4 -0
  4. package/cookie/cookie.js +5 -1
  5. package/css/css-variables.d.ts +38 -0
  6. package/css/css-variables.js +38 -0
  7. package/document-management/api/document-management.api.d.ts +17 -3
  8. package/document-management/api/document-management.api.js +8 -1
  9. package/document-management/models/document-category.model.js +0 -1
  10. package/document-management/models/document-property.model.js +0 -1
  11. package/document-management/server/api/document-management.api.d.ts +1 -0
  12. package/document-management/server/api/document-management.api.js +13 -1
  13. package/document-management/server/drizzle/{0000_needy_steel_serpent.sql → 0000_silly_chimera.sql} +0 -2
  14. package/document-management/server/drizzle/meta/0000_snapshot.json +1 -15
  15. package/document-management/server/drizzle/meta/_journal.json +2 -2
  16. package/document-management/server/services/document-statistics.service.d.ts +6 -0
  17. package/document-management/server/services/document-statistics.service.js +167 -0
  18. package/document-management/server/services/index.d.ts +1 -0
  19. package/document-management/server/services/index.js +1 -0
  20. package/document-management/service-models/document-statistics.view-model.d.ts +38 -0
  21. package/document-management/service-models/document-statistics.view-model.js +160 -0
  22. package/document-management/service-models/document.service-model.d.ts +1 -1
  23. package/document-management/service-models/index.d.ts +1 -0
  24. package/document-management/service-models/index.js +1 -0
  25. package/document-management/tests/document-management-core.test.js +2 -2
  26. package/document-management/tests/document-management.api.test.d.ts +1 -0
  27. package/document-management/tests/document-management.api.test.js +102 -0
  28. package/document-management/tests/document-statistics.service.test.d.ts +1 -0
  29. package/document-management/tests/document-statistics.service.test.js +495 -0
  30. package/document-management/tests/enum-helpers.test.js +3 -2
  31. package/enumeration/enumeration.d.ts +24 -0
  32. package/enumeration/enumeration.js +20 -0
  33. package/examples/document-management/main.js +1 -1
  34. package/intl/number-parser.d.ts +16 -9
  35. package/intl/number-parser.js +31 -19
  36. package/module/module.js +3 -0
  37. package/notification/api/notification.api.d.ts +78 -0
  38. package/notification/api/notification.api.js +81 -0
  39. package/notification/enums.d.ts +22 -0
  40. package/notification/enums.js +19 -0
  41. package/notification/index.d.ts +2 -0
  42. package/notification/index.js +2 -0
  43. package/notification/models/in-app-notification.model.d.ts +9 -0
  44. package/notification/models/in-app-notification.model.js +42 -0
  45. package/notification/models/index.d.ts +6 -0
  46. package/notification/models/index.js +6 -0
  47. package/notification/models/notification-category.model.d.ts +17 -0
  48. package/notification/models/notification-category.model.js +41 -0
  49. package/notification/models/notification-log.model.d.ts +13 -0
  50. package/notification/models/notification-log.model.js +59 -0
  51. package/notification/models/notification-preference.model.d.ts +9 -0
  52. package/notification/models/notification-preference.model.js +45 -0
  53. package/notification/models/notification-table.d.ts +3 -0
  54. package/notification/models/notification-table.js +4 -0
  55. package/notification/models/web-push-subscription.model.d.ts +8 -0
  56. package/notification/models/web-push-subscription.model.js +41 -0
  57. package/notification/server/api/notification.api-controller.d.ts +16 -0
  58. package/notification/server/api/notification.api-controller.js +51 -0
  59. package/notification/server/drizzle/0000_glorious_randall.sql +90 -0
  60. package/notification/server/drizzle/meta/0000_snapshot.json +652 -0
  61. package/notification/server/drizzle/meta/_journal.json +13 -0
  62. package/notification/server/drizzle.config.d.ts +2 -0
  63. package/notification/server/drizzle.config.js +11 -0
  64. package/notification/server/index.d.ts +4 -0
  65. package/notification/server/index.js +4 -0
  66. package/notification/server/module.d.ts +12 -0
  67. package/notification/server/module.js +21 -0
  68. package/notification/server/providers/channel-provider.d.ts +4 -0
  69. package/notification/server/providers/channel-provider.js +1 -0
  70. package/notification/server/providers/email-channel-provider.d.ts +6 -0
  71. package/notification/server/providers/email-channel-provider.js +34 -0
  72. package/notification/server/providers/in-app-channel-provider.d.ts +7 -0
  73. package/notification/server/providers/in-app-channel-provider.js +31 -0
  74. package/notification/server/providers/index.d.ts +4 -0
  75. package/notification/server/providers/index.js +4 -0
  76. package/notification/server/providers/web-push-channel-provider.d.ts +6 -0
  77. package/notification/server/providers/web-push-channel-provider.js +26 -0
  78. package/notification/server/schemas.d.ts +25 -0
  79. package/notification/server/schemas.js +12 -0
  80. package/notification/server/services/index.d.ts +8 -0
  81. package/notification/server/services/index.js +8 -0
  82. package/notification/server/services/notification-category.service.d.ts +11 -0
  83. package/notification/server/services/notification-category.service.js +41 -0
  84. package/notification/server/services/notification-delivery.task.d.ts +9 -0
  85. package/notification/server/services/notification-delivery.task.js +1 -0
  86. package/notification/server/services/notification-delivery.worker.d.ts +12 -0
  87. package/notification/server/services/notification-delivery.worker.js +108 -0
  88. package/notification/server/services/notification-sse.service.d.ts +13 -0
  89. package/notification/server/services/notification-sse.service.js +74 -0
  90. package/notification/server/services/notification-template.d.ts +12 -0
  91. package/notification/server/services/notification-template.js +1 -0
  92. package/notification/server/services/notification-template.service.d.ts +7 -0
  93. package/notification/server/services/notification-template.service.js +29 -0
  94. package/notification/server/services/notification.service.d.ts +17 -0
  95. package/notification/server/services/notification.service.js +80 -0
  96. package/notification/server/services/singleton.d.ts +3 -0
  97. package/notification/server/services/singleton.js +10 -0
  98. package/notification/tests/notification-category.service.test.d.ts +1 -0
  99. package/notification/tests/notification-category.service.test.js +36 -0
  100. package/notification/tests/notification-flow.test.d.ts +1 -0
  101. package/notification/tests/notification-flow.test.js +112 -0
  102. package/notification/tests/notification-sse.service.test.d.ts +1 -0
  103. package/notification/tests/notification-sse.service.test.js +20 -0
  104. package/notification/tests/test-notification.model.d.ts +4 -0
  105. package/notification/tests/test-notification.model.js +25 -0
  106. package/object-storage/google/google.object-storage-provider.d.ts +0 -1
  107. package/object-storage/google/google.object-storage-provider.js +0 -1
  108. package/object-storage/index.d.ts +0 -1
  109. package/object-storage/index.js +0 -1
  110. package/object-storage/s3/s3.object-storage-provider.d.ts +0 -1
  111. package/object-storage/s3/s3.object-storage-provider.js +0 -1
  112. package/orm/server/transactional.d.ts +3 -2
  113. package/orm/server/transactional.js +3 -2
  114. package/package.json +4 -2
  115. package/pool/pool.d.ts +1 -1
  116. package/promise/cancelable-promise.d.ts +1 -0
  117. package/promise/cancelable-promise.js +1 -0
  118. package/promise/index.d.ts +1 -0
  119. package/promise/index.js +1 -0
  120. package/random/number-generator/index.d.ts +1 -0
  121. package/random/number-generator/index.js +1 -0
  122. package/sse/data-stream.js +16 -3
  123. package/task-queue/task-queue.d.ts +7 -2
  124. package/task-queue/task-queue.js +4 -1
  125. package/unit-test/integration-setup.d.ts +7 -6
  126. package/unit-test/integration-setup.js +7 -2
@@ -1,12 +1,12 @@
1
1
  import { createArray } from '../utils/array/array.js';
2
2
  import { memoizeClassSingle } from '../utils/function/memoize.js';
3
3
  export class NumberParser {
4
- group;
5
- decimal;
6
- numeral;
7
- loosePattern;
8
- numeralIndex;
9
- numeralReplacer;
4
+ #group;
5
+ #decimal;
6
+ #numeral;
7
+ #loosePattern;
8
+ #numeralIndex;
9
+ #numeralReplacer;
10
10
  locale;
11
11
  constructor(locale) {
12
12
  this.locale = locale;
@@ -14,28 +14,40 @@ export class NumberParser {
14
14
  const parts = format.formatToParts(12345.6);
15
15
  const numerals = createArray(10, (i) => format.format(i));
16
16
  const numeralPattern = `[${numerals.join('')}]`;
17
- this.numeralIndex = new Map(numerals.map((d, i) => [d, i.toString()]));
18
- this.group = parts.find((part) => part.type == 'group').value;
19
- this.decimal = parts.find((part) => part.type == 'decimal').value;
20
- this.numeral = new RegExp(numeralPattern, 'ug');
21
- this.loosePattern = new RegExp(`[^${numerals.join()}${this.group}${this.decimal}]`, 'ug');
22
- this.numeralReplacer = (numeral) => this.numeralIndex.get(numeral);
17
+ this.#numeralIndex = new Map(numerals.map((d, i) => [d, i.toString()]));
18
+ this.#group = parts.find((part) => part.type == 'group').value;
19
+ this.#decimal = parts.find((part) => part.type == 'decimal').value;
20
+ this.#numeral = new RegExp(numeralPattern, 'ug');
21
+ this.#loosePattern = new RegExp(`[^${numerals.join()}${this.#group}${this.#decimal}]`, 'ug');
22
+ this.#numeralReplacer = (numeral) => this.#numeralIndex.get(numeral);
23
23
  }
24
24
  /**
25
- * Parse a string
26
- * @param value Value to parse
27
- * @param loose Try to parse an invalid string by removing unsupported characters. Might produce incorrect results, depending on input
25
+ * Parse a string.
26
+ * @param value Value to parse.
27
+ * @param loose Try to parse an invalid string by removing unsupported characters. Might produce incorrect results, depending on input.
28
28
  */
29
29
  parse(value, loose = false) {
30
- const source = loose ? value.replaceAll(this.loosePattern, '') : value;
30
+ const source = loose ? value.replaceAll(this.#loosePattern, '') : value;
31
31
  const normalized = source.trim()
32
- .replaceAll(this.group, '')
33
- .replaceAll(this.decimal, '.')
34
- .replaceAll(this.numeral, this.numeralReplacer);
32
+ .replaceAll(this.#group, '')
33
+ .replaceAll(this.#decimal, '.')
34
+ .replaceAll(this.#numeral, this.#numeralReplacer);
35
35
  return Number(normalized);
36
36
  }
37
37
  }
38
+ /**
39
+ * Get a memoized {@link NumberParser} instance for a given locale.
40
+ * @param locale The locale to get the parser for.
41
+ * @returns A {@link NumberParser} instance.
42
+ */
38
43
  export const getNumberParser = memoizeClassSingle(NumberParser);
44
+ /**
45
+ * Parses a localized number string into a standard JavaScript number.
46
+ * @param locale The locale of the number string.
47
+ * @param value The string to parse.
48
+ * @param loose Whether to use loose parsing (stripping non-numeric characters).
49
+ * @returns The parsed number, or `NaN` if parsing fails.
50
+ */
39
51
  export function parseNumber(locale, value, loose) {
40
52
  return getNumberParser(locale).parse(value, loose);
41
53
  }
package/module/module.js CHANGED
@@ -44,6 +44,9 @@ export class Module {
44
44
  }
45
45
  }
46
46
  async stop() {
47
+ if (this._state == ModuleState.Running) {
48
+ this._state = ModuleState.Stopping;
49
+ }
47
50
  this.cancellationToken.set();
48
51
  await this.runPromise.catch(() => { });
49
52
  }
@@ -0,0 +1,78 @@
1
+ import { ServerSentEvents } from '../../sse/server-sent-events.js';
2
+ export declare const notificationApiDefinition: {
3
+ resource: string;
4
+ endpoints: {
5
+ stream: {
6
+ resource: string;
7
+ method: "GET";
8
+ result: typeof ServerSentEvents;
9
+ };
10
+ listInApp: {
11
+ resource: string;
12
+ method: "GET";
13
+ parameters: import("../../schema/index.js").ObjectSchema<{
14
+ offset?: number | undefined;
15
+ limit?: number | undefined;
16
+ includeArchived?: boolean | undefined;
17
+ }>;
18
+ result: import("../../schema/index.js").ArraySchema<{
19
+ type: string;
20
+ id: string;
21
+ createdAt: number;
22
+ priority: string;
23
+ logId: string;
24
+ payload?: {} | undefined;
25
+ readAt?: number | undefined;
26
+ archivedAt?: number | undefined;
27
+ }>;
28
+ };
29
+ markRead: {
30
+ resource: string;
31
+ method: "POST";
32
+ parameters: import("../../schema/index.js").ObjectSchema<{
33
+ id: string;
34
+ }>;
35
+ result: import("../../schema/index.js").LiteralSchema<"ok">;
36
+ };
37
+ archive: {
38
+ resource: string;
39
+ method: "POST";
40
+ parameters: import("../../schema/index.js").ObjectSchema<{
41
+ id: string;
42
+ }>;
43
+ result: import("../../schema/index.js").LiteralSchema<"ok">;
44
+ };
45
+ getPreferences: {
46
+ resource: string;
47
+ method: "GET";
48
+ result: import("../../schema/index.js").ArraySchema<{
49
+ enabled: boolean;
50
+ channel: string;
51
+ categoryId: string;
52
+ }>;
53
+ };
54
+ updatePreference: {
55
+ resource: string;
56
+ method: "POST";
57
+ parameters: import("../../schema/index.js").ObjectSchema<{
58
+ readonly categoryId: string;
59
+ readonly channel: string;
60
+ readonly enabled: boolean;
61
+ }>;
62
+ result: import("../../schema/index.js").LiteralSchema<"ok">;
63
+ };
64
+ registerWebPush: {
65
+ resource: string;
66
+ method: "POST";
67
+ parameters: import("../../schema/index.js").ObjectSchema<{
68
+ readonly endpoint: string;
69
+ readonly keys: {
70
+ auth: string;
71
+ p256dh: string;
72
+ };
73
+ }>;
74
+ result: import("../../schema/index.js").LiteralSchema<"ok">;
75
+ };
76
+ };
77
+ };
78
+ export type NotificationApiDefinition = typeof notificationApiDefinition;
@@ -0,0 +1,81 @@
1
+ import { defineApi } from '../../api/types.js';
2
+ import { boolean, explicitObject, literal, number, object, optional, string, array, unknown } from '../../schema/index.js';
3
+ import { NotificationChannel } from '../enums.js';
4
+ import { ServerSentEvents } from '../../sse/server-sent-events.js';
5
+ export const notificationApiDefinition = defineApi({
6
+ resource: 'notification',
7
+ endpoints: {
8
+ stream: {
9
+ resource: 'stream',
10
+ method: 'GET',
11
+ result: ServerSentEvents,
12
+ },
13
+ listInApp: {
14
+ resource: 'in-app',
15
+ method: 'GET',
16
+ parameters: object({
17
+ limit: optional(number()),
18
+ offset: optional(number()),
19
+ includeArchived: optional(boolean()),
20
+ }),
21
+ result: array(object({
22
+ id: string(),
23
+ logId: string(),
24
+ readAt: optional(number()),
25
+ archivedAt: optional(number()),
26
+ // Add more joined fields from Log if needed, or return polymorphic payload
27
+ type: string(),
28
+ priority: string(),
29
+ createdAt: number(),
30
+ payload: optional(object({})),
31
+ })),
32
+ },
33
+ markRead: {
34
+ resource: 'in-app/:id/read',
35
+ method: 'POST',
36
+ parameters: object({
37
+ id: string(),
38
+ }),
39
+ result: literal('ok'),
40
+ },
41
+ archive: {
42
+ resource: 'in-app/:id/archive',
43
+ method: 'POST',
44
+ parameters: object({
45
+ id: string(),
46
+ }),
47
+ result: literal('ok'),
48
+ },
49
+ getPreferences: {
50
+ resource: 'preferences',
51
+ method: 'GET',
52
+ result: array(object({
53
+ categoryId: string(),
54
+ channel: string(),
55
+ enabled: boolean(),
56
+ })),
57
+ },
58
+ updatePreference: {
59
+ resource: 'preferences',
60
+ method: 'POST',
61
+ parameters: explicitObject({
62
+ categoryId: string(),
63
+ channel: string(),
64
+ enabled: boolean(),
65
+ }),
66
+ result: literal('ok'),
67
+ },
68
+ registerWebPush: {
69
+ resource: 'web-push/register',
70
+ method: 'POST',
71
+ parameters: explicitObject({
72
+ endpoint: string(),
73
+ keys: object({
74
+ p256dh: string(),
75
+ auth: string(),
76
+ }),
77
+ }),
78
+ result: literal('ok'),
79
+ },
80
+ },
81
+ });
@@ -0,0 +1,22 @@
1
+ import { type EnumType } from '../enumeration/index.js';
2
+ export declare const NotificationChannel: {
3
+ readonly InApp: "in-app";
4
+ readonly Email: "email";
5
+ readonly WebPush: "web-push";
6
+ };
7
+ export type NotificationChannel = EnumType<typeof NotificationChannel>;
8
+ export declare const NotificationPriority: {
9
+ readonly Low: "low";
10
+ readonly Medium: "medium";
11
+ readonly High: "high";
12
+ readonly Urgent: "urgent";
13
+ };
14
+ export type NotificationPriority = EnumType<typeof NotificationPriority>;
15
+ export declare const NotificationStatus: {
16
+ readonly Pending: "pending";
17
+ readonly Sent: "sent";
18
+ readonly Delivered: "delivered";
19
+ readonly Read: "read";
20
+ readonly Failed: "failed";
21
+ };
22
+ export type NotificationStatus = EnumType<typeof NotificationStatus>;
@@ -0,0 +1,19 @@
1
+ import { defineEnum } from '../enumeration/index.js';
2
+ export const NotificationChannel = defineEnum('NotificationChannel', {
3
+ InApp: 'in-app',
4
+ Email: 'email',
5
+ WebPush: 'web-push',
6
+ });
7
+ export const NotificationPriority = defineEnum('NotificationPriority', {
8
+ Low: 'low',
9
+ Medium: 'medium',
10
+ High: 'high',
11
+ Urgent: 'urgent',
12
+ });
13
+ export const NotificationStatus = defineEnum('NotificationStatus', {
14
+ Pending: 'pending',
15
+ Sent: 'sent',
16
+ Delivered: 'delivered',
17
+ Read: 'read',
18
+ Failed: 'failed',
19
+ });
@@ -0,0 +1,2 @@
1
+ export * from './enums.js';
2
+ export * from './models/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './enums.js';
2
+ export * from './models/index.js';
@@ -0,0 +1,9 @@
1
+ import { TenantEntity, type Uuid } from '../../orm/index.js';
2
+ import type { Timestamp } from '../../orm/types.js';
3
+ export declare class InAppNotification extends TenantEntity {
4
+ static readonly entityName = "InAppNotification";
5
+ userId: Uuid;
6
+ logId: Uuid;
7
+ readAt: Timestamp | null;
8
+ archivedAt: Timestamp | null;
9
+ }
@@ -0,0 +1,42 @@
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 { User } from '../../authentication/models/user.model.js';
11
+ import { TenantEntity, TenantReference, TimestampProperty, UuidProperty } from '../../orm/index.js';
12
+ import { NotificationLog } from './notification-log.model.js';
13
+ import { NotificationTable } from './notification-table.js';
14
+ let InAppNotification = class InAppNotification extends TenantEntity {
15
+ static entityName = 'InAppNotification';
16
+ userId;
17
+ logId;
18
+ readAt;
19
+ archivedAt;
20
+ };
21
+ __decorate([
22
+ UuidProperty(),
23
+ TenantReference(() => User),
24
+ __metadata("design:type", String)
25
+ ], InAppNotification.prototype, "userId", void 0);
26
+ __decorate([
27
+ UuidProperty(),
28
+ TenantReference(() => NotificationLog),
29
+ __metadata("design:type", String)
30
+ ], InAppNotification.prototype, "logId", void 0);
31
+ __decorate([
32
+ TimestampProperty({ nullable: true }),
33
+ __metadata("design:type", Object)
34
+ ], InAppNotification.prototype, "readAt", void 0);
35
+ __decorate([
36
+ TimestampProperty({ nullable: true }),
37
+ __metadata("design:type", Object)
38
+ ], InAppNotification.prototype, "archivedAt", void 0);
39
+ InAppNotification = __decorate([
40
+ NotificationTable({ name: 'in_app' })
41
+ ], InAppNotification);
42
+ export { InAppNotification };
@@ -0,0 +1,6 @@
1
+ export * from './in-app-notification.model.js';
2
+ export * from './notification-category.model.js';
3
+ export * from './notification-log.model.js';
4
+ export * from './notification-preference.model.js';
5
+ export * from './notification-table.js';
6
+ export * from './web-push-subscription.model.js';
@@ -0,0 +1,6 @@
1
+ export * from './in-app-notification.model.js';
2
+ export * from './notification-category.model.js';
3
+ export * from './notification-log.model.js';
4
+ export * from './notification-preference.model.js';
5
+ export * from './notification-table.js';
6
+ export * from './web-push-subscription.model.js';
@@ -0,0 +1,17 @@
1
+ import { TenantEntity } from '../../orm/index.js';
2
+ import { NotificationChannel } from '../enums.js';
3
+ export type ThrottlingConfig = {
4
+ limit: number;
5
+ intervalMs: number;
6
+ };
7
+ export type EscalationRule = {
8
+ delayMs: number;
9
+ channel: NotificationChannel;
10
+ };
11
+ export declare class NotificationCategory extends TenantEntity {
12
+ static readonly entityName = "NotificationCategory";
13
+ label: string;
14
+ key: string;
15
+ throttling: ThrottlingConfig | null;
16
+ escalations: EscalationRule[] | null;
17
+ }
@@ -0,0 +1,41 @@
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 { JsonProperty, TenantEntity, Unique } from '../../orm/index.js';
11
+ import { StringProperty } from '../../schema/index.js';
12
+ import { NotificationChannel } from '../enums.js';
13
+ import { NotificationTable } from './notification-table.js';
14
+ let NotificationCategory = class NotificationCategory extends TenantEntity {
15
+ static entityName = 'NotificationCategory';
16
+ label;
17
+ key;
18
+ throttling;
19
+ escalations;
20
+ };
21
+ __decorate([
22
+ StringProperty(),
23
+ __metadata("design:type", String)
24
+ ], NotificationCategory.prototype, "label", void 0);
25
+ __decorate([
26
+ StringProperty(),
27
+ __metadata("design:type", String)
28
+ ], NotificationCategory.prototype, "key", void 0);
29
+ __decorate([
30
+ JsonProperty({ nullable: true }),
31
+ __metadata("design:type", Object)
32
+ ], NotificationCategory.prototype, "throttling", void 0);
33
+ __decorate([
34
+ JsonProperty({ nullable: true }),
35
+ __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 };
@@ -0,0 +1,13 @@
1
+ import { type Json, TenantEntity, type Uuid } from '../../orm/index.js';
2
+ import type { ObjectLiteral } from '../../types/types.js';
3
+ import { NotificationPriority, NotificationStatus } from '../enums.js';
4
+ export declare class NotificationLog extends TenantEntity {
5
+ static readonly entityName = "NotificationLog";
6
+ userId: Uuid;
7
+ categoryId: Uuid;
8
+ type: string;
9
+ priority: NotificationPriority;
10
+ status: NotificationStatus;
11
+ currentStep: number;
12
+ payload: Json<ObjectLiteral> | null;
13
+ }
@@ -0,0 +1,59 @@
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 { User } from '../../authentication/models/user.model.js';
11
+ import { JsonProperty, TenantEntity, TenantReference, UuidProperty } from '../../orm/index.js';
12
+ import { Enumeration, Integer, StringProperty } from '../../schema/index.js';
13
+ import { NotificationPriority, NotificationStatus } from '../enums.js';
14
+ import { NotificationCategory } from './notification-category.model.js';
15
+ import { NotificationTable } from './notification-table.js';
16
+ let NotificationLog = class NotificationLog extends TenantEntity {
17
+ static entityName = 'NotificationLog';
18
+ userId;
19
+ categoryId;
20
+ type;
21
+ priority;
22
+ status;
23
+ currentStep;
24
+ payload;
25
+ };
26
+ __decorate([
27
+ UuidProperty(),
28
+ TenantReference(() => User),
29
+ __metadata("design:type", String)
30
+ ], NotificationLog.prototype, "userId", void 0);
31
+ __decorate([
32
+ UuidProperty(),
33
+ TenantReference(() => NotificationCategory),
34
+ __metadata("design:type", String)
35
+ ], NotificationLog.prototype, "categoryId", void 0);
36
+ __decorate([
37
+ StringProperty(),
38
+ __metadata("design:type", String)
39
+ ], NotificationLog.prototype, "type", void 0);
40
+ __decorate([
41
+ Enumeration(NotificationPriority),
42
+ __metadata("design:type", String)
43
+ ], NotificationLog.prototype, "priority", void 0);
44
+ __decorate([
45
+ Enumeration(NotificationStatus),
46
+ __metadata("design:type", String)
47
+ ], NotificationLog.prototype, "status", void 0);
48
+ __decorate([
49
+ Integer(),
50
+ __metadata("design:type", Number)
51
+ ], NotificationLog.prototype, "currentStep", void 0);
52
+ __decorate([
53
+ JsonProperty({ nullable: true }),
54
+ __metadata("design:type", Object)
55
+ ], NotificationLog.prototype, "payload", void 0);
56
+ NotificationLog = __decorate([
57
+ NotificationTable({ name: 'log' })
58
+ ], NotificationLog);
59
+ export { NotificationLog };
@@ -0,0 +1,9 @@
1
+ import { TenantEntity, type Uuid } from '../../orm/index.js';
2
+ import { NotificationChannel } from '../enums.js';
3
+ export declare class NotificationPreference extends TenantEntity {
4
+ static readonly entityName = "NotificationPreference";
5
+ userId: Uuid;
6
+ categoryId: Uuid;
7
+ channel: NotificationChannel;
8
+ enabled: boolean;
9
+ }
@@ -0,0 +1,45 @@
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 { User } from '../../authentication/models/user.model.js';
11
+ import { TenantEntity, TenantReference, Unique, UuidProperty } from '../../orm/index.js';
12
+ import { BooleanProperty, Enumeration } from '../../schema/index.js';
13
+ import { NotificationChannel } from '../enums.js';
14
+ import { NotificationCategory } from './notification-category.model.js';
15
+ import { NotificationTable } from './notification-table.js';
16
+ let NotificationPreference = class NotificationPreference extends TenantEntity {
17
+ static entityName = 'NotificationPreference';
18
+ userId;
19
+ categoryId;
20
+ channel;
21
+ enabled;
22
+ };
23
+ __decorate([
24
+ UuidProperty(),
25
+ TenantReference(() => User),
26
+ __metadata("design:type", String)
27
+ ], NotificationPreference.prototype, "userId", void 0);
28
+ __decorate([
29
+ UuidProperty(),
30
+ TenantReference(() => NotificationCategory),
31
+ __metadata("design:type", String)
32
+ ], NotificationPreference.prototype, "categoryId", void 0);
33
+ __decorate([
34
+ Enumeration(NotificationChannel),
35
+ __metadata("design:type", String)
36
+ ], NotificationPreference.prototype, "channel", void 0);
37
+ __decorate([
38
+ BooleanProperty(),
39
+ __metadata("design:type", Boolean)
40
+ ], NotificationPreference.prototype, "enabled", void 0);
41
+ NotificationPreference = __decorate([
42
+ NotificationTable({ name: 'preference' }),
43
+ Unique(['tenantId', 'userId', 'categoryId', 'channel'])
44
+ ], NotificationPreference);
45
+ export { NotificationPreference };
@@ -0,0 +1,3 @@
1
+ import { type TableOptions } from '../../orm/index.js';
2
+ import type { TypedOmit } from '../../types/index.js';
3
+ export declare function NotificationTable(options?: TypedOmit<TableOptions, 'schema'>): ClassDecorator;
@@ -0,0 +1,4 @@
1
+ import { Table } from '../../orm/index.js';
2
+ export function NotificationTable(options) {
3
+ return Table({ ...options, schema: 'notification' });
4
+ }
@@ -0,0 +1,8 @@
1
+ import { TenantEntity, type Uuid } from '../../orm/index.js';
2
+ export declare class WebPushSubscription extends TenantEntity {
3
+ static readonly entityName = "WebPushSubscription";
4
+ userId: Uuid;
5
+ endpoint: string;
6
+ p256dh: string;
7
+ auth: string;
8
+ }
@@ -0,0 +1,41 @@
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 { User } from '../../authentication/models/user.model.js';
11
+ import { TenantEntity, TenantReference, UuidProperty } from '../../orm/index.js';
12
+ import { StringProperty } from '../../schema/index.js';
13
+ import { NotificationTable } from './notification-table.js';
14
+ let WebPushSubscription = class WebPushSubscription extends TenantEntity {
15
+ static entityName = 'WebPushSubscription';
16
+ userId;
17
+ endpoint;
18
+ p256dh;
19
+ auth;
20
+ };
21
+ __decorate([
22
+ UuidProperty(),
23
+ TenantReference(() => User),
24
+ __metadata("design:type", String)
25
+ ], WebPushSubscription.prototype, "userId", void 0);
26
+ __decorate([
27
+ StringProperty(),
28
+ __metadata("design:type", String)
29
+ ], WebPushSubscription.prototype, "endpoint", void 0);
30
+ __decorate([
31
+ StringProperty(),
32
+ __metadata("design:type", String)
33
+ ], WebPushSubscription.prototype, "p256dh", void 0);
34
+ __decorate([
35
+ StringProperty(),
36
+ __metadata("design:type", String)
37
+ ], WebPushSubscription.prototype, "auth", void 0);
38
+ WebPushSubscription = __decorate([
39
+ NotificationTable({ name: 'web_push_subscription' })
40
+ ], WebPushSubscription);
41
+ export { WebPushSubscription };
@@ -0,0 +1,16 @@
1
+ import type { ApiController, ApiRequestContext } from '../../../api/types.js';
2
+ import type { NotificationApiDefinition } from '../../api/notification.api.js';
3
+ import { NotificationService } from '../services/notification.service.js';
4
+ import { NotificationSseService } from '../services/notification-sse.service.js';
5
+ import type { ServerSentEventsSource } from '../../../sse/server-sent-events-source.js';
6
+ export declare class NotificationApiController implements ApiController<NotificationApiDefinition> {
7
+ protected readonly notificationService: NotificationService;
8
+ protected readonly sseService: NotificationSseService;
9
+ stream({ getToken }: ApiRequestContext<NotificationApiDefinition, 'stream'>): Promise<ServerSentEventsSource>;
10
+ listInApp({ parameters, getToken }: ApiRequestContext<NotificationApiDefinition, 'listInApp'>): Promise<any>;
11
+ markRead({ parameters, getToken }: ApiRequestContext<NotificationApiDefinition, 'markRead'>): Promise<'ok'>;
12
+ archive({ parameters, getToken }: ApiRequestContext<NotificationApiDefinition, 'archive'>): Promise<'ok'>;
13
+ getPreferences({ getToken }: ApiRequestContext<NotificationApiDefinition, 'getPreferences'>): Promise<any>;
14
+ updatePreference({ parameters, getToken }: ApiRequestContext<NotificationApiDefinition, 'updatePreference'>): Promise<'ok'>;
15
+ registerWebPush({ parameters, getToken }: ApiRequestContext<NotificationApiDefinition, 'registerWebPush'>): Promise<'ok'>;
16
+ }