@middlewr/contracts 0.0.51 → 0.0.53

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/cjs/index.js CHANGED
@@ -333,7 +333,9 @@ var SplitNodeSchema = import_zod6.z.object({
333
333
  weight: import_zod6.z.number().min(1).max(100),
334
334
  target: import_zod6.z.string().nullable()
335
335
  })
336
- ).min(2)
336
+ ).min(2).refine((variants) => variants.reduce((sum, v) => sum + v.weight, 0) === 100, {
337
+ message: "Split variant weights must sum to 100"
338
+ })
337
339
  });
338
340
  var DestinationNodeSchema = import_zod6.z.object({
339
341
  id: import_zod6.z.string(),
@@ -397,10 +399,21 @@ var EntryNodeSchema = import_zod6.z.object({
397
399
  type: import_zod6.z.literal("entry"),
398
400
  position: PositionSchema,
399
401
  next: import_zod6.z.string().nullable(),
400
- starts_at: import_zod6.z.string().nullable(),
401
- expires_at: import_zod6.z.string().nullable(),
402
+ starts_at: import_zod6.z.string().datetime({ offset: true }).nullable(),
403
+ expires_at: import_zod6.z.string().datetime({ offset: true }).nullable(),
402
404
  fallback_url: import_zod6.z.string().nullable()
403
- });
405
+ }).refine(
406
+ (data) => {
407
+ if (data.starts_at && data.expires_at) {
408
+ return new Date(data.starts_at) < new Date(data.expires_at);
409
+ }
410
+ return true;
411
+ },
412
+ {
413
+ message: "starts_at must be before expires_at",
414
+ path: ["expires_at"]
415
+ }
416
+ );
404
417
  var RuleGraphNodeSchema = import_zod6.z.discriminatedUnion("type", [
405
418
  ConditionNodeSchema,
406
419
  SplitNodeSchema,
@@ -1 +1 @@
1
- {"version":3,"file":"rules.schema.d.ts","sourceRoot":"","sources":["../../src/rules.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0HxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAS9B,CAAC;AAOH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGhC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBvB,CAAC"}
1
+ {"version":3,"file":"rules.schema.d.ts","sourceRoot":"","sources":["../../src/rules.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0IxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAS9B,CAAC;AAOH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGhC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBvB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -232,7 +232,9 @@ var SplitNodeSchema = z6.object({
232
232
  weight: z6.number().min(1).max(100),
233
233
  target: z6.string().nullable()
234
234
  })
235
- ).min(2)
235
+ ).min(2).refine((variants) => variants.reduce((sum, v) => sum + v.weight, 0) === 100, {
236
+ message: "Split variant weights must sum to 100"
237
+ })
236
238
  });
237
239
  var DestinationNodeSchema = z6.object({
238
240
  id: z6.string(),
@@ -296,10 +298,21 @@ var EntryNodeSchema = z6.object({
296
298
  type: z6.literal("entry"),
297
299
  position: PositionSchema,
298
300
  next: z6.string().nullable(),
299
- starts_at: z6.string().nullable(),
300
- expires_at: z6.string().nullable(),
301
+ starts_at: z6.string().datetime({ offset: true }).nullable(),
302
+ expires_at: z6.string().datetime({ offset: true }).nullable(),
301
303
  fallback_url: z6.string().nullable()
302
- });
304
+ }).refine(
305
+ (data) => {
306
+ if (data.starts_at && data.expires_at) {
307
+ return new Date(data.starts_at) < new Date(data.expires_at);
308
+ }
309
+ return true;
310
+ },
311
+ {
312
+ message: "starts_at must be before expires_at",
313
+ path: ["expires_at"]
314
+ }
315
+ );
303
316
  var RuleGraphNodeSchema = z6.discriminatedUnion("type", [
304
317
  ConditionNodeSchema,
305
318
  SplitNodeSchema,
@@ -1 +1 @@
1
- {"version":3,"file":"rules.schema.d.ts","sourceRoot":"","sources":["../../src/rules.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0HxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAS9B,CAAC;AAOH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGhC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBvB,CAAC"}
1
+ {"version":3,"file":"rules.schema.d.ts","sourceRoot":"","sources":["../../src/rules.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0IxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAS9B,CAAC;AAOH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGhC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBvB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middlewr/contracts",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -34,7 +34,10 @@ const SplitNodeSchema = z.object({
34
34
  target: z.string().nullable(),
35
35
  }),
36
36
  )
37
- .min(2),
37
+ .min(2)
38
+ .refine((variants) => variants.reduce((sum, v) => sum + v.weight, 0) === 100, {
39
+ message: 'Split variant weights must sum to 100',
40
+ }),
38
41
  });
39
42
 
40
43
  const DestinationNodeSchema = z.object({
@@ -110,15 +113,28 @@ const WebhookNodeSchema = z.object({
110
113
  next: z.string().nullable(),
111
114
  });
112
115
 
113
- const EntryNodeSchema = z.object({
114
- id: z.string(),
115
- type: z.literal('entry'),
116
- position: PositionSchema,
117
- next: z.string().nullable(),
118
- starts_at: z.string().nullable(),
119
- expires_at: z.string().nullable(),
120
- fallback_url: z.string().nullable(),
121
- });
116
+ const EntryNodeSchema = z
117
+ .object({
118
+ id: z.string(),
119
+ type: z.literal('entry'),
120
+ position: PositionSchema,
121
+ next: z.string().nullable(),
122
+ starts_at: z.string().datetime({ offset: true }).nullable(),
123
+ expires_at: z.string().datetime({ offset: true }).nullable(),
124
+ fallback_url: z.string().nullable(),
125
+ })
126
+ .refine(
127
+ (data) => {
128
+ if (data.starts_at && data.expires_at) {
129
+ return new Date(data.starts_at) < new Date(data.expires_at);
130
+ }
131
+ return true;
132
+ },
133
+ {
134
+ message: 'starts_at must be before expires_at',
135
+ path: ['expires_at'],
136
+ },
137
+ );
122
138
 
123
139
  export const RuleGraphNodeSchema = z.discriminatedUnion('type', [
124
140
  ConditionNodeSchema,