import type { LanguageCode as I18nLanguageCode } from "@swishapp/i18n"; import { IntentOptions } from "../intents/intents"; import { CountryCode, LanguageCode } from "../storefront-api/types/storefront.types"; import { Intent, StorefrontApiOptions, SwishClientConfig } from "../swish"; import type { Product, ProductVariant } from "../types"; export interface SwishAuthOptions { tokenUrl: string; } export interface SwishOptions { auth: SwishAuthOptions; products: SwishProductsOptions; translations?: Record>; storefrontApi: StorefrontApiOptions; storefrontContext: StorefrontContext; swishApi: SwishClientConfig; swishUi: SwishUiOptions; features: SwishFeaturesOptions; intents: IntentOptions; } export type Badge = { id: string; label: string; style?: Record; }; export interface SwishProductsMetafieldOptions { product: `${string}.${string}`[]; productVariant: `${string}.${string}`[]; } export interface SwishProductTransformOptions { badges?: (args: { product: Product; variant?: ProductVariant; defaultBadges: string[]; }) => (string | Badge)[]; title?: (args: { product: Product; }) => string; description?: (args: { product: Product; }) => string; variantTitle?: (args: { variant: ProductVariant; }) => string; optionValues?: (args: { option: NonNullable["options"][number]; optionValues: NonNullable["options"][number]["optionValues"]; }) => NonNullable["options"][number]["optionValues"]; } /** * Resolved version of SwishProductTransformOptions where all properties are required. * This is the type used after createSwishOptions processes the input. */ export type SwishProductTransformOptionsResolved = Required; export interface SwishProductsOptions { metafields: SwishProductsMetafieldOptions; transform: SwishProductTransformOptionsResolved; } export interface SwishUiDesignOptions { appearance?: { iconThickness?: number | string; }; sizes?: { buttonHeight?: number | string; iconButtonSize?: number | string; formInputHeight?: number | string; iconSize?: number | string; imageCardAspectRatio?: string; imageSliderAspectRatio?: string; }; rounding?: { borderRadiusScale?: number | string; badgeBorderRadius?: string; buttonBorderRadius?: string; dialogBorderRadius?: string; formInputBorderRadius?: string; imageCardBorderRadius?: string; imageSliderBorderRadius?: string; thumbnailBorderRadius?: string; }; colors?: { backgroundRgb?: string; textColorRgb?: string; textColorDangerRgb?: string; headingColorRgb?: string; primaryButtonBackgroundRgb?: string; primaryButtonColorRgb?: string; neutralButtonBackgroundRgb?: string; neutralButtonColorRgb?: string; dangerButtonColorRgb?: string; statusDotBackgroundRgb?: string; badgeBackgroundRgb?: string; badgeColorRgb?: string; }; typography?: { headingFontFamily?: string; headingTextTransform?: string; headingFontSize?: number | string; headingLetterSpacing?: string; headingLineHeight?: number | string; headingFontWeight?: number | string; textFontFamily?: string; textFontSize?: number | string; textLetterSpacing?: string; textLineHeight?: number | string; textLineHeightParagraph?: number | string; textFontWeight?: number | string; buttonFontFamily?: string; buttonTextTransform?: string; buttonFontSize?: number | string; buttonLetterSpacing?: string; buttonLineHeight?: number | string; buttonFontWeight?: number | string; badgeFontFamily?: string; badgeTextTransform?: string; badgeFontSize?: number | string; badgeLetterSpacing?: string; badgeLineHeight?: number | string; badgeFontWeight?: number | string; }; } export interface SwishUiOptions { baseUrl: string; components: SwishComponentOptions; css: (string | URL)[]; design: SwishUiDesignOptions; } export interface SwishFeaturesOptions { accounts: boolean; lists: boolean; orders: boolean; notifications: boolean; recentlyViewed: boolean; savedFromCart: boolean; } export interface StorefrontContext { customer: { id: string | null; email: string | null; firstName: string | null; lastName: string | null; b2b: boolean | null; }; localization: { country: CountryCode; language: LanguageCode; market: string; }; myshopifyDomain: string; newCustomerAccounts: boolean; routes: { accountUrl: string; rootUrl: string; listDetailPagePath: string; }; } export interface SwishComponentOptions { productCard: SwishProductCardOptions; productRow: SwishProductRowOptions; productDetail: SwishProductDetailOptions; variantSelect: SwishVariantSelectOptions; imageSlider: SwishImageSliderOptions; icons: Record; images: SwishImageOptions; buyButtons: SwishBuyButtonsOptions; drawer: SwishDrawerOptions; listDetailPage: SwishListDetailPageOptions; listsSection: SwishListsSectionOptions; } export interface SwishProductCardOptions { linkToProductPage: boolean; } export interface SwishListDetailPageOptions { desktopColumns: number; showBuyButton: boolean; showVariantOptionNames: boolean; enableVariantChange: boolean; } export interface SwishProductRowOptions { showVariantTitle: boolean; } export interface SwishProductDetailOptions { /** Clamp the description to this many lines in the UI. */ descriptionMaxLines: number; } export type SwishVariantSelectDisplay = "pills" | "rows"; export interface SwishVariantSelectOptions { displayType: SwishVariantSelectDisplay; hideSingleValueOptions: boolean; } export interface SwishImageSliderOptions { flush: boolean; loop: boolean; } export interface SwishBuyButtonsOptions { shopPay: boolean; } export interface SwishImageOptions { baseTint: boolean; } export type SwishListsSectionDisplay = "list" | "slider"; export interface SwishListsSectionOptions { displayType: SwishListsSectionDisplay; } export type SwishDrawerNavigationVariant = "floating" | "docked"; export interface SwishDrawerNavigationItem { id: string; enabled: boolean; intent: Intent; } export interface SwishDrawerNavigationOptions { enabled: boolean; variant: SwishDrawerNavigationVariant; showIcons: boolean; showText: boolean; items: SwishDrawerNavigationItem[]; } export interface SwishDrawerMiniMenuItem { title: string; url: string; } export interface SwishDrawerMiniMenuOptions { enabled: boolean; items: SwishDrawerMiniMenuItem[]; } export interface SwishDrawerListDetailViewOptions { enableVariantChange: boolean; showVariantOptionNames: boolean; } export interface SwishDrawerLogoOptions { url: string; altText: string; } export interface SwishDrawerContentBlockOptions { title?: string; body?: string; image?: { url: string; width?: number; height?: number; }; link?: { url: string; target?: string; }; } export interface SwishDrawerHomeOptions { contentBlock?: SwishDrawerContentBlockOptions; } export interface SwishDrawerOptions { title: string; logo: SwishDrawerLogoOptions; navigation: SwishDrawerNavigationOptions; miniMenu: SwishDrawerMiniMenuOptions; listDetailView: SwishDrawerListDetailViewOptions; emptyCallout: SwishDrawerEmptyCalloutOptions; home?: SwishDrawerHomeOptions; } export interface SwishDrawerEmptyCalloutOptions { enabled: boolean; shoppingCalloutUrl: string; }