@contractspec/module.notifications 2.4.0 → 2.6.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.
- package/dist/browser/channels/index.js +187 -1
- package/dist/browser/contracts/index.js +12 -0
- package/dist/browser/entities/index.js +12 -0
- package/dist/browser/i18n/catalogs/en.js +64 -0
- package/dist/browser/i18n/catalogs/es.js +64 -0
- package/dist/browser/i18n/catalogs/fr.js +64 -0
- package/dist/browser/i18n/catalogs/index.js +165 -0
- package/dist/browser/i18n/index.js +225 -0
- package/dist/browser/i18n/keys.js +33 -0
- package/dist/browser/i18n/locale.js +25 -0
- package/dist/browser/i18n/messages.js +186 -0
- package/dist/browser/index.js +279 -3
- package/dist/browser/notifications.capability.js +12 -0
- package/dist/browser/notifications.feature.js +12 -0
- package/dist/browser/templates/index.js +104 -2
- package/dist/channels/index.d.ts +4 -0
- package/dist/channels/index.js +187 -1
- package/dist/contracts/index.js +12 -0
- package/dist/entities/index.js +12 -0
- package/dist/i18n/catalogs/en.d.ts +6 -0
- package/dist/i18n/catalogs/en.js +65 -0
- package/dist/i18n/catalogs/es.d.ts +6 -0
- package/dist/i18n/catalogs/es.js +65 -0
- package/dist/i18n/catalogs/fr.d.ts +6 -0
- package/dist/i18n/catalogs/fr.js +65 -0
- package/dist/i18n/catalogs/index.d.ts +8 -0
- package/dist/i18n/catalogs/index.js +166 -0
- package/dist/i18n/i18n.test.d.ts +1 -0
- package/dist/i18n/index.d.ts +14 -0
- package/dist/i18n/index.js +226 -0
- package/dist/i18n/keys.d.ts +29 -0
- package/dist/i18n/keys.js +34 -0
- package/dist/i18n/locale.d.ts +8 -0
- package/dist/i18n/locale.js +26 -0
- package/dist/i18n/messages.d.ts +14 -0
- package/dist/i18n/messages.js +187 -0
- package/dist/index.js +279 -3
- package/dist/node/channels/index.js +187 -1
- package/dist/node/contracts/index.js +12 -0
- package/dist/node/entities/index.js +12 -0
- package/dist/node/i18n/catalogs/en.js +64 -0
- package/dist/node/i18n/catalogs/es.js +64 -0
- package/dist/node/i18n/catalogs/fr.js +64 -0
- package/dist/node/i18n/catalogs/index.js +165 -0
- package/dist/node/i18n/index.js +225 -0
- package/dist/node/i18n/keys.js +33 -0
- package/dist/node/i18n/locale.js +25 -0
- package/dist/node/i18n/messages.js +186 -0
- package/dist/node/index.js +279 -3
- package/dist/node/notifications.capability.js +12 -0
- package/dist/node/notifications.feature.js +12 -0
- package/dist/node/templates/index.js +104 -2
- package/dist/notifications.capability.js +12 -0
- package/dist/notifications.feature.js +12 -0
- package/dist/templates/index.d.ts +17 -7
- package/dist/templates/index.js +104 -2
- package/package.json +147 -6
package/dist/index.js
CHANGED
|
@@ -1,4 +1,184 @@
|
|
|
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
|
+
|
|
14
|
+
// src/i18n/catalogs/en.ts
|
|
15
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
|
|
16
|
+
var enMessages;
|
|
17
|
+
var init_en = __esm(() => {
|
|
18
|
+
enMessages = defineTranslation({
|
|
19
|
+
meta: {
|
|
20
|
+
key: "notifications.messages",
|
|
21
|
+
version: "1.0.0",
|
|
22
|
+
domain: "notifications",
|
|
23
|
+
description: "Template and channel strings for the notifications module",
|
|
24
|
+
owners: ["platform"],
|
|
25
|
+
stability: "experimental"
|
|
26
|
+
},
|
|
27
|
+
locale: "en",
|
|
28
|
+
fallback: "en",
|
|
29
|
+
messages: {
|
|
30
|
+
"template.welcome.name": {
|
|
31
|
+
value: "Welcome",
|
|
32
|
+
description: "Welcome template display name"
|
|
33
|
+
},
|
|
34
|
+
"template.welcome.description": {
|
|
35
|
+
value: "Sent when a user signs up.",
|
|
36
|
+
description: "Welcome template description"
|
|
37
|
+
},
|
|
38
|
+
"template.orgInvite.name": {
|
|
39
|
+
value: "Organization Invitation",
|
|
40
|
+
description: "Org invite template display name"
|
|
41
|
+
},
|
|
42
|
+
"template.orgInvite.description": {
|
|
43
|
+
value: "Sent when a user is invited to an organization.",
|
|
44
|
+
description: "Org invite template description"
|
|
45
|
+
},
|
|
46
|
+
"template.mention.name": {
|
|
47
|
+
value: "Mention",
|
|
48
|
+
description: "Mention template display name"
|
|
49
|
+
},
|
|
50
|
+
"template.mention.description": {
|
|
51
|
+
value: "Sent when a user is mentioned.",
|
|
52
|
+
description: "Mention template description"
|
|
53
|
+
},
|
|
54
|
+
"channel.webhook.noUrl": {
|
|
55
|
+
value: "No webhook URL configured",
|
|
56
|
+
description: "Error when webhook channel has no URL"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// src/i18n/catalogs/fr.ts
|
|
63
|
+
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
|
|
64
|
+
var frMessages;
|
|
65
|
+
var init_fr = __esm(() => {
|
|
66
|
+
frMessages = defineTranslation2({
|
|
67
|
+
meta: {
|
|
68
|
+
key: "notifications.messages",
|
|
69
|
+
version: "1.0.0",
|
|
70
|
+
domain: "notifications",
|
|
71
|
+
description: "Template and channel strings (French)",
|
|
72
|
+
owners: ["platform"],
|
|
73
|
+
stability: "experimental"
|
|
74
|
+
},
|
|
75
|
+
locale: "fr",
|
|
76
|
+
fallback: "en",
|
|
77
|
+
messages: {
|
|
78
|
+
"template.welcome.name": {
|
|
79
|
+
value: "Bienvenue",
|
|
80
|
+
description: "Welcome template display name"
|
|
81
|
+
},
|
|
82
|
+
"template.welcome.description": {
|
|
83
|
+
value: "Envoy\xE9 lorsqu'un utilisateur s'inscrit.",
|
|
84
|
+
description: "Welcome template description"
|
|
85
|
+
},
|
|
86
|
+
"template.orgInvite.name": {
|
|
87
|
+
value: "Invitation \xE0 l'organisation",
|
|
88
|
+
description: "Org invite template display name"
|
|
89
|
+
},
|
|
90
|
+
"template.orgInvite.description": {
|
|
91
|
+
value: "Envoy\xE9 lorsqu'un utilisateur est invit\xE9 \xE0 une organisation.",
|
|
92
|
+
description: "Org invite template description"
|
|
93
|
+
},
|
|
94
|
+
"template.mention.name": {
|
|
95
|
+
value: "Mention",
|
|
96
|
+
description: "Mention template display name"
|
|
97
|
+
},
|
|
98
|
+
"template.mention.description": {
|
|
99
|
+
value: "Envoy\xE9 lorsqu'un utilisateur est mentionn\xE9.",
|
|
100
|
+
description: "Mention template description"
|
|
101
|
+
},
|
|
102
|
+
"channel.webhook.noUrl": {
|
|
103
|
+
value: "Aucune URL de webhook configur\xE9e",
|
|
104
|
+
description: "Error when webhook channel has no URL"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// src/i18n/catalogs/es.ts
|
|
111
|
+
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
|
|
112
|
+
var esMessages;
|
|
113
|
+
var init_es = __esm(() => {
|
|
114
|
+
esMessages = defineTranslation3({
|
|
115
|
+
meta: {
|
|
116
|
+
key: "notifications.messages",
|
|
117
|
+
version: "1.0.0",
|
|
118
|
+
domain: "notifications",
|
|
119
|
+
description: "Template and channel strings (Spanish)",
|
|
120
|
+
owners: ["platform"],
|
|
121
|
+
stability: "experimental"
|
|
122
|
+
},
|
|
123
|
+
locale: "es",
|
|
124
|
+
fallback: "en",
|
|
125
|
+
messages: {
|
|
126
|
+
"template.welcome.name": {
|
|
127
|
+
value: "Bienvenida",
|
|
128
|
+
description: "Welcome template display name"
|
|
129
|
+
},
|
|
130
|
+
"template.welcome.description": {
|
|
131
|
+
value: "Enviado cuando un usuario se registra.",
|
|
132
|
+
description: "Welcome template description"
|
|
133
|
+
},
|
|
134
|
+
"template.orgInvite.name": {
|
|
135
|
+
value: "Invitaci\xF3n a la organizaci\xF3n",
|
|
136
|
+
description: "Org invite template display name"
|
|
137
|
+
},
|
|
138
|
+
"template.orgInvite.description": {
|
|
139
|
+
value: "Enviado cuando un usuario es invitado a una organizaci\xF3n.",
|
|
140
|
+
description: "Org invite template description"
|
|
141
|
+
},
|
|
142
|
+
"template.mention.name": {
|
|
143
|
+
value: "Menci\xF3n",
|
|
144
|
+
description: "Mention template display name"
|
|
145
|
+
},
|
|
146
|
+
"template.mention.description": {
|
|
147
|
+
value: "Enviado cuando un usuario es mencionado.",
|
|
148
|
+
description: "Mention template description"
|
|
149
|
+
},
|
|
150
|
+
"channel.webhook.noUrl": {
|
|
151
|
+
value: "No se ha configurado una URL de webhook",
|
|
152
|
+
description: "Error when webhook channel has no URL"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// src/i18n/messages.ts
|
|
159
|
+
var exports_messages = {};
|
|
160
|
+
__export(exports_messages, {
|
|
161
|
+
resetI18nRegistry: () => resetI18nRegistry,
|
|
162
|
+
getDefaultI18n: () => getDefaultI18n,
|
|
163
|
+
createNotificationsI18n: () => createNotificationsI18n
|
|
164
|
+
});
|
|
165
|
+
import {
|
|
166
|
+
createI18nFactory
|
|
167
|
+
} from "@contractspec/lib.contracts-spec/translations";
|
|
168
|
+
var factory, createNotificationsI18n, getDefaultI18n, resetI18nRegistry;
|
|
169
|
+
var init_messages = __esm(() => {
|
|
170
|
+
init_en();
|
|
171
|
+
init_fr();
|
|
172
|
+
init_es();
|
|
173
|
+
factory = createI18nFactory({
|
|
174
|
+
specKey: "notifications.messages",
|
|
175
|
+
catalogs: [enMessages, frMessages, esMessages]
|
|
176
|
+
});
|
|
177
|
+
createNotificationsI18n = factory.create;
|
|
178
|
+
getDefaultI18n = factory.getDefault;
|
|
179
|
+
resetI18nRegistry = factory.resetRegistry;
|
|
180
|
+
});
|
|
181
|
+
|
|
2
182
|
// src/channels/index.ts
|
|
3
183
|
class InAppChannel {
|
|
4
184
|
channelId = "IN_APP";
|
|
@@ -47,11 +227,17 @@ class PushChannel {
|
|
|
47
227
|
|
|
48
228
|
class WebhookChannel {
|
|
49
229
|
channelId = "WEBHOOK";
|
|
230
|
+
locale;
|
|
231
|
+
constructor(options) {
|
|
232
|
+
this.locale = options?.locale;
|
|
233
|
+
}
|
|
50
234
|
async send(notification) {
|
|
51
235
|
if (!notification.webhook?.url) {
|
|
236
|
+
const { createNotificationsI18n: createNotificationsI18n2 } = await Promise.resolve().then(() => (init_messages(), exports_messages));
|
|
237
|
+
const i18n = createNotificationsI18n2(this.locale);
|
|
52
238
|
return {
|
|
53
239
|
success: false,
|
|
54
|
-
responseMessage: "
|
|
240
|
+
responseMessage: i18n.t("channel.webhook.noUrl")
|
|
55
241
|
};
|
|
56
242
|
}
|
|
57
243
|
try {
|
|
@@ -666,8 +852,8 @@ function renderTemplate(content, variables) {
|
|
|
666
852
|
return String(value);
|
|
667
853
|
});
|
|
668
854
|
}
|
|
669
|
-
function renderNotificationTemplate(template, channel, variables) {
|
|
670
|
-
const channelContent = template.channels[channel];
|
|
855
|
+
function renderNotificationTemplate(template, channel, variables, locale) {
|
|
856
|
+
const channelContent = (locale && template.localeChannels?.[locale]?.[channel]) ?? template.channels[channel];
|
|
671
857
|
if (!channelContent) {
|
|
672
858
|
return null;
|
|
673
859
|
}
|
|
@@ -735,6 +921,38 @@ var WelcomeTemplate = defineTemplate({
|
|
|
735
921
|
body: "Thanks for joining. Click to complete your profile.",
|
|
736
922
|
actionUrl: "{{actionUrl}}"
|
|
737
923
|
}
|
|
924
|
+
},
|
|
925
|
+
localeChannels: {
|
|
926
|
+
fr: {
|
|
927
|
+
email: {
|
|
928
|
+
subject: "Bienvenue sur {{appName}}, {{name}}\u202F!",
|
|
929
|
+
body: `
|
|
930
|
+
<h1>Bienvenue, {{name}}\u202F!</h1>
|
|
931
|
+
<p>Merci d\u2019avoir rejoint {{appName}}. Nous sommes ravis de vous compter parmi nous.</p>
|
|
932
|
+
<p><a href="{{actionUrl}}">Commencer maintenant</a></p>
|
|
933
|
+
`
|
|
934
|
+
},
|
|
935
|
+
inApp: {
|
|
936
|
+
title: "Bienvenue sur {{appName}}\u202F!",
|
|
937
|
+
body: "Merci de nous avoir rejoint. Cliquez pour compl\xE9ter votre profil.",
|
|
938
|
+
actionUrl: "{{actionUrl}}"
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
es: {
|
|
942
|
+
email: {
|
|
943
|
+
subject: "\xA1Bienvenido a {{appName}}, {{name}}!",
|
|
944
|
+
body: `
|
|
945
|
+
<h1>\xA1Bienvenido, {{name}}!</h1>
|
|
946
|
+
<p>Gracias por unirte a {{appName}}. Estamos encantados de tenerte.</p>
|
|
947
|
+
<p><a href="{{actionUrl}}">Comenzar ahora</a></p>
|
|
948
|
+
`
|
|
949
|
+
},
|
|
950
|
+
inApp: {
|
|
951
|
+
title: "\xA1Bienvenido a {{appName}}!",
|
|
952
|
+
body: "Gracias por unirte. Haz clic para completar tu perfil.",
|
|
953
|
+
actionUrl: "{{actionUrl}}"
|
|
954
|
+
}
|
|
955
|
+
}
|
|
738
956
|
}
|
|
739
957
|
});
|
|
740
958
|
var OrgInviteTemplate = defineTemplate({
|
|
@@ -764,6 +982,40 @@ var OrgInviteTemplate = defineTemplate({
|
|
|
764
982
|
actionUrl: "{{actionUrl}}",
|
|
765
983
|
actionText: "Accept"
|
|
766
984
|
}
|
|
985
|
+
},
|
|
986
|
+
localeChannels: {
|
|
987
|
+
fr: {
|
|
988
|
+
email: {
|
|
989
|
+
subject: "{{inviterName}} vous invite \xE0 rejoindre {{orgName}}",
|
|
990
|
+
body: `
|
|
991
|
+
<h1>Vous \xEAtes invit\xE9\u202F!</h1>
|
|
992
|
+
<p>{{inviterName}} vous a invit\xE9 \xE0 rejoindre <strong>{{orgName}}</strong> en tant que {{role}}.</p>
|
|
993
|
+
<p><a href="{{actionUrl}}">Accepter l\u2019invitation</a></p>
|
|
994
|
+
`
|
|
995
|
+
},
|
|
996
|
+
inApp: {
|
|
997
|
+
title: "Invitation \xE0 {{orgName}}",
|
|
998
|
+
body: "{{inviterName}} vous a invit\xE9 \xE0 rejoindre en tant que {{role}}.",
|
|
999
|
+
actionUrl: "{{actionUrl}}",
|
|
1000
|
+
actionText: "Accepter"
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
1003
|
+
es: {
|
|
1004
|
+
email: {
|
|
1005
|
+
subject: "{{inviterName}} te invit\xF3 a unirte a {{orgName}}",
|
|
1006
|
+
body: `
|
|
1007
|
+
<h1>\xA1Has sido invitado!</h1>
|
|
1008
|
+
<p>{{inviterName}} te ha invitado a unirte a <strong>{{orgName}}</strong> como {{role}}.</p>
|
|
1009
|
+
<p><a href="{{actionUrl}}">Aceptar invitaci\xF3n</a></p>
|
|
1010
|
+
`
|
|
1011
|
+
},
|
|
1012
|
+
inApp: {
|
|
1013
|
+
title: "Invitaci\xF3n a {{orgName}}",
|
|
1014
|
+
body: "{{inviterName}} te invit\xF3 a unirte como {{role}}.",
|
|
1015
|
+
actionUrl: "{{actionUrl}}",
|
|
1016
|
+
actionText: "Aceptar"
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
767
1019
|
}
|
|
768
1020
|
});
|
|
769
1021
|
var MentionTemplate = defineTemplate({
|
|
@@ -788,6 +1040,30 @@ var MentionTemplate = defineTemplate({
|
|
|
788
1040
|
title: "{{mentionerName}} mentioned you",
|
|
789
1041
|
body: "{{preview}}"
|
|
790
1042
|
}
|
|
1043
|
+
},
|
|
1044
|
+
localeChannels: {
|
|
1045
|
+
fr: {
|
|
1046
|
+
inApp: {
|
|
1047
|
+
title: "{{mentionerName}} vous a mentionn\xE9",
|
|
1048
|
+
body: "Dans {{context}}\u202F: \xAB\u202F{{preview}}\u202F\xBB",
|
|
1049
|
+
actionUrl: "{{actionUrl}}"
|
|
1050
|
+
},
|
|
1051
|
+
push: {
|
|
1052
|
+
title: "{{mentionerName}} vous a mentionn\xE9",
|
|
1053
|
+
body: "{{preview}}"
|
|
1054
|
+
}
|
|
1055
|
+
},
|
|
1056
|
+
es: {
|
|
1057
|
+
inApp: {
|
|
1058
|
+
title: "{{mentionerName}} te mencion\xF3",
|
|
1059
|
+
body: 'En {{context}}: "{{preview}}"',
|
|
1060
|
+
actionUrl: "{{actionUrl}}"
|
|
1061
|
+
},
|
|
1062
|
+
push: {
|
|
1063
|
+
title: "{{mentionerName}} te mencion\xF3",
|
|
1064
|
+
body: "{{preview}}"
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
791
1067
|
}
|
|
792
1068
|
});
|
|
793
1069
|
|
|
@@ -1,3 +1,183 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, {
|
|
5
|
+
get: all[name],
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
set: (newValue) => all[name] = () => newValue
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
|
+
|
|
13
|
+
// src/i18n/catalogs/en.ts
|
|
14
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
|
|
15
|
+
var enMessages;
|
|
16
|
+
var init_en = __esm(() => {
|
|
17
|
+
enMessages = defineTranslation({
|
|
18
|
+
meta: {
|
|
19
|
+
key: "notifications.messages",
|
|
20
|
+
version: "1.0.0",
|
|
21
|
+
domain: "notifications",
|
|
22
|
+
description: "Template and channel strings for the notifications module",
|
|
23
|
+
owners: ["platform"],
|
|
24
|
+
stability: "experimental"
|
|
25
|
+
},
|
|
26
|
+
locale: "en",
|
|
27
|
+
fallback: "en",
|
|
28
|
+
messages: {
|
|
29
|
+
"template.welcome.name": {
|
|
30
|
+
value: "Welcome",
|
|
31
|
+
description: "Welcome template display name"
|
|
32
|
+
},
|
|
33
|
+
"template.welcome.description": {
|
|
34
|
+
value: "Sent when a user signs up.",
|
|
35
|
+
description: "Welcome template description"
|
|
36
|
+
},
|
|
37
|
+
"template.orgInvite.name": {
|
|
38
|
+
value: "Organization Invitation",
|
|
39
|
+
description: "Org invite template display name"
|
|
40
|
+
},
|
|
41
|
+
"template.orgInvite.description": {
|
|
42
|
+
value: "Sent when a user is invited to an organization.",
|
|
43
|
+
description: "Org invite template description"
|
|
44
|
+
},
|
|
45
|
+
"template.mention.name": {
|
|
46
|
+
value: "Mention",
|
|
47
|
+
description: "Mention template display name"
|
|
48
|
+
},
|
|
49
|
+
"template.mention.description": {
|
|
50
|
+
value: "Sent when a user is mentioned.",
|
|
51
|
+
description: "Mention template description"
|
|
52
|
+
},
|
|
53
|
+
"channel.webhook.noUrl": {
|
|
54
|
+
value: "No webhook URL configured",
|
|
55
|
+
description: "Error when webhook channel has no URL"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// src/i18n/catalogs/fr.ts
|
|
62
|
+
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
|
|
63
|
+
var frMessages;
|
|
64
|
+
var init_fr = __esm(() => {
|
|
65
|
+
frMessages = defineTranslation2({
|
|
66
|
+
meta: {
|
|
67
|
+
key: "notifications.messages",
|
|
68
|
+
version: "1.0.0",
|
|
69
|
+
domain: "notifications",
|
|
70
|
+
description: "Template and channel strings (French)",
|
|
71
|
+
owners: ["platform"],
|
|
72
|
+
stability: "experimental"
|
|
73
|
+
},
|
|
74
|
+
locale: "fr",
|
|
75
|
+
fallback: "en",
|
|
76
|
+
messages: {
|
|
77
|
+
"template.welcome.name": {
|
|
78
|
+
value: "Bienvenue",
|
|
79
|
+
description: "Welcome template display name"
|
|
80
|
+
},
|
|
81
|
+
"template.welcome.description": {
|
|
82
|
+
value: "Envoyé lorsqu'un utilisateur s'inscrit.",
|
|
83
|
+
description: "Welcome template description"
|
|
84
|
+
},
|
|
85
|
+
"template.orgInvite.name": {
|
|
86
|
+
value: "Invitation à l'organisation",
|
|
87
|
+
description: "Org invite template display name"
|
|
88
|
+
},
|
|
89
|
+
"template.orgInvite.description": {
|
|
90
|
+
value: "Envoyé lorsqu'un utilisateur est invité à une organisation.",
|
|
91
|
+
description: "Org invite template description"
|
|
92
|
+
},
|
|
93
|
+
"template.mention.name": {
|
|
94
|
+
value: "Mention",
|
|
95
|
+
description: "Mention template display name"
|
|
96
|
+
},
|
|
97
|
+
"template.mention.description": {
|
|
98
|
+
value: "Envoyé lorsqu'un utilisateur est mentionné.",
|
|
99
|
+
description: "Mention template description"
|
|
100
|
+
},
|
|
101
|
+
"channel.webhook.noUrl": {
|
|
102
|
+
value: "Aucune URL de webhook configurée",
|
|
103
|
+
description: "Error when webhook channel has no URL"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// src/i18n/catalogs/es.ts
|
|
110
|
+
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
|
|
111
|
+
var esMessages;
|
|
112
|
+
var init_es = __esm(() => {
|
|
113
|
+
esMessages = defineTranslation3({
|
|
114
|
+
meta: {
|
|
115
|
+
key: "notifications.messages",
|
|
116
|
+
version: "1.0.0",
|
|
117
|
+
domain: "notifications",
|
|
118
|
+
description: "Template and channel strings (Spanish)",
|
|
119
|
+
owners: ["platform"],
|
|
120
|
+
stability: "experimental"
|
|
121
|
+
},
|
|
122
|
+
locale: "es",
|
|
123
|
+
fallback: "en",
|
|
124
|
+
messages: {
|
|
125
|
+
"template.welcome.name": {
|
|
126
|
+
value: "Bienvenida",
|
|
127
|
+
description: "Welcome template display name"
|
|
128
|
+
},
|
|
129
|
+
"template.welcome.description": {
|
|
130
|
+
value: "Enviado cuando un usuario se registra.",
|
|
131
|
+
description: "Welcome template description"
|
|
132
|
+
},
|
|
133
|
+
"template.orgInvite.name": {
|
|
134
|
+
value: "Invitación a la organización",
|
|
135
|
+
description: "Org invite template display name"
|
|
136
|
+
},
|
|
137
|
+
"template.orgInvite.description": {
|
|
138
|
+
value: "Enviado cuando un usuario es invitado a una organización.",
|
|
139
|
+
description: "Org invite template description"
|
|
140
|
+
},
|
|
141
|
+
"template.mention.name": {
|
|
142
|
+
value: "Mención",
|
|
143
|
+
description: "Mention template display name"
|
|
144
|
+
},
|
|
145
|
+
"template.mention.description": {
|
|
146
|
+
value: "Enviado cuando un usuario es mencionado.",
|
|
147
|
+
description: "Mention template description"
|
|
148
|
+
},
|
|
149
|
+
"channel.webhook.noUrl": {
|
|
150
|
+
value: "No se ha configurado una URL de webhook",
|
|
151
|
+
description: "Error when webhook channel has no URL"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// src/i18n/messages.ts
|
|
158
|
+
var exports_messages = {};
|
|
159
|
+
__export(exports_messages, {
|
|
160
|
+
resetI18nRegistry: () => resetI18nRegistry,
|
|
161
|
+
getDefaultI18n: () => getDefaultI18n,
|
|
162
|
+
createNotificationsI18n: () => createNotificationsI18n
|
|
163
|
+
});
|
|
164
|
+
import {
|
|
165
|
+
createI18nFactory
|
|
166
|
+
} from "@contractspec/lib.contracts-spec/translations";
|
|
167
|
+
var factory, createNotificationsI18n, getDefaultI18n, resetI18nRegistry;
|
|
168
|
+
var init_messages = __esm(() => {
|
|
169
|
+
init_en();
|
|
170
|
+
init_fr();
|
|
171
|
+
init_es();
|
|
172
|
+
factory = createI18nFactory({
|
|
173
|
+
specKey: "notifications.messages",
|
|
174
|
+
catalogs: [enMessages, frMessages, esMessages]
|
|
175
|
+
});
|
|
176
|
+
createNotificationsI18n = factory.create;
|
|
177
|
+
getDefaultI18n = factory.getDefault;
|
|
178
|
+
resetI18nRegistry = factory.resetRegistry;
|
|
179
|
+
});
|
|
180
|
+
|
|
1
181
|
// src/channels/index.ts
|
|
2
182
|
class InAppChannel {
|
|
3
183
|
channelId = "IN_APP";
|
|
@@ -46,11 +226,17 @@ class PushChannel {
|
|
|
46
226
|
|
|
47
227
|
class WebhookChannel {
|
|
48
228
|
channelId = "WEBHOOK";
|
|
229
|
+
locale;
|
|
230
|
+
constructor(options) {
|
|
231
|
+
this.locale = options?.locale;
|
|
232
|
+
}
|
|
49
233
|
async send(notification) {
|
|
50
234
|
if (!notification.webhook?.url) {
|
|
235
|
+
const { createNotificationsI18n: createNotificationsI18n2 } = await Promise.resolve().then(() => (init_messages(), exports_messages));
|
|
236
|
+
const i18n = createNotificationsI18n2(this.locale);
|
|
51
237
|
return {
|
|
52
238
|
success: false,
|
|
53
|
-
responseMessage: "
|
|
239
|
+
responseMessage: i18n.t("channel.webhook.noUrl")
|
|
54
240
|
};
|
|
55
241
|
}
|
|
56
242
|
try {
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, {
|
|
5
|
+
get: all[name],
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
set: (newValue) => all[name] = () => newValue
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
|
+
|
|
1
13
|
// src/contracts/index.ts
|
|
2
14
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
3
15
|
import {
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, {
|
|
5
|
+
get: all[name],
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
set: (newValue) => all[name] = () => newValue
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
|
+
|
|
1
13
|
// src/entities/index.ts
|
|
2
14
|
import {
|
|
3
15
|
defineEntity,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, {
|
|
5
|
+
get: all[name],
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
set: (newValue) => all[name] = () => newValue
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
|
+
|
|
13
|
+
// src/i18n/catalogs/en.ts
|
|
14
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
|
|
15
|
+
var enMessages;
|
|
16
|
+
var init_en = __esm(() => {
|
|
17
|
+
enMessages = defineTranslation({
|
|
18
|
+
meta: {
|
|
19
|
+
key: "notifications.messages",
|
|
20
|
+
version: "1.0.0",
|
|
21
|
+
domain: "notifications",
|
|
22
|
+
description: "Template and channel strings for the notifications module",
|
|
23
|
+
owners: ["platform"],
|
|
24
|
+
stability: "experimental"
|
|
25
|
+
},
|
|
26
|
+
locale: "en",
|
|
27
|
+
fallback: "en",
|
|
28
|
+
messages: {
|
|
29
|
+
"template.welcome.name": {
|
|
30
|
+
value: "Welcome",
|
|
31
|
+
description: "Welcome template display name"
|
|
32
|
+
},
|
|
33
|
+
"template.welcome.description": {
|
|
34
|
+
value: "Sent when a user signs up.",
|
|
35
|
+
description: "Welcome template description"
|
|
36
|
+
},
|
|
37
|
+
"template.orgInvite.name": {
|
|
38
|
+
value: "Organization Invitation",
|
|
39
|
+
description: "Org invite template display name"
|
|
40
|
+
},
|
|
41
|
+
"template.orgInvite.description": {
|
|
42
|
+
value: "Sent when a user is invited to an organization.",
|
|
43
|
+
description: "Org invite template description"
|
|
44
|
+
},
|
|
45
|
+
"template.mention.name": {
|
|
46
|
+
value: "Mention",
|
|
47
|
+
description: "Mention template display name"
|
|
48
|
+
},
|
|
49
|
+
"template.mention.description": {
|
|
50
|
+
value: "Sent when a user is mentioned.",
|
|
51
|
+
description: "Mention template description"
|
|
52
|
+
},
|
|
53
|
+
"channel.webhook.noUrl": {
|
|
54
|
+
value: "No webhook URL configured",
|
|
55
|
+
description: "Error when webhook channel has no URL"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
init_en();
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
enMessages
|
|
64
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, {
|
|
5
|
+
get: all[name],
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
set: (newValue) => all[name] = () => newValue
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
|
+
|
|
13
|
+
// src/i18n/catalogs/es.ts
|
|
14
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
|
|
15
|
+
var esMessages;
|
|
16
|
+
var init_es = __esm(() => {
|
|
17
|
+
esMessages = defineTranslation({
|
|
18
|
+
meta: {
|
|
19
|
+
key: "notifications.messages",
|
|
20
|
+
version: "1.0.0",
|
|
21
|
+
domain: "notifications",
|
|
22
|
+
description: "Template and channel strings (Spanish)",
|
|
23
|
+
owners: ["platform"],
|
|
24
|
+
stability: "experimental"
|
|
25
|
+
},
|
|
26
|
+
locale: "es",
|
|
27
|
+
fallback: "en",
|
|
28
|
+
messages: {
|
|
29
|
+
"template.welcome.name": {
|
|
30
|
+
value: "Bienvenida",
|
|
31
|
+
description: "Welcome template display name"
|
|
32
|
+
},
|
|
33
|
+
"template.welcome.description": {
|
|
34
|
+
value: "Enviado cuando un usuario se registra.",
|
|
35
|
+
description: "Welcome template description"
|
|
36
|
+
},
|
|
37
|
+
"template.orgInvite.name": {
|
|
38
|
+
value: "Invitación a la organización",
|
|
39
|
+
description: "Org invite template display name"
|
|
40
|
+
},
|
|
41
|
+
"template.orgInvite.description": {
|
|
42
|
+
value: "Enviado cuando un usuario es invitado a una organización.",
|
|
43
|
+
description: "Org invite template description"
|
|
44
|
+
},
|
|
45
|
+
"template.mention.name": {
|
|
46
|
+
value: "Mención",
|
|
47
|
+
description: "Mention template display name"
|
|
48
|
+
},
|
|
49
|
+
"template.mention.description": {
|
|
50
|
+
value: "Enviado cuando un usuario es mencionado.",
|
|
51
|
+
description: "Mention template description"
|
|
52
|
+
},
|
|
53
|
+
"channel.webhook.noUrl": {
|
|
54
|
+
value: "No se ha configurado una URL de webhook",
|
|
55
|
+
description: "Error when webhook channel has no URL"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
init_es();
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
esMessages
|
|
64
|
+
};
|