@closerepo/notification-contracts 1.11.0 → 1.13.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
@@ -1,4 +1,17 @@
1
1
  import { z } from "zod";
2
+ //#region src/browser-payload.d.ts
3
+ /** Data-only FCM transport consumed by the single notification service worker. */
4
+ declare const notificationBrowserPayloadSchema: z.ZodObject<{
5
+ eventId: z.ZodUUID;
6
+ deliverBy: z.ZodISODateTime;
7
+ locale: z.ZodString;
8
+ contentLocale: z.ZodString;
9
+ title: z.ZodString;
10
+ body: z.ZodString;
11
+ url: z.ZodURL;
12
+ }, z.core.$strict>;
13
+ type NotificationBrowserPayload = z.infer<typeof notificationBrowserPayloadSchema>;
14
+ //#endregion
2
15
  //#region src/index.d.ts
3
16
  declare const notificationDeliveryContractVersionV1: 1;
4
17
  declare const notificationDeliveryContractVersionV2: 2;
@@ -7,6 +20,7 @@ declare const notificationDeliveryContractVersionV4: 4;
7
20
  declare const notificationDeliveryContractVersionV5: 5;
8
21
  declare const notificationDeliveryContractVersionV7: 7;
9
22
  declare const notificationDeliveryContractVersionV8: 8;
23
+ declare const notificationDeliveryContractVersionV9: 9;
10
24
  declare const notificationDeliveryMaximumDestinationsV1 = 20;
11
25
  declare const notificationDeliveryRequestMaximumUtf8BytesV1: number;
12
26
  declare const notificationDeliveryMaximumDeadlineMillisecondsV1: number;
@@ -17,6 +31,7 @@ declare const notificationDeliveryMaximumDeadlineMillisecondsV3: number;
17
31
  declare const notificationDeliveryRequestMaximumUtf8BytesV4: number;
18
32
  declare const notificationDeliveryMaximumDeadlineMillisecondsV4: number;
19
33
  declare const notificationDeliveryRequestMaximumUtf8BytesV5: number;
34
+ declare const notificationDeliveryRequestMaximumUtf8BytesV9: number;
20
35
  declare const notificationDeliveryMaximumDeadlineMillisecondsV5: number;
21
36
  declare const localTaskDeliveryContractVersionV1: 1;
22
37
  declare const localTaskDeliveryRequestMaximumUtf8BytesV1: number;
@@ -409,7 +424,7 @@ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
409
424
  }, z.core.$strict>], "type">>;
410
425
  bodyRefs: z.ZodArray<z.ZodObject<{
411
426
  key: z.ZodString;
412
- label: z.ZodString;
427
+ label: z.ZodOptional<z.ZodString>;
413
428
  }, z.core.$strict>>;
414
429
  footer: z.ZodOptional<z.ZodString>;
415
430
  }, z.core.$strict>, z.ZodObject<{
@@ -435,7 +450,7 @@ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
435
450
  }, z.core.$strict>], "type">>;
436
451
  bodyRefs: z.ZodArray<z.ZodObject<{
437
452
  key: z.ZodString;
438
- label: z.ZodString;
453
+ label: z.ZodOptional<z.ZodString>;
439
454
  }, z.core.$strict>>;
440
455
  footer: z.ZodOptional<z.ZodString>;
441
456
  }, z.core.$strict>], "key">>;
@@ -493,7 +508,7 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
493
508
  }, z.core.$strict>], "type">>;
494
509
  bodyRefs: z.ZodArray<z.ZodObject<{
495
510
  key: z.ZodString;
496
- label: z.ZodString;
511
+ label: z.ZodOptional<z.ZodString>;
497
512
  }, z.core.$strict>>;
498
513
  footer: z.ZodOptional<z.ZodString>;
499
514
  }, z.core.$strict>, z.ZodObject<{
@@ -519,7 +534,7 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
519
534
  }, z.core.$strict>], "type">>;
520
535
  bodyRefs: z.ZodArray<z.ZodObject<{
521
536
  key: z.ZodString;
522
- label: z.ZodString;
537
+ label: z.ZodOptional<z.ZodString>;
523
538
  }, z.core.$strict>>;
524
539
  footer: z.ZodOptional<z.ZodString>;
525
540
  }, z.core.$strict>], "key">>;
@@ -576,7 +591,7 @@ declare const notificationDeliveryRequestV8Schema: z.ZodObject<{
576
591
  }, z.core.$strict>], "type">>;
577
592
  bodyRefs: z.ZodArray<z.ZodObject<{
578
593
  key: z.ZodString;
579
- label: z.ZodString;
594
+ label: z.ZodOptional<z.ZodString>;
580
595
  }, z.core.$strict>>;
581
596
  footer: z.ZodOptional<z.ZodString>;
582
597
  }, z.core.$strict>, z.ZodObject<{
@@ -602,7 +617,7 @@ declare const notificationDeliveryRequestV8Schema: z.ZodObject<{
602
617
  }, z.core.$strict>], "type">>;
603
618
  bodyRefs: z.ZodArray<z.ZodObject<{
604
619
  key: z.ZodString;
605
- label: z.ZodString;
620
+ label: z.ZodOptional<z.ZodString>;
606
621
  }, z.core.$strict>>;
607
622
  footer: z.ZodOptional<z.ZodString>;
608
623
  }, z.core.$strict>], "key">>;
@@ -633,9 +648,111 @@ declare const notificationDeliveryRequestV8Schema: z.ZodObject<{
633
648
  }, z.core.$strict>>;
634
649
  }, z.core.$strict>], "type">>;
