feat: improve structure and error handling

This commit is contained in:
Michael Zetterberg
2024-05-14 15:55:46 +02:00
parent 01587d7fd5
commit f5108d1a8e
104 changed files with 1505 additions and 1570 deletions

View File

@@ -120,24 +120,18 @@ const accountPageContentItem = z.discriminatedUnion("__typename", [
])
export const validateAccountPageSchema = z.object({
all_account_page: z.object({
items: z.array(
z.object({
url: z.string(),
title: z.string(),
content: z.array(accountPageContentItem),
})
),
account_page: z.object({
url: z.string(),
title: z.string(),
content: z.array(accountPageContentItem),
}),
})
type AccountPageDataRaw = z.infer<typeof validateAccountPageSchema>
export type AccountPageDataRaw = z.infer<typeof validateAccountPageSchema>
type AccountPageRaw = AccountPageDataRaw["all_account_page"]["items"][0]
type AccountPageRaw = AccountPageDataRaw["account_page"]
export type AccountPage = Omit<AccountPageRaw, "content"> & {
url: string
title: string
content: AccountPageContentItem[]
}
@@ -182,16 +176,12 @@ const accountPageContentItemRefs = z.discriminatedUnion("__typename", [
])
export const validateAccountPageRefsSchema = z.object({
all_account_page: z.object({
items: z.array(
z.object({
content: z.array(accountPageContentItemRefs),
system: z.object({
content_type_uid: z.string(),
uid: z.string(),
}),
})
),
account_page: z.object({
content: z.array(accountPageContentItemRefs),
system: z.object({
content_type_uid: z.string(),
uid: z.string(),
}),
}),
})