@closerepo/notification-contracts 1.8.0 → 1.9.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 +1 -1
- package/package.json +1 -1
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,re=c,f=s,p=c,ie=1,m=32*1024,h=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`],ae=[`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,c,s)),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,ne,te)),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,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`]})}},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,u,l)),B=e.object({label:w(48).optional(),value:w(d)}).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,re,d)),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(f)}).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,p,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`]})}}),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(f)}).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((e,t)=>L(e,t,!0))})}).strict().superRefine(ye);function ye(e,t){j(e,t,p,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`});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((e,t)=>L(e,t,!0))})}).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(m),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,h,m)),Oe=De,ke=e.union([M,P,z,V,U,W,we]),Ae=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: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(g),reason:e.enum(_),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(x),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(v),reason:e.enum(y),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(ae.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{ie as localTaskDeliveryContractVersionV1,h as localTaskDeliveryMaximumDeadlineMillisecondsV1,m 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,o as notificationDeliveryContractVersionV7,c as notificationDeliveryMaximumDeadlineMillisecondsV1,ne as notificationDeliveryMaximumDeadlineMillisecondsV2,u as notificationDeliveryMaximumDeadlineMillisecondsV3,re as notificationDeliveryMaximumDeadlineMillisecondsV4,p as notificationDeliveryMaximumDeadlineMillisecondsV5,ee as notificationDeliveryMaximumDestinationsV1,_ as notificationDeliveryReasonsV1,y as notificationDeliveryReasonsV2,J as notificationDeliveryReceiptV1Schema,Z as notificationDeliveryReceiptV2Schema,Me as notificationDeliveryReceiptV3Schema,ae as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,s as notificationDeliveryRequestMaximumUtf8BytesV1,te as notificationDeliveryRequestMaximumUtf8BytesV2,l as notificationDeliveryRequestMaximumUtf8BytesV3,d as notificationDeliveryRequestMaximumUtf8BytesV4,f 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,g as notificationDeliveryStatesV1,v as notificationDeliveryStatesV2,S as notificationDestinationFailureCodesV1,b as notificationDestinationStatesV1,x as notificationDestinationStatesV2,Le as notificationGetReceiptResultV1Schema,ze as notificationGetReceiptResultV2Schema,Q as notificationMessageReceiptSchema,se as notificationMessageVariantKeys,Te as notificationRouteKeys,oe as notificationValidationIssueCodesV1,X as safeDeliveryCauseSchema};
|