@adatechnology/notification-contracts 0.2.1 → 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 +636 -5
- package/dist/index.d.ts +636 -5
- package/dist/index.js +103 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37,7 +37,8 @@ var DEVICE_PLATFORM = {
|
|
|
37
37
|
};
|
|
38
38
|
var PUSH_DRIVER = {
|
|
39
39
|
EXPO: "expo",
|
|
40
|
-
FCM: "fcm"
|
|
40
|
+
FCM: "fcm",
|
|
41
|
+
WEBPUSH: "webpush"
|
|
41
42
|
};
|
|
42
43
|
var EMAIL_DRIVER = {
|
|
43
44
|
SMTP: "smtp",
|
|
@@ -159,6 +160,64 @@ var deliveryWebhookSchema = z.object({
|
|
|
159
160
|
occurredAt: z.coerce.date(),
|
|
160
161
|
suppressionReason: z.nativeEnum(SUPPRESSION_REASON).optional()
|
|
161
162
|
});
|
|
163
|
+
var webPushKeysSchema = z.object({
|
|
164
|
+
p256dh: z.string().min(1),
|
|
165
|
+
auth: z.string().min(1)
|
|
166
|
+
});
|
|
167
|
+
var webPushSubscriptionSchema = z.object({
|
|
168
|
+
endpoint: z.string().url(),
|
|
169
|
+
keys: webPushKeysSchema,
|
|
170
|
+
expirationTime: z.number().nullable().optional()
|
|
171
|
+
});
|
|
172
|
+
var pushNotificationPayloadSchema = z.object({
|
|
173
|
+
title: z.string().min(1).max(256),
|
|
174
|
+
body: z.string().min(1).max(4096),
|
|
175
|
+
icon: z.string().url().optional(),
|
|
176
|
+
badge: z.number().int().nonnegative().optional(),
|
|
177
|
+
image: z.string().url().optional(),
|
|
178
|
+
tag: z.string().max(64).optional(),
|
|
179
|
+
url: z.string().optional(),
|
|
180
|
+
data: z.record(z.unknown()).optional()
|
|
181
|
+
});
|
|
182
|
+
var sendPushDirectTargetSchema = z.discriminatedUnion("type", [
|
|
183
|
+
z.object({
|
|
184
|
+
type: z.literal("token"),
|
|
185
|
+
token: z.string().min(1),
|
|
186
|
+
platform: z.nativeEnum(DEVICE_PLATFORM),
|
|
187
|
+
driver: z.nativeEnum(PUSH_DRIVER).optional()
|
|
188
|
+
}),
|
|
189
|
+
z.object({
|
|
190
|
+
type: z.literal("user"),
|
|
191
|
+
userId: z.string().min(1)
|
|
192
|
+
}),
|
|
193
|
+
z.object({
|
|
194
|
+
type: z.literal("subscription"),
|
|
195
|
+
subscription: webPushSubscriptionSchema
|
|
196
|
+
})
|
|
197
|
+
]);
|
|
198
|
+
var sendPushDirectSchema = z.object({
|
|
199
|
+
target: sendPushDirectTargetSchema,
|
|
200
|
+
notification: pushNotificationPayloadSchema,
|
|
201
|
+
dedupeKey: z.string().max(256).optional()
|
|
202
|
+
});
|
|
203
|
+
var broadcastPushFilterSchema = z.object({
|
|
204
|
+
topic: z.string().max(128).optional(),
|
|
205
|
+
tags: z.array(z.string().max(64)).optional(),
|
|
206
|
+
platform: z.nativeEnum(DEVICE_PLATFORM).optional()
|
|
207
|
+
});
|
|
208
|
+
var broadcastPushSchema = z.object({
|
|
209
|
+
filter: broadcastPushFilterSchema.optional(),
|
|
210
|
+
notification: pushNotificationPayloadSchema
|
|
211
|
+
});
|
|
212
|
+
var registerPushSubscriptionSchema = z.object({
|
|
213
|
+
platform: z.nativeEnum(DEVICE_PLATFORM),
|
|
214
|
+
driver: z.nativeEnum(PUSH_DRIVER),
|
|
215
|
+
subscription: webPushSubscriptionSchema,
|
|
216
|
+
appVersion: z.string().max(32).optional(),
|
|
217
|
+
locale: z.string().min(2).max(16).optional(),
|
|
218
|
+
timezone: z.string().min(1).max(64).optional(),
|
|
219
|
+
tags: z.array(z.string().max(64)).optional()
|
|
220
|
+
});
|
|
162
221
|
|
|
163
222
|
// src/events.ts
|
|
164
223
|
var NOTIFICATION_EVENT = {
|
|
@@ -197,7 +256,10 @@ var NOTIFICATION_ERROR_CODES = {
|
|
|
197
256
|
DEVICE_NOT_FOUND: "NOTIFICATION_DEVICE_NOT_FOUND",
|
|
198
257
|
THROTTLED: "NOTIFICATION_THROTTLED",
|
|
199
258
|
CONFIG_MISSING: "NOTIFICATION_CONFIG_MISSING",
|
|
200
|
-
TEMPLATE_UNKNOWN_VARIABLE: "NOTIFICATION_TEMPLATE_UNKNOWN_VARIABLE"
|
|
259
|
+
TEMPLATE_UNKNOWN_VARIABLE: "NOTIFICATION_TEMPLATE_UNKNOWN_VARIABLE",
|
|
260
|
+
WEBPUSH_ENCRYPTION_FAILED: "NOTIFICATION_WEBPUSH_ENCRYPTION_FAILED",
|
|
261
|
+
INVALID_VAPID_KEYS: "NOTIFICATION_INVALID_VAPID_KEYS",
|
|
262
|
+
SUBSCRIPTION_NOT_FOUND: "NOTIFICATION_SUBSCRIPTION_NOT_FOUND"
|
|
201
263
|
};
|
|
202
264
|
var TemplateIdNotFoundError = class extends NotificationError {
|
|
203
265
|
static {
|
|
@@ -346,6 +408,33 @@ var ConfigMissingError = class extends NotificationError {
|
|
|
346
408
|
}), this.field = field;
|
|
347
409
|
}
|
|
348
410
|
};
|
|
411
|
+
var WebPushEncryptionError = class extends NotificationError {
|
|
412
|
+
static {
|
|
413
|
+
__name(this, "WebPushEncryptionError");
|
|
414
|
+
}
|
|
415
|
+
constructor(message, details) {
|
|
416
|
+
super(message, 500, NOTIFICATION_ERROR_CODES.WEBPUSH_ENCRYPTION_FAILED, details);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
var InvalidVapidKeysError = class extends NotificationError {
|
|
420
|
+
static {
|
|
421
|
+
__name(this, "InvalidVapidKeysError");
|
|
422
|
+
}
|
|
423
|
+
constructor(message) {
|
|
424
|
+
super(message, 500, NOTIFICATION_ERROR_CODES.INVALID_VAPID_KEYS);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
var SubscriptionNotFoundError = class extends NotificationError {
|
|
428
|
+
static {
|
|
429
|
+
__name(this, "SubscriptionNotFoundError");
|
|
430
|
+
}
|
|
431
|
+
endpoint;
|
|
432
|
+
constructor(endpoint) {
|
|
433
|
+
super(`Assinatura de push n\xE3o encontrada.`, 404, NOTIFICATION_ERROR_CODES.SUBSCRIPTION_NOT_FOUND, {
|
|
434
|
+
endpoint
|
|
435
|
+
}), this.endpoint = endpoint;
|
|
436
|
+
}
|
|
437
|
+
};
|
|
349
438
|
|
|
350
439
|
// src/whatsappDriver.ts
|
|
351
440
|
var INVALID_TARGET_CODES = /* @__PURE__ */ new Set([
|
|
@@ -931,6 +1020,7 @@ export {
|
|
|
931
1020
|
EMAIL_ATTACHMENT_MAX_COUNT,
|
|
932
1021
|
EMAIL_DRIVER,
|
|
933
1022
|
INTRUSIVE_CHANNELS,
|
|
1023
|
+
InvalidVapidKeysError,
|
|
934
1024
|
InvalidWebhookSignatureError,
|
|
935
1025
|
NOTIFICATION_CATEGORY_HINT,
|
|
936
1026
|
NOTIFICATION_CHANNEL,
|
|
@@ -953,6 +1043,7 @@ export {
|
|
|
953
1043
|
STANDARD_EMAIL_THEME,
|
|
954
1044
|
STANDARD_EMAIL_VARIABLES,
|
|
955
1045
|
SUPPRESSION_REASON,
|
|
1046
|
+
SubscriptionNotFoundError,
|
|
956
1047
|
SuppressedTargetError,
|
|
957
1048
|
TEMPLATE_CONSTRAINTS_BY_CHANNEL,
|
|
958
1049
|
TEMPLATE_VARIABLE_KIND,
|
|
@@ -960,7 +1051,10 @@ export {
|
|
|
960
1051
|
TemplateNotFoundError,
|
|
961
1052
|
ThrottledError,
|
|
962
1053
|
UnknownTemplateVariablesError,
|
|
1054
|
+
WebPushEncryptionError,
|
|
963
1055
|
assessStandardEmailTemplate,
|
|
1056
|
+
broadcastPushFilterSchema,
|
|
1057
|
+
broadcastPushSchema,
|
|
964
1058
|
buildInitials,
|
|
965
1059
|
buildPreviewPayload,
|
|
966
1060
|
categoryPolicyEntrySchema,
|
|
@@ -978,14 +1072,20 @@ export {
|
|
|
978
1072
|
interpolateTemplate,
|
|
979
1073
|
listNotificationsQuerySchema,
|
|
980
1074
|
preferenceEntrySchema,
|
|
1075
|
+
pushNotificationPayloadSchema,
|
|
981
1076
|
registerDeviceSchema,
|
|
1077
|
+
registerPushSubscriptionSchema,
|
|
982
1078
|
renderEmailLogoHtml,
|
|
983
1079
|
renderEmailMarksHtml,
|
|
984
1080
|
renderStandardEmail,
|
|
985
1081
|
renderTemplate,
|
|
986
1082
|
sendNotificationSchema,
|
|
1083
|
+
sendPushDirectSchema,
|
|
1084
|
+
sendPushDirectTargetSchema,
|
|
987
1085
|
updateCategoryPoliciesSchema,
|
|
988
1086
|
updatePreferencesSchema,
|
|
989
|
-
upsertTemplateSchema
|
|
1087
|
+
upsertTemplateSchema,
|
|
1088
|
+
webPushKeysSchema,
|
|
1089
|
+
webPushSubscriptionSchema
|
|
990
1090
|
};
|
|
991
1091
|
//# sourceMappingURL=index.js.map
|