Bookings SDK reference

Booking lists, offers, availability, slots and booking actions.

Import these public values from @upstorr/theme-sdk/v1. Do not import their internal source files.

buildThemeBookingUrl

buildThemeBookingUrl(handle: string, variantId?: string | null): string

createThemeBookingAvailabilityView

createThemeBookingAvailabilityView(slots: ThemeBookingSlotViewInput[]): ThemeBookingAvailabilityView

createThemeBookingHold

createThemeBookingHold(input: { handle: string; startsAt: string; quantity?: number; variantId?: string; }): Promise<ThemeBookingHold>

createThemeBookingListView

createThemeBookingListView(input: { offers: ThemeBookingOfferViewInput[]; currencyCode: string; layout: string; requestedLimit: unknown; }): { limit: number; cards: ThemeBookingListCardView[]; hasItems: boolean; }

createThemeBookingOfferView

createThemeBookingOfferView(offer: ThemeBookingOfferViewInput, options: { currencyCode: string; showCurrencyCode?: boolean; }): ThemeBookingOfferView

formatThemeBookingSlotParts

formatThemeBookingSlotParts(input: { startsAt: string; endsAt: string; timezone?: string | null; }): { dateLabel: string; timeLabel: string; }

formatThemeBookingSlotRange

formatThemeBookingSlotRange(input: { startsAt: string; endsAt: string; timezone?: string | null; }): string

normalizeThemeBookingListLimit

normalizeThemeBookingListLimit(layout: unknown, requestedLimit: unknown): number

THEME_BOOKING_DATE_PAGE_SIZE

THEME_BOOKING_DATE_PAGE_SIZE: 4

ThemeBookingAvailabilityView

type ThemeBookingAvailabilityView = {
    hasSlots: boolean;
    activeDateKey: string;
    groups: Array<{
        key: string;
        dateLabel: string;
        weekdayLabel: string;
        dayLabel: string;
        initiallySelected: boolean;
        initiallyVisible: boolean;
        slots: Array<ThemeBookingSlotViewInput & {
            maxQuantity: number;
            usesQuantitySelector: boolean;
            remainingCapacityLabel: string | null;
        }>;
    }>;
    navigation: {
        pageSize: number;
        previousDisabled: boolean;
        nextDisabled: boolean;
    };
    interaction: {
        quantity: {
            value: number;
            minimum: number;
            maximum: number;
            step: number;
            hidden: boolean;
            decreaseDisabled: boolean;
            increaseDisabled: boolean;
        };
        continue: {
            disabled: boolean;
            defaultLabel: string;
        };
    };
};

ThemeBookingListCardView

type ThemeBookingListCardView = {
    id: string;
    title: string;
    handle: string;
    imageUrl: string | null;
    hideMediaWhenMissing: true;
    url: string;
    all_products_count: 1;
    products_count: 1;
    products: [];
};

ThemeBookingMediaProductView

type ThemeBookingMediaProductView = {
    id: string;
    name: string;
    title: string;
    handle: string;
    description: string;
    thumbnail: string;
    images: string[];
    price?: number;
    salePrice: number | null;
    currency: string;
    currencyCode: string;
    inStock: true;
    fulfillmentKind: 'SERVICE';
    variants: Array<ThemeBookingVariantViewInput & {
        image: string | null;
        featuredImage: string | null;
        thumbnail: string | null;
        images: string[];
    }>;
    selectedVariant: ThemeBookingVariantViewInput & {
        image: string | null;
        featuredImage: string | null;
        thumbnail: string | null;
        images: string[];
    };
    selectedVariantId: string;
};

ThemeBookingOfferView

type ThemeBookingOfferView = {
    id: string;
    handle: string;
    title: string;
    description: string;
    typeLabel: string;
    formattedPrice: string;
    durationLabel: string;
    bookingWindowLabel: string;
    primaryImage: string | null;
    mediaProduct: ThemeBookingMediaProductView | null;
    hasMedia: boolean;
    variants: ThemeBookingVariantView[];
    showVariantSelector: boolean;
    selectedVariantId: string | null;
    securityDeposit: {
        label: string;
        amountLabel: string;
        terms: string | null;
        expandable: boolean;
    } | null;
    checkout: {
        productId: string;
        variantId: string | null;
        canCheckout: boolean;
    };
};

ThemeBookingOfferViewInput

type ThemeBookingOfferViewInput = {
    id: string;
    title: string;
    handle: string;
    description?: string | null;
    type?: string | null;
    durationMinutes: number;
    bookingWindowMinHours?: number | null;
    bookingWindowMaxDays?: number | null;
    productId?: string | null;
    price?: number | null;
    currency?: string | null;
    imageUrl?: string | null;
    securityDeposit?: ThemeBookingSecurityDeposit | null;
    product?: {
        id: string;
        handle?: string | null;
        title?: string | null;
        description?: string | null;
        variantId?: string | null;
        selectedVariantId?: string | null;
        variants: ThemeBookingVariantViewInput[];
        price?: number | null;
        salePrice?: number | null;
        currency?: string | null;
        thumbnail?: string | null;
        imageUrl?: string | null;
        featuredImage?: string | null;
        featured_image?: string | null;
        images?: string[] | null;
    } | null;
};

ThemeBookingSlotViewInput

type ThemeBookingSlotViewInput = {
    id: string;
    startsAt: string;
    endsAt: string;
    timezone: string;
    dateLabel: string;
    timeLabel: string;
    displayLabel: string;
    capacity: number;
    remainingCapacity: number;
    maxSelectableQuantity: number;
};

ThemeBookingVariantView

type ThemeBookingVariantView = ThemeBookingVariantViewInput & {
    label: string;
    href: string;
    selected: boolean;
    disabled: boolean;
};

ThemeBookingVariantViewInput

type ThemeBookingVariantViewInput = {
    id: string;
    name?: string | null;
    title?: string | null;
    sku?: string | null;
    thumbnail?: string | null;
    image?: string | null;
    imageUrl?: string | null;
    featuredImage?: string | null;
    featured_image?: string | null;
    images?: string[] | null;
    price?: number | null;
    salePrice?: number | null;
    inStock?: boolean;
    option1?: string | null;
    option2?: string | null;
    option3?: string | null;
    options?: Record<string, string> | Array<{ name?: string; value?: string }>;
};

updateThemeBookingCartItemQuantity

updateThemeBookingCartItemQuantity(cartItemId: string, quantity: number): Promise<ThemeCart>