@closerepo/notification-contracts 1.6.0 → 1.7.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
@@ -20,7 +20,10 @@ declare const localTaskDeliveryRequestMaximumUtf8BytesV1: number;
20
20
  declare const localTaskDeliveryMaximumDeadlineMillisecondsV1: number;
21
21
  declare const notificationDeliveryStatesV1: readonly ["pending", "delivering", "partial", "delivered", "failed", "expired"];
22
22
  declare const notificationDeliveryReasonsV1: readonly ["accepted", "enqueue_retry_wait", "in_progress", "partial_delivery", "complete", "retry_exhausted", "delivery_deadline_exceeded", "destination_configuration_unavailable"];
23
+ declare const notificationDeliveryStatesV2: readonly ["pending", "delivering", "partial", "delivered", "failed", "expired", "unconfirmed"];
24
+ declare const notificationDeliveryReasonsV2: readonly ["accepted", "enqueue_retry_wait", "in_progress", "partial_delivery", "complete", "retry_exhausted", "delivery_deadline_exceeded", "destination_configuration_unavailable", "delivery_unconfirmed"];
23
25
  declare const notificationDestinationStatesV1: readonly ["pending", "delivering", "delivered", "failed", "expired"];
26
+ declare const notificationDestinationStatesV2: readonly ["pending", "delivering", "delivered", "failed", "expired", "unconfirmed"];
24
27
  declare const notificationDestinationFailureCodesV1: readonly ["provider_timeout", "provider_rate_limited", "provider_unavailable", "provider_rejected", "destination_configuration_unavailable", "delivery_interrupted", "retry_exhausted"];
25
28
  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"];
26
29
  declare const notificationValidationIssueCodesV1: readonly ["invalid_type", "invalid_value", "too_small", "too_big", "invalid_format", "unrecognized_keys", "custom"];
@@ -929,6 +932,270 @@ declare const notificationDeliveryReceiptV1Schema: z.ZodObject<{
929
932
  leaseExpiresAt: z.ZodNullable<z.ZodString>;
930
933
  }, z.core.$strict>>;
931
934
  }, z.core.$strict>;
