@doswiftly/storefront-sdk 4.0.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.
Files changed (206) hide show
  1. package/README.md +430 -0
  2. package/dist/__tests__/unit/test-helpers.d.ts +46 -0
  3. package/dist/__tests__/unit/test-helpers.d.ts.map +1 -0
  4. package/dist/__tests__/unit/test-helpers.js +72 -0
  5. package/dist/core/auth/auth-client.d.ts +46 -0
  6. package/dist/core/auth/auth-client.d.ts.map +1 -0
  7. package/dist/core/auth/auth-client.js +82 -0
  8. package/dist/core/auth/cookie-config.d.ts +18 -0
  9. package/dist/core/auth/cookie-config.d.ts.map +1 -0
  10. package/dist/core/auth/cookie-config.js +18 -0
  11. package/dist/core/auth/handlers.d.ts +32 -0
  12. package/dist/core/auth/handlers.d.ts.map +1 -0
  13. package/dist/core/auth/handlers.js +127 -0
  14. package/dist/core/auth/routes.d.ts +21 -0
  15. package/dist/core/auth/routes.d.ts.map +1 -0
  16. package/dist/core/auth/routes.js +14 -0
  17. package/dist/core/auth/token-client.d.ts +26 -0
  18. package/dist/core/auth/token-client.d.ts.map +1 -0
  19. package/dist/core/auth/token-client.js +42 -0
  20. package/dist/core/auth/types.d.ts +53 -0
  21. package/dist/core/auth/types.d.ts.map +1 -0
  22. package/dist/core/auth/types.js +4 -0
  23. package/dist/core/cache.d.ts +54 -0
  24. package/dist/core/cache.d.ts.map +1 -0
  25. package/dist/core/cache.js +82 -0
  26. package/dist/core/cart/cart-client.d.ts +57 -0
  27. package/dist/core/cart/cart-client.d.ts.map +1 -0
  28. package/dist/core/cart/cart-client.js +89 -0
  29. package/dist/core/cart/types.d.ts +110 -0
  30. package/dist/core/cart/types.d.ts.map +1 -0
  31. package/dist/core/cart/types.js +6 -0
  32. package/dist/core/client/compose.d.ts +9 -0
  33. package/dist/core/client/compose.d.ts.map +1 -0
  34. package/dist/core/client/compose.js +9 -0
  35. package/dist/core/client/create-client.d.ts +15 -0
  36. package/dist/core/client/create-client.d.ts.map +1 -0
  37. package/dist/core/client/create-client.js +85 -0
  38. package/dist/core/client/dedupe.d.ts +7 -0
  39. package/dist/core/client/dedupe.d.ts.map +1 -0
  40. package/dist/core/client/dedupe.js +16 -0
  41. package/dist/core/client/execute.d.ts +20 -0
  42. package/dist/core/client/execute.d.ts.map +1 -0
  43. package/dist/core/client/execute.js +48 -0
  44. package/dist/core/client/hash.d.ts +7 -0
  45. package/dist/core/client/hash.d.ts.map +1 -0
  46. package/dist/core/client/hash.js +21 -0
  47. package/dist/core/client/operation-name.d.ts +7 -0
  48. package/dist/core/client/operation-name.d.ts.map +1 -0
  49. package/dist/core/client/operation-name.js +10 -0
  50. package/dist/core/client/types.d.ts +126 -0
  51. package/dist/core/client/types.d.ts.map +1 -0
  52. package/dist/core/client/types.js +26 -0
  53. package/dist/core/errors.d.ts +43 -0
  54. package/dist/core/errors.d.ts.map +1 -0
  55. package/dist/core/errors.js +43 -0
  56. package/dist/core/format.d.ts +92 -0
  57. package/dist/core/format.d.ts.map +1 -0
  58. package/dist/core/format.js +216 -0
  59. package/dist/core/helpers/assert-no-user-errors.d.ts +10 -0
  60. package/dist/core/helpers/assert-no-user-errors.d.ts.map +1 -0
  61. package/dist/core/helpers/assert-no-user-errors.js +16 -0
  62. package/dist/core/helpers/normalize-connection.d.ts +36 -0
  63. package/dist/core/helpers/normalize-connection.d.ts.map +1 -0
  64. package/dist/core/helpers/normalize-connection.js +21 -0
  65. package/dist/core/helpers/sanitize-html.d.ts +8 -0
  66. package/dist/core/helpers/sanitize-html.d.ts.map +1 -0
  67. package/dist/core/helpers/sanitize-html.js +35 -0
  68. package/dist/core/index.d.ts +59 -0
  69. package/dist/core/index.d.ts.map +1 -0
  70. package/dist/core/index.js +68 -0
  71. package/dist/core/middleware/auth.d.ts +16 -0
  72. package/dist/core/middleware/auth.d.ts.map +1 -0
  73. package/dist/core/middleware/auth.js +22 -0
  74. package/dist/core/middleware/currency.d.ts +15 -0
  75. package/dist/core/middleware/currency.d.ts.map +1 -0
  76. package/dist/core/middleware/currency.js +21 -0
  77. package/dist/core/middleware/errors.d.ts +24 -0
  78. package/dist/core/middleware/errors.d.ts.map +1 -0
  79. package/dist/core/middleware/errors.js +77 -0
  80. package/dist/core/middleware/retry.d.ts +22 -0
  81. package/dist/core/middleware/retry.d.ts.map +1 -0
  82. package/dist/core/middleware/retry.js +58 -0
  83. package/dist/core/middleware/timeout.d.ts +19 -0
  84. package/dist/core/middleware/timeout.d.ts.map +1 -0
  85. package/dist/core/middleware/timeout.js +51 -0
  86. package/dist/core/operations/auth.d.ts +11 -0
  87. package/dist/core/operations/auth.d.ts.map +1 -0
  88. package/dist/core/operations/auth.js +112 -0
  89. package/dist/core/operations/cart.d.ts +15 -0
  90. package/dist/core/operations/cart.d.ts.map +1 -0
  91. package/dist/core/operations/cart.js +169 -0
  92. package/dist/index.d.ts +24 -0
  93. package/dist/index.d.ts.map +1 -0
  94. package/dist/index.js +24 -0
  95. package/dist/react/cookies.d.ts +28 -0
  96. package/dist/react/cookies.d.ts.map +1 -0
  97. package/dist/react/cookies.js +49 -0
  98. package/dist/react/helpers/create-store-context.d.ts +37 -0
  99. package/dist/react/helpers/create-store-context.d.ts.map +1 -0
  100. package/dist/react/helpers/create-store-context.js +47 -0
  101. package/dist/react/hooks/use-auth.d.ts +65 -0
  102. package/dist/react/hooks/use-auth.d.ts.map +1 -0
  103. package/dist/react/hooks/use-auth.js +168 -0
  104. package/dist/react/hooks/use-cart-manager.d.ts +30 -0
  105. package/dist/react/hooks/use-cart-manager.d.ts.map +1 -0
  106. package/dist/react/hooks/use-cart-manager.js +223 -0
  107. package/dist/react/hooks/use-currency.d.ts +11 -0
  108. package/dist/react/hooks/use-currency.d.ts.map +1 -0
  109. package/dist/react/hooks/use-currency.js +19 -0
  110. package/dist/react/hooks/use-debounced-value.d.ts +15 -0
  111. package/dist/react/hooks/use-debounced-value.d.ts.map +1 -0
  112. package/dist/react/hooks/use-debounced-value.js +25 -0
  113. package/dist/react/hooks/use-hydrated.d.ts +9 -0
  114. package/dist/react/hooks/use-hydrated.d.ts.map +1 -0
  115. package/dist/react/hooks/use-hydrated.js +14 -0
  116. package/dist/react/hooks/use-storefront-client.d.ts +6 -0
  117. package/dist/react/hooks/use-storefront-client.d.ts.map +1 -0
  118. package/dist/react/hooks/use-storefront-client.js +8 -0
  119. package/dist/react/index.d.ts +30 -0
  120. package/dist/react/index.d.ts.map +1 -0
  121. package/dist/react/index.js +34 -0
  122. package/dist/react/providers/currency-provider.d.ts +14 -0
  123. package/dist/react/providers/currency-provider.d.ts.map +1 -0
  124. package/dist/react/providers/currency-provider.js +20 -0
  125. package/dist/react/providers/storefront-client-provider.d.ts +33 -0
  126. package/dist/react/providers/storefront-client-provider.d.ts.map +1 -0
  127. package/dist/react/providers/storefront-client-provider.js +57 -0
  128. package/dist/react/providers/storefront-provider.d.ts +42 -0
  129. package/dist/react/providers/storefront-provider.d.ts.map +1 -0
  130. package/dist/react/providers/storefront-provider.js +40 -0
  131. package/dist/react/server/get-storefront-client.d.ts +42 -0
  132. package/dist/react/server/get-storefront-client.d.ts.map +1 -0
  133. package/dist/react/server/get-storefront-client.js +44 -0
  134. package/dist/react/server/index.d.ts +2 -0
  135. package/dist/react/server/index.d.ts.map +1 -0
  136. package/dist/react/server/index.js +1 -0
  137. package/dist/react/stores/auth.store.d.ts +48 -0
  138. package/dist/react/stores/auth.store.d.ts.map +1 -0
  139. package/dist/react/stores/auth.store.js +67 -0
  140. package/dist/react/stores/currency.store.d.ts +29 -0
  141. package/dist/react/stores/currency.store.d.ts.map +1 -0
  142. package/dist/react/stores/currency.store.js +76 -0
  143. package/dist/react/stores/index.d.ts +8 -0
  144. package/dist/react/stores/index.d.ts.map +1 -0
  145. package/dist/react/stores/index.js +10 -0
  146. package/dist/react/stores/store-context.d.ts +27 -0
  147. package/dist/react/stores/store-context.d.ts.map +1 -0
  148. package/dist/react/stores/store-context.js +62 -0
  149. package/package.json +71 -0
  150. package/src/__tests__/contract/storefront-api.contract.test.ts +450 -0
  151. package/src/__tests__/unit/auth-client.test.ts +210 -0
  152. package/src/__tests__/unit/cart-client.test.ts +233 -0
  153. package/src/__tests__/unit/create-client.test.ts +356 -0
  154. package/src/__tests__/unit/helpers.test.ts +377 -0
  155. package/src/__tests__/unit/middleware.test.ts +374 -0
  156. package/src/__tests__/unit/test-helpers.ts +103 -0
  157. package/src/core/auth/auth-client.ts +123 -0
  158. package/src/core/auth/cookie-config.ts +23 -0
  159. package/src/core/auth/handlers.ts +168 -0
  160. package/src/core/auth/routes.ts +26 -0
  161. package/src/core/auth/token-client.ts +51 -0
  162. package/src/core/auth/types.ts +54 -0
  163. package/src/core/cache.ts +102 -0
  164. package/src/core/cart/cart-client.ts +150 -0
  165. package/src/core/cart/types.ts +104 -0
  166. package/src/core/client/compose.ts +15 -0
  167. package/src/core/client/create-client.ts +129 -0
  168. package/src/core/client/dedupe.ts +19 -0
  169. package/src/core/client/execute.ts +70 -0
  170. package/src/core/client/hash.ts +21 -0
  171. package/src/core/client/operation-name.ts +12 -0
  172. package/src/core/client/types.ts +171 -0
  173. package/src/core/errors.ts +67 -0
  174. package/src/core/format.ts +254 -0
  175. package/src/core/helpers/assert-no-user-errors.ts +21 -0
  176. package/src/core/helpers/normalize-connection.ts +48 -0
  177. package/src/core/helpers/sanitize-html.ts +42 -0
  178. package/src/core/index.ts +148 -0
  179. package/src/core/middleware/auth.ts +27 -0
  180. package/src/core/middleware/currency.ts +26 -0
  181. package/src/core/middleware/errors.ts +86 -0
  182. package/src/core/middleware/retry.ts +75 -0
  183. package/src/core/middleware/timeout.ts +61 -0
  184. package/src/core/operations/auth.ts +123 -0
  185. package/src/core/operations/cart.ts +185 -0
  186. package/src/index.ts +25 -0
  187. package/src/react/cookies.ts +54 -0
  188. package/src/react/helpers/create-store-context.ts +56 -0
  189. package/src/react/hooks/use-auth.ts +218 -0
  190. package/src/react/hooks/use-cart-manager.ts +236 -0
  191. package/src/react/hooks/use-currency.ts +23 -0
  192. package/src/react/hooks/use-debounced-value.ts +30 -0
  193. package/src/react/hooks/use-hydrated.ts +20 -0
  194. package/src/react/hooks/use-storefront-client.ts +12 -0
  195. package/src/react/index.ts +45 -0
  196. package/src/react/providers/currency-provider.tsx +30 -0
  197. package/src/react/providers/storefront-client-provider.tsx +90 -0
  198. package/src/react/providers/storefront-provider.tsx +71 -0
  199. package/src/react/server/get-storefront-client.ts +60 -0
  200. package/src/react/server/index.ts +1 -0
  201. package/src/react/stores/auth.store.ts +112 -0
  202. package/src/react/stores/currency.store.ts +113 -0
  203. package/src/react/stores/index.ts +17 -0
  204. package/src/react/stores/store-context.tsx +82 -0
  205. package/tsconfig.json +20 -0
  206. package/vitest.config.ts +14 -0
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @doswiftly/storefront-sdk — Core (framework-agnostic)
3
+ *
4
+ * 100% framework-agnostic, 0 runtime dependencies.
5
+ * Works in Node.js, Edge Workers, Deno, Bun, CLI scripts — without React.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import {
10
+ * createStorefrontClient,
11
+ * authMiddleware,
12
+ * currencyMiddleware,
13
+ * retryMiddleware,
14
+ * timeoutMiddleware,
15
+ * errorMiddleware,
16
+ * CartClient,
17
+ * AuthClient,
18
+ * } from '@doswiftly/storefront-sdk';
19
+ *
20
+ * const client = createStorefrontClient({
21
+ * apiUrl: 'https://api.doswiftly.pl',
22
+ * shopSlug: 'my-shop',
23
+ * middleware: [
24
+ * authMiddleware(() => getToken()),
25
+ * currencyMiddleware(() => getCurrency()),
26
+ * retryMiddleware({ maxRetries: 2 }),
27
+ * timeoutMiddleware({ timeout: 5000 }),
28
+ * errorMiddleware(),
29
+ * ],
30
+ * });
31
+ *
32
+ * const cartClient = new CartClient(client);
33
+ * const cart = await cartClient.create();
34
+ * ```
35
+ */
36
+ // Client factory
37
+ export { createStorefrontClient } from './client/create-client';
38
+ // Middleware
39
+ export { authMiddleware } from './middleware/auth';
40
+ export { currencyMiddleware } from './middleware/currency';
41
+ export { retryMiddleware } from './middleware/retry';
42
+ export { timeoutMiddleware } from './middleware/timeout';
43
+ export { errorMiddleware } from './middleware/errors';
44
+ // Errors
45
+ export { StorefrontError, ErrorCodes } from './errors';
46
+ // Cache strategies
47
+ export { cacheNone, cacheShort, cacheLong, cachePrivate, cacheCustom, generateCacheControlHeader, } from './cache';
48
+ // Cart client
49
+ export { CartClient } from './cart/cart-client';
50
+ // Auth client
51
+ export { AuthClient } from './auth/auth-client';
52
+ // Helpers
53
+ export { assertNoUserErrors } from './helpers/assert-no-user-errors';
54
+ export { sanitizeHtml } from './helpers/sanitize-html';
55
+ export { normalizeConnection, } from './helpers/normalize-connection';
56
+ // Format utilities
57
+ export { formatPrice, formatPriceRange, formatAmount, formatDate, formatDateTime, formatNumber, formatPercentage, getCurrencySymbol, CURRENCY_SYMBOLS, CURRENCY_LOCALES, } from './format';
58
+ // Auth cookie config (platform contract)
59
+ export { AUTH_COOKIE_NAME, AUTH_COOKIE_DEFAULTS, } from './auth/cookie-config';
60
+ // Auth route matching
61
+ export { matchesRoute } from './auth/routes';
62
+ // Auth cookie handlers (API route factories)
63
+ export { createSetTokenHandler, createClearTokenHandler } from './auth/handlers';
64
+ // Auth token client (client-side fetch helpers)
65
+ export { createAuthTokenClient } from './auth/token-client';
66
+ // Utilities
67
+ export { getOperationName } from './client/operation-name';
68
+ export { hashQuery } from './client/hash';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Auth middleware — adds Authorization header from token getter.
3
+ *
4
+ * Token is resolved lazily (on each request) so it picks up
5
+ * store changes, token renewals, etc.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { authMiddleware } from '@doswiftly/storefront-sdk';
10
+ *
11
+ * client.use(authMiddleware(() => authStore.getState().accessToken));
12
+ * ```
13
+ */
14
+ import type { Middleware } from '../client/types';
15
+ export declare function authMiddleware(getToken: () => string | null | undefined): Middleware;
16
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/core/middleware/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,GACxC,UAAU,CAQZ"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Auth middleware — adds Authorization header from token getter.
3
+ *
4
+ * Token is resolved lazily (on each request) so it picks up
5
+ * store changes, token renewals, etc.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { authMiddleware } from '@doswiftly/storefront-sdk';
10
+ *
11
+ * client.use(authMiddleware(() => authStore.getState().accessToken));
12
+ * ```
13
+ */
14
+ export function authMiddleware(getToken) {
15
+ return (request, next) => {
16
+ const token = getToken();
17
+ if (token) {
18
+ request.headers['Authorization'] = `Bearer ${token}`;
19
+ }
20
+ return next(request);
21
+ };
22
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Currency middleware — adds X-Preferred-Currency header.
3
+ *
4
+ * Currency is resolved lazily so currency switches are reflected immediately.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { currencyMiddleware } from '@doswiftly/storefront-sdk';
9
+ *
10
+ * client.use(currencyMiddleware(() => currencyStore.getState().currency));
11
+ * ```
12
+ */
13
+ import type { Middleware } from '../client/types';
14
+ export declare function currencyMiddleware(getCurrency: () => string | null | undefined): Middleware;
15
+ //# sourceMappingURL=currency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../src/core/middleware/currency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,GAC3C,UAAU,CAQZ"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Currency middleware — adds X-Preferred-Currency header.
3
+ *
4
+ * Currency is resolved lazily so currency switches are reflected immediately.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { currencyMiddleware } from '@doswiftly/storefront-sdk';
9
+ *
10
+ * client.use(currencyMiddleware(() => currencyStore.getState().currency));
11
+ * ```
12
+ */
13
+ export function currencyMiddleware(getCurrency) {
14
+ return (request, next) => {
15
+ const currency = getCurrency();
16
+ if (currency) {
17
+ request.headers['X-Preferred-Currency'] = currency;
18
+ }
19
+ return next(request);
20
+ };
21
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Error normalization middleware — ALWAYS LAST in the pipeline.
3
+ *
4
+ * Catches all errors from downstream middleware and the transport,
5
+ * normalizes them into StorefrontError instances.
6
+ *
7
+ * Handles:
8
+ * - Network errors (fetch failures)
9
+ * - HTTP errors (non-200 responses)
10
+ * - GraphQL errors (errors array in response)
11
+ * - Abort/timeout errors
12
+ * - Missing data in response
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { errorMiddleware } from '@doswiftly/storefront-sdk';
17
+ *
18
+ * // Always add as the LAST middleware
19
+ * client.use(errorMiddleware());
20
+ * ```
21
+ */
22
+ import type { Middleware } from '../client/types';
23
+ export declare function errorMiddleware(): Middleware;
24
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/core/middleware/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,wBAAgB,eAAe,IAAI,UAAU,CA4D5C"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Error normalization middleware — ALWAYS LAST in the pipeline.
3
+ *
4
+ * Catches all errors from downstream middleware and the transport,
5
+ * normalizes them into StorefrontError instances.
6
+ *
7
+ * Handles:
8
+ * - Network errors (fetch failures)
9
+ * - HTTP errors (non-200 responses)
10
+ * - GraphQL errors (errors array in response)
11
+ * - Abort/timeout errors
12
+ * - Missing data in response
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { errorMiddleware } from '@doswiftly/storefront-sdk';
17
+ *
18
+ * // Always add as the LAST middleware
19
+ * client.use(errorMiddleware());
20
+ * ```
21
+ */
22
+ import { StorefrontError, ErrorCodes } from '../errors';
23
+ export function errorMiddleware() {
24
+ return async (request, next) => {
25
+ let response;
26
+ try {
27
+ response = await next(request);
28
+ }
29
+ catch (error) {
30
+ // Already a StorefrontError — re-throw as-is
31
+ if (error instanceof StorefrontError) {
32
+ throw error;
33
+ }
34
+ // AbortError (timeout handled by timeout middleware, manual abort here)
35
+ if (error instanceof Error && error.name === 'AbortError') {
36
+ throw new StorefrontError({
37
+ code: ErrorCodes.TIMEOUT,
38
+ message: 'Request was aborted',
39
+ cause: error,
40
+ });
41
+ }
42
+ // Network error (fetch failed — DNS, connection refused, etc.)
43
+ throw new StorefrontError({
44
+ code: ErrorCodes.NETWORK_ERROR,
45
+ message: error instanceof Error ? error.message : 'Network request failed',
46
+ cause: error,
47
+ });
48
+ }
49
+ // HTTP error (non-2xx response)
50
+ if (response.status >= 400) {
51
+ throw new StorefrontError({
52
+ code: ErrorCodes.HTTP_ERROR,
53
+ message: `HTTP ${response.status}`,
54
+ status: response.status,
55
+ graphqlErrors: response.errors ?? [],
56
+ });
57
+ }
58
+ // GraphQL errors in the response
59
+ if (response.errors?.length) {
60
+ throw new StorefrontError({
61
+ code: ErrorCodes.GRAPHQL_ERROR,
62
+ message: response.errors[0].message,
63
+ status: response.status,
64
+ graphqlErrors: response.errors,
65
+ });
66
+ }
67
+ // No data returned
68
+ if (response.data === undefined || response.data === null) {
69
+ throw new StorefrontError({
70
+ code: ErrorCodes.NO_DATA,
71
+ message: 'No data returned from GraphQL',
72
+ status: response.status,
73
+ });
74
+ }
75
+ return response;
76
+ };
77
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Retry middleware — retries on network errors and 5xx responses.
3
+ *
4
+ * ONLY retries queries, NEVER mutations (to prevent double-charges, etc.).
5
+ * Uses exponential backoff with jitter.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { retryMiddleware } from '@doswiftly/storefront-sdk';
10
+ *
11
+ * client.use(retryMiddleware({ maxRetries: 2 }));
12
+ * ```
13
+ */
14
+ import type { Middleware } from '../client/types';
15
+ export interface RetryOptions {
16
+ /** Maximum number of retries (default: 2) */
17
+ maxRetries?: number;
18
+ /** Initial delay in ms (default: 300) */
19
+ initialDelay?: number;
20
+ }
21
+ export declare function retryMiddleware(options?: RetryOptions): Middleware;
22
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../src/core/middleware/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,YAAiB,GAAG,UAAU,CA4CtE"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Retry middleware — retries on network errors and 5xx responses.
3
+ *
4
+ * ONLY retries queries, NEVER mutations (to prevent double-charges, etc.).
5
+ * Uses exponential backoff with jitter.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { retryMiddleware } from '@doswiftly/storefront-sdk';
10
+ *
11
+ * client.use(retryMiddleware({ maxRetries: 2 }));
12
+ * ```
13
+ */
14
+ import { StorefrontError, ErrorCodes } from '../errors';
15
+ export function retryMiddleware(options = {}) {
16
+ const { maxRetries = 2, initialDelay = 300 } = options;
17
+ return async (request, next) => {
18
+ // Never retry mutations
19
+ if (request.isMutation) {
20
+ return next(request);
21
+ }
22
+ let lastError;
23
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
24
+ try {
25
+ const response = await next(request);
26
+ // Retry on 5xx server errors
27
+ if (response.status >= 500 && attempt < maxRetries) {
28
+ await delay(initialDelay * Math.pow(2, attempt));
29
+ continue;
30
+ }
31
+ return response;
32
+ }
33
+ catch (error) {
34
+ lastError = error;
35
+ // Don't retry on non-retriable errors
36
+ if (error instanceof StorefrontError) {
37
+ if (error.code === ErrorCodes.TIMEOUT) {
38
+ // Timeouts are retriable
39
+ }
40
+ else if (error.status >= 400 && error.status < 500) {
41
+ // 4xx errors are not retriable
42
+ throw error;
43
+ }
44
+ }
45
+ if (attempt < maxRetries) {
46
+ await delay(initialDelay * Math.pow(2, attempt));
47
+ continue;
48
+ }
49
+ }
50
+ }
51
+ throw lastError;
52
+ };
53
+ }
54
+ function delay(ms) {
55
+ // Add jitter: ±25%
56
+ const jitter = ms * 0.25 * (Math.random() * 2 - 1);
57
+ return new Promise(resolve => setTimeout(resolve, ms + jitter));
58
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Timeout middleware — aborts request after timeout via AbortController.
3
+ *
4
+ * Edge-safe (no Node.js APIs). Default: 5 seconds.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { timeoutMiddleware } from '@doswiftly/storefront-sdk';
9
+ *
10
+ * client.use(timeoutMiddleware({ timeout: 10000 })); // 10s
11
+ * ```
12
+ */
13
+ import type { Middleware } from '../client/types';
14
+ export interface TimeoutOptions {
15
+ /** Timeout in milliseconds (default: 5000) */
16
+ timeout?: number;
17
+ }
18
+ export declare function timeoutMiddleware(options?: TimeoutOptions): Middleware;
19
+ //# sourceMappingURL=timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../../../src/core/middleware/timeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,cAAmB,GAAG,UAAU,CAuC1E"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Timeout middleware — aborts request after timeout via AbortController.
3
+ *
4
+ * Edge-safe (no Node.js APIs). Default: 5 seconds.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { timeoutMiddleware } from '@doswiftly/storefront-sdk';
9
+ *
10
+ * client.use(timeoutMiddleware({ timeout: 10000 })); // 10s
11
+ * ```
12
+ */
13
+ import { StorefrontError, ErrorCodes } from '../errors';
14
+ export function timeoutMiddleware(options = {}) {
15
+ const { timeout = 5000 } = options;
16
+ return async (request, next) => {
17
+ const controller = new AbortController();
18
+ // If request already has a signal, link them
19
+ if (request.signal) {
20
+ if (request.signal.aborted) {
21
+ controller.abort(request.signal.reason);
22
+ }
23
+ else {
24
+ request.signal.addEventListener('abort', () => {
25
+ controller.abort(request.signal.reason);
26
+ }, { once: true });
27
+ }
28
+ }
29
+ request.signal = controller.signal;
30
+ const timer = setTimeout(() => {
31
+ controller.abort(new Error(`Request timed out after ${timeout}ms`));
32
+ }, timeout);
33
+ try {
34
+ const response = await next(request);
35
+ return response;
36
+ }
37
+ catch (error) {
38
+ if (controller.signal.aborted) {
39
+ throw new StorefrontError({
40
+ code: ErrorCodes.TIMEOUT,
41
+ message: `Request timed out after ${timeout}ms`,
42
+ cause: error,
43
+ });
44
+ }
45
+ throw error;
46
+ }
47
+ finally {
48
+ clearTimeout(timer);
49
+ }
50
+ };
51
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Auth/Customer GraphQL operations — manual query strings (no codegen).
3
+ *
4
+ * These match the backend storefront-graphql schema exactly.
5
+ */
6
+ export declare const CUSTOMER_LOGIN = "\n mutation CustomerLogin($input: CustomerAccessTokenCreateInput!) {\n customerAccessTokenCreate(input: $input) {\n customerAccessToken { ...CustomerAccessTokenFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CustomerAccessTokenFields on CustomerAccessToken {\n accessToken\n expiresAt\n }\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
7
+ export declare const CUSTOMER_LOGOUT = "\n mutation CustomerLogout($customerAccessToken: String!) {\n customerAccessTokenDelete(customerAccessToken: $customerAccessToken) {\n deletedAccessToken\n deletedCustomerAccessTokenId\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
8
+ export declare const CUSTOMER_TOKEN_RENEW = "\n mutation CustomerTokenRenew($customerAccessToken: String!) {\n customerAccessTokenRenew(customerAccessToken: $customerAccessToken) {\n customerAccessToken { ...CustomerAccessTokenFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CustomerAccessTokenFields on CustomerAccessToken {\n accessToken\n expiresAt\n }\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
9
+ export declare const CUSTOMER_CREATE = "\n mutation CustomerCreate($input: CustomerCreateInput!) {\n customerCreate(input: $input) {\n customer { ...CustomerFields }\n customerAccessToken { ...CustomerAccessTokenFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CustomerFields on Customer {\n id\n email\n firstName\n lastName\n displayName\n phone\n emailVerified\n emailMarketingState\n defaultAddress {\n id\n address1\n address2\n city\n company\n country\n countryCode\n firstName\n lastName\n phone\n province\n provinceCode\n zip\n isDefault\n }\n ordersCount\n totalSpent {\n amount\n currencyCode\n }\n createdAt\n updatedAt\n }\n\n \n fragment CustomerAccessTokenFields on CustomerAccessToken {\n accessToken\n expiresAt\n }\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
10
+ export declare const CUSTOMER_QUERY = "\n query Customer($customerAccessToken: String!) {\n customer(customerAccessToken: $customerAccessToken) {\n ...CustomerFields\n }\n }\n \n fragment CustomerFields on Customer {\n id\n email\n firstName\n lastName\n displayName\n phone\n emailVerified\n emailMarketingState\n defaultAddress {\n id\n address1\n address2\n city\n company\n country\n countryCode\n firstName\n lastName\n phone\n province\n provinceCode\n zip\n isDefault\n }\n ordersCount\n totalSpent {\n amount\n currencyCode\n }\n createdAt\n updatedAt\n }\n\n";
11
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/core/operations/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA6DH,eAAO,MAAM,cAAc,+aAS1B,CAAC;AAEF,eAAO,MAAM,eAAe,0VAS3B,CAAC;AAEF,eAAO,MAAM,oBAAoB,qcAShC,CAAC;AAEF,eAAO,MAAM,eAAe,w8BAW3B,CAAC;AAMF,eAAO,MAAM,cAAc,kqBAO1B,CAAC"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Auth/Customer GraphQL operations — manual query strings (no codegen).
3
+ *
4
+ * These match the backend storefront-graphql schema exactly.
5
+ */
6
+ // ---------------------------------------------------------------------------
7
+ // Fragments
8
+ // ---------------------------------------------------------------------------
9
+ const CUSTOMER_ACCESS_TOKEN_FRAGMENT = `
10
+ fragment CustomerAccessTokenFields on CustomerAccessToken {
11
+ accessToken
12
+ expiresAt
13
+ }
14
+ `;
15
+ const USER_ERROR_FRAGMENT = `
16
+ fragment UserErrorFields on UserError {
17
+ message
18
+ field
19
+ code
20
+ }
21
+ `;
22
+ const CUSTOMER_FRAGMENT = `
23
+ fragment CustomerFields on Customer {
24
+ id
25
+ email
26
+ firstName
27
+ lastName
28
+ displayName
29
+ phone
30
+ emailVerified
31
+ emailMarketingState
32
+ defaultAddress {
33
+ id
34
+ address1
35
+ address2
36
+ city
37
+ company
38
+ country
39
+ countryCode
40
+ firstName
41
+ lastName
42
+ phone
43
+ province
44
+ provinceCode
45
+ zip
46
+ isDefault
47
+ }
48
+ ordersCount
49
+ totalSpent {
50
+ amount
51
+ currencyCode
52
+ }
53
+ createdAt
54
+ updatedAt
55
+ }
56
+ `;
57
+ // ---------------------------------------------------------------------------
58
+ // Mutations
59
+ // ---------------------------------------------------------------------------
60
+ export const CUSTOMER_LOGIN = `
61
+ mutation CustomerLogin($input: CustomerAccessTokenCreateInput!) {
62
+ customerAccessTokenCreate(input: $input) {
63
+ customerAccessToken { ...CustomerAccessTokenFields }
64
+ userErrors { ...UserErrorFields }
65
+ }
66
+ }
67
+ ${CUSTOMER_ACCESS_TOKEN_FRAGMENT}
68
+ ${USER_ERROR_FRAGMENT}
69
+ `;
70
+ export const CUSTOMER_LOGOUT = `
71
+ mutation CustomerLogout($customerAccessToken: String!) {
72
+ customerAccessTokenDelete(customerAccessToken: $customerAccessToken) {
73
+ deletedAccessToken
74
+ deletedCustomerAccessTokenId
75
+ userErrors { ...UserErrorFields }
76
+ }
77
+ }
78
+ ${USER_ERROR_FRAGMENT}
79
+ `;
80
+ export const CUSTOMER_TOKEN_RENEW = `
81
+ mutation CustomerTokenRenew($customerAccessToken: String!) {
82
+ customerAccessTokenRenew(customerAccessToken: $customerAccessToken) {
83
+ customerAccessToken { ...CustomerAccessTokenFields }
84
+ userErrors { ...UserErrorFields }
85
+ }
86
+ }
87
+ ${CUSTOMER_ACCESS_TOKEN_FRAGMENT}
88
+ ${USER_ERROR_FRAGMENT}
89
+ `;
90
+ export const CUSTOMER_CREATE = `
91
+ mutation CustomerCreate($input: CustomerCreateInput!) {
92
+ customerCreate(input: $input) {
93
+ customer { ...CustomerFields }
94
+ customerAccessToken { ...CustomerAccessTokenFields }
95
+ userErrors { ...UserErrorFields }
96
+ }
97
+ }
98
+ ${CUSTOMER_FRAGMENT}
99
+ ${CUSTOMER_ACCESS_TOKEN_FRAGMENT}
100
+ ${USER_ERROR_FRAGMENT}
101
+ `;
102
+ // ---------------------------------------------------------------------------
103
+ // Queries
104
+ // ---------------------------------------------------------------------------
105
+ export const CUSTOMER_QUERY = `
106
+ query Customer($customerAccessToken: String!) {
107
+ customer(customerAccessToken: $customerAccessToken) {
108
+ ...CustomerFields
109
+ }
110
+ }
111
+ ${CUSTOMER_FRAGMENT}
112
+ `;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Cart GraphQL operations — manual query strings (no codegen).
3
+ *
4
+ * These match the backend storefront-graphql schema exactly.
5
+ * Cart mutations always return full Cart + userErrors.
6
+ */
7
+ export declare const CART_QUERY = "\n query Cart($id: ID!) {\n cart(id: $id) {\n ...CartFields\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n";
8
+ export declare const CART_CREATE = "\n mutation CartCreate($input: CartCreateInput) {\n cartCreate(input: $input) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
9
+ export declare const CART_LINES_ADD = "\n mutation CartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
10
+ export declare const CART_LINES_UPDATE = "\n mutation CartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
11
+ export declare const CART_LINES_REMOVE = "\n mutation CartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
12
+ export declare const CART_DISCOUNT_CODES_UPDATE = "\n mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
13
+ export declare const CART_NOTE_UPDATE = "\n mutation CartNoteUpdate($cartId: ID!, $note: String!) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
14
+ export declare const CART_BUYER_IDENTITY_UPDATE = "\n mutation CartBuyerIdentityUpdate($cartId: ID!, $buyerIdentity: CartBuyerIdentityInput!) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
15
+ //# sourceMappingURL=cart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../../src/core/operations/cart.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2FH,eAAO,MAAM,UAAU,quCAOtB,CAAC;AAMF,eAAO,MAAM,WAAW,m5CASvB,CAAC;AAEF,eAAO,MAAM,cAAc,w7CAS1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,o8CAS7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,y7CAS7B,CAAC;AAEF,eAAO,MAAM,0BAA0B,+9CAStC,CAAC;AAEF,eAAO,MAAM,gBAAgB,+6CAS5B,CAAC;AAEF,eAAO,MAAM,0BAA0B,4+CAStC,CAAC"}