@closerepo/notification-contracts 1.9.0 → 1.11.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
@@ -6,6 +6,7 @@ declare const notificationDeliveryContractVersionV3: 3;
6
6
  declare const notificationDeliveryContractVersionV4: 4;
7
7
  declare const notificationDeliveryContractVersionV5: 5;
8
8
  declare const notificationDeliveryContractVersionV7: 7;
9
+ declare const notificationDeliveryContractVersionV8: 8;
9
10
  declare const notificationDeliveryMaximumDestinationsV1 = 20;
10
11
  declare const notificationDeliveryRequestMaximumUtf8BytesV1: number;
11
12
  declare const notificationDeliveryMaximumDeadlineMillisecondsV1: number;
@@ -30,6 +31,8 @@ declare const notificationDestinationFailureCodesV1: readonly ["provider_timeout
30
31
  declare const notificationDeliveryRejectionCodesV1: readonly ["invalid_request", "request_too_large", "producer_scope_mismatch", "route_not_allowed", "event_identity_conflict", "route_not_found", "route_empty", "delivery_deadline_invalid"];
31
32
  declare const notificationValidationIssueCodesV1: readonly ["invalid_type", "invalid_value", "too_small", "too_big", "invalid_format", "unrecognized_keys", "custom"];
32
33
  declare const notificationMessageVariantKeys: readonly ["source", "zh-CN"];
34
+ declare const notificationDeliveryChannelKeys: readonly ["qq", "tg", "wechat", "lark"];
35
+ type NotificationDeliveryChannelKey = (typeof notificationDeliveryChannelKeys)[number];
33
36
  declare const notificationDeliveryRequestV1Schema: z.ZodObject<{
34
37
  message: z.ZodObject<{
35
38
  type: z.ZodLiteral<"link_summary">;
@@ -387,6 +390,10 @@ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
387
390
  key: z.ZodLiteral<"source">;
388
391
  title: z.ZodString;
389
392
  locale: z.ZodLiteral<"und">;
393
+ linkLabels: z.ZodArray<z.ZodObject<{
394
+ key: z.ZodString;
395
+ label: z.ZodString;
396
+ }, z.core.$strict>>;
390
397
  sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
391
398
  key: z.ZodString;
392
399
  type: z.ZodLiteral<"text">;
@@ -400,19 +407,19 @@ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
400
407
  value: z.ZodString;
401
408
  }, z.core.$strict>>;
402
409
  }, z.core.$strict>], "type">>;
403
- linkLabels: z.ZodArray<z.ZodObject<{
404
- key: z.ZodString;
405
- label: z.ZodString;
406
- }, z.core.$strict>>;
407
410
  bodyRefs: z.ZodArray<z.ZodObject<{
408
411
  key: z.ZodString;
409
412
  label: z.ZodString;
410
413
  }, z.core.$strict>>;
411
- footer: z.ZodString;
414
+ footer: z.ZodOptional<z.ZodString>;
412
415
  }, z.core.$strict>, z.ZodObject<{
413
416
  key: z.ZodLiteral<"zh-CN">;
414
417
  title: z.ZodString;
415
418
  locale: z.ZodLiteral<"zh-CN">;
419
+ linkLabels: z.ZodArray<z.ZodObject<{
420
+ key: z.ZodString;
421
+ label: z.ZodString;
422
+ }, z.core.$strict>>;
416
423
  sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
417
424
  key: z.ZodString;
418
425
  type: z.ZodLiteral<"text">;
@@ -426,15 +433,11 @@ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
426
433
  value: z.ZodString;
427
434
  }, z.core.$strict>>;
428
435
  }, z.core.$strict>], "type">>;
429
- linkLabels: z.ZodArray<z.ZodObject<{
430
- key: z.ZodString;
431
- label: z.ZodString;
432
- }, z.core.$strict>>;
433
436
  bodyRefs: z.ZodArray<z.ZodObject<{
434
437
  key: z.ZodString;
435
438
  label: z.ZodString;
436
439
  }, z.core.$strict>>;
437
- footer: z.ZodString;
440
+ footer: z.ZodOptional<z.ZodString>;
438
441
  }, z.core.$strict>], "key">>;
439
442
  }, z.core.$strict>;
440
443
  eventType: z.ZodLiteral<"notification.delivery.requested">;
@@ -471,6 +474,36 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
471
474
  key: z.ZodLiteral<"source">;
472
475
  title: z.ZodString;
473
476
  locale: z.ZodLiteral<"und">;
