@middlewr/contracts 0.0.46 → 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.
- package/dist/cjs/index.js +11 -4
- package/dist/cjs/rules.schema.d.ts +92 -0
- package/dist/cjs/rules.schema.d.ts.map +1 -1
- package/dist/esm/index.js +10 -4
- package/dist/esm/rules.schema.d.ts +92 -0
- package/dist/esm/rules.schema.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/link-templates.schema.ts +2 -2
- package/src/links.schema.ts +2 -2
- package/src/rules.schema.ts +14 -9
package/dist/cjs/index.js
CHANGED
|
@@ -60,6 +60,7 @@ __export(index_exports, {
|
|
|
60
60
|
PlansOutputSchema: () => PlansOutputSchema,
|
|
61
61
|
QrCodeSettingsSchema: () => QrCodeSettingsSchema,
|
|
62
62
|
RuleGraphNodeSchema: () => RuleGraphNodeSchema,
|
|
63
|
+
RuleGraphOutputSchema: () => RuleGraphOutputSchema,
|
|
63
64
|
RuleGraphSchema: () => RuleGraphSchema,
|
|
64
65
|
SignInInputSchema: () => SignInInputSchema,
|
|
65
66
|
TagIdParamSchema: () => TagIdParamSchema,
|
|
@@ -386,10 +387,15 @@ var RuleGraphNodeSchema = import_zod6.z.discriminatedUnion("type", [
|
|
|
386
387
|
PasswordNodeSchema,
|
|
387
388
|
EntryNodeSchema
|
|
388
389
|
]);
|
|
389
|
-
var
|
|
390
|
+
var BaseRuleGraphSchema = import_zod6.z.object({
|
|
390
391
|
entry: import_zod6.z.string(),
|
|
391
392
|
nodes: import_zod6.z.record(import_zod6.z.string(), RuleGraphNodeSchema)
|
|
392
|
-
})
|
|
393
|
+
});
|
|
394
|
+
var RuleGraphOutputSchema = BaseRuleGraphSchema.refine((data) => data.nodes[data.entry] !== void 0, {
|
|
395
|
+
message: "Entry node must reference an existing node in the graph",
|
|
396
|
+
path: ["entry"]
|
|
397
|
+
});
|
|
398
|
+
var RuleGraphSchema = BaseRuleGraphSchema.refine((data) => data.nodes[data.entry] !== void 0, {
|
|
393
399
|
message: "Entry node must reference an existing node in the graph",
|
|
394
400
|
path: ["entry"]
|
|
395
401
|
}).refine(
|
|
@@ -418,7 +424,7 @@ var LinkTemplateSchema = import_zod7.z.object({
|
|
|
418
424
|
workspace_id: import_zod7.z.string().uuid(),
|
|
419
425
|
title: import_zod7.z.string(),
|
|
420
426
|
description: import_zod7.z.string().nullable(),
|
|
421
|
-
rule_graph:
|
|
427
|
+
rule_graph: RuleGraphOutputSchema.nullable(),
|
|
422
428
|
created_at: import_zod7.z.coerce.date(),
|
|
423
429
|
updated_at: import_zod7.z.coerce.date().nullable()
|
|
424
430
|
});
|
|
@@ -511,7 +517,7 @@ var LinkSchema = import_zod9.z.object({
|
|
|
511
517
|
qr_logo_key: import_zod9.z.string().nullable(),
|
|
512
518
|
logo_url: import_zod9.z.string().nullable(),
|
|
513
519
|
link_type: import_zod9.z.enum(["redirect", "rules"]).default("redirect"),
|
|
514
|
-
rule_graph:
|
|
520
|
+
rule_graph: RuleGraphOutputSchema.nullable().optional(),
|
|
515
521
|
tags: import_zod9.z.array(TagSchema)
|
|
516
522
|
});
|
|
517
523
|
var CreateLinkInputSchema = import_zod9.z.object({
|
|
@@ -835,6 +841,7 @@ var contract = {
|
|
|
835
841
|
PlansOutputSchema,
|
|
836
842
|
QrCodeSettingsSchema,
|
|
837
843
|
RuleGraphNodeSchema,
|
|
844
|
+
RuleGraphOutputSchema,
|
|
838
845
|
RuleGraphSchema,
|
|
839
846
|
SignInInputSchema,
|
|
840
847
|
TagIdParamSchema,
|
|
@@ -88,6 +88,98 @@ export declare const RuleGraphNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
88
88
|
}, z.core.$strip>;
|
|
89
89
|
next: z.ZodNullable<z.ZodString>;
|
|
90
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>;
|
|
91
183
|
export declare const RuleGraphSchema: z.ZodObject<{
|
|
92
184
|
entry: z.ZodString;
|
|
93
185
|
nodes: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -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;AA+FxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAO9B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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/dist/esm/index.js
CHANGED
|
@@ -286,10 +286,15 @@ var RuleGraphNodeSchema = z6.discriminatedUnion("type", [
|
|
|
286
286
|
PasswordNodeSchema,
|
|
287
287
|
EntryNodeSchema
|
|
288
288
|
]);
|
|
289
|
-
var
|
|
289
|
+
var BaseRuleGraphSchema = z6.object({
|
|
290
290
|
entry: z6.string(),
|
|
291
291
|
nodes: z6.record(z6.string(), RuleGraphNodeSchema)
|
|
292
|
-
})
|
|
292
|
+
});
|
|
293
|
+
var RuleGraphOutputSchema = BaseRuleGraphSchema.refine((data) => data.nodes[data.entry] !== void 0, {
|
|
294
|
+
message: "Entry node must reference an existing node in the graph",
|
|
295
|
+
path: ["entry"]
|
|
296
|
+
});
|
|
297
|
+
var RuleGraphSchema = BaseRuleGraphSchema.refine((data) => data.nodes[data.entry] !== void 0, {
|
|
293
298
|
message: "Entry node must reference an existing node in the graph",
|
|
294
299
|
path: ["entry"]
|
|
295
300
|
}).refine(
|
|
@@ -318,7 +323,7 @@ var LinkTemplateSchema = z7.object({
|
|
|
318
323
|
workspace_id: z7.string().uuid(),
|
|
319
324
|
title: z7.string(),
|
|
320
325
|
description: z7.string().nullable(),
|
|
321
|
-
rule_graph:
|
|
326
|
+
rule_graph: RuleGraphOutputSchema.nullable(),
|
|
322
327
|
created_at: z7.coerce.date(),
|
|
323
328
|
updated_at: z7.coerce.date().nullable()
|
|
324
329
|
});
|
|
@@ -411,7 +416,7 @@ var LinkSchema = z9.object({
|
|
|
411
416
|
qr_logo_key: z9.string().nullable(),
|
|
412
417
|
logo_url: z9.string().nullable(),
|
|
413
418
|
link_type: z9.enum(["redirect", "rules"]).default("redirect"),
|
|
414
|
-
rule_graph:
|
|
419
|
+
rule_graph: RuleGraphOutputSchema.nullable().optional(),
|
|
415
420
|
tags: z9.array(TagSchema)
|
|
416
421
|
});
|
|
417
422
|
var CreateLinkInputSchema = z9.object({
|
|
@@ -734,6 +739,7 @@ export {
|
|
|
734
739
|
PlansOutputSchema,
|
|
735
740
|
QrCodeSettingsSchema,
|
|
736
741
|
RuleGraphNodeSchema,
|
|
742
|
+
RuleGraphOutputSchema,
|
|
737
743
|
RuleGraphSchema,
|
|
738
744
|
SignInInputSchema,
|
|
739
745
|
TagIdParamSchema,
|
|
@@ -88,6 +88,98 @@ export declare const RuleGraphNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
88
88
|
}, z.core.$strip>;
|
|
89
89
|
next: z.ZodNullable<z.ZodString>;
|
|
90
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>;
|
|
91
183
|
export declare const RuleGraphSchema: z.ZodObject<{
|
|
92
184
|
entry: z.ZodString;
|
|
93
185
|
nodes: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -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;AA+FxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAO9B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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,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:
|
|
10
|
+
rule_graph: RuleGraphOutputSchema.nullable(),
|
|
11
11
|
created_at: z.coerce.date(),
|
|
12
12
|
updated_at: z.coerce.date().nullable(),
|
|
13
13
|
});
|
package/src/links.schema.ts
CHANGED
|
@@ -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:
|
|
51
|
+
rule_graph: RuleGraphOutputSchema.nullable().optional(),
|
|
52
52
|
tags: z.array(TagSchema),
|
|
53
53
|
});
|
|
54
54
|
|
package/src/rules.schema.ts
CHANGED
|
@@ -102,15 +102,20 @@ export const RuleGraphNodeSchema = z.discriminatedUnion('type', [
|
|
|
102
102
|
EntryNodeSchema,
|
|
103
103
|
]);
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
+
})
|
|
114
119
|
.refine(
|
|
115
120
|
(data) => {
|
|
116
121
|
const entryNode = data.nodes[data.entry];
|