@closerepo/notification-contracts 1.13.0 → 1.14.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
@@ -21,6 +21,7 @@ declare const notificationDeliveryContractVersionV5: 5;
21
21
  declare const notificationDeliveryContractVersionV7: 7;
22
22
  declare const notificationDeliveryContractVersionV8: 8;
23
23
  declare const notificationDeliveryContractVersionV9: 9;
24
+ declare const notificationDeliveryContractVersionV10: 10;
24
25
  declare const notificationDeliveryMaximumDestinationsV1 = 20;
25
26
  declare const notificationDeliveryRequestMaximumUtf8BytesV1: number;
26
27
  declare const notificationDeliveryMaximumDeadlineMillisecondsV1: number;
@@ -32,6 +33,7 @@ declare const notificationDeliveryRequestMaximumUtf8BytesV4: number;
32
33
  declare const notificationDeliveryMaximumDeadlineMillisecondsV4: number;
33
34
  declare const notificationDeliveryRequestMaximumUtf8BytesV5: number;
34
35
  declare const notificationDeliveryRequestMaximumUtf8BytesV9: number;
36
+ declare const notificationDeliveryRequestMaximumUtf8BytesV10: number;
35
37
  declare const notificationDeliveryMaximumDeadlineMillisecondsV5: number;
36
38
  declare const localTaskDeliveryContractVersionV1: 1;
37
39
  declare const localTaskDeliveryRequestMaximumUtf8BytesV1: number;
@@ -859,6 +861,201 @@ declare const notificationDeliveryRequestV9Schema: z.ZodObject<{
859
861
  type NotificationDeliveryRequestV9 = z.infer<typeof notificationDeliveryRequestV9Schema>;
860
862
  type NotificationBrowserMessage = z.infer<typeof notificationBrowserMessageSchema>;
861
863
  type NotificationMessageVariantsV6 = NotificationDeliveryRequestV6['message']['variants'];
864
+ /** A quoted interval in its containing string, measured in UTF-16 code units. */
865
+ declare const notificationQuoteRangeSchema: z.ZodObject<{
866
+ offset: z.ZodNumber;
867
+ length: z.ZodNumber;
868
+ }, z.core.$strict>;
869
+ type NotificationQuoteRange = z.infer<typeof notificationQuoteRangeSchema>;
870
+ /** V10 preserves V9 delivery semantics and adds producer-owned quoted text intervals. */
871
+ declare const notificationDeliveryRequestV10Schema: z.ZodObject<{
872
+ contractVersion: z.ZodLiteral<10>;
873
+ message: z.ZodObject<{
874
+ type: z.ZodLiteral<"structured_notification">;
875
+ links: z.ZodArray<z.ZodObject<{
876
+ key: z.ZodString;
877
+ url: z.ZodString;
878
+ }, z.core.$strict>>;
879
+ bodies: z.ZodArray<z.ZodObject<{
880
+ key: z.ZodString;
881
+ value: z.ZodString;
882
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
883
+ offset: z.ZodNumber;
884
+ length: z.ZodNumber;
885
+ }, z.core.$strict>>>;
886
+ }, z.core.$strict>>;
887
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
888
+ key: z.ZodLiteral<"source">;
889
+ title: z.ZodString;
890
+ locale: z.ZodLiteral<"und">;
891
+ linkLabels: z.ZodArray<z.ZodObject<{
892
+ key: z.ZodString;
893
+ label: z.ZodString;
894
+ }, z.core.$strict>>;
895
+ bodyRefs: z.ZodArray<z.ZodObject<{
896
+ key: z.ZodString;
897
+ label: z.ZodOptional<z.ZodString>;
898
+ }, z.core.$strict>>;
899
+ footer: z.ZodOptional<z.ZodString>;
900
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
901
+ offset: z.ZodNumber;
902
+ length: z.ZodNumber;
903
+ }, z.core.$strict>>>;
904
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
905
+ key: z.ZodString;
906
+ type: z.ZodLiteral<"text">;
907
+ label: z.ZodOptional<z.ZodString>;
908
+ value: z.ZodString;
909
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
910
+ offset: z.ZodNumber;
911
+ length: z.ZodNumber;
912
+ }, z.core.$strict>>>;
913
+ }, z.core.$strict>, z.ZodObject<{
914
+ key: z.ZodString;
915
+ type: z.ZodLiteral<"fields">;
916
+ items: z.ZodArray<z.ZodObject<{
917
+ label: z.ZodString;
918
+ value: z.ZodString;
919
+ }, z.core.$strict>>;
920
+ }, z.core.$strict>], "type">>;
921
+ }, z.core.$strict>, z.ZodObject<{
922
+ key: z.ZodLiteral<"zh-CN">;
923
+ title: z.ZodString;
924
+ locale: z.ZodLiteral<"zh-CN">;
925
+ linkLabels: z.ZodArray<z.ZodObject<{
926
+ key: z.ZodString;
927
+ label: z.ZodString;
928
+ }, z.core.$strict>>;
929
+ bodyRefs: z.ZodArray<z.ZodObject<{
930
+ key: z.ZodString;
931
+ label: z.ZodOptional<z.ZodString>;
932
+ }, z.core.$strict>>;
933
+ footer: z.ZodOptional<z.ZodString>;
934
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
935
+ offset: z.ZodNumber;
936
+ length: z.ZodNumber;
937
+ }, z.core.$strict>>>;
938
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
939
+ key: z.ZodString;
940
+ type: z.ZodLiteral<"text">;
941
+ label: z.ZodOptional<z.ZodString>;
942
+ value: z.ZodString;
943
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
944
+ offset: z.ZodNumber;
945
+ length: z.ZodNumber;
946
+ }, z.core.$strict>>>;
947
+ }, z.core.$strict>, z.ZodObject<{
948
+ key: z.ZodString;
949
+ type: z.ZodLiteral<"fields">;
950
+ items: z.ZodArray<z.ZodObject<{
951
+ label: z.ZodString;
952
+ value: z.ZodString;
953
+ }, z.core.$strict>>;
954
+ }, z.core.$strict>], "type">>;
955
+ }, z.core.$strict>], "key">>;
956
+ channelVariants: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
957
+ qq: "qq";
958
+ tg: "tg";
959
+ wechat: "wechat";
960
+ lark: "lark";
961
+ }> & z.core.$partial, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
962
+ key: z.ZodLiteral<"source">;
963
+ title: z.ZodString;
964
+ locale: z.ZodLiteral<"und">;
965
+ linkLabels: z.ZodArray<z.ZodObject<{
966
+ key: z.ZodString;
967
+ label: z.ZodString;
968
+ }, z.core.$strict>>;
969
+ bodyRefs: z.ZodArray<z.ZodObject<{
970
+ key: z.ZodString;
971
+ label: z.ZodOptional<z.ZodString>;
972
+ }, z.core.$strict>>;
973
+ footer: z.ZodOptional<z.ZodString>;
974
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
975
+ offset: z.ZodNumber;
976
+ length: z.ZodNumber;
977
+ }, z.core.$strict>>>;
978
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
979
+ key: z.ZodString;
980
+ type: z.ZodLiteral<"text">;
981
+ label: z.ZodOptional<z.ZodString>;
982
+ value: z.ZodString;
983
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
984
+ offset: z.ZodNumber;
985
+ length: z.ZodNumber;
986
+ }, z.core.$strict>>>;
987
+ }, z.core.$strict>, z.ZodObject<{
988
+ key: z.ZodString;
989
+ type: z.ZodLiteral<"fields">;
990
+ items: z.ZodArray<z.ZodObject<{
991
+ label: z.ZodString;
992
+ value: z.ZodString;
993
+ }, z.core.$strict>>;
994
+ }, z.core.$strict>], "type">>;
995
+ }, z.core.$strict>, z.ZodObject<{
996
+ key: z.ZodLiteral<"zh-CN">;
997
+ title: z.ZodString;
998
+ locale: z.ZodLiteral<"zh-CN">;
999
+ linkLabels: z.ZodArray<z.ZodObject<{
1000
+ key: z.ZodString;
1001
+ label: z.ZodString;
1002
+ }, z.core.$strict>>;
1003
+ bodyRefs: z.ZodArray<z.ZodObject<{
1004
+ key: z.ZodString;
1005
+ label: z.ZodOptional<z.ZodString>;
1006
+ }, z.core.$strict>>;
1007
+ footer: z.ZodOptional<z.ZodString>;
1008
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1009
+ offset: z.ZodNumber;
1010
+ length: z.ZodNumber;
1011
+ }, z.core.$strict>>>;
1012
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1013
+ key: z.ZodString;
1014
+ type: z.ZodLiteral<"text">;
1015
+ label: z.ZodOptional<z.ZodString>;
1016
+ value: z.ZodString;
1017
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1018
+ offset: z.ZodNumber;
1019
+ length: z.ZodNumber;
1020
+ }, z.core.$strict>>>;
1021
+ }, z.core.$strict>, z.ZodObject<{
1022
+ key: z.ZodString;
1023
+ type: z.ZodLiteral<"fields">;
1024
+ items: z.ZodArray<z.ZodObject<{
1025
+ label: z.ZodString;
1026
+ value: z.ZodString;
1027
+ }, z.core.$strict>>;
1028
+ }, z.core.$strict>], "type">>;
1029
+ }, z.core.$strict>], "key">>>>;
1030
+ }, z.core.$strict>;
1031
+ audience: z.ZodOptional<z.ZodObject<{
1032
+ topics: z.ZodArray<z.ZodString>;
1033
+ }, z.core.$strict>>;
1034
+ browserMessages: z.ZodOptional<z.ZodArray<z.ZodObject<{
1035
+ locale: z.ZodString;
1036
+ contentLocale: z.ZodString;
1037
+ title: z.ZodString;
1038
+ body: z.ZodString;
1039
+ url: z.ZodString;
1040
+ }, z.core.$strict>>>;
1041
+ routeKeys: z.ZodArray<z.ZodString>;
1042
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
1043
+ eventId: z.ZodString;
1044
+ producer: z.ZodObject<{
1045
+ key: z.ZodString;
1046
+ environment: z.ZodString;
1047
+ }, z.core.$strict>;
1048
+ occurredAt: z.ZodString;
1049
+ requestedAt: z.ZodString;
1050
+ deliverBy: z.ZodString;
1051
+ subject: z.ZodObject<{
1052
+ type: z.ZodString;
1053
+ id: z.ZodString;
1054
+ revision: z.ZodNumber;
1055
+ }, z.core.$strict>;
1056
+ }, z.core.$strict>;
1057
+ type NotificationDeliveryRequestV10 = z.infer<typeof notificationDeliveryRequestV10Schema>;
1058
+ type NotificationMessageVariantsV10 = NotificationDeliveryRequestV10['message']['variants'];
862
1059
  /** Reads routing facts from current envelopes and historical single-route records. */
863
1060
  declare function notificationRouteKeys(value: {
864
1061
  routeKey: string;
@@ -1654,6 +1851,191 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1654
1851
  id: z.ZodString;
1655
1852
  revision: z.ZodNumber;
1656
1853
  }, z.core.$strict>;
1854
+ }, z.core.$strict>, z.ZodObject<{
1855
+ contractVersion: z.ZodLiteral<10>;
1856
+ message: z.ZodObject<{
1857
+ type: z.ZodLiteral<"structured_notification">;
1858
+ links: z.ZodArray<z.ZodObject<{
1859
+ key: z.ZodString;
1860
+ url: z.ZodString;
1861
+ }, z.core.$strict>>;
1862
+ bodies: z.ZodArray<z.ZodObject<{
1863
+ key: z.ZodString;
1864
+ value: z.ZodString;
1865
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1866
+ offset: z.ZodNumber;
1867
+ length: z.ZodNumber;
1868
+ }, z.core.$strict>>>;
1869
+ }, z.core.$strict>>;
1870
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1871
+ key: z.ZodLiteral<"source">;
1872
+ title: z.ZodString;
1873
+ locale: z.ZodLiteral<"und">;
1874
+ linkLabels: z.ZodArray<z.ZodObject<{
1875
+ key: z.ZodString;
1876
+ label: z.ZodString;
1877
+ }, z.core.$strict>>;
1878
+ bodyRefs: z.ZodArray<z.ZodObject<{
1879
+ key: z.ZodString;
1880
+ label: z.ZodOptional<z.ZodString>;
1881
+ }, z.core.$strict>>;
1882
+ footer: z.ZodOptional<z.ZodString>;
1883
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1884
+ offset: z.ZodNumber;
1885
+ length: z.ZodNumber;
1886
+ }, z.core.$strict>>>;
1887
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1888
+ key: z.ZodString;
1889
+ type: z.ZodLiteral<"text">;
1890
+ label: z.ZodOptional<z.ZodString>;
1891
+ value: z.ZodString;
1892
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1893
+ offset: z.ZodNumber;
1894
+ length: z.ZodNumber;
1895
+ }, z.core.$strict>>>;
1896
+ }, z.core.$strict>, z.ZodObject<{
1897
+ key: z.ZodString;
1898
+ type: z.ZodLiteral<"fields">;
1899
+ items: z.ZodArray<z.ZodObject<{
1900
+ label: z.ZodString;
1901
+ value: z.ZodString;
1902
+ }, z.core.$strict>>;
1903
+ }, z.core.$strict>], "type">>;
1904
+ }, z.core.$strict>, z.ZodObject<{
1905
+ key: z.ZodLiteral<"zh-CN">;
1906
+ title: z.ZodString;
1907
+ locale: z.ZodLiteral<"zh-CN">;
1908
+ linkLabels: z.ZodArray<z.ZodObject<{
1909
+ key: z.ZodString;
1910
+ label: z.ZodString;
1911
+ }, z.core.$strict>>;
1912
+ bodyRefs: z.ZodArray<z.ZodObject<{
1913
+ key: z.ZodString;
1914
+ label: z.ZodOptional<z.ZodString>;
1915
+ }, z.core.$strict>>;
1916
+ footer: z.ZodOptional<z.ZodString>;
1917
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1918
+ offset: z.ZodNumber;
1919
+ length: z.ZodNumber;
1920
+ }, z.core.$strict>>>;
1921
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1922
+ key: z.ZodString;
1923
+ type: z.ZodLiteral<"text">;
1924
+ label: z.ZodOptional<z.ZodString>;
1925
+ value: z.ZodString;
1926
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1927
+ offset: z.ZodNumber;
1928
+ length: z.ZodNumber;
1929
+ }, z.core.$strict>>>;
1930
+ }, z.core.$strict>, z.ZodObject<{
1931
+ key: z.ZodString;
1932
+ type: z.ZodLiteral<"fields">;
1933
+ items: z.ZodArray<z.ZodObject<{
1934
+ label: z.ZodString;
1935
+ value: z.ZodString;
1936
+ }, z.core.$strict>>;
1937
+ }, z.core.$strict>], "type">>;
1938
+ }, z.core.$strict>], "key">>;
1939
+ channelVariants: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
1940
+ qq: "qq";
1941
+ tg: "tg";
1942
+ wechat: "wechat";
1943
+ lark: "lark";
1944
+ }> & z.core.$partial, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1945
+ key: z.ZodLiteral<"source">;
1946
+ title: z.ZodString;
1947
+ locale: z.ZodLiteral<"und">;
1948
+ linkLabels: z.ZodArray<z.ZodObject<{
1949
+ key: z.ZodString;
1950
+ label: z.ZodString;
1951
+ }, z.core.$strict>>;
1952
+ bodyRefs: z.ZodArray<z.ZodObject<{
1953
+ key: z.ZodString;
1954
+ label: z.ZodOptional<z.ZodString>;
1955
+ }, z.core.$strict>>;
1956
+ footer: z.ZodOptional<z.ZodString>;
1957
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1958
+ offset: z.ZodNumber;
1959
+ length: z.ZodNumber;
1960
+ }, z.core.$strict>>>;
1961
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1962
+ key: z.ZodString;
1963
+ type: z.ZodLiteral<"text">;
1964
+ label: z.ZodOptional<z.ZodString>;
1965
+ value: z.ZodString;
1966
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1967
+ offset: z.ZodNumber;
1968
+ length: z.ZodNumber;
1969
+ }, z.core.$strict>>>;
1970
+ }, z.core.$strict>, z.ZodObject<{
1971
+ key: z.ZodString;
1972
+ type: z.ZodLiteral<"fields">;
1973
+ items: z.ZodArray<z.ZodObject<{
1974
+ label: z.ZodString;
1975
+ value: z.ZodString;
1976
+ }, z.core.$strict>>;
1977
+ }, z.core.$strict>], "type">>;
1978
+ }, z.core.$strict>, z.ZodObject<{
1979
+ key: z.ZodLiteral<"zh-CN">;
1980
+ title: z.ZodString;
1981
+ locale: z.ZodLiteral<"zh-CN">;
1982
+ linkLabels: z.ZodArray<z.ZodObject<{
1983
+ key: z.ZodString;
1984
+ label: z.ZodString;
1985
+ }, z.core.$strict>>;
1986
+ bodyRefs: z.ZodArray<z.ZodObject<{
1987
+ key: z.ZodString;
1988
+ label: z.ZodOptional<z.ZodString>;
1989
+ }, z.core.$strict>>;
1990
+ footer: z.ZodOptional<z.ZodString>;
1991
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1992
+ offset: z.ZodNumber;
1993
+ length: z.ZodNumber;
1994
+ }, z.core.$strict>>>;
1995
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1996
+ key: z.ZodString;
1997
+ type: z.ZodLiteral<"text">;
1998
+ label: z.ZodOptional<z.ZodString>;
1999
+ value: z.ZodString;
2000
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
2001
+ offset: z.ZodNumber;
2002
+ length: z.ZodNumber;
2003
+ }, z.core.$strict>>>;
2004
+ }, z.core.$strict>, z.ZodObject<{
2005
+ key: z.ZodString;
2006
+ type: z.ZodLiteral<"fields">;
2007
+ items: z.ZodArray<z.ZodObject<{
2008
+ label: z.ZodString;
2009
+ value: z.ZodString;
2010
+ }, z.core.$strict>>;
2011
+ }, z.core.$strict>], "type">>;
2012
+ }, z.core.$strict>], "key">>>>;
2013
+ }, z.core.$strict>;
2014
+ audience: z.ZodOptional<z.ZodObject<{
2015
+ topics: z.ZodArray<z.ZodString>;
2016
+ }, z.core.$strict>>;
2017
+ browserMessages: z.ZodOptional<z.ZodArray<z.ZodObject<{
2018
+ locale: z.ZodString;
2019
+ contentLocale: z.ZodString;
2020
+ title: z.ZodString;
2021
+ body: z.ZodString;
2022
+ url: z.ZodString;
2023
+ }, z.core.$strict>>>;
2024
+ routeKeys: z.ZodArray<z.ZodString>;
2025
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
2026
+ eventId: z.ZodString;
2027
+ producer: z.ZodObject<{
2028
+ key: z.ZodString;
2029
+ environment: z.ZodString;
2030
+ }, z.core.$strict>;
2031
+ occurredAt: z.ZodString;
2032
+ requestedAt: z.ZodString;
2033
+ deliverBy: z.ZodString;
2034
+ subject: z.ZodObject<{
2035
+ type: z.ZodString;
2036
+ id: z.ZodString;
2037
+ revision: z.ZodNumber;
2038
+ }, z.core.$strict>;
1657
2039
  }, z.core.$strict>]>;