477
+ linkLabels: z.ZodArray<z.ZodObject<{
478
+ key: z.ZodString;
479
+ label: z.ZodString;
480
+ }, z.core.$strict>>;
481
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
482
+ key: z.ZodString;
483
+ type: z.ZodLiteral<"text">;
484
+ label: z.ZodOptional<z.ZodString>;
485
+ value: z.ZodString;
486
+ }, z.core.$strict>, z.ZodObject<{
487
+ key: z.ZodString;
488
+ type: z.ZodLiteral<"fields">;
489
+ items: z.ZodArray<z.ZodObject<{
490
+ label: z.ZodString;
491
+ value: z.ZodString;
492
+ }, z.core.$strict>>;
493
+ }, z.core.$strict>], "type">>;
494
+ bodyRefs: z.ZodArray<z.ZodObject<{
495
+ key: z.ZodString;
496
+ label: z.ZodString;
497
+ }, z.core.$strict>>;
498
+ footer: z.ZodOptional<z.ZodString>;
499
+ }, z.core.$strict>, z.ZodObject<{
500
+ key: z.ZodLiteral<"zh-CN">;
501
+ title: z.ZodString;
502
+ locale: z.ZodLiteral<"zh-CN">;
503
+ linkLabels: z.ZodArray<z.ZodObject<{
504
+ key: z.ZodString;
505
+ label: z.ZodString;
506
+ }, z.core.$strict>>;
474
507
  sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
475
508
  key: z.ZodString;
476
509
  type: z.ZodLiteral<"text">;
@@ -484,10 +517,63 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
484
517
  value: z.ZodString;
485
518
  }, z.core.$strict>>;
486
519
  }, z.core.$strict>], "type">>;
520
+ bodyRefs: z.ZodArray<z.ZodObject<{
521
+ key: z.ZodString;
522
+ label: z.ZodString;
523
+ }, z.core.$strict>>;
524
+ footer: z.ZodOptional<z.ZodString>;
525
+ }, z.core.$strict>], "key">>;
526
+ }, z.core.$strict>;
527
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
528
+ eventId: z.ZodString;
529
+ producer: z.ZodObject<{
530
+ key: z.ZodString;
531
+ environment: z.ZodString;
532
+ }, z.core.$strict>;
533
+ occurredAt: z.ZodString;
534
+ requestedAt: z.ZodString;
535
+ deliverBy: z.ZodString;
536
+ subject: z.ZodObject<{
537
+ type: z.ZodString;
538
+ id: z.ZodString;
539
+ revision: z.ZodNumber;
540
+ }, z.core.$strict>;
541
+ }, z.core.$strict>;
542
+ type NotificationDeliveryRequestV7 = z.infer<typeof notificationDeliveryRequestV7Schema>;
543
+ /** Frozen channel copy shares message bodies and links; omitted channels use default variants. */
544
+ declare const notificationDeliveryRequestV8Schema: z.ZodObject<{
545
+ contractVersion: z.ZodLiteral<8>;
546
+ message: z.ZodObject<{
547
+ type: z.ZodLiteral<"structured_notification">;
548
+ links: z.ZodArray<z.ZodObject<{
549
+ key: z.ZodString;
550
+ url: z.ZodString;
551
+ }, z.core.$strict>>;
552
+ bodies: z.ZodArray<z.ZodObject<{
553
+ key: z.ZodString;
554
+ value: z.ZodString;
555
+ }, z.core.$strict>>;
556
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
557
+ key: z.ZodLiteral<"source">;
558
+ title: z.ZodString;
559
+ locale: z.ZodLiteral<"und">;
487
560
  linkLabels: z.ZodArray<z.ZodObject<{
488
561
  key: z.ZodString;
489
562
  label: z.ZodString;
490
563
  }, z.core.$strict>>;
564
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
565
+ key: z.ZodString;
566
+ type: z.ZodLiteral<"text">;
567
+ label: z.ZodOptional<z.ZodString>;
568
+ value: z.ZodString;
569
+ }, z.core.$strict>, z.ZodObject<{
570
+ key: z.ZodString;
571
+ type: z.ZodLiteral<"fields">;
572
+ items: z.ZodArray<z.ZodObject<{
573
+ label: z.ZodString;
574
+ value: z.ZodString;
575
+ }, z.core.$strict>>;
576
+ }, z.core.$strict>], "type">>;
491
577
  bodyRefs: z.ZodArray<z.ZodObject<{
492
578
  key: z.ZodString;
493
579
  label: z.ZodString;
@@ -497,6 +583,42 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
497
583
  key: z.ZodLiteral<"zh-CN">;
498
584
  title: z.ZodString;
499
585
  locale: z.ZodLiteral<"zh-CN">;
586
+ linkLabels: z.ZodArray<z.ZodObject<{
587
+ key: z.ZodString;
588
+ label: z.ZodString;
589
+ }, z.core.$strict>>;
590
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
591
+ key: z.ZodString;
592
+ type: z.ZodLiteral<"text">;
593
+ label: z.ZodOptional<z.ZodString>;
594
+ value: z.ZodString;
595
+ }, z.core.$strict>, z.ZodObject<{
596
+ key: z.ZodString;
597
+ type: z.ZodLiteral<"fields">;
598
+ items: z.ZodArray<z.ZodObject<{
599
+ label: z.ZodString;
600
+ value: z.ZodString;
601
+ }, z.core.$strict>>;
602
+ }, z.core.$strict>], "type">>;
603
+ bodyRefs: z.ZodArray<z.ZodObject<{
604
+ key: z.ZodString;
605
+ label: z.ZodString;
606
+ }, z.core.$strict>>;
607
+ footer: z.ZodOptional<z.ZodString>;
608
+ }, z.core.$strict>], "key">>;
609
+ channelVariants: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
610
+ qq: "qq";
611
+ tg: "tg";
612
+ wechat: "wechat";
613
+ lark: "lark";
614
+ }> & z.core.$partial, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
615
+ key: z.ZodLiteral<"source">;
616
+ title: z.ZodString;
617
+ locale: z.ZodLiteral<"und">;
618
+ linkLabels: z.ZodArray<z.ZodObject<{
619
+ key: z.ZodString;
620
+ label: z.ZodString;
621
+ }, z.core.$strict>>;
500
622
  sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
