@eldrajs/sdk 0.2.1 → 0.2.2
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/CHANGELOG.md +4 -0
- package/README.md +7 -0
- package/dist/{client-BREAy8rQ.js → client-CfkktZmj.js} +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{types-Bq1jUVcz.d.ts → types-CPUs_QPj.d.ts} +2 -0
- package/dist/vite.d.ts +3 -1
- package/dist/vite.js +5 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,10 @@ platform repository.
|
|
|
9
9
|
|
|
10
10
|
## Unreleased
|
|
11
11
|
|
|
12
|
+
- Restore `previewToken` on the SDK client and Vite generator after the move from
|
|
13
|
+
`vue-ui-components`. Accepts a string or callback and sends `X-Preview-Token`; the generator
|
|
14
|
+
forwards it to both type endpoints without embedding it in generated files.
|
|
15
|
+
|
|
12
16
|
- The Vite plugin writes `.eldra/web-studio/` beside the nearest `package.json` instead of Vite's
|
|
13
17
|
root; on Nuxt 4 the root is `app/`, and the folder landed there. A relative `outDir` is resolved
|
|
14
18
|
the same way.
|
package/README.md
CHANGED
|
@@ -35,6 +35,13 @@ call site.
|
|
|
35
35
|
|
|
36
36
|
The full walkthrough is [docs/getting-started.md](../../docs/getting-started.md).
|
|
37
37
|
|
|
38
|
+
## Preview mode
|
|
39
|
+
|
|
40
|
+
Both `createEldraClient` and the Vite plugin accept `previewToken` as a string or callback and send
|
|
41
|
+
it as `X-Preview-Token`. Configure each separately; the generator never embeds the token in its
|
|
42
|
+
output. See [preview mode](../../docs/getting-started.md#preview-mode) for examples and header
|
|
43
|
+
precedence.
|
|
44
|
+
|
|
38
45
|
## What is in the client
|
|
39
46
|
|
|
40
47
|
| Group | Methods |
|
|
@@ -254,6 +254,8 @@ function createHttpRequest(clientOptions, requestOptions) {
|
|
|
254
254
|
const headers = mergeHeaders(resolveRuntimeValue(clientOptions.headers), requestOptions.headers);
|
|
255
255
|
const orgId = requestOptions.orgId ?? resolveOrgId(clientOptions);
|
|
256
256
|
if (orgId) headers.set("X-Org-Id", orgId);
|
|
257
|
+
const previewToken = resolveRuntimeValue(clientOptions.previewToken);
|
|
258
|
+
if (previewToken) headers.set("X-Preview-Token", previewToken);
|
|
257
259
|
let body;
|
|
258
260
|
if (requestOptions.body !== void 0) {
|
|
259
261
|
headers.set("Content-Type", headers.get("Content-Type") ?? "application/json");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as EldraProductVariant, A as EldraFeature, B as EldraOrdersClient, C as EldraCmsResolveEntryListResponse, D as EldraCollectionListOptions, E as EldraCollectionList, F as EldraInventoryClient, G as EldraPaginated, H as EldraOrganizationFeature, I as EldraLocaleOptions, J as EldraProductListItem, K as EldraProductDetails, L as EldraOrder, M as EldraFeatureClient, N as EldraHttpClient, O as EldraCollectionProductsOptions, P as EldraHttpRequest, Q as EldraProductThumbnail, R as EldraOrderLine, S as EldraCmsResolveEntryListOptions, T as EldraCollection, U as EldraOrganizationOptions, V as EldraOrganizationDetails, W as EldraPageMeta, X as EldraProductOption, Y as EldraProductMediaLink, Z as EldraProductOptionValue, _ as EldraCmsEntryListEntry, _t as EldraContractProp, a as EldraCartTotals, at as EldraSearchResponse, b as EldraCmsGetOptions, c as EldraCatalogListProductsOptions, ct as EldraStockAvailabilityItem, d as EldraCheckoutHandoffOptions, dt as EldraContract, et as EldraRecoveredBasket, f as EldraClient, ft as EldraContractBody, g as EldraCmsEntryListDisplayMode, gt as EldraContractPaths, h as EldraCmsEntryList, ht as EldraContractPath, i as EldraCartItem, it as EldraSearchOptions, j as EldraFeatureCapabilities, k as EldraDiscountResult, l as EldraCategory, lt as RuntimeEnv, m as EldraCmsClient, mt as EldraContractMethod, n as EldraCart, nt as EldraRequestContext, o as EldraCatalogClient, ot as EldraStockAvailability, p as EldraClientOptions, pt as EldraContractItem, q as EldraProductList, r as EldraCartClient, rt as EldraRequestOptions, s as EldraCatalogGetProductOptions, st as EldraStockAvailabilityInput, t as EldraAddCartItemInput, tt as EldraRecoveredBasketItem, u as EldraCheckoutClient, ut as RuntimeValue, v as EldraCmsEntryListFilterCriterion, vt as EldraContractQuery, w as EldraCmsResolvedEntryList, x as EldraCmsListOptions, y as EldraCmsGetEntryByUniqueFieldOptions, yt as EldraContractResponse, z as EldraOrderReadOptions } from "./types-
|
|
1
|
+
import { $ as EldraProductVariant, A as EldraFeature, B as EldraOrdersClient, C as EldraCmsResolveEntryListResponse, D as EldraCollectionListOptions, E as EldraCollectionList, F as EldraInventoryClient, G as EldraPaginated, H as EldraOrganizationFeature, I as EldraLocaleOptions, J as EldraProductListItem, K as EldraProductDetails, L as EldraOrder, M as EldraFeatureClient, N as EldraHttpClient, O as EldraCollectionProductsOptions, P as EldraHttpRequest, Q as EldraProductThumbnail, R as EldraOrderLine, S as EldraCmsResolveEntryListOptions, T as EldraCollection, U as EldraOrganizationOptions, V as EldraOrganizationDetails, W as EldraPageMeta, X as EldraProductOption, Y as EldraProductMediaLink, Z as EldraProductOptionValue, _ as EldraCmsEntryListEntry, _t as EldraContractProp, a as EldraCartTotals, at as EldraSearchResponse, b as EldraCmsGetOptions, c as EldraCatalogListProductsOptions, ct as EldraStockAvailabilityItem, d as EldraCheckoutHandoffOptions, dt as EldraContract, et as EldraRecoveredBasket, f as EldraClient, ft as EldraContractBody, g as EldraCmsEntryListDisplayMode, gt as EldraContractPaths, h as EldraCmsEntryList, ht as EldraContractPath, i as EldraCartItem, it as EldraSearchOptions, j as EldraFeatureCapabilities, k as EldraDiscountResult, l as EldraCategory, lt as RuntimeEnv, m as EldraCmsClient, mt as EldraContractMethod, n as EldraCart, nt as EldraRequestContext, o as EldraCatalogClient, ot as EldraStockAvailability, p as EldraClientOptions, pt as EldraContractItem, q as EldraProductList, r as EldraCartClient, rt as EldraRequestOptions, s as EldraCatalogGetProductOptions, st as EldraStockAvailabilityInput, t as EldraAddCartItemInput, tt as EldraRecoveredBasketItem, u as EldraCheckoutClient, ut as RuntimeValue, v as EldraCmsEntryListFilterCriterion, vt as EldraContractQuery, w as EldraCmsResolvedEntryList, x as EldraCmsListOptions, y as EldraCmsGetEntryByUniqueFieldOptions, yt as EldraContractResponse, z as EldraOrderReadOptions } from "./types-CPUs_QPj.js";
|
|
2
2
|
//#region src/client.d.ts
|
|
3
3
|
export declare const DEFAULT_ELDRA_API_BASE_URL = "https://web.eldra.app/api";
|
|
4
4
|
export declare class EldraHttpError extends Error {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as initEldraClient, i as getEldraClient, n as EldraHttpError, r as createEldraClient, t as DEFAULT_ELDRA_API_BASE_URL } from "./client-
|
|
1
|
+
import { a as initEldraClient, i as getEldraClient, n as EldraHttpError, r as createEldraClient, t as DEFAULT_ELDRA_API_BASE_URL } from "./client-CfkktZmj.js";
|
|
2
2
|
//#region src/storage.ts
|
|
3
3
|
const DEFAULT_CART_KEY = "eldra.cartId";
|
|
4
4
|
const DEFAULT_ORDER_TOKEN_PREFIX = "eldra.orderAccessToken.";
|
|
@@ -57,6 +57,8 @@ type EldraHttpClient = <T = unknown>(request: EldraHttpRequest) => Promise<T>;
|
|
|
57
57
|
interface EldraClientOptions {
|
|
58
58
|
apiBaseUrl?: RuntimeValue<string>;
|
|
59
59
|
orgId?: RuntimeValue<string>;
|
|
60
|
+
/** Sends X-Preview-Token on requests, overriding the same header in headers/context. */
|
|
61
|
+
previewToken?: RuntimeValue<string>;
|
|
60
62
|
env?: RuntimeValue<RuntimeEnv>;
|
|
61
63
|
headers?: RuntimeValue<HeadersInit>;
|
|
62
64
|
httpClient?: EldraHttpClient;
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { lt as RuntimeEnv, ut as RuntimeValue } from "./types-
|
|
1
|
+
import { lt as RuntimeEnv, ut as RuntimeValue } from "./types-CPUs_QPj.js";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
//#region src/vite-plugin.d.ts
|
|
4
4
|
export interface EldraVitePluginOptions {
|
|
5
5
|
apiBaseUrl?: RuntimeValue<string>;
|
|
6
6
|
orgId?: RuntimeValue<string>;
|
|
7
|
+
/** Sends X-Preview-Token when fetching types/contracts; never embedded in generated files. */
|
|
8
|
+
previewToken?: RuntimeValue<string>;
|
|
7
9
|
env?: RuntimeValue<RuntimeEnv>;
|
|
8
10
|
headers?: RuntimeValue<HeadersInit>;
|
|
9
11
|
schemas?: string[];
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./client-
|
|
1
|
+
import "./client-CfkktZmj.js";
|
|
2
2
|
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import { dirname, resolve } from "node:path";
|
|
4
4
|
import openapiTS, { astToString } from "openapi-typescript";
|
|
@@ -65,9 +65,12 @@ async function generateEldraFiles(root, options, mode = process.env.NODE_ENV ??
|
|
|
65
65
|
const contractFileName = options.contractFileName ?? defaultContractFileName;
|
|
66
66
|
const clientFileName = options.clientFileName ?? defaultClientFileName;
|
|
67
67
|
const indexFileName = options.indexFileName ?? defaultIndexFileName;
|
|
68
|
+
const headers = new Headers(resolveRuntimeValue(options.headers));
|
|
69
|
+
const previewToken = resolveRuntimeValue(options.previewToken);
|
|
70
|
+
if (previewToken) headers.set("X-Preview-Token", previewToken);
|
|
68
71
|
const fetchOptions = {
|
|
69
72
|
fetch: options.fetch,
|
|
70
|
-
headers
|
|
73
|
+
headers
|
|
71
74
|
};
|
|
72
75
|
const result = {
|
|
73
76
|
written: [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eldrajs/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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",
|