From 5d51c79739128c3286fbf778e712cdf81413aa44 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Thu, 21 Nov 2024 04:35:43 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20temporarily=20revert=20stricter=20schema?= =?UTF-8?q?=20so=20we=20can=20handle=20invalid=20DB=20e=E2=80=A6=20(#17774?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/lib/raqb/zod.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/lib/raqb/zod.ts b/packages/lib/raqb/zod.ts index 6ff60044ea..69c74aa296 100644 --- a/packages/lib/raqb/zod.ts +++ b/packages/lib/raqb/zod.ts @@ -1,6 +1,20 @@ import { z } from "zod"; export const raqbChildSchema = z.object({ + type: z.string().optional(), + properties: z + .object({ + field: z.any().optional(), + operator: z.any().optional(), + value: z.any().optional(), + valueSrc: z.any().optional(), + valueError: z.array(z.union([z.string(), z.null()])).optional(), + valueType: z.any().optional(), + }) + .optional(), + /* + * TODO: (emrysal) This schema is good, but our DB contains invalid entries- + * instead of crashing on read we need to handle this on write first. type: z.union([z.literal("rule"), z.literal("rule_group")]), properties: z.object({ // This is RAQB field that is used in the rules. The aluealue we provide here is used as a lookup key in RAQB_CONFIG.fields @@ -21,7 +35,7 @@ export const raqbChildSchema = z.object({ // Type of the value - can be text, number, boolean, date, time, datetime, select, multiselect, treeselect, treemultiselect and maybe more // We only use a few of them in our app valueType: z.array(z.string()).optional(), - }), + }),*/ }); // The actual schema of children1 is quite complex, we don't want to worry about that at the moment.