635
650
  bodyRefs: z.ZodArray<z.ZodObject<{
651
+ key: z.ZodString;
652
+ label: z.ZodOptional<z.ZodString>;
653
+ }, z.core.$strict>>;
654
+ footer: z.ZodOptional<z.ZodString>;
655
+ }, z.core.$strict>, z.ZodObject<{
656
+ key: z.ZodLiteral<"zh-CN">;
657
+ title: z.ZodString;
658
+ locale: z.ZodLiteral<"zh-CN">;
659
+ linkLabels: z.ZodArray<z.ZodObject<{
636
660
  key: z.ZodString;
637
661
  label: z.ZodString;
638
662
  }, z.core.$strict>>;
663
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
664
+ key: z.ZodString;
665
+ type: z.ZodLiteral<"text">;
666
+ label: z.ZodOptional<z.ZodString>;
667
+ value: z.ZodString;
668
+ }, z.core.$strict>, z.ZodObject<{
669
+ key: z.ZodString;
670
+ type: z.ZodLiteral<"fields">;
671
+ items: z.ZodArray<z.ZodObject<{
672
+ label: z.ZodString;
673
+ value: z.ZodString;
674
+ }, z.core.$strict>>;
675
+ }, z.core.$strict>], "type">>;
676
+ bodyRefs: z.ZodArray<z.ZodObject<{
677
+ key: z.ZodString;
678
+ label: z.ZodOptional<z.ZodString>;
679
+ }, z.core.$strict>>;
680
+ footer: z.ZodOptional<z.ZodString>;
681
+ }, z.core.$strict>], "key">>>>;
682
+ }, z.core.$strict>;
683
+ routeKeys: z.ZodArray<z.ZodString>;
684
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
685
+ eventId: z.ZodString;
686
+ producer: z.ZodObject<{
687
+ key: z.ZodString;
688
+ environment: z.ZodString;
689
+ }, z.core.$strict>;
690
+ occurredAt: z.ZodString;
691
+ requestedAt: z.ZodString;
692
+ deliverBy: z.ZodString;
693
+ subject: z.ZodObject<{
694
+ type: z.ZodString;
695
+ id: z.ZodString;
696
+ revision: z.ZodNumber;
697
+ }, z.core.$strict>;
698
+ }, z.core.$strict>;
699
+ type NotificationDeliveryRequestV8 = z.infer<typeof notificationDeliveryRequestV8Schema>;
700
+ /** Producer-owned copy; a fallback keeps the intended audience separate from the actual language. */
701
+ declare const notificationBrowserMessageSchema: z.ZodObject<{
702
+ locale: z.ZodString;
703
+ contentLocale: z.ZodString;
704
+ title: z.ZodString;
705
+ body: z.ZodString;
706
+ url: z.ZodString;
707
+ }, z.core.$strict>;
708
+ /** Audience and browser copy are additive; historical channel contracts keep their exact validation. */
709
+ declare const notificationDeliveryRequestV9Schema: z.ZodObject<{
710
+ contractVersion: z.ZodLiteral<9>;
711
+ audience: z.ZodOptional<z.ZodObject<{
712
+ topics: z.ZodArray<z.ZodString>;
713
+ }, z.core.$strict>>;
714
+ browserMessages: z.ZodOptional<z.ZodArray<z.ZodObject<{
715
+ locale: z.ZodString;
716
+ contentLocale: z.ZodString;
717
+ title: z.ZodString;
718
+ body: z.ZodString;
719
+ url: z.ZodString;
720
+ }, z.core.$strict>>>;
721
+ message: z.ZodObject<{
722
+ type: z.ZodLiteral<"structured_notification">;
723
+ links: z.ZodArray<z.ZodObject<{
724
+ key: z.ZodString;
725
+ url: z.ZodString;
726
+ }, z.core.$strict>>;
727
+ bodies: z.ZodArray<z.ZodObject<{
728
+ key: z.ZodString;
729
+ value: z.ZodString;
730
+ }, z.core.$strict>>;
731
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
732
+ key: z.ZodLiteral<"source">;
733
+ title: z.ZodString;
734
+ locale: z.ZodLiteral<"und">;
735
+ linkLabels: z.ZodArray<z.ZodObject<{
736
+ key: z.ZodString;
737
+ label: z.ZodString;
738
+ }, z.core.$strict>>;
739
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
740
+ key: z.ZodString;
741
+ type: z.ZodLiteral<"text">;
742
+ label: z.ZodOptional<z.ZodString>;
743
+ value: z.ZodString;
744
+ }, z.core.$strict>, z.ZodObject<{
745
+ key: z.ZodString;
746
+ type: z.ZodLiteral<"fields">;
747
+ items: z.ZodArray<z.ZodObject<{
748
+ label: z.ZodString;
749
+ value: z.ZodString;
750
+ }, z.core.$strict>>;
751
+ }, z.core.$strict>], "type">>;
752
+ bodyRefs: z.ZodArray<z.ZodObject<{
753
+ key: z.ZodString;
754
+ label: z.ZodOptional<z.ZodString>;
755
+ }, z.core.$strict>>;
639
756
  footer: z.ZodOptional<z.ZodString>;
640
757
  }, z.core.$strict>, z.ZodObject<{
641
758
  key: z.ZodLiteral<"zh-CN">;
@@ -659,9 +776,67 @@ declare const notificationDeliveryRequestV8Schema: z.ZodObject<{
659
776
  }, z.core.$strict>>;
660
777
  }, z.core.$strict>], "type">>;
661
778
  bodyRefs: z.ZodArray<z.ZodObject<{
779
+ key: z.ZodString;
780
+ label: z.ZodOptional<z.ZodString>;
781
+ }, z.core.$strict>>;
782
+ footer: z.ZodOptional<z.ZodString>;
783
+ }, z.core.$strict>], "key">>;
784
+ channelVariants: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
785
+ qq: "qq";
786
+ tg: "tg";
787
+ wechat: "wechat";
788
+ lark: "lark";
789
+ }> & z.core.$partial, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
790
+ key: z.ZodLiteral<"source">;
791
+ title: z.ZodString;
792
+ locale: z.ZodLiteral<"und">;
793
+ linkLabels: z.ZodArray<z.ZodObject<{
662
794
  key: z.ZodString;
663
795
  label: z.ZodString;
664
796
  }, z.core.$strict>>;
797
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
798
+ key: z.ZodString;
799
+ type: z.ZodLiteral<"text">;
800
+ label: z.ZodOptional<z.ZodString>;
801
+ value: z.ZodString;
802
+ }, z.core.$strict>, z.ZodObject<{
803
+ key: z.ZodString;
804
+ type: z.ZodLiteral<"fields">;
805
+ items: z.ZodArray<z.ZodObject<{
806
+ label: z.ZodString;
807
+ value: z.ZodString;
808
+ }, z.core.$strict>>;
809
+ }, z.core.$strict>], "type">>;
810
+ bodyRefs: z.ZodArray<z.ZodObject<{
811
+ key: z.ZodString;
812
+ label: z.ZodOptional<z.ZodString>;
813
+ }, z.core.$strict>>;
814
+ footer: z.ZodOptional<z.ZodString>;
815
+ }, z.core.$strict>, z.ZodObject<{
816
+ key: z.ZodLiteral<"zh-CN">;
817
+ title: z.ZodString;
818
+ locale: z.ZodLiteral<"zh-CN">;
819
+ linkLabels: z.ZodArray<z.ZodObject<{
820
+ key: z.ZodString;
821
+ label: z.ZodString;
822
+ }, z.core.$strict>>;
823
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
824
+ key: z.ZodString;
825
+ type: z.ZodLiteral<"text">;
826
+ label: z.ZodOptional<z.ZodString>;
827
+ value: z.ZodString;
828
+ }, z.core.$strict>, z.ZodObject<{
829
+ key: z.ZodString;
830
+ type: z.ZodLiteral<"fields">;
831
+ items: z.ZodArray<z.ZodObject<{
832
+ label: z.ZodString;
833
+ value: z.ZodString;
834
+ }, z.core.$strict>>;
835
+ }, z.core.$strict>], "type">>;
836
+ bodyRefs: z.ZodArray<z.ZodObject<{
837
+ key: z.ZodString;
838
+ label: z.ZodOptional<z.ZodString>;
839
+ }, z.core.$strict>>;
665
840
  footer: z.ZodOptional<z.ZodString>;
666
841
  }, z.core.$strict>], "key">>>>;
667
842
  }, z.core.$strict>;
