@closerepo/notification-contracts 1.13.0 → 1.15.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.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,c=8,ee=9,te=10,ne=11,re=20,l=32*1024,u=1380*60*1e3,ie=l,ae=u,oe=l,se=u,d=l,ce=u,f=l,p=64*1024,m=p,h=m,g=u,le=1,_=32*1024,ue=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`],de=[...v,`unconfirmed`],fe=[...y,`delivery_unconfirmed`],b=[`pending`,`delivering`,`delivered`,`failed`,`expired`],pe=[...b,`unconfirmed`],me=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],he=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],ge=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],_e=[`source`,`zh-CN`],x=[`qq`,`tg`,`wechat`,`lark`],ve=new TextEncoder,S=/^[a-z][a-z0-9-]{0,62}$/,ye=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,be=/^[A-Z0-9][\w.:-]{0,127}$/i;function xe(e){return[...e].length}function C(t){return e.string().refine(e=>xe(e)>0,{message:`too_small`}).refine(e=>xe(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(be),revision:e.number().int().positive()}).strict(),D=e.string().min(1).max(127).regex(ye),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},Se=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`]}),ve.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const j=Se.superRefine((e,t)=>A(e,t,u,l)),Ce={title:C(160),summary:C(1200),facts:e.array(e.object({label:C(48),value:C(500)}).strict()).max(10)},we=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...Ce}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...Ce}).strict()]),Te=e.array(we).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`})}),Ee=e.object({contractVersion:e.literal(2),...k,message:e.object({type:e.literal(`localized_link_summary`),variants:Te,primaryLink:O,sourceLink:O.optional()}).strict()}).strict().superRefine((e,t)=>A(e,t,ae,ie)),M=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()]),N=e.array(M).max(30).superRefine((e,t)=>{new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_section_duplicate`})}),De=N.min(1),P=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:C(160),sections:De}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:C(160),sections:De}).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}`),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`]})}},Oe=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:Oe,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(),ke=I.superRefine((e,t)=>A(e,t,se,oe)),Ae=e.object({label:C(48).optional(),value:C(d)}).strict(),je=e.discriminatedUnion(`key`,[P.options[0].extend({body:Ae}),P.options[1].extend({body:Ae})]),Me=I.extend({contractVersion:e.literal(4),message:I.shape.message.extend({variants:e.array(je).min(1).max(2).superRefine(F)})}).superRefine((e,t)=>A(e,t,ce,d)),L=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`})})})]),Ne=e.object({value:C(f)}).strict(),R=e.object({contractVersion:e.literal(5),...k,message:e.object({type:e.literal(`structured_notification`),variants:e.array(L).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:Ne}).strict()}).strict().superRefine((e,t)=>{A(e,t,g,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`]})}}),z=e.object({...R.shape,contractVersion:e.literal(6),message:R.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`,[L.options[0].omit({bodyLabel:!0}).extend({sections:N,bodyRefs:e.array(e.object({key:e.string().regex(S),label:C(48).optional()}).strict()).max(2),footer:C(500).optional()}),L.options[1].omit({bodyLabel:!0}).extend({sections:N,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(B);function B(e,t){A(e,t,g,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`}),Pe(e.message.variants,n,r,t)}function Pe(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 Fe=e.array(D).min(1).superRefine((e,t)=>{new Set(e).size!==e.length&&t.addIssue({code:`custom`,message:`route_key_duplicate`})}),{routeKey:Ie,...Le}=z.shape,V=z.shape.message,H=e.object({...Le,contractVersion:e.literal(7),routeKeys:Fe,message:V}).strict().superRefine(B),U=e.object({...H.shape,contractVersion:e.literal(8),message:V.extend({channelVariants:e.partialRecord(e.enum(x),V.shape.variants).optional()})}).strict().superRefine((e,t)=>{B(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}),Pe(o,r,i,t,s)}}),Re=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(),W=e.object({...U.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(Re).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=U.safeParse({...i,contractVersion:8});if(a.success)A(e,t,g,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`]})}),G=e.object({offset:e.number().int().nonnegative(),length:e.number().int().positive()}).strict();function K(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 ze=M.options[0].extend({quotes:e.array(G).optional()}).superRefine((e,t)=>K(e.value,e.quotes,t,[`quotes`])),Be=e.discriminatedUnion(`type`,[ze,M.options[1]]),Ve=e.array(Be).max(30),He={titleQuotes:e.array(G).optional(),sections:Ve},Ue=e.array(e.discriminatedUnion(`key`,[V.shape.variants.element.options[0].extend(He),V.shape.variants.element.options[1].extend(He)])).min(1).max(2).superRefine((e,t)=>{for(let[n,r]of e.entries())K(r.title,r.titleQuotes,t,[n,`titleQuotes`])}),q=U.shape.message.extend({bodies:e.array(V.shape.bodies.element.extend({quotes:e.array(G).optional()}).superRefine((e,t)=>K(e.value,e.quotes,t,[`quotes`]))).max(2),variants:Ue,channelVariants:e.partialRecord(e.enum(x),Ue).optional()});function We(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 J=e.object({...W.shape,contractVersion:e.literal(10),message:q}).strict().superRefine((e,t)=>{let n=W.safeParse({...e,contractVersion:9,message:{...e.message,bodies:e.message.bodies.map(({quotes:e,...t})=>t),variants:e.message.variants.map(We),...e.message.channelVariants===void 0?{}:{channelVariants:Object.fromEntries(Object.entries(e.message.channelVariants).map(([e,t])=>[e,t.map(We)]))}}});if(!n.success){for(let e of n.error.issues)t.addIssue({...e});return}let{audience:r,browserMessages:i,...a}=e;A(a,t,g,f),A(e,t,g,m)}),Ge=e.object({qq:e.enum([`auto`,`markdown`,`plain_text`]).optional(),tg:e.enum([`auto`,`rich_text`,`plain_text`]).optional()}).strict(),Ke=e.object({...J.shape,contractVersion:e.literal(11),message:q.extend({channelFormats:Ge.optional(),channelBodies:e.partialRecord(e.enum(x),q.shape.bodies).optional(),channelLinks:e.partialRecord(e.enum(x),q.shape.links).optional()})}).strict().superRefine((e,t)=>{let{channelFormats:n,channelBodies:r,channelLinks:i,...a}=e.message,o=J.safeParse({...e,contractVersion:10,message:a});if(!o.success){for(let e of o.error.issues)t.addIssue({...e});return}let s=a.bodies.map(e=>e.key).sort(),c=a.links.map(e=>e.key);for(let n of x){let r=e.message.channelBodies?.[n],i=e.message.channelLinks?.[n];r!==void 0&&JSON.stringify(r.map(e=>e.key).sort())!==JSON.stringify(s)&&t.addIssue({code:`custom`,message:`message_channel_body_keys_mismatch`,path:[`message`,`channelBodies`,n]}),i!==void 0&&JSON.stringify(i.map(e=>e.key))!==JSON.stringify(c)&&t.addIssue({code:`custom`,message:`message_channel_link_keys_mismatch`,path:[`message`,`channelLinks`,n]})}A(e,t,g,h)});function qe(e){return`routeKeys`in e?[...e.routeKeys].sort():[e.routeKey]}const Je=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(_),sourceUrl:O.shape.url.optional()}).strict(),Ye=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:Je}).strict().superRefine((e,t)=>A(e,t,ue,_)),Xe=Ye,Ze=e.union([j,Ee,ke,Me,R,z,H,U,W,J,Ke]),Qe=e.object({destinationKey:e.string().min(1),state:e.enum(b),attempts:e.number().int().min(0).max(4),failureCode:e.enum(me).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(v),reason:e.enum(y),terminal:e.boolean(),acceptedAt:w,updatedAt:w,deliverBy:w,terminalAt:w.nullable(),destinations:e.array(Qe).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(),$e=X.extend({cause:X.extend({cause:X.extend({cause:X.optional()}).optional()}).optional()}),et=Qe.extend({state:e.enum(pe),attempts:e.number().int().min(0),revision:e.number().int().min(0),cause:$e.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(et).min(1).max(20)}),tt=Z.omit({routeKey:!0}).extend({contractVersion:e.literal(3),routeKeys:Fe}),Q=e.union([Y,Z,tt]),nt=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(ge)}).strict(),rt=e.object({code:e.literal(`invalid_request`),issues:e.array(nt).max(20).optional()}).strict(),it=e.object({code:e.enum(he.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([rt,it]),at=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Y}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),ot=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()]),st=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),ct=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,_ as localTaskDeliveryRequestMaximumUtf8BytesV1,Xe as localTaskDeliveryRequestSchema,Ye as localTaskDeliveryRequestV1Schema,Re as notificationBrowserMessageSchema,t as notificationBrowserPayloadSchema,Ge as notificationChannelFormatsSchema,at as notificationDeliverResultV1Schema,st as notificationDeliverResultV2Schema,x as notificationDeliveryChannelKeys,n as notificationDeliveryContractVersionV1,te as notificationDeliveryContractVersionV10,ne as notificationDeliveryContractVersionV11,r as notificationDeliveryContractVersionV2,i as notificationDeliveryContractVersionV3,a as notificationDeliveryContractVersionV4,o as notificationDeliveryContractVersionV5,s as notificationDeliveryContractVersionV7,c as notificationDeliveryContractVersionV8,ee as notificationDeliveryContractVersionV9,u as notificationDeliveryMaximumDeadlineMillisecondsV1,ae as notificationDeliveryMaximumDeadlineMillisecondsV2,se as notificationDeliveryMaximumDeadlineMillisecondsV3,ce as notificationDeliveryMaximumDeadlineMillisecondsV4,g as notificationDeliveryMaximumDeadlineMillisecondsV5,re as notificationDeliveryMaximumDestinationsV1,y as notificationDeliveryReasonsV1,fe as notificationDeliveryReasonsV2,Y as notificationDeliveryReceiptV1Schema,Z as notificationDeliveryReceiptV2Schema,tt as notificationDeliveryReceiptV3Schema,he as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,l as notificationDeliveryRequestMaximumUtf8BytesV1,m as notificationDeliveryRequestMaximumUtf8BytesV10,h as notificationDeliveryRequestMaximumUtf8BytesV11,ie as notificationDeliveryRequestMaximumUtf8BytesV2,oe as notificationDeliveryRequestMaximumUtf8BytesV3,d as notificationDeliveryRequestMaximumUtf8BytesV4,f as notificationDeliveryRequestMaximumUtf8BytesV5,p as notificationDeliveryRequestMaximumUtf8BytesV9,Ze as notificationDeliveryRequestSchema,J as notificationDeliveryRequestV10Schema,Ke as notificationDeliveryRequestV11Schema,j as notificationDeliveryRequestV1Schema,Ee as notificationDeliveryRequestV2Schema,ke as notificationDeliveryRequestV3Schema,Me as notificationDeliveryRequestV4Schema,R as notificationDeliveryRequestV5Schema,z as notificationDeliveryRequestV6Schema,H as notificationDeliveryRequestV7Schema,U as notificationDeliveryRequestV8Schema,W as notificationDeliveryRequestV9Schema,v as notificationDeliveryStatesV1,de as notificationDeliveryStatesV2,me as notificationDestinationFailureCodesV1,b as notificationDestinationStatesV1,pe as notificationDestinationStatesV2,ot as notificationGetReceiptResultV1Schema,ct as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,_e as notificationMessageVariantKeys,G as notificationQuoteRangeSchema,qe as notificationRouteKeys,ge as notificationValidationIssueCodesV1,$e as safeDeliveryCauseSchema};