UNPKG

@wallfar/ocd-studio-core-sdk

Version:

Helper SDK for our OneClick Studio modules

218 lines (211 loc) 7.07 kB
import { W as WebshopConfig, a as Collection, S as ShippingOption, P as Product, V as VariantOptions, A as Address, b as PromoCodeValidationResult, U as UseProductReturn } from './shared/ocd-studio-core-sdk.Swh7aSCT.js'; import * as vue from 'vue'; import { MaybeRefOrGetter, ComputedRef, Ref } from 'vue'; import { CalendarDate } from '@internationalized/date'; declare class Webshop { private config; private cart; private taxRate; private _shippingOptions; private _shippingOption; private _activePromoCode; private _collections; private _deliveryAddress; constructor(config: WebshopConfig); refreshCollections(): Promise<Collection[] | null>; refreshShippingOptions(): Promise<ShippingOption[] | null>; fetchProduct(slug: string): Promise<Product | null>; /** * Sends a notification to a user. * * @param product: Product created in the Products module from whitelabel core modules package. */ setProductSeo(product: Product): void; createConfigurator(product: Partial<Product>): { selection: any; getSelectedVariant: () => VariantOptions | undefined; getVariant: (variant: VariantOptions) => VariantOptions | undefined; }; addToCart(product: Partial<Product>, variant?: VariantOptions, quantity?: number): Promise<void>; removeFromCart(productId: string, variant?: VariantOptions): void; decreaseItem(productId: string, variant?: VariantOptions): void; updateQuantity(productId: string, variant: VariantOptions | undefined, newQty: number): void; private validatePromoCode; updateDeliveryAddress(updates: Partial<Address>): void; get cartItems(): { productId: string; title: string; slug: string; thumbnail?: string | undefined; price: number; currency: string; quantity: number; stock?: number | undefined; variant?: VariantOptions | undefined; }[]; get activePromoCode(): { id?: string | undefined; code: string; type: string; value?: number | undefined; minOrderAmount?: number | undefined; } | null; get collections(): vue.Ref<{ id?: string | undefined; title: string; description?: string | undefined; thumbnail?: string | undefined; slug: string; type: "manual" | "auto"; status: "published" | "draft"; conditions?: { field: string; operator: "==" | "!=" | "<" | ">" | "<=" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any"; value: any; }[] | undefined; seo?: { title?: string | undefined; description?: string | undefined; } | undefined; }[] | null, Collection[] | { id?: string | undefined; title: string; description?: string | undefined; thumbnail?: string | undefined; slug: string; type: "manual" | "auto"; status: "published" | "draft"; conditions?: { field: string; operator: "==" | "!=" | "<" | ">" | "<=" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any"; value: any; }[] | undefined; seo?: { title?: string | undefined; description?: string | undefined; } | undefined; }[] | null>; get itemCount(): number; get subtotal(): number; get deliveryAddress(): vue.ToRefs<{ firstName: string; lastName: string; company?: string | undefined; streetLine1: string; streetLine2?: string | undefined; streetLine3?: string | undefined; city: string; stateOrProvince?: string | undefined; countyOrDistrict?: string | undefined; postalCode: string; country: string; phoneNumber?: string | undefined; email?: string | undefined; instructions?: string | undefined; latitude?: number | undefined; longitude?: number | undefined; }>; get shippingOptions(): ShippingOption[]; get shippingOption(): string | null; set shippingOption(option: string | null); get shippingFee(): number; get discount(): number; get tax(): number; get total(): number; get country(): string; set country(val: string); applyPromoCode(code: string): Promise<PromoCodeValidationResult>; createPaymentLink(): Promise<string | undefined>; removePromoCode(): void; clearCart(): void; formatPrice(price: number, currency?: string, locale?: string): string; useProduct(slug: MaybeRefOrGetter<string>): UseProductReturn; useCollection(slug: MaybeRefOrGetter<string>): any; } interface ContentDeliveryConfig { defaultLocale?: string; defaultQueryLimit?: number; previewWhiteList?: string | string[]; provider: 'firebase'; firebase?: { db: any; entries: string; collections: string; }; } interface Content { id: string; slug: string; locale: string; title: string; description?: string; content?: object; settings?: object; createdAt: Date; } interface ContentSettings { collection: string; slug: string; locale?: string; entryId?: string; version?: string; } interface UseContentReturn { /** The content */ content: ComputedRef<Content | null>; /** The custom entry settings */ settings: ComputedRef<{ [key: string]: any; } | null>; /** Pre-generated i18n parameters */ i18nParams: ComputedRef<{ [key: string]: { slug: string; }; } | null>; /** loading state */ pending: Ref<boolean>; /** status of the fetch */ status: Ref<string>; /** fetch errors */ error: Ref<Error | null>; /** manually re-fetch */ refresh: () => Promise<void>; } declare class ContentDelivery { private config; constructor(config: ContentDeliveryConfig); useContent(settings: ContentSettings): UseContentReturn; } interface BookerConfig { defaultLocale?: string; defaultQueryLimit?: number; previewWhiteList?: string | string[]; provider: 'firebase'; firebase?: { db: any; entries: string; collections: string; }; } interface UseAppointmentBookerReturn { selectedDate: Ref<CalendarDate | null>; selectedHour: Ref<string | null>; selectedAddOns: Ref<{ [key: string]: any; }>; selectedSpots: Ref<number>; minimumBookingDate: ComputedRef<CalendarDate>; maximumBookingDate: ComputedRef<CalendarDate>; availableHours: ComputedRef<string[]>; availableSpots: ComputedRef<number>; availableAddOns: ComputedRef<any[]>; totalPrice: ComputedRef<number>; } declare class Booker { private config; private _activePromoCode; constructor(config: BookerConfig); useAppointmentBooker(agendaId: MaybeRefOrGetter<string>): UseAppointmentBookerReturn; } export { Booker, ContentDelivery, Webshop };