501
623
  key: z.ZodString;
502
624
  type: z.ZodLiteral<"text">;
@@ -510,17 +632,40 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
510
632
  value: z.ZodString;
511
633
  }, z.core.$strict>>;
512
634
  }, z.core.$strict>], "type">>;
635
+ bodyRefs: z.ZodArray<z.ZodObject<{
636
+ key: z.ZodString;
637
+ label: z.ZodString;
638
+ }, z.core.$strict>>;
639
+ footer: z.ZodOptional<z.ZodString>;
640
+ }, z.core.$strict>, z.ZodObject<{
641
+ key: z.ZodLiteral<"zh-CN">;
642
+ title: z.ZodString;
643
+ locale: z.ZodLiteral<"zh-CN">;
513
644
  linkLabels: z.ZodArray<z.ZodObject<{
514
645
  key: z.ZodString;
515
646
  label: z.ZodString;
516
647
  }, z.core.$strict>>;
648
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
649
+ key: z.ZodString;
650
+ type: z.ZodLiteral<"text">;
651
+ label: z.ZodOptional<z.ZodString>;
652
+ value: z.ZodString;
653
+ }, z.core.$strict>, z.ZodObject<{
654
+ key: z.ZodString;
655
+ type: z.ZodLiteral<"fields">;
656
+ items: z.ZodArray<z.ZodObject<{
657
+ label: z.ZodString;
658
+ value: z.ZodString;
659
+ }, z.core.$strict>>;
660
+ }, z.core.$strict>], "type">>;
517
661
  bodyRefs: z.ZodArray<z.ZodObject<{
518
662
  key: z.ZodString;
519
663
  label: z.ZodString;
520
664
  }, z.core.$strict>>;
521
665
  footer: z.ZodOptional<z.ZodString>;
522
- }, z.core.$strict>], "key">>;
666
+ }, z.core.$strict>], "key">>>>;
523
667
  }, z.core.$strict>;
668
+ routeKeys: z.ZodArray<z.ZodString>;
524
669
  eventType: z.ZodLiteral<"notification.delivery.requested">;
525
670
  eventId: z.ZodString;
526
671
  producer: z.ZodObject<{
@@ -536,7 +681,8 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
536
681
  revision: z.ZodNumber;
537
682
  }, z.core.$strict>;
538
683
  }, z.core.$strict>;
539
- type NotificationDeliveryRequestV7 = z.infer<typeof notificationDeliveryRequestV7Schema>;
684
+ type NotificationDeliveryRequestV8 = z.infer<typeof notificationDeliveryRequestV8Schema>;
685
+ type NotificationMessageVariantsV6 = NotificationDeliveryRequestV6['message']['variants'];
540
686
  /** Reads routing facts from current envelopes and historical single-route records. */