935
+ declare const safeDeliveryCauseSchema: z.ZodObject<{
936
+ name: z.ZodString;
937
+ message: z.ZodOptional<z.ZodString>;
938
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
939
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
940
+ cause: z.ZodOptional<z.ZodObject<{
941
+ name: z.ZodString;
942
+ message: z.ZodOptional<z.ZodString>;
943
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
944
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
945
+ cause: z.ZodOptional<z.ZodObject<{
946
+ name: z.ZodString;
947
+ message: z.ZodOptional<z.ZodString>;
948
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
949
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
950
+ cause: z.ZodOptional<z.ZodObject<{
951
+ name: z.ZodString;
952
+ message: z.ZodOptional<z.ZodString>;
953
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
954
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
955
+ }, z.core.$strict>>;
956
+ }, z.core.$strict>>;
957
+ }, z.core.$strict>>;
958
+ }, z.core.$strict>;
959
+ /** Message receipt V2 is additive; V1 remains the local-task and in-flight format. */
960
+ declare const notificationDeliveryReceiptV2Schema: z.ZodObject<{
961
+ eventId: z.ZodString;
962
+ producer: z.ZodObject<{
963
+ key: z.ZodString;
964
+ environment: z.ZodString;
965
+ }, z.core.$strict>;
966
+ routeKey: z.ZodString;
967
+ subject: z.ZodObject<{
968
+ type: z.ZodString;
969
+ id: z.ZodString;
970
+ revision: z.ZodNumber;
971
+ }, z.core.$strict>;
972
+ terminal: z.ZodBoolean;
973
+ acceptedAt: z.ZodString;
974
+ updatedAt: z.ZodString;
975
+ deliverBy: z.ZodString;
976
+ terminalAt: z.ZodNullable<z.ZodString>;
977
+ contractVersion: z.ZodLiteral<2>;
978
+ state: z.ZodEnum<{
979
+ pending: "pending";
980
+ delivering: "delivering";
981
+ partial: "partial";
982
+ delivered: "delivered";
983
+ failed: "failed";
984
+ expired: "expired";
985
+ unconfirmed: "unconfirmed";
986
+ }>;
987
+ reason: z.ZodEnum<{
988
+ accepted: "accepted";
989
+ enqueue_retry_wait: "enqueue_retry_wait";
990
+ in_progress: "in_progress";
991
+ partial_delivery: "partial_delivery";
992
+ complete: "complete";
993
+ retry_exhausted: "retry_exhausted";
994
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
995
+ destination_configuration_unavailable: "destination_configuration_unavailable";
996
+ delivery_unconfirmed: "delivery_unconfirmed";
997
+ }>;
998
+ revision: z.ZodNumber;
999
+ destinations: z.ZodArray<z.ZodObject<{
1000
+ destinationKey: z.ZodString;
1001
+ failureCode: z.ZodNullable<z.ZodEnum<{
1002
+ retry_exhausted: "retry_exhausted";
1003
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1004
+ provider_timeout: "provider_timeout";
1005
+ provider_rate_limited: "provider_rate_limited";
1006
+ provider_unavailable: "provider_unavailable";
1007
+ provider_rejected: "provider_rejected";
1008
+ delivery_interrupted: "delivery_interrupted";
1009
+ }>>;
1010
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
1011
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
1012
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
1013
+ state: z.ZodEnum<{
1014
+ pending: "pending";
1015
+ delivering: "delivering";
1016
+ delivered: "delivered";
1017
+ failed: "failed";
1018
+ expired: "expired";
1019
+ unconfirmed: "unconfirmed";
1020
+ }>;
1021
+ attempts: z.ZodNumber;
1022
+ revision: z.ZodNumber;
1023
+ cause: z.ZodNullable<z.ZodObject<{
1024
+ name: z.ZodString;
1025
+ message: z.ZodOptional<z.ZodString>;
1026
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1027
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1028
+ cause: z.ZodOptional<z.ZodObject<{
1029
+ name: z.ZodString;
1030
+ message: z.ZodOptional<z.ZodString>;
1031
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1032
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1033
+ cause: z.ZodOptional<z.ZodObject<{
1034
+ name: z.ZodString;
1035
+ message: z.ZodOptional<z.ZodString>;
1036
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1037
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1038
+ cause: z.ZodOptional<z.ZodObject<{
1039
+ name: z.ZodString;
1040
+ message: z.ZodOptional<z.ZodString>;
1041
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1042
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1043
+ }, z.core.$strict>>;
1044
+ }, z.core.$strict>>;
1045
+ }, z.core.$strict>>;
1046
+ }, z.core.$strict>>;
1047
+ unconfirmedAt: z.ZodNullable<z.ZodString>;
1048
+ }, z.core.$strict>>;
1049
+ }, z.core.$strict>;
1050
+ declare const notificationMessageReceiptSchema: z.ZodUnion<readonly [z.ZodObject<{
1051
+ contractVersion: z.ZodLiteral<1>;
1052
+ eventId: z.ZodString;
1053
+ producer: z.ZodObject<{
1054
+ key: z.ZodString;
1055
+ environment: z.ZodString;
1056
+ }, z.core.$strict>;
1057
+ routeKey: z.ZodString;
1058
+ subject: z.ZodObject<{
1059
+ type: z.ZodString;
1060
+ id: z.ZodString;
1061
+ revision: z.ZodNumber;
1062
+ }, z.core.$strict>;
1063
+ state: z.ZodEnum<{
1064
+ pending: "pending";
1065
+ delivering: "delivering";
1066
+ partial: "partial";
1067
+ delivered: "delivered";
1068
+ failed: "failed";
1069
+ expired: "expired";
1070
+ }>;
1071
+ reason: z.ZodEnum<{
1072
+ accepted: "accepted";
1073
+ enqueue_retry_wait: "enqueue_retry_wait";
1074
+ in_progress: "in_progress";
1075
+ partial_delivery: "partial_delivery";
1076
+ complete: "complete";
1077
+ retry_exhausted: "retry_exhausted";
1078
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
1079
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1080
+ }>;
1081
+ terminal: z.ZodBoolean;
1082
+ acceptedAt: z.ZodString;
1083
+ updatedAt: z.ZodString;
1084
+ deliverBy: z.ZodString;
1085
+ terminalAt: z.ZodNullable<z.ZodString>;
1086
+ destinations: z.ZodArray<z.ZodObject<{
1087
+ destinationKey: z.ZodString;
1088
+ state: z.ZodEnum<{
1089
+ pending: "pending";
1090
+ delivering: "delivering";
1091
+ delivered: "delivered";
1092
+ failed: "failed";
1093
+ expired: "expired";
1094
+ }>;
1095
+ attempts: z.ZodNumber;
1096
+ failureCode: z.ZodNullable<z.ZodEnum<{
1097
+ retry_exhausted: "retry_exhausted";
1098
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1099
+ provider_timeout: "provider_timeout";
1100
+ provider_rate_limited: "provider_rate_limited";
1101
+ provider_unavailable: "provider_unavailable";
1102
+ provider_rejected: "provider_rejected";
1103
+ delivery_interrupted: "delivery_interrupted";
1104
+ }>>;
1105
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
1106
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
1107
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
1108
+ }, z.core.$strict>>;
1109
+ }, z.core.$strict>, z.ZodObject<{
1110
+ eventId: z.ZodString;
1111
+ producer: z.ZodObject<{
1112
+ key: z.ZodString;
1113
+ environment: z.ZodString;
1114
+ }, z.core.$strict>;
1115
+ routeKey: z.ZodString;
1116
+ subject: z.ZodObject<{
1117
+ type: z.ZodString;
1118
+ id: z.ZodString;
1119
+ revision: z.ZodNumber;
1120
+ }, z.core.$strict>;
1121
+ terminal: z.ZodBoolean;
1122
+ acceptedAt: z.ZodString;
1123
+ updatedAt: z.ZodString;
1124
+ deliverBy: z.ZodString;
1125
+ terminalAt: z.ZodNullable<z.ZodString>;
1126
+ contractVersion: z.ZodLiteral<2>;
1127
+ state: z.ZodEnum<{
1128
+ pending: "pending";
1129
+ delivering: "delivering";
1130
+ partial: "partial";
1131
+ delivered: "delivered";
1132
+ failed: "failed";
1133
+ expired: "expired";
1134
+ unconfirmed: "unconfirmed";
1135
+ }>;
1136
+ reason: z.ZodEnum<{
1137
+ accepted: "accepted";
1138
+ enqueue_retry_wait: "enqueue_retry_wait";
1139
+ in_progress: "in_progress";
1140
+ partial_delivery: "partial_delivery";
1141
+ complete: "complete";
1142
+ retry_exhausted: "retry_exhausted";
1143
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
1144
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1145
+ delivery_unconfirmed: "delivery_unconfirmed";
1146
+ }>;
1147
+ revision: z.ZodNumber;
1148
+ destinations: z.ZodArray<z.ZodObject<{
1149
+ destinationKey: z.ZodString;
1150
+ failureCode: z.ZodNullable<z.ZodEnum<{
1151
+ retry_exhausted: "retry_exhausted";
1152
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1153
+ provider_timeout: "provider_timeout";
1154
+ provider_rate_limited: "provider_rate_limited";
1155
+ provider_unavailable: "provider_unavailable";
1156
+ provider_rejected: "provider_rejected";
1157
+ delivery_interrupted: "delivery_interrupted";
1158
+ }>>;
1159
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
1160
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
1161
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
1162
+ state: z.ZodEnum<{
1163
+ pending: "pending";
1164
+ delivering: "delivering";
1165
+ delivered: "delivered";
1166
+ failed: "failed";
1167
+ expired: "expired";
1168
+ unconfirmed: "unconfirmed";
1169
+ }>;
1170
+ attempts: z.ZodNumber;
1171
+ revision: z.ZodNumber;
1172
+ cause: z.ZodNullable<z.ZodObject<{
1173
+ name: z.ZodString;
1174
+ message: z.ZodOptional<z.ZodString>;
1175
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1176
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1177
+ cause: z.ZodOptional<z.ZodObject<{
1178
+ name: z.ZodString;
1179
+ message: z.ZodOptional<z.ZodString>;
1180
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1181
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1182
+ cause: z.ZodOptional<z.ZodObject<{
1183
+ name: z.ZodString;
1184
+ message: z.ZodOptional<z.ZodString>;
1185
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1186
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1187
+ cause: z.ZodOptional<z.ZodObject<{
1188
+ name: z.ZodString;
1189
+ message: z.ZodOptional<z.ZodString>;
1190
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1191
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1192
+ }, z.core.$strict>>;
1193
+ }, z.core.$strict>>;
1194
+ }, z.core.$strict>>;
1195
+ }, z.core.$strict>>;
1196
+ unconfirmedAt: z.ZodNullable<z.ZodString>;
1197
+ }, z.core.$strict>>;
1198
+ }, z.core.$strict>]>;
932
1199
  declare const notificationDeliveryRejectionV1Schema: z.ZodUnion<readonly [z.ZodObject<{
933
1200
  code: z.ZodLiteral<"invalid_request">;
934
1201
  issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -1114,6 +1381,344 @@ declare const notificationGetReceiptResultV1Schema: z.ZodDiscriminatedUnion<[z.Z
1114
1381
  code: z.ZodLiteral<"receipt_unavailable">;
1115
1382
  }, z.core.$strict>;
1116
1383
  }, z.core.$strict>], "status">;
