@contractspec/module.notifications 2.4.0 → 2.5.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 (57) hide show
  1. package/dist/browser/channels/index.js +187 -1
  2. package/dist/browser/contracts/index.js +12 -0
  3. package/dist/browser/entities/index.js +12 -0
  4. package/dist/browser/i18n/catalogs/en.js +64 -0
  5. package/dist/browser/i18n/catalogs/es.js +64 -0
  6. package/dist/browser/i18n/catalogs/fr.js +64 -0
  7. package/dist/browser/i18n/catalogs/index.js +165 -0
  8. package/dist/browser/i18n/index.js +225 -0
  9. package/dist/browser/i18n/keys.js +33 -0
  10. package/dist/browser/i18n/locale.js +25 -0
  11. package/dist/browser/i18n/messages.js +186 -0
  12. package/dist/browser/index.js +279 -3
  13. package/dist/browser/notifications.capability.js +12 -0
  14. package/dist/browser/notifications.feature.js +12 -0
  15. package/dist/browser/templates/index.js +104 -2
  16. package/dist/channels/index.d.ts +4 -0
  17. package/dist/channels/index.js +187 -1
  18. package/dist/contracts/index.js +12 -0
  19. package/dist/entities/index.js +12 -0
  20. package/dist/i18n/catalogs/en.d.ts +6 -0
  21. package/dist/i18n/catalogs/en.js +65 -0
  22. package/dist/i18n/catalogs/es.d.ts +6 -0
  23. package/dist/i18n/catalogs/es.js +65 -0
  24. package/dist/i18n/catalogs/fr.d.ts +6 -0
  25. package/dist/i18n/catalogs/fr.js +65 -0
  26. package/dist/i18n/catalogs/index.d.ts +8 -0
  27. package/dist/i18n/catalogs/index.js +166 -0
  28. package/dist/i18n/i18n.test.d.ts +1 -0
  29. package/dist/i18n/index.d.ts +14 -0
  30. package/dist/i18n/index.js +226 -0
  31. package/dist/i18n/keys.d.ts +29 -0
  32. package/dist/i18n/keys.js +34 -0
  33. package/dist/i18n/locale.d.ts +8 -0
  34. package/dist/i18n/locale.js +26 -0
  35. package/dist/i18n/messages.d.ts +14 -0
  36. package/dist/i18n/messages.js +187 -0
  37. package/dist/index.js +279 -3
  38. package/dist/node/channels/index.js +187 -1
  39. package/dist/node/contracts/index.js +12 -0
  40. package/dist/node/entities/index.js +12 -0
  41. package/dist/node/i18n/catalogs/en.js +64 -0
  42. package/dist/node/i18n/catalogs/es.js +64 -0
  43. package/dist/node/i18n/catalogs/fr.js +64 -0
  44. package/dist/node/i18n/catalogs/index.js +165 -0
  45. package/dist/node/i18n/index.js +225 -0
  46. package/dist/node/i18n/keys.js +33 -0
  47. package/dist/node/i18n/locale.js +25 -0
  48. package/dist/node/i18n/messages.js +186 -0
  49. package/dist/node/index.js +279 -3
  50. package/dist/node/notifications.capability.js +12 -0
  51. package/dist/node/notifications.feature.js +12 -0
  52. package/dist/node/templates/index.js +104 -2
  53. package/dist/notifications.capability.js +12 -0
  54. package/dist/notifications.feature.js +12 -0
  55. package/dist/templates/index.d.ts +17 -7
  56. package/dist/templates/index.js +104 -2
  57. package/package.json +147 -6
@@ -1,4 +1,16 @@
1
1
  // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true,
8
+ configurable: true,
9
+ set: (newValue) => all[name] = () => newValue
10
+ });
11
+ };
12
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
13
+
2
14
  // src/templates/index.ts
3
15
  function defineTemplate(def) {
4
16
  return def;
@@ -12,8 +24,8 @@ function renderTemplate(content, variables) {
12
24
  return String(value);
13
25
  });
14
26
  }
15
- function renderNotificationTemplate(template, channel, variables) {
16
- const channelContent = template.channels[channel];
27
+ function renderNotificationTemplate(template, channel, variables, locale) {
28
+ const channelContent = (locale && template.localeChannels?.[locale]?.[channel]) ?? template.channels[channel];
17
29
  if (!channelContent) {
18
30
  return null;
19
31
  }
@@ -81,6 +93,38 @@ var WelcomeTemplate = defineTemplate({
81
93
  body: "Thanks for joining. Click to complete your profile.",
82
94
  actionUrl: "{{actionUrl}}"
83
95
  }
96
+ },
97
+ localeChannels: {
98
+ fr: {
99
+ email: {
100
+ subject: "Bienvenue sur {{appName}}, {{name}}\u202F!",
101
+ body: `
102
+ <h1>Bienvenue, {{name}}\u202F!</h1>
103
+ <p>Merci d\u2019avoir rejoint {{appName}}. Nous sommes ravis de vous compter parmi nous.</p>
104
+ <p><a href="{{actionUrl}}">Commencer maintenant</a></p>
105
+ `
106
+ },
107
+ inApp: {
108
+ title: "Bienvenue sur {{appName}}\u202F!",
109
+ body: "Merci de nous avoir rejoint. Cliquez pour compl\xE9ter votre profil.",
110
+ actionUrl: "{{actionUrl}}"
111
+ }
112
+ },
113
+ es: {
114
+ email: {
115
+ subject: "\xA1Bienvenido a {{appName}}, {{name}}!",
116
+ body: `
117
+ <h1>\xA1Bienvenido, {{name}}!</h1>
118
+ <p>Gracias por unirte a {{appName}}. Estamos encantados de tenerte.</p>
119
+ <p><a href="{{actionUrl}}">Comenzar ahora</a></p>
120
+ `
121
+ },
122
+ inApp: {
123
+ title: "\xA1Bienvenido a {{appName}}!",
124
+ body: "Gracias por unirte. Haz clic para completar tu perfil.",
125
+ actionUrl: "{{actionUrl}}"
126
+ }
127
+ }
84
128
  }
85
129
  });
86
130
  var OrgInviteTemplate = defineTemplate({
@@ -110,6 +154,40 @@ var OrgInviteTemplate = defineTemplate({
110
154
  actionUrl: "{{actionUrl}}",
111
155
  actionText: "Accept"
112
156
  }
157
+ },
158
+ localeChannels: {
159
+ fr: {
160
+ email: {
161
+ subject: "{{inviterName}} vous invite \xE0 rejoindre {{orgName}}",
162
+ body: `
163
+ <h1>Vous \xEAtes invit\xE9\u202F!</h1>
164
+ <p>{{inviterName}} vous a invit\xE9 \xE0 rejoindre <strong>{{orgName}}</strong> en tant que {{role}}.</p>
165
+ <p><a href="{{actionUrl}}">Accepter l\u2019invitation</a></p>
166
+ `
167
+ },
168
+ inApp: {
169
+ title: "Invitation \xE0 {{orgName}}",
170
+ body: "{{inviterName}} vous a invit\xE9 \xE0 rejoindre en tant que {{role}}.",
171
+ actionUrl: "{{actionUrl}}",
172
+ actionText: "Accepter"
173
+ }
174
+ },
175
+ es: {
176
+ email: {
177
+ subject: "{{inviterName}} te invit\xF3 a unirte a {{orgName}}",
178
+ body: `
179
+ <h1>\xA1Has sido invitado!</h1>
180
+ <p>{{inviterName}} te ha invitado a unirte a <strong>{{orgName}}</strong> como {{role}}.</p>
181
+ <p><a href="{{actionUrl}}">Aceptar invitaci\xF3n</a></p>
182
+ `
183
+ },
184
+ inApp: {
185
+ title: "Invitaci\xF3n a {{orgName}}",
186
+ body: "{{inviterName}} te invit\xF3 a unirte como {{role}}.",
187
+ actionUrl: "{{actionUrl}}",
188
+ actionText: "Aceptar"
189
+ }
190
+ }
113
191
  }
114
192
  });
115
193
  var MentionTemplate = defineTemplate({
@@ -134,6 +212,30 @@ var MentionTemplate = defineTemplate({
134
212
  title: "{{mentionerName}} mentioned you",
135
213
  body: "{{preview}}"
136
214
  }
215
+ },
216
+ localeChannels: {
217
+ fr: {
218
+ inApp: {
219
+ title: "{{mentionerName}} vous a mentionn\xE9",
220
+ body: "Dans {{context}}\u202F: \xAB\u202F{{preview}}\u202F\xBB",
221
+ actionUrl: "{{actionUrl}}"
222
+ },
223
+ push: {
224
+ title: "{{mentionerName}} vous a mentionn\xE9",
225
+ body: "{{preview}}"
226
+ }
227
+ },
228
+ es: {
229
+ inApp: {
230
+ title: "{{mentionerName}} te mencion\xF3",
231
+ body: 'En {{context}}: "{{preview}}"',
232
+ actionUrl: "{{actionUrl}}"
233
+ },
234
+ push: {
235
+ title: "{{mentionerName}} te mencion\xF3",
236
+ body: "{{preview}}"
237
+ }
238
+ }
137
239
  }
138
240
  });
139
241
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/module.notifications",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Notification center module for ContractSpec applications",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -23,19 +23,20 @@
23
23
  "lint": "bun lint:fix",
