Repository navigation
Server and APIs
The server/ and gapi/ folders connect Selldone apps to the Selldone platform. SetupService reads runtime configuration from meta tags, CDN, URLS and GAPI build media, service and API URLs, and APIAbstract is the HTTP base class, with response caching and request cancellation, that every Selldone SDK extends. Gapi is a small client for the general API. This page documents each of them and shows how to build your own client.
All configuration in Selldone front ends comes from <meta> tags written by the server (or by you). SetupService is the single place that reads them.
import { SetupService } from "@selldone/core-js";
SetupService.GetMetaValue("shop-name"); // content of <meta name="shop-name">
SetupService.GetMetaValue("custom-home", "shop"); // with a default valueGetMetaValue(name, default_val?) returns, in order: the <meta name="…"> content, then window.selldone_config[name] (useful for embedded widgets), then default_val.
| Method | Meta tag | Notes |
|---|---|---|
MainServiceUrl(language?) |
service-url |
Throws if missing. With a non-default language, returns the language subdomain (e.g. https://de.selldone.com). |
GetApiSubdomain(subdomain) |
service-url |
Same origin with a subdomain prefix. |
SelldoneIframe() |
selldone-iframe |
Throws if missing. |
GetSelldoneCDN_Images(), _Jsons(), _AR(), _Videos(), _ID(), GetSelldoneCDNTemp_Files()
|
selldone-cdn-* |
Throw if missing. |
GetStorageDirect(), GetStorageDirectHost(), GetStorageDirectThumbnails()
|
storage-redirect* |
Serve files directly from cloud storage. |
DefaultLanguageCode(), DefaultCurrency(), DefaultCountry(), GetInitialLanguage()
|
default-language, default-currency, default-country, initial-language
|
GetInitialLanguage() defaults to "en". |
GetCampaignId(), GetCampaignLinkId(), GetAffiliateId(), GetEmailId()
|
campaign_id, link_id, affiliate_id, email_id
|
Attribution sent as request headers by the Storefront SDK. |
GetReferrerMeta() |
http-referer |
Original referrer (or the landing URL with utm_source), remembered in local storage for 24 hours; same-domain referrers are ignored. |
GetTemporaryAccessKey() |
temp_access_key |
Preview access to inactive shops. |
GetLoginModes() |
login-modes |
` |
ColorThemeLight(), ColorThemeDark(), ColorThemeDeepDark(), ColorThemeInfo(), SelldoneActiveButtonColor()
|
color--theme-* |
With built-in default colors. |
MapToken(), MapStyle()
|
map-token, map-style
|
Mapbox settings. |
GetCaptchaKey(), GetGDPREnable(), ShowSelldoneCopyright()
|
captcha, gdpr, copyright-mark
|
|
Contacts(), Socials()
|
contacts, socials
|
JSON values. |
GetLayoutOperator(), GetLayoutImage(), GetLayoutVersion(), GetLayoutPackage()
|
layout-operator, layout-image, layout-version, layout-package
|
Information about the deployed Layout ("official", "test" or "dev" operator). |
PWAVersion(), ShopsDomain(), EchoServer(), EchoPort(), LocalServiceCountry(), AndroidApp(), IosApp(), GetTwitterAccount()
|
various | Platform details. |
window.CDN (created by SelldoneCore.Setup()) builds media URLs. Images stored by Selldone are referenced by file name; always resolve them with these methods.
| Method | Returns |
|---|---|
GET_SHOP_IMAGE_PATH(file_name, size = null, random_fill = false) |
Image URL, optionally resized. Full URLs and relative paths are returned as is; an empty name returns a placeholder. |
GET_SHOP_JSON_PATH(file_name) |
JSON/Lottie file URL. |
GET_VIDEO_URL(file_name) |
Video URL. |
GET_SHOP_TEMP_FILE_PATH(file_name) |
Temporary file URL. |
GET_PUBLIC_FILE_PATH(file_name) |
Public storage file URL. |
GET_SHOP_3D_MODEL_PATH(shop_name, product_id, variant_id, folder_name, file_name) |
AR/3D model file URL. |
GET_USER_AVATAR(user_id, size = "small") |
User avatar ("small" or "big"). |
GET_SHOP_ICON(shop_id, size = 128), GET_CATEGORY_ICON(id, size?), GET_PRODUCT_IMAGE(id, size?), GET_DELIVERY_SERVICE_ICON(id, size?), GET_CONNECT_ICON(id)
|
Icons by ID. |
const src = window.CDN.GET_SHOP_IMAGE_PATH(product.icon, 256);
const logo = window.CDN.GET_SHOP_ICON(shop.id);When storage-redirect is true and storage-redirect-host is set, images are served straight from cloud storage instead of the image CDN.
window.URLS builds links to Selldone itself: MainServiceUrl(), AdminShopsURL(), AdminShopURL(shop_id), UserSettingURL(), StripeLandingLoginPage(), ARViewURL(shop_name, product_id, variant_id, folder_name), CommunityPostUrl(base_url, post_id), CommunityPostEmbedUrl(base_url, post_id) and ProductIframeUrl(shop, product).
window.GAPI is a URL builder for the general API at the selldone-gapi origin. Each method returns a URL; examples:
| Method | Path |
|---|---|
GET_COUNTRIES() |
/countries |
GET_GATEWAYS(), GET_AVAILABLE_GATEWAYS(currency)
|
/gateways, /gateways/{currency}
|
GET_TAXES(country_code) |
/taxes/{country_code} |
GET_TERMS(), GET_PRIVACY()
|
/terms, /privacy
|
GET_OFFICIAL_PAGE(language, page) |
/official-pages/{language}/{page} |
GET_PRICING(currency), GET_APP_STORE_APPS(), GET_APP_INFO(app_code), GET_PAGE_BUILDER_TEMPLATES(), GET_BLOGS(), GET_HELPS(), GET_FAQS(), … |
Platform content. |
window.$selldone.gapi is a Gapi instance (an APIAbstract subclass) with ready-made requests:
window.$selldone.gapi
.optimize(3600)
.fetchCountries()
.cache((countries) => render(countries))
.then((countries) => render(countries)); // [{ name, alpha2, alpha3, numeric, currency: string[] }]APIAbstract (server/APIAbstract.ts) is the base class of every Selldone SDK namespace (window.$storefront.products, window.$backoffice.product, …) and of Gapi.
constructor(config?: { axiosInstance: AxiosInstance; debounceTime?: number })Without a config it uses window.axios (set up by SelldoneCore.Setup() or an SDK) and a 1000 ms debounce time.
| Method | Effect |
|---|---|
optimize(duration = 60) |
Reuse a stored GET response newer than duration seconds instead of calling the server. Stays active on the instance until force(). |
force() |
Disable optimize so the next request always hits the server. |
cancellation(has_cancellation = true) |
Cancel an in-flight GET to the same URL when a new one starts. Canceled requests reject with undefined. |
GET requests return an IExtendedPromiseWithCache<T> that supports .cache(callback):
- Call it before
.then(). If a stored response exists,callbackreceives it immediately. - It also marks the request so its fresh response is stored. Only requests chained with
.cache()are stored, sooptimize()has an effect only together with.cache(). - For detail requests, the SDK can pass a "deep cache" finder that searches stored list responses (for example, a product inside a cached product list).
The store is an in-memory LRU cache of 100 responses, keyed by an MD5 hash of the URL and the non-empty query parameters. CleanCache() clears it.
| Method | Description |
|---|---|
getNow<T>(url, query?, deep_cache_finder?) |
GET with cache and cancellation support. |
postNow<T>(url, params, { query? }?) |
POST; FormData bodies are sent as multipart/form-data. |
putNow<T>(url, params?, { query?, accept_error_response? }?) |
PUT; with accept_error_response: true, responses with error resolve instead of rejecting. |
deleteNow<T>(url, query?) |
DELETE. |
getDebounce(url, params, onSuccess, onError?, { max_valid_status_code?, debounce_time? }?) |
Debounced GET with callbacks. |
When a response body contains an error field, the promise rejects with it (IErrorResponse: { error, error_msg, code? }); network failures reject with an Axios error.
Follow the same pattern as Gapi and the SDKs: a class that extends APIAbstract and exposes request methods.
import { APIAbstract } from "@selldone/core-js";
export class TaxApi extends APIAbstract {
fetchTaxes(country_code: string) {
return this.getNow<any>(window.GAPI.GET_TAXES(country_code));
}
}
export const taxApi = new TaxApi();taxApi
.cancellation()
.optimize(600)
.fetchTaxes("DE")
.cache(showTaxes)
.then(showTaxes)
.catch((e) => e !== undefined && console.error(e));APIAbstract.CleanedQuery(query) (static) removes null, undefined and empty-string values from a query object.
-
Getting Started: the meta tags
SelldoneCore.Setup()needs. - Storefront SDK: Products → Caching
- Backoffice SDK wiki
- Helpers and Utilities