@middlewr/contracts 0.0.45 → 0.0.47

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.
@@ -86,6 +86,14 @@ export declare const LinkTemplateSchema: z.ZodObject<{
86
86
  y: z.ZodNumber;
87
87
  }, z.core.$strip>;
88
88
  next: z.ZodNullable<z.ZodString>;
89
+ }, z.core.$strip>, z.ZodObject<{
90
+ id: z.ZodString;
91
+ type: z.ZodLiteral<"entry">;
92
+ position: z.ZodObject<{
93
+ x: z.ZodNumber;
94
+ y: z.ZodNumber;
95
+ }, z.core.$strip>;
96
+ next: z.ZodNullable<z.ZodString>;
89
97
  }, z.core.$strip>], "type">>;
90
98
  }, z.core.$strip>>;
91
99
  created_at: z.ZodCoercedDate<unknown>;
@@ -176,6 +184,14 @@ export declare const CreateLinkTemplateInputSchema: z.ZodObject<{
176
184
  y: z.ZodNumber;
177
185
  }, z.core.$strip>;
178
186
  next: z.ZodNullable<z.ZodString>;
187
+ }, z.core.$strip>, z.ZodObject<{
188
+ id: z.ZodString;
189
+ type: z.ZodLiteral<"entry">;
190
+ position: z.ZodObject<{
191
+ x: z.ZodNumber;
192
+ y: z.ZodNumber;
193
+ }, z.core.$strip>;
194
+ next: z.ZodNullable<z.ZodString>;
179
195
  }, z.core.$strip>], "type">>;
180
196
  }, z.core.$strip>>>;
181
197
  }, z.core.$strip>;
@@ -264,6 +280,14 @@ export declare const UpdateLinkTemplateInputSchema: z.ZodObject<{
264
280
  y: z.ZodNumber;
265
281
  }, z.core.$strip>;
266
282
  next: z.ZodNullable<z.ZodString>;
283
+ }, z.core.$strip>, z.ZodObject<{
284
+ id: z.ZodString;
285
+ type: z.ZodLiteral<"entry">;
286
+ position: z.ZodObject<{
287
+ x: z.ZodNumber;
288
+ y: z.ZodNumber;
289
+ }, z.core.$strip>;
290
+ next: z.ZodNullable<z.ZodString>;
267
291
  }, z.core.$strip>], "type">>;
268
292
  }, z.core.$strip>>;
269
293
  }, z.core.$strip>;
@@ -360,6 +384,14 @@ export declare const PaginatedLinkTemplatesSchema: z.ZodObject<{
360
384
  y: z.ZodNumber;
361
385
  }, z.core.$strip>;
362
386
  next: z.ZodNullable<z.ZodString>;
387
+ }, z.core.$strip>, z.ZodObject<{
388
+ id: z.ZodString;
389
+ type: z.ZodLiteral<"entry">;
390
+ position: z.ZodObject<{
391
+ x: z.ZodNumber;
392
+ y: z.ZodNumber;
393
+ }, z.core.$strip>;
394
+ next: z.ZodNullable<z.ZodString>;
363
395
  }, z.core.$strip>], "type">>;
364
396
  }, z.core.$strip>>;
365
397
  created_at: z.ZodCoercedDate<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"link-templates.schema.d.ts","sourceRoot":"","sources":["../../src/link-templates.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ7B,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIxC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIxC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;iBAIpC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMvC,CAAC"}
1
+ {"version":3,"file":"link-templates.schema.d.ts","sourceRoot":"","sources":["../../src/link-templates.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ7B,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIxC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIxC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;iBAIpC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMvC,CAAC"}
@@ -163,6 +163,14 @@ export declare const LinkSchema: z.ZodObject<{
163
163
  y: z.ZodNumber;
164
164
  }, z.core.$strip>;
165
165
  next: z.ZodNullable<z.ZodString>;
166
+ }, z.core.$strip>, z.ZodObject<{
167
+ id: z.ZodString;
168
+ type: z.ZodLiteral<"entry">;
169
+ position: z.ZodObject<{
170
+ x: z.ZodNumber;
171
+ y: z.ZodNumber;
172
+ }, z.core.$strip>;
173
+ next: z.ZodNullable<z.ZodString>;
166
174
  }, z.core.$strip>], "type">>;
