@contractspec/module.notifications 3.7.15 → 3.7.17

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 (46) hide show
  1. package/dist/browser/channels/index.js +1 -314
  2. package/dist/browser/contracts/index.js +1 -356
  3. package/dist/browser/entities/index.js +1 -239
  4. package/dist/browser/i18n/catalogs/en.js +1 -68
  5. package/dist/browser/i18n/catalogs/es.js +1 -68
  6. package/dist/browser/i18n/catalogs/fr.js +1 -68
  7. package/dist/browser/i18n/catalogs/index.js +1 -169
  8. package/dist/browser/i18n/index.js +1 -229
  9. package/dist/browser/i18n/keys.js +1 -37
  10. package/dist/browser/i18n/locale.js +1 -29
  11. package/dist/browser/i18n/messages.js +1 -190
  12. package/dist/browser/index.js +7 -1126
  13. package/dist/browser/notifications.capability.js +1 -35
  14. package/dist/browser/notifications.feature.js +1 -50
  15. package/dist/browser/templates/index.js +7 -235
  16. package/dist/channels/index.js +1 -314
  17. package/dist/contracts/index.js +1 -356
  18. package/dist/entities/index.js +1 -239
  19. package/dist/i18n/catalogs/en.js +1 -68
  20. package/dist/i18n/catalogs/es.js +1 -68
  21. package/dist/i18n/catalogs/fr.js +1 -68
  22. package/dist/i18n/catalogs/index.js +1 -169
  23. package/dist/i18n/index.js +1 -229
  24. package/dist/i18n/keys.js +1 -37
  25. package/dist/i18n/locale.js +1 -29
  26. package/dist/i18n/messages.js +1 -190
  27. package/dist/index.js +7 -1126
  28. package/dist/node/channels/index.js +1 -314
  29. package/dist/node/contracts/index.js +1 -356
  30. package/dist/node/entities/index.js +1 -239
  31. package/dist/node/i18n/catalogs/en.js +1 -68
  32. package/dist/node/i18n/catalogs/es.js +1 -68
  33. package/dist/node/i18n/catalogs/fr.js +1 -68
  34. package/dist/node/i18n/catalogs/index.js +1 -169
  35. package/dist/node/i18n/index.js +1 -229
  36. package/dist/node/i18n/keys.js +1 -37
  37. package/dist/node/i18n/locale.js +1 -29
  38. package/dist/node/i18n/messages.js +1 -190
  39. package/dist/node/index.js +7 -1126
  40. package/dist/node/notifications.capability.js +1 -35
  41. package/dist/node/notifications.feature.js +1 -50
  42. package/dist/node/templates/index.js +7 -235
  43. package/dist/notifications.capability.js +1 -35
  44. package/dist/notifications.feature.js +1 -50
  45. package/dist/templates/index.js +7 -235
  46. package/package.json +8 -8