1384
+ declare const notificationDeliverResultV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1385
+ status: z.ZodLiteral<"accepted">;
1386
+ receipt: z.ZodUnion<readonly [z.ZodObject<{
1387
+ contractVersion: z.ZodLiteral<1>;
1388
+ eventId: z.ZodString;
1389
+ producer: z.ZodObject<{
1390
+ key: z.ZodString;
1391
+ environment: z.ZodString;
1392
+ }, z.core.$strict>;
1393
+ routeKey: z.ZodString;
1394
+ subject: z.ZodObject<{
1395
+ type: z.ZodString;
1396
+ id: z.ZodString;
1397
+ revision: z.ZodNumber;
1398
+ }, z.core.$strict>;
1399
+ state: z.ZodEnum<{
1400
+ pending: "pending";
1401
+ delivering: "delivering";
1402
+ partial: "partial";
1403
+ delivered: "delivered";
1404
+ failed: "failed";
1405
+ expired: "expired";
1406
+ }>;
1407
+ reason: z.ZodEnum<{
1408
+ accepted: "accepted";
1409
+ enqueue_retry_wait: "enqueue_retry_wait";
1410
+ in_progress: "in_progress";
1411
+ partial_delivery: "partial_delivery";
1412
+ complete: "complete";
1413
+ retry_exhausted: "retry_exhausted";
1414
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
1415
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1416
+ }>;
1417
+ terminal: z.ZodBoolean;
1418
+ acceptedAt: z.ZodString;
1419
+ updatedAt: z.ZodString;
1420
+ deliverBy: z.ZodString;
1421
+ terminalAt: z.ZodNullable<z.ZodString>;
1422
+ destinations: z.ZodArray<z.ZodObject<{
1423
+ destinationKey: z.ZodString;
1424
+ state: z.ZodEnum<{
1425
+ pending: "pending";
1426
+ delivering: "delivering";
1427
+ delivered: "delivered";
1428
+ failed: "failed";
1429
+ expired: "expired";
1430
+ }>;
1431
+ attempts: z.ZodNumber;
1432
+ failureCode: z.ZodNullable<z.ZodEnum<{
1433
+ retry_exhausted: "retry_exhausted";
1434
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1435
+ provider_timeout: "provider_timeout";
1436
+ provider_rate_limited: "provider_rate_limited";
1437
+ provider_unavailable: "provider_unavailable";
1438
+ provider_rejected: "provider_rejected";
1439
+ delivery_interrupted: "delivery_interrupted";
1440
+ }>>;
1441
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
1442
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
1443
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
1444
+ }, z.core.$strict>>;
1445
+ }, z.core.$strict>, z.ZodObject<{
1446
+ eventId: z.ZodString;
1447
+ producer: z.ZodObject<{
1448
+ key: z.ZodString;
1449
+ environment: z.ZodString;
1450
+ }, z.core.$strict>;
1451
+ routeKey: z.ZodString;
1452
+ subject: z.ZodObject<{
1453
+ type: z.ZodString;
1454
+ id: z.ZodString;
1455
+ revision: z.ZodNumber;
1456
+ }, z.core.$strict>;
1457
+ terminal: z.ZodBoolean;
1458
+ acceptedAt: z.ZodString;
1459
+ updatedAt: z.ZodString;
1460
+ deliverBy: z.ZodString;
1461
+ terminalAt: z.ZodNullable<z.ZodString>;
1462
+ contractVersion: z.ZodLiteral<2>;
1463
+ state: z.ZodEnum<{
1464
+ pending: "pending";
1465
+ delivering: "delivering";
1466
+ partial: "partial";
1467
+ delivered: "delivered";
1468
+ failed: "failed";
1469
+ expired: "expired";
1470
+ unconfirmed: "unconfirmed";
1471
+ }>;
1472
+ reason: z.ZodEnum<{
1473
+ accepted: "accepted";
1474
+ enqueue_retry_wait: "enqueue_retry_wait";
1475
+ in_progress: "in_progress";
1476
+ partial_delivery: "partial_delivery";
1477
+ complete: "complete";
1478
+ retry_exhausted: "retry_exhausted";
1479
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
1480
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1481
+ delivery_unconfirmed: "delivery_unconfirmed";
1482
+ }>;
1483
+ revision: z.ZodNumber;
1484
+ destinations: z.ZodArray<z.ZodObject<{
1485
+ destinationKey: z.ZodString;
1486
+ failureCode: z.ZodNullable<z.ZodEnum<{
1487
+ retry_exhausted: "retry_exhausted";
1488
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1489
+ provider_timeout: "provider_timeout";
1490
+ provider_rate_limited: "provider_rate_limited";
1491
+ provider_unavailable: "provider_unavailable";
1492
+ provider_rejected: "provider_rejected";
1493
+ delivery_interrupted: "delivery_interrupted";
1494
+ }>>;
1495
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
1496
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
1497
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
1498
+ state: z.ZodEnum<{
1499
+ pending: "pending";
1500
+ delivering: "delivering";
1501
+ delivered: "delivered";
1502
+ failed: "failed";
1503
+ expired: "expired";
1504
+ unconfirmed: "unconfirmed";
1505
+ }>;
1506
+ attempts: z.ZodNumber;
1507
+ revision: z.ZodNumber;
1508
+ cause: z.ZodNullable<z.ZodObject<{
1509
+ name: z.ZodString;
1510
+ message: z.ZodOptional<z.ZodString>;
1511
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1512
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1513
+ cause: z.ZodOptional<z.ZodObject<{
1514
+ name: z.ZodString;
1515
+ message: z.ZodOptional<z.ZodString>;
1516
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1517
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1518
+ cause: z.ZodOptional<z.ZodObject<{
1519
+ name: z.ZodString;
1520
+ message: z.ZodOptional<z.ZodString>;
1521
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1522
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1523
+ cause: z.ZodOptional<z.ZodObject<{
1524
+ name: z.ZodString;
1525
+ message: z.ZodOptional<z.ZodString>;
1526
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1527
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1528
+ }, z.core.$strict>>;
1529
+ }, z.core.$strict>>;
1530
+ }, z.core.$strict>>;
1531
+ }, z.core.$strict>>;
1532
+ unconfirmedAt: z.ZodNullable<z.ZodString>;
1533
+ }, z.core.$strict>>;
1534
+ }, z.core.$strict>]>;
1535
+ }, z.core.$strict>, z.ZodObject<{
1536
+ status: z.ZodLiteral<"rejected">;
1537
+ error: z.ZodUnion<readonly [z.ZodObject<{
1538
+ code: z.ZodLiteral<"invalid_request">;
1539
+ issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
1540
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1541
+ code: z.ZodEnum<{
1542
+ invalid_type: "invalid_type";
1543
+ invalid_value: "invalid_value";
1544
+ too_small: "too_small";
1545
+ too_big: "too_big";
1546
+ invalid_format: "invalid_format";
1547
+ unrecognized_keys: "unrecognized_keys";
1548
+ custom: "custom";
1549
+ }>;
1550
+ }, z.core.$strict>>>;
1551
+ }, z.core.$strict>, z.ZodObject<{
1552
+ code: z.ZodEnum<{
1553
+ request_too_large: "request_too_large";
1554
+ producer_scope_mismatch: "producer_scope_mismatch";
1555
+ route_not_allowed: "route_not_allowed";
1556
+ event_identity_conflict: "event_identity_conflict";
1557
+ route_not_found: "route_not_found";
1558
+ route_empty: "route_empty";
1559
+ delivery_deadline_invalid: "delivery_deadline_invalid";
1560
+ }>;
1561
+ }, z.core.$strict>]>;
1562
+ }, z.core.$strict>], "status">;
1563
+ declare const notificationGetReceiptResultV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1564
+ status: z.ZodLiteral<"found">;
1565
+ receipt: z.ZodUnion<readonly [z.ZodObject<{
1566
+ contractVersion: z.ZodLiteral<1>;
1567
+ eventId: z.ZodString;
1568
+ producer: z.ZodObject<{
1569
+ key: z.ZodString;
1570
+ environment: z.ZodString;
1571
+ }, z.core.$strict>;
1572
+ routeKey: z.ZodString;
1573
+ subject: z.ZodObject<{
1574
+ type: z.ZodString;
1575
+ id: z.ZodString;
1576
+ revision: z.ZodNumber;
1577
+ }, z.core.$strict>;
1578
+ state: z.ZodEnum<{
1579
+ pending: "pending";
1580
+ delivering: "delivering";
1581
+ partial: "partial";
1582
+ delivered: "delivered";
1583
+ failed: "failed";
1584
+ expired: "expired";
1585
+ }>;
1586
+ reason: z.ZodEnum<{
1587
+ accepted: "accepted";
1588
+ enqueue_retry_wait: "enqueue_retry_wait";
1589
+ in_progress: "in_progress";
1590
+ partial_delivery: "partial_delivery";
1591
+ complete: "complete";
1592
+ retry_exhausted: "retry_exhausted";
1593
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
1594
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1595
+ }>;
1596
+ terminal: z.ZodBoolean;
1597
+ acceptedAt: z.ZodString;
1598
+ updatedAt: z.ZodString;
1599
+ deliverBy: z.ZodString;
1600
+ terminalAt: z.ZodNullable<z.ZodString>;
1601
+ destinations: z.ZodArray<z.ZodObject<{
1602
+ destinationKey: z.ZodString;
1603
+ state: z.ZodEnum<{
1604
+ pending: "pending";
1605
+ delivering: "delivering";
1606
+ delivered: "delivered";
1607
+ failed: "failed";
1608
+ expired: "expired";
1609
+ }>;
1610
+ attempts: z.ZodNumber;
1611
+ failureCode: z.ZodNullable<z.ZodEnum<{
1612
+ retry_exhausted: "retry_exhausted";
1613
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1614
+ provider_timeout: "provider_timeout";
1615
+ provider_rate_limited: "provider_rate_limited";
1616
+ provider_unavailable: "provider_unavailable";
1617
+ provider_rejected: "provider_rejected";
1618
+ delivery_interrupted: "delivery_interrupted";
1619
+ }>>;
1620
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
1621
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
1622
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
1623
+ }, z.core.$strict>>;
1624
+ }, z.core.$strict>, z.ZodObject<{
1625
+ eventId: z.ZodString;
1626
+ producer: z.ZodObject<{
1627
+ key: z.ZodString;
1628
+ environment: z.ZodString;
1629
+ }, z.core.$strict>;
1630
+ routeKey: z.ZodString;
1631
+ subject: z.ZodObject<{
1632
+ type: z.ZodString;
1633
+ id: z.ZodString;
1634
+ revision: z.ZodNumber;
1635
+ }, z.core.$strict>;
1636
+ terminal: z.ZodBoolean;
1637
+ acceptedAt: z.ZodString;
1638
+ updatedAt: z.ZodString;
1639
+ deliverBy: z.ZodString;
1640
+ terminalAt: z.ZodNullable<z.ZodString>;
1641
+ contractVersion: z.ZodLiteral<2>;
1642
+ state: z.ZodEnum<{
1643
+ pending: "pending";
1644
+ delivering: "delivering";
1645
+ partial: "partial";
1646
+ delivered: "delivered";
1647
+ failed: "failed";
1648
+ expired: "expired";
1649
+ unconfirmed: "unconfirmed";
1650
+ }>;
1651
+ reason: z.ZodEnum<{
1652
+ accepted: "accepted";
1653
+ enqueue_retry_wait: "enqueue_retry_wait";
1654
+ in_progress: "in_progress";
1655
+ partial_delivery: "partial_delivery";
1656
+ complete: "complete";
1657
+ retry_exhausted: "retry_exhausted";
1658
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
1659
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1660
+ delivery_unconfirmed: "delivery_unconfirmed";
1661
+ }>;
1662
+ revision: z.ZodNumber;
1663
+ destinations: z.ZodArray<z.ZodObject<{
1664
+ destinationKey: z.ZodString;
1665
+ failureCode: z.ZodNullable<z.ZodEnum<{
1666
+ retry_exhausted: "retry_exhausted";
1667
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1668
+ provider_timeout: "provider_timeout";
1669
+ provider_rate_limited: "provider_rate_limited";
1670
+ provider_unavailable: "provider_unavailable";
1671
+ provider_rejected: "provider_rejected";
1672
+ delivery_interrupted: "delivery_interrupted";
1673
+ }>>;
1674
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
1675
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
1676
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
1677
+ state: z.ZodEnum<{
1678
+ pending: "pending";
1679
+ delivering: "delivering";
1680
+ delivered: "delivered";
1681
+ failed: "failed";
1682
+ expired: "expired";
1683
+ unconfirmed: "unconfirmed";
1684
+ }>;
1685
+ attempts: z.ZodNumber;
1686
+ revision: z.ZodNumber;
1687
+ cause: z.ZodNullable<z.ZodObject<{
1688
+ name: z.ZodString;
1689
+ message: z.ZodOptional<z.ZodString>;
1690
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1691
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1692
+ cause: z.ZodOptional<z.ZodObject<{
1693
+ name: z.ZodString;
1694
+ message: z.ZodOptional<z.ZodString>;
1695
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1696
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1697
+ cause: z.ZodOptional<z.ZodObject<{
1698
+ name: z.ZodString;
1699
+ message: z.ZodOptional<z.ZodString>;
1700
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1701
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1702
+ cause: z.ZodOptional<z.ZodObject<{
1703
+ name: z.ZodString;
1704
+ message: z.ZodOptional<z.ZodString>;
1705
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1706
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1707
+ }, z.core.$strict>>;
1708
+ }, z.core.$strict>>;
1709
+ }, z.core.$strict>>;
1710
+ }, z.core.$strict>>;
1711
+ unconfirmedAt: z.ZodNullable<z.ZodString>;
1712
+ }, z.core.$strict>>;
1713
+ }, z.core.$strict>]>;
1714
+ }, z.core.$strict>, z.ZodObject<{
1715
+ status: z.ZodLiteral<"not_found">;
1716
+ }, z.core.$strict>, z.ZodObject<{
1717
+ status: z.ZodLiteral<"unavailable">;
1718
+ error: z.ZodObject<{
1719
+ code: z.ZodLiteral<"receipt_unavailable">;
1720
+ }, z.core.$strict>;
1721
+ }, z.core.$strict>], "status">;
1117
1722
  type NotificationDeliveryRequestV1 = z.infer<typeof notificationDeliveryRequestV1Schema>;
