@anker-in/lib 0.0.0-beta.1 → 0.0.0-beta.3

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 (247) hide show
  1. package/.gitkeep +0 -0
  2. package/.turbo/turbo-build.log +22 -0
  3. package/.turbo/turbo-test.log +5 -0
  4. package/dist/cjs/context/HeadlessProvider.js +1 -1
  5. package/dist/cjs/context/HeadlessProvider.js.map +2 -2
  6. package/dist/context/HeadlessProvider.d.ts.map +1 -1
  7. package/dist/esm/cart/const.js +2 -0
  8. package/dist/esm/cart/const.js.map +7 -0
  9. package/dist/esm/cart/hooks/basic/useBuyNow.js +2 -0
  10. package/dist/esm/cart/hooks/basic/useBuyNow.js.map +7 -0
  11. package/dist/esm/cart/index.js +2 -0
  12. package/dist/esm/cart/index.js.map +7 -0
  13. package/dist/esm/cart/track/fbq.js +2 -0
  14. package/dist/esm/cart/track/fbq.js.map +7 -0
  15. package/dist/esm/cart/types/index.js +1 -0
  16. package/dist/esm/cart/types/index.js.map +7 -0
  17. package/dist/esm/cart/utils/index.js +2 -0
  18. package/dist/esm/cart/utils/index.js.map +7 -0
  19. package/dist/esm/context/HeadlessProvider.js +2 -0
  20. package/dist/esm/context/HeadlessProvider.js.map +7 -0
  21. package/dist/esm/context/config.js +1 -0
  22. package/dist/esm/context/config.js.map +7 -0
  23. package/dist/esm/context/index.js +2 -0
  24. package/dist/esm/context/index.js.map +7 -0
  25. package/dist/esm/index.js +2 -0
  26. package/dist/esm/index.js.map +7 -0
  27. package/dist/esm/package.json +3 -0
  28. package/dist/esm/shopify/fetchers/add-cart-lines.js +2 -0
  29. package/dist/esm/shopify/fetchers/add-cart-lines.js.map +7 -0
  30. package/dist/esm/shopify/fetchers/create-cart.js +2 -0
  31. package/dist/esm/shopify/fetchers/create-cart.js.map +7 -0
  32. package/dist/esm/shopify/fetchers/get-cart.js +2 -0
  33. package/dist/esm/shopify/fetchers/get-cart.js.map +7 -0
  34. package/dist/esm/shopify/fetchers/get-products-by-handles.js +2 -0
  35. package/dist/esm/shopify/fetchers/get-products-by-handles.js.map +7 -0
  36. package/dist/esm/shopify/fetchers/index.js +2 -0
  37. package/dist/esm/shopify/fetchers/index.js.map +7 -0
  38. package/dist/esm/shopify/fetchers/remove-cart-lines.js +2 -0
  39. package/dist/esm/shopify/fetchers/remove-cart-lines.js.map +7 -0
  40. package/dist/esm/shopify/fetchers/update-cart-attributes.js +2 -0
  41. package/dist/esm/shopify/fetchers/update-cart-attributes.js.map +7 -0
  42. package/dist/esm/shopify/fetchers/update-cart-buyer-identity.js +2 -0
  43. package/dist/esm/shopify/fetchers/update-cart-buyer-identity.js.map +7 -0
  44. package/dist/esm/shopify/fetchers/update-cart-codes.js +2 -0
  45. package/dist/esm/shopify/fetchers/update-cart-codes.js.map +7 -0
  46. package/dist/esm/shopify/fetchers/update-cart-lines.js +2 -0
  47. package/dist/esm/shopify/fetchers/update-cart-lines.js.map +7 -0
  48. package/dist/esm/shopify/fragments/article.js +50 -0
  49. package/dist/esm/shopify/fragments/article.js.map +7 -0
  50. package/dist/esm/shopify/fragments/blog.js +11 -0
  51. package/dist/esm/shopify/fragments/blog.js.map +7 -0
  52. package/dist/esm/shopify/fragments/cart.js +189 -0
  53. package/dist/esm/shopify/fragments/cart.js.map +7 -0
  54. package/dist/esm/shopify/fragments/collection.js +16 -0
  55. package/dist/esm/shopify/fragments/collection.js.map +7 -0
  56. package/dist/esm/shopify/fragments/image.js +9 -0
  57. package/dist/esm/shopify/fragments/image.js.map +7 -0
  58. package/dist/esm/shopify/fragments/index.js +2 -0
  59. package/dist/esm/shopify/fragments/index.js.map +7 -0
  60. package/dist/esm/shopify/fragments/metafields.js +16 -0
  61. package/dist/esm/shopify/fragments/metafields.js.map +7 -0
  62. package/dist/esm/shopify/fragments/page-info.js +9 -0
  63. package/dist/esm/shopify/fragments/page-info.js.map +7 -0
  64. package/dist/esm/shopify/fragments/page.js +13 -0
  65. package/dist/esm/shopify/fragments/page.js.map +7 -0
  66. package/dist/esm/shopify/fragments/product.js +72 -0
  67. package/dist/esm/shopify/fragments/product.js.map +7 -0
  68. package/dist/esm/shopify/fragments/seo.js +7 -0
  69. package/dist/esm/shopify/fragments/seo.js.map +7 -0
  70. package/dist/esm/shopify/fragments/variant.js +30 -0
  71. package/dist/esm/shopify/fragments/variant.js.map +7 -0
  72. package/dist/esm/shopify/gql/fragment-masking.js +2 -0
  73. package/dist/esm/shopify/gql/fragment-masking.js.map +7 -0
  74. package/dist/esm/shopify/gql/gql.js +2 -0
  75. package/dist/esm/shopify/gql/gql.js.map +7 -0
  76. package/dist/esm/shopify/gql/graphql.js +2 -0
  77. package/dist/esm/shopify/gql/graphql.js.map +7 -0
  78. package/dist/esm/shopify/gql/index.js +2 -0
  79. package/dist/esm/shopify/gql/index.js.map +7 -0
  80. package/dist/esm/shopify/hooks/index.js +2 -0
  81. package/dist/esm/shopify/hooks/index.js.map +7 -0
  82. package/dist/esm/shopify/hooks/useProductsByHandles.js +2 -0
  83. package/dist/esm/shopify/hooks/useProductsByHandles.js.map +7 -0
  84. package/dist/esm/shopify/index.js +2 -0
  85. package/dist/esm/shopify/index.js.map +7 -0
  86. package/dist/esm/shopify/mutations/add-cart-lines.js +15 -0
  87. package/dist/esm/shopify/mutations/add-cart-lines.js.map +7 -0
  88. package/dist/esm/shopify/mutations/create-cart.js +21 -0
  89. package/dist/esm/shopify/mutations/create-cart.js.map +7 -0
  90. package/dist/esm/shopify/mutations/remove-cart-items.js +15 -0
  91. package/dist/esm/shopify/mutations/remove-cart-items.js.map +7 -0
  92. package/dist/esm/shopify/mutations/update-cart-attributes.js +15 -0
  93. package/dist/esm/shopify/mutations/update-cart-attributes.js.map +7 -0
  94. package/dist/esm/shopify/mutations/update-cart-buyer-identity.js +15 -0
  95. package/dist/esm/shopify/mutations/update-cart-buyer-identity.js.map +7 -0
  96. package/dist/esm/shopify/mutations/update-cart-discount-code.js +15 -0
  97. package/dist/esm/shopify/mutations/update-cart-discount-code.js.map +7 -0
  98. package/dist/esm/shopify/mutations/update-cart-items.js +15 -0
  99. package/dist/esm/shopify/mutations/update-cart-items.js.map +7 -0
  100. package/dist/esm/shopify/queries/get-cart.js +13 -0
  101. package/dist/esm/shopify/queries/get-cart.js.map +7 -0
  102. package/dist/esm/shopify/queries/get-product-by-handles.js +29 -0
  103. package/dist/esm/shopify/queries/get-product-by-handles.js.map +7 -0
  104. package/dist/esm/shopify/queries/index.js +2 -0
  105. package/dist/esm/shopify/queries/index.js.map +7 -0
  106. package/dist/esm/shopify/types/article.js +1 -0
  107. package/dist/esm/shopify/types/article.js.map +7 -0
  108. package/dist/esm/shopify/types/cart.js +1 -0
  109. package/dist/esm/shopify/types/cart.js.map +7 -0
  110. package/dist/esm/shopify/types/checkout.js +1 -0
  111. package/dist/esm/shopify/types/checkout.js.map +7 -0
  112. package/dist/esm/shopify/types/collection.js +1 -0
  113. package/dist/esm/shopify/types/collection.js.map +7 -0
  114. package/dist/esm/shopify/types/common.js +1 -0
  115. package/dist/esm/shopify/types/common.js.map +7 -0
  116. package/dist/esm/shopify/types/config.js +1 -0
  117. package/dist/esm/shopify/types/config.js.map +7 -0
  118. package/dist/esm/shopify/types/customer.js +1 -0
  119. package/dist/esm/shopify/types/customer.js.map +7 -0
  120. package/dist/esm/shopify/types/fetcher.js +2 -0
  121. package/dist/esm/shopify/types/fetcher.js.map +7 -0
  122. package/dist/esm/shopify/types/index.js +2 -0
  123. package/dist/esm/shopify/types/index.js.map +7 -0
  124. package/dist/esm/shopify/types/page.js +1 -0
  125. package/dist/esm/shopify/types/page.js.map +7 -0
  126. package/dist/esm/shopify/types/product.js +1 -0
  127. package/dist/esm/shopify/types/product.js.map +7 -0
  128. package/dist/esm/shopify/types/search.js +1 -0
  129. package/dist/esm/shopify/types/search.js.map +7 -0
  130. package/dist/esm/shopify/types/site.js +1 -0
  131. package/dist/esm/shopify/types/site.js.map +7 -0
  132. package/dist/esm/shopify/types/type-helper.js +1 -0
  133. package/dist/esm/shopify/types/type-helper.js.map +7 -0
  134. package/dist/esm/shopify/utils/colors.js +2 -0
  135. package/dist/esm/shopify/utils/colors.js.map +7 -0
  136. package/dist/esm/shopify/utils/const.js +2 -0
  137. package/dist/esm/shopify/utils/const.js.map +7 -0
  138. package/dist/esm/shopify/utils/cookie.js +2 -0
  139. package/dist/esm/shopify/utils/cookie.js.map +7 -0
  140. package/dist/esm/shopify/utils/errors.js +3 -0
  141. package/dist/esm/shopify/utils/errors.js.map +7 -0
  142. package/dist/esm/shopify/utils/fetch-graphql-api.js +3 -0
  143. package/dist/esm/shopify/utils/fetch-graphql-api.js.map +7 -0
  144. package/dist/esm/shopify/utils/handle-fetch-response.js +2 -0
  145. package/dist/esm/shopify/utils/handle-fetch-response.js.map +7 -0
  146. package/dist/esm/shopify/utils/helper.js +2 -0
  147. package/dist/esm/shopify/utils/helper.js.map +7 -0
  148. package/dist/esm/shopify/utils/normalize/cart.js +2 -0
  149. package/dist/esm/shopify/utils/normalize/cart.js.map +7 -0
  150. package/dist/esm/shopify/utils/normalize/customer.js +2 -0
  151. package/dist/esm/shopify/utils/normalize/customer.js.map +7 -0
  152. package/dist/esm/shopify/utils/normalize/index.js +2 -0
  153. package/dist/esm/shopify/utils/normalize/index.js.map +7 -0
  154. package/dist/esm/shopify/utils/normalize/metafield.js +2 -0
  155. package/dist/esm/shopify/utils/normalize/metafield.js.map +7 -0
  156. package/dist/esm/shopify/utils/normalize/product.js +2 -0
  157. package/dist/esm/shopify/utils/normalize/product.js.map +7 -0
  158. package/dist/esm/shopify/utils/store.js +2 -0
  159. package/dist/esm/shopify/utils/store.js.map +7 -0
  160. package/dist/esm/shopify/utils/type-helper.js +1 -0
  161. package/dist/esm/shopify/utils/type-helper.js.map +7 -0
  162. package/esbuild-cjs.mjs +23 -0
  163. package/esbuild-esm.mjs +30 -0
  164. package/jest.config.ts +12 -0
  165. package/package.json +10 -15
  166. package/src/cart/const.ts +23 -0
  167. package/src/cart/hooks/basic/useBuyNow.ts +105 -0
  168. package/src/cart/index.ts +19 -0
  169. package/src/cart/track/fbq.ts +63 -0
  170. package/src/cart/types/index.ts +25 -0
  171. package/src/cart/utils/index.ts +22 -0
  172. package/src/context/HeadlessProvider.tsx +30 -0
  173. package/src/context/config.ts +10 -0
  174. package/src/context/index.ts +3 -0
  175. package/src/index.ts +22 -0
  176. package/src/shopify/fetchers/add-cart-lines.ts +53 -0
  177. package/src/shopify/fetchers/create-cart.ts +43 -0
  178. package/src/shopify/fetchers/get-cart.ts +48 -0
  179. package/src/shopify/fetchers/get-products-by-handles.ts +48 -0
  180. package/src/shopify/fetchers/index.ts +10 -0
  181. package/src/shopify/fetchers/remove-cart-lines.ts +31 -0
  182. package/src/shopify/fetchers/update-cart-attributes.ts +29 -0
  183. package/src/shopify/fetchers/update-cart-buyer-identity.ts +32 -0
  184. package/src/shopify/fetchers/update-cart-codes.ts +32 -0
  185. package/src/shopify/fetchers/update-cart-lines.ts +42 -0
  186. package/src/shopify/fragments/article.ts +51 -0
  187. package/src/shopify/fragments/blog.ts +10 -0
  188. package/src/shopify/fragments/cart.ts +193 -0
  189. package/src/shopify/fragments/collection.ts +15 -0
  190. package/src/shopify/fragments/image.ts +8 -0
  191. package/src/shopify/fragments/index.ts +11 -0
  192. package/src/shopify/fragments/metafields.ts +17 -0
  193. package/src/shopify/fragments/page-info.ts +8 -0
  194. package/src/shopify/fragments/page.ts +12 -0
  195. package/src/shopify/fragments/product.ts +71 -0
  196. package/src/shopify/fragments/seo.ts +6 -0
  197. package/src/shopify/fragments/variant.ts +29 -0
  198. package/src/shopify/gql/fragment-masking.ts +85 -0
  199. package/src/shopify/gql/gql.ts +110 -0
  200. package/src/shopify/gql/graphql.ts +11780 -0
  201. package/src/shopify/gql/index.ts +4 -0
  202. package/src/shopify/hooks/index.ts +1 -0
  203. package/src/shopify/hooks/useProductsByHandles.ts +24 -0
  204. package/src/shopify/index.ts +5 -0
  205. package/src/shopify/mutations/add-cart-lines.ts +16 -0
  206. package/src/shopify/mutations/create-cart.ts +22 -0
  207. package/src/shopify/mutations/remove-cart-items.ts +16 -0
  208. package/src/shopify/mutations/update-cart-attributes.ts +16 -0
  209. package/src/shopify/mutations/update-cart-buyer-identity.ts +16 -0
  210. package/src/shopify/mutations/update-cart-discount-code.ts +16 -0
  211. package/src/shopify/mutations/update-cart-items.ts +16 -0
  212. package/src/shopify/queries/get-cart.ts +14 -0
  213. package/src/shopify/queries/get-product-by-handles.ts +32 -0
  214. package/src/shopify/queries/index.ts +2 -0
  215. package/src/shopify/types/article.ts +46 -0
  216. package/src/shopify/types/cart.ts +204 -0
  217. package/src/shopify/types/checkout.ts +44 -0
  218. package/src/shopify/types/collection.ts +104 -0
  219. package/src/shopify/types/common.ts +53 -0
  220. package/src/shopify/types/config.ts +14 -0
  221. package/src/shopify/types/customer.ts +31 -0
  222. package/src/shopify/types/fetcher.ts +67 -0
  223. package/src/shopify/types/index.ts +11 -0
  224. package/src/shopify/types/page.ts +45 -0
  225. package/src/shopify/types/product.ts +176 -0
  226. package/src/shopify/types/search.ts +62 -0
  227. package/src/shopify/types/site.ts +38 -0
  228. package/src/shopify/types/type-helper.ts +5 -0
  229. package/src/shopify/utils/colors.ts +206 -0
  230. package/src/shopify/utils/const.ts +115 -0
  231. package/src/shopify/utils/cookie.ts +28 -0
  232. package/src/shopify/utils/errors.ts +65 -0
  233. package/src/shopify/utils/fetch-graphql-api.ts +67 -0
  234. package/src/shopify/utils/handle-fetch-response.ts +60 -0
  235. package/src/shopify/utils/helper.ts +89 -0
  236. package/src/shopify/utils/normalize/cart.ts +106 -0
  237. package/src/shopify/utils/normalize/customer.ts +18 -0
  238. package/src/shopify/utils/normalize/index.ts +2 -0
  239. package/src/shopify/utils/normalize/metafield.ts +69 -0
  240. package/src/shopify/utils/normalize/product.ts +193 -0
  241. package/src/shopify/utils/store.ts +5 -0
  242. package/src/shopify/utils/type-helper.ts +7 -0
  243. package/tsconfig.json +20 -0
  244. package/tsup.config.ts +17 -0
  245. package/dist/index.esm.js +0 -1669
  246. package/dist/index.js +0 -1679
  247. package/dist/index.mjs +0 -1669
