@eldrajs/sdk 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{client-DEKwEhpg.js → client-DVn7qqKo.js} +1 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +21 -2
- package/dist/vite.js +1 -1
- package/package.json +1 -1
|
@@ -344,4 +344,4 @@ function isRawBody(body) {
|
|
|
344
344
|
return typeof body === "string" || typeof FormData !== "undefined" && body instanceof FormData || typeof URLSearchParams !== "undefined" && body instanceof URLSearchParams || typeof Blob !== "undefined" && body instanceof Blob || body instanceof ArrayBuffer;
|
|
345
345
|
}
|
|
346
346
|
//#endregion
|
|
347
|
-
export { getEldraClient as a, createEldraClient as i, DEFAULT_ELDRA_CHECKOUT_URL as n, initEldraClient as o, EldraHttpError as r, DEFAULT_ELDRA_API_BASE_URL as t };
|
|
347
|
+
export { getEldraClient as a, resolveOrgId as c, createEldraClient as i, DEFAULT_ELDRA_CHECKOUT_URL as n, initEldraClient as o, EldraHttpError as r, resolveApiBaseUrl as s, DEFAULT_ELDRA_API_BASE_URL as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -47,4 +47,24 @@ export declare function createCartSession(options?: EldraCartSessionOptions): El
|
|
|
47
47
|
*/
|
|
48
48
|
export declare function createOrderAccessTokens(options?: EldraOrderAccessTokenOptions): EldraOrderAccessTokens;
|
|
49
49
|
//#endregion
|
|
50
|
-
|
|
50
|
+
//#region src/tracker.d.ts
|
|
51
|
+
interface EldraTrackerScriptOptions extends Pick<EldraClientOptions, 'apiBaseUrl' | 'orgId' | 'env'> {
|
|
52
|
+
/** Origin that receives events when the script is served through a first-party proxy. */
|
|
53
|
+
eventOrigin?: string;
|
|
54
|
+
}
|
|
55
|
+
/** Attributes of the `<script>` tag that loads the Eldra analytics tracker. */
|
|
56
|
+
interface EldraTrackerScript {
|
|
57
|
+
src: string;
|
|
58
|
+
defer: true;
|
|
59
|
+
crossorigin: 'anonymous';
|
|
60
|
+
'data-org': string;
|
|
61
|
+
'data-api'?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Builds the tracker `<script>` attributes from the same configuration the client uses, so the
|
|
65
|
+
* tracker always reports to the gateway the site reads from. Returns `undefined` when no
|
|
66
|
+
* organisation id is configured, which is the case in builds that should not report at all.
|
|
67
|
+
*/
|
|
68
|
+
export declare function analyticsTrackerScript(options?: EldraTrackerScriptOptions): EldraTrackerScript | undefined;
|
|
69
|
+
//#endregion
|
|
70
|
+
export type { EldraAddCartItemInput, EldraCart, EldraCartClient, EldraCartItem, EldraCartSession, EldraCartSessionOptions, EldraCartTotals, EldraCatalogClient, EldraCatalogGetProductOptions, EldraCatalogListProductsOptions, EldraCategory, EldraCheckoutClient, EldraCheckoutHandoffOptions, EldraClient, EldraClientOptions, EldraCmsClient, EldraCmsEntryList, EldraCmsEntryListDisplayMode, EldraCmsEntryListEntry, EldraCmsEntryListFilterCriterion, EldraCmsGetEntryByUniqueFieldOptions, EldraCmsGetOptions, EldraCmsListOptions, EldraCmsResolveEntryListOptions, EldraCmsResolveEntryListResponse, EldraCmsResolvedEntryList, EldraCollection, EldraCollectionList, EldraCollectionListOptions, EldraCollectionProductsOptions, EldraContract, EldraContractBody, EldraContractItem, EldraContractMethod, EldraContractPath, EldraContractPaths, EldraContractProp, EldraContractQuery, EldraContractResponse, EldraDiscountResult, EldraFeature, EldraFeatureCapabilities, EldraFeatureClient, EldraHttpClient, EldraHttpRequest, EldraInventoryClient, EldraKeyValueStorage, EldraLocaleOptions, EldraOrder, EldraOrderAccessTokenOptions, EldraOrderAccessTokens, EldraOrderLine, EldraOrderReadOptions, EldraOrdersClient, EldraOrganizationDetails, EldraOrganizationFeature, EldraOrganizationOptions, EldraPageMeta, EldraPaginated, EldraProductDetails, EldraProductList, EldraProductListItem, EldraProductMediaLink, EldraProductOption, EldraProductOptionValue, EldraProductThumbnail, EldraProductVariant, EldraRecoveredBasket, EldraRecoveredBasketItem, EldraRequestContext, EldraRequestOptions, EldraSearchOptions, EldraSearchResponse, EldraStockAvailability, EldraStockAvailabilityInput, EldraStockAvailabilityItem, EldraTrackerScript, EldraTrackerScriptOptions, RuntimeEnv, RuntimeValue };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getEldraClient, i as createEldraClient, n as DEFAULT_ELDRA_CHECKOUT_URL, o as initEldraClient, r as EldraHttpError, t as DEFAULT_ELDRA_API_BASE_URL } from "./client-
|
|
1
|
+
import { a as getEldraClient, c as resolveOrgId, i as createEldraClient, n as DEFAULT_ELDRA_CHECKOUT_URL, o as initEldraClient, r as EldraHttpError, s as resolveApiBaseUrl, t as DEFAULT_ELDRA_API_BASE_URL } from "./client-DVn7qqKo.js";
|
|
2
2
|
//#region src/storage.ts
|
|
3
3
|
const DEFAULT_CART_KEY = "eldra.cartId";
|
|
4
4
|
const DEFAULT_ORDER_TOKEN_PREFIX = "eldra.orderAccessToken.";
|
|
@@ -47,4 +47,23 @@ function createOrderAccessTokens(options = {}) {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
//#endregion
|
|
50
|
-
|
|
50
|
+
//#region src/tracker.ts
|
|
51
|
+
/**
|
|
52
|
+
* Builds the tracker `<script>` attributes from the same configuration the client uses, so the
|
|
53
|
+
* tracker always reports to the gateway the site reads from. Returns `undefined` when no
|
|
54
|
+
* organisation id is configured, which is the case in builds that should not report at all.
|
|
55
|
+
*/
|
|
56
|
+
function analyticsTrackerScript(options = {}) {
|
|
57
|
+
const orgId = resolveOrgId(options);
|
|
58
|
+
if (!orgId) return;
|
|
59
|
+
const script = {
|
|
60
|
+
src: `${new URL(resolveApiBaseUrl(options)).origin}/js/script.js`,
|
|
61
|
+
defer: true,
|
|
62
|
+
crossorigin: "anonymous",
|
|
63
|
+
"data-org": orgId
|
|
64
|
+
};
|
|
65
|
+
if (options.eventOrigin) script["data-api"] = options.eventOrigin;
|
|
66
|
+
return script;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { DEFAULT_ELDRA_API_BASE_URL, DEFAULT_ELDRA_CHECKOUT_URL, EldraHttpError, analyticsTrackerScript, createCartSession, createEldraClient, createOrderAccessTokens, getEldraClient, initEldraClient };
|
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eldrajs/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Framework-free client for the Eldra Web Studio public storefront API: CMS, catalog, cart, checkout handoff, orders, inventory. Types generated from your gateway's OpenAPI document and CMS schemas at build time.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|