24
24
  "lint:fix": "eslint src --fix",
25
25
  "lint:check": "eslint src",
26
+ "test": "bun test",
26
27
  "prebuild": "contractspec-bun-build prebuild",
27
28
  "typecheck": "tsc --noEmit"
28
29
  },
29
30
  "dependencies": {
30
- "@contractspec/lib.schema": "2.4.0",
31
- "@contractspec/lib.contracts-spec": "2.4.0",
32
- "@contractspec/lib.bus": "2.4.0",
31
+ "@contractspec/lib.schema": "2.5.0",
32
+ "@contractspec/lib.contracts-spec": "2.5.0",
33
+ "@contractspec/lib.bus": "2.5.0",
33
34
  "zod": "^4.3.5"
34
35
  },
35
36
  "devDependencies": {
36
- "@contractspec/tool.typescript": "2.4.0",
37
+ "@contractspec/tool.typescript": "2.5.0",
37
38
  "typescript": "^5.9.3",
38
- "@contractspec/tool.bun": "2.4.0"
39
+ "@contractspec/tool.bun": "2.5.0"
39
40
  },
40
41
  "exports": {
41
42
  ".": {
@@ -87,6 +88,76 @@
87
88
  "browser": "./dist/browser/entities/index.js",
88
89
  "default": "./dist/entities/index.js"
89
90
  },
91
+ "./i18n": {
92
+ "types": "./dist/i18n/index.d.ts",
93
+ "bun": "./dist/i18n/index.js",
94
+ "node": "./dist/node/i18n/index.js",
95
+ "browser": "./dist/browser/i18n/index.js",
96
+ "default": "./dist/i18n/index.js"
97
+ },
98
+ "./i18n/catalogs": {
99
+ "types": "./dist/i18n/catalogs/index.d.ts",
100
+ "bun": "./dist/i18n/catalogs/index.js",
101
+ "node": "./dist/node/i18n/catalogs/index.js",
102
+ "browser": "./dist/browser/i18n/catalogs/index.js",
103
+ "default": "./dist/i18n/catalogs/index.js"
104
+ },
105
+ "./i18n/catalogs/en": {
106
+ "types": "./dist/i18n/catalogs/en.d.ts",
107
+ "bun": "./dist/i18n/catalogs/en.js",
108
+ "node": "./dist/node/i18n/catalogs/en.js",
109
+ "browser": "./dist/browser/i18n/catalogs/en.js",
110
+ "default": "./dist/i18n/catalogs/en.js"
111
+ },
112
+ "./i18n/catalogs/es": {
113
+ "types": "./dist/i18n/catalogs/es.d.ts",
114
+ "bun": "./dist/i18n/catalogs/es.js",
115
+ "node": "./dist/node/i18n/catalogs/es.js",
116
+ "browser": "./dist/browser/i18n/catalogs/es.js",
117
+ "default": "./dist/i18n/catalogs/es.js"
118
+ },
119
+ "./i18n/catalogs/fr": {
120
+ "types": "./dist/i18n/catalogs/fr.d.ts",
121
+ "bun": "./dist/i18n/catalogs/fr.js",
122
+ "node": "./dist/node/i18n/catalogs/fr.js",
123
+ "browser": "./dist/browser/i18n/catalogs/fr.js",
124
+ "default": "./dist/i18n/catalogs/fr.js"
125
+ },
126
+ "./i18n/catalogs/index": {
127
+ "types": "./dist/i18n/catalogs/index.d.ts",
128
+ "bun": "./dist/i18n/catalogs/index.js",
129
+ "node": "./dist/node/i18n/catalogs/index.js",
130
+ "browser": "./dist/browser/i18n/catalogs/index.js",
131
+ "default": "./dist/i18n/catalogs/index.js"
132
+ },
133
+ "./i18n/index": {
134
+ "types": "./dist/i18n/index.d.ts",
135
+ "bun": "./dist/i18n/index.js",
136
+ "node": "./dist/node/i18n/index.js",
137
+ "browser": "./dist/browser/i18n/index.js",
138
+ "default": "./dist/i18n/index.js"
139
+ },
140
+ "./i18n/keys": {
141
+ "types": "./dist/i18n/keys.d.ts",
142
+ "bun": "./dist/i18n/keys.js",
143
+ "node": "./dist/node/i18n/keys.js",
144
+ "browser": "./dist/browser/i18n/keys.js",
145
+ "default": "./dist/i18n/keys.js"
146
+ },
147
+ "./i18n/locale": {
148
+ "types": "./dist/i18n/locale.d.ts",
149
+ "bun": "./dist/i18n/locale.js",
150
+ "node": "./dist/node/i18n/locale.js",
151
+ "browser": "./dist/browser/i18n/locale.js",
152
+ "default": "./dist/i18n/locale.js"
153
+ },
154
+ "./i18n/messages": {
155
+ "types": "./dist/i18n/messages.d.ts",
156
+ "bun": "./dist/i18n/messages.js",
157
+ "node": "./dist/node/i18n/messages.js",
158
+ "browser": "./dist/browser/i18n/messages.js",
159
+ "default": "./dist/i18n/messages.js"
160
+ },
90
161
  "./notifications.capability": {
91
162
  "types": "./dist/notifications.capability.d.ts",
92
163
  "bun": "./dist/notifications.capability.js",
@@ -172,6 +243,76 @@
172
243
  "browser": "./dist/browser/entities/index.js",
173
244
  "default": "./dist/entities/index.js"
174
245
  },
246
+ "./i18n": {
247
+ "types": "./dist/i18n/index.d.ts",
248
+ "bun": "./dist/i18n/index.js",
249
+ "node": "./dist/node/i18n/index.js",
250
+ "browser": "./dist/browser/i18n/index.js",
251
+ "default": "./dist/i18n/index.js"
252
+ },
253
+ "./i18n/catalogs": {
254
+ "types": "./dist/i18n/catalogs/index.d.ts",
255
+ "bun": "./dist/i18n/catalogs/index.js",
256
+ "node": "./dist/node/i18n/catalogs/index.js",
257
+ "browser": "./dist/browser/i18n/catalogs/index.js",
258
+ "default": "./dist/i18n/catalogs/index.js"
259
+ },
260
+ "./i18n/catalogs/en": {
261
+ "types": "./dist/i18n/catalogs/en.d.ts",
262
+ "bun": "./dist/i18n/catalogs/en.js",
263
+ "node": "./dist/node/i18n/catalogs/en.js",
264
+ "browser": "./dist/browser/i18n/catalogs/en.js",
265
+ "default": "./dist/i18n/catalogs/en.js"
266
+ },
267
+ "./i18n/catalogs/es": {
268
+ "types": "./dist/i18n/catalogs/es.d.ts",
269
+ "bun": "./dist/i18n/catalogs/es.js",
270
+ "node": "./dist/node/i18n/catalogs/es.js",
271
+ "browser": "./dist/browser/i18n/catalogs/es.js",
272
+ "default": "./dist/i18n/catalogs/es.js"
273
+ },
274
+ "./i18n/catalogs/fr": {
275
+ "types": "./dist/i18n/catalogs/fr.d.ts",
276
+ "bun": "./dist/i18n/catalogs/fr.js",
277
+ "node": "./dist/node/i18n/catalogs/fr.js",
278
+ "browser": "./dist/browser/i18n/catalogs/fr.js",
279
+ "default": "./dist/i18n/catalogs/fr.js"
280
+ },
281
+ "./i18n/catalogs/index": {
282
+ "types": "./dist/i18n/catalogs/index.d.ts",
283
+ "bun": "./dist/i18n/catalogs/index.js",
284
+ "node": "./dist/node/i18n/catalogs/index.js",
285
+ "browser": "./dist/browser/i18n/catalogs/index.js",
286
+ "default": "./dist/i18n/catalogs/index.js"
287
+ },
288
+ "./i18n/index": {
289
+ "types": "./dist/i18n/index.d.ts",
290
+ "bun": "./dist/i18n/index.js",
291
+ "node": "./dist/node/i18n/index.js",
292
+ "browser": "./dist/browser/i18n/index.js",
293
+ "default": "./dist/i18n/index.js"
294
+ },
295
+ "./i18n/keys": {
296
+ "types": "./dist/i18n/keys.d.ts",
297
+ "bun": "./dist/i18n/keys.js",
298
+ "node": "./dist/node/i18n/keys.js",
299
+ "browser": "./dist/browser/i18n/keys.js",
300
+ "default": "./dist/i18n/keys.js"
301
+ },
302
+ "./i18n/locale": {
303
+ "types": "./dist/i18n/locale.d.ts",
304
+ "bun": "./dist/i18n/locale.js",
305
+ "node": "./dist/node/i18n/locale.js",
306
+ "browser": "./dist/browser/i18n/locale.js",
307
+ "default": "./dist/i18n/locale.js"
308
+ },
309
+ "./i18n/messages": {
310
+ "types": "./dist/i18n/messages.d.ts",
311
+ "bun": "./dist/i18n/messages.js",
312
+ "node": "./dist/node/i18n/messages.js",
313
+ "browser": "./dist/browser/i18n/messages.js",
314
+ "default": "./dist/i18n/messages.js"
315
+ },
175
316
  "./notifications.capability": {
176
317
  "types": "./dist/notifications.capability.d.ts",
177
318
  "bun": "./dist/notifications.capability.js",