@eldrajs/sdk 0.2.6 → 0.2.8

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,25 +9,61 @@ platform repository.
9
9
 
10
10
  ## Unreleased
11
11
 
12
+ - **A request that answered `429` or `503` is retried instead of failing.** The gateway rate-limits a
13
+ client by requests per minute, which a static build of a real catalogue meets routinely. The
14
+ default `fetch` transport now repeats an **idempotent** request (`GET`/`HEAD`/`OPTIONS` — never a
15
+ `POST`, which may already have been applied), and one whose connection dropped (`fetch failed`,
16
+ `ECONNRESET` and the rest), honouring `Retry-After` in seconds or as an HTTP-date (up to a minute)
17
+ and otherwise waiting `250 ms × 2^attempt` capped at 5 s with jitter, for at most five attempts
18
+ including the first. Configurable as `retry: { attempts, baseDelayMs, maxDelayMs }` on
19
+ `createEldraClient` (`EldraRetryOptions`); `{ attempts: 0 }` is one request and no waiting. Every
20
+ other status is unchanged, and a consumer-supplied `httpClient` is left alone — the retry belongs
21
+ to the transport, and a replaced transport is the consumer's own. A caller's `AbortSignal` ends a
22
+ retry during the wait as well as during the request, rejecting with the signal's own reason. A
23
+ dropped connection is told apart from a **malformed** request by the shape `fetch` reports (a known
24
+ network message, or a retryable `code` on the error or its `cause`): an unparseable URL, an invalid
25
+ header name or a `GET` with a body fails on the first attempt, because repeating it can only fail
26
+ the same way. **This is a minor**: the behaviour is a repair, but `retry` is a new public option
27
+ and `EldraRetryOptions` a new exported type.
28
+
29
+ - `analyticsTrackerScript`'s documentation no longer says events always reach the gateway; with
30
+ `eventOrigin` set they go to that first-party proxy.
31
+
32
+ ## 0.2.6 — 2026-10-08
33
+
12
34
  - Responsive images: `responsiveImage` returns `src`, `srcset`, `sizes`, `width` and `height` for
13
35
  an `<img>` from any media URL or object the API returns; `imageSrcset`, `imageUrl`,
14
36
  `imageVariantFor`, `isEldraImage` and `ELDRA_IMAGE_VARIANT_WIDTHS` are the parts. A bare media
15
37
  URL serves 800 px, so a storefront rendering it as-is was soft on wide screens. External URLs
16
38
  and formats the host does not resize come back unchanged. See `docs/images.md`.
17
39
 
40
+ ## 0.2.5 — 2026-09-25
41
+
42
+ - `analyticsTrackerScript` builds the analytics tracker `<script>` attributes from the same
43
+ configuration as the client, so the script comes from the gateway the site reads from. Events go
44
+ there too, unless `eventOrigin` names a first-party proxy to send them through.
45
+
46
+ ## 0.2.4 — 2026-09-23
47
+
18
48
  - `checkout.handoffUrl` defaults to the hosted checkout at `https://checkout.eldra.app` (exported
19
49
  as `DEFAULT_ELDRA_CHECKOUT_URL`) when the client uses the default API base URL, so a production
20
50
  storefront no longer needs a checkout URL setting. `checkoutUrl` and the `ELDRA_CHECKOUT_URL` env
21
51
  keys still override it; a client on any other gateway must still name its checkout.
22
52
 
53
+ ## 0.2.3 — 2026-09-23
54
+
23
55
  - `EldraHttpError.errorId` carries the problem's specific reason, such as `CART_NOT_FOUND` or
24
56
  `CART_INSUFFICIENT_STOCK`. The docs told you to branch on `code` for these, but the gateway puts
25
57
  them in `errorId`; `code` is only the category (`NOT_FOUND`, `CONFLICT`) and is unchanged.
26
58
 
59
+ ## 0.2.2 — 2026-09-20
60
+
27
61
  - Restore `previewToken` on the SDK client and Vite generator after the move from
28
62
  `vue-ui-components`. Accepts a string or callback and sends `X-Preview-Token`; the generator
29
63
  forwards it to both type endpoints without embedding it in generated files.
30
64
 
