@closerepo/notification-contracts 1.5.0 → 1.6.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 +74 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ declare const notificationDeliveryRequestMaximumUtf8BytesV4: number;
|
|
|
15
15
|
declare const notificationDeliveryMaximumDeadlineMillisecondsV4: number;
|
|
16
16
|
declare const notificationDeliveryRequestMaximumUtf8BytesV5: number;
|
|
17
17
|
declare const notificationDeliveryMaximumDeadlineMillisecondsV5: number;
|
|
18
|
+
declare const localTaskDeliveryContractVersionV1: 1;
|
|
19
|
+
declare const localTaskDeliveryRequestMaximumUtf8BytesV1: number;
|
|
20
|
+
declare const localTaskDeliveryMaximumDeadlineMillisecondsV1: number;
|
|
18
21
|
declare const notificationDeliveryStatesV1: readonly ["pending", "delivering", "partial", "delivered", "failed", "expired"];
|
|
19
22
|
declare const notificationDeliveryReasonsV1: readonly ["accepted", "enqueue_retry_wait", "in_progress", "partial_delivery", "complete", "retry_exhausted", "delivery_deadline_exceeded", "destination_configuration_unavailable"];
|
|
20
23
|
declare const notificationDestinationStatesV1: readonly ["pending", "delivering", "delivered", "failed", "expired"];
|
|
@@ -446,6 +449,63 @@ declare const notificationDeliveryRequestV6Schema: z.ZodObject<{
|
|
|
446
449
|
}, z.core.$strict>;
|
|
447
450
|
}, z.core.$strict>;
|
|
448
451
|
type NotificationDeliveryRequestV6 = z.infer<typeof notificationDeliveryRequestV6Schema>;
|
|
452
|
+
declare const creatorDraftTaskV1Schema: z.ZodObject<{
|
|
453
|
+
type: z.ZodLiteral<"creator.draft.v1">;
|
|
454
|
+
templateId: z.ZodString;
|
|
455
|
+
signalType: z.ZodString;
|
|
456
|
+
sourceTextZh: z.ZodString;
|
|
457
|
+
sourceUrl: z.ZodOptional<z.ZodString>;
|
|
458
|
+
}, z.core.$strict>;
|
|
459
|
+
declare const localTaskDeliveryRequestV1Schema: z.ZodObject<{
|
|
460
|
+
contractVersion: z.ZodLiteral<1>;
|
|
461
|
+
eventType: z.ZodLiteral<"local-task.delivery.requested">;
|
|
462
|
+
eventId: z.ZodString;
|
|
463
|
+
producer: z.ZodObject<{
|
|
464
|
+
key: z.ZodString;
|
|
465
|
+
environment: z.ZodString;
|
|
466
|
+
}, z.core.$strict>;
|
|
467
|
+
routeKey: z.ZodString;
|
|
468
|
+
occurredAt: z.ZodString;
|
|
469
|
+
requestedAt: z.ZodString;
|
|
470
|
+
deliverBy: z.ZodString;
|
|
471
|
+
subject: z.ZodObject<{
|
|
472
|
+
id: z.ZodString;
|
|
473
|
+
revision: z.ZodNumber;
|
|
474
|
+
type: z.ZodLiteral<"creator-event">;
|
|
475
|
+
}, z.core.$strict>;
|
|
476
|
+
task: z.ZodObject<{
|
|
477
|
+
type: z.ZodLiteral<"creator.draft.v1">;
|
|
478
|
+
templateId: z.ZodString;
|
|
479
|
+
signalType: z.ZodString;
|
|
480
|
+
sourceTextZh: z.ZodString;
|
|
481
|
+
sourceUrl: z.ZodOptional<z.ZodString>;
|
|
482
|
+
}, z.core.$strict>;
|
|
483
|
+
}, z.core.$strict>;
|
|
484
|
+
declare const localTaskDeliveryRequestSchema: z.ZodObject<{
|
|
485
|
+
contractVersion: z.ZodLiteral<1>;
|
|
486
|
+
eventType: z.ZodLiteral<"local-task.delivery.requested">;
|
|
487
|
+
eventId: z.ZodString;
|
|
488
|
+
producer: z.ZodObject<{
|
|
489
|
+
key: z.ZodString;
|
|
490
|
+
environment: z.ZodString;
|
|
491
|
+
}, z.core.$strict>;
|
|
492
|
+
routeKey: z.ZodString;
|
|
493
|
+
occurredAt: z.ZodString;
|
|
494
|
+
requestedAt: z.ZodString;
|
|
495
|
+
deliverBy: z.ZodString;
|
|
496
|
+
subject: z.ZodObject<{
|
|
497
|
+
id: z.ZodString;
|
|
498
|
+
revision: z.ZodNumber;
|
|
499
|
+
type: z.ZodLiteral<"creator-event">;
|
|
500
|
+
}, z.core.$strict>;
|
|
501
|
+
task: z.ZodObject<{
|
|
502
|
+
type: z.ZodLiteral<"creator.draft.v1">;
|
|
503
|
+
templateId: z.ZodString;
|
|
504
|
+
signalType: z.ZodString;
|
|
505
|
+
sourceTextZh: z.ZodString;
|
|
506
|
+
sourceUrl: z.ZodOptional<z.ZodString>;
|
|
507
|
+
}, z.core.$strict>;
|
|
508
|
+
}, z.core.$strict>;
|
|
449
509
|
declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
450
510
|
message: z.ZodObject<{
|
|
451
511
|
type: z.ZodLiteral<"link_summary">;
|
|
@@ -1069,6 +1129,12 @@ type NotificationDeliveryReceiptV1 = z.infer<typeof notificationDeliveryReceiptV
|
|
|
1069
1129
|
type NotificationDeliveryRejectionV1 = z.infer<typeof notificationDeliveryRejectionV1Schema>;
|
|
1070
1130
|
type NotificationDeliverResultV1 = z.infer<typeof notificationDeliverResultV1Schema>;
|
|
1071
1131
|
type NotificationGetReceiptResultV1 = z.infer<typeof notificationGetReceiptResultV1Schema>;
|
|
1132
|
+
type CreatorDraftTaskV1 = z.infer<typeof creatorDraftTaskV1Schema>;
|
|
1133
|
+
type LocalTaskDeliveryRequestV1 = z.infer<typeof localTaskDeliveryRequestV1Schema>;
|
|
1134
|
+
type LocalTaskDeliveryRequest = z.infer<typeof localTaskDeliveryRequestSchema>;
|
|
1135
|
+
type LocalTaskDeliveryReceiptV1 = NotificationDeliveryReceiptV1;
|
|
1136
|
+
type LocalTaskDeliverResultV1 = NotificationDeliverResultV1;
|
|
1137
|
+
type LocalTaskGetReceiptResultV1 = NotificationGetReceiptResultV1;
|
|
1072
1138
|
/** Private Service Binding contract implemented by a Notification producer entrypoint. */
|
|
1073
1139
|
interface NotificationDeliveryServiceV1 {
|
|
1074
1140
|
deliver: (request: NotificationDeliveryRequestV1) => Promise<NotificationDeliverResultV1>;
|
|
@@ -1079,5 +1145,12 @@ interface NotificationDeliveryServiceV2 {
|
|
|
1079
1145
|
deliver: (request: NotificationDeliveryRequest) => Promise<NotificationDeliverResultV1>;
|
|
1080
1146
|
getReceipt: (eventId: string) => Promise<NotificationGetReceiptResultV1>;
|
|
1081
1147
|
}
|
|
1148
|
+
/** Private Service Binding contract for profile-routed local tasks. */
|
|
1149
|
+
interface LocalTaskDeliveryServiceV1 {
|
|
1150
|
+
deliverTask: (request: LocalTaskDeliveryRequest) => Promise<LocalTaskDeliverResultV1>;
|
|
1151
|
+
getTaskReceipt: (eventId: string) => Promise<LocalTaskGetReceiptResultV1>;
|
|
1152
|
+
}
|
|
1153
|
+
/** Private Service Binding supporting notifications and profile-routed local tasks. */
|
|
1154
|
+
interface NotificationDeliveryServiceV3 extends NotificationDeliveryServiceV2, LocalTaskDeliveryServiceV1 {}
|
|
1082
1155
|
//#endregion
|
|
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 };
|
|
1156
|
+
export { CreatorDraftTaskV1, LocalTaskDeliverResultV1, LocalTaskDeliveryReceiptV1, LocalTaskDeliveryRequest, LocalTaskDeliveryRequestV1, LocalTaskDeliveryServiceV1, LocalTaskGetReceiptResultV1, NotificationDeliverResultV1, NotificationDeliveryReceiptV1, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryRequestV4, NotificationDeliveryRequestV5, NotificationDeliveryRequestV6, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationDeliveryServiceV3, NotificationGetReceiptResultV1, NotificationMessageBody, NotificationMessageVariantKey, NotificationSharedMessageBody, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, localTaskDeliveryContractVersionV1, localTaskDeliveryMaximumDeadlineMillisecondsV1, localTaskDeliveryRequestMaximumUtf8BytesV1, localTaskDeliveryRequestSchema, localTaskDeliveryRequestV1Schema, 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`],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};
|
|
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,ee=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=[`pending`,`delivering`,`delivered`,`failed`,`expired`],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`],C=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],te=[`source`,`zh-CN`],ne=new TextEncoder,w=/^[a-z][a-z0-9-]{0,62}$/,re=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,T=/^[A-Z0-9][\w.:-]{0,127}$/i;function E(e){return[...e].length}function D(t){return e.string().refine(e=>E(e)>0,{message:`too_small`}).refine(e=>E(e)<=t,{message:`too_big`})}const O=e.string().datetime({offset:!0}),k=e.object({key:e.string().regex(w),environment:e.string().regex(w)}).strict(),A=e.object({type:e.string().regex(w),id:e.string().regex(T),revision:e.number().int().positive()}).strict(),j=e.string().min(1).max(127).regex(re),M=e.object({label:D(48),url:D(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(),N={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:k,routeKey:j,occurredAt:O,requestedAt:O,deliverBy:O,subject:A},ie=e.object({contractVersion:e.literal(1),...N,message:e.object({type:e.literal(`link_summary`),title:D(160),summary:D(1200),facts:e.array(e.object({label:D(48),value:D(500)}).strict()).max(10),primaryLink:M,sourceLink:M.optional()}).strict()}).strict();function P(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`]}),ne.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const F=ie.superRefine((e,t)=>P(e,t,s,o)),I={title:D(160),summary:D(1200),facts:e.array(e.object({label:D(48),value:D(500)}).strict()).max(10)},ae=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...I}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...I}).strict()]),oe=e.array(ae).min(1).max(2).superRefine((e,t)=>{e.filter(e=>e.key===`source`).length!==1&&t.addIssue({code:`custom`,message:`source_variant_required_once`}),new Set(e.map(e=>e.key)).size!==e.length&&t.addIssue({code:`custom`,message:`message_variant_duplicate`})}),L=e.object({contractVersion:e.literal(2),...N,message:e.object({type:e.literal(`localized_link_summary`),variants:oe,primaryLink:M,sourceLink:M.optional()}).strict()}).strict().superRefine((e,t)=>P(e,t,l,c)),R=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(w),type:e.literal(`text`),label:D(48).optional(),value:D(4e3)}).strict(),e.object({key:e.string().regex(w),type:e.literal(`fields`),items:e.array(e.object({label:D(48),value:D(1200)}).strict()).min(1).max(20)}).strict()]),z=e.array(R).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`})}),B=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:D(160),sections:z}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:D(160),sections:z}).strict()]),V=(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`]})}},se=e.array(B).min(1).max(2).superRefine(V),H=e.object({contractVersion:e.literal(3),...N,message:e.object({type:e.literal(`structured_notification`),variants:se,links:e.array(e.object({key:e.string().regex(w),...M.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(),U=H.superRefine((e,t)=>P(e,t,d,u)),W=e.object({label:D(48).optional(),value:D(f)}).strict(),G=e.discriminatedUnion(`key`,[B.options[0].extend({body:W}),B.options[1].extend({body:W})]),K=H.extend({contractVersion:e.literal(4),message:H.shape.message.extend({variants:e.array(G).min(1).max(2).superRefine(V)})}).superRefine((e,t)=>P(e,t,p,f)),q=e.discriminatedUnion(`key`,[B.options[0].extend({bodyLabel:D(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(w),label:D(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`})})}),B.options[1].extend({bodyLabel:D(48).optional(),linkLabels:e.array(e.object({key:e.string().regex(w),label:D(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`})})})]),ce=e.object({value:D(m)}).strict(),J=e.object({contractVersion:e.literal(5),...N,message:e.object({type:e.literal(`structured_notification`),variants:e.array(q).min(1).max(2).superRefine(V),links:e.array(e.object({key:e.string().regex(w),url:M.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:ce}).strict()}).strict().superRefine((e,t)=>{P(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`]})}}),Y=e.object({...J.shape,contractVersion:e.literal(6),message:J.shape.message.omit({body:!0}).extend({bodies:e.array(e.object({key:e.string().regex(w),value:D(m)}).strict()).min(1).max(2),variants:e.array(e.discriminatedUnion(`key`,[q.options[0].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(w),label:D(48)}).strict()).min(1).max(2),footer:D(500)}),q.options[1].omit({bodyLabel:!0}).extend({bodyRefs:e.array(e.object({key:e.string().regex(w),label:D(48)}).strict()).min(1).max(2),footer:D(500)})])).min(1).max(2).superRefine(V)})}).strict().superRefine((e,t)=>{P(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`})}}),le=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:D(g),sourceUrl:M.shape.url.optional()}).strict(),X=e.object({contractVersion:e.literal(1),eventType:e.literal(`local-task.delivery.requested`),eventId:e.string().uuid(),producer:k,routeKey:j,occurredAt:O,requestedAt:O,deliverBy:O,subject:A.extend({type:e.literal(`creator-event`)}),task:le}).strict().superRefine((e,t)=>P(e,t,_,g)),ue=X,de=e.union([F,L,U,K,J,Y]),Z=e.object({destinationKey:e.string().min(1),state:e.enum(b),attempts:e.number().int().min(0).max(4),failureCode:e.enum(x).nullable(),lastAttemptAt:O.nullable(),nextAttemptAt:O.nullable(),leaseExpiresAt:O.nullable()}).strict(),Q=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:k,routeKey:j,subject:A,state:e.enum(v),reason:e.enum(y),terminal:e.boolean(),acceptedAt:O,updatedAt:O,deliverBy:O,terminalAt:O.nullable(),destinations:e.array(Z).min(1).max(20)}).strict(),fe=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(C)}).strict(),pe=e.object({code:e.literal(`invalid_request`),issues:e.array(fe).max(20).optional()}).strict(),me=e.object({code:e.enum(S.filter(e=>e!==`invalid_request`))}).strict(),$=e.union([pe,me]),he=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:Q}).strict(),e.object({status:e.literal(`rejected`),error:$}).strict()]),ge=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{ee as localTaskDeliveryContractVersionV1,_ as localTaskDeliveryMaximumDeadlineMillisecondsV1,g as localTaskDeliveryRequestMaximumUtf8BytesV1,ue as localTaskDeliveryRequestSchema,X as localTaskDeliveryRequestV1Schema,he 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,y as notificationDeliveryReasonsV1,Q as notificationDeliveryReceiptV1Schema,S as notificationDeliveryRejectionCodesV1,$ as notificationDeliveryRejectionV1Schema,o as notificationDeliveryRequestMaximumUtf8BytesV1,c as notificationDeliveryRequestMaximumUtf8BytesV2,u as notificationDeliveryRequestMaximumUtf8BytesV3,f as notificationDeliveryRequestMaximumUtf8BytesV4,m as notificationDeliveryRequestMaximumUtf8BytesV5,de as notificationDeliveryRequestSchema,F as notificationDeliveryRequestV1Schema,L as notificationDeliveryRequestV2Schema,U as notificationDeliveryRequestV3Schema,K as notificationDeliveryRequestV4Schema,J as notificationDeliveryRequestV5Schema,Y as notificationDeliveryRequestV6Schema,v as notificationDeliveryStatesV1,x as notificationDestinationFailureCodesV1,b as notificationDestinationStatesV1,ge as notificationGetReceiptResultV1Schema,te as notificationMessageVariantKeys,C as notificationValidationIssueCodesV1};
|