@@ -681,7 +856,8 @@ declare const notificationDeliveryRequestV8Schema: z.ZodObject<{
681
856
  revision: z.ZodNumber;
682
857
  }, z.core.$strict>;
683
858
  }, z.core.$strict>;
684
- type NotificationDeliveryRequestV8 = z.infer<typeof notificationDeliveryRequestV8Schema>;
859
+ type NotificationDeliveryRequestV9 = z.infer<typeof notificationDeliveryRequestV9Schema>;
860
+ type NotificationBrowserMessage = z.infer<typeof notificationBrowserMessageSchema>;
685
861
  type NotificationMessageVariantsV6 = NotificationDeliveryRequestV6['message']['variants'];
686
862
  /** Reads routing facts from current envelopes and historical single-route records. */
687
863
  declare function notificationRouteKeys(value: {
@@ -1063,7 +1239,7 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1063
1239
  }, z.core.$strict>], "type">>;
1064
1240
  bodyRefs: z.ZodArray<z.ZodObject<{
1065
1241
  key: z.ZodString;
1066
- label: z.ZodString;
1242
+ label: z.ZodOptional<z.ZodString>;
1067
1243
  }, z.core.$strict>>;
1068
1244
  footer: z.ZodOptional<z.ZodString>;
1069
1245
  }, z.core.$strict>, z.ZodObject<{
@@ -1089,7 +1265,7 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1089
1265
  }, z.core.$strict>], "type">>;
1090
1266
  bodyRefs: z.ZodArray<z.ZodObject<{
1091
1267
  key: z.ZodString;
1092
- label: z.ZodString;
1268
+ label: z.ZodOptional<z.ZodString>;
1093
1269
  }, z.core.$strict>>;
1094
1270
  footer: z.ZodOptional<z.ZodString>;
1095
1271
  }, z.core.$strict>], "key">>;
@@ -1145,7 +1321,7 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1145
1321
  }, z.core.$strict>], "type">>;
1146
1322
  bodyRefs: z.ZodArray<z.ZodObject<{
1147
1323
  key: z.ZodString;
1148
- label: z.ZodString;
1324
+ label: z.ZodOptional<z.ZodString>;
1149
1325
  }, z.core.$strict>>;
1150
1326
  footer: z.ZodOptional<z.ZodString>;
1151
1327
  }, z.core.$strict>, z.ZodObject<{
@@ -1171,7 +1347,7 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1171
1347
  }, z.core.$strict>], "type">>;
1172
1348
  bodyRefs: z.ZodArray<z.ZodObject<{
1173
1349
  key: z.ZodString;
1174
- label: z.ZodString;
1350
+ label: z.ZodOptional<z.ZodString>;
1175
1351
  }, z.core.$strict>>;
1176
1352
  footer: z.ZodOptional<z.ZodString>;
1177
1353
  }, z.core.$strict>], "key">>;
@@ -1225,7 +1401,7 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1225
1401
  }, z.core.$strict>], "type">>;
1226
1402
  bodyRefs: z.ZodArray<z.ZodObject<{
1227
1403
  key: z.ZodString;
1228
- label: z.ZodString;
1404
+ label: z.ZodOptional<z.ZodString>;
1229
1405
  }, z.core.$strict>>;
1230
1406
  footer: z.ZodOptional<z.ZodString>;
1231
1407
  }, z.core.$strict>, z.ZodObject<{
@@ -1251,7 +1427,7 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1251
1427
  }, z.core.$strict>], "type">>;
1252
1428
  bodyRefs: z.ZodArray<z.ZodObject<{
1253
1429
  key: z.ZodString;
1254
- label: z.ZodString;
1430
+ label: z.ZodOptional<z.ZodString>;
1255
1431
  }, z.core.$strict>>;
1256
1432
  footer: z.ZodOptional<z.ZodString>;
1257
1433
  }, z.core.$strict>], "key">>;
@@ -1282,9 +1458,100 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1282
1458
  }, z.core.$strict>>;
1283
1459
  }, z.core.$strict>], "type">>;
1284
1460
  bodyRefs: z.ZodArray<z.ZodObject<{
1461
+ key: z.ZodString;
1462
+ label: z.ZodOptional<z.ZodString>;
1463
+ }, z.core.$strict>>;
1464
+ footer: z.ZodOptional<z.ZodString>;
1465
+ }, z.core.$strict>, z.ZodObject<{
1466
+ key: z.ZodLiteral<"zh-CN">;
1467
+ title: z.ZodString;
1468
+ locale: z.ZodLiteral<"zh-CN">;
1469
+ linkLabels: z.ZodArray<z.ZodObject<{
1470
+ key: z.ZodString;
1471
+ label: z.ZodString;
1472
+ }, z.core.$strict>>;
1473
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1474
+ key: z.ZodString;
1475
+ type: z.ZodLiteral<"text">;
1476
+ label: z.ZodOptional<z.ZodString>;
1477
+ value: z.ZodString;
1478
+ }, z.core.$strict>, z.ZodObject<{
1479
+ key: z.ZodString;
1480
+ type: z.ZodLiteral<"fields">;
1481
+ items: z.ZodArray<z.ZodObject<{
1482
+ label: z.ZodString;
1483
+ value: z.ZodString;
1484
+ }, z.core.$strict>>;
1485
+ }, z.core.$strict>], "type">>;
1486
+ bodyRefs: z.ZodArray<z.ZodObject<{
1487
+ key: z.ZodString;
1488
+ label: z.ZodOptional<z.ZodString>;
1489
+ }, z.core.$strict>>;
1490
+ footer: z.ZodOptional<z.ZodString>;
1491
+ }, z.core.$strict>], "key">>>>;
1492
+ }, z.core.$strict>;
1493
+ routeKeys: z.ZodArray<z.ZodString>;
1494
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
1495
+ eventId: z.ZodString;
1496
+ producer: z.ZodObject<{
1497
+ key: z.ZodString;
1498
+ environment: z.ZodString;
1499
+ }, z.core.$strict>;
1500
+ occurredAt: z.ZodString;
1501
+ requestedAt: z.ZodString;
1502
+ deliverBy: z.ZodString;
1503
+ subject: z.ZodObject<{
1504
+ type: z.ZodString;
1505
+ id: z.ZodString;
1506
+ revision: z.ZodNumber;
1507
+ }, z.core.$strict>;
1508
+ }, z.core.$strict>, z.ZodObject<{
1509
+ contractVersion: z.ZodLiteral<9>;
1510
+ audience: z.ZodOptional<z.ZodObject<{
1511
+ topics: z.ZodArray<z.ZodString>;
1512
+ }, z.core.$strict>>;
1513
+ browserMessages: z.ZodOptional<z.ZodArray<z.ZodObject<{
1514
+ locale: z.ZodString;
1515
+ contentLocale: z.ZodString;
1516
+ title: z.ZodString;
1517
+ body: z.ZodString;
1518
+ url: z.ZodString;
1519
+ }, z.core.$strict>>>;
1520
+ message: z.ZodObject<{
1521
+ type: z.ZodLiteral<"structured_notification">;
1522
+ links: z.ZodArray<z.ZodObject<{
1523
+ key: z.ZodString;
1524
+ url: z.ZodString;
1525
+ }, z.core.$strict>>;
1526
+ bodies: z.ZodArray<z.ZodObject<{
1527
+ key: z.ZodString;
1528
+ value: z.ZodString;
1529
+ }, z.core.$strict>>;
1530
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1531
+ key: z.ZodLiteral<"source">;
1532
+ title: z.ZodString;
1533
+ locale: z.ZodLiteral<"und">;
1534
+ linkLabels: z.ZodArray<z.ZodObject<{
1285
1535
  key: z.ZodString;
1286
1536
  label: z.ZodString;
1287
1537
  }, z.core.$strict>>;
1538
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1539
+ key: z.ZodString;
1540
+ type: z.ZodLiteral<"text">;
1541
+ label: z.ZodOptional<z.ZodString>;
1542
+ value: z.ZodString;
1543
+ }, z.core.$strict>, z.ZodObject<{
1544
+ key: z.ZodString;
1545
+ type: z.ZodLiteral<"fields">;
1546
+ items: z.ZodArray<z.ZodObject<{
1547
+ label: z.ZodString;
1548
+ value: z.ZodString;
1549
+ }, z.core.$strict>>;
1550
+ }, z.core.$strict>], "type">>;
1551
+ bodyRefs: z.ZodArray<z.ZodObject<{
1552
+ key: z.ZodString;
1553
+ label: z.ZodOptional<z.ZodString>;
1554
+ }, z.core.$strict>>;
1288
1555
  footer: z.ZodOptional<z.ZodString>;