1118
1723
  type NotificationDeliveryRequestV2 = z.infer<typeof notificationDeliveryRequestV2Schema>;
1119
1724
  type NotificationDeliveryRequestV3 = z.infer<typeof notificationDeliveryRequestV3Schema>;
@@ -1126,9 +1731,13 @@ type NotificationStructuredMessageVariant = z.infer<typeof structuredNotificatio
1126
1731
  type NotificationMessageBody = z.infer<typeof notificationMessageBodySchema>;
1127
1732
  type NotificationSharedMessageBody = z.infer<typeof sharedNotificationBodySchema>;
1128
1733
  type NotificationDeliveryReceiptV1 = z.infer<typeof notificationDeliveryReceiptV1Schema>;
1734
+ type NotificationDeliveryReceiptV2 = z.infer<typeof notificationDeliveryReceiptV2Schema>;
1735
+ type NotificationMessageReceipt = z.infer<typeof notificationMessageReceiptSchema>;
1129
1736
  type NotificationDeliveryRejectionV1 = z.infer<typeof notificationDeliveryRejectionV1Schema>;
1130
1737
  type NotificationDeliverResultV1 = z.infer<typeof notificationDeliverResultV1Schema>;
1131
1738
  type NotificationGetReceiptResultV1 = z.infer<typeof notificationGetReceiptResultV1Schema>;
