@contractspec/module.notifications 1.57.0 → 1.58.0

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 (42) hide show
  1. package/dist/browser/channels/index.js +124 -0
  2. package/dist/browser/contracts/index.js +340 -0
  3. package/dist/browser/entities/index.js +223 -0
  4. package/dist/browser/index.js +864 -0
  5. package/dist/browser/notifications.capability.js +16 -0
  6. package/dist/browser/notifications.feature.js +34 -0
  7. package/dist/browser/templates/index.js +147 -0
  8. package/dist/channels/index.d.ts +64 -67
  9. package/dist/channels/index.d.ts.map +1 -1
  10. package/dist/channels/index.js +123 -125
  11. package/dist/contracts/index.d.ts +571 -577
  12. package/dist/contracts/index.d.ts.map +1 -1
  13. package/dist/contracts/index.js +324 -416
  14. package/dist/entities/index.d.ts +145 -150
  15. package/dist/entities/index.d.ts.map +1 -1
  16. package/dist/entities/index.js +215 -245
  17. package/dist/index.d.ts +6 -6
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +864 -6
  20. package/dist/node/channels/index.js +124 -0
  21. package/dist/node/contracts/index.js +340 -0
  22. package/dist/node/entities/index.js +223 -0
  23. package/dist/node/index.js +864 -0
  24. package/dist/node/notifications.capability.js +16 -0
  25. package/dist/node/notifications.feature.js +34 -0
  26. package/dist/node/templates/index.js +147 -0
  27. package/dist/notifications.capability.d.ts +1 -6
  28. package/dist/notifications.capability.d.ts.map +1 -1
  29. package/dist/notifications.capability.js +17 -20
  30. package/dist/notifications.feature.d.ts +1 -6
  31. package/dist/notifications.feature.d.ts.map +1 -1
  32. package/dist/notifications.feature.js +33 -75
  33. package/dist/templates/index.d.ts +47 -50
  34. package/dist/templates/index.d.ts.map +1 -1
  35. package/dist/templates/index.js +127 -181
  36. package/package.json +102 -27
  37. package/dist/channels/index.js.map +0 -1
  38. package/dist/contracts/index.js.map +0 -1
  39. package/dist/entities/index.js.map +0 -1
  40. package/dist/notifications.capability.js.map +0 -1
  41. package/dist/notifications.feature.js.map +0 -1
  42. package/dist/templates/index.js.map +0 -1