167
175
  }, z.core.$strip>>>;
168
176
  tags: z.ZodArray<z.ZodObject<{
@@ -303,6 +311,14 @@ export declare const CreateLinkInputSchema: z.ZodObject<{
303
311
  y: z.ZodNumber;
304
312
  }, z.core.$strip>;
305
313
  next: z.ZodNullable<z.ZodString>;
314
+ }, z.core.$strip>, z.ZodObject<{
315
+ id: z.ZodString;
316
+ type: z.ZodLiteral<"entry">;
317
+ position: z.ZodObject<{
318
+ x: z.ZodNumber;
319
+ y: z.ZodNumber;
320
+ }, z.core.$strip>;
321
+ next: z.ZodNullable<z.ZodString>;
306
322
  }, z.core.$strip>], "type">>;
307
323
  }, z.core.$strip>>>;
308
324
  }, z.core.$strip>;
@@ -436,6 +452,14 @@ export declare const UpdateLinkInputSchema: z.ZodObject<{
436
452
  y: z.ZodNumber;
437
453
  }, z.core.$strip>;
438
454
  next: z.ZodNullable<z.ZodString>;
455
+ }, z.core.$strip>, z.ZodObject<{
456
+ id: z.ZodString;
457
+ type: z.ZodLiteral<"entry">;
458
+ position: z.ZodObject<{
459
+ x: z.ZodNumber;
460
+ y: z.ZodNumber;
461
+ }, z.core.$strip>;
462
+ next: z.ZodNullable<z.ZodString>;
439
463
  }, z.core.$strip>], "type">>;
440
464
  }, z.core.$strip>>>;
441
465
  }, z.core.$strip>;
@@ -642,6 +666,14 @@ export declare const PaginatedLinksSchema: z.ZodObject<{
642
666
  y: z.ZodNumber;
643
667
  }, z.core.$strip>;
644
668
  next: z.ZodNullable<z.ZodString>;
669
+ }, z.core.$strip>, z.ZodObject<{
670
+ id: z.ZodString;
671
+ type: z.ZodLiteral<"entry">;
672
+ position: z.ZodObject<{
673
+ x: z.ZodNumber;
674
+ y: z.ZodNumber;
675
+ }, z.core.$strip>;
676
+ next: z.ZodNullable<z.ZodString>;
645
677
  }, z.core.$strip>], "type">>;
646
678
  }, z.core.$strip>>>;
647
679
  tags: z.ZodArray<z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"links.schema.d.ts","sourceRoot":"","sources":["../../src/links.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;iBAW/B,CAA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Schema: z.ZodDiscriminatedUnion<[z.ZodObject<{
79
79
  y: z.ZodNumber;
80
80
  }, z.core.$strip>;
81
81
  next: z.ZodNullable<z.ZodString>;
82
+ }, z.core.$strip>, z.ZodObject<{
83
+ id: z.ZodString;
84
+ type: z.ZodLiteral<"entry">;
85
+ position: z.ZodObject<{
86
+ x: z.ZodNumber;
87
+ y: z.ZodNumber;
88
+ }, z.core.$strip>;
89
+ next: z.ZodNullable<z.ZodString>;
82
90
  }, z.core.$strip>], "type">;