1739
+ type NotificationDeliverResultV2 = z.infer<typeof notificationDeliverResultV2Schema>;
1740
+ type NotificationGetReceiptResultV2 = z.infer<typeof notificationGetReceiptResultV2Schema>;
1132
1741
  type CreatorDraftTaskV1 = z.infer<typeof creatorDraftTaskV1Schema>;
1133
1742
  type LocalTaskDeliveryRequestV1 = z.infer<typeof localTaskDeliveryRequestV1Schema>;
1134
1743
  type LocalTaskDeliveryRequest = z.infer<typeof localTaskDeliveryRequestSchema>;
@@ -1152,5 +1761,12 @@ interface LocalTaskDeliveryServiceV1 {
1152
1761
  }
1153
1762
  /** Private Service Binding supporting notifications and profile-routed local tasks. */
1154
1763
  interface NotificationDeliveryServiceV3 extends NotificationDeliveryServiceV2, LocalTaskDeliveryServiceV1 {}
1764
+ /** Message receipts may be V1 during drain or V2 after the independent-outcome cutover. */
1765
+ interface NotificationMessageDeliveryServiceV4 {
1766
+ deliver: (request: NotificationDeliveryRequest) => Promise<NotificationDeliverResultV2>;
1767
+ getReceipt: (eventId: string) => Promise<NotificationGetReceiptResultV2>;
1768
+ deliverTask: LocalTaskDeliveryServiceV1['deliverTask'];
1769
+ getTaskReceipt: LocalTaskDeliveryServiceV1['getTaskReceipt'];
1770
+ }
1155
1771
  //#endregion