@@ -1,314 +1 @@
1
- var __defProp = Object.defineProperty;
2
- var __returnValue = (v) => v;
3
- function __exportSetter(name, newValue) {
4
- this[name] = __returnValue.bind(null, newValue);
5
- }
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true,
11
- configurable: true,
12
- set: __exportSetter.bind(all, name)
13
- });
14
- };
15
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
16
-
17
- // src/i18n/catalogs/en.ts
18
- import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
19
- var enMessages;
20
- var init_en = __esm(() => {
21
- enMessages = defineTranslation({
22
- meta: {
23
- key: "notifications.messages",
24
- version: "1.0.0",
25
- domain: "notifications",
26
- description: "Template and channel strings for the notifications module",
27
- owners: ["platform"],
28
- stability: "experimental"
29
- },
30
- locale: "en",
31
- fallback: "en",
32
- messages: {
33
- "template.welcome.name": {
34
- value: "Welcome",
35
- description: "Welcome template display name"
36
- },
37
- "template.welcome.description": {
38
- value: "Sent when a user signs up.",
39
- description: "Welcome template description"
40
- },
41
- "template.orgInvite.name": {
42
- value: "Organization Invitation",
43
- description: "Org invite template display name"
44
- },
45
- "template.orgInvite.description": {
46
- value: "Sent when a user is invited to an organization.",
47
- description: "Org invite template description"
48
- },
49
- "template.mention.name": {
50
- value: "Mention",
51
- description: "Mention template display name"
52
- },
53
- "template.mention.description": {
54
- value: "Sent when a user is mentioned.",
55
- description: "Mention template description"
56
- },
57
- "channel.webhook.noUrl": {
58
- value: "No webhook URL configured",
59
- description: "Error when webhook channel has no URL"
60
- }
61
- }
62
- });
63
- });
64
-
65
- // src/i18n/catalogs/es.ts
66
- import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
67
- var esMessages;
68
- var init_es = __esm(() => {
69
- esMessages = defineTranslation2({
70
- meta: {
71
- key: "notifications.messages",
72
- version: "1.0.0",
73
- domain: "notifications",
74
- description: "Template and channel strings (Spanish)",
75
- owners: ["platform"],
76
- stability: "experimental"
77
- },
78
- locale: "es",
79
- fallback: "en",
80
- messages: {
81
- "template.welcome.name": {
82
- value: "Bienvenida",
83
- description: "Welcome template display name"
84
- },
85
- "template.welcome.description": {
86
- value: "Enviado cuando un usuario se registra.",
87
- description: "Welcome template description"
88
- },
89
- "template.orgInvite.name": {
90
- value: "Invitación a la organización",
91
- description: "Org invite template display name"
92
- },
93
- "template.orgInvite.description": {
94
- value: "Enviado cuando un usuario es invitado a una organización.",
95
- description: "Org invite template description"
96
- },
97
- "template.mention.name": {
98
- value: "Mención",
99
- description: "Mention template display name"
100
- },
101
- "template.mention.description": {
102
- value: "Enviado cuando un usuario es mencionado.",
103
- description: "Mention template description"
104
- },
105
- "channel.webhook.noUrl": {
106
- value: "No se ha configurado una URL de webhook",
107
- description: "Error when webhook channel has no URL"
108
- }
109
- }
110
- });
111
- });
112
-
113
- // src/i18n/catalogs/fr.ts
114
- import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
115
- var frMessages;
116
- var init_fr = __esm(() => {
117
- frMessages = defineTranslation3({
118
- meta: {
119
- key: "notifications.messages",
120
- version: "1.0.0",
121
- domain: "notifications",
122
- description: "Template and channel strings (French)",
123
- owners: ["platform"],
124
- stability: "experimental"
125
- },
126
- locale: "fr",
127
- fallback: "en",
128
- messages: {
129
- "template.welcome.name": {
130
- value: "Bienvenue",
131
- description: "Welcome template display name"
132
- },
133
- "template.welcome.description": {
134
- value: "Envoyé lorsqu'un utilisateur s'inscrit.",
135
- description: "Welcome template description"
136
- },
137
- "template.orgInvite.name": {
138
- value: "Invitation à l'organisation",
139
- description: "Org invite template display name"
140
- },
141
- "template.orgInvite.description": {
142
- value: "Envoyé lorsqu'un utilisateur est invité à une organisation.",
143
- description: "Org invite template description"
144
- },
145
- "template.mention.name": {
146
- value: "Mention",
147
- description: "Mention template display name"
148
- },
149
- "template.mention.description": {
150
- value: "Envoyé lorsqu'un utilisateur est mentionné.",
151
- description: "Mention template description"
152
- },
153
- "channel.webhook.noUrl": {
154
- value: "Aucune URL de webhook configurée",
155
- description: "Error when webhook channel has no URL"
156
- }
157
- }
158
- });
159
- });
160
-
161
- // src/i18n/messages.ts
162
- var exports_messages = {};
163
- __export(exports_messages, {
164
- resetI18nRegistry: () => resetI18nRegistry,
165
- getDefaultI18n: () => getDefaultI18n,
166
- createNotificationsI18n: () => createNotificationsI18n
167
- });
168
- import {
169
- createI18nFactory
170
- } from "@contractspec/lib.contracts-spec/translations";
171
- var factory, createNotificationsI18n, getDefaultI18n, resetI18nRegistry;
172
- var init_messages = __esm(() => {
173
- init_en();
174
- init_es();
175
- init_fr();
176
- factory = createI18nFactory({
177
- specKey: "notifications.messages",
178
- catalogs: [enMessages, frMessages, esMessages]
179
- });
180
- createNotificationsI18n = factory.create;
181
- getDefaultI18n = factory.getDefault;
182
- resetI18nRegistry = factory.resetRegistry;
183
- });
184
-
185
- // src/channels/index.ts
186
- class InAppChannel {
187
- channelId = "IN_APP";
188
- async send(_notification) {
189
- return {
190
- success: true,
191
- responseMessage: "Stored in database"
192
- };
193
- }
194
- async isAvailable() {
195
- return true;
196
- }
197
- }
198
-
199
- class ConsoleChannel {
200
- channelId = "CONSOLE";
201
- async send(notification) {
202
- console.log(`\uD83D\uDCEC [${notification.id}] ${notification.title}`);
203
- console.log(` ${notification.body}`);
204
- if (notification.actionUrl) {
205
- console.log(` Action: ${notification.actionUrl}`);
206
- }
207
- return {
208
- success: true,
209
- responseMessage: "Logged to console"
210
- };
211
- }
212
- async isAvailable() {
213
- return true;
214
- }
215
- }
216
-
217
- class EmailChannel {
218
- channelId = "EMAIL";
219
- async isAvailable() {
220
- return true;
221
- }
222
- }
223
-
224
- class PushChannel {
225
- channelId = "PUSH";
226
- async isAvailable() {
227
- return true;
228
- }
229
- }
230
-
231
- class WebhookChannel {
232
- channelId = "WEBHOOK";
233
- locale;
234
- constructor(options) {
235
- this.locale = options?.locale;
236
- }
237
- async send(notification) {
238
- if (!notification.webhook?.url) {
239
- const { createNotificationsI18n: createNotificationsI18n2 } = await Promise.resolve().then(() => (init_messages(), exports_messages));
240
- const i18n = createNotificationsI18n2(this.locale);
241
- return {
242
- success: false,
243
- responseMessage: i18n.t("channel.webhook.noUrl")
244
- };
245
- }
246
- try {
247
- const response = await fetch(notification.webhook.url, {
248
- method: "POST",
249
- headers: {
250
- "Content-Type": "application/json",
251
- ...notification.webhook.headers
252
- },
253
- body: JSON.stringify({
254
- id: notification.id,
255
- title: notification.title,
256
- body: notification.body,
257
- actionUrl: notification.actionUrl,
258
- metadata: notification.metadata
259
- })
260
- });
261
- return {
262
- success: response.ok,
263
- responseCode: String(response.status),
264
- responseMessage: response.statusText
265
- };
266
- } catch (error) {
267
- return {
268
- success: false,
269
- responseMessage: error instanceof Error ? error.message : "Unknown error"
270
- };
271
- }
272
- }
273
- async isAvailable() {
274
- return true;
275
- }
276
- }
277
-
278
- class ChannelRegistry {
279
- channels = new Map;
280
- register(channel) {
281
- this.channels.set(channel.channelId, channel);
282
- }
283
- get(channelId) {
284
- return this.channels.get(channelId);
285
- }
286
- getAll() {
287
- return Array.from(this.channels.values());
288
- }
289
- async getAvailable() {
290
- const available = [];
291
- for (const channel of this.channels.values()) {
292
- if (await channel.isAvailable()) {
293
- available.push(channel);
294
- }
295
- }
296
- return available;
297
- }
298
- }
299
- function createChannelRegistry() {
300
- const registry = new ChannelRegistry;
301
- registry.register(new InAppChannel);
302
- registry.register(new ConsoleChannel);
303
- registry.register(new WebhookChannel);
304
- return registry;
305
- }
306
- export {
307
- createChannelRegistry,
308
- WebhookChannel,
309
- PushChannel,
310
- InAppChannel,
311
- EmailChannel,
312
- ConsoleChannel,
313
- ChannelRegistry
314
- };
1
+ var V=Object.defineProperty;var X=(j)=>j;function Y(j,q){this[j]=X.bind(null,q)}var Z=(j,q)=>{for(var x in q)V(j,x,{get:q[x],enumerable:!0,configurable:!0,set:Y.bind(q,x)})};var z=(j,q)=>()=>(j&&(q=j(j=0)),q);import{defineTranslation as _}from"@contractspec/lib.contracts-spec/translations";var D;var E=z(()=>{D=_({meta:{key:"notifications.messages",version:"1.0.0",domain:"notifications",description:"Template and channel strings for the notifications module",owners:["platform"],stability:"experimental"},locale:"en",fallback:"en",messages:{"template.welcome.name":{value:"Welcome",description:"Welcome template display name"},"template.welcome.description":{value:"Sent when a user signs up.",description:"Welcome template description"},"template.orgInvite.name":{value:"Organization Invitation",description:"Org invite template display name"},"template.orgInvite.description":{value:"Sent when a user is invited to an organization.",description:"Org invite template description"},"template.mention.name":{value:"Mention",description:"Mention template display name"},"template.mention.description":{value:"Sent when a user is mentioned.",description:"Mention template description"},"channel.webhook.noUrl":{value:"No webhook URL configured",description:"Error when webhook channel has no URL"}}})});import{defineTranslation as $}from"@contractspec/lib.contracts-spec/translations";var G;var H=z(()=>{G=$({meta:{key:"notifications.messages",version:"1.0.0",domain:"notifications",description:"Template and channel strings (Spanish)",owners:["platform"],stability:"experimental"},locale:"es",fallback:"en",messages:{"template.welcome.name":{value:"Bienvenida",description:"Welcome template display name"},"template.welcome.description":{value:"Enviado cuando un usuario se registra.",description:"Welcome template description"},"template.orgInvite.name":{value:"Invitación a la organización",description:"Org invite template display name"},"template.orgInvite.description":{value:"Enviado cuando un usuario es invitado a una organización.",description:"Org invite template description"},"template.mention.name":{value:"Mención",description:"Mention template display name"},"template.mention.description":{value:"Enviado cuando un usuario es mencionado.",description:"Mention template description"},"channel.webhook.noUrl":{value:"No se ha configurado una URL de webhook",description:"Error when webhook channel has no URL"}}})});import{defineTranslation as m}from"@contractspec/lib.contracts-spec/translations";var J;var K=z(()=>{J=m({meta:{key:"notifications.messages",version:"1.0.0",domain:"notifications",description:"Template and channel strings (French)",owners:["platform"],stability:"experimental"},locale:"fr",fallback:"en",messages:{"template.welcome.name":{value:"Bienvenue",description:"Welcome template display name"},"template.welcome.description":{value:"Envoyé lorsqu'un utilisateur s'inscrit.",description:"Welcome template description"},"template.orgInvite.name":{value:"Invitation à l'organisation",description:"Org invite template display name"},"template.orgInvite.description":{value:"Envoyé lorsqu'un utilisateur est invité à une organisation.",description:"Org invite template description"},"template.mention.name":{value:"Mention",description:"Mention template display name"},"template.mention.description":{value:"Envoyé lorsqu'un utilisateur est mentionné.",description:"Mention template description"},"channel.webhook.noUrl":{value:"Aucune URL de webhook configurée",description:"Error when webhook channel has no URL"}}})});var L={};Z(L,{resetI18nRegistry:()=>N,getDefaultI18n:()=>F,createNotificationsI18n:()=>w});import{createI18nFactory as u}from"@contractspec/lib.contracts-spec/translations";var B,w,F,N;var O=z(()=>{E();H();K();B=u({specKey:"notifications.messages",catalogs:[D,J,G]}),w=B.create,F=B.getDefault,N=B.resetRegistry});class P{channelId="IN_APP";async send(j){return{success:!0,responseMessage:"Stored in database"}}async isAvailable(){return!0}}class Q{channelId="CONSOLE";async send(j){if(console.log(`\uD83D\uDCEC [${j.id}] ${j.title}`),console.log(` ${j.body}`),j.actionUrl)console.log(` Action: ${j.actionUrl}`);return{success:!0,responseMessage:"Logged to console"}}async isAvailable(){return!0}}class k{channelId="EMAIL";async isAvailable(){return!0}}class v{channelId="PUSH";async isAvailable(){return!0}}class S{channelId="WEBHOOK";locale;constructor(j){this.locale=j?.locale}async send(j){if(!j.webhook?.url){let{createNotificationsI18n:q}=await Promise.resolve().then(() => (O(),L));return{success:!1,responseMessage:q(this.locale).t("channel.webhook.noUrl")}}try{let q=await fetch(j.webhook.url,{method:"POST",headers:{"Content-Type":"application/json",...j.webhook.headers},body:JSON.stringify({id:j.id,title:j.title,body:j.body,actionUrl:j.actionUrl,metadata:j.metadata})});return{success:q.ok,responseCode:String(q.status),responseMessage:q.statusText}}catch(q){return{success:!1,responseMessage:q instanceof Error?q.message:"Unknown error"}}}async isAvailable(){return!0}}class U{channels=new Map;register(j){this.channels.set(j.channelId,j)}get(j){return this.channels.get(j)}getAll(){return Array.from(this.channels.values())}async getAvailable(){let j=[];for(let q of this.channels.values())if(await q.isAvailable())j.push(q);return j}}function p(){let j=new U;return j.register(new P),j.register(new Q),j.register(new S),j}export{p as createChannelRegistry,S as WebhookChannel,v as PushChannel,P as InAppChannel,k as EmailChannel,Q as ConsoleChannel,U as ChannelRegistry};
@@ -1,356 +1 @@
1
- var __defProp = Object.defineProperty;
2
- var __returnValue = (v) => v;
3
- function __exportSetter(name, newValue) {
4
- this[name] = __returnValue.bind(null, newValue);
5
- }
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true,
11
- configurable: true,
12
- set: __exportSetter.bind(all, name)
13
- });
14
- };
15
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
16
-
17
- // src/contracts/index.ts
18
- import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
19
- import {
20
- defineEnum,
21
- defineSchemaModel,
22
- ScalarTypeEnum
23
- } from "@contractspec/lib.schema";
24
- var OWNERS = ["platform.notifications"];
25
- var NotificationStatusSchemaEnum = defineEnum("NotificationStatus", [
26
- "PENDING",
27
- "SENT",
28
- "DELIVERED",
29
- "READ",
30
- "FAILED",
31
- "CANCELLED"
32
- ]);
33
- var NotificationChannelSchemaEnum = defineEnum("NotificationChannel", [
34
- "EMAIL",
35
- "IN_APP",
36
- "PUSH",
37
- "WEBHOOK"
38
- ]);
39
- var NotificationFilterEnum = defineEnum("NotificationFilter", [
40
- "unread",
41
- "read",
42
- "all"
43
- ]);
44
- var NotificationModel = defineSchemaModel({
45
- name: "Notification",
46
- description: "A notification sent to a user",
47
- fields: {
48
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
49
- userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
50
- title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
51
- body: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
52
- type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
53
- status: { type: NotificationStatusSchemaEnum, isOptional: false },
54
- channels: {
55
- type: NotificationChannelSchemaEnum,
56
- isArray: true,
57
- isOptional: false
58
- },
59
- actionUrl: { type: ScalarTypeEnum.URL(), isOptional: true },
60
- readAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
61
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
62
- }
63
- });
64
- var NotificationPreferenceModel = defineSchemaModel({
65
- name: "NotificationPreference",
66
- description: "User notification preferences",
67
- fields: {
68
- userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
69
- globalEnabled: { type: ScalarTypeEnum.Boolean(), isOptional: false },
70
- channelPreferences: {
71
- type: ScalarTypeEnum.JSONObject(),
72
- isOptional: false
73
- },
74
- typePreferences: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
75
- quietHoursStart: {
76
- type: ScalarTypeEnum.String_unsecure(),
77
- isOptional: true
78
- },
79
- quietHoursEnd: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
80
- timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
81
- digestEnabled: { type: ScalarTypeEnum.Boolean(), isOptional: false },
82
- digestFrequency: {
83
- type: ScalarTypeEnum.String_unsecure(),
84
- isOptional: true
85
- }
86
- }
87
- });
88
- var SendNotificationInputModel = defineSchemaModel({
89
- name: "SendNotificationInput",
90
- description: "Input for sending a notification",
91
- fields: {
92
- userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
93
- templateId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
94
- title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
95
- body: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
96
- type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
97
- channels: {
98
- type: NotificationChannelSchemaEnum,
99
- isArray: true,
100
- isOptional: true
101
- },
102
- actionUrl: { type: ScalarTypeEnum.URL(), isOptional: true },
103
- variables: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
104
- metadata: { type: ScalarTypeEnum.JSONObject(), isOptional: true }
105
- }
106
- });
107
- var ListNotificationsInputModel = defineSchemaModel({
108
- name: "ListNotificationsInput",
109
- description: "Input for listing notifications",
110
- fields: {
111
- status: { type: NotificationFilterEnum, isOptional: true },
112
- type: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
113
- limit: {
114
- type: ScalarTypeEnum.Int_unsecure(),
115
- isOptional: true,
116
- defaultValue: 20
117
- },
118
- offset: {
119
- type: ScalarTypeEnum.Int_unsecure(),
120
- isOptional: true,
121
- defaultValue: 0
122
- }
123
- }
124
- });
125
- var ListNotificationsOutputModel = defineSchemaModel({
126
- name: "ListNotificationsOutput",
127
- description: "Output for listing notifications",
128
- fields: {
129
- notifications: {
130
- type: NotificationModel,
131
- isArray: true,
132
- isOptional: false
133
- },
134
- total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
135
- unreadCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
136
- }
137
- });
138
- var UpdatePreferencesInputModel = defineSchemaModel({
139
- name: "UpdateNotificationPreferencesInput",
140
- description: "Input for updating notification preferences",
141
- fields: {
142
- globalEnabled: { type: ScalarTypeEnum.Boolean(), isOptional: true },
143
- channelPreferences: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
144
- typePreferences: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
145
- quietHoursStart: {
146
- type: ScalarTypeEnum.String_unsecure(),
147
- isOptional: true
148
- },
149
- quietHoursEnd: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
150
- timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
151
- digestEnabled: { type: ScalarTypeEnum.Boolean(), isOptional: true },
152
- digestFrequency: {
153
- type: ScalarTypeEnum.String_unsecure(),
154
- isOptional: true
155
- }
156
- }
157
- });
158
- var SendNotificationContract = defineCommand({
159
- meta: {
160
- key: "notifications.send",
161
- version: "1.0.0",
162
- stability: "stable",
163
- owners: [...OWNERS],
164
- tags: ["notifications", "send"],
165
- description: "Send a notification to a user.",
166
- goal: "Deliver notifications across multiple channels.",
167
- context: "Called by services when events require user notification."
168
- },
169
- io: {
170
- input: SendNotificationInputModel,
171
- output: NotificationModel,
172
- errors: {
173
- USER_NOT_FOUND: {
174
- description: "Target user does not exist",
175
- http: 404,
176
- gqlCode: "USER_NOT_FOUND",
177
- when: "User ID is invalid"
178
- },
179
- TEMPLATE_NOT_FOUND: {
180
- description: "Notification template does not exist",
181
- http: 404,
182
- gqlCode: "TEMPLATE_NOT_FOUND",
183
- when: "Template ID is invalid"
184
- }
185
- }
186
- },
187
- policy: {
188
- auth: "user"
189
- },
190
- sideEffects: {
191
- emits: [
192
- {
193
- key: "notification.sent",
194
- version: "1.0.0",
195
- when: "Notification is sent",
196
- payload: NotificationModel
197
- }
198
- ]
199
- }
200
- });
201
- var ListNotificationsContract = defineQuery({
202
- meta: {
203
- key: "notifications.list",
204
- version: "1.0.0",
205
- stability: "stable",
206
- owners: [...OWNERS],
207
- tags: ["notifications", "list"],
208
- description: "List notifications for the current user.",
209
- goal: "Show user their notifications.",
210
- context: "Notification center UI."
211
- },
212
- io: {
213
- input: ListNotificationsInputModel,
214
- output: ListNotificationsOutputModel
215
- },
216
- policy: {
217
- auth: "user"
218
- }
219
- });
220
- var MarkNotificationReadContract = defineCommand({
221
- meta: {
222
- key: "notifications.markRead",
223
- version: "1.0.0",
224
- stability: "stable",
225
- owners: [...OWNERS],
226
- tags: ["notifications", "read"],
227
- description: "Mark a notification as read.",
228
- goal: "Track which notifications user has seen.",
229
- context: "User clicks on a notification."
230
- },
231
- io: {
232
- input: defineSchemaModel({
233
- name: "MarkNotificationReadInput",
234
- fields: {
235
- notificationId: {
236
- type: ScalarTypeEnum.String_unsecure(),
237
- isOptional: false
238
- }
239
- }
240
- }),
241
- output: NotificationModel
242
- },
243
- policy: {
244
- auth: "user"
245
- }
246
- });
247
- var MarkAllNotificationsReadContract = defineCommand({
248
- meta: {
249
- key: "notifications.markAllRead",
250
- version: "1.0.0",
251
- stability: "stable",
252
- owners: [...OWNERS],
253
- tags: ["notifications", "read"],
254
- description: "Mark all notifications as read.",
255
- goal: "Clear notification badge.",
256
- context: 'User clicks "mark all as read".'
257
- },
258
- io: {
259
- input: null,
260
- output: defineSchemaModel({
261
- name: "MarkAllNotificationsReadOutput",
262
- fields: {
263
- markedCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
264
- }
265
- })
266
- },
267
- policy: {
268
- auth: "user"
269
- }
270
- });
271
- var GetNotificationPreferencesContract = defineQuery({
272
- meta: {
273
- key: "notifications.preferences.get",
274
- version: "1.0.0",
275
- stability: "stable",
276
- owners: [...OWNERS],
277
- tags: ["notifications", "preferences", "get"],
278
- description: "Get notification preferences for current user.",
279
- goal: "Show user their notification settings.",
280
- context: "Notification settings page."
281
- },
282
- io: {
283
- input: null,
284
- output: NotificationPreferenceModel
285
- },
286
- policy: {
287
- auth: "user"
288
- }
289
- });
290
- var UpdateNotificationPreferencesContract = defineCommand({
291
- meta: {
292
- key: "notifications.preferences.update",
293
- version: "1.0.0",
294
- stability: "stable",
295
- owners: [...OWNERS],
296
- tags: ["notifications", "preferences", "update"],
297
- description: "Update notification preferences.",
298
- goal: "Allow user to control notification delivery.",
299
- context: "Notification settings page."
300
- },
301
- io: {
302
- input: UpdatePreferencesInputModel,
303
- output: NotificationPreferenceModel
304
- },
305
- policy: {
306
- auth: "user"
307
- }
308
- });
309
- var DeleteNotificationContract = defineCommand({
310
- meta: {
311
- key: "notifications.delete",
312
- version: "1.0.0",
313
- stability: "stable",
314
- owners: [...OWNERS],
315
- tags: ["notifications", "delete"],
316
- description: "Delete a notification.",
317
- goal: "Allow user to remove unwanted notifications.",
318
- context: "User dismisses a notification."
319
- },
320
- io: {
321
- input: defineSchemaModel({
322
- name: "DeleteNotificationInput",
323
- fields: {
324
- notificationId: {
325
- type: ScalarTypeEnum.String_unsecure(),
326
- isOptional: false
327
- }
328
- }
329
- }),
330
- output: defineSchemaModel({
331
- name: "DeleteNotificationOutput",
332
- fields: {
333
- success: { type: ScalarTypeEnum.Boolean(), isOptional: false }
334
- }
335
- })
336
- },
337
- policy: {
338
- auth: "user"
339
- }
340
- });
341
- export {
342
- UpdatePreferencesInputModel,
343
- UpdateNotificationPreferencesContract,
344
- SendNotificationInputModel,
345
- SendNotificationContract,
346
- NotificationPreferenceModel,
347
- NotificationModel,
348
- NotificationFilterEnum,
349
- MarkNotificationReadContract,
350
- MarkAllNotificationsReadContract,
351
- ListNotificationsOutputModel,
352
- ListNotificationsInputModel,
353
- ListNotificationsContract,
354
- GetNotificationPreferencesContract,
355
- DeleteNotificationContract
356
- };
1
+ var H=Object.defineProperty;var J=(k)=>k;function K(k,q){this[k]=J.bind(null,q)}var F=(k,q)=>{for(var z in q)H(k,z,{get:q[z],enumerable:!0,configurable:!0,set:K.bind(q,z)})};var U=(k,q)=>()=>(k&&(q=k(k=0)),q);import{defineCommand as w,defineQuery as B}from"@contractspec/lib.contracts-spec";import{defineEnum as A,defineSchemaModel as j,ScalarTypeEnum as g}from"@contractspec/lib.schema";var v=["platform.notifications"],V=A("NotificationStatus",["PENDING","SENT","DELIVERED","READ","FAILED","CANCELLED"]),D=A("NotificationChannel",["EMAIL","IN_APP","PUSH","WEBHOOK"]),X=A("NotificationFilter",["unread","read","all"]),x=j({name:"Notification",description:"A notification sent to a user",fields:{id:{type:g.String_unsecure(),isOptional:!1},userId:{type:g.String_unsecure(),isOptional:!1},title:{type:g.String_unsecure(),isOptional:!1},body:{type:g.String_unsecure(),isOptional:!1},type:{type:g.String_unsecure(),isOptional:!1},status:{type:V,isOptional:!1},channels:{type:D,isArray:!0,isOptional:!1},actionUrl:{type:g.URL(),isOptional:!0},readAt:{type:g.DateTime(),isOptional:!0},createdAt:{type:g.DateTime(),isOptional:!1}}}),G=j({name:"NotificationPreference",description:"User notification preferences",fields:{userId:{type:g.String_unsecure(),isOptional:!1},globalEnabled:{type:g.Boolean(),isOptional:!1},channelPreferences:{type:g.JSONObject(),isOptional:!1},typePreferences:{type:g.JSONObject(),isOptional:!1},quietHoursStart:{type:g.String_unsecure(),isOptional:!0},quietHoursEnd:{type:g.String_unsecure(),isOptional:!0},timezone:{type:g.String_unsecure(),isOptional:!1},digestEnabled:{type:g.Boolean(),isOptional:!1},digestFrequency:{type:g.String_unsecure(),isOptional:!0}}}),Y=j({name:"SendNotificationInput",description:"Input for sending a notification",fields:{userId:{type:g.String_unsecure(),isOptional:!1},templateId:{type:g.String_unsecure(),isOptional:!0},title:{type:g.String_unsecure(),isOptional:!0},body:{type:g.String_unsecure(),isOptional:!0},type:{type:g.String_unsecure(),isOptional:!1},channels:{type:D,isArray:!0,isOptional:!0},actionUrl:{type:g.URL(),isOptional:!0},variables:{type:g.JSONObject(),isOptional:!0},metadata:{type:g.JSONObject(),isOptional:!0}}}),Z=j({name:"ListNotificationsInput",description:"Input for listing notifications",fields:{status:{type:X,isOptional:!0},type:{type:g.String_unsecure(),isOptional:!0},limit:{type:g.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:g.Int_unsecure(),isOptional:!0,defaultValue:0}}}),_=j({name:"ListNotificationsOutput",description:"Output for listing notifications",fields:{notifications:{type:x,isArray:!0,isOptional:!1},total:{type:g.Int_unsecure(),isOptional:!1},unreadCount:{type:g.Int_unsecure(),isOptional:!1}}}),$=j({name:"UpdateNotificationPreferencesInput",description:"Input for updating notification preferences",fields:{globalEnabled:{type:g.Boolean(),isOptional:!0},channelPreferences:{type:g.JSONObject(),isOptional:!0},typePreferences:{type:g.JSONObject(),isOptional:!0},quietHoursStart:{type:g.String_unsecure(),isOptional:!0},quietHoursEnd:{type:g.String_unsecure(),isOptional:!0},timezone:{type:g.String_unsecure(),isOptional:!0},digestEnabled:{type:g.Boolean(),isOptional:!0},digestFrequency:{type:g.String_unsecure(),isOptional:!0}}}),I=w({meta:{key:"notifications.send",version:"1.0.0",stability:"stable",owners:[...v],tags:["notifications","send"],description:"Send a notification to a user.",goal:"Deliver notifications across multiple channels.",context:"Called by services when events require user notification."},io:{input:Y,output:x,errors:{USER_NOT_FOUND:{description:"Target user does not exist",http:404,gqlCode:"USER_NOT_FOUND",when:"User ID is invalid"},TEMPLATE_NOT_FOUND:{description:"Notification template does not exist",http:404,gqlCode:"TEMPLATE_NOT_FOUND",when:"Template ID is invalid"}}},policy:{auth:"user"},sideEffects:{emits:[{key:"notification.sent",version:"1.0.0",when:"Notification is sent",payload:x}]}}),P=B({meta:{key:"notifications.list",version:"1.0.0",stability:"stable",owners:[...v],tags:["notifications","list"],description:"List notifications for the current user.",goal:"Show user their notifications.",context:"Notification center UI."},io:{input:Z,output:_},policy:{auth:"user"}}),C=w({meta:{key:"notifications.markRead",version:"1.0.0",stability:"stable",owners:[...v],tags:["notifications","read"],description:"Mark a notification as read.",goal:"Track which notifications user has seen.",context:"User clicks on a notification."},io:{input:j({name:"MarkNotificationReadInput",fields:{notificationId:{type:g.String_unsecure(),isOptional:!1}}}),output:x},policy:{auth:"user"}}),R=w({meta:{key:"notifications.markAllRead",version:"1.0.0",stability:"stable",owners:[...v],tags:["notifications","read"],description:"Mark all notifications as read.",goal:"Clear notification badge.",context:'User clicks "mark all as read".'},io:{input:null,output:j({name:"MarkAllNotificationsReadOutput",fields:{markedCount:{type:g.Int_unsecure(),isOptional:!1}}})},policy:{auth:"user"}}),W=B({meta:{key:"notifications.preferences.get",version:"1.0.0",stability:"stable",owners:[...v],tags:["notifications","preferences","get"],description:"Get notification preferences for current user.",goal:"Show user their notification settings.",context:"Notification settings page."},io:{input:null,output:G},policy:{auth:"user"}}),O=w({meta:{key:"notifications.preferences.update",version:"1.0.0",stability:"stable",owners:[...v],tags:["notifications","preferences","update"],description:"Update notification preferences.",goal:"Allow user to control notification delivery.",context:"Notification settings page."},io:{input:$,output:G},policy:{auth:"user"}}),s=w({meta:{key:"notifications.delete",version:"1.0.0",stability:"stable",owners:[...v],tags:["notifications","delete"],description:"Delete a notification.",goal:"Allow user to remove unwanted notifications.",context:"User dismisses a notification."},io:{input:j({name:"DeleteNotificationInput",fields:{notificationId:{type:g.String_unsecure(),isOptional:!1}}}),output:j({name:"DeleteNotificationOutput",fields:{success:{type:g.Boolean(),isOptional:!1}}})},policy:{auth:"user"}});export{$ as UpdatePreferencesInputModel,O as UpdateNotificationPreferencesContract,Y as SendNotificationInputModel,I as SendNotificationContract,G as NotificationPreferenceModel,x as NotificationModel,X as NotificationFilterEnum,C as MarkNotificationReadContract,R as MarkAllNotificationsReadContract,_ as ListNotificationsOutputModel,Z as ListNotificationsInputModel,P as ListNotificationsContract,W as GetNotificationPreferencesContract,s as DeleteNotificationContract};