@closerepo/notification-contracts 1.1.0 → 1.2.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 CHANGED
@@ -2,10 +2,13 @@ import { z } from "zod";
2
2
  //#region src/index.d.ts
3
3
  declare const notificationDeliveryContractVersionV1: 1;
4
4
  declare const notificationDeliveryContractVersionV2: 2;
5
+ declare const notificationDeliveryContractVersionV3: 3;
5
6
  declare const notificationDeliveryRequestMaximumUtf8BytesV1: number;
6
7
  declare const notificationDeliveryMaximumDeadlineMillisecondsV1: number;
7
8
  declare const notificationDeliveryRequestMaximumUtf8BytesV2: number;
8
9
  declare const notificationDeliveryMaximumDeadlineMillisecondsV2: number;
10
+ declare const notificationDeliveryRequestMaximumUtf8BytesV3: number;
11
+ declare const notificationDeliveryMaximumDeadlineMillisecondsV3: number;
9
12
  declare const notificationDeliveryStatesV1: readonly ["pending", "delivering", "partial", "delivered", "failed", "expired"];
10
13
  declare const notificationDeliveryReasonsV1: readonly ["accepted", "enqueue_retry_wait", "in_progress", "partial_delivery", "complete", "retry_exhausted", "delivery_deadline_exceeded", "destination_configuration_unavailable"];
11
14
  declare const notificationDestinationStatesV1: readonly ["pending", "delivering", "delivered", "failed", "expired"];
@@ -96,6 +99,115 @@ declare const notificationDeliveryRequestV2Schema: z.ZodObject<{
96
99
  }, z.core.$strict>;
97
100
  contractVersion: z.ZodLiteral<2>;
98
101
  }, z.core.$strict>;
