@commerce-blocks/sdk 1.2.0 → 1.3.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/README.md +142 -34
- package/dist/index.d.ts +68 -23
- package/dist/index.js +790 -739
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { signal as $ } from "@preact/signals-core";
|
|
2
|
-
import { batch as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
2
|
+
import { batch as br, computed as vr, effect as Fr, signal as Mr } from "@preact/signals-core";
|
|
3
|
+
const He = "2026-01", Qe = "https://app.uselayers.com/api/storefront/v1", Ke = 1e3, ke = 1e3, Ne = 100, We = 300 * Ke, Xe = "6.0.0", se = 250, j = 20, H = 250, ie = 250, ae = 250, ce = 1, le = 1, Y = 1, Z = 24, ue = 1, de = 1, fe = 100, ze = 20, Je = 50, Ye = 300, Ze = "USD", et = "en-US", tt = 1e3, De = /* @__PURE__ */ new Map();
|
|
4
|
+
function rt(e, t) {
|
|
5
5
|
const r = `${e}:${t}`;
|
|
6
|
-
let o =
|
|
7
|
-
return o || (o = new Intl.NumberFormat(
|
|
6
|
+
let o = De.get(r);
|
|
7
|
+
return o || (o = new Intl.NumberFormat(et, {
|
|
8
8
|
style: "currency",
|
|
9
9
|
currency: t
|
|
10
|
-
}).format(e),
|
|
10
|
+
}).format(e), De.set(r, o)), o;
|
|
11
11
|
}
|
|
12
12
|
function M(e) {
|
|
13
13
|
return { data: e };
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function p(e) {
|
|
16
16
|
return { error: e };
|
|
17
17
|
}
|
|
18
18
|
function ee() {
|
|
19
19
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
20
20
|
}
|
|
21
|
-
const
|
|
21
|
+
const nt = ["TIMEOUT", "CONNECTION_FAILED", "DNS_FAILED"];
|
|
22
22
|
function J(e) {
|
|
23
|
-
const t =
|
|
23
|
+
const t = nt.includes(e.code);
|
|
24
24
|
return {
|
|
25
25
|
_tag: "NetworkError",
|
|
26
26
|
code: e.code,
|
|
@@ -32,7 +32,7 @@ function J(e) {
|
|
|
32
32
|
retryAfterMs: t ? 1e3 : void 0
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function ot(e) {
|
|
36
36
|
if (!e) return;
|
|
37
37
|
const t = e["retry-after"] ?? e["Retry-After"];
|
|
38
38
|
if (!t) return;
|
|
@@ -42,8 +42,8 @@ function st(e) {
|
|
|
42
42
|
if (!isNaN(o.getTime()))
|
|
43
43
|
return Math.max(0, o.getTime() - Date.now());
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const t = e.code === "RATE_LIMITED" || e.code === "SERVICE_UNAVAILABLE" || e.status !== void 0 && e.status >= 500, r = e.retryAfterMs ??
|
|
45
|
+
function C(e) {
|
|
46
|
+
const t = e.code === "RATE_LIMITED" || e.code === "SERVICE_UNAVAILABLE" || e.status !== void 0 && e.status >= 500, r = e.retryAfterMs ?? ot(e.response?.headers) ?? (t ? 1e3 : void 0);
|
|
47
47
|
return {
|
|
48
48
|
_tag: "ApiError",
|
|
49
49
|
code: e.code,
|
|
@@ -70,7 +70,7 @@ function D(e) {
|
|
|
70
70
|
input: e.input
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function A(e, t, r, o) {
|
|
74
74
|
return {
|
|
75
75
|
path: e.split("."),
|
|
76
76
|
field: e.split(".").pop() ?? e,
|
|
@@ -96,16 +96,16 @@ function rr(e) {
|
|
|
96
96
|
function nr(e) {
|
|
97
97
|
return "retryable" in e ? e.retryable : !1;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function st(e, t) {
|
|
100
100
|
const r = e === 401 ? "UNAUTHORIZED" : e === 403 ? "FORBIDDEN" : e === 429 ? "RATE_LIMITED" : e >= 500 ? "SERVICE_UNAVAILABLE" : "UNKNOWN";
|
|
101
|
-
return
|
|
101
|
+
return C({
|
|
102
102
|
code: r,
|
|
103
103
|
source: "layers",
|
|
104
104
|
message: t || `HTTP ${e}`,
|
|
105
105
|
status: e
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function ye(e) {
|
|
109
109
|
if (e instanceof Error && (e.name === "AbortError" || e.name === "TimeoutError")) {
|
|
110
110
|
const t = e.name === "TimeoutError" || e.message.includes("timeout");
|
|
111
111
|
return J({
|
|
@@ -123,13 +123,13 @@ function Ee(e) {
|
|
|
123
123
|
async function _e(e) {
|
|
124
124
|
if (!e.ok) {
|
|
125
125
|
const t = await e.text().catch(() => "");
|
|
126
|
-
return
|
|
126
|
+
return p(st(e.status, t));
|
|
127
127
|
}
|
|
128
128
|
try {
|
|
129
129
|
return M(await e.json());
|
|
130
130
|
} catch (t) {
|
|
131
|
-
return
|
|
132
|
-
|
|
131
|
+
return p(
|
|
132
|
+
C({
|
|
133
133
|
code: "PARSE_ERROR",
|
|
134
134
|
source: "layers",
|
|
135
135
|
message: "Invalid JSON response",
|
|
@@ -138,75 +138,75 @@ async function _e(e) {
|
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Ee({
|
|
142
142
|
token: e,
|
|
143
143
|
json: t = !0
|
|
144
144
|
}) {
|
|
145
145
|
const r = {
|
|
146
146
|
Accept: "application/json",
|
|
147
147
|
"X-Storefront-Access-Token": e,
|
|
148
|
-
"X-SDK-Client": `commerce-blocks-sdk/${
|
|
148
|
+
"X-SDK-Client": `commerce-blocks-sdk/${Xe}`
|
|
149
149
|
};
|
|
150
150
|
return t && (r["Content-Type"] = "application/json"), r;
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
const { layersBaseUrl: r =
|
|
152
|
+
function Ie({ config: e, endpoint: t }) {
|
|
153
|
+
const { layersBaseUrl: r = Qe } = e;
|
|
154
154
|
return `${r}${t}`;
|
|
155
155
|
}
|
|
156
156
|
async function G(e) {
|
|
157
157
|
const t = e.config.fetch ?? fetch;
|
|
158
158
|
try {
|
|
159
|
-
const r = await t(
|
|
159
|
+
const r = await t(Ie({ config: e.config, endpoint: e.endpoint }), {
|
|
160
160
|
method: "POST",
|
|
161
|
-
headers:
|
|
161
|
+
headers: Ee({ token: e.config.layersPublicToken }),
|
|
162
162
|
body: JSON.stringify(e.body),
|
|
163
163
|
signal: e.signal
|
|
164
164
|
});
|
|
165
165
|
return _e(r);
|
|
166
166
|
} catch (r) {
|
|
167
|
-
return
|
|
167
|
+
return p(ye(r));
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
async function
|
|
170
|
+
async function it(e) {
|
|
171
171
|
const t = new URLSearchParams();
|
|
172
|
-
for (const [
|
|
173
|
-
|
|
172
|
+
for (const [i, s] of Object.entries(e.params))
|
|
173
|
+
s != null && t.append(i, typeof s == "object" ? JSON.stringify(s) : String(s));
|
|
174
174
|
const r = t.toString(), o = r ? `${e.endpoint}?${r}` : e.endpoint, n = e.config.fetch ?? fetch;
|
|
175
175
|
try {
|
|
176
|
-
const
|
|
176
|
+
const i = await n(Ie({ config: e.config, endpoint: o }), {
|
|
177
177
|
method: "GET",
|
|
178
|
-
headers:
|
|
178
|
+
headers: Ee({ token: e.config.layersPublicToken }),
|
|
179
179
|
signal: e.signal
|
|
180
180
|
});
|
|
181
|
-
return _e(
|
|
182
|
-
} catch (
|
|
183
|
-
return
|
|
181
|
+
return _e(i);
|
|
182
|
+
} catch (i) {
|
|
183
|
+
return p(ye(i));
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
async function
|
|
186
|
+
async function at(e) {
|
|
187
187
|
const t = e.config.fetch ?? fetch;
|
|
188
188
|
try {
|
|
189
|
-
const r = await t(
|
|
189
|
+
const r = await t(Ie({ config: e.config, endpoint: e.endpoint }), {
|
|
190
190
|
method: "POST",
|
|
191
|
-
headers:
|
|
191
|
+
headers: Ee({ token: e.config.layersPublicToken, json: !1 }),
|
|
192
192
|
body: e.formData,
|
|
193
193
|
signal: e.signal
|
|
194
194
|
});
|
|
195
195
|
return _e(r);
|
|
196
196
|
} catch (r) {
|
|
197
|
-
return
|
|
197
|
+
return p(ye(r));
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
function Q(e, t) {
|
|
201
201
|
if (!e) return null;
|
|
202
202
|
const r = [];
|
|
203
203
|
return e.page !== void 0 && e.page < ue && r.push(
|
|
204
|
-
|
|
204
|
+
A("pagination.page", "OUT_OF_RANGE", `page must be >= ${ue}`, {
|
|
205
205
|
value: e.page,
|
|
206
206
|
constraints: { min: ue }
|
|
207
207
|
})
|
|
208
208
|
), e.limit !== void 0 && (e.limit < de || e.limit > fe) && r.push(
|
|
209
|
-
|
|
209
|
+
A(
|
|
210
210
|
"pagination.limit",
|
|
211
211
|
"OUT_OF_RANGE",
|
|
212
212
|
`limit must be between ${de} and ${fe}`,
|
|
@@ -217,7 +217,7 @@ function Q(e, t) {
|
|
|
217
217
|
)
|
|
218
218
|
), r.length > 0 ? D({ operation: t, fields: r }) : null;
|
|
219
219
|
}
|
|
220
|
-
const
|
|
220
|
+
const ct = [
|
|
221
221
|
"title",
|
|
222
222
|
"handle",
|
|
223
223
|
"body_html",
|
|
@@ -238,9 +238,9 @@ const lt = [
|
|
|
238
238
|
"named_tags",
|
|
239
239
|
"category"
|
|
240
240
|
];
|
|
241
|
-
function
|
|
241
|
+
function lt(e) {
|
|
242
242
|
if (!e.layersPublicToken)
|
|
243
|
-
return
|
|
243
|
+
return p(
|
|
244
244
|
B({
|
|
245
245
|
code: "MISSING_CONFIG",
|
|
246
246
|
message: "layersPublicToken is required",
|
|
@@ -249,7 +249,7 @@ function ut(e) {
|
|
|
249
249
|
})
|
|
250
250
|
);
|
|
251
251
|
if (!e.sorts || e.sorts.length === 0)
|
|
252
|
-
return
|
|
252
|
+
return p(
|
|
253
253
|
B({
|
|
254
254
|
code: "MISSING_CONFIG",
|
|
255
255
|
message: "At least one sort option is required",
|
|
@@ -258,7 +258,7 @@ function ut(e) {
|
|
|
258
258
|
})
|
|
259
259
|
);
|
|
260
260
|
function t(n) {
|
|
261
|
-
return [.../* @__PURE__ */ new Set([...
|
|
261
|
+
return [.../* @__PURE__ */ new Set([...ct, ...e.attributes ?? [], ...n ?? []])];
|
|
262
262
|
}
|
|
263
263
|
const r = {
|
|
264
264
|
layersPublicToken: e.layersPublicToken,
|
|
@@ -266,173 +266,173 @@ function ut(e) {
|
|
|
266
266
|
fetch: e.fetch
|
|
267
267
|
};
|
|
268
268
|
return M({
|
|
269
|
-
browse: async (n,
|
|
269
|
+
browse: async (n, i) => {
|
|
270
270
|
if (!n.collectionHandle)
|
|
271
|
-
return
|
|
271
|
+
return p(
|
|
272
272
|
D({
|
|
273
273
|
operation: "browse",
|
|
274
274
|
fields: [
|
|
275
|
-
|
|
275
|
+
A("collectionHandle", "REQUIRED_FIELD", "collectionHandle is required")
|
|
276
276
|
]
|
|
277
277
|
})
|
|
278
278
|
);
|
|
279
279
|
if (!n.sort_order_code)
|
|
280
|
-
return
|
|
280
|
+
return p(
|
|
281
281
|
D({
|
|
282
282
|
operation: "browse",
|
|
283
283
|
fields: [
|
|
284
|
-
|
|
284
|
+
A("sort_order_code", "REQUIRED_FIELD", "sort_order_code is required")
|
|
285
285
|
]
|
|
286
286
|
})
|
|
287
287
|
);
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
const { collectionHandle: a, attributes:
|
|
291
|
-
let
|
|
288
|
+
const s = Q(n.pagination, "browse");
|
|
289
|
+
if (s) return p(s);
|
|
290
|
+
const { collectionHandle: a, attributes: u, transformBody: c, ...f } = n;
|
|
291
|
+
let d = {
|
|
292
292
|
facets: e.facets,
|
|
293
|
-
attributes: t(
|
|
293
|
+
attributes: t(u),
|
|
294
294
|
retrieveFacetCount: !0,
|
|
295
295
|
includeFacetRanges: !0,
|
|
296
|
-
...
|
|
296
|
+
...f
|
|
297
297
|
};
|
|
298
|
-
return
|
|
298
|
+
return c && (d = c(d)), G({
|
|
299
299
|
config: r,
|
|
300
300
|
endpoint: `/browse/${a}`,
|
|
301
|
-
body:
|
|
302
|
-
signal:
|
|
301
|
+
body: d,
|
|
302
|
+
signal: i
|
|
303
303
|
});
|
|
304
304
|
},
|
|
305
|
-
predictiveSearch: async (n,
|
|
305
|
+
predictiveSearch: async (n, i) => n ? it({
|
|
306
306
|
config: r,
|
|
307
307
|
endpoint: "/search/complete",
|
|
308
308
|
params: { query: n },
|
|
309
|
-
signal:
|
|
310
|
-
}) :
|
|
309
|
+
signal: i
|
|
310
|
+
}) : p(
|
|
311
311
|
D({
|
|
312
312
|
operation: "predictiveSearch",
|
|
313
|
-
fields: [
|
|
313
|
+
fields: [A("query", "REQUIRED_FIELD", "query is required")]
|
|
314
314
|
})
|
|
315
315
|
),
|
|
316
|
-
prepareSearch: async (n,
|
|
316
|
+
prepareSearch: async (n, i) => {
|
|
317
317
|
if (!n.query)
|
|
318
|
-
return
|
|
318
|
+
return p(
|
|
319
319
|
D({
|
|
320
320
|
operation: "prepareSearch",
|
|
321
|
-
fields: [
|
|
321
|
+
fields: [A("query", "REQUIRED_FIELD", "query is required")]
|
|
322
322
|
})
|
|
323
323
|
);
|
|
324
|
-
const { query:
|
|
325
|
-
let
|
|
326
|
-
return a && (
|
|
324
|
+
const { query: s, transformBody: a, ...u } = n;
|
|
325
|
+
let c = { ...u };
|
|
326
|
+
return a && (c = a(c)), G({
|
|
327
327
|
config: r,
|
|
328
|
-
endpoint: `/search/${encodeURIComponent(
|
|
329
|
-
body:
|
|
330
|
-
signal:
|
|
328
|
+
endpoint: `/search/${encodeURIComponent(s)}/prepare`,
|
|
329
|
+
body: c,
|
|
330
|
+
signal: i
|
|
331
331
|
});
|
|
332
332
|
},
|
|
333
|
-
search: async (n,
|
|
333
|
+
search: async (n, i) => {
|
|
334
334
|
if (!n.query)
|
|
335
|
-
return
|
|
335
|
+
return p(
|
|
336
336
|
D({
|
|
337
337
|
operation: "search",
|
|
338
|
-
fields: [
|
|
338
|
+
fields: [A("query", "REQUIRED_FIELD", "query is required")]
|
|
339
339
|
})
|
|
340
340
|
);
|
|
341
|
-
const
|
|
342
|
-
if (
|
|
343
|
-
const { query: a, attributes:
|
|
344
|
-
let
|
|
341
|
+
const s = Q(n.pagination, "search");
|
|
342
|
+
if (s) return p(s);
|
|
343
|
+
const { query: a, attributes: u, transformBody: c, ...f } = n;
|
|
344
|
+
let d = {
|
|
345
345
|
facets: e.facets,
|
|
346
|
-
attributes: t(
|
|
346
|
+
attributes: t(u),
|
|
347
347
|
retrieveFacetCount: !0,
|
|
348
348
|
includeFacetRanges: !0,
|
|
349
|
-
...
|
|
349
|
+
...f
|
|
350
350
|
};
|
|
351
|
-
return
|
|
351
|
+
return c && (d = c(d)), G({
|
|
352
352
|
config: r,
|
|
353
353
|
endpoint: `/search/${encodeURIComponent(a)}/execute`,
|
|
354
|
-
body:
|
|
355
|
-
signal:
|
|
354
|
+
body: d,
|
|
355
|
+
signal: i
|
|
356
356
|
});
|
|
357
357
|
},
|
|
358
|
-
imageSearch: async (n,
|
|
358
|
+
imageSearch: async (n, i) => {
|
|
359
359
|
if (!n.image_data && !n.image_id)
|
|
360
|
-
return
|
|
360
|
+
return p(
|
|
361
361
|
D({
|
|
362
362
|
operation: "imageSearch",
|
|
363
363
|
fields: [
|
|
364
|
-
|
|
364
|
+
A("image_data", "REQUIRED_FIELD", "image_data or image_id is required")
|
|
365
365
|
]
|
|
366
366
|
})
|
|
367
367
|
);
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
370
|
-
const { attributes: a, transformBody:
|
|
371
|
-
let
|
|
368
|
+
const s = Q(n.pagination, "imageSearch");
|
|
369
|
+
if (s) return p(s);
|
|
370
|
+
const { attributes: a, transformBody: u, ...c } = n;
|
|
371
|
+
let f = {
|
|
372
372
|
attributes: t(a),
|
|
373
|
-
...
|
|
373
|
+
...c
|
|
374
374
|
};
|
|
375
|
-
return
|
|
375
|
+
return u && (f = u(f)), G({
|
|
376
376
|
config: r,
|
|
377
377
|
endpoint: "/search/image",
|
|
378
|
-
body:
|
|
379
|
-
signal:
|
|
378
|
+
body: f,
|
|
379
|
+
signal: i
|
|
380
380
|
});
|
|
381
381
|
},
|
|
382
|
-
uploadImage: async (n,
|
|
383
|
-
const
|
|
384
|
-
return
|
|
382
|
+
uploadImage: async (n, i) => {
|
|
383
|
+
const s = new FormData();
|
|
384
|
+
return s.append("image", n), at({
|
|
385
385
|
config: r,
|
|
386
386
|
endpoint: "/images/upload",
|
|
387
|
-
formData:
|
|
388
|
-
signal:
|
|
387
|
+
formData: s,
|
|
388
|
+
signal: i
|
|
389
389
|
});
|
|
390
390
|
},
|
|
391
|
-
blocks: async (n,
|
|
391
|
+
blocks: async (n, i) => {
|
|
392
392
|
if (!n.blockId)
|
|
393
|
-
return
|
|
393
|
+
return p(
|
|
394
394
|
D({
|
|
395
395
|
operation: "block",
|
|
396
|
-
fields: [
|
|
396
|
+
fields: [A("blockId", "REQUIRED_FIELD", "blockId is required")]
|
|
397
397
|
})
|
|
398
398
|
);
|
|
399
|
-
const
|
|
400
|
-
if (
|
|
401
|
-
const { blockId: a, attributes:
|
|
402
|
-
let
|
|
399
|
+
const s = Q(n.pagination, "block");
|
|
400
|
+
if (s) return p(s);
|
|
401
|
+
const { blockId: a, attributes: u, transformBody: c, ...f } = n;
|
|
402
|
+
let d = {
|
|
403
403
|
facets: e.facets,
|
|
404
|
-
attributes: t(
|
|
404
|
+
attributes: t(u),
|
|
405
405
|
retrieveFacetCount: !0,
|
|
406
406
|
includeFacetRanges: !0,
|
|
407
|
-
...
|
|
407
|
+
...f
|
|
408
408
|
};
|
|
409
|
-
return
|
|
409
|
+
return c && (d = c(d)), G({
|
|
410
410
|
config: r,
|
|
411
411
|
endpoint: `/blocks/${a}/products`,
|
|
412
|
-
body:
|
|
413
|
-
signal:
|
|
412
|
+
body: d,
|
|
413
|
+
signal: i
|
|
414
414
|
});
|
|
415
415
|
},
|
|
416
|
-
similarProducts: async (n,
|
|
416
|
+
similarProducts: async (n, i) => {
|
|
417
417
|
if (!n.productId)
|
|
418
|
-
return
|
|
418
|
+
return p(
|
|
419
419
|
D({
|
|
420
420
|
operation: "similarProducts",
|
|
421
|
-
fields: [
|
|
421
|
+
fields: [A("productId", "REQUIRED_FIELD", "productId is required")]
|
|
422
422
|
})
|
|
423
423
|
);
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
426
|
-
const { productId: a, attributes:
|
|
427
|
-
let
|
|
428
|
-
attributes: t(
|
|
429
|
-
...
|
|
424
|
+
const s = Q(n.pagination, "similarProducts");
|
|
425
|
+
if (s) return p(s);
|
|
426
|
+
const { productId: a, attributes: u, transformBody: c, ...f } = n;
|
|
427
|
+
let d = {
|
|
428
|
+
attributes: t(u),
|
|
429
|
+
...f
|
|
430
430
|
};
|
|
431
|
-
return
|
|
431
|
+
return c && (d = c(d)), G({
|
|
432
432
|
config: r,
|
|
433
433
|
endpoint: `/search/product/${a}`,
|
|
434
|
-
body:
|
|
435
|
-
signal:
|
|
434
|
+
body: d,
|
|
435
|
+
signal: i
|
|
436
436
|
});
|
|
437
437
|
}
|
|
438
438
|
});
|
|
@@ -442,14 +442,14 @@ const te = `
|
|
|
442
442
|
title
|
|
443
443
|
description
|
|
444
444
|
}
|
|
445
|
-
`,
|
|
445
|
+
`, qe = `
|
|
446
446
|
fragment FilterValueFields on FilterValue {
|
|
447
447
|
id
|
|
448
448
|
label
|
|
449
449
|
count
|
|
450
450
|
input
|
|
451
451
|
}
|
|
452
|
-
`,
|
|
452
|
+
`, $e = `
|
|
453
453
|
fragment FilterFields on Filter {
|
|
454
454
|
id
|
|
455
455
|
label
|
|
@@ -463,22 +463,22 @@ const te = `
|
|
|
463
463
|
width
|
|
464
464
|
height
|
|
465
465
|
}
|
|
466
|
-
`,
|
|
466
|
+
`, be = `
|
|
467
467
|
fragment MoneyFields on MoneyV2 {
|
|
468
468
|
amount
|
|
469
469
|
currencyCode
|
|
470
470
|
}
|
|
471
|
-
`,
|
|
471
|
+
`, ve = `
|
|
472
472
|
fragment SelectedOptionFields on SelectedOption {
|
|
473
473
|
name
|
|
474
474
|
value
|
|
475
475
|
}
|
|
476
|
-
`,
|
|
476
|
+
`, Fe = `
|
|
477
477
|
fragment PriceRangeFields on ProductPriceRange {
|
|
478
478
|
minVariantPrice { ...MoneyFields }
|
|
479
479
|
maxVariantPrice { ...MoneyFields }
|
|
480
480
|
}
|
|
481
|
-
`,
|
|
481
|
+
`, Me = `
|
|
482
482
|
fragment ProductOptionFields on ProductOption {
|
|
483
483
|
id
|
|
484
484
|
name
|
|
@@ -501,7 +501,7 @@ const te = `
|
|
|
501
501
|
type
|
|
502
502
|
}
|
|
503
503
|
`;
|
|
504
|
-
function
|
|
504
|
+
function Se(e) {
|
|
505
505
|
return `
|
|
506
506
|
fragment VariantFields on ProductVariant {
|
|
507
507
|
id
|
|
@@ -522,7 +522,7 @@ function Pe(e) {
|
|
|
522
522
|
}
|
|
523
523
|
`;
|
|
524
524
|
}
|
|
525
|
-
function
|
|
525
|
+
function Pe(e) {
|
|
526
526
|
const { maxImages: t, maxVariants: r, includeProductMetafields: o } = e;
|
|
527
527
|
return `
|
|
528
528
|
fragment ProductFields on Product {
|
|
@@ -549,7 +549,7 @@ function Re(e) {
|
|
|
549
549
|
}
|
|
550
550
|
`;
|
|
551
551
|
}
|
|
552
|
-
function
|
|
552
|
+
function Le(e) {
|
|
553
553
|
return `
|
|
554
554
|
fragment CollectionFields on Collection {
|
|
555
555
|
id
|
|
@@ -564,7 +564,7 @@ function Ue(e) {
|
|
|
564
564
|
}
|
|
565
565
|
`;
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function Ue(e) {
|
|
568
568
|
return `
|
|
569
569
|
fragment PageFields on Page {
|
|
570
570
|
id
|
|
@@ -580,33 +580,33 @@ function Ve(e) {
|
|
|
580
580
|
}
|
|
581
581
|
`;
|
|
582
582
|
}
|
|
583
|
-
function
|
|
583
|
+
function ut(e) {
|
|
584
584
|
const { includeProductMetafields: t, includeVariantMetafields: r } = e;
|
|
585
585
|
return [
|
|
586
586
|
re,
|
|
587
|
+
be,
|
|
587
588
|
ve,
|
|
588
589
|
Fe,
|
|
589
590
|
Me,
|
|
590
|
-
Se,
|
|
591
591
|
t || r ? z : "",
|
|
592
|
-
|
|
593
|
-
|
|
592
|
+
Se(r),
|
|
593
|
+
Pe(e)
|
|
594
594
|
].join(`
|
|
595
595
|
`);
|
|
596
596
|
}
|
|
597
|
-
function
|
|
597
|
+
function dt(e = {}) {
|
|
598
598
|
const {
|
|
599
|
-
maxImages: t =
|
|
600
|
-
maxVariants: r =
|
|
599
|
+
maxImages: t = j,
|
|
600
|
+
maxVariants: r = H,
|
|
601
601
|
productMetafields: o = [],
|
|
602
602
|
variantMetafields: n = []
|
|
603
|
-
} = e,
|
|
604
|
-
return
|
|
605
|
-
${
|
|
603
|
+
} = e, i = o.length > 0, s = n.length > 0, a = ["$ids: [ID!]!"];
|
|
604
|
+
return i && a.push("$productMetafields: [HasMetafieldsIdentifier!]!"), s && a.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), `
|
|
605
|
+
${ut({
|
|
606
606
|
maxImages: t,
|
|
607
607
|
maxVariants: r,
|
|
608
|
-
includeProductMetafields:
|
|
609
|
-
includeVariantMetafields:
|
|
608
|
+
includeProductMetafields: i,
|
|
609
|
+
includeVariantMetafields: s
|
|
610
610
|
})}
|
|
611
611
|
|
|
612
612
|
query ProductsByIds(${a.join(", ")}) {
|
|
@@ -618,40 +618,40 @@ function ft(e = {}) {
|
|
|
618
618
|
}
|
|
619
619
|
`;
|
|
620
620
|
}
|
|
621
|
-
function
|
|
621
|
+
function ft(e = {}) {
|
|
622
622
|
const {
|
|
623
|
-
maxImages: t =
|
|
624
|
-
maxVariants: r =
|
|
623
|
+
maxImages: t = j,
|
|
624
|
+
maxVariants: r = H,
|
|
625
625
|
productMetafields: o = [],
|
|
626
626
|
variantMetafields: n = [],
|
|
627
|
-
collectionMetafields:
|
|
628
|
-
includeFilters:
|
|
629
|
-
} = e, a = o.length > 0,
|
|
630
|
-
return a &&
|
|
627
|
+
collectionMetafields: i = [],
|
|
628
|
+
includeFilters: s = !1
|
|
629
|
+
} = e, a = o.length > 0, u = n.length > 0, c = i.length > 0, f = a || u || c, d = ["$ids: [ID!]!", "$handle: String!"];
|
|
630
|
+
return a && d.push("$productMetafields: [HasMetafieldsIdentifier!]!"), u && d.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), c && d.push("$collectionMetafields: [HasMetafieldsIdentifier!]!"), `
|
|
631
631
|
${[
|
|
632
632
|
re,
|
|
633
|
+
be,
|
|
633
634
|
ve,
|
|
634
635
|
Fe,
|
|
635
636
|
Me,
|
|
636
|
-
Se,
|
|
637
637
|
te,
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
638
|
+
f ? z : "",
|
|
639
|
+
s ? qe : "",
|
|
640
|
+
s ? $e : "",
|
|
641
|
+
Se(u),
|
|
642
|
+
Pe({
|
|
643
643
|
maxImages: t,
|
|
644
644
|
maxVariants: r,
|
|
645
645
|
includeProductMetafields: a
|
|
646
646
|
}),
|
|
647
|
-
|
|
647
|
+
Le(c)
|
|
648
648
|
].join(`
|
|
649
649
|
`)}
|
|
650
650
|
|
|
651
|
-
query CollectionWithProducts(${
|
|
651
|
+
query CollectionWithProducts(${d.join(", ")}) {
|
|
652
652
|
collection(handle: $handle) {
|
|
653
653
|
...CollectionFields
|
|
654
|
-
${
|
|
654
|
+
${s ? "products(first: 1) { filters { ...FilterFields } }" : ""}
|
|
655
655
|
}
|
|
656
656
|
nodes(ids: $ids) {
|
|
657
657
|
... on Product {
|
|
@@ -661,16 +661,16 @@ function gt(e = {}) {
|
|
|
661
661
|
}
|
|
662
662
|
`;
|
|
663
663
|
}
|
|
664
|
-
function
|
|
664
|
+
function gt(e = {}) {
|
|
665
665
|
const { collectionMetafields: t = [], includeFilters: r = !1 } = e, o = t.length > 0, n = ["$handle: String!"];
|
|
666
666
|
return o && n.push("$collectionMetafields: [HasMetafieldsIdentifier!]!"), `
|
|
667
667
|
${[
|
|
668
668
|
re,
|
|
669
669
|
te,
|
|
670
670
|
o ? z : "",
|
|
671
|
+
r ? qe : "",
|
|
671
672
|
r ? $e : "",
|
|
672
|
-
|
|
673
|
-
Ue(o)
|
|
673
|
+
Le(o)
|
|
674
674
|
].join(`
|
|
675
675
|
`)}
|
|
676
676
|
|
|
@@ -682,13 +682,13 @@ function mt(e = {}) {
|
|
|
682
682
|
}
|
|
683
683
|
`;
|
|
684
684
|
}
|
|
685
|
-
function
|
|
685
|
+
function mt(e = {}) {
|
|
686
686
|
const { pageMetafields: t = [] } = e, r = t.length > 0, o = ["$handle: String!"];
|
|
687
687
|
return r && o.push("$pageMetafields: [HasMetafieldsIdentifier!]!"), `
|
|
688
688
|
${[
|
|
689
689
|
te,
|
|
690
690
|
r ? z : "",
|
|
691
|
-
|
|
691
|
+
Ue(r)
|
|
692
692
|
].join(`
|
|
693
693
|
`)}
|
|
694
694
|
|
|
@@ -699,34 +699,34 @@ function pt(e = {}) {
|
|
|
699
699
|
}
|
|
700
700
|
`;
|
|
701
701
|
}
|
|
702
|
-
function
|
|
702
|
+
function pt(e = {}) {
|
|
703
703
|
const {
|
|
704
|
-
maxImages: t =
|
|
705
|
-
maxVariants: r =
|
|
704
|
+
maxImages: t = j,
|
|
705
|
+
maxVariants: r = H,
|
|
706
706
|
productMetafields: o = [],
|
|
707
707
|
variantMetafields: n = [],
|
|
708
|
-
pageMetafields:
|
|
709
|
-
} = e,
|
|
710
|
-
return
|
|
708
|
+
pageMetafields: i = []
|
|
709
|
+
} = e, s = o.length > 0, a = n.length > 0, u = i.length > 0, c = s || a || u, f = ["$ids: [ID!]!", "$handle: String!"];
|
|
710
|
+
return s && f.push("$productMetafields: [HasMetafieldsIdentifier!]!"), a && f.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), u && f.push("$pageMetafields: [HasMetafieldsIdentifier!]!"), `
|
|
711
711
|
${[
|
|
712
712
|
re,
|
|
713
|
+
be,
|
|
713
714
|
ve,
|
|
714
715
|
Fe,
|
|
715
716
|
Me,
|
|
716
|
-
Se,
|
|
717
717
|
te,
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
718
|
+
c ? z : "",
|
|
719
|
+
Se(a),
|
|
720
|
+
Pe({
|
|
721
721
|
maxImages: t,
|
|
722
722
|
maxVariants: r,
|
|
723
|
-
includeProductMetafields:
|
|
723
|
+
includeProductMetafields: s
|
|
724
724
|
}),
|
|
725
|
-
|
|
725
|
+
Ue(u)
|
|
726
726
|
].join(`
|
|
727
727
|
`)}
|
|
728
728
|
|
|
729
|
-
query PageWithProducts(${
|
|
729
|
+
query PageWithProducts(${f.join(", ")}) {
|
|
730
730
|
page(handle: $handle) {
|
|
731
731
|
...PageFields
|
|
732
732
|
}
|
|
@@ -738,7 +738,7 @@ function ht(e = {}) {
|
|
|
738
738
|
}
|
|
739
739
|
`;
|
|
740
740
|
}
|
|
741
|
-
function
|
|
741
|
+
function ht({
|
|
742
742
|
shop: e,
|
|
743
743
|
token: t,
|
|
744
744
|
apiVersion: r,
|
|
@@ -746,23 +746,23 @@ function yt({
|
|
|
746
746
|
}) {
|
|
747
747
|
const n = `https://${e}/api/${r}/graphql.json`;
|
|
748
748
|
return {
|
|
749
|
-
async request(
|
|
750
|
-
const
|
|
749
|
+
async request(i, { variables: s, signal: a } = {}) {
|
|
750
|
+
const u = await o(n, {
|
|
751
751
|
method: "POST",
|
|
752
752
|
headers: {
|
|
753
753
|
"Content-Type": "application/json",
|
|
754
754
|
"X-Shopify-Storefront-Access-Token": t
|
|
755
755
|
},
|
|
756
|
-
body: JSON.stringify({ query:
|
|
756
|
+
body: JSON.stringify({ query: i, variables: s }),
|
|
757
757
|
signal: a
|
|
758
758
|
});
|
|
759
|
-
if (!
|
|
759
|
+
if (!u.ok)
|
|
760
760
|
return {
|
|
761
761
|
data: null,
|
|
762
|
-
errors: { message: `HTTP ${
|
|
762
|
+
errors: { message: `HTTP ${u.status}`, networkStatusCode: u.status }
|
|
763
763
|
};
|
|
764
|
-
const
|
|
765
|
-
return
|
|
764
|
+
const c = await u.json();
|
|
765
|
+
return c.errors ? { data: c.data, errors: { graphQLErrors: c.errors } } : { data: c.data };
|
|
766
766
|
}
|
|
767
767
|
};
|
|
768
768
|
}
|
|
@@ -772,9 +772,9 @@ function ge({ ids: e, maxSize: t }) {
|
|
|
772
772
|
r.push(e.slice(o, o + t));
|
|
773
773
|
return r;
|
|
774
774
|
}
|
|
775
|
-
function
|
|
775
|
+
function yt(e) {
|
|
776
776
|
if (!e.storefrontPublicToken)
|
|
777
|
-
return
|
|
777
|
+
return p(
|
|
778
778
|
B({
|
|
779
779
|
code: "MISSING_CONFIG",
|
|
780
780
|
message: "storefrontPublicToken is required",
|
|
@@ -783,7 +783,7 @@ function Et(e) {
|
|
|
783
783
|
})
|
|
784
784
|
);
|
|
785
785
|
if (!e.shop)
|
|
786
|
-
return
|
|
786
|
+
return p(
|
|
787
787
|
B({
|
|
788
788
|
code: "MISSING_CONFIG",
|
|
789
789
|
message: "shop is required",
|
|
@@ -791,7 +791,7 @@ function Et(e) {
|
|
|
791
791
|
expected: "non-empty string"
|
|
792
792
|
})
|
|
793
793
|
);
|
|
794
|
-
const { storefrontApiVersion: t =
|
|
794
|
+
const { storefrontApiVersion: t = He } = e, r = ht({
|
|
795
795
|
shop: e.shop,
|
|
796
796
|
token: e.storefrontPublicToken,
|
|
797
797
|
apiVersion: t,
|
|
@@ -800,194 +800,194 @@ function Et(e) {
|
|
|
800
800
|
return M({
|
|
801
801
|
async getProducts(n) {
|
|
802
802
|
const {
|
|
803
|
-
ids:
|
|
804
|
-
productMetafields:
|
|
803
|
+
ids: i,
|
|
804
|
+
productMetafields: s = [],
|
|
805
805
|
variantMetafields: a = [],
|
|
806
|
-
maxImages:
|
|
807
|
-
maxVariants:
|
|
808
|
-
signal:
|
|
809
|
-
} = n,
|
|
810
|
-
if (
|
|
811
|
-
return
|
|
812
|
-
if (
|
|
806
|
+
maxImages: u = j,
|
|
807
|
+
maxVariants: c = H,
|
|
808
|
+
signal: f
|
|
809
|
+
} = n, d = me(n);
|
|
810
|
+
if (d.length > 0)
|
|
811
|
+
return p(D({ operation: "getProducts", fields: d }));
|
|
812
|
+
if (i.length === 0)
|
|
813
813
|
return M([]);
|
|
814
|
-
const
|
|
815
|
-
maxImages:
|
|
816
|
-
maxVariants:
|
|
817
|
-
productMetafields:
|
|
814
|
+
const m = dt({
|
|
815
|
+
maxImages: u,
|
|
816
|
+
maxVariants: c,
|
|
817
|
+
productMetafields: s,
|
|
818
818
|
variantMetafields: a
|
|
819
|
-
}),
|
|
820
|
-
for (const h of
|
|
819
|
+
}), l = ge({ ids: i, maxSize: se }), g = [];
|
|
820
|
+
for (const h of l) {
|
|
821
821
|
const y = { ids: h };
|
|
822
|
-
|
|
823
|
-
const
|
|
824
|
-
if (
|
|
825
|
-
return
|
|
826
|
-
|
|
822
|
+
s.length > 0 && (y.productMetafields = s), a.length > 0 && (y.variantMetafields = a);
|
|
823
|
+
const _ = await _t({ shopifyClient: r, query: m, variables: y, signal: f });
|
|
824
|
+
if (_.error)
|
|
825
|
+
return _;
|
|
826
|
+
g.push(..._.data);
|
|
827
827
|
}
|
|
828
|
-
return M(
|
|
828
|
+
return M(g);
|
|
829
829
|
},
|
|
830
830
|
async getCollection(n) {
|
|
831
|
-
const { handle:
|
|
832
|
-
if (!
|
|
833
|
-
return
|
|
831
|
+
const { handle: i, collectionMetafields: s = [], includeFilters: a = !1, signal: u } = n;
|
|
832
|
+
if (!i)
|
|
833
|
+
return p(
|
|
834
834
|
D({
|
|
835
835
|
operation: "getCollection",
|
|
836
|
-
fields: [
|
|
836
|
+
fields: [A("handle", "REQUIRED_FIELD", "handle is required")]
|
|
837
837
|
})
|
|
838
838
|
);
|
|
839
|
-
const
|
|
840
|
-
|
|
839
|
+
const c = gt({ collectionMetafields: s, includeFilters: a }), f = { handle: i };
|
|
840
|
+
s.length > 0 && (f.collectionMetafields = s);
|
|
841
841
|
try {
|
|
842
|
-
const { data:
|
|
843
|
-
if (
|
|
844
|
-
return
|
|
845
|
-
const
|
|
846
|
-
return
|
|
847
|
-
|
|
842
|
+
const { data: d, errors: m } = await r.request(c, { variables: f, signal: u });
|
|
843
|
+
if (m)
|
|
844
|
+
return p(K(m));
|
|
845
|
+
const l = d;
|
|
846
|
+
return l.collection ? M(l.collection) : p(
|
|
847
|
+
C({
|
|
848
848
|
code: "NOT_FOUND",
|
|
849
849
|
source: "shopify",
|
|
850
|
-
message: `Collection not found: ${
|
|
850
|
+
message: `Collection not found: ${i}`
|
|
851
851
|
})
|
|
852
852
|
);
|
|
853
|
-
} catch (
|
|
854
|
-
return
|
|
853
|
+
} catch (d) {
|
|
854
|
+
return p(W(d));
|
|
855
855
|
}
|
|
856
856
|
},
|
|
857
857
|
async getCollectionWithProducts(n) {
|
|
858
858
|
const {
|
|
859
|
-
handle:
|
|
860
|
-
ids:
|
|
859
|
+
handle: i,
|
|
860
|
+
ids: s,
|
|
861
861
|
productMetafields: a = [],
|
|
862
|
-
variantMetafields:
|
|
863
|
-
collectionMetafields:
|
|
864
|
-
includeFilters:
|
|
865
|
-
maxImages:
|
|
866
|
-
maxVariants:
|
|
867
|
-
signal:
|
|
868
|
-
} = n,
|
|
869
|
-
if (
|
|
870
|
-
return
|
|
862
|
+
variantMetafields: u = [],
|
|
863
|
+
collectionMetafields: c = [],
|
|
864
|
+
includeFilters: f = !1,
|
|
865
|
+
maxImages: d = j,
|
|
866
|
+
maxVariants: m = H,
|
|
867
|
+
signal: l
|
|
868
|
+
} = n, g = me(n);
|
|
869
|
+
if (i || g.push(A("handle", "REQUIRED_FIELD", "handle is required")), g.length > 0)
|
|
870
|
+
return p(
|
|
871
871
|
D({
|
|
872
872
|
operation: "getCollectionWithProducts",
|
|
873
|
-
fields:
|
|
873
|
+
fields: g
|
|
874
874
|
})
|
|
875
875
|
);
|
|
876
|
-
const h =
|
|
877
|
-
maxImages:
|
|
878
|
-
maxVariants:
|
|
876
|
+
const h = ft({
|
|
877
|
+
maxImages: d,
|
|
878
|
+
maxVariants: m,
|
|
879
879
|
productMetafields: a,
|
|
880
|
-
variantMetafields:
|
|
881
|
-
collectionMetafields:
|
|
882
|
-
includeFilters:
|
|
883
|
-
}), y =
|
|
884
|
-
let
|
|
880
|
+
variantMetafields: u,
|
|
881
|
+
collectionMetafields: c,
|
|
882
|
+
includeFilters: f
|
|
883
|
+
}), y = s.length > 0 ? ge({ ids: s, maxSize: se }) : [[]];
|
|
884
|
+
let _ = null;
|
|
885
885
|
const b = [];
|
|
886
886
|
for (let v = 0; v < y.length; v++) {
|
|
887
|
-
const E = { ids: y[v], handle:
|
|
888
|
-
a.length > 0 && (E.productMetafields = a),
|
|
887
|
+
const E = { ids: y[v], handle: i };
|
|
888
|
+
a.length > 0 && (E.productMetafields = a), u.length > 0 && (E.variantMetafields = u), c.length > 0 && (E.collectionMetafields = c);
|
|
889
889
|
try {
|
|
890
|
-
const { data: F, errors: P } = await r.request(h, { variables: E, signal:
|
|
890
|
+
const { data: F, errors: P } = await r.request(h, { variables: E, signal: l });
|
|
891
891
|
if (P)
|
|
892
|
-
return
|
|
893
|
-
const
|
|
894
|
-
if (v === 0 && (
|
|
895
|
-
return
|
|
896
|
-
|
|
892
|
+
return p(K(P));
|
|
893
|
+
const R = F;
|
|
894
|
+
if (v === 0 && (_ = R.collection ?? null, !_))
|
|
895
|
+
return p(
|
|
896
|
+
C({
|
|
897
897
|
code: "NOT_FOUND",
|
|
898
898
|
source: "shopify",
|
|
899
|
-
message: `Collection not found: ${
|
|
899
|
+
message: `Collection not found: ${i}`
|
|
900
900
|
})
|
|
901
901
|
);
|
|
902
|
-
const
|
|
903
|
-
b.push(...
|
|
902
|
+
const I = (R.nodes ?? []).filter((O) => O !== null);
|
|
903
|
+
b.push(...I);
|
|
904
904
|
} catch (F) {
|
|
905
|
-
return
|
|
905
|
+
return p(W(F));
|
|
906
906
|
}
|
|
907
907
|
}
|
|
908
|
-
return M({ collection:
|
|
908
|
+
return M({ collection: _, products: b });
|
|
909
909
|
},
|
|
910
910
|
async getPage(n) {
|
|
911
|
-
const { handle:
|
|
912
|
-
if (!
|
|
913
|
-
return
|
|
911
|
+
const { handle: i, pageMetafields: s = [], signal: a } = n;
|
|
912
|
+
if (!i)
|
|
913
|
+
return p(
|
|
914
914
|
D({
|
|
915
915
|
operation: "getPage",
|
|
916
|
-
fields: [
|
|
916
|
+
fields: [A("handle", "REQUIRED_FIELD", "handle is required")]
|
|
917
917
|
})
|
|
918
918
|
);
|
|
919
|
-
const
|
|
920
|
-
|
|
919
|
+
const u = mt({ pageMetafields: s }), c = { handle: i };
|
|
920
|
+
s.length > 0 && (c.pageMetafields = s);
|
|
921
921
|
try {
|
|
922
|
-
const { data:
|
|
923
|
-
if (
|
|
924
|
-
return
|
|
925
|
-
const
|
|
926
|
-
return
|
|
927
|
-
|
|
922
|
+
const { data: f, errors: d } = await r.request(u, { variables: c, signal: a });
|
|
923
|
+
if (d)
|
|
924
|
+
return p(K(d));
|
|
925
|
+
const m = f;
|
|
926
|
+
return m.page ? M(m.page) : p(
|
|
927
|
+
C({
|
|
928
928
|
code: "NOT_FOUND",
|
|
929
929
|
source: "shopify",
|
|
930
|
-
message: `Page not found: ${
|
|
930
|
+
message: `Page not found: ${i}`
|
|
931
931
|
})
|
|
932
932
|
);
|
|
933
|
-
} catch (
|
|
934
|
-
return
|
|
933
|
+
} catch (f) {
|
|
934
|
+
return p(W(f));
|
|
935
935
|
}
|
|
936
936
|
},
|
|
937
937
|
async getPageWithProducts(n) {
|
|
938
938
|
const {
|
|
939
|
-
handle:
|
|
940
|
-
ids:
|
|
939
|
+
handle: i,
|
|
940
|
+
ids: s,
|
|
941
941
|
productMetafields: a = [],
|
|
942
|
-
variantMetafields:
|
|
943
|
-
pageMetafields:
|
|
944
|
-
maxImages:
|
|
945
|
-
maxVariants:
|
|
946
|
-
signal:
|
|
947
|
-
} = n,
|
|
948
|
-
if (
|
|
949
|
-
return
|
|
950
|
-
D({ operation: "getPageWithProducts", fields:
|
|
942
|
+
variantMetafields: u = [],
|
|
943
|
+
pageMetafields: c = [],
|
|
944
|
+
maxImages: f = j,
|
|
945
|
+
maxVariants: d = H,
|
|
946
|
+
signal: m
|
|
947
|
+
} = n, l = me(n);
|
|
948
|
+
if (i || l.push(A("handle", "REQUIRED_FIELD", "handle is required")), l.length > 0)
|
|
949
|
+
return p(
|
|
950
|
+
D({ operation: "getPageWithProducts", fields: l })
|
|
951
951
|
);
|
|
952
|
-
const
|
|
953
|
-
maxImages:
|
|
954
|
-
maxVariants:
|
|
952
|
+
const g = pt({
|
|
953
|
+
maxImages: f,
|
|
954
|
+
maxVariants: d,
|
|
955
955
|
productMetafields: a,
|
|
956
|
-
variantMetafields:
|
|
957
|
-
pageMetafields:
|
|
958
|
-
}), h =
|
|
956
|
+
variantMetafields: u,
|
|
957
|
+
pageMetafields: c
|
|
958
|
+
}), h = s.length > 0 ? ge({ ids: s, maxSize: se }) : [[]];
|
|
959
959
|
let y = null;
|
|
960
|
-
const
|
|
960
|
+
const _ = [];
|
|
961
961
|
for (let b = 0; b < h.length; b++) {
|
|
962
|
-
const S = { ids: h[b], handle:
|
|
963
|
-
a.length > 0 && (S.productMetafields = a),
|
|
962
|
+
const S = { ids: h[b], handle: i };
|
|
963
|
+
a.length > 0 && (S.productMetafields = a), u.length > 0 && (S.variantMetafields = u), c.length > 0 && (S.pageMetafields = c);
|
|
964
964
|
try {
|
|
965
|
-
const { data: E, errors: F } = await r.request(
|
|
965
|
+
const { data: E, errors: F } = await r.request(g, { variables: S, signal: m });
|
|
966
966
|
if (F)
|
|
967
|
-
return
|
|
967
|
+
return p(K(F));
|
|
968
968
|
const P = E;
|
|
969
969
|
if (b === 0 && (y = P.page ?? null, !y))
|
|
970
|
-
return
|
|
971
|
-
|
|
970
|
+
return p(
|
|
971
|
+
C({
|
|
972
972
|
code: "NOT_FOUND",
|
|
973
973
|
source: "shopify",
|
|
974
|
-
message: `Page not found: ${
|
|
974
|
+
message: `Page not found: ${i}`
|
|
975
975
|
})
|
|
976
976
|
);
|
|
977
|
-
const
|
|
978
|
-
|
|
977
|
+
const R = (P.nodes ?? []).filter((I) => I !== null);
|
|
978
|
+
_.push(...R);
|
|
979
979
|
} catch (E) {
|
|
980
|
-
return
|
|
980
|
+
return p(W(E));
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
|
-
return M({ page: y, products:
|
|
983
|
+
return M({ page: y, products: _ });
|
|
984
984
|
}
|
|
985
985
|
});
|
|
986
986
|
}
|
|
987
987
|
function me(e) {
|
|
988
988
|
const t = [];
|
|
989
989
|
e.maxImages !== void 0 && (e.maxImages < ce || e.maxImages > ie) && t.push(
|
|
990
|
-
|
|
990
|
+
A(
|
|
991
991
|
"maxImages",
|
|
992
992
|
"OUT_OF_RANGE",
|
|
993
993
|
`maxImages must be between ${ce} and ${ie}`,
|
|
@@ -997,7 +997,7 @@ function me(e) {
|
|
|
997
997
|
}
|
|
998
998
|
)
|
|
999
999
|
), e.maxVariants !== void 0 && (e.maxVariants < le || e.maxVariants > ae) && t.push(
|
|
1000
|
-
|
|
1000
|
+
A(
|
|
1001
1001
|
"maxVariants",
|
|
1002
1002
|
"OUT_OF_RANGE",
|
|
1003
1003
|
`maxVariants must be between ${le} and ${ae}`,
|
|
@@ -1009,7 +1009,7 @@ function me(e) {
|
|
|
1009
1009
|
);
|
|
1010
1010
|
for (const r of e.productMetafields ?? [])
|
|
1011
1011
|
(!r.namespace || !r.key) && t.push(
|
|
1012
|
-
|
|
1012
|
+
A(
|
|
1013
1013
|
"productMetafields",
|
|
1014
1014
|
"REQUIRED_FIELD",
|
|
1015
1015
|
"Metafield identifier requires both namespace and key",
|
|
@@ -1021,7 +1021,7 @@ function me(e) {
|
|
|
1021
1021
|
);
|
|
1022
1022
|
for (const r of e.variantMetafields ?? [])
|
|
1023
1023
|
(!r.namespace || !r.key) && t.push(
|
|
1024
|
-
|
|
1024
|
+
A(
|
|
1025
1025
|
"variantMetafields",
|
|
1026
1026
|
"REQUIRED_FIELD",
|
|
1027
1027
|
"Metafield identifier requires both namespace and key",
|
|
@@ -1040,40 +1040,40 @@ async function _t({
|
|
|
1040
1040
|
signal: o
|
|
1041
1041
|
}) {
|
|
1042
1042
|
try {
|
|
1043
|
-
const { data: n, errors:
|
|
1044
|
-
if (
|
|
1045
|
-
return
|
|
1046
|
-
const
|
|
1043
|
+
const { data: n, errors: i } = await e.request(t, { variables: r, signal: o });
|
|
1044
|
+
if (i)
|
|
1045
|
+
return p(K(i));
|
|
1046
|
+
const s = (n?.nodes ?? []).filter(
|
|
1047
1047
|
(a) => a !== null
|
|
1048
1048
|
);
|
|
1049
|
-
return M(
|
|
1049
|
+
return M(s);
|
|
1050
1050
|
} catch (n) {
|
|
1051
|
-
return
|
|
1051
|
+
return p(W(n));
|
|
1052
1052
|
}
|
|
1053
1053
|
}
|
|
1054
|
-
function
|
|
1054
|
+
function K(e) {
|
|
1055
1055
|
const t = e.networkStatusCode;
|
|
1056
|
-
return t === 401 ?
|
|
1056
|
+
return t === 401 ? C({
|
|
1057
1057
|
code: "UNAUTHORIZED",
|
|
1058
1058
|
source: "shopify",
|
|
1059
1059
|
message: "Unauthorized: Invalid or missing storefront access token",
|
|
1060
1060
|
status: t
|
|
1061
|
-
}) : t === 403 ?
|
|
1061
|
+
}) : t === 403 ? C({
|
|
1062
1062
|
code: "FORBIDDEN",
|
|
1063
1063
|
source: "shopify",
|
|
1064
1064
|
message: "Forbidden: Access denied to the requested resource",
|
|
1065
1065
|
status: t
|
|
1066
|
-
}) : t === 429 ?
|
|
1066
|
+
}) : t === 429 ? C({
|
|
1067
1067
|
code: "RATE_LIMITED",
|
|
1068
1068
|
source: "shopify",
|
|
1069
1069
|
message: "Rate limited: Too many requests to the Storefront API",
|
|
1070
1070
|
status: t
|
|
1071
|
-
}) : t !== void 0 && t >= 500 ?
|
|
1071
|
+
}) : t !== void 0 && t >= 500 ? C({
|
|
1072
1072
|
code: "SERVICE_UNAVAILABLE",
|
|
1073
1073
|
source: "shopify",
|
|
1074
1074
|
message: `Shopify service error: ${e.message ?? `HTTP ${t}`}`,
|
|
1075
1075
|
status: t
|
|
1076
|
-
}) :
|
|
1076
|
+
}) : C({
|
|
1077
1077
|
code: "GRAPHQL_ERROR",
|
|
1078
1078
|
source: "shopify",
|
|
1079
1079
|
message: e.message ?? "GraphQL request failed",
|
|
@@ -1087,7 +1087,7 @@ function W(e) {
|
|
|
1087
1087
|
}
|
|
1088
1088
|
});
|
|
1089
1089
|
}
|
|
1090
|
-
function
|
|
1090
|
+
function W(e) {
|
|
1091
1091
|
if (e instanceof Error && (e.name === "AbortError" || e.name === "TimeoutError")) {
|
|
1092
1092
|
const t = e.name === "TimeoutError" || e.message.includes("timeout");
|
|
1093
1093
|
return J({
|
|
@@ -1102,194 +1102,227 @@ function K(e) {
|
|
|
1102
1102
|
cause: e
|
|
1103
1103
|
});
|
|
1104
1104
|
}
|
|
1105
|
-
const Oe =
|
|
1106
|
-
function
|
|
1107
|
-
return typeof window > "u" || !window.localStorage ? null :
|
|
1105
|
+
const Oe = 2, Et = "cb-sdk-store";
|
|
1106
|
+
function It(e) {
|
|
1107
|
+
return typeof window > "u" || !window.localStorage ? null : {
|
|
1108
|
+
read: () => window.localStorage.getItem(e),
|
|
1109
|
+
write: (t) => window.localStorage.setItem(e, t),
|
|
1110
|
+
remove: () => window.localStorage.removeItem(e)
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
function or(e, t) {
|
|
1114
|
+
return {
|
|
1115
|
+
read() {
|
|
1116
|
+
try {
|
|
1117
|
+
return t.readFileSync(e, "utf-8");
|
|
1118
|
+
} catch {
|
|
1119
|
+
return null;
|
|
1120
|
+
}
|
|
1121
|
+
},
|
|
1122
|
+
write(r) {
|
|
1123
|
+
try {
|
|
1124
|
+
t.writeFileSync(e, r, "utf-8");
|
|
1125
|
+
} catch {
|
|
1126
|
+
}
|
|
1127
|
+
},
|
|
1128
|
+
remove() {
|
|
1129
|
+
try {
|
|
1130
|
+
t.unlinkSync(e);
|
|
1131
|
+
} catch {
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1108
1135
|
}
|
|
1109
1136
|
function bt(e) {
|
|
1110
|
-
typeof requestIdleCallback == "function" ? requestIdleCallback(e, { timeout:
|
|
1137
|
+
typeof requestIdleCallback == "function" ? requestIdleCallback(e, { timeout: tt }) : setTimeout(e, 0);
|
|
1111
1138
|
}
|
|
1112
|
-
function
|
|
1139
|
+
function Ce(e) {
|
|
1113
1140
|
return [...e].sort((t, r) => r[1].timestamp - t[1].timestamp);
|
|
1114
1141
|
}
|
|
1115
1142
|
function vt({
|
|
1116
|
-
storageKey: e =
|
|
1143
|
+
storageKey: e = Et,
|
|
1117
1144
|
maxProducts: t = ke,
|
|
1118
|
-
maxQueries: r =
|
|
1145
|
+
maxQueries: r = Ne,
|
|
1146
|
+
adapter: o
|
|
1119
1147
|
} = {}) {
|
|
1148
|
+
const n = o ?? It(e);
|
|
1120
1149
|
return {
|
|
1121
|
-
save(
|
|
1122
|
-
const n = pe();
|
|
1150
|
+
save(i) {
|
|
1123
1151
|
n && bt(() => {
|
|
1124
1152
|
try {
|
|
1125
1153
|
const s = {
|
|
1126
|
-
products:
|
|
1154
|
+
products: Ce(i.products).slice(
|
|
1127
1155
|
0,
|
|
1128
1156
|
t
|
|
1129
1157
|
),
|
|
1130
|
-
queries:
|
|
1131
|
-
collections:
|
|
1158
|
+
queries: Ce(i.queries).slice(0, r),
|
|
1159
|
+
collections: i.collections,
|
|
1132
1160
|
version: Oe
|
|
1133
1161
|
};
|
|
1134
|
-
n.
|
|
1162
|
+
n.write(JSON.stringify(s));
|
|
1135
1163
|
} catch {
|
|
1136
1164
|
}
|
|
1137
1165
|
});
|
|
1138
1166
|
},
|
|
1139
1167
|
restore() {
|
|
1140
|
-
|
|
1141
|
-
if (!o) return null;
|
|
1168
|
+
if (!n) return null;
|
|
1142
1169
|
try {
|
|
1143
|
-
const
|
|
1144
|
-
if (!
|
|
1145
|
-
const s = JSON.parse(
|
|
1146
|
-
return s.version !== Oe || !Array.isArray(s.products) || !Array.isArray(s.queries) ? (
|
|
1170
|
+
const i = n.read();
|
|
1171
|
+
if (!i) return null;
|
|
1172
|
+
const s = JSON.parse(i);
|
|
1173
|
+
return s.version !== Oe || !Array.isArray(s.products) || !Array.isArray(s.queries) ? (n.remove(), null) : s;
|
|
1147
1174
|
} catch {
|
|
1148
|
-
return
|
|
1175
|
+
return n.remove(), null;
|
|
1149
1176
|
}
|
|
1150
1177
|
},
|
|
1151
1178
|
clear() {
|
|
1152
|
-
|
|
1179
|
+
n?.remove();
|
|
1153
1180
|
}
|
|
1154
1181
|
};
|
|
1155
1182
|
}
|
|
1156
1183
|
function Ft(e, t) {
|
|
1157
1184
|
if (e.size <= t) return;
|
|
1158
|
-
const o = [...e.entries()].sort((n,
|
|
1185
|
+
const o = [...e.entries()].sort((n, i) => n[1].timestamp - i[1].timestamp).slice(0, e.size - t);
|
|
1159
1186
|
for (const [n] of o)
|
|
1160
1187
|
e.delete(n);
|
|
1161
1188
|
}
|
|
1162
1189
|
function Mt(e, t) {
|
|
1163
1190
|
if (e.size <= t) return;
|
|
1164
1191
|
const r = [];
|
|
1165
|
-
for (const [n,
|
|
1166
|
-
|
|
1167
|
-
r.sort((n,
|
|
1192
|
+
for (const [n, i] of e)
|
|
1193
|
+
i.value && r.push([n, i.value.timestamp]);
|
|
1194
|
+
r.sort((n, i) => n[1] - i[1]);
|
|
1168
1195
|
const o = r.slice(0, e.size - t);
|
|
1169
1196
|
for (const [n] of o) {
|
|
1170
|
-
const
|
|
1171
|
-
|
|
1197
|
+
const i = e.get(n);
|
|
1198
|
+
i && (i.value = null), e.delete(n);
|
|
1172
1199
|
}
|
|
1173
1200
|
}
|
|
1174
1201
|
function St(e = {}) {
|
|
1175
1202
|
const {
|
|
1176
|
-
ttl: t =
|
|
1203
|
+
ttl: t = We,
|
|
1177
1204
|
maxProducts: r = ke,
|
|
1178
|
-
maxQueries: o =
|
|
1179
|
-
storageKey: n
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1205
|
+
maxQueries: o = Ne,
|
|
1206
|
+
storageKey: n,
|
|
1207
|
+
storageAdapter: i
|
|
1208
|
+
} = e, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), f = vt({
|
|
1209
|
+
storageKey: n,
|
|
1210
|
+
maxProducts: r,
|
|
1211
|
+
maxQueries: o,
|
|
1212
|
+
adapter: i
|
|
1213
|
+
});
|
|
1214
|
+
function d(l) {
|
|
1215
|
+
return Date.now() - l > t;
|
|
1183
1216
|
}
|
|
1184
|
-
function
|
|
1185
|
-
let
|
|
1186
|
-
return
|
|
1217
|
+
function m(l) {
|
|
1218
|
+
let g = c.get(l);
|
|
1219
|
+
return g || (g = $(null), c.set(l, g)), g;
|
|
1187
1220
|
}
|
|
1188
1221
|
return {
|
|
1189
1222
|
products: {
|
|
1190
|
-
get(
|
|
1191
|
-
const
|
|
1192
|
-
if (
|
|
1193
|
-
if (g
|
|
1194
|
-
s.delete(
|
|
1223
|
+
get(l) {
|
|
1224
|
+
const g = s.get(l);
|
|
1225
|
+
if (g) {
|
|
1226
|
+
if (d(g.timestamp)) {
|
|
1227
|
+
s.delete(l);
|
|
1195
1228
|
return;
|
|
1196
1229
|
}
|
|
1197
|
-
return
|
|
1230
|
+
return g.data;
|
|
1198
1231
|
}
|
|
1199
1232
|
},
|
|
1200
|
-
getMany(
|
|
1201
|
-
const
|
|
1202
|
-
for (const
|
|
1203
|
-
const
|
|
1204
|
-
|
|
1233
|
+
getMany(l) {
|
|
1234
|
+
const g = [], h = [];
|
|
1235
|
+
for (const y of l) {
|
|
1236
|
+
const _ = s.get(y);
|
|
1237
|
+
_ && !d(_.timestamp) ? g.push(_.data) : h.push(y);
|
|
1205
1238
|
}
|
|
1206
|
-
return { cached:
|
|
1239
|
+
return { cached: g, missing: h };
|
|
1207
1240
|
},
|
|
1208
|
-
set(
|
|
1209
|
-
const
|
|
1210
|
-
for (const
|
|
1211
|
-
s.set(
|
|
1241
|
+
set(l) {
|
|
1242
|
+
const g = Date.now(), h = Array.isArray(l) ? l : [l];
|
|
1243
|
+
for (const y of h)
|
|
1244
|
+
s.set(y.gid, { data: y, timestamp: g });
|
|
1212
1245
|
Ft(s, r);
|
|
1213
1246
|
},
|
|
1214
|
-
has(
|
|
1215
|
-
const
|
|
1216
|
-
return
|
|
1247
|
+
has(l) {
|
|
1248
|
+
const g = s.get(l);
|
|
1249
|
+
return g != null && !d(g.timestamp);
|
|
1217
1250
|
}
|
|
1218
1251
|
},
|
|
1219
1252
|
queries: {
|
|
1220
|
-
get(
|
|
1221
|
-
return
|
|
1253
|
+
get(l) {
|
|
1254
|
+
return m(l);
|
|
1222
1255
|
},
|
|
1223
|
-
set(
|
|
1224
|
-
const
|
|
1225
|
-
|
|
1256
|
+
set(l, g) {
|
|
1257
|
+
const h = m(l);
|
|
1258
|
+
h.value = { data: g, timestamp: Date.now() }, Mt(c, o);
|
|
1226
1259
|
},
|
|
1227
|
-
isExpired(
|
|
1228
|
-
const
|
|
1229
|
-
return
|
|
1260
|
+
isExpired(l) {
|
|
1261
|
+
const g = c.get(l);
|
|
1262
|
+
return g?.value ? d(g.value.timestamp) : !0;
|
|
1230
1263
|
},
|
|
1231
|
-
invalidate(
|
|
1232
|
-
for (const [
|
|
1233
|
-
|
|
1264
|
+
invalidate(l) {
|
|
1265
|
+
for (const [g, h] of c)
|
|
1266
|
+
g.includes(l) && (h.value = null);
|
|
1234
1267
|
}
|
|
1235
1268
|
},
|
|
1236
1269
|
collections: {
|
|
1237
|
-
get(
|
|
1238
|
-
return
|
|
1270
|
+
get(l) {
|
|
1271
|
+
return a.get(l);
|
|
1239
1272
|
},
|
|
1240
|
-
set(
|
|
1241
|
-
|
|
1273
|
+
set(l, g) {
|
|
1274
|
+
a.set(l, { ...g, handle: l });
|
|
1242
1275
|
},
|
|
1243
|
-
delete(
|
|
1244
|
-
|
|
1276
|
+
delete(l) {
|
|
1277
|
+
a.delete(l);
|
|
1245
1278
|
}
|
|
1246
1279
|
},
|
|
1247
1280
|
pages: {
|
|
1248
|
-
get(
|
|
1249
|
-
return
|
|
1281
|
+
get(l) {
|
|
1282
|
+
return u.get(l);
|
|
1250
1283
|
},
|
|
1251
|
-
set(
|
|
1252
|
-
|
|
1284
|
+
set(l, g) {
|
|
1285
|
+
u.set(l, { ...g, handle: l });
|
|
1253
1286
|
},
|
|
1254
|
-
delete(
|
|
1255
|
-
|
|
1287
|
+
delete(l) {
|
|
1288
|
+
u.delete(l);
|
|
1256
1289
|
}
|
|
1257
1290
|
},
|
|
1258
1291
|
persist() {
|
|
1259
|
-
const
|
|
1260
|
-
for (const [
|
|
1261
|
-
|
|
1262
|
-
for (const [
|
|
1263
|
-
|
|
1264
|
-
for (const [
|
|
1265
|
-
|
|
1266
|
-
|
|
1292
|
+
const l = [], g = [], h = [];
|
|
1293
|
+
for (const [y, _] of s)
|
|
1294
|
+
d(_.timestamp) || l.push([y, _]);
|
|
1295
|
+
for (const [y, _] of c)
|
|
1296
|
+
_.value && !d(_.value.timestamp) && g.push([y, _.value]);
|
|
1297
|
+
for (const [y, _] of a)
|
|
1298
|
+
h.push([y, _]);
|
|
1299
|
+
f.save({ products: l, queries: g, collections: h });
|
|
1267
1300
|
},
|
|
1268
1301
|
restore() {
|
|
1269
|
-
const
|
|
1270
|
-
if (
|
|
1271
|
-
for (const [
|
|
1272
|
-
|
|
1273
|
-
for (const [
|
|
1274
|
-
if (!
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1302
|
+
const l = f.restore();
|
|
1303
|
+
if (l) {
|
|
1304
|
+
for (const [g, h] of l.products)
|
|
1305
|
+
d(h.timestamp) || s.set(g, h);
|
|
1306
|
+
for (const [g, h] of l.queries)
|
|
1307
|
+
if (!d(h.timestamp)) {
|
|
1308
|
+
const y = m(g);
|
|
1309
|
+
y.value = h;
|
|
1277
1310
|
}
|
|
1278
|
-
for (const [
|
|
1279
|
-
|
|
1311
|
+
for (const [g, h] of l.collections)
|
|
1312
|
+
a.set(g, h);
|
|
1280
1313
|
}
|
|
1281
1314
|
},
|
|
1282
1315
|
clear() {
|
|
1283
1316
|
s.clear();
|
|
1284
|
-
for (const
|
|
1285
|
-
|
|
1317
|
+
for (const l of c.values()) l.value = null;
|
|
1318
|
+
c.clear(), a.clear(), u.clear(), f.clear();
|
|
1286
1319
|
},
|
|
1287
1320
|
get stats() {
|
|
1288
1321
|
return {
|
|
1289
1322
|
products: s.size,
|
|
1290
|
-
queries:
|
|
1291
|
-
collections:
|
|
1292
|
-
pages:
|
|
1323
|
+
queries: c.size,
|
|
1324
|
+
collections: a.size,
|
|
1325
|
+
pages: u.size
|
|
1293
1326
|
};
|
|
1294
1327
|
}
|
|
1295
1328
|
};
|
|
@@ -1304,112 +1337,112 @@ function Pt(e, t = {}) {
|
|
|
1304
1337
|
const r = `/browse/${encodeURIComponent(e)}`, o = Ae(t, ["collectionHandle", "signal"]);
|
|
1305
1338
|
return o ? `${r}?${o}` : r;
|
|
1306
1339
|
}
|
|
1307
|
-
function
|
|
1340
|
+
function At(e, t = {}) {
|
|
1308
1341
|
if (!e?.trim()) return;
|
|
1309
1342
|
const r = `/search/${encodeURIComponent(e)}`, o = Ae(t, ["query", "signal"]);
|
|
1310
1343
|
return o ? `${r}?${o}` : r;
|
|
1311
1344
|
}
|
|
1312
|
-
function
|
|
1345
|
+
function Rt(e, t = {}) {
|
|
1313
1346
|
if (!e?.trim()) return;
|
|
1314
1347
|
const r = `/blocks/${encodeURIComponent(e)}`, o = Ae(t, ["blockId", "signal"]);
|
|
1315
1348
|
return o ? `${r}?${o}` : r;
|
|
1316
1349
|
}
|
|
1317
|
-
var
|
|
1318
|
-
function
|
|
1350
|
+
var pe = /* @__PURE__ */ ((e) => (e.Equal = "eq", e.NotEqual = "not_eq", e.In = "in", e.NotIn = "not_in", e.GreaterThan = "gt", e.GreaterThanOrEqual = "gte", e.LessThan = "lt", e.LessThanOrEqual = "lte", e.Exists = "exists", e.NotExists = "not_exists", e))(pe || {}), Ve = /* @__PURE__ */ ((e) => (e.And = "AND", e.Or = "OR", e))(Ve || {});
|
|
1351
|
+
function sr(e, t) {
|
|
1319
1352
|
return { property: e, operator: "eq", values: [t] };
|
|
1320
1353
|
}
|
|
1321
|
-
function
|
|
1354
|
+
function ir(e, t) {
|
|
1322
1355
|
return { property: e, operator: "not_eq", values: [t] };
|
|
1323
1356
|
}
|
|
1324
|
-
function
|
|
1357
|
+
function ar(e, t) {
|
|
1325
1358
|
return { property: e, operator: "in", values: t };
|
|
1326
1359
|
}
|
|
1327
|
-
function
|
|
1360
|
+
function cr(e, t) {
|
|
1328
1361
|
return { property: e, operator: "not_in", values: t };
|
|
1329
1362
|
}
|
|
1330
|
-
function
|
|
1363
|
+
function lr(e, t) {
|
|
1331
1364
|
return { property: e, operator: "gt", values: [t] };
|
|
1332
1365
|
}
|
|
1333
|
-
function
|
|
1366
|
+
function ur(e, t) {
|
|
1334
1367
|
return { property: e, operator: "gte", values: [t] };
|
|
1335
1368
|
}
|
|
1336
|
-
function
|
|
1369
|
+
function dr(e, t) {
|
|
1337
1370
|
return { property: e, operator: "lt", values: [t] };
|
|
1338
1371
|
}
|
|
1339
|
-
function
|
|
1372
|
+
function fr(e, t) {
|
|
1340
1373
|
return { property: e, operator: "lte", values: [t] };
|
|
1341
1374
|
}
|
|
1342
|
-
function
|
|
1375
|
+
function gr(e) {
|
|
1343
1376
|
return { property: e, operator: "exists", values: [] };
|
|
1344
1377
|
}
|
|
1345
|
-
function
|
|
1378
|
+
function mr(e) {
|
|
1346
1379
|
return { property: e, operator: "not_exists", values: [] };
|
|
1347
1380
|
}
|
|
1348
1381
|
function Tt(...e) {
|
|
1349
1382
|
return { conditional: "AND", expressions: e };
|
|
1350
1383
|
}
|
|
1351
|
-
function
|
|
1384
|
+
function pr(...e) {
|
|
1352
1385
|
return { conditional: "OR", expressions: e };
|
|
1353
1386
|
}
|
|
1354
1387
|
function wt(e) {
|
|
1355
1388
|
return "conditional" in e;
|
|
1356
1389
|
}
|
|
1357
|
-
function
|
|
1390
|
+
function hr(e) {
|
|
1358
1391
|
return { filter_group: wt(e) ? e : Tt(e) };
|
|
1359
1392
|
}
|
|
1360
1393
|
function Dt(e, t) {
|
|
1361
1394
|
return `gid://shopify/${e}/${t}`;
|
|
1362
1395
|
}
|
|
1363
|
-
function
|
|
1396
|
+
function Ot(e) {
|
|
1364
1397
|
return Dt("Product", e);
|
|
1365
1398
|
}
|
|
1366
|
-
function
|
|
1399
|
+
function Be({
|
|
1367
1400
|
type: e,
|
|
1368
1401
|
selectedOptions: t
|
|
1369
1402
|
}) {
|
|
1370
1403
|
const r = t.map(({ name: o, value: n }) => `${o}:${n}`).join("-");
|
|
1371
1404
|
return `${e}-${r}`;
|
|
1372
1405
|
}
|
|
1373
|
-
function
|
|
1406
|
+
function xe(e) {
|
|
1374
1407
|
return e.product_id ?? e.id;
|
|
1375
1408
|
}
|
|
1376
|
-
function
|
|
1377
|
-
return
|
|
1409
|
+
function he(e) {
|
|
1410
|
+
return Ot(xe(e));
|
|
1378
1411
|
}
|
|
1379
|
-
function
|
|
1412
|
+
function Ct(e, t = {}) {
|
|
1380
1413
|
const {
|
|
1381
|
-
currencyCode: r =
|
|
1382
|
-
formatPrice: o =
|
|
1414
|
+
currencyCode: r = Ze,
|
|
1415
|
+
formatPrice: o = rt,
|
|
1383
1416
|
swatches: n = []
|
|
1384
|
-
} = t,
|
|
1385
|
-
min: S.reduce((
|
|
1386
|
-
max: S.reduce((
|
|
1387
|
-
} : void 0, F = e.first_or_matched_variant ? $t(e.first_or_matched_variant) : [], P =
|
|
1417
|
+
} = t, i = xe(e), s = he(e), a = e.title, u = e.handle ?? "", c = e.vendor ?? "", f = e.product_type ?? "", d = e.body_html ?? "", m = e.available ?? !1, l = e.is_gift_card ?? !1, g = Bt(e), h = e.tags ?? [], y = kt(e), _ = Nt(e.price_range, r, o), b = qt(e, n), v = Lt(e, r, o), S = v.map((I) => I.compareAtPrice).filter((I) => I !== null), E = S.length > 0 ? {
|
|
1418
|
+
min: S.reduce((I, O) => I.amount < O.amount ? I : O),
|
|
1419
|
+
max: S.reduce((I, O) => I.amount > O.amount ? I : O)
|
|
1420
|
+
} : void 0, F = e.first_or_matched_variant ? $t(e.first_or_matched_variant) : [], P = Be({ type: "Product", selectedOptions: F }), R = e.metafields ?? {};
|
|
1388
1421
|
return {
|
|
1389
1422
|
id: P,
|
|
1390
|
-
gid:
|
|
1391
|
-
numericId:
|
|
1423
|
+
gid: s,
|
|
1424
|
+
numericId: i,
|
|
1392
1425
|
title: a,
|
|
1393
|
-
handle:
|
|
1394
|
-
type:
|
|
1395
|
-
vendor:
|
|
1396
|
-
description:
|
|
1397
|
-
availableForSale:
|
|
1426
|
+
handle: u,
|
|
1427
|
+
type: f,
|
|
1428
|
+
vendor: c,
|
|
1429
|
+
description: d,
|
|
1430
|
+
availableForSale: m,
|
|
1398
1431
|
images: y,
|
|
1399
|
-
priceRange:
|
|
1432
|
+
priceRange: _,
|
|
1400
1433
|
compareAtPriceRange: E,
|
|
1401
1434
|
options: b,
|
|
1402
1435
|
tags: h,
|
|
1403
1436
|
variants: v,
|
|
1404
1437
|
selectedOptions: F,
|
|
1405
|
-
metafields:
|
|
1438
|
+
metafields: R,
|
|
1406
1439
|
calculated: e.calculated,
|
|
1407
|
-
isGiftCard:
|
|
1440
|
+
isGiftCard: l,
|
|
1408
1441
|
onlineStoreUrl: null,
|
|
1409
|
-
totalInventory:
|
|
1442
|
+
totalInventory: g
|
|
1410
1443
|
};
|
|
1411
1444
|
}
|
|
1412
|
-
function
|
|
1445
|
+
function kt(e) {
|
|
1413
1446
|
return (e.images ?? []).map((t) => ({
|
|
1414
1447
|
url: t.src,
|
|
1415
1448
|
alt: t.alt ?? "",
|
|
@@ -1417,7 +1450,7 @@ function Nt(e) {
|
|
|
1417
1450
|
height: t.height
|
|
1418
1451
|
}));
|
|
1419
1452
|
}
|
|
1420
|
-
function
|
|
1453
|
+
function Nt(e, t, r) {
|
|
1421
1454
|
const o = e?.from ?? 0, n = e?.to ?? o;
|
|
1422
1455
|
return {
|
|
1423
1456
|
min: { amount: o, currencyCode: t, formatted: r(o, t) },
|
|
@@ -1426,10 +1459,10 @@ function kt(e, t, r) {
|
|
|
1426
1459
|
}
|
|
1427
1460
|
function qt(e, t) {
|
|
1428
1461
|
const r = [], o = e.options ?? {};
|
|
1429
|
-
for (const [n,
|
|
1430
|
-
for (const
|
|
1431
|
-
const a = t.find((
|
|
1432
|
-
r.push({ name: n, value:
|
|
1462
|
+
for (const [n, i] of Object.entries(o))
|
|
1463
|
+
for (const s of i) {
|
|
1464
|
+
const a = t.find((u) => u.name === n && u.value === s);
|
|
1465
|
+
r.push({ name: n, value: s, swatch: a });
|
|
1433
1466
|
}
|
|
1434
1467
|
return r;
|
|
1435
1468
|
}
|
|
@@ -1442,7 +1475,7 @@ function Lt(e, t, r) {
|
|
|
1442
1475
|
function Ut(e, t, r) {
|
|
1443
1476
|
const o = parseFloat(e.price), n = e.compare_at_price ? parseFloat(e.compare_at_price) : null;
|
|
1444
1477
|
return {
|
|
1445
|
-
id:
|
|
1478
|
+
id: Be({ type: "ProductVariant", selectedOptions: e.selected_options }),
|
|
1446
1479
|
gid: `gid://shopify/ProductVariant/${e.id}`,
|
|
1447
1480
|
numericId: e.id,
|
|
1448
1481
|
title: e.title,
|
|
@@ -1466,9 +1499,10 @@ function Ut(e, t, r) {
|
|
|
1466
1499
|
width: e.featured_media.width,
|
|
1467
1500
|
height: e.featured_media.height
|
|
1468
1501
|
} : null,
|
|
1469
|
-
selectedOptions: e.selected_options.map((
|
|
1502
|
+
selectedOptions: e.selected_options.map((i) => ({ name: i.name, value: i.value })),
|
|
1470
1503
|
metafields: Vt(e.metafields),
|
|
1471
|
-
inventoryLevels: e.inventory_levels ?? {}
|
|
1504
|
+
inventoryLevels: e.inventory_levels ?? {},
|
|
1505
|
+
inStockLocationIds: e.in_stock_location_ids ?? []
|
|
1472
1506
|
};
|
|
1473
1507
|
}
|
|
1474
1508
|
function Vt(e) {
|
|
@@ -1483,16 +1517,16 @@ function Bt(e) {
|
|
|
1483
1517
|
const t = e.first_or_matched_variant;
|
|
1484
1518
|
return t?.inventory_quantity != null ? t.inventory_quantity : 0;
|
|
1485
1519
|
}
|
|
1486
|
-
function
|
|
1520
|
+
function Ge() {
|
|
1487
1521
|
return typeof window < "u" && typeof window.document < "u";
|
|
1488
1522
|
}
|
|
1489
1523
|
const je = "__COMMERCE_BLOCKS__";
|
|
1490
1524
|
function xt(e) {
|
|
1491
|
-
|
|
1525
|
+
Ge() && (window[je] = e);
|
|
1492
1526
|
}
|
|
1493
1527
|
function Gt() {
|
|
1494
|
-
if (!
|
|
1495
|
-
return
|
|
1528
|
+
if (!Ge())
|
|
1529
|
+
return p(
|
|
1496
1530
|
B({
|
|
1497
1531
|
code: "INVALID_CONFIG",
|
|
1498
1532
|
message: "SDK only available in browser",
|
|
@@ -1501,7 +1535,7 @@ function Gt() {
|
|
|
1501
1535
|
})
|
|
1502
1536
|
);
|
|
1503
1537
|
const e = window[je];
|
|
1504
|
-
return e ? M(e) :
|
|
1538
|
+
return e ? M(e) : p(
|
|
1505
1539
|
B({
|
|
1506
1540
|
code: "MISSING_CONFIG",
|
|
1507
1541
|
message: "SDK not initialized. Call createSdk() first.",
|
|
@@ -1509,7 +1543,7 @@ function Gt() {
|
|
|
1509
1543
|
})
|
|
1510
1544
|
);
|
|
1511
1545
|
}
|
|
1512
|
-
function
|
|
1546
|
+
function yr() {
|
|
1513
1547
|
return Gt().data !== void 0;
|
|
1514
1548
|
}
|
|
1515
1549
|
function ne({
|
|
@@ -1522,11 +1556,15 @@ function ne({
|
|
|
1522
1556
|
totalResults: t.totalResults,
|
|
1523
1557
|
totalPages: t.totalPages,
|
|
1524
1558
|
page: t.page,
|
|
1525
|
-
|
|
1559
|
+
resultsPerPage: t.resultsPerPage,
|
|
1560
|
+
facets: t.facets ?? {},
|
|
1561
|
+
facetRanges: t.facetRanges,
|
|
1562
|
+
attributionToken: t.attributionToken,
|
|
1563
|
+
_workflow: t._workflow
|
|
1526
1564
|
};
|
|
1527
1565
|
return r ? r(o, t) : o;
|
|
1528
1566
|
}
|
|
1529
|
-
function
|
|
1567
|
+
function jt(e) {
|
|
1530
1568
|
return {
|
|
1531
1569
|
id: "",
|
|
1532
1570
|
handle: e.handle,
|
|
@@ -1544,65 +1582,65 @@ function Ht(e) {
|
|
|
1544
1582
|
metafields: e.metafields
|
|
1545
1583
|
};
|
|
1546
1584
|
}
|
|
1547
|
-
function
|
|
1585
|
+
function Ht({ ctx: e }) {
|
|
1548
1586
|
function t(a) {
|
|
1549
|
-
return a.map(
|
|
1587
|
+
return a.map(he);
|
|
1550
1588
|
}
|
|
1551
|
-
function r(a,
|
|
1552
|
-
const
|
|
1589
|
+
function r(a, u) {
|
|
1590
|
+
const c = Ct(a, e.mergeConfig);
|
|
1553
1591
|
return e.config.extendProduct ? { ...e.config.extendProduct({
|
|
1554
|
-
base:
|
|
1592
|
+
base: c,
|
|
1555
1593
|
raw: a,
|
|
1556
|
-
shopify:
|
|
1557
|
-
}), _base:
|
|
1594
|
+
shopify: u
|
|
1595
|
+
}), _base: c } : c;
|
|
1558
1596
|
}
|
|
1559
|
-
function o(a,
|
|
1560
|
-
return a.map((
|
|
1561
|
-
const
|
|
1562
|
-
return
|
|
1597
|
+
function o(a, u, c) {
|
|
1598
|
+
return a.map((f) => {
|
|
1599
|
+
const d = he(f), m = c.get(d);
|
|
1600
|
+
return m || r(f, u.get(d) ?? null);
|
|
1563
1601
|
});
|
|
1564
1602
|
}
|
|
1565
|
-
async function n(a,
|
|
1566
|
-
const
|
|
1567
|
-
if (!e.storefrontEnabled || a.length === 0) return M(
|
|
1568
|
-
const
|
|
1603
|
+
async function n(a, u = e.config.productMetafields, c = e.config.variantMetafields) {
|
|
1604
|
+
const f = /* @__PURE__ */ new Map();
|
|
1605
|
+
if (!e.storefrontEnabled || a.length === 0) return M(f);
|
|
1606
|
+
const d = await e.storefront.getProducts({
|
|
1569
1607
|
ids: a,
|
|
1570
|
-
productMetafields:
|
|
1571
|
-
variantMetafields:
|
|
1608
|
+
productMetafields: u,
|
|
1609
|
+
variantMetafields: c
|
|
1572
1610
|
});
|
|
1573
|
-
if (
|
|
1574
|
-
for (const
|
|
1575
|
-
|
|
1576
|
-
return M(
|
|
1611
|
+
if (d.error) return p(d.error);
|
|
1612
|
+
for (const m of d.data)
|
|
1613
|
+
f.set(m.id, m);
|
|
1614
|
+
return M(f);
|
|
1577
1615
|
}
|
|
1578
|
-
async function
|
|
1579
|
-
const
|
|
1580
|
-
if (
|
|
1581
|
-
return M(
|
|
1582
|
-
const
|
|
1583
|
-
return
|
|
1616
|
+
async function i(a) {
|
|
1617
|
+
const u = t(a), { cached: c, missing: f } = e.store.products.getMany(u), d = new Map(c.map((l) => [l.gid, l]));
|
|
1618
|
+
if (f.length === 0)
|
|
1619
|
+
return M(u.map((l) => d.get(l)));
|
|
1620
|
+
const m = await n(f);
|
|
1621
|
+
return m.error ? p(m.error) : M(o(a, m.data, d));
|
|
1584
1622
|
}
|
|
1585
|
-
function
|
|
1623
|
+
function s(a) {
|
|
1586
1624
|
if (a) {
|
|
1587
1625
|
if (e.config.transformFilters)
|
|
1588
1626
|
return e.config.transformFilters(a);
|
|
1589
1627
|
if (e.config.filterMap && typeof a == "object" && !Array.isArray(a)) {
|
|
1590
|
-
const
|
|
1591
|
-
for (const [
|
|
1592
|
-
if (
|
|
1593
|
-
const
|
|
1594
|
-
const b = String(
|
|
1595
|
-
return
|
|
1628
|
+
const u = a, c = [];
|
|
1629
|
+
for (const [f, d] of Object.entries(u)) {
|
|
1630
|
+
if (d == null) continue;
|
|
1631
|
+
const m = e.config.filterMap[f], l = typeof m == "string" ? m : m?.property ?? f, g = typeof m == "object" ? m.values : void 0, y = (Array.isArray(d) ? d : [d]).map((_) => {
|
|
1632
|
+
const b = String(_);
|
|
1633
|
+
return g?.[b] ?? b;
|
|
1596
1634
|
});
|
|
1597
|
-
|
|
1598
|
-
property:
|
|
1599
|
-
operator: y.length > 1 ?
|
|
1635
|
+
c.push({
|
|
1636
|
+
property: l,
|
|
1637
|
+
operator: y.length > 1 ? pe.In : pe.Equal,
|
|
1600
1638
|
values: y
|
|
1601
1639
|
});
|
|
1602
1640
|
}
|
|
1603
|
-
return
|
|
1604
|
-
conditional:
|
|
1605
|
-
expressions:
|
|
1641
|
+
return c.length === 0 ? void 0 : {
|
|
1642
|
+
conditional: Ve.And,
|
|
1643
|
+
expressions: c
|
|
1606
1644
|
};
|
|
1607
1645
|
}
|
|
1608
1646
|
return a;
|
|
@@ -1613,8 +1651,8 @@ function jt({ ctx: e }) {
|
|
|
1613
1651
|
buildSingleProduct: r,
|
|
1614
1652
|
buildProductsWithCache: o,
|
|
1615
1653
|
fetchStorefrontProductsMap: n,
|
|
1616
|
-
fetchAndBuildProducts:
|
|
1617
|
-
transformFilters:
|
|
1654
|
+
fetchAndBuildProducts: i,
|
|
1655
|
+
transformFilters: s
|
|
1618
1656
|
};
|
|
1619
1657
|
}
|
|
1620
1658
|
function oe(e) {
|
|
@@ -1637,14 +1675,14 @@ function X({
|
|
|
1637
1675
|
paramDefinitions: t,
|
|
1638
1676
|
transformBody: r
|
|
1639
1677
|
}) {
|
|
1640
|
-
const o = Qt({ definitions: t }), n = { ...e, ...o },
|
|
1641
|
-
if (!(!
|
|
1642
|
-
return (
|
|
1643
|
-
const a =
|
|
1678
|
+
const o = Qt({ definitions: t }), n = { ...e, ...o }, i = Object.keys(n).length > 0;
|
|
1679
|
+
if (!(!i && !r))
|
|
1680
|
+
return (s) => {
|
|
1681
|
+
const a = i ? { ...s, ...n } : s;
|
|
1644
1682
|
return r ? r(a) : a;
|
|
1645
1683
|
};
|
|
1646
1684
|
}
|
|
1647
|
-
function
|
|
1685
|
+
function Kt({
|
|
1648
1686
|
ctx: e,
|
|
1649
1687
|
helpers: t
|
|
1650
1688
|
}) {
|
|
@@ -1654,86 +1692,86 @@ function Wt({
|
|
|
1654
1692
|
error: null,
|
|
1655
1693
|
isFetching: !1
|
|
1656
1694
|
});
|
|
1657
|
-
let
|
|
1695
|
+
let i = null, s = o ?? e.config.sorts[0]?.code;
|
|
1658
1696
|
return {
|
|
1659
1697
|
state: n,
|
|
1660
1698
|
async execute(a = {}) {
|
|
1661
1699
|
const {
|
|
1662
|
-
page:
|
|
1663
|
-
limit:
|
|
1664
|
-
filters:
|
|
1665
|
-
sortOrderCode:
|
|
1666
|
-
signal:
|
|
1667
|
-
includeMeta:
|
|
1668
|
-
collectionMetafields:
|
|
1700
|
+
page: u = Y,
|
|
1701
|
+
limit: c = Z,
|
|
1702
|
+
filters: f,
|
|
1703
|
+
sortOrderCode: d,
|
|
1704
|
+
signal: m,
|
|
1705
|
+
includeMeta: l = e.config.includeMeta ?? !1,
|
|
1706
|
+
collectionMetafields: g = e.config.collectionMetafields,
|
|
1669
1707
|
includeFilters: h,
|
|
1670
1708
|
dynamicLinking: y,
|
|
1671
|
-
params:
|
|
1709
|
+
params: _,
|
|
1672
1710
|
paramDefinitions: b,
|
|
1673
1711
|
transformBody: v
|
|
1674
|
-
} = a, S =
|
|
1675
|
-
|
|
1712
|
+
} = a, S = d ?? s;
|
|
1713
|
+
s = S, i?.abort(), i = oe(m);
|
|
1676
1714
|
const E = n.value.data;
|
|
1677
1715
|
n.value = { data: E, error: null, isFetching: !0 };
|
|
1678
1716
|
const { data: F, error: P } = await e.layers.browse(
|
|
1679
1717
|
{
|
|
1680
1718
|
collectionHandle: r,
|
|
1681
1719
|
sort_order_code: S,
|
|
1682
|
-
pagination: { page:
|
|
1683
|
-
filter_group: t.transformFilters(
|
|
1720
|
+
pagination: { page: u, limit: c },
|
|
1721
|
+
filter_group: t.transformFilters(f),
|
|
1684
1722
|
dynamicLinking: y,
|
|
1685
|
-
transformBody: X({ params:
|
|
1723
|
+
transformBody: X({ params: _, paramDefinitions: b, transformBody: v })
|
|
1686
1724
|
},
|
|
1687
|
-
|
|
1725
|
+
i.signal
|
|
1688
1726
|
);
|
|
1689
1727
|
if (P)
|
|
1690
|
-
return n.value = { data: E, error: P, isFetching: !1 },
|
|
1691
|
-
const { results:
|
|
1728
|
+
return n.value = { data: E, error: P, isFetching: !1 }, p(P);
|
|
1729
|
+
const { results: R } = F, I = R, O = t.extractGids(I), { cached: k, missing: N } = e.store.products.getMany(O), L = new Map(k.map((w) => [w.gid, w])), U = l && !g?.length ? e.store.collections.get(r) : void 0, Re = U?.title !== void 0;
|
|
1692
1730
|
let x, T;
|
|
1693
|
-
if (
|
|
1694
|
-
x =
|
|
1695
|
-
else if (e.storefrontEnabled &&
|
|
1731
|
+
if (N.length === 0)
|
|
1732
|
+
x = O.map((w) => L.get(w));
|
|
1733
|
+
else if (e.storefrontEnabled && l && !Re) {
|
|
1696
1734
|
const w = await e.storefront.getCollectionWithProducts({
|
|
1697
1735
|
handle: r,
|
|
1698
|
-
ids:
|
|
1736
|
+
ids: N,
|
|
1699
1737
|
productMetafields: e.config.productMetafields,
|
|
1700
1738
|
variantMetafields: e.config.variantMetafields,
|
|
1701
|
-
collectionMetafields:
|
|
1739
|
+
collectionMetafields: g,
|
|
1702
1740
|
includeFilters: h
|
|
1703
1741
|
});
|
|
1704
1742
|
if (w.data) {
|
|
1705
1743
|
T = w.data.collection;
|
|
1706
1744
|
const V = /* @__PURE__ */ new Map();
|
|
1707
|
-
for (const
|
|
1708
|
-
V.set(
|
|
1709
|
-
x = t.buildProductsWithCache(
|
|
1745
|
+
for (const we of w.data.products)
|
|
1746
|
+
V.set(we.id, we);
|
|
1747
|
+
x = t.buildProductsWithCache(I, V, L);
|
|
1710
1748
|
} else {
|
|
1711
|
-
const V = await t.fetchStorefrontProductsMap(
|
|
1749
|
+
const V = await t.fetchStorefrontProductsMap(N);
|
|
1712
1750
|
if (V.error)
|
|
1713
|
-
return n.value = { data: E, error: V.error, isFetching: !1 },
|
|
1751
|
+
return n.value = { data: E, error: V.error, isFetching: !1 }, p(V.error);
|
|
1714
1752
|
x = t.buildProductsWithCache(
|
|
1715
|
-
|
|
1753
|
+
I,
|
|
1716
1754
|
V.data,
|
|
1717
1755
|
L
|
|
1718
1756
|
);
|
|
1719
1757
|
}
|
|
1720
1758
|
} else {
|
|
1721
|
-
const w = await t.fetchStorefrontProductsMap(
|
|
1759
|
+
const w = await t.fetchStorefrontProductsMap(N);
|
|
1722
1760
|
if (w.error)
|
|
1723
|
-
return n.value = { data: E, error: w.error, isFetching: !1 },
|
|
1761
|
+
return n.value = { data: E, error: w.error, isFetching: !1 }, p(w.error);
|
|
1724
1762
|
x = t.buildProductsWithCache(
|
|
1725
|
-
|
|
1763
|
+
I,
|
|
1726
1764
|
w.data,
|
|
1727
1765
|
L
|
|
1728
1766
|
);
|
|
1729
1767
|
}
|
|
1730
|
-
if (e.storefrontEnabled &&
|
|
1731
|
-
if (
|
|
1732
|
-
T =
|
|
1768
|
+
if (e.storefrontEnabled && l && !T)
|
|
1769
|
+
if (Re)
|
|
1770
|
+
T = jt(U);
|
|
1733
1771
|
else {
|
|
1734
1772
|
const w = await e.storefront.getCollection({
|
|
1735
1773
|
handle: r,
|
|
1736
|
-
collectionMetafields:
|
|
1774
|
+
collectionMetafields: g,
|
|
1737
1775
|
includeFilters: h
|
|
1738
1776
|
});
|
|
1739
1777
|
w.data && (T = w.data);
|
|
@@ -1743,12 +1781,12 @@ function Wt({
|
|
|
1743
1781
|
raw: F,
|
|
1744
1782
|
extender: e.config.extendCollection
|
|
1745
1783
|
});
|
|
1746
|
-
|
|
1747
|
-
const
|
|
1748
|
-
return
|
|
1784
|
+
l && F._meta && (q._meta = F._meta), T && (q.collection = T);
|
|
1785
|
+
const Te = Pt(r, { sortOrderCode: S, page: u, limit: c, filters: f });
|
|
1786
|
+
return Te && e.store.queries.set(Te, q), e.store.products.set(x), e.store.collections.set(r, {
|
|
1749
1787
|
totalProducts: q.totalResults,
|
|
1750
1788
|
totalPages: q.totalPages,
|
|
1751
|
-
lastPageFetched:
|
|
1789
|
+
lastPageFetched: u,
|
|
1752
1790
|
facets: q.facets,
|
|
1753
1791
|
lastFetched: Date.now(),
|
|
1754
1792
|
...T && {
|
|
@@ -1766,12 +1804,12 @@ function Wt({
|
|
|
1766
1804
|
}), n.value = { data: q, error: null, isFetching: !1 }, M(q);
|
|
1767
1805
|
},
|
|
1768
1806
|
dispose() {
|
|
1769
|
-
|
|
1807
|
+
i?.abort();
|
|
1770
1808
|
}
|
|
1771
1809
|
};
|
|
1772
1810
|
};
|
|
1773
1811
|
}
|
|
1774
|
-
function
|
|
1812
|
+
function Wt({
|
|
1775
1813
|
ctx: e,
|
|
1776
1814
|
helpers: t
|
|
1777
1815
|
}) {
|
|
@@ -1784,107 +1822,107 @@ function Kt({
|
|
|
1784
1822
|
let o = null, n;
|
|
1785
1823
|
return {
|
|
1786
1824
|
state: r,
|
|
1787
|
-
async prepare(
|
|
1825
|
+
async prepare(i) {
|
|
1788
1826
|
const {
|
|
1789
|
-
query:
|
|
1827
|
+
query: s,
|
|
1790
1828
|
filters: a,
|
|
1791
|
-
tuning:
|
|
1792
|
-
signal:
|
|
1793
|
-
dynamicLinking:
|
|
1794
|
-
params:
|
|
1795
|
-
paramDefinitions:
|
|
1796
|
-
transformBody:
|
|
1797
|
-
} =
|
|
1829
|
+
tuning: u,
|
|
1830
|
+
signal: c,
|
|
1831
|
+
dynamicLinking: f,
|
|
1832
|
+
params: d,
|
|
1833
|
+
paramDefinitions: m,
|
|
1834
|
+
transformBody: l
|
|
1835
|
+
} = i, g = t.transformFilters(a), h = await e.layers.prepareSearch(
|
|
1798
1836
|
{
|
|
1799
|
-
query:
|
|
1800
|
-
filter_group:
|
|
1801
|
-
tuning:
|
|
1802
|
-
dynamicLinking:
|
|
1803
|
-
transformBody: X({ params:
|
|
1837
|
+
query: s,
|
|
1838
|
+
filter_group: g,
|
|
1839
|
+
tuning: u,
|
|
1840
|
+
dynamicLinking: f,
|
|
1841
|
+
transformBody: X({ params: d, paramDefinitions: m, transformBody: l })
|
|
1804
1842
|
},
|
|
1805
|
-
|
|
1843
|
+
c
|
|
1806
1844
|
);
|
|
1807
|
-
return h.error ?
|
|
1845
|
+
return h.error ? p(h.error) : (n = h.data.search_id, M({ searchId: h.data.search_id }));
|
|
1808
1846
|
},
|
|
1809
|
-
async execute(
|
|
1847
|
+
async execute(i) {
|
|
1810
1848
|
const {
|
|
1811
|
-
query:
|
|
1849
|
+
query: s,
|
|
1812
1850
|
searchId: a,
|
|
1813
|
-
page:
|
|
1814
|
-
limit:
|
|
1815
|
-
filters:
|
|
1816
|
-
tuning:
|
|
1817
|
-
signal:
|
|
1818
|
-
dynamicLinking:
|
|
1819
|
-
params:
|
|
1851
|
+
page: u = Y,
|
|
1852
|
+
limit: c = Z,
|
|
1853
|
+
filters: f,
|
|
1854
|
+
tuning: d,
|
|
1855
|
+
signal: m,
|
|
1856
|
+
dynamicLinking: l,
|
|
1857
|
+
params: g,
|
|
1820
1858
|
paramDefinitions: h,
|
|
1821
1859
|
transformBody: y
|
|
1822
|
-
} =
|
|
1823
|
-
o?.abort(), o = oe(
|
|
1860
|
+
} = i, _ = t.transformFilters(f), b = X({ params: g, paramDefinitions: h, transformBody: y });
|
|
1861
|
+
o?.abort(), o = oe(m), r.value = { ...r.value, isFetching: !0, error: null };
|
|
1824
1862
|
let v = a ?? n;
|
|
1825
1863
|
if (n = void 0, !v) {
|
|
1826
|
-
const
|
|
1864
|
+
const k = await e.layers.prepareSearch(
|
|
1827
1865
|
{
|
|
1828
|
-
query:
|
|
1829
|
-
filter_group:
|
|
1830
|
-
tuning:
|
|
1831
|
-
dynamicLinking:
|
|
1866
|
+
query: s,
|
|
1867
|
+
filter_group: _,
|
|
1868
|
+
tuning: d,
|
|
1869
|
+
dynamicLinking: l,
|
|
1832
1870
|
transformBody: b
|
|
1833
1871
|
},
|
|
1834
1872
|
o.signal
|
|
1835
1873
|
);
|
|
1836
|
-
if (
|
|
1837
|
-
return r.value = { ...r.value, isFetching: !1, error:
|
|
1838
|
-
v =
|
|
1874
|
+
if (k.error)
|
|
1875
|
+
return r.value = { ...r.value, isFetching: !1, error: k.error }, p(k.error);
|
|
1876
|
+
v = k.data.search_id;
|
|
1839
1877
|
}
|
|
1840
|
-
const S =
|
|
1878
|
+
const S = ze;
|
|
1841
1879
|
let E = await e.layers.search(
|
|
1842
1880
|
{
|
|
1843
|
-
query:
|
|
1881
|
+
query: s,
|
|
1844
1882
|
search_id: v,
|
|
1845
|
-
pagination: { page:
|
|
1846
|
-
filter_group:
|
|
1847
|
-
tuning:
|
|
1848
|
-
dynamicLinking:
|
|
1883
|
+
pagination: { page: u, limit: c },
|
|
1884
|
+
filter_group: _,
|
|
1885
|
+
tuning: d,
|
|
1886
|
+
dynamicLinking: l,
|
|
1849
1887
|
transformBody: b
|
|
1850
1888
|
},
|
|
1851
1889
|
o.signal
|
|
1852
1890
|
);
|
|
1853
|
-
for (let
|
|
1854
|
-
const
|
|
1855
|
-
if (
|
|
1856
|
-
let L =
|
|
1891
|
+
for (let k = 0; k < S && E.error; k++) {
|
|
1892
|
+
const N = E.error;
|
|
1893
|
+
if (N._tag !== "ApiError" || N.status !== 425) break;
|
|
1894
|
+
let L = Je;
|
|
1857
1895
|
try {
|
|
1858
|
-
const U = JSON.parse(
|
|
1896
|
+
const U = JSON.parse(N.message);
|
|
1859
1897
|
U.retry_after_ms && (L = U.retry_after_ms);
|
|
1860
1898
|
} catch {
|
|
1861
1899
|
}
|
|
1862
1900
|
await new Promise((U) => setTimeout(U, L)), E = await e.layers.search(
|
|
1863
1901
|
{
|
|
1864
|
-
query:
|
|
1902
|
+
query: s,
|
|
1865
1903
|
search_id: v,
|
|
1866
|
-
pagination: { page:
|
|
1867
|
-
filter_group:
|
|
1868
|
-
tuning:
|
|
1869
|
-
dynamicLinking:
|
|
1904
|
+
pagination: { page: u, limit: c },
|
|
1905
|
+
filter_group: _,
|
|
1906
|
+
tuning: d,
|
|
1907
|
+
dynamicLinking: l,
|
|
1870
1908
|
transformBody: b
|
|
1871
1909
|
},
|
|
1872
1910
|
o.signal
|
|
1873
1911
|
);
|
|
1874
1912
|
}
|
|
1875
1913
|
if (E.error)
|
|
1876
|
-
return r.value = { data: r.value.data, error: E.error, isFetching: !1 },
|
|
1914
|
+
return r.value = { data: r.value.data, error: E.error, isFetching: !1 }, p(E.error);
|
|
1877
1915
|
const { results: F } = E.data, P = await t.fetchAndBuildProducts(F);
|
|
1878
1916
|
if (P.error)
|
|
1879
|
-
return r.value = { data: r.value.data, error: P.error, isFetching: !1 },
|
|
1880
|
-
const
|
|
1881
|
-
products:
|
|
1917
|
+
return r.value = { data: r.value.data, error: P.error, isFetching: !1 }, p(P.error);
|
|
1918
|
+
const R = P.data, I = ne({
|
|
1919
|
+
products: R,
|
|
1882
1920
|
raw: E.data,
|
|
1883
1921
|
extender: e.config.extendSearch
|
|
1884
1922
|
});
|
|
1885
|
-
e.config.includeMeta && E.data._meta && (
|
|
1886
|
-
const
|
|
1887
|
-
return
|
|
1923
|
+
e.config.includeMeta && E.data._meta && (I._meta = E.data._meta), e.store.products.set(R);
|
|
1924
|
+
const O = At(s, { page: u, limit: c, filters: f });
|
|
1925
|
+
return O && e.store.queries.set(O, I), r.value = { data: I, error: null, isFetching: !1 }, M(I);
|
|
1888
1926
|
},
|
|
1889
1927
|
dispose() {
|
|
1890
1928
|
o?.abort();
|
|
@@ -1897,60 +1935,60 @@ function Xt({
|
|
|
1897
1935
|
helpers: t
|
|
1898
1936
|
}) {
|
|
1899
1937
|
return ({ blockId: r, anchorId: o, anchorHandle: n }) => {
|
|
1900
|
-
const
|
|
1938
|
+
const i = $({
|
|
1901
1939
|
data: null,
|
|
1902
1940
|
error: null,
|
|
1903
1941
|
isFetching: !1
|
|
1904
1942
|
});
|
|
1905
|
-
let
|
|
1943
|
+
let s = null;
|
|
1906
1944
|
return {
|
|
1907
|
-
state:
|
|
1945
|
+
state: i,
|
|
1908
1946
|
async execute(a = {}) {
|
|
1909
1947
|
const {
|
|
1910
|
-
page:
|
|
1911
|
-
limit:
|
|
1912
|
-
filters:
|
|
1913
|
-
signal:
|
|
1914
|
-
discountEntitlements:
|
|
1915
|
-
context:
|
|
1916
|
-
dynamicLinking:
|
|
1948
|
+
page: u = Y,
|
|
1949
|
+
limit: c = Z,
|
|
1950
|
+
filters: f,
|
|
1951
|
+
signal: d,
|
|
1952
|
+
discountEntitlements: m,
|
|
1953
|
+
context: l,
|
|
1954
|
+
dynamicLinking: g,
|
|
1917
1955
|
params: h,
|
|
1918
1956
|
paramDefinitions: y,
|
|
1919
|
-
transformBody:
|
|
1957
|
+
transformBody: _
|
|
1920
1958
|
} = a;
|
|
1921
|
-
|
|
1922
|
-
const b =
|
|
1923
|
-
|
|
1959
|
+
s?.abort(), s = oe(d);
|
|
1960
|
+
const b = i.value.data;
|
|
1961
|
+
i.value = { data: b, error: null, isFetching: !0 };
|
|
1924
1962
|
const { data: v, error: S } = await e.layers.blocks(
|
|
1925
1963
|
{
|
|
1926
1964
|
blockId: r,
|
|
1927
1965
|
anchor_id: o,
|
|
1928
1966
|
anchor_handle: n,
|
|
1929
|
-
pagination: { page:
|
|
1930
|
-
filter_group: t.transformFilters(
|
|
1931
|
-
discountEntitlements:
|
|
1932
|
-
context:
|
|
1933
|
-
dynamicLinking:
|
|
1934
|
-
transformBody: X({ params: h, paramDefinitions: y, transformBody:
|
|
1967
|
+
pagination: { page: u, limit: c },
|
|
1968
|
+
filter_group: t.transformFilters(f),
|
|
1969
|
+
discountEntitlements: m,
|
|
1970
|
+
context: l,
|
|
1971
|
+
dynamicLinking: g,
|
|
1972
|
+
transformBody: X({ params: h, paramDefinitions: y, transformBody: _ })
|
|
1935
1973
|
},
|
|
1936
|
-
|
|
1974
|
+
s.signal
|
|
1937
1975
|
);
|
|
1938
1976
|
if (S)
|
|
1939
|
-
return
|
|
1977
|
+
return i.value = { data: b, error: S, isFetching: !1 }, p(S);
|
|
1940
1978
|
const { results: E } = v, F = await t.fetchAndBuildProducts(E);
|
|
1941
1979
|
if (F.error)
|
|
1942
|
-
return
|
|
1943
|
-
const P = F.data,
|
|
1980
|
+
return i.value = { data: b, error: F.error, isFetching: !1 }, p(F.error);
|
|
1981
|
+
const P = F.data, R = ne({
|
|
1944
1982
|
products: P,
|
|
1945
1983
|
raw: v,
|
|
1946
1984
|
extender: e.config.extendBlock
|
|
1947
1985
|
});
|
|
1948
|
-
e.config.includeMeta && v._meta && (
|
|
1949
|
-
const
|
|
1950
|
-
return
|
|
1986
|
+
e.config.includeMeta && v._meta && (R._meta = v._meta), v.block && (R.block = v.block);
|
|
1987
|
+
const I = Rt(r, { anchorId: o, anchorHandle: n, page: u, limit: c, filters: f });
|
|
1988
|
+
return I && e.store.queries.set(I, R), e.store.products.set(P), i.value = { data: R, error: null, isFetching: !1 }, M(R);
|
|
1951
1989
|
},
|
|
1952
1990
|
dispose() {
|
|
1953
|
-
|
|
1991
|
+
s?.abort();
|
|
1954
1992
|
}
|
|
1955
1993
|
};
|
|
1956
1994
|
};
|
|
@@ -1970,32 +2008,32 @@ function Jt({
|
|
|
1970
2008
|
ctx: e
|
|
1971
2009
|
}) {
|
|
1972
2010
|
return (t = {}) => {
|
|
1973
|
-
const { debounceMs: r =
|
|
2011
|
+
const { debounceMs: r = Ye, signal: o } = t, n = $({
|
|
1974
2012
|
data: null,
|
|
1975
2013
|
error: null,
|
|
1976
2014
|
isFetching: !1
|
|
1977
2015
|
});
|
|
1978
|
-
let
|
|
1979
|
-
const
|
|
2016
|
+
let i = null;
|
|
2017
|
+
const s = /* @__PURE__ */ new Map();
|
|
1980
2018
|
function a() {
|
|
1981
|
-
|
|
2019
|
+
u.cancel(), i?.abort();
|
|
1982
2020
|
}
|
|
1983
2021
|
o?.addEventListener("abort", a, { once: !0 });
|
|
1984
|
-
const
|
|
1985
|
-
if (!
|
|
2022
|
+
const u = zt(async (c) => {
|
|
2023
|
+
if (!c.trim()) {
|
|
1986
2024
|
n.value = { data: null, error: null, isFetching: !1 };
|
|
1987
2025
|
return;
|
|
1988
2026
|
}
|
|
1989
|
-
const
|
|
1990
|
-
if (
|
|
1991
|
-
n.value = { data:
|
|
2027
|
+
const f = c.trim().toLowerCase(), d = s.get(f);
|
|
2028
|
+
if (d) {
|
|
2029
|
+
n.value = { data: d, error: null, isFetching: !1 };
|
|
1992
2030
|
return;
|
|
1993
2031
|
}
|
|
1994
|
-
|
|
1995
|
-
const
|
|
1996
|
-
|
|
2032
|
+
i?.abort(), i = oe(o), n.value = { ...n.value, isFetching: !0 };
|
|
2033
|
+
const m = await e.layers.predictiveSearch(c.trim(), i.signal);
|
|
2034
|
+
m.error ? m.error._tag !== "NetworkError" || m.error.code !== "ABORTED" ? n.value = { data: null, error: m.error, isFetching: !1 } : n.value = { ...n.value, isFetching: !1 } : (s.set(f, m.data), n.value = { data: m.data, error: null, isFetching: !1 });
|
|
1997
2035
|
}, r);
|
|
1998
|
-
return { state: n, execute: (
|
|
2036
|
+
return { state: n, execute: (c) => u.call(c), dispose: a };
|
|
1999
2037
|
};
|
|
2000
2038
|
}
|
|
2001
2039
|
function Yt({
|
|
@@ -2006,8 +2044,8 @@ function Yt({
|
|
|
2006
2044
|
ids: r,
|
|
2007
2045
|
meta: o,
|
|
2008
2046
|
collectionMetafields: n = e.config.collectionMetafields,
|
|
2009
|
-
pageMetafields:
|
|
2010
|
-
signal:
|
|
2047
|
+
pageMetafields: i = e.config.pageMetafields,
|
|
2048
|
+
signal: s
|
|
2011
2049
|
} = t, a = $({
|
|
2012
2050
|
data: null,
|
|
2013
2051
|
error: null,
|
|
@@ -2015,36 +2053,36 @@ function Yt({
|
|
|
2015
2053
|
});
|
|
2016
2054
|
if (r.length === 0)
|
|
2017
2055
|
return a.value = { data: { products: [] }, error: null, isFetching: !1 }, a;
|
|
2018
|
-
const
|
|
2019
|
-
return !o || !e.storefrontEnabled ? (a.value = { data: { products:
|
|
2020
|
-
let
|
|
2056
|
+
const u = r, { cached: c } = e.store.products.getMany(u), f = new Map(c.map((m) => [m.gid, m])), d = u.map((m) => f.get(m)).filter((m) => m != null);
|
|
2057
|
+
return !o || !e.storefrontEnabled ? (a.value = { data: { products: d }, error: null, isFetching: !1 }, a) : (a.value = { data: null, error: null, isFetching: !0 }, (async () => {
|
|
2058
|
+
let m, l;
|
|
2021
2059
|
if (o.collection) {
|
|
2022
2060
|
const h = await e.storefront.getCollection({
|
|
2023
2061
|
handle: o.collection,
|
|
2024
2062
|
collectionMetafields: n,
|
|
2025
2063
|
includeFilters: o.includeFilters,
|
|
2026
|
-
signal:
|
|
2064
|
+
signal: s
|
|
2027
2065
|
});
|
|
2028
2066
|
if (h.error) {
|
|
2029
2067
|
a.value = { data: null, error: h.error, isFetching: !1 };
|
|
2030
2068
|
return;
|
|
2031
2069
|
}
|
|
2032
|
-
|
|
2070
|
+
m = h.data;
|
|
2033
2071
|
}
|
|
2034
2072
|
if (o.page) {
|
|
2035
2073
|
const h = await e.storefront.getPage({
|
|
2036
2074
|
handle: o.page,
|
|
2037
|
-
pageMetafields:
|
|
2038
|
-
signal:
|
|
2075
|
+
pageMetafields: i,
|
|
2076
|
+
signal: s
|
|
2039
2077
|
});
|
|
2040
2078
|
if (h.error) {
|
|
2041
2079
|
a.value = { data: null, error: h.error, isFetching: !1 };
|
|
2042
2080
|
return;
|
|
2043
2081
|
}
|
|
2044
|
-
|
|
2082
|
+
l = h.data;
|
|
2045
2083
|
}
|
|
2046
|
-
const
|
|
2047
|
-
|
|
2084
|
+
const g = { products: d };
|
|
2085
|
+
m && (g.collection = m), l && (g.page = l), a.value = { data: g, error: null, isFetching: !1 };
|
|
2048
2086
|
})(), a);
|
|
2049
2087
|
};
|
|
2050
2088
|
}
|
|
@@ -2076,51 +2114,51 @@ function er({
|
|
|
2076
2114
|
const {
|
|
2077
2115
|
imageId: o,
|
|
2078
2116
|
page: n = Y,
|
|
2079
|
-
limit:
|
|
2080
|
-
filters:
|
|
2117
|
+
limit: i = Z,
|
|
2118
|
+
filters: s,
|
|
2081
2119
|
tuning: a,
|
|
2082
|
-
signal:
|
|
2083
|
-
dynamicLinking:
|
|
2084
|
-
params:
|
|
2085
|
-
paramDefinitions:
|
|
2086
|
-
transformBody:
|
|
2087
|
-
} = r,
|
|
2120
|
+
signal: u,
|
|
2121
|
+
dynamicLinking: c,
|
|
2122
|
+
params: f,
|
|
2123
|
+
paramDefinitions: d,
|
|
2124
|
+
transformBody: m
|
|
2125
|
+
} = r, l = $({
|
|
2088
2126
|
data: null,
|
|
2089
2127
|
error: null,
|
|
2090
2128
|
isFetching: !0
|
|
2091
2129
|
});
|
|
2092
2130
|
return (async () => {
|
|
2093
|
-
const
|
|
2131
|
+
const g = await e.layers.imageSearch(
|
|
2094
2132
|
{
|
|
2095
2133
|
image_id: o,
|
|
2096
|
-
pagination: { page: n, limit:
|
|
2097
|
-
filter_group: t.transformFilters(
|
|
2134
|
+
pagination: { page: n, limit: i },
|
|
2135
|
+
filter_group: t.transformFilters(s),
|
|
2098
2136
|
tuning: a,
|
|
2099
|
-
dynamicLinking:
|
|
2100
|
-
transformBody: X({ params:
|
|
2137
|
+
dynamicLinking: c,
|
|
2138
|
+
transformBody: X({ params: f, paramDefinitions: d, transformBody: m })
|
|
2101
2139
|
},
|
|
2102
|
-
|
|
2140
|
+
u
|
|
2103
2141
|
);
|
|
2104
|
-
if (
|
|
2105
|
-
|
|
2142
|
+
if (g.error) {
|
|
2143
|
+
l.value = { data: null, error: g.error, isFetching: !1 };
|
|
2106
2144
|
return;
|
|
2107
2145
|
}
|
|
2108
|
-
const { results: h } =
|
|
2146
|
+
const { results: h } = g.data, y = await t.fetchAndBuildProducts(h);
|
|
2109
2147
|
if (y.error) {
|
|
2110
|
-
|
|
2148
|
+
l.value = { data: null, error: y.error, isFetching: !1 };
|
|
2111
2149
|
return;
|
|
2112
2150
|
}
|
|
2113
|
-
const
|
|
2114
|
-
products:
|
|
2115
|
-
raw:
|
|
2151
|
+
const _ = y.data, b = ne({
|
|
2152
|
+
products: _,
|
|
2153
|
+
raw: g.data,
|
|
2116
2154
|
extender: e.config.extendSearch
|
|
2117
2155
|
});
|
|
2118
|
-
e.store.products.set(
|
|
2119
|
-
})(),
|
|
2156
|
+
e.store.products.set(_), l.value = { data: b, error: null, isFetching: !1 };
|
|
2157
|
+
})(), l;
|
|
2120
2158
|
};
|
|
2121
2159
|
}
|
|
2122
|
-
function
|
|
2123
|
-
const t =
|
|
2160
|
+
function _r(e) {
|
|
2161
|
+
const t = lt({
|
|
2124
2162
|
layersPublicToken: e.layersPublicToken,
|
|
2125
2163
|
layersBaseUrl: e.layersBaseUrl,
|
|
2126
2164
|
sorts: e.sorts,
|
|
@@ -2128,12 +2166,12 @@ function yr(e) {
|
|
|
2128
2166
|
attributes: e.attributes,
|
|
2129
2167
|
fetch: e.fetch
|
|
2130
2168
|
});
|
|
2131
|
-
if (t.error) return
|
|
2169
|
+
if (t.error) return p(t.error);
|
|
2132
2170
|
const r = t.data;
|
|
2133
2171
|
let o, n = !1;
|
|
2134
2172
|
if (e.enableStorefront) {
|
|
2135
2173
|
if (!e.shop || !e.storefrontPublicToken)
|
|
2136
|
-
return
|
|
2174
|
+
return p(
|
|
2137
2175
|
B({
|
|
2138
2176
|
code: "MISSING_CONFIG",
|
|
2139
2177
|
message: "shop and storefrontPublicToken are required when enableStorefront is true",
|
|
@@ -2141,64 +2179,77 @@ function yr(e) {
|
|
|
2141
2179
|
expected: "non-empty string"
|
|
2142
2180
|
})
|
|
2143
2181
|
);
|
|
2144
|
-
const
|
|
2182
|
+
const c = yt({
|
|
2145
2183
|
shop: e.shop,
|
|
2146
2184
|
storefrontPublicToken: e.storefrontPublicToken,
|
|
2147
2185
|
storefrontApiVersion: e.storefrontApiVersion,
|
|
2148
2186
|
fetch: e.fetch
|
|
2149
2187
|
});
|
|
2150
|
-
if (
|
|
2151
|
-
o =
|
|
2188
|
+
if (c.error) return p(c.error);
|
|
2189
|
+
o = c.data, n = !0;
|
|
2152
2190
|
}
|
|
2153
|
-
const
|
|
2191
|
+
const i = St({
|
|
2154
2192
|
maxProducts: e.cacheMaxProducts,
|
|
2155
2193
|
maxQueries: e.cacheMaxEntries,
|
|
2156
|
-
ttl: e.cacheTtl
|
|
2157
|
-
|
|
2194
|
+
ttl: e.cacheTtl,
|
|
2195
|
+
storageAdapter: e.storageAdapter
|
|
2196
|
+
});
|
|
2197
|
+
if (e.restoreFromStorage !== !1 && i.restore(), e.initialData) {
|
|
2198
|
+
const { products: c, queries: f, collections: d } = e.initialData;
|
|
2199
|
+
if (c?.length && i.products.set(c), f)
|
|
2200
|
+
for (const [m, l] of Object.entries(f))
|
|
2201
|
+
i.queries.set(m, l);
|
|
2202
|
+
if (d)
|
|
2203
|
+
for (const [m, l] of Object.entries(d))
|
|
2204
|
+
i.collections.set(m, l);
|
|
2205
|
+
}
|
|
2206
|
+
const s = {
|
|
2158
2207
|
config: e,
|
|
2159
2208
|
layers: r,
|
|
2160
2209
|
storefront: o,
|
|
2161
2210
|
storefrontEnabled: n,
|
|
2162
|
-
store:
|
|
2211
|
+
store: i,
|
|
2163
2212
|
mergeConfig: {
|
|
2164
2213
|
currencyCode: e.currencyCode,
|
|
2165
2214
|
formatPrice: e.formatPrice,
|
|
2166
2215
|
swatches: e.swatches
|
|
2167
2216
|
}
|
|
2168
|
-
}, a =
|
|
2217
|
+
}, a = Ht({ ctx: s }), u = {
|
|
2169
2218
|
config: e,
|
|
2170
|
-
store:
|
|
2171
|
-
collection:
|
|
2172
|
-
search:
|
|
2173
|
-
blocks: Xt({ ctx:
|
|
2174
|
-
autocomplete: Jt({ ctx:
|
|
2175
|
-
storefront: Yt({ ctx:
|
|
2176
|
-
uploadImage: Zt({ ctx:
|
|
2177
|
-
imageSearch: er({ ctx:
|
|
2219
|
+
store: i,
|
|
2220
|
+
collection: Kt({ ctx: s, helpers: a }),
|
|
2221
|
+
search: Wt({ ctx: s, helpers: a }),
|
|
2222
|
+
blocks: Xt({ ctx: s, helpers: a }),
|
|
2223
|
+
autocomplete: Jt({ ctx: s }),
|
|
2224
|
+
storefront: Yt({ ctx: s }),
|
|
2225
|
+
uploadImage: Zt({ ctx: s }),
|
|
2226
|
+
imageSearch: er({ ctx: s, helpers: a })
|
|
2178
2227
|
};
|
|
2179
|
-
return xt(
|
|
2228
|
+
return xt(u), M(u);
|
|
2180
2229
|
}
|
|
2181
2230
|
export {
|
|
2182
2231
|
Tt as and,
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2232
|
+
br as batch,
|
|
2233
|
+
vr as computed,
|
|
2234
|
+
_r as createSdk,
|
|
2235
|
+
Fr as effect,
|
|
2236
|
+
sr as eq,
|
|
2237
|
+
gr as exists,
|
|
2238
|
+
hr as filter,
|
|
2190
2239
|
Gt as getSdk,
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2240
|
+
lr as gt,
|
|
2241
|
+
ur as gte,
|
|
2242
|
+
ar as inValues,
|
|
2243
|
+
yr as isInitialized,
|
|
2195
2244
|
nr as isRetryable,
|
|
2196
2245
|
rr as isSdkError,
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
mr as
|
|
2203
|
-
|
|
2246
|
+
or as jsonFileAdapter,
|
|
2247
|
+
It as localStorageAdapter,
|
|
2248
|
+
dr as lt,
|
|
2249
|
+
fr as lte,
|
|
2250
|
+
ir as notEq,
|
|
2251
|
+
mr as notExists,
|
|
2252
|
+
cr as notIn,
|
|
2253
|
+
pr as or,
|
|
2254
|
+
Mr as signal
|
|
2204
2255
|
};
|