@closerepo/notification-contracts 1.1.0 → 1.3.1
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.d.ts +323 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,16 @@ import { z } from "zod";
|
|
|
2
2
|
//#region src/index.d.ts
|
|
3
3
|
declare const notificationDeliveryContractVersionV1: 1;
|
|
4
4
|
declare const notificationDeliveryContractVersionV2: 2;
|
|
5
|
+
declare const notificationDeliveryContractVersionV3: 3;
|
|
6
|
+
declare const notificationDeliveryContractVersionV4: 4;
|
|
5
7
|
declare const notificationDeliveryRequestMaximumUtf8BytesV1: number;
|
|
6
8
|
declare const notificationDeliveryMaximumDeadlineMillisecondsV1: number;
|
|
7
9
|
declare const notificationDeliveryRequestMaximumUtf8BytesV2: number;
|
|
8
10
|
declare const notificationDeliveryMaximumDeadlineMillisecondsV2: number;
|
|
11
|
+
declare const notificationDeliveryRequestMaximumUtf8BytesV3: number;
|
|
12
|
+
declare const notificationDeliveryMaximumDeadlineMillisecondsV3: number;
|
|
13
|
+
declare const notificationDeliveryRequestMaximumUtf8BytesV4: number;
|
|
14
|
+
declare const notificationDeliveryMaximumDeadlineMillisecondsV4: number;
|
|
9
15
|
declare const notificationDeliveryStatesV1: readonly ["pending", "delivering", "partial", "delivered", "failed", "expired"];
|
|
10
16
|
declare const notificationDeliveryReasonsV1: readonly ["accepted", "enqueue_retry_wait", "in_progress", "partial_delivery", "complete", "retry_exhausted", "delivery_deadline_exceeded", "destination_configuration_unavailable"];
|
|
11
17
|
declare const notificationDestinationStatesV1: readonly ["pending", "delivering", "delivered", "failed", "expired"];
|
|
@@ -96,6 +102,188 @@ declare const notificationDeliveryRequestV2Schema: z.ZodObject<{
|
|
|
96
102
|
}, z.core.$strict>;
|
|
97
103
|
contractVersion: z.ZodLiteral<2>;
|
|
98
104
|
}, z.core.$strict>;
|
|
105
|
+
declare const structuredMessageSectionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
106
|
+
key: z.ZodString;
|
|
107
|
+
type: z.ZodLiteral<"text">;
|
|
108
|
+
label: z.ZodOptional<z.ZodString>;
|
|
109
|
+
value: z.ZodString;
|
|
110
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
111
|
+
key: z.ZodString;
|
|
112
|
+
type: z.ZodLiteral<"fields">;
|
|
113
|
+
items: z.ZodArray<z.ZodObject<{
|
|
114
|
+
label: z.ZodString;
|
|
115
|
+
value: z.ZodString;
|
|
116
|
+
}, z.core.$strict>>;
|
|
117
|
+
}, z.core.$strict>], "type">;
|
|
118
|
+
declare const structuredNotificationVariantSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
119
|
+
key: z.ZodLiteral<"source">;
|
|
120
|
+
locale: z.ZodLiteral<"und">;
|
|
121
|
+
title: z.ZodString;
|
|
122
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
123
|
+
key: z.ZodString;
|
|
124
|
+
type: z.ZodLiteral<"text">;
|
|
125
|
+
label: z.ZodOptional<z.ZodString>;
|
|
126
|
+
value: z.ZodString;
|
|
127
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
128
|
+
key: z.ZodString;
|
|
129
|
+
type: z.ZodLiteral<"fields">;
|
|
130
|
+
items: z.ZodArray<z.ZodObject<{
|
|
131
|
+
label: z.ZodString;
|
|
132
|
+
value: z.ZodString;
|
|
133
|
+
}, z.core.$strict>>;
|
|
134
|
+
}, z.core.$strict>], "type">>;
|
|
135
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
136
|
+
key: z.ZodLiteral<"zh-CN">;
|
|
137
|
+
locale: z.ZodLiteral<"zh-CN">;
|
|
138
|
+
title: z.ZodString;
|
|
139
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
140
|
+
key: z.ZodString;
|
|
141
|
+
type: z.ZodLiteral<"text">;
|
|
142
|
+
label: z.ZodOptional<z.ZodString>;
|
|
143
|
+
value: z.ZodString;
|
|
144
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
145
|
+
key: z.ZodString;
|
|
146
|
+
type: z.ZodLiteral<"fields">;
|
|
147
|
+
items: z.ZodArray<z.ZodObject<{
|
|
148
|
+
label: z.ZodString;
|
|
149
|
+
value: z.ZodString;
|
|
150
|
+
}, z.core.$strict>>;
|
|
151
|
+
}, z.core.$strict>], "type">>;
|
|
152
|
+
}, z.core.$strict>], "key">;
|
|
153
|
+
declare const notificationDeliveryRequestV3Schema: z.ZodObject<{
|
|
154
|
+
message: z.ZodObject<{
|
|
155
|
+
type: z.ZodLiteral<"structured_notification">;
|
|
156
|
+
variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
157
|
+
key: z.ZodLiteral<"source">;
|
|
158
|
+
locale: z.ZodLiteral<"und">;
|
|
159
|
+
title: z.ZodString;
|
|
160
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
161
|
+
key: z.ZodString;
|
|
162
|
+
type: z.ZodLiteral<"text">;
|
|
163
|
+
label: z.ZodOptional<z.ZodString>;
|
|
164
|
+
value: z.ZodString;
|
|
165
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
166
|
+
key: z.ZodString;
|
|
167
|
+
type: z.ZodLiteral<"fields">;
|
|
168
|
+
items: z.ZodArray<z.ZodObject<{
|
|
169
|
+
label: z.ZodString;
|
|
170
|
+
value: z.ZodString;
|
|
171
|
+
}, z.core.$strict>>;
|
|
172
|
+
}, z.core.$strict>], "type">>;
|
|
173
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
174
|
+
key: z.ZodLiteral<"zh-CN">;
|
|
175
|
+
locale: z.ZodLiteral<"zh-CN">;
|
|
176
|
+
title: z.ZodString;
|
|
177
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
178
|
+
key: z.ZodString;
|
|
179
|
+
type: z.ZodLiteral<"text">;
|
|
180
|
+
label: z.ZodOptional<z.ZodString>;
|
|
181
|
+
value: z.ZodString;
|
|
182
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
183
|
+
key: z.ZodString;
|
|
184
|
+
type: z.ZodLiteral<"fields">;
|
|
185
|
+
items: z.ZodArray<z.ZodObject<{
|
|
186
|
+
label: z.ZodString;
|
|
187
|
+
value: z.ZodString;
|
|
188
|
+
}, z.core.$strict>>;
|
|
189
|
+
}, z.core.$strict>], "type">>;
|
|
190
|
+
}, z.core.$strict>], "key">>;
|
|
191
|
+
links: z.ZodArray<z.ZodObject<{
|
|
192
|
+
label: z.ZodString;
|
|
193
|
+
url: z.ZodString;
|
|
194
|
+
key: z.ZodString;
|
|
195
|
+
}, z.core.$strict>>;
|
|
196
|
+
}, z.core.$strict>;
|
|
197
|
+
eventType: z.ZodLiteral<"notification.delivery.requested">;
|
|
198
|
+
eventId: z.ZodString;
|
|
199
|
+
producer: z.ZodObject<{
|
|
200
|
+
key: z.ZodString;
|
|
201
|
+
environment: z.ZodString;
|
|
202
|
+
}, z.core.$strict>;
|
|
203
|
+
routeKey: z.ZodString;
|
|
204
|
+
occurredAt: z.ZodString;
|
|
205
|
+
requestedAt: z.ZodString;
|
|
206
|
+
deliverBy: z.ZodString;
|
|
207
|
+
subject: z.ZodObject<{
|
|
208
|
+
type: z.ZodString;
|
|
209
|
+
id: z.ZodString;
|
|
210
|
+
revision: z.ZodNumber;
|
|
211
|
+
}, z.core.$strict>;
|
|
212
|
+
contractVersion: z.ZodLiteral<3>;
|
|
213
|
+
}, z.core.$strict>;
|
|
214
|
+
declare const notificationMessageBodySchema: z.ZodObject<{
|
|
215
|
+
label: z.ZodOptional<z.ZodString>;
|
|
216
|
+
value: z.ZodString;
|
|
217
|
+
}, z.core.$strict>;
|
|
218
|
+
declare const notificationDeliveryRequestV4Schema: z.ZodObject<{
|
|
219
|
+
eventType: z.ZodLiteral<"notification.delivery.requested">;
|
|
220
|
+
eventId: z.ZodString;
|
|
221
|
+
producer: z.ZodObject<{
|
|
222
|
+
key: z.ZodString;
|
|
223
|
+
environment: z.ZodString;
|
|
224
|
+
}, z.core.$strict>;
|
|
225
|
+
routeKey: z.ZodString;
|
|
226
|
+
occurredAt: z.ZodString;
|
|
227
|
+
requestedAt: z.ZodString;
|
|
228
|
+
deliverBy: z.ZodString;
|
|
229
|
+
subject: z.ZodObject<{
|
|
230
|
+
type: z.ZodString;
|
|
231
|
+
id: z.ZodString;
|
|
232
|
+
revision: z.ZodNumber;
|
|
233
|
+
}, z.core.$strict>;
|
|
234
|
+
contractVersion: z.ZodLiteral<4>;
|
|
235
|
+
message: z.ZodObject<{
|
|
236
|
+
type: z.ZodLiteral<"structured_notification">;
|
|
237
|
+
links: z.ZodArray<z.ZodObject<{
|
|
238
|
+
label: z.ZodString;
|
|
239
|
+
url: z.ZodString;
|
|
240
|
+
key: z.ZodString;
|
|
241
|
+
}, z.core.$strict>>;
|
|
242
|
+
variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
243
|
+
key: z.ZodLiteral<"source">;
|
|
244
|
+
locale: z.ZodLiteral<"und">;
|
|
245
|
+
title: z.ZodString;
|
|
246
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
247
|
+
key: z.ZodString;
|
|
248
|
+
type: z.ZodLiteral<"text">;
|
|
249
|
+
label: z.ZodOptional<z.ZodString>;
|
|
250
|
+
value: z.ZodString;
|
|
251
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
252
|
+
key: z.ZodString;
|
|
253
|
+
type: z.ZodLiteral<"fields">;
|
|
254
|
+
items: z.ZodArray<z.ZodObject<{
|
|
255
|
+
label: z.ZodString;
|
|
256
|
+
value: z.ZodString;
|
|
257
|
+
}, z.core.$strict>>;
|
|
258
|
+
}, z.core.$strict>], "type">>;
|
|
259
|
+
body: z.ZodObject<{
|
|
260
|
+
label: z.ZodOptional<z.ZodString>;
|
|
261
|
+
value: z.ZodString;
|
|
262
|
+
}, z.core.$strict>;
|
|
263
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
264
|
+
key: z.ZodLiteral<"zh-CN">;
|
|
265
|
+
locale: z.ZodLiteral<"zh-CN">;
|
|
266
|
+
title: z.ZodString;
|
|
267
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
268
|
+
key: z.ZodString;
|
|
269
|
+
type: z.ZodLiteral<"text">;
|
|
270
|
+
label: z.ZodOptional<z.ZodString>;
|
|
271
|
+
value: z.ZodString;
|
|
272
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
273
|
+
key: z.ZodString;
|
|
274
|
+
type: z.ZodLiteral<"fields">;
|
|
275
|
+
items: z.ZodArray<z.ZodObject<{
|
|
276
|
+
label: z.ZodString;
|
|
277
|
+
value: z.ZodString;
|
|
278
|
+
}, z.core.$strict>>;
|
|
279
|
+
}, z.core.$strict>], "type">>;
|
|
280
|
+
body: z.ZodObject<{
|
|
281
|
+
label: z.ZodOptional<z.ZodString>;
|
|
282
|
+
value: z.ZodString;
|
|
283
|
+
}, z.core.$strict>;
|
|
284
|
+
}, z.core.$strict>], "key">>;
|
|
285
|
+
}, z.core.$strict>;
|
|
286
|
+
}, z.core.$strict>;
|
|
99
287
|
declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
100
288
|
message: z.ZodObject<{
|
|
101
289
|
type: z.ZodLiteral<"link_summary">;
|
|
@@ -177,6 +365,134 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
177
365
|
revision: z.ZodNumber;
|
|
178
366
|
}, z.core.$strict>;
|
|
179
367
|
contractVersion: z.ZodLiteral<2>;
|
|
368
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
369
|
+
message: z.ZodObject<{
|
|
370
|
+
type: z.ZodLiteral<"structured_notification">;
|
|
371
|
+
variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
372
|
+
key: z.ZodLiteral<"source">;
|
|
373
|
+
locale: z.ZodLiteral<"und">;
|
|
374
|
+
title: z.ZodString;
|
|
375
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
376
|
+
key: z.ZodString;
|
|
377
|
+
type: z.ZodLiteral<"text">;
|
|
378
|
+
label: z.ZodOptional<z.ZodString>;
|
|
379
|
+
value: z.ZodString;
|
|
380
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
381
|
+
key: z.ZodString;
|
|
382
|
+
type: z.ZodLiteral<"fields">;
|
|
383
|
+
items: z.ZodArray<z.ZodObject<{
|
|
384
|
+
label: z.ZodString;
|
|
385
|
+
value: z.ZodString;
|
|
386
|
+
}, z.core.$strict>>;
|
|
387
|
+
}, z.core.$strict>], "type">>;
|
|
388
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
389
|
+
key: z.ZodLiteral<"zh-CN">;
|
|
390
|
+
locale: z.ZodLiteral<"zh-CN">;
|
|
391
|
+
title: z.ZodString;
|
|
392
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
393
|
+
key: z.ZodString;
|
|
394
|
+
type: z.ZodLiteral<"text">;
|
|
395
|
+
label: z.ZodOptional<z.ZodString>;
|
|
396
|
+
value: z.ZodString;
|
|
397
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
398
|
+
key: z.ZodString;
|
|
399
|
+
type: z.ZodLiteral<"fields">;
|
|
400
|
+
items: z.ZodArray<z.ZodObject<{
|
|
401
|
+
label: z.ZodString;
|
|
402
|
+
value: z.ZodString;
|
|
403
|
+
}, z.core.$strict>>;
|
|
404
|
+
}, z.core.$strict>], "type">>;
|
|
405
|
+
}, z.core.$strict>], "key">>;
|
|
406
|
+
links: z.ZodArray<z.ZodObject<{
|
|
407
|
+
label: z.ZodString;
|
|
408
|
+
url: z.ZodString;
|
|
409
|
+
key: z.ZodString;
|
|
410
|
+
}, z.core.$strict>>;
|
|
411
|
+
}, z.core.$strict>;
|
|
412
|
+
eventType: z.ZodLiteral<"notification.delivery.requested">;
|
|
413
|
+
eventId: z.ZodString;
|
|
414
|
+
producer: z.ZodObject<{
|
|
415
|
+
key: z.ZodString;
|
|
416
|
+
environment: z.ZodString;
|
|
417
|
+
}, z.core.$strict>;
|
|
418
|
+
routeKey: z.ZodString;
|
|
419
|
+
occurredAt: z.ZodString;
|
|
420
|
+
requestedAt: z.ZodString;
|
|
421
|
+
deliverBy: z.ZodString;
|
|
422
|
+
subject: z.ZodObject<{
|
|
423
|
+
type: z.ZodString;
|
|
424
|
+
id: z.ZodString;
|
|
425
|
+
revision: z.ZodNumber;
|
|
426
|
+
}, z.core.$strict>;
|
|
427
|
+
contractVersion: z.ZodLiteral<3>;
|
|
428
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
429
|
+
eventType: z.ZodLiteral<"notification.delivery.requested">;
|
|
430
|
+
eventId: z.ZodString;
|
|
431
|
+
producer: z.ZodObject<{
|
|
432
|
+
key: z.ZodString;
|
|
433
|
+
environment: z.ZodString;
|
|
434
|
+
}, z.core.$strict>;
|
|
435
|
+
routeKey: z.ZodString;
|
|
436
|
+
occurredAt: z.ZodString;
|
|
437
|
+
requestedAt: z.ZodString;
|
|
438
|
+
deliverBy: z.ZodString;
|
|
439
|
+
subject: z.ZodObject<{
|
|
440
|
+
type: z.ZodString;
|
|
441
|
+
id: z.ZodString;
|
|
442
|
+
revision: z.ZodNumber;
|
|
443
|
+
}, z.core.$strict>;
|
|
444
|
+
contractVersion: z.ZodLiteral<4>;
|
|
445
|
+
message: z.ZodObject<{
|
|
446
|
+
type: z.ZodLiteral<"structured_notification">;
|
|
447
|
+
links: z.ZodArray<z.ZodObject<{
|
|
448
|
+
label: z.ZodString;
|
|
449
|
+
url: z.ZodString;
|
|
450
|
+
key: z.ZodString;
|
|
451
|
+
}, z.core.$strict>>;
|
|
452
|
+
variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
453
|
+
key: z.ZodLiteral<"source">;
|
|
454
|
+
locale: z.ZodLiteral<"und">;
|
|
455
|
+
title: z.ZodString;
|
|
456
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
457
|
+
key: z.ZodString;
|
|
458
|
+
type: z.ZodLiteral<"text">;
|
|
459
|
+
label: z.ZodOptional<z.ZodString>;
|
|
460
|
+
value: z.ZodString;
|
|
461
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
462
|
+
key: z.ZodString;
|
|
463
|
+
type: z.ZodLiteral<"fields">;
|
|
464
|
+
items: z.ZodArray<z.ZodObject<{
|
|
465
|
+
label: z.ZodString;
|
|
466
|
+
value: z.ZodString;
|
|
467
|
+
}, z.core.$strict>>;
|
|
468
|
+
}, z.core.$strict>], "type">>;
|
|
469
|
+
body: z.ZodObject<{
|
|
470
|
+
label: z.ZodOptional<z.ZodString>;
|
|
471
|
+
value: z.ZodString;
|
|
472
|
+
}, z.core.$strict>;
|
|
473
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
474
|
+
key: z.ZodLiteral<"zh-CN">;
|
|
475
|
+
locale: z.ZodLiteral<"zh-CN">;
|
|
476
|
+
title: z.ZodString;
|
|
477
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
478
|
+
key: z.ZodString;
|
|
479
|
+
type: z.ZodLiteral<"text">;
|
|
480
|
+
label: z.ZodOptional<z.ZodString>;
|
|
481
|
+
value: z.ZodString;
|
|
482
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
483
|
+
key: z.ZodString;
|
|
484
|
+
type: z.ZodLiteral<"fields">;
|
|
485
|
+
items: z.ZodArray<z.ZodObject<{
|
|
486
|
+
label: z.ZodString;
|
|
487
|
+
value: z.ZodString;
|
|
488
|
+
}, z.core.$strict>>;
|
|
489
|
+
}, z.core.$strict>], "type">>;
|
|
490
|
+
body: z.ZodObject<{
|
|
491
|
+
label: z.ZodOptional<z.ZodString>;
|
|
492
|
+
value: z.ZodString;
|
|
493
|
+
}, z.core.$strict>;
|
|
494
|
+
}, z.core.$strict>], "key">>;
|
|
495
|
+
}, z.core.$strict>;
|
|
180
496
|
}, z.core.$strict>]>;
|
|
181
497
|
declare const notificationDeliveryReceiptV1Schema: z.ZodObject<{
|
|
182
498
|
contractVersion: z.ZodLiteral<1>;
|
|
@@ -425,8 +741,13 @@ declare const notificationGetReceiptResultV1Schema: z.ZodDiscriminatedUnion<[z.Z
|
|
|
425
741
|
}, z.core.$strict>], "status">;
|
|
426
742
|
type NotificationDeliveryRequestV1 = z.infer<typeof notificationDeliveryRequestV1Schema>;
|
|
427
743
|
type NotificationDeliveryRequestV2 = z.infer<typeof notificationDeliveryRequestV2Schema>;
|
|
744
|
+
type NotificationDeliveryRequestV3 = z.infer<typeof notificationDeliveryRequestV3Schema>;
|
|
745
|
+
type NotificationDeliveryRequestV4 = z.infer<typeof notificationDeliveryRequestV4Schema>;
|
|
428
746
|
type NotificationDeliveryRequest = z.infer<typeof notificationDeliveryRequestSchema>;
|
|
429
747
|
type NotificationMessageVariantKey = (typeof notificationMessageVariantKeys)[number];
|
|
748
|
+
type NotificationStructuredMessageSection = z.infer<typeof structuredMessageSectionSchema>;
|
|
749
|
+
type NotificationStructuredMessageVariant = z.infer<typeof structuredNotificationVariantSchema>;
|
|
750
|
+
type NotificationMessageBody = z.infer<typeof notificationMessageBodySchema>;
|
|
430
751
|
type NotificationDeliveryReceiptV1 = z.infer<typeof notificationDeliveryReceiptV1Schema>;
|
|
431
752
|
type NotificationDeliveryRejectionV1 = z.infer<typeof notificationDeliveryRejectionV1Schema>;
|
|
432
753
|
type NotificationDeliverResultV1 = z.infer<typeof notificationDeliverResultV1Schema>;
|
|
@@ -436,10 +757,10 @@ interface NotificationDeliveryServiceV1 {
|
|
|
436
757
|
deliver: (request: NotificationDeliveryRequestV1) => Promise<NotificationDeliverResultV1>;
|
|
437
758
|
getReceipt: (eventId: string) => Promise<NotificationGetReceiptResultV1>;
|
|
438
759
|
}
|
|
439
|
-
/** Private Service Binding contract accepting
|
|
760
|
+
/** Private Service Binding contract accepting all published request versions. */
|
|
440
761
|
interface NotificationDeliveryServiceV2 {
|
|
441
762
|
deliver: (request: NotificationDeliveryRequest) => Promise<NotificationDeliverResultV1>;
|
|
442
763
|
getReceipt: (eventId: string) => Promise<NotificationGetReceiptResultV1>;
|
|
443
764
|
}
|
|
444
765
|
//#endregion
|
|
445
|
-
export { NotificationDeliverResultV1, NotificationDeliveryReceiptV1, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationGetReceiptResultV1, NotificationMessageVariantKey, notificationDeliverResultV1Schema, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryReasonsV1, notificationDeliveryReceiptV1Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryStatesV1, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationGetReceiptResultV1Schema, notificationMessageVariantKeys, notificationValidationIssueCodesV1 };
|
|
766
|
+
export { NotificationDeliverResultV1, NotificationDeliveryReceiptV1, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationGetReceiptResultV1, NotificationMessageBody, NotificationMessageVariantKey, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, notificationDeliverResultV1Schema, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryMaximumDeadlineMillisecondsV4, notificationDeliveryReasonsV1, notificationDeliveryReceiptV1Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestMaximumUtf8BytesV4, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, notificationDeliveryRequestV4Schema, notificationDeliveryStatesV1, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationGetReceiptResultV1Schema, notificationMessageVariantKeys, notificationValidationIssueCodesV1 };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";const t=1,n=2,r=32*1024,
|
|
1
|
+
import{z as e}from"zod";const t=1,n=2,r=3,i=4,a=32*1024,o=1380*60*1e3,s=a,c=o,l=a,u=o,d=a,f=o,p=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],m=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],h=[`pending`,`delivering`,`delivered`,`failed`,`expired`],g=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],_=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],v=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],y=[`source`,`zh-CN`],ee=new TextEncoder,b=/^[a-z][a-z0-9-]{0,62}$/,x=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,S=/^[A-Z0-9][\w.:-]{0,127}$/i;function C(e){return[...e].length}function w(t){return e.string().refine(e=>C(e)>0,{message:`too_small`}).refine(e=>C(e)<=t,{message:`too_big`})}const T=e.string().datetime({offset:!0}),E=e.object({key:e.string().regex(b),environment:e.string().regex(b)}).strict(),D=e.object({type:e.string().regex(b),id:e.string().regex(S),revision:e.number().int().positive()}).strict(),O=e.string().min(1).max(127).regex(x),k=e.object({label:w(48),url:w(2048).refine(e=>[...e].every(e=>{let t=e.codePointAt(0);return t!==void 0&&t>31&&t!==127}),{message:`invalid_https_url`}).refine(e=>{try{return new URL(e).protocol===`https:`}catch{return!1}},{message:`invalid_https_url`})}).strict(),A={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:E,routeKey:O,occurredAt:T,requestedAt:T,deliverBy:T,subject:D},j=e.object({contractVersion:e.literal(1),...A,message:e.object({type:e.literal(`link_summary`),title:w(160),summary:w(1200),facts:e.array(e.object({label:w(48),value:w(500)}).strict()).max(10),primaryLink:k,sourceLink:k.optional()}).strict()}).strict();function M(e,t,n,r){let i=Date.parse(e.requestedAt),a=Date.parse(e.deliverBy);(!Number.isFinite(i)||!Number.isFinite(a)||a<=i||a-i>n)&&t.addIssue({code:`custom`,message:`delivery_deadline_invalid`,path:[`deliverBy`]}),ee.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const N=j.superRefine((e,t)=>M(e,t,o,a)),P={title:w(160),summary:w(1200),facts:e.array(e.object({label:w(48),value:w(500)}).strict()).max(10)},F=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...P}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...P}).strict()]),I=e.array(F).min(1).max(2).superRefine((e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`})}),L=e.object({contractVersion:e.literal(2),...A,message:e.object({type:e.literal(`localized_link_summary`),variants:I,primaryLink:k,sourceLink:k.optional()}).strict()}).strict().superRefine((e,t)=>M(e,t,c,s)),R=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(b),type:e.literal(`text`),label:w(48).optional(),value:w(4e3)}).strict(),e.object({key:e.string().regex(b),type:e.literal(`fields`),items:e.array(e.object({label:w(48),value:w(1200)}).strict()).min(1).max(20)}).strict()]),z=e.array(R).min(1).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),B=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:w(160),sections:z}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:w(160),sections:z}).strict()]),V=(e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`});let n=e.find(e=>e.key===`source`),r=e.find(e=>e.key===`zh-CN`);if(n&&r){let i=n.sections.map(e=>`${e.key}:${e.type}`),a=r.sections.map(e=>`${e.key}:${e.type}`);JSON.stringify(i)!==JSON.stringify(a)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(r),`sections`]})}},H=e.array(B).min(1).max(2).superRefine(V),U=e.object({contractVersion:e.literal(3),...A,message:e.object({type:e.literal(`structured_notification`),variants:H,links:e.array(e.object({key:e.string().regex(b),...k.shape}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_duplicate`})})}).strict()}).strict(),W=U.superRefine((e,t)=>M(e,t,u,l)),G=e.object({label:w(48).optional(),value:w(d)}).strict(),K=e.discriminatedUnion(`key`,[B.options[0].extend({body:G}),B.options[1].extend({body:G})]),q=U.extend({contractVersion:e.literal(4),message:U.shape.message.extend({variants:e.array(K).min(1).max(2).superRefine(V)})}).superRefine((e,t)=>M(e,t,f,d)),J=e.union([N,L,W,q]),Y=e.object({destinationKey:e.string().min(1),state:e.enum(h),attempts:e.number().int().min(0).max(4),failureCode:e.enum(g).nullable(),lastAttemptAt:T.nullable(),nextAttemptAt:T.nullable(),leaseExpiresAt:T.nullable()}).strict(),X=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:E,routeKey:O,subject:D,state:e.enum(p),reason:e.enum(m),terminal:e.boolean(),acceptedAt:T,updatedAt:T,deliverBy:T,terminalAt:T.nullable(),destinations:e.array(Y).min(1).max(20)}).strict(),Z=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(v)}).strict(),Q=e.object({code:e.literal(`invalid_request`),issues:e.array(Z).max(20).optional()}).strict(),te=e.object({code:e.enum(_.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([Q,te]),ne=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:X}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),re=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:X}).strict(),e.object({status:e.literal(`not_found`)}).strict(),e.object({status:e.literal(`unavailable`),error:e.object({code:e.literal(`receipt_unavailable`)}).strict()}).strict()]);export{ne as notificationDeliverResultV1Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,i as notificationDeliveryContractVersionV4,o as notificationDeliveryMaximumDeadlineMillisecondsV1,c as notificationDeliveryMaximumDeadlineMillisecondsV2,u as notificationDeliveryMaximumDeadlineMillisecondsV3,f as notificationDeliveryMaximumDeadlineMillisecondsV4,m as notificationDeliveryReasonsV1,X as notificationDeliveryReceiptV1Schema,_ as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,a as notificationDeliveryRequestMaximumUtf8BytesV1,s as notificationDeliveryRequestMaximumUtf8BytesV2,l as notificationDeliveryRequestMaximumUtf8BytesV3,d as notificationDeliveryRequestMaximumUtf8BytesV4,J as notificationDeliveryRequestSchema,N as notificationDeliveryRequestV1Schema,L as notificationDeliveryRequestV2Schema,W as notificationDeliveryRequestV3Schema,q as notificationDeliveryRequestV4Schema,p as notificationDeliveryStatesV1,g as notificationDestinationFailureCodesV1,h as notificationDestinationStatesV1,re as notificationGetReceiptResultV1Schema,y as notificationMessageVariantKeys,v as notificationValidationIssueCodesV1};
|