@closerepo/notification-contracts 1.7.0 → 1.8.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
@@ -5,6 +5,8 @@ declare const notificationDeliveryContractVersionV2: 2;
5
5
  declare const notificationDeliveryContractVersionV3: 3;
6
6
  declare const notificationDeliveryContractVersionV4: 4;
7
7
  declare const notificationDeliveryContractVersionV5: 5;
8
+ declare const notificationDeliveryContractVersionV7: 7;
9
+ declare const notificationDeliveryMaximumDestinationsV1 = 20;
8
10
  declare const notificationDeliveryRequestMaximumUtf8BytesV1: number;
9
11
  declare const notificationDeliveryMaximumDeadlineMillisecondsV1: number;
10
12
  declare const notificationDeliveryRequestMaximumUtf8BytesV2: number;
@@ -451,6 +453,96 @@ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
451
453
  revision: z.ZodNumber;
452
454
  }, z.core.$strict>;
453
455
  }, z.core.$strict>;
456
+ /** One event matches multiple subscriptions; destinations are unioned before admission. */
457
+ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
458
+ contractVersion: z.ZodLiteral<7>;
459
+ routeKeys: z.ZodArray<z.ZodString>;
460
+ message: z.ZodObject<{
461
+ type: z.ZodLiteral<"structured_notification">;
462
+ links: z.ZodArray<z.ZodObject<{
463
+ key: z.ZodString;
464
+ url: z.ZodString;
465
+ }, z.core.$strict>>;
466
+ bodies: z.ZodArray<z.ZodObject<{
467
+ key: z.ZodString;
468
+ value: z.ZodString;
469
+ }, z.core.$strict>>;
470
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
471
+ key: z.ZodLiteral<"source">;
472
+ title: z.ZodString;
473
+ locale: z.ZodLiteral<"und">;
474
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
475
+ key: z.ZodString;
476
+ type: z.ZodLiteral<"text">;
477
+ label: z.ZodOptional<z.ZodString>;
478
+ value: z.ZodString;
479
+ }, z.core.$strict>, z.ZodObject<{
480
+ key: z.ZodString;
481
+ type: z.ZodLiteral<"fields">;
482
+ items: z.ZodArray<z.ZodObject<{
483
+ label: z.ZodString;
484
+ value: z.ZodString;
485
+ }, z.core.$strict>>;
486
+ }, z.core.$strict>], "type">>;
487
+ linkLabels: z.ZodArray<z.ZodObject<{
488
+ key: z.ZodString;
489
+ label: z.ZodString;
490
+ }, z.core.$strict>>;
491
+ bodyRefs: z.ZodArray<z.ZodObject<{
492
+ key: z.ZodString;
493
+ label: z.ZodString;
494
+ }, z.core.$strict>>;
495
+ footer: z.ZodOptional<z.ZodString>;
496
+ }, z.core.$strict>, z.ZodObject<{
497
+ key: z.ZodLiteral<"zh-CN">;
498
+ title: z.ZodString;
499
+ locale: z.ZodLiteral<"zh-CN">;
500
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
501
+ key: z.ZodString;
502
+ type: z.ZodLiteral<"text">;
503
+ label: z.ZodOptional<z.ZodString>;
504
+ value: z.ZodString;
505
+ }, z.core.$strict>, z.ZodObject<{
506
+ key: z.ZodString;
507
+ type: z.ZodLiteral<"fields">;
508
+ items: z.ZodArray<z.ZodObject<{
509
+ label: z.ZodString;
510
+ value: z.ZodString;
511
+ }, z.core.$strict>>;
512
+ }, z.core.$strict>], "type">>;
513
+ linkLabels: z.ZodArray<z.ZodObject<{
514
+ key: z.ZodString;
515
+ label: z.ZodString;
516
+ }, z.core.$strict>>;
517
+ bodyRefs: z.ZodArray<z.ZodObject<{
518
+ key: z.ZodString;
519
+ label: z.ZodString;
520
+ }, z.core.$strict>>;
521
+ footer: z.ZodOptional<z.ZodString>;
522
+ }, z.core.$strict>], "key">>;
523
+ }, z.core.$strict>;
524
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
525
+ eventId: z.ZodString;
526
+ producer: z.ZodObject<{
527
+ key: z.ZodString;
528
+ environment: z.ZodString;
529
+ }, z.core.$strict>;
530
+ occurredAt: z.ZodString;
531
+ requestedAt: z.ZodString;
532
+ deliverBy: z.ZodString;
533
+ subject: z.ZodObject<{
534
+ type: z.ZodString;
535
+ id: z.ZodString;
536
+ revision: z.ZodNumber;
537
+ }, z.core.$strict>;
538
+ }, z.core.$strict>;
539
+ type NotificationDeliveryRequestV7 = z.infer<typeof notificationDeliveryRequestV7Schema>;
540
+ /** Reads routing facts from current envelopes and historical single-route records. */
541
+ declare function notificationRouteKeys(value: {
542
+ routeKey: string;
543
+ } | {
544
+ routeKeys: string[];
545
+ }): string[];
454
546
  type NotificationDeliveryRequestV6 = z.infer<typeof notificationDeliveryRequestV6Schema>;