102
+ declare const structuredMessageSectionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
103
+ key: z.ZodString;
104
+ type: z.ZodLiteral<"text">;
105
+ label: z.ZodOptional<z.ZodString>;
106
+ value: z.ZodString;
107
+ }, z.core.$strict>, z.ZodObject<{
108
+ key: z.ZodString;
109
+ type: z.ZodLiteral<"fields">;
110
+ items: z.ZodArray<z.ZodObject<{
111
+ label: z.ZodString;
112
+ value: z.ZodString;
113
+ }, z.core.$strict>>;
114
+ }, z.core.$strict>], "type">;
115
+ declare const structuredNotificationVariantSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
116
+ key: z.ZodLiteral<"source">;
117
+ locale: z.ZodLiteral<"und">;
118
+ title: z.ZodString;
119
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
120
+ key: z.ZodString;
121
+ type: z.ZodLiteral<"text">;
122
+ label: z.ZodOptional<z.ZodString>;
123
+ value: z.ZodString;
124
+ }, z.core.$strict>, z.ZodObject<{
125
+ key: z.ZodString;
126
+ type: z.ZodLiteral<"fields">;
127
+ items: z.ZodArray<z.ZodObject<{
128
+ label: z.ZodString;
129
+ value: z.ZodString;
130
+ }, z.core.$strict>>;
131
+ }, z.core.$strict>], "type">>;
132
+ }, z.core.$strict>, z.ZodObject<{
133
+ key: z.ZodLiteral<"zh-CN">;
134
+ locale: z.ZodLiteral<"zh-CN">;
135
+ title: z.ZodString;
136
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
137
+ key: z.ZodString;
138
+ type: z.ZodLiteral<"text">;
139
+ label: z.ZodOptional<z.ZodString>;
140
+ value: z.ZodString;
141
+ }, z.core.$strict>, z.ZodObject<{
142
+ key: z.ZodString;
143
+ type: z.ZodLiteral<"fields">;
144
+ items: z.ZodArray<z.ZodObject<{
145
+ label: z.ZodString;
146
+ value: z.ZodString;
147
+ }, z.core.$strict>>;
148
+ }, z.core.$strict>], "type">>;
149
+ }, z.core.$strict>], "key">;
150
+ declare const notificationDeliveryRequestV3Schema: z.ZodObject<{
151
+ message: z.ZodObject<{
152
+ type: z.ZodLiteral<"structured_notification">;
153
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
154
+ key: z.ZodLiteral<"source">;
155
+ locale: z.ZodLiteral<"und">;
156
+ title: z.ZodString;
157
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
158
+ key: z.ZodString;
159
+ type: z.ZodLiteral<"text">;
160
+ label: z.ZodOptional<z.ZodString>;
161
+ value: z.ZodString;
162
+ }, z.core.$strict>, z.ZodObject<{
163
+ key: z.ZodString;
164
+ type: z.ZodLiteral<"fields">;
165
+ items: z.ZodArray<z.ZodObject<{
166
+ label: z.ZodString;
167
+ value: z.ZodString;
168
+ }, z.core.$strict>>;
169
+ }, z.core.$strict>], "type">>;
170
+ }, z.core.$strict>, z.ZodObject<{
171
+ key: z.ZodLiteral<"zh-CN">;
172
+ locale: z.ZodLiteral<"zh-CN">;
173
+ title: z.ZodString;
174
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
175
+ key: z.ZodString;
176
+ type: z.ZodLiteral<"text">;
177
+ label: z.ZodOptional<z.ZodString>;
178
+ value: z.ZodString;
179
+ }, z.core.$strict>, z.ZodObject<{
180
+ key: z.ZodString;
181
+ type: z.ZodLiteral<"fields">;
182
+ items: z.ZodArray<z.ZodObject<{
183
+ label: z.ZodString;
184
+ value: z.ZodString;
185
+ }, z.core.$strict>>;
186
+ }, z.core.$strict>], "type">>;
187
+ }, z.core.$strict>], "key">>;
188
+ links: z.ZodArray<z.ZodObject<{
189
+ label: z.ZodString;
190
+ url: z.ZodString;
191
+ key: z.ZodString;
192
+ }, z.core.$strict>>;
193
+ }, z.core.$strict>;
194
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
195
+ eventId: z.ZodString;
196
+ producer: z.ZodObject<{
197
+ key: z.ZodString;
198
+ environment: z.ZodString;
199
+ }, z.core.$strict>;
200
+ routeKey: z.ZodString;
201
+ occurredAt: z.ZodString;
202
+ requestedAt: z.ZodString;
203
+ deliverBy: z.ZodString;
204
+ subject: z.ZodObject<{
205
+ type: z.ZodString;
206
+ id: z.ZodString;
207
+ revision: z.ZodNumber;
208
+ }, z.core.$strict>;
209
+ contractVersion: z.ZodLiteral<3>;
210
+ }, z.core.$strict>;
99
211
  declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObject<{
100
212
  message: z.ZodObject<{
101
213
  type: z.ZodLiteral<"link_summary">;
@@ -177,6 +289,66 @@ declare const notificationDeliveryRequestSchema: z.ZodUnion<readonly [z.ZodObjec
177
289
  revision: z.ZodNumber;
178
290
  }, z.core.$strict>;
179
291
  contractVersion: z.ZodLiteral<2>;
292
+ }, z.core.$strict>, z.ZodObject<{
293
+ message: z.ZodObject<{
294
+ type: z.ZodLiteral<"structured_notification">;
295
+ variants: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
296
+ key: z.ZodLiteral<"source">;
297
+ locale: z.ZodLiteral<"und">;
298
+ title: z.ZodString;
299
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
300
+ key: z.ZodString;
301
+ type: z.ZodLiteral<"text">;
302
+ label: z.ZodOptional<z.ZodString>;
303
+ value: z.ZodString;
304
+ }, z.core.$strict>, z.ZodObject<{
305
+ key: z.ZodString;
306
+ type: z.ZodLiteral<"fields">;
307
+ items: z.ZodArray<z.ZodObject<{
308
+ label: z.ZodString;
309
+ value: z.ZodString;
310
+ }, z.core.$strict>>;
311
+ }, z.core.$strict>], "type">>;
312
+ }, z.core.$strict>, z.ZodObject<{
313
+ key: z.ZodLiteral<"zh-CN">;
314
+ locale: z.ZodLiteral<"zh-CN">;
315
+ title: z.ZodString;
316
+ sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
317
+ key: z.ZodString;
318
+ type: z.ZodLiteral<"text">;
319
+ label: z.ZodOptional<z.ZodString>;
320
+ value: z.ZodString;
321
+ }, z.core.$strict>, z.ZodObject<{
322
+ key: z.ZodString;
323
+ type: z.ZodLiteral<"fields">;
324
+ items: z.ZodArray<z.ZodObject<{
325
+ label: z.ZodString;
326
+ value: z.ZodString;
327
+ }, z.core.$strict>>;
328
+ }, z.core.$strict>], "type">>;
329
+ }, z.core.$strict>], "key">>;
330
+ links: z.ZodArray<z.ZodObject<{
331
+ label: z.ZodString;
332
+ url: z.ZodString;
333
+ key: z.ZodString;
334
+ }, z.core.$strict>>;
335
+ }, z.core.$strict>;
336
+ eventType: z.ZodLiteral<"notification.delivery.requested">;
337
+ eventId: z.ZodString;
338
+ producer: z.ZodObject<{
339
+ key: z.ZodString;
340
+ environment: z.ZodString;
341
+ }, z.core.$strict>;
342
+ routeKey: z.ZodString;
343
+ occurredAt: z.ZodString;
344
+ requestedAt: z.ZodString;
345
+ deliverBy: z.ZodString;
346
+ subject: z.ZodObject<{
347
+ type: z.ZodString;
348
+ id: z.ZodString;
349
+ revision: z.ZodNumber;
350
+ }, z.core.$strict>;
351
+ contractVersion: z.ZodLiteral<3>;
180
352
  }, z.core.$strict>]>;
