@adatechnology/notification-contracts 0.3.0 → 0.4.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/index.cjs +115 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +630 -5
- package/dist/index.d.ts +630 -5
- package/dist/index.js +103 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ __export(index_exports, {
|
|
|
31
31
|
EMAIL_ATTACHMENT_MAX_COUNT: () => EMAIL_ATTACHMENT_MAX_COUNT,
|
|
32
32
|
EMAIL_DRIVER: () => EMAIL_DRIVER,
|
|
33
33
|
INTRUSIVE_CHANNELS: () => INTRUSIVE_CHANNELS,
|
|
34
|
+
InvalidVapidKeysError: () => InvalidVapidKeysError,
|
|
34
35
|
InvalidWebhookSignatureError: () => InvalidWebhookSignatureError,
|
|
35
36
|
NOTIFICATION_CATEGORY_HINT: () => NOTIFICATION_CATEGORY_HINT,
|
|
36
37
|
NOTIFICATION_CHANNEL: () => NOTIFICATION_CHANNEL,
|
|
@@ -53,6 +54,7 @@ __export(index_exports, {
|
|
|
53
54
|
STANDARD_EMAIL_THEME: () => STANDARD_EMAIL_THEME,
|
|
54
55
|
STANDARD_EMAIL_VARIABLES: () => STANDARD_EMAIL_VARIABLES,
|
|
55
56
|
SUPPRESSION_REASON: () => SUPPRESSION_REASON,
|
|
57
|
+
SubscriptionNotFoundError: () => SubscriptionNotFoundError,
|
|
56
58
|
SuppressedTargetError: () => SuppressedTargetError,
|
|
57
59
|
TEMPLATE_CONSTRAINTS_BY_CHANNEL: () => TEMPLATE_CONSTRAINTS_BY_CHANNEL,
|
|
58
60
|
TEMPLATE_VARIABLE_KIND: () => TEMPLATE_VARIABLE_KIND,
|
|
@@ -60,7 +62,10 @@ __export(index_exports, {
|
|
|
60
62
|
TemplateNotFoundError: () => TemplateNotFoundError,
|
|
61
63
|
ThrottledError: () => ThrottledError,
|
|
62
64
|
UnknownTemplateVariablesError: () => UnknownTemplateVariablesError,
|
|
65
|
+
WebPushEncryptionError: () => WebPushEncryptionError,
|
|
63
66
|
assessStandardEmailTemplate: () => assessStandardEmailTemplate,
|
|
67
|
+
broadcastPushFilterSchema: () => broadcastPushFilterSchema,
|
|
68
|
+
broadcastPushSchema: () => broadcastPushSchema,
|
|
64
69
|
buildInitials: () => buildInitials,
|
|
65
70
|
buildPreviewPayload: () => buildPreviewPayload,
|
|
66
71
|
categoryPolicyEntrySchema: () => categoryPolicyEntrySchema,
|
|
@@ -78,15 +83,21 @@ __export(index_exports, {
|
|
|
78
83
|
interpolateTemplate: () => interpolateTemplate,
|
|
79
84
|
listNotificationsQuerySchema: () => listNotificationsQuerySchema,
|
|
80
85
|
preferenceEntrySchema: () => preferenceEntrySchema,
|
|
86
|
+
pushNotificationPayloadSchema: () => pushNotificationPayloadSchema,
|
|
81
87
|
registerDeviceSchema: () => registerDeviceSchema,
|
|
88
|
+
registerPushSubscriptionSchema: () => registerPushSubscriptionSchema,
|
|
82
89
|
renderEmailLogoHtml: () => renderEmailLogoHtml,
|
|
83
90
|
renderEmailMarksHtml: () => renderEmailMarksHtml,
|
|
84
91
|
renderStandardEmail: () => renderStandardEmail,
|
|
85
92
|
renderTemplate: () => renderTemplate,
|
|
86
93
|
sendNotificationSchema: () => sendNotificationSchema,
|
|
94
|
+
sendPushDirectSchema: () => sendPushDirectSchema,
|
|
95
|
+
sendPushDirectTargetSchema: () => sendPushDirectTargetSchema,
|
|
87
96
|
updateCategoryPoliciesSchema: () => updateCategoryPoliciesSchema,
|
|
88
97
|
updatePreferencesSchema: () => updatePreferencesSchema,
|
|
89
|
-
upsertTemplateSchema: () => upsertTemplateSchema
|
|
98
|
+
upsertTemplateSchema: () => upsertTemplateSchema,
|
|
99
|
+
webPushKeysSchema: () => webPushKeysSchema,
|
|
100
|
+
webPushSubscriptionSchema: () => webPushSubscriptionSchema
|
|
90
101
|
});
|
|
91
102
|
module.exports = __toCommonJS(index_exports);
|
|
92
103
|
|
|
@@ -126,7 +137,8 @@ var DEVICE_PLATFORM = {
|
|
|
126
137
|
};
|
|
127
138
|
var PUSH_DRIVER = {
|
|
128
139
|
EXPO: "expo",
|
|
129
|
-
FCM: "fcm"
|
|
140
|
+
FCM: "fcm",
|
|
141
|
+
WEBPUSH: "webpush"
|
|
130
142
|
};
|
|
131
143
|
var EMAIL_DRIVER = {
|
|
132
144
|
SMTP: "smtp",
|
|
@@ -248,6 +260,64 @@ var deliveryWebhookSchema = import_zod.z.object({
|
|
|
248
260
|
occurredAt: import_zod.z.coerce.date(),
|
|
249
261
|
suppressionReason: import_zod.z.nativeEnum(SUPPRESSION_REASON).optional()
|
|
250
262
|
});
|
|
263
|
+
var webPushKeysSchema = import_zod.z.object({
|
|
264
|
+
p256dh: import_zod.z.string().min(1),
|
|
265
|
+
auth: import_zod.z.string().min(1)
|
|
266
|
+
});
|
|
267
|
+
var webPushSubscriptionSchema = import_zod.z.object({
|
|
268
|
+
endpoint: import_zod.z.string().url(),
|
|
269
|
+
keys: webPushKeysSchema,
|
|
270
|
+
expirationTime: import_zod.z.number().nullable().optional()
|
|
271
|
+
});
|
|
272
|
+
var pushNotificationPayloadSchema = import_zod.z.object({
|
|
273
|
+
title: import_zod.z.string().min(1).max(256),
|
|
274
|
+
body: import_zod.z.string().min(1).max(4096),
|
|
275
|
+
icon: import_zod.z.string().url().optional(),
|
|
276
|
+
badge: import_zod.z.number().int().nonnegative().optional(),
|
|
277
|
+
image: import_zod.z.string().url().optional(),
|
|
278
|
+
tag: import_zod.z.string().max(64).optional(),
|
|
279
|
+
url: import_zod.z.string().optional(),
|
|
280
|
+
data: import_zod.z.record(import_zod.z.unknown()).optional()
|
|
281
|
+
});
|
|
282
|
+
var sendPushDirectTargetSchema = import_zod.z.discriminatedUnion("type", [
|
|
283
|
+
import_zod.z.object({
|
|
284
|
+
type: import_zod.z.literal("token"),
|
|
285
|
+
token: import_zod.z.string().min(1),
|
|
286
|
+
platform: import_zod.z.nativeEnum(DEVICE_PLATFORM),
|
|
287
|
+
driver: import_zod.z.nativeEnum(PUSH_DRIVER).optional()
|
|
288
|
+
}),
|
|
289
|
+
import_zod.z.object({
|
|
290
|
+
type: import_zod.z.literal("user"),
|
|
291
|
+
userId: import_zod.z.string().min(1)
|
|
292
|
+
}),
|
|
293
|
+
import_zod.z.object({
|
|
294
|
+
type: import_zod.z.literal("subscription"),
|
|
295
|
+
subscription: webPushSubscriptionSchema
|
|
296
|
+
})
|
|
297
|
+
]);
|
|
298
|
+
var sendPushDirectSchema = import_zod.z.object({
|
|
299
|
+
target: sendPushDirectTargetSchema,
|
|
300
|
+
notification: pushNotificationPayloadSchema,
|
|
301
|
+
dedupeKey: import_zod.z.string().max(256).optional()
|
|
302
|
+
});
|
|
303
|
+
var broadcastPushFilterSchema = import_zod.z.object({
|
|
304
|
+
topic: import_zod.z.string().max(128).optional(),
|
|
305
|
+
tags: import_zod.z.array(import_zod.z.string().max(64)).optional(),
|
|
306
|
+
platform: import_zod.z.nativeEnum(DEVICE_PLATFORM).optional()
|
|
307
|
+
});
|
|
308
|
+
var broadcastPushSchema = import_zod.z.object({
|
|
309
|
+
filter: broadcastPushFilterSchema.optional(),
|
|
310
|
+
notification: pushNotificationPayloadSchema
|
|
311
|
+
});
|
|
312
|
+
var registerPushSubscriptionSchema = import_zod.z.object({
|
|
313
|
+
platform: import_zod.z.nativeEnum(DEVICE_PLATFORM),
|
|
314
|
+
driver: import_zod.z.nativeEnum(PUSH_DRIVER),
|
|
315
|
+
subscription: webPushSubscriptionSchema,
|
|
316
|
+
appVersion: import_zod.z.string().max(32).optional(),
|
|
317
|
+
locale: import_zod.z.string().min(2).max(16).optional(),
|
|
318
|
+
timezone: import_zod.z.string().min(1).max(64).optional(),
|
|
319
|
+
tags: import_zod.z.array(import_zod.z.string().max(64)).optional()
|
|
320
|
+
});
|
|
251
321
|
|
|
252
322
|
// src/events.ts
|
|
253
323
|
var NOTIFICATION_EVENT = {
|
|
@@ -286,7 +356,10 @@ var NOTIFICATION_ERROR_CODES = {
|
|
|
286
356
|
DEVICE_NOT_FOUND: "NOTIFICATION_DEVICE_NOT_FOUND",
|
|
287
357
|
THROTTLED: "NOTIFICATION_THROTTLED",
|
|
288
358
|
CONFIG_MISSING: "NOTIFICATION_CONFIG_MISSING",
|
|
289
|
-
TEMPLATE_UNKNOWN_VARIABLE: "NOTIFICATION_TEMPLATE_UNKNOWN_VARIABLE"
|
|
359
|
+
TEMPLATE_UNKNOWN_VARIABLE: "NOTIFICATION_TEMPLATE_UNKNOWN_VARIABLE",
|
|
360
|
+
WEBPUSH_ENCRYPTION_FAILED: "NOTIFICATION_WEBPUSH_ENCRYPTION_FAILED",
|
|
361
|
+
INVALID_VAPID_KEYS: "NOTIFICATION_INVALID_VAPID_KEYS",
|
|
362
|
+
SUBSCRIPTION_NOT_FOUND: "NOTIFICATION_SUBSCRIPTION_NOT_FOUND"
|
|
290
363
|
};
|
|
291
364
|
var TemplateIdNotFoundError = class extends NotificationError {
|
|
292
365
|
static {
|
|
@@ -435,6 +508,33 @@ var ConfigMissingError = class extends NotificationError {
|
|
|
435
508
|
}), this.field = field;
|
|
436
509
|
}
|
|
437
510
|
};
|
|
511
|
+
var WebPushEncryptionError = class extends NotificationError {
|
|
512
|
+
static {
|
|
513
|
+
__name(this, "WebPushEncryptionError");
|
|
514
|
+
}
|
|
515
|
+
constructor(message, details) {
|
|
516
|
+
super(message, 500, NOTIFICATION_ERROR_CODES.WEBPUSH_ENCRYPTION_FAILED, details);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
var InvalidVapidKeysError = class extends NotificationError {
|
|
520
|
+
static {
|
|
521
|
+
__name(this, "InvalidVapidKeysError");
|
|
522
|
+
}
|
|
523
|
+
constructor(message) {
|
|
524
|
+
super(message, 500, NOTIFICATION_ERROR_CODES.INVALID_VAPID_KEYS);
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
var SubscriptionNotFoundError = class extends NotificationError {
|
|
528
|
+
static {
|
|
529
|
+
__name(this, "SubscriptionNotFoundError");
|
|
530
|
+
}
|
|
531
|
+
endpoint;
|
|
532
|
+
constructor(endpoint) {
|
|
533
|
+
super(`Assinatura de push n\xE3o encontrada.`, 404, NOTIFICATION_ERROR_CODES.SUBSCRIPTION_NOT_FOUND, {
|
|
534
|
+
endpoint
|
|
535
|
+
}), this.endpoint = endpoint;
|
|
536
|
+
}
|
|
537
|
+
};
|
|
438
538
|
|
|
439
539
|
// src/whatsappDriver.ts
|
|
440
540
|
var INVALID_TARGET_CODES = /* @__PURE__ */ new Set([
|
|
@@ -1021,6 +1121,7 @@ __name(renderStandardEmail, "renderStandardEmail");
|
|
|
1021
1121
|
EMAIL_ATTACHMENT_MAX_COUNT,
|
|
1022
1122
|
EMAIL_DRIVER,
|
|
1023
1123
|
INTRUSIVE_CHANNELS,
|
|
1124
|
+
InvalidVapidKeysError,
|
|
1024
1125
|
InvalidWebhookSignatureError,
|
|
1025
1126
|
NOTIFICATION_CATEGORY_HINT,
|
|
1026
1127
|
NOTIFICATION_CHANNEL,
|
|
@@ -1043,6 +1144,7 @@ __name(renderStandardEmail, "renderStandardEmail");
|
|
|
1043
1144
|
STANDARD_EMAIL_THEME,
|
|
1044
1145
|
STANDARD_EMAIL_VARIABLES,
|
|
1045
1146
|
SUPPRESSION_REASON,
|
|
1147
|
+
SubscriptionNotFoundError,
|
|
1046
1148
|
SuppressedTargetError,
|
|
1047
1149
|
TEMPLATE_CONSTRAINTS_BY_CHANNEL,
|
|
1048
1150
|
TEMPLATE_VARIABLE_KIND,
|
|
@@ -1050,7 +1152,10 @@ __name(renderStandardEmail, "renderStandardEmail");
|
|
|
1050
1152
|
TemplateNotFoundError,
|
|
1051
1153
|
ThrottledError,
|
|
1052
1154
|
UnknownTemplateVariablesError,
|
|
1155
|
+
WebPushEncryptionError,
|
|
1053
1156
|
assessStandardEmailTemplate,
|
|
1157
|
+
broadcastPushFilterSchema,
|
|
1158
|
+
broadcastPushSchema,
|
|
1054
1159
|
buildInitials,
|
|
1055
1160
|
buildPreviewPayload,
|
|
1056
1161
|
categoryPolicyEntrySchema,
|
|
@@ -1068,14 +1173,20 @@ __name(renderStandardEmail, "renderStandardEmail");
|
|
|
1068
1173
|
interpolateTemplate,
|
|
1069
1174
|
listNotificationsQuerySchema,
|
|
1070
1175
|
preferenceEntrySchema,
|
|
1176
|
+
pushNotificationPayloadSchema,
|
|
1071
1177
|
registerDeviceSchema,
|
|
1178
|
+
registerPushSubscriptionSchema,
|
|
1072
1179
|
renderEmailLogoHtml,
|
|
1073
1180
|
renderEmailMarksHtml,
|
|
1074
1181
|
renderStandardEmail,
|
|
1075
1182
|
renderTemplate,
|
|
1076
1183
|
sendNotificationSchema,
|
|
1184
|
+
sendPushDirectSchema,
|
|
1185
|
+
sendPushDirectTargetSchema,
|
|
1077
1186
|
updateCategoryPoliciesSchema,
|
|
1078
1187
|
updatePreferencesSchema,
|
|
1079
|
-
upsertTemplateSchema
|
|
1188
|
+
upsertTemplateSchema,
|
|
1189
|
+
webPushKeysSchema,
|
|
1190
|
+
webPushSubscriptionSchema
|
|
1080
1191
|
});
|
|
1081
1192
|
//# sourceMappingURL=index.cjs.map
|