From 876800aad5426b80ad24f7c56ff6cd5806b3716d Mon Sep 17 00:00:00 2001 From: Victor Gerbrands Date: Tue, 2 May 2023 15:41:12 +0200 Subject: [PATCH] feat: add medusa types --- lib/medusa/types.ts | 252 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 lib/medusa/types.ts diff --git a/lib/medusa/types.ts b/lib/medusa/types.ts new file mode 100644 index 000000000..123166959 --- /dev/null +++ b/lib/medusa/types.ts @@ -0,0 +1,252 @@ +export type ProductCollection = { + id: string; + title: string; + handle: string | null; + products?: Product[]; + created_at: string; // format: date-time + updated_at: string; // format: date-time + deleted_at?: string | null; // format: date-time + metadata?: Record | null; +}; + +export type MedusaProduct = { + id: string; + title: string; + subtitle?: string | null; + description?: string | null; + handle?: string | null; + is_giftcard: boolean; + status?: 'draft' | 'proposed' | 'published' | 'rejected'; + images?: Array; + thumbnail?: string | null; + options?: Array; + variants?: Array; + categories?: Array; + profile_id?: string | null; + profile?: ShippingProfile | null; + weight?: number | null; + length?: number | null; + height?: number | null; + width?: number | null; + hs_code?: string | null; + origin_country?: string | null; + mid_code?: string | null; + metadata?: Record; + discountable?: boolean; + collection_id: string; + created_at: Date; + updated_at: Date; + deleted_at: Date | null; + type_id: string; + material?: string | null; +}; + +export type Product = MedusaProduct & { + featuredImage: { + url: string; + }; + priceRange: { + maxVariantPrice: { + amount: string; + currencyCode: string; + }; + }; +}; + +export type Image = { + id: string; + url: string; + created_at: string; + updated_at: string; + deleted_at?: string | null; + metadata?: { [key: string]: string } | null; +}; + +export type ShippingProfile = { + id: string; + name: string; + type: 'default' | 'gift_card' | 'custom'; + products?: Product[]; + shipping_options?: ShippingOption[]; + created_at: string; + updated_at: string; + deleted_at?: string | null; + metadata?: { [key: string]: any } | null; +}; + +export type ProductCategory = { + id: string; + name: string; + handle: string; + mpath: string | null; + is_internal?: boolean; + is_active?: boolean; + rank?: number; + category_children?: ProductCategory[]; + parent_category_id?: string | null; + parent_category?: ProductCategory | null; + products?: Product[]; + created_at: string; + updated_at: string; +}; + +export type ProductVariant = { + id: string; + title?: string; + product_id: string; + product?: Product; + prices?: MoneyAmount[]; + sku?: string; + barcode?: string | null; + ean?: string | null; + upc?: string | null; + variant_rank?: number | null; + inventory_quantity: number; + allow_backorder: boolean; + manage_inventory: boolean; + hs_code?: string | null; + origin_country?: string | null; + mid_code?: string | null; + material?: string | null; + weight?: number | null; + length?: number | null; + height?: number | null; + width?: number | null; + options?: ProductOptionValue[]; + created_at: string; + updated_at: string; + deleted_at: string | null; +}; + +type MoneyAmount = { + id: string; + currency_code: string; + currency?: Currency | null; + amount: number; + min_quantity?: number | null; + max_quantity?: number | null; + price_list_id?: string | null; + price_list?: PriceList | null; + variant_id?: string | null; + variant?: ProductVariant | null; + region_id?: string | null; + region?: Region | null; + created_at: string; + updated_at: string; + deleted_at?: string | null; +}; + +export type Currency = { + code: string; + symbol: string; + symbol_native: string; + name: string; + includes_tax?: boolean; +}; + +export type PriceList = { + id: string; + name: string; + description: string; + type?: 'sale' | 'override'; + status?: 'active' | 'draft'; + starts_at?: string | null; + ends_at?: string | null; + customer_groups?: CustomerGroup[]; + prices?: MoneyAmount[]; + includes_tax?: boolean; + created_at: string; + updated_at: string; + deleted_at?: string | null; +}; + +export type CustomerGroup = { + id: string; + name: string; +}; + +export type ProductOption = { + id: string; + title: string; + values?: ProductOptionValue[]; + product_id: string; + product?: Product | null; + created_at: string; + updated_at: string; + deleted_at?: string | null; + metadata?: Record | null; +}; + +export type ProductOptionValue = { + id: string; + value: string; + option_id: string; + option?: ProductOption | null; + variant_id: string; + variant?: ProductVariant | null; + created_at: string; + updated_at: string; + deleted_at?: string | null; + metadata?: Record | null; +}; + +type ShippingOption = { + id: string; + name: string; + region_id: string; + region?: Region | null; + profile_id: string; + profile?: ShippingProfile | null; + provider_id: string; + provider?: FulfillmentProvider | null; + price_type: 'flat_rate' | 'calculated'; + amount?: number | null; + is_return: boolean; + admin_only: boolean; + requirements?: ShippingOptionRequirement[]; + data: Record; + includes_tax: boolean; + created_at: string; + updated_at: string; + deleted_at?: string | null; + metadata?: Record | null; +}; + +export type Region = { + id: string; + name: string; + country_code: string; + created_at: string; + updated_at: string; + deleted_at?: string | null; + metadata?: Record | null; +}; + +export type FulfillmentProvider = { + id: string; + name: string; + created_at: string; + updated_at: string; + deleted_at?: string | null; + metadata?: Record | null; +}; + +export type ShippingOptionRequirement = { + id: string; + requirement_id: string; + value: string; + created_at: string; + updated_at: string; + deleted_at?: string | null; + metadata?: Record | null; +}; + +export type MedusaCart = { + id: string; + items: []; +}; + +export type Cart = Omit & { + lines: []; + totalQuantity: number; +};