feat: improve structure and error handling
This commit is contained in:
@@ -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(),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user