Back to arky.io

E-shop Types

E-commerce type definitions

Type definitions for the E-shop module.

Product

interface Product {
  id: string;
  key: string;
  businessId: string;
  slug: Record<string, string>;
  blocks: Block[];
  taxonomies: TaxonomyEntry[];
  variants: ProductVariant[];
  audienceIds: string[];
  status: Status;        // 'active' | 'archived'
  createdAt: number;
  updatedAt: number;
}
Note

Product display fields (name, description, images, price) live on blocks and variants rather than as fixed columns. Use the CMS block helpers to read localized values.

Order

interface Order {
  id: string;
  number: string;
  businessId: string;
  status: OrderStatus;
  workflowStatus: OrderWorkflowStatus;
  items: OrderLineItem[];
  blocks: Block[];
  payment: Payment;
  shipping?: OrderShipping;
  shipments?: Shipment[];
  address?: Address;
  billingAddress?: Address;
  audienceId?: string;
  createdAt: number;
  updatedAt: number;
}

type OrderStatus = 'active' | 'archived';

type OrderWorkflowStatus =
  | 'created'
  | 'pending'
  | 'authorized'
  | 'confirmed'
  | 'shipped'
  | 'completed'
  | 'cancelled'
  | 'failed';
Note

status is the active/archived split (used to hide an order from the default admin view). workflowStatus carries the lifecycle state that used to live on status.

Order Line Item

interface OrderLineItem {
  id: string;
  productId: string;
  name: string;
  sku?: string;
  price: number;
  quantity: number;
  image?: string;
}

Payment

interface Payment {
  currency: string;
  market: string;
  subtotal: number;
  shipping: number;
  discount: number;
  total: number;
  paid: number;
  tax?: {
    amount: number;
    modeSnapshot?: string;
    rateBps: number;
    lines: Array<{
      rateBps: number;
      amount: number;
      label?: string;
      scope?: string;
    }>;
  };
  promoCode?: {
    id: string;
    code: string;
    type: string;
    value: number;
  };
  type: PaymentMethodType;
  provider?: {
    customerId: string;
    paymentIntentId?: string;
    subscriptionId?: string;
    priceId?: string;
  };
  refunds: PaymentRefund[];
  zoneId?: string;
  paymentMethodId?: string;
  shippingMethodId?: string;
}

enum PaymentMethodType {
  Cash = 'cash',
  CreditCard = 'credit_card',
}

interface PaymentRefund {
  id: string;
  entity: string;
  total: number;
  providerRefundId?: string;
  status: string;
  createdAt: number;
}

Quote

interface Quote {
  market: string;
  zone: Zone | null;
  subtotal: number;
  shipping: number;
  discount: number;
  tax: number;
  total: number;
  shippingMethod: ShippingMethod | null;
  paymentMethod: PaymentMethod | null;
  paymentMethods: PaymentMethod[];
  promoCode: PromoCodeValidation | null;
  payment: Payment;
  chargeAmount: number;
  id?: string;
  expiresAt?: number;
}

interface PromoCodeValidation {
  promoCodeId: string;
  code: string;
  discounts: any[];
  conditions: any[];
}

Checkout Response

interface CheckoutResponse {
  order: Order;
  requiresAction: boolean;
  clientSecret?: string;  // For 3D Secure
  redirectUrl?: string;
}

Promo Code

interface PromoCode {
  id: string;
  businessId: string;
  code: string;
  discounts: Discount[];
  conditions: Condition[];
  status: Status;        // 'active' | 'archived'
  createdAt: number;
  updatedAt: number;
}

interface Discount {
  type: 'items_percentage' | 'items_fixed' | 'shipping_percentage';
  marketId: string;
  bps?: number;
  amount?: number;
}

interface Condition {
  type:
    | 'products'
    | 'services'
    | 'min_order_amount'
    | 'date_range'
    | 'max_uses'
    | 'max_uses_per_user';
  value: string[] | number | { start?: number; end?: number };
}

Cart Item (Client-Side)

interface EshopCartItem {
  id: string;
  productId: string;
  variantId: string;
  productName: string;
  productSlug: string;
  variantAttributes: Record<string, any>;
  price: Price;
  quantity: number;
  addedAt: number;
}

Product Category

interface ProductCategory {
  slug: string;
  name: string;
  description?: string;
  image?: string;
  parentSlug?: string;
  productCount: number;
}

Inventory Event

interface InventoryEvent {
  productId: string;
  type: 'INCREMENT' | 'DECREMENT' | 'SET';
  quantity: number;
  reason?: string;
  orderId?: string;
  timestamp: number;
}

Filter & Sort Options

interface ProductFilters {
  status?: Status;       // 'active' | 'archived'
  category?: string;
  minPrice?: number;
  maxPrice?: number;
  inStock?: boolean;
  search?: string;
}

interface ProductSort {
  field: 'createdAt' | 'name' | 'price' | 'inventory';
  order: 'asc' | 'desc';
}