@magicstoreai/storefront-client 0.1.0
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/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/index.cjs +413 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +11332 -0
- package/dist/index.d.ts +11332 -0
- package/dist/index.js +371 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MagicStore
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @magicstoreai/storefront-client
|
|
2
|
+
|
|
3
|
+
Typed client for the MagicStore **Storefront API v2**. One method per `operationId`, types generated
|
|
4
|
+
from the published OpenAPI document. No React, no Node-only APIs: it runs in Node (≥ 22), edge
|
|
5
|
+
runtimes and the browser.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createStorefrontClient, MagicStoreError } from '@magicstoreai/storefront-client';
|
|
9
|
+
|
|
10
|
+
const client = createStorefrontClient({
|
|
11
|
+
shopDomain: 'shop.example.uz', // or baseUrl
|
|
12
|
+
storefrontToken: process.env.MAGICSTORE_STOREFRONT_TOKEN, // when the host is not the shop's domain
|
|
13
|
+
locale: 'uz',
|
|
14
|
+
customerToken: () => session.accessToken, // read on every call — it rotates hourly
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const { data: product } = await client.productsShow({ path: { handle: 'red-shoes' } });
|
|
18
|
+
|
|
19
|
+
for await (const item of client.paginate('productsIndex', { query: { sort: '-createdAt' } })) {
|
|
20
|
+
// every product, page after page
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
await client.checkoutsCompletion({ path: { id: checkoutId } });
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (error instanceof MagicStoreError && error.code === 'CHECKOUT_NOT_READY') {
|
|
27
|
+
// error.errors, error.detail (localized), error.requestId
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## What the client does for you
|
|
33
|
+
|
|
34
|
+
| | |
|
|
35
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
36
|
+
| Headers | `X-Storefront-Token`, `Accept-Language`, `Authorization: Bearer <customer>`, `X-Request-Id` (generated) |
|
|
37
|
+
| Idempotency | Money-moving calls (checkout completion, payment link, reward redemption, ambassador payout) get an `Idempotency-Key`. To retry one whose answer you did not get, pass `{ idempotencyKey: error.idempotencyKey }`. |
|
|
38
|
+
| Errors | Every non-2xx answer throws `MagicStoreError` with the API's `code`; no answer is `NETWORK_ERROR`, a cancelled call `ABORTED`. |
|
|
39
|
+
| Retries | `GET`s answered `429` / `5xx` or not answered: 2 retries with jittered backoff, honouring `Retry-After`. Writes are never retried. `retry: false` turns it off. |
|
|
40
|
+
| Pagination | `client.paginate(operationId, input)` — offset (`page`) and cursor (`cursor`) operations alike. |
|
|
41
|
+
|
|
42
|
+
Every method takes `(input, options?)`: `input` has `path`, `query`, `header` and `body` exactly as
|
|
43
|
+
the operation declares them; `options` are `signal`, `locale`, `customerToken`, `idempotencyKey`,
|
|
44
|
+
`requestId` and `headers` for that one call.
|
|
45
|
+
|
|
46
|
+
Resource types by name: `Schema<'Product'>`, `Schema<'Cart'>`, …
|
|
47
|
+
|
|
48
|
+
The API itself — rules, errors, auth, cart and checkout — is documented in the backend repository
|
|
49
|
+
under `docs/api/v2/`.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
API_VERSION: () => API_VERSION,
|
|
34
|
+
MagicStoreError: () => MagicStoreError,
|
|
35
|
+
createStorefrontClient: () => createStorefrontClient,
|
|
36
|
+
operationInput: () => operationInput,
|
|
37
|
+
operationTable: () => operationTable,
|
|
38
|
+
retryAfterSeconds: () => retryAfterSeconds
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(index_exports);
|
|
41
|
+
|
|
42
|
+
// src/client.ts
|
|
43
|
+
var import_openapi_fetch = __toESM(require("openapi-fetch"), 1);
|
|
44
|
+
|
|
45
|
+
// src/errors.ts
|
|
46
|
+
var CODE_BY_STATUS = {
|
|
47
|
+
400: "BAD_REQUEST",
|
|
48
|
+
401: "UNAUTHENTICATED",
|
|
49
|
+
403: "FORBIDDEN",
|
|
50
|
+
404: "NOT_FOUND",
|
|
51
|
+
405: "METHOD_NOT_ALLOWED",
|
|
52
|
+
413: "PAYLOAD_TOO_LARGE",
|
|
53
|
+
422: "VALIDATION_FAILED",
|
|
54
|
+
429: "RATE_LIMITED",
|
|
55
|
+
503: "SERVICE_UNAVAILABLE"
|
|
56
|
+
};
|
|
57
|
+
var MagicStoreError = class _MagicStoreError extends Error {
|
|
58
|
+
name = "MagicStoreError";
|
|
59
|
+
/** HTTP status; `0` when no answer arrived. */
|
|
60
|
+
status;
|
|
61
|
+
/** An API `code` (open to new values), or `NETWORK_ERROR` / `ABORTED`. */
|
|
62
|
+
code;
|
|
63
|
+
/** Localized, safe to show to a customer — when the API sent one. */
|
|
64
|
+
detail;
|
|
65
|
+
/** Per-field failures on `VALIDATION_FAILED` and per-line conflicts. */
|
|
66
|
+
errors;
|
|
67
|
+
/** `X-Request-Id` of the call. Quote it when reporting a problem. */
|
|
68
|
+
requestId;
|
|
69
|
+
/** Seconds to wait before trying again (`Retry-After`), when the API said. */
|
|
70
|
+
retryAfter;
|
|
71
|
+
/** The key a money-moving call was sent with: retry with the same one. */
|
|
72
|
+
idempotencyKey;
|
|
73
|
+
/** The problem document as received, when there was one. */
|
|
74
|
+
problem;
|
|
75
|
+
constructor(init) {
|
|
76
|
+
super(init.message, init.cause === void 0 ? void 0 : { cause: init.cause });
|
|
77
|
+
this.status = init.status;
|
|
78
|
+
this.code = init.code;
|
|
79
|
+
this.detail = init.detail;
|
|
80
|
+
this.errors = init.errors ?? [];
|
|
81
|
+
this.requestId = init.requestId;
|
|
82
|
+
this.retryAfter = init.retryAfter;
|
|
83
|
+
this.idempotencyKey = init.idempotencyKey;
|
|
84
|
+
this.problem = init.problem;
|
|
85
|
+
}
|
|
86
|
+
/** From a non-2xx answer. A body that is not a problem document still yields a code. */
|
|
87
|
+
static fromResponse(response, body, context) {
|
|
88
|
+
const problem = isRecord(body) ? body : void 0;
|
|
89
|
+
const code = typeof problem?.code === "string" ? problem.code : CODE_BY_STATUS[response.status] ?? (response.status >= 500 ? "INTERNAL_ERROR" : "BAD_REQUEST");
|
|
90
|
+
const requestId = (typeof problem?.requestId === "string" ? problem.requestId : void 0) ?? response.headers.get("X-Request-Id") ?? context.requestId;
|
|
91
|
+
return new _MagicStoreError({
|
|
92
|
+
status: response.status,
|
|
93
|
+
code,
|
|
94
|
+
message: problem?.title ?? `${response.status} ${code}`,
|
|
95
|
+
detail: problem?.detail,
|
|
96
|
+
errors: Array.isArray(problem?.errors) ? problem.errors : void 0,
|
|
97
|
+
requestId,
|
|
98
|
+
retryAfter: retryAfterSeconds(response),
|
|
99
|
+
idempotencyKey: context.idempotencyKey,
|
|
100
|
+
problem
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/** No answer: the request never completed. */
|
|
104
|
+
static fromFailure(cause, context) {
|
|
105
|
+
return new _MagicStoreError({
|
|
106
|
+
status: 0,
|
|
107
|
+
code: context.aborted ? "ABORTED" : "NETWORK_ERROR",
|
|
108
|
+
message: context.aborted ? "The request was aborted." : "The request did not complete.",
|
|
109
|
+
requestId: context.requestId,
|
|
110
|
+
idempotencyKey: context.idempotencyKey,
|
|
111
|
+
cause
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
function retryAfterSeconds(response) {
|
|
116
|
+
const value = response.headers.get("Retry-After");
|
|
117
|
+
if (value === null) {
|
|
118
|
+
return void 0;
|
|
119
|
+
}
|
|
120
|
+
const seconds = Number(value);
|
|
121
|
+
return Number.isFinite(seconds) && seconds >= 0 ? seconds : void 0;
|
|
122
|
+
}
|
|
123
|
+
function isRecord(value) {
|
|
124
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/generated/operations.ts
|
|
128
|
+
var API_VERSION = "2.0.0-alpha.1";
|
|
129
|
+
var operationTable = {
|
|
130
|
+
analyticsEventsStore: { method: "POST", path: "/analytics/events", idempotencyKey: false, customer: false, pagination: null },
|
|
131
|
+
authClick: { method: "POST", path: "/auth/click", idempotencyKey: false, customer: false, pagination: null },
|
|
132
|
+
authOq: { method: "POST", path: "/auth/oq", idempotencyKey: false, customer: false, pagination: null },
|
|
133
|
+
authOtp: { method: "POST", path: "/auth/otp", idempotencyKey: false, customer: false, pagination: null },
|
|
134
|
+
authOtpVerification: { method: "POST", path: "/auth/otp/verification", idempotencyKey: false, customer: false, pagination: null },
|
|
135
|
+
authTelegram: { method: "POST", path: "/auth/telegram", idempotencyKey: false, customer: false, pagination: null },
|
|
136
|
+
authTokenDestroy: { method: "DELETE", path: "/auth/token", idempotencyKey: false, customer: true, pagination: null },
|
|
137
|
+
authTokenRefresh: { method: "POST", path: "/auth/token/refresh", idempotencyKey: false, customer: false, pagination: null },
|
|
138
|
+
cartsAttributes: { method: "PUT", path: "/carts/{id}/attributes", idempotencyKey: false, customer: false, pagination: null },
|
|
139
|
+
cartsBuyerIdentity: { method: "PUT", path: "/carts/{id}/buyer-identity", idempotencyKey: false, customer: true, pagination: null },
|
|
140
|
+
cartsDiscountCodes: { method: "PUT", path: "/carts/{id}/discount-codes", idempotencyKey: false, customer: false, pagination: null },
|
|
141
|
+
cartsGift: { method: "PUT", path: "/carts/{id}/gift", idempotencyKey: false, customer: false, pagination: null },
|
|
142
|
+
cartsLinesDestroy: { method: "DELETE", path: "/carts/{id}/lines/{lineId}", idempotencyKey: false, customer: false, pagination: null },
|
|
143
|
+
cartsLinesStore: { method: "POST", path: "/carts/{id}/lines", idempotencyKey: false, customer: false, pagination: null },
|
|
144
|
+
cartsLinesUpdate: { method: "PATCH", path: "/carts/{id}/lines/{lineId}", idempotencyKey: false, customer: false, pagination: null },
|
|
145
|
+
cartsNote: { method: "PUT", path: "/carts/{id}/note", idempotencyKey: false, customer: false, pagination: null },
|
|
146
|
+
cartsPoints: { method: "PUT", path: "/carts/{id}/points", idempotencyKey: false, customer: true, pagination: null },
|
|
147
|
+
cartsShow: { method: "GET", path: "/carts/{id}", idempotencyKey: false, customer: false, pagination: null },
|
|
148
|
+
cartsStore: { method: "POST", path: "/carts", idempotencyKey: false, customer: false, pagination: null },
|
|
149
|
+
chatConversationsCustomer: { method: "PUT", path: "/chat/conversations/{id}/customer", idempotencyKey: false, customer: true, pagination: null },
|
|
150
|
+
chatConversationsIndex: { method: "GET", path: "/chat/conversations", idempotencyKey: false, customer: true, pagination: "offset" },
|
|
151
|
+
chatConversationsMessagesIndex: { method: "GET", path: "/chat/conversations/{id}/messages", idempotencyKey: false, customer: false, pagination: "cursor" },
|
|
152
|
+
chatConversationsMessagesStore: { method: "POST", path: "/chat/conversations/{id}/messages", idempotencyKey: false, customer: false, pagination: null },
|
|
153
|
+
chatConversationsOperatorRequest: { method: "PUT", path: "/chat/conversations/{id}/operator-request", idempotencyKey: false, customer: false, pagination: null },
|
|
154
|
+
chatConversationsReadMarker: { method: "PUT", path: "/chat/conversations/{id}/read-marker", idempotencyKey: false, customer: false, pagination: null },
|
|
155
|
+
chatConversationsShow: { method: "GET", path: "/chat/conversations/{id}", idempotencyKey: false, customer: false, pagination: null },
|
|
156
|
+
chatConversationsStore: { method: "POST", path: "/chat/conversations", idempotencyKey: false, customer: false, pagination: null },
|
|
157
|
+
checkoutsCompletion: { method: "POST", path: "/checkouts/{id}/completion", idempotencyKey: true, customer: false, pagination: null },
|
|
158
|
+
checkoutsContact: { method: "PUT", path: "/checkouts/{id}/contact", idempotencyKey: false, customer: false, pagination: null },
|
|
159
|
+
checkoutsDeliveryOption: { method: "PUT", path: "/checkouts/{id}/delivery-option", idempotencyKey: false, customer: false, pagination: null },
|
|
160
|
+
checkoutsDeliveryOptions: { method: "GET", path: "/checkouts/{id}/delivery-options", idempotencyKey: false, customer: false, pagination: null },
|
|
161
|
+
checkoutsPaymentMethod: { method: "PUT", path: "/checkouts/{id}/payment-method", idempotencyKey: false, customer: false, pagination: null },
|
|
162
|
+
checkoutsPaymentMethods: { method: "GET", path: "/checkouts/{id}/payment-methods", idempotencyKey: false, customer: false, pagination: null },
|
|
163
|
+
checkoutsPickupLocation: { method: "PUT", path: "/checkouts/{id}/pickup-location", idempotencyKey: false, customer: false, pagination: null },
|
|
164
|
+
checkoutsShippingAddress: { method: "PUT", path: "/checkouts/{id}/shipping-address", idempotencyKey: false, customer: false, pagination: null },
|
|
165
|
+
checkoutsShow: { method: "GET", path: "/checkouts/{id}", idempotencyKey: false, customer: false, pagination: null },
|
|
166
|
+
checkoutsStore: { method: "POST", path: "/checkouts", idempotencyKey: false, customer: false, pagination: null },
|
|
167
|
+
collectionsFilters: { method: "GET", path: "/collections/{handle}/filters", idempotencyKey: false, customer: false, pagination: null },
|
|
168
|
+
collectionsIndex: { method: "GET", path: "/collections", idempotencyKey: false, customer: false, pagination: "offset" },
|
|
169
|
+
collectionsProducts: { method: "GET", path: "/collections/{handle}/products", idempotencyKey: false, customer: false, pagination: "offset" },
|
|
170
|
+
collectionsShow: { method: "GET", path: "/collections/{handle}", idempotencyKey: false, customer: false, pagination: null },
|
|
171
|
+
collectionsTree: { method: "GET", path: "/collections/tree", idempotencyKey: false, customer: false, pagination: null },
|
|
172
|
+
contacts: { method: "GET", path: "/contacts", idempotencyKey: false, customer: false, pagination: null },
|
|
173
|
+
customerAddressesDestroy: { method: "DELETE", path: "/customer/addresses/{addressId}", idempotencyKey: false, customer: true, pagination: null },
|
|
174
|
+
customerAddressesIndex: { method: "GET", path: "/customer/addresses", idempotencyKey: false, customer: true, pagination: null },
|
|
175
|
+
customerAddressesShow: { method: "GET", path: "/customer/addresses/{addressId}", idempotencyKey: false, customer: true, pagination: null },
|
|
176
|
+
customerAddressesStore: { method: "POST", path: "/customer/addresses", idempotencyKey: false, customer: true, pagination: null },
|
|
177
|
+
customerAddressesUpdate: { method: "PUT", path: "/customer/addresses/{addressId}", idempotencyKey: false, customer: true, pagination: null },
|
|
178
|
+
customerAmbassadorPayoutsIndex: { method: "GET", path: "/customer/ambassador/payouts", idempotencyKey: false, customer: true, pagination: "offset" },
|
|
179
|
+
customerAmbassadorPayoutsShow: { method: "GET", path: "/customer/ambassador/payouts/{payoutId}", idempotencyKey: false, customer: true, pagination: null },
|
|
180
|
+
customerAmbassadorPayoutsStore: { method: "POST", path: "/customer/ambassador/payouts", idempotencyKey: true, customer: true, pagination: null },
|
|
181
|
+
customerAmbassadorReferrals: { method: "GET", path: "/customer/ambassador/referrals", idempotencyKey: false, customer: true, pagination: "offset" },
|
|
182
|
+
customerAmbassadorShow: { method: "GET", path: "/customer/ambassador", idempotencyKey: false, customer: true, pagination: null },
|
|
183
|
+
customerAmbassadorStats: { method: "GET", path: "/customer/ambassador/stats", idempotencyKey: false, customer: true, pagination: null },
|
|
184
|
+
customerDeletionRequest: { method: "POST", path: "/customer/deletion-request", idempotencyKey: false, customer: true, pagination: null },
|
|
185
|
+
customerOrdersCancellation: { method: "POST", path: "/customer/orders/{id}/cancellation", idempotencyKey: false, customer: true, pagination: null },
|
|
186
|
+
customerOrdersIndex: { method: "GET", path: "/customer/orders", idempotencyKey: false, customer: true, pagination: "offset" },
|
|
187
|
+
customerOrdersReorder: { method: "POST", path: "/customer/orders/{id}/reorder", idempotencyKey: false, customer: true, pagination: null },
|
|
188
|
+
customerOrdersShow: { method: "GET", path: "/customer/orders/{id}", idempotencyKey: false, customer: true, pagination: null },
|
|
189
|
+
customerPhoneVerification: { method: "POST", path: "/customer/phone-verification", idempotencyKey: false, customer: true, pagination: null },
|
|
190
|
+
customerPreOrdersIndex: { method: "GET", path: "/customer/pre-orders", idempotencyKey: false, customer: true, pagination: "offset" },
|
|
191
|
+
customerPreOrdersShow: { method: "GET", path: "/customer/pre-orders/{id}", idempotencyKey: false, customer: true, pagination: null },
|
|
192
|
+
customerReferralInvitees: { method: "GET", path: "/customer/referral/invitees", idempotencyKey: false, customer: true, pagination: "offset" },
|
|
193
|
+
customerReferralShow: { method: "GET", path: "/customer/referral", idempotencyKey: false, customer: true, pagination: null },
|
|
194
|
+
customerReviewsAwaiting: { method: "GET", path: "/customer/reviews/awaiting", idempotencyKey: false, customer: true, pagination: null },
|
|
195
|
+
customerReviewsIndex: { method: "GET", path: "/customer/reviews", idempotencyKey: false, customer: true, pagination: "offset" },
|
|
196
|
+
customerRewardsDiscountCodesIndex: { method: "GET", path: "/customer/rewards/discount-codes", idempotencyKey: false, customer: true, pagination: "offset" },
|
|
197
|
+
customerRewardsDiscountCodesShow: { method: "GET", path: "/customer/rewards/discount-codes/{id}", idempotencyKey: false, customer: true, pagination: null },
|
|
198
|
+
customerRewardsRedemptionsStore: { method: "POST", path: "/customer/rewards/redemptions", idempotencyKey: true, customer: true, pagination: null },
|
|
199
|
+
customerShow: { method: "GET", path: "/customer", idempotencyKey: false, customer: true, pagination: null },
|
|
200
|
+
customerUpdate: { method: "PATCH", path: "/customer", idempotencyKey: false, customer: true, pagination: null },
|
|
201
|
+
customerWalletActivities: { method: "GET", path: "/customer/wallet/activities", idempotencyKey: false, customer: true, pagination: "offset" },
|
|
202
|
+
customerWalletShow: { method: "GET", path: "/customer/wallet", idempotencyKey: false, customer: true, pagination: null },
|
|
203
|
+
customerWishlistAdd: { method: "PUT", path: "/customer/wishlist/{productId}", idempotencyKey: false, customer: true, pagination: null },
|
|
204
|
+
customerWishlistIndex: { method: "GET", path: "/customer/wishlist", idempotencyKey: false, customer: true, pagination: "offset" },
|
|
205
|
+
customerWishlistRemove: { method: "DELETE", path: "/customer/wishlist/{productId}", idempotencyKey: false, customer: true, pagination: null },
|
|
206
|
+
home: { method: "GET", path: "/home", idempotencyKey: false, customer: false, pagination: null },
|
|
207
|
+
locationsIndex: { method: "GET", path: "/locations", idempotencyKey: false, customer: false, pagination: null },
|
|
208
|
+
mediaUploadsStore: { method: "POST", path: "/media/uploads", idempotencyKey: false, customer: true, pagination: null },
|
|
209
|
+
menusShow: { method: "GET", path: "/menus/{handle}", idempotencyKey: false, customer: false, pagination: null },
|
|
210
|
+
ordersPayment: { method: "GET", path: "/orders/{id}/payment", idempotencyKey: false, customer: false, pagination: null },
|
|
211
|
+
ordersPaymentLink: { method: "POST", path: "/orders/{id}/payment-link", idempotencyKey: true, customer: false, pagination: null },
|
|
212
|
+
pagesIndex: { method: "GET", path: "/pages", idempotencyKey: false, customer: false, pagination: null },
|
|
213
|
+
pagesShow: { method: "GET", path: "/pages/{handle}", idempotencyKey: false, customer: false, pagination: null },
|
|
214
|
+
ping: { method: "GET", path: "/ping", idempotencyKey: false, customer: false, pagination: null },
|
|
215
|
+
preOrdersStore: { method: "POST", path: "/pre-orders", idempotencyKey: false, customer: false, pagination: null },
|
|
216
|
+
productsIndex: { method: "GET", path: "/products", idempotencyKey: false, customer: false, pagination: "offset" },
|
|
217
|
+
productsRecommendations: { method: "GET", path: "/products/{handle}/recommendations", idempotencyKey: false, customer: false, pagination: null },
|
|
218
|
+
productsReviews: { method: "GET", path: "/products/{handle}/reviews", idempotencyKey: false, customer: false, pagination: "offset" },
|
|
219
|
+
productsShow: { method: "GET", path: "/products/{handle}", idempotencyKey: false, customer: false, pagination: null },
|
|
220
|
+
realtimeAuthorizationsStore: { method: "POST", path: "/realtime/authorizations", idempotencyKey: false, customer: false, pagination: null },
|
|
221
|
+
reelsIndex: { method: "GET", path: "/reels", idempotencyKey: false, customer: false, pagination: "offset" },
|
|
222
|
+
referralProgram: { method: "GET", path: "/referral-program", idempotencyKey: false, customer: false, pagination: null },
|
|
223
|
+
reviewsLike: { method: "PUT", path: "/reviews/{id}/like", idempotencyKey: false, customer: true, pagination: null },
|
|
224
|
+
reviewsSite: { method: "GET", path: "/reviews/site", idempotencyKey: false, customer: false, pagination: "offset" },
|
|
225
|
+
reviewsSiteStore: { method: "POST", path: "/reviews/site", idempotencyKey: false, customer: true, pagination: null },
|
|
226
|
+
reviewsStore: { method: "POST", path: "/reviews", idempotencyKey: false, customer: true, pagination: null },
|
|
227
|
+
reviewsUnlike: { method: "DELETE", path: "/reviews/{id}/like", idempotencyKey: false, customer: true, pagination: null },
|
|
228
|
+
rewardsEarningRules: { method: "GET", path: "/rewards/earning-rules", idempotencyKey: false, customer: false, pagination: null },
|
|
229
|
+
rewardsSpendingRules: { method: "GET", path: "/rewards/spending-rules", idempotencyKey: false, customer: false, pagination: null },
|
|
230
|
+
search: { method: "GET", path: "/search", idempotencyKey: false, customer: false, pagination: "offset" },
|
|
231
|
+
searchFilters: { method: "GET", path: "/search/filters", idempotencyKey: false, customer: false, pagination: null },
|
|
232
|
+
searchSuggestions: { method: "GET", path: "/search/suggestions", idempotencyKey: false, customer: false, pagination: null },
|
|
233
|
+
searchTrending: { method: "GET", path: "/search/trending", idempotencyKey: false, customer: false, pagination: null },
|
|
234
|
+
shop: { method: "GET", path: "/shop", idempotencyKey: false, customer: false, pagination: null },
|
|
235
|
+
sitemap: { method: "GET", path: "/sitemap", idempotencyKey: false, customer: false, pagination: "offset" },
|
|
236
|
+
themeSectionSchema: { method: "GET", path: "/theme/section-schema", idempotencyKey: false, customer: false, pagination: null }
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// src/pagination.ts
|
|
240
|
+
async function* paginate(call, operationId, style, [input, options]) {
|
|
241
|
+
const base = input ?? {};
|
|
242
|
+
let query = { ...base.query };
|
|
243
|
+
for (; ; ) {
|
|
244
|
+
const args = [{ ...base, query }, options];
|
|
245
|
+
const body = await call(operationId, ...args);
|
|
246
|
+
for (const item of body.data ?? []) {
|
|
247
|
+
yield item;
|
|
248
|
+
}
|
|
249
|
+
if (style === "offset") {
|
|
250
|
+
const pagination = body.meta?.pagination;
|
|
251
|
+
if (!pagination?.hasNextPage) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
query = { ...query, page: pagination.page + 1 };
|
|
255
|
+
} else {
|
|
256
|
+
const cursor = body.meta?.cursor;
|
|
257
|
+
if (!cursor?.hasNextPage || cursor.next === null) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
query = { ...query, cursor: cursor.next };
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/client.ts
|
|
266
|
+
var RETRYABLE_STATUS = (status) => status === 429 || status >= 500;
|
|
267
|
+
function createStorefrontClient(options) {
|
|
268
|
+
const baseUrl = resolveBaseUrl(options);
|
|
269
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
270
|
+
const retry = options.retry === false ? null : {
|
|
271
|
+
retries: options.retry?.retries ?? 2,
|
|
272
|
+
baseDelayMs: options.retry?.baseDelayMs ?? 300,
|
|
273
|
+
maxDelayMs: options.retry?.maxDelayMs ?? 1e4
|
|
274
|
+
};
|
|
275
|
+
const transport = (0, import_openapi_fetch.default)({
|
|
276
|
+
baseUrl,
|
|
277
|
+
// Resolved on each call: a test (or an app) may swap the global fetch later.
|
|
278
|
+
fetch: (request) => fetchImpl(request)
|
|
279
|
+
});
|
|
280
|
+
async function call(operationId, ...[input, requestOptions]) {
|
|
281
|
+
const operation = operationTable[operationId];
|
|
282
|
+
if (operation === void 0) {
|
|
283
|
+
throw new TypeError(`Unknown Storefront API operation: ${String(operationId)}`);
|
|
284
|
+
}
|
|
285
|
+
const request = input ?? {};
|
|
286
|
+
const perCall = requestOptions ?? {};
|
|
287
|
+
const requestId = perCall.requestId ?? randomId();
|
|
288
|
+
const idempotencyKey = operation.idempotencyKey ? perCall.idempotencyKey ?? randomId() : void 0;
|
|
289
|
+
const headers = await buildHeaders(request, perCall, requestId, idempotencyKey);
|
|
290
|
+
const tries = operation.method === "GET" && retry !== null ? retry.retries + 1 : 1;
|
|
291
|
+
for (let attempt = 1; ; attempt++) {
|
|
292
|
+
let result;
|
|
293
|
+
try {
|
|
294
|
+
result = await transport.request(
|
|
295
|
+
operation.method,
|
|
296
|
+
operation.path,
|
|
297
|
+
{
|
|
298
|
+
params: { path: request.path, query: request.query },
|
|
299
|
+
body: request.body,
|
|
300
|
+
headers,
|
|
301
|
+
signal: perCall.signal
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
} catch (cause) {
|
|
305
|
+
const aborted = perCall.signal?.aborted === true;
|
|
306
|
+
if (!aborted && attempt < tries) {
|
|
307
|
+
await sleep(backoff(attempt, retry), perCall.signal);
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
throw MagicStoreError.fromFailure(cause, { requestId, idempotencyKey, aborted });
|
|
311
|
+
}
|
|
312
|
+
const { response } = result;
|
|
313
|
+
if (response.ok) {
|
|
314
|
+
return response.status === 204 ? void 0 : result.data;
|
|
315
|
+
}
|
|
316
|
+
const error = MagicStoreError.fromResponse(response, result.error, {
|
|
317
|
+
requestId,
|
|
318
|
+
idempotencyKey
|
|
319
|
+
});
|
|
320
|
+
if (attempt < tries && RETRYABLE_STATUS(response.status)) {
|
|
321
|
+
const wait = error.retryAfter !== void 0 ? error.retryAfter * 1e3 : backoff(attempt, retry);
|
|
322
|
+
if (wait <= retry.maxDelayMs) {
|
|
323
|
+
await sleep(wait, perCall.signal);
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
async function buildHeaders(request, perCall, requestId, idempotencyKey) {
|
|
331
|
+
const headers = { Accept: "application/json", ...options.headers };
|
|
332
|
+
if (options.storefrontToken) {
|
|
333
|
+
headers["X-Storefront-Token"] = options.storefrontToken;
|
|
334
|
+
}
|
|
335
|
+
const locale = perCall.locale ?? options.locale;
|
|
336
|
+
if (locale) {
|
|
337
|
+
headers["Accept-Language"] = locale;
|
|
338
|
+
}
|
|
339
|
+
const token = perCall.customerToken !== void 0 ? perCall.customerToken : await readToken(options.customerToken);
|
|
340
|
+
if (token) {
|
|
341
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
342
|
+
}
|
|
343
|
+
for (const [name, value] of Object.entries(request.header ?? {})) {
|
|
344
|
+
if (value !== void 0 && value !== null) {
|
|
345
|
+
headers[name] = String(value);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
headers["X-Request-Id"] = requestId;
|
|
349
|
+
if (idempotencyKey !== void 0) {
|
|
350
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
351
|
+
}
|
|
352
|
+
return { ...headers, ...perCall.headers };
|
|
353
|
+
}
|
|
354
|
+
const client = { call };
|
|
355
|
+
client.paginate = (operationId, ...args) => paginate(call, operationId, operationTable[operationId].pagination, args);
|
|
356
|
+
for (const operationId of Object.keys(operationTable)) {
|
|
357
|
+
client[operationId] = (...args) => call(operationId, ...args);
|
|
358
|
+
}
|
|
359
|
+
return client;
|
|
360
|
+
}
|
|
361
|
+
function operationInput(_operationId, input) {
|
|
362
|
+
return input;
|
|
363
|
+
}
|
|
364
|
+
function resolveBaseUrl(options) {
|
|
365
|
+
if (options.baseUrl) {
|
|
366
|
+
return options.baseUrl.replace(/\/+$/, "");
|
|
367
|
+
}
|
|
368
|
+
if (options.shopDomain) {
|
|
369
|
+
const host = options.shopDomain.replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
370
|
+
return `https://${host}/api/v2/storefront`;
|
|
371
|
+
}
|
|
372
|
+
throw new TypeError("createStorefrontClient needs a shopDomain or a baseUrl.");
|
|
373
|
+
}
|
|
374
|
+
async function readToken(source) {
|
|
375
|
+
if (typeof source === "function") {
|
|
376
|
+
return await source() ?? null;
|
|
377
|
+
}
|
|
378
|
+
return source ?? null;
|
|
379
|
+
}
|
|
380
|
+
function randomId() {
|
|
381
|
+
return globalThis.crypto.randomUUID();
|
|
382
|
+
}
|
|
383
|
+
function backoff(attempt, retry) {
|
|
384
|
+
const ceiling = Math.min(retry.maxDelayMs, retry.baseDelayMs * 2 ** (attempt - 1));
|
|
385
|
+
return Math.round(Math.random() * ceiling);
|
|
386
|
+
}
|
|
387
|
+
function sleep(ms, signal) {
|
|
388
|
+
return new Promise((resolve, reject) => {
|
|
389
|
+
if (signal?.aborted) {
|
|
390
|
+
reject(signal.reason);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const timer = setTimeout(() => {
|
|
394
|
+
signal?.removeEventListener("abort", onAbort);
|
|
395
|
+
resolve();
|
|
396
|
+
}, ms);
|
|
397
|
+
const onAbort = () => {
|
|
398
|
+
clearTimeout(timer);
|
|
399
|
+
reject(signal?.reason);
|
|
400
|
+
};
|
|
401
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
405
|
+
0 && (module.exports = {
|
|
406
|
+
API_VERSION,
|
|
407
|
+
MagicStoreError,
|
|
408
|
+
createStorefrontClient,
|
|
409
|
+
operationInput,
|
|
410
|
+
operationTable,
|
|
411
|
+
retryAfterSeconds
|
|
412
|
+
});
|
|
413
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/errors.ts","../src/generated/operations.ts","../src/pagination.ts"],"sourcesContent":["export { createStorefrontClient, operationInput } from './client';\nexport type {\n CustomerTokenSource,\n RetryOptions,\n StorefrontClient,\n StorefrontClientOptions,\n} from './client';\nexport { MagicStoreError, retryAfterSeconds } from './errors';\nexport type { ClientErrorCode, MagicStoreErrorCode, ProblemFieldError } from './errors';\nexport { API_VERSION, operationTable } from './generated/operations';\nexport type { components, operations, paths } from './generated/schema';\nexport type {\n OperationArgs,\n OperationId,\n OperationInput,\n OperationMethods,\n OperationResult,\n PageItem,\n PaginatedOperationId,\n Problem,\n ProblemCode,\n RequestOptions,\n} from './types';\n\nimport type { components } from './generated/schema';\n\n/** The API's resource shapes by name: `Schema<'Product'>`, `Schema<'Cart'>`, … */\nexport type Schema<Name extends keyof components['schemas']> = components['schemas'][Name];\n","import createClient from 'openapi-fetch';\nimport { MagicStoreError } from './errors';\nimport { operationTable } from './generated/operations';\nimport type { paths } from './generated/schema';\nimport { paginate } from './pagination';\nimport type {\n OperationArgs,\n OperationId,\n OperationInput,\n OperationMethods,\n OperationResult,\n PageItem,\n PaginatedOperationId,\n RequestOptions,\n} from './types';\n\n/** A customer access token, or where to read it from on every call (it rotates hourly). */\nexport type CustomerTokenSource =\n string | null | (() => string | null | undefined | Promise<string | null | undefined>);\n\nexport interface RetryOptions {\n /** Retries after the first try. Default 2. */\n retries?: number;\n /** First backoff; doubled per retry, with jitter. Default 300 ms. */\n baseDelayMs?: number;\n /** Longest wait between tries — a longer `Retry-After` is not waited out. Default 10 s. */\n maxDelayMs?: number;\n}\n\nexport interface StorefrontClientOptions {\n /** The shop's storefront domain, e.g. `shop.example.uz` → `https://shop.example.uz/api/v2/storefront`. */\n shopDomain?: string;\n /** The full API base URL, instead of `shopDomain`. */\n baseUrl?: string;\n /** `X-Storefront-Token` — identifies the shop when the host is not one of its domains. */\n storefrontToken?: string;\n /** Default language (`Accept-Language`); the shop's default when omitted. */\n locale?: string;\n /** The signed-in customer, sent as `Authorization: Bearer` when present. */\n customerToken?: CustomerTokenSource;\n /**\n * Retry policy for `GET`s answered `429` or `5xx`, or not answered at all. Writes are never\n * retried by the client. `false` turns retries off.\n */\n retry?: RetryOptions | false;\n /** A `fetch` implementation; the global one by default. */\n fetch?: typeof globalThis.fetch;\n /** Headers sent on every call. */\n headers?: Record<string, string>;\n}\n\nexport type StorefrontClient = OperationMethods & {\n /** Calls an operation by its `operationId` — what every named method does. */\n call<K extends OperationId>(\n operationId: K,\n ...args: OperationArgs<K>\n ): Promise<OperationResult<K>>;\n /**\n * Every item of a paginated operation, page after page (`page` for offset operations,\n * `cursor` for feeds). Stops when the API says there is no next page.\n */\n paginate<K extends PaginatedOperationId>(\n operationId: K,\n ...args: OperationArgs<K>\n ): AsyncGenerator<PageItem<K>, void, undefined>;\n};\n\ninterface OperationRequest {\n path?: Record<string, unknown>;\n query?: Record<string, unknown>;\n header?: Record<string, unknown>;\n body?: unknown;\n}\n\nconst RETRYABLE_STATUS = (status: number): boolean => status === 429 || status >= 500;\n\nexport function createStorefrontClient(options: StorefrontClientOptions): StorefrontClient {\n const baseUrl = resolveBaseUrl(options);\n const fetchImpl = options.fetch ?? globalThis.fetch;\n const retry =\n options.retry === false\n ? null\n : {\n retries: options.retry?.retries ?? 2,\n baseDelayMs: options.retry?.baseDelayMs ?? 300,\n maxDelayMs: options.retry?.maxDelayMs ?? 10_000,\n };\n\n const transport = createClient<paths>({\n baseUrl,\n // Resolved on each call: a test (or an app) may swap the global fetch later.\n fetch: (request) => fetchImpl(request),\n });\n\n async function call<K extends OperationId>(\n operationId: K,\n ...[input, requestOptions]: OperationArgs<K>\n ): Promise<OperationResult<K>> {\n const operation = operationTable[operationId];\n if (operation === undefined) {\n throw new TypeError(`Unknown Storefront API operation: ${String(operationId)}`);\n }\n\n const request = (input ?? {}) as OperationRequest;\n const perCall: RequestOptions = requestOptions ?? {};\n const requestId = perCall.requestId ?? randomId();\n const idempotencyKey = operation.idempotencyKey\n ? (perCall.idempotencyKey ?? randomId())\n : undefined;\n const headers = await buildHeaders(request, perCall, requestId, idempotencyKey);\n const tries = operation.method === 'GET' && retry !== null ? retry.retries + 1 : 1;\n\n for (let attempt = 1; ; attempt++) {\n let result: { data?: unknown; error?: unknown; response: Response };\n try {\n result = await transport.request(\n operation.method as never,\n operation.path as never,\n {\n params: { path: request.path, query: request.query },\n body: request.body,\n headers,\n signal: perCall.signal,\n } as never,\n );\n } catch (cause) {\n const aborted = perCall.signal?.aborted === true;\n if (!aborted && attempt < tries) {\n await sleep(backoff(attempt, retry!), perCall.signal);\n continue;\n }\n throw MagicStoreError.fromFailure(cause, { requestId, idempotencyKey, aborted });\n }\n\n const { response } = result;\n if (response.ok) {\n return (response.status === 204 ? undefined : result.data) as OperationResult<K>;\n }\n\n const error = MagicStoreError.fromResponse(response, result.error, {\n requestId,\n idempotencyKey,\n });\n if (attempt < tries && RETRYABLE_STATUS(response.status)) {\n const wait =\n error.retryAfter !== undefined ? error.retryAfter * 1000 : backoff(attempt, retry!);\n if (wait <= retry!.maxDelayMs) {\n await sleep(wait, perCall.signal);\n continue;\n }\n }\n throw error;\n }\n }\n\n async function buildHeaders(\n request: OperationRequest,\n perCall: RequestOptions,\n requestId: string,\n idempotencyKey: string | undefined,\n ): Promise<Record<string, string>> {\n const headers: Record<string, string> = { Accept: 'application/json', ...options.headers };\n\n if (options.storefrontToken) {\n headers['X-Storefront-Token'] = options.storefrontToken;\n }\n const locale = perCall.locale ?? options.locale;\n if (locale) {\n headers['Accept-Language'] = locale;\n }\n const token =\n perCall.customerToken !== undefined\n ? perCall.customerToken\n : await readToken(options.customerToken);\n if (token) {\n headers['Authorization'] = `Bearer ${token}`;\n }\n for (const [name, value] of Object.entries(request.header ?? {})) {\n if (value !== undefined && value !== null) {\n headers[name] = String(value);\n }\n }\n headers['X-Request-Id'] = requestId;\n if (idempotencyKey !== undefined) {\n headers['Idempotency-Key'] = idempotencyKey;\n }\n\n return { ...headers, ...perCall.headers };\n }\n\n const client = { call } as StorefrontClient;\n client.paginate = <K extends PaginatedOperationId>(operationId: K, ...args: OperationArgs<K>) =>\n paginate(call, operationId, operationTable[operationId].pagination, args);\n\n for (const operationId of Object.keys(operationTable) as OperationId[]) {\n (client as unknown as Record<string, unknown>)[operationId] = (\n ...args: OperationArgs<typeof operationId>\n ) => call(operationId, ...args);\n }\n\n return client;\n}\n\n/** For callers that build an input apart from the call. */\nexport function operationInput<K extends OperationId>(\n _operationId: K,\n input: OperationInput<K>,\n): OperationInput<K> {\n return input;\n}\n\nfunction resolveBaseUrl(options: StorefrontClientOptions): string {\n if (options.baseUrl) {\n return options.baseUrl.replace(/\\/+$/, '');\n }\n if (options.shopDomain) {\n const host = options.shopDomain.replace(/^https?:\\/\\//, '').replace(/\\/+$/, '');\n return `https://${host}/api/v2/storefront`;\n }\n throw new TypeError('createStorefrontClient needs a shopDomain or a baseUrl.');\n}\n\nasync function readToken(source: CustomerTokenSource | undefined): Promise<string | null> {\n if (typeof source === 'function') {\n return (await source()) ?? null;\n }\n return source ?? null;\n}\n\nfunction randomId(): string {\n return globalThis.crypto.randomUUID();\n}\n\n/** Exponential backoff with full jitter: a random wait up to base × 2^(attempt-1), capped. */\nfunction backoff(attempt: number, retry: Required<RetryOptions>): number {\n const ceiling = Math.min(retry.maxDelayMs, retry.baseDelayMs * 2 ** (attempt - 1));\n return Math.round(Math.random() * ceiling);\n}\n\nfunction sleep(ms: number, signal: AbortSignal | undefined): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(signal.reason);\n return;\n }\n const timer = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n const onAbort = (): void => {\n clearTimeout(timer);\n reject(signal?.reason);\n };\n signal?.addEventListener('abort', onAbort, { once: true });\n });\n}\n","import type { Problem, ProblemCode } from './types';\n\n/** No answer at all: the network failed, or the call was aborted. Never sent by the API. */\nexport type ClientErrorCode = 'NETWORK_ERROR' | 'ABORTED';\n\nexport type MagicStoreErrorCode = ProblemCode | ClientErrorCode;\n\n/** One failed rule on a validation failure or a per-line conflict. */\nexport type ProblemFieldError = NonNullable<Problem['errors']>[number];\n\nconst CODE_BY_STATUS: Record<number, ProblemCode> = {\n 400: 'BAD_REQUEST',\n 401: 'UNAUTHENTICATED',\n 403: 'FORBIDDEN',\n 404: 'NOT_FOUND',\n 405: 'METHOD_NOT_ALLOWED',\n 413: 'PAYLOAD_TOO_LARGE',\n 422: 'VALIDATION_FAILED',\n 429: 'RATE_LIMITED',\n 503: 'SERVICE_UNAVAILABLE',\n};\n\n/**\n * Every failed call. `code` is what to branch on — never the message, which is localized.\n *\n * ```ts\n * try {\n * await client.checkoutsCompletion({ path: { id } });\n * } catch (error) {\n * if (error instanceof MagicStoreError && error.code === 'CHECKOUT_NOT_READY') { … }\n * }\n * ```\n */\nexport class MagicStoreError extends Error {\n override readonly name = 'MagicStoreError';\n\n /** HTTP status; `0` when no answer arrived. */\n readonly status: number;\n\n /** An API `code` (open to new values), or `NETWORK_ERROR` / `ABORTED`. */\n readonly code: MagicStoreErrorCode | (string & {});\n\n /** Localized, safe to show to a customer — when the API sent one. */\n readonly detail: string | undefined;\n\n /** Per-field failures on `VALIDATION_FAILED` and per-line conflicts. */\n readonly errors: ProblemFieldError[];\n\n /** `X-Request-Id` of the call. Quote it when reporting a problem. */\n readonly requestId: string;\n\n /** Seconds to wait before trying again (`Retry-After`), when the API said. */\n readonly retryAfter: number | undefined;\n\n /** The key a money-moving call was sent with: retry with the same one. */\n readonly idempotencyKey: string | undefined;\n\n /** The problem document as received, when there was one. */\n readonly problem: Partial<Problem> | undefined;\n\n constructor(init: {\n status: number;\n code: MagicStoreErrorCode | (string & {});\n message: string;\n requestId: string;\n detail?: string | undefined;\n errors?: ProblemFieldError[] | undefined;\n retryAfter?: number | undefined;\n idempotencyKey?: string | undefined;\n problem?: Partial<Problem> | undefined;\n cause?: unknown;\n }) {\n super(init.message, init.cause === undefined ? undefined : { cause: init.cause });\n this.status = init.status;\n this.code = init.code;\n this.detail = init.detail;\n this.errors = init.errors ?? [];\n this.requestId = init.requestId;\n this.retryAfter = init.retryAfter;\n this.idempotencyKey = init.idempotencyKey;\n this.problem = init.problem;\n }\n\n /** From a non-2xx answer. A body that is not a problem document still yields a code. */\n static fromResponse(\n response: Response,\n body: unknown,\n context: { requestId: string; idempotencyKey?: string | undefined },\n ): MagicStoreError {\n const problem = isRecord(body) ? (body as Partial<Problem>) : undefined;\n const code =\n typeof problem?.code === 'string'\n ? problem.code\n : (CODE_BY_STATUS[response.status] ??\n (response.status >= 500 ? 'INTERNAL_ERROR' : 'BAD_REQUEST'));\n const requestId =\n (typeof problem?.requestId === 'string' ? problem.requestId : undefined) ??\n response.headers.get('X-Request-Id') ??\n context.requestId;\n\n return new MagicStoreError({\n status: response.status,\n code,\n message: problem?.title ?? `${response.status} ${code}`,\n detail: problem?.detail,\n errors: Array.isArray(problem?.errors) ? problem.errors : undefined,\n requestId,\n retryAfter: retryAfterSeconds(response),\n idempotencyKey: context.idempotencyKey,\n problem,\n });\n }\n\n /** No answer: the request never completed. */\n static fromFailure(\n cause: unknown,\n context: { requestId: string; idempotencyKey?: string | undefined; aborted: boolean },\n ): MagicStoreError {\n return new MagicStoreError({\n status: 0,\n code: context.aborted ? 'ABORTED' : 'NETWORK_ERROR',\n message: context.aborted ? 'The request was aborted.' : 'The request did not complete.',\n requestId: context.requestId,\n idempotencyKey: context.idempotencyKey,\n cause,\n });\n }\n}\n\n/** `Retry-After` as delta-seconds (the API never sends an HTTP date). */\nexport function retryAfterSeconds(response: Response): number | undefined {\n const value = response.headers.get('Retry-After');\n if (value === null) {\n return undefined;\n }\n const seconds = Number(value);\n return Number.isFinite(seconds) && seconds >= 0 ? seconds : undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","// Generated by scripts/generate-operations.mjs from spec/storefront-v2.json — do not edit.\n// Storefront API 2.0.0-alpha.1, 107 operations.\n\nexport const API_VERSION = '2.0.0-alpha.1';\n\nexport const operationTable = {\n analyticsEventsStore: { method: 'POST', path: '/analytics/events', idempotencyKey: false, customer: false, pagination: null },\n authClick: { method: 'POST', path: '/auth/click', idempotencyKey: false, customer: false, pagination: null },\n authOq: { method: 'POST', path: '/auth/oq', idempotencyKey: false, customer: false, pagination: null },\n authOtp: { method: 'POST', path: '/auth/otp', idempotencyKey: false, customer: false, pagination: null },\n authOtpVerification: { method: 'POST', path: '/auth/otp/verification', idempotencyKey: false, customer: false, pagination: null },\n authTelegram: { method: 'POST', path: '/auth/telegram', idempotencyKey: false, customer: false, pagination: null },\n authTokenDestroy: { method: 'DELETE', path: '/auth/token', idempotencyKey: false, customer: true, pagination: null },\n authTokenRefresh: { method: 'POST', path: '/auth/token/refresh', idempotencyKey: false, customer: false, pagination: null },\n cartsAttributes: { method: 'PUT', path: '/carts/{id}/attributes', idempotencyKey: false, customer: false, pagination: null },\n cartsBuyerIdentity: { method: 'PUT', path: '/carts/{id}/buyer-identity', idempotencyKey: false, customer: true, pagination: null },\n cartsDiscountCodes: { method: 'PUT', path: '/carts/{id}/discount-codes', idempotencyKey: false, customer: false, pagination: null },\n cartsGift: { method: 'PUT', path: '/carts/{id}/gift', idempotencyKey: false, customer: false, pagination: null },\n cartsLinesDestroy: { method: 'DELETE', path: '/carts/{id}/lines/{lineId}', idempotencyKey: false, customer: false, pagination: null },\n cartsLinesStore: { method: 'POST', path: '/carts/{id}/lines', idempotencyKey: false, customer: false, pagination: null },\n cartsLinesUpdate: { method: 'PATCH', path: '/carts/{id}/lines/{lineId}', idempotencyKey: false, customer: false, pagination: null },\n cartsNote: { method: 'PUT', path: '/carts/{id}/note', idempotencyKey: false, customer: false, pagination: null },\n cartsPoints: { method: 'PUT', path: '/carts/{id}/points', idempotencyKey: false, customer: true, pagination: null },\n cartsShow: { method: 'GET', path: '/carts/{id}', idempotencyKey: false, customer: false, pagination: null },\n cartsStore: { method: 'POST', path: '/carts', idempotencyKey: false, customer: false, pagination: null },\n chatConversationsCustomer: { method: 'PUT', path: '/chat/conversations/{id}/customer', idempotencyKey: false, customer: true, pagination: null },\n chatConversationsIndex: { method: 'GET', path: '/chat/conversations', idempotencyKey: false, customer: true, pagination: 'offset' },\n chatConversationsMessagesIndex: { method: 'GET', path: '/chat/conversations/{id}/messages', idempotencyKey: false, customer: false, pagination: 'cursor' },\n chatConversationsMessagesStore: { method: 'POST', path: '/chat/conversations/{id}/messages', idempotencyKey: false, customer: false, pagination: null },\n chatConversationsOperatorRequest: { method: 'PUT', path: '/chat/conversations/{id}/operator-request', idempotencyKey: false, customer: false, pagination: null },\n chatConversationsReadMarker: { method: 'PUT', path: '/chat/conversations/{id}/read-marker', idempotencyKey: false, customer: false, pagination: null },\n chatConversationsShow: { method: 'GET', path: '/chat/conversations/{id}', idempotencyKey: false, customer: false, pagination: null },\n chatConversationsStore: { method: 'POST', path: '/chat/conversations', idempotencyKey: false, customer: false, pagination: null },\n checkoutsCompletion: { method: 'POST', path: '/checkouts/{id}/completion', idempotencyKey: true, customer: false, pagination: null },\n checkoutsContact: { method: 'PUT', path: '/checkouts/{id}/contact', idempotencyKey: false, customer: false, pagination: null },\n checkoutsDeliveryOption: { method: 'PUT', path: '/checkouts/{id}/delivery-option', idempotencyKey: false, customer: false, pagination: null },\n checkoutsDeliveryOptions: { method: 'GET', path: '/checkouts/{id}/delivery-options', idempotencyKey: false, customer: false, pagination: null },\n checkoutsPaymentMethod: { method: 'PUT', path: '/checkouts/{id}/payment-method', idempotencyKey: false, customer: false, pagination: null },\n checkoutsPaymentMethods: { method: 'GET', path: '/checkouts/{id}/payment-methods', idempotencyKey: false, customer: false, pagination: null },\n checkoutsPickupLocation: { method: 'PUT', path: '/checkouts/{id}/pickup-location', idempotencyKey: false, customer: false, pagination: null },\n checkoutsShippingAddress: { method: 'PUT', path: '/checkouts/{id}/shipping-address', idempotencyKey: false, customer: false, pagination: null },\n checkoutsShow: { method: 'GET', path: '/checkouts/{id}', idempotencyKey: false, customer: false, pagination: null },\n checkoutsStore: { method: 'POST', path: '/checkouts', idempotencyKey: false, customer: false, pagination: null },\n collectionsFilters: { method: 'GET', path: '/collections/{handle}/filters', idempotencyKey: false, customer: false, pagination: null },\n collectionsIndex: { method: 'GET', path: '/collections', idempotencyKey: false, customer: false, pagination: 'offset' },\n collectionsProducts: { method: 'GET', path: '/collections/{handle}/products', idempotencyKey: false, customer: false, pagination: 'offset' },\n collectionsShow: { method: 'GET', path: '/collections/{handle}', idempotencyKey: false, customer: false, pagination: null },\n collectionsTree: { method: 'GET', path: '/collections/tree', idempotencyKey: false, customer: false, pagination: null },\n contacts: { method: 'GET', path: '/contacts', idempotencyKey: false, customer: false, pagination: null },\n customerAddressesDestroy: { method: 'DELETE', path: '/customer/addresses/{addressId}', idempotencyKey: false, customer: true, pagination: null },\n customerAddressesIndex: { method: 'GET', path: '/customer/addresses', idempotencyKey: false, customer: true, pagination: null },\n customerAddressesShow: { method: 'GET', path: '/customer/addresses/{addressId}', idempotencyKey: false, customer: true, pagination: null },\n customerAddressesStore: { method: 'POST', path: '/customer/addresses', idempotencyKey: false, customer: true, pagination: null },\n customerAddressesUpdate: { method: 'PUT', path: '/customer/addresses/{addressId}', idempotencyKey: false, customer: true, pagination: null },\n customerAmbassadorPayoutsIndex: { method: 'GET', path: '/customer/ambassador/payouts', idempotencyKey: false, customer: true, pagination: 'offset' },\n customerAmbassadorPayoutsShow: { method: 'GET', path: '/customer/ambassador/payouts/{payoutId}', idempotencyKey: false, customer: true, pagination: null },\n customerAmbassadorPayoutsStore: { method: 'POST', path: '/customer/ambassador/payouts', idempotencyKey: true, customer: true, pagination: null },\n customerAmbassadorReferrals: { method: 'GET', path: '/customer/ambassador/referrals', idempotencyKey: false, customer: true, pagination: 'offset' },\n customerAmbassadorShow: { method: 'GET', path: '/customer/ambassador', idempotencyKey: false, customer: true, pagination: null },\n customerAmbassadorStats: { method: 'GET', path: '/customer/ambassador/stats', idempotencyKey: false, customer: true, pagination: null },\n customerDeletionRequest: { method: 'POST', path: '/customer/deletion-request', idempotencyKey: false, customer: true, pagination: null },\n customerOrdersCancellation: { method: 'POST', path: '/customer/orders/{id}/cancellation', idempotencyKey: false, customer: true, pagination: null },\n customerOrdersIndex: { method: 'GET', path: '/customer/orders', idempotencyKey: false, customer: true, pagination: 'offset' },\n customerOrdersReorder: { method: 'POST', path: '/customer/orders/{id}/reorder', idempotencyKey: false, customer: true, pagination: null },\n customerOrdersShow: { method: 'GET', path: '/customer/orders/{id}', idempotencyKey: false, customer: true, pagination: null },\n customerPhoneVerification: { method: 'POST', path: '/customer/phone-verification', idempotencyKey: false, customer: true, pagination: null },\n customerPreOrdersIndex: { method: 'GET', path: '/customer/pre-orders', idempotencyKey: false, customer: true, pagination: 'offset' },\n customerPreOrdersShow: { method: 'GET', path: '/customer/pre-orders/{id}', idempotencyKey: false, customer: true, pagination: null },\n customerReferralInvitees: { method: 'GET', path: '/customer/referral/invitees', idempotencyKey: false, customer: true, pagination: 'offset' },\n customerReferralShow: { method: 'GET', path: '/customer/referral', idempotencyKey: false, customer: true, pagination: null },\n customerReviewsAwaiting: { method: 'GET', path: '/customer/reviews/awaiting', idempotencyKey: false, customer: true, pagination: null },\n customerReviewsIndex: { method: 'GET', path: '/customer/reviews', idempotencyKey: false, customer: true, pagination: 'offset' },\n customerRewardsDiscountCodesIndex: { method: 'GET', path: '/customer/rewards/discount-codes', idempotencyKey: false, customer: true, pagination: 'offset' },\n customerRewardsDiscountCodesShow: { method: 'GET', path: '/customer/rewards/discount-codes/{id}', idempotencyKey: false, customer: true, pagination: null },\n customerRewardsRedemptionsStore: { method: 'POST', path: '/customer/rewards/redemptions', idempotencyKey: true, customer: true, pagination: null },\n customerShow: { method: 'GET', path: '/customer', idempotencyKey: false, customer: true, pagination: null },\n customerUpdate: { method: 'PATCH', path: '/customer', idempotencyKey: false, customer: true, pagination: null },\n customerWalletActivities: { method: 'GET', path: '/customer/wallet/activities', idempotencyKey: false, customer: true, pagination: 'offset' },\n customerWalletShow: { method: 'GET', path: '/customer/wallet', idempotencyKey: false, customer: true, pagination: null },\n customerWishlistAdd: { method: 'PUT', path: '/customer/wishlist/{productId}', idempotencyKey: false, customer: true, pagination: null },\n customerWishlistIndex: { method: 'GET', path: '/customer/wishlist', idempotencyKey: false, customer: true, pagination: 'offset' },\n customerWishlistRemove: { method: 'DELETE', path: '/customer/wishlist/{productId}', idempotencyKey: false, customer: true, pagination: null },\n home: { method: 'GET', path: '/home', idempotencyKey: false, customer: false, pagination: null },\n locationsIndex: { method: 'GET', path: '/locations', idempotencyKey: false, customer: false, pagination: null },\n mediaUploadsStore: { method: 'POST', path: '/media/uploads', idempotencyKey: false, customer: true, pagination: null },\n menusShow: { method: 'GET', path: '/menus/{handle}', idempotencyKey: false, customer: false, pagination: null },\n ordersPayment: { method: 'GET', path: '/orders/{id}/payment', idempotencyKey: false, customer: false, pagination: null },\n ordersPaymentLink: { method: 'POST', path: '/orders/{id}/payment-link', idempotencyKey: true, customer: false, pagination: null },\n pagesIndex: { method: 'GET', path: '/pages', idempotencyKey: false, customer: false, pagination: null },\n pagesShow: { method: 'GET', path: '/pages/{handle}', idempotencyKey: false, customer: false, pagination: null },\n ping: { method: 'GET', path: '/ping', idempotencyKey: false, customer: false, pagination: null },\n preOrdersStore: { method: 'POST', path: '/pre-orders', idempotencyKey: false, customer: false, pagination: null },\n productsIndex: { method: 'GET', path: '/products', idempotencyKey: false, customer: false, pagination: 'offset' },\n productsRecommendations: { method: 'GET', path: '/products/{handle}/recommendations', idempotencyKey: false, customer: false, pagination: null },\n productsReviews: { method: 'GET', path: '/products/{handle}/reviews', idempotencyKey: false, customer: false, pagination: 'offset' },\n productsShow: { method: 'GET', path: '/products/{handle}', idempotencyKey: false, customer: false, pagination: null },\n realtimeAuthorizationsStore: { method: 'POST', path: '/realtime/authorizations', idempotencyKey: false, customer: false, pagination: null },\n reelsIndex: { method: 'GET', path: '/reels', idempotencyKey: false, customer: false, pagination: 'offset' },\n referralProgram: { method: 'GET', path: '/referral-program', idempotencyKey: false, customer: false, pagination: null },\n reviewsLike: { method: 'PUT', path: '/reviews/{id}/like', idempotencyKey: false, customer: true, pagination: null },\n reviewsSite: { method: 'GET', path: '/reviews/site', idempotencyKey: false, customer: false, pagination: 'offset' },\n reviewsSiteStore: { method: 'POST', path: '/reviews/site', idempotencyKey: false, customer: true, pagination: null },\n reviewsStore: { method: 'POST', path: '/reviews', idempotencyKey: false, customer: true, pagination: null },\n reviewsUnlike: { method: 'DELETE', path: '/reviews/{id}/like', idempotencyKey: false, customer: true, pagination: null },\n rewardsEarningRules: { method: 'GET', path: '/rewards/earning-rules', idempotencyKey: false, customer: false, pagination: null },\n rewardsSpendingRules: { method: 'GET', path: '/rewards/spending-rules', idempotencyKey: false, customer: false, pagination: null },\n search: { method: 'GET', path: '/search', idempotencyKey: false, customer: false, pagination: 'offset' },\n searchFilters: { method: 'GET', path: '/search/filters', idempotencyKey: false, customer: false, pagination: null },\n searchSuggestions: { method: 'GET', path: '/search/suggestions', idempotencyKey: false, customer: false, pagination: null },\n searchTrending: { method: 'GET', path: '/search/trending', idempotencyKey: false, customer: false, pagination: null },\n shop: { method: 'GET', path: '/shop', idempotencyKey: false, customer: false, pagination: null },\n sitemap: { method: 'GET', path: '/sitemap', idempotencyKey: false, customer: false, pagination: 'offset' },\n themeSectionSchema: { method: 'GET', path: '/theme/section-schema', idempotencyKey: false, customer: false, pagination: null },\n} as const;\n","import type {\n OperationArgs,\n OperationId,\n OperationResult,\n PageItem,\n PaginatedOperationId,\n} from './types';\n\ntype Call = <K extends OperationId>(\n operationId: K,\n ...args: OperationArgs<K>\n) => Promise<OperationResult<K>>;\n\ninterface PageBody {\n data?: unknown[];\n meta?: {\n pagination?: { page: number; hasNextPage: boolean };\n cursor?: { next: string | null; hasNextPage: boolean };\n };\n}\n\nexport async function* paginate<K extends PaginatedOperationId>(\n call: Call,\n operationId: K,\n style: 'offset' | 'cursor',\n [input, options]: OperationArgs<K>,\n): AsyncGenerator<PageItem<K>, void, undefined> {\n const base = (input ?? {}) as { query?: Record<string, unknown> };\n let query: Record<string, unknown> = { ...base.query };\n\n for (;;) {\n const args = [{ ...base, query }, options] as unknown as OperationArgs<K>;\n const body = (await call(operationId, ...args)) as unknown as PageBody;\n\n for (const item of body.data ?? []) {\n yield item as PageItem<K>;\n }\n\n if (style === 'offset') {\n const pagination = body.meta?.pagination;\n if (!pagination?.hasNextPage) {\n return;\n }\n query = { ...query, page: pagination.page + 1 };\n } else {\n const cursor = body.meta?.cursor;\n if (!cursor?.hasNextPage || cursor.next === null) {\n return;\n }\n query = { ...query, cursor: cursor.next };\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;;;ACUzB,IAAM,iBAA8C;AAAA,EAClD,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACP;AAaO,IAAM,kBAAN,MAAM,yBAAwB,MAAM;AAAA,EACvB,OAAO;AAAA;AAAA,EAGhB;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA,EAET,YAAY,MAWT;AACD,UAAM,KAAK,SAAS,KAAK,UAAU,SAAY,SAAY,EAAE,OAAO,KAAK,MAAM,CAAC;AAChF,SAAK,SAAS,K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