181
353
  declare const notificationDeliveryReceiptV1Schema: z.ZodObject<{
182
354
  contractVersion: z.ZodLiteral<1>;
@@ -425,8 +597,11 @@ declare const notificationGetReceiptResultV1Schema: z.ZodDiscriminatedUnion<[z.Z
425
597
  }, z.core.$strict>], "status">;
426
598
  type NotificationDeliveryRequestV1 = z.infer<typeof notificationDeliveryRequestV1Schema>;
427
599
  type NotificationDeliveryRequestV2 = z.infer<typeof notificationDeliveryRequestV2Schema>;
600
+ type NotificationDeliveryRequestV3 = z.infer<typeof notificationDeliveryRequestV3Schema>;
428
601
  type NotificationDeliveryRequest = z.infer<typeof notificationDeliveryRequestSchema>;
429
602
  type NotificationMessageVariantKey = (typeof notificationMessageVariantKeys)[number];
603
+ type NotificationStructuredMessageSection = z.infer<typeof structuredMessageSectionSchema>;
604
+ type NotificationStructuredMessageVariant = z.infer<typeof structuredNotificationVariantSchema>;
430
605
  type NotificationDeliveryReceiptV1 = z.infer<typeof notificationDeliveryReceiptV1Schema>;
431
606
  type NotificationDeliveryRejectionV1 = z.infer<typeof notificationDeliveryRejectionV1Schema>;
432
607
  type NotificationDeliverResultV1 = z.infer<typeof notificationDeliverResultV1Schema>;
@@ -436,10 +611,10 @@ interface NotificationDeliveryServiceV1 {
436
611
  deliver: (request: NotificationDeliveryRequestV1) => Promise<NotificationDeliverResultV1>;
437
612
  getReceipt: (eventId: string) => Promise<NotificationGetReceiptResultV1>;
438
613
  }
439
- /** Private Service Binding contract accepting both published request versions. */
614
+ /** Private Service Binding contract accepting all published request versions. */
440
615
  interface NotificationDeliveryServiceV2 {
441
616
  deliver: (request: NotificationDeliveryRequest) => Promise<NotificationDeliverResultV1>;
442
617
  getReceipt: (eventId: string) => Promise<NotificationGetReceiptResultV1>;
443
618
  }
