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

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 -13
  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,4 @@
1
+ export * from './fragment-masking'
2
+ export * from './gql'
3
+ export * from './graphql'
4
+
@@ -0,0 +1 @@
1
+ export { useProductsByHandles } from './useProductsByHandles'
@@ -0,0 +1,24 @@
1
+ import useSWR from 'swr'
2
+ import { useHeadlessContext } from '../../context'
3
+
4
+ import { getProductsByHandles, GetProductsMetafieldQueryRoot } from '../fetchers/get-products-by-handles'
5
+ import { ShopifyHookOptions } from '../types/fetcher'
6
+ import { GetProductsByHandlesReq } from '../fetchers/get-products-by-handles'
7
+
8
+ export function useProductsByHandles({
9
+ handles,
10
+ metafieldIdentifiers,
11
+ }: ShopifyHookOptions<GetProductsByHandlesReq, GetProductsMetafieldQueryRoot>) {
12
+ const { storefrontToken, storeDomain, comboMetafieldsNamespace } = useHeadlessContext()
13
+
14
+ return useSWR(handles?.length ? { handles, metafieldIdentifiers } : undefined, async () => {
15
+ return getProductsByHandles({
16
+ options: {
17
+ handles: handles,
18
+ metafieldIdentifiers: metafieldIdentifiers,
19
+ comboMetafieldsNamespace,
20
+ },
21
+ config: { storefrontToken, storeDomain },
22
+ })
23
+ })
24
+ }
@@ -0,0 +1,5 @@
1
+ export * from './fetchers'
2
+ export * from './hooks'
3
+ export * from './queries'
4
+ export * from './fragments'
5
+ export * from './types'
@@ -0,0 +1,16 @@
1
+ import { cartFragment } from '../fragments/cart'
2
+
3
+ export const addCartLinesMutation = /* GraphQL */ `
4
+ mutation addCartLines($cartId: ID!, $lines: [CartLineInput!]!) {
5
+ cartLinesAdd(cartId: $cartId, lines: $lines) {
6
+ cart {
7
+ ...cart
8
+ }
9
+ userErrors {
10
+ field
11
+ message
12
+ }
13
+ }
14
+ }
15
+ ${cartFragment}
16
+ `
@@ -0,0 +1,22 @@
1
+ import { cartFragment } from '../fragments/cart'
2
+
3
+ export const createCartMutation = /* GraphQL */ `
4
+ mutation createCart(
5
+ $lines: [CartLineInput!]
6
+ $discountCodes: [String!]
7
+ $attributes: [AttributeInput!] = []
8
+ $productMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
9
+ $variantMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
10
+ ) {
11
+ cartCreate(input: { lines: $lines, discountCodes: $discountCodes, attributes: $attributes }) {
12
+ cart {
13
+ ...cart
14
+ }
15
+ userErrors {
16
+ field
17
+ message
18
+ }
19
+ }
20
+ }
21
+ ${cartFragment}
22
+ `
@@ -0,0 +1,16 @@
1
+ import { cartFragment } from '../fragments/cart'
2
+
3
+ export const removeCartItemsMutation = /* GraphQL */ `
4
+ mutation removeFromCart($cartId: ID!, $lineIds: [ID!]!) {
5
+ cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
6
+ cart {
7
+ ...cart
8
+ }
9
+ userErrors {
10
+ field
11
+ message
12
+ }
13
+ }
14
+ }
15
+ ${cartFragment}
16
+ `
@@ -0,0 +1,16 @@
1
+ import { cartFragment } from '../fragments/cart'
2
+
3
+ export const updateCartAttributesMutation = /* GraphQL */ `
4
+ mutation updateCartAttributes($cartId: ID!, $attributes: [AttributeInput!]!) {
5
+ cartAttributesUpdate(cartId: $cartId, attributes: $attributes) {
6
+ cart {
7
+ ...cart
8
+ }
9
+ userErrors {
10
+ field
11
+ message
12
+ }
13
+ }
14
+ }
15
+ ${cartFragment}
16
+ `
@@ -0,0 +1,16 @@
1
+ import { cartFragment } from '../fragments/cart'
2
+
3
+ export const updateCartBuyerIdentityMutation = /* GraphQL */ `
4
+ mutation updateCartBuyerIdentity($cartId: ID!, $buyerIdentity: CartBuyerIdentityInput!) {
5
+ cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
6
+ cart {
7
+ ...cart
8
+ }
9
+ userErrors {
10
+ field
11
+ message
12
+ }
13
+ }
14
+ }
15
+ ${cartFragment}
16
+ `
@@ -0,0 +1,16 @@
1
+ import { cartFragment } from '../fragments/cart'
2
+
3
+ export const updateCartDiscountCodeMutation = /* GraphQL */ `
4
+ mutation updateCartDiscountCodes($cartId: ID!, $discountCodes: [String!]) {
5
+ cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
6
+ cart {
7
+ ...cart
8
+ }
9
+ userErrors {
10
+ field
11
+ message
12
+ }
13
+ }
14
+ }
15
+ ${cartFragment}
16
+ `
@@ -0,0 +1,16 @@
1
+ import { cartFragment } from '../fragments/cart'
2
+
3
+ export const updateCartLinesMutation = /* GraphQL */ `
4
+ mutation updateCartLines($cartId: ID!, $lines: [CartLineUpdateInput!]!) {
5
+ cartLinesUpdate(cartId: $cartId, lines: $lines) {
6
+ cart {
7
+ ...cart
8
+ }
9
+ userErrors {
10
+ field
11
+ message
12
+ }
13
+ }
14
+ }
15
+ ${cartFragment}
16
+ `
@@ -0,0 +1,14 @@
1
+ import { cartFragment } from '../fragments'
2
+
3
+ export const getCartQuery = /* GraphQL */ `
4
+ query getCart(
5
+ $cartId: ID!
6
+ $productMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
7
+ $variantMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
8
+ ) {
9
+ cart(id: $cartId) {
10
+ ...cart
11
+ }
12
+ }
13
+ ${cartFragment}
14
+ `
@@ -0,0 +1,32 @@
1
+ import { imageFragment, metafieldFragment, productFragment, seoFragment, variantFragment } from '../fragments'
2
+
3
+ export const getProductsByHandlesQuery = (handles: string[]) => /* GraphQL */ `
4
+ query GetProductByHandles(
5
+ $productMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
6
+ $variantMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
7
+ ) {
8
+ ${handles.map(
9
+ (handle, index: number) => /* GraphQL */ `
10
+ product${index}: product(handle: "${handle}") {
11
+ ...product
12
+ metafields(identifiers: $productMetafieldIdentifiers) {
13
+ ...metafield
14
+ }
15
+ variants(first: 250) {
16
+ nodes {
17
+ ...variant
18
+ metafields(identifiers: $variantMetafieldIdentifiers) {
19
+ ...metafield
20
+ }
21
+ }
22
+ }
23
+ }
24
+ `
25
+ )}
26
+ }
27
+ ${productFragment}
28
+ ${variantFragment}
29
+ ${metafieldFragment}
30
+ ${seoFragment}
31
+ ${imageFragment}
32
+ `
@@ -0,0 +1,2 @@
1
+ export { getProductsByHandlesQuery } from './get-product-by-handles'
2
+
@@ -0,0 +1,46 @@
1
+ import { Article, ArticleEdge } from '../gql'
2
+
3
+ export type ArticleResponse = {
4
+ blog: {
5
+ title: string
6
+ seo: string
7
+ article: Article
8
+ articles: {
9
+ edges: ArticleEdge[]
10
+ pageInfo: {
11
+ hasNextPage: boolean
12
+ hasPreviousPage: boolean
13
+ }
14
+ }
15
+ handle: string
16
+ }
17
+ }
18
+
19
+ export type ArticleImage = {
20
+ url: string
21
+ alt?: string
22
+ }
23
+
24
+ export type ArticleTypes = {
25
+ article: Article
26
+ metafields: any
27
+ }
28
+
29
+ export type ArticleQuery = {
30
+ locale: string
31
+ blog: string
32
+ slug: string
33
+ }
34
+
35
+ export type GetArticleOperation = {
36
+ data: { blog_article?: ArticleTypes; error?: string }
37
+ variables: { blog: string; slug: string }
38
+ }
39
+
40
+ export type GetAllArticleOperation<T extends ArticleTypes = ArticleTypes> = {
41
+ data: { articles: T['article'][] }
42
+ variables: {
43
+ first?: number
44
+ after?: string
45
+ }
46
+ }
@@ -0,0 +1,204 @@
1
+ import { ProductVariant, Product } from '../types/product'
2
+ import { Cart as ShopifyCart } from '../gql'
3
+ import { Discount } from './common'
4
+ import { CustomerAddress } from './customer'
5
+
6
+ export type { CartBuyerIdentity, CartInput } from '../gql'
7
+
8
+ export type Attributes = {
9
+ key: string
10
+ value: string
11
+ }[]
12
+
13
+ export type ShopifyCartOperation = {
14
+ cart: ShopifyCart
15
+ variables: {
16
+ cartId: string
17
+ }
18
+ }
19
+
20
+ export type ShopifyCreateCartOperation = {
21
+ cartCreate: { cart: Cart }
22
+ // cartCreate: { cart: ShopifyCart }
23
+ variables: {
24
+ buyerIdentity?: any
25
+ lines: {
26
+ merchandiseId: string
27
+ quantity: number
28
+ attributes?: any
29
+ }[]
30
+ attributes?: {}
31
+ }
32
+ }
33
+
34
+ export type ShopifyAddToCartOperation = {
35
+ cartLinesAdd: {
36
+ cart: ShopifyCart
37
+ }
38
+ variables: {
39
+ cartId: string
40
+ buyerIdentity?: any
41
+ lines: {
42
+ merchandiseId: string
43
+ quantity: number
44
+ attributes?: any
45
+ }[]
46
+ attributes?: {}
47
+ }
48
+ }
49
+
50
+ export type ShopifyRemoveFromCartOperation = {
51
+ cartLinesRemove: {
52
+ cart: ShopifyCart
53
+ }
54
+ variables: {
55
+ cartId: string
56
+ lineIds: string[]
57
+ }
58
+ }
59
+
60
+ export type ShopifyUpdateCartOperation = {
61
+ cartLinesUpdate: {
62
+ cart: ShopifyCart
63
+ }
64
+ variables: {
65
+ cartId: string
66
+ lines: {
67
+ id: string
68
+ merchandiseId?: string
69
+ quantity?: number
70
+ attributes?: any
71
+ }[]
72
+ attributes?: any
73
+ }
74
+ }
75
+
76
+ export type ShopifyCodesUpdateCartOperation = {
77
+ cartDiscountCodesUpdate: {
78
+ cart: ShopifyCart
79
+ }
80
+ variables: {
81
+ cartId: string
82
+ discountCodes: string[]
83
+ }
84
+ }
85
+
86
+ export type CartAttributesUpdateOperation = {
87
+ cartAttributesUpdate: { cart: ShopifyCart }
88
+ variables: {
89
+ cartId: string
90
+ attributes: any
91
+ }
92
+ }
93
+
94
+ export type InputArribute = {
95
+ key?: string
96
+ value?: string
97
+ }
98
+
99
+ export type subInputValue = {
100
+ [key: string]: string
101
+ }
102
+
103
+ export type InputLineItem = {
104
+ merchandiseId: string
105
+ quantity: number
106
+ attributes: any
107
+ buyerIdentity?: any
108
+ sellingPlanId?: string
109
+ }
110
+
111
+ export type SelectedOption = {
112
+ // The option's id.
113
+ id?: string
114
+ // The product option’s name.
115
+ name: string
116
+ /// The product option’s value.
117
+ value: string
118
+ }
119
+
120
+ export type LineItem = {
121
+ id: string
122
+ variantId: string
123
+ productId: string
124
+ name: string
125
+ quantity: number
126
+ discounts: Discount[]
127
+ // A human-friendly unique string automatically generated from the product’s name
128
+ path: string
129
+ variant: ProductVariant
130
+ totalAmount: number
131
+ subtotalAmount: number
132
+ options?: SelectedOption[]
133
+ discountAllocations?: DiscountAllocations[]
134
+ product?: Product
135
+ customAttributes?: any
136
+ attributes?: any
137
+ sellingPlan?: string
138
+ }
139
+
140
+ export type Discounts = {
141
+ applicable: boolean
142
+ code: string
143
+ }
144
+
145
+ export type DiscountAllocations = {
146
+ amount: number
147
+ code: string
148
+ }
149
+
150
+ export type EstimatedCost = {
151
+ amount: string
152
+ currencyCode: string
153
+ }
154
+
155
+ export type SelectedDeliveryOption = {
156
+ code: string
157
+ estimatedCost: EstimatedCost
158
+ handle: string
159
+ title: string
160
+ }
161
+
162
+ export type DeliveryGroups = {
163
+ deliveryAddress: CustomerAddress
164
+ deliveryOptions: any
165
+ id: string
166
+ selectedDeliveryOption?: any
167
+ }
168
+
169
+ export type Cart = {
170
+ id: string
171
+ // ID of the customer to which the cart belongs.
172
+ customerId?: string
173
+ // The email assigned to this cart
174
+ email?: string
175
+ // The date and time when the cart was created.
176
+ createdAt: string
177
+ // The currency used for this cart
178
+ currency: { code: string }
179
+ // Specifies if taxes are included in the line items.
180
+ taxesIncluded?: boolean
181
+ lineItems: LineItem[]
182
+ // The sum of all the prices of all the items in the cart.
183
+ // Duties, taxes, shipping and discounts excluded.
184
+ totalLineItemsDiscount?: number
185
+ orderDiscounts?: number
186
+ lineItemsSubtotalPrice: number
187
+ // Price of the cart before duties, shipping and taxes.
188
+ subtotalPrice: number
189
+ // The sum of all the prices of all the items in the cart.
190
+ // Duties, taxes and discounts included.
191
+ totalPrice: number
192
+ // Discounts that have been applied on the cart.
193
+ totalTaxAmount: number
194
+ discountCodes: Discounts[]
195
+ discountAllocations?: DiscountAllocations[]
196
+ discounts?: Discount[]
197
+ url?: string
198
+ ready: boolean
199
+ orderStatusUrl?: any
200
+ customAttributes?: any
201
+ buyerIdentity?: any
202
+ deliveryAmount?: number
203
+ deliveryGroups?: DeliveryGroups[]
204
+ }
@@ -0,0 +1,44 @@
1
+ export type ShopifyGetCheckoutOperation = {
2
+ node: {
3
+ id: string
4
+ webUrl: string
5
+ completedAt: string
6
+ }
7
+ variables: {
8
+ checkoutId: string
9
+ }
10
+ }
11
+ export type ShopifyCreateCheckoutOperation = {
12
+ checkoutCreate: {
13
+ checkout: {
14
+ id: string
15
+ webUrl: string
16
+ }
17
+ }
18
+ variables: {
19
+ customAttributes?: any
20
+ lineItems: {
21
+ variantId: string
22
+ quantity: number
23
+ customAttributes?: any
24
+ }[]
25
+ }
26
+ }
27
+
28
+ export type ShopifyCheckoutDiscountApplyOperation = {
29
+ checkoutDiscountCodeApplyV2: {
30
+ checkout: {
31
+ id: string
32
+ webUrl: string
33
+ }
34
+ }
35
+ variables: {
36
+ checkoutId: string
37
+ discountCode: string
38
+ }
39
+ }
40
+
41
+ export type Checkout = {
42
+ id?: string
43
+ webUrl?: string
44
+ }
@@ -0,0 +1,104 @@
1
+ import { ProductTypes } from './product'
2
+ import { Collection, Image, Maybe } from '../gql'
3
+
4
+ export type CollectionsMetafield = {
5
+ [key: string]: string[]
6
+ }
7
+
8
+ export type FilterPriceTxt = {
9
+ text: string
10
+ gte: string
11
+ lte: string
12
+ }
13
+
14
+ export type FiltersPairMetafield = {
15
+ collections: {
16
+ [key: string]: {
17
+ filter_params: string[]
18
+ price?: [number[]]
19
+ }
20
+ }
21
+ filters_label: { [key: string]: any }
22
+ cabletype?: { [key: string]: any }
23
+ length?: { [key: string]: any }
24
+ videoports?: { [key: string]: any }
25
+ datatransferspeed?: { [key: string]: any }
26
+ connectivity?: { [key: string]: any }
27
+ numberofports?: { [key: string]: any }
28
+ porttype?: { [key: string]: any }
29
+ numberofdevicespowered?: { [key: string]: any }
30
+ chargingtechnology?: { [key: string]: any }
31
+ capacity?: { [key: string]: any }
32
+ product_type: { [key: string]: any }
33
+ price: FilterPriceTxt
34
+ filter_txt: { [key: string]: any }
35
+ [key: string]: any
36
+ }
37
+
38
+ export type FiltersPair = {
39
+ label: string
40
+ value: string
41
+ options: Array<{
42
+ value: string
43
+ label: string
44
+ }>
45
+ }
46
+
47
+ export type CategoryImage = {
48
+ url: string
49
+ alt?: string
50
+ }
51
+
52
+ export type Category<T extends ProductTypes = ProductTypes> = {
53
+ id: string
54
+ name: string
55
+ slug: string
56
+ path: string
57
+ description?: string
58
+ descriptionHtml?: string
59
+ image?: Maybe<Image>
60
+ products?: T['product'][]
61
+ filters?: any
62
+ pageInfo?: any
63
+ seo?: any
64
+ initData?: any
65
+ metafields?: { [key: string]: any }
66
+ }
67
+
68
+ export type CategoryTypes = {
69
+ collection: Category
70
+ }
71
+
72
+ export type GetCollectionOperation<T extends CategoryTypes = CategoryTypes> = {
73
+ collectionByHandle: Collection
74
+ variables: {
75
+ handle?: string
76
+ first?: number
77
+ after?: string
78
+ last?: string
79
+ before?: string
80
+ reverse?: boolean
81
+ sortKey?: string
82
+ filters?: any
83
+ }
84
+ }
85
+
86
+ export type CollectionQuery = {
87
+ locale?: string
88
+ handle?: string
89
+ queryArgument?: {
90
+ first?: number
91
+ after?: string
92
+ last?: string
93
+ before?: string
94
+ reverse?: boolean
95
+ sortKey?: string
96
+ filters?: any
97
+ }
98
+ }
99
+
100
+ export type PriceLabel = {
101
+ text: string
102
+ gte: string
103
+ lte: string
104
+ }
@@ -0,0 +1,53 @@
1
+ export type Discount = {
2
+ // The value of the discount, can be an amount or percentage
3
+ value?: number
4
+ percentage?: number
5
+ amount?: number
6
+ currencyCode?: string
7
+ }
8
+
9
+ export type Measurement = {
10
+ value: number
11
+ unit: 'KILOGRAMS' | 'GRAMS' | 'POUNDS' | 'OUNCES'
12
+ }
13
+
14
+ export type Image = {
15
+ url: string
16
+ altText?: string
17
+ width?: number
18
+ height?: number
19
+ }
20
+
21
+ export type Maybe<T> = T | null
22
+
23
+ export type ExtractVariables<T> = T extends { variables?: object }
24
+ ? T['variables']
25
+ : undefined
26
+
27
+ export interface CommerceAPIFetchOptions<T> {
28
+ variables?: ExtractVariables<T>
29
+ preview?: boolean
30
+ }
31
+
32
+ export type Connection<T> = {
33
+ edges: Array<Edge<T>>
34
+ }
35
+
36
+ export type Edge<T> = {
37
+ node: T
38
+ }
39
+
40
+ export type Menu = {
41
+ title: string
42
+ path: string
43
+ }
44
+
45
+ export type Money = {
46
+ amount: string
47
+ currencyCode: string
48
+ }
49
+
50
+ export type SEO = {
51
+ title: string
52
+ description: string
53
+ }
@@ -0,0 +1,14 @@
1
+ export type SiteConfig = {
2
+ locale: string
3
+ comboMetafieldsNamespace: string
4
+ cartIdCookieName: string
5
+ brand: string
6
+ appName: string
7
+ }
8
+
9
+ export type ShopifyConfig = {
10
+ storefrontToken: string
11
+ storeDomain: string
12
+ }
13
+ export type ShopifyContextValue = SiteConfig & ShopifyConfig
14
+