1156
- export { CreatorDraftTaskV1, LocalTaskDeliverResultV1, LocalTaskDeliveryReceiptV1, LocalTaskDeliveryRequest, LocalTaskDeliveryRequestV1, LocalTaskDeliveryServiceV1, LocalTaskGetReceiptResultV1, NotificationDeliverResultV1, NotificationDeliveryReceiptV1, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryRequestV6, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationDeliveryServiceV3, NotificationGetReceiptResultV1, NotificationMessageBody, NotificationMessageVariantKey, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, localTaskDeliveryContractVersionV1, localTaskDeliveryMaximumDeadlineMillisecondsV1, localTaskDeliveryRequestMaximumUtf8BytesV1, localTaskDeliveryRequestSchema, localTaskDeliveryRequestV1Schema, notificationDeliverResultV1Schema, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryContractVersionV5, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryMaximumDeadlineMillisecondsV4, notificationDeliveryMaximumDeadlineMillisecondsV5, notificationDeliveryReasonsV1, notificationDeliveryReceiptV1Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestMaximumUtf8BytesV4, notificationDeliveryRequestMaximumUtf8BytesV5, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, notificationDeliveryRequestV4Schema, notificationDeliveryRequestV5Schema, notificationDeliveryRequestV6Schema, notificationDeliveryStatesV1, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationGetReceiptResultV1Schema, notificationMessageVariantKeys, notificationValidationIssueCodesV1 };
1772
+ export { CreatorDraftTaskV1, LocalTaskDeliverResultV1, LocalTaskDeliveryReceiptV1, LocalTaskDeliveryRequest, LocalTaskDeliveryRequestV1, LocalTaskDeliveryServiceV1, LocalTaskGetReceiptResultV1, NotificationDeliverResultV1, NotificationDeliverResultV2, NotificationDeliveryReceiptV1, NotificationDeliveryReceiptV2, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryRequestV6, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationDeliveryServiceV3, NotificationGetReceiptResultV1, NotificationGetReceiptResultV2, NotificationMessageBody, NotificationMessageDeliveryServiceV4, NotificationMessageReceipt, NotificationMessageVariantKey, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, localTaskDeliveryContractVersionV1, localTaskDeliveryMaximumDeadlineMillisecondsV1, localTaskDeliveryRequestMaximumUtf8BytesV1, localTaskDeliveryRequestSchema, localTaskDeliveryRequestV1Schema, notificationDeliverResultV1Schema, notificationDeliverResultV2Schema, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryContractVersionV5, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryMaximumDeadlineMillisecondsV4, notificationDeliveryMaximumDeadlineMillisecondsV5, notificationDeliveryReasonsV1, notificationDeliveryReasonsV2, notificationDeliveryReceiptV1Schema, notificationDeliveryReceiptV2Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestMaximumUtf8BytesV4, notificationDeliveryRequestMaximumUtf8BytesV5, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, notificationDeliveryRequestV4Schema, notificationDeliveryRequestV5Schema, notificationDeliveryRequestV6Schema, notificationDeliveryStatesV1, notificationDeliveryStatesV2, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationDestinationStatesV2, notificationGetReceiptResultV1Schema, notificationGetReceiptResultV2Schema, notificationMessageReceiptSchema, notificationMessageVariantKeys, 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=32*1024,s=1380*60*1e3,c=o,l=s,u=o,d=s,f=o,p=s,m=o,h=s,ee=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=[`pending`,`delivering`,`delivered`,`failed`,`expired`],x=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],S=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],C=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],te=[`source`,`zh-CN`],ne=new TextEncoder,w=/^[a-z][a-z0-9-]{0,62}$/,re=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,T=/^[A-Z0-9][\w.:-]{0,127}$/i;function E(e){return[...e].length}function D(t){return e.string().refine(e=>E(e)>0,{message:`too_small`}).refine(e=>E(e)<=t,{message:`too_big`})}const O=e.string().datetime({offset:!0}),k=e.object({key:e.string().regex(w),environment:e.string().regex(w)}).strict(),A=e.object({type:e.string().regex(w),id:e.string().regex(T),revision:e.number().int().positive()}).strict(),j=e.string().min(1).max(127).regex(re),M=e.object({label:D(48),url:D(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(),N={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:k,routeKey:j,occurredAt:O,requestedAt:O,deliverBy:O,subject:A},ie=e.object({contractVersion:e.literal(1),...N,message:e.object({type:e.literal(`link_summary`),title:D(160),summary:D(1200),facts:e.array(e.object({label:D(48),value:D(500)}).strict()).max(10),primaryLink:M,sourceLink:M.optional()}).strict()}).strict();function P(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`]}),ne.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const F=ie.superRefine((e,t)=>P(e,t,s,o)),I={title:D(160),summary:D(1200),facts:e.array(e.object({label:D(48),value:D(500)}).strict()).max(10)},ae=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...I}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...I}).strict()]),oe=e.array(ae).min(1).max(2).superRefine((e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`})}),L=e.object({contractVersion:e.literal(2),...N,message:e.object({type:e.literal(`localized_link_summary`),variants:oe,primaryLink:M,sourceLink:M.optional()}).strict()}).strict().superRefine((e,t)=>P(e,t,l,c)),R=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(w),type:e.literal(`text`),label:D(48).optional(),value:D(4e3)}).strict(),e.object({key:e.string().regex(w),type:e.literal(`fields`),items:e.array(e.object({label:D(48),value:D(1200)}).strict()).min(1).max(20)}).strict()]),z=e.array(R).min(1).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),B=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:D(160),sections:z}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:D(160),sections:z}).strict()]),V=(e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`});let n=e.find(e=>e.key===`source`),r=e.find(e=>e.key===`zh-CN`);if(n&&r){let i=n.sections.map(e=>`${e.key}:${e.type}`),a=r.sections.map(e=>`${e.key}:${e.type}`);JSON.stringify(i)!==JSON.stringify(a)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(r),`sections`]})}},se=e.array(B).min(1).max(2).superRefine(V),H=e.object({contractVersion:e.literal(3),...N,message:e.object({type:e.literal(`structured_notification`),variants:se,links:e.array(e.object({key:e.string().regex(w),...M.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(),U=H.superRefine((e,t)=>P(e,t,d,u)),W=e.object({label:D(48).optional(),value:D(f)}).strict(),G=e.discriminatedUnion(`key`,[B.options[0].extend({body:W}),B.options[1].extend({body:W})]),K=H.extend({contractVersion:e.literal(4),message:H.shape.message.extend({variants:e.array(G).min(1).max(2).superRefine(V)})}).superRefine((e,t)=>P(e,t,p,f)),q=e.discriminatedUnion(`key`,[B.options[0].extend({bodyLabel:D(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(w),label:D(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`})})}),B.options[1].extend({bodyLabel:D(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(w),label:D(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`})})})]),ce=e.object({value:D(m)}).strict(),J=e.object({contractVersion:e.literal(5),...N,message:e.object({type:e.literal(`structured_notification`),variants:e.array(q).min(1).max(2).superRefine(V),links:e.array(e.object({key:e.string().regex(w),url:M.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:ce}).strict()}).strict().superRefine((e,t)=>{P(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`]})}}),Y=e.object({...J.shape,contractVersion:e.literal(6),message:J.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(w),value:D(m)}).strict()).min(1).max(2),variants:e.array(e.discriminatedUnion(`key`,[q.options[0].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(w),label:D(48)}).strict()).min(1).max(2),footer:D(500)}),q.options[1].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(w),label:D(48)}).strict()).min(1).max(2),footer:D(500)})])).min(1).max(2).superRefine(V)})}).strict().superRefine((e,t)=>{P(e,t,h,m);let n=e.message.bodies.map(e=>e.key),r=e.message.links.map(e=>e.key);new Set(n).size!==n.length&&t.addIssue({code:`custom`,message:`message_body_duplicate`});for(let i of e.message.variants){let e=i.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!n.includes(e)))&&t.addIssue({code:`custom`,message:`message_body_reference_invalid`}),JSON.stringify(i.linkLabels.map(e=>e.key))!==JSON.stringify(r)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`})}}),le=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:D(g),sourceUrl:M.shape.url.optional()}).strict(),X=e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:k,routeKey:j,occurredAt:O,requestedAt:O,deliverBy:O,subject:A.extend({type:e.literal(`creator-event`)}),task:le}).strict().superRefine((e,t)=>P(e,t,_,g)),ue=X,de=e.union([F,L,U,K,J,Y]),Z=e.object({destinationKey:e.string().min(1),state:e.enum(b),attempts:e.number().int().min(0).max(4),failureCode:e.enum(x).nullable(),lastAttemptAt:O.nullable(),nextAttemptAt:O.nullable(),leaseExpiresAt:O.nullable()}).strict(),Q=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:k,routeKey:j,subject:A,state:e.enum(v),reason:e.enum(y),terminal:e.boolean(),acceptedAt:O,updatedAt:O,deliverBy:O,terminalAt:O.nullable(),destinations:e.array(Z).min(1).max(20)}).strict(),fe=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(C)}).strict(),pe=e.object({code:e.literal(`invalid_request`),issues:e.array(fe).max(20).optional()}).strict(),me=e.object({code:e.enum(S.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([pe,me]),he=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),ge=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{ee as localTaskDeliveryContractVersionV1,_ as localTaskDeliveryMaximumDeadlineMillisecondsV1,g as localTaskDeliveryRequestMaximumUtf8BytesV1,ue as localTaskDeliveryRequestSchema,X as localTaskDeliveryRequestV1Schema,he as notificationDeliverResultV1Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,i as notificationDeliveryContractVersionV4,a as notificationDeliveryContractVersionV5,s as notificationDeliveryMaximumDeadlineMillisecondsV1,l as notificationDeliveryMaximumDeadlineMillisecondsV2,d as notificationDeliveryMaximumDeadlineMillisecondsV3,p as notificationDeliveryMaximumDeadlineMillisecondsV4,h as notificationDeliveryMaximumDeadlineMillisecondsV5,y as notificationDeliveryReasonsV1,Q as notificationDeliveryReceiptV1Schema,S as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,o as notificationDeliveryRequestMaximumUtf8BytesV1,c as notificationDeliveryRequestMaximumUtf8BytesV2,u as notificationDeliveryRequestMaximumUtf8BytesV3,f as notificationDeliveryRequestMaximumUtf8BytesV4,m as notificationDeliveryRequestMaximumUtf8BytesV5,de as notificationDeliveryRequestSchema,F as notificationDeliveryRequestV1Schema,L as notificationDeliveryRequestV2Schema,U as notificationDeliveryRequestV3Schema,K as notificationDeliveryRequestV4Schema,J as notificationDeliveryRequestV5Schema,Y as notificationDeliveryRequestV6Schema,v as notificationDeliveryStatesV1,x as notificationDestinationFailureCodesV1,b as notificationDestinationStatesV1,ge as notificationGetReceiptResultV1Schema,te as notificationMessageVariantKeys,C as notificationValidationIssueCodesV1};
1
+ import{z as e}from"zod";const t=1,n=2,r=3,i=4,a=5,o=32*1024,s=1380*60*1e3,c=o,l=s,u=o,d=s,f=o,p=s,m=o,h=s,ee=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`],C=[...S,`unconfirmed`],w=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],T=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],E=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],te=[`source`,`zh-CN`],ne=new TextEncoder,D=/^[a-z][a-z0-9-]{0,62}$/,re=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,ie=/^[A-Z0-9][\w.:-]{0,127}$/i;function ae(e){return[...e].length}function O(t){return e.string().refine(e=>ae(e)>0,{message:`too_small`}).refine(e=>ae(e)<=t,{message:`too_big`})}const k=e.string().datetime({offset:!0}),A=e.object({key:e.string().regex(D),environment:e.string().regex(D)}).strict(),j=e.object({type:e.string().regex(D),id:e.string().regex(ie),revision:e.number().int().positive()}).strict(),M=e.string().min(1).max(127).regex(re),N=e.object({label:O(48),url:O(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(),P={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:A,routeKey:M,occurredAt:k,requestedAt:k,deliverBy:k,subject:j},oe=e.object({contractVersion:e.literal(1),...P,message:e.object({type:e.literal(`link_summary`),title:O(160),summary:O(1200),facts:e.array(e.object({label:O(48),value:O(500)}).strict()).max(10),primaryLink:N,sourceLink:N.optional()}).strict()}).strict();function F(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`]}),ne.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const I=oe.superRefine((e,t)=>F(e,t,s,o)),L={title:O(160),summary:O(1200),facts:e.array(e.object({label:O(48),value:O(500)}).strict()).max(10)},se=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...L}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...L}).strict()]),ce=e.array(se).min(1).max(2).superRefine((e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`})}),R=e.object({contractVersion:e.literal(2),...P,message:e.object({type:e.literal(`localized_link_summary`),variants:ce,primaryLink:N,sourceLink:N.optional()}).strict()}).strict().superRefine((e,t)=>F(e,t,l,c)),le=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(D),type:e.literal(`text`),label:O(48).optional(),value:O(4e3)}).strict(),e.object({key:e.string().regex(D),type:e.literal(`fields`),items:e.array(e.object({label:O(48),value:O(1200)}).strict()).min(1).max(20)}).strict()]),z=e.array(le).min(1).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),B=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:O(160),sections:z}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:O(160),sections:z}).strict()]),V=(e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`});let n=e.find(e=>e.key===`source`),r=e.find(e=>e.key===`zh-CN`);if(n&&r){let i=n.sections.map(e=>`${e.key}:${e.type}`),a=r.sections.map(e=>`${e.key}:${e.type}`);JSON.stringify(i)!==JSON.stringify(a)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(r),`sections`]})}},ue=e.array(B).min(1).max(2).superRefine(V),H=e.object({contractVersion:e.literal(3),...P,message:e.object({type:e.literal(`structured_notification`),variants:ue,links:e.array(e.object({key:e.string().regex(D),...N.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(),de=H.superRefine((e,t)=>F(e,t,d,u)),U=e.object({label:O(48).optional(),value:O(f)}).strict(),fe=e.discriminatedUnion(`key`,[B.options[0].extend({body:U}),B.options[1].extend({body:U})]),W=H.extend({contractVersion:e.literal(4),message:H.shape.message.extend({variants:e.array(fe).min(1).max(2).superRefine(V)})}).superRefine((e,t)=>F(e,t,p,f)),G=e.discriminatedUnion(`key`,[B.options[0].extend({bodyLabel:O(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(D),label:O(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`})})}),B.options[1].extend({bodyLabel:O(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(D),label:O(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`})})})]),pe=e.object({value:O(m)}).strict(),K=e.object({contractVersion:e.literal(5),...P,message:e.object({type:e.literal(`structured_notification`),variants:e.array(G).min(1).max(2).superRefine(V),links:e.array(e.object({key:e.string().regex(D),url:N.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:pe}).strict()}).strict().superRefine((e,t)=>{F(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`]})}}),q=e.object({...K.shape,contractVersion:e.literal(6),message:K.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(D),value:O(m)}).strict()).min(1).max(2),variants:e.array(e.discriminatedUnion(`key`,[G.options[0].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(D),label:O(48)}).strict()).min(1).max(2),footer:O(500)}),G.options[1].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(D),label:O(48)}).strict()).min(1).max(2),footer:O(500)})])).min(1).max(2).superRefine(V)})}).strict().superRefine((e,t)=>{F(e,t,h,m);let n=e.message.bodies.map(e=>e.key),r=e.message.links.map(e=>e.key);new Set(n).size!==n.length&&t.addIssue({code:`custom`,message:`message_body_duplicate`});for(let i of e.message.variants){let e=i.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!n.includes(e)))&&t.addIssue({code:`custom`,message:`message_body_reference_invalid`}),JSON.stringify(i.linkLabels.map(e=>e.key))!==JSON.stringify(r)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`})}}),me=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:O(g),sourceUrl:N.shape.url.optional()}).strict(),J=e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:A,routeKey:M,occurredAt:k,requestedAt:k,deliverBy:k,subject:j.extend({type:e.literal(`creator-event`)}),task:me}).strict().superRefine((e,t)=>F(e,t,_,g)),he=J,ge=e.union([I,R,de,W,K,q]),Y=e.object({destinationKey:e.string().min(1),state:e.enum(S),attempts:e.number().int().min(0).max(4),failureCode:e.enum(w).nullable(),lastAttemptAt:k.nullable(),nextAttemptAt:k.nullable(),leaseExpiresAt:k.nullable()}).strict(),X=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:A,routeKey:M,subject:j,state:e.enum(v),reason:e.enum(y),terminal:e.boolean(),acceptedAt:k,updatedAt:k,deliverBy:k,terminalAt:k.nullable(),destinations:e.array(Y).min(1).max(20)}).strict(),Z=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(),_e=Z.extend({cause:Z.extend({cause:Z.extend({cause:Z.optional()}).optional()}).optional()}),ve=Y.extend({state:e.enum(C),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:_e.nullable(),unconfirmedAt:k.nullable()}),ye=X.extend({contractVersion:e.literal(2),state:e.enum(b),reason:e.enum(x),revision:e.number().int().min(0),destinations:e.array(ve).min(1).max(20)}),Q=e.union([X,ye]),be=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(E)}).strict(),xe=e.object({code:e.literal(`invalid_request`),issues:e.array(be).max(20).optional()}).strict(),Se=e.object({code:e.enum(T.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([xe,Se]),Ce=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:X}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),we=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:X}).strict(),e.object({status:e.literal(`not_found`)}).strict(),e.object({status:e.literal(`unavailable`),error:e.object({code:e.literal(`receipt_unavailable`)}).strict()}).strict()]),Te=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),Ee=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{ee as localTaskDeliveryContractVersionV1,_ as localTaskDeliveryMaximumDeadlineMillisecondsV1,g as localTaskDeliveryRequestMaximumUtf8BytesV1,he as localTaskDeliveryRequestSchema,J as localTaskDeliveryRequestV1Schema,Ce as notificationDeliverResultV1Schema,Te as notificationDeliverResultV2Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,i as notificationDeliveryContractVersionV4,a as notificationDeliveryContractVersionV5,s as notificationDeliveryMaximumDeadlineMillisecondsV1,l as notificationDeliveryMaximumDeadlineMillisecondsV2,d as notificationDeliveryMaximumDeadlineMillisecondsV3,p as notificationDeliveryMaximumDeadlineMillisecondsV4,h as notificationDeliveryMaximumDeadlineMillisecondsV5,y as notificationDeliveryReasonsV1,x as notificationDeliveryReasonsV2,X as notificationDeliveryReceiptV1Schema,ye as notificationDeliveryReceiptV2Schema,T as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,o as notificationDeliveryRequestMaximumUtf8BytesV1,c as notificationDeliveryRequestMaximumUtf8BytesV2,u as notificationDeliveryRequestMaximumUtf8BytesV3,f as notificationDeliveryRequestMaximumUtf8BytesV4,m as notificationDeliveryRequestMaximumUtf8BytesV5,ge as notificationDeliveryRequestSchema,I as notificationDeliveryRequestV1Schema,R as notificationDeliveryRequestV2Schema,de as notificationDeliveryRequestV3Schema,W as notificationDeliveryRequestV4Schema,K as notificationDeliveryRequestV5Schema,q as notificationDeliveryRequestV6Schema,v as notificationDeliveryStatesV1,b as notificationDeliveryStatesV2,w as notificationDestinationFailureCodesV1,S as notificationDestinationStatesV1,C as notificationDestinationStatesV2,we as notificationGetReceiptResultV1Schema,Ee as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,te as notificationMessageVariantKeys,E as notificationValidationIssueCodesV1,_e as safeDeliveryCauseSchema};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@closerepo/notification-contracts",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {