@eldrajs/sdk 0.5.0 → 0.5.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 CHANGED
@@ -9,6 +9,10 @@ platform repository.
9
9
 
10
10
  ## Unreleased
11
11
 
12
+ - **A 3840 px image variant, `uhd`.** A full-width image on a high-density screen wants about 3840 px, and
13
+ `full` stops at 2560. `imageSrcset` now lists `…/uhd 3840w` after `full`, `imageVariantFor` falls back to
14
+ `uhd` instead of `full`, and the original is listed only when it is wider than 3840 px.
15
+ `ELDRA_IMAGE_VARIANT_WIDTHS` and `EldraImageVariant` carry it. It needs the media host that serves `uhd`.
12
16
  - **Removed: the checkout summary types.** `EldraOrderPreview`, `EldraOrderPreviewGiftCard` and
13
17
  `EldraOrderPreviewDiscountCode` are no longer exported. They typed `POST /order/v1/preview`, which the SDK
14
18
  never had a method for: delivery choice, the order summary, order creation and payment belong to the hosted
@@ -80,6 +84,74 @@ platform repository.
80
84
  `clearCampaignAttribution()`, the `EldraCampaignAttribution` type and the client option
81
85
  `campaignAttribution` (`{ storage }`, or `false` to send none). Nothing clears it automatically.
82
86
 