541
687
  declare function notificationRouteKeys(value: {
542
688
  routeKey: string;
@@ -898,6 +1044,10 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
898
1044
  key: z.ZodLiteral<"source">;
899
1045
  title: z.ZodString;
900
1046
  locale: z.ZodLiteral<"und">;
1047
+ linkLabels: z.ZodArray<z.ZodObject<{
1048
+ key: z.ZodString;
1049
+ label: z.ZodString;
1050
+ }, z.core.$strict>>;
901
1051
  sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
902
1052
  key: z.ZodString;
903
1053
  type: z.ZodLiteral<"text">;
@@ -911,19 +1061,19 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
911
1061
  value: z.ZodString;
912
1062
  }, z.core.$strict>>;
913
1063
  }, z.core.$strict>], "type">>;
914
- linkLabels: z.ZodArray<z.ZodObject<{
915
- key: z.ZodString;
916
- label: z.ZodString;
917
- }, z.core.$strict>>;
918
1064
  bodyRefs: z.ZodArray<z.ZodObject<{
919
1065
  key: z.ZodString;
920
1066
  label: z.ZodString;
921
1067
  }, z.core.$strict>>;
922
- footer: z.ZodString;
1068
+ footer: z.ZodOptional<z.ZodString>;
923
1069
  }, z.core.$strict>, z.ZodObject<{
924
1070
  key: z.ZodLiteral<"zh-CN">;
925
1071
  title: z.ZodString;
926
1072
  locale: z.ZodLiteral<"zh-CN">;
1073
+ linkLabels: z.ZodArray<z.ZodObject<{
1074
+ key: z.ZodString;
1075
+ label: z.ZodString;
1076
+ }, z.core.$strict>>;
927
1077
  sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
928
1078
  key: z.ZodString;
929
1079
  type: z.ZodLiteral<"text">;
@@ -937,15 +1087,11 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
937
1087
  value: z.ZodString;
938
1088
  }, z.core.$strict>>;
939
1089
  }, z.core.$strict>], "type">>;
940
- linkLabels: z.ZodArray<z.ZodObject<{
941
- key: z.ZodString;
942
- label: z.ZodString;
943
- }, z.core.$strict>>;
944
1090
  bodyRefs: z.ZodArray<z.ZodObject<{
945
1091
  key: z.ZodString;
946
1092
  label: z.ZodString;
947
1093
  }, z.core.$strict>>;
948
- footer: z.ZodString;
1094
+ footer: z.ZodOptional<z.ZodString>;
949
1095
  }, z.core.$strict>], "key">>;
950
1096
  }, z.core.$strict>;
951
1097
  eventType: z.ZodLiteral<"notification.delivery.requested">;
@@ -980,6 +1126,36 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
980
1126
  key: z.ZodLiteral<"source">;
981
1127
  title: z.ZodString;
982
1128
  locale: z.ZodLiteral<"und">;
1129
+ linkLabels: z.ZodArray<z.ZodObject<{
1130
+ key: z.ZodString;
1131
+ label: z.ZodString;
1132
+ }, z.core.$strict>>;
1133
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1134
+ key: z.ZodString;
1135
+ type: z.ZodLiteral<"text">;
1136
+ label: z.ZodOptional<z.ZodString>;
1137
+ value: z.ZodString;
1138
+ }, z.core.$strict>, z.ZodObject<{
1139
+ key: z.ZodString;
1140
+ type: z.ZodLiteral<"fields">;
1141
+ items: z.ZodArray<z.ZodObject<{
1142
+ label: z.ZodString;
1143
+ value: z.ZodString;
1144
+ }, z.core.$strict>>;
1145
+ }, z.core.$strict>], "type">>;
1146
+ bodyRefs: z.ZodArray<z.ZodObject<{
1147
+ key: z.ZodString;
1148
+ label: z.ZodString;
1149
+ }, z.core.$strict>>;
1150
+ footer: z.ZodOptional<z.ZodString>;
1151
+ }, z.core.$strict>, z.ZodObject<{
1152
+ key: z.ZodLiteral<"zh-CN">;
1153
+ title: z.ZodString;
1154
+ locale: z.ZodLiteral<"zh-CN">;
1155
+ linkLabels: z.ZodArray<z.ZodObject<{
1156
+ key: z.ZodString;
1157
+ label: z.ZodString;
1158
+ }, z.core.$strict>>;
983
1159
  sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
984
1160
  key: z.ZodString;
985
1161
  type: z.ZodLiteral<"text">;
@@ -993,10 +1169,60 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
993
1169
  value: z.ZodString;
994
1170
  }, z.core.$strict>>;