1289
1556
  }, z.core.$strict>, z.ZodObject<{
1290
1557
  key: z.ZodLiteral<"zh-CN">;
@@ -1308,9 +1575,67 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1308
1575
  }, z.core.$strict>>;
1309
1576
  }, z.core.$strict>], "type">>;
1310
1577
  bodyRefs: z.ZodArray<z.ZodObject<{
1578
+ key: z.ZodString;
1579
+ label: z.ZodOptional<z.ZodString>;
1580
+ }, z.core.$strict>>;
1581
+ footer: z.ZodOptional<z.ZodString>;
1582
+ }, z.core.$strict>], "key">>;
1583
+ channelVariants: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
1584
+ qq: "qq";
1585
+ tg: "tg";
1586
+ wechat: "wechat";
1587
+ lark: "lark";
1588
+ }> & z.core.$partial, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1589
+ key: z.ZodLiteral<"source">;
1590
+ title: z.ZodString;
1591
+ locale: z.ZodLiteral<"und">;
1592
+ linkLabels: z.ZodArray<z.ZodObject<{
1593
+ key: z.ZodString;
1594
+ label: z.ZodString;
1595
+ }, z.core.$strict>>;
1596
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1597
+ key: z.ZodString;
1598
+ type: z.ZodLiteral<"text">;
1599
+ label: z.ZodOptional<z.ZodString>;
1600
+ value: z.ZodString;
1601
+ }, z.core.$strict>, z.ZodObject<{
1602
+ key: z.ZodString;
1603
+ type: z.ZodLiteral<"fields">;
1604
+ items: z.ZodArray<z.ZodObject<{
1605
+ label: z.ZodString;
1606
+ value: z.ZodString;
1607
+ }, z.core.$strict>>;
1608
+ }, z.core.$strict>], "type">>;
1609
+ bodyRefs: z.ZodArray<z.ZodObject<{
1610
+ key: z.ZodString;
1611
+ label: z.ZodOptional<z.ZodString>;
1612
+ }, z.core.$strict>>;
1613
+ footer: z.ZodOptional<z.ZodString>;
1614
+ }, z.core.$strict>, z.ZodObject<{
1615
+ key: z.ZodLiteral<"zh-CN">;
1616
+ title: z.ZodString;
1617
+ locale: z.ZodLiteral<"zh-CN">;
1618
+ linkLabels: z.ZodArray<z.ZodObject<{
1311
1619
  key: z.ZodString;
1312
1620
  label: z.ZodString;
1313
1621
  }, z.core.$strict>>;
1622
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1623
+ key: z.ZodString;
1624
+ type: z.ZodLiteral<"text">;
1625
+ label: z.ZodOptional<z.ZodString>;
1626
+ value: z.ZodString;
1627
+ }, z.core.$strict>, z.ZodObject<{
1628
+ key: z.ZodString;
1629
+ type: z.ZodLiteral<"fields">;
1630
+ items: z.ZodArray<z.ZodObject<{
1631
+ label: z.ZodString;
1632
+ value: z.ZodString;
1633
+ }, z.core.$strict>>;
1634
+ }, z.core.$strict>], "type">>;
1635
+ bodyRefs: z.ZodArray<z.ZodObject<{
1636
+ key: z.ZodString;
1637
+ label: z.ZodOptional<z.ZodString>;
1638
+ }, z.core.$strict>>;
1314
1639
  footer: z.ZodOptional<z.ZodString>;
1315
1640
  }, z.core.$strict>], "key">>>>;
1316
1641
  }, z.core.$strict>;