65
+ ## 0.2.1 — 2026-09-16
66
+
31
67
  - The Vite plugin writes `.eldra/web-studio/` beside the nearest `package.json` instead of Vite's
32
68
  root; on Nuxt 4 the root is `app/`, and the folder landed there. A relative `outDir` is resolved
33
69
  the same way.
package/README.md CHANGED
@@ -68,10 +68,52 @@ choosing `sizes`, and avoiding layout shift are in [docs/images.md](../../docs/i
68
68
  | `catalog` | `listProducts`, `getProduct`, `listCategories`, `listCollections`, `getCollection`, `listCollectionProducts`, `search` |
69
69
  | `cms` | `list`, `get`, `getEntryByUniqueField`, `resolveEntryList` |
70
70
  | `cart` | `addItem`, `get`, `updateItem`, `removeItem`, `applyDiscount`, `removeDiscount` |
71
- | `checkout` | `handoffUrl` |
71
+ | `checkout` | `url` |
72
72
  | `orders` | `get`, `recover` |
73
73
  | `inventory` | `availability` |
74
- | `features` | `getOrganization`, `list`, `isEnabled`, `getCapabilities` |
74
+ | `features` | `getOrganization`, `list`, `isEnabled`, `getCapabilities`, `getCommerce` |
75
+ | `platform` | `config` |
76
+
77
+ `checkout.url({ cartId, locale })` is where a storefront sends the shopper. The platform hosts the
78
+ checkout page, so the client asks the platform where (`platform.config()`, a public read cached per
79
+ client instance, sent without the organisation header because the route takes none) and returns
80
+ `{checkoutUrl}/checkout/{orgId}/{cartId}`. It rejects — with a different message for each cause, and
81
+ the read failure as `cause` where there was one — when the platform published no checkout URL, when
82
+ the config could not be read, and when what was published is not an absolute `http(s)` URL. A
83
+ storefront should treat all three as "no Check out to show" rather than something to report to a
84
+ shopper.
85
+
86
+ `features.getCommerce()` answers what the store sells in — `{ currency, taxInclusivePricing,
87
+ defaultTaxRate }` — or `null` when the organisation publishes no commerce settings, which is the
88
+ honest answer for a store that has not configured any: a storefront can then render a price as a
89
+ number rather than under a currency symbol nobody chose. It reads the same organisation document the
90
+ rest of the group reads, so a caller already holding an `EldraOrganizationDetails` should take
91
+ `commerce` off it instead of asking again.
92
+
93
+ ## Retrying what the gateway refused for now
94
+
95
+ The gateway rate-limits a client by requests per minute, so a static build of a real catalogue —
96
+ thousands of reads from one address in a few minutes — meets that limit routinely. A `429` is not an
97
+ answer, and neither is a `503` while the gateway restarts or a connection the network drops, so the
98
+ client asks again: **idempotent requests only** (`GET`/`HEAD`/`OPTIONS` — a `POST` that timed out may
99
+ well have been applied), at most five attempts including the first, honouring `Retry-After` (seconds
100
+ or HTTP-date, up to a minute) and otherwise waiting 250 ms doubled per attempt, capped at 5 s, with
101
+ jitter. Every other status — a `404`, a `422`, a `401` — is returned on the first answer, as before.
102
+ The caller's `AbortSignal` ends it immediately, during a wait as much as during a request. A dropped connection is told apart from a **malformed** request — an
103
+ unparseable URL, an invalid header name, a `GET` with a body — which fails on the first attempt,
104
+ because repeating it can only fail the same way.
105
+
106
+ ```ts
107
+ const eldra = createEldraClient({
108
+ orgId: 'your-organisation-id',
109
+ retry: { attempts: 5, baseDelayMs: 250, maxDelayMs: 5000 }, // the defaults
110
+ });
111
+
112
+ // One request, no waiting:
113
+ createEldraClient({ orgId: 'your-organisation-id', retry: { attempts: 0 } });
114
+ ```
115
+
116
+ A consumer-supplied `httpClient` replaces the transport, so the retry is that client's own.
75
117
 
76
118
  Every failed request throws `EldraHttpError` with `status`, the problem's category `code` (such as
77
119
  `NOT_FOUND`) and its specific `errorId` (such as `CART_NOT_FOUND`); branch on `errorId`.