995
1171
  }, z.core.$strict>], "type">>;
1172
+ bodyRefs: z.ZodArray<z.ZodObject<{
1173
+ key: z.ZodString;
1174
+ label: z.ZodString;
1175
+ }, z.core.$strict>>;
1176
+ footer: z.ZodOptional<z.ZodString>;
1177
+ }, z.core.$strict>], "key">>;
1178
+ }, z.core.$strict>;
1179
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
1180
+ eventId: z.ZodString;
1181
+ producer: z.ZodObject<{
1182
+ key: z.ZodString;
1183
+ environment: z.ZodString;
1184
+ }, z.core.$strict>;
1185
+ occurredAt: z.ZodString;
1186
+ requestedAt: z.ZodString;
1187
+ deliverBy: z.ZodString;
1188
+ subject: z.ZodObject<{
1189
+ type: z.ZodString;
1190
+ id: z.ZodString;
1191
+ revision: z.ZodNumber;
1192
+ }, z.core.$strict>;
1193
+ }, z.core.$strict>, z.ZodObject<{
1194
+ contractVersion: z.ZodLiteral<8>;
1195
+ message: z.ZodObject<{
1196
+ type: z.ZodLiteral<"structured_notification">;
1197
+ links: z.ZodArray<z.ZodObject<{
1198
+ key: z.ZodString;
1199
+ url: z.ZodString;
1200
+ }, z.core.$strict>>;
1201
+ bodies: z.ZodArray<z.ZodObject<{
1202
+ key: z.ZodString;
1203
+ value: z.ZodString;
1204
+ }, z.core.$strict>>;
1205
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1206
+ key: z.ZodLiteral<"source">;
1207
+ title: z.ZodString;
1208
+ locale: z.ZodLiteral<"und">;
996
1209
  linkLabels: z.ZodArray<z.ZodObject<{
997
1210
  key: z.ZodString;
998
1211
  label: z.ZodString;
999
1212
  }, z.core.$strict>>;
1213
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1214
+ key: z.ZodString;
1215
+ type: z.ZodLiteral<"text">;
1216
+ label: z.ZodOptional<z.ZodString>;
1217
+ value: z.ZodString;
1218
+ }, z.core.$strict>, z.ZodObject<{
1219
+ key: z.ZodString;
1220
+ type: z.ZodLiteral<"fields">;
1221
+ items: z.ZodArray<z.ZodObject<{
1222
+ label: z.ZodString;
1223
+ value: z.ZodString;
1224
+ }, z.core.$strict>>;
1225
+ }, z.core.$strict>], "type">>;
1000
1226
  bodyRefs: z.ZodArray<z.ZodObject<{
1001
1227
  key: z.ZodString;
1002
1228
  label: z.ZodString;
@@ -1006,6 +1232,42 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1006
1232
  key: z.ZodLiteral<"zh-CN">;
1007
1233
  title: z.ZodString;
1008
1234
  locale: z.ZodLiteral<"zh-CN">;
1235
+ linkLabels: z.ZodArray<z.ZodObject<{
1236
+ key: z.ZodString;
1237
+ label: z.ZodString;
1238
+ }, z.core.$strict>>;
1239
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1240
+ key: z.ZodString;
1241
+ type: z.ZodLiteral<"text">;
1242
+ label: z.ZodOptional<z.ZodString>;
1243
+ value: z.ZodString;
1244
+ }, z.core.$strict>, z.ZodObject<{
1245
+ key: z.ZodString;
1246
+ type: z.ZodLiteral<"fields">;
1247
+ items: z.ZodArray<z.ZodObject<{
1248
+ label: z.ZodString;
1249
+ value: z.ZodString;
1250
+ }, z.core.$strict>>;
1251
+ }, z.core.$strict>], "type">>;
1252
+ bodyRefs: z.ZodArray<z.ZodObject<{
1253
+ key: z.ZodString;
1254
+ label: z.ZodString;
1255
+ }, z.core.$strict>>;
1256
+ footer: z.ZodOptional<z.ZodString>;
1257
+ }, z.core.$strict>], "key">>;
1258
+ channelVariants: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
1259
+ qq: "qq";
1260
+ tg: "tg";
1261
+ wechat: "wechat";
1262
+ lark: "lark";
1263
+ }> & z.core.$partial, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1264
+ key: z.ZodLiteral<"source">;
1265
+ title: z.ZodString;
1266
+ locale: z.ZodLiteral<"und">;
1267
+ linkLabels: z.ZodArray<z.ZodObject<{
1268
+ key: z.ZodString;
1269
+ label: z.ZodString;
1270
+ }, z.core.$strict>>;
1009
1271
  sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1010
