@closerepo/notification-contracts 1.3.1 → 1.5.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.d.ts CHANGED
@@ -4,6 +4,7 @@ declare const notificationDeliveryContractVersionV1: 1;
4
4
  declare const notificationDeliveryContractVersionV2: 2;
5
5
  declare const notificationDeliveryContractVersionV3: 3;
6
6
  declare const notificationDeliveryContractVersionV4: 4;
7
+ declare const notificationDeliveryContractVersionV5: 5;
7
8
  declare const notificationDeliveryRequestMaximumUtf8BytesV1: number;
8
9
  declare const notificationDeliveryMaximumDeadlineMillisecondsV1: number;
9
10
  declare const notificationDeliveryRequestMaximumUtf8BytesV2: number;
@@ -12,6 +13,8 @@ declare const notificationDeliveryRequestMaximumUtf8BytesV3: number;
12
13
  declare const notificationDeliveryMaximumDeadlineMillisecondsV3: number;
13
14
  declare const notificationDeliveryRequestMaximumUtf8BytesV4: number;
14
15
  declare const notificationDeliveryMaximumDeadlineMillisecondsV4: number;
16
+ declare const notificationDeliveryRequestMaximumUtf8BytesV5: number;
17
+ declare const notificationDeliveryMaximumDeadlineMillisecondsV5: number;
15
18
  declare const notificationDeliveryStatesV1: readonly ["pending", "delivering", "partial", "delivered", "failed", "expired"];
16
19
  declare const notificationDeliveryReasonsV1: readonly ["accepted", "enqueue_retry_wait", "in_progress", "partial_delivery", "complete", "retry_exhausted", "delivery_deadline_exceeded", "destination_configuration_unavailable"];
17
20
  declare const notificationDestinationStatesV1: readonly ["pending", "delivering", "delivered", "failed", "expired"];
@@ -284,6 +287,165 @@ declare const notificationDeliveryRequestV4Schema: z.ZodObject<{
284
287
  }, z.core.$strict>], "key">>;
285
288
  }, z.core.$strict>;
286
289
  }, z.core.$strict>;