455
547
  declare const creatorDraftTaskV1Schema: z.ZodObject<{
456
548
  type: z.ZodLiteral<"creator.draft.v1">;
@@ -871,6 +963,87 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
871
963
  id: z.ZodString;
872
964
  revision: z.ZodNumber;
873
965
  }, z.core.$strict>;
966
+ }, z.core.$strict>, z.ZodObject<{
967
+ contractVersion: z.ZodLiteral<7>;
968
+ routeKeys: z.ZodArray<z.ZodString>;
969
+ message: z.ZodObject<{
970
+ type: z.ZodLiteral<"structured_notification">;
971
+ links: z.ZodArray<z.ZodObject<{
972
+ key: z.ZodString;
973
+ url: z.ZodString;
974
+ }, z.core.$strict>>;
975
+ bodies: z.ZodArray<z.ZodObject<{
976
+ key: z.ZodString;
977
+ value: z.ZodString;
978
+ }, z.core.$strict>>;
979
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
980
+ key: z.ZodLiteral<"source">;
981
+ title: z.ZodString;
982
+ locale: z.ZodLiteral<"und">;
983
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
984
+ key: z.ZodString;
985
+ type: z.ZodLiteral<"text">;
986
+ label: z.ZodOptional<z.ZodString>;
987
+ value: z.ZodString;
988
+ }, z.core.$strict>, z.ZodObject<{
989
+ key: z.ZodString;
990
+ type: z.ZodLiteral<"fields">;
991
+ items: z.ZodArray<z.ZodObject<{
992
+ label: z.ZodString;
993
+ value: z.ZodString;
994
+ }, z.core.$strict>>;
995
+ }, z.core.$strict>], "type">>;
996
+ linkLabels: z.ZodArray<z.ZodObject<{
997
+ key: z.ZodString;
998
+ label: z.ZodString;
999
+ }, z.core.$strict>>;
1000
+ bodyRefs: z.ZodArray<z.ZodObject<{
1001
+ key: z.ZodString;
1002
+ label: z.ZodString;
1003
+ }, z.core.$strict>>;
1004
+ footer: z.ZodOptional<z.ZodString>;
1005
+ }, z.core.$strict>, z.ZodObject<{
1006
+ key: z.ZodLiteral<"zh-CN">;
1007
+ title: z.ZodString;
1008
+ locale: z.ZodLiteral<"zh-CN">;
1009
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1010
+ key: z.ZodString;
1011
+ type: z.ZodLiteral<"text">;
1012
+ label: z.ZodOptional<z.ZodString>;
1013
+ value: z.ZodString;
1014
+ }, z.core.$strict>, z.ZodObject<{
1015
+ key: z.ZodString;
1016
+ type: z.ZodLiteral<"fields">;
1017
+ items: z.ZodArray<z.ZodObject<{
1018
+ label: z.ZodString;
1019
+ value: z.ZodString;
1020
+ }, z.core.$strict>>;
1021
+ }, z.core.$strict>], "type">>;
1022
+ linkLabels: z.ZodArray<z.ZodObject<{
1023
+ key: z.ZodString;
1024
+ label: z.ZodString;
1025
+ }, z.core.$strict>>;
1026
+ bodyRefs: z.ZodArray<z.ZodObject<{
1027
+ key: z.ZodString;
1028
+ label: z.ZodString;
1029
+ }, z.core.$strict>>;
1030
+ footer: z.ZodOptional<z.ZodString>;
1031
+ }, z.core.$strict>], "key">>;
1032
+ }, z.core.$strict>;
1033
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
1034
+ eventId: z.ZodString;
1035
+ producer: z.ZodObject<{
1036
+ key: z.ZodString;
1037
+ environment: z.ZodString;
1038
+ }, z.core.$strict>;
1039
+ occurredAt: z.ZodString;
1040
+ requestedAt: z.ZodString;
1041
+ deliverBy: z.ZodString;
1042
+ subject: z.ZodObject<{
1043
+ type: z.ZodString;
1044
+ id: z.ZodString;
1045
+ revision: z.ZodNumber;
1046
+ }, z.core.$strict>;
874
1047
  }, z.core.$strict>]>;
