@closerepo/notification-contracts 1.4.0 → 1.5.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 +165 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -363,6 +363,89 @@ declare const notificationDeliveryRequestV5Schema: z.ZodObject<{
|
|
|
363
363
|
}, z.core.$strict>;
|
|
364
364
|
contractVersion: z.ZodLiteral<5>;
|
|
365
365
|
}, z.core.$strict>;
|
|
366
|
+
declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
|
|
367
|
+
contractVersion: z.ZodLiteral<6>;
|
|
368
|
+
message: z.ZodObject<{
|
|
369
|
+
type: z.ZodLiteral<"structured_notification">;
|
|
370
|
+
links: z.ZodArray<z.ZodObject<{
|
|
371
|
+
key: z.ZodString;
|
|
372
|
+
url: z.ZodString;
|
|
373
|
+
}, z.core.$strict>>;
|
|
374
|
+
bodies: z.ZodArray<z.ZodObject<{
|
|
375
|
+
key: z.ZodString;
|
|
376
|
+
value: z.ZodString;
|
|
377
|
+
}, z.core.$strict>>;
|
|
378
|
+
variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
379
|
+
key: z.ZodLiteral<"source">;
|
|
380
|
+
title: z.ZodString;
|
|
381
|
+
locale: z.ZodLiteral<"und">;
|
|
382
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
383
|
+
key: z.ZodString;
|
|
384
|
+
type: z.ZodLiteral<"text">;
|
|
385
|
+
label: z.ZodOptional<z.ZodString>;
|
|
386
|
+
value: z.ZodString;
|
|
387
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
388
|
+
key: z.ZodString;
|
|
389
|
+
type: z.ZodLiteral<"fields">;
|
|
390
|
+
items: z.ZodArray<z.ZodObject<{
|
|
391
|
+
label: z.ZodString;
|
|
392
|
+
value: z.ZodString;
|
|
393
|
+
}, z.core.$strict>>;
|
|
394
|
+
}, z.core.$strict>], "type">>;
|
|
395
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
396
|
+
key: z.ZodString;
|
|
397
|
+
label: z.ZodString;
|
|
398
|
+
}, z.core.$strict>>;
|
|
399
|
+
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
400
|
+
key: z.ZodString;
|
|
401
|
+
label: z.ZodString;
|
|
402
|
+
}, z.core.$strict>>;
|
|
403
|
+
footer: z.ZodString;
|
|
404
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
405
|
+
key: z.ZodLiteral<"zh-CN">;
|
|
406
|
+
title: z.ZodString;
|
|
407
|
+
locale: z.ZodLiteral<"zh-CN">;
|
|
408
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
409
|
+
key: z.ZodString;
|
|
410
|
+
type: z.ZodLiteral<"text">;
|
|
411
|
+
label: z.ZodOptional<z.ZodString>;
|
|
412
|
+
value: z.ZodString;
|
|
413
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
414
|
+
key: z.ZodString;
|
|
415
|
+
type: z.ZodLiteral<"fields">;
|
|
416
|
+
items: z.ZodArray<z.ZodObject<{
|
|
417
|
+
label: z.ZodString;
|
|
418
|
+
value: z.ZodString;
|
|
419
|
+
}, z.core.$strict>>;
|
|
420
|
+
}, z.core.$strict>], "type">>;
|
|
421
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
422
|
+
key: z.ZodString;
|
|
423
|
+
label: z.ZodString;
|
|
424
|
+
}, z.core.$strict>>;
|
|
425
|
+
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
426
|
+
key: z.ZodString;
|
|
427
|
+
label: z.ZodString;
|
|
428
|
+
}, z.core.$strict>>;
|
|
429
|
+
footer: z.ZodString;
|
|
430
|
+
}, z.core.$strict>], "key">>;
|
|
431
|
+
}, z.core.$strict>;
|
|
432
|
+
eventType: z.ZodLiteral<"notification.delivery.requested">;
|
|
433
|
+
eventId: z.ZodString;
|
|
434
|
+
producer: z.ZodObject<{
|
|
435
|
+
key: z.ZodString;
|
|
436
|
+
environment: z.ZodString;
|
|
437
|
+
}, z.core.$strict>;
|
|
438
|
+
routeKey: z.ZodString;
|
|
439
|
+
occurredAt: z.ZodString;
|
|
440
|
+
requestedAt: z.ZodString;
|
|
441
|
+
deliverBy: z.ZodString;
|
|
442
|
+
subject: z.ZodObject<{
|
|
443
|
+
type: z.ZodString;
|
|
444
|
+
id: z.ZodString;
|
|
445
|
+
revision: z.ZodNumber;
|
|
446
|
+
}, z.core.$strict>;
|
|
447
|
+
}, z.core.$strict>;
|
|
448
|
+
type NotificationDeliveryRequestV6 = z.infer<typeof notificationDeliveryRequestV6Schema>;
|
|
366
449
|
declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
367
450
|
message: z.ZodObject<{
|
|
368
451
|
type: z.ZodLiteral<"link_summary">;
|
|
@@ -644,6 +727,87 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
644
727
|
revision: z.ZodNumber;
|
|
645
728
|
}, z.core.$strict>;
|
|
646
729
|
contractVersion: z.ZodLiteral<5>;
|
|
730
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
731
|
+
contractVersion: z.ZodLiteral<6>;
|
|
732
|
+
message: z.ZodObject<{
|
|
733
|
+
type: z.ZodLiteral<"structured_notification">;
|
|
734
|
+
links: z.ZodArray<z.ZodObject<{
|
|
735
|
+
key: z.ZodString;
|
|
736
|
+
url: z.ZodString;
|
|
737
|
+
}, z.core.$strict>>;
|
|
738
|
+
bodies: z.ZodArray<z.ZodObject<{
|
|
739
|
+
key: z.ZodString;
|
|
740
|
+
value: z.ZodString;
|
|
741
|
+
}, z.core.$strict>>;
|
|
742
|
+
variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
743
|
+
key: z.ZodLiteral<"source">;
|
|
744
|
+
title: z.ZodString;
|
|
745
|
+
locale: z.ZodLiteral<"und">;
|
|
746
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
747
|
+
key: z.ZodString;
|
|
748
|
+
type: z.ZodLiteral<"text">;
|
|
749
|
+
label: z.ZodOptional<z.ZodString>;
|
|
750
|
+
value: z.ZodString;
|
|
751
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
752
|
+
key: z.ZodString;
|
|
753
|
+
type: z.ZodLiteral<"fields">;
|
|
754
|
+
items: z.ZodArray<z.ZodObject<{
|
|
755
|
+
label: z.ZodString;
|
|
756
|
+
value: z.ZodString;
|
|
757
|
+
}, z.core.$strict>>;
|
|
758
|
+
}, z.core.$strict>], "type">>;
|
|
759
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
760
|
+
key: z.ZodString;
|
|
761
|
+
label: z.ZodString;
|
|
762
|
+
}, z.core.$strict>>;
|
|
763
|
+
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
764
|
+
key: z.ZodString;
|
|
765
|
+
label: z.ZodString;
|
|
766
|
+
}, z.core.$strict>>;
|
|
767
|
+
footer: z.ZodString;
|
|
768
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
769
|
+
key: z.ZodLiteral<"zh-CN">;
|
|
770
|
+
title: z.ZodString;
|
|
771
|
+
locale: z.ZodLiteral<"zh-CN">;
|
|
772
|
+
sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
773
|
+
key: z.ZodString;
|
|
774
|
+
type: z.ZodLiteral<"text">;
|
|
775
|
+
label: z.ZodOptional<z.ZodString>;
|
|
776
|
+
value: z.ZodString;
|
|
777
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
778
|
+
key: z.ZodString;
|
|
779
|
+
type: z.ZodLiteral<"fields">;
|
|
780
|
+
items: z.ZodArray<z.ZodObject<{
|
|
781
|
+
label: z.ZodString;
|
|
782
|
+
value: z.ZodString;
|
|
783
|
+
}, z.core.$strict>>;
|
|
784
|
+
}, z.core.$strict>], "type">>;
|
|
785
|
+
linkLabels: z.ZodArray<z.ZodObject<{
|
|
786
|
+
key: z.ZodString;
|
|
787
|
+
label: z.ZodString;
|
|
788
|
+
}, z.core.$strict>>;
|
|
789
|
+
bodyRefs: z.ZodArray<z.ZodObject<{
|
|
790
|
+
key: z.ZodString;
|
|
791
|
+
label: z.ZodString;
|
|
792
|
+
}, z.core.$strict>>;
|
|
793
|
+
footer: z.ZodString;
|
|
794
|
+
}, z.core.$strict>], "key">>;
|
|
795
|
+
}, z.core.$strict>;
|
|
796
|
+
eventType: z.ZodLiteral<"notification.delivery.requested">;
|
|
797
|
+
eventId: z.ZodString;
|
|
798
|
+
producer: z.ZodObject<{
|
|
799
|
+
key: z.ZodString;
|
|
800
|
+
environment: z.ZodString;
|
|
801
|
+
}, z.core.$strict>;
|
|
802
|
+
routeKey: z.ZodString;
|
|
803
|
+
occurredAt: z.ZodString;
|
|
804
|
+
requestedAt: z.ZodString;
|
|
805
|
+
deliverBy: z.ZodString;
|
|
806
|
+
subject: z.ZodObject<{
|
|
807
|
+
type: z.ZodString;
|
|
808
|
+
id: z.ZodString;
|
|
809
|
+
revision: z.ZodNumber;
|
|
810
|
+
}, z.core.$strict>;
|
|
647
811
|
}, z.core.$strict>]>;
|
|
648
812
|
declare const notificationDeliveryReceiptV1Schema: z.ZodObject<{
|
|
649
813
|
contractVersion: z.ZodLiteral<1>;
|
|
@@ -916,4 +1080,4 @@ interface NotificationDeliveryServiceV2 {
|
|
|
916
1080
|
getReceipt: (eventId: string) => Promise<NotificationGetReceiptResultV1>;
|
|
917
1081
|
}
|
|
918
1082
|
//#endregion
|
|
919
|
-
export { NotificationDeliverResultV1, NotificationDeliveryReceiptV1, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationGetReceiptResultV1, NotificationMessageBody, NotificationMessageVariantKey, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, notificationDeliverResultV1Schema, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryContractVersionV5, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryMaximumDeadlineMillisecondsV4, notificationDeliveryMaximumDeadlineMillisecondsV5, notificationDeliveryReasonsV1, notificationDeliveryReceiptV1Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestMaximumUtf8BytesV4, notificationDeliveryRequestMaximumUtf8BytesV5, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, notificationDeliveryRequestV4Schema, notificationDeliveryRequestV5Schema, notificationDeliveryStatesV1, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationGetReceiptResultV1Schema, notificationMessageVariantKeys, notificationValidationIssueCodesV1 };
|
|
1083
|
+
export { NotificationDeliverResultV1, NotificationDeliveryReceiptV1, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryRequestV6, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationGetReceiptResultV1, NotificationMessageBody, NotificationMessageVariantKey, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, notificationDeliverResultV1Schema, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryContractVersionV4, notificationDeliveryContractVersionV5, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryMaximumDeadlineMillisecondsV4, notificationDeliveryMaximumDeadlineMillisecondsV5, notificationDeliveryReasonsV1, notificationDeliveryReceiptV1Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestMaximumUtf8BytesV4, notificationDeliveryRequestMaximumUtf8BytesV5, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, notificationDeliveryRequestV4Schema, notificationDeliveryRequestV5Schema, notificationDeliveryRequestV6Schema, notificationDeliveryStatesV1, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationGetReceiptResultV1Schema, notificationMessageVariantKeys, notificationValidationIssueCodesV1 };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";const t=1,n=2,r=3,i=4,a=5,o=32*1024,s=1380*60*1e3,c=o,l=s,u=o,d=s,f=o,p=s,m=o,h=s,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=[`pending`,`delivering`,`delivered`,`failed`,`expired`],y=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],b=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],x=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],S=[`source`,`zh-CN`],ee=new TextEncoder,C=/^[a-z][a-z0-9-]{0,62}$/,te=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,ne=/^[A-Z0-9][\w.:-]{0,127}$/i;function w(e){return[...e].length}function T(t){return e.string().refine(e=>w(e)>0,{message:`too_small`}).refine(e=>w(e)<=t,{message:`too_big`})}const E=e.string().datetime({offset:!0}),D=e.object({key:e.string().regex(C),environment:e.string().regex(C)}).strict(),O=e.object({type:e.string().regex(C),id:e.string().regex(ne),revision:e.number().int().positive()}).strict(),k=e.string().min(1).max(127).regex(te),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},M=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 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`]}),ee.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const P=M.superRefine((e,t)=>N(e,t,s,o)),F={title:T(160),summary:T(1200),facts:e.array(e.object({label:T(48),value:T(500)}).strict()).max(10)},I=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()]),L=e.array(I).min(1).max(2).superRefine((e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`})}),R=e.object({contractVersion:e.literal(2),...j,message:e.object({type:e.literal(`localized_link_summary`),variants:L,primaryLink:A,sourceLink:A.optional()}).strict()}).strict().superRefine((e,t)=>N(e,t,l,c)),z=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(C),type:e.literal(`text`),label:T(48).optional(),value:T(4e3)}).strict(),e.object({key:e.string().regex(C),type:e.literal(`fields`),items:e.array(e.object({label:T(48),value:T(1200)}).strict()).min(1).max(20)}).strict()]),B=e.array(z).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`})}),V=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:T(160),sections:B}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:T(160),sections:B}).strict()]),H=(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`]})}},U=e.array(V).min(1).max(2).superRefine(H),W=e.object({contractVersion:e.literal(3),...j,message:e.object({type:e.literal(`structured_notification`),variants:U,links:e.array(e.object({key:e.string().regex(C),...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(),G=W.superRefine((e,t)=>N(e,t,d,u)),K=e.object({label:T(48).optional(),value:T(f)}).strict(),q=e.discriminatedUnion(`key`,[V.options[0].extend({body:K}),V.options[1].extend({body:K})]),J=W.extend({contractVersion:e.literal(4),message:W.shape.message.extend({variants:e.array(q).min(1).max(2).superRefine(H)})}).superRefine((e,t)=>N(e,t,p,f)),Y=e.discriminatedUnion(`key`,[V.options[0].extend({bodyLabel:T(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(C),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`})})}),V.options[1].extend({bodyLabel:T(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(C),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`})})})]),X=e.object({value:T(m)}).strict(),Z=e.object({contractVersion:e.literal(5),...j,message:e.object({type:e.literal(`structured_notification`),variants:e.array(Y).min(1).max(2).superRefine(H),links:e.array(e.object({key:e.string().regex(C),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:X}).strict()}).strict().superRefine((e,t)=>{N(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`]})}}),re=e.union([P,R,G,J,Z]),ie=e.object({destinationKey:e.string().min(1),state:e.enum(v),attempts:e.number().int().min(0).max(4),failureCode:e.enum(y).nullable(),lastAttemptAt:E.nullable(),nextAttemptAt:E.nullable(),leaseExpiresAt:E.nullable()}).strict(),Q=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:D,routeKey:k,subject:O,state:e.enum(g),reason:e.enum(_),terminal:e.boolean(),acceptedAt:E,updatedAt:E,deliverBy:E,terminalAt:E.nullable(),destinations:e.array(ie).min(1).max(20)}).strict(),ae=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(x)}).strict(),oe=e.object({code:e.literal(`invalid_request`),issues:e.array(ae).max(20).optional()}).strict(),se=e.object({code:e.enum(b.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([oe,se]),ce=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{ce as notificationDeliverResultV1Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,i as notificationDeliveryContractVersionV4,a as notificationDeliveryContractVersionV5,s as notificationDeliveryMaximumDeadlineMillisecondsV1,l as notificationDeliveryMaximumDeadlineMillisecondsV2,d as notificationDeliveryMaximumDeadlineMillisecondsV3,p as notificationDeliveryMaximumDeadlineMillisecondsV4,h as notificationDeliveryMaximumDeadlineMillisecondsV5,_ as notificationDeliveryReasonsV1,Q as notificationDeliveryReceiptV1Schema,b as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,o as notificationDeliveryRequestMaximumUtf8BytesV1,c as notificationDeliveryRequestMaximumUtf8BytesV2,u as notificationDeliveryRequestMaximumUtf8BytesV3,f as notificationDeliveryRequestMaximumUtf8BytesV4,m as notificationDeliveryRequestMaximumUtf8BytesV5,re as notificationDeliveryRequestSchema,P as notificationDeliveryRequestV1Schema,R as notificationDeliveryRequestV2Schema,G as notificationDeliveryRequestV3Schema,J as notificationDeliveryRequestV4Schema,Z as notificationDeliveryRequestV5Schema,g as notificationDeliveryStatesV1,y as notificationDestinationFailureCodesV1,v as notificationDestinationStatesV1,le as notificationGetReceiptResultV1Schema,S as notificationMessageVariantKeys,x as notificationValidationIssueCodesV1};
|
|
1
|
+
import{z as e}from"zod";const t=1,n=2,r=3,i=4,a=5,o=32*1024,s=1380*60*1e3,c=o,l=s,u=o,d=s,f=o,p=s,m=o,h=s,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=[`pending`,`delivering`,`delivered`,`failed`,`expired`],y=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],b=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],x=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],ee=[`source`,`zh-CN`],te=new TextEncoder,S=/^[a-z][a-z0-9-]{0,62}$/,C=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,w=/^[A-Z0-9][\w.:-]{0,127}$/i;function T(e){return[...e].length}function E(t){return e.string().refine(e=>T(e)>0,{message:`too_small`}).refine(e=>T(e)<=t,{message:`too_big`})}const D=e.string().datetime({offset:!0}),O=e.object({key:e.string().regex(S),environment:e.string().regex(S)}).strict(),k=e.object({type:e.string().regex(S),id:e.string().regex(w),revision:e.number().int().positive()}).strict(),A=e.string().min(1).max(127).regex(C),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},ne=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`]}),te.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const P=ne.superRefine((e,t)=>N(e,t,s,o)),F={title:E(160),summary:E(1200),facts:e.array(e.object({label:E(48),value:E(500)}).strict()).max(10)},I=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()]),L=e.array(I).min(1).max(2).superRefine((e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`})}),R=e.object({contractVersion:e.literal(2),...M,message:e.object({type:e.literal(`localized_link_summary`),variants:L,primaryLink:j,sourceLink:j.optional()}).strict()}).strict().superRefine((e,t)=>N(e,t,l,c)),z=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(S),type:e.literal(`text`),label:E(48).optional(),value:E(4e3)}).strict(),e.object({key:e.string().regex(S),type:e.literal(`fields`),items:e.array(e.object({label:E(48),value:E(1200)}).strict()).min(1).max(20)}).strict()]),B=e.array(z).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`})}),V=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:E(160),sections:B}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:E(160),sections:B}).strict()]),H=(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`]})}},re=e.array(V).min(1).max(2).superRefine(H),U=e.object({contractVersion:e.literal(3),...M,message:e.object({type:e.literal(`structured_notification`),variants:re,links:e.array(e.object({key:e.string().regex(S),...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(),W=U.superRefine((e,t)=>N(e,t,d,u)),G=e.object({label:E(48).optional(),value:E(f)}).strict(),K=e.discriminatedUnion(`key`,[V.options[0].extend({body:G}),V.options[1].extend({body:G})]),q=U.extend({contractVersion:e.literal(4),message:U.shape.message.extend({variants:e.array(K).min(1).max(2).superRefine(H)})}).superRefine((e,t)=>N(e,t,p,f)),J=e.discriminatedUnion(`key`,[V.options[0].extend({bodyLabel:E(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(S),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`})})}),V.options[1].extend({bodyLabel:E(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(S),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`})})})]),Y=e.object({value:E(m)}).strict(),X=e.object({contractVersion:e.literal(5),...M,message:e.object({type:e.literal(`structured_notification`),variants:e.array(J).min(1).max(2).superRefine(H),links:e.array(e.object({key:e.string().regex(S),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:Y}).strict()}).strict().superRefine((e,t)=>{N(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`]})}}),Z=e.object({...X.shape,contractVersion:e.literal(6),message:X.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(S),value:E(m)}).strict()).min(1).max(2),variants:e.array(e.discriminatedUnion(`key`,[J.options[0].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(S),label:E(48)}).strict()).min(1).max(2),footer:E(500)}),J.options[1].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(S),label:E(48)}).strict()).min(1).max(2),footer:E(500)})])).min(1).max(2).superRefine(H)})}).strict().superRefine((e,t)=>{N(e,t,h,m);let n=e.message.bodies.map(e=>e.key),r=e.message.links.map(e=>e.key);new Set(n).size!==n.length&&t.addIssue({code:`custom`,message:`message_body_duplicate`});for(let i of e.message.variants){let e=i.bodyRefs.map(e=>e.key);(new Set(e).size!==e.length||e.some(e=>!n.includes(e)))&&t.addIssue({code:`custom`,message:`message_body_reference_invalid`}),JSON.stringify(i.linkLabels.map(e=>e.key))!==JSON.stringify(r)&&t.addIssue({code:`custom`,message:`message_variant_link_labels_mismatch`})}}),ie=e.union([P,R,W,q,X,Z]),ae=e.object({destinationKey:e.string().min(1),state:e.enum(v),attempts:e.number().int().min(0).max(4),failureCode:e.enum(y).nullable(),lastAttemptAt:D.nullable(),nextAttemptAt:D.nullable(),leaseExpiresAt:D.nullable()}).strict(),Q=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(ae).min(1).max(20)}).strict(),oe=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(x)}).strict(),se=e.object({code:e.literal(`invalid_request`),issues:e.array(oe).max(20).optional()}).strict(),ce=e.object({code:e.enum(b.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([se,ce]),le=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),ue=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 notificationDeliverResultV1Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,i as notificationDeliveryContractVersionV4,a as notificationDeliveryContractVersionV5,s as notificationDeliveryMaximumDeadlineMillisecondsV1,l as notificationDeliveryMaximumDeadlineMillisecondsV2,d as notificationDeliveryMaximumDeadlineMillisecondsV3,p as notificationDeliveryMaximumDeadlineMillisecondsV4,h as notificationDeliveryMaximumDeadlineMillisecondsV5,_ as notificationDeliveryReasonsV1,Q as notificationDeliveryReceiptV1Schema,b as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,o as notificationDeliveryRequestMaximumUtf8BytesV1,c as notificationDeliveryRequestMaximumUtf8BytesV2,u as notificationDeliveryRequestMaximumUtf8BytesV3,f as notificationDeliveryRequestMaximumUtf8BytesV4,m as notificationDeliveryRequestMaximumUtf8BytesV5,ie as notificationDeliveryRequestSchema,P as notificationDeliveryRequestV1Schema,R as notificationDeliveryRequestV2Schema,W as notificationDeliveryRequestV3Schema,q as notificationDeliveryRequestV4Schema,X as notificationDeliveryRequestV5Schema,Z as notificationDeliveryRequestV6Schema,g as notificationDeliveryStatesV1,y as notificationDestinationFailureCodesV1,v as notificationDestinationStatesV1,ue as notificationGetReceiptResultV1Schema,ee as notificationMessageVariantKeys,x as notificationValidationIssueCodesV1};
|