91
+ export declare const RuleGraphOutputSchema: z.ZodObject<{
92
+ entry: z.ZodString;
93
+ nodes: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
94
+ id: z.ZodString;
95
+ type: z.ZodLiteral<"condition">;
96
+ position: z.ZodObject<{
97
+ x: z.ZodNumber;
98
+ y: z.ZodNumber;
99
+ }, z.core.$strip>;
100
+ field: z.ZodString;
101
+ operator: z.ZodEnum<{
102
+ eq: "eq";
103
+ neq: "neq";
104
+ in: "in";
105
+ not_in: "not_in";
106
+ contains: "contains";
107
+ not_contains: "not_contains";
108
+ gt: "gt";
109
+ lt: "lt";
110
+ gte: "gte";
111
+ lte: "lte";
112
+ regex: "regex";
113
+ }>;
114
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodNumber]>;
115
+ outputs: z.ZodObject<{
116
+ true: z.ZodNullable<z.ZodString>;
117
+ false: z.ZodNullable<z.ZodString>;
118
+ }, z.core.$strip>;
119
+ }, z.core.$strip>, z.ZodObject<{
120
+ id: z.ZodString;
121
+ type: z.ZodLiteral<"split">;
122
+ position: z.ZodObject<{
123
+ x: z.ZodNumber;
124
+ y: z.ZodNumber;
125
+ }, z.core.$strip>;
126
+ variants: z.ZodArray<z.ZodObject<{
127
+ weight: z.ZodNumber;
128
+ target: z.ZodNullable<z.ZodString>;
129
+ }, z.core.$strip>>;
130
+ }, z.core.$strip>, z.ZodObject<{
131
+ id: z.ZodString;
132
+ type: z.ZodLiteral<"destination">;
133
+ position: z.ZodObject<{
134
+ x: z.ZodNumber;
135
+ y: z.ZodNumber;
136
+ }, z.core.$strip>;
137
+ url: z.ZodString;
138
+ }, z.core.$strip>, z.ZodObject<{
139
+ id: z.ZodString;
140
+ type: z.ZodLiteral<"transform">;
141
+ position: z.ZodObject<{
142
+ x: z.ZodNumber;
143
+ y: z.ZodNumber;
144
+ }, z.core.$strip>;
145
+ transforms: z.ZodObject<{
146
+ query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
147
+ key: z.ZodString;
148
+ value: z.ZodString;
149
+ mode: z.ZodEnum<{
150
+ set: "set";
151
+ append: "append";
152
+ }>;
153
+ }, z.core.$strip>>>;
154
+ redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
155
+ response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
156
+ key: z.ZodString;
157
+ value: z.ZodString;
158
+ mode: z.ZodEnum<{
159
+ set: "set";
160
+ append: "append";
161
+ }>;
162
+ }, z.core.$strip>>>;
163
+ }, z.core.$strip>;
164
+ next: z.ZodNullable<z.ZodString>;
165
+ }, z.core.$strip>, z.ZodObject<{
166
+ id: z.ZodString;
167
+ type: z.ZodLiteral<"password">;
168
+ position: z.ZodObject<{
169
+ x: z.ZodNumber;
170
+ y: z.ZodNumber;
171
+ }, z.core.$strip>;
172
+ next: z.ZodNullable<z.ZodString>;
173
+ }, z.core.$strip>, z.ZodObject<{
174
+ id: z.ZodString;
175
+ type: z.ZodLiteral<"entry">;
176
+ position: z.ZodObject<{
177
+ x: z.ZodNumber;
178
+ y: z.ZodNumber;
179
+ }, z.core.$strip>;
180
+ next: z.ZodNullable<z.ZodString>;
181
+ }, z.core.$strip>], "type">>;
182
+ }, z.core.$strip>;
83
183
  export declare const RuleGraphSchema: z.ZodObject<{
84
184
  entry: z.ZodString;
85
185
  nodes: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -162,6 +262,14 @@ export declare const RuleGraphSchema: z.ZodObject<{
162
262
  y: z.ZodNumber;
163
263
  }, z.core.$strip>;
164
264
  next: z.ZodNullable<z.ZodString>;
265
+ }, z.core.$strip>, z.ZodObject<{
266
+ id: z.ZodString;
267
+ type: z.ZodLiteral<"entry">;
268
+ position: z.ZodObject<{
269
+ x: z.ZodNumber;
270
+ y: z.ZodNumber;
271
+ }, z.core.$strip>;
272
+ next: z.ZodNullable<z.ZodString>;
165
273
  }, z.core.$strip>], "type">>;
166
274
  }, z.core.$strip>;
167
275
  //# sourceMappingURL=rules.schema.d.ts.map
@@ -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;AAwFxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAM9B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQtB,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;AA+FxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAO9B,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.45",
3
+ "version": "0.0.47",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -1,13 +1,13 @@
1
1
  import { z } from 'zod';
2
2
 
3
- import { RuleGraphSchema } from './rules.schema';
3
+ import { RuleGraphOutputSchema, RuleGraphSchema } from './rules.schema';
4
4
 
5
5
  export const LinkTemplateSchema = z.object({
6
6
  id: z.string().uuid(),
7
7
  workspace_id: z.string().uuid(),
8
8
  title: z.string(),
9
9
  description: z.string().nullable(),
10
- rule_graph: RuleGraphSchema.nullable(),
10
+ rule_graph: RuleGraphOutputSchema.nullable(),
11
11
  created_at: z.coerce.date(),
12
12
  updated_at: z.coerce.date().nullable(),
13
13
  });
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- import { RuleGraphSchema } from './rules.schema';
3
+ import { RuleGraphOutputSchema, RuleGraphSchema } from './rules.schema';
4
4
  import { TagSchema } from './tags.schema';
5
5
 
6
6
  const DotStyleSchema = z.enum(['square', 'dots', 'rounded', 'classy', 'classy-rounded', 'extra-rounded']);
@@ -48,7 +48,7 @@ export const LinkSchema = z.object({
48
48
  qr_logo_key: z.string().nullable(),
49
49
  logo_url: z.string().nullable(),
50
50
  link_type: z.enum(['redirect', 'rules']).default('redirect'),
51
- rule_graph: RuleGraphSchema.nullable().optional(),
51
+ rule_graph: RuleGraphOutputSchema.nullable().optional(),
52
52
  tags: z.array(TagSchema),
53
53
  });
54
54
 
@@ -86,20 +86,53 @@ const PasswordNodeSchema = z.object({
86
86
  next: z.string().nullable(),
87
87
  });
88
88
 
89
+ const EntryNodeSchema = z.object({
90
+ id: z.string(),
91
+ type: z.literal('entry'),
92
+ position: PositionSchema,
93
+ next: z.string().nullable(),
94
+ });
95
+
89
96
  export const RuleGraphNodeSchema = z.discriminatedUnion('type', [
90
97
  ConditionNodeSchema,
91
98
  SplitNodeSchema,
92
99
  DestinationNodeSchema,
93
100
  TransformNodeSchema,
94
101
  PasswordNodeSchema,
102
+ EntryNodeSchema,
95
103
  ]);
96
104
 
97
- export const RuleGraphSchema = z
98
- .object({
99
- entry: z.string(),
100
- nodes: z.record(z.string(), RuleGraphNodeSchema),
101
- })
102
- .refine((data) => data.nodes[data.entry] !== undefined, {
103
- message: 'Entry node must reference an existing node in the graph',
104
- path: ['entry'],
105
- });
105
+ const BaseRuleGraphSchema = z.object({
106
+ entry: z.string(),
107
+ nodes: z.record(z.string(), RuleGraphNodeSchema),
108
+ });
109
+
110
+ export const RuleGraphOutputSchema = BaseRuleGraphSchema.refine((data) => data.nodes[data.entry] !== undefined, {
111
+ message: 'Entry node must reference an existing node in the graph',
112
+ path: ['entry'],
113
+ });
114
+
115
+ export const RuleGraphSchema = BaseRuleGraphSchema.refine((data) => data.nodes[data.entry] !== undefined, {
116
+ message: 'Entry node must reference an existing node in the graph',
117
+ path: ['entry'],
118
+ })
119
+ .refine(
120
+ (data) => {
121
+ const entryNode = data.nodes[data.entry];
122
+ return entryNode !== undefined && entryNode.type === 'entry';
123
+ },
124
+ {
125
+ message: 'Entry must point to a node of type "entry"',
126
+ path: ['entry'],
127
+ },
128
+ )
129
+ .refine(
130
+ (data) => {
131
+ const entryNodes = Object.values(data.nodes).filter((n) => n.type === 'entry');
132
+ return entryNodes.length === 1;
133
+ },
134
+ {
135
+ message: 'Graph must contain exactly one entry node',
136
+ path: ['nodes'],
137
+ },
138
+ );