290
+ declare const sharedNotificationBodySchema: z.ZodObject<{
291
+ value: z.ZodString;
292
+ }, z.core.$strict>;
293
+ declare const notificationDeliveryRequestV5Schema: z.ZodObject<{
294
+ message: z.ZodObject<{
295
+ type: z.ZodLiteral<"structured_notification">;
296
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
297
+ key: z.ZodLiteral<"source">;
298
+ locale: z.ZodLiteral<"und">;
299
+ title: z.ZodString;
300
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
301
+ key: z.ZodString;
302
+ type: z.ZodLiteral<"text">;
303
+ label: z.ZodOptional<z.ZodString>;
304
+ value: z.ZodString;
305
+ }, z.core.$strict>, z.ZodObject<{
306
+ key: z.ZodString;
307
+ type: z.ZodLiteral<"fields">;
308
+ items: z.ZodArray<z.ZodObject<{
309
+ label: z.ZodString;
310
+ value: z.ZodString;
311
+ }, z.core.$strict>>;
312
+ }, z.core.$strict>], "type">>;
313
+ bodyLabel: z.ZodOptional<z.ZodString>;
314
+ linkLabels: z.ZodArray<z.ZodObject<{
315
+ key: z.ZodString;
316
+ label: z.ZodString;
317
+ }, z.core.$strict>>;
318
+ }, z.core.$strict>, z.ZodObject<{
319
+ key: z.ZodLiteral<"zh-CN">;
320
+ locale: z.ZodLiteral<"zh-CN">;
321
+ title: z.ZodString;
322
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
323
+ key: z.ZodString;
324
+ type: z.ZodLiteral<"text">;
325
+ label: z.ZodOptional<z.ZodString>;
326
+ value: z.ZodString;
327
+ }, z.core.$strict>, z.ZodObject<{
328
+ key: z.ZodString;
329
+ type: z.ZodLiteral<"fields">;
330
+ items: z.ZodArray<z.ZodObject<{
331
+ label: z.ZodString;
332
+ value: z.ZodString;
333
+ }, z.core.$strict>>;
334
+ }, z.core.$strict>], "type">>;
335
+ bodyLabel: z.ZodOptional<z.ZodString>;
336
+ linkLabels: z.ZodArray<z.ZodObject<{
337
+ key: z.ZodString;
338
+ label: z.ZodString;
339
+ }, z.core.$strict>>;
340
+ }, z.core.$strict>], "key">>;
341
+ links: z.ZodArray<z.ZodObject<{
342
+ key: z.ZodString;
343
+ url: z.ZodString;
344
+ }, z.core.$strict>>;
345
+ body: z.ZodObject<{
346
+ value: z.ZodString;
347
+ }, z.core.$strict>;
348
+ }, z.core.$strict>;
349
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
350
+ eventId: z.ZodString;
351
+ producer: z.ZodObject<{
352
+ key: z.ZodString;
353
+ environment: z.ZodString;
354
+ }, z.core.$strict>;
355
+ routeKey: z.ZodString;
356
+ occurredAt: z.ZodString;
357
+ requestedAt: z.ZodString;
358
+ deliverBy: z.ZodString;
359
+ subject: z.ZodObject<{
360
+ type: z.ZodString;
361
+ id: z.ZodString;
362
+ revision: z.ZodNumber;
363
+ }, z.core.$strict>;
364
+ contractVersion: z.ZodLiteral<5>;
365
+ }, z.core.$strict>;
366
+ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
367
+ contractVersion: z.ZodLiteral<6>;
368
+ message: z.ZodObject<{
369
+ type: z.ZodLiteral<"structured_notification">;
370
+ links: z.ZodArray<z.ZodObject<{
371
+ key: z.ZodString;
372
+ url: z.ZodString;
373
+ }, z.core.$strict>>;
374
+ bodies: z.ZodArray<z.ZodObject<{
375
+ key: z.ZodString;
376
+ value: z.ZodString;
377
+ }, z.core.$strict>>;
378
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
379
+ key: z.ZodLiteral<"source">;
380
+ title: z.ZodString;
381
+ locale: z.ZodLiteral<"und">;
382
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
383
+ key: z.ZodString;
384
+ type: z.ZodLiteral<"text">;
385
+ label: z.ZodOptional<z.ZodString>;
386
+ value: z.ZodString;
387
+ }, z.core.$strict>, z.ZodObject<{
388
+ key: z.ZodString;
389
+ type: z.ZodLiteral<"fields">;
390
+ items: z.ZodArray<z.ZodObject<{
391
+ label: z.ZodString;
392
+ value: z.ZodString;
393
+ }, z.core.$strict>>;
394
+ }, z.core.$strict>], "type">>;
395
+ linkLabels: z.ZodArray<z.ZodObject<{
396
+ key: z.ZodString;
397
+ label: z.ZodString;
398
+ }, z.core.$strict>>;
399
+ bodyRefs: z.ZodArray<z.ZodObject<{
400
+ key: z.ZodString;
401
+ label: z.ZodString;
402
+ }, z.core.$strict>>;
403
+ footer: z.ZodString;
404
+ }, z.core.$strict>, z.ZodObject<{
405
+ key: z.ZodLiteral<"zh-CN">;
406
+ title: z.ZodString;
407
+ locale: z.ZodLiteral<"zh-CN">;
408
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
409
+ key: z.ZodString;
410
+ type: z.ZodLiteral<"text">;
411
+ label: z.ZodOptional<z.ZodString>;
412
+ value: z.ZodString;
413
+ }, z.core.$strict>, z.ZodObject<{
414
+ key: z.ZodString;
415
+ type: z.ZodLiteral<"fields">;
416
+ items: z.ZodArray<z.ZodObject<{
417
+ label: z.ZodString;
418
+ value: z.ZodString;
419
+ }, z.core.$strict>>;
420
+ }, z.core.$strict>], "type">>;
421
+ linkLabels: z.ZodArray<z.ZodObject<{
422
+ key: z.ZodString;
423
+ label: z.ZodString;
424
+ }, z.core.$strict>>;
425
+ bodyRefs: z.ZodArray<z.ZodObject<{
426
+ key: z.ZodString;
427
+ label: z.ZodString;
428
+ }, z.core.$strict>>;
429
+ footer: z.ZodString;
430
+ }, z.core.$strict>], "key">>;
431
+ }, z.core.$strict>;
432
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
433
+ eventId: z.ZodString;
434
+ producer: z.ZodObject<{
435
+ key: z.ZodString;
436
+ environment: z.ZodString;
437
+ }, z.core.$strict>;
438
+ routeKey: z.ZodString;
439
+ occurredAt: z.ZodString;
440
+ requestedAt: z.ZodString;
441
+ deliverBy: z.ZodString;
442
+ subject: z.ZodObject<{
443
+ type: z.ZodString;
444
+ id: z.ZodString;
445
+ revision: z.ZodNumber;
446
+ }, z.core.$strict>;
447
+ }, z.core.$strict>;
448
+ type NotificationDeliveryRequestV6 = z.infer<typeof notificationDeliveryRequestV6Schema>;
287
449
  declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObject<{
288
450
  message: z.ZodObject<{
289
451
  type: z.ZodLiteral<"link_summary">;
@@ -493,6 +655,159 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
493
655
  }, z.core.$strict>;
494
656
  }, z.core.$strict>], "key">>;
