@usethrottle/catalog 1.0.0 → 1.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/CHANGELOG.md +8 -0
- package/README.md +64 -7
- package/dist/admin.cjs +681 -0
- package/dist/admin.d.cts +660 -0
- package/dist/admin.d.ts +660 -0
- package/dist/admin.js +681 -0
- package/dist/{catalog-error-BWUoZCzY.d.ts → catalog-error-C_zLOtYA.d.ts} +3 -3
- package/dist/{catalog-error-DO6ANrGR.d.cts → catalog-error-s1BINNkt.d.cts} +3 -3
- package/dist/{chunk-ZFUELHUU.cjs → chunk-4ORXUW2U.cjs} +4 -2
- package/dist/{chunk-2PJXGAZF.js → chunk-JK2UY4CD.js} +3 -1
- package/dist/{client-BNtBTEyh.d.cts → client-BAoq6jmM.d.cts} +1 -1
- package/dist/{client-CHLvULRQ.d.ts → client-c2F-eCaL.d.ts} +1 -1
- package/dist/{types-DYfIvIaI.d.cts → contract-types-DhiThMEr.d.cts} +1 -272
- package/dist/{types-DYfIvIaI.d.ts → contract-types-DhiThMEr.d.ts} +1 -272
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/dist/react.cjs +17 -17
- package/dist/react.d.cts +5 -4
- package/dist/react.d.ts +5 -4
- package/dist/react.js +1 -1
- package/dist/server.cjs +14 -13
- package/dist/server.d.cts +3 -2
- package/dist/server.d.ts +3 -2
- package/dist/server.js +3 -2
- package/dist/types-DsjoG8ce.d.cts +276 -0
- package/dist/types-xQLID-4j.d.ts +276 -0
- package/dist/url.d.cts +1 -0
- package/dist/url.d.ts +1 -0
- package/package.json +11 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { S as StorefrontCategoryNode, a as StorefrontListAnswer, b as StorefrontListProduct, c as StorefrontProductAnswer } from './types-
|
|
2
|
-
export { C as
|
|
3
|
-
export { C as CatalogClient, S as SDK_VERSION, c as createCatalogClient } from './client-
|
|
4
|
-
export { C as
|
|
1
|
+
import { S as StorefrontCategoryNode, a as StorefrontListAnswer, b as StorefrontListProduct, c as StorefrontProductAnswer } from './contract-types-DhiThMEr.cjs';
|
|
2
|
+
export { C as CartCheckAnswer, d as CartCheckRequest, e as CartCreateAnswer, f as CartCreateRequest, g as CatalogContractErrorCode, R as ReviewEligibilityAnswer, h as ReviewSubmitAnswer, i as ReviewSubmitInput, j as StorefrontCategoriesAnswer, k as StorefrontCategoryAnswer, l as StorefrontCollectionAnswer, m as StorefrontCollectionsAnswer, n as StorefrontConfigAnswer, o as StorefrontFilterValuesAnswer, p as StorefrontRelatedAnswer, q as StorefrontReviewsAnswer, r as StorefrontSuggestAnswer, s as StorefrontTagsAnswer } from './contract-types-DhiThMEr.cjs';
|
|
3
|
+
export { C as CatalogClient, S as SDK_VERSION, c as createCatalogClient } from './client-BAoq6jmM.cjs';
|
|
4
|
+
export { C as CallOptions, a as CartCheckout, b as CartCheckoutInput, c as CartSession, d as CartSessionBranding, e as CartSessionDetail, f as CartSessionSnapshot, g as CartsNamespace, h as CatalogClientOptions, i as CatalogHttpCache, j as CatalogHttpCacheEntry, k as CatalogNamespaces, l as CategoriesNamespace, m as CategoryTreeDepth, n as CollectionsNamespace, o as CustomerTokenSource, F as FieldsOption, p as FiltersNamespace, N as NextFetchOptions, P as ProductsNamespace, q as ProductsQuery, R as Redirect, r as ReviewsNamespace, S as SessionCallOptions, s as StorefrontSort, T as TagsNamespace, t as ThrottleCart, u as ThrottleLine } from './types-DsjoG8ce.cjs';
|
|
5
|
+
export { C as CartLineError, a as CartLineProblem, b as CatalogError, c as CatalogErrorCode, d as CatalogErrorInit, e as CatalogErrorIssue, f as CatalogErrorSource, g as ClientErrorCode, h as CustomerTokenInvalidError, F as FeatureUnavailableError, N as NetworkError, O as OriginNotAllowedError, R as RateLimitedError, j as ThrottleCartCode, T as TimeoutError, i as isCatalogError } from './catalog-error-s1BINNkt.cjs';
|
|
5
6
|
|
|
6
7
|
/** A product as `products.get` answers it (the full projection). */
|
|
7
8
|
type StorefrontProduct = StorefrontProductAnswer['product'];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { S as StorefrontCategoryNode, a as StorefrontListAnswer, b as StorefrontListProduct, c as StorefrontProductAnswer } from './types-
|
|
2
|
-
export { C as
|
|
3
|
-
export { C as CatalogClient, S as SDK_VERSION, c as createCatalogClient } from './client-
|
|
4
|
-
export { C as
|
|
1
|
+
import { S as StorefrontCategoryNode, a as StorefrontListAnswer, b as StorefrontListProduct, c as StorefrontProductAnswer } from './contract-types-DhiThMEr.js';
|
|
2
|
+
export { C as CartCheckAnswer, d as CartCheckRequest, e as CartCreateAnswer, f as CartCreateRequest, g as CatalogContractErrorCode, R as ReviewEligibilityAnswer, h as ReviewSubmitAnswer, i as ReviewSubmitInput, j as StorefrontCategoriesAnswer, k as StorefrontCategoryAnswer, l as StorefrontCollectionAnswer, m as StorefrontCollectionsAnswer, n as StorefrontConfigAnswer, o as StorefrontFilterValuesAnswer, p as StorefrontRelatedAnswer, q as StorefrontReviewsAnswer, r as StorefrontSuggestAnswer, s as StorefrontTagsAnswer } from './contract-types-DhiThMEr.js';
|
|
3
|
+
export { C as CatalogClient, S as SDK_VERSION, c as createCatalogClient } from './client-c2F-eCaL.js';
|
|
4
|
+
export { C as CallOptions, a as CartCheckout, b as CartCheckoutInput, c as CartSession, d as CartSessionBranding, e as CartSessionDetail, f as CartSessionSnapshot, g as CartsNamespace, h as CatalogClientOptions, i as CatalogHttpCache, j as CatalogHttpCacheEntry, k as CatalogNamespaces, l as CategoriesNamespace, m as CategoryTreeDepth, n as CollectionsNamespace, o as CustomerTokenSource, F as FieldsOption, p as FiltersNamespace, N as NextFetchOptions, P as ProductsNamespace, q as ProductsQuery, R as Redirect, r as ReviewsNamespace, S as SessionCallOptions, s as StorefrontSort, T as TagsNamespace, t as ThrottleCart, u as ThrottleLine } from './types-xQLID-4j.js';
|
|
5
|
+
export { C as CartLineError, a as CartLineProblem, b as CatalogError, c as CatalogErrorCode, d as CatalogErrorInit, e as CatalogErrorIssue, f as CatalogErrorSource, g as ClientErrorCode, h as CustomerTokenInvalidError, F as FeatureUnavailableError, N as NetworkError, O as OriginNotAllowedError, R as RateLimitedError, j as ThrottleCartCode, T as TimeoutError, i as isCatalogError } from './catalog-error-C_zLOtYA.js';
|
|
5
6
|
|
|
6
7
|
/** A product as `products.get` answers it (the full projection). */
|
|
7
8
|
type StorefrontProduct = StorefrontProductAnswer['product'];
|
package/dist/index.js
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunk4ORXUW2Ucjs = require('./chunk-4ORXUW2U.cjs');
|
|
15
15
|
require('./chunk-ETV4XYOV.cjs');
|
|
16
16
|
|
|
17
17
|
// src/react/provider.tsx
|
|
@@ -38,7 +38,7 @@ function createStore(client, options = {}) {
|
|
|
38
38
|
let until = 0;
|
|
39
39
|
let cause;
|
|
40
40
|
let pauseTimer;
|
|
41
|
-
const pausedError = () => new (0,
|
|
41
|
+
const pausedError = () => new (0, _chunk4ORXUW2Ucjs.RateLimitedError)({
|
|
42
42
|
code: _nullishCoalesce(_optionalChain([cause, 'optionalAccess', _ => _.code]), () => ( "RATE_LIMITED")),
|
|
43
43
|
message: _nullishCoalesce(_optionalChain([cause, 'optionalAccess', _2 => _2.message]), () => ( "Too many requests.")),
|
|
44
44
|
statusCode: 429,
|
|
@@ -59,7 +59,7 @@ function createStore(client, options = {}) {
|
|
|
59
59
|
subs: /* @__PURE__ */ new Set()
|
|
60
60
|
};
|
|
61
61
|
for (const [oldKey, old] of entries) {
|
|
62
|
-
if (entries.size <
|
|
62
|
+
if (entries.size < _chunk4ORXUW2Ucjs.CACHE_MAX_ENTRIES) break;
|
|
63
63
|
if (old.subs.size === 0 && old.flight === void 0) {
|
|
64
64
|
clearTimeout(old.timer);
|
|
65
65
|
entries.delete(oldKey);
|
|
@@ -78,7 +78,7 @@ function createStore(client, options = {}) {
|
|
|
78
78
|
else entry.indexing = false;
|
|
79
79
|
}, ms);
|
|
80
80
|
};
|
|
81
|
-
function fetchKey(key, run, { force = false, staleMs =
|
|
81
|
+
function fetchKey(key, run, { force = false, staleMs = _chunk4ORXUW2Ucjs.STALE_MS } = {}) {
|
|
82
82
|
const entry = touch(key);
|
|
83
83
|
entry.run = run;
|
|
84
84
|
if (entry.promise !== void 0 && !_optionalChain([entry, 'access', _4 => _4.flight, 'optionalAccess', _5 => _5.signal, 'access', _6 => _6.aborted]))
|
|
@@ -128,7 +128,7 @@ function createStore(client, options = {}) {
|
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
if (_optionalChain([result, 'access', _7 => _7.data, 'optionalAccess', _8 => _8.indexing]) === true) {
|
|
131
|
-
if (!entry.indexing) later(key, entry,
|
|
131
|
+
if (!entry.indexing) later(key, entry, _chunk4ORXUW2Ucjs.INDEXING_REVALIDATE_MS);
|
|
132
132
|
} else {
|
|
133
133
|
entry.indexing = false;
|
|
134
134
|
}
|
|
@@ -141,7 +141,7 @@ function createStore(client, options = {}) {
|
|
|
141
141
|
},
|
|
142
142
|
(error) => {
|
|
143
143
|
if (!current()) return;
|
|
144
|
-
const retryMs = (_nullishCoalesce(error.retryAfterSeconds, () => (
|
|
144
|
+
const retryMs = (_nullishCoalesce(error.retryAfterSeconds, () => ( _chunk4ORXUW2Ucjs.RATE_LIMIT_DEFAULT_RETRY_S))) * 1e3;
|
|
145
145
|
if (error.statusCode === 429 && error.code === "RATE_LIMITED")
|
|
146
146
|
pause(now() + retryMs, error);
|
|
147
147
|
else if (error.code === "STOREFRONT_INDEXING" && !entry.indexing)
|
|
@@ -389,9 +389,9 @@ function useDebounced(q, ms) {
|
|
|
389
389
|
return _react.useSyncExternalStore.call(void 0, box.subscribe, box.get, box.get);
|
|
390
390
|
}
|
|
391
391
|
function useSuggest(q, options = {}) {
|
|
392
|
-
const settled = useDebounced(q, _nullishCoalesce(options.debounceMs, () => (
|
|
392
|
+
const settled = useDebounced(q, _nullishCoalesce(options.debounceMs, () => ( _chunk4ORXUW2Ucjs.SUGGEST_DEBOUNCE_MS)));
|
|
393
393
|
const extra = defined({ limit: options.limit });
|
|
394
|
-
const long = (value) => value.trim().length >=
|
|
394
|
+
const long = (value) => value.trim().length >= _chunk4ORXUW2Ucjs.SUGGEST_MIN_CHARS;
|
|
395
395
|
return useQuery(
|
|
396
396
|
"suggest",
|
|
397
397
|
{ q: settled, ...extra },
|
|
@@ -461,7 +461,7 @@ function newKey() {
|
|
|
461
461
|
return out;
|
|
462
462
|
}
|
|
463
463
|
function refuse(message, path) {
|
|
464
|
-
return new (0,
|
|
464
|
+
return new (0, _chunk4ORXUW2Ucjs.CatalogError)({
|
|
465
465
|
code: "INVALID_REQUEST",
|
|
466
466
|
message,
|
|
467
467
|
statusCode: 0,
|
|
@@ -474,7 +474,7 @@ var UNSAFE = /[\x00-\x20\x7f]/u;
|
|
|
474
474
|
function isHttpUrl(value) {
|
|
475
475
|
return typeof value === "string" && /^https?:\/\/[^/?#\\]/iu.test(value) && !UNSAFE.test(value);
|
|
476
476
|
}
|
|
477
|
-
var wrap = (error) =>
|
|
477
|
+
var wrap = (error) => _chunk4ORXUW2Ucjs.isCatalogError.call(void 0, error) ? error : new (0, _chunk4ORXUW2Ucjs.CatalogError)({
|
|
478
478
|
code: "CLIENT_ERROR",
|
|
479
479
|
message: "The action failed.",
|
|
480
480
|
statusCode: 0,
|
|
@@ -485,7 +485,7 @@ var wrap = (error) => _chunkZFUELHUUcjs.isCatalogError.call(void 0, error) ? err
|
|
|
485
485
|
function checkPause(store) {
|
|
486
486
|
const until = store.pausedUntil();
|
|
487
487
|
if (until > 0) {
|
|
488
|
-
throw new (0,
|
|
488
|
+
throw new (0, _chunk4ORXUW2Ucjs.RateLimitedError)({
|
|
489
489
|
code: "RATE_LIMITED",
|
|
490
490
|
message: "Too many requests.",
|
|
491
491
|
statusCode: 429,
|
|
@@ -495,7 +495,7 @@ function checkPause(store) {
|
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
function notePause(store, error) {
|
|
498
|
-
if (error instanceof
|
|
498
|
+
if (error instanceof _chunk4ORXUW2Ucjs.RateLimitedError && error.source === "catalog" && error.code === "RATE_LIMITED")
|
|
499
499
|
store.pause(Date.now() + error.retryAfterSeconds * 1e3, error);
|
|
500
500
|
}
|
|
501
501
|
function createBox(initial) {
|
|
@@ -529,7 +529,7 @@ var ENDED = /* @__PURE__ */ new Set([
|
|
|
529
529
|
"cart_not_open",
|
|
530
530
|
"cart_not_found"
|
|
531
531
|
]);
|
|
532
|
-
var ended = (error) =>
|
|
532
|
+
var ended = (error) => _chunk4ORXUW2Ucjs.isCatalogError.call(void 0, error) && ENDED.has(error.code);
|
|
533
533
|
var converted = (error) => _optionalChain([error, 'access', _23 => _23.details, 'optionalAccess', _24 => _24.reason]) === "converted";
|
|
534
534
|
function itemsOf(cart) {
|
|
535
535
|
const items = /* @__PURE__ */ new Map();
|
|
@@ -568,7 +568,7 @@ function createController(home) {
|
|
|
568
568
|
throttleBaseUrl === void 0 ? void 0 : { throttleBaseUrl }
|
|
569
569
|
);
|
|
570
570
|
};
|
|
571
|
-
const fallbackUrl = (id) => `${(_nullishCoalesce(ctx().throttleCheckoutUrl, () => (
|
|
571
|
+
const fallbackUrl = (id) => `${(_nullishCoalesce(ctx().throttleCheckoutUrl, () => ( _chunk4ORXUW2Ucjs.THROTTLE_CHECKOUT_URL))).replace(/\/+$/u, "")}/cart/${encodeURIComponent(id)}`;
|
|
572
572
|
const live = async (signal, value) => {
|
|
573
573
|
const out = await value;
|
|
574
574
|
if (signal.aborted) throw signal.reason;
|
|
@@ -897,7 +897,7 @@ function useCart(options = {}) {
|
|
|
897
897
|
{ signal: callSignal }
|
|
898
898
|
);
|
|
899
899
|
} catch (error) {
|
|
900
|
-
const repriced =
|
|
900
|
+
const repriced = _chunk4ORXUW2Ucjs.isCatalogError.call(void 0, error) && error.code === "cart_prices_changed" ? _optionalChain([error, 'access', _37 => _37.details, 'optionalAccess', _38 => _38.cart]) : void 0;
|
|
901
901
|
if (!callSignal.aborted && typeof repriced === "object" && repriced !== null)
|
|
902
902
|
controller.box.set({ cart: repriced });
|
|
903
903
|
throw error;
|
|
@@ -917,7 +917,7 @@ function useCart(options = {}) {
|
|
|
917
917
|
if (out === void 0)
|
|
918
918
|
throw _nullishCoalesce(met, () => ( refuse("There is no cart to check out.")));
|
|
919
919
|
if (!isHttpUrl(out.checkoutUrl))
|
|
920
|
-
throw new (0,
|
|
920
|
+
throw new (0, _chunk4ORXUW2Ucjs.CatalogError)({
|
|
921
921
|
code: "INVALID_RESPONSE",
|
|
922
922
|
message: "Throttle answered a checkout URL that is not http or https.",
|
|
923
923
|
statusCode: 200,
|
|
@@ -1015,4 +1015,4 @@ function useSubmitReview(handle) {
|
|
|
1015
1015
|
|
|
1016
1016
|
|
|
1017
1017
|
|
|
1018
|
-
exports.CatalogProvider = CatalogProvider; exports.SDK_VERSION =
|
|
1018
|
+
exports.CatalogProvider = CatalogProvider; exports.SDK_VERSION = _chunk4ORXUW2Ucjs.SDK_VERSION; exports.catalogQueryKey = catalogQueryKey; exports.createMemoryCartStorage = createMemoryCartStorage; exports.useCart = useCart; exports.useCatalog = useCatalog; exports.useCategories = useCategories; exports.useCollection = useCollection; exports.useConfig = useConfig; exports.useFilterValues = useFilterValues; exports.useProduct = useProduct; exports.useProducts = useProducts; exports.useRelated = useRelated; exports.useReviews = useReviews; exports.useSubmitReview = useSubmitReview; exports.useSuggest = useSuggest;
|
package/dist/react.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CatalogClient } from './index.cjs';
|
|
2
|
-
export { S as SDK_VERSION } from './client-
|
|
2
|
+
export { S as SDK_VERSION } from './client-BAoq6jmM.cjs';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { CatalogError } from './
|
|
5
|
-
import { ProductsQuery, ThrottleCart
|
|
4
|
+
import { CatalogError } from './admin.cjs';
|
|
5
|
+
import { CategoryTreeDepth, ProductsQuery, ThrottleCart } from './index.cjs';
|
|
6
|
+
import { ReviewSubmitAnswer, ReviewSubmitInput } from './index.cjs';
|
|
6
7
|
|
|
7
8
|
/** Where `useCart` keeps the cart session id (P6-R15). The default is memory only. */
|
|
8
9
|
type CartStorage = {
|
|
@@ -91,7 +92,7 @@ declare function useSuggest(q: string, options?: QueryOptions<Answer<CatalogClie
|
|
|
91
92
|
limit?: number;
|
|
92
93
|
}): QueryResult<Answer<CatalogClient['suggest']>>;
|
|
93
94
|
declare function useCategories(options?: QueryOptions<Answer<CatalogClient['categories']['tree']>> & {
|
|
94
|
-
depth?:
|
|
95
|
+
depth?: CategoryTreeDepth;
|
|
95
96
|
}): QueryResult<Answer<CatalogClient['categories']['tree']>>;
|
|
96
97
|
/** The collection, or `{ redirectTo }` for a renamed handle. */
|
|
97
98
|
declare function useCollection(handle: string | null, options?: QueryOptions<Answer<CatalogClient['collections']['get']>>): QueryResult<Answer<CatalogClient['collections']['get']>>;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CatalogClient } from './index.js';
|
|
2
|
-
export { S as SDK_VERSION } from './client-
|
|
2
|
+
export { S as SDK_VERSION } from './client-c2F-eCaL.js';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { CatalogError } from './
|
|
5
|
-
import { ProductsQuery, ThrottleCart
|
|
4
|
+
import { CatalogError } from './admin.js';
|
|
5
|
+
import { CategoryTreeDepth, ProductsQuery, ThrottleCart } from './index.js';
|
|
6
|
+
import { ReviewSubmitAnswer, ReviewSubmitInput } from './index.js';
|
|
6
7
|
|
|
7
8
|
/** Where `useCart` keeps the cart session id (P6-R15). The default is memory only. */
|
|
8
9
|
type CartStorage = {
|
|
@@ -91,7 +92,7 @@ declare function useSuggest(q: string, options?: QueryOptions<Answer<CatalogClie
|
|
|
91
92
|
limit?: number;
|
|
92
93
|
}): QueryResult<Answer<CatalogClient['suggest']>>;
|
|
93
94
|
declare function useCategories(options?: QueryOptions<Answer<CatalogClient['categories']['tree']>> & {
|
|
94
|
-
depth?:
|
|
95
|
+
depth?: CategoryTreeDepth;
|
|
95
96
|
}): QueryResult<Answer<CatalogClient['categories']['tree']>>;
|
|
96
97
|
/** The collection, or `{ redirectTo }` for a renamed handle. */
|
|
97
98
|
declare function useCollection(handle: string | null, options?: QueryOptions<Answer<CatalogClient['collections']['get']>>): QueryResult<Answer<CatalogClient['collections']['get']>>;
|
package/dist/react.js
CHANGED
package/dist/server.cjs
CHANGED
|
@@ -8,14 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
var _chunk4ORXUW2Ucjs = require('./chunk-4ORXUW2U.cjs');
|
|
12
13
|
require('./chunk-ETV4XYOV.cjs');
|
|
13
14
|
|
|
14
15
|
// src/server/tags.ts
|
|
15
16
|
function catalogTags(route, handle) {
|
|
16
|
-
const tags = [
|
|
17
|
-
if (handle !== void 0) tags.push(`${
|
|
18
|
-
return tags.filter((tag) => tag.length <=
|
|
17
|
+
const tags = [_chunk4ORXUW2Ucjs.CACHE_TAG, `${_chunk4ORXUW2Ucjs.CACHE_TAG}:${route}`];
|
|
18
|
+
if (handle !== void 0) tags.push(`${_chunk4ORXUW2Ucjs.CACHE_TAG}:${route}:${handle}`);
|
|
19
|
+
return tags.filter((tag) => tag.length <= _chunk4ORXUW2Ucjs.TAG_MAX_CHARS);
|
|
19
20
|
}
|
|
20
21
|
function decode(segment) {
|
|
21
22
|
try {
|
|
@@ -72,9 +73,9 @@ function serverInit(url, init, storefront, revalidate, extraTags) {
|
|
|
72
73
|
}
|
|
73
74
|
function createServerCatalogClient(options) {
|
|
74
75
|
const { next, ...rest } = options;
|
|
75
|
-
const revalidate = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _ => _.revalidate]), () => (
|
|
76
|
+
const revalidate = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _ => _.revalidate]), () => ( _chunk4ORXUW2Ucjs.DEFAULT_REVALIDATE_S));
|
|
76
77
|
const extraTags = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _2 => _2.tags]), () => ( []));
|
|
77
|
-
const storefront = `${(_nullishCoalesce(rest.baseUrl, () => (
|
|
78
|
+
const storefront = `${(_nullishCoalesce(rest.baseUrl, () => ( _chunk4ORXUW2Ucjs.DEFAULT_BASE_URL))).replace(/\/+$/u, "")}/v1/storefront/`;
|
|
78
79
|
const base = rest.fetch;
|
|
79
80
|
const serverFetch = (input, init = {}) => {
|
|
80
81
|
const out = serverInit(
|
|
@@ -86,7 +87,7 @@ function createServerCatalogClient(options) {
|
|
|
86
87
|
);
|
|
87
88
|
return base !== void 0 ? base(input, out) : globalThis.fetch(input, out);
|
|
88
89
|
};
|
|
89
|
-
return
|
|
90
|
+
return _chunk4ORXUW2Ucjs.createCatalogClient.call(void 0, {
|
|
90
91
|
...rest,
|
|
91
92
|
fetch: serverFetch
|
|
92
93
|
});
|
|
@@ -106,16 +107,16 @@ async function syncCatalogGeneration(input) {
|
|
|
106
107
|
|
|
107
108
|
// src/server/paging.ts
|
|
108
109
|
function bounds(opts) {
|
|
109
|
-
const pageSize = _nullishCoalesce(opts.pageSize, () => (
|
|
110
|
-
const max = _nullishCoalesce(opts.max, () => (
|
|
111
|
-
if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize >
|
|
110
|
+
const pageSize = _nullishCoalesce(opts.pageSize, () => ( _chunk4ORXUW2Ucjs.LIST_PAGE_SIZE));
|
|
111
|
+
const max = _nullishCoalesce(opts.max, () => ( _chunk4ORXUW2Ucjs.LIST_MAX_HANDLES));
|
|
112
|
+
if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > _chunk4ORXUW2Ucjs.LIST_PAGE_SIZE)
|
|
112
113
|
throw invalid("pageSize must be a whole number from 1 to 100.");
|
|
113
114
|
if (!Number.isInteger(max) || max < 0)
|
|
114
115
|
throw invalid("max must be a whole number of 0 or more.");
|
|
115
116
|
return { pageSize, max };
|
|
116
117
|
}
|
|
117
118
|
function invalid(message) {
|
|
118
|
-
return new (0,
|
|
119
|
+
return new (0, _chunk4ORXUW2Ucjs.CatalogError)({
|
|
119
120
|
code: "INVALID_REQUEST",
|
|
120
121
|
message,
|
|
121
122
|
statusCode: 0,
|
|
@@ -185,7 +186,7 @@ function listAllCollectionHandles(client, opts = {}) {
|
|
|
185
186
|
}
|
|
186
187
|
async function listAllCategoryHandles(client, opts = {}) {
|
|
187
188
|
const { categories } = await client.categories.tree({
|
|
188
|
-
depth:
|
|
189
|
+
depth: _chunk4ORXUW2Ucjs.CATEGORY_TREE_MAX_DEPTH,
|
|
189
190
|
...call(opts.signal)
|
|
190
191
|
});
|
|
191
192
|
const out = [];
|
|
@@ -207,4 +208,4 @@ async function listAllCategoryHandles(client, opts = {}) {
|
|
|
207
208
|
|
|
208
209
|
|
|
209
210
|
|
|
210
|
-
exports.SDK_VERSION =
|
|
211
|
+
exports.SDK_VERSION = _chunk4ORXUW2Ucjs.SDK_VERSION; exports.catalogTags = catalogTags; exports.createServerCatalogClient = createServerCatalogClient; exports.listAllCategoryHandles = listAllCategoryHandles; exports.listAllCollectionHandles = listAllCollectionHandles; exports.listAllProductHandles = listAllProductHandles; exports.staticProductParams = staticProductParams; exports.syncCatalogGeneration = syncCatalogGeneration;
|
package/dist/server.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CatalogClient } from './index.cjs';
|
|
2
|
-
export { S as SDK_VERSION } from './client-
|
|
2
|
+
export { S as SDK_VERSION } from './client-BAoq6jmM.cjs';
|
|
3
3
|
import { CatalogClientOptions, NextFetchOptions } from './index.cjs';
|
|
4
|
+
import './contract-types-DhiThMEr.cjs';
|
|
4
5
|
|
|
5
6
|
type ServerCatalogClientOptions = CatalogClientOptions & {
|
|
6
7
|
/** `revalidate` defaults to 60 seconds; `tags` are appended to the route's own. */
|
|
@@ -70,7 +71,7 @@ declare function staticProductParams(client: CatalogClient, opts?: {
|
|
|
70
71
|
}[]>;
|
|
71
72
|
/** Every listed collection handle, following `nextCursor`. */
|
|
72
73
|
declare function listAllCollectionHandles(client: CatalogClient, opts?: ListHandlesOptions): AsyncIterable<string>;
|
|
73
|
-
/** Every listed category handle: the tree at
|
|
74
|
+
/** Every listed category handle: the tree at its deepest level, depth-first. */
|
|
74
75
|
declare function listAllCategoryHandles(client: CatalogClient, opts?: {
|
|
75
76
|
signal?: AbortSignal;
|
|
76
77
|
}): Promise<string[]>;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CatalogClient } from './index.js';
|
|
2
|
-
export { S as SDK_VERSION } from './client-
|
|
2
|
+
export { S as SDK_VERSION } from './client-c2F-eCaL.js';
|
|
3
3
|
import { CatalogClientOptions, NextFetchOptions } from './index.js';
|
|
4
|
+
import './contract-types-DhiThMEr.js';
|
|
4
5
|
|
|
5
6
|
type ServerCatalogClientOptions = CatalogClientOptions & {
|
|
6
7
|
/** `revalidate` defaults to 60 seconds; `tags` are appended to the route's own. */
|
|
@@ -70,7 +71,7 @@ declare function staticProductParams(client: CatalogClient, opts?: {
|
|
|
70
71
|
}[]>;
|
|
71
72
|
/** Every listed collection handle, following `nextCursor`. */
|
|
72
73
|
declare function listAllCollectionHandles(client: CatalogClient, opts?: ListHandlesOptions): AsyncIterable<string>;
|
|
73
|
-
/** Every listed category handle: the tree at
|
|
74
|
+
/** Every listed category handle: the tree at its deepest level, depth-first. */
|
|
74
75
|
declare function listAllCategoryHandles(client: CatalogClient, opts?: {
|
|
75
76
|
signal?: AbortSignal;
|
|
76
77
|
}): Promise<string[]>;
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CACHE_TAG,
|
|
3
|
+
CATEGORY_TREE_MAX_DEPTH,
|
|
3
4
|
CatalogError,
|
|
4
5
|
DEFAULT_BASE_URL,
|
|
5
6
|
DEFAULT_REVALIDATE_S,
|
|
@@ -8,7 +9,7 @@ import {
|
|
|
8
9
|
SDK_VERSION,
|
|
9
10
|
TAG_MAX_CHARS,
|
|
10
11
|
createCatalogClient
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-JK2UY4CD.js";
|
|
12
13
|
import "./chunk-PKBMQBKP.js";
|
|
13
14
|
|
|
14
15
|
// src/server/tags.ts
|
|
@@ -185,7 +186,7 @@ function listAllCollectionHandles(client, opts = {}) {
|
|
|
185
186
|
}
|
|
186
187
|
async function listAllCategoryHandles(client, opts = {}) {
|
|
187
188
|
const { categories } = await client.categories.tree({
|
|
188
|
-
depth:
|
|
189
|
+
depth: CATEGORY_TREE_MAX_DEPTH,
|
|
189
190
|
...call(opts.signal)
|
|
190
191
|
});
|
|
191
192
|
const out = [];
|