@usethrottle/catalog 1.3.0 → 1.4.1
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 +22 -0
- package/README.md +105 -9
- package/dist/admin.cjs +16 -16
- package/dist/admin.d.cts +14 -2
- package/dist/admin.d.ts +14 -2
- package/dist/admin.js +1 -1
- package/dist/{catalog-error-BOaSKgY3.d.cts → catalog-error-bG1XHquN.d.cts} +1 -1
- package/dist/{catalog-error-CSoPS0-d.d.ts → catalog-error-c3BVgU6k.d.ts} +1 -1
- package/dist/{chunk-2YQNMBDI.cjs → chunk-2ODFFMZ4.cjs} +274 -38
- package/dist/chunk-5AJS3CX5.cjs +192 -0
- package/dist/{chunk-CADIHOIR.js → chunk-6K7H7HBD.js} +89 -2
- package/dist/chunk-P3ABGAF5.js +192 -0
- package/dist/{chunk-3DLH56OX.js → chunk-STNQNHNZ.js} +258 -22
- package/dist/{chunk-GU63WFXI.cjs → chunk-VOOX3WJY.cjs} +102 -15
- package/dist/{client-6j1Iz-iJ.d.cts → client-CGGlbacq.d.cts} +1 -1
- package/dist/{client-B3mL2-xJ.d.ts → client-CNsVr2lR.d.ts} +1 -1
- package/dist/{contract-types-BRyonOYH.d.cts → contract-types-BJMeJSTz.d.cts} +269 -2
- package/dist/{contract-types-BRyonOYH.d.ts → contract-types-BJMeJSTz.d.ts} +269 -2
- package/dist/index.cjs +12 -2
- package/dist/index.d.cts +53 -7
- package/dist/index.d.ts +53 -7
- package/dist/index.js +11 -1
- package/dist/next.cjs +180 -0
- package/dist/next.d.cts +60 -0
- package/dist/next.d.ts +60 -0
- package/dist/next.js +180 -0
- package/dist/react-extras.cjs +27 -9
- package/dist/react-extras.d.cts +6 -4
- package/dist/react-extras.d.ts +6 -4
- package/dist/react-extras.js +20 -2
- package/dist/react.cjs +18 -14
- package/dist/react.d.cts +22 -5
- package/dist/react.d.ts +22 -5
- package/dist/react.js +6 -2
- package/dist/server.cjs +58 -66
- package/dist/server.d.cts +57 -10
- package/dist/server.d.ts +57 -10
- package/dist/server.js +52 -60
- package/dist/{types-D0PywKnN.d.cts → types-BtBxMbM5.d.cts} +40 -3
- package/dist/{types-BfveENg1.d.ts → types-dKvIfrVH.d.ts} +40 -3
- package/dist/url.d.cts +1 -1
- package/dist/url.d.ts +1 -1
- package/dist/{use-query-UWf6Pi5g.d.cts → use-query-C2rfTJd4.d.cts} +1 -1
- package/dist/{use-query-CR7r5tam.d.ts → use-query-DeCj1hXt.d.ts} +1 -1
- package/package.json +16 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CurrencyCode } from '@usethrottle/money';
|
|
2
|
-
import { C as CartCheckAnswer,
|
|
2
|
+
import { C as CartCheckAnswer, j as CartCreateRequest, i as CartCreateAnswer, d as StorefrontListAnswer, g as StorefrontProductAnswer, w as StorefrontRelatedAnswer, r as StorefrontFilterValuesAnswer, l as StorefrontCategoriesAnswer, m as StorefrontCategoryAnswer, z as StorefrontTagsAnswer, o as StorefrontCollectionsAnswer, n as StorefrontCollectionAnswer, y as StorefrontSuggestAnswer, p as StorefrontConfigAnswer, S as StorefrontSettings, v as StorefrontPagesAnswer, u as StorefrontPageAnswer, x as StorefrontReviewsAnswer, f as ReviewEligibilityAnswer, a as ReviewSubmitInput, R as ReviewSubmitAnswer } from './contract-types-BJMeJSTz.js';
|
|
3
3
|
|
|
4
4
|
type QueryPairs = [string, string][];
|
|
5
5
|
|
|
@@ -36,6 +36,13 @@ type CatalogClientOptions = {
|
|
|
36
36
|
* the header.
|
|
37
37
|
*/
|
|
38
38
|
keyInQuery?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* A preview token (from the dashboard's preview link). Settings and pages
|
|
41
|
+
* reads then send it as `X-Storefront-Preview` and answer the draft: they
|
|
42
|
+
* are never cached, here or in the `cache` store. A token that does not
|
|
43
|
+
* verify is a `401` `PREVIEW_EXPIRED`. Other routes never carry it.
|
|
44
|
+
*/
|
|
45
|
+
previewToken?: string;
|
|
39
46
|
};
|
|
40
47
|
/** Next.js's `fetch` cache options; the SDK never imports Next. */
|
|
41
48
|
type NextFetchOptions = {
|
|
@@ -57,6 +64,14 @@ type CallOptions = {
|
|
|
57
64
|
*/
|
|
58
65
|
next?: NextFetchOptions;
|
|
59
66
|
};
|
|
67
|
+
/** Options of the reads that answer settings (`config`, `settings`, `pages`). */
|
|
68
|
+
type SettingsCallOptions = CallOptions & {
|
|
69
|
+
/**
|
|
70
|
+
* The storefront generation the caller knows exists (a change notice names
|
|
71
|
+
* it). Above the one the edge holds, the answer is read fresh.
|
|
72
|
+
*/
|
|
73
|
+
minGeneration?: number;
|
|
74
|
+
};
|
|
60
75
|
type RequestSpec = {
|
|
61
76
|
method: 'GET' | 'POST';
|
|
62
77
|
/** Already encoded, starting with `/`. */
|
|
@@ -85,6 +100,8 @@ type RequestSpec = {
|
|
|
85
100
|
* options). A POST takes them in its body, from `context()`.
|
|
86
101
|
*/
|
|
87
102
|
context?: 'priced' | 'locale';
|
|
103
|
+
/** The route answers a draft to a preview token, so the client sends one. */
|
|
104
|
+
preview?: boolean;
|
|
88
105
|
};
|
|
89
106
|
|
|
90
107
|
/** A list sort the catalog knows. */
|
|
@@ -309,6 +326,24 @@ type CartsNamespace = {
|
|
|
309
326
|
throttleBaseUrl?: string;
|
|
310
327
|
}): CartSession;
|
|
311
328
|
};
|
|
329
|
+
/** `settings()`: the storefront settings and what versions them. */
|
|
330
|
+
type StorefrontSettingsResult = {
|
|
331
|
+
settings: StorefrontSettings;
|
|
332
|
+
settingsVersion: number;
|
|
333
|
+
generation: number;
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* `client.settings()`. The document may later be assembled from more than one
|
|
337
|
+
* extension (site design and catalog display); callers always read it through
|
|
338
|
+
* here, so its source can move without a change in the store.
|
|
339
|
+
*/
|
|
340
|
+
type SettingsNamespace = (call?: SettingsCallOptions) => Promise<StorefrontSettingsResult>;
|
|
341
|
+
type PagesNamespace = {
|
|
342
|
+
/** The published pages, in the store's order. */
|
|
343
|
+
list(call?: SettingsCallOptions): Promise<StorefrontPagesAnswer>;
|
|
344
|
+
/** One page; an unknown handle is a `404` `PAGE_NOT_FOUND`. */
|
|
345
|
+
get(handle: string, call?: SettingsCallOptions): Promise<StorefrontPageAnswer>;
|
|
346
|
+
};
|
|
312
347
|
type CatalogNamespaces = {
|
|
313
348
|
readonly products: ProductsNamespace;
|
|
314
349
|
readonly filters: FiltersNamespace;
|
|
@@ -318,7 +353,9 @@ type CatalogNamespaces = {
|
|
|
318
353
|
readonly suggest: (q: string, opts?: {
|
|
319
354
|
limit?: number;
|
|
320
355
|
} & CallOptions) => Promise<StorefrontSuggestAnswer>;
|
|
321
|
-
readonly config: (call?:
|
|
356
|
+
readonly config: (call?: SettingsCallOptions) => Promise<StorefrontConfigAnswer>;
|
|
357
|
+
readonly settings: SettingsNamespace;
|
|
358
|
+
readonly pages: PagesNamespace;
|
|
322
359
|
readonly reviews: ReviewsNamespace;
|
|
323
360
|
readonly carts: CartsNamespace;
|
|
324
361
|
};
|
|
@@ -346,4 +383,4 @@ type CustomerCartSource = {
|
|
|
346
383
|
whenClaimSettled(): Promise<void>;
|
|
347
384
|
};
|
|
348
385
|
|
|
349
|
-
export type { CustomerCartSource as C, FieldsOption as F, NextFetchOptions as N, OpenCartRef as O, ProductsQuery as P, Redirect as R, SessionCallOptions as S, ThrottleCart as T, CategoryTreeDepth as a, CartWarning as b, CallOptions as c, CartAbsorb as d, CartCheckout as e, CartCheckoutInput as f, CartSession as g, CartSessionBranding as h, CartSessionDetail as i, CartSessionSnapshot as j, CartsNamespace as k, CatalogClientOptions as l, CatalogHttpCache as m, CatalogHttpCacheEntry as n, CatalogNamespaces as o, CategoriesNamespace as p, CollectionsNamespace as q, CustomerTokenSource as r, FiltersNamespace as s,
|
|
386
|
+
export type { TagsNamespace as A, ThrottleLine as B, CustomerCartSource as C, RequestSpec as D, FieldsOption as F, NextFetchOptions as N, OpenCartRef as O, ProductsQuery as P, Redirect as R, SessionCallOptions as S, ThrottleCart as T, CategoryTreeDepth as a, CartWarning as b, CallOptions as c, CartAbsorb as d, CartCheckout as e, CartCheckoutInput as f, CartSession as g, CartSessionBranding as h, CartSessionDetail as i, CartSessionSnapshot as j, CartsNamespace as k, CatalogClientOptions as l, CatalogHttpCache as m, CatalogHttpCacheEntry as n, CatalogNamespaces as o, CategoriesNamespace as p, CollectionsNamespace as q, CustomerTokenSource as r, FiltersNamespace as s, PagesNamespace as t, ProductsNamespace as u, ReviewsNamespace as v, SettingsCallOptions as w, SettingsNamespace as x, StorefrontSettingsResult as y, StorefrontSort as z };
|
package/dist/url.d.cts
CHANGED
package/dist/url.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usethrottle/catalog",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Storefront SDK for the Throttle Product Catalog: a typed client, React hooks, server helpers and URL helpers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -56,6 +56,16 @@
|
|
|
56
56
|
"default": "./dist/server.cjs"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
+
"./next": {
|
|
60
|
+
"import": {
|
|
61
|
+
"types": "./dist/next.d.ts",
|
|
62
|
+
"default": "./dist/next.js"
|
|
63
|
+
},
|
|
64
|
+
"require": {
|
|
65
|
+
"types": "./dist/next.d.cts",
|
|
66
|
+
"default": "./dist/next.cjs"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
59
69
|
"./url": {
|
|
60
70
|
"import": {
|
|
61
71
|
"types": "./dist/url.d.ts",
|
|
@@ -89,12 +99,16 @@
|
|
|
89
99
|
},
|
|
90
100
|
"dependencies": {
|
|
91
101
|
"@usethrottle/errors": "^1.1.0",
|
|
92
|
-
"@usethrottle/money": "^1.
|
|
102
|
+
"@usethrottle/money": "^1.1.0"
|
|
93
103
|
},
|
|
94
104
|
"peerDependencies": {
|
|
105
|
+
"next": ">=14",
|
|
95
106
|
"react": "^18.2.0 || ^19.0.0"
|
|
96
107
|
},
|
|
97
108
|
"peerDependenciesMeta": {
|
|
109
|
+
"next": {
|
|
110
|
+
"optional": true
|
|
111
|
+
},
|
|
98
112
|
"react": {
|
|
99
113
|
"optional": true
|
|
100
114
|
}
|