1272
  key: z.ZodString;
1011
1273
  type: z.ZodLiteral<"text">;
@@ -1019,17 +1281,40 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1019
1281
  value: z.ZodString;
1020
1282
  }, z.core.$strict>>;
1021
1283
  }, z.core.$strict>], "type">>;
1284
+ bodyRefs: z.ZodArray<z.ZodObject<{
1285
+ key: z.ZodString;
1286
+ label: z.ZodString;
1287
+ }, z.core.$strict>>;
1288
+ footer: z.ZodOptional<z.ZodString>;
1289
+ }, z.core.$strict>, z.ZodObject<{
1290
+ key: z.ZodLiteral<"zh-CN">;
1291
+ title: z.ZodString;
1292
+ locale: z.ZodLiteral<"zh-CN">;
1022
1293
  linkLabels: z.ZodArray<z.ZodObject<{
1023
1294
  key: z.ZodString;
1024
1295
  label: z.ZodString;
1025
1296
  }, z.core.$strict>>;
1297
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1298
+ key: z.ZodString;
1299
+ type: z.ZodLiteral<"text">;
1300
+ label: z.ZodOptional<z.ZodString>;
1301
+ value: z.ZodString;
1302
+ }, z.core.$strict>, z.ZodObject<{
1303
+ key: z.ZodString;
1304
+ type: z.ZodLiteral<"fields">;
1305
+ items: z.ZodArray<z.ZodObject<{
1306
+ label: z.ZodString;
1307
+ value: z.ZodString;
1308
+ }, z.core.$strict>>;
1309
+ }, z.core.$strict>], "type">>;
1026
1310
  bodyRefs: z.ZodArray<z.ZodObject<{
1027
1311
  key: z.ZodString;
1028
1312
  label: z.ZodString;
1029
1313
  }, z.core.$strict>>;
1030
1314
  footer: z.ZodOptional<z.ZodString>;
1031
- }, z.core.$strict>], "key">>;
1315
+ }, z.core.$strict>], "key">>>>;
1032
1316
  }, z.core.$strict>;
1317
+ routeKeys: z.ZodArray<z.ZodString>;
1033
1318
  eventType: z.ZodLiteral<"notification.delivery.requested">;
1034
1319
  eventId: z.ZodString;