@@ -1,254 +1,224 @@
1
- import { defineEntity, defineEntityEnum, field, index } from "@contractspec/lib.schema";
2
-
3
- //#region src/entities/index.ts
4
- /**
5
- * Notification status enum.
6
- */
7
- const NotificationStatusEnum = defineEntityEnum({
8
- name: "NotificationStatus",
9
- values: [
10
- "PENDING",
11
- "SENT",
12
- "DELIVERED",
13
- "READ",
14
- "FAILED",
15
- "CANCELLED"
16
- ],
17
- schema: "lssm_notifications",
18
- description: "Status of a notification."
1
+ // @bun
2
+ // src/entities/index.ts
3
+ import {
4
+ defineEntity,
5
+ defineEntityEnum,
6
+ field,
7
+ index
8
+ } from "@contractspec/lib.schema";
9
+ var NotificationStatusEnum = defineEntityEnum({
10
+ name: "NotificationStatus",
11
+ values: [
12
+ "PENDING",
13
+ "SENT",
14
+ "DELIVERED",
15
+ "READ",
16
+ "FAILED",
17
+ "CANCELLED"
18
+ ],
19
+ schema: "lssm_notifications",
20
+ description: "Status of a notification."
19
21
  });
20
- /**
21
- * Notification channel enum.
22
- */
23
- const NotificationChannelEnum = defineEntityEnum({
24
- name: "NotificationChannel",
25
- values: [
26
- "EMAIL",
27
- "IN_APP",
28
- "PUSH",
29
- "WEBHOOK",
30
- "SMS"
31
- ],
32
- schema: "lssm_notifications",
33
- description: "Delivery channel for notifications."
22
+ var NotificationChannelEnum = defineEntityEnum({
23
+ name: "NotificationChannel",
24
+ values: ["EMAIL", "IN_APP", "PUSH", "WEBHOOK", "SMS"],
25
+ schema: "lssm_notifications",
26
+ description: "Delivery channel for notifications."
34
27
  });
35
- /**
36
- * Notification entity - individual notification instance.
37
- */
38
- const NotificationEntity = defineEntity({
39
- name: "Notification",
40
- description: "An individual notification to be delivered to a user.",
41
- schema: "lssm_notifications",
42
- map: "notification",
43
- fields: {
44
- id: field.id({ description: "Unique notification ID" }),
45
- userId: field.foreignKey({ description: "Target user ID" }),
46
- orgId: field.string({
47
- isOptional: true,
48
- description: "Organization context"
49
- }),
50
- templateId: field.string({
51
- isOptional: true,
52
- description: "Template used"
53
- }),
54
- title: field.string({ description: "Notification title" }),
55
- body: field.string({ description: "Notification body" }),
56
- actionUrl: field.string({
57
- isOptional: true,
58
- description: "Action URL"
59
- }),
60
- imageUrl: field.string({
61
- isOptional: true,
62
- description: "Image URL"
63
- }),
64
- type: field.string({ description: "Notification type (e.g., mention, update)" }),
65
- category: field.string({
66
- isOptional: true,
67
- description: "Notification category"
68
- }),
69
- priority: field.enum("NotificationPriority", { default: "NORMAL" }),
70
- channels: field.string({
71
- isArray: true,
72
- description: "Target delivery channels"
73
- }),
74
- status: field.enum("NotificationStatus", { default: "PENDING" }),
75
- sentAt: field.dateTime({ isOptional: true }),
76
- deliveredAt: field.dateTime({ isOptional: true }),
77
- readAt: field.dateTime({ isOptional: true }),
78
- metadata: field.json({
79
- isOptional: true,
80
- description: "Additional metadata"
81
- }),
82
- variables: field.json({
83
- isOptional: true,
84
- description: "Template variables used"
85
- }),
86
- triggeredBy: field.string({
87
- isOptional: true,
88
- description: "Event/action that triggered"
89
- }),
90
- sourceId: field.string({
91
- isOptional: true,
92
- description: "Source entity ID"
93
- }),
94
- sourceType: field.string({
95
- isOptional: true,
96
- description: "Source entity type"
97
- }),
98
- createdAt: field.createdAt(),
99
- updatedAt: field.updatedAt(),
100
- expiresAt: field.dateTime({
101
- isOptional: true,
102
- description: "Notification expiry"
103
- }),
104
- deliveryLogs: field.hasMany("DeliveryLog")
105
- },
106
- indexes: [
107
- index.on([
108
- "userId",
109
- "status",
110
- "createdAt"
111
- ]),
112
- index.on(["userId", "readAt"]),
113
- index.on(["orgId", "createdAt"]),
114
- index.on(["type", "createdAt"])
115
- ],
116
- enums: [NotificationStatusEnum, NotificationChannelEnum]
28
+ var NotificationEntity = defineEntity({
29
+ name: "Notification",
30
+ description: "An individual notification to be delivered to a user.",
31
+ schema: "lssm_notifications",
32
+ map: "notification",
33
+ fields: {
34
+ id: field.id({ description: "Unique notification ID" }),
35
+ userId: field.foreignKey({ description: "Target user ID" }),
36
+ orgId: field.string({
37
+ isOptional: true,
38
+ description: "Organization context"
39
+ }),
40
+ templateId: field.string({
41
+ isOptional: true,
42
+ description: "Template used"
43
+ }),
44
+ title: field.string({ description: "Notification title" }),
45
+ body: field.string({ description: "Notification body" }),
46
+ actionUrl: field.string({ isOptional: true, description: "Action URL" }),
47
+ imageUrl: field.string({ isOptional: true, description: "Image URL" }),
48
+ type: field.string({
49
+ description: "Notification type (e.g., mention, update)"
50
+ }),
51
+ category: field.string({
52
+ isOptional: true,
53
+ description: "Notification category"
54
+ }),
55
+ priority: field.enum("NotificationPriority", { default: "NORMAL" }),
56
+ channels: field.string({
57
+ isArray: true,
58
+ description: "Target delivery channels"
59
+ }),
60
+ status: field.enum("NotificationStatus", { default: "PENDING" }),
61
+ sentAt: field.dateTime({ isOptional: true }),
62
+ deliveredAt: field.dateTime({ isOptional: true }),
63
+ readAt: field.dateTime({ isOptional: true }),
64
+ metadata: field.json({
65
+ isOptional: true,
66
+ description: "Additional metadata"
67
+ }),
68
+ variables: field.json({
69
+ isOptional: true,
70
+ description: "Template variables used"
71
+ }),
72
+ triggeredBy: field.string({
73
+ isOptional: true,
74
+ description: "Event/action that triggered"
75
+ }),
76
+ sourceId: field.string({
77
+ isOptional: true,
78
+ description: "Source entity ID"
79
+ }),
80
+ sourceType: field.string({
81
+ isOptional: true,
82
+ description: "Source entity type"
83
+ }),
84
+ createdAt: field.createdAt(),
85
+ updatedAt: field.updatedAt(),
86
+ expiresAt: field.dateTime({
87
+ isOptional: true,
88
+ description: "Notification expiry"
89
+ }),
90
+ deliveryLogs: field.hasMany("DeliveryLog")
91
+ },
92
+ indexes: [
93
+ index.on(["userId", "status", "createdAt"]),
94
+ index.on(["userId", "readAt"]),
95
+ index.on(["orgId", "createdAt"]),
96
+ index.on(["type", "createdAt"])
97
+ ],
98
+ enums: [NotificationStatusEnum, NotificationChannelEnum]
117
99
  });
118
- /**
119
- * Notification priority enum.
120
- */
121
- const NotificationPriorityEnum = defineEntityEnum({
122
- name: "NotificationPriority",
123
- values: [
124
- "LOW",
125
- "NORMAL",
126
- "HIGH",
127
- "URGENT"
128
- ],
129
- schema: "lssm_notifications",
130
- description: "Priority level of a notification."
100
+ var NotificationPriorityEnum = defineEntityEnum({
101
+ name: "NotificationPriority",
102
+ values: ["LOW", "NORMAL", "HIGH", "URGENT"],
103
+ schema: "lssm_notifications",
104
+ description: "Priority level of a notification."
131
105
  });
132
- /**
133
- * NotificationTemplate entity - reusable notification templates.
134
- */
135
- const NotificationTemplateEntity = defineEntity({
136
- name: "NotificationTemplate",
137
- description: "Reusable notification template.",
138
- schema: "lssm_notifications",
139
- map: "notification_template",
140
- fields: {
141
- id: field.id(),
142
- templateId: field.string({
143
- isUnique: true,
144
- description: "Template identifier"
145
- }),
146
- name: field.string({ description: "Template display name" }),
147
- description: field.string({ isOptional: true }),
148
- emailSubject: field.string({ isOptional: true }),
149
- emailBody: field.string({ isOptional: true }),
150
- inAppTitle: field.string({ isOptional: true }),
151
- inAppBody: field.string({ isOptional: true }),
152
- pushTitle: field.string({ isOptional: true }),
153
- pushBody: field.string({ isOptional: true }),
154
- defaultChannels: field.string({ isArray: true }),
155
- category: field.string({ isOptional: true }),
156
- priority: field.enum("NotificationPriority", { default: "NORMAL" }),
157
- variablesSchema: field.json({
158
- isOptional: true,
159
- description: "JSON schema for variables"
160
- }),
161
- enabled: field.boolean({ default: true }),
162
- createdAt: field.createdAt(),
163
- updatedAt: field.updatedAt()
164
- },
165
- enums: [NotificationPriorityEnum]
106
+ var NotificationTemplateEntity = defineEntity({
107
+ name: "NotificationTemplate",
108
+ description: "Reusable notification template.",
109
+ schema: "lssm_notifications",
110
+ map: "notification_template",
111
+ fields: {
112
+ id: field.id(),
113
+ templateId: field.string({
114
+ isUnique: true,
115
+ description: "Template identifier"
116
+ }),
117
+ name: field.string({ description: "Template display name" }),
118
+ description: field.string({ isOptional: true }),
119
+ emailSubject: field.string({ isOptional: true }),
120
+ emailBody: field.string({ isOptional: true }),
121
+ inAppTitle: field.string({ isOptional: true }),
122
+ inAppBody: field.string({ isOptional: true }),
123
+ pushTitle: field.string({ isOptional: true }),
124
+ pushBody: field.string({ isOptional: true }),
125
+ defaultChannels: field.string({ isArray: true }),
126
+ category: field.string({ isOptional: true }),
127
+ priority: field.enum("NotificationPriority", { default: "NORMAL" }),
128
+ variablesSchema: field.json({
129
+ isOptional: true,
130
+ description: "JSON schema for variables"
131
+ }),
132
+ enabled: field.boolean({ default: true }),
133
+ createdAt: field.createdAt(),
134
+ updatedAt: field.updatedAt()
135
+ },
136
+ enums: [NotificationPriorityEnum]
166
137
  });
167
- /**
168
- * NotificationPreference entity - user notification preferences.
169
- */
170
- const NotificationPreferenceEntity = defineEntity({
171
- name: "NotificationPreference",
172
- description: "User notification preferences by type and channel.",
173
- schema: "lssm_notifications",
174
- map: "notification_preference",
175
- fields: {
176
- id: field.id(),
177
- userId: field.foreignKey(),
178
- globalEnabled: field.boolean({ default: true }),
179
- quietHoursStart: field.string({
180
- isOptional: true,
181
- description: "Quiet hours start (HH:MM)"
182
- }),
183
- quietHoursEnd: field.string({
184
- isOptional: true,
185
- description: "Quiet hours end (HH:MM)"
186
- }),
187
- timezone: field.string({ default: "\"UTC\"" }),
188
- channelPreferences: field.json({ description: "Channel-level preferences" }),
189
- typePreferences: field.json({ description: "Type-level preferences" }),
190
- digestEnabled: field.boolean({ default: false }),
191
- digestFrequency: field.string({
192
- isOptional: true,
193
- description: "daily, weekly, etc."
194
- }),
195
- digestTime: field.string({
196
- isOptional: true,
197
- description: "Digest send time (HH:MM)"
198
- }),
199
- createdAt: field.createdAt(),
200
- updatedAt: field.updatedAt()
201
- },
202
- indexes: [index.unique(["userId"])]
138
+ var NotificationPreferenceEntity = defineEntity({
139
+ name: "NotificationPreference",
140
+ description: "User notification preferences by type and channel.",
141
+ schema: "lssm_notifications",
142
+ map: "notification_preference",
143
+ fields: {
144
+ id: field.id(),
145
+ userId: field.foreignKey(),
146
+ globalEnabled: field.boolean({ default: true }),
147
+ quietHoursStart: field.string({
148
+ isOptional: true,
149
+ description: "Quiet hours start (HH:MM)"
150
+ }),
151
+ quietHoursEnd: field.string({
152
+ isOptional: true,
153
+ description: "Quiet hours end (HH:MM)"
154
+ }),
155
+ timezone: field.string({ default: '"UTC"' }),
156
+ channelPreferences: field.json({
157
+ description: "Channel-level preferences"
158
+ }),
159
+ typePreferences: field.json({ description: "Type-level preferences" }),
160
+ digestEnabled: field.boolean({ default: false }),
161
+ digestFrequency: field.string({
162
+ isOptional: true,
163
+ description: "daily, weekly, etc."
164
+ }),
165
+ digestTime: field.string({
166
+ isOptional: true,
167
+ description: "Digest send time (HH:MM)"
168
+ }),
169
+ createdAt: field.createdAt(),
170
+ updatedAt: field.updatedAt()
171
+ },
172
+ indexes: [index.unique(["userId"])]
203
173
  });
204
- /**
205
- * DeliveryLog entity - track delivery attempts per channel.
206
- */
207
- const DeliveryLogEntity = defineEntity({
208
- name: "DeliveryLog",
209
- description: "Log of notification delivery attempts.",
210
- schema: "lssm_notifications",
211
- map: "delivery_log",
212
- fields: {
213
- id: field.id(),
214
- notificationId: field.foreignKey(),
215
- channel: field.enum("NotificationChannel"),
216
- status: field.enum("NotificationStatus"),
217
- attemptedAt: field.dateTime(),
218
- deliveredAt: field.dateTime({ isOptional: true }),
219
- responseCode: field.string({ isOptional: true }),
220
- responseMessage: field.string({ isOptional: true }),
221
- externalId: field.string({
222
- isOptional: true,
223
- description: "Provider message ID"
224
- }),
225
- metadata: field.json({ isOptional: true }),
226
- notification: field.belongsTo("Notification", ["notificationId"], ["id"], { onDelete: "Cascade" })
227
- },
228
- indexes: [index.on(["notificationId", "channel"])]
174
+ var DeliveryLogEntity = defineEntity({
175
+ name: "DeliveryLog",
176
+ description: "Log of notification delivery attempts.",
177
+ schema: "lssm_notifications",
178
+ map: "delivery_log",
179
+ fields: {
180
+ id: field.id(),
181
+ notificationId: field.foreignKey(),
182
+ channel: field.enum("NotificationChannel"),
183
+ status: field.enum("NotificationStatus"),
184
+ attemptedAt: field.dateTime(),
185
+ deliveredAt: field.dateTime({ isOptional: true }),
186
+ responseCode: field.string({ isOptional: true }),
187
+ responseMessage: field.string({ isOptional: true }),
188
+ externalId: field.string({
189
+ isOptional: true,
190
+ description: "Provider message ID"
191
+ }),
192
+ metadata: field.json({ isOptional: true }),
193
+ notification: field.belongsTo("Notification", ["notificationId"], ["id"], {
194
+ onDelete: "Cascade"
195
+ })
196
+ },
197
+ indexes: [index.on(["notificationId", "channel"])]
229
198
  });
230
- /**
231
- * All notification entities for schema composition.
232
- */
233
- const notificationEntities = [
234
- NotificationEntity,
235
- NotificationTemplateEntity,
236
- NotificationPreferenceEntity,
237
- DeliveryLogEntity
199
+ var notificationEntities = [
200
+ NotificationEntity,
201
+ NotificationTemplateEntity,
202
+ NotificationPreferenceEntity,
203
+ DeliveryLogEntity
238
204
  ];
239
- /**
240
- * Module schema contribution for notifications.
241
- */
242
- const notificationsSchemaContribution = {
243
- moduleId: "@contractspec/module.notifications",
244
- entities: notificationEntities,
245
- enums: [
246
- NotificationStatusEnum,
247
- NotificationChannelEnum,
248
- NotificationPriorityEnum
249
- ]
205
+ var notificationsSchemaContribution = {
206
+ moduleId: "@contractspec/module.notifications",
207
+ entities: notificationEntities,
208
+ enums: [
209
+ NotificationStatusEnum,
210
+ NotificationChannelEnum,
211
+ NotificationPriorityEnum
212
+ ]
213
+ };
214
+ export {
215
+ notificationsSchemaContribution,
216
+ notificationEntities,
217
+ NotificationTemplateEntity,
218
+ NotificationStatusEnum,
219
+ NotificationPriorityEnum,
220
+ NotificationPreferenceEntity,
221
+ NotificationEntity,
222
+ NotificationChannelEnum,
223
+ DeliveryLogEntity
250
224
  };
251
-
252
- //#endregion
253
- export { DeliveryLogEntity, NotificationChannelEnum, NotificationEntity, NotificationPreferenceEntity, NotificationPriorityEnum, NotificationStatusEnum, NotificationTemplateEntity, notificationEntities, notificationsSchemaContribution };
254
- //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ChannelDeliveryResult, ChannelNotification, ChannelRegistry, ConsoleChannel, EmailChannel, InAppChannel, NotificationChannel, PushChannel, WebhookChannel, createChannelRegistry } from "./channels/index.js";
2
- import { DeleteNotificationContract, GetNotificationPreferencesContract, ListNotificationsContract, ListNotificationsInputModel, ListNotificationsOutputModel, MarkAllNotificationsReadContract, MarkNotificationReadContract, NotificationFilterEnum, NotificationModel, NotificationPreferenceModel, SendNotificationContract, SendNotificationInputModel, UpdateNotificationPreferencesContract, UpdatePreferencesInputModel } from "./contracts/index.js";
3
- import { DeliveryLogEntity, NotificationChannelEnum, NotificationEntity, NotificationPreferenceEntity, NotificationPriorityEnum, NotificationStatusEnum, NotificationTemplateEntity, notificationEntities, notificationsSchemaContribution } from "./entities/index.js";
4
- import { ChannelTemplateContent, MentionTemplate, NotificationTemplateDefinition, OrgInviteTemplate, RenderedNotification, TemplateRegistry, TemplateVariable, WelcomeTemplate, createTemplateRegistry, defineTemplate, renderNotificationTemplate, renderTemplate } from "./templates/index.js";
5
- import { NotificationsFeature } from "./notifications.feature.js";
6
- export { ChannelDeliveryResult, ChannelNotification, ChannelRegistry, ChannelTemplateContent, ConsoleChannel, DeleteNotificationContract, DeliveryLogEntity, EmailChannel, GetNotificationPreferencesContract, InAppChannel, ListNotificationsContract, ListNotificationsInputModel, ListNotificationsOutputModel, MarkAllNotificationsReadContract, MarkNotificationReadContract, MentionTemplate, NotificationChannel, NotificationChannelEnum, NotificationEntity, NotificationFilterEnum, NotificationModel, NotificationPreferenceEntity, NotificationPreferenceModel, NotificationPriorityEnum, NotificationStatusEnum, NotificationTemplateDefinition, NotificationTemplateEntity, NotificationsFeature, OrgInviteTemplate, PushChannel, RenderedNotification, SendNotificationContract, SendNotificationInputModel, TemplateRegistry, TemplateVariable, UpdateNotificationPreferencesContract, UpdatePreferencesInputModel, WebhookChannel, WelcomeTemplate, createChannelRegistry, createTemplateRegistry, defineTemplate, notificationEntities, notificationsSchemaContribution, renderNotificationTemplate, renderTemplate };
1
+ export * from './entities';
2
+ export * from './contracts';
3
+ export * from './channels';
4
+ export * from './templates';
5
+ export * from './notifications.feature';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAG3B,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cAAc,aAAa,CAAC;AAG5B,cAAc,yBAAyB,CAAC"}