1658
2040
  declare const notificationDeliveryReceiptV1Schema: z.ZodObject<{
1659
2041
  contractVersion: z.ZodLiteral<1>;
@@ -2913,4 +3295,4 @@ interface NotificationMessageDeliveryServiceV4 {
2913
3295
  /** Multi-route message delivery; historical requests and receipts remain supported. */
2914
3296
  interface NotificationMessageDeliveryServiceV5 extends NotificationMessageDeliveryServiceV4 {}
2915
3297
  //#endregion
2916
- export { CreatorDraftTaskV1, LocalTaskDeliverResultV1, LocalTaskDeliveryReceiptV1, LocalTaskDeliveryRequest, LocalTaskDeliveryRequestV1, LocalTaskDeliveryServiceV1, LocalTaskGetReceiptResultV1, NotificationBrowserMessage, type NotificationBrowserPayload, NotificationDeliverResultV1, NotificationDeliverResultV2, NotificationDeliveryChannelKey, NotificationDeliveryReceiptV1, NotificationDeliveryReceiptV2, NotificationDeliveryReceiptV3, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryRequestV6, NotificationDeliveryRequestV7, NotificationDeliveryRequestV8, NotificationDeliveryRequestV9, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationDeliveryServiceV3, NotificationGetReceiptResultV1, NotificationGetReceiptResultV2, NotificationMessageBody, NotificationMessageDeliveryServiceV4, NotificationMessageDeliveryServiceV5, NotificationMessageReceipt, NotificationMessageVariantKey, NotificationMessageVariantsV6, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, localTaskDeliveryContractVersionV1, localTaskDeliveryMaximumDeadlineMillisecondsV1, localTaskDeliveryRequestMaximumUtf8BytesV1, localTaskDeliveryRequestSchema, localTaskDeliveryRequestV1Schema, notificationBrowserMessageSchema, notificationBrowserPayloadSchema, notificationDeliverResultV1Schema, notificationDeliverResultV2Schema, notificationDeliveryChannelKeys, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryContractVersionV5, notificationDeliveryContractVersionV7, notificationDeliveryContractVersionV8, notificationDeliveryContractVersionV9, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryMaximumDeadlineMillisecondsV4, notificationDeliveryMaximumDeadlineMillisecondsV5, notificationDeliveryMaximumDestinationsV1, notificationDeliveryReasonsV1, notificationDeliveryReasonsV2, notificationDeliveryReceiptV1Schema, notificationDeliveryReceiptV2Schema, notificationDeliveryReceiptV3Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestMaximumUtf8BytesV4, notificationDeliveryRequestMaximumUtf8BytesV5, notificationDeliveryRequestMaximumUtf8BytesV9, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, notificationDeliveryRequestV4Schema, notificationDeliveryRequestV5Schema, notificationDeliveryRequestV6Schema, notificationDeliveryRequestV7Schema, notificationDeliveryRequestV8Schema, notificationDeliveryRequestV9Schema, notificationDeliveryStatesV1, notificationDeliveryStatesV2, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationDestinationStatesV2, notificationGetReceiptResultV1Schema, notificationGetReceiptResultV2Schema, notificationMessageReceiptSchema, notificationMessageVariantKeys, notificationRouteKeys, notificationValidationIssueCodesV1, safeDeliveryCauseSchema };
3298
+ export { CreatorDraftTaskV1, LocalTaskDeliverResultV1, LocalTaskDeliveryReceiptV1, LocalTaskDeliveryRequest, LocalTaskDeliveryRequestV1, LocalTaskDeliveryServiceV1, LocalTaskGetReceiptResultV1, NotificationBrowserMessage, type NotificationBrowserPayload, NotificationDeliverResultV1, NotificationDeliverResultV2, NotificationDeliveryChannelKey, NotificationDeliveryReceiptV1, NotificationDeliveryReceiptV2, NotificationDeliveryReceiptV3, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV10, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryRequestV6, NotificationDeliveryRequestV7, NotificationDeliveryRequestV8, NotificationDeliveryRequestV9, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationDeliveryServiceV3, NotificationGetReceiptResultV1, NotificationGetReceiptResultV2, NotificationMessageBody, NotificationMessageDeliveryServiceV4, NotificationMessageDeliveryServiceV5, NotificationMessageReceipt, NotificationMessageVariantKey, NotificationMessageVariantsV10, NotificationMessageVariantsV6, NotificationQuoteRange, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, localTaskDeliveryContractVersionV1, localTaskDeliveryMaximumDeadlineMillisecondsV1, localTaskDeliveryRequestMaximumUtf8BytesV1, localTaskDeliveryRequestSchema, localTaskDeliveryRequestV1Schema, notificationBrowserMessageSchema, notificationBrowserPayloadSchema, notificationDeliverResultV1Schema, notificationDeliverResultV2Schema, notificationDeliveryChannelKeys, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV10, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryContractVersionV5, notificationDeliveryContractVersionV7, notificationDeliveryContractVersionV8, notificationDeliveryContractVersionV9, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryMaximumDeadlineMillisecondsV4, notificationDeliveryMaximumDeadlineMillisecondsV5, notificationDeliveryMaximumDestinationsV1, notificationDeliveryReasonsV1, notificationDeliveryReasonsV2, notificationDeliveryReceiptV1Schema, notificationDeliveryReceiptV2Schema, notificationDeliveryReceiptV3Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV10, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestMaximumUtf8BytesV4, notificationDeliveryRequestMaximumUtf8BytesV5, notificationDeliveryRequestMaximumUtf8BytesV9, notificationDeliveryRequestSchema, notificationDeliveryRequestV10Schema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, notificationDeliveryRequestV4Schema, notificationDeliveryRequestV5Schema, notificationDeliveryRequestV6Schema, notificationDeliveryRequestV7Schema, notificationDeliveryRequestV8Schema, notificationDeliveryRequestV9Schema, notificationDeliveryStatesV1, notificationDeliveryStatesV2, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationDestinationStatesV2, notificationGetReceiptResultV1Schema, notificationGetReceiptResultV2Schema, notificationMessageReceiptSchema, notificationMessageVariantKeys, notificationQuoteRangeSchema, notificationRouteKeys, notificationValidationIssueCodesV1, safeDeliveryCauseSchema };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{z as e}from"zod";const t=e.strictObject({eventId:e.uuid(),deliverBy:e.iso.datetime(),locale:e.string().min(1).max(35),contentLocale:e.string().min(1).max(35),title:e.string().trim().min(1).max(512),body:e.string(),url:e.url().refine(e=>new URL(e).protocol===`https:`,`notification_https_target_required`)}),n=1,r=2,i=3,a=4,o=5,s=7,ee=8,te=9,ne=20,c=32*1024,l=1380*60*1e3,u=c,d=l,f=c,re=l,p=c,ie=l,m=c,ae=64*1024,h=l,oe=1,g=32*1024,_=10080*60*1e3,v=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],y=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],b=[...v,`unconfirmed`],x=[...y,`delivery_unconfirmed`],S=[`pending`,`delivering`,`delivered`,`failed`,`expired`],se=[...S,`unconfirmed`],ce=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],le=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],ue=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],de=[`source`,`zh-CN`],C=[`qq`,`tg`,`wechat`,`lark`],fe=new TextEncoder,w=/^[a-z][a-z0-9-]{0,62}$/,pe=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,me=/^[A-Z0-9][\w.:-]{0,127}$/i;function he(e){return[...e].length}function T(t){return e.string().refine(e=>he(e)>0,{message:`too_small`}).refine(e=>he(e)<=t,{message:`too_big`})}const E=e.string().datetime({offset:!0}),D=e.object({key:e.string().regex(w),environment:e.string().regex(w)}).strict(),O=e.object({type:e.string().regex(w),id:e.string().regex(me),revision:e.number().int().positive()}).strict(),k=e.string().min(1).max(127).regex(pe),A=e.object({label:T(48),url:T(2048).refine(e=>[...e].every(e=>{let t=e.codePointAt(0);return t!==void 0&&t>31&&t!==127}),{message:`invalid_https_url`}).refine(e=>{try{return new URL(e).protocol===`https:`}catch{return!1}},{message:`invalid_https_url`})}).strict(),j={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:D,routeKey:k,occurredAt:E,requestedAt:E,deliverBy:E,subject:O},ge=e.object({contractVersion:e.literal(1),...j,message:e.object({type:e.literal(`link_summary`),title:T(160),summary:T(1200),facts:e.array(e.object({label:T(48),value:T(500)}).strict()).max(10),primaryLink:A,sourceLink:A.optional()}).strict()}).strict();function M(e,t,n,r){let i=Date.parse(e.requestedAt),a=Date.parse(e.deliverBy);(!Number.isFinite(i)||!Number.isFinite(a)||a<=i||a-i>n)&&t.addIssue({code:`custom`,message:`delivery_deadline_invalid`,path:[`deliverBy`]}),fe.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const N=ge.superRefine((e,t)=>M(e,t,l,c)),P={title:T(160),summary:T(1200),facts:e.array(e.object({label:T(48),value:T(500)}).strict()).max(10)},_e=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...P}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...P}).strict()]),ve=e.array(_e).min(1).max(2).superRefine((e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`})}),F=e.object({contractVersion:e.literal(2),...j,message:e.object({type:e.literal(`localized_link_summary`),variants:ve,primaryLink:A,sourceLink:A.optional()}).strict()}).strict().superRefine((e,t)=>M(e,t,d,u)),ye=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(w),type:e.literal(`text`),label:T(48).optional(),value:T(4e3)}).strict(),e.object({key:e.string().regex(w),type:e.literal(`fields`),items:e.array(e.object({label:T(48),value:T(1200)}).strict()).min(1).max(20)}).strict()]),I=e.array(ye).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),L=I.min(1),R=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:T(160),sections:L}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:T(160),sections:L}).strict()]),z=(e,t,n=!1)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`});let r=e.find(e=>e.key===`source`),i=e.find(e=>e.key===`zh-CN`);if(r&&i){let a=new Set(r.sections.map(e=>e.key)),o=new Set(i.sections.map(e=>e.key)),s=r.sections.filter(e=>!n||e.type!==`text`||o.has(e.key)).map(e=>`${e.key}:${e.type}`),ee=i.sections.filter(e=>!n||e.type!==`text`||a.has(e.key)).map(e=>`${e.key}:${e.type}`);JSON.stringify(s)!==JSON.stringify(ee)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(i),`sections`]})}},be=e.array(R).min(1).max(2).superRefine(z),B=e.object({contractVersion:e.literal(3),...j,message:e.object({type:e.literal(`structured_notification`),variants:be,links:e.array(e.object({key:e.string().regex(w),...A.shape}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_duplicate`})})}).strict()}).strict(),xe=B.superRefine((e,t)=>M(e,t,re,f)),Se=e.object({label:T(48).optional(),value:T(p)}).strict(),Ce=e.discriminatedUnion(`key`,[R.options[0].extend({body:Se}),R.options[1].extend({body:Se})]),we=B.extend({contractVersion:e.literal(4),message:B.shape.message.extend({variants:e.array(Ce).min(1).max(2).superRefine(z)})}).superRefine((e,t)=>M(e,t,ie,p)),V=e.discriminatedUnion(`key`,[R.options[0].extend({bodyLabel:T(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(w),label:T(48)}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_label_duplicate`})})}),R.options[1].extend({bodyLabel:T(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(w),label:T(48)}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_label_duplicate`})})})]),Te=e.object({value:T(m)}).strict(),H=e.object({contractVersion:e.literal(5),...j,message:e.object({type:e.literal(`structured_notification`),variants:e.array(V).min(1).max(2).superRefine(z),links:e.array(e.object({key:e.string().regex(w),url:A.shape.url}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_duplicate`})}),body:Te}).strict()}).strict().superRefine((e,t)=>{M(e,t,h,m);let n=e.message.links.map(e=>e.key);for(let[r,i]of e.message.variants.entries()){let e=i.linkLabels.map(e=>e.key);JSON.stringify(e)!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,path:[`message`,`variants`,r,`linkLabels`]})}}),U=e.object({...H.shape,contractVersion:e.literal(6),message:H.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(w),value:T(m)}).strict()).max(2),variants:e.array(e.discriminatedUnion(`key`,[V.options[0].omit({bodyLabel:!0}).extend({sections:I,bodyRefs:e.array(e.object({key:e.string().regex(w),label:T(48).optional()}).strict()).max(2),footer:T(500).optional()}),V.options[1].omit({bodyLabel:!0}).extend({sections:I,bodyRefs:e.array(e.object({key:e.string().regex(w),label:T(48).optional()}).strict()).max(2),footer:T(500).optional()})])).min(1).max(2).superRefine((e,t)=>z(e,t,!0))})}).strict().superRefine(W);function W(e,t){M(e,t,h,m);let n=e.message.bodies.map(e=>e.key),r=e.message.links.map(e=>e.key);new Set(n).size!==n.length&&t.addIssue({code:`custom`,message:`message_body_duplicate`}),Ee(e.message.variants,n,r,t)}function Ee(e,t,n,r,i){for(let[a,o]of e.entries()){let e=o.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!t.includes(e)))&&r.addIssue({code:`custom`,message:`message_body_reference_invalid`,...i?{path:[...i,a,`bodyRefs`]}:{}}),JSON.stringify(o.linkLabels.map(e=>e.key))!==JSON.stringify(n)&&r.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,...i?{path:[...i,a,`linkLabels`]}:{}})}}const De=e.array(k).min(1).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`route_key_duplicate`})}),{routeKey:Oe,...ke}=U.shape,G=U.shape.message,K=e.object({...ke,contractVersion:e.literal(7),routeKeys:De,message:G}).strict().superRefine(W),q=e.object({...K.shape,contractVersion:e.literal(8),message:G.extend({channelVariants:e.partialRecord(e.enum(C),G.shape.variants).optional()})}).strict().superRefine((e,t)=>{W(e,t);let n=e.message.variants.map(e=>`${e.key}:${e.locale}`).sort(),r=e.message.bodies.map(e=>e.key),i=e.message.links.map(e=>e.key);for(let a of C){let o=e.message.channelVariants?.[a];if(!o)continue;let s=[`message`,`channelVariants`,a];JSON.stringify(o.map(e=>`${e.key}:${e.locale}`).sort())!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_channel_variant_languages_mismatch`,path:s}),Ee(o,r,i,t,s)}}),Ae=e.object({locale:T(35),contentLocale:T(35),title:T(160).refine(e=>e.trim().length>0,`browser_message_title_blank`),body:e.string().max(8192),url:A.shape.url}).strict(),je=e.object({...q.shape,contractVersion:e.literal(9),audience:e.object({topics:e.array(T(128)).min(1).max(2).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`audience_topic_duplicate`})})}).strict().optional(),browserMessages:e.array(Ae).min(1).max(5).superRefine((e,t)=>{new Set(e.map(e=>e.locale)).size!==e.length&&t.addIssue({code:`custom`,message:`browser_message_locale_duplicate`})}).optional()}).strict().superRefine((e,t)=>{let{audience:n,browserMessages:r,...i}=e,a=q.safeParse({...i,contractVersion:8});if(a.success)M(e,t,h,ae);else for(let e of a.error.issues)t.addIssue({...e});r!==void 0&&n===void 0&&t.addIssue({code:`custom`,message:`browser_message_audience_missing`,path:[`audience`]})});function Me(e){return`routeKeys`in e?[...e.routeKeys].sort():[e.routeKey]}const Ne=e.object({type:e.literal(`creator.draft.v1`),templateId:e.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),signalType:e.string().regex(/^[a-z][a-z0-9_]*$/),sourceTextZh:T(g),sourceUrl:A.shape.url.optional()}).strict(),Pe=e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:D,routeKey:k,occurredAt:E,requestedAt:E,deliverBy:E,subject:O.extend({type:e.literal(`creator-event`)}),task:Ne}).strict().superRefine((e,t)=>M(e,t,_,g)),Fe=Pe,Ie=e.union([N,F,xe,we,H,U,K,q,je]),Le=e.object({destinationKey:e.string().min(1),state:e.enum(S),attempts:e.number().int().min(0).max(4),failureCode:e.enum(ce).nullable(),lastAttemptAt:E.nullable(),nextAttemptAt:E.nullable(),leaseExpiresAt:E.nullable()}).strict(),J=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:D,routeKey:k,subject:O,state:e.enum(v),reason:e.enum(y),terminal:e.boolean(),acceptedAt:E,updatedAt:E,deliverBy:E,terminalAt:E.nullable(),destinations:e.array(Le).min(1).max(20)}).strict(),Y=e.object({name:e.string().min(1).max(100),message:e.string().max(500).optional(),code:e.union([e.string().max(100),e.number()]).optional(),status:e.union([e.string().max(100),e.number()]).optional()}).strict(),X=Y.extend({cause:Y.extend({cause:Y.extend({cause:Y.optional()}).optional()}).optional()}),Re=Le.extend({state:e.enum(se),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:X.nullable(),unconfirmedAt:E.nullable()}),Z=J.extend({contractVersion:e.literal(2),state:e.enum(b),reason:e.enum(x),revision:e.number().int().min(0),destinations:e.array(Re).min(1).max(20)}),ze=Z.omit({routeKey:!0}).extend({contractVersion:e.literal(3),routeKeys:De}),Q=e.union([J,Z,ze]),Be=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(ue)}).strict(),Ve=e.object({code:e.literal(`invalid_request`),issues:e.array(Be).max(20).optional()}).strict(),He=e.object({code:e.enum(le.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([Ve,He]),Ue=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:J}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),We=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:J}).strict(),e.object({status:e.literal(`not_found`)}).strict(),e.object({status:e.literal(`unavailable`),error:e.object({code:e.literal(`receipt_unavailable`)}).strict()}).strict()]),Ge=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),Ke=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:Q}).strict(),e.object({status:e.literal(`not_found`)}).strict(),e.object({status:e.literal(`unavailable`),error:e.object({code:e.literal(`receipt_unavailable`)}).strict()}).strict()]);export{oe as localTaskDeliveryContractVersionV1,_ as localTaskDeliveryMaximumDeadlineMillisecondsV1,g as localTaskDeliveryRequestMaximumUtf8BytesV1,Fe as localTaskDeliveryRequestSchema,Pe as localTaskDeliveryRequestV1Schema,Ae as notificationBrowserMessageSchema,t as notificationBrowserPayloadSchema,Ue as notificationDeliverResultV1Schema,Ge as notificationDeliverResultV2Schema,C as notificationDeliveryChannelKeys,n as notificationDeliveryContractVersionV1,r as notificationDeliveryContractVersionV2,i as notificationDeliveryContractVersionV3,a as notificationDeliveryContractVersionV4,o as notificationDeliveryContractVersionV5,s as notificationDeliveryContractVersionV7,ee as notificationDeliveryContractVersionV8,te as notificationDeliveryContractVersionV9,l as notificationDeliveryMaximumDeadlineMillisecondsV1,d as notificationDeliveryMaximumDeadlineMillisecondsV2,re as notificationDeliveryMaximumDeadlineMillisecondsV3,ie as notificationDeliveryMaximumDeadlineMillisecondsV4,h as notificationDeliveryMaximumDeadlineMillisecondsV5,ne as notificationDeliveryMaximumDestinationsV1,y as notificationDeliveryReasonsV1,x as notificationDeliveryReasonsV2,J as notificationDeliveryReceiptV1Schema,Z as notificationDeliveryReceiptV2Schema,ze as notificationDeliveryReceiptV3Schema,le as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,c as notificationDeliveryRequestMaximumUtf8BytesV1,u as notificationDeliveryRequestMaximumUtf8BytesV2,f as notificationDeliveryRequestMaximumUtf8BytesV3,p as notificationDeliveryRequestMaximumUtf8BytesV4,m as notificationDeliveryRequestMaximumUtf8BytesV5,ae as notificationDeliveryRequestMaximumUtf8BytesV9,Ie as notificationDeliveryRequestSchema,N as notificationDeliveryRequestV1Schema,F as notificationDeliveryRequestV2Schema,xe as notificationDeliveryRequestV3Schema,we as notificationDeliveryRequestV4Schema,H as notificationDeliveryRequestV5Schema,U as notificationDeliveryRequestV6Schema,K as notificationDeliveryRequestV7Schema,q as notificationDeliveryRequestV8Schema,je as notificationDeliveryRequestV9Schema,v as notificationDeliveryStatesV1,b as notificationDeliveryStatesV2,ce as notificationDestinationFailureCodesV1,S as notificationDestinationStatesV1,se as notificationDestinationStatesV2,We as notificationGetReceiptResultV1Schema,Ke as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,de as notificationMessageVariantKeys,Me as notificationRouteKeys,ue as notificationValidationIssueCodesV1,X as safeDeliveryCauseSchema};
1
+ import{z as e}from"zod";const t=e.strictObject({eventId:e.uuid(),deliverBy:e.iso.datetime(),locale:e.string().min(1).max(35),contentLocale:e.string().min(1).max(35),title:e.string().trim().min(1).max(512),body:e.string(),url:e.url().refine(e=>new URL(e).protocol===`https:`,`notification_https_target_required`)}),n=1,r=2,i=3,a=4,o=5,s=7,ee=8,te=9,ne=10,re=20,c=32*1024,l=1380*60*1e3,ie=c,u=l,ae=c,oe=l,d=c,se=l,f=c,p=64*1024,ce=p,m=l,le=1,h=32*1024,ue=10080*60*1e3,g=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],_=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],de=[...g,`unconfirmed`],fe=[..._,`delivery_unconfirmed`],v=[`pending`,`delivering`,`delivered`,`failed`,`expired`],pe=[...v,`unconfirmed`],y=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],b=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],me=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],he=[`source`,`zh-CN`],x=[`qq`,`tg`,`wechat`,`lark`],ge=new TextEncoder,S=/^[a-z][a-z0-9-]{0,62}$/,_e=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,ve=/^[A-Z0-9][\w.:-]{0,127}$/i;function ye(e){return[...e].length}function C(t){return e.string().refine(e=>ye(e)>0,{message:`too_small`}).refine(e=>ye(e)<=t,{message:`too_big`})}const w=e.string().datetime({offset:!0}),T=e.object({key:e.string().regex(S),environment:e.string().regex(S)}).strict(),E=e.object({type:e.string().regex(S),id:e.string().regex(ve),revision:e.number().int().positive()}).strict(),D=e.string().min(1).max(127).regex(_e),O=e.object({label:C(48),url:C(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(),k={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:T,routeKey:D,occurredAt:w,requestedAt:w,deliverBy:w,subject:E},be=e.object({contractVersion:e.literal(1),...k,message:e.object({type:e.literal(`link_summary`),title:C(160),summary:C(1200),facts:e.array(e.object({label:C(48),value:C(500)}).strict()).max(10),primaryLink:O,sourceLink:O.optional()}).strict()}).strict();function A(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`]}),ge.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const xe=be.superRefine((e,t)=>A(e,t,l,c)),Se={title:C(160),summary:C(1200),facts:e.array(e.object({label:C(48),value:C(500)}).strict()).max(10)},Ce=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...Se}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...Se}).strict()]),we=e.array(Ce).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`})}),Te=e.object({contractVersion:e.literal(2),...k,message:e.object({type:e.literal(`localized_link_summary`),variants:we,primaryLink:O,sourceLink:O.optional()}).strict()}).strict().superRefine((e,t)=>A(e,t,u,ie)),j=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(S),type:e.literal(`text`),label:C(48).optional(),value:C(4e3)}).strict(),e.object({key:e.string().regex(S),type:e.literal(`fields`),items:e.array(e.object({label:C(48),value:C(1200)}).strict()).min(1).max(20)}).strict()]),M=e.array(j).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),N=M.min(1),P=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:C(160),sections:N}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:C(160),sections:N}).strict()]),F=(e,t,n=!1)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`});let r=e.find(e=>e.key===`source`),i=e.find(e=>e.key===`zh-CN`);if(r&&i){let a=new Set(r.sections.map(e=>e.key)),o=new Set(i.sections.map(e=>e.key)),s=r.sections.filter(e=>!n||e.type!==`text`||o.has(e.key)).map(e=>`${e.key}:${e.type}`),ee=i.sections.filter(e=>!n||e.type!==`text`||a.has(e.key)).map(e=>`${e.key}:${e.type}`);JSON.stringify(s)!==JSON.stringify(ee)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(i),`sections`]})}},Ee=e.array(P).min(1).max(2).superRefine(F),I=e.object({contractVersion:e.literal(3),...k,message:e.object({type:e.literal(`structured_notification`),variants:Ee,links:e.array(e.object({key:e.string().regex(S),...O.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(),L=I.superRefine((e,t)=>A(e,t,oe,ae)),De=e.object({label:C(48).optional(),value:C(d)}).strict(),Oe=e.discriminatedUnion(`key`,[P.options[0].extend({body:De}),P.options[1].extend({body:De})]),R=I.extend({contractVersion:e.literal(4),message:I.shape.message.extend({variants:e.array(Oe).min(1).max(2).superRefine(F)})}).superRefine((e,t)=>A(e,t,se,d)),z=e.discriminatedUnion(`key`,[P.options[0].extend({bodyLabel:C(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(S),label:C(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`})})}),P.options[1].extend({bodyLabel:C(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(S),label:C(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`})})})]),ke=e.object({value:C(f)}).strict(),B=e.object({contractVersion:e.literal(5),...k,message:e.object({type:e.literal(`structured_notification`),variants:e.array(z).min(1).max(2).superRefine(F),links:e.array(e.object({key:e.string().regex(S),url:O.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:ke}).strict()}).strict().superRefine((e,t)=>{A(e,t,m,f);let n=e.message.links.map(e=>e.key);for(let[r,i]of e.message.variants.entries()){let e=i.linkLabels.map(e=>e.key);JSON.stringify(e)!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,path:[`message`,`variants`,r,`linkLabels`]})}}),V=e.object({...B.shape,contractVersion:e.literal(6),message:B.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(S),value:C(f)}).strict()).max(2),variants:e.array(e.discriminatedUnion(`key`,[z.options[0].omit({bodyLabel:!0}).extend({sections:M,bodyRefs:e.array(e.object({key:e.string().regex(S),label:C(48).optional()}).strict()).max(2),footer:C(500).optional()}),z.options[1].omit({bodyLabel:!0}).extend({sections:M,bodyRefs:e.array(e.object({key:e.string().regex(S),label:C(48).optional()}).strict()).max(2),footer:C(500).optional()})])).min(1).max(2).superRefine((e,t)=>F(e,t,!0))})}).strict().superRefine(H);function H(e,t){A(e,t,m,f);let n=e.message.bodies.map(e=>e.key),r=e.message.links.map(e=>e.key);new Set(n).size!==n.length&&t.addIssue({code:`custom`,message:`message_body_duplicate`}),Ae(e.message.variants,n,r,t)}function Ae(e,t,n,r,i){for(let[a,o]of e.entries()){let e=o.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!t.includes(e)))&&r.addIssue({code:`custom`,message:`message_body_reference_invalid`,...i?{path:[...i,a,`bodyRefs`]}:{}}),JSON.stringify(o.linkLabels.map(e=>e.key))!==JSON.stringify(n)&&r.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,...i?{path:[...i,a,`linkLabels`]}:{}})}}const je=e.array(D).min(1).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`route_key_duplicate`})}),{routeKey:Me,...Ne}=V.shape,U=V.shape.message,W=e.object({...Ne,contractVersion:e.literal(7),routeKeys:je,message:U}).strict().superRefine(H),G=e.object({...W.shape,contractVersion:e.literal(8),message:U.extend({channelVariants:e.partialRecord(e.enum(x),U.shape.variants).optional()})}).strict().superRefine((e,t)=>{H(e,t);let n=e.message.variants.map(e=>`${e.key}:${e.locale}`).sort(),r=e.message.bodies.map(e=>e.key),i=e.message.links.map(e=>e.key);for(let a of x){let o=e.message.channelVariants?.[a];if(!o)continue;let s=[`message`,`channelVariants`,a];JSON.stringify(o.map(e=>`${e.key}:${e.locale}`).sort())!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_channel_variant_languages_mismatch`,path:s}),Ae(o,r,i,t,s)}}),Pe=e.object({locale:C(35),contentLocale:C(35),title:C(160).refine(e=>e.trim().length>0,`browser_message_title_blank`),body:e.string().max(8192),url:O.shape.url}).strict(),K=e.object({...G.shape,contractVersion:e.literal(9),audience:e.object({topics:e.array(C(128)).min(1).max(2).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`audience_topic_duplicate`})})}).strict().optional(),browserMessages:e.array(Pe).min(1).max(5).superRefine((e,t)=>{new Set(e.map(e=>e.locale)).size!==e.length&&t.addIssue({code:`custom`,message:`browser_message_locale_duplicate`})}).optional()}).strict().superRefine((e,t)=>{let{audience:n,browserMessages:r,...i}=e,a=G.safeParse({...i,contractVersion:8});if(a.success)A(e,t,m,p);else for(let e of a.error.issues)t.addIssue({...e});r!==void 0&&n===void 0&&t.addIssue({code:`custom`,message:`browser_message_audience_missing`,path:[`audience`]})}),q=e.object({offset:e.number().int().nonnegative(),length:e.number().int().positive()}).strict();function J(e,t,n,r){let i=t?.map((e,t)=>({...e,index:t})).sort((e,t)=>e.offset-t.offset)??[],a=t=>!(t>0&&t<e.length&&/[\uD800-\uDBFF]/u.test(e.charAt(t-1))&&/[\uDC00-\uDFFF]/u.test(e.charAt(t))),o=0;for(let t of i){let i=t.offset+t.length;i>e.length?n.addIssue({code:`custom`,message:`quote_range_out_of_bounds`,path:[...r,t.index]}):(!a(t.offset)||!a(i))&&n.addIssue({code:`custom`,message:`quote_range_splits_code_point`,path:[...r,t.index]}),t.offset<o&&n.addIssue({code:`custom`,message:`quote_range_overlap`,path:[...r,t.index]}),o=Math.max(o,i)}}const Fe=j.options[0].extend({quotes:e.array(q).optional()}).superRefine((e,t)=>J(e.value,e.quotes,t,[`quotes`])),Ie=e.discriminatedUnion(`type`,[Fe,j.options[1]]),Le=e.array(Ie).max(30),Re={titleQuotes:e.array(q).optional(),sections:Le},ze=e.array(e.discriminatedUnion(`key`,[U.shape.variants.element.options[0].extend(Re),U.shape.variants.element.options[1].extend(Re)])).min(1).max(2).superRefine((e,t)=>{for(let[n,r]of e.entries())J(r.title,r.titleQuotes,t,[n,`titleQuotes`])}),Be=G.shape.message.extend({bodies:e.array(U.shape.bodies.element.extend({quotes:e.array(q).optional()}).superRefine((e,t)=>J(e.value,e.quotes,t,[`quotes`]))).max(2),variants:ze,channelVariants:e.partialRecord(e.enum(x),ze).optional()});function Ve(e){let{titleQuotes:t,...n}=e;return{...n,sections:n.sections.map(e=>{if(e.type!==`text`)return e;let{quotes:t,...n}=e;return n})}}const He=e.object({...K.shape,contractVersion:e.literal(10),message:Be}).strict().superRefine((e,t)=>{let n=K.safeParse({...e,contractVersion:9,message:{...e.message,bodies:e.message.bodies.map(({quotes:e,...t})=>t),variants:e.message.variants.map(Ve),...e.message.channelVariants===void 0?{}:{channelVariants:Object.fromEntries(Object.entries(e.message.channelVariants).map(([e,t])=>[e,t.map(Ve)]))}}});if(!n.success){for(let e of n.error.issues)t.addIssue({...e});return}let{audience:r,browserMessages:i,...a}=e;A(a,t,m,f),A(e,t,m,ce)});function Ue(e){return`routeKeys`in e?[...e.routeKeys].sort():[e.routeKey]}const We=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:C(h),sourceUrl:O.shape.url.optional()}).strict(),Ge=e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:T,routeKey:D,occurredAt:w,requestedAt:w,deliverBy:w,subject:E.extend({type:e.literal(`creator-event`)}),task:We}).strict().superRefine((e,t)=>A(e,t,ue,h)),Ke=Ge,qe=e.union([xe,Te,L,R,B,V,W,G,K,He]),Je=e.object({destinationKey:e.string().min(1),state:e.enum(v),attempts:e.number().int().min(0).max(4),failureCode:e.enum(y).nullable(),lastAttemptAt:w.nullable(),nextAttemptAt:w.nullable(),leaseExpiresAt:w.nullable()}).strict(),Y=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:T,routeKey:D,subject:E,state:e.enum(g),reason:e.enum(_),terminal:e.boolean(),acceptedAt:w,updatedAt:w,deliverBy:w,terminalAt:w.nullable(),destinations:e.array(Je).min(1).max(20)}).strict(),X=e.object({name:e.string().min(1).max(100),message:e.string().max(500).optional(),code:e.union([e.string().max(100),e.number()]).optional(),status:e.union([e.string().max(100),e.number()]).optional()}).strict(),Ye=X.extend({cause:X.extend({cause:X.extend({cause:X.optional()}).optional()}).optional()}),Xe=Je.extend({state:e.enum(pe),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:Ye.nullable(),unconfirmedAt:w.nullable()}),Z=Y.extend({contractVersion:e.literal(2),state:e.enum(de),reason:e.enum(fe),revision:e.number().int().min(0),destinations:e.array(Xe).min(1).max(20)}),Ze=Z.omit({routeKey:!0}).extend({contractVersion:e.literal(3),routeKeys:je}),Q=e.union([Y,Z,Ze]),Qe=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(me)}).strict(),$e=e.object({code:e.literal(`invalid_request`),issues:e.array(Qe).max(20).optional()}).strict(),et=e.object({code:e.enum(b.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([$e,et]),tt=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Y}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),nt=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:Y}).strict(),e.object({status:e.literal(`not_found`)}).strict(),e.object({status:e.literal(`unavailable`),error:e.object({code:e.literal(`receipt_unavailable`)}).strict()}).strict()]),rt=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),it=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:Q}).strict(),e.object({status:e.literal(`not_found`)}).strict(),e.object({status:e.literal(`unavailable`),error:e.object({code:e.literal(`receipt_unavailable`)}).strict()}).strict()]);export{le as localTaskDeliveryContractVersionV1,ue as localTaskDeliveryMaximumDeadlineMillisecondsV1,h as localTaskDeliveryRequestMaximumUtf8BytesV1,Ke as localTaskDeliveryRequestSchema,Ge as localTaskDeliveryRequestV1Schema,Pe as notificationBrowserMessageSchema,t as notificationBrowserPayloadSchema,tt as notificationDeliverResultV1Schema,rt as notificationDeliverResultV2Schema,x as notificationDeliveryChannelKeys,n as notificationDeliveryContractVersionV1,ne as notificationDeliveryContractVersionV10,r as notificationDeliveryContractVersionV2,i as notificationDeliveryContractVersionV3,a as notificationDeliveryContractVersionV4,o as notificationDeliveryContractVersionV5,s as notificationDeliveryContractVersionV7,ee as notificationDeliveryContractVersionV8,te as notificationDeliveryContractVersionV9,l as notificationDeliveryMaximumDeadlineMillisecondsV1,u as notificationDeliveryMaximumDeadlineMillisecondsV2,oe as notificationDeliveryMaximumDeadlineMillisecondsV3,se as notificationDeliveryMaximumDeadlineMillisecondsV4,m as notificationDeliveryMaximumDeadlineMillisecondsV5,re as notificationDeliveryMaximumDestinationsV1,_ as notificationDeliveryReasonsV1,fe as notificationDeliveryReasonsV2,Y as notificationDeliveryReceiptV1Schema,Z as notificationDeliveryReceiptV2Schema,Ze as notificationDeliveryReceiptV3Schema,b as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,c as notificationDeliveryRequestMaximumUtf8BytesV1,ce as notificationDeliveryRequestMaximumUtf8BytesV10,ie as notificationDeliveryRequestMaximumUtf8BytesV2,ae as notificationDeliveryRequestMaximumUtf8BytesV3,d as notificationDeliveryRequestMaximumUtf8BytesV4,f as notificationDeliveryRequestMaximumUtf8BytesV5,p as notificationDeliveryRequestMaximumUtf8BytesV9,qe as notificationDeliveryRequestSchema,He as notificationDeliveryRequestV10Schema,xe as notificationDeliveryRequestV1Schema,Te as notificationDeliveryRequestV2Schema,L as notificationDeliveryRequestV3Schema,R as notificationDeliveryRequestV4Schema,B as notificationDeliveryRequestV5Schema,V as notificationDeliveryRequestV6Schema,W as notificationDeliveryRequestV7Schema,G as notificationDeliveryRequestV8Schema,K as notificationDeliveryRequestV9Schema,g as notificationDeliveryStatesV1,de as notificationDeliveryStatesV2,y as notificationDestinationFailureCodesV1,v as notificationDestinationStatesV1,pe as notificationDestinationStatesV2,nt as notificationGetReceiptResultV1Schema,it as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,he as notificationMessageVariantKeys,q as notificationQuoteRangeSchema,Ue as notificationRouteKeys,me as notificationValidationIssueCodesV1,Ye as safeDeliveryCauseSchema};
package/dist/render.d.ts CHANGED
@@ -3,19 +3,6 @@ import { z } from "zod";
3
3
  declare const notificationMessageVariantKeys: readonly ["source", "zh-CN"];
4
4
  declare const notificationDeliveryChannelKeys: readonly ["qq", "tg", "wechat", "lark"];
5
5
  type NotificationDeliveryChannelKey = (typeof notificationDeliveryChannelKeys)[number];
6
- declare const structuredMessageSectionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7
- key: z.ZodString;
8
- type: z.ZodLiteral<"text">;
9
- label: z.ZodOptional<z.ZodString>;
10
- value: z.ZodString;
11
- }, z.core.$strict>, z.ZodObject<{
12
- key: z.ZodString;
13
- type: z.ZodLiteral<"fields">;
14
- items: z.ZodArray<z.ZodObject<{
15
- label: z.ZodString;
16
- value: z.ZodString;
17
- }, z.core.$strict>>;
18
- }, z.core.$strict>], "type">;
19
6
  declare const notificationMessageBodySchema: z.ZodObject<{
20
7
  label: z.ZodOptional<z.ZodString>;
21
8
  value: z.ZodString;
@@ -480,6 +467,200 @@ declare const notificationDeliveryRequestV9Schema: z.ZodObject<{
480
467
  }, z.core.$strict>;
481
468
  }, z.core.$strict>;
482
469
  type NotificationDeliveryRequestV9 = z.infer<typeof notificationDeliveryRequestV9Schema>;
470
+ /** A quoted interval in its containing string, measured in UTF-16 code units. */
471
+ declare const notificationQuoteRangeSchema: z.ZodObject<{
472
+ offset: z.ZodNumber;
473
+ length: z.ZodNumber;
474
+ }, z.core.$strict>;
475
+ type NotificationQuoteRange = z.infer<typeof notificationQuoteRangeSchema>;
476
+ /** V10 preserves V9 delivery semantics and adds producer-owned quoted text intervals. */
477
+ declare const notificationDeliveryRequestV10Schema: z.ZodObject<{
478
+ contractVersion: z.ZodLiteral<10>;
479
+ message: z.ZodObject<{
480
+ type: z.ZodLiteral<"structured_notification">;
481
+ links: z.ZodArray<z.ZodObject<{
482
+ key: z.ZodString;
483
+ url: z.ZodString;
484
+ }, z.core.$strict>>;
485
+ bodies: z.ZodArray<z.ZodObject<{
486
+ key: z.ZodString;
487
+ value: z.ZodString;
488
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
489
+ offset: z.ZodNumber;
490
+ length: z.ZodNumber;
491
+ }, z.core.$strict>>>;
492
+ }, z.core.$strict>>;
493
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
494
+ key: z.ZodLiteral<"source">;
495
+ locale: z.ZodLiteral<"und">;
496
+ title: z.ZodString;
497
+ linkLabels: z.ZodArray<z.ZodObject<{
498
+ key: z.ZodString;
499
+ label: z.ZodString;
500
+ }, z.core.$strict>>;
501
+ bodyRefs: z.ZodArray<z.ZodObject<{
502
+ key: z.ZodString;
503
+ label: z.ZodOptional<z.ZodString>;
504
+ }, z.core.$strict>>;
505
+ footer: z.ZodOptional<z.ZodString>;
506
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
507
+ offset: z.ZodNumber;
508
+ length: z.ZodNumber;
509
+ }, z.core.$strict>>>;
510
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
511
+ key: z.ZodString;
512
+ type: z.ZodLiteral<"text">;
513
+ label: z.ZodOptional<z.ZodString>;
514
+ value: z.ZodString;
515
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
516
+ offset: z.ZodNumber;
517
+ length: z.ZodNumber;
518
+ }, z.core.$strict>>>;
519
+ }, z.core.$strict>, z.ZodObject<{
520
+ key: z.ZodString;
521
+ type: z.ZodLiteral<"fields">;
522
+ items: z.ZodArray<z.ZodObject<{
523
+ label: z.ZodString;
524
+ value: z.ZodString;
525
+ }, z.core.$strict>>;
526
+ }, z.core.$strict>], "type">>;
527
+ }, z.core.$strict>, z.ZodObject<{
528
+ key: z.ZodLiteral<"zh-CN">;
529
+ locale: z.ZodLiteral<"zh-CN">;
530
+ title: z.ZodString;
531
+ linkLabels: z.ZodArray<z.ZodObject<{
532
+ key: z.ZodString;
533
+ label: z.ZodString;
534
+ }, z.core.$strict>>;
535
+ bodyRefs: z.ZodArray<z.ZodObject<{
536
+ key: z.ZodString;
537
+ label: z.ZodOptional<z.ZodString>;
538
+ }, z.core.$strict>>;
539
+ footer: z.ZodOptional<z.ZodString>;
540
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
541
+ offset: z.ZodNumber;
542
+ length: z.ZodNumber;
543
+ }, z.core.$strict>>>;
544
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
545
+ key: z.ZodString;
546
+ type: z.ZodLiteral<"text">;
547
+ label: z.ZodOptional<z.ZodString>;
548
+ value: z.ZodString;
549
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
550
+ offset: z.ZodNumber;
551
+ length: z.ZodNumber;
552
+ }, z.core.$strict>>>;
553
+ }, z.core.$strict>, z.ZodObject<{
554
+ key: z.ZodString;
555
+ type: z.ZodLiteral<"fields">;
556
+ items: z.ZodArray<z.ZodObject<{
557
+ label: z.ZodString;
558
+ value: z.ZodString;
559
+ }, z.core.$strict>>;
560
+ }, z.core.$strict>], "type">>;
561
+ }, z.core.$strict>], "key">>;
562
+ channelVariants: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
563
+ qq: "qq";
564
+ tg: "tg";
565
+ wechat: "wechat";
566
+ lark: "lark";
567
+ }> & z.core.$partial, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
568
+ key: z.ZodLiteral<"source">;
569
+ locale: z.ZodLiteral<"und">;
570
+ title: z.ZodString;
571
+ linkLabels: z.ZodArray<z.ZodObject<{
572
+ key: z.ZodString;
573
+ label: z.ZodString;
574
+ }, z.core.$strict>>;
575
+ bodyRefs: z.ZodArray<z.ZodObject<{
576
+ key: z.ZodString;
577
+ label: z.ZodOptional<z.ZodString>;
578
+ }, z.core.$strict>>;
579
+ footer: z.ZodOptional<z.ZodString>;
580
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
581
+ offset: z.ZodNumber;
582
+ length: z.ZodNumber;
583
+ }, z.core.$strict>>>;
584
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
585
+ key: z.ZodString;
586
+ type: z.ZodLiteral<"text">;
587
+ label: z.ZodOptional<z.ZodString>;
588
+ value: z.ZodString;
589
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
590
+ offset: z.ZodNumber;
591
+ length: z.ZodNumber;
592
+ }, z.core.$strict>>>;
593
+ }, z.core.$strict>, z.ZodObject<{
594
+ key: z.ZodString;
595
+ type: z.ZodLiteral<"fields">;
596
+ items: z.ZodArray<z.ZodObject<{
597
+ label: z.ZodString;
598
+ value: z.ZodString;
599
+ }, z.core.$strict>>;
600
+ }, z.core.$strict>], "type">>;
601
+ }, z.core.$strict>, z.ZodObject<{
602
+ key: z.ZodLiteral<"zh-CN">;
603
+ locale: z.ZodLiteral<"zh-CN">;
604
+ title: z.ZodString;
605
+ linkLabels: z.ZodArray<z.ZodObject<{
606
+ key: z.ZodString;
607
+ label: z.ZodString;
608
+ }, z.core.$strict>>;
609
+ bodyRefs: z.ZodArray<z.ZodObject<{
610
+ key: z.ZodString;
611
+ label: z.ZodOptional<z.ZodString>;
612
+ }, z.core.$strict>>;
613
+ footer: z.ZodOptional<z.ZodString>;
614
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
615
+ offset: z.ZodNumber;
616
+ length: z.ZodNumber;
617
+ }, z.core.$strict>>>;
618
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
619
+ key: z.ZodString;
620
+ type: z.ZodLiteral<"text">;
621
+ label: z.ZodOptional<z.ZodString>;
622
+ value: z.ZodString;
623
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
624
+ offset: z.ZodNumber;
625
+ length: z.ZodNumber;
626
+ }, z.core.$strict>>>;
627
+ }, z.core.$strict>, z.ZodObject<{
628
+ key: z.ZodString;
629
+ type: z.ZodLiteral<"fields">;
630
+ items: z.ZodArray<z.ZodObject<{
631
+ label: z.ZodString;
632
+ value: z.ZodString;
633
+ }, z.core.$strict>>;
634
+ }, z.core.$strict>], "type">>;
635
+ }, z.core.$strict>], "key">>>>;
636
+ }, z.core.$strict>;
637
+ audience: z.ZodOptional<z.ZodObject<{
638
+ topics: z.ZodArray<z.ZodString>;
639
+ }, z.core.$strict>>;
640
+ browserMessages: z.ZodOptional<z.ZodArray<z.ZodObject<{
641
+ locale: z.ZodString;
642
+ contentLocale: z.ZodString;
643
+ title: z.ZodString;
644
+ body: z.ZodString;
645
+ url: z.ZodString;
646
+ }, z.core.$strict>>>;
647
+ routeKeys: z.ZodArray<z.ZodString>;
648
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
649
+ eventId: z.ZodString;
650
+ producer: z.ZodObject<{
651
+ key: z.ZodString;
652
+ environment: z.ZodString;
653
+ }, z.core.$strict>;
654
+ occurredAt: z.ZodString;
655
+ requestedAt: z.ZodString;
656
+ deliverBy: z.ZodString;
657
+ subject: z.ZodObject<{
658
+ type: z.ZodString;
659
+ id: z.ZodString;
660
+ revision: z.ZodNumber;
661
+ }, z.core.$strict>;
662
+ }, z.core.$strict>;
663
+ type NotificationDeliveryRequestV10 = z.infer<typeof notificationDeliveryRequestV10Schema>;
483
664
  type NotificationDeliveryRequestV6 = z.infer<typeof notificationDeliveryRequestV6Schema>;
484
665
  declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObject<{
485
666
  message: z.ZodObject<{
@@ -1212,10 +1393,194 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
1212
1393
  id: z.ZodString;
1213
1394
  revision: z.ZodNumber;
1214
1395
  }, z.core.$strict>;
1396
+ }, z.core.$strict>, z.ZodObject<{
1397
+ contractVersion: z.ZodLiteral<10>;
1398
+ message: z.ZodObject<{
1399
+ type: z.ZodLiteral<"structured_notification">;
1400
+ links: z.ZodArray<z.ZodObject<{
1401
+ key: z.ZodString;
1402
+ url: z.ZodString;
1403
+ }, z.core.$strict>>;
1404
+ bodies: z.ZodArray<z.ZodObject<{
1405
+ key: z.ZodString;
1406
+ value: z.ZodString;
1407
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1408
+ offset: z.ZodNumber;
1409
+ length: z.ZodNumber;
1410
+ }, z.core.$strict>>>;
1411
+ }, z.core.$strict>>;
1412
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1413
+ key: z.ZodLiteral<"source">;
1414
+ locale: z.ZodLiteral<"und">;
1415
+ title: z.ZodString;
1416
+ linkLabels: z.ZodArray<z.ZodObject<{
1417
+ key: z.ZodString;
1418
+ label: z.ZodString;
1419
+ }, z.core.$strict>>;
1420
+ bodyRefs: z.ZodArray<z.ZodObject<{
1421
+ key: z.ZodString;
1422
+ label: z.ZodOptional<z.ZodString>;
1423
+ }, z.core.$strict>>;
1424
+ footer: z.ZodOptional<z.ZodString>;
1425
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1426
+ offset: z.ZodNumber;
1427
+ length: z.ZodNumber;
1428
+ }, z.core.$strict>>>;
1429
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1430
+ key: z.ZodString;
1431
+ type: z.ZodLiteral<"text">;
1432
+ label: z.ZodOptional<z.ZodString>;
1433
+ value: z.ZodString;
1434
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1435
+ offset: z.ZodNumber;
1436
+ length: z.ZodNumber;
1437
+ }, z.core.$strict>>>;
1438
+ }, z.core.$strict>, z.ZodObject<{
1439
+ key: z.ZodString;
1440
+ type: z.ZodLiteral<"fields">;
1441
+ items: z.ZodArray<z.ZodObject<{
1442
+ label: z.ZodString;
1443
+ value: z.ZodString;
1444
+ }, z.core.$strict>>;
1445
+ }, z.core.$strict>], "type">>;
1446
+ }, z.core.$strict>, z.ZodObject<{
1447
+ key: z.ZodLiteral<"zh-CN">;
1448
+ locale: z.ZodLiteral<"zh-CN">;
1449
+ title: z.ZodString;
1450
+ linkLabels: z.ZodArray<z.ZodObject<{
1451
+ key: z.ZodString;
1452
+ label: z.ZodString;
1453
+ }, z.core.$strict>>;
1454
+ bodyRefs: z.ZodArray<z.ZodObject<{
1455
+ key: z.ZodString;
1456
+ label: z.ZodOptional<z.ZodString>;
1457
+ }, z.core.$strict>>;
1458
+ footer: z.ZodOptional<z.ZodString>;
1459
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1460
+ offset: z.ZodNumber;
1461
+ length: z.ZodNumber;
1462
+ }, z.core.$strict>>>;
1463
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1464
+ key: z.ZodString;
1465
+ type: z.ZodLiteral<"text">;
1466
+ label: z.ZodOptional<z.ZodString>;
1467
+ value: z.ZodString;
1468
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1469
+ offset: z.ZodNumber;
1470
+ length: z.ZodNumber;
1471
+ }, z.core.$strict>>>;
1472
+ }, z.core.$strict>, z.ZodObject<{
1473
+ key: z.ZodString;
1474
+ type: z.ZodLiteral<"fields">;
1475
+ items: z.ZodArray<z.ZodObject<{
1476
+ label: z.ZodString;
1477
+ value: z.ZodString;
1478
+ }, z.core.$strict>>;
1479
+ }, z.core.$strict>], "type">>;
1480
+ }, z.core.$strict>], "key">>;
1481
+ channelVariants: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
1482
+ qq: "qq";
1483
+ tg: "tg";
1484
+ wechat: "wechat";
1485
+ lark: "lark";
1486
+ }> & z.core.$partial, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1487
+ key: z.ZodLiteral<"source">;
1488
+ locale: z.ZodLiteral<"und">;
1489
+ title: z.ZodString;
1490
+ linkLabels: z.ZodArray<z.ZodObject<{
1491
+ key: z.ZodString;
1492
+ label: z.ZodString;
1493
+ }, z.core.$strict>>;
1494
+ bodyRefs: z.ZodArray<z.ZodObject<{
1495
+ key: z.ZodString;
1496
+ label: z.ZodOptional<z.ZodString>;
1497
+ }, z.core.$strict>>;
1498
+ footer: z.ZodOptional<z.ZodString>;
1499
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1500
+ offset: z.ZodNumber;
1501
+ length: z.ZodNumber;
1502
+ }, z.core.$strict>>>;
1503
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1504
+ key: z.ZodString;
1505
+ type: z.ZodLiteral<"text">;
1506
+ label: z.ZodOptional<z.ZodString>;
1507
+ value: z.ZodString;
1508
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1509
+ offset: z.ZodNumber;
1510
+ length: z.ZodNumber;
1511
+ }, z.core.$strict>>>;
1512
+ }, z.core.$strict>, z.ZodObject<{
1513
+ key: z.ZodString;
1514
+ type: z.ZodLiteral<"fields">;
1515
+ items: z.ZodArray<z.ZodObject<{
1516
+ label: z.ZodString;
1517
+ value: z.ZodString;
1518
+ }, z.core.$strict>>;
1519
+ }, z.core.$strict>], "type">>;
1520
+ }, z.core.$strict>, z.ZodObject<{
1521
+ key: z.ZodLiteral<"zh-CN">;
1522
+ locale: z.ZodLiteral<"zh-CN">;
1523
+ title: z.ZodString;
1524
+ linkLabels: z.ZodArray<z.ZodObject<{
1525
+ key: z.ZodString;
1526
+ label: z.ZodString;
1527
+ }, z.core.$strict>>;
1528
+ bodyRefs: z.ZodArray<z.ZodObject<{
1529
+ key: z.ZodString;
1530
+ label: z.ZodOptional<z.ZodString>;
1531
+ }, z.core.$strict>>;
1532
+ footer: z.ZodOptional<z.ZodString>;
1533
+ titleQuotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1534
+ offset: z.ZodNumber;
1535
+ length: z.ZodNumber;
1536
+ }, z.core.$strict>>>;
1537
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1538
+ key: z.ZodString;
1539
+ type: z.ZodLiteral<"text">;
1540
+ label: z.ZodOptional<z.ZodString>;
1541
+ value: z.ZodString;
1542
+ quotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1543
+ offset: z.ZodNumber;
1544
+ length: z.ZodNumber;
1545
+ }, z.core.$strict>>>;
1546
+ }, z.core.$strict>, z.ZodObject<{
1547
+ key: z.ZodString;
1548
+ type: z.ZodLiteral<"fields">;
1549
+ items: z.ZodArray<z.ZodObject<{
1550
+ label: z.ZodString;
1551
+ value: z.ZodString;
1552
+ }, z.core.$strict>>;
1553
+ }, z.core.$strict>], "type">>;
1554
+ }, z.core.$strict>], "key">>>>;
1555
+ }, z.core.$strict>;
1556
+ audience: z.ZodOptional<z.ZodObject<{
1557
+ topics: z.ZodArray<z.ZodString>;
1558
+ }, z.core.$strict>>;
1559
+ browserMessages: z.ZodOptional<z.ZodArray<z.ZodObject<{
1560
+ locale: z.ZodString;
1561
+ contentLocale: z.ZodString;
1562
+ title: z.ZodString;
1563
+ body: z.ZodString;
1564
+ url: z.ZodString;
1565
+ }, z.core.$strict>>>;
1566
+ routeKeys: z.ZodArray<z.ZodString>;
1567
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
1568
+ eventId: z.ZodString;
1569
+ producer: z.ZodObject<{
1570
+ key: z.ZodString;
1571
+ environment: z.ZodString;
1572
+ }, z.core.$strict>;
1573
+ occurredAt: z.ZodString;
1574
+ requestedAt: z.ZodString;
1575
+ deliverBy: z.ZodString;
1576
+ subject: z.ZodObject<{
1577
+ type: z.ZodString;
1578
+ id: z.ZodString;
1579
+ revision: z.ZodNumber;
1580
+ }, z.core.$strict>;
1215
1581
  }, z.core.$strict>]>;
1216
1582
  type NotificationDeliveryRequest = z.infer<typeof notificationDeliveryRequestSchema>;
1217
1583
  type NotificationMessageVariantKey = (typeof notificationMessageVariantKeys)[number];
1218
- type NotificationStructuredMessageSection = z.infer<typeof structuredMessageSectionSchema>;
1219
1584
  type NotificationMessageBody = z.infer<typeof notificationMessageBodySchema>;
1220
1585
  //#endregion
1221
1586
  //#region src/generic-plain-text.d.ts
@@ -1229,6 +1594,12 @@ interface PlainTextOptions {
1229
1594
  /** Destination-owned immutable copy appended to its corresponding language block. */
1230
1595
  variantSuffixes?: Partial<Record<NotificationMessageVariantKey, string>>;
1231
1596
  }
1597
+ interface GenericNotificationAnnotatedText {
1598
+ text: string;
1599
+ quotes: NotificationQuoteRange[];
1600
+ }
1601
+ /** Renders bounded text and producer-owned quote ranges using UTF-16 offsets. */
1602
+ declare function renderGenericNotificationAnnotatedText(input: NotificationDeliveryRequest, maximumCodePoints: number, requestedVariantKeys?: readonly NotificationMessageVariantKey[], options?: PlainTextOptions): GenericNotificationAnnotatedText;
1232
1603
  /** Renders one validated provider-neutral delivery snapshot as bounded plain text. */
1233
1604
  declare function renderGenericNotificationPlainText(input: NotificationDeliveryRequest, maximumCodePoints: number, requestedVariantKeys?: readonly NotificationMessageVariantKey[], options?: PlainTextOptions): string;
1234
1605
  //#endregion
@@ -1238,19 +1609,21 @@ interface GenericNotificationMessageContent {
1238
1609
  locale: 'und' | 'zh-CN';
1239
1610
  sections: GenericNotificationMessageSection[];
1240
1611
  title: string;
1241
- body?: NotificationMessageBody;
1242
- bodies?: NotificationMessageBody[];
1612
+ titleQuotes?: NotificationQuoteRange[];
1613
+ body?: GenericNotificationMessageBody;
1614
+ bodies?: GenericNotificationMessageBody[];
1243
1615
  footer?: string | undefined;
1244
1616
  links?: GenericNotificationMessageLink[];
1245
1617
  }
1246
- type GenericNotificationMessageSection = NotificationStructuredMessageSection;
1618
+ type GenericNotificationMessageSection = NotificationDeliveryRequestV10['message']['variants'][number]['sections'][number];
1619
+ type GenericNotificationMessageBody = NotificationMessageBody & Pick<NotificationDeliveryRequestV10['message']['bodies'][number], 'quotes'>;
1247
1620
  interface GenericNotificationMessageLink {
1248
1621
  key: string;
1249
1622
  label: string;
1250
1623
  url: string;
1251
1624
  }
1252
1625
  /** Selects frozen channel copy; an absent override keeps the request's frozen default copy. */
1253
- declare function resolveGenericNotificationChannelVariants(input: NotificationDeliveryRequestV6 | NotificationDeliveryRequestV7 | NotificationDeliveryRequestV8 | NotificationDeliveryRequestV9, channel?: NotificationDeliveryChannelKey): ({
1626
+ declare function resolveGenericNotificationChannelVariants(input: NotificationDeliveryRequestV6 | NotificationDeliveryRequestV7 | NotificationDeliveryRequestV8 | NotificationDeliveryRequestV9 | NotificationDeliveryRequestV10, channel?: NotificationDeliveryChannelKey): ({
1254
1627
  key: "source";
1255
1628
  locale: "und";
1256
1629
  title: string;
@@ -1302,6 +1675,74 @@ declare function resolveGenericNotificationChannelVariants(input: NotificationDe
1302
1675
  label?: string | undefined;
1303
1676
  }[];
1304
1677
  footer?: string | undefined;
1678
+ })[] | ({
1679
+ key: "source";
1680
+ locale: "und";
1681
+ title: string;
1682
+ linkLabels: {
1683
+ key: string;
1684
+ label: string;
1685
+ }[];
1686
+ bodyRefs: {
1687
+ key: string;
1688
+ label?: string | undefined;
1689
+ }[];
1690
+ sections: ({
1691
+ key: string;
1692
+ type: "fields";
1693
+ items: {
1694
+ label: string;
1695
+ value: string;
1696
+ }[];
1697
+ } | {
1698
+ key: string;
1699
+ type: "text";
1700
+ value: string;
1701
+ label?: string | undefined;
1702
+ quotes?: {
1703
+ offset: number;
1704
+ length: number;
1705
+ }[] | undefined;
1706
+ })[];
1707
+ footer?: string | undefined;
1708
+ titleQuotes?: {
1709
+ offset: number;
1710
+ length: number;
1711
+ }[] | undefined;
1712
+ } | {
1713
+ key: "zh-CN";
1714
+ locale: "zh-CN";
1715
+ title: string;
1716
+ linkLabels: {
1717
+ key: string;
1718
+ label: string;
1719
+ }[];
1720
+ bodyRefs: {
1721
+ key: string;
1722
+ label?: string | undefined;
1723
+ }[];
1724
+ sections: ({
1725
+ key: string;
1726
+ type: "fields";
1727
+ items: {
1728
+ label: string;
1729
+ value: string;
1730
+ }[];
1731
+ } | {
1732
+ key: string;
1733
+ type: "text";
1734
+ value: string;
1735
+ label?: string | undefined;
1736
+ quotes?: {
1737
+ offset: number;
1738
+ length: number;
1739
+ }[] | undefined;
1740
+ })[];
1741
+ footer?: string | undefined;
1742
+ titleQuotes?: {
1743
+ offset: number;
1744
+ length: number;
1745
+ }[] | undefined;
1305
1746
  })[];
1306
1747
  /** Resolves a validated request into the ordered message variants selected by one destination. */
1307
1748
  declare function resolveGenericNotificationMessage(input: NotificationDeliveryRequest, requestedVariantKeys?: readonly NotificationMessageVariantKey[], channel?: NotificationDeliveryChannelKey): {
@@ -1312,4 +1753,4 @@ declare function resolveGenericNotificationMessage(input: NotificationDeliveryRe
1312
1753
  /** Returns the ordered variant identity used by renderer caches. */
1313
1754
  declare function resolveGenericNotificationMessageVariantKeys(input: NotificationDeliveryRequest, requestedVariantKeys?: readonly NotificationMessageVariantKey[], channel?: NotificationDeliveryChannelKey): ("source" | "zh-CN")[];
1314
1755
  //#endregion
1315
- export { type GenericNotificationMessageContent, type GenericNotificationMessageLink, type GenericNotificationMessageSection, GenericNotificationRenderError, type PlainTextOptions, renderGenericNotificationPlainText, resolveGenericNotificationChannelVariants, resolveGenericNotificationMessage, resolveGenericNotificationMessageVariantKeys };
1756
+ export { type GenericNotificationAnnotatedText, type GenericNotificationMessageBody, type GenericNotificationMessageContent, type GenericNotificationMessageLink, type GenericNotificationMessageSection, GenericNotificationRenderError, type PlainTextOptions, renderGenericNotificationAnnotatedText, renderGenericNotificationPlainText, resolveGenericNotificationChannelVariants, resolveGenericNotificationMessage, resolveGenericNotificationMessageVariantKeys };
package/dist/render.js CHANGED
@@ -1,23 +1,24 @@
1
- import{z as e}from"zod";e.strictObject({eventId:e.uuid(),deliverBy:e.iso.datetime(),locale:e.string().min(1).max(35),contentLocale:e.string().min(1).max(35),title:e.string().trim().min(1).max(512),body:e.string(),url:e.url().refine(e=>new URL(e).protocol===`https:`,`notification_https_target_required`)});const t=32*1024,n=1380*60*1e3,r=t,i=t,a=n,o=32*1024,s=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],c=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],l=[...s,`unconfirmed`],u=[...c,`delivery_unconfirmed`],d=[`pending`,`delivering`,`delivered`,`failed`,`expired`],f=[...d,`unconfirmed`],p=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],m=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],h=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],g=[`qq`,`tg`,`wechat`,`lark`],ee=new TextEncoder,_=/^[a-z][a-z0-9-]{0,62}$/,te=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,ne=/^[A-Z0-9][\w.:-]{0,127}$/i;function v(e){return[...e].length}function y(t){return e.string().refine(e=>v(e)>0,{message:`too_small`}).refine(e=>v(e)<=t,{message:`too_big`})}const b=e.string().datetime({offset:!0}),x=e.object({key:e.string().regex(_),environment:e.string().regex(_)}).strict(),S=e.object({type:e.string().regex(_),id:e.string().regex(ne),revision:e.number().int().positive()}).strict(),C=e.string().min(1).max(127).regex(te),w=e.object({label:y(48),url:y(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(),T={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:x,routeKey:C,occurredAt:b,requestedAt:b,deliverBy:b,subject:S},re=e.object({contractVersion:e.literal(1),...T,message:e.object({type:e.literal(`link_summary`),title:y(160),summary:y(1200),facts:e.array(e.object({label:y(48),value:y(500)}).strict()).max(10),primaryLink:w,sourceLink:w.optional()}).strict()}).strict();function E(e,t,n,r){let i=Date.parse(e.requestedAt),a=Date.parse(e.deliverBy);(!Number.isFinite(i)||!Number.isFinite(a)||a<=i||a-i>n)&&t.addIssue({code:`custom`,message:`delivery_deadline_invalid`,path:[`deliverBy`]}),ee.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const ie=re.superRefine((e,r)=>E(e,r,n,t)),D={title:y(160),summary:y(1200),facts:e.array(e.object({label:y(48),value:y(500)}).strict()).max(10)},ae=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...D}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...D}).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`})}),se=e.object({contractVersion:e.literal(2),...T,message:e.object({type:e.literal(`localized_link_summary`),variants:oe,primaryLink:w,sourceLink:w.optional()}).strict()}).strict().superRefine((e,t)=>E(e,t,828e5,32768)),ce=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(_),type:e.literal(`text`),label:y(48).optional(),value:y(4e3)}).strict(),e.object({key:e.string().regex(_),type:e.literal(`fields`),items:e.array(e.object({label:y(48),value:y(1200)}).strict()).min(1).max(20)}).strict()]),O=e.array(ce).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),k=O.min(1),A=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:y(160),sections:k}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:y(160),sections:k}).strict()]),j=(e,t,n=!1)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`});let r=e.find(e=>e.key===`source`),i=e.find(e=>e.key===`zh-CN`);if(r&&i){let a=new Set(r.sections.map(e=>e.key)),o=new Set(i.sections.map(e=>e.key)),s=r.sections.filter(e=>!n||e.type!==`text`||o.has(e.key)).map(e=>`${e.key}:${e.type}`),c=i.sections.filter(e=>!n||e.type!==`text`||a.has(e.key)).map(e=>`${e.key}:${e.type}`);JSON.stringify(s)!==JSON.stringify(c)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(i),`sections`]})}},le=e.array(A).min(1).max(2).superRefine(j),M=e.object({contractVersion:e.literal(3),...T,message:e.object({type:e.literal(`structured_notification`),variants:le,links:e.array(e.object({key:e.string().regex(_),...w.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(),ue=M.superRefine((e,t)=>E(e,t,828e5,32768)),N=e.object({label:y(48).optional(),value:y(r)}).strict(),de=e.discriminatedUnion(`key`,[A.options[0].extend({body:N}),A.options[1].extend({body:N})]),fe=M.extend({contractVersion:e.literal(4),message:M.shape.message.extend({variants:e.array(de).min(1).max(2).superRefine(j)})}).superRefine((e,t)=>E(e,t,828e5,r)),P=e.discriminatedUnion(`key`,[A.options[0].extend({bodyLabel:y(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(_),label:y(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`})})}),A.options[1].extend({bodyLabel:y(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(_),label:y(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:y(i)}).strict(),F=e.object({contractVersion:e.literal(5),...T,message:e.object({type:e.literal(`structured_notification`),variants:e.array(P).min(1).max(2).superRefine(j),links:e.array(e.object({key:e.string().regex(_),url:w.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)=>{E(e,t,a,i);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`]})}}),I=e.object({...F.shape,contractVersion:e.literal(6),message:F.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(_),value:y(i)}).strict()).max(2),variants:e.array(e.discriminatedUnion(`key`,[P.options[0].omit({bodyLabel:!0}).extend({sections:O,bodyRefs:e.array(e.object({key:e.string().regex(_),label:y(48).optional()}).strict()).max(2),footer:y(500).optional()}),P.options[1].omit({bodyLabel:!0}).extend({sections:O,bodyRefs:e.array(e.object({key:e.string().regex(_),label:y(48).optional()}).strict()).max(2),footer:y(500).optional()})])).min(1).max(2).superRefine((e,t)=>j(e,t,!0))})}).strict().superRefine(L);function L(e,t){E(e,t,a,i);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`}),R(e.message.variants,n,r,t)}function R(e,t,n,r,i){for(let[a,o]of e.entries()){let e=o.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!t.includes(e)))&&r.addIssue({code:`custom`,message:`message_body_reference_invalid`,...i?{path:[...i,a,`bodyRefs`]}:{}}),JSON.stringify(o.linkLabels.map(e=>e.key))!==JSON.stringify(n)&&r.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,...i?{path:[...i,a,`linkLabels`]}:{}})}}const z=e.array(C).min(1).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`route_key_duplicate`})}),{routeKey:me,...he}=I.shape,B=I.shape.message,V=e.object({...he,contractVersion:e.literal(7),routeKeys:z,message:B}).strict().superRefine(L),H=e.object({...V.shape,contractVersion:e.literal(8),message:B.extend({channelVariants:e.partialRecord(e.enum(g),B.shape.variants).optional()})}).strict().superRefine((e,t)=>{L(e,t);let n=e.message.variants.map(e=>`${e.key}:${e.locale}`).sort(),r=e.message.bodies.map(e=>e.key),i=e.message.links.map(e=>e.key);for(let a of g){let o=e.message.channelVariants?.[a];if(!o)continue;let s=[`message`,`channelVariants`,a];JSON.stringify(o.map(e=>`${e.key}:${e.locale}`).sort())!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_channel_variant_languages_mismatch`,path:s}),R(o,r,i,t,s)}}),ge=e.object({locale:y(35),contentLocale:y(35),title:y(160).refine(e=>e.trim().length>0,`browser_message_title_blank`),body:e.string().max(8192),url:w.shape.url}).strict(),_e=e.object({...H.shape,contractVersion:e.literal(9),audience:e.object({topics:e.array(y(128)).min(1).max(2).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`audience_topic_duplicate`})})}).strict().optional(),browserMessages:e.array(ge).min(1).max(5).superRefine((e,t)=>{new Set(e.map(e=>e.locale)).size!==e.length&&t.addIssue({code:`custom`,message:`browser_message_locale_duplicate`})}).optional()}).strict().superRefine((e,t)=>{let{audience:n,browserMessages:r,...i}=e,o=H.safeParse({...i,contractVersion:8});if(o.success)E(e,t,a,65536);else for(let e of o.error.issues)t.addIssue({...e});r!==void 0&&n===void 0&&t.addIssue({code:`custom`,message:`browser_message_audience_missing`,path:[`audience`]})}),ve=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:y(o),sourceUrl:w.shape.url.optional()}).strict();e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:x,routeKey:C,occurredAt:b,requestedAt:b,deliverBy:b,subject:S.extend({type:e.literal(`creator-event`)}),task:ve}).strict().superRefine((e,t)=>E(e,t,6048e5,o));const ye=e.union([ie,se,ue,fe,F,I,V,H,_e]),U=e.object({destinationKey:e.string().min(1),state:e.enum(d),attempts:e.number().int().min(0).max(4),failureCode:e.enum(p).nullable(),lastAttemptAt:b.nullable(),nextAttemptAt:b.nullable(),leaseExpiresAt:b.nullable()}).strict(),W=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:x,routeKey:C,subject:S,state:e.enum(s),reason:e.enum(c),terminal:e.boolean(),acceptedAt:b,updatedAt:b,deliverBy:b,terminalAt:b.nullable(),destinations:e.array(U).min(1).max(20)}).strict(),G=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(),be=G.extend({cause:G.extend({cause:G.extend({cause:G.optional()}).optional()}).optional()}),xe=U.extend({state:e.enum(f),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:be.nullable(),unconfirmedAt:b.nullable()}),K=W.extend({contractVersion:e.literal(2),state:e.enum(l),reason:e.enum(u),revision:e.number().int().min(0),destinations:e.array(xe).min(1).max(20)}),Se=K.omit({routeKey:!0}).extend({contractVersion:e.literal(3),routeKeys:z}),q=e.union([W,K,Se]),Ce=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(h)}).strict(),we=e.object({code:e.literal(`invalid_request`),issues:e.array(Ce).max(20).optional()}).strict(),Te=e.object({code:e.enum(m.filter(e=>e!==`invalid_request`))}).strict(),J=e.union([we,Te]);e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:W}).strict(),e.object({status:e.literal(`rejected`),error:J}).strict()]),e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:W}).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()]),e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:q}).strict(),e.object({status:e.literal(`rejected`),error:J}).strict()]),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()]);function Ee(e,t){if((e.contractVersion===8||e.contractVersion===9)&&t!==void 0){let n=e.message.channelVariants?.[t];if(n!==void 0)return n}return e.message.variants}function Y(e,t=[`source`],n){let r=ye.parse(e);return r.contractVersion===6||r.contractVersion===7||r.contractVersion===8||r.contractVersion===9?{links:[],linksPerVariant:!0,variants:X(Ee(r,n).map(e=>({key:e.key,locale:e.locale,title:e.title,sections:e.sections,footer:e.footer,bodies:e.bodyRefs.map(e=>({label:e.label,value:r.message.bodies.find(t=>t.key===e.key).value})),links:r.message.links.map((t,n)=>({...t,label:e.linkLabels[n].label}))})),t)}:r.contractVersion===1?{links:[...r.message.sourceLink?[{key:`source`,...r.message.sourceLink}]:[],{key:`primary`,...r.message.primaryLink}],linksPerVariant:!1,variants:[{key:`source`,locale:`und`,sections:[{key:`summary`,type:`text`,value:r.message.summary},...r.message.facts.length>0?[{key:`facts`,type:`fields`,items:r.message.facts}]:[]],title:r.message.title}]}:r.contractVersion===3||r.contractVersion===4?{links:r.message.links,linksPerVariant:!1,variants:X(r.message.variants,t)}:r.contractVersion===5?{links:[],linksPerVariant:!0,variants:X(r.message.variants.map(e=>({key:e.key,locale:e.locale,sections:e.sections,title:e.title,body:{label:e.bodyLabel,value:r.message.body.value},links:r.message.links.map((t,n)=>({...t,label:e.linkLabels[n].label}))})),t)}:{links:[...r.message.sourceLink?[{key:`source`,...r.message.sourceLink}]:[],{key:`primary`,...r.message.primaryLink}],linksPerVariant:!1,variants:X(r.message.variants.map(e=>({key:e.key,locale:e.locale,sections:[{key:`summary`,type:`text`,value:e.summary},...e.facts.length>0?[{key:`facts`,type:`fields`,items:e.facts}]:[]],title:e.title})),t)}}function X(e,t){let n=new Map(e.map(e=>[e.key,e])),r=[...new Set(t)].flatMap(e=>{let t=n.get(e);return t?[t]:[]});return r.length>0?r:[n.get(`source`)]}function De(e,t=[`source`],n){return Y(e,t,n).variants.map(e=>e.key)}var Z=class extends Error{code=`mandatory_content_too_large`;constructor(){super(`generic_notification_mandatory_content_too_large`),this.name=`GenericNotificationRenderError`}};function Oe(e,t,n=[`source`],r={}){if(!Number.isSafeInteger(t)||t<1)throw Error(`generic_notification_plain_text_limit_invalid`);let i=Y(e,n,r.channel);if(e.contractVersion===6||e.contractVersion===7||e.contractVersion===8||e.contractVersion===9)return je(i.variants,t,r);let a=i.links.map(e=>$(e.label,e.url)),o=a.length>0?`\n\n${a.join(`
1
+ import{z as e}from"zod";e.strictObject({eventId:e.uuid(),deliverBy:e.iso.datetime(),locale:e.string().min(1).max(35),contentLocale:e.string().min(1).max(35),title:e.string().trim().min(1).max(512),body:e.string(),url:e.url().refine(e=>new URL(e).protocol===`https:`,`notification_https_target_required`)});const t=32*1024,n=1380*60*1e3,r=t,i=t,a=n,o=32*1024,s=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],c=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],l=[...s,`unconfirmed`],u=[...c,`delivery_unconfirmed`],d=[`pending`,`delivering`,`delivered`,`failed`,`expired`],f=[...d,`unconfirmed`],p=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],m=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],h=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],g=[`qq`,`tg`,`wechat`,`lark`],ee=new TextEncoder,_=/^[a-z][a-z0-9-]{0,62}$/,te=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,ne=/^[A-Z0-9][\w.:-]{0,127}$/i;function v(e){return[...e].length}function y(t){return e.string().refine(e=>v(e)>0,{message:`too_small`}).refine(e=>v(e)<=t,{message:`too_big`})}const b=e.string().datetime({offset:!0}),x=e.object({key:e.string().regex(_),environment:e.string().regex(_)}).strict(),S=e.object({type:e.string().regex(_),id:e.string().regex(ne),revision:e.number().int().positive()}).strict(),C=e.string().min(1).max(127).regex(te),w=e.object({label:y(48),url:y(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(),T={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:x,routeKey:C,occurredAt:b,requestedAt:b,deliverBy:b,subject:S},re=e.object({contractVersion:e.literal(1),...T,message:e.object({type:e.literal(`link_summary`),title:y(160),summary:y(1200),facts:e.array(e.object({label:y(48),value:y(500)}).strict()).max(10),primaryLink:w,sourceLink:w.optional()}).strict()}).strict();function E(e,t,n,r){let i=Date.parse(e.requestedAt),a=Date.parse(e.deliverBy);(!Number.isFinite(i)||!Number.isFinite(a)||a<=i||a-i>n)&&t.addIssue({code:`custom`,message:`delivery_deadline_invalid`,path:[`deliverBy`]}),ee.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const ie=re.superRefine((e,r)=>E(e,r,n,t)),ae={title:y(160),summary:y(1200),facts:e.array(e.object({label:y(48),value:y(500)}).strict()).max(10)},oe=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...ae}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...ae}).strict()]),se=e.array(oe).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`})}),ce=e.object({contractVersion:e.literal(2),...T,message:e.object({type:e.literal(`localized_link_summary`),variants:se,primaryLink:w,sourceLink:w.optional()}).strict()}).strict().superRefine((e,t)=>E(e,t,828e5,32768)),D=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(_),type:e.literal(`text`),label:y(48).optional(),value:y(4e3)}).strict(),e.object({key:e.string().regex(_),type:e.literal(`fields`),items:e.array(e.object({label:y(48),value:y(1200)}).strict()).min(1).max(20)}).strict()]),O=e.array(D).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),le=O.min(1),k=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:y(160),sections:le}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:y(160),sections:le}).strict()]),A=(e,t,n=!1)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`});let r=e.find(e=>e.key===`source`),i=e.find(e=>e.key===`zh-CN`);if(r&&i){let a=new Set(r.sections.map(e=>e.key)),o=new Set(i.sections.map(e=>e.key)),s=r.sections.filter(e=>!n||e.type!==`text`||o.has(e.key)).map(e=>`${e.key}:${e.type}`),c=i.sections.filter(e=>!n||e.type!==`text`||a.has(e.key)).map(e=>`${e.key}:${e.type}`);JSON.stringify(s)!==JSON.stringify(c)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(i),`sections`]})}},ue=e.array(k).min(1).max(2).superRefine(A),j=e.object({contractVersion:e.literal(3),...T,message:e.object({type:e.literal(`structured_notification`),variants:ue,links:e.array(e.object({key:e.string().regex(_),...w.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=j.superRefine((e,t)=>E(e,t,828e5,32768)),M=e.object({label:y(48).optional(),value:y(r)}).strict(),fe=e.discriminatedUnion(`key`,[k.options[0].extend({body:M}),k.options[1].extend({body:M})]),pe=j.extend({contractVersion:e.literal(4),message:j.shape.message.extend({variants:e.array(fe).min(1).max(2).superRefine(A)})}).superRefine((e,t)=>E(e,t,828e5,r)),N=e.discriminatedUnion(`key`,[k.options[0].extend({bodyLabel:y(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(_),label:y(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`})})}),k.options[1].extend({bodyLabel:y(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(_),label:y(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`})})})]),me=e.object({value:y(i)}).strict(),P=e.object({contractVersion:e.literal(5),...T,message:e.object({type:e.literal(`structured_notification`),variants:e.array(N).min(1).max(2).superRefine(A),links:e.array(e.object({key:e.string().regex(_),url:w.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:me}).strict()}).strict().superRefine((e,t)=>{E(e,t,a,i);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`]})}}),F=e.object({...P.shape,contractVersion:e.literal(6),message:P.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(_),value:y(i)}).strict()).max(2),variants:e.array(e.discriminatedUnion(`key`,[N.options[0].omit({bodyLabel:!0}).extend({sections:O,bodyRefs:e.array(e.object({key:e.string().regex(_),label:y(48).optional()}).strict()).max(2),footer:y(500).optional()}),N.options[1].omit({bodyLabel:!0}).extend({sections:O,bodyRefs:e.array(e.object({key:e.string().regex(_),label:y(48).optional()}).strict()).max(2),footer:y(500).optional()})])).min(1).max(2).superRefine((e,t)=>A(e,t,!0))})}).strict().superRefine(I);function I(e,t){E(e,t,a,i);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`}),he(e.message.variants,n,r,t)}function he(e,t,n,r,i){for(let[a,o]of e.entries()){let e=o.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!t.includes(e)))&&r.addIssue({code:`custom`,message:`message_body_reference_invalid`,...i?{path:[...i,a,`bodyRefs`]}:{}}),JSON.stringify(o.linkLabels.map(e=>e.key))!==JSON.stringify(n)&&r.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,...i?{path:[...i,a,`linkLabels`]}:{}})}}const ge=e.array(C).min(1).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`route_key_duplicate`})}),{routeKey:_e,...ve}=F.shape,L=F.shape.message,ye=e.object({...ve,contractVersion:e.literal(7),routeKeys:ge,message:L}).strict().superRefine(I),R=e.object({...ye.shape,contractVersion:e.literal(8),message:L.extend({channelVariants:e.partialRecord(e.enum(g),L.shape.variants).optional()})}).strict().superRefine((e,t)=>{I(e,t);let n=e.message.variants.map(e=>`${e.key}:${e.locale}`).sort(),r=e.message.bodies.map(e=>e.key),i=e.message.links.map(e=>e.key);for(let a of g){let o=e.message.channelVariants?.[a];if(!o)continue;let s=[`message`,`channelVariants`,a];JSON.stringify(o.map(e=>`${e.key}:${e.locale}`).sort())!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_channel_variant_languages_mismatch`,path:s}),he(o,r,i,t,s)}}),be=e.object({locale:y(35),contentLocale:y(35),title:y(160).refine(e=>e.trim().length>0,`browser_message_title_blank`),body:e.string().max(8192),url:w.shape.url}).strict(),z=e.object({...R.shape,contractVersion:e.literal(9),audience:e.object({topics:e.array(y(128)).min(1).max(2).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`audience_topic_duplicate`})})}).strict().optional(),browserMessages:e.array(be).min(1).max(5).superRefine((e,t)=>{new Set(e.map(e=>e.locale)).size!==e.length&&t.addIssue({code:`custom`,message:`browser_message_locale_duplicate`})}).optional()}).strict().superRefine((e,t)=>{let{audience:n,browserMessages:r,...i}=e,o=R.safeParse({...i,contractVersion:8});if(o.success)E(e,t,a,65536);else for(let e of o.error.issues)t.addIssue({...e});r!==void 0&&n===void 0&&t.addIssue({code:`custom`,message:`browser_message_audience_missing`,path:[`audience`]})}),B=e.object({offset:e.number().int().nonnegative(),length:e.number().int().positive()}).strict();function V(e,t,n,r){let i=t?.map((e,t)=>({...e,index:t})).sort((e,t)=>e.offset-t.offset)??[],a=t=>!(t>0&&t<e.length&&/[\uD800-\uDBFF]/u.test(e.charAt(t-1))&&/[\uDC00-\uDFFF]/u.test(e.charAt(t))),o=0;for(let t of i){let i=t.offset+t.length;i>e.length?n.addIssue({code:`custom`,message:`quote_range_out_of_bounds`,path:[...r,t.index]}):(!a(t.offset)||!a(i))&&n.addIssue({code:`custom`,message:`quote_range_splits_code_point`,path:[...r,t.index]}),t.offset<o&&n.addIssue({code:`custom`,message:`quote_range_overlap`,path:[...r,t.index]}),o=Math.max(o,i)}}const xe=D.options[0].extend({quotes:e.array(B).optional()}).superRefine((e,t)=>V(e.value,e.quotes,t,[`quotes`])),Se=e.discriminatedUnion(`type`,[xe,D.options[1]]),Ce=e.array(Se).max(30),we={titleQuotes:e.array(B).optional(),sections:Ce},Te=e.array(e.discriminatedUnion(`key`,[L.shape.variants.element.options[0].extend(we),L.shape.variants.element.options[1].extend(we)])).min(1).max(2).superRefine((e,t)=>{for(let[n,r]of e.entries())V(r.title,r.titleQuotes,t,[n,`titleQuotes`])}),Ee=R.shape.message.extend({bodies:e.array(L.shape.bodies.element.extend({quotes:e.array(B).optional()}).superRefine((e,t)=>V(e.value,e.quotes,t,[`quotes`]))).max(2),variants:Te,channelVariants:e.partialRecord(e.enum(g),Te).optional()});function De(e){let{titleQuotes:t,...n}=e;return{...n,sections:n.sections.map(e=>{if(e.type!==`text`)return e;let{quotes:t,...n}=e;return n})}}const Oe=e.object({...z.shape,contractVersion:e.literal(10),message:Ee}).strict().superRefine((e,t)=>{let n=z.safeParse({...e,contractVersion:9,message:{...e.message,bodies:e.message.bodies.map(({quotes:e,...t})=>t),variants:e.message.variants.map(De),...e.message.channelVariants===void 0?{}:{channelVariants:Object.fromEntries(Object.entries(e.message.channelVariants).map(([e,t])=>[e,t.map(De)]))}}});if(!n.success){for(let e of n.error.issues)t.addIssue({...e});return}let{audience:r,browserMessages:o,...s}=e;E(s,t,a,i),E(e,t,a,65536)}),ke=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:y(o),sourceUrl:w.shape.url.optional()}).strict();e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:x,routeKey:C,occurredAt:b,requestedAt:b,deliverBy:b,subject:S.extend({type:e.literal(`creator-event`)}),task:ke}).strict().superRefine((e,t)=>E(e,t,6048e5,o));const Ae=e.union([ie,ce,de,pe,P,F,ye,R,z,Oe]),je=e.object({destinationKey:e.string().min(1),state:e.enum(d),attempts:e.number().int().min(0).max(4),failureCode:e.enum(p).nullable(),lastAttemptAt:b.nullable(),nextAttemptAt:b.nullable(),leaseExpiresAt:b.nullable()}).strict(),H=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:x,routeKey:C,subject:S,state:e.enum(s),reason:e.enum(c),terminal:e.boolean(),acceptedAt:b,updatedAt:b,deliverBy:b,terminalAt:b.nullable(),destinations:e.array(je).min(1).max(20)}).strict(),U=e.object({name:e.string().min(1).max(100),message:e.string().max(500).optional(),code:e.union([e.string().max(100),e.number()]).optional(),status:e.union([e.string().max(100),e.number()]).optional()}).strict(),Me=U.extend({cause:U.extend({cause:U.extend({cause:U.optional()}).optional()}).optional()}),Ne=je.extend({state:e.enum(f),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:Me.nullable(),unconfirmedAt:b.nullable()}),W=H.extend({contractVersion:e.literal(2),state:e.enum(l),reason:e.enum(u),revision:e.number().int().min(0),destinations:e.array(Ne).min(1).max(20)}),Pe=W.omit({routeKey:!0}).extend({contractVersion:e.literal(3),routeKeys:ge}),G=e.union([H,W,Pe]),Fe=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(h)}).strict(),Ie=e.object({code:e.literal(`invalid_request`),issues:e.array(Fe).max(20).optional()}).strict(),Le=e.object({code:e.enum(m.filter(e=>e!==`invalid_request`))}).strict(),Re=e.union([Ie,Le]);e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:H}).strict(),e.object({status:e.literal(`rejected`),error:Re}).strict()]),e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:H}).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()]),e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:G}).strict(),e.object({status:e.literal(`rejected`),error:Re}).strict()]),e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:G}).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()]);function ze(e,t){if((e.contractVersion===8||e.contractVersion===9||e.contractVersion===10)&&t!==void 0){let n=e.message.channelVariants?.[t];if(n!==void 0)return n}return e.message.variants}function K(e,t=[`source`],n){let r=Ae.parse(e),i=n===`tg`?t.toSorted((e,t)=>Number(e!==`source`)-Number(t!==`source`)):t;if(r.contractVersion===6||r.contractVersion===7||r.contractVersion===8||r.contractVersion===9||r.contractVersion===10){let e=ze(r,n),t=r.message.bodies;return{links:[],linksPerVariant:!0,variants:q(e.map(e=>({key:e.key,locale:e.locale,title:e.title,...e.titleQuotes===void 0?{}:{titleQuotes:e.titleQuotes},sections:e.sections,footer:e.footer,bodies:e.bodyRefs.map(e=>{let n=t.find(t=>t.key===e.key);return{label:e.label,value:n.value,...n.quotes===void 0?{}:{quotes:n.quotes}}}),links:r.message.links.map((t,n)=>({...t,label:e.linkLabels[n].label}))})),i)}}return r.contractVersion===1?{links:[...r.message.sourceLink?[{key:`source`,...r.message.sourceLink}]:[],{key:`primary`,...r.message.primaryLink}],linksPerVariant:!1,variants:[{key:`source`,locale:`und`,sections:[{key:`summary`,type:`text`,value:r.message.summary},...r.message.facts.length>0?[{key:`facts`,type:`fields`,items:r.message.facts}]:[]],title:r.message.title}]}:r.contractVersion===3||r.contractVersion===4?{links:r.message.links,linksPerVariant:!1,variants:q(r.message.variants,i)}:r.contractVersion===5?{links:[],linksPerVariant:!0,variants:q(r.message.variants.map(e=>({key:e.key,locale:e.locale,sections:e.sections,title:e.title,body:{label:e.bodyLabel,value:r.message.body.value},links:r.message.links.map((t,n)=>({...t,label:e.linkLabels[n].label}))})),i)}:{links:[...r.message.sourceLink?[{key:`source`,...r.message.sourceLink}]:[],{key:`primary`,...r.message.primaryLink}],linksPerVariant:!1,variants:q(r.message.variants.map(e=>({key:e.key,locale:e.locale,sections:[{key:`summary`,type:`text`,value:e.summary},...e.facts.length>0?[{key:`facts`,type:`fields`,items:e.facts}]:[]],title:e.title})),i)}}function q(e,t){let n=new Map(e.map(e=>[e.key,e])),r=[...new Set(t)].flatMap(e=>{let t=n.get(e);return t?[t]:[]});return r.length>0?r:[n.get(`source`)]}function Be(e,t=[`source`],n){return K(e,t,n).variants.map(e=>e.key)}var J=class extends Error{code=`mandatory_content_too_large`;constructor(){super(`generic_notification_mandatory_content_too_large`),this.name=`GenericNotificationRenderError`}};function Ve(e,t,n=[`source`],r={}){return Y(e,t,n,r)}function He(e,t,n=[`source`],r={}){return Y(e,t,n,r).text}function Y(e,t,n,r){if(!Number.isSafeInteger(t)||t<1)throw Error(`generic_notification_plain_text_limit_invalid`);let i=K(e,n,r.channel);if(e.contractVersion===6||e.contractVersion===7||e.contractVersion===8||e.contractVersion===9||e.contractVersion===10)return Ge(i.variants,t,r);let a=i.links.map(e=>$(e.label,e.url)),o=a.length>0?`\n\n${a.join(`
2
2
 
3
3
  `)}`:``,s=i.linksPerVariant?``:o,c=r.variantSuffixes?.[i.variants.at(-1).key]??``,l=c.length>0?``:s,u=`
4
4
 
5
5
  ---
6
6
 
7
- `,d=i.variants.map((e,t)=>{let n=`${t===i.variants.length-1&&c.length>0?s:``}${r.variantSuffixes?.[e.key]??``}`,a=r.omitFirstTitle===!0&&t===0,o=e.sections.map(ke).join(`
7
+ `,d=i.variants.map((e,t)=>{let n=`${t===i.variants.length-1&&c.length>0?s:``}${r.variantSuffixes?.[e.key]??``}`,a=r.omitFirstTitle===!0&&t===0,o=e.sections.map(Ue).join(`
8
8
 
9
9
  `),l=e.links??i.links,u=l.length>0?`\n\n${l.map(e=>$(e.label,e.url)).join(`
10
10
 
11
11
  `)}`:``;return e.body===void 0?{fixed:a?``:e.title,optional:o.length===0?``:`${a?``:`
12
12
 
13
- `}${o}`,minimum:0,suffix:`${i.linksPerVariant?u:``}${n}`}:{fixed:`${a?``:`${e.title}\n\n`}${o}\n\n${e.body.label===void 0?``:`${e.body.label}\n`}`,optional:e.body.value,minimum:1,suffix:`${i.linksPerVariant?u:``}${n}`}}),f=d.reduce((e,t)=>e+Q(t.fixed)+t.minimum,Q(u)*(d.length-1)+Q(l)+d.reduce((e,t)=>e+Q(t.suffix),0));if(f>t)throw new Z;let p=d.map(e=>Q(e.optional)),m=d.map(e=>e.minimum),h=t-f;for(;h>0;){let e=p.map((e,t)=>({demand:e,index:t})).filter(({demand:e,index:t})=>e>m[t]);if(e.length===0)break;let t=Math.max(1,Math.floor(h/e.length));for(let{demand:n,index:r}of e){let e=Math.min(t,h,n-m[r]);m[r]+=e,h-=e}}return`${d.map((e,t)=>`${e.fixed}${Me(e.optional,m[t])}${e.suffix}`).join(u)}${l}`}function ke(e){return e.type===`fields`?e.items.map(e=>`${e.label}: ${e.value}`).join(`
14
- `):e.label?`${e.label}\n${e.value}`:e.value}function Ae(e,t){let n=e.map(()=>0);for(;t>0;){let r=e.map((e,t)=>({demand:e,index:t})).filter(({demand:e,index:t})=>e>n[t]);if(r.length===0)break;let i=Math.max(1,Math.floor(t/r.length));for(let{demand:e,index:a}of r){let r=Math.min(i,t,e-n[a]);n[a]+=r,t-=r}}return n}function je(e,t,n){let r=`
13
+ `}${o}`,minimum:0,suffix:`${i.linksPerVariant?u:``}${n}`}:{fixed:`${a?``:`${e.title}\n\n`}${o}\n\n${e.body.label===void 0?``:`${e.body.label}\n`}`,optional:e.body.value,minimum:1,suffix:`${i.linksPerVariant?u:``}${n}`}}),f=d.reduce((e,t)=>e+Q(t.fixed)+t.minimum,Q(u)*(d.length-1)+Q(l)+d.reduce((e,t)=>e+Q(t.suffix),0));if(f>t)throw new J;let p=d.map(e=>Q(e.optional)),m=d.map(e=>e.minimum),h=t-f;for(;h>0;){let e=p.map((e,t)=>({demand:e,index:t})).filter(({demand:e,index:t})=>e>m[t]);if(e.length===0)break;let t=Math.max(1,Math.floor(h/e.length));for(let{demand:n,index:r}of e){let e=Math.min(t,h,n-m[r]);m[r]+=e,h-=e}}return{text:`${d.map((e,t)=>`${e.fixed}${Ke(e.optional,m[t])}${e.suffix}`).join(u)}${l}`,quotes:[]}}function Ue(e){return e.type===`fields`?e.items.map(e=>`${e.label}: ${e.value}`).join(`
14
+ `):e.label?`${e.label}\n${e.value}`:e.value}function We(e,t){let n=e.map(()=>0);for(;t>0;){let r=e.map((e,t)=>({demand:e,index:t})).filter(({demand:e,index:t})=>e>n[t]);if(r.length===0)break;let i=Math.max(1,Math.floor(t/r.length));for(let{demand:e,index:a}of r){let r=Math.min(i,t,e-n[a]);n[a]+=r,t-=r}}return n}function Ge(e,t,n){let r=`
15
15
 
16
16
  ---
17
17
 
18
- `,i=e.map((e,t)=>{let r=e.bodies,i=[...n.omitFirstTitle&&t===0?[]:[e.title],...e.sections.map(ke)].join(`
18
+ `,i=e.map((e,t)=>{let r=e.bodies,i=Z([...n.omitFirstTitle&&t===0?[]:[X(e.title,e.titleQuotes)],...e.sections.map(e=>e.type===`fields`?X(Ue(e)):Z([...e.label?[X(e.label)]:[],X(e.value,e.quotes)],`
19
+ `))],`
19
20
 
20
- `),a=[...(e.links??[]).map(e=>$(e.label,e.url)),...e.footer===void 0?[]:[e.footer]].map(e=>`\n\n${e}`).join(``)+(n.variantSuffixes?.[e.key]??``),o=r.map((e,t)=>e.label===void 0?i.length===0&&t===0?``:`
21
+ `),a=[...(e.links??[]).map(e=>$(e.label,e.url)),...e.footer===void 0?[]:[e.footer]].map(e=>`\n\n${e}`).join(``)+(n.variantSuffixes?.[e.key]??``),o=r.map((e,t)=>e.label===void 0?i.text.length===0&&t===0?``:`
21
22
 
22
- `:`\n\n${e.label}\n`),s=e.locale===`zh-CN`?`……(已截断)`:`… (truncated)`;return{bodies:r,prefix:i,suffix:a,labels:o,marker:s,minimums:r.map(e=>Math.min(Q(e.value),Q(s)))}}),a=Q(r)*(i.length-1)+i.reduce((e,t)=>e+Q(t.prefix+t.suffix+t.labels.join(``))+t.minimums.reduce((e,t)=>e+t,0),0);if(a>t)throw new Z;let o=Ae(i.map(e=>e.bodies.reduce((t,n,r)=>t+Q(n.value)-e.minimums[r],0)),t-a);return i.map((e,t)=>{let n=Ae(e.bodies.map((t,n)=>Q(t.value)-e.minimums[n]),o[t]),r=e.bodies.map((t,r)=>{let i=e.minimums[r]+n[r];if(Q(t.value)<=i)return e.labels[r]+t.value;let a=Math.max(0,i-Q(e.marker)),o=[...t.value].slice(0,a).join(``),s=Math.max(o.lastIndexOf(`
23
- `),o.lastIndexOf(`。`),o.lastIndexOf(`. `)),c=s>=o.length*.8?o.slice(0,s+1):o;return e.labels[r]+c+e.marker}).join(``);return e.prefix+r+e.suffix}).join(r)}function Q(e){return[...e].length}function $(e,t){return`${e}: ${new URL(t).toString()}`}function Me(e,t){if(t<=0)return``;let n=[...e];return n.length<=t?e:t===1?`…`:`${n.slice(0,t-1).join(``)}…`}export{Z as GenericNotificationRenderError,Oe as renderGenericNotificationPlainText,Ee as resolveGenericNotificationChannelVariants,Y as resolveGenericNotificationMessage,De as resolveGenericNotificationMessageVariantKeys};
23
+ `:`\n\n${e.label}\n`),s=e.locale===`zh-CN`?`……(已截断)`:`… (truncated)`;return{bodies:r,prefix:i,suffix:a,labels:o,marker:s,minimums:r.map(e=>Math.min(Q(e.value),Q(s)))}}),a=Q(r)*(i.length-1)+i.reduce((e,t)=>e+Q(t.prefix.text+t.suffix+t.labels.join(``))+t.minimums.reduce((e,t)=>e+t,0),0);if(a>t)throw new J;let o=We(i.map(e=>e.bodies.reduce((t,n,r)=>t+Q(n.value)-e.minimums[r],0)),t-a);return Z(i.map((e,t)=>{let n=We(e.bodies.map((t,n)=>Q(t.value)-e.minimums[n]),o[t]),r=e.bodies.map((t,r)=>{let i=e.minimums[r]+n[r];if(Q(t.value)<=i)return Z([X(e.labels[r]),X(t.value,t.quotes)]);let a=Math.max(0,i-Q(e.marker)),o=[...t.value].slice(0,a).join(``),s=Math.max(o.lastIndexOf(`
24
+ `),o.lastIndexOf(`。`),o.lastIndexOf(`. `)),c=s>=o.length*.8?o.slice(0,s+1):o;return Z([X(e.labels[r]),X(c,t.quotes),X(e.marker)])});return Z([e.prefix,...r,X(e.suffix)])}),r)}function X(e,t=[]){return{text:e,quotes:t.flatMap(t=>{let n=Math.min(e.length,t.offset+t.length)-t.offset;return n>0?[{offset:t.offset,length:n}]:[]}).sort((e,t)=>e.offset-t.offset)}}function Z(e,t=``){let n=``,r=[];for(let[i,a]of e.entries())i>0&&(n+=t),r.push(...a.quotes.map(e=>({offset:n.length+e.offset,length:e.length}))),n+=a.text;return{text:n,quotes:r}}function Q(e){return[...e].length}function $(e,t){return`${e}: ${new URL(t).toString()}`}function Ke(e,t){if(t<=0)return``;let n=[...e];return n.length<=t?e:t===1?`…`:`${n.slice(0,t-1).join(``)}…`}export{J as GenericNotificationRenderError,Ve as renderGenericNotificationAnnotatedText,He as renderGenericNotificationPlainText,ze as resolveGenericNotificationChannelVariants,K as resolveGenericNotificationMessage,Be as resolveGenericNotificationMessageVariantKeys};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@closerepo/notification-contracts",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {