@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.
- package/dist/browser/channels/index.js +1 -314
- package/dist/browser/contracts/index.js +1 -356
- package/dist/browser/entities/index.js +1 -239
- package/dist/browser/i18n/catalogs/en.js +1 -68
- package/dist/browser/i18n/catalogs/es.js +1 -68
- package/dist/browser/i18n/catalogs/fr.js +1 -68
- package/dist/browser/i18n/catalogs/index.js +1 -169
- package/dist/browser/i18n/index.js +1 -229
- package/dist/browser/i18n/keys.js +1 -37
- package/dist/browser/i18n/locale.js +1 -29
- package/dist/browser/i18n/messages.js +1 -190
- package/dist/browser/index.js +7 -1126
- package/dist/browser/notifications.capability.js +1 -35
- package/dist/browser/notifications.feature.js +1 -50
- package/dist/browser/templates/index.js +7 -235
- package/dist/channels/index.js +1 -314
- package/dist/contracts/index.js +1 -356
- package/dist/entities/index.js +1 -239
- package/dist/i18n/catalogs/en.js +1 -68
- package/dist/i18n/catalogs/es.js +1 -68
- package/dist/i18n/catalogs/fr.js +1 -68
- package/dist/i18n/catalogs/index.js +1 -169
- package/dist/i18n/index.js +1 -229
- package/dist/i18n/keys.js +1 -37
- package/dist/i18n/locale.js +1 -29
- package/dist/i18n/messages.js +1 -190
- package/dist/index.js +7 -1126
- package/dist/node/channels/index.js +1 -314
- package/dist/node/contracts/index.js +1 -356
- package/dist/node/entities/index.js +1 -239
- package/dist/node/i18n/catalogs/en.js +1 -68
- package/dist/node/i18n/catalogs/es.js +1 -68
- package/dist/node/i18n/catalogs/fr.js +1 -68
- package/dist/node/i18n/catalogs/index.js +1 -169
- package/dist/node/i18n/index.js +1 -229
- package/dist/node/i18n/keys.js +1 -37
- package/dist/node/i18n/locale.js +1 -29
- package/dist/node/i18n/messages.js +1 -190
- package/dist/node/index.js +7 -1126
- package/dist/node/notifications.capability.js +1 -35
- package/dist/node/notifications.feature.js +1 -50
- package/dist/node/templates/index.js +7 -235
- package/dist/notifications.capability.js +1 -35
- package/dist/notifications.feature.js +1 -50
- package/dist/templates/index.js +7 -235
- package/package.json +8 -8
package/dist/templates/index.js
CHANGED
|
@@ -1,254 +1,26 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
|
|
18
|
-
// src/templates/index.ts
|
|
19
|
-
function defineTemplate(def) {
|
|
20
|
-
return def;
|
|
21
|
-
}
|
|
22
|
-
function renderTemplate(content, variables) {
|
|
23
|
-
return content.replace(/\{\{(\w+)\}\}/g, (match, key) => {
|
|
24
|
-
const value = variables[key];
|
|
25
|
-
if (value === undefined || value === null) {
|
|
26
|
-
return match;
|
|
27
|
-
}
|
|
28
|
-
return String(value);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function renderNotificationTemplate(template, channel, variables, locale) {
|
|
32
|
-
const channelContent = (locale && template.localeChannels?.[locale]?.[channel]) ?? template.channels[channel];
|
|
33
|
-
if (!channelContent) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
const title = channelContent.title ? renderTemplate(channelContent.title, variables) : template.name;
|
|
37
|
-
const body = renderTemplate(channelContent.body, variables);
|
|
38
|
-
const actionUrl = channelContent.actionUrl ? renderTemplate(channelContent.actionUrl, variables) : undefined;
|
|
39
|
-
const result = {
|
|
40
|
-
title,
|
|
41
|
-
body,
|
|
42
|
-
actionUrl
|
|
43
|
-
};
|
|
44
|
-
if (channel === "email" && channelContent.subject) {
|
|
45
|
-
result.email = {
|
|
46
|
-
subject: renderTemplate(channelContent.subject, variables),
|
|
47
|
-
html: body,
|
|
48
|
-
text: stripHtml(body)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
function stripHtml(html) {
|
|
54
|
-
return html.replace(/<[^>]*>/g, "").replace(/\s+/g, " ").trim();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
class TemplateRegistry {
|
|
58
|
-
templates = new Map;
|
|
59
|
-
register(template) {
|
|
60
|
-
this.templates.set(template.id, template);
|
|
61
|
-
}
|
|
62
|
-
get(templateId) {
|
|
63
|
-
return this.templates.get(templateId);
|
|
64
|
-
}
|
|
65
|
-
getAll() {
|
|
66
|
-
return Array.from(this.templates.values());
|
|
67
|
-
}
|
|
68
|
-
getByCategory(category) {
|
|
69
|
-
return this.getAll().filter((t) => t.category === category);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function createTemplateRegistry() {
|
|
73
|
-
return new TemplateRegistry;
|
|
74
|
-
}
|
|
75
|
-
var WelcomeTemplate = defineTemplate({
|
|
76
|
-
id: "welcome",
|
|
77
|
-
name: "Welcome",
|
|
78
|
-
description: "Sent when a user signs up.",
|
|
79
|
-
category: "onboarding",
|
|
80
|
-
variables: [
|
|
81
|
-
{ name: "name", type: "string", required: true },
|
|
82
|
-
{ name: "appName", type: "string", default: "ContractSpec" },
|
|
83
|
-
{ name: "actionUrl", type: "url" }
|
|
84
|
-
],
|
|
85
|
-
defaultChannels: ["EMAIL", "IN_APP"],
|
|
86
|
-
channels: {
|
|
87
|
-
email: {
|
|
88
|
-
subject: "Welcome to {{appName}}, {{name}}!",
|
|
89
|
-
body: `
|
|
2
|
+
var L=Object.defineProperty;var N=(j)=>j;function P(j,q){this[j]=N.bind(null,q)}var S=(j,q)=>{for(var x in q)L(j,x,{get:q[x],enumerable:!0,configurable:!0,set:P.bind(q,x)})};var V=(j,q)=>()=>(j&&(q=j(j=0)),q);function E(j){return j}function B(j,q){return j.replace(/\{\{(\w+)\}\}/g,(x,A)=>{let w=q[A];if(w===void 0||w===null)return x;return String(w)})}function X(j,q,x,A){let w=(A&&j.localeChannels?.[A]?.[q])??j.channels[q];if(!w)return null;let J=w.title?B(w.title,x):j.name,D=B(w.body,x),K=w.actionUrl?B(w.actionUrl,x):void 0,F={title:J,body:D,actionUrl:K};if(q==="email"&&w.subject)F.email={subject:B(w.subject,x),html:D,text:Q(D)};return F}function Q(j){return j.replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim()}class G{templates=new Map;register(j){this.templates.set(j.id,j)}get(j){return this.templates.get(j)}getAll(){return Array.from(this.templates.values())}getByCategory(j){return this.getAll().filter((q)=>q.category===j)}}function Y(){return new G}var Z=E({id:"welcome",name:"Welcome",description:"Sent when a user signs up.",category:"onboarding",variables:[{name:"name",type:"string",required:!0},{name:"appName",type:"string",default:"ContractSpec"},{name:"actionUrl",type:"url"}],defaultChannels:["EMAIL","IN_APP"],channels:{email:{subject:"Welcome to {{appName}}, {{name}}!",body:`
|
|
90
3
|
<h1>Welcome, {{name}}!</h1>
|
|
91
4
|
<p>Thanks for joining {{appName}}. We're excited to have you on board.</p>
|
|
92
5
|
<p><a href="{{actionUrl}}">Get started now</a></p>
|
|
93
|
-
`
|
|
94
|
-
},
|
|
95
|
-
inApp: {
|
|
96
|
-
title: "Welcome to {{appName}}!",
|
|
97
|
-
body: "Thanks for joining. Click to complete your profile.",
|
|
98
|
-
actionUrl: "{{actionUrl}}"
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
localeChannels: {
|
|
102
|
-
fr: {
|
|
103
|
-
email: {
|
|
104
|
-
subject: "Bienvenue sur {{appName}}, {{name}}\u202F!",
|
|
105
|
-
body: `
|
|
6
|
+
`},inApp:{title:"Welcome to {{appName}}!",body:"Thanks for joining. Click to complete your profile.",actionUrl:"{{actionUrl}}"}},localeChannels:{fr:{email:{subject:"Bienvenue sur {{appName}}, {{name}}\u202F!",body:`
|
|
106
7
|
<h1>Bienvenue, {{name}}\u202F!</h1>
|
|
107
8
|
<p>Merci d\u2019avoir rejoint {{appName}}. Nous sommes ravis de vous compter parmi nous.</p>
|
|
108
9
|
<p><a href="{{actionUrl}}">Commencer maintenant</a></p>
|
|
109
|
-
`
|
|
110
|
-
},
|
|
111
|
-
inApp: {
|
|
112
|
-
title: "Bienvenue sur {{appName}}\u202F!",
|
|
113
|
-
body: "Merci de nous avoir rejoint. Cliquez pour compl\xE9ter votre profil.",
|
|
114
|
-
actionUrl: "{{actionUrl}}"
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
es: {
|
|
118
|
-
email: {
|
|
119
|
-
subject: "\xA1Bienvenido a {{appName}}, {{name}}!",
|
|
120
|
-
body: `
|
|
10
|
+
`},inApp:{title:"Bienvenue sur {{appName}}\u202F!",body:"Merci de nous avoir rejoint. Cliquez pour compl\xE9ter votre profil.",actionUrl:"{{actionUrl}}"}},es:{email:{subject:"\xA1Bienvenido a {{appName}}, {{name}}!",body:`
|
|
121
11
|
<h1>\xA1Bienvenido, {{name}}!</h1>
|
|
122
12
|
<p>Gracias por unirte a {{appName}}. Estamos encantados de tenerte.</p>
|
|
123
13
|
<p><a href="{{actionUrl}}">Comenzar ahora</a></p>
|
|
124
|
-
`
|
|
125
|
-
},
|
|
126
|
-
inApp: {
|
|
127
|
-
title: "\xA1Bienvenido a {{appName}}!",
|
|
128
|
-
body: "Gracias por unirte. Haz clic para completar tu perfil.",
|
|
129
|
-
actionUrl: "{{actionUrl}}"
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
var OrgInviteTemplate = defineTemplate({
|
|
135
|
-
id: "org-invite",
|
|
136
|
-
name: "Organization Invitation",
|
|
137
|
-
description: "Sent when a user is invited to an organization.",
|
|
138
|
-
category: "organization",
|
|
139
|
-
variables: [
|
|
140
|
-
{ name: "inviterName", type: "string", required: true },
|
|
141
|
-
{ name: "orgName", type: "string", required: true },
|
|
142
|
-
{ name: "role", type: "string", default: "member" },
|
|
143
|
-
{ name: "actionUrl", type: "url", required: true }
|
|
144
|
-
],
|
|
145
|
-
defaultChannels: ["EMAIL"],
|
|
146
|
-
channels: {
|
|
147
|
-
email: {
|
|
148
|
-
subject: "{{inviterName}} invited you to join {{orgName}}",
|
|
149
|
-
body: `
|
|
14
|
+
`},inApp:{title:"\xA1Bienvenido a {{appName}}!",body:"Gracias por unirte. Haz clic para completar tu perfil.",actionUrl:"{{actionUrl}}"}}}}),_=E({id:"org-invite",name:"Organization Invitation",description:"Sent when a user is invited to an organization.",category:"organization",variables:[{name:"inviterName",type:"string",required:!0},{name:"orgName",type:"string",required:!0},{name:"role",type:"string",default:"member"},{name:"actionUrl",type:"url",required:!0}],defaultChannels:["EMAIL"],channels:{email:{subject:"{{inviterName}} invited you to join {{orgName}}",body:`
|
|
150
15
|
<h1>You've been invited!</h1>
|
|
151
16
|
<p>{{inviterName}} has invited you to join <strong>{{orgName}}</strong> as a {{role}}.</p>
|
|
152
17
|
<p><a href="{{actionUrl}}">Accept invitation</a></p>
|
|
153
|
-
`
|
|
154
|
-
},
|
|
155
|
-
inApp: {
|
|
156
|
-
title: "Invitation to {{orgName}}",
|
|
157
|
-
body: "{{inviterName}} invited you to join as {{role}}.",
|
|
158
|
-
actionUrl: "{{actionUrl}}",
|
|
159
|
-
actionText: "Accept"
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
localeChannels: {
|
|
163
|
-
fr: {
|
|
164
|
-
email: {
|
|
165
|
-
subject: "{{inviterName}} vous invite \xE0 rejoindre {{orgName}}",
|
|
166
|
-
body: `
|
|
18
|
+
`},inApp:{title:"Invitation to {{orgName}}",body:"{{inviterName}} invited you to join as {{role}}.",actionUrl:"{{actionUrl}}",actionText:"Accept"}},localeChannels:{fr:{email:{subject:"{{inviterName}} vous invite \xE0 rejoindre {{orgName}}",body:`
|
|
167
19
|
<h1>Vous \xEAtes invit\xE9\u202F!</h1>
|
|
168
20
|
<p>{{inviterName}} vous a invit\xE9 \xE0 rejoindre <strong>{{orgName}}</strong> en tant que {{role}}.</p>
|
|
169
21
|
<p><a href="{{actionUrl}}">Accepter l\u2019invitation</a></p>
|
|
170
|
-
`
|
|
171
|
-
},
|
|
172
|
-
inApp: {
|
|
173
|
-
title: "Invitation \xE0 {{orgName}}",
|
|
174
|
-
body: "{{inviterName}} vous a invit\xE9 \xE0 rejoindre en tant que {{role}}.",
|
|
175
|
-
actionUrl: "{{actionUrl}}",
|
|
176
|
-
actionText: "Accepter"
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
es: {
|
|
180
|
-
email: {
|
|
181
|
-
subject: "{{inviterName}} te invit\xF3 a unirte a {{orgName}}",
|
|
182
|
-
body: `
|
|
22
|
+
`},inApp:{title:"Invitation \xE0 {{orgName}}",body:"{{inviterName}} vous a invit\xE9 \xE0 rejoindre en tant que {{role}}.",actionUrl:"{{actionUrl}}",actionText:"Accepter"}},es:{email:{subject:"{{inviterName}} te invit\xF3 a unirte a {{orgName}}",body:`
|
|
183
23
|
<h1>\xA1Has sido invitado!</h1>
|
|
184
24
|
<p>{{inviterName}} te ha invitado a unirte a <strong>{{orgName}}</strong> como {{role}}.</p>
|
|
185
25
|
<p><a href="{{actionUrl}}">Aceptar invitaci\xF3n</a></p>
|
|
186
|
-
`
|
|
187
|
-
},
|
|
188
|
-
inApp: {
|
|
189
|
-
title: "Invitaci\xF3n a {{orgName}}",
|
|
190
|
-
body: "{{inviterName}} te invit\xF3 a unirte como {{role}}.",
|
|
191
|
-
actionUrl: "{{actionUrl}}",
|
|
192
|
-
actionText: "Aceptar"
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
var MentionTemplate = defineTemplate({
|
|
198
|
-
id: "mention",
|
|
199
|
-
name: "Mention",
|
|
200
|
-
description: "Sent when a user is mentioned.",
|
|
201
|
-
category: "social",
|
|
202
|
-
variables: [
|
|
203
|
-
{ name: "mentionerName", type: "string", required: true },
|
|
204
|
-
{ name: "context", type: "string", required: true },
|
|
205
|
-
{ name: "preview", type: "string" },
|
|
206
|
-
{ name: "actionUrl", type: "url", required: true }
|
|
207
|
-
],
|
|
208
|
-
defaultChannels: ["IN_APP", "PUSH"],
|
|
209
|
-
channels: {
|
|
210
|
-
inApp: {
|
|
211
|
-
title: "{{mentionerName}} mentioned you",
|
|
212
|
-
body: 'In {{context}}: "{{preview}}"',
|
|
213
|
-
actionUrl: "{{actionUrl}}"
|
|
214
|
-
},
|
|
215
|
-
push: {
|
|
216
|
-
title: "{{mentionerName}} mentioned you",
|
|
217
|
-
body: "{{preview}}"
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
localeChannels: {
|
|
221
|
-
fr: {
|
|
222
|
-
inApp: {
|
|
223
|
-
title: "{{mentionerName}} vous a mentionn\xE9",
|
|
224
|
-
body: "Dans {{context}}\u202F: \xAB\u202F{{preview}}\u202F\xBB",
|
|
225
|
-
actionUrl: "{{actionUrl}}"
|
|
226
|
-
},
|
|
227
|
-
push: {
|
|
228
|
-
title: "{{mentionerName}} vous a mentionn\xE9",
|
|
229
|
-
body: "{{preview}}"
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
es: {
|
|
233
|
-
inApp: {
|
|
234
|
-
title: "{{mentionerName}} te mencion\xF3",
|
|
235
|
-
body: 'En {{context}}: "{{preview}}"',
|
|
236
|
-
actionUrl: "{{actionUrl}}"
|
|
237
|
-
},
|
|
238
|
-
push: {
|
|
239
|
-
title: "{{mentionerName}} te mencion\xF3",
|
|
240
|
-
body: "{{preview}}"
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
export {
|
|
246
|
-
renderTemplate,
|
|
247
|
-
renderNotificationTemplate,
|
|
248
|
-
defineTemplate,
|
|
249
|
-
createTemplateRegistry,
|
|
250
|
-
WelcomeTemplate,
|
|
251
|
-
TemplateRegistry,
|
|
252
|
-
OrgInviteTemplate,
|
|
253
|
-
MentionTemplate
|
|
254
|
-
};
|
|
26
|
+
`},inApp:{title:"Invitaci\xF3n a {{orgName}}",body:"{{inviterName}} te invit\xF3 a unirte como {{role}}.",actionUrl:"{{actionUrl}}",actionText:"Aceptar"}}}}),$=E({id:"mention",name:"Mention",description:"Sent when a user is mentioned.",category:"social",variables:[{name:"mentionerName",type:"string",required:!0},{name:"context",type:"string",required:!0},{name:"preview",type:"string"},{name:"actionUrl",type:"url",required:!0}],defaultChannels:["IN_APP","PUSH"],channels:{inApp:{title:"{{mentionerName}} mentioned you",body:'In {{context}}: "{{preview}}"',actionUrl:"{{actionUrl}}"},push:{title:"{{mentionerName}} mentioned you",body:"{{preview}}"}},localeChannels:{fr:{inApp:{title:"{{mentionerName}} vous a mentionn\xE9",body:"Dans {{context}}\u202F: \xAB\u202F{{preview}}\u202F\xBB",actionUrl:"{{actionUrl}}"},push:{title:"{{mentionerName}} vous a mentionn\xE9",body:"{{preview}}"}},es:{inApp:{title:"{{mentionerName}} te mencion\xF3",body:'En {{context}}: "{{preview}}"',actionUrl:"{{actionUrl}}"},push:{title:"{{mentionerName}} te mencion\xF3",body:"{{preview}}"}}}});export{B as renderTemplate,X as renderNotificationTemplate,E as defineTemplate,Y as createTemplateRegistry,Z as WelcomeTemplate,G as TemplateRegistry,_ as OrgInviteTemplate,$ as MentionTemplate};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/module.notifications",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.17",
|
|
4
4
|
"description": "Notification center module for ContractSpec applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -21,22 +21,22 @@
|
|
|
21
21
|
"dev": "contractspec-bun-build dev",
|
|
22
22
|
"clean": "rimraf dist .turbo",
|
|
23
23
|
"lint": "bun lint:fix",
|
|
24
|
-
"lint:fix": "biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .",
|
|
25
|
-
"lint:check": "biome check .",
|
|
24
|
+
"lint:fix": "node ../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../scripts/biome.cjs check --write .",
|
|
25
|
+
"lint:check": "node ../../../scripts/biome.cjs check .",
|
|
26
26
|
"test": "bun test",
|
|
27
27
|
"prebuild": "contractspec-bun-build prebuild",
|
|
28
28
|
"typecheck": "tsc --noEmit"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@contractspec/lib.schema": "3.7.
|
|
32
|
-
"@contractspec/lib.contracts-spec": "5.0
|
|
33
|
-
"@contractspec/lib.bus": "3.7.
|
|
31
|
+
"@contractspec/lib.schema": "3.7.14",
|
|
32
|
+
"@contractspec/lib.contracts-spec": "5.2.0",
|
|
33
|
+
"@contractspec/lib.bus": "3.7.18",
|
|
34
34
|
"zod": "^4.3.5"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@contractspec/tool.typescript": "3.7.
|
|
37
|
+
"@contractspec/tool.typescript": "3.7.13",
|
|
38
38
|
"typescript": "^5.9.3",
|
|
39
|
-
"@contractspec/tool.bun": "3.7.
|
|
39
|
+
"@contractspec/tool.bun": "3.7.14"
|
|
40
40
|
},
|
|
41
41
|
"exports": {
|
|
42
42
|
".": {
|