@closerepo/notification-contracts 1.8.0 → 1.10.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 +36 -36
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -387,6 +387,10 @@ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
|
|
|
387
387
|
key: z.ZodLiteral<"source">;
|
|
388
388
|
title: z.ZodString;
|
|
389
389
|
locale: z.ZodLiteral<"und">;
|
|
390
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
391
|
+
key: z.ZodString;
|
|
392
|
+
label: z.ZodString;
|
|
393
|
+
}, z.core.$strict>>;
|
|
390
394
|
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
391
395
|
key: z.ZodString;
|
|
392
396
|
type: z.ZodLiteral<"text">;
|
|
@@ -400,19 +404,19 @@ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
|
|
|
400
404
|
value: z.ZodString;
|
|
401
405
|
}, z.core.$strict>>;
|
|
402
406
|
}, z.core.$strict>], "type">>;
|
|
403
|
-
linkLabels: z.ZodArray<z.ZodObject<{
|
|
404
|
-
key: z.ZodString;
|
|
405
|
-
label: z.ZodString;
|
|
406
|
-
}, z.core.$strict>>;
|
|
407
407
|
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
408
408
|
key: z.ZodString;
|
|
409
409
|
label: z.ZodString;
|
|
410
410
|
}, z.core.$strict>>;
|
|
411
|
-
footer: z.ZodString
|
|
411
|
+
footer: z.ZodOptional<z.ZodString>;
|
|
412
412
|
}, z.core.$strict>, z.ZodObject<{
|
|
413
413
|
key: z.ZodLiteral<"zh-CN">;
|
|
414
414
|
title: z.ZodString;
|
|
415
415
|
locale: z.ZodLiteral<"zh-CN">;
|
|
416
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
417
|
+
key: z.ZodString;
|
|
418
|
+
label: z.ZodString;
|
|
419
|
+
}, z.core.$strict>>;
|
|
416
420
|
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
417
421
|
key: z.ZodString;
|
|
418
422
|
type: z.ZodLiteral<"text">;
|
|
@@ -426,15 +430,11 @@ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
|
|
|
426
430
|
value: z.ZodString;
|
|
427
431
|
}, z.core.$strict>>;
|
|
428
432
|
}, z.core.$strict>], "type">>;
|
|
429
|
-
linkLabels: z.ZodArray<z.ZodObject<{
|
|
430
|
-
key: z.ZodString;
|
|
431
|
-
label: z.ZodString;
|
|
432
|
-
}, z.core.$strict>>;
|
|
433
433
|
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
434
434
|
key: z.ZodString;
|
|
435
435
|
label: z.ZodString;
|
|
436
436
|
}, z.core.$strict>>;
|
|
437
|
-
footer: z.ZodString
|
|
437
|
+
footer: z.ZodOptional<z.ZodString>;
|
|
438
438
|
}, z.core.$strict>], "key">>;
|
|
439
439
|
}, z.core.$strict>;
|
|
440
440
|
eventType: z.ZodLiteral<"notification.delivery.requested">;
|
|
@@ -471,6 +471,10 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
|
|
|
471
471
|
key: z.ZodLiteral<"source">;
|
|
472
472
|
title: z.ZodString;
|
|
473
473
|
locale: z.ZodLiteral<"und">;
|
|
474
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
475
|
+
key: z.ZodString;
|
|
476
|
+
label: z.ZodString;
|
|
477
|
+
}, z.core.$strict>>;
|
|
474
478
|
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
475
479
|
key: z.ZodString;
|
|
476
480
|
type: z.ZodLiteral<"text">;
|
|
@@ -484,10 +488,6 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
|
|
|
484
488
|
value: z.ZodString;
|
|
485
489
|
}, z.core.$strict>>;
|
|
486
490
|
}, z.core.$strict>], "type">>;
|
|
487
|
-
linkLabels: z.ZodArray<z.ZodObject<{
|
|
488
|
-
key: z.ZodString;
|
|
489
|
-
label: z.ZodString;
|
|
490
|
-
}, z.core.$strict>>;
|
|
491
491
|
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
492
492
|
key: z.ZodString;
|
|
493
493
|
label: z.ZodString;
|
|
@@ -497,6 +497,10 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
|
|
|
497
497
|
key: z.ZodLiteral<"zh-CN">;
|
|
498
498
|
title: z.ZodString;
|
|
499
499
|
locale: z.ZodLiteral<"zh-CN">;
|
|
500
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
501
|
+
key: z.ZodString;
|
|
502
|
+
label: z.ZodString;
|
|
503
|
+
}, z.core.$strict>>;
|
|
500
504
|
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
501
505
|
key: z.ZodString;
|
|
502
506
|
type: z.ZodLiteral<"text">;
|
|
@@ -510,10 +514,6 @@ declare const notificationDeliveryRequestV7Schema: z.ZodObject<{
|
|
|
510
514
|
value: z.ZodString;
|
|
511
515
|
}, z.core.$strict>>;
|
|
512
516
|
}, z.core.$strict>], "type">>;
|
|
513
|
-
linkLabels: z.ZodArray<z.ZodObject<{
|
|
514
|
-
key: z.ZodString;
|
|
515
|
-
label: z.ZodString;
|
|
516
|
-
}, z.core.$strict>>;
|
|
517
517
|
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
518
518
|
key: z.ZodString;
|
|
519
519
|
label: z.ZodString;
|
|
@@ -898,6 +898,10 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
898
898
|
key: z.ZodLiteral<"source">;
|
|
899
899
|
title: z.ZodString;
|
|
900
900
|
locale: z.ZodLiteral<"und">;
|
|
901
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
902
|
+
key: z.ZodString;
|
|
903
|
+
label: z.ZodString;
|
|
904
|
+
}, z.core.$strict>>;
|
|
901
905
|
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
902
906
|
key: z.ZodString;
|
|
903
907
|
type: z.ZodLiteral<"text">;
|
|
@@ -911,19 +915,19 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
911
915
|
value: z.ZodString;
|
|
912
916
|
}, z.core.$strict>>;
|
|
913
917
|
}, z.core.$strict>], "type">>;
|
|
914
|
-
linkLabels: z.ZodArray<z.ZodObject<{
|
|
915
|
-
key: z.ZodString;
|
|
916
|
-
label: z.ZodString;
|
|
917
|
-
}, z.core.$strict>>;
|
|
918
918
|
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
919
919
|
key: z.ZodString;
|
|
920
920
|
label: z.ZodString;
|
|
921
921
|
}, z.core.$strict>>;
|
|
922
|
-
footer: z.ZodString
|
|
922
|
+
footer: z.ZodOptional<z.ZodString>;
|
|
923
923
|
}, z.core.$strict>, z.ZodObject<{
|
|
924
924
|
key: z.ZodLiteral<"zh-CN">;
|
|
925
925
|
title: z.ZodString;
|
|
926
926
|
locale: z.ZodLiteral<"zh-CN">;
|
|
927
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
928
|
+
key: z.ZodString;
|
|
929
|
+
label: z.ZodString;
|
|
930
|
+
}, z.core.$strict>>;
|
|
927
931
|
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
928
932
|
key: z.ZodString;
|
|
929
933
|
type: z.ZodLiteral<"text">;
|
|
@@ -937,15 +941,11 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
937
941
|
value: z.ZodString;
|
|
938
942
|
}, z.core.$strict>>;
|
|
939
943
|
}, z.core.$strict>], "type">>;
|
|
940
|
-
linkLabels: z.ZodArray<z.ZodObject<{
|
|
941
|
-
key: z.ZodString;
|
|
942
|
-
label: z.ZodString;
|
|
943
|
-
}, z.core.$strict>>;
|
|
944
944
|
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
945
945
|
key: z.ZodString;
|
|
946
946
|
label: z.ZodString;
|
|
947
947
|
}, z.core.$strict>>;
|
|
948
|
-
footer: z.ZodString
|
|
948
|
+
footer: z.ZodOptional<z.ZodString>;
|
|
949
949
|
}, z.core.$strict>], "key">>;
|
|
950
950
|
}, z.core.$strict>;
|
|
951
951
|
eventType: z.ZodLiteral<"notification.delivery.requested">;
|
|
@@ -980,6 +980,10 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
980
980
|
key: z.ZodLiteral<"source">;
|
|
981
981
|
title: z.ZodString;
|
|
982
982
|
locale: z.ZodLiteral<"und">;
|
|
983
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
984
|
+
key: z.ZodString;
|
|
985
|
+
label: z.ZodString;
|
|
986
|
+
}, z.core.$strict>>;
|
|
983
987
|
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
984
988
|
key: z.ZodString;
|
|
985
989
|
type: z.ZodLiteral<"text">;
|
|
@@ -993,10 +997,6 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
993
997
|
value: z.ZodString;
|
|
994
998
|
}, z.core.$strict>>;
|
|
995
999
|
}, z.core.$strict>], "type">>;
|
|
996
|
-
linkLabels: z.ZodArray<z.ZodObject<{
|
|
997
|
-
key: z.ZodString;
|
|
998
|
-
label: z.ZodString;
|
|
999
|
-
}, z.core.$strict>>;
|
|
1000
1000
|
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
1001
1001
|
key: z.ZodString;
|
|
1002
1002
|
label: z.ZodString;
|
|
@@ -1006,6 +1006,10 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
1006
1006
|
key: z.ZodLiteral<"zh-CN">;
|
|
1007
1007
|
title: z.ZodString;
|
|
1008
1008
|
locale: z.ZodLiteral<"zh-CN">;
|
|
1009
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
1010
|
+
key: z.ZodString;
|
|
1011
|
+
label: z.ZodString;
|
|
1012
|
+
}, z.core.$strict>>;
|
|
1009
1013
|
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1010
1014
|
key: z.ZodString;
|
|
1011
1015
|
type: z.ZodLiteral<"text">;
|
|
@@ -1019,10 +1023,6 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
1019
1023
|
value: z.ZodString;
|
|
1020
1024
|
}, z.core.$strict>>;
|
|
1021
1025
|
}, z.core.$strict>], "type">>;
|
|
1022
|
-
linkLabels: z.ZodArray<z.ZodObject<{
|
|
1023
|
-
key: z.ZodString;
|
|
1024
|
-
label: z.ZodString;
|
|
1025
|
-
}, z.core.$strict>>;
|
|
1026
1026
|
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
1027
1027
|
key: z.ZodString;
|
|
1028
1028
|
label: z.ZodString;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";const t=1,n=2,r=3,i=4,a=5,ee=7,te=20,o=32*1024,s=1380*60*1e3,ne=o,re=s,c=o,l=s,u=o,ie=s,d=o,f=s,ae=1,p=32*1024,m=10080*60*1e3,h=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],g=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],_=[...h,`unconfirmed`],v=[...g,`delivery_unconfirmed`],y=[`pending`,`delivering`,`delivered`,`failed`,`expired`],b=[...y,`unconfirmed`],x=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],S=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],oe=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],se=[`source`,`zh-CN`],ce=new TextEncoder,C=/^[a-z][a-z0-9-]{0,62}$/,le=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,ue=/^[A-Z0-9][\w.:-]{0,127}$/i;function de(e){return[...e].length}function w(t){return e.string().refine(e=>de(e)>0,{message:`too_small`}).refine(e=>de(e)<=t,{message:`too_big`})}const T=e.string().datetime({offset:!0}),E=e.object({key:e.string().regex(C),environment:e.string().regex(C)}).strict(),D=e.object({type:e.string().regex(C),id:e.string().regex(ue),revision:e.number().int().positive()}).strict(),O=e.string().min(1).max(127).regex(le),k=e.object({label:w(48),url:w(2048).refine(e=>[...e].every(e=>{let t=e.codePointAt(0);return t!==void 0&&t>31&&t!==127}),{message:`invalid_https_url`}).refine(e=>{try{return new URL(e).protocol===`https:`}catch{return!1}},{message:`invalid_https_url`})}).strict(),A={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:E,routeKey:O,occurredAt:T,requestedAt:T,deliverBy:T,subject:D},fe=e.object({contractVersion:e.literal(1),...A,message:e.object({type:e.literal(`link_summary`),title:w(160),summary:w(1200),facts:e.array(e.object({label:w(48),value:w(500)}).strict()).max(10),primaryLink:k,sourceLink:k.optional()}).strict()}).strict();function j(e,t,n,r){let i=Date.parse(e.requestedAt),a=Date.parse(e.deliverBy);(!Number.isFinite(i)||!Number.isFinite(a)||a<=i||a-i>n)&&t.addIssue({code:`custom`,message:`delivery_deadline_invalid`,path:[`deliverBy`]}),ce.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const M=fe.superRefine((e,t)=>j(e,t,s,o)),N={title:w(160),summary:w(1200),facts:e.array(e.object({label:w(48),value:w(500)}).strict()).max(10)},pe=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...N}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...N}).strict()]),me=e.array(pe).min(1).max(2).superRefine((e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`})}),P=e.object({contractVersion:e.literal(2),...A,message:e.object({type:e.literal(`localized_link_summary`),variants:me,primaryLink:k,sourceLink:k.optional()}).strict()}).strict().superRefine((e,t)=>j(e,t,re,ne)),he=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(C),type:e.literal(`text`),label:w(48).optional(),value:w(4e3)}).strict(),e.object({key:e.string().regex(C),type:e.literal(`fields`),items:e.array(e.object({label:w(48),value:w(1200)}).strict()).min(1).max(20)}).strict()]),F=e.array(he).min(1).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),I=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:w(160),sections:F}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:w(160),sections:F}).strict()]),L=(e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`});let n=e.find(e=>e.key===`source`),r=e.find(e=>e.key===`zh-CN`);if(n&&r){let i=n.sections.map(e=>`${e.key}:${e.type}`),a=r.sections.map(e=>`${e.key}:${e.type}`);JSON.stringify(i)!==JSON.stringify(a)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(r),`sections`]})}},ge=e.array(I).min(1).max(2).superRefine(L),R=e.object({contractVersion:e.literal(3),...A,message:e.object({type:e.literal(`structured_notification`),variants:ge,links:e.array(e.object({key:e.string().regex(C),...k.shape}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_duplicate`})})}).strict()}).strict(),z=R.superRefine((e,t)=>j(e,t,l,c)),B=e.object({label:w(48).optional(),value:w(u)}).strict(),_e=e.discriminatedUnion(`key`,[I.options[0].extend({body:B}),I.options[1].extend({body:B})]),V=R.extend({contractVersion:e.literal(4),message:R.shape.message.extend({variants:e.array(_e).min(1).max(2).superRefine(L)})}).superRefine((e,t)=>j(e,t,ie,u)),H=e.discriminatedUnion(`key`,[I.options[0].extend({bodyLabel:w(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(C),label:w(48)}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_label_duplicate`})})}),I.options[1].extend({bodyLabel:w(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(C),label:w(48)}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_label_duplicate`})})})]),ve=e.object({value:w(d)}).strict(),U=e.object({contractVersion:e.literal(5),...A,message:e.object({type:e.literal(`structured_notification`),variants:e.array(H).min(1).max(2).superRefine(L),links:e.array(e.object({key:e.string().regex(C),url:k.shape.url}).strict()).max(10).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_link_duplicate`})}),body:ve}).strict()}).strict().superRefine((e,t)=>{j(e,t,f,d);let n=e.message.links.map(e=>e.key);for(let[r,i]of e.message.variants.entries()){let e=i.linkLabels.map(e=>e.key);JSON.stringify(e)!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,path:[`message`,`variants`,r,`linkLabels`]})}}),W=e.object({...U.shape,contractVersion:e.literal(6),message:U.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(C),value:w(d)}).strict()).min(1).max(2),variants:e.array(e.discriminatedUnion(`key`,[H.options[0].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(C),label:w(48)}).strict()).min(1).max(2),footer:w(500)}),H.options[1].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(C),label:w(48)}).strict()).min(1).max(2),footer:w(500)})])).min(1).max(2).superRefine(L)})}).strict().superRefine(ye);function ye(e,t){j(e,t,f,d);let n=e.message.bodies.map(e=>e.key),r=e.message.links.map(e=>e.key);new Set(n).size!==n.length&&t.addIssue({code:`custom`,message:`message_body_duplicate`});for(let i of e.message.variants){let e=i.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!n.includes(e)))&&t.addIssue({code:`custom`,message:`message_body_reference_invalid`}),JSON.stringify(i.linkLabels.map(e=>e.key))!==JSON.stringify(r)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`})}}const be=e.array(O).min(1).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`route_key_duplicate`})}),{routeKey:xe,...Se}=W.shape,G=W.shape.message,[K,q]=G.shape.variants.element.options,Ce=e.discriminatedUnion(`key`,[K.extend({bodyRefs:e.array(K.shape.bodyRefs.element).max(2),footer:K.shape.footer.optional()}),q.extend({bodyRefs:e.array(q.shape.bodyRefs.element).max(2),footer:q.shape.footer.optional()})]),we=e.object({...Se,contractVersion:e.literal(7),routeKeys:be,message:G.extend({bodies:e.array(G.shape.bodies.element).max(2),variants:e.array(Ce).min(1).max(2).superRefine(L)})}).strict().superRefine(ye);function Te(e){return`routeKeys`in e?[...e.routeKeys].sort():[e.routeKey]}const Ee=e.object({type:e.literal(`creator.draft.v1`),templateId:e.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),signalType:e.string().regex(/^[a-z][a-z0-9_]*$/),sourceTextZh:w(p),sourceUrl:k.shape.url.optional()}).strict(),De=e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:E,routeKey:O,occurredAt:T,requestedAt:T,deliverBy:T,subject:D.extend({type:e.literal(`creator-event`)}),task:Ee}).strict().superRefine((e,t)=>j(e,t,m,p)),Oe=De,ke=e.union([M,P,z,V,U,W,we]),Ae=e.object({destinationKey:e.string().min(1),state:e.enum(y),attempts:e.number().int().min(0).max(4),failureCode:e.enum(x).nullable(),lastAttemptAt:T.nullable(),nextAttemptAt:T.nullable(),leaseExpiresAt:T.nullable()}).strict(),J=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:E,routeKey:O,subject:D,state:e.enum(h),reason:e.enum(g),terminal:e.boolean(),acceptedAt:T,updatedAt:T,deliverBy:T,terminalAt:T.nullable(),destinations:e.array(Ae).min(1).max(20)}).strict(),Y=e.object({name:e.string().min(1).max(100),message:e.string().max(500).optional(),code:e.union([e.string().max(100),e.number()]).optional(),status:e.union([e.string().max(100),e.number()]).optional()}).strict(),X=Y.extend({cause:Y.extend({cause:Y.extend({cause:Y.optional()}).optional()}).optional()}),je=Ae.extend({state:e.enum(b),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:X.nullable(),unconfirmedAt:T.nullable()}),Z=J.extend({contractVersion:e.literal(2),state:e.enum(_),reason:e.enum(v),revision:e.number().int().min(0),destinations:e.array(je).min(1).max(20)}),Me=Z.omit({routeKey:!0}).extend({contractVersion:e.literal(3),routeKeys:be}),Q=e.union([J,Z,Me]),Ne=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(oe)}).strict(),Pe=e.object({code:e.literal(`invalid_request`),issues:e.array(Ne).max(20).optional()}).strict(),Fe=e.object({code:e.enum(S.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([Pe,Fe]),Ie=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:J}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),Le=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:J}).strict(),e.object({status:e.literal(`not_found`)}).strict(),e.object({status:e.literal(`unavailable`),error:e.object({code:e.literal(`receipt_unavailable`)}).strict()}).strict()]),Re=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),ze=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:Q}).strict(),e.object({status:e.literal(`not_found`)}).strict(),e.object({status:e.literal(`unavailable`),error:e.object({code:e.literal(`receipt_unavailable`)}).strict()}).strict()]);export{ae as localTaskDeliveryContractVersionV1,m as localTaskDeliveryMaximumDeadlineMillisecondsV1,p as localTaskDeliveryRequestMaximumUtf8BytesV1,Oe as localTaskDeliveryRequestSchema,De as localTaskDeliveryRequestV1Schema,Ie as notificationDeliverResultV1Schema,Re as notificationDeliverResultV2Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,i as notificationDeliveryContractVersionV4,a as notificationDeliveryContractVersionV5,ee as notificationDeliveryContractVersionV7,s as notificationDeliveryMaximumDeadlineMillisecondsV1,re as notificationDeliveryMaximumDeadlineMillisecondsV2,l as notificationDeliveryMaximumDeadlineMillisecondsV3,ie as notificationDeliveryMaximumDeadlineMillisecondsV4,f as notificationDeliveryMaximumDeadlineMillisecondsV5,te as notificationDeliveryMaximumDestinationsV1,g as notificationDeliveryReasonsV1,v as notificationDeliveryReasonsV2,J as notificationDeliveryReceiptV1Schema,Z as notificationDeliveryReceiptV2Schema,Me as notificationDeliveryReceiptV3Schema,S as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,o as notificationDeliveryRequestMaximumUtf8BytesV1,ne as notificationDeliveryRequestMaximumUtf8BytesV2,c as notificationDeliveryRequestMaximumUtf8BytesV3,u as notificationDeliveryRequestMaximumUtf8BytesV4,d as notificationDeliveryRequestMaximumUtf8BytesV5,ke as notificationDeliveryRequestSchema,M as notificationDeliveryRequestV1Schema,P as notificationDeliveryRequestV2Schema,z as notificationDeliveryRequestV3Schema,V as notificationDeliveryRequestV4Schema,U as notificationDeliveryRequestV5Schema,W as notificationDeliveryRequestV6Schema,we as notificationDeliveryRequestV7Schema,h as notificationDeliveryStatesV1,_ as notificationDeliveryStatesV2,x as notificationDestinationFailureCodesV1,y as notificationDestinationStatesV1,b as notificationDestinationStatesV2,Le as notificationGetReceiptResultV1Schema,ze as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,se as notificationMessageVariantKeys,Te as notificationRouteKeys,oe as notificationValidationIssueCodesV1,X as safeDeliveryCauseSchema};
|
|
1
|
+
import{z as e}from"zod";const t=1,n=2,r=3,i=4,a=5,o=7,ee=20,s=32*1024,c=1380*60*1e3,te=s,ne=c,l=s,u=c,d=s,f=c,p=s,m=c,re=1,h=32*1024,ie=10080*60*1e3,g=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],_=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],v=[...g,`unconfirmed`],y=[..._,`delivery_unconfirmed`],b=[`pending`,`delivering`,`delivered`,`failed`,`expired`],x=[...b,`unconfirmed`],S=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],C=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],w=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],ae=[`source`,`zh-CN`],oe=new TextEncoder,T=/^[a-z][a-z0-9-]{0,62}$/,se=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,ce=/^[A-Z0-9][\w.:-]{0,127}$/i;function le(e){return[...e].length}function E(t){return e.string().refine(e=>le(e)>0,{message:`too_small`}).refine(e=>le(e)<=t,{message:`too_big`})}const D=e.string().datetime({offset:!0}),O=e.object({key:e.string().regex(T),environment:e.string().regex(T)}).strict(),k=e.object({type:e.string().regex(T),id:e.string().regex(ce),revision:e.number().int().positive()}).strict(),A=e.string().min(1).max(127).regex(se),j=e.object({label:E(48),url:E(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(),M={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:O,routeKey:A,occurredAt:D,requestedAt:D,deliverBy:D,subject:k},ue=e.object({contractVersion:e.literal(1),...M,message:e.object({type:e.literal(`link_summary`),title:E(160),summary:E(1200),facts:e.array(e.object({label:E(48),value:E(500)}).strict()).max(10),primaryLink:j,sourceLink:j.optional()}).strict()}).strict();function N(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`]}),oe.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const P=ue.superRefine((e,t)=>N(e,t,c,s)),F={title:E(160),summary:E(1200),facts:e.array(e.object({label:E(48),value:E(500)}).strict()).max(10)},de=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...F}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...F}).strict()]),fe=e.array(de).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`})}),I=e.object({contractVersion:e.literal(2),...M,message:e.object({type:e.literal(`localized_link_summary`),variants:fe,primaryLink:j,sourceLink:j.optional()}).strict()}).strict().superRefine((e,t)=>N(e,t,ne,te)),pe=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(T),type:e.literal(`text`),label:E(48).optional(),value:E(4e3)}).strict(),e.object({key:e.string().regex(T),type:e.literal(`fields`),items:e.array(e.object({label:E(48),value:E(1200)}).strict()).min(1).max(20)}).strict()]),L=e.array(pe).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),R=L.min(1),z=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:E(160),sections:R}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:E(160),sections:R}).strict()]),B=(e,t,n=!1)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`});let r=e.find(e=>e.key===`source`),i=e.find(e=>e.key===`zh-CN`);if(r&&i){let a=new Set(r.sections.map(e=>e.key)),o=new Set(i.sections.map(e=>e.key)),ee=r.sections.filter(e=>!n||e.type!==`text`||o.has(e.key)).map(e=>`${e.key}:${e.type}`),s=i.sections.filter(e=>!n||e.type!==`text`||a.has(e.key)).map(e=>`${e.key}:${e.type}`);JSON.stringify(ee)!==JSON.stringify(s)&&t.addIssue({code:`custom`,message:`message_variant_structure_mismatch`,path:[e.indexOf(i),`sections`]})}},me=e.array(z).min(1).max(2).superRefine(B),V=e.object({contractVersion:e.literal(3),...M,message:e.object({type:e.literal(`structured_notification`),variants:me,links:e.array(e.object({key:e.string().regex(T),...j.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(),H=V.superRefine((e,t)=>N(e,t,u,l)),U=e.object({label:E(48).optional(),value:E(d)}).strict(),he=e.discriminatedUnion(`key`,[z.options[0].extend({body:U}),z.options[1].extend({body:U})]),W=V.extend({contractVersion:e.literal(4),message:V.shape.message.extend({variants:e.array(he).min(1).max(2).superRefine(B)})}).superRefine((e,t)=>N(e,t,f,d)),G=e.discriminatedUnion(`key`,[z.options[0].extend({bodyLabel:E(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(T),label:E(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`})})}),z.options[1].extend({bodyLabel:E(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(T),label:E(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`})})})]),ge=e.object({value:E(p)}).strict(),K=e.object({contractVersion:e.literal(5),...M,message:e.object({type:e.literal(`structured_notification`),variants:e.array(G).min(1).max(2).superRefine(B),links:e.array(e.object({key:e.string().regex(T),url:j.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:ge}).strict()}).strict().superRefine((e,t)=>{N(e,t,m,p);let n=e.message.links.map(e=>e.key);for(let[r,i]of e.message.variants.entries()){let e=i.linkLabels.map(e=>e.key);JSON.stringify(e)!==JSON.stringify(n)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`,path:[`message`,`variants`,r,`linkLabels`]})}}),q=e.object({...K.shape,contractVersion:e.literal(6),message:K.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(T),value:E(p)}).strict()).max(2),variants:e.array(e.discriminatedUnion(`key`,[G.options[0].omit({bodyLabel:!0}).extend({sections:L,bodyRefs:e.array(e.object({key:e.string().regex(T),label:E(48)}).strict()).max(2),footer:E(500).optional()}),G.options[1].omit({bodyLabel:!0}).extend({sections:L,bodyRefs:e.array(e.object({key:e.string().regex(T),label:E(48)}).strict()).max(2),footer:E(500).optional()})])).min(1).max(2).superRefine((e,t)=>B(e,t,!0))})}).strict().superRefine(J);function J(e,t){N(e,t,m,p);let n=e.message.bodies.map(e=>e.key),r=e.message.links.map(e=>e.key);new Set(n).size!==n.length&&t.addIssue({code:`custom`,message:`message_body_duplicate`});for(let i of e.message.variants){let e=i.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!n.includes(e)))&&t.addIssue({code:`custom`,message:`message_body_reference_invalid`}),JSON.stringify(i.linkLabels.map(e=>e.key))!==JSON.stringify(r)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`})}}const _e=e.array(A).min(1).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`route_key_duplicate`})}),{routeKey:ve,...ye}=q.shape,be=q.shape.message,xe=e.object({...ye,contractVersion:e.literal(7),routeKeys:_e,message:be}).strict().superRefine(J);function Se(e){return`routeKeys`in e?[...e.routeKeys].sort():[e.routeKey]}const Ce=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:E(h),sourceUrl:j.shape.url.optional()}).strict(),we=e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:O,routeKey:A,occurredAt:D,requestedAt:D,deliverBy:D,subject:k.extend({type:e.literal(`creator-event`)}),task:Ce}).strict().superRefine((e,t)=>N(e,t,ie,h)),Te=we,Ee=e.union([P,I,H,W,K,q,xe]),De=e.object({destinationKey:e.string().min(1),state:e.enum(b),attempts:e.number().int().min(0).max(4),failureCode:e.enum(S).nullable(),lastAttemptAt:D.nullable(),nextAttemptAt:D.nullable(),leaseExpiresAt:D.nullable()}).strict(),Y=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:O,routeKey:A,subject:k,state:e.enum(g),reason:e.enum(_),terminal:e.boolean(),acceptedAt:D,updatedAt:D,deliverBy:D,terminalAt:D.nullable(),destinations:e.array(De).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(),Oe=X.extend({cause:X.extend({cause:X.extend({cause:X.optional()}).optional()}).optional()}),ke=De.extend({state:e.enum(x),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:Oe.nullable(),unconfirmedAt:D.nullable()}),Z=Y.extend({contractVersion:e.literal(2),state:e.enum(v),reason:e.enum(y),revision:e.number().int().min(0),destinations:e.array(ke).min(1).max(20)}),Ae=Z.omit({routeKey:!0}).extend({contractVersion:e.literal(3),routeKeys:_e}),Q=e.union([Y,Z,Ae]),je=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(w)}).strict(),Me=e.object({code:e.literal(`invalid_request`),issues:e.array(je).max(20).optional()}).strict(),Ne=e.object({code:e.enum(C.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([Me,Ne]),Pe=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Y}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),Fe=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()]),Ie=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),Le=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{re as localTaskDeliveryContractVersionV1,ie as localTaskDeliveryMaximumDeadlineMillisecondsV1,h as localTaskDeliveryRequestMaximumUtf8BytesV1,Te as localTaskDeliveryRequestSchema,we as localTaskDeliveryRequestV1Schema,Pe as notificationDeliverResultV1Schema,Ie as notificationDeliverResultV2Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,i as notificationDeliveryContractVersionV4,a as notificationDeliveryContractVersionV5,o as notificationDeliveryContractVersionV7,c as notificationDeliveryMaximumDeadlineMillisecondsV1,ne as notificationDeliveryMaximumDeadlineMillisecondsV2,u as notificationDeliveryMaximumDeadlineMillisecondsV3,f as notificationDeliveryMaximumDeadlineMillisecondsV4,m as notificationDeliveryMaximumDeadlineMillisecondsV5,ee as notificationDeliveryMaximumDestinationsV1,_ as notificationDeliveryReasonsV1,y as notificationDeliveryReasonsV2,Y as notificationDeliveryReceiptV1Schema,Z as notificationDeliveryReceiptV2Schema,Ae as notificationDeliveryReceiptV3Schema,C as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,s as notificationDeliveryRequestMaximumUtf8BytesV1,te as notificationDeliveryRequestMaximumUtf8BytesV2,l as notificationDeliveryRequestMaximumUtf8BytesV3,d as notificationDeliveryRequestMaximumUtf8BytesV4,p as notificationDeliveryRequestMaximumUtf8BytesV5,Ee as notificationDeliveryRequestSchema,P as notificationDeliveryRequestV1Schema,I as notificationDeliveryRequestV2Schema,H as notificationDeliveryRequestV3Schema,W as notificationDeliveryRequestV4Schema,K as notificationDeliveryRequestV5Schema,q as notificationDeliveryRequestV6Schema,xe as notificationDeliveryRequestV7Schema,g as notificationDeliveryStatesV1,v as notificationDeliveryStatesV2,S as notificationDestinationFailureCodesV1,b as notificationDestinationStatesV1,x as notificationDestinationStatesV2,Fe as notificationGetReceiptResultV1Schema,Le as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,ae as notificationMessageVariantKeys,Se as notificationRouteKeys,w as notificationValidationIssueCodesV1,Oe as safeDeliveryCauseSchema};
|