875
1048
  declare const notificationDeliveryReceiptV1Schema: z.ZodObject<{
876
1049
  contractVersion: z.ZodLiteral<1>;
@@ -1047,6 +1220,98 @@ declare const notificationDeliveryReceiptV2Schema: z.ZodObject<{
1047
1220
  unconfirmedAt: z.ZodNullable<z.ZodString>;
1048
1221
  }, z.core.$strict>>;
1049
1222
  }, z.core.$strict>;
1223
+ /** V3 retains independent destination outcomes and records every matched route. */
1224
+ declare const notificationDeliveryReceiptV3Schema: z.ZodObject<{
1225
+ revision: z.ZodNumber;
1226
+ eventId: z.ZodString;
1227
+ producer: z.ZodObject<{
1228
+ key: z.ZodString;
1229
+ environment: z.ZodString;
1230
+ }, z.core.$strict>;
1231
+ deliverBy: z.ZodString;
1232
+ subject: z.ZodObject<{
1233
+ type: z.ZodString;
1234
+ id: z.ZodString;
1235
+ revision: z.ZodNumber;
1236
+ }, z.core.$strict>;
1237
+ acceptedAt: z.ZodString;
1238
+ updatedAt: z.ZodString;
1239
+ state: z.ZodEnum<{
1240
+ pending: "pending";
1241
+ delivering: "delivering";
1242
+ partial: "partial";
1243
+ delivered: "delivered";
1244
+ failed: "failed";
1245
+ expired: "expired";
1246
+ unconfirmed: "unconfirmed";
1247
+ }>;
1248
+ reason: z.ZodEnum<{
1249
+ accepted: "accepted";
1250
+ enqueue_retry_wait: "enqueue_retry_wait";
1251
+ in_progress: "in_progress";
1252
+ partial_delivery: "partial_delivery";
1253
+ complete: "complete";
1254
+ retry_exhausted: "retry_exhausted";
1255
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
1256
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1257
+ delivery_unconfirmed: "delivery_unconfirmed";
1258
+ }>;
1259
+ terminal: z.ZodBoolean;
1260
+ terminalAt: z.ZodNullable<z.ZodString>;
1261
+ destinations: z.ZodArray<z.ZodObject<{
1262
+ destinationKey: z.ZodString;
1263
+ failureCode: z.ZodNullable<z.ZodEnum<{
1264
+ retry_exhausted: "retry_exhausted";
1265
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1266
+ provider_timeout: "provider_timeout";
1267
+ provider_rate_limited: "provider_rate_limited";
1268
+ provider_unavailable: "provider_unavailable";
1269
+ provider_rejected: "provider_rejected";
1270
+ delivery_interrupted: "delivery_interrupted";
1271
+ }>>;
1272
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
1273
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
1274
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
1275
+ state: z.ZodEnum<{
1276
+ pending: "pending";
1277
+ delivering: "delivering";
1278
+ delivered: "delivered";
1279
+ failed: "failed";
1280
+ expired: "expired";
1281
+ unconfirmed: "unconfirmed";
1282
+ }>;
1283
+ attempts: z.ZodNumber;
1284
+ revision: z.ZodNumber;
1285
+ cause: z.ZodNullable<z.ZodObject<{
1286
+ name: z.ZodString;
1287
+ message: z.ZodOptional<z.ZodString>;
1288
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1289
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1290
+ cause: z.ZodOptional<z.ZodObject<{
1291
+ name: z.ZodString;
1292
+ message: z.ZodOptional<z.ZodString>;
1293
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1294
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1295
+ cause: z.ZodOptional<z.ZodObject<{
1296
+ name: z.ZodString;
1297
+ message: z.ZodOptional<z.ZodString>;
1298
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1299
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1300
+ cause: z.ZodOptional<z.ZodObject<{
1301
+ name: z.ZodString;
1302
+ message: z.ZodOptional<z.ZodString>;
1303
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1304
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1305
+ }, z.core.$strict>>;
1306
+ }, z.core.$strict>>;
1307
+ }, z.core.$strict>>;
1308
+ }, z.core.$strict>>;
1309
+ unconfirmedAt: z.ZodNullable<z.ZodString>;
1310
+ }, z.core.$strict>>;
1311
+ contractVersion: z.ZodLiteral<3>;
1312
+ routeKeys: z.ZodArray<z.ZodString>;
1313
+ }, z.core.$strict>;
1314
+ type NotificationDeliveryReceiptV3 = z.infer<typeof notificationDeliveryReceiptV3Schema>;
1050
1315
  declare const notificationMessageReceiptSchema: z.ZodUnion<readonly [z.ZodObject<{
1051
1316
  contractVersion: z.ZodLiteral<1>;
1052
1317
  eventId: z.ZodString;
@@ -1195,6 +1460,95 @@ declare const notificationMessageReceiptSchema: z.ZodUnion<readonly [z.ZodObject
1195
1460
  }, z.core.$strict>>;
1196
1461
  unconfirmedAt: z.ZodNullable<z.ZodString>;
1197
1462
  }, z.core.$strict>>;
1463
+ }, z.core.$strict>, z.ZodObject<{
1464
+ revision: z.ZodNumber;
1465
+ eventId: z.ZodString;
1466
+ producer: z.ZodObject<{
1467
+ key: z.ZodString;
1468
+ environment: z.ZodString;
1469
+ }, z.core.$strict>;
1470
+ deliverBy: z.ZodString;
1471
+ subject: z.ZodObject<{
1472
+ type: z.ZodString;
1473
+ id: z.ZodString;
1474
+ revision: z.ZodNumber;
1475
+ }, z.core.$strict>;
1476
+ acceptedAt: z.ZodString;
1477
+ updatedAt: z.ZodString;
1478
+ state: z.ZodEnum<{
1479
+ pending: "pending";
1480
+ delivering: "delivering";
1481
+ partial: "partial";
1482
+ delivered: "delivered";
1483
+ failed: "failed";
1484
+ expired: "expired";
1485
+ unconfirmed: "unconfirmed";
1486
+ }>;
1487
+ reason: z.ZodEnum<{
1488
+ accepted: "accepted";
1489
+ enqueue_retry_wait: "enqueue_retry_wait";
1490
+ in_progress: "in_progress";
1491
+ partial_delivery: "partial_delivery";
1492
+ complete: "complete";
1493
+ retry_exhausted: "retry_exhausted";
1494
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
1495
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1496
+ delivery_unconfirmed: "delivery_unconfirmed";
1497
+ }>;
1498
+ terminal: z.ZodBoolean;
1499
+ terminalAt: z.ZodNullable<z.ZodString>;
1500
+ destinations: z.ZodArray<z.ZodObject<{
1501
+ destinationKey: z.ZodString;
1502
+ failureCode: z.ZodNullable<z.ZodEnum<{
1503
+ retry_exhausted: "retry_exhausted";
1504
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1505
+ provider_timeout: "provider_timeout";
1506
+ provider_rate_limited: "provider_rate_limited";
1507
+ provider_unavailable: "provider_unavailable";
1508
+ provider_rejected: "provider_rejected";
1509
+ delivery_interrupted: "delivery_interrupted";
1510
+ }>>;
1511
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
1512
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
1513
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
1514
+ state: z.ZodEnum<{
1515
+ pending: "pending";
1516
+ delivering: "delivering";
1517
+ delivered: "delivered";
1518
+ failed: "failed";
1519
+ expired: "expired";
1520
+ unconfirmed: "unconfirmed";
1521
+ }>;
1522
+ attempts: z.ZodNumber;
1523
+ revision: z.ZodNumber;
1524
+ cause: z.ZodNullable<z.ZodObject<{
1525
+ name: z.ZodString;
1526
+ message: z.ZodOptional<z.ZodString>;
1527
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1528
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1529
+ cause: z.ZodOptional<z.ZodObject<{
1530
+ name: z.ZodString;
1531
+ message: z.ZodOptional<z.ZodString>;
1532
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1533
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1534
+ cause: z.ZodOptional<z.ZodObject<{
1535
+ name: z.ZodString;
1536
+ message: z.ZodOptional<z.ZodString>;
1537
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1538
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1539
+ cause: z.ZodOptional<z.ZodObject<{
1540
+ name: z.ZodString;
1541
+ message: z.ZodOptional<z.ZodString>;
1542
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1543
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1544
+ }, z.core.$strict>>;
1545
+ }, z.core.$strict>>;
1546
+ }, z.core.$strict>>;
1547
+ }, z.core.$strict>>;
1548
+ unconfirmedAt: z.ZodNullable<z.ZodString>;
1549
+ }, z.core.$strict>>;
1550
+ contractVersion: z.ZodLiteral<3>;
1551
+ routeKeys: z.ZodArray<z.ZodString>;
1198
1552
  }, z.core.$strict>]>;
1199
1553
  declare const notificationDeliveryRejectionV1Schema: z.ZodUnion<readonly [z.ZodObject<{
1200
1554
  code: z.ZodLiteral<"invalid_request">;
@@ -1531,6 +1885,95 @@ declare const notificationDeliverResultV2Schema: z.ZodDiscriminatedUnion<[z.ZodO
1531
1885
  }, z.core.$strict>>;
1532
1886
  unconfirmedAt: z.ZodNullable<z.ZodString>;
1533
1887
  }, z.core.$strict>>;
1888
+ }, z.core.$strict>, z.ZodObject<{
1889
+ revision: z.ZodNumber;
1890
+ eventId: z.ZodString;
1891
+ producer: z.ZodObject<{
1892
+ key: z.ZodString;
1893
+ environment: z.ZodString;
1894
+ }, z.core.$strict>;
1895
+ deliverBy: z.ZodString;
1896
+ subject: z.ZodObject<{
1897
+ type: z.ZodString;
1898
+ id: z.ZodString;
1899
+ revision: z.ZodNumber;
1900
+ }, z.core.$strict>;
1901
+ acceptedAt: z.ZodString;
1902
+ updatedAt: z.ZodString;
1903
+ state: z.ZodEnum<{
1904
+ pending: "pending";
1905
+ delivering: "delivering";
1906
+ partial: "partial";
1907
+ delivered: "delivered";
1908
+ failed: "failed";
1909
+ expired: "expired";
1910
+ unconfirmed: "unconfirmed";
1911
+ }>;
1912
+ reason: z.ZodEnum<{
1913
+ accepted: "accepted";
1914
+ enqueue_retry_wait: "enqueue_retry_wait";
1915
+ in_progress: "in_progress";
1916
+ partial_delivery: "partial_delivery";
1917
+ complete: "complete";
1918
+ retry_exhausted: "retry_exhausted";
1919
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
1920
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1921
+ delivery_unconfirmed: "delivery_unconfirmed";
1922
+ }>;
1923
+ terminal: z.ZodBoolean;
1924
+ terminalAt: z.ZodNullable<z.ZodString>;
1925
+ destinations: z.ZodArray<z.ZodObject<{
1926
+ destinationKey: z.ZodString;
1927
+ failureCode: z.ZodNullable<z.ZodEnum<{
1928
+ retry_exhausted: "retry_exhausted";
1929
+ destination_configuration_unavailable: "destination_configuration_unavailable";
1930
+ provider_timeout: "provider_timeout";
1931
+ provider_rate_limited: "provider_rate_limited";
1932
+ provider_unavailable: "provider_unavailable";
1933
+ provider_rejected: "provider_rejected";
1934
+ delivery_interrupted: "delivery_interrupted";
1935
+ }>>;
1936
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
1937
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
1938
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
1939
+ state: z.ZodEnum<{
1940
+ pending: "pending";
1941
+ delivering: "delivering";
1942
+ delivered: "delivered";
1943
+ failed: "failed";
1944
+ expired: "expired";
1945
+ unconfirmed: "unconfirmed";
1946
+ }>;
1947
+ attempts: z.ZodNumber;
1948
+ revision: z.ZodNumber;
1949
+ cause: z.ZodNullable<z.ZodObject<{
1950
+ name: z.ZodString;
1951
+ message: z.ZodOptional<z.ZodString>;
1952
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1953
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1954
+ cause: z.ZodOptional<z.ZodObject<{
1955
+ name: z.ZodString;
1956
+ message: z.ZodOptional<z.ZodString>;
1957
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1958
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1959
+ cause: z.ZodOptional<z.ZodObject<{
1960
+ name: z.ZodString;
1961
+ message: z.ZodOptional<z.ZodString>;
1962
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1963
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1964
+ cause: z.ZodOptional<z.ZodObject<{
1965
+ name: z.ZodString;
1966
+ message: z.ZodOptional<z.ZodString>;
1967
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1968
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1969
+ }, z.core.$strict>>;
1970
+ }, z.core.$strict>>;
1971
+ }, z.core.$strict>>;
1972
+ }, z.core.$strict>>;
1973
+ unconfirmedAt: z.ZodNullable<z.ZodString>;
1974
+ }, z.core.$strict>>;
1975
+ contractVersion: z.ZodLiteral<3>;
1976
+ routeKeys: z.ZodArray<z.ZodString>;
1534
1977
  }, z.core.$strict>]>;
1535
1978
  }, z.core.$strict>, z.ZodObject<{
1536
1979
  status: z.ZodLiteral<"rejected">;
@@ -1710,6 +2153,95 @@ declare const notificationGetReceiptResultV2Schema: z.ZodDiscriminatedUnion<[z.Z
1710
2153
  }, z.core.$strict>>;
1711
2154
  unconfirmedAt: z.ZodNullable<z.ZodString>;
1712
2155
  }, z.core.$strict>>;
2156
+ }, z.core.$strict>, z.ZodObject<{
2157
+ revision: z.ZodNumber;
2158
+ eventId: z.ZodString;
2159
+ producer: z.ZodObject<{
2160
+ key: z.ZodString;
2161
+ environment: z.ZodString;
2162
+ }, z.core.$strict>;
2163
+ deliverBy: z.ZodString;
2164
+ subject: z.ZodObject<{
2165
+ type: z.ZodString;
2166
+ id: z.ZodString;
2167
+ revision: z.ZodNumber;
2168
+ }, z.core.$strict>;
2169
+ acceptedAt: z.ZodString;
2170
+ updatedAt: z.ZodString;
2171
+ state: z.ZodEnum<{
2172
+ pending: "pending";
2173
+ delivering: "delivering";
2174
+ partial: "partial";
2175
+ delivered: "delivered";
2176
+ failed: "failed";
2177
+ expired: "expired";
2178
+ unconfirmed: "unconfirmed";
2179
+ }>;
2180
+ reason: z.ZodEnum<{
2181
+ accepted: "accepted";
2182
+ enqueue_retry_wait: "enqueue_retry_wait";
2183
+ in_progress: "in_progress";
2184
+ partial_delivery: "partial_delivery";
2185
+ complete: "complete";
2186
+ retry_exhausted: "retry_exhausted";
2187
+ delivery_deadline_exceeded: "delivery_deadline_exceeded";
2188
+ destination_configuration_unavailable: "destination_configuration_unavailable";
2189
+ delivery_unconfirmed: "delivery_unconfirmed";
2190
+ }>;
2191
+ terminal: z.ZodBoolean;
2192
+ terminalAt: z.ZodNullable<z.ZodString>;
2193
+ destinations: z.ZodArray<z.ZodObject<{
2194
+ destinationKey: z.ZodString;
2195
+ failureCode: z.ZodNullable<z.ZodEnum<{
2196
+ retry_exhausted: "retry_exhausted";
2197
+ destination_configuration_unavailable: "destination_configuration_unavailable";
2198
+ provider_timeout: "provider_timeout";
2199
+ provider_rate_limited: "provider_rate_limited";
2200
+ provider_unavailable: "provider_unavailable";
2201
+ provider_rejected: "provider_rejected";
2202
+ delivery_interrupted: "delivery_interrupted";
2203
+ }>>;
2204
+ lastAttemptAt: z.ZodNullable<z.ZodString>;
2205
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
2206
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
2207
+ state: z.ZodEnum<{
2208
+ pending: "pending";
2209
+ delivering: "delivering";
2210
+ delivered: "delivered";
2211
+ failed: "failed";
2212
+ expired: "expired";
2213
+ unconfirmed: "unconfirmed";
2214
+ }>;
2215
+ attempts: z.ZodNumber;
2216
+ revision: z.ZodNumber;
2217
+ cause: z.ZodNullable<z.ZodObject<{
2218
+ name: z.ZodString;
2219
+ message: z.ZodOptional<z.ZodString>;
2220
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
2221
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
2222
+ cause: z.ZodOptional<z.ZodObject<{
2223
+ name: z.ZodString;
2224
+ message: z.ZodOptional<z.ZodString>;
2225
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
2226
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
2227
+ cause: z.ZodOptional<z.ZodObject<{
2228
+ name: z.ZodString;
2229
+ message: z.ZodOptional<z.ZodString>;
2230
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
2231
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
2232
+ cause: z.ZodOptional<z.ZodObject<{
2233
+ name: z.ZodString;
2234
+ message: z.ZodOptional<z.ZodString>;
2235
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
2236
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
2237
+ }, z.core.$strict>>;
2238
+ }, z.core.$strict>>;
2239
+ }, z.core.$strict>>;
2240
+ }, z.core.$strict>>;
2241
+ unconfirmedAt: z.ZodNullable<z.ZodString>;
2242
+ }, z.core.$strict>>;
2243
+ contractVersion: z.ZodLiteral<3>;
2244
+ routeKeys: z.ZodArray<z.ZodString>;
1713
2245
  }, z.core.$strict>]>;