444
619
  //#endregion
445
- export { NotificationDeliverResultV1, NotificationDeliveryReceiptV1, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationGetReceiptResultV1, NotificationMessageVariantKey, notificationDeliverResultV1Schema, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryReasonsV1, notificationDeliveryReceiptV1Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryStatesV1, notificationDestinationFailureCodesV1, notificationDestinationStatesV1, notificationGetReceiptResultV1Schema, notificationMessageVariantKeys, notificationValidationIssueCodesV1 };
620
+ export { NotificationDeliverResultV1, NotificationDeliveryReceiptV1, NotificationDeliveryRejectionV1, NotificationDeliveryRequest, NotificationDeliveryRequestV1, NotificationDeliveryRequestV2, NotificationDeliveryRequestV3, NotificationDeliveryServiceV1, NotificationDeliveryServiceV2, NotificationGetReceiptResultV1, NotificationMessageVariantKey, NotificationStructuredMessageSection, NotificationStructuredMessageVariant, notificationDeliverResultV1Schema, notificationDeliveryContractVersionV1, notificationDeliveryContractVersionV2, notificationDeliveryContractVersionV3, notificationDeliveryMaximumDeadlineMillisecondsV1, notificationDeliveryMaximumDeadlineMillisecondsV2, notificationDeliveryMaximumDeadlineMillisecondsV3, notificationDeliveryReasonsV1, notificationDeliveryReceiptV1Schema, notificationDeliveryRejectionCodesV1, notificationDeliveryRejectionV1Schema, notificationDeliveryRequestMaximumUtf8BytesV1, notificationDeliveryRequestMaximumUtf8BytesV2, notificationDeliveryRequestMaximumUtf8BytesV3, notificationDeliveryRequestSchema, notificationDeliveryRequestV1Schema, notificationDeliveryRequestV2Schema, notificationDeliveryRequestV3Schema, 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=32*1024,i=1380*60*1e3,a=r,o=i,s=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],c=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],l=[`pending`,`delivering`,`delivered`,`failed`,`expired`],u=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],d=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],f=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],p=[`source`,`zh-CN`],m=new TextEncoder,h=/^[a-z][a-z0-9-]{0,62}$/,g=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,_=/^[A-Z0-9][\w.:-]{0,127}$/i;function v(e){return[...e].length}function y(t){return e.string().refine(e=>v(e)>0,{message:`too_small`}).refine(e=>v(e)<=t,{message:`too_big`})}const b=e.string().datetime({offset:!0}),x=e.object({key:e.string().regex(h),environment:e.string().regex(h)}).strict(),S=e.object({type:e.string().regex(h),id:e.string().regex(_),revision:e.number().int().positive()}).strict(),C=e.string().min(1).max(127).regex(g),w=e.object({label:y(48),url:y(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(),T={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:x,routeKey:C,occurredAt:b,requestedAt:b,deliverBy:b,subject:S},E=e.object({contractVersion:e.literal(1),...T,message:e.object({type:e.literal(`link_summary`),title:y(160),summary:y(1200),facts:e.array(e.object({label:y(48),value:y(500)}).strict()).max(10),primaryLink:w,sourceLink:w.optional()}).strict()}).strict();function D(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`]}),m.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const O=E.superRefine((e,t)=>D(e,t,i,r)),k={title:y(160),summary:y(1200),facts:e.array(e.object({label:y(48),value:y(500)}).strict()).max(10)},A=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...k}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...k}).strict()]),j=e.array(A).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`})}),M=e.object({contractVersion:e.literal(2),...T,message:e.object({type:e.literal(`localized_link_summary`),variants:j,primaryLink:w,sourceLink:w.optional()}).strict()}).strict().superRefine((e,t)=>D(e,t,o,a)),N=e.union([O,M]),P=e.object({destinationKey:e.string().min(1),state:e.enum(l),attempts:e.number().int().min(0).max(4),failureCode:e.enum(u).nullable(),lastAttemptAt:b.nullable(),nextAttemptAt:b.nullable(),leaseExpiresAt:b.nullable()}).strict(),F=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:x,routeKey:C,subject:S,state:e.enum(s),reason:e.enum(c),terminal:e.boolean(),acceptedAt:b,updatedAt:b,deliverBy:b,terminalAt:b.nullable(),destinations:e.array(P).min(1).max(20)}).strict(),I=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(f)}).strict(),L=e.object({code:e.literal(`invalid_request`),issues:e.array(I).max(20).optional()}).strict(),R=e.object({code:e.enum(d.filter(e=>e!==`invalid_request`))}).strict(),z=e.union([L,R]),B=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:F}).strict(),e.object({status:e.literal(`rejected`),error:z}).strict()]),V=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:F}).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{B as notificationDeliverResultV1Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,i as notificationDeliveryMaximumDeadlineMillisecondsV1,o as notificationDeliveryMaximumDeadlineMillisecondsV2,c as notificationDeliveryReasonsV1,F as notificationDeliveryReceiptV1Schema,d as notificationDeliveryRejectionCodesV1,z as notificationDeliveryRejectionV1Schema,r as notificationDeliveryRequestMaximumUtf8BytesV1,a as notificationDeliveryRequestMaximumUtf8BytesV2,N as notificationDeliveryRequestSchema,O as notificationDeliveryRequestV1Schema,M as notificationDeliveryRequestV2Schema,s as notificationDeliveryStatesV1,u as notificationDestinationFailureCodesV1,l as notificationDestinationStatesV1,V as notificationGetReceiptResultV1Schema,p as notificationMessageVariantKeys,f as notificationValidationIssueCodesV1};
1
+ import{z as e}from"zod";const t=1,n=2,r=3,i=32*1024,a=1380*60*1e3,o=i,s=a,c=i,l=a,u=[`pending`,`delivering`,`partial`,`delivered`,`failed`,`expired`],d=[`accepted`,`enqueue_retry_wait`,`in_progress`,`partial_delivery`,`complete`,`retry_exhausted`,`delivery_deadline_exceeded`,`destination_configuration_unavailable`],f=[`pending`,`delivering`,`delivered`,`failed`,`expired`],p=[`provider_timeout`,`provider_rate_limited`,`provider_unavailable`,`provider_rejected`,`destination_configuration_unavailable`,`delivery_interrupted`,`retry_exhausted`],m=[`invalid_request`,`request_too_large`,`producer_scope_mismatch`,`route_not_allowed`,`event_identity_conflict`,`route_not_found`,`route_empty`,`delivery_deadline_invalid`],h=[`invalid_type`,`invalid_value`,`too_small`,`too_big`,`invalid_format`,`unrecognized_keys`,`custom`],g=[`source`,`zh-CN`],_=new TextEncoder,v=/^[a-z][a-z0-9-]{0,62}$/,y=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31}){1,3}$/,b=/^[A-Z0-9][\w.:-]{0,127}$/i;function x(e){return[...e].length}function S(t){return e.string().refine(e=>x(e)>0,{message:`too_small`}).refine(e=>x(e)<=t,{message:`too_big`})}const C=e.string().datetime({offset:!0}),w=e.object({key:e.string().regex(v),environment:e.string().regex(v)}).strict(),T=e.object({type:e.string().regex(v),id:e.string().regex(b),revision:e.number().int().positive()}).strict(),E=e.string().min(1).max(127).regex(y),D=e.object({label:S(48),url:S(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(),O={eventType:e.literal(`notification.delivery.requested`),eventId:e.string().uuid(),producer:w,routeKey:E,occurredAt:C,requestedAt:C,deliverBy:C,subject:T},k=e.object({contractVersion:e.literal(1),...O,message:e.object({type:e.literal(`link_summary`),title:S(160),summary:S(1200),facts:e.array(e.object({label:S(48),value:S(500)}).strict()).max(10),primaryLink:D,sourceLink:D.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`]}),_.encode(JSON.stringify(e)).byteLength>r&&t.addIssue({code:`custom`,message:`request_too_large`})}const j=k.superRefine((e,t)=>A(e,t,a,i)),M={title:S(160),summary:S(1200),facts:e.array(e.object({label:S(48),value:S(500)}).strict()).max(10)},N=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),...M}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),...M}).strict()]),P=e.array(N).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),...O,message:e.object({type:e.literal(`localized_link_summary`),variants:P,primaryLink:D,sourceLink:D.optional()}).strict()}).strict().superRefine((e,t)=>A(e,t,s,o)),I=e.discriminatedUnion(`type`,[e.object({key:e.string().regex(v),type:e.literal(`text`),label:S(48).optional(),value:S(4e3)}).strict(),e.object({key:e.string().regex(v),type:e.literal(`fields`),items:e.array(e.object({label:S(48),value:S(1200)}).strict()).min(1).max(20)}).strict()]),L=e.array(I).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`})}),R=e.discriminatedUnion(`key`,[e.object({key:e.literal(`source`),locale:e.literal(`und`),title:S(160),sections:L}).strict(),e.object({key:e.literal(`zh-CN`),locale:e.literal(`zh-CN`),title:S(160),sections:L}).strict()]),z=e.array(R).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`});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`]})}}),B=e.object({contractVersion:e.literal(3),...O,message:e.object({type:e.literal(`structured_notification`),variants:z,links:e.array(e.object({key:e.string().regex(v),...D.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().superRefine((e,t)=>A(e,t,l,c)),V=e.union([j,F,B]),H=e.object({destinationKey:e.string().min(1),state:e.enum(f),attempts:e.number().int().min(0).max(4),failureCode:e.enum(p).nullable(),lastAttemptAt:C.nullable(),nextAttemptAt:C.nullable(),leaseExpiresAt:C.nullable()}).strict(),U=e.object({contractVersion:e.literal(1),eventId:e.string().uuid(),producer:w,routeKey:E,subject:T,state:e.enum(u),reason:e.enum(d),terminal:e.boolean(),acceptedAt:C,updatedAt:C,deliverBy:C,terminalAt:C.nullable(),destinations:e.array(H).min(1).max(20)}).strict(),W=e.object({path:e.array(e.union([e.string(),e.number().int().min(0)])).max(16),code:e.enum(h)}).strict(),G=e.object({code:e.literal(`invalid_request`),issues:e.array(W).max(20).optional()}).strict(),K=e.object({code:e.enum(m.filter(e=>e!==`invalid_request`))}).strict(),q=e.union([G,K]),J=e.discriminatedUnion(`status`,[e.object({status:e.literal(`accepted`),receipt:U}).strict(),e.object({status:e.literal(`rejected`),error:q}).strict()]),Y=e.discriminatedUnion(`status`,[e.object({status:e.literal(`found`),receipt:U}).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{J as notificationDeliverResultV1Schema,t as notificationDeliveryContractVersionV1,n as notificationDeliveryContractVersionV2,r as notificationDeliveryContractVersionV3,a as notificationDeliveryMaximumDeadlineMillisecondsV1,s as notificationDeliveryMaximumDeadlineMillisecondsV2,l as notificationDeliveryMaximumDeadlineMillisecondsV3,d as notificationDeliveryReasonsV1,U as notificationDeliveryReceiptV1Schema,m as notificationDeliveryRejectionCodesV1,q as notificationDeliveryRejectionV1Schema,i as notificationDeliveryRequestMaximumUtf8BytesV1,o as notificationDeliveryRequestMaximumUtf8BytesV2,c as notificationDeliveryRequestMaximumUtf8BytesV3,V as notificationDeliveryRequestSchema,j as notificationDeliveryRequestV1Schema,F as notificationDeliveryRequestV2Schema,B as notificationDeliveryRequestV3Schema,u as notificationDeliveryStatesV1,p as notificationDestinationFailureCodesV1,f as notificationDestinationStatesV1,Y as notificationGetReceiptResultV1Schema,g as notificationMessageVariantKeys,h as notificationValidationIssueCodesV1};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@closerepo/notification-contracts",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {