@doswiftly/storefront-sdk 4.3.0 → 4.5.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 +6 -14
- package/dist/core/cart/types.d.ts +53 -20
- package/dist/core/cart/types.d.ts.map +1 -1
- package/dist/core/cart/types.js +3 -0
- package/dist/core/image.d.ts +4 -46
- package/dist/core/image.d.ts.map +1 -1
- package/dist/core/image.js +4 -65
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +0 -2
- package/dist/core/operations/cart.d.ts +15 -9
- package/dist/core/operations/cart.d.ts.map +1 -1
- package/dist/core/operations/cart.js +130 -58
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +9 -4
- package/src/__tests__/contract/storefront-api.contract.test.ts +0 -450
- package/src/__tests__/unit/auth-client.test.ts +0 -210
- package/src/__tests__/unit/bot-protection.test.ts +0 -461
- package/src/__tests__/unit/cart-client.test.ts +0 -233
- package/src/__tests__/unit/cart-store.test.ts +0 -349
- package/src/__tests__/unit/create-client.test.ts +0 -356
- package/src/__tests__/unit/helpers.test.ts +0 -377
- package/src/__tests__/unit/middleware.test.ts +0 -374
- package/src/__tests__/unit/test-helpers.ts +0 -103
- package/src/core/auth/auth-client.ts +0 -123
- package/src/core/auth/cookie-config.ts +0 -23
- package/src/core/auth/handlers.ts +0 -168
- package/src/core/auth/routes.ts +0 -26
- package/src/core/auth/token-client.ts +0 -51
- package/src/core/auth/types.ts +0 -54
- package/src/core/bot-protection/abstract-manager.ts +0 -185
- package/src/core/bot-protection/create-manager.ts +0 -37
- package/src/core/bot-protection/eucaptcha-manager.ts +0 -88
- package/src/core/bot-protection/fallback-manager.ts +0 -43
- package/src/core/bot-protection/turnstile-manager.ts +0 -92
- package/src/core/bot-protection/types/eucaptcha.d.ts +0 -28
- package/src/core/bot-protection/types/turnstile.d.ts +0 -33
- package/src/core/cache.ts +0 -102
- package/src/core/cart/cart-client.ts +0 -150
- package/src/core/cart/cookie-config.ts +0 -13
- package/src/core/cart/types.ts +0 -104
- package/src/core/client/compose.ts +0 -15
- package/src/core/client/create-client.ts +0 -129
- package/src/core/client/dedupe.ts +0 -19
- package/src/core/client/execute.ts +0 -70
- package/src/core/client/hash.ts +0 -21
- package/src/core/client/operation-name.ts +0 -12
- package/src/core/client/types.ts +0 -171
- package/src/core/currency/cookie-config.ts +0 -13
- package/src/core/errors.ts +0 -67
- package/src/core/format.ts +0 -254
- package/src/core/helpers/assert-no-user-errors.ts +0 -21
- package/src/core/helpers/normalize-connection.ts +0 -48
- package/src/core/helpers/sanitize-html.ts +0 -42
- package/src/core/image.ts +0 -103
- package/src/core/index.ts +0 -180
- package/src/core/language/cookie-config.ts +0 -13
- package/src/core/middleware/auth.ts +0 -27
- package/src/core/middleware/bot-protection.ts +0 -140
- package/src/core/middleware/currency.ts +0 -27
- package/src/core/middleware/errors.ts +0 -86
- package/src/core/middleware/language.ts +0 -30
- package/src/core/middleware/retry.ts +0 -75
- package/src/core/middleware/timeout.ts +0 -61
- package/src/core/operations/auth.ts +0 -123
- package/src/core/operations/cart.ts +0 -185
- package/src/index.ts +0 -25
- package/src/react/bot-protection/bot-protection-context.ts +0 -17
- package/src/react/bot-protection/bot-protection-widget.tsx +0 -46
- package/src/react/cookies.ts +0 -89
- package/src/react/helpers/create-store-context.ts +0 -56
- package/src/react/hooks/use-auth.ts +0 -218
- package/src/react/hooks/use-bot-protection.ts +0 -31
- package/src/react/hooks/use-cart-manager.ts +0 -236
- package/src/react/hooks/use-currency.ts +0 -23
- package/src/react/hooks/use-debounced-value.ts +0 -30
- package/src/react/hooks/use-hydrated.ts +0 -20
- package/src/react/hooks/use-storefront-client.ts +0 -12
- package/src/react/index.ts +0 -71
- package/src/react/providers/currency-provider.tsx +0 -30
- package/src/react/providers/language-provider.tsx +0 -34
- package/src/react/providers/storefront-client-provider.tsx +0 -107
- package/src/react/providers/storefront-provider.tsx +0 -99
- package/src/react/server/get-storefront-client.ts +0 -60
- package/src/react/server/index.ts +0 -1
- package/src/react/stores/auth.store.ts +0 -112
- package/src/react/stores/cart.context.ts +0 -10
- package/src/react/stores/cart.store.ts +0 -254
- package/src/react/stores/currency.store.ts +0 -93
- package/src/react/stores/index.ts +0 -17
- package/src/react/stores/language.store.ts +0 -90
- package/src/react/stores/store-context.tsx +0 -103
- package/src/react/types/shop-config.ts +0 -22
- package/tsconfig.json +0 -20
- package/vitest.config.ts +0 -14
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Layered runtime SDK for DoSwiftly Commerce storefronts. Hydrogen-aligned archite
|
|
|
7
7
|
```
|
|
8
8
|
@doswiftly/storefront-sdk
|
|
9
9
|
├── core (.) — Framework-agnostic: transport, middleware, CartClient, AuthClient,
|
|
10
|
-
│ cache, format utilities, image
|
|
10
|
+
│ cache, format utilities, image types, sanitizeHtml,
|
|
11
11
|
│ normalizeConnection, auth cookie config/handlers/token client, route matching
|
|
12
12
|
├── react (./react) — React adapter: providers, Zustand stores (Context-based), hooks,
|
|
13
13
|
│ useHydrated, useDebouncedValue, createStoreContext
|
|
@@ -93,7 +93,7 @@ const { currency, setCurrency } = useCurrencyStore();
|
|
|
93
93
|
|
|
94
94
|
| Path | Description | Dependencies |
|
|
95
95
|
|------|-------------|-------------|
|
|
96
|
-
| `@doswiftly/storefront-sdk` | Core: transport, middleware, clients, errors, format, image
|
|
96
|
+
| `@doswiftly/storefront-sdk` | Core: transport, middleware, clients, errors, format, image types, sanitize, auth handlers, route matching | **0** |
|
|
97
97
|
| `@doswiftly/storefront-sdk/react` | Providers, hooks, store hooks, useHydrated, useDebouncedValue, createStoreContext | react, zustand |
|
|
98
98
|
| `@doswiftly/storefront-sdk/react/server` | Server-side client factory | react |
|
|
99
99
|
| `@doswiftly/storefront-sdk/cache` | Cache strategy functions | **0** |
|
|
@@ -213,19 +213,11 @@ formatDate(new Date()); // "Dec 9, 2025"
|
|
|
213
213
|
formatPercentage(0.15); // "15%"
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
-
### Image
|
|
216
|
+
### Image Types
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
GraphQL API returns ready-to-use CDN URLs via `url(transform: { maxWidth: 800 })`. No client-side loader needed.
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
// For custom frameworks (Svelte, Astro, etc.) — import the loader function directly:
|
|
222
|
-
import { storefrontImageLoader } from '@doswiftly/storefront-sdk';
|
|
223
|
-
|
|
224
|
-
const url = storefrontImageLoader({ src: image.url, width: 800, quality: 85 });
|
|
225
|
-
// → image.url + "?width=800&quality=85&format=webp"
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
Width quantized to Next.js-aligned breakpoints for CDN cache efficiency. `ImageData` type matches GraphQL `Image` fragment: `{ url, altText?, width?, height?, id? }`.
|
|
220
|
+
`ImageData` type matches GraphQL `Image` fragment: `{ url, altText?, width?, height?, id? }`.
|
|
229
221
|
|
|
230
222
|
### HTML Sanitizer
|
|
231
223
|
|
|
@@ -456,7 +448,7 @@ SDK provides: Template owns:
|
|
|
456
448
|
├── Providers + Zustand stores ├── lib/graphql/fragments/
|
|
457
449
|
├── Format utilities ├── hooks/use-cart-di.ts (CartActions DI impl)
|
|
458
450
|
├── sanitizeHtml ├── hooks/use-cart-actions.ts (UX wrapper)
|
|
459
|
-
├──
|
|
451
|
+
├── ImageData type ├── components/product/product-image.tsx
|
|
460
452
|
├── normalizeConnection ├── stores/ (checkout, wishlist via createStoreContext)
|
|
461
453
|
├── Auth handlers + token client ├── lib/auth/routes.ts (route config)
|
|
462
454
|
├── useHydrated + useDebouncedValue
|
|
@@ -2,32 +2,67 @@
|
|
|
2
2
|
* Cart types — manual (no codegen).
|
|
3
3
|
*
|
|
4
4
|
* These match the backend storefront-graphql Cart type.
|
|
5
|
+
* Keep in sync with SSOT: backend/storefront-graphql/types/cart.types.ts
|
|
6
|
+
*
|
|
7
|
+
* Validate with: pnpm test:contract (cart-operations-drift test)
|
|
5
8
|
*/
|
|
6
9
|
export interface Money {
|
|
7
10
|
amount: string;
|
|
8
11
|
currencyCode: string;
|
|
9
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Price with full currency-conversion transparency.
|
|
15
|
+
*
|
|
16
|
+
* Used for all cart/checkout prices where the customer may be viewing
|
|
17
|
+
* prices converted from the shop's base currency.
|
|
18
|
+
*/
|
|
19
|
+
export interface PriceMoney {
|
|
20
|
+
amount: string;
|
|
21
|
+
currencyCode: string;
|
|
22
|
+
baseAmount: string;
|
|
23
|
+
baseCurrencyCode: string;
|
|
24
|
+
exchangeRate: number | null;
|
|
25
|
+
marginApplied: number | null;
|
|
26
|
+
rateTimestamp: string | null;
|
|
27
|
+
isConverted: boolean;
|
|
28
|
+
}
|
|
10
29
|
export interface CartCost {
|
|
11
|
-
totalAmount:
|
|
12
|
-
subtotalAmount:
|
|
13
|
-
totalTaxAmount:
|
|
14
|
-
totalDutyAmount:
|
|
30
|
+
totalAmount: PriceMoney;
|
|
31
|
+
subtotalAmount: PriceMoney;
|
|
32
|
+
totalTaxAmount: PriceMoney | null;
|
|
33
|
+
totalDutyAmount: PriceMoney | null;
|
|
15
34
|
}
|
|
16
35
|
export interface CartLineCost {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
36
|
+
amountPerQuantity: PriceMoney;
|
|
37
|
+
subtotalAmount: PriceMoney;
|
|
38
|
+
totalAmount: PriceMoney;
|
|
39
|
+
compareAtAmountPerQuantity: PriceMoney | null;
|
|
40
|
+
}
|
|
41
|
+
export interface SelectedOption {
|
|
42
|
+
name: string;
|
|
43
|
+
value: string;
|
|
20
44
|
}
|
|
21
45
|
export interface CartLineMerchandise {
|
|
22
46
|
id: string;
|
|
23
47
|
title: string;
|
|
24
48
|
sku: string | null;
|
|
49
|
+
price: PriceMoney;
|
|
50
|
+
originalPrice: Money | null;
|
|
51
|
+
compareAtPrice: PriceMoney | null;
|
|
52
|
+
originalCompareAtPrice: Money | null;
|
|
53
|
+
available: boolean;
|
|
54
|
+
quantityAvailable: number | null;
|
|
25
55
|
image: {
|
|
56
|
+
id: string | null;
|
|
26
57
|
url: string;
|
|
27
58
|
altText: string | null;
|
|
59
|
+
width: number | null;
|
|
60
|
+
height: number | null;
|
|
28
61
|
} | null;
|
|
29
|
-
|
|
30
|
-
|
|
62
|
+
selectedOptions: SelectedOption[];
|
|
63
|
+
barcode: string | null;
|
|
64
|
+
weight: number | null;
|
|
65
|
+
position: number | null;
|
|
31
66
|
}
|
|
32
67
|
export interface CartLine {
|
|
33
68
|
id: string;
|
|
@@ -36,18 +71,20 @@ export interface CartLine {
|
|
|
36
71
|
cost: CartLineCost;
|
|
37
72
|
attributes: Array<{
|
|
38
73
|
key: string;
|
|
39
|
-
value: string;
|
|
74
|
+
value: string | null;
|
|
40
75
|
}>;
|
|
41
|
-
productId: string;
|
|
42
|
-
productTitle: string;
|
|
43
|
-
productHandle: string;
|
|
76
|
+
productId: string | null;
|
|
77
|
+
productTitle: string | null;
|
|
78
|
+
productHandle: string | null;
|
|
79
|
+
productType: string | null;
|
|
44
80
|
}
|
|
45
81
|
export interface CartDiscountCode {
|
|
46
82
|
code: string;
|
|
47
83
|
applicable: boolean;
|
|
48
84
|
}
|
|
49
85
|
export interface CartDiscountAllocation {
|
|
50
|
-
|
|
86
|
+
discountCode: string;
|
|
87
|
+
amount: Money;
|
|
51
88
|
}
|
|
52
89
|
export interface CartBuyerIdentity {
|
|
53
90
|
email: string | null;
|
|
@@ -62,17 +99,13 @@ export interface Cart {
|
|
|
62
99
|
createdAt: string;
|
|
63
100
|
updatedAt: string;
|
|
64
101
|
cost: CartCost;
|
|
65
|
-
lines:
|
|
66
|
-
edges: Array<{
|
|
67
|
-
node: CartLine;
|
|
68
|
-
}>;
|
|
69
|
-
};
|
|
102
|
+
lines: CartLine[];
|
|
70
103
|
buyerIdentity: CartBuyerIdentity | null;
|
|
71
104
|
discountCodes: CartDiscountCode[];
|
|
72
105
|
discountAllocations: CartDiscountAllocation[];
|
|
73
106
|
attributes: Array<{
|
|
74
107
|
key: string;
|
|
75
|
-
value: string;
|
|
108
|
+
value: string | null;
|
|
76
109
|
}>;
|
|
77
110
|
}
|
|
78
111
|
export interface CartLineInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/cart/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/cart/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;CACtB;AAMD,MAAM,WAAW,QAAQ;IACvB,WAAW,EAAE,UAAU,CAAC;IACxB,cAAc,EAAE,UAAU,CAAC;IAC3B,cAAc,EAAE,UAAU,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,UAAU,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,iBAAiB,EAAE,UAAU,CAAC;IAC9B,cAAc,EAAE,UAAU,CAAC;IAC3B,WAAW,EAAE,UAAU,CAAC;IACxB,0BAA0B,EAAE,UAAU,GAAG,IAAI,CAAC;CAC/C;AAMD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,E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AAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/core/cart/types.js
CHANGED
package/dist/core/image.d.ts
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Image
|
|
2
|
+
* Image types for DoSwiftly storefronts.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { storefrontImageLoader, type ImageData } from '@doswiftly/storefront-sdk';
|
|
10
|
-
*
|
|
11
|
-
* <Image loader={storefrontImageLoader} src={product.featuredImage.url} width={800} alt="..." />
|
|
12
|
-
* ```
|
|
4
|
+
* GraphQL API returns ready-to-use CDN URLs with transform query params.
|
|
5
|
+
* No client-side loader needed — use `url(transform: { maxWidth: 800 })` in queries.
|
|
13
6
|
*/
|
|
14
7
|
/**
|
|
15
8
|
* Image data from GraphQL API (matches Image type in storefront schema).
|
|
16
9
|
*/
|
|
17
10
|
export interface ImageData {
|
|
18
|
-
/** Image URL from GraphQL (ready-to-use CDN URL) */
|
|
11
|
+
/** Image URL from GraphQL (ready-to-use CDN URL, optionally with transform query params) */
|
|
19
12
|
url: string;
|
|
20
13
|
/** Alt text for accessibility + SEO */
|
|
21
14
|
altText?: string | null;
|
|
@@ -26,39 +19,4 @@ export interface ImageData {
|
|
|
26
19
|
/** Image ID */
|
|
27
20
|
id?: string | null;
|
|
28
21
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Next.js Image loader function signature.
|
|
31
|
-
*/
|
|
32
|
-
export interface ImageLoaderParams {
|
|
33
|
-
src: string;
|
|
34
|
-
width: number;
|
|
35
|
-
quality?: number;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Image format for imgproxy output.
|
|
39
|
-
*/
|
|
40
|
-
export type ImageFormat = 'webp' | 'avif' | 'jpeg';
|
|
41
|
-
/**
|
|
42
|
-
* Default image loader — WebP format. Used as global loaderFile in next.config.ts.
|
|
43
|
-
* Zero configuration: works out-of-the-box with GraphQL image URLs.
|
|
44
|
-
* Width quantized to preset breakpoints for optimal CDN cache.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```tsx
|
|
48
|
-
* import { storefrontImageLoader } from '@doswiftly/storefront-sdk';
|
|
49
|
-
* <Image loader={storefrontImageLoader} src={image.url} width={800} alt="..." />
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare function storefrontImageLoader({ src, width, quality }: ImageLoaderParams): string;
|
|
53
|
-
/**
|
|
54
|
-
* Create a custom loader with specific format (avif, jpeg).
|
|
55
|
-
* Use as per-component override when you need a different format than default WebP.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```tsx
|
|
59
|
-
* const avifLoader = createImageLoader('avif');
|
|
60
|
-
* <Image loader={avifLoader} src={image.url} width={800} alt="..." />
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export declare function createImageLoader(format: ImageFormat): (params: ImageLoaderParams) => string;
|
|
64
22
|
//# sourceMappingURL=image.d.ts.map
|
package/dist/core/image.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/core/image.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/core/image.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,4FAA4F;IAC5F,GAAG,EAAE,MAAM,CAAC;IACZ,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,eAAe;IACf,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB"}
|
package/dist/core/image.js
CHANGED
|
@@ -1,68 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Image
|
|
2
|
+
* Image types for DoSwiftly storefronts.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { storefrontImageLoader, type ImageData } from '@doswiftly/storefront-sdk';
|
|
10
|
-
*
|
|
11
|
-
* <Image loader={storefrontImageLoader} src={product.featuredImage.url} width={800} alt="..." />
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Preset widths for CDN cache optimization.
|
|
16
|
-
* Loader quantizes requested width to the nearest preset — limits cache variants.
|
|
17
|
-
*/
|
|
18
|
-
const PRESET_WIDTHS = [150, 320, 640, 750, 828, 1080, 1200, 1600, 1920, 2048];
|
|
19
|
-
function nearestPresetWidth(requested) {
|
|
20
|
-
for (const w of PRESET_WIDTHS) {
|
|
21
|
-
if (w >= requested)
|
|
22
|
-
return w;
|
|
23
|
-
}
|
|
24
|
-
return PRESET_WIDTHS[PRESET_WIDTHS.length - 1];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Default image loader — WebP format. Used as global loaderFile in next.config.ts.
|
|
28
|
-
* Zero configuration: works out-of-the-box with GraphQL image URLs.
|
|
29
|
-
* Width quantized to preset breakpoints for optimal CDN cache.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```tsx
|
|
33
|
-
* import { storefrontImageLoader } from '@doswiftly/storefront-sdk';
|
|
34
|
-
* <Image loader={storefrontImageLoader} src={image.url} width={800} alt="..." />
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export function storefrontImageLoader({ src, width, quality }) {
|
|
38
|
-
return buildImgproxyUrl(src, width, quality);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Create a custom loader with specific format (avif, jpeg).
|
|
42
|
-
* Use as per-component override when you need a different format than default WebP.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```tsx
|
|
46
|
-
* const avifLoader = createImageLoader('avif');
|
|
47
|
-
* <Image loader={avifLoader} src={image.url} width={800} alt="..." />
|
|
48
|
-
* ```
|
|
4
|
+
* GraphQL API returns ready-to-use CDN URLs with transform query params.
|
|
5
|
+
* No client-side loader needed — use `url(transform: { maxWidth: 800 })` in queries.
|
|
49
6
|
*/
|
|
50
|
-
export
|
|
51
|
-
return ({ src, width, quality }) => buildImgproxyUrl(src, width, quality, format);
|
|
52
|
-
}
|
|
53
|
-
function buildImgproxyUrl(src, width, quality, format = 'webp') {
|
|
54
|
-
const w = nearestPresetWidth(width);
|
|
55
|
-
const q = quality ?? 85;
|
|
56
|
-
if (!src.startsWith('http')) {
|
|
57
|
-
return src;
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
const url = new URL(src);
|
|
61
|
-
const path = url.pathname.slice(1);
|
|
62
|
-
return `${url.origin}/rs:fit:${w}:0:0/q:${q}/f:${format}/plain/${path}`;
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
// Malformed URL — return as-is, let browser handle it
|
|
66
|
-
return src;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
7
|
+
export {};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export { CART_COOKIE_NAME, CART_COOKIE_MAX_AGE } from './cart/cookie-config';
|
|
|
61
61
|
export { matchesRoute, type RouteProtectionConfig } from './auth/routes';
|
|
62
62
|
export { createSetTokenHandler, createClearTokenHandler } from './auth/handlers';
|
|
63
63
|
export { createAuthTokenClient, type AuthTokenClient } from './auth/token-client';
|
|
64
|
-
export {
|
|
64
|
+
export { type ImageData } from './image';
|
|
65
65
|
export { getOperationName } from './client/operation-name';
|
|
66
66
|
export { hashQuery } from './client/hash';
|
|
67
67
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,EACnC,KAAK,YAAY,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC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,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,UAAU,GAChB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,gBAAgB,GACtB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAG/G,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAG/G,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG7E,OAAO,EAAE,YAAY,EAAE,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGzE,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAGjF,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGlF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -74,8 +74,6 @@ export { matchesRoute } from './auth/routes';
|
|
|
74
74
|
export { createSetTokenHandler, createClearTokenHandler } from './auth/handlers';
|
|
75
75
|
// Auth token client (client-side fetch helpers)
|
|
76
76
|
export { createAuthTokenClient } from './auth/token-client';
|
|
77
|
-
// Image utilities
|
|
78
|
-
export { storefrontImageLoader, createImageLoader, } from './image';
|
|
79
77
|
// Utilities
|
|
80
78
|
export { getOperationName } from './client/operation-name';
|
|
81
79
|
export { hashQuery } from './client/hash';
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cart GraphQL operations — manual query strings (no codegen).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* SSOT: packages/backend/src/commerce/storefront-graphql/operations/
|
|
5
|
+
* - fragments.graphql (CartCost, CartLineCost, CartLine, Cart, etc.)
|
|
6
|
+
* - queries.graphql (Cart query)
|
|
7
|
+
* - mutations.graphql (cartCreate, cartLinesAdd, etc.)
|
|
8
|
+
*
|
|
9
|
+
* Validate drift: pnpm test:contract (cart-operations-drift test)
|
|
10
|
+
*
|
|
5
11
|
* Cart mutations always return full Cart + userErrors.
|
|
6
12
|
*/
|
|
7
|
-
export declare const CART_QUERY = "\n query Cart($id: ID!) {\n cart(id: $id) {\n ...
|
|
8
|
-
export declare const CART_CREATE = "\n mutation CartCreate($input: CartCreateInput) {\n cartCreate(input: $input) {\n cart { ...
|
|
9
|
-
export declare const CART_LINES_ADD = "\n mutation CartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart { ...
|
|
10
|
-
export declare const CART_LINES_UPDATE = "\n mutation CartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart { ...
|
|
11
|
-
export declare const CART_LINES_REMOVE = "\n mutation CartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart { ...
|
|
12
|
-
export declare const CART_DISCOUNT_CODES_UPDATE = "\n mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart { ...
|
|
13
|
-
export declare const CART_NOTE_UPDATE = "\n mutation CartNoteUpdate($cartId: ID!, $note: String!) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart { ...
|
|
14
|
-
export declare const CART_BUYER_IDENTITY_UPDATE = "\n mutation CartBuyerIdentityUpdate($cartId: ID!, $buyerIdentity: CartBuyerIdentityInput!) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart { ...
|
|
13
|
+
export declare const CART_QUERY = "\n query Cart($id: ID!) {\n cart(id: $id) {\n ...Cart\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n";
|
|
14
|
+
export declare const CART_CREATE = "\n mutation CartCreate($input: CartCreateInput) {\n cartCreate(input: $input) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
|
|
15
|
+
export declare const CART_LINES_ADD = "\n mutation CartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
|
|
16
|
+
export declare const CART_LINES_UPDATE = "\n mutation CartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
|
|
17
|
+
export declare const CART_LINES_REMOVE = "\n mutation CartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
|
|
18
|
+
export declare const CART_DISCOUNT_CODES_UPDATE = "\n mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
|
|
19
|
+
export declare const CART_NOTE_UPDATE = "\n mutation CartNoteUpdate($cartId: ID!, $note: String!) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
|
|
20
|
+
export declare const CART_BUYER_IDENTITY_UPDATE = "\n mutation CartBuyerIdentityUpdate($cartId: ID!, $buyerIdentity: CartBuyerIdentityInput!) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
|
|
15
21
|
//# sourceMappingURL=cart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../../src/core/operations/cart.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../../src/core/operations/cart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAuKH,eAAO,MAAM,UAAU,otEAOtB,CAAC;AAMF,eAAO,MAAM,WAAW,s3EASvB,CAAC;AAEF,eAAO,MAAM,cAAc,25EAS1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,u6EAS7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,45EAS7B,CAAC;AAEF,eAAO,MAAM,0BAA0B,k8EAStC,CAAC;AAEF,eAAO,MAAM,gBAAgB,k5EAS5B,CAAC;AAEF,eAAO,MAAM,0BAA0B,+8EAStC,CAAC"}
|