1714
2246
  }, z.core.$strict>, z.ZodObject<{
1715
2247
  status: z.ZodLiteral<"not_found">;
@@ -1761,12 +2293,14 @@ interface LocalTaskDeliveryServiceV1 {
1761
2293
  }
1762
2294
  /** Private Service Binding supporting notifications and profile-routed local tasks. */
1763
2295
  interface NotificationDeliveryServiceV3 extends NotificationDeliveryServiceV2, LocalTaskDeliveryServiceV1 {}
1764
- /** Message receipts may be V1 during drain or V2 after the independent-outcome cutover. */
2296
+ /** Message receipts include historical V1/V2 and multi-route V3 outcomes. */
1765
2297
  interface NotificationMessageDeliveryServiceV4 {
1766
2298
  deliver: (request: NotificationDeliveryRequest) => Promise<NotificationDeliverResultV2>;
1767
2299
  getReceipt: (eventId: string) => Promise<NotificationGetReceiptResultV2>;
1768
2300
  deliverTask: LocalTaskDeliveryServiceV1['deliverTask'];
1769
2301
  getTaskReceipt: LocalTaskDeliveryServiceV1['getTaskReceipt'];
1770
2302
  }
2303
+ /** Multi-route message delivery; historical requests and receipts remain supported. */
2304
+ interface NotificationMessageDeliveryServiceV5 extends NotificationMessageDeliveryServiceV4 {}
1771
2305
  //#endregion
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 };
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 };
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=[...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};
1
+ import{z as e}from"zod";const t=1,n=2,r=3,i=4,a=5,ee=7,te=20,o=32*1024,s=1380*60*1e3,ne=o,re=s,c=o,l=s,u=o,ie=s,d=o,f=s,ae=1,p=32*1024,m=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`],_=[...h,`unconfirmed`],v=[...g,`delivery_unconfirmed`],y=[`pending`,`delivering`,`delivered`,`failed`,`expired`],b=[...y,`unconfirmed`],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`],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,s,o)),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,re,ne)),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)=>{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`]})}},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,l,c)),B=e.object({label:w(48).optional(),value:w(u)}).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,ie,u)),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(d)}).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,f,d);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(d)}).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(L)})}).strict().superRefine(ye);function ye(e,t){j(e,t,f,d);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(L)})}).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(p),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,m,p)),Oe=De,ke=e.union([M,P,z,V,U,W,we]),Ae=e.object({destinationKey:e.string().min(1),state:e.enum(y),attempts:e.number().int().min(0).max(4),failureCode:e.enum(x).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(h),reason:e.enum(g),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(b),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(_),reason:e.enum(v),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(S.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{ae as localTaskDeliveryContractVersionV1,m as localTaskDeliveryMaximumDeadlineMillisecondsV1,p 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,ee as notificationDeliveryContractVersionV7,s as notificationDeliveryMaximumDeadlineMillisecondsV1,re as notificationDeliveryMaximumDeadlineMillisecondsV2,l as notificationDeliveryMaximumDeadlineMillisecondsV3,ie as notificationDeliveryMaximumDeadlineMillisecondsV4,f as notificationDeliveryMaximumDeadlineMillisecondsV5,te as notificationDeliveryMaximumDestinationsV1,g as notificationDeliveryReasonsV1,v as notificationDeliveryReasonsV2,J as notificationDeliveryReceiptV1Schema,Z as notificationDeliveryReceiptV2Schema,Me as notificationDeliveryReceiptV3Schema,S as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,o as notificationDeliveryRequestMaximumUtf8BytesV1,ne as notificationDeliveryRequestMaximumUtf8BytesV2,c as notificationDeliveryRequestMaximumUtf8BytesV3,u as notificationDeliveryRequestMaximumUtf8BytesV4,d 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,h as notificationDeliveryStatesV1,_ as notificationDeliveryStatesV2,x as notificationDestinationFailureCodesV1,y as notificationDestinationStatesV1,b as notificationDestinationStatesV2,Le as notificationGetReceiptResultV1Schema,ze as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,se as notificationMessageVariantKeys,Te as notificationRouteKeys,oe as notificationValidationIssueCodesV1,X as safeDeliveryCauseSchema};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@closerepo/notification-contracts",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {