From 20010d0d1227a9c8e4416d7b8619762324c67154 Mon Sep 17 00:00:00 2001 From: Adebesin Cell Date: Fri, 22 Nov 2024 19:25:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8chore:=20fixes=20nullish=20and=20de?= =?UTF-8?q?fault=20to=20linked=20keys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/rude-carpets-build.md | 5 +++++ .changeset/yellow-baboons-push.md | 5 +++++ src/schema/index.ts | 22 +++++++++++++++------- 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 .changeset/rude-carpets-build.md create mode 100644 .changeset/yellow-baboons-push.md diff --git a/.changeset/rude-carpets-build.md b/.changeset/rude-carpets-build.md new file mode 100644 index 0000000..5744624 --- /dev/null +++ b/.changeset/rude-carpets-build.md @@ -0,0 +1,5 @@ +--- +"@everipedia/iq-utils": patch +--- + +Adds nullish and default diff --git a/.changeset/yellow-baboons-push.md b/.changeset/yellow-baboons-push.md new file mode 100644 index 0000000..a53df18 --- /dev/null +++ b/.changeset/yellow-baboons-push.md @@ -0,0 +1,5 @@ +--- +"@everipedia/iq-utils": patch +--- + +Adds default flag to keys diff --git a/src/schema/index.ts b/src/schema/index.ts index 4bc5f68..74ba6a4 100644 --- a/src/schema/index.ts +++ b/src/schema/index.ts @@ -253,11 +253,19 @@ export const Wiki = z version: z.number().default(1), linkedWikis: z .object({ - [LinkedWikiKey.Enum.blockchains]: z.array(z.string()).nullable(), - [LinkedWikiKey.Enum.founders]: z.array(z.string()).nullable(), - [LinkedWikiKey.Enum.speakers]: z.array(z.string()).nullable(), + [LinkedWikiKey.Enum.blockchains]: z + .array(z.string()) + .nullish() + .default([]), + [LinkedWikiKey.Enum.founders]: z + .array(z.string()) + .nullish() + .default([]), + [LinkedWikiKey.Enum.speakers]: z + .array(z.string()) + .nullish() + .default([]), }) - .nullable() .default({ [LinkedWikiKey.Enum.blockchains]: [], [LinkedWikiKey.Enum.founders]: [], @@ -265,9 +273,9 @@ export const Wiki = z }) .transform((val) => ({ [LinkedWikiKey.Enum.blockchains]: - val?.[LinkedWikiKey.Enum.blockchains] ?? [], - [LinkedWikiKey.Enum.founders]: val?.[LinkedWikiKey.Enum.founders] ?? [], - [LinkedWikiKey.Enum.speakers]: val?.[LinkedWikiKey.Enum.speakers] ?? [], + val[LinkedWikiKey.Enum.blockchains] ?? [], + [LinkedWikiKey.Enum.founders]: val[LinkedWikiKey.Enum.founders] ?? [], + [LinkedWikiKey.Enum.speakers]: val[LinkedWikiKey.Enum.speakers] ?? [], })), }) .refine(isEventWikiValid, {