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:
Riqwan Thamir
2024-06-20 10:10:59 +00:00
committed by GitHub
parent 33c4cd34cc
commit f61557712c
64 changed files with 431 additions and 416 deletions
@@ -102,7 +102,8 @@ function prepareFulfillmentData({
} as FulfillmentWorkflow.CreateFulfillmentItemWorkflowDTO
})
let locationId: string | undefined = input.location_id
let locationId: string | undefined | null = input.location_id
if (!locationId) {
locationId = shippingOption.service_zone.fulfillment_set.location?.id
}
@@ -168,7 +168,7 @@ function prepareFulfillmentData({
} as FulfillmentWorkflow.CreateFulfillmentItemWorkflowDTO
})
let locationId: string | undefined = input.location_id
let locationId: string | undefined | null = input.location_id
if (!locationId) {
locationId = returnShippingOption.service_zone.fulfillment_set.location?.id
}
+2
View File
@@ -361,3 +361,5 @@ export type KebabCase<S extends string> =
? `${Lowercase<T>}-${KebabCase<`${Lowercase<U>}${V}`>}`
: `${T}${KebabCase<`${U}${V}`>}`
: S
export type MetadataType = Record<string, unknown> | null
+28 -26
View File
@@ -1,3 +1,5 @@
import { MetadataType } from "../common"
/**
* The customer address to be created.
*/
@@ -5,7 +7,7 @@ export interface CreateCustomerAddressDTO {
/**
* The address's name.
*/
address_name?: string
address_name?: string | null
/**
* Whether the address is default shipping.
@@ -25,57 +27,57 @@ export interface CreateCustomerAddressDTO {
/**
* The company.
*/
company?: string
company?: string | null
/**
* The first name.
*/
first_name?: string
first_name?: string | null
/**
* The last name.
*/
last_name?: string
last_name?: string | null
/**
* The address 1.
*/
address_1?: string
address_1?: string | null
/**
* The address 2.
*/
address_2?: string
address_2?: string | null
/**
* The city.
*/
city?: string
city?: string | null
/**
* The country code.
*/
country_code?: string
country_code?: string | null
/**
* The province.
*/
province?: string
province?: string | null
/**
* The postal code.
*/
postal_code?: string
postal_code?: string | null
/**
* The phone.
*/
phone?: string
phone?: string | null
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -160,7 +162,7 @@ export interface UpdateCustomerAddressDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -170,32 +172,32 @@ export interface CreateCustomerDTO {
/**
* The company name of the customer.
*/
company_name?: string
company_name?: string | null
/**
* The first name of the customer.
*/
first_name?: string
first_name?: string | null
/**
* The last name of the customer.
*/
last_name?: string
last_name?: string | null
/**
* The email of the customer.
*/
email?: string
email?: string | null
/**
* The phone of the customer.
*/
phone?: string
phone?: string | null
/**
* Who created the customer.
*/
created_by?: string
created_by?: string | null
/**
* The addresses of the customer.
@@ -205,7 +207,7 @@ export interface CreateCustomerDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -245,7 +247,7 @@ export interface UpdateCustomerDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -280,7 +282,7 @@ export interface CustomerUpdatableFields {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -295,7 +297,7 @@ export interface CustomerGroupUpdatableFields {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -320,7 +322,7 @@ export interface UpdateCustomerGroupDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -335,7 +337,7 @@ export interface CreateCustomerGroupDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
/**
* Who created the customer group. For example,
@@ -361,5 +363,5 @@ export interface UpdateCustomerGroupDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
@@ -46,7 +46,7 @@ export interface UpdateServiceZoneDTO {
/**
* The name of the service zone.
*/
name?: string
name?: string | null
/**
* The geo zones associated with the service zone.
@@ -16,7 +16,7 @@ export interface UpdateReservationItemInput {
/**
* The description of the reservation item.
*/
description?: string
description?: string | null
/**
* Allow backorder of the item. If true, it won't check inventory levels before reserving it.
*/
@@ -36,7 +36,7 @@ export interface CreateReservationItemInput {
/**
* The ID of the associated line item.
*/
line_item_id?: string
line_item_id?: string | null
/**
* The ID of the associated inventory item.
*/
@@ -56,15 +56,15 @@ export interface CreateReservationItemInput {
/**
* The description of the reservation.
*/
description?: string
description?: string | null
/**
* The user or system that created the reservation. Can be any form of identification string.
*/
created_by?: string
created_by?: string | null
/**
* An ID associated with an external third-party system that the reservation item is connected to.
*/
external_id?: string
external_id?: string | null
/**
* Holds custom data in key-value pairs.
*/
@@ -72,7 +72,7 @@ export interface CreateReservationItemInput {
}
export interface ReserveQuantityContext {
locationId?: string
lineItemId?: string
locationId?: string | null
lineItemId?: string | null
salesChannelId?: string | null
}
+13 -13
View File
@@ -253,7 +253,7 @@ export interface CreateOrderChangeDTO {
claim_id?: string
exchange_id?: string
description?: string
internal_note?: string
internal_note?: string | null
requested_by?: string
requested_at?: Date
created_by?: string
@@ -265,7 +265,7 @@ export interface UpdateOrderChangeDTO {
id: string
status?: string
description?: string
internal_note?: string
internal_note?: string | null
requested_by?: string
requested_at?: Date
confirmed_by?: string
@@ -309,14 +309,14 @@ export interface CreateOrderChangeActionDTO {
reference?: string
reference_id?: string
action: ChangeActionType
internal_note?: string
internal_note?: string | null
amount?: BigNumberInput
details?: Record<string, unknown>
}
export interface UpdateOrderChangeActionDTO {
id: string
internal_note?: string
internal_note?: string | null
}
/** ORDER TRANSACTION START */
@@ -326,7 +326,7 @@ export interface CreateOrderTransactionDTO {
description?: string
reference?: string
reference_id?: string
internal_note?: string
internal_note?: string | null
created_by?: string
amount: BigNumberInput
currency_code: string
@@ -338,7 +338,7 @@ export interface UpdateOrderTransactionDTO {
amount?: BigNumberInput
currency_code?: string
description?: string
internal_note?: string
internal_note?: string | null
reference?: string
reference_id?: string
metadata?: Record<string, unknown> | null
@@ -378,8 +378,8 @@ export interface UpdateOrderItemWithSelectorDTO {
interface BaseOrderBundledItemActionsDTO {
id: string
quantity: BigNumberInput
internal_note?: string
note?: string
internal_note?: string | null
note?: string | null
metadata?: Record<string, unknown> | null
}
interface BaseOrderBundledActionsDTO {
@@ -389,10 +389,10 @@ interface BaseOrderBundledActionsDTO {
exchange_id?: string
description?: string
internal_note?: string
internal_note?: string | null
reference?: string
reference_id?: string
created_by?: string
created_by?: string | null
metadata?: Record<string, unknown> | null
}
@@ -414,9 +414,9 @@ export interface CreateOrderReturnDTO extends BaseOrderBundledActionsDTO {
items: {
id: string
quantity: BigNumberInput
internal_note?: string
note?: string
reason_id?: string
internal_note?: string | null
note?: string | null
reason_id?: string | null
metadata?: Record<string, any>
}[]
shipping_method?: Omit<CreateOrderShippingMethodDTO, "order_id"> | string
@@ -90,11 +90,11 @@ export interface UpdateMoneyAmountDTO {
/**
* The minimum quantity required to be purchased for this money amount to be applied.
*/
min_quantity?: BigNumberInput
min_quantity?: BigNumberInput | null
/**
* The maximum quantity required to be purchased for this money amount to be applied.
*/
max_quantity?: BigNumberInput
max_quantity?: BigNumberInput | null
}
/**
@@ -203,7 +203,7 @@ export interface UpdatePriceListDTO {
/**
* The price list's description.
*/
description?: string
description?: string | null
/**
* The price list is enabled starting from this date.
*/
+5 -5
View File
@@ -5,8 +5,8 @@ export interface CreatePriceListPriceWorkflowDTO {
amount: number
currency_code: string
variant_id: string
max_quantity?: number
min_quantity?: number
max_quantity?: number | null
min_quantity?: number | null
rules?: Record<string, string>
}
@@ -15,8 +15,8 @@ export interface UpdatePriceListPriceWorkflowDTO {
variant_id: string
amount?: number
currency_code?: string
max_quantity?: number
min_quantity?: number
max_quantity?: number | null
min_quantity?: number | null
rules?: Record<string, string>
}
@@ -33,7 +33,7 @@ export interface CreatePriceListWorkflowInputDTO {
export interface UpdatePriceListWorkflowInputDTO {
id: string
title?: string
description?: string
description?: string | null
starts_at?: string | null
ends_at?: string | null
status?: PriceListStatus
+21 -20
View File
@@ -1,3 +1,4 @@
import { MetadataType } from "../common"
import { BaseFilterable } from "../dal"
import { OperatorMap } from "../dal/utils"
@@ -150,7 +151,7 @@ export interface ProductDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -298,7 +299,7 @@ export interface ProductCategoryDTO {
/**
* The ranking of the product category among sibling categories.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
/**
* The associated parent category.
*
@@ -368,7 +369,7 @@ export interface CreateProductCategoryDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
export interface UpsertProductCategoryDTO extends UpdateProductCategoryDTO {
@@ -415,7 +416,7 @@ export interface UpdateProductCategoryDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -435,7 +436,7 @@ export interface ProductTagDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
/**
* The associated products.
*
@@ -465,7 +466,7 @@ export interface ProductCollectionDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
/**
* When the product collection was created.
*/
@@ -503,7 +504,7 @@ export interface ProductTypeDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
/**
* When the product type was created.
*/
@@ -552,7 +553,7 @@ export interface ProductOptionDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
/**
* When the product option was created.
*/
@@ -589,7 +590,7 @@ export interface ProductImageDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
/**
* When the product image was created.
*/
@@ -638,7 +639,7 @@ export interface ProductOptionValueDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
/**
* When the product option value was created.
*/
@@ -950,7 +951,7 @@ export interface CreateProductCollectionDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -992,7 +993,7 @@ export interface UpdateProductCollectionDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -1008,7 +1009,7 @@ export interface CreateProductTypeDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -1038,7 +1039,7 @@ export interface UpdateProductTypeDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -1054,7 +1055,7 @@ export interface CreateProductImageDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -1083,7 +1084,7 @@ export interface UpdateProductImageDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -1255,7 +1256,7 @@ export interface CreateProductVariantDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -1347,7 +1348,7 @@ export interface UpdateProductVariantDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -1456,7 +1457,7 @@ export interface CreateProductDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -1573,5 +1574,5 @@ export interface UpdateProductDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
@@ -67,7 +67,7 @@ export interface CreateCampaignDTO {
/**
* The description of the campaign.
*/
description?: string
description?: string | null
/**
* The campaign identifier of the campaign.
@@ -77,12 +77,12 @@ export interface CreateCampaignDTO {
/**
* The start date of the campaign.
*/
starts_at?: Date
starts_at?: Date | null
/**
* The end date of the campaign.
*/
ends_at?: Date
ends_at?: Date | null
/**
* The associated campaign budget.
@@ -107,7 +107,7 @@ export interface UpdateCampaignDTO {
/**
* The description of the campaign.
*/
description?: string
description?: string | null
/**
* The campaign identifier of the campaign.
@@ -117,12 +117,12 @@ export interface UpdateCampaignDTO {
/**
* The start date of the campaign.
*/
starts_at?: Date
starts_at?: Date | null
/**
* The end date of the campaign.
*/
ends_at?: Date
ends_at?: Date | null
/**
* The budget of the campaign.
+5 -3
View File
@@ -1,3 +1,5 @@
import { MetadataType } from "../common"
/**
* The region to be created.
*/
@@ -25,7 +27,7 @@ export interface CreateRegionDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -57,7 +59,7 @@ export interface UpsertRegionDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -83,5 +85,5 @@ export interface UpdateRegionDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
@@ -1,3 +1,5 @@
import { MetadataType } from "../common"
/**
* The sales channel to be created.
*/
@@ -10,7 +12,7 @@ export interface CreateSalesChannelDTO {
/**
* The description of the sales channel.
*/
description?: string
description?: string | null
/**
* Whether the sales channel is disabled.
@@ -39,7 +41,7 @@ export interface UpdateSalesChannelDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -69,5 +71,5 @@ export interface UpsertSalesChannelDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
@@ -1,3 +1,4 @@
import { MetadataType } from "../common"
import { BaseFilterable, OperatorMap } from "../dal"
import { FulfillmentSetDTO } from "../fulfillment"
@@ -114,7 +115,7 @@ export type StockLocationAddressDTO = {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
/**
* The creation date of the stock location address.
@@ -346,7 +347,7 @@ export type StockLocationAddressInput = {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -382,7 +383,7 @@ export type CreateStockLocationInput = {
/**
* The associated address's ID.
*/
address_id?: string
address_id?: string | null
/**
* The associated address.
@@ -392,7 +393,7 @@ export type CreateStockLocationInput = {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -426,7 +427,7 @@ export type UpdateStockLocationInput = {
/**
* The associated address's ID.
*/
address_id?: string
address_id?: string | null
/**
* The associated address's details.
@@ -436,7 +437,7 @@ export type UpdateStockLocationInput = {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
+8 -6
View File
@@ -1,3 +1,5 @@
import { MetadataType } from "../common"
/**
* The tax rate to be created.
*/
@@ -44,7 +46,7 @@ export interface CreateTaxRateDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -89,7 +91,7 @@ export interface UpsertTaxRateDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null
metadata?: MetadataType
}
/**
@@ -142,7 +144,7 @@ export interface UpdateTaxRateDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
/**
@@ -167,7 +169,7 @@ export interface CreateTaxRegionDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
/**
* Who created the tax region. For example, the ID of
@@ -200,7 +202,7 @@ export interface CreateTaxRegionDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
}
}
@@ -232,7 +234,7 @@ export interface CreateTaxRateRuleDTO {
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown>
metadata?: MetadataType
/**
* Who created the tax rate rule. For example, the ID of the
@@ -22,7 +22,7 @@ export interface CreateServiceZonesWorkflowInput {
}
interface UpdateServiceZone {
name?: string
name?: string | null
geo_zones?: (
| Omit<CreateCountryGeoZoneDTO, "service_zone_id">
| Omit<CreateProvinceGeoZoneDTO, "service_zone_id">
@@ -10,6 +10,6 @@ export interface CreateOrderFulfillmentWorkflowInput {
created_by?: string // The id of the authenticated user
items: CreateOrderFulfillmentItem[]
no_notification?: boolean
location_id?: string
metadata?: Record<string, any>
location_id?: string | null
metadata?: Record<string, any> | null
}
@@ -3,25 +3,25 @@ import { BigNumberInput } from "../../totals"
interface CreateReturnItem {
id: string
quantity: BigNumberInput
internal_note?: string
note?: string
reason_id?: string
internal_note?: string | null
reason_id?: string | null
note?: string | null
metadata?: Record<string, any>
}
export interface CreateOrderReturnWorkflowInput {
order_id: string
created_by?: string // The id of the authenticated user
created_by?: string | null // The id of the authenticated user
items: CreateReturnItem[]
return_shipping: {
option_id: string
price?: number
}
note?: string
note?: string | null
receive_now?: boolean
refund_amount?: number
/**
* Default fallback to the shipping option location id
*/
location_id?: string
location_id?: string | null
}
@@ -1,3 +1,4 @@
import { MetadataType } from "../../common"
import { BigNumberInput } from "../../totals"
import { CreateFulfillmentLabelWorkflowDTO } from "../fulfillment"
@@ -13,5 +14,5 @@ export interface CreateOrderShipmentWorkflowInput {
items: CreateOrderShipmentItem[]
labels: CreateFulfillmentLabelWorkflowDTO[]
no_notification?: boolean
metadata?: Record<string, any>
metadata?: MetadataType
}