@@ -0,0 +1,193 @@
1
+ import { imageFragment } from './image'
2
+ import { metafieldFragment } from './metafields'
3
+ import { productFragment } from './product'
4
+ import { seoFragment } from './seo'
5
+
6
+ export const cartFragment = /* GraphQL */ `
7
+ fragment cart on Cart {
8
+ id
9
+ totalQuantity
10
+ updatedAt
11
+ createdAt
12
+ checkoutUrl
13
+ note
14
+ attributes {
15
+ key
16
+ value
17
+ }
18
+ cost {
19
+ checkoutChargeAmount {
20
+ amount
21
+ currencyCode
22
+ }
23
+ subtotalAmount {
24
+ amount
25
+ currencyCode
26
+ }
27
+ totalAmount {
28
+ amount
29
+ currencyCode
30
+ }
31
+ totalTaxAmount {
32
+ amount
33
+ currencyCode
34
+ }
35
+ totalDutyAmount {
36
+ amount
37
+ currencyCode
38
+ }
39
+ totalAmountEstimated
40
+ totalTaxAmountEstimated
41
+ totalDutyAmountEstimated
42
+ subtotalAmountEstimated
43
+ }
44
+ buyerIdentity {
45
+ email
46
+ customer {
47
+ email
48
+ id
49
+ }
50
+ deliveryAddressPreferences {
51
+ ... on MailingAddress {
52
+ address1
53
+ address2
54
+ city
55
+ country
56
+ zip
57
+ }
58
+ }
59
+ }
60
+ discountCodes {
61
+ applicable
62
+ code
63
+ }
64
+ discountAllocations {
65
+ ... on CartCodeDiscountAllocation {
66
+ code
67
+ discountedAmount {
68
+ amount
69
+ currencyCode
70
+ }
71
+ }
72
+ ... on CartAutomaticDiscountAllocation {
73
+ title
74
+ discountedAmount {
75
+ amount
76
+ currencyCode
77
+ }
78
+ }
79
+ ... on CartCustomDiscountAllocation {
80
+ title
81
+ discountedAmount {
82
+ amount
83
+ currencyCode
84
+ }
85
+ }
86
+ }
87
+ deliveryGroups(first: 10) {
88
+ nodes {
89
+ deliveryAddress {
90
+ address1
91
+ address2
92
+ city
93
+ country
94
+ zip
95
+ }
96
+ }
97
+ }
98
+ lines(first: 100) {
99
+ edges {
100
+ node {
101
+ id
102
+ quantity
103
+ discountAllocations {
104
+ ... on CartCodeDiscountAllocation {
105
+ code
106
+ discountedAmount {
107
+ amount
108
+ currencyCode
109
+ }
110
+ }
111
+ ... on CartAutomaticDiscountAllocation {
112
+ title
113
+ discountedAmount {
114
+ amount
115
+ currencyCode
116
+ }
117
+ }
118
+ ... on CartCustomDiscountAllocation {
119
+ title
120
+ discountedAmount {
121
+ amount
122
+ currencyCode
123
+ }
124
+ }
125
+ }
126
+ attributes {
127
+ key
128
+ value
129
+ }
130
+ cost {
131
+ amountPerQuantity {
132
+ amount
133
+ currencyCode
134
+ }
135
+ compareAtAmountPerQuantity {
136
+ amount
137
+ currencyCode
138
+ }
139
+ subtotalAmount {
140
+ amount
141
+ currencyCode
142
+ }
143
+ totalAmount {
144
+ amount
145
+ currencyCode
146
+ }
147
+ }
148
+ merchandise {
149
+ ... on ProductVariant {
150
+ id
151
+ sku
152
+ title
153
+ quantityAvailable
154
+ currentlyNotInStock
155
+ availableForSale
156
+ barcode
157
+ weight
158
+ selectedOptions {
159
+ name
160
+ value
161
+ }
162
+ image {
163
+ ...image
164
+ }
165
+ price {
166
+ amount
167
+ currencyCode
168
+ }
169
+ compareAtPrice {
170
+ amount
171
+ currencyCode
172
+ }
173
+ metafields(identifiers: $variantMetafieldIdentifiers) {
174
+ ...metafield
175
+ }
176
+ product {
177
+ ...product
178
+ metafields(identifiers: $productMetafieldIdentifiers) {
179
+ ...metafield
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+ }
187
+ totalQuantity
188
+ }
189
+ ${productFragment}
190
+ ${seoFragment}
191
+ ${imageFragment}
192
+ ${metafieldFragment}
193
+ `
@@ -0,0 +1,15 @@
1
+ export const collectionFragment = /* GraphQL */ `
2
+ fragment collection on Collection {
3
+ id
4
+ handle
5
+ title
6
+ description
7
+ descriptionHtml
8
+ seo {
9
+ ...seo
10
+ }
11
+ image {
12
+ ...image
13
+ }
14
+ }
15
+ `
@@ -0,0 +1,8 @@
1
+ export const imageFragment = /* GraphQL */ `
2
+ fragment image on Image {
3
+ url
4
+ altText
5
+ width
6
+ height
7
+ }
8
+ `
@@ -0,0 +1,11 @@
1
+ export * from './article'
2
+ export * from './blog'
3
+ export * from './collection'
4
+ export * from './cart'
5
+ export * from './image'
6
+ export * from './metafields'
7
+ export * from './page-info'
8
+ export * from './product'
9
+ export * from './seo'
10
+ export * from './variant'
11
+ export * from './page'
@@ -0,0 +1,17 @@
1
+ export const metafieldFragment = /* GraphQL */ `
2
+ fragment metafield on Metafield {
3
+ value
4
+ type
5
+ description
6
+ namespace
7
+ key
8
+ }
9
+ `
10
+
11
+ export const metafieldFragmentStr = `
12
+ value
13
+ type
14
+ description
15
+ namespace
16
+ key
17
+ `
@@ -0,0 +1,8 @@
1
+ export const pageInfoFragment = /* GraphQL */ `
2
+ fragment pageInfo on PageInfo {
3
+ hasNextPage
4
+ hasPreviousPage
5
+ startCursor
6
+ endCursor
7
+ }
8
+ `
@@ -0,0 +1,12 @@
1
+ export const pageFragment = /* GraphQL */ `
2
+ fragment page on Page {
3
+ title
4
+ handle
5
+ body
6
+ bodySummary
7
+ seo {
8
+ title
9
+ description
10
+ }
11
+ }
12
+ `
@@ -0,0 +1,71 @@
1
+ export const productFragment = /* GraphQL */ `
2
+ fragment product on Product {
3
+ id
4
+ handle
5
+ availableForSale
6
+ title
7
+ description
8
+ descriptionHtml
9
+ options {
10
+ id
11
+ name
12
+ values
13
+ }
14
+ productType
15
+ priceRange {
16
+ maxVariantPrice {
17
+ amount
18
+ currencyCode
19
+ }
20
+ minVariantPrice {
21
+ amount
22
+ currencyCode
23
+ }
24
+ }
25
+ compareAtPriceRange {
26
+ minVariantPrice {
27
+ amount
28
+ currencyCode
29
+ }
30
+ }
31
+ featuredImage {
32
+ ...image
33
+ }
34
+ images(first: 250) {
35
+ nodes {
36
+ ...image
37
+ }
38
+ }
39
+ media(first: 250) {
40
+ nodes {
41
+ id
42
+ mediaContentType
43
+ presentation {
44
+ id
45
+ }
46
+ ... on Video {
47
+ id
48
+ sources {
49
+ format
50
+ height
51
+ mimeType
52
+ url
53
+ width
54
+ }
55
+ }
56
+ ... on MediaImage {
57
+ id
58
+ image {
59
+ altText
60
+ url
61
+ }
62
+ }
63
+ }
64
+ }
65
+ seo {
66
+ ...seo
67
+ }
68
+ tags
69
+ updatedAt
70
+ }
71
+ `
@@ -0,0 +1,6 @@
1
+ export const seoFragment = /* GraphQL */ `
2
+ fragment seo on SEO {
3
+ description
4
+ title
5
+ }
6
+ `
@@ -0,0 +1,29 @@
1
+ export const variantFragment = /* GraphQL */ `
2
+ fragment variant on ProductVariant {
3
+ id
4
+ sku
5
+ title
6
+ requiresShipping
7
+ quantityAvailable
8
+ currentlyNotInStock
9
+ availableForSale
10
+ barcode
11
+ quantityAvailable
12
+ weight
13
+ selectedOptions {
14
+ name
15
+ value
16
+ }
17
+ image {
18
+ ...image
19
+ }
20
+ price {
21
+ amount
22
+ currencyCode
23
+ }
24
+ compareAtPrice {
25
+ amount
26
+ currencyCode
27
+ }
28
+ }
29
+ `
@@ -0,0 +1,85 @@
1
+ import {
2
+ ResultOf,
3
+ DocumentTypeDecoration,
4
+ TypedDocumentNode,
5
+ } from '@graphql-typed-document-node/core'
6
+ import { FragmentDefinitionNode } from 'graphql'
7
+ import { Incremental } from './graphql'
8
+
9
+ export type FragmentType<
10
+ TDocumentType extends DocumentTypeDecoration<any, any>
11
+ > = TDocumentType extends DocumentTypeDecoration<infer TType, any>
12
+ ? [TType] extends [{ ' $fragmentName'?: infer TKey }]
13
+ ? TKey extends string
14
+ ? { ' $fragmentRefs'?: { [key in TKey]: TType } }
15
+ : never
16
+ : never
17
+ : never
18
+
19
+ // return non-nullable if `fragmentType` is non-nullable
20
+ export function useFragment<TType>(
21
+ _documentNode: DocumentTypeDecoration<TType, any>,
22
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>
23
+ ): TType
24
+ // return nullable if `fragmentType` is nullable
25
+ export function useFragment<TType>(
26
+ _documentNode: DocumentTypeDecoration<TType, any>,
27
+ fragmentType:
28
+ | FragmentType<DocumentTypeDecoration<TType, any>>
29
+ | null
30
+ | undefined
31
+ ): TType | null | undefined
32
+ // return array of non-nullable if `fragmentType` is array of non-nullable
33
+ export function useFragment<TType>(
34
+ _documentNode: DocumentTypeDecoration<TType, any>,
35
+ fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
36
+ ): ReadonlyArray<TType>
37
+ // return array of nullable if `fragmentType` is array of nullable
38
+ export function useFragment<TType>(
39
+ _documentNode: DocumentTypeDecoration<TType, any>,
40
+ fragmentType:
41
+ | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
42
+ | null
43
+ | undefined
44
+ ): ReadonlyArray<TType> | null | undefined
45
+ export function useFragment<TType>(
46
+ _documentNode: DocumentTypeDecoration<TType, any>,
47
+ fragmentType:
48
+ | FragmentType<DocumentTypeDecoration<TType, any>>
49
+ | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
50
+ | null
51
+ | undefined
52
+ ): TType | ReadonlyArray<TType> | null | undefined {
53
+ return fragmentType as any
54
+ }
55
+
56
+ export function makeFragmentData<
57
+ F extends DocumentTypeDecoration<any, any>,
58
+ FT extends ResultOf<F>
59
+ >(data: FT, _fragment: F): FragmentType<F> {
60
+ return data as FragmentType<F>
61
+ }
62
+ export function isFragmentReady<TQuery, TFrag>(
63
+ queryNode: DocumentTypeDecoration<TQuery, any>,
64
+ fragmentNode: TypedDocumentNode<TFrag>,
65
+ data:
66
+ | FragmentType<TypedDocumentNode<Incremental<TFrag>, any>>
67
+ | null
68
+ | undefined
69
+ ): data is FragmentType<typeof fragmentNode> {
70
+ const deferredFields = (
71
+ queryNode as {
72
+ __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> }
73
+ }
74
+ ).__meta__?.deferredFields
75
+
76
+ if (!deferredFields) return true
77
+
78
+ const fragDef = fragmentNode.definitions[0] as
79
+ | FragmentDefinitionNode
80
+ | undefined
81
+ const fragName = fragDef?.name?.value
82
+
83
+ const fields = (fragName && deferredFields[fragName]) || []
84
+ return fields.length > 0 && fields.every((field) => data && field in data)
85
+ }
@@ -0,0 +1,110 @@
1
+ /* eslint-disable */
2
+ import * as types from './graphql'
3
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'
4
+
5
+ /**
6
+ * Map of all GraphQL operations in the project.
7
+ *
8
+ * This map has several performance disadvantages:
9
+ * 1. It is not tree-shakeable, so it will include all operations in the project.
10
+ * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
11
+ * 3. It does not support dead code elimination, so it will add unused operations.
12
+ *
13
+ * Therefore it is highly recommended to use the babel or swc plugin for production.
14
+ */
15
+ const documents = {
16
+ '\n fragment cart on Cart {\n id\n checkoutUrl\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n edges {\n node {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n selectedOptions {\n name\n value\n }\n product {\n ...product\n }\n }\n }\n }\n }\n }\n totalQuantity\n }\n \n':
17
+ types.CartFragmentDoc,
18
+ '\n fragment image on Image {\n url\n altText\n width\n height\n }\n':
19
+ types.ImageFragmentDoc,
20
+ '\n fragment product on Product {\n id\n handle\n availableForSale\n title\n description\n descriptionHtml\n options {\n id\n name\n values\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n variants(first: 250) {\n edges {\n node {\n id\n title\n availableForSale\n selectedOptions {\n name\n value\n }\n price {\n amount\n currencyCode\n }\n }\n }\n }\n featuredImage {\n ...image\n }\n images(first: 20) {\n edges {\n node {\n ...image\n }\n }\n }\n seo {\n ...seo\n }\n tags\n updatedAt\n }\n \n \n':
21
+ types.ProductFragmentDoc,
22
+ '\n fragment seo on SEO {\n description\n title\n }\n':
23
+ types.SeoFragmentDoc,
24
+ '\n mutation addToCart($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...cart\n }\n }\n }\n \n':
25
+ types.AddToCartDocument,
26
+ '\n mutation createCart($lineItems: [CartLineInput!]) {\n cartCreate(input: { lines: $lineItems }) {\n cart {\n ...cart\n }\n }\n }\n \n':
27
+ types.CreateCartDocument,
28
+ '\n mutation editCartItems($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...cart\n }\n }\n }\n \n':
29
+ types.EditCartItemsDocument,
30
+ '\n mutation removeFromCart($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...cart\n }\n }\n }\n \n':
31
+ types.RemoveFromCartDocument,
32
+ '\n query getCart($cartId: ID!) {\n cart(id: $cartId) {\n ...cart\n }\n }\n \n':
33
+ types.GetCartDocument,
34
+ }
35
+
36
+ /**
37
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
38
+ *
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
43
+ * ```
44
+ *
45
+ * The query argument is unknown!
46
+ * Please regenerate the types.
47
+ */
48
+ export function graphql(source: string): unknown
49
+
50
+ /**
51
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
52
+ */
53
+ export function graphql(
54
+ source: '\n fragment cart on Cart {\n id\n checkoutUrl\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n edges {\n node {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n selectedOptions {\n name\n value\n }\n product {\n ...product\n }\n }\n }\n }\n }\n }\n totalQuantity\n }\n \n'
55
+ ): (typeof documents)['\n fragment cart on Cart {\n id\n checkoutUrl\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n edges {\n node {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n selectedOptions {\n name\n value\n }\n product {\n ...product\n }\n }\n }\n }\n }\n }\n totalQuantity\n }\n \n']
56
+ /**
57
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
58
+ */
59
+ export function graphql(
60
+ source: '\n fragment image on Image {\n url\n altText\n width\n height\n }\n'
61
+ ): (typeof documents)['\n fragment image on Image {\n url\n altText\n width\n height\n }\n']
62
+ /**
63
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
64
+ */
65
+ export function graphql(
66
+ source: '\n fragment product on Product {\n id\n handle\n availableForSale\n title\n description\n descriptionHtml\n options {\n id\n name\n values\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n variants(first: 250) {\n edges {\n node {\n id\n title\n availableForSale\n selectedOptions {\n name\n value\n }\n price {\n amount\n currencyCode\n }\n }\n }\n }\n featuredImage {\n ...image\n }\n images(first: 20) {\n edges {\n node {\n ...image\n }\n }\n }\n seo {\n ...seo\n }\n tags\n updatedAt\n }\n \n \n'
67
+ ): (typeof documents)['\n fragment product on Product {\n id\n handle\n availableForSale\n title\n description\n descriptionHtml\n options {\n id\n name\n values\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n variants(first: 250) {\n edges {\n node {\n id\n title\n availableForSale\n selectedOptions {\n name\n value\n }\n price {\n amount\n currencyCode\n }\n }\n }\n }\n featuredImage {\n ...image\n }\n images(first: 20) {\n edges {\n node {\n ...image\n }\n }\n }\n seo {\n ...seo\n }\n tags\n updatedAt\n }\n \n \n']
68
+ /**
69
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
70
+ */
71
+ export function graphql(
72
+ source: '\n fragment seo on SEO {\n description\n title\n }\n'
73
+ ): (typeof documents)['\n fragment seo on SEO {\n description\n title\n }\n']
74
+ /**
75
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
76
+ */
77
+ export function graphql(
78
+ source: '\n mutation addToCart($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...cart\n }\n }\n }\n \n'
79
+ ): (typeof documents)['\n mutation addToCart($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...cart\n }\n }\n }\n \n']
80
+ /**
81
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
82
+ */
83
+ export function graphql(
84
+ source: '\n mutation createCart($lineItems: [CartLineInput!]) {\n cartCreate(input: { lines: $lineItems }) {\n cart {\n ...cart\n }\n }\n }\n \n'
85
+ ): (typeof documents)['\n mutation createCart($lineItems: [CartLineInput!]) {\n cartCreate(input: { lines: $lineItems }) {\n cart {\n ...cart\n }\n }\n }\n \n']
86
+ /**
87
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
88
+ */
89
+ export function graphql(
90
+ source: '\n mutation editCartItems($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...cart\n }\n }\n }\n \n'
91
+ ): (typeof documents)['\n mutation editCartItems($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...cart\n }\n }\n }\n \n']
92
+ /**
93
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
94
+ */
95
+ export function graphql(
96
+ source: '\n mutation removeFromCart($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...cart\n }\n }\n }\n \n'
97
+ ): (typeof documents)['\n mutation removeFromCart($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...cart\n }\n }\n }\n \n']
98
+ /**
99
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
100
+ */
101
+ export function graphql(
102
+ source: '\n query getCart($cartId: ID!) {\n cart(id: $cartId) {\n ...cart\n }\n }\n \n'
103
+ ): (typeof documents)['\n query getCart($cartId: ID!) {\n cart(id: $cartId) {\n ...cart\n }\n }\n \n']
104
+
105
+ export function graphql(source: string) {
106
+ return (documents as any)[source] ?? {}
107
+ }
108
+
109
+ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> =
110
+ TDocumentNode extends DocumentNode<infer TType, any> ? TType : never