87
+ Business customers (B2B), for the next release after 0.4.3. Every entry below needs a gateway
88
+ serving public contract 6.15.0 (core merged main's 6.14.0 first).
89
+
90
+ - Contract 6.15.0. Business login: `shopIssuer`, `ELDRA_SHOP_CLIENT_ID`, `createPkcePair`,
91
+ `pkceChallenge`, `buildAuthorizeUrl`, `exchangeAuthorizationCode`, `refreshTokens` and
92
+ `buildLogoutUrl` (OIDC authorization code with PKCE against the shop realm, `EldraOidcError` on
93
+ failure), `bearer(accessToken)`, and `customer.me(context)` for the signed-in business customer
94
+ and their company memberships (`GET /customer/v1/me`). The token is passed
95
+ per call in `context.headers`. `EldraCustomerMe`, `EldraShopUser` and `EldraCustomerMembership`
96
+ are derived from the generated contract like every other response type. `refreshExpiresAt` is
97
+ `undefined` when the server sends no `refresh_expires_in`. See `docs/business-login.md`.
98
+ - `buildAuthorizeUrl` takes an optional `uiLocales` (a BCP 47 tag or a list, most preferred
99
+ first), sent as the OIDC `ui_locales` parameter so the shop login pages use the storefront's
100
+ language. No contract change.
101
+ - Customer prices (contract 6.15.0): catalog product, list and collection-product reads and cart
102
+ writes accept a signed-in token and `X-Customer-Id` per call in `context.headers`. Priced
103
+ variants carry `listPrice`, list items carry the customer's `minPrice` and `maxPrice`, and priced
104
+ responses have no `compareAtPrice`. `customerHeaders(accessToken, customerId?)` builds the
105
+ headers. Priced responses are `Cache-Control: private, no-store`. See `docs/customer-prices.md`.
106
+ - Customer carts (contract 6.15.0): cart and order error ids `CART_CUSTOMER_MISMATCH` (also on a
107
+ signed-in read), `CART_SIGN_IN_REQUIRED` (a guest may still remove a line),
108
+ `CART_CUSTOMER_PRICES_OFF`, `ORDER_CUSTOMER_PRICES_OFF`, `CART_DISCOUNT_NOT_FOR_CUSTOMER_PRICES`,
109
+ `CART_PRICES_UNAVAILABLE`. Every cart answer is `private, no-store`; binding drops the discount
110
+ code; list items carry `listPrice`. The docs explain tracking the binding and moving the cart.
111
+ - Customer carts (contract 6.15.0): an archived or unknown company answers 409
112
+ `CART_CUSTOMER_UNAVAILABLE` on cart writes and 409 `ORDER_CUSTOMER_UNAVAILABLE` on order create and
113
+ preview; treat them like `*_CUSTOMER_PRICES_OFF`. A bound
114
+ cart shows the prices stored when lines were added, and the order re-prices, so show the order
115
+ preview total before payment. No change to the generated contract.
116
+ - Sales orders and delivery locations (contract 6.15.0) for a signed-in business customer's active
117
+ company: `customer.locations(context)` (`GET /customer/v1/locations`, answered as the `{ data }`
118
+ envelope like every other list, the default first, `data` `[]` for none), `salesOrders.preview(input, context)`, `salesOrders.create(input, { idempotencyKey },
119
+ context)`, `salesOrders.list(options, context)` and `salesOrders.get(id, context)`. `create`
120
+ requires the idempotency key (1 to 255 printable ASCII characters, no spaces) and rejects with
121
+ `EldraIdempotencyKeyError` (a `TypeError`) without a usable one, sending nothing. Catch that class,
122
+ not every `TypeError`: a lost connection is a `TypeError` too and is retried with the key. Keep the key across
123
+ retries (a 502, a 503 or a timeout may follow a placed order, and the same key replays it) and
124
+ mint a new one when the cart or the form changes. Types derived from the contract:
125
+ `EldraCustomerLocationList`, `EldraCustomerLocation`, `EldraSalesOrderPreview`, `EldraSalesOrderPreviewLine`,
126
+ `EldraSalesOrderCredit`, `EldraSalesOrder`, `EldraSalesOrderLine`, `EldraSalesOrderWarning`,
127
+ `EldraSalesOrderDelivery`, `EldraSalesOrderStatus`, `EldraSalesOrderList`,
128
+ `EldraSalesOrderListItem`, `EldraSalesOrderListOptions`, `EldraSalesOrderPreviewInput`,
129
+ `EldraCreateSalesOrderInput`. `EldraSalesOrderCredit` carries `creditCurrency` when the company's
130
+ credit is kept in another currency than the order's. Warnings on create:
131
+ `SALES_ORDER_STOCK_NOT_SET_ASIDE`, `SALES_ORDER_PAYMENT_NOT_RECORDED` (the order stands). See
132
+ `docs/sales-orders.md`.
133
+ - Error ids are typed: `EldraHttpError.errorId` is `EldraErrorId`, the known `EldraShopErrorId` and
134
+ `EldraSalesOrderErrorId` values or any other string. New with sales orders: `CUSTOMER_BLOCKED`,
135
+ `SALES_ORDER_CREDIT_LIMIT_EXCEEDED`, `SALES_ORDER_CREDIT_CURRENCY_MISMATCH` (the supplier blocks
136
+ over-limit orders and keeps the credit in another currency; do not retry),
137
+ `SALES_ORDER_CREDIT_CHECK_UNAVAILABLE`,
138
+ `SALES_ORDER_CART_NOT_BOUND`, `SALES_ORDER_CART_EMPTY`, `SALES_ORDER_TOO_MANY_LINES`,
139
+ `SALES_ORDER_LINE_INVALID`, `SALES_ORDER_CART_ALREADY_ORDERED`, `SALES_ORDER_LOCATION_UNKNOWN`,
140
+ `SALES_ORDER_TERMS_UNAVAILABLE`, `SALES_ORDER_CART_UNAVAILABLE`,
141
+ `SALES_ORDER_IDEMPOTENCY_KEY_REQUIRED`, `SALES_ORDER_NOT_FOUND`, `SALES_ORDER_UPSTREAM_REFUSED`
142
+ (502: the supplier's order service refused the platform; never sign the person out over it), and
143
+ the reused `ORDER_CUSTOMER_UNAVAILABLE`, `ORDER_CUSTOMER_PRICES_OFF`, `ORDER_PRODUCT_UNAVAILABLE`,
144
+ `ORDER_PRICES_UNAVAILABLE`, `ORDER_IDEMPOTENCY_CONFLICT`. `EldraHttpError.errors` carries the
145
+ problem's details, such as `salesOrderId` on `SALES_ORDER_CART_ALREADY_ORDERED` and `variantId`
146
+ on `SALES_ORDER_LINE_INVALID`. `isEldraError(error, id)` narrows an unknown error to one refusal
147
+ and types its `errors` from `EldraProblemErrors` (`SALES_ORDER_CART_ALREADY_ORDERED`,
148
+ `SALES_ORDER_LINE_INVALID`, `ORDER_PRODUCT_UNAVAILABLE`, `SHIPPING_CART_NOT_EXPORTABLE`).
149
+ - New required interface members: `EldraClient.salesOrders` and `EldraCustomerClient.locations`. Code
150
+ that only calls the client is unaffected; code that implements these interfaces itself (a mock or a
151
+ wrapper) must add them.
152
+
153
+ ## 0.3.2 — 2026-10-22
154
+
83
155
  - **Images use the size the API gives them (contract 4.14.0).** `EldraImageSource` accepts the
84
156
  `width` and `height` an image object now carries (its pixels as displayed). `imageSrcset` stops at
85
157
  that width unless `originalWidth` is passed, and `responsiveImage` sets `width`/`height` to the
@@ -94,12 +166,16 @@ platform repository.
94
166
  which most browsers cannot show as uploaded. A narrower original still ends the list at its own
95
167
  width.
96
168
 
169
+ ## 0.3.1 — 2026-10-19
170
+
97
171
  - **`buildToken` client option (WS-403).** When set (a string or a function returning one), every
98
172
  request carries `X-Eldra-Build-Token`, a read-only build token (`eldra_bld_…`, created in Studio → Settings → Developers → Build tokens),
99
173
  so the gateway can give a theme build's reads their own rate-limit bucket. Server and build only;
100
174
  omitted or empty sends no header. Never pass the site deploy token. Pass it from server-side code
101
175
  only; an SSR server that sends it on every visitor request shares the organisation's build budget.
102
176
 
177
+ ## 0.3.0 — 2026-10-18
178
+
103
179
  - **`EldraFormDefinition.consentText` (WS-386, contract 4.13.0).** A form that subscribes the
104
180
  visitor now publishes the consent sentence per locale, with the shop name already filled in
105
181
  (`consentText?: EldraFormLocalized`, present only when `kinds` contains `subscribe`). Show it
@@ -123,6 +199,7 @@ platform repository.
123
199
  and unsubscribes nobody. The two methods now `POST` the same paths with the token in the query and
124
200
  still resolve `{ status }`; confirming or unsubscribing twice is a success. Needs a gateway at
125
201
  contract 4.10.0 or later (the `GET` JSON answer of 4.7.0 to 4.9.0, never released, is gone).
202
+
126
203
  - **`client.forms`: the site-forms API (WS-386).** `get(key)` reads a form definition,
127
204
  `submit(key, { values, locale, pagePath, turnstileToken?, hp? })` posts a submission and
128
205
  `confirm(token)` / `unsubscribe(token)` finish a subscriber's emailed links. A `422` resolves as
@@ -130,12 +207,18 @@ platform repository.
130
207
  `404`, `413` and `429` reject with `EldraHttpError`. New types `EldraFormDefinition`,
131
208
  `EldraFormField`, `EldraFormSubmitInput`, `EldraFormSubmitResult` and friends, hand-written like
132
209
  `EldraPlatformConfig`. Needs a gateway at contract 4.4.0 or later.
210
+
211
+ ## 0.2.9 — 2026-10-12
212
+
133
213
  - **Icelandic formatting that prints the same on every runtime: `@eldrajs/sdk/format`.**
134
214
  `numberFormat`, `formatPrice` and `comparator`/`compareIcelandic`, plus `./format/date`,
135
215
  `./format/list`, `./format/relative-time` and `./format/display-names`. Icelandic and English come
136
216
  from the package's own CLDR 48.2 data, so Chrome and Cloudflare Workers, which lack it, print what
137
217
  Node and Safari do; every other locale goes to the runtime's `Intl`. Dates are UTC. No new
138
218
  runtime dependency: the formatjs code is bundled.
219
+
220
+ ## 0.2.8 — 2026-10-10
221
+
139
222
  - **A request that answered `429` or `503` is retried instead of failing.** The gateway rate-limits a
140
223
  client by requests per minute, which a static build of a real catalogue meets routinely. The
141
224
  default `fetch` transport now repeats an **idempotent** request (`GET`/`HEAD`/`OPTIONS` — never a
@@ -153,6 +236,8 @@ platform repository.
153
236
  the same way. **This is a minor**: the behaviour is a repair, but `retry` is a new public option
154
237
  and `EldraRetryOptions` a new exported type.
155
238
 
239
+ ## 0.2.7 — 2026-10-09
240
+
156
241
  - `analyticsTrackerScript`'s documentation no longer says events always reach the gateway; with
157
242
  `eventOrigin` set they go to that first-party proxy.
158
243
 
@@ -391,9 +391,11 @@ var EldraHttpError = class extends Error {
391
391
  errorId;
392
392
  /**
393
393
  * The gateway's problem `errors` — the refusal's detail, when the body carried it as an object.
394
- * A refused discount code names what blocked it here: `errors.blockingCode` on
395
- * `CART_DISCOUNT_NOT_COMBINABLE`, `errors.limit` on `CART_DISCOUNT_CODES_LIMIT_REACHED`. Its
396
- * members depend on the `errorId`, so read each as unknown and check its type.
394
+ * For example `salesOrderId` on `SALES_ORDER_CART_ALREADY_ORDERED` or `variantId` on
395
+ * `SALES_ORDER_LINE_INVALID`; a refused discount code names what blocked it here:
396
+ * `errors.blockingCode` on `CART_DISCOUNT_NOT_COMBINABLE`, `errors.limit` on
397
+ * `CART_DISCOUNT_CODES_LIMIT_REACHED`. Its members depend on the `errorId`, so read each as
398
+ * unknown and check its type (or narrow with `isEldraError`).
397
399
  */
398
400
  errors;
399
401
  constructor(response, body) {
@@ -407,6 +409,27 @@ var EldraHttpError = class extends Error {
407
409
  this.errors = problemErrors(body);
408
410
  }
409
411
  };
412
+ /**
413
+ * Thrown by `salesOrders.create`, before anything is sent, when the idempotency key is missing or not
414
+ * 1 to 255 printable ASCII characters without spaces. A bug in the calling code: fix it, never retry.
415
+ * Catch this class, not every `TypeError`: `fetch` reports a lost connection as a `TypeError` too,
416
+ * and that one may follow a placed order, so it is retried with the same key.
417
+ */
418
+ var EldraIdempotencyKeyError = class extends TypeError {
419
+ name = "EldraIdempotencyKeyError";
420
+ };
421
+ const idempotencyKeyPattern = /^[\x21-\x7e]{1,255}$/;
422
+ function checkIdempotencyKey(key) {
423
+ if (typeof key !== "string" || !idempotencyKeyPattern.test(key)) throw new EldraIdempotencyKeyError("salesOrders.create needs an idempotency key of 1 to 255 printable ASCII characters");
424
+ return key;
425
+ }
426
+ /**
427
+ * Narrows an unknown error to an `EldraHttpError` with the given `errorId`. For an id in
428
+ * `EldraProblemErrors` its `errors` is typed (each field optional: it is as the gateway sent it).
429
+ */
430
+ function isEldraError(error, errorId) {
431
+ return error instanceof EldraHttpError && error.errorId === errorId;
432
+ }
410
433
  /** One field of an RFC 9457 problem body, when the body is an object that carries it as a string. */
411
434
  function problemString(body, key) {
412
435
  if (body && typeof body === "object" && key in body) {
@@ -532,11 +555,21 @@ function createEldraClient(options) {
532
555
  }
533
556
  },
534
557
  catalog: {
558
+ /**
559
+ * Lists products. Pass `customerHeaders(token, customerId)` as `context.headers` to get a
560
+ * signed-in business customer's prices (`listPrice` is the list price). Server-side only;
561
+ * never cache the result. See docs/customer-prices.md.
562
+ */
535
563
  listProducts: (listOptions, context) => request({
536
564
  ...context,
537
565
  path: "/catalog/v1/products/list",
538
566
  query: listOptions
539
567
  }),
568
+ /**
569
+ * Reads one product. Pass `customerHeaders(token, customerId)` as `context.headers` to get a
570
+ * signed-in business customer's prices (`listPrice` is the list price). Server-side only;
571
+ * never cache the result. See docs/customer-prices.md.
572
+ */
540
573
  getProduct: (productId, getOptions, context) => request({
541
574
  ...context,
542
575
  path: `/catalog/v1/products/${encodeURIComponent(productId)}`,
@@ -557,6 +590,11 @@ function createEldraClient(options) {
557
590
  path: `/catalog/v1/collections/${encodeURIComponent(slug)}`,
558
591
  query: localeOptions
559
592
  }),
593
+ /**
594
+ * Lists a collection's products. Pass `customerHeaders(token, customerId)` as `context.headers` to get a
595
+ * signed-in business customer's prices (`listPrice` is the list price). Server-side only;
596
+ * never cache the result. See docs/customer-prices.md.
597
+ */
560
598
  listCollectionProducts: (slug, listOptions, context) => request({
561
599
  ...context,
562
600
  path: `/catalog/v1/collections/${encodeURIComponent(slug)}/products`,
@@ -572,6 +610,7 @@ function createEldraClient(options) {
572
610
  path: `/catalog/v1/brands/${encodeURIComponent(slug)}`,
573
611
  query: localeOptions
574
612
  }),
613
+ /** Search results carry list prices, never customer prices. */
575
614
  search: (query, searchOptions, context) => request({
576
615
  ...context,
577
616
  path: "/search/v1",
@@ -582,6 +621,11 @@ function createEldraClient(options) {
582
621
  })
583
622
  },
584
623
  cart: {
624
+ /**
625
+ * Adds a line. A signed-in token in `context.headers` binds the cart to that customer and
626
+ * prices its lines for them. Errors: 409 CART_CUSTOMER_MISMATCH, CART_SIGN_IN_REQUIRED;
627
+ * 503 CART_PRICES_UNAVAILABLE. See docs/customer-prices.md.
628
+ */
585
629
  addItem: (input, context) => {
586
630
  const attribution = options.campaignAttribution === false || "attribution" in input ? null : readCampaignAttribution(options.campaignAttribution);
587
631
  return request({
@@ -594,22 +638,38 @@ function createEldraClient(options) {
594
638
  }
595
639
  });
596
640
  },
641
+ /**
642
+ * Reads a cart by id. Reads stay open for a cart bound to a customer (hosted checkout).
643
+ */
597
644
  get: (cartId, localeOptions, context) => request({
598
645
  ...context,
599
646
  path: `/shopping-cart/v1/cart/${encodeURIComponent(cartId)}`,
600
647
  query: localeOptions
601
648
  }),
649
+ /**
650
+ * Changes a line's quantity. A signed-in token in `context.headers` binds the cart to that customer and
651
+ * prices its lines for them. Errors: 409 CART_CUSTOMER_MISMATCH, CART_SIGN_IN_REQUIRED;
652
+ * 503 CART_PRICES_UNAVAILABLE. See docs/customer-prices.md.
653
+ */
602
654
  updateItem: (cartId, itemId, input, context) => request({
603
655
  ...context,
604
656
  method: "PATCH",
605
657
  path: `/shopping-cart/v1/cart/${encodeURIComponent(cartId)}/items/${encodeURIComponent(itemId)}`,
606
658
  body: input
607
659
  }),
660
+ /**
661
+ * Removes a line. A guest may remove a line from a bound cart; a signed-in token binds the
662
+ * cart to that customer. Errors: 409 CART_CUSTOMER_MISMATCH; 503 CART_PRICES_UNAVAILABLE. See docs/customer-prices.md.
663
+ */
608
664
  removeItem: (cartId, itemId, context) => request({
609
665
  ...context,
610
666
  method: "DELETE",
611
667
  path: `/shopping-cart/v1/cart/${encodeURIComponent(cartId)}/items/${encodeURIComponent(itemId)}`
612
668
  }),
669
+ /**
670
+ * Applies a discount code. On a cart bound to a customer this is 409
671
+ * CART_DISCOUNT_NOT_FOR_CUSTOMER_PRICES: codes do not combine with customer prices.
672
+ */
613
673
  applyDiscount: async (cartId, code, localeOptions, context) => {
614
674
  const trimmed = code.trim();
615
675
  const cart = await request({
@@ -624,6 +684,9 @@ function createEldraClient(options) {
624
684
  applied: cartHoldsDiscountCode(cart, trimmed)
625
685
  };
626
686
  },
687
+ /**
688
+ * Removes the discount code. A guest write to a bound cart is 409 CART_SIGN_IN_REQUIRED.
689
+ */
627
690
  removeDiscount: (cartId, localeOptions, context) => request({
628
691
  ...context,
629
692
  method: "DELETE",
@@ -723,6 +786,43 @@ function createEldraClient(options) {
723
786
  if (!checkoutUrl) throw cause === void 0 ? /* @__PURE__ */ new Error("The platform did not publish a checkout URL (GET /platform/v1/config).") : new Error(`Could not read the platform checkout URL (GET /platform/v1/config): ${describeCause(cause)}`, { cause });
724
787
  return buildCheckoutUrl(checkoutUrl, handoff, options);
725
788
  } },
789
+ customer: {
790
+ me: (context) => request({
791
+ ...context,
792
+ path: "/customer/v1/me"
793
+ }),
794
+ locations: (context) => request({
795
+ ...context,
796
+ path: "/customer/v1/locations"
797
+ })
798
+ },
799
+ salesOrders: {
800
+ preview: (input, context) => request({
801
+ ...context,
802
+ method: "POST",
803
+ path: "/sales-order/v1/preview",
804
+ body: input
805
+ }),
806
+ create: async (input, createOptions, context) => {
807
+ const idempotencyKey = checkIdempotencyKey(createOptions?.idempotencyKey);
808
+ return request({
809
+ ...context,
810
+ method: "POST",
811
+ path: "/sales-order/v1",
812
+ headers: mergeHeaders(context?.headers, { "Idempotency-Key": idempotencyKey }),
813
+ body: input
814
+ });
815
+ },
816
+ list: (listOptions, context) => request({
817
+ ...context,
818
+ path: "/sales-order/v1",
819
+ query: listOptions
820
+ }),
821
+ get: (salesOrderId, context) => request({
822
+ ...context,
823
+ path: `/sales-order/v1/${encodeURIComponent(salesOrderId)}`
824
+ })
825
+ },
726
826
  inventory: { availability: (items, context) => request({
727
827
  ...context,
728
828
  method: "POST",
@@ -985,4 +1085,4 @@ function appendQueryValue(searchParams, key, value) {
985
1085
  function isRawBody(body) {
986
1086
  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;
987
1087
  }
988
- export { initEldraClient as a, captureCampaignAttribution as c, readCampaignAttribution as d, withdrawCampaignAttributionConsent as f, getEldraClient as i, clearCampaignAttribution as l, createOrderAccessTokens as m, EldraHttpError as n, resolveApiBaseUrl as o, createCartSession as p, createEldraClient as r, resolveOrgId as s, DEFAULT_ELDRA_API_BASE_URL as t, grantCampaignAttributionConsent as u };
1088
+ export { getEldraClient as a, resolveApiBaseUrl as c, clearCampaignAttribution as d, grantCampaignAttributionConsent as f, createOrderAccessTokens as g, createCartSession as h, createEldraClient as i, resolveOrgId as l, withdrawCampaignAttributionConsent as m, EldraHttpError as n, initEldraClient as o, readCampaignAttribution as p, EldraIdempotencyKeyError as r, isEldraError as s, DEFAULT_ELDRA_API_BASE_URL as t, captureCampaignAttribution as u };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as EldraOrderDiscountCode, $t as EldraOrderAccessTokenOptions, A as EldraCollection, At as EldraStockAvailabilityInput, B as EldraFormField, Bt as EldraContractProp, C as EldraCmsEntryListFilterCriterion, Ct as EldraRecoveredBasketItem, D as EldraCmsResolveEntryListOptions, Dt as EldraSearchOptions, E as EldraCmsListOptions, Et as EldraRetryOptions, F as EldraFeature, Ft as EldraContractBody, G as EldraFormSubmitResult, Gt as captureCampaignAttribution, H as EldraFormFieldType, Ht as EldraContractResponse, I as EldraFeatureCapabilities, It as EldraContractItem, J as EldraHttpClient, Jt as readCampaignAttribution, K as EldraFormTokenResult, Kt as clearCampaignAttribution, L as EldraFeatureClient, Lt as EldraContractMethod, M as EldraCollectionListOptions, Mt as RuntimeEnv, N as EldraCollectionProductsOptions, Nt as RuntimeValue, O as EldraCmsResolveEntryListResponse, Ot as EldraSearchResponse, P as EldraDiscountResult, Pt as EldraContract, Q as EldraOrder, Qt as EldraKeyValueStorage, R as EldraFormActionKind, Rt as EldraContractPath, S as EldraCmsEntryListEntry, St as EldraRecoveredBasket, T as EldraCmsGetOptions, Tt as EldraRequestOptions, U as EldraFormLocalized, Ut as EldraCampaignAttribution, V as EldraFormFieldOption, Vt as EldraContractQuery, W as EldraFormSubmitInput, Wt as EldraCampaignAttributionOptions, X as EldraInventoryClient, Xt as EldraCartSession, Y as EldraHttpRequest, Yt as withdrawCampaignAttributionConsent, Z as EldraLocaleOptions, Zt as EldraCartSessionOptions, _ as EldraClient, _t as EldraProductMediaLink, a as EldraCartClient, at as EldraOrganizationFeature, b as EldraCmsEntryList, bt as EldraProductThumbnail, c as EldraCartGiftCardEntry, ct as EldraPageMeta, d as EldraCatalogClient, dt as EldraPlatformConfig, en as EldraOrderAccessTokens, et as EldraOrderLine, f as EldraCatalogGetProductOptions, ft as EldraPlatformReadOptions, g as EldraCheckoutUrlOptions, gt as EldraProductListItem, h as EldraCheckoutClient, ht as EldraProductList, i as EldraCartAppliedCode, it as EldraOrganizationDetails, j as EldraCollectionList, jt as EldraStockAvailabilityItem, k as EldraCmsResolvedEntryList, kt as EldraStockAvailability, l as EldraCartItem, lt as EldraPaginated, m as EldraCategory, mt as EldraProductExtensions, n as EldraBrand, nn as createOrderAccessTokens, nt as EldraOrdersClient, o as EldraCartDiscountCodeEntry, ot as EldraOrganizationLocales, p as EldraCatalogListProductsOptions, pt as EldraProductDetails, q as EldraFormsClient, qt as grantCampaignAttributionConsent, r as EldraCart, rt as EldraOrganizationCommerce, s as EldraCartGiftCard, st as EldraOrganizationOptions, t as EldraAddCartItemInput, tn as createCartSession, tt as EldraOrderReadOptions, u as EldraCartTotals, ut as EldraPlatformClient, v as EldraClientOptions, vt as EldraProductOption, w as EldraCmsGetEntryByUniqueFieldOptions, wt as EldraRequestContext, x as EldraCmsEntryListDisplayMode, xt as EldraProductVariant, y as EldraCmsClient, yt as EldraProductOptionValue, z as EldraFormDefinition, zt as EldraContractPaths } from "./types-r819aFGS.js";
1
+ import { $ as EldraFormSubmitResult, $t as EldraShopUser, A as EldraCollection, At as EldraProductVariant, B as EldraCustomerMembership, Bt as EldraSalesOrderLine, C as EldraCmsEntryListFilterCriterion, Cn as EldraKeyValueStorage, Ct as EldraProductExtensions, D as EldraCmsResolveEntryListOptions, Dn as createOrderAccessTokens, Dt as EldraProductOption, E as EldraCmsListOptions, En as createCartSession, Et as EldraProductMediaLink, F as EldraCreateSalesOrderOptions, Ft as EldraRetryOptions, G as EldraFeatureClient, Gt as EldraSalesOrderPreviewInput, H as EldraErrorId, Ht as EldraSalesOrderListItem, I as EldraCustomerClient, It as EldraSalesOrder, J as EldraFormField, Jt as EldraSalesOrderWarning, K as EldraFormActionKind, Kt as EldraSalesOrderPreviewLine, L as EldraCustomerLocation, Lt as EldraSalesOrderCredit, M as EldraCollectionListOptions, Mt as EldraRecoveredBasketItem, N as EldraCollectionProductsOptions, Nt as EldraRequestContext, O as EldraCmsResolveEntryListResponse, Ot as EldraProductOptionValue, P as EldraCreateSalesOrderInput, Pt as EldraRequestOptions, Q as EldraFormSubmitInput, Qt as EldraShopErrorId, R as EldraCustomerLocationList, Rt as EldraSalesOrderDelivery, S as EldraCmsEntryListEntry, Sn as EldraCartSessionOptions, St as EldraProductDetails, T as EldraCmsGetOptions, Tn as EldraOrderAccessTokens, Tt as EldraProductListItem, U as EldraFeature, Ut as EldraSalesOrderListOptions, V as EldraDiscountResult, Vt as EldraSalesOrderList, W as EldraFeatureCapabilities, Wt as EldraSalesOrderPreview, X as EldraFormFieldType, Xt as EldraSearchOptions, Y as EldraFormFieldOption, Yt as EldraSalesOrdersClient, Z as EldraFormLocalized, Zt as EldraSearchResponse, _ as EldraClient, _n as clearCampaignAttribution, _t as EldraPaginated, a as EldraCartClient, an as EldraContract, at as EldraLocaleOptions, b as EldraCmsEntryList, bn as withdrawCampaignAttributionConsent, bt as EldraPlatformReadOptions, c as EldraCartGiftCardEntry, cn as EldraContractMethod, ct as EldraOrderLine, d as EldraCatalogClient, dn as EldraContractProp, dt as EldraOrganizationCommerce, en as EldraStockAvailability, et as EldraFormTokenResult, f as EldraCatalogGetProductOptions, fn as EldraContractQuery, ft as EldraOrganizationDetails, g as EldraCheckoutUrlOptions, gn as captureCampaignAttribution, gt as EldraPageMeta, h as EldraCheckoutClient, hn as EldraCampaignAttributionOptions, ht as EldraOrganizationOptions, i as EldraCartAppliedCode, in as RuntimeValue, it as EldraInventoryClient, j as EldraCollectionList, jt as EldraRecoveredBasket, k as EldraCmsResolvedEntryList, kt as EldraProductThumbnail, l as EldraCartItem, ln as EldraContractPath, lt as EldraOrderReadOptions, m as EldraCategory, mn as EldraCampaignAttribution, mt as EldraOrganizationLocales, n as EldraBrand, nn as EldraStockAvailabilityItem, nt as EldraHttpClient, o as EldraCartDiscountCodeEntry, on as EldraContractBody, ot as EldraOrder, p as EldraCatalogListProductsOptions, pn as EldraContractResponse, pt as EldraOrganizationFeature, q as EldraFormDefinition, qt as EldraSalesOrderStatus, r as EldraCart, rn as RuntimeEnv, rt as EldraHttpRequest, s as EldraCartGiftCard, sn as EldraContractItem, st as EldraOrderDiscountCode, t as EldraAddCartItemInput, tn as EldraStockAvailabilityInput, tt as EldraFormsClient, u as EldraCartTotals, un as EldraContractPaths, ut as EldraOrdersClient, v as EldraClientOptions, vn as grantCampaignAttributionConsent, vt as EldraPlatformClient, w as EldraCmsGetEntryByUniqueFieldOptions, wn as EldraOrderAccessTokenOptions, wt as EldraProductList, x as EldraCmsEntryListDisplayMode, xn as EldraCartSession, xt as EldraProblemErrors, y as EldraCmsClient, yn as readCampaignAttribution, yt as EldraPlatformConfig, z as EldraCustomerMe, zt as EldraSalesOrderErrorId } from "./types-BrQEYrD5.js";
2
2
  export declare const DEFAULT_ELDRA_API_BASE_URL = "https://web.eldra.app/api";
3
3
  export declare class EldraHttpError extends Error {
4
4
  readonly status: number;
@@ -14,19 +14,130 @@ export declare class EldraHttpError extends Error {
14
14
  * telling it apart from any other conflict is what lets a storefront say "out of stock" rather
15
15
  * than "something went wrong".
16
16
  */
17
- readonly errorId: string | undefined;
17
+ readonly errorId: EldraErrorId | undefined;
18
18
  /**
19
19
  * The gateway's problem `errors` — the refusal's detail, when the body carried it as an object.
20
- * A refused discount code names what blocked it here: `errors.blockingCode` on
21
- * `CART_DISCOUNT_NOT_COMBINABLE`, `errors.limit` on `CART_DISCOUNT_CODES_LIMIT_REACHED`. Its
22
- * members depend on the `errorId`, so read each as unknown and check its type.
20
+ * For example `salesOrderId` on `SALES_ORDER_CART_ALREADY_ORDERED` or `variantId` on
21
+ * `SALES_ORDER_LINE_INVALID`; a refused discount code names what blocked it here:
22
+ * `errors.blockingCode` on `CART_DISCOUNT_NOT_COMBINABLE`, `errors.limit` on
23
+ * `CART_DISCOUNT_CODES_LIMIT_REACHED`. Its members depend on the `errorId`, so read each as
24
+ * unknown and check its type (or narrow with `isEldraError`).
23
25
  */
24
26
  readonly errors: Readonly<Record<string, unknown>> | undefined;
25
27
  constructor(response: Response, body: unknown);
26
28
  }
29
+ /**
30
+ * Thrown by `salesOrders.create`, before anything is sent, when the idempotency key is missing or not
31
+ * 1 to 255 printable ASCII characters without spaces. A bug in the calling code: fix it, never retry.
32
+ * Catch this class, not every `TypeError`: `fetch` reports a lost connection as a `TypeError` too,
33
+ * and that one may follow a placed order, so it is retried with the same key.
34
+ */
35
+ export declare class EldraIdempotencyKeyError extends TypeError {
36
+ name: string;
37
+ }
38
+ /** An `EldraHttpError` whose `errorId` is `Id`, with that refusal's `errors` typed. */
39
+ type EldraHttpErrorWith<Id extends EldraErrorId> = EldraHttpError & {
40
+ readonly errorId: Id;
41
+ readonly errors: (Id extends keyof EldraProblemErrors ? Readonly<Partial<EldraProblemErrors[Id]>> : Readonly<Record<string, unknown>>) | undefined;
42
+ };
43
+ /**
44
+ * Narrows an unknown error to an `EldraHttpError` with the given `errorId`. For an id in
45
+ * `EldraProblemErrors` its `errors` is typed (each field optional: it is as the gateway sent it).
46
+ */
47
+ export declare function isEldraError<Id extends EldraErrorId>(error: unknown, errorId: Id): error is EldraHttpErrorWith<Id>;
27
48
  export declare function initEldraClient(options: EldraClientOptions): EldraClient;
28
49
  export declare function getEldraClient(): EldraClient;
29
50
  export declare function createEldraClient(options: EldraClientOptions): EldraClient;
51
+ /**
52
+ * OpenID Connect helpers for business-customer login. Framework-free and free of Node-only APIs:
53
+ * URL builders, PKCE through WebCrypto, and the two token-endpoint calls over `fetch`.
54
+ *
55
+ * The token endpoint calls take the storefront client's secret. Make them on a server only; see
56
+ * `docs/business-login.md`.
57
+ */
58
+ interface EldraOidcTokens {
59
+ accessToken: string;
60
+ refreshToken: string;
61
+ idToken: string;
62
+ /** Epoch milliseconds when the access token expires. */
63
+ expiresAt: number;
64
+ /** Epoch milliseconds when the refresh token expires; undefined when the server sent no `refresh_expires_in`. */
65
+ refreshExpiresAt: number | undefined;
66
+ }
67
+ export declare class EldraOidcError extends Error {
68
+ readonly status: number;
69
+ /** The OAuth `error` code, such as `invalid_grant`. */
70
+ readonly error: string;
71
+ readonly errorDescription: string | undefined;
72
+ constructor(status: number, error: string, errorDescription?: string);
73
+ }
74
+ interface EldraPkcePair {
75
+ codeVerifier: string;
76
+ codeChallenge: string;
77
+ codeChallengeMethod: 'S256';
78
+ }
79
+ interface EldraAuthorizeUrlOptions {
80
+ issuer: string;
81
+ clientId: string;
82
+ redirectUri: string;
83
+ state: string;
84
+ codeChallenge: string;
85
+ scope?: string;
86
+ prompt?: string;
87
+ /**
88
+ * The language(s) the login pages should use, most preferred first, as BCP 47 tags (`is`,
89
+ * `en`). Sent as the OIDC `ui_locales` parameter (space-separated); omitted when empty.
90
+ */
91
+ uiLocales?: string | readonly string[];
92
+ }
93
+ interface EldraTokenClientOptions {
94
+ issuer: string;
95
+ clientId: string;
96
+ /** Sent as `client_secret` in the form body (client_secret_post). Server-side only. */
97
+ clientSecret?: string;
98
+ fetch?: typeof fetch;
99
+ }
100
+ interface EldraExchangeCodeOptions extends EldraTokenClientOptions {
101
+ code: string;
102
+ redirectUri: string;
103
+ codeVerifier: string;
104
+ }
105
+ interface EldraRefreshTokensOptions extends EldraTokenClientOptions {
106
+ refreshToken: string;
107
+ }
108
+ interface EldraLogoutUrlOptions {
109
+ issuer: string;
110
+ clientId: string;
111
+ postLogoutRedirectUri: string;
112
+ idTokenHint?: string;
113
+ }
114
+ /** The default client id of the storefront client in every shop realm. */
115
+ export declare const ELDRA_SHOP_CLIENT_ID = "storefront";
116
+ /** The issuer of an organization's shop realm. */
117
+ export declare function shopIssuer(options: {
118
+ keycloakBaseUrl: string;
119
+ orgId: string;
120
+ }): string;
121
+ /** Headers carrying an access token, for `context.headers` of `customer.me()`. */
122
+ export declare function bearer(accessToken: string): {
123
+ Authorization: string;
124
+ };
125
+ /**
126
+ * Headers for a priced catalog read or a cart write: the access token plus, when the person
127
+ * belongs to more than one company, the active company as `X-Customer-Id`. Server-side only.
128
+ */
129
+ export declare function customerHeaders(accessToken: string, customerId?: string): {
130
+ Authorization: string;
131
+ 'X-Customer-Id'?: string;
132
+ };
133
+ /** The S256 code challenge for a verifier. */
134
+ export declare function pkceChallenge(codeVerifier: string): Promise<string>;
135
+ /** A fresh PKCE verifier (43 characters of base64url) with its S256 challenge. */
136
+ export declare function createPkcePair(): Promise<EldraPkcePair>;
137
+ export declare function buildAuthorizeUrl(options: EldraAuthorizeUrlOptions): string;
138
+ export declare function buildLogoutUrl(options: EldraLogoutUrlOptions): string;
139
+ export declare function exchangeAuthorizationCode(options: EldraExchangeCodeOptions): Promise<EldraOidcTokens>;
140
+ export declare function refreshTokens(options: EldraRefreshTokensOptions): Promise<EldraOidcTokens>;
30
141
  interface EldraTrackerScriptOptions extends Pick<EldraClientOptions, 'apiBaseUrl' | 'orgId' | 'env'> {
31
142
  /** Origin that receives events when the script is served through a first-party proxy. */
32
143
  eventOrigin?: string;
@@ -47,7 +158,7 @@ interface EldraTrackerScript {
47
158
  */
48
159
  export declare function analyticsTrackerScript(options?: EldraTrackerScriptOptions): EldraTrackerScript | undefined;
49
160
  /** A size the media host serves by path suffix; `original` is the uploaded file, untransformed. */
50
- type EldraImageVariant = 'sm' | 'md' | 'lg' | 'xl' | 'full' | 'original';
161
+ type EldraImageVariant = 'sm' | 'md' | 'lg' | 'xl' | 'full' | 'uhd' | 'original';
51
162
  /** The variants the media host resizes, narrowest first. */
52
163
  type EldraSizedImageVariant = Exclude<EldraImageVariant, 'original'>;
53
164
  /**
@@ -75,14 +186,14 @@ export declare function isEldraImage(source: EldraImageSource): boolean;
75
186
  export declare function imageUrl(source: string, variant: EldraImageVariant): string;
76
187
  export declare function imageUrl(source: EldraImageSource, variant: EldraImageVariant): string | undefined;
77
188
  /**
78
- * The narrowest variant at least `width` CSS pixels wide at the given pixel density, or `full`
189
+ * The narrowest variant at least `width` CSS pixels wide at the given pixel density, or `uhd`
79
190
  * when nothing is that wide.
80
191
  */
81
192
  export declare function imageVariantFor(width: number, density?: number): EldraSizedImageVariant;
82
193
  interface EldraImageSrcsetOptions {
83
194
  /**
84
195
  * The original's width in pixels, by default the source's `width`. Wider variants are dropped and
85
- * the last is described at its true width; an original wider than `full` is listed itself, last.
196
+ * the last is described at its true width; an original wider than `uhd` is listed itself, last.
86
197
  */
87
198
  originalWidth?: number;
88
199
  }
@@ -121,4 +232,4 @@ interface EldraResponsiveImage {
121
232
  * as `src` and no `srcset`. Returns `undefined` when there is no URL to render.
122
233
  */
123
234
  export declare function responsiveImage(source: EldraImageSource, options: EldraResponsiveImageOptions): EldraResponsiveImage | undefined;
124
- export { type EldraAddCartItemInput, type EldraBrand, type EldraCampaignAttribution, type EldraCampaignAttributionOptions, type EldraCart, type EldraCartAppliedCode, type EldraCartClient, type EldraCartDiscountCodeEntry, type EldraCartGiftCard, type EldraCartGiftCardEntry, type EldraCartItem, type EldraCartSession, type EldraCartSessionOptions, type EldraCartTotals, type EldraCatalogClient, type EldraCatalogGetProductOptions, type EldraCatalogListProductsOptions, type EldraCategory, type EldraCheckoutClient, type EldraCheckoutUrlOptions, type EldraClient, type EldraClientOptions, type EldraCmsClient, type EldraCmsEntryList, type EldraCmsEntryListDisplayMode, type EldraCmsEntryListEntry, type EldraCmsEntryListFilterCriterion, type EldraCmsGetEntryByUniqueFieldOptions, type EldraCmsGetOptions, type EldraCmsListOptions, type EldraCmsResolveEntryListOptions, type EldraCmsResolveEntryListResponse, type EldraCmsResolvedEntryList, type EldraCollection, type EldraCollectionList, type EldraCollectionListOptions, type EldraCollectionProductsOptions, type EldraContract, type EldraContractBody, type EldraContractItem, type EldraContractMethod, type EldraContractPath, type EldraContractPaths, type EldraContractProp, type EldraContractQuery, type EldraContractResponse, type EldraDiscountResult, type EldraFeature, type EldraFeatureCapabilities, type EldraFeatureClient, type EldraFormActionKind, type EldraFormDefinition, type EldraFormField, type EldraFormFieldOption, type EldraFormFieldType, type EldraFormLocalized, type EldraFormSubmitInput, type EldraFormSubmitResult, type EldraFormTokenResult, type EldraFormsClient, type EldraHttpClient, type EldraHttpRequest, type EldraImageSource, type EldraImageSrcsetOptions, type EldraImageVariant, type EldraInventoryClient, type EldraKeyValueStorage, type EldraLocaleOptions, type EldraOrder, type EldraOrderAccessTokenOptions, type EldraOrderAccessTokens, type EldraOrderDiscountCode, type EldraOrderLine, type EldraOrderReadOptions, type EldraOrdersClient, type EldraOrganizationCommerce, type EldraOrganizationDetails, type EldraOrganizationFeature, type EldraOrganizationLocales, type EldraOrganizationOptions, type EldraPageMeta, type EldraPaginated, type EldraPlatformClient, type EldraPlatformConfig, type EldraPlatformReadOptions, type EldraProductDetails, type EldraProductExtensions, type EldraProductList, type EldraProductListItem, type EldraProductMediaLink, type EldraProductOption, type EldraProductOptionValue, type EldraProductThumbnail, type EldraProductVariant, type EldraRecoveredBasket, type EldraRecoveredBasketItem, type EldraRequestContext, type EldraRequestOptions, type EldraResponsiveImage, type EldraResponsiveImageOptions, type EldraRetryOptions, type EldraSearchOptions, type EldraSearchResponse, type EldraSizedImageVariant, type EldraStockAvailability, type EldraStockAvailabilityInput, type EldraStockAvailabilityItem, type EldraTrackerScript, type EldraTrackerScriptOptions, type RuntimeEnv, type RuntimeValue, captureCampaignAttribution, clearCampaignAttribution, createCartSession, createOrderAccessTokens, grantCampaignAttributionConsent, readCampaignAttribution, withdrawCampaignAttributionConsent };
235
+ export { type EldraAddCartItemInput, type EldraAuthorizeUrlOptions, type EldraBrand, type EldraCampaignAttribution, type EldraCampaignAttributionOptions, type EldraCart, type EldraCartAppliedCode, type EldraCartClient, type EldraCartDiscountCodeEntry, type EldraCartGiftCard, type EldraCartGiftCardEntry, type EldraCartItem, type EldraCartSession, type EldraCartSessionOptions, type EldraCartTotals, type EldraCatalogClient, type EldraCatalogGetProductOptions, type EldraCatalogListProductsOptions, type EldraCategory, type EldraCheckoutClient, type EldraCheckoutUrlOptions, type EldraClient, type EldraClientOptions, type EldraCmsClient, type EldraCmsEntryList, type EldraCmsEntryListDisplayMode, type EldraCmsEntryListEntry, type EldraCmsEntryListFilterCriterion, type EldraCmsGetEntryByUniqueFieldOptions, type EldraCmsGetOptions, type EldraCmsListOptions, type EldraCmsResolveEntryListOptions, type EldraCmsResolveEntryListResponse, type EldraCmsResolvedEntryList, type EldraCollection, type EldraCollectionList, type EldraCollectionListOptions, type EldraCollectionProductsOptions, type EldraContract, type EldraContractBody, type EldraContractItem, type EldraContractMethod, type EldraContractPath, type EldraContractPaths, type EldraContractProp, type EldraContractQuery, type EldraContractResponse, type EldraCreateSalesOrderInput, type EldraCreateSalesOrderOptions, type EldraCustomerClient, type EldraCustomerLocation, type EldraCustomerLocationList, type EldraCustomerMe, type EldraCustomerMembership, type EldraDiscountResult, type EldraErrorId, type EldraExchangeCodeOptions, type EldraFeature, type EldraFeatureCapabilities, type EldraFeatureClient, type EldraFormActionKind, type EldraFormDefinition, type EldraFormField, type EldraFormFieldOption, type EldraFormFieldType, type EldraFormLocalized, type EldraFormSubmitInput, type EldraFormSubmitResult, type EldraFormTokenResult, type EldraFormsClient, type EldraHttpClient, type EldraHttpErrorWith, type EldraHttpRequest, type EldraImageSource, type EldraImageSrcsetOptions, type EldraImageVariant, type EldraInventoryClient, type EldraKeyValueStorage, type EldraLocaleOptions, type EldraLogoutUrlOptions, type EldraOidcTokens, type EldraOrder, type EldraOrderAccessTokenOptions, type EldraOrderAccessTokens, type EldraOrderDiscountCode, type EldraOrderLine, type EldraOrderReadOptions, type EldraOrdersClient, type EldraOrganizationCommerce, type EldraOrganizationDetails, type EldraOrganizationFeature, type EldraOrganizationLocales, type EldraOrganizationOptions, type EldraPageMeta, type EldraPaginated, type EldraPkcePair, type EldraPlatformClient, type EldraPlatformConfig, type EldraPlatformReadOptions, type EldraProblemErrors, type EldraProductDetails, type EldraProductExtensions, type EldraProductList, type EldraProductListItem, type EldraProductMediaLink, type EldraProductOption, type EldraProductOptionValue, type EldraProductThumbnail, type EldraProductVariant, type EldraRecoveredBasket, type EldraRecoveredBasketItem, type EldraRefreshTokensOptions, type EldraRequestContext, type EldraRequestOptions, type EldraResponsiveImage, type EldraResponsiveImageOptions, type EldraRetryOptions, type EldraSalesOrder, type EldraSalesOrderCredit, type EldraSalesOrderDelivery, type EldraSalesOrderErrorId, type EldraSalesOrderLine, type EldraSalesOrderList, type EldraSalesOrderListItem, type EldraSalesOrderListOptions, type EldraSalesOrderPreview, type EldraSalesOrderPreviewInput, type EldraSalesOrderPreviewLine, type EldraSalesOrderStatus, type EldraSalesOrderWarning, type EldraSalesOrdersClient, type EldraSearchOptions, type EldraSearchResponse, type EldraShopErrorId, type EldraShopUser, type EldraSizedImageVariant, type EldraStockAvailability, type EldraStockAvailabilityInput, type EldraStockAvailabilityItem, type EldraTokenClientOptions, type EldraTrackerScript, type EldraTrackerScriptOptions, type RuntimeEnv, type RuntimeValue, captureCampaignAttribution, clearCampaignAttribution, createCartSession, createOrderAccessTokens, grantCampaignAttributionConsent, readCampaignAttribution, withdrawCampaignAttributionConsent };
package/dist/index.js CHANGED
@@ -1,4 +1,132 @@
1
- import { a as initEldraClient, c as captureCampaignAttribution, d as readCampaignAttribution, f as withdrawCampaignAttributionConsent, i as getEldraClient, l as clearCampaignAttribution, m as createOrderAccessTokens, n as EldraHttpError, o as resolveApiBaseUrl, p as createCartSession, r as createEldraClient, s as resolveOrgId, t as DEFAULT_ELDRA_API_BASE_URL, u as grantCampaignAttributionConsent } from "./client-DCs3cAQK.js";
1
+ import { a as getEldraClient, c as resolveApiBaseUrl, d as clearCampaignAttribution, f as grantCampaignAttributionConsent, g as createOrderAccessTokens, h as createCartSession, i as createEldraClient, l as resolveOrgId, m as withdrawCampaignAttributionConsent, n as EldraHttpError, o as initEldraClient, p as readCampaignAttribution, r as EldraIdempotencyKeyError, s as isEldraError, t as DEFAULT_ELDRA_API_BASE_URL, u as captureCampaignAttribution } from "./client-cO8GCJK9.js";
2
+ // src/oidc.ts
3
+ var EldraOidcError = class extends Error {
4
+ status;
5
+ /** The OAuth `error` code, such as `invalid_grant`. */
6
+ error;
7
+ errorDescription;
8
+ constructor(status, error, errorDescription) {
9
+ super(`Token request failed with ${status} ${error}${errorDescription ? `: ${errorDescription}` : ""}`);
10
+ this.name = "EldraOidcError";
11
+ this.status = status;
12
+ this.error = error;
13
+ this.errorDescription = errorDescription;
14
+ }
15
+ };
16
+ function trimTrailingSlashes(url) {
17
+ let end = url.length;
18
+ while (end > 0 && url[end - 1] === "/") end--;
19
+ return url.slice(0, end);
20
+ }
21
+ function oidcUrl(issuer, endpoint) {
22
+ return new URL(`${trimTrailingSlashes(issuer)}/protocol/openid-connect/${endpoint}`);
23
+ }
24
+ /** The default client id of the storefront client in every shop realm. */
25
+ const ELDRA_SHOP_CLIENT_ID = "storefront";
26
+ /** The issuer of an organization's shop realm. */
27
+ function shopIssuer(options) {
28
+ return `${trimTrailingSlashes(options.keycloakBaseUrl)}/realms/shop-${encodeURIComponent(options.orgId)}`;
29
+ }
30
+ /** Headers carrying an access token, for `context.headers` of `customer.me()`. */
31
+ function bearer(accessToken) {
32
+ return { Authorization: `Bearer ${accessToken}` };
33
+ }
34
+ /**
35
+ * Headers for a priced catalog read or a cart write: the access token plus, when the person
36
+ * belongs to more than one company, the active company as `X-Customer-Id`. Server-side only.
37
+ */
38
+ function customerHeaders(accessToken, customerId) {
39
+ return customerId ? {
40
+ ...bearer(accessToken),
41
+ "X-Customer-Id": customerId
42
+ } : bearer(accessToken);
43
+ }
44
+ function base64Url(bytes) {
45
+ let binary = "";
46
+ for (const byte of bytes) binary += String.fromCharCode(byte);
47
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
48
+ }
49
+ /** The S256 code challenge for a verifier. */
50
+ async function pkceChallenge(codeVerifier) {
51
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(codeVerifier));
52
+ return base64Url(new Uint8Array(digest));
53
+ }
54
+ /** A fresh PKCE verifier (43 characters of base64url) with its S256 challenge. */
55
+ async function createPkcePair() {
56
+ const codeVerifier = base64Url(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32)));
57
+ return {
58
+ codeVerifier,
59
+ codeChallenge: await pkceChallenge(codeVerifier),
60
+ codeChallengeMethod: "S256"
61
+ };
62
+ }
63
+ function buildAuthorizeUrl(options) {
64
+ const url = oidcUrl(options.issuer, "auth");
65
+ url.searchParams.set("client_id", options.clientId);
66
+ url.searchParams.set("redirect_uri", options.redirectUri);
67
+ url.searchParams.set("response_type", "code");
68
+ url.searchParams.set("scope", options.scope ?? "openid");
69
+ url.searchParams.set("state", options.state);
70
+ url.searchParams.set("code_challenge", options.codeChallenge);
71
+ url.searchParams.set("code_challenge_method", "S256");
72
+ if (options.prompt) url.searchParams.set("prompt", options.prompt);
73
+ const uiLocales = (typeof options.uiLocales === "string" ? options.uiLocales.split(" ") : options.uiLocales ?? []).map((tag) => tag.trim()).filter(Boolean).join(" ");
74
+ if (uiLocales) url.searchParams.set("ui_locales", uiLocales);
75
+ return url.toString();
76
+ }
77
+ function buildLogoutUrl(options) {
78
+ const url = oidcUrl(options.issuer, "logout");
79
+ url.searchParams.set("client_id", options.clientId);
80
+ url.searchParams.set("post_logout_redirect_uri", options.postLogoutRedirectUri);
81
+ if (options.idTokenHint) url.searchParams.set("id_token_hint", options.idTokenHint);
82
+ return url.toString();
83
+ }
84
+ async function tokenRequest(options, params) {
85
+ const form = new URLSearchParams({
86
+ ...params,
87
+ client_id: options.clientId
88
+ });
89
+ if (options.clientSecret) form.set("client_secret", options.clientSecret);
90
+ const requestedAt = Date.now();
91
+ const response = await (options.fetch ?? globalThis.fetch)(oidcUrl(options.issuer, "token").toString(), {
92
+ method: "POST",
93
+ headers: {
94
+ "Content-Type": "application/x-www-form-urlencoded",
95
+ Accept: "application/json"
96
+ },
97
+ body: form.toString()
98
+ });
99
+ const body = await response.json().catch(() => void 0);
100
+ if (!response.ok) {
101
+ const error = typeof body?.error === "string" ? body.error : "server_error";
102
+ const description = typeof body?.error_description === "string" ? body.error_description : void 0;
103
+ throw new EldraOidcError(response.status, error, description);
104
+ }
105
+ if (typeof body?.access_token !== "string" || !body.access_token) throw new EldraOidcError(response.status, "invalid_response", "Token response has no access_token");
106
+ const text = (key) => typeof body?.[key] === "string" ? body[key] : "";
107
+ const seconds = (key) => typeof body?.[key] === "number" ? body[key] : 0;
108
+ return {
109
+ accessToken: text("access_token"),
110
+ refreshToken: text("refresh_token"),
111
+ idToken: text("id_token"),
112
+ expiresAt: requestedAt + seconds("expires_in") * 1e3,
113
+ refreshExpiresAt: typeof body.refresh_expires_in === "number" ? requestedAt + body.refresh_expires_in * 1e3 : void 0
114
+ };
115
+ }
116
+ function exchangeAuthorizationCode(options) {
117
+ return tokenRequest(options, {
118
+ grant_type: "authorization_code",
119
+ code: options.code,
120
+ redirect_uri: options.redirectUri,
121
+ code_verifier: options.codeVerifier
122
+ });
123
+ }
124
+ function refreshTokens(options) {
125
+ return tokenRequest(options, {
126
+ grant_type: "refresh_token",
127
+ refresh_token: options.refreshToken
128
+ });
129
+ }
2
130
  // src/tracker.ts
3
131
  /**
4
132
  * Builds the tracker `<script>` attributes from the same configuration the client uses, so the
@@ -28,11 +156,13 @@ const ELDRA_IMAGE_VARIANT_WIDTHS = {
28
156
  md: 800,
29
157
  lg: 1200,
30
158
  xl: 1920,
31
- full: 2560
159
+ full: 2560,
160
+ uhd: 3840
32
161
  };
33
162
  const SIZED_VARIANTS = Object.keys(ELDRA_IMAGE_VARIANT_WIDTHS);
163
+ const WIDEST = "uhd";
34
164
  const UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
35
- const ELDRA_ASSET_URL = new RegExp(`^((?:(?:https?:)?//[^/\\s,?#]+)?(?:/[^\\s,?#]*)?/public/${UUID}/assets/${UUID})(?:/(?:sm|md|lg|xl|full|original))?/?$`, "i");
165
+ const ELDRA_ASSET_URL = new RegExp(`^((?:(?:https?:)?//[^/\\s,?#]+)?(?:/[^\\s,?#]*)?/public/${UUID}/assets/${UUID})(?:/(?:sm|md|lg|xl|full|uhd|original))?/?$`, "i");
36
166
  const RESIZABLE_CONTENT_TYPES = /* @__PURE__ */ new Set([
37
167
  "image/jpeg",
38
168
  "image/png",
@@ -70,13 +200,13 @@ function imageUrl(source, variant) {
70
200
  return base ? `${base}/${variant}` : sourceUrl(source);
71
201
  }
72
202
  /**
73
- * The narrowest variant at least `width` CSS pixels wide at the given pixel density, or `full`
203
+ * The narrowest variant at least `width` CSS pixels wide at the given pixel density, or `uhd`
74
204
  * when nothing is that wide.
75
205
  */
76
206
  function imageVariantFor(width, density = 1) {
77
207
  const needed = width * density;
78
208
  if (!Number.isFinite(needed) || needed <= 0) throw new RangeError(`imageVariantFor needs a positive width, got ${width} at ${density}x`);
79
- return SIZED_VARIANTS.find((variant) => ELDRA_IMAGE_VARIANT_WIDTHS[variant] >= needed) ?? "full";
209
+ return SIZED_VARIANTS.find((variant) => ELDRA_IMAGE_VARIANT_WIDTHS[variant] >= needed) ?? WIDEST;
80
210
  }
81
211
  function originalDisplays(source) {
82
212
  const contentType = typeof source === "object" ? source?.contentType?.toLowerCase() : void 0;
@@ -99,7 +229,7 @@ function imageSrcset(source, options = {}) {
99
229
  }
100
230
  candidates.push(`${base}/${variant} ${width}w`);
101
231
  }
102
- if (isSide(originalWidth) && Math.round(originalWidth) > ELDRA_IMAGE_VARIANT_WIDTHS.full && originalDisplays(source)) candidates.push(`${base}/original ${Math.round(originalWidth)}w`);
232
+ if (isSide(originalWidth) && Math.round(originalWidth) > ELDRA_IMAGE_VARIANT_WIDTHS[WIDEST] && originalDisplays(source)) candidates.push(`${base}/original ${Math.round(originalWidth)}w`);
103
233
  return candidates.join(", ");
104
234
  }
105
235
  /**
@@ -129,4 +259,4 @@ function responsiveImage(source, options) {
129
259
  }
130
260
  return image;
131
261
  }
132
- export { DEFAULT_ELDRA_API_BASE_URL, ELDRA_IMAGE_VARIANT_WIDTHS, EldraHttpError, analyticsTrackerScript, captureCampaignAttribution, clearCampaignAttribution, createCartSession, createEldraClient, createOrderAccessTokens, getEldraClient, grantCampaignAttributionConsent, imageSrcset, imageUrl, imageVariantFor, initEldraClient, isEldraImage, readCampaignAttribution, responsiveImage, withdrawCampaignAttributionConsent };
262
+ export { DEFAULT_ELDRA_API_BASE_URL, ELDRA_IMAGE_VARIANT_WIDTHS, ELDRA_SHOP_CLIENT_ID, EldraHttpError, EldraIdempotencyKeyError, EldraOidcError, analyticsTrackerScript, bearer, buildAuthorizeUrl, buildLogoutUrl, captureCampaignAttribution, clearCampaignAttribution, createCartSession, createEldraClient, createOrderAccessTokens, createPkcePair, customerHeaders, exchangeAuthorizationCode, getEldraClient, grantCampaignAttributionConsent, imageSrcset, imageUrl, imageVariantFor, initEldraClient, isEldraError, isEldraImage, pkceChallenge, readCampaignAttribution, refreshTokens, responsiveImage, shopIssuer, withdrawCampaignAttributionConsent };
@@ -358,6 +358,8 @@ interface EldraClient {
358
358
  forms: EldraFormsClient;
359
359
  checkout: EldraCheckoutClient;
360
360
  inventory: EldraInventoryClient;
361
+ customer: EldraCustomerClient;
362
+ salesOrders: EldraSalesOrdersClient;
361
363
  }
362
364
  interface EldraLocaleOptions {
363
365
  locale?: string;
@@ -552,6 +554,113 @@ interface EldraPlatformClient {
552
554
  */
553
555
  config(readOptions?: EldraPlatformReadOptions): Promise<EldraPlatformConfig>;
554
556
  }
557
+ type EldraCustomerMe = EldraContractResponse<'/customer/v1/me', 'get'>;
558
+ type EldraShopUser = EldraContractProp<EldraCustomerMe, 'shopUser'>;
559
+ type EldraCustomerMembership = EldraContractItem<EldraContractProp<EldraCustomerMe, 'memberships'>>;
560
+ interface EldraCustomerClient {
561
+ /**
562
+ * The signed-in business customer and their company memberships. Pass the shop-realm access
563
+ * token in `context.headers`, for example `bearer(accessToken)`. Rejects with `EldraHttpError`,
564
+ * branch on `errorId`:
565
+ * - 401 `SHOP_TOKEN_INVALID`: the token is missing, expired or not from this shop realm; refresh
566
+ * or sign in again.
567
+ * - 403 `SHOP_NO_MEMBERSHIP`: the login buys for no customer company.
568
+ * - 403 `FEATURE_DISABLED`: the organisation has business sales turned off.
569
+ * - 503 `SHOP_LOGIN_UNAVAILABLE`: the login service is unreachable; try again.
570
+ */
571
+ me(context?: EldraRequestContext): Promise<EldraCustomerMe>;
572
+ /**
573
+ * The active company's delivery locations as `{ data }`, the default first; `data` is `[]` for a
574
+ * company with none.
575
+ * Pass `customerHeaders(accessToken, customerId)` as `context.headers`. Server-side only. Refusals
576
+ * are the sign-in's: 401 `SHOP_TOKEN_INVALID`, 403 `SHOP_NO_MEMBERSHIP`, `FEATURE_DISABLED`,
577
+ * `SHOP_CUSTOMER_NOT_MEMBER`, 409 `SHOP_CUSTOMER_REQUIRED`, 503 `SHOP_LOGIN_UNAVAILABLE`.
578
+ */
579
+ locations(context?: EldraRequestContext): Promise<EldraCustomerLocationList>;
580
+ }
581
+ type EldraCustomerLocationList = EldraContractResponse<'/customer/v1/locations', 'get'>;
582
+ type EldraCustomerLocation = EldraContractItem<EldraContractProp<EldraCustomerLocationList, 'data'>>;
583
+ type EldraSalesOrderPreviewInput = EldraContractBody<'/sales-order/v1/preview', 'post'>;
584
+ type EldraSalesOrderPreview = EldraContractResponse<'/sales-order/v1/preview', 'post'>;
585
+ type EldraSalesOrderPreviewLine = EldraContractItem<EldraContractProp<EldraSalesOrderPreview, 'lines'>>;
586
+ type EldraSalesOrderCredit = EldraContractProp<EldraSalesOrderPreview, 'credit'>;
587
+ type EldraCreateSalesOrderInput = EldraContractBody<'/sales-order/v1', 'post'>;
588
+ type EldraSalesOrder = EldraContractResponse<'/sales-order/v1/{salesOrderId}', 'get'>;
589
+ type EldraSalesOrderLine = EldraContractItem<EldraContractProp<EldraSalesOrder, 'lines'>>;
590
+ type EldraSalesOrderWarning = EldraContractItem<EldraContractProp<EldraSalesOrder, 'warnings'>>;
591
+ type EldraSalesOrderDelivery = EldraContractProp<EldraSalesOrder, 'delivery'>;
592
+ type EldraSalesOrderStatus = EldraContractProp<EldraSalesOrder, 'salesStatus'>;
593
+ type EldraSalesOrderList = EldraContractResponse<'/sales-order/v1', 'get'>;
594
+ type EldraSalesOrderListItem = EldraContractItem<EldraContractProp<EldraSalesOrderList, 'data'>>;
595
+ type EldraSalesOrderListOptions = EldraContractQuery<'/sales-order/v1', 'get'>;
596
+ interface EldraCreateSalesOrderOptions {
597
+ /**
598
+ * Required. Mint one per attempt to place the order (a random UUID), keep it across retries of
599
+ * that attempt, and mint a new one when the cart or the form changes. The same key replays the
600
+ * first order rather than placing a second; a different body under it is 409
601
+ * `ORDER_IDEMPOTENCY_CONFLICT`.
602
+ */
603
+ idempotencyKey: string;
604
+ }
605
+ /** Error ids of the business sign-in, on every route that takes a shop token. */
606
+ type EldraShopErrorId = 'SHOP_TOKEN_INVALID' | 'SHOP_NO_MEMBERSHIP' | 'SHOP_CUSTOMER_NOT_MEMBER' | 'SHOP_CUSTOMER_REQUIRED' | 'SHOP_LOGIN_UNAVAILABLE' | 'FEATURE_DISABLED';
607
+ /**
608
+ * Error ids of the sales-order routes (contract 6.15.0). `SALES_ORDER_CART_ALREADY_ORDERED`
609
+ * carries `errors.salesOrderId`, `SALES_ORDER_LINE_INVALID` `errors.variantId` and
610
+ * `ORDER_PRODUCT_UNAVAILABLE` `errors.variantIds` on `EldraHttpError.errors`.
611
+ */
612
+ type EldraSalesOrderErrorId = 'SALES_ORDER_IDEMPOTENCY_KEY_REQUIRED' | 'SALES_ORDER_CART_EMPTY' | 'SALES_ORDER_TOO_MANY_LINES' | 'SALES_ORDER_LINE_INVALID' | 'SALES_ORDER_CART_NOT_BOUND' | 'SALES_ORDER_CART_ALREADY_ORDERED' | 'SALES_ORDER_LOCATION_UNKNOWN' | 'SALES_ORDER_CREDIT_LIMIT_EXCEEDED' | 'SALES_ORDER_CREDIT_CURRENCY_MISMATCH' | 'SALES_ORDER_CREDIT_CHECK_UNAVAILABLE' | 'SALES_ORDER_TERMS_UNAVAILABLE' | 'SALES_ORDER_CART_UNAVAILABLE' | 'SALES_ORDER_UPSTREAM_REFUSED' | 'SALES_ORDER_NOT_FOUND' | 'CUSTOMER_BLOCKED' | 'CART_NOT_FOUND' | 'ORDER_CUSTOMER_UNAVAILABLE' | 'ORDER_CUSTOMER_PRICES_OFF' | 'ORDER_PRODUCT_UNAVAILABLE' | 'ORDER_PRICES_UNAVAILABLE' | 'ORDER_IDEMPOTENCY_CONFLICT' | 'ORIGIN_NOT_REGISTERED';
613
+ /**
614
+ * The `errors` object each refusal carries, by `errorId`, as the gateway documents it. Read it through
615
+ * `isEldraError(error, id)`. `ORDER_PRODUCT_UNAVAILABLE` names `variantIds` on a sales order and the
616
+ * cart's `itemIds` on a web order.
617
+ */
618
+ interface EldraProblemErrors {
619
+ SALES_ORDER_CART_ALREADY_ORDERED: {
620
+ salesOrderId: string;
621
+ };
622
+ SALES_ORDER_LINE_INVALID: {
623
+ variantId: string;
624
+ };
625
+ ORDER_PRODUCT_UNAVAILABLE: {
626
+ variantIds: string[];
627
+ itemIds: string[];
628
+ };
629
+ SHIPPING_CART_NOT_EXPORTABLE: {
630
+ itemIds: string[];
631
+ };
632
+ }
633
+ /** A problem's `errorId`: the ids above, or any other the gateway answers. */
634
+ type EldraErrorId = EldraShopErrorId | EldraSalesOrderErrorId | keyof EldraProblemErrors | (string & {});
635
+ /**
636
+ * Orders on account for a signed-in business customer's active company (contract 6.15.0).
637
+ * Server-side only: pass `customerHeaders(accessToken, customerId)` as `context.headers` on every
638
+ * call. Every answer is `Cache-Control: private, no-store`; never cache one. See
639
+ * docs/sales-orders.md.
640
+ *
641
+ * Only 401 `SHOP_TOKEN_INVALID` means sign in again. 502 `SALES_ORDER_UPSTREAM_REFUSED` is the
642
+ * supplier's order service refusing the platform, not the person: try again later and never sign
643
+ * the person out over it.
644
+ */
645
+ interface EldraSalesOrdersClient {
646
+ /**
647
+ * Prices the company's bound cart exactly as placing it would, and writes nothing. No credit
648
+ * limit or balance is answered: `credit.wouldBlock` says placing would be refused for credit.
649
+ */
650
+ preview(input: EldraSalesOrderPreviewInput, context?: EldraRequestContext): Promise<EldraSalesOrderPreview>;
651
+ /**
652
+ * Places the order from the cart (201) and the cart is removed. `options.idempotencyKey` is
653
+ * required (1 to 255 printable ASCII characters, no spaces): without a usable one the call rejects
654
+ * with an `EldraIdempotencyKeyError`, a programming error, and sends nothing. **A 502, a 503 or a timeout may
655
+ * follow an order that was placed**: retry with the same key, which replays that order rather
656
+ * than placing a second. `warnings` name steps the supplier finishes later; the order stands.
657
+ */
658
+ create(input: EldraCreateSalesOrderInput, options: EldraCreateSalesOrderOptions, context?: EldraRequestContext): Promise<EldraSalesOrder>;
659
+ /** The company's sales orders, newest first; `pageSize` 1–50 (default 50). */
660
+ list(options?: EldraSalesOrderListOptions, context?: EldraRequestContext): Promise<EldraSalesOrderList>;
661
+ /** One sales order; another company's is 404 `SALES_ORDER_NOT_FOUND`. `warnings` is `[]`. */
662
+ get(salesOrderId: string, context?: EldraRequestContext): Promise<EldraSalesOrder>;
663
+ }
555
664
  interface EldraInventoryClient {
556
665
  availability(items: EldraStockAvailabilityInput[], context?: EldraRequestContext): Promise<EldraStockAvailability>;
557
666
  }
@@ -655,4 +764,4 @@ interface EldraFormsClient {
655
764
  /** `POST /site/v1/forms/subscriptions/unsubscribe?token=` (a GET of the link is only a page). */
656
765
  unsubscribe(token: string, context?: EldraRequestContext): Promise<EldraFormTokenResult>;
657
766
  }
658
- export { EldraOrderDiscountCode as $, EldraOrderAccessTokenOptions as $t, EldraCollection as A, EldraStockAvailabilityInput as At, EldraFormField as B, EldraContractProp as Bt, EldraCmsEntryListFilterCriterion as C, EldraRecoveredBasketItem as Ct, EldraCmsResolveEntryListOptions as D, EldraSearchOptions as Dt, EldraCmsListOptions as E, EldraRetryOptions as Et, EldraFeature as F, EldraContractBody as Ft, EldraFormSubmitResult as G, captureCampaignAttribution as Gt, EldraFormFieldType as H, EldraContractResponse as Ht, EldraFeatureCapabilities as I, EldraContractItem as It, EldraHttpClient as J, readCampaignAttribution as Jt, EldraFormTokenResult as K, clearCampaignAttribution as Kt, EldraFeatureClient as L, EldraContractMethod as Lt, EldraCollectionListOptions as M, RuntimeEnv as Mt, EldraCollectionProductsOptions as N, RuntimeValue as Nt, EldraCmsResolveEntryListResponse as O, EldraSearchResponse as Ot, EldraDiscountResult as P, EldraContract as Pt, EldraOrder as Q, EldraKeyValueStorage as Qt, EldraFormActionKind as R, EldraContractPath as Rt, EldraCmsEntryListEntry as S, EldraRecoveredBasket as St, EldraCmsGetOptions as T, EldraRequestOptions as Tt, EldraFormLocalized as U, EldraCampaignAttribution as Ut, EldraFormFieldOption as V, EldraContractQuery as Vt, EldraFormSubmitInput as W, EldraCampaignAttributionOptions as Wt, EldraInventoryClient as X, EldraCartSession as Xt, EldraHttpRequest as Y, withdrawCampaignAttributionConsent as Yt, EldraLocaleOptions as Z, EldraCartSessionOptions as Zt, EldraClient as _, EldraProductMediaLink as _t, EldraCartClient as a, EldraOrganizationFeature as at, EldraCmsEntryList as b, EldraProductThumbnail as bt, EldraCartGiftCardEntry as c, EldraPageMeta as ct, EldraCatalogClient as d, EldraPlatformConfig as dt, EldraOrderAccessTokens as en, EldraOrderLine as et, EldraCatalogGetProductOptions as f, EldraPlatformReadOptions as ft, EldraCheckoutUrlOptions as g, EldraProductListItem as gt, EldraCheckoutClient as h, EldraProductList as ht, EldraCartAppliedCode as i, EldraOrganizationDetails as it, EldraCollectionList as j, EldraStockAvailabilityItem as jt, EldraCmsResolvedEntryList as k, EldraStockAvailability as kt, EldraCartItem as l, EldraPaginated as lt, EldraCategory as m, EldraProductExtensions as mt, EldraBrand as n, createOrderAccessTokens as nn, EldraOrdersClient as nt, EldraCartDiscountCodeEntry as o, EldraOrganizationLocales as ot, EldraCatalogListProductsOptions as p, EldraProductDetails as pt, EldraFormsClient as q, grantCampaignAttributionConsent as qt, EldraCart as r, EldraOrganizationCommerce as rt, EldraCartGiftCard as s, EldraOrganizationOptions as st, EldraAddCartItemInput as t, createCartSession as tn, EldraOrderReadOptions as tt, EldraCartTotals as u, EldraPlatformClient as ut, EldraClientOptions as v, EldraProductOption as vt, EldraCmsGetEntryByUniqueFieldOptions as w, EldraRequestContext as wt, EldraCmsEntryListDisplayMode as x, EldraProductVariant as xt, EldraCmsClient as y, EldraProductOptionValue as yt, EldraFormDefinition as z, EldraContractPaths as zt };
767
+ export { EldraFormSubmitResult as $, EldraShopUser as $t, EldraCollection as A, EldraProductVariant as At, EldraCustomerMembership as B, EldraSalesOrderLine as Bt, EldraCmsEntryListFilterCriterion as C, EldraKeyValueStorage as Cn, EldraProductExtensions as Ct, EldraCmsResolveEntryListOptions as D, createOrderAccessTokens as Dn, EldraProductOption as Dt, EldraCmsListOptions as E, createCartSession as En, EldraProductMediaLink as Et, EldraCreateSalesOrderOptions as F, EldraRetryOptions as Ft, EldraFeatureClient as G, EldraSalesOrderPreviewInput as Gt, EldraErrorId as H, EldraSalesOrderListItem as Ht, EldraCustomerClient as I, EldraSalesOrder as It, EldraFormField as J, EldraSalesOrderWarning as Jt, EldraFormActionKind as K, EldraSalesOrderPreviewLine as Kt, EldraCustomerLocation as L, EldraSalesOrderCredit as Lt, EldraCollectionListOptions as M, EldraRecoveredBasketItem as Mt, EldraCollectionProductsOptions as N, EldraRequestContext as Nt, EldraCmsResolveEntryListResponse as O, EldraProductOptionValue as Ot, EldraCreateSalesOrderInput as P, EldraRequestOptions as Pt, EldraFormSubmitInput as Q, EldraShopErrorId as Qt, EldraCustomerLocationList as R, EldraSalesOrderDelivery as Rt, EldraCmsEntryListEntry as S, EldraCartSessionOptions as Sn, EldraProductDetails as St, EldraCmsGetOptions as T, EldraOrderAccessTokens as Tn, EldraProductListItem as Tt, EldraFeature as U, EldraSalesOrderListOptions as Ut, EldraDiscountResult as V, EldraSalesOrderList as Vt, EldraFeatureCapabilities as W, EldraSalesOrderPreview as Wt, EldraFormFieldType as X, EldraSearchOptions as Xt, EldraFormFieldOption as Y, EldraSalesOrdersClient as Yt, EldraFormLocalized as Z, EldraSearchResponse as Zt, EldraClient as _, clearCampaignAttribution as _n, EldraPaginated as _t, EldraCartClient as a, EldraContract as an, EldraLocaleOptions as at, EldraCmsEntryList as b, withdrawCampaignAttributionConsent as bn, EldraPlatformReadOptions as bt, EldraCartGiftCardEntry as c, EldraContractMethod as cn, EldraOrderLine as ct, EldraCatalogClient as d, EldraContractProp as dn, EldraOrganizationCommerce as dt, EldraStockAvailability as en, EldraFormTokenResult as et, EldraCatalogGetProductOptions as f, EldraContractQuery as fn, EldraOrganizationDetails as ft, EldraCheckoutUrlOptions as g, captureCampaignAttribution as gn, EldraPageMeta as gt, EldraCheckoutClient as h, EldraCampaignAttributionOptions as hn, EldraOrganizationOptions as ht, EldraCartAppliedCode as i, RuntimeValue as in, EldraInventoryClient as it, EldraCollectionList as j, EldraRecoveredBasket as jt, EldraCmsResolvedEntryList as k, EldraProductThumbnail as kt, EldraCartItem as l, EldraContractPath as ln, EldraOrderReadOptions as lt, EldraCategory as m, EldraCampaignAttribution as mn, EldraOrganizationLocales as mt, EldraBrand as n, EldraStockAvailabilityItem as nn, EldraHttpClient as nt, EldraCartDiscountCodeEntry as o, EldraContractBody as on, EldraOrder as ot, EldraCatalogListProductsOptions as p, EldraContractResponse as pn, EldraOrganizationFeature as pt, EldraFormDefinition as q, EldraSalesOrderStatus as qt, EldraCart as r, RuntimeEnv as rn, EldraHttpRequest as rt, EldraCartGiftCard as s, EldraContractItem as sn, EldraOrderDiscountCode as st, EldraAddCartItemInput as t, EldraStockAvailabilityInput as tn, EldraFormsClient as tt, EldraCartTotals as u, EldraContractPaths as un, EldraOrdersClient as ut, EldraClientOptions as v, grantCampaignAttributionConsent as vn, EldraPlatformClient as vt, EldraCmsGetEntryByUniqueFieldOptions as w, EldraOrderAccessTokenOptions as wn, EldraProductList as wt, EldraCmsEntryListDisplayMode as x, EldraCartSession as xn, EldraProblemErrors as xt, EldraCmsClient as y, readCampaignAttribution as yn, EldraPlatformConfig as yt, EldraCustomerMe as z, EldraSalesOrderErrorId as zt };
package/dist/vite.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Mt as RuntimeEnv, Nt as RuntimeValue } from "./types-r819aFGS.js";
1
+ import { in as RuntimeValue, rn as RuntimeEnv } from "./types-BrQEYrD5.js";
2
2
  import { Plugin } from "vite";
3
3
  export interface EldraVitePluginOptions {
4
4
  apiBaseUrl?: RuntimeValue<string>;
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./client-DCs3cAQK.js";
1
+ import "./client-cO8GCJK9.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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eldrajs/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.5.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",