495
657
  }, z.core.$strict>;
658
+ }, z.core.$strict>, z.ZodObject<{
659
+ message: z.ZodObject<{
660
+ type: z.ZodLiteral<"structured_notification">;
661
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
662
+ key: z.ZodLiteral<"source">;
663
+ locale: z.ZodLiteral<"und">;
664
+ title: z.ZodString;
665
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
666
+ key: z.ZodString;
667
+ type: z.ZodLiteral<"text">;
668
+ label: z.ZodOptional<z.ZodString>;
669
+ value: z.ZodString;
670
+ }, z.core.$strict>, z.ZodObject<{
671
+ key: z.ZodString;
672
+ type: z.ZodLiteral<"fields">;
673
+ items: z.ZodArray<z.ZodObject<{
674
+ label: z.ZodString;
675
+ value: z.ZodString;
676
+ }, z.core.$strict>>;
677
+ }, z.core.$strict>], "type">>;
678
+ bodyLabel: z.ZodOptional<z.ZodString>;
679
+ linkLabels: z.ZodArray<z.ZodObject<{
680
+ key: z.ZodString;
681
+ label: z.ZodString;
682
+ }, z.core.$strict>>;
683
+ }, z.core.$strict>, z.ZodObject<{
684
+ key: z.ZodLiteral<"zh-CN">;
685
+ locale: z.ZodLiteral<"zh-CN">;
686
+ title: z.ZodString;
687
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
688
+ key: z.ZodString;
689
+ type: z.ZodLiteral<"text">;
690
+ label: z.ZodOptional<z.ZodString>;
691
+ value: z.ZodString;
692
+ }, z.core.$strict>, z.ZodObject<{
693
+ key: z.ZodString;
694
+ type: z.ZodLiteral<"fields">;
695
+ items: z.ZodArray<z.ZodObject<{
696
+ label: z.ZodString;
697
+ value: z.ZodString;
698
+ }, z.core.$strict>>;
699
+ }, z.core.$strict>], "type">>;
700
+ bodyLabel: z.ZodOptional<z.ZodString>;
701
+ linkLabels: z.ZodArray<z.ZodObject<{
702
+ key: z.ZodString;
703
+ label: z.ZodString;
704
+ }, z.core.$strict>>;
705
+ }, z.core.$strict>], "key">>;
706
+ links: z.ZodArray<z.ZodObject<{
707
+ key: z.ZodString;
708
+ url: z.ZodString;
709
+ }, z.core.$strict>>;
710
+ body: z.ZodObject<{
711
+ value: z.ZodString;
712
+ }, z.core.$strict>;
713
+ }, z.core.$strict>;
714
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
715
+ eventId: z.ZodString;
716
+ producer: z.ZodObject<{
717
+ key: z.ZodString;
718
+ environment: z.ZodString;
719
+ }, z.core.$strict>;
720
+ routeKey: z.ZodString;
721
+ occurredAt: z.ZodString;
722
+ requestedAt: z.ZodString;
723
+ deliverBy: z.ZodString;
724
+ subject: z.ZodObject<{
725
+ type: z.ZodString;
726
+ id: z.ZodString;
727
+ revision: z.ZodNumber;
728
+ }, z.core.$strict>;
729
+ contractVersion: z.ZodLiteral<5>;
730
+ }, z.core.$strict>, z.ZodObject<{
731
+ contractVersion: z.ZodLiteral<6>;
732
+ message: z.ZodObject<{
733
+ type: z.ZodLiteral<"structured_notification">;
734
+ links: z.ZodArray<z.ZodObject<{
735
+ key: z.ZodString;
736
+ url: z.ZodString;
737
+ }, z.core.$strict>>;
738
+ bodies: z.ZodArray<z.ZodObject<{
739
+ key: z.ZodString;
740
+ value: z.ZodString;
741
+ }, z.core.$strict>>;
742
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
743
+ key: z.ZodLiteral<"source">;
744
+ title: z.ZodString;
745
+ locale: z.ZodLiteral<"und">;
746
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
747
+ key: z.ZodString;
748
+ type: z.ZodLiteral<"text">;
749
+ label: z.ZodOptional<z.ZodString>;
750
+ value: z.ZodString;
751
+ }, z.core.$strict>, z.ZodObject<{
752
+ key: z.ZodString;
753
+ type: z.ZodLiteral<"fields">;
754
+ items: z.ZodArray<z.ZodObject<{
755
+ label: z.ZodString;
756
+ value: z.ZodString;
757
+ }, z.core.$strict>>;
758
+ }, z.core.$strict>], "type">>;
759
+ linkLabels: z.ZodArray<z.ZodObject<{
760
+ key: z.ZodString;
761
+ label: z.ZodString;
762
+ }, z.core.$strict>>;
763
+ bodyRefs: z.ZodArray<z.ZodObject<{
764
+ key: z.ZodString;
765
+ label: z.ZodString;
766
+ }, z.core.$strict>>;
767
+ footer: z.ZodString;
768
+ }, z.core.$strict>, z.ZodObject<{
769
+ key: z.ZodLiteral<"zh-CN">;
770
+ title: z.ZodString;
771
+ locale: z.ZodLiteral<"zh-CN">;
772
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
773
+ key: z.ZodString;
774
+ type: z.ZodLiteral<"text">;
775
+ label: z.ZodOptional<z.ZodString>;
776
+ value: z.ZodString;
777
+ }, z.core.$strict>, z.ZodObject<{
778
+ key: z.ZodString;
779
+ type: z.ZodLiteral<"fields">;
780
+ items: z.ZodArray<z.ZodObject<{
781
+ label: z.ZodString;
782
+ value: z.ZodString;
783
+ }, z.core.$strict>>;
784
+ }, z.core.$strict>], "type">>;
785
+ linkLabels: z.ZodArray<z.ZodObject<{
786
+ key: z.ZodString;
787
+ label: z.ZodString;
788
+ }, z.core.$strict>>;
789
+ bodyRefs: z.ZodArray<z.ZodObject<{
790
+ key: z.ZodString;
791
+ label: z.ZodString;
792
+ }, z.core.$strict>>;
793
+ footer: z.ZodString;
794
+ }, z.core.$strict>], "key">>;
795
+ }, z.core.$strict>;
796
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
797
+ eventId: z.ZodString;
798
+ producer: z.ZodObject<{
799
+ key: z.ZodString;
800
+ environment: z.ZodString;
801
+ }, z.core.$strict>;
802
+ routeKey: z.ZodString;
803
+ occurredAt: z.ZodString;
804
+ requestedAt: z.ZodString;
805
+ deliverBy: z.ZodString;
806
+ subject: z.ZodObject<{
807
+ type: z.ZodString;
808
+ id: z.ZodString;
809
+ revision: z.ZodNumber;
810
+ }, z.core.$strict>;
496
811
  }, z.core.$strict>]>;