@@ -2588,4 +2913,4 @@ interface NotificationMessageDeliveryServiceV4 {
2588
2913
  /** Multi-route message delivery; historical requests and receipts remain supported. */
2589
2914
  interface NotificationMessageDeliveryServiceV5 extends NotificationMessageDeliveryServiceV4 {}
2590
2915
  //#endregion
2591
- export { CreatorDraftTaskV1, LocalTaskDeliverResultV1, LocalTaskDeliveryReceiptV1, LocalTaskDeliveryRequest, LocalTaskDeliveryRequestV1, LocalTaskDeliveryServiceV1, LocalTaskGetReceiptResultV1, NotificationDeliverResultV1, NotificationDeliverResultV2, NotificationDeliveryChannelKey, NotificationDeliveryReceiptV1, NotificationDeliveryReceiptV2, NotificationDeliveryReceiptV3, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryRequestV6, NotificationDeliveryRequestV7, NotificationDeliveryRequestV8, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationDeliveryServiceV3, NotificationGetReceiptResultV1, NotificationGetReceiptResultV2, NotificationMessageBody, NotificationMessageDeliveryServiceV4, NotificationMessageDeliveryServiceV5, NotificationMessageReceipt, NotificationMessageVariantKey, NotificationMessageVariantsV6, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, localTaskDeliveryContractVersionV1, localTaskDeliveryMaximumDeadlineMillisecondsV1, localTaskDeliveryRequestMaximumUtf8BytesV1, localTaskDeliveryRequestSchema, localTaskDeliveryRequestV1Schema, notificationDeliverResultV1Schema, notificationDeliverResultV2Schema, notificationDeliveryChannelKeys, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryContractVersionV5, notificationDeliveryContractVersionV7, notificationDeliveryContractVersionV8, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryMaximumDeadlineMillisecondsV4, notificationDeliveryMaximumDeadlineMillisecondsV5, notificationDeliveryMaximumDestinationsV1, notificationDeliveryReasonsV1, notificationDeliveryReasonsV2, notificationDeliveryReceiptV1Schema, notificationDeliveryReceiptV2Schema, notificationDeliveryReceiptV3Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestMaximumUtf8BytesV4, notificationDeliveryRequestMaximumUtf8BytesV5, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, notificationDeliveryRequestV4Schema, notificationDeliveryRequestV5Schema, notificationDeliveryRequestV6Schema, notificationDeliveryRequestV7Schema, notificationDeliveryRequestV8Schema, notificationDeliveryStatesV1, notificationDeliveryStatesV2, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationDestinationStatesV2, notificationGetReceiptResultV1Schema, notificationGetReceiptResultV2Schema, notificationMessageReceiptSchema, notificationMessageVariantKeys, notificationRouteKeys, notificationValidationIssueCodesV1, safeDeliveryCauseSchema };
2916
+ export { CreatorDraftTaskV1, LocalTaskDeliverResultV1, LocalTaskDeliveryReceiptV1, LocalTaskDeliveryRequest, LocalTaskDeliveryRequestV1, LocalTaskDeliveryServiceV1, LocalTaskGetReceiptResultV1, NotificationBrowserMessage, type NotificationBrowserPayload, NotificationDeliverResultV1, NotificationDeliverResultV2, NotificationDeliveryChannelKey, NotificationDeliveryReceiptV1, NotificationDeliveryReceiptV2, NotificationDeliveryReceiptV3, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryRequestV6, NotificationDeliveryRequestV7, NotificationDeliveryRequestV8, NotificationDeliveryRequestV9, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationDeliveryServiceV3, NotificationGetReceiptResultV1, NotificationGetReceiptResultV2, NotificationMessageBody, NotificationMessageDeliveryServiceV4, NotificationMessageDeliveryServiceV5, NotificationMessageReceipt, NotificationMessageVariantKey, NotificationMessageVariantsV6, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, localTaskDeliveryContractVersionV1, localTaskDeliveryMaximumDeadlineMillisecondsV1, localTaskDeliveryRequestMaximumUtf8BytesV1, localTaskDeliveryRequestSchema, localTaskDeliveryRequestV1Schema, notificationBrowserMessageSchema, notificationBrowserPayloadSchema, notificationDeliverResultV1Schema, notificationDeliverResultV2Schema, notificationDeliveryChannelKeys, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryContractVersionV5, notificationDeliveryContractVersionV7, notificationDeliveryContractVersionV8, notificationDeliveryContractVersionV9, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryMaximumDeadlineMillisecondsV4, notificationDeliveryMaximumDeadlineMillisecondsV5, notificationDeliveryMaximumDestinationsV1, notificationDeliveryReasonsV1, notificationDeliveryReasonsV2, notificationDeliveryReceiptV1Schema, notificationDeliveryReceiptV2Schema, notificationDeliveryReceiptV3Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestMaximumUtf8BytesV4, notificationDeliveryRequestMaximumUtf8BytesV5, notificationDeliveryRequestMaximumUtf8BytesV9, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, notificationDeliveryRequestV4Schema, notificationDeliveryRequestV5Schema, notificationDeliveryRequestV6Schema, notificationDeliveryRequestV7Schema, notificationDeliveryRequestV8Schema, notificationDeliveryRequestV9Schema, notificationDeliveryStatesV1, notificationDeliveryStatesV2, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationDestinationStatesV2, notificationGetReceiptResultV1Schema, notificationGetReceiptResultV2Schema, notificationMessageReceiptSchema, notificationMessageVariantKeys, notificationRouteKeys, notificationValidationIssueCodesV1, safeDeliveryCauseSchema };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{z as e}from"zod";const t=1,n=2,r=3,i=4,a=5,o=7,s=8,ee=20,c=32*1024,l=1380*60*1e3,te=c,ne=l,re=c,ie=l,u=c,d=l,f=c,p=l,ae=1,m=32*1024,oe=10080*60*1e3,h=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],g=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],se=[...h,`unconfirmed`],_=[...g,`delivery_unconfirmed`],v=[`pending`,`delivering`,`delivered`,`failed`,`expired`],y=[...v,`unconfirmed`],b=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],x=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],S=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],ce=[`source`,`zh-CN`],C=[`qq`,`tg`,`wechat`,`lark`],le=new TextEncoder,w=/^[a-z][a-z0-9-]{0,62}$/,ue=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,de=/^[A-Z0-9][\w.:-]{0,127}$/i;function fe(e){return[...e].length}function T(t){return e.string().refine(e=>fe(e)>0,{message:`too_small`}).refine(e=>fe(e)<=t,{message:`too_big`})}const E=e.string().datetime({offset:!0}),D=e.object({key:e.string().regex(w),environment:e.string().regex(w)}).strict(),O=e.object({type:e.string().regex(w),id:e.string().regex(de),revision:e.number().int().positive()}).strict(),k=e.string().min(1).max(127).regex(ue),A=e.object({label:T(48),url:T(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(),j={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:D,routeKey:k,occurredAt:E,requestedAt:E,deliverBy:E,subject:O},pe=e.object({contractVersion:e.literal(1),...j,message:e.object({type:e.literal(`link_summary`),title:T(160),summary:T(1200),facts:e.array(e.object({label:T(48),value:T(500)}).strict()).max(10),primaryLink:A,sourceLink:A.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`]}),le.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const N=pe.superRefine((e,t)=>M(e,t,l,c)),P={title:T(160),summary:T(1200),facts:e.array(e.object({label:T(48),value:T(500)}).strict()).max(10)},me=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()]),he=e.array(me).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`})}),F=e.object({contractVersion:e.literal(2),...j,message:e.object({type:e.literal(`localized_link_summary`),variants:he,primaryLink:A,sourceLink:A.optional()}).strict()}).strict().superRefine((e,t)=>M(e,t,ne,te)),ge=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(w),type:e.literal(`text`),label:T(48).optional(),value:T(4e3)}).strict(),e.object({key:e.string().regex(w),type:e.literal(`fields`),items:e.array(e.object({label:T(48),value:T(1200)}).strict()).min(1).max(20)}).strict()]),I=e.array(ge).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),L=I.min(1),R=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:T(160),sections:L}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:T(160),sections:L}).strict()]),z=(e,t,n=!1)=>{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 r=e.find(e=>e.key===`source`),i=e.find(e=>e.key===`zh-CN`);if(r&&i){let a=new Set(r.sections.map(e=>e.key)),o=new Set(i.sections.map(e=>e.key)),s=r.sections.filter(e=>!n||e.type!==`text`||o.has(e.key)).map(e=>`${e.key}:${e.type}`),ee=i.sections.filter(e=>!n||e.type!==`text`||a.has(e.key)).map(e=>`${e.key}:${e.type}`);JSON.stringify(s)!==JSON.stringify(ee)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(i),`sections`]})}},_e=e.array(R).min(1).max(2).superRefine(z),B=e.object({contractVersion:e.literal(3),...j,message:e.object({type:e.literal(`structured_notification`),variants:_e,links:e.array(e.object({key:e.string().regex(w),...A.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(),V=B.superRefine((e,t)=>M(e,t,ie,re)),H=e.object({label:T(48).optional(),value:T(u)}).strict(),ve=e.discriminatedUnion(`key`,[R.options[0].extend({body:H}),R.options[1].extend({body:H})]),ye=B.extend({contractVersion:e.literal(4),message:B.shape.message.extend({variants:e.array(ve).min(1).max(2).superRefine(z)})}).superRefine((e,t)=>M(e,t,d,u)),U=e.discriminatedUnion(`key`,[R.options[0].extend({bodyLabel:T(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(w),label:T(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`})})}),R.options[1].extend({bodyLabel:T(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(w),label:T(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`})})})]),be=e.object({value:T(f)}).strict(),W=e.object({contractVersion:e.literal(5),...j,message:e.object({type:e.literal(`structured_notification`),variants:e.array(U).min(1).max(2).superRefine(z),links:e.array(e.object({key:e.string().regex(w),url:A.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:be}).strict()}).strict().superRefine((e,t)=>{M(e,t,p,f);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`]})}}),G=e.object({...W.shape,contractVersion:e.literal(6),message:W.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(w),value:T(f)}).strict()).max(2),variants:e.array(e.discriminatedUnion(`key`,[U.options[0].omit({bodyLabel:!0}).extend({sections:I,bodyRefs:e.array(e.object({key:e.string().regex(w),label:T(48)}).strict()).max(2),footer:T(500).optional()}),U.options[1].omit({bodyLabel:!0}).extend({sections:I,bodyRefs:e.array(e.object({key:e.string().regex(w),label:T(48)}).strict()).max(2),footer:T(500).optional()})])).min(1).max(2).superRefine((e,t)=>z(e,t,!0))})}).strict().superRefine(K);function K(e,t){M(e,t,p,f);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`}),xe(e.message.variants,n,r,t)}function xe(e,t,n,r,i){for(let[a,o]of e.entries()){let e=o.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!t.includes(e)))&&r.addIssue({code:`custom`,message:`message_body_reference_invalid`,...i?{path:[...i,a,`bodyRefs`]}:{}}),JSON.stringify(o.linkLabels.map(e=>e.key))!==JSON.stringify(n)&&r.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,...i?{path:[...i,a,`linkLabels`]}:{}})}}const Se=e.array(k).min(1).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`route_key_duplicate`})}),{routeKey:Ce,...we}=G.shape,q=G.shape.message,J=e.object({...we,contractVersion:e.literal(7),routeKeys:Se,message:q}).strict().superRefine(K),Te=e.object({...J.shape,contractVersion:e.literal(8),message:q.extend({channelVariants:e.partialRecord(e.enum(C),q.shape.variants).optional()})}).strict().superRefine((e,t)=>{K(e,t);let n=e.message.variants.map(e=>`${e.key}:${e.locale}`).sort(),r=e.message.bodies.map(e=>e.key),i=e.message.links.map(e=>e.key);for(let a of C){let o=e.message.channelVariants?.[a];if(!o)continue;let s=[`message`,`channelVariants`,a];JSON.stringify(o.map(e=>`${e.key}:${e.locale}`).sort())!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_channel_variant_languages_mismatch`,path:s}),xe(o,r,i,t,s)}});function Ee(e){return`routeKeys`in e?[...e.routeKeys].sort():[e.routeKey]}const De=e.object({type:e.literal(`creator.draft.v1`),templateId:e.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),signalType:e.string().regex(/^[a-z][a-z0-9_]*$/),sourceTextZh:T(m),sourceUrl:A.shape.url.optional()}).strict(),Oe=e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:D,routeKey:k,occurredAt:E,requestedAt:E,deliverBy:E,subject:O.extend({type:e.literal(`creator-event`)}),task:De}).strict().superRefine((e,t)=>M(e,t,oe,m)),ke=Oe,Ae=e.union([N,F,V,ye,W,G,J,Te]),je=e.object({destinationKey:e.string().min(1),state:e.enum(v),attempts:e.number().int().min(0).max(4),failureCode:e.enum(b).nullable(),lastAttemptAt:E.nullable(),nextAttemptAt:E.nullable(),leaseExpiresAt:E.nullable()}).strict(),Y=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:D,routeKey:k,subject:O,state:e.enum(h),reason:e.enum(g),terminal:e.boolean(),acceptedAt:E,updatedAt:E,deliverBy:E,terminalAt:E.nullable(),destinations:e.array(je).min(1).max(20)}).strict(),X=e.object({name:e.string().min(1).max(100),message:e.string().max(500).optional(),code:e.union([e.string().max(100),e.number()]).optional(),status:e.union([e.string().max(100),e.number()]).optional()}).strict(),Me=X.extend({cause:X.extend({cause:X.extend({cause:X.optional()}).optional()}).optional()}),Ne=je.extend({state:e.enum(y),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:Me.nullable(),unconfirmedAt:E.nullable()}),Z=Y.extend({contractVersion:e.literal(2),state:e.enum(se),reason:e.enum(_),revision:e.number().int().min(0),destinations:e.array(Ne).min(1).max(20)}),Pe=Z.omit({routeKey:!0}).extend({contractVersion:e.literal(3),routeKeys:Se}),Q=e.union([Y,Z,Pe]),Fe=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(S)}).strict(),Ie=e.object({code:e.literal(`invalid_request`),issues:e.array(Fe).max(20).optional()}).strict(),Le=e.object({code:e.enum(x.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([Ie,Le]),Re=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Y}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),ze=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:Y}).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()]),Be=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),Ve=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{ae as localTaskDeliveryContractVersionV1,oe as localTaskDeliveryMaximumDeadlineMillisecondsV1,m as localTaskDeliveryRequestMaximumUtf8BytesV1,ke as localTaskDeliveryRequestSchema,Oe as localTaskDeliveryRequestV1Schema,Re as notificationDeliverResultV1Schema,Be as notificationDeliverResultV2Schema,C as notificationDeliveryChannelKeys,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,i as notificationDeliveryContractVersionV4,a as notificationDeliveryContractVersionV5,o as notificationDeliveryContractVersionV7,s as notificationDeliveryContractVersionV8,l as notificationDeliveryMaximumDeadlineMillisecondsV1,ne as notificationDeliveryMaximumDeadlineMillisecondsV2,ie as notificationDeliveryMaximumDeadlineMillisecondsV3,d as notificationDeliveryMaximumDeadlineMillisecondsV4,p as notificationDeliveryMaximumDeadlineMillisecondsV5,ee as notificationDeliveryMaximumDestinationsV1,g as notificationDeliveryReasonsV1,_ as notificationDeliveryReasonsV2,Y as notificationDeliveryReceiptV1Schema,Z as notificationDeliveryReceiptV2Schema,Pe as notificationDeliveryReceiptV3Schema,x as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,c as notificationDeliveryRequestMaximumUtf8BytesV1,te as notificationDeliveryRequestMaximumUtf8BytesV2,re as notificationDeliveryRequestMaximumUtf8BytesV3,u as notificationDeliveryRequestMaximumUtf8BytesV4,f as notificationDeliveryRequestMaximumUtf8BytesV5,Ae as notificationDeliveryRequestSchema,N as notificationDeliveryRequestV1Schema,F as notificationDeliveryRequestV2Schema,V as notificationDeliveryRequestV3Schema,ye as notificationDeliveryRequestV4Schema,W as notificationDeliveryRequestV5Schema,G as notificationDeliveryRequestV6Schema,J as notificationDeliveryRequestV7Schema,Te as notificationDeliveryRequestV8Schema,h as notificationDeliveryStatesV1,se as notificationDeliveryStatesV2,b as notificationDestinationFailureCodesV1,v as notificationDestinationStatesV1,y as notificationDestinationStatesV2,ze as notificationGetReceiptResultV1Schema,Ve as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,ce as notificationMessageVariantKeys,Ee as notificationRouteKeys,S as notificationValidationIssueCodesV1,Me as safeDeliveryCauseSchema};
1
+ import{z as e}from"zod";const t=e.strictObject({eventId:e.uuid(),deliverBy:e.iso.datetime(),locale:e.string().min(1).max(35),contentLocale:e.string().min(1).max(35),title:e.string().trim().min(1).max(512),body:e.string(),url:e.url().refine(e=>new URL(e).protocol===`https:`,`notification_https_target_required`)}),n=1,r=2,i=3,a=4,o=5,s=7,ee=8,te=9,ne=20,c=32*1024,l=1380*60*1e3,u=c,d=l,f=c,re=l,p=c,ie=l,m=c,ae=64*1024,h=l,oe=1,g=32*1024,_=10080*60*1e3,v=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],y=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],b=[...v,`unconfirmed`],x=[...y,`delivery_unconfirmed`],S=[`pending`,`delivering`,`delivered`,`failed`,`expired`],se=[...S,`unconfirmed`],ce=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],le=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],ue=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],de=[`source`,`zh-CN`],C=[`qq`,`tg`,`wechat`,`lark`],fe=new TextEncoder,w=/^[a-z][a-z0-9-]{0,62}$/,pe=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,me=/^[A-Z0-9][\w.:-]{0,127}$/i;function he(e){return[...e].length}function T(t){return e.string().refine(e=>he(e)>0,{message:`too_small`}).refine(e=>he(e)<=t,{message:`too_big`})}const E=e.string().datetime({offset:!0}),D=e.object({key:e.string().regex(w),environment:e.string().regex(w)}).strict(),O=e.object({type:e.string().regex(w),id:e.string().regex(me),revision:e.number().int().positive()}).strict(),k=e.string().min(1).max(127).regex(pe),A=e.object({label:T(48),url:T(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(),j={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:D,routeKey:k,occurredAt:E,requestedAt:E,deliverBy:E,subject:O},ge=e.object({contractVersion:e.literal(1),...j,message:e.object({type:e.literal(`link_summary`),title:T(160),summary:T(1200),facts:e.array(e.object({label:T(48),value:T(500)}).strict()).max(10),primaryLink:A,sourceLink:A.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`]}),fe.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const N=ge.superRefine((e,t)=>M(e,t,l,c)),P={title:T(160),summary:T(1200),facts:e.array(e.object({label:T(48),value:T(500)}).strict()).max(10)},_e=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()]),ve=e.array(_e).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`})}),F=e.object({contractVersion:e.literal(2),...j,message:e.object({type:e.literal(`localized_link_summary`),variants:ve,primaryLink:A,sourceLink:A.optional()}).strict()}).strict().superRefine((e,t)=>M(e,t,d,u)),ye=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(w),type:e.literal(`text`),label:T(48).optional(),value:T(4e3)}).strict(),e.object({key:e.string().regex(w),type:e.literal(`fields`),items:e.array(e.object({label:T(48),value:T(1200)}).strict()).min(1).max(20)}).strict()]),I=e.array(ye).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),L=I.min(1),R=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:T(160),sections:L}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:T(160),sections:L}).strict()]),z=(e,t,n=!1)=>{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 r=e.find(e=>e.key===`source`),i=e.find(e=>e.key===`zh-CN`);if(r&&i){let a=new Set(r.sections.map(e=>e.key)),o=new Set(i.sections.map(e=>e.key)),s=r.sections.filter(e=>!n||e.type!==`text`||o.has(e.key)).map(e=>`${e.key}:${e.type}`),ee=i.sections.filter(e=>!n||e.type!==`text`||a.has(e.key)).map(e=>`${e.key}:${e.type}`);JSON.stringify(s)!==JSON.stringify(ee)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(i),`sections`]})}},be=e.array(R).min(1).max(2).superRefine(z),B=e.object({contractVersion:e.literal(3),...j,message:e.object({type:e.literal(`structured_notification`),variants:be,links:e.array(e.object({key:e.string().regex(w),...A.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(),xe=B.superRefine((e,t)=>M(e,t,re,f)),Se=e.object({label:T(48).optional(),value:T(p)}).strict(),Ce=e.discriminatedUnion(`key`,[R.options[0].extend({body:Se}),R.options[1].extend({body:Se})]),we=B.extend({contractVersion:e.literal(4),message:B.shape.message.extend({variants:e.array(Ce).min(1).max(2).superRefine(z)})}).superRefine((e,t)=>M(e,t,ie,p)),V=e.discriminatedUnion(`key`,[R.options[0].extend({bodyLabel:T(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(w),label:T(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`})})}),R.options[1].extend({bodyLabel:T(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(w),label:T(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`})})})]),Te=e.object({value:T(m)}).strict(),H=e.object({contractVersion:e.literal(5),...j,message:e.object({type:e.literal(`structured_notification`),variants:e.array(V).min(1).max(2).superRefine(z),links:e.array(e.object({key:e.string().regex(w),url:A.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:Te}).strict()}).strict().superRefine((e,t)=>{M(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`]})}}),U=e.object({...H.shape,contractVersion:e.literal(6),message:H.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(w),value:T(m)}).strict()).max(2),variants:e.array(e.discriminatedUnion(`key`,[V.options[0].omit({bodyLabel:!0}).extend({sections:I,bodyRefs:e.array(e.object({key:e.string().regex(w),label:T(48).optional()}).strict()).max(2),footer:T(500).optional()}),V.options[1].omit({bodyLabel:!0}).extend({sections:I,bodyRefs:e.array(e.object({key:e.string().regex(w),label:T(48).optional()}).strict()).max(2),footer:T(500).optional()})])).min(1).max(2).superRefine((e,t)=>z(e,t,!0))})}).strict().superRefine(W);function W(e,t){M(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`}),Ee(e.message.variants,n,r,t)}function Ee(e,t,n,r,i){for(let[a,o]of e.entries()){let e=o.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!t.includes(e)))&&r.addIssue({code:`custom`,message:`message_body_reference_invalid`,...i?{path:[...i,a,`bodyRefs`]}:{}}),JSON.stringify(o.linkLabels.map(e=>e.key))!==JSON.stringify(n)&&r.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,...i?{path:[...i,a,`linkLabels`]}:{}})}}const De=e.array(k).min(1).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`route_key_duplicate`})}),{routeKey:Oe,...ke}=U.shape,G=U.shape.message,K=e.object({...ke,contractVersion:e.literal(7),routeKeys:De,message:G}).strict().superRefine(W),q=e.object({...K.shape,contractVersion:e.literal(8),message:G.extend({channelVariants:e.partialRecord(e.enum(C),G.shape.variants).optional()})}).strict().superRefine((e,t)=>{W(e,t);let n=e.message.variants.map(e=>`${e.key}:${e.locale}`).sort(),r=e.message.bodies.map(e=>e.key),i=e.message.links.map(e=>e.key);for(let a of C){let o=e.message.channelVariants?.[a];if(!o)continue;let s=[`message`,`channelVariants`,a];JSON.stringify(o.map(e=>`${e.key}:${e.locale}`).sort())!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_channel_variant_languages_mismatch`,path:s}),Ee(o,r,i,t,s)}}),Ae=e.object({locale:T(35),contentLocale:T(35),title:T(160).refine(e=>e.trim().length>0,`browser_message_title_blank`),body:e.string().max(8192),url:A.shape.url}).strict(),je=e.object({...q.shape,contractVersion:e.literal(9),audience:e.object({topics:e.array(T(128)).min(1).max(2).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`audience_topic_duplicate`})})}).strict().optional(),browserMessages:e.array(Ae).min(1).max(5).superRefine((e,t)=>{new Set(e.map(e=>e.locale)).size!==e.length&&t.addIssue({code:`custom`,message:`browser_message_locale_duplicate`})}).optional()}).strict().superRefine((e,t)=>{let{audience:n,browserMessages:r,...i}=e,a=q.safeParse({...i,contractVersion:8});if(a.success)M(e,t,h,ae);else for(let e of a.error.issues)t.addIssue({...e});r!==void 0&&n===void 0&&t.addIssue({code:`custom`,message:`browser_message_audience_missing`,path:[`audience`]})});function Me(e){return`routeKeys`in e?[...e.routeKeys].sort():[e.routeKey]}const Ne=e.object({type:e.literal(`creator.draft.v1`),templateId:e.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),signalType:e.string().regex(/^[a-z][a-z0-9_]*$/),sourceTextZh:T(g),sourceUrl:A.shape.url.optional()}).strict(),Pe=e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:D,routeKey:k,occurredAt:E,requestedAt:E,deliverBy:E,subject:O.extend({type:e.literal(`creator-event`)}),task:Ne}).strict().superRefine((e,t)=>M(e,t,_,g)),Fe=Pe,Ie=e.union([N,F,xe,we,H,U,K,q,je]),Le=e.object({destinationKey:e.string().min(1),state:e.enum(S),attempts:e.number().int().min(0).max(4),failureCode:e.enum(ce).nullable(),lastAttemptAt:E.nullable(),nextAttemptAt:E.nullable(),leaseExpiresAt:E.nullable()}).strict(),J=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:D,routeKey:k,subject:O,state:e.enum(v),reason:e.enum(y),terminal:e.boolean(),acceptedAt:E,updatedAt:E,deliverBy:E,terminalAt:E.nullable(),destinations:e.array(Le).min(1).max(20)}).strict(),Y=e.object({name:e.string().min(1).max(100),message:e.string().max(500).optional(),code:e.union([e.string().max(100),e.number()]).optional(),status:e.union([e.string().max(100),e.number()]).optional()}).strict(),X=Y.extend({cause:Y.extend({cause:Y.extend({cause:Y.optional()}).optional()}).optional()}),Re=Le.extend({state:e.enum(se),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:X.nullable(),unconfirmedAt:E.nullable()}),Z=J.extend({contractVersion:e.literal(2),state:e.enum(b),reason:e.enum(x),revision:e.number().int().min(0),destinations:e.array(Re).min(1).max(20)}),ze=Z.omit({routeKey:!0}).extend({contractVersion:e.literal(3),routeKeys:De}),Q=e.union([J,Z,ze]),Be=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(ue)}).strict(),Ve=e.object({code:e.literal(`invalid_request`),issues:e.array(Be).max(20).optional()}).strict(),He=e.object({code:e.enum(le.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([Ve,He]),Ue=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:J}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),We=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:J}).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()]),Ge=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),Ke=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{oe as localTaskDeliveryContractVersionV1,_ as localTaskDeliveryMaximumDeadlineMillisecondsV1,g as localTaskDeliveryRequestMaximumUtf8BytesV1,Fe as localTaskDeliveryRequestSchema,Pe as localTaskDeliveryRequestV1Schema,Ae as notificationBrowserMessageSchema,t as notificationBrowserPayloadSchema,Ue as notificationDeliverResultV1Schema,Ge as notificationDeliverResultV2Schema,C as notificationDeliveryChannelKeys,n as notificationDeliveryContractVersionV1,r as notificationDeliveryContractVersionV2,i as notificationDeliveryContractVersionV3,a as notificationDeliveryContractVersionV4,o as notificationDeliveryContractVersionV5,s as notificationDeliveryContractVersionV7,ee as notificationDeliveryContractVersionV8,te as notificationDeliveryContractVersionV9,l as notificationDeliveryMaximumDeadlineMillisecondsV1,d as notificationDeliveryMaximumDeadlineMillisecondsV2,re as notificationDeliveryMaximumDeadlineMillisecondsV3,ie as notificationDeliveryMaximumDeadlineMillisecondsV4,h as notificationDeliveryMaximumDeadlineMillisecondsV5,ne as notificationDeliveryMaximumDestinationsV1,y as notificationDeliveryReasonsV1,x as notificationDeliveryReasonsV2,J as notificationDeliveryReceiptV1Schema,Z as notificationDeliveryReceiptV2Schema,ze as notificationDeliveryReceiptV3Schema,le as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,c as notificationDeliveryRequestMaximumUtf8BytesV1,u as notificationDeliveryRequestMaximumUtf8BytesV2,f as notificationDeliveryRequestMaximumUtf8BytesV3,p as notificationDeliveryRequestMaximumUtf8BytesV4,m as notificationDeliveryRequestMaximumUtf8BytesV5,ae as notificationDeliveryRequestMaximumUtf8BytesV9,Ie as notificationDeliveryRequestSchema,N as notificationDeliveryRequestV1Schema,F as notificationDeliveryRequestV2Schema,xe as notificationDeliveryRequestV3Schema,we as notificationDeliveryRequestV4Schema,H as notificationDeliveryRequestV5Schema,U as notificationDeliveryRequestV6Schema,K as notificationDeliveryRequestV7Schema,q as notificationDeliveryRequestV8Schema,je as notificationDeliveryRequestV9Schema,v as notificationDeliveryStatesV1,b as notificationDeliveryStatesV2,ce as notificationDestinationFailureCodesV1,S as notificationDestinationStatesV1,se as notificationDestinationStatesV2,We as notificationGetReceiptResultV1Schema,Ke as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,de as notificationMessageVariantKeys,Me as notificationRouteKeys,ue as notificationValidationIssueCodesV1,X as safeDeliveryCauseSchema};