UNPKG

@selldone/sdk-storefront

Version:

A TypeScript SDK to connect to your shop and build a fully functional storefront and website by simply developing a frontend web application. All backend operations are seamlessly managed by the serverless Selldone solution.

98 lines (97 loc) 3.74 kB
import { CDN, URLS, User } from "@selldone/core-js"; import { XapiUser } from "./user/XapiUser"; import { XAPI } from "./apis/XAPI"; import { XapiShop } from "./shop/XapiShop"; import { XapiAuth } from "./auth/XapiAuth"; import { Shop } from "@selldone/core-js/models/shop/shop.model"; import { XapiProduct } from "./product/XapiProduct"; import { XapiLottery } from "./lottery/XapiLottery"; import { StorefrontDatabase } from "./database/StorefrontDatabase"; import { XapiCoupon } from "./coupon/XapiCoupon"; import { XapiOffer } from "./offer/XapiOffer"; import { type ICurrency } from "@selldone/core-js/enums/payment/Currency"; import { XapiBasket } from "./basket/XapiBasket"; import { XapiVendor } from "./vendor/XapiVendor"; import { XapiAvocado } from "./avocado/XapiAvocado"; import { XapiArticle } from "./article/XapiArticle"; import { StorefrontRoutesName } from "@selldone/core-js/enums/route/StorefrontRoutesName"; import { XapiCashback } from "@selldone/sdk-storefront/cashback/XapiCashback"; declare global { interface Window { NativeApp?: boolean; axios: any; SelldoneUser?: { access_token: string; /** * The expires_in field specifies the time at which the access token expires, represented in seconds since the token was issued. */ expires_in: number; refresh_token?: string | null; }; /** * 🚀 Preloaded Shop Information * * When the shop page loads, the backend might already populate `window.shop` with relevant shop data. * * Example: * window.shop = {!! json_encode(\App\Shop\Shop::GetPublicInfo($shop->name, null, false)) !!}; */ shop: Partial<Shop>; CDN: CDN; XAPI: XAPI; URLS: URLS; ADDRESS_API: XAPI; ARTICLE_API: XAPI; $storefront: { USER: User | null; name: string; prefix_url: string; local_storage_path: string; database: StorefrontDatabase; currency: ICurrency; home: Shop.Home | null; user: XapiUser; shop: XapiShop; auth: XapiAuth; products: XapiProduct; lottery: XapiLottery; coupon: XapiCoupon; offer: XapiOffer; cashback: XapiCashback; basket: XapiBasket; vendor: XapiVendor; avocado: XapiAvocado; article: XapiArticle; routes: typeof StorefrontRoutesName; }; } } export declare class StorefrontSDK { /** * Initializes and sets up the Selldone Storefront SDK. * It configures essential SDK parameters, either by taking them from provided arguments or by * fetching them from meta tags. Additionally, it logs the SDK version to the console and * handles different environments, specifically the back office. * * @param _shop_name Optional shop name. If not provided, the function attempts to retrieve the * shop name from a meta tag with the attribute name "shop-name". * * @throws Will throw an error if the shop name is not provided and is also not available * in the meta tag when not in the backoffice environment. * * @returns void * * @constructor * * @example * // Usage in the backoffice environment * StorefrontSDK.Setup("exampleShop"); * * // Typical usage without providing shop name (relies on meta tag) * StorefrontSDK.Setup(); */ static Setup(_shop_name?: string, options?: { cookie_key_access_token?: string; }): void; static CheckDependencies(): void; }