497
812
  declare const notificationDeliveryReceiptV1Schema: z.ZodObject<{
498
813
  contractVersion: z.ZodLiteral<1>;
@@ -743,11 +1058,13 @@ type NotificationDeliveryRequestV1 = z.infer<typeof notificationDeliveryRequestV
743
1058
  type NotificationDeliveryRequestV2 = z.infer<typeof notificationDeliveryRequestV2Schema>;
744
1059
  type NotificationDeliveryRequestV3 = z.infer<typeof notificationDeliveryRequestV3Schema>;
745
1060
  type NotificationDeliveryRequestV4 = z.infer<typeof notificationDeliveryRequestV4Schema>;
1061
+ type NotificationDeliveryRequestV5 = z.infer<typeof notificationDeliveryRequestV5Schema>;
746
1062
  type NotificationDeliveryRequest = z.infer<typeof notificationDeliveryRequestSchema>;
747
1063
  type NotificationMessageVariantKey = (typeof notificationMessageVariantKeys)[number];
748
1064
  type NotificationStructuredMessageSection = z.infer<typeof structuredMessageSectionSchema>;
749
1065
  type NotificationStructuredMessageVariant = z.infer<typeof structuredNotificationVariantSchema>;
750
1066
  type NotificationMessageBody = z.infer<typeof notificationMessageBodySchema>;
1067
+ type NotificationSharedMessageBody = z.infer<typeof sharedNotificationBodySchema>;
751
1068
  type NotificationDeliveryReceiptV1 = z.infer<typeof notificationDeliveryReceiptV1Schema>;
752
1069
  type NotificationDeliveryRejectionV1 = z.infer<typeof notificationDeliveryRejectionV1Schema>;
753
1070
  type NotificationDeliverResultV1 = z.infer<typeof notificationDeliverResultV1Schema>;
@@ -763,4 +1080,4 @@ interface NotificationDeliveryServiceV2 {
763
1080
  getReceipt: (eventId: string) => Promise<NotificationGetReceiptResultV1>;
764
1081
  }
765
1082
  //#endregion
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 };
1083
+ export { NotificationDeliverResultV1, NotificationDeliveryReceiptV1, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryRequestV6, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationGetReceiptResultV1, NotificationMessageBody, NotificationMessageVariantKey, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, notificationDeliverResultV1Schema, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryContractVersionV5, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryMaximumDeadlineMillisecondsV4, notificationDeliveryMaximumDeadlineMillisecondsV5, notificationDeliveryReasonsV1, notificationDeliveryReceiptV1Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestMaximumUtf8BytesV4, notificationDeliveryRequestMaximumUtf8BytesV5, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, notificationDeliveryRequestV4Schema, notificationDeliveryRequestV5Schema, notificationDeliveryRequestV6Schema, 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=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};
1
+ import{z as e}from"zod";const t=1,n=2,r=3,i=4,a=5,o=32*1024,s=1380*60*1e3,c=o,l=s,u=o,d=s,f=o,p=s,m=o,h=s,g=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],_=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],v=[`pending`,`delivering`,`delivered`,`failed`,`expired`],y=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],b=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],x=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],ee=[`source`,`zh-CN`],te=new TextEncoder,S=/^[a-z][a-z0-9-]{0,62}$/,C=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,w=/^[A-Z0-9][\w.:-]{0,127}$/i;function T(e){return[...e].length}function E(t){return e.string().refine(e=>T(e)>0,{message:`too_small`}).refine(e=>T(e)<=t,{message:`too_big`})}const D=e.string().datetime({offset:!0}),O=e.object({key:e.string().regex(S),environment:e.string().regex(S)}).strict(),k=e.object({type:e.string().regex(S),id:e.string().regex(w),revision:e.number().int().positive()}).strict(),A=e.string().min(1).max(127).regex(C),j=e.object({label:E(48),url:E(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(),M={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:O,routeKey:A,occurredAt:D,requestedAt:D,deliverBy:D,subject:k},ne=e.object({contractVersion:e.literal(1),...M,message:e.object({type:e.literal(`link_summary`),title:E(160),summary:E(1200),facts:e.array(e.object({label:E(48),value:E(500)}).strict()).max(10),primaryLink:j,sourceLink:j.optional()}).strict()}).strict();function N(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`]}),te.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const P=ne.superRefine((e,t)=>N(e,t,s,o)),F={title:E(160),summary:E(1200),facts:e.array(e.object({label:E(48),value:E(500)}).strict()).max(10)},I=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...F}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...F}).strict()]),L=e.array(I).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`})}),R=e.object({contractVersion:e.literal(2),...M,message:e.object({type:e.literal(`localized_link_summary`),variants:L,primaryLink:j,sourceLink:j.optional()}).strict()}).strict().superRefine((e,t)=>N(e,t,l,c)),z=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(S),type:e.literal(`text`),label:E(48).optional(),value:E(4e3)}).strict(),e.object({key:e.string().regex(S),type:e.literal(`fields`),items:e.array(e.object({label:E(48),value:E(1200)}).strict()).min(1).max(20)}).strict()]),B=e.array(z).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`})}),V=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:E(160),sections:B}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:E(160),sections:B}).strict()]),H=(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`]})}},re=e.array(V).min(1).max(2).superRefine(H),U=e.object({contractVersion:e.literal(3),...M,message:e.object({type:e.literal(`structured_notification`),variants:re,links:e.array(e.object({key:e.string().regex(S),...j.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)=>N(e,t,d,u)),G=e.object({label:E(48).optional(),value:E(f)}).strict(),K=e.discriminatedUnion(`key`,[V.options[0].extend({body:G}),V.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(H)})}).superRefine((e,t)=>N(e,t,p,f)),J=e.discriminatedUnion(`key`,[V.options[0].extend({bodyLabel:E(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(S),label:E(48)}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_label_duplicate`})})}),V.options[1].extend({bodyLabel:E(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(S),label:E(48)}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_label_duplicate`})})})]),Y=e.object({value:E(m)}).strict(),X=e.object({contractVersion:e.literal(5),...M,message:e.object({type:e.literal(`structured_notification`),variants:e.array(J).min(1).max(2).superRefine(H),links:e.array(e.object({key:e.string().regex(S),url:j.shape.url}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_duplicate`})}),body:Y}).strict()}).strict().superRefine((e,t)=>{N(e,t,h,m);let n=e.message.links.map(e=>e.key);for(let[r,i]of e.message.variants.entries()){let e=i.linkLabels.map(e=>e.key);JSON.stringify(e)!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,path:[`message`,`variants`,r,`linkLabels`]})}}),Z=e.object({...X.shape,contractVersion:e.literal(6),message:X.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(S),value:E(m)}).strict()).min(1).max(2),variants:e.array(e.discriminatedUnion(`key`,[J.options[0].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(S),label:E(48)}).strict()).min(1).max(2),footer:E(500)}),J.options[1].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(S),label:E(48)}).strict()).min(1).max(2),footer:E(500)})])).min(1).max(2).superRefine(H)})}).strict().superRefine((e,t)=>{N(e,t,h,m);let n=e.message.bodies.map(e=>e.key),r=e.message.links.map(e=>e.key);new Set(n).size!==n.length&&t.addIssue({code:`custom`,message:`message_body_duplicate`});for(let i of e.message.variants){let e=i.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!n.includes(e)))&&t.addIssue({code:`custom`,message:`message_body_reference_invalid`}),JSON.stringify(i.linkLabels.map(e=>e.key))!==JSON.stringify(r)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`})}}),ie=e.union([P,R,W,q,X,Z]),ae=e.object({destinationKey:e.string().min(1),state:e.enum(v),attempts:e.number().int().min(0).max(4),failureCode:e.enum(y).nullable(),lastAttemptAt:D.nullable(),nextAttemptAt:D.nullable(),leaseExpiresAt:D.nullable()}).strict(),Q=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:O,routeKey:A,subject:k,state:e.enum(g),reason:e.enum(_),terminal:e.boolean(),acceptedAt:D,updatedAt:D,deliverBy:D,terminalAt:D.nullable(),destinations:e.array(ae).min(1).max(20)}).strict(),oe=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(x)}).strict(),se=e.object({code:e.literal(`invalid_request`),issues:e.array(oe).max(20).optional()}).strict(),ce=e.object({code:e.enum(b.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([se,ce]),le=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),ue=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:Q}).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{le as notificationDeliverResultV1Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,i as notificationDeliveryContractVersionV4,a as notificationDeliveryContractVersionV5,s as notificationDeliveryMaximumDeadlineMillisecondsV1,l as notificationDeliveryMaximumDeadlineMillisecondsV2,d as notificationDeliveryMaximumDeadlineMillisecondsV3,p as notificationDeliveryMaximumDeadlineMillisecondsV4,h as notificationDeliveryMaximumDeadlineMillisecondsV5,_ as notificationDeliveryReasonsV1,Q as notificationDeliveryReceiptV1Schema,b as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,o as notificationDeliveryRequestMaximumUtf8BytesV1,c as notificationDeliveryRequestMaximumUtf8BytesV2,u as notificationDeliveryRequestMaximumUtf8BytesV3,f as notificationDeliveryRequestMaximumUtf8BytesV4,m as notificationDeliveryRequestMaximumUtf8BytesV5,ie as notificationDeliveryRequestSchema,P as notificationDeliveryRequestV1Schema,R as notificationDeliveryRequestV2Schema,W as notificationDeliveryRequestV3Schema,q as notificationDeliveryRequestV4Schema,X as notificationDeliveryRequestV5Schema,Z as notificationDeliveryRequestV6Schema,g as notificationDeliveryStatesV1,y as notificationDestinationFailureCodesV1,v as notificationDestinationStatesV1,ue as notificationGetReceiptResultV1Schema,ee as notificationMessageVariantKeys,x as notificationValidationIssueCodesV1};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@closerepo/notification-contracts",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {