chore: make apis nullable (#7763)
what: - makes top level attributes of each object an optional field in the http layer where possible RESOLVES CORE-2229
This commit is contained in:
@@ -8,20 +8,20 @@ export const StoreGetCartsCart = createSelectParams()
|
||||
const ItemSchema = z.object({
|
||||
variant_id: z.string(),
|
||||
quantity: z.number(),
|
||||
metadata: z.record(z.unknown()).optional().nullable(),
|
||||
metadata: z.record(z.unknown()).nullish(),
|
||||
})
|
||||
|
||||
export type StoreCreateCartType = z.infer<typeof StoreCreateCart>
|
||||
export const StoreCreateCart = z
|
||||
.object({
|
||||
region_id: z.string().optional().nullable(),
|
||||
region_id: z.string().nullish(),
|
||||
shipping_address: z.union([AddressPayload, z.string()]).optional(),
|
||||
billing_address: z.union([AddressPayload, z.string()]).optional(),
|
||||
email: z.string().email().optional().nullable(),
|
||||
currency_code: z.string().optional(),
|
||||
email: z.string().email().nullish(),
|
||||
currency_code: z.string().nullish(),
|
||||
items: z.array(ItemSchema).optional(),
|
||||
sales_channel_id: z.string().optional().nullable(),
|
||||
metadata: z.record(z.unknown()).optional().nullable(),
|
||||
sales_channel_id: z.string().nullish(),
|
||||
metadata: z.record(z.unknown()).nullish(),
|
||||
})
|
||||
.strict()
|
||||
|
||||
@@ -44,12 +44,12 @@ export const StoreRemoveCartPromotions = z
|
||||
export type StoreUpdateCartType = z.infer<typeof StoreUpdateCart>
|
||||
export const StoreUpdateCart = z
|
||||
.object({
|
||||
region_id: z.string().optional().nullable(),
|
||||
email: z.string().email().optional().nullable(),
|
||||
region_id: z.string().nullish(),
|
||||
email: z.string().email().nullish(),
|
||||
billing_address: z.union([AddressPayload, z.string()]).optional(),
|
||||
shipping_address: z.union([AddressPayload, z.string()]).optional(),
|
||||
sales_channel_id: z.string().optional().nullable(),
|
||||
metadata: z.record(z.unknown()).optional().nullable(),
|
||||
sales_channel_id: z.string().nullish(),
|
||||
metadata: z.record(z.unknown()).nullish(),
|
||||
promo_codes: z.array(z.string()).optional(),
|
||||
})
|
||||
.strict()
|
||||
@@ -63,7 +63,7 @@ export type StoreAddCartLineItemType = z.infer<typeof StoreAddCartLineItem>
|
||||
export const StoreAddCartLineItem = z.object({
|
||||
variant_id: z.string(),
|
||||
quantity: z.number(),
|
||||
metadata: z.record(z.unknown()).optional().nullable(),
|
||||
metadata: z.record(z.unknown()).nullish(),
|
||||
})
|
||||
|
||||
export type StoreUpdateCartLineItemType = z.infer<
|
||||
@@ -71,7 +71,7 @@ export type StoreUpdateCartLineItemType = z.infer<
|
||||
>
|
||||
export const StoreUpdateCartLineItem = z.object({
|
||||
quantity: z.number(),
|
||||
metadata: z.record(z.unknown()).optional(),
|
||||
metadata: z.record(z.unknown()).nullish(),
|
||||
})
|
||||
|
||||
export type StoreAddCartShippingMethodsType = z.infer<
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { z } from "zod"
|
||||
import {
|
||||
createFindParams,
|
||||
createOperatorMap,
|
||||
createSelectParams,
|
||||
} from "../../utils/validators"
|
||||
import { z } from "zod"
|
||||
|
||||
export const StoreGetCollectionParams = createSelectParams()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createFindParams, createSelectParams } from "../../utils/validators"
|
||||
import { z } from "zod"
|
||||
import { createFindParams, createSelectParams } from "../../utils/validators"
|
||||
|
||||
export const StoreGetCurrencyParams = createSelectParams()
|
||||
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import { createFindParams, createSelectParams } from "../../utils/validators"
|
||||
import { z } from "zod"
|
||||
import { AddressPayload } from "../../utils/common-validators"
|
||||
import { createFindParams, createSelectParams } from "../../utils/validators"
|
||||
|
||||
export const StoreGetCustomerParams = createSelectParams()
|
||||
|
||||
export const StoreCreateCustomer = z.object({
|
||||
email: z.string().email().optional(),
|
||||
company_name: z.string().optional(),
|
||||
first_name: z.string().optional(),
|
||||
last_name: z.string().optional(),
|
||||
phone: z.string().optional(),
|
||||
email: z.string().email().nullish(),
|
||||
company_name: z.string().nullish(),
|
||||
first_name: z.string().nullish(),
|
||||
last_name: z.string().nullish(),
|
||||
phone: z.string().nullish(),
|
||||
})
|
||||
|
||||
export const StoreUpdateCustomer = z.object({
|
||||
company_name: z.string().nullable().optional(),
|
||||
first_name: z.string().nullable().optional(),
|
||||
last_name: z.string().nullable().optional(),
|
||||
phone: z.string().nullable().optional(),
|
||||
company_name: z.string().nullish(),
|
||||
first_name: z.string().nullish(),
|
||||
last_name: z.string().nullish(),
|
||||
phone: z.string().nullish(),
|
||||
})
|
||||
|
||||
export const StoreGetCustomerAddressParams = createSelectParams()
|
||||
|
||||
export const StoreCreateCustomerAddress = AddressPayload.merge(
|
||||
z.object({
|
||||
address_name: z.string().optional(),
|
||||
address_name: z.string().nullish(),
|
||||
is_default_shipping: z.boolean().optional(),
|
||||
is_default_billing: z.boolean().optional(),
|
||||
})
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { z } from "zod"
|
||||
import { OptionalBooleanValidator } from "../../utils/common-validators"
|
||||
import {
|
||||
createFindParams,
|
||||
createOperatorMap,
|
||||
createSelectParams,
|
||||
} from "../../utils/validators"
|
||||
import { OptionalBooleanValidator } from "../../utils/common-validators"
|
||||
|
||||
export type StoreProductCategoryParamsType = z.infer<
|
||||
typeof StoreProductCategoryParams
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createFindParams, createSelectParams } from "../../utils/validators"
|
||||
import { z } from "zod"
|
||||
import { createFindParams, createSelectParams } from "../../utils/validators"
|
||||
|
||||
export type StoreGetRegionParamsType = z.infer<typeof StoreGetRegionParams>
|
||||
export const StoreGetRegionParams = createSelectParams()
|
||||
|
||||
@@ -22,17 +22,17 @@ const ReturnShippingSchema = z.object({
|
||||
const ItemSchema = z.object({
|
||||
id: z.string(),
|
||||
quantity: z.number().min(1),
|
||||
reason_id: z.string().optional(),
|
||||
note: z.string().optional(),
|
||||
reason_id: z.string().nullish(),
|
||||
note: z.string().nullish(),
|
||||
})
|
||||
|
||||
export const StorePostReturnsReqSchema = z.object({
|
||||
order_id: z.string(),
|
||||
items: z.array(ItemSchema),
|
||||
return_shipping: ReturnShippingSchema,
|
||||
note: z.string().optional(),
|
||||
note: z.string().nullish(),
|
||||
receive_now: z.boolean().optional(),
|
||||
location_id: z.string().optional(),
|
||||
location_id: z.string().nullish(),
|
||||
})
|
||||
export type StorePostReturnsReqSchemaType = z.infer<
|
||||
typeof StorePostReturnsReqSchema
|
||||
|
||||
Reference in New Issue
Block a user