1035
1320
  producer: z.ZodObject<{
@@ -2303,4 +2588,4 @@ interface NotificationMessageDeliveryServiceV4 {
2303
2588
  /** Multi-route message delivery; historical requests and receipts remain supported. */
2304
2589
  interface NotificationMessageDeliveryServiceV5 extends NotificationMessageDeliveryServiceV4 {}
2305
2590
  //#endregion
2306
- export { CreatorDraftTaskV1, LocalTaskDeliverResultV1, LocalTaskDeliveryReceiptV1, LocalTaskDeliveryRequest, LocalTaskDeliveryRequestV1, LocalTaskDeliveryServiceV1, LocalTaskGetReceiptResultV1, NotificationDeliverResultV1, NotificationDeliverResultV2, NotificationDeliveryReceiptV1, NotificationDeliveryReceiptV2, NotificationDeliveryReceiptV3, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryRequestV6, NotificationDeliveryRequestV7, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationDeliveryServiceV3, NotificationGetReceiptResultV1, NotificationGetReceiptResultV2, NotificationMessageBody, NotificationMessageDeliveryServiceV4, NotificationMessageDeliveryServiceV5, NotificationMessageReceipt, NotificationMessageVariantKey, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, localTaskDeliveryContractVersionV1, localTaskDeliveryMaximumDeadlineMillisecondsV1, localTaskDeliveryRequestMaximumUtf8BytesV1, localTaskDeliveryRequestSchema, localTaskDeliveryRequestV1Schema, notificationDeliverResultV1Schema, notificationDeliverResultV2Schema, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryContractVersionV5, notificationDeliveryContractVersionV7, 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, notificationDeliveryStatesV1, notificationDeliveryStatesV2, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationDestinationStatesV2, notificationGetReceiptResultV1Schema, notificationGetReceiptResultV2Schema, notificationMessageReceiptSchema, notificationMessageVariantKeys, notificationRouteKeys, notificationValidationIssueCodesV1, safeDeliveryCauseSchema };
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 };
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,ee=20,s=32*1024,c=1380*60*1e3,te=s,ne=c,l=s,u=c,d=s,re=c,f=s,p=c,ie=1,m=32*1024,h=10080*60*1e3,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=[...g,`unconfirmed`],y=[..._,`delivery_unconfirmed`],b=[`pending`,`delivering`,`delivered`,`failed`,`expired`],x=[...b,`unconfirmed`],S=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],ae=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],oe=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],se=[`source`,`zh-CN`],ce=new TextEncoder,C=/^[a-z][a-z0-9-]{0,62}$/,le=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,ue=/^[A-Z0-9][\w.:-]{0,127}$/i;function de(e){return[...e].length}function w(t){return e.string().refine(e=>de(e)>0,{message:`too_small`}).refine(e=>de(e)<=t,{message:`too_big`})}const T=e.string().datetime({offset:!0}),E=e.object({key:e.string().regex(C),environment:e.string().regex(C)}).strict(),D=e.object({type:e.string().regex(C),id:e.string().regex(ue),revision:e.number().int().positive()}).strict(),O=e.string().min(1).max(127).regex(le),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},fe=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 j(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`]}),ce.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const M=fe.superRefine((e,t)=>j(e,t,c,s)),N={title:w(160),summary:w(1200),facts:e.array(e.object({label:w(48),value:w(500)}).strict()).max(10)},pe=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...N}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...N}).strict()]),me=e.array(pe).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`})}),P=e.object({contractVersion:e.literal(2),...A,message:e.object({type:e.literal(`localized_link_summary`),variants:me,primaryLink:k,sourceLink:k.optional()}).strict()}).strict().superRefine((e,t)=>j(e,t,ne,te)),he=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(C),type:e.literal(`text`),label:w(48).optional(),value:w(4e3)}).strict(),e.object({key:e.string().regex(C),type:e.literal(`fields`),items:e.array(e.object({label:w(48),value:w(1200)}).strict()).min(1).max(20)}).strict()]),F=e.array(he).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`})}),I=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:w(160),sections:F}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:w(160),sections:F}).strict()]),L=(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)),ee=r.sections.filter(e=>!n||e.type!==`text`||o.has(e.key)).map(e=>`${e.key}:${e.type}`),s=i.sections.filter(e=>!n||e.type!==`text`||a.has(e.key)).map(e=>`${e.key}:${e.type}`);JSON.stringify(ee)!==JSON.stringify(s)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(i),`sections`]})}},ge=e.array(I).min(1).max(2).superRefine(L),R=e.object({contractVersion:e.literal(3),...A,message:e.object({type:e.literal(`structured_notification`),variants:ge,links:e.array(e.object({key:e.string().regex(C),...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(),z=R.superRefine((e,t)=>j(e,t,u,l)),B=e.object({label:w(48).optional(),value:w(d)}).strict(),_e=e.discriminatedUnion(`key`,[I.options[0].extend({body:B}),I.options[1].extend({body:B})]),V=R.extend({contractVersion:e.literal(4),message:R.shape.message.extend({variants:e.array(_e).min(1).max(2).superRefine(L)})}).superRefine((e,t)=>j(e,t,re,d)),H=e.discriminatedUnion(`key`,[I.options[0].extend({bodyLabel:w(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(C),label:w(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`})})}),I.options[1].extend({bodyLabel:w(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(C),label:w(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`})})})]),ve=e.object({value:w(f)}).strict(),U=e.object({contractVersion:e.literal(5),...A,message:e.object({type:e.literal(`structured_notification`),variants:e.array(H).min(1).max(2).superRefine(L),links:e.array(e.object({key:e.string().regex(C),url:k.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:ve}).strict()}).strict().superRefine((e,t)=>{j(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`]})}}),W=e.object({...U.shape,contractVersion:e.literal(6),message:U.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(C),value:w(f)}).strict()).min(1).max(2),variants:e.array(e.discriminatedUnion(`key`,[H.options[0].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(C),label:w(48)}).strict()).min(1).max(2),footer:w(500)}),H.options[1].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(C),label:w(48)}).strict()).min(1).max(2),footer:w(500)})])).min(1).max(2).superRefine((e,t)=>L(e,t,!0))})}).strict().superRefine(ye);function ye(e,t){j(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`});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`})}}const be=e.array(O).min(1).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`route_key_duplicate`})}),{routeKey:xe,...Se}=W.shape,G=W.shape.message,[K,q]=G.shape.variants.element.options,Ce=e.discriminatedUnion(`key`,[K.extend({bodyRefs:e.array(K.shape.bodyRefs.element).max(2),footer:K.shape.footer.optional()}),q.extend({bodyRefs:e.array(q.shape.bodyRefs.element).max(2),footer:q.shape.footer.optional()})]),we=e.object({...Se,contractVersion:e.literal(7),routeKeys:be,message:G.extend({bodies:e.array(G.shape.bodies.element).max(2),variants:e.array(Ce).min(1).max(2).superRefine((e,t)=>L(e,t,!0))})}).strict().superRefine(ye);function Te(e){return`routeKeys`in e?[...e.routeKeys].sort():[e.routeKey]}const Ee=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:w(m),sourceUrl:k.shape.url.optional()}).strict(),De=e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:E,routeKey:O,occurredAt:T,requestedAt:T,deliverBy:T,subject:D.extend({type:e.literal(`creator-event`)}),task:Ee}).strict().superRefine((e,t)=>j(e,t,h,m)),Oe=De,ke=e.union([M,P,z,V,U,W,we]),Ae=e.object({destinationKey:e.string().min(1),state:e.enum(b),attempts:e.number().int().min(0).max(4),failureCode:e.enum(S).nullable(),lastAttemptAt:T.nullable(),nextAttemptAt:T.nullable(),leaseExpiresAt:T.nullable()}).strict(),J=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:E,routeKey:O,subject:D,state:e.enum(g),reason:e.enum(_),terminal:e.boolean(),acceptedAt:T,updatedAt:T,deliverBy:T,terminalAt:T.nullable(),destinations:e.array(Ae).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()}),je=Ae.extend({state:e.enum(x),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:X.nullable(),unconfirmedAt:T.nullable()}),Z=J.extend({contractVersion:e.literal(2),state:e.enum(v),reason:e.enum(y),revision:e.number().int().min(0),destinations:e.array(je).min(1).max(20)}),Me=Z.omit({routeKey:!0}).extend({contractVersion:e.literal(3),routeKeys:be}),Q=e.union([J,Z,Me]),Ne=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(oe)}).strict(),Pe=e.object({code:e.literal(`invalid_request`),issues:e.array(Ne).max(20).optional()}).strict(),Fe=e.object({code:e.enum(ae.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([Pe,Fe]),Ie=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:J}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),Le=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()]),Re=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),ze=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{ie as localTaskDeliveryContractVersionV1,h as localTaskDeliveryMaximumDeadlineMillisecondsV1,m as localTaskDeliveryRequestMaximumUtf8BytesV1,Oe as localTaskDeliveryRequestSchema,De as localTaskDeliveryRequestV1Schema,Ie as notificationDeliverResultV1Schema,Re as notificationDeliverResultV2Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,i as notificationDeliveryContractVersionV4,a as notificationDeliveryContractVersionV5,o as notificationDeliveryContractVersionV7,c as notificationDeliveryMaximumDeadlineMillisecondsV1,ne as notificationDeliveryMaximumDeadlineMillisecondsV2,u as notificationDeliveryMaximumDeadlineMillisecondsV3,re as notificationDeliveryMaximumDeadlineMillisecondsV4,p as notificationDeliveryMaximumDeadlineMillisecondsV5,ee as notificationDeliveryMaximumDestinationsV1,_ as notificationDeliveryReasonsV1,y as notificationDeliveryReasonsV2,J as notificationDeliveryReceiptV1Schema,Z as notificationDeliveryReceiptV2Schema,Me as notificationDeliveryReceiptV3Schema,ae as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,s as notificationDeliveryRequestMaximumUtf8BytesV1,te as notificationDeliveryRequestMaximumUtf8BytesV2,l as notificationDeliveryRequestMaximumUtf8BytesV3,d as notificationDeliveryRequestMaximumUtf8BytesV4,f as notificationDeliveryRequestMaximumUtf8BytesV5,ke as notificationDeliveryRequestSchema,M as notificationDeliveryRequestV1Schema,P as notificationDeliveryRequestV2Schema,z as notificationDeliveryRequestV3Schema,V as notificationDeliveryRequestV4Schema,U as notificationDeliveryRequestV5Schema,W as notificationDeliveryRequestV6Schema,we as notificationDeliveryRequestV7Schema,g as notificationDeliveryStatesV1,v as notificationDeliveryStatesV2,S as notificationDestinationFailureCodesV1,b as notificationDestinationStatesV1,x as notificationDestinationStatesV2,Le as notificationGetReceiptResultV1Schema,ze as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,se as notificationMessageVariantKeys,Te as notificationRouteKeys,oe as notificationValidationIssueCodesV1,X as safeDeliveryCauseSchema};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@closerepo/notification-contracts",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {