@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,89 @@
1
+ /**
2
+ * CartClient — plain async API for cart operations (no React, no React Query).
3
+ *
4
+ * Wraps StorefrontClient.mutate/query with typed operations.
5
+ * Auto-throws on userErrors via assertNoUserErrors.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const cartClient = new CartClient(storefrontClient);
10
+ *
11
+ * const cart = await cartClient.create();
12
+ * const updated = await cartClient.addItem(cart.id, [
13
+ * { merchandiseId: 'variant-123', quantity: 1 }
14
+ * ]);
15
+ * ```
16
+ */
17
+ import { assertNoUserErrors } from '../helpers/assert-no-user-errors';
18
+ import { CART_QUERY, CART_CREATE, CART_LINES_ADD, CART_LINES_UPDATE, CART_LINES_REMOVE, CART_DISCOUNT_CODES_UPDATE, CART_NOTE_UPDATE, CART_BUYER_IDENTITY_UPDATE, } from '../operations/cart';
19
+ export class CartClient {
20
+ client;
21
+ constructor(client) {
22
+ this.client = client;
23
+ }
24
+ /**
25
+ * Fetch existing cart by ID.
26
+ * Returns null if cart doesn't exist or has expired.
27
+ */
28
+ async get(cartId) {
29
+ const data = await this.client.query(CART_QUERY, { id: cartId });
30
+ return data.cart;
31
+ }
32
+ /**
33
+ * Create a new cart, optionally with initial lines.
34
+ */
35
+ async create(input) {
36
+ const data = await this.client.mutate(CART_CREATE, { input: input ?? {} });
37
+ assertNoUserErrors(data.cartCreate);
38
+ return data.cartCreate.cart;
39
+ }
40
+ /**
41
+ * Add line items to an existing cart.
42
+ */
43
+ async addItems(cartId, lines) {
44
+ const data = await this.client.mutate(CART_LINES_ADD, { cartId, lines });
45
+ assertNoUserErrors(data.cartLinesAdd);
46
+ return data.cartLinesAdd.cart;
47
+ }
48
+ /**
49
+ * Update line items (quantity, attributes).
50
+ */
51
+ async updateItems(cartId, lines) {
52
+ const data = await this.client.mutate(CART_LINES_UPDATE, { cartId, lines });
53
+ assertNoUserErrors(data.cartLinesUpdate);
54
+ return data.cartLinesUpdate.cart;
55
+ }
56
+ /**
57
+ * Remove line items by their line IDs.
58
+ */
59
+ async removeItems(cartId, lineIds) {
60
+ const data = await this.client.mutate(CART_LINES_REMOVE, { cartId, lineIds });
61
+ assertNoUserErrors(data.cartLinesRemove);
62
+ return data.cartLinesRemove.cart;
63
+ }
64
+ /**
65
+ * Update discount codes (replaces all existing codes).
66
+ * Pass empty array to clear discounts.
67
+ */
68
+ async updateDiscountCodes(cartId, discountCodes) {
69
+ const data = await this.client.mutate(CART_DISCOUNT_CODES_UPDATE, { cartId, discountCodes });
70
+ assertNoUserErrors(data.cartDiscountCodesUpdate);
71
+ return data.cartDiscountCodesUpdate.cart;
72
+ }
73
+ /**
74
+ * Update cart note / gift message.
75
+ */
76
+ async updateNote(cartId, note) {
77
+ const data = await this.client.mutate(CART_NOTE_UPDATE, { cartId, note });
78
+ assertNoUserErrors(data.cartNoteUpdate);
79
+ return data.cartNoteUpdate.cart;
80
+ }
81
+ /**
82
+ * Update buyer identity (email, phone, country, customer link).
83
+ */
84
+ async updateBuyerIdentity(cartId, buyerIdentity) {
85
+ const data = await this.client.mutate(CART_BUYER_IDENTITY_UPDATE, { cartId, buyerIdentity });
86
+ assertNoUserErrors(data.cartBuyerIdentityUpdate);
87
+ return data.cartBuyerIdentityUpdate.cart;
88
+ }
89
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Cart types — manual (no codegen).
3
+ *
4
+ * These match the backend storefront-graphql Cart type.
5
+ */
6
+ export interface Money {
7
+ amount: string;
8
+ currencyCode: string;
9
+ }
10
+ export interface CartCost {
11
+ totalAmount: Money;
12
+ subtotalAmount: Money;
13
+ totalTaxAmount: Money | null;
14
+ totalDutyAmount: Money | null;
15
+ }
16
+ export interface CartLineCost {
17
+ totalAmount: Money;
18
+ amountPerQuantity: Money;
19
+ compareAtAmountPerQuantity: Money | null;
20
+ }
21
+ export interface CartLineMerchandise {
22
+ id: string;
23
+ title: string;
24
+ sku: string | null;
25
+ image: {
26
+ url: string;
27
+ altText: string | null;
28
+ } | null;
29
+ price: Money;
30
+ compareAtPrice: Money | null;
31
+ }
32
+ export interface CartLine {
33
+ id: string;
34
+ quantity: number;
35
+ merchandise: CartLineMerchandise;
36
+ cost: CartLineCost;
37
+ attributes: Array<{
38
+ key: string;
39
+ value: string;
40
+ }>;
41
+ productId: string;
42
+ productTitle: string;
43
+ productHandle: string;
44
+ }
45
+ export interface CartDiscountCode {
46
+ code: string;
47
+ applicable: boolean;
48
+ }
49
+ export interface CartDiscountAllocation {
50
+ discountedAmount: Money;
51
+ }
52
+ export interface CartBuyerIdentity {
53
+ email: string | null;
54
+ phone: string | null;
55
+ countryCode: string | null;
56
+ }
57
+ export interface Cart {
58
+ id: string;
59
+ checkoutUrl: string | null;
60
+ totalQuantity: number;
61
+ note: string | null;
62
+ createdAt: string;
63
+ updatedAt: string;
64
+ cost: CartCost;
65
+ lines: {
66
+ edges: Array<{
67
+ node: CartLine;
68
+ }>;
69
+ };
70
+ buyerIdentity: CartBuyerIdentity | null;
71
+ discountCodes: CartDiscountCode[];
72
+ discountAllocations: CartDiscountAllocation[];
73
+ attributes: Array<{
74
+ key: string;
75
+ value: string;
76
+ }>;
77
+ }
78
+ export interface CartLineInput {
79
+ merchandiseId: string;
80
+ quantity?: number;
81
+ attributes?: Array<{
82
+ key: string;
83
+ value: string;
84
+ }>;
85
+ }
86
+ export interface CartLineUpdateInput {
87
+ id: string;
88
+ quantity: number;
89
+ attributes?: Array<{
90
+ key: string;
91
+ value: string;
92
+ }>;
93
+ }
94
+ export interface CartCreateInput {
95
+ lines?: CartLineInput[];
96
+ buyerIdentity?: CartBuyerIdentityInput;
97
+ discountCodes?: string[];
98
+ note?: string;
99
+ attributes?: Array<{
100
+ key: string;
101
+ value: string;
102
+ }>;
103
+ }
104
+ export interface CartBuyerIdentityInput {
105
+ email?: string;
106
+ phone?: string;
107
+ countryCode?: string;
108
+ customerId?: string;
109
+ }
110
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/cart/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,WAAW,EAAE,KAAK,CAAC;IACnB,cAAc,EAAE,KAAK,CAAC;IACtB,cAAc,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,eAAe,EAAE,KAAK,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,KAAK,CAAC;IACnB,iBAAiB,EAAE,KAAK,CAAC;IACzB,0BAA0B,EAAE,KAAK,GAAG,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACtD,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,QAAQ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CAAC,CAAC;CACnD;AAMD,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,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"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Cart types — manual (no codegen).
3
+ *
4
+ * These match the backend storefront-graphql Cart type.
5
+ */
6
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Compose middleware chain using reduceRight (Hydrogen pattern).
3
+ *
4
+ * Middleware execute in order: first registered runs first.
5
+ * Each can modify request, modify response, retry, or short-circuit.
6
+ */
7
+ import type { Middleware, ExecuteFn } from './types';
8
+ export declare function compose(middlewares: Middleware[], execute: ExecuteFn): ExecuteFn;
9
+ //# sourceMappingURL=compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../src/core/client/compose.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAErD,wBAAgB,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS,CAKhF"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Compose middleware chain using reduceRight (Hydrogen pattern).
3
+ *
4
+ * Middleware execute in order: first registered runs first.
5
+ * Each can modify request, modify response, retry, or short-circuit.
6
+ */
7
+ export function compose(middlewares, execute) {
8
+ return middlewares.reduceRight((next, mw) => (req) => mw(req, next), execute);
9
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * createStorefrontClient — transport factory (Hydrogen pattern).
3
+ *
4
+ * Creates a framework-agnostic GraphQL client with:
5
+ * - Middleware pipeline (composable, lazy)
6
+ * - Request deduplication (same-tick queries)
7
+ * - TypedDocumentString support (Saleor/client-preset)
8
+ * - Plain string queries (for custom operations)
9
+ * - Debug mode
10
+ *
11
+ * 0 runtime dependencies.
12
+ */
13
+ import type { StorefrontClientConfig, StorefrontClient } from './types';
14
+ export declare function createStorefrontClient(config: StorefrontClientConfig): StorefrontClient;
15
+ //# sourceMappingURL=create-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-client.d.ts","sourceRoot":"","sources":["../../../src/core/client/create-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAKjB,MAAM,SAAS,CAAC;AAOjB,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,gBAAgB,CAqGvF"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * createStorefrontClient — transport factory (Hydrogen pattern).
3
+ *
4
+ * Creates a framework-agnostic GraphQL client with:
5
+ * - Middleware pipeline (composable, lazy)
6
+ * - Request deduplication (same-tick queries)
7
+ * - TypedDocumentString support (Saleor/client-preset)
8
+ * - Plain string queries (for custom operations)
9
+ * - Debug mode
10
+ *
11
+ * 0 runtime dependencies.
12
+ */
13
+ import { createExecute } from './execute';
14
+ import { compose } from './compose';
15
+ import { dedupe } from './dedupe';
16
+ import { hashQuery } from './hash';
17
+ import { getOperationName } from './operation-name';
18
+ export function createStorefrontClient(config) {
19
+ const { apiUrl, shopSlug, defaultHeaders = {}, middleware: initialMiddleware = [], fetch: customFetch = globalThis.fetch, debug = false, } = config;
20
+ const endpoint = `${apiUrl.replace(/\/$/, '')}/storefront/graphql`;
21
+ // Mutable middleware list — use() adds to it, invalidates compiled pipeline
22
+ const middlewares = [...initialMiddleware];
23
+ let compiledPipeline = null;
24
+ // Create the innermost execute function (native fetch)
25
+ const innerExecute = createExecute({ endpoint, fetch: customFetch, debug });
26
+ /**
27
+ * Get or build the compiled middleware pipeline (lazy).
28
+ * Rebuilt on first call and after use() is called.
29
+ */
30
+ function getPipeline() {
31
+ if (!compiledPipeline) {
32
+ compiledPipeline = middlewares.length > 0
33
+ ? compose(middlewares, innerExecute)
34
+ : innerExecute;
35
+ }
36
+ return compiledPipeline;
37
+ }
38
+ /**
39
+ * Resolve query string from TypedDocumentString or plain string.
40
+ */
41
+ function resolveQuery(document) {
42
+ return typeof document === 'string' ? document : document.toString();
43
+ }
44
+ /**
45
+ * Core request execution — shared by query() and mutate().
46
+ */
47
+ async function request(document, variables, isMutation = false, cache) {
48
+ const query = resolveQuery(document);
49
+ const operationName = getOperationName(query);
50
+ const pipeline = getPipeline();
51
+ const headers = {
52
+ 'X-Shop-Slug': shopSlug,
53
+ ...defaultHeaders,
54
+ };
55
+ if (operationName !== 'anonymous') {
56
+ headers['X-Operation-Name'] = operationName;
57
+ }
58
+ const graphqlRequest = {
59
+ query,
60
+ variables,
61
+ operationName,
62
+ headers,
63
+ isMutation,
64
+ cache,
65
+ };
66
+ // Dedupe queries (not mutations) in the same tick
67
+ const executeFn = () => pipeline(graphqlRequest);
68
+ const response = isMutation
69
+ ? await executeFn()
70
+ : await dedupe(hashQuery(query, variables), executeFn);
71
+ return response.data;
72
+ }
73
+ return {
74
+ query(document, variables, cache) {
75
+ return request(document, variables, false, cache);
76
+ },
77
+ mutate(document, variables) {
78
+ return request(document, variables, true);
79
+ },
80
+ use(middleware) {
81
+ middlewares.push(middleware);
82
+ compiledPipeline = null; // Invalidate — rebuild on next request
83
+ },
84
+ };
85
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Request deduplication — identical queries in the same tick share one fetch.
3
+ *
4
+ * Key = hashQuery(query, variables). Only applies to queries, not mutations.
5
+ */
6
+ export declare function dedupe<T>(key: string, fn: () => Promise<T>): Promise<T>;
7
+ //# sourceMappingURL=dedupe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedupe.d.ts","sourceRoot":"","sources":["../../../src/core/client/dedupe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAUvE"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Request deduplication — identical queries in the same tick share one fetch.
3
+ *
4
+ * Key = hashQuery(query, variables). Only applies to queries, not mutations.
5
+ */
6
+ const pending = new Map();
7
+ export function dedupe(key, fn) {
8
+ const existing = pending.get(key);
9
+ if (existing)
10
+ return existing;
11
+ const promise = fn().finally(() => {
12
+ pending.delete(key);
13
+ });
14
+ pending.set(key, promise);
15
+ return promise;
16
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Native fetch transport — 0 runtime dependencies.
3
+ *
4
+ * Sends GraphQL POST request, parses response, returns typed GraphQLResponse.
5
+ * Error normalization is handled by error middleware, NOT here.
6
+ */
7
+ import type { GraphQLRequest, GraphQLResponse } from './types';
8
+ export interface ExecuteConfig {
9
+ /** GraphQL endpoint URL */
10
+ endpoint: string;
11
+ /** Custom fetch implementation */
12
+ fetch: typeof globalThis.fetch;
13
+ /** Enable debug logging */
14
+ debug: boolean;
15
+ }
16
+ /**
17
+ * Create the innermost execute function for the middleware pipeline.
18
+ */
19
+ export declare function createExecute(config: ExecuteConfig): (request: GraphQLRequest) => Promise<GraphQLResponse>;
20
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/core/client/execute.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAEjF,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAC/B,2BAA2B;IAC3B,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,IAGnB,SAAS,cAAc,KAAG,OAAO,CAAC,eAAe,CAAC,CA6CjF"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Native fetch transport — 0 runtime dependencies.
3
+ *
4
+ * Sends GraphQL POST request, parses response, returns typed GraphQLResponse.
5
+ * Error normalization is handled by error middleware, NOT here.
6
+ */
7
+ /**
8
+ * Create the innermost execute function for the middleware pipeline.
9
+ */
10
+ export function createExecute(config) {
11
+ const { endpoint, fetch: fetchFn, debug } = config;
12
+ return async function execute(request) {
13
+ const { query, variables, headers, signal, operationName } = request;
14
+ if (debug) {
15
+ console.log('[StorefrontSDK]', operationName ?? 'request', { variables });
16
+ }
17
+ const body = { query };
18
+ if (variables && Object.keys(variables).length > 0) {
19
+ body.variables = variables;
20
+ }
21
+ if (operationName) {
22
+ body.operationName = operationName;
23
+ }
24
+ const response = await fetchFn(endpoint, {
25
+ method: 'POST',
26
+ headers: {
27
+ 'Content-Type': 'application/json',
28
+ Accept: 'application/json',
29
+ ...headers,
30
+ },
31
+ body: JSON.stringify(body),
32
+ signal,
33
+ });
34
+ const json = await response.json();
35
+ if (debug) {
36
+ console.log('[StorefrontSDK]', operationName ?? 'response', {
37
+ status: response.status,
38
+ hasErrors: !!json.errors?.length,
39
+ });
40
+ }
41
+ return {
42
+ data: json.data,
43
+ errors: json.errors,
44
+ status: response.status,
45
+ headers: response.headers,
46
+ };
47
+ };
48
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Stable query hashing for request deduplication.
3
+ *
4
+ * Sorts object keys so `{a:1,b:2}` and `{b:2,a:1}` produce the same hash.
5
+ */
6
+ export declare function hashQuery(query: string, variables?: Record<string, unknown>): string;
7
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/core/client/hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAIpF"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Stable query hashing for request deduplication.
3
+ *
4
+ * Sorts object keys so `{a:1,b:2}` and `{b:2,a:1}` produce the same hash.
5
+ */
6
+ function stableStringify(value) {
7
+ if (value === null || value === undefined)
8
+ return '';
9
+ if (typeof value !== 'object')
10
+ return JSON.stringify(value);
11
+ if (Array.isArray(value)) {
12
+ return '[' + value.map(stableStringify).join(',') + ']';
13
+ }
14
+ const keys = Object.keys(value).sort();
15
+ return '{' + keys.map(k => JSON.stringify(k) + ':' + stableStringify(value[k])).join(',') + '}';
16
+ }
17
+ export function hashQuery(query, variables) {
18
+ const queryPart = query.trim();
19
+ const varsPart = variables ? stableStringify(variables) : '';
20
+ return queryPart + '::' + varsPart;
21
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Auto-extract operation name from a GraphQL query string.
3
+ *
4
+ * Used for: X-Operation-Name header (debugging), cache tags, logging.
5
+ */
6
+ export declare function getOperationName(query: string): string;
7
+ //# sourceMappingURL=operation-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-name.d.ts","sourceRoot":"","sources":["../../../src/core/client/operation-name.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGtD"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Auto-extract operation name from a GraphQL query string.
3
+ *
4
+ * Used for: X-Operation-Name header (debugging), cache tags, logging.
5
+ */
6
+ const OPERATION_RE = /(?:query|mutation|subscription)\s+(\w+)/;
7
+ export function getOperationName(query) {
8
+ const match = query.match(OPERATION_RE);
9
+ return match?.[1] ?? 'anonymous';
10
+ }
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Core types for Storefront SDK transport layer.
3
+ *
4
+ * Framework-agnostic — no React, no Zustand, 0 runtime dependencies.
5
+ */
6
+ /**
7
+ * A branded string carrying result & variable types.
8
+ * Produced by graphql-codegen client-preset with `documentMode: 'string'`.
9
+ *
10
+ * SDK also accepts plain strings — TypedDocumentString is purely for DX.
11
+ */
12
+ export declare class TypedDocumentString<TResult = unknown, TVariables = unknown> extends String {
13
+ __meta__?: {
14
+ hash: string;
15
+ } | undefined;
16
+ /** Type-level brand — never used at runtime */
17
+ __apiType?: (variables: TVariables) => TResult;
18
+ constructor(value: string, __meta__?: {
19
+ hash: string;
20
+ } | undefined);
21
+ toString(): string;
22
+ }
23
+ export interface GraphQLRequest {
24
+ /** GraphQL query or mutation string */
25
+ query: string;
26
+ /** Operation variables */
27
+ variables?: Record<string, unknown>;
28
+ /** Operation name (auto-extracted if omitted) */
29
+ operationName?: string;
30
+ /** Request headers (merged: default < middleware < request) */
31
+ headers: Record<string, string>;
32
+ /** AbortSignal for cancellation */
33
+ signal?: AbortSignal;
34
+ /** Whether this is a mutation (affects retry, cache) */
35
+ isMutation: boolean;
36
+ /** Cache strategy override */
37
+ cache?: CacheStrategy;
38
+ }
39
+ export interface GraphQLResponse<T = unknown> {
40
+ /** Parsed response data */
41
+ data: T;
42
+ /** GraphQL errors (if any) */
43
+ errors?: GraphQLErrorInfo[];
44
+ /** HTTP status code */
45
+ status: number;
46
+ /** Raw response headers */
47
+ headers: Headers;
48
+ }
49
+ export interface GraphQLErrorInfo {
50
+ message: string;
51
+ locations?: Array<{
52
+ line: number;
53
+ column: number;
54
+ }>;
55
+ path?: Array<string | number>;
56
+ extensions?: Record<string, unknown>;
57
+ }
58
+ export interface UserError {
59
+ message: string;
60
+ field?: string[];
61
+ code?: string;
62
+ }
63
+ /**
64
+ * Execute function — the innermost (or next) handler in the pipeline.
65
+ */
66
+ export type ExecuteFn = (request: GraphQLRequest) => Promise<GraphQLResponse>;
67
+ /**
68
+ * Middleware function — receives the request and the next handler.
69
+ *
70
+ * Can modify request, modify response, short-circuit, retry, etc.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const authMiddleware: Middleware = (req, next) => {
75
+ * req.headers['Authorization'] = `Bearer ${getToken()}`;
76
+ * return next(req);
77
+ * };
78
+ * ```
79
+ */
80
+ export type Middleware = (request: GraphQLRequest, next: ExecuteFn) => Promise<GraphQLResponse>;
81
+ export interface CacheOptions {
82
+ /** Max age in seconds */
83
+ maxAge: number;
84
+ /** Stale-while-revalidate in seconds */
85
+ staleWhileRevalidate?: number;
86
+ /** Cache mode */
87
+ mode: 'public' | 'private' | 'no-store';
88
+ /** Cache tags (for Next.js revalidateTag) */
89
+ tags?: string[];
90
+ }
91
+ export type CacheStrategy = CacheOptions;
92
+ export interface StorefrontClientConfig {
93
+ /** GraphQL API URL (e.g. 'https://api.doswiftly.pl') */
94
+ apiUrl: string;
95
+ /** Shop slug for multi-tenant routing */
96
+ shopSlug: string;
97
+ /** Default headers for all requests */
98
+ defaultHeaders?: Record<string, string>;
99
+ /** Middleware pipeline */
100
+ middleware?: Middleware[];
101
+ /** Custom fetch implementation (polyfill, test mocks, edge) */
102
+ fetch?: typeof globalThis.fetch;
103
+ /** Enable debug logging (request/response in dev) */
104
+ debug?: boolean;
105
+ }
106
+ export interface StorefrontClient {
107
+ /**
108
+ * Execute a typed GraphQL query.
109
+ *
110
+ * Accepts TypedDocumentString (from codegen) or plain string.
111
+ */
112
+ query<T = unknown, V = Record<string, unknown>>(document: TypedDocumentString<T, V> | string, variables?: V, cache?: CacheStrategy): Promise<T>;
113
+ /**
114
+ * Execute a typed GraphQL mutation.
115
+ *
116
+ * Mutations are never cached and never retried by retry middleware.
117
+ */
118
+ mutate<T = unknown, V = Record<string, unknown>>(document: TypedDocumentString<T, V> | string, variables?: V): Promise<T>;
119
+ /**
120
+ * Add middleware to the pipeline (imperative API).
121
+ *
122
+ * Invalidates the compiled pipeline — next request re-composes.
123
+ */
124
+ use(middleware: Middleware): void;
125
+ }
126
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/client/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;;;GAKG;AACH,qBAAa,mBAAmB,CAAC,OAAO,GAAG,OAAO,EAAE,UAAU,GAAG,OAAO,CAAE,SAAQ,MAAM;IAIpD,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAH7D,+CAA+C;IAC/C,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC;gBAEnC,KAAK,EAAE,MAAM,EAAS,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,YAAA;IAIpD,QAAQ,IAAI,MAAM;CAG5B;AAMD,MAAM,WAAW,cAAc;IAC7B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IAC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,CAAC,EAAE,CAAC,GACZ,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd;;;;OAIG;IACH,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;CACnC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Core types for Storefront SDK transport layer.
3
+ *
4
+ * Framework-agnostic — no React, no Zustand, 0 runtime dependencies.
5
+ */
6
+ // ---------------------------------------------------------------------------
7
+ // TypedDocumentString (Saleor / client-preset pattern)
8
+ // ---------------------------------------------------------------------------
9
+ /**
10
+ * A branded string carrying result & variable types.
11
+ * Produced by graphql-codegen client-preset with `documentMode: 'string'`.
12
+ *
13
+ * SDK also accepts plain strings — TypedDocumentString is purely for DX.
14
+ */
15
+ export class TypedDocumentString extends String {
16
+ __meta__;
17
+ /** Type-level brand — never used at runtime */
18
+ __apiType;
19
+ constructor(value, __meta__) {
20
+ super(value);
21
+ this.__meta__ = __meta__;
22
+ }
23
+ toString() {
24
+ return this.valueOf();
25
+ }
26
+ }