@contractspec/module.notifications 3.7.16 → 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 +6 -6
|
@@ -1,35 +1 @@
|
|
|
1
|
-
var
|
|
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/notifications.capability.ts
|
|
18
|
-
import {
|
|
19
|
-
defineCapability,
|
|
20
|
-
StabilityEnum
|
|
21
|
-
} from "@contractspec/lib.contracts-spec";
|
|
22
|
-
var NotificationsCapability = defineCapability({
|
|
23
|
-
meta: {
|
|
24
|
-
key: "notifications",
|
|
25
|
-
version: "1.0.0",
|
|
26
|
-
kind: "ui",
|
|
27
|
-
stability: StabilityEnum.Experimental,
|
|
28
|
-
description: "User notifications and alerts",
|
|
29
|
-
owners: ["@platform.messaging"],
|
|
30
|
-
tags: ["notifications", "messaging", "alerts"]
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
export {
|
|
34
|
-
NotificationsCapability
|
|
35
|
-
};
|
|
1
|
+
var k=Object.defineProperty;var q=(g)=>g;function v(g,h){this[g]=q.bind(null,h)}var z=(g,h)=>{for(var j in h)k(g,j,{get:h[j],enumerable:!0,configurable:!0,set:v.bind(h,j)})};var A=(g,h)=>()=>(g&&(h=g(g=0)),h);import{defineCapability as w,StabilityEnum as x}from"@contractspec/lib.contracts-spec";var F=w({meta:{key:"notifications",version:"1.0.0",kind:"ui",stability:x.Experimental,description:"User notifications and alerts",owners:["@platform.messaging"],tags:["notifications","messaging","alerts"]}});export{F as NotificationsCapability};
|
|
@@ -1,50 +1 @@
|
|
|
1
|
-
var
|
|
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/notifications.feature.ts
|
|
18
|
-
import { defineFeature } from "@contractspec/lib.contracts-spec";
|
|
19
|
-
var NotificationsFeature = defineFeature({
|
|
20
|
-
meta: {
|
|
21
|
-
key: "notifications",
|
|
22
|
-
title: "Notifications",
|
|
23
|
-
description: "Multi-channel notification delivery with preference management",
|
|
24
|
-
domain: "platform",
|
|
25
|
-
version: "1.0.0",
|
|
26
|
-
owners: ["@platform.notifications"],
|
|
27
|
-
tags: ["notifications", "email", "push", "in-app"],
|
|
28
|
-
stability: "stable"
|
|
29
|
-
},
|
|
30
|
-
operations: [
|
|
31
|
-
{ key: "notifications.send", version: "1.0.0" },
|
|
32
|
-
{ key: "notifications.markRead", version: "1.0.0" },
|
|
33
|
-
{ key: "notifications.markAllRead", version: "1.0.0" },
|
|
34
|
-
{ key: "notifications.delete", version: "1.0.0" },
|
|
35
|
-
{ key: "notifications.list", version: "1.0.0" },
|
|
36
|
-
{ key: "notifications.preferences.update", version: "1.0.0" },
|
|
37
|
-
{ key: "notifications.preferences.get", version: "1.0.0" }
|
|
38
|
-
],
|
|
39
|
-
events: [],
|
|
40
|
-
presentations: [],
|
|
41
|
-
opToPresentation: [],
|
|
42
|
-
presentationsTargets: [],
|
|
43
|
-
capabilities: {
|
|
44
|
-
provides: [{ key: "notifications", version: "1.0.0" }],
|
|
45
|
-
requires: [{ key: "identity", version: "1.0.0" }]
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
export {
|
|
49
|
-
NotificationsFeature
|
|
50
|
-
};
|
|
1
|
+
var k=Object.defineProperty;var m=(g)=>g;function q(g,h){this[g]=m.bind(null,h)}var w=(g,h)=>{for(var j in h)k(g,j,{get:h[j],enumerable:!0,configurable:!0,set:q.bind(h,j)})};var x=(g,h)=>()=>(g&&(h=g(g=0)),h);import{defineFeature as v}from"@contractspec/lib.contracts-spec";var A=v({meta:{key:"notifications",title:"Notifications",description:"Multi-channel notification delivery with preference management",domain:"platform",version:"1.0.0",owners:["@platform.notifications"],tags:["notifications","email","push","in-app"],stability:"stable"},operations:[{key:"notifications.send",version:"1.0.0"},{key:"notifications.markRead",version:"1.0.0"},{key:"notifications.markAllRead",version:"1.0.0"},{key:"notifications.delete",version:"1.0.0"},{key:"notifications.list",version:"1.0.0"},{key:"notifications.preferences.update",version:"1.0.0"},{key:"notifications.preferences.get",version:"1.0.0"}],events:[],presentations:[],opToPresentation:[],presentationsTargets:[],capabilities:{provides:[{key:"notifications",version:"1.0.0"}],requires:[{key:"identity",version:"1.0.0"}]}});export{A as NotificationsFeature};
|
|
@@ -1,253 +1,25 @@
|
|
|
1
|
-
var
|
|
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/templates/index.ts
|
|
18
|
-
function defineTemplate(def) {
|
|
19
|
-
return def;
|
|
20
|
-
}
|
|
21
|
-
function renderTemplate(content, variables) {
|
|
22
|
-
return content.replace(/\{\{(\w+)\}\}/g, (match, key) => {
|
|
23
|
-
const value = variables[key];
|
|
24
|
-
if (value === undefined || value === null) {
|
|
25
|
-
return match;
|
|
26
|
-
}
|
|
27
|
-
return String(value);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function renderNotificationTemplate(template, channel, variables, locale) {
|
|
31
|
-
const channelContent = (locale && template.localeChannels?.[locale]?.[channel]) ?? template.channels[channel];
|
|
32
|
-
if (!channelContent) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
const title = channelContent.title ? renderTemplate(channelContent.title, variables) : template.name;
|
|
36
|
-
const body = renderTemplate(channelContent.body, variables);
|
|
37
|
-
const actionUrl = channelContent.actionUrl ? renderTemplate(channelContent.actionUrl, variables) : undefined;
|
|
38
|
-
const result = {
|
|
39
|
-
title,
|
|
40
|
-
body,
|
|
41
|
-
actionUrl
|
|
42
|
-
};
|
|
43
|
-
if (channel === "email" && channelContent.subject) {
|
|
44
|
-
result.email = {
|
|
45
|
-
subject: renderTemplate(channelContent.subject, variables),
|
|
46
|
-
html: body,
|
|
47
|
-
text: stripHtml(body)
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
function stripHtml(html) {
|
|
53
|
-
return html.replace(/<[^>]*>/g, "").replace(/\s+/g, " ").trim();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
class TemplateRegistry {
|
|
57
|
-
templates = new Map;
|
|
58
|
-
register(template) {
|
|
59
|
-
this.templates.set(template.id, template);
|
|
60
|
-
}
|
|
61
|
-
get(templateId) {
|
|
62
|
-
return this.templates.get(templateId);
|
|
63
|
-
}
|
|
64
|
-
getAll() {
|
|
65
|
-
return Array.from(this.templates.values());
|
|
66
|
-
}
|
|
67
|
-
getByCategory(category) {
|
|
68
|
-
return this.getAll().filter((t) => t.category === category);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function createTemplateRegistry() {
|
|
72
|
-
return new TemplateRegistry;
|
|
73
|
-
}
|
|
74
|
-
var WelcomeTemplate = defineTemplate({
|
|
75
|
-
id: "welcome",
|
|
76
|
-
name: "Welcome",
|
|
77
|
-
description: "Sent when a user signs up.",
|
|
78
|
-
category: "onboarding",
|
|
79
|
-
variables: [
|
|
80
|
-
{ name: "name", type: "string", required: true },
|
|
81
|
-
{ name: "appName", type: "string", default: "ContractSpec" },
|
|
82
|
-
{ name: "actionUrl", type: "url" }
|
|
83
|
-
],
|
|
84
|
-
defaultChannels: ["EMAIL", "IN_APP"],
|
|
85
|
-
channels: {
|
|
86
|
-
email: {
|
|
87
|
-
subject: "Welcome to {{appName}}, {{name}}!",
|
|
88
|
-
body: `
|
|
1
|
+
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:`
|
|
89
2
|
<h1>Welcome, {{name}}!</h1>
|
|
90
3
|
<p>Thanks for joining {{appName}}. We're excited to have you on board.</p>
|
|
91
4
|
<p><a href="{{actionUrl}}">Get started now</a></p>
|
|
92
|
-
`
|
|
93
|
-
},
|
|
94
|
-
inApp: {
|
|
95
|
-
title: "Welcome to {{appName}}!",
|
|
96
|
-
body: "Thanks for joining. Click to complete your profile.",
|
|
97
|
-
actionUrl: "{{actionUrl}}"
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
localeChannels: {
|
|
101
|
-
fr: {
|
|
102
|
-
email: {
|
|
103
|
-
subject: "Bienvenue sur {{appName}}, {{name}} !",
|
|
104
|
-
body: `
|
|
5
|
+
`},inApp:{title:"Welcome to {{appName}}!",body:"Thanks for joining. Click to complete your profile.",actionUrl:"{{actionUrl}}"}},localeChannels:{fr:{email:{subject:"Bienvenue sur {{appName}}, {{name}} !",body:`
|
|
105
6
|
<h1>Bienvenue, {{name}} !</h1>
|
|
106
7
|
<p>Merci d’avoir rejoint {{appName}}. Nous sommes ravis de vous compter parmi nous.</p>
|
|
107
8
|
<p><a href="{{actionUrl}}">Commencer maintenant</a></p>
|
|
108
|
-
`
|
|
109
|
-
},
|
|
110
|
-
inApp: {
|
|
111
|
-
title: "Bienvenue sur {{appName}} !",
|
|
112
|
-
body: "Merci de nous avoir rejoint. Cliquez pour compléter votre profil.",
|
|
113
|
-
actionUrl: "{{actionUrl}}"
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
es: {
|
|
117
|
-
email: {
|
|
118
|
-
subject: "¡Bienvenido a {{appName}}, {{name}}!",
|
|
119
|
-
body: `
|
|
9
|
+
`},inApp:{title:"Bienvenue sur {{appName}} !",body:"Merci de nous avoir rejoint. Cliquez pour compléter votre profil.",actionUrl:"{{actionUrl}}"}},es:{email:{subject:"¡Bienvenido a {{appName}}, {{name}}!",body:`
|
|
120
10
|
<h1>¡Bienvenido, {{name}}!</h1>
|
|
121
11
|
<p>Gracias por unirte a {{appName}}. Estamos encantados de tenerte.</p>
|
|
122
12
|
<p><a href="{{actionUrl}}">Comenzar ahora</a></p>
|
|
123
|
-
`
|
|
124
|
-
},
|
|
125
|
-
inApp: {
|
|
126
|
-
title: "¡Bienvenido a {{appName}}!",
|
|
127
|
-
body: "Gracias por unirte. Haz clic para completar tu perfil.",
|
|
128
|
-
actionUrl: "{{actionUrl}}"
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
var OrgInviteTemplate = defineTemplate({
|
|
134
|
-
id: "org-invite",
|
|
135
|
-
name: "Organization Invitation",
|
|
136
|
-
description: "Sent when a user is invited to an organization.",
|
|
137
|
-
category: "organization",
|
|
138
|
-
variables: [
|
|
139
|
-
{ name: "inviterName", type: "string", required: true },
|
|
140
|
-
{ name: "orgName", type: "string", required: true },
|
|
141
|
-
{ name: "role", type: "string", default: "member" },
|
|
142
|
-
{ name: "actionUrl", type: "url", required: true }
|
|
143
|
-
],
|
|
144
|
-
defaultChannels: ["EMAIL"],
|
|
145
|
-
channels: {
|
|
146
|
-
email: {
|
|
147
|
-
subject: "{{inviterName}} invited you to join {{orgName}}",
|
|
148
|
-
body: `
|
|
13
|
+
`},inApp:{title:"¡Bienvenido 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:`
|
|
149
14
|
<h1>You've been invited!</h1>
|
|
150
15
|
<p>{{inviterName}} has invited you to join <strong>{{orgName}}</strong> as a {{role}}.</p>
|
|
151
16
|
<p><a href="{{actionUrl}}">Accept invitation</a></p>
|
|
152
|
-
`
|
|
153
|
-
},
|
|
154
|
-
inApp: {
|
|
155
|
-
title: "Invitation to {{orgName}}",
|
|
156
|
-
body: "{{inviterName}} invited you to join as {{role}}.",
|
|
157
|
-
actionUrl: "{{actionUrl}}",
|
|
158
|
-
actionText: "Accept"
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
localeChannels: {
|
|
162
|
-
fr: {
|
|
163
|
-
email: {
|
|
164
|
-
subject: "{{inviterName}} vous invite à rejoindre {{orgName}}",
|
|
165
|
-
body: `
|
|
17
|
+
`},inApp:{title:"Invitation to {{orgName}}",body:"{{inviterName}} invited you to join as {{role}}.",actionUrl:"{{actionUrl}}",actionText:"Accept"}},localeChannels:{fr:{email:{subject:"{{inviterName}} vous invite à rejoindre {{orgName}}",body:`
|
|
166
18
|
<h1>Vous êtes invité !</h1>
|
|
167
19
|
<p>{{inviterName}} vous a invité à rejoindre <strong>{{orgName}}</strong> en tant que {{role}}.</p>
|
|
168
20
|
<p><a href="{{actionUrl}}">Accepter l’invitation</a></p>
|
|
169
|
-
`
|
|
170
|
-
},
|
|
171
|
-
inApp: {
|
|
172
|
-
title: "Invitation à {{orgName}}",
|
|
173
|
-
body: "{{inviterName}} vous a invité à rejoindre en tant que {{role}}.",
|
|
174
|
-
actionUrl: "{{actionUrl}}",
|
|
175
|
-
actionText: "Accepter"
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
es: {
|
|
179
|
-
email: {
|
|
180
|
-
subject: "{{inviterName}} te invitó a unirte a {{orgName}}",
|
|
181
|
-
body: `
|
|
21
|
+
`},inApp:{title:"Invitation à {{orgName}}",body:"{{inviterName}} vous a invité à rejoindre en tant que {{role}}.",actionUrl:"{{actionUrl}}",actionText:"Accepter"}},es:{email:{subject:"{{inviterName}} te invitó a unirte a {{orgName}}",body:`
|
|
182
22
|
<h1>¡Has sido invitado!</h1>
|
|
183
23
|
<p>{{inviterName}} te ha invitado a unirte a <strong>{{orgName}}</strong> como {{role}}.</p>
|
|
184
24
|
<p><a href="{{actionUrl}}">Aceptar invitación</a></p>
|
|
185
|
-
`
|
|
186
|
-
},
|
|
187
|
-
inApp: {
|
|
188
|
-
title: "Invitación a {{orgName}}",
|
|
189
|
-
body: "{{inviterName}} te invitó a unirte como {{role}}.",
|
|
190
|
-
actionUrl: "{{actionUrl}}",
|
|
191
|
-
actionText: "Aceptar"
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
var MentionTemplate = defineTemplate({
|
|
197
|
-
id: "mention",
|
|
198
|
-
name: "Mention",
|
|
199
|
-
description: "Sent when a user is mentioned.",
|
|
200
|
-
category: "social",
|
|
201
|
-
variables: [
|
|
202
|
-
{ name: "mentionerName", type: "string", required: true },
|
|
203
|
-
{ name: "context", type: "string", required: true },
|
|
204
|
-
{ name: "preview", type: "string" },
|
|
205
|
-
{ name: "actionUrl", type: "url", required: true }
|
|
206
|
-
],
|
|
207
|
-
defaultChannels: ["IN_APP", "PUSH"],
|
|
208
|
-
channels: {
|
|
209
|
-
inApp: {
|
|
210
|
-
title: "{{mentionerName}} mentioned you",
|
|
211
|
-
body: 'In {{context}}: "{{preview}}"',
|
|
212
|
-
actionUrl: "{{actionUrl}}"
|
|
213
|
-
},
|
|
214
|
-
push: {
|
|
215
|
-
title: "{{mentionerName}} mentioned you",
|
|
216
|
-
body: "{{preview}}"
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
localeChannels: {
|
|
220
|
-
fr: {
|
|
221
|
-
inApp: {
|
|
222
|
-
title: "{{mentionerName}} vous a mentionné",
|
|
223
|
-
body: "Dans {{context}} : « {{preview}} »",
|
|
224
|
-
actionUrl: "{{actionUrl}}"
|
|
225
|
-
},
|
|
226
|
-
push: {
|
|
227
|
-
title: "{{mentionerName}} vous a mentionné",
|
|
228
|
-
body: "{{preview}}"
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
es: {
|
|
232
|
-
inApp: {
|
|
233
|
-
title: "{{mentionerName}} te mencionó",
|
|
234
|
-
body: 'En {{context}}: "{{preview}}"',
|
|
235
|
-
actionUrl: "{{actionUrl}}"
|
|
236
|
-
},
|
|
237
|
-
push: {
|
|
238
|
-
title: "{{mentionerName}} te mencionó",
|
|
239
|
-
body: "{{preview}}"
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
export {
|
|
245
|
-
renderTemplate,
|
|
246
|
-
renderNotificationTemplate,
|
|
247
|
-
defineTemplate,
|
|
248
|
-
createTemplateRegistry,
|
|
249
|
-
WelcomeTemplate,
|
|
250
|
-
TemplateRegistry,
|
|
251
|
-
OrgInviteTemplate,
|
|
252
|
-
MentionTemplate
|
|
253
|
-
};
|
|
25
|
+
`},inApp:{title:"Invitación a {{orgName}}",body:"{{inviterName}} te invitó 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é",body:"Dans {{context}} : « {{preview}} »",actionUrl:"{{actionUrl}}"},push:{title:"{{mentionerName}} vous a mentionné",body:"{{preview}}"}},es:{inApp:{title:"{{mentionerName}} te mencionó",body:'En {{context}}: "{{preview}}"',actionUrl:"{{actionUrl}}"},push:{title:"{{mentionerName}} te mencionó",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/dist/channels/index.js
CHANGED
|
@@ -1,315 +1,2 @@
|
|
|
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/i18n/catalogs/en.ts
|
|
19
|
-
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
|
|
20
|
-
var enMessages;
|
|
21
|
-
var init_en = __esm(() => {
|
|
22
|
-
enMessages = defineTranslation({
|
|
23
|
-
meta: {
|
|
24
|
-
key: "notifications.messages",
|
|
25
|
-
version: "1.0.0",
|
|
26
|
-
domain: "notifications",
|
|
27
|
-
description: "Template and channel strings for the notifications module",
|
|
28
|
-
owners: ["platform"],
|
|
29
|
-
stability: "experimental"
|
|
30
|
-
},
|
|
31
|
-
locale: "en",
|
|
32
|
-
fallback: "en",
|
|
33
|
-
messages: {
|
|
34
|
-
"template.welcome.name": {
|
|
35
|
-
value: "Welcome",
|
|
36
|
-
description: "Welcome template display name"
|
|
37
|
-
},
|
|
38
|
-
"template.welcome.description": {
|
|
39
|
-
value: "Sent when a user signs up.",
|
|
40
|
-
description: "Welcome template description"
|
|
41
|
-
},
|
|
42
|
-
"template.orgInvite.name": {
|
|
43
|
-
value: "Organization Invitation",
|
|
44
|
-
description: "Org invite template display name"
|
|
45
|
-
},
|
|
46
|
-
"template.orgInvite.description": {
|
|
47
|
-
value: "Sent when a user is invited to an organization.",
|
|
48
|
-
description: "Org invite template description"
|
|
49
|
-
},
|
|
50
|
-
"template.mention.name": {
|
|
51
|
-
value: "Mention",
|
|
52
|
-
description: "Mention template display name"
|
|
53
|
-
},
|
|
54
|
-
"template.mention.description": {
|
|
55
|
-
value: "Sent when a user is mentioned.",
|
|
56
|
-
description: "Mention template description"
|
|
57
|
-
},
|
|
58
|
-
"channel.webhook.noUrl": {
|
|
59
|
-
value: "No webhook URL configured",
|
|
60
|
-
description: "Error when webhook channel has no URL"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// src/i18n/catalogs/es.ts
|
|
67
|
-
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
|
|
68
|
-
var esMessages;
|
|
69
|
-
var init_es = __esm(() => {
|
|
70
|
-
esMessages = defineTranslation2({
|
|
71
|
-
meta: {
|
|
72
|
-
key: "notifications.messages",
|
|
73
|
-
version: "1.0.0",
|
|
74
|
-
domain: "notifications",
|
|
75
|
-
description: "Template and channel strings (Spanish)",
|
|
76
|
-
owners: ["platform"],
|
|
77
|
-
stability: "experimental"
|
|
78
|
-
},
|
|
79
|
-
locale: "es",
|
|
80
|
-
fallback: "en",
|
|
81
|
-
messages: {
|
|
82
|
-
"template.welcome.name": {
|
|
83
|
-
value: "Bienvenida",
|
|
84
|
-
description: "Welcome template display name"
|
|
85
|
-
},
|
|
86
|
-
"template.welcome.description": {
|
|
87
|
-
value: "Enviado cuando un usuario se registra.",
|
|
88
|
-
description: "Welcome template description"
|
|
89
|
-
},
|
|
90
|
-
"template.orgInvite.name": {
|
|
91
|
-
value: "Invitaci\xF3n a la organizaci\xF3n",
|
|
92
|
-
description: "Org invite template display name"
|
|
93
|
-
},
|
|
94
|
-
"template.orgInvite.description": {
|
|
95
|
-
value: "Enviado cuando un usuario es invitado a una organizaci\xF3n.",
|
|
96
|
-
description: "Org invite template description"
|
|
97
|
-
},
|
|
98
|
-
"template.mention.name": {
|
|
99
|
-
value: "Menci\xF3n",
|
|
100
|
-
description: "Mention template display name"
|
|
101
|
-
},
|
|
102
|
-
"template.mention.description": {
|
|
103
|
-
value: "Enviado cuando un usuario es mencionado.",
|
|
104
|
-
description: "Mention template description"
|
|
105
|
-
},
|
|
106
|
-
"channel.webhook.noUrl": {
|
|
107
|
-
value: "No se ha configurado una URL de webhook",
|
|
108
|
-
description: "Error when webhook channel has no URL"
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// src/i18n/catalogs/fr.ts
|
|
115
|
-
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
|
|
116
|
-
var frMessages;
|
|
117
|
-
var init_fr = __esm(() => {
|
|
118
|
-
frMessages = defineTranslation3({
|
|
119
|
-
meta: {
|
|
120
|
-
key: "notifications.messages",
|
|
121
|
-
version: "1.0.0",
|
|
122
|
-
domain: "notifications",
|
|
123
|
-
description: "Template and channel strings (French)",
|
|
124
|
-
owners: ["platform"],
|
|
125
|
-
stability: "experimental"
|
|
126
|
-
},
|
|
127
|
-
locale: "fr",
|
|
128
|
-
fallback: "en",
|
|
129
|
-
messages: {
|
|
130
|
-
"template.welcome.name": {
|
|
131
|
-
value: "Bienvenue",
|
|
132
|
-
description: "Welcome template display name"
|
|
133
|
-
},
|
|
134
|
-
"template.welcome.description": {
|
|
135
|
-
value: "Envoy\xE9 lorsqu'un utilisateur s'inscrit.",
|
|
136
|
-
description: "Welcome template description"
|
|
137
|
-
},
|
|
138
|
-
"template.orgInvite.name": {
|
|
139
|
-
value: "Invitation \xE0 l'organisation",
|
|
140
|
-
description: "Org invite template display name"
|
|
141
|
-
},
|
|
142
|
-
"template.orgInvite.description": {
|
|
143
|
-
value: "Envoy\xE9 lorsqu'un utilisateur est invit\xE9 \xE0 une organisation.",
|
|
144
|
-
description: "Org invite template description"
|
|
145
|
-
},
|
|
146
|
-
"template.mention.name": {
|
|
147
|
-
value: "Mention",
|
|
148
|
-
description: "Mention template display name"
|
|
149
|
-
},
|
|
150
|
-
"template.mention.description": {
|
|
151
|
-
value: "Envoy\xE9 lorsqu'un utilisateur est mentionn\xE9.",
|
|
152
|
-
description: "Mention template description"
|
|
153
|
-
},
|
|
154
|
-
"channel.webhook.noUrl": {
|
|
155
|
-
value: "Aucune URL de webhook configur\xE9e",
|
|
156
|
-
description: "Error when webhook channel has no URL"
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// src/i18n/messages.ts
|
|
163
|
-
var exports_messages = {};
|
|
164
|
-
__export(exports_messages, {
|
|
165
|
-
resetI18nRegistry: () => resetI18nRegistry,
|
|
166
|
-
getDefaultI18n: () => getDefaultI18n,
|
|
167
|
-
createNotificationsI18n: () => createNotificationsI18n
|
|
168
|
-
});
|
|
169
|
-
import {
|
|
170
|
-
createI18nFactory
|
|
171
|
-
} from "@contractspec/lib.contracts-spec/translations";
|
|
172
|
-
var factory, createNotificationsI18n, getDefaultI18n, resetI18nRegistry;
|
|
173
|
-
var init_messages = __esm(() => {
|
|
174
|
-
init_en();
|
|
175
|
-
init_es();
|
|
176
|
-
init_fr();
|
|
177
|
-
factory = createI18nFactory({
|
|
178
|
-
specKey: "notifications.messages",
|
|
179
|
-
catalogs: [enMessages, frMessages, esMessages]
|
|
180
|
-
});
|
|
181
|
-
createNotificationsI18n = factory.create;
|
|
182
|
-
getDefaultI18n = factory.getDefault;
|
|
183
|
-
resetI18nRegistry = factory.resetRegistry;
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
// src/channels/index.ts
|
|
187
|
-
class InAppChannel {
|
|
188
|
-
channelId = "IN_APP";
|
|
189
|
-
async send(_notification) {
|
|
190
|
-
return {
|
|
191
|
-
success: true,
|
|
192
|
-
responseMessage: "Stored in database"
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
async isAvailable() {
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
class ConsoleChannel {
|
|
201
|
-
channelId = "CONSOLE";
|
|
202
|
-
async send(notification) {
|
|
203
|
-
console.log(`\uD83D\uDCEC [${notification.id}] ${notification.title}`);
|
|
204
|
-
console.log(` ${notification.body}`);
|
|
205
|
-
if (notification.actionUrl) {
|
|
206
|
-
console.log(` Action: ${notification.actionUrl}`);
|
|
207
|
-
}
|
|
208
|
-
return {
|
|
209
|
-
success: true,
|
|
210
|
-
responseMessage: "Logged to console"
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
async isAvailable() {
|
|
214
|
-
return true;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
class EmailChannel {
|
|
219
|
-
channelId = "EMAIL";
|
|
220
|
-
async isAvailable() {
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
class PushChannel {
|
|
226
|
-
channelId = "PUSH";
|
|
227
|
-
async isAvailable() {
|
|
228
|
-
return true;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
class WebhookChannel {
|
|
233
|
-
channelId = "WEBHOOK";
|
|
234
|
-
locale;
|
|
235
|
-
constructor(options) {
|
|
236
|
-
this.locale = options?.locale;
|
|
237
|
-
}
|
|
238
|
-
async send(notification) {
|
|
239
|
-
if (!notification.webhook?.url) {
|
|
240
|
-
const { createNotificationsI18n: createNotificationsI18n2 } = await Promise.resolve().then(() => (init_messages(), exports_messages));
|
|
241
|
-
const i18n = createNotificationsI18n2(this.locale);
|
|
242
|
-
return {
|
|
243
|
-
success: false,
|
|
244
|
-
responseMessage: i18n.t("channel.webhook.noUrl")
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
try {
|
|
248
|
-
const response = await fetch(notification.webhook.url, {
|
|
249
|
-
method: "POST",
|
|
250
|
-
headers: {
|
|
251
|
-
"Content-Type": "application/json",
|
|
252
|
-
...notification.webhook.headers
|
|
253
|
-
},
|
|
254
|
-
body: JSON.stringify({
|
|
255
|
-
id: notification.id,
|
|
256
|
-
title: notification.title,
|
|
257
|
-
body: notification.body,
|
|
258
|
-
actionUrl: notification.actionUrl,
|
|
259
|
-
metadata: notification.metadata
|
|
260
|
-
})
|
|
261
|
-
});
|
|
262
|
-
return {
|
|
263
|
-
success: response.ok,
|
|
264
|
-
responseCode: String(response.status),
|
|
265
|
-
responseMessage: response.statusText
|
|
266
|
-
};
|
|
267
|
-
} catch (error) {
|
|
268
|
-
return {
|
|
269
|
-
success: false,
|
|
270
|
-
responseMessage: error instanceof Error ? error.message : "Unknown error"
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
async isAvailable() {
|
|
275
|
-
return true;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
class ChannelRegistry {
|
|
280
|
-
channels = new Map;
|
|
281
|
-
register(channel) {
|
|
282
|
-
this.channels.set(channel.channelId, channel);
|
|
283
|
-
}
|
|
284
|
-
get(channelId) {
|
|
285
|
-
return this.channels.get(channelId);
|
|
286
|
-
}
|
|
287
|
-
getAll() {
|
|
288
|
-
return Array.from(this.channels.values());
|
|
289
|
-
}
|
|
290
|
-
async getAvailable() {
|
|
291
|
-
const available = [];
|
|
292
|
-
for (const channel of this.channels.values()) {
|
|
293
|
-
if (await channel.isAvailable()) {
|
|
294
|
-
available.push(channel);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return available;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function createChannelRegistry() {
|
|
301
|
-
const registry = new ChannelRegistry;
|
|
302
|
-
registry.register(new InAppChannel);
|
|
303
|
-
registry.register(new ConsoleChannel);
|
|
304
|
-
registry.register(new WebhookChannel);
|
|
305
|
-
return registry;
|
|
306
|
-
}
|
|
307
|
-
export {
|
|
308
|
-
createChannelRegistry,
|
|
309
|
-
WebhookChannel,
|
|
310
|
-
PushChannel,
|
|
311
|
-
InAppChannel,
|
|
312
|
-
EmailChannel,
|
|
313
|
-
ConsoleChannel,
|
|
314
|
-
ChannelRegistry
|
|
315
|
-
};
|
|
2
|
+
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\xF3n a la organizaci\xF3n",description:"Org invite template display name"},"template.orgInvite.description":{value:"Enviado cuando un usuario es invitado a una organizaci\xF3n.",description:"Org invite template description"},"template.mention.name":{value:"Menci\xF3n",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\xE9 lorsqu'un utilisateur s'inscrit.",description:"Welcome template description"},"template.orgInvite.name":{value:"Invitation \xE0 l'organisation",description:"Org invite template display name"},"template.orgInvite.description":{value:"Envoy\xE9 lorsqu'un utilisateur est invit\xE9 \xE0 une organisation.",description:"Org invite template description"},"template.mention.name":{value:"Mention",description:"Mention template display name"},"template.mention.description":{value:"Envoy\xE9 lorsqu'un utilisateur est mentionn\xE9.",description:"Mention template description"},"channel.webhook.noUrl":{value:"Aucune URL de webhook configur\xE9e",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};
|