@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.
- package/.gitkeep +0 -0
- package/.turbo/turbo-build.log +22 -0
- package/.turbo/turbo-test.log +5 -0
- package/dist/cjs/context/HeadlessProvider.js +1 -1
- package/dist/cjs/context/HeadlessProvider.js.map +2 -2
- package/dist/context/HeadlessProvider.d.ts.map +1 -1
- package/dist/esm/cart/const.js +2 -0
- package/dist/esm/cart/const.js.map +7 -0
- package/dist/esm/cart/hooks/basic/useBuyNow.js +2 -0
- package/dist/esm/cart/hooks/basic/useBuyNow.js.map +7 -0
- package/dist/esm/cart/index.js +2 -0
- package/dist/esm/cart/index.js.map +7 -0
- package/dist/esm/cart/track/fbq.js +2 -0
- package/dist/esm/cart/track/fbq.js.map +7 -0
- package/dist/esm/cart/types/index.js +1 -0
- package/dist/esm/cart/types/index.js.map +7 -0
- package/dist/esm/cart/utils/index.js +2 -0
- package/dist/esm/cart/utils/index.js.map +7 -0
- package/dist/esm/context/HeadlessProvider.js +2 -0
- package/dist/esm/context/HeadlessProvider.js.map +7 -0
- package/dist/esm/context/config.js +1 -0
- package/dist/esm/context/config.js.map +7 -0
- package/dist/esm/context/index.js +2 -0
- package/dist/esm/context/index.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/shopify/fetchers/add-cart-lines.js +2 -0
- package/dist/esm/shopify/fetchers/add-cart-lines.js.map +7 -0
- package/dist/esm/shopify/fetchers/create-cart.js +2 -0
- package/dist/esm/shopify/fetchers/create-cart.js.map +7 -0
- package/dist/esm/shopify/fetchers/get-cart.js +2 -0
- package/dist/esm/shopify/fetchers/get-cart.js.map +7 -0
- package/dist/esm/shopify/fetchers/get-products-by-handles.js +2 -0
- package/dist/esm/shopify/fetchers/get-products-by-handles.js.map +7 -0
- package/dist/esm/shopify/fetchers/index.js +2 -0
- package/dist/esm/shopify/fetchers/index.js.map +7 -0
- package/dist/esm/shopify/fetchers/remove-cart-lines.js +2 -0
- package/dist/esm/shopify/fetchers/remove-cart-lines.js.map +7 -0
- package/dist/esm/shopify/fetchers/update-cart-attributes.js +2 -0
- package/dist/esm/shopify/fetchers/update-cart-attributes.js.map +7 -0
- package/dist/esm/shopify/fetchers/update-cart-buyer-identity.js +2 -0
- package/dist/esm/shopify/fetchers/update-cart-buyer-identity.js.map +7 -0
- package/dist/esm/shopify/fetchers/update-cart-codes.js +2 -0
- package/dist/esm/shopify/fetchers/update-cart-codes.js.map +7 -0
- package/dist/esm/shopify/fetchers/update-cart-lines.js +2 -0
- package/dist/esm/shopify/fetchers/update-cart-lines.js.map +7 -0
- package/dist/esm/shopify/fragments/article.js +50 -0
- package/dist/esm/shopify/fragments/article.js.map +7 -0
- package/dist/esm/shopify/fragments/blog.js +11 -0
- package/dist/esm/shopify/fragments/blog.js.map +7 -0
- package/dist/esm/shopify/fragments/cart.js +189 -0
- package/dist/esm/shopify/fragments/cart.js.map +7 -0
- package/dist/esm/shopify/fragments/collection.js +16 -0
- package/dist/esm/shopify/fragments/collection.js.map +7 -0
- package/dist/esm/shopify/fragments/image.js +9 -0
- package/dist/esm/shopify/fragments/image.js.map +7 -0
- package/dist/esm/shopify/fragments/index.js +2 -0
- package/dist/esm/shopify/fragments/index.js.map +7 -0
- package/dist/esm/shopify/fragments/metafields.js +16 -0
- package/dist/esm/shopify/fragments/metafields.js.map +7 -0
- package/dist/esm/shopify/fragments/page-info.js +9 -0
- package/dist/esm/shopify/fragments/page-info.js.map +7 -0
- package/dist/esm/shopify/fragments/page.js +13 -0
- package/dist/esm/shopify/fragments/page.js.map +7 -0
- package/dist/esm/shopify/fragments/product.js +72 -0
- package/dist/esm/shopify/fragments/product.js.map +7 -0
- package/dist/esm/shopify/fragments/seo.js +7 -0
- package/dist/esm/shopify/fragments/seo.js.map +7 -0
- package/dist/esm/shopify/fragments/variant.js +30 -0
- package/dist/esm/shopify/fragments/variant.js.map +7 -0
- package/dist/esm/shopify/gql/fragment-masking.js +2 -0
- package/dist/esm/shopify/gql/fragment-masking.js.map +7 -0
- package/dist/esm/shopify/gql/gql.js +2 -0
- package/dist/esm/shopify/gql/gql.js.map +7 -0
- package/dist/esm/shopify/gql/graphql.js +2 -0
- package/dist/esm/shopify/gql/graphql.js.map +7 -0
- package/dist/esm/shopify/gql/index.js +2 -0
- package/dist/esm/shopify/gql/index.js.map +7 -0
- package/dist/esm/shopify/hooks/index.js +2 -0
- package/dist/esm/shopify/hooks/index.js.map +7 -0
- package/dist/esm/shopify/hooks/useProductsByHandles.js +2 -0
- package/dist/esm/shopify/hooks/useProductsByHandles.js.map +7 -0
- package/dist/esm/shopify/index.js +2 -0
- package/dist/esm/shopify/index.js.map +7 -0
- package/dist/esm/shopify/mutations/add-cart-lines.js +15 -0
- package/dist/esm/shopify/mutations/add-cart-lines.js.map +7 -0
- package/dist/esm/shopify/mutations/create-cart.js +21 -0
- package/dist/esm/shopify/mutations/create-cart.js.map +7 -0
- package/dist/esm/shopify/mutations/remove-cart-items.js +15 -0
- package/dist/esm/shopify/mutations/remove-cart-items.js.map +7 -0
- package/dist/esm/shopify/mutations/update-cart-attributes.js +15 -0
- package/dist/esm/shopify/mutations/update-cart-attributes.js.map +7 -0
- package/dist/esm/shopify/mutations/update-cart-buyer-identity.js +15 -0
- package/dist/esm/shopify/mutations/update-cart-buyer-identity.js.map +7 -0
- package/dist/esm/shopify/mutations/update-cart-discount-code.js +15 -0
- package/dist/esm/shopify/mutations/update-cart-discount-code.js.map +7 -0
- package/dist/esm/shopify/mutations/update-cart-items.js +15 -0
- package/dist/esm/shopify/mutations/update-cart-items.js.map +7 -0
- package/dist/esm/shopify/queries/get-cart.js +13 -0
- package/dist/esm/shopify/queries/get-cart.js.map +7 -0
- package/dist/esm/shopify/queries/get-product-by-handles.js +29 -0
- package/dist/esm/shopify/queries/get-product-by-handles.js.map +7 -0
- package/dist/esm/shopify/queries/index.js +2 -0
- package/dist/esm/shopify/queries/index.js.map +7 -0
- package/dist/esm/shopify/types/article.js +1 -0
- package/dist/esm/shopify/types/article.js.map +7 -0
- package/dist/esm/shopify/types/cart.js +1 -0
- package/dist/esm/shopify/types/cart.js.map +7 -0
- package/dist/esm/shopify/types/checkout.js +1 -0
- package/dist/esm/shopify/types/checkout.js.map +7 -0
- package/dist/esm/shopify/types/collection.js +1 -0
- package/dist/esm/shopify/types/collection.js.map +7 -0
- package/dist/esm/shopify/types/common.js +1 -0
- package/dist/esm/shopify/types/common.js.map +7 -0
- package/dist/esm/shopify/types/config.js +1 -0
- package/dist/esm/shopify/types/config.js.map +7 -0
- package/dist/esm/shopify/types/customer.js +1 -0
- package/dist/esm/shopify/types/customer.js.map +7 -0
- package/dist/esm/shopify/types/fetcher.js +2 -0
- package/dist/esm/shopify/types/fetcher.js.map +7 -0
- package/dist/esm/shopify/types/index.js +2 -0
- package/dist/esm/shopify/types/index.js.map +7 -0
- package/dist/esm/shopify/types/page.js +1 -0
- package/dist/esm/shopify/types/page.js.map +7 -0
- package/dist/esm/shopify/types/product.js +1 -0
- package/dist/esm/shopify/types/product.js.map +7 -0
- package/dist/esm/shopify/types/search.js +1 -0
- package/dist/esm/shopify/types/search.js.map +7 -0
- package/dist/esm/shopify/types/site.js +1 -0
- package/dist/esm/shopify/types/site.js.map +7 -0
- package/dist/esm/shopify/types/type-helper.js +1 -0
- package/dist/esm/shopify/types/type-helper.js.map +7 -0
- package/dist/esm/shopify/utils/colors.js +2 -0
- package/dist/esm/shopify/utils/colors.js.map +7 -0
- package/dist/esm/shopify/utils/const.js +2 -0
- package/dist/esm/shopify/utils/const.js.map +7 -0
- package/dist/esm/shopify/utils/cookie.js +2 -0
- package/dist/esm/shopify/utils/cookie.js.map +7 -0
- package/dist/esm/shopify/utils/errors.js +3 -0
- package/dist/esm/shopify/utils/errors.js.map +7 -0
- package/dist/esm/shopify/utils/fetch-graphql-api.js +3 -0
- package/dist/esm/shopify/utils/fetch-graphql-api.js.map +7 -0
- package/dist/esm/shopify/utils/handle-fetch-response.js +2 -0
- package/dist/esm/shopify/utils/handle-fetch-response.js.map +7 -0
- package/dist/esm/shopify/utils/helper.js +2 -0
- package/dist/esm/shopify/utils/helper.js.map +7 -0
- package/dist/esm/shopify/utils/normalize/cart.js +2 -0
- package/dist/esm/shopify/utils/normalize/cart.js.map +7 -0
- package/dist/esm/shopify/utils/normalize/customer.js +2 -0
- package/dist/esm/shopify/utils/normalize/customer.js.map +7 -0
- package/dist/esm/shopify/utils/normalize/index.js +2 -0
- package/dist/esm/shopify/utils/normalize/index.js.map +7 -0
- package/dist/esm/shopify/utils/normalize/metafield.js +2 -0
- package/dist/esm/shopify/utils/normalize/metafield.js.map +7 -0
- package/dist/esm/shopify/utils/normalize/product.js +2 -0
- package/dist/esm/shopify/utils/normalize/product.js.map +7 -0
- package/dist/esm/shopify/utils/store.js +2 -0
- package/dist/esm/shopify/utils/store.js.map +7 -0
- package/dist/esm/shopify/utils/type-helper.js +1 -0
- package/dist/esm/shopify/utils/type-helper.js.map +7 -0
- package/esbuild-cjs.mjs +23 -0
- package/esbuild-esm.mjs +30 -0
- package/jest.config.ts +12 -0
- package/package.json +10 -15
- package/src/cart/const.ts +23 -0
- package/src/cart/hooks/basic/useBuyNow.ts +105 -0
- package/src/cart/index.ts +19 -0
- package/src/cart/track/fbq.ts +63 -0
- package/src/cart/types/index.ts +25 -0
- package/src/cart/utils/index.ts +22 -0
- package/src/context/HeadlessProvider.tsx +30 -0
- package/src/context/config.ts +10 -0
- package/src/context/index.ts +3 -0
- package/src/index.ts +22 -0
- package/src/shopify/fetchers/add-cart-lines.ts +53 -0
- package/src/shopify/fetchers/create-cart.ts +43 -0
- package/src/shopify/fetchers/get-cart.ts +48 -0
- package/src/shopify/fetchers/get-products-by-handles.ts +48 -0
- package/src/shopify/fetchers/index.ts +10 -0
- package/src/shopify/fetchers/remove-cart-lines.ts +31 -0
- package/src/shopify/fetchers/update-cart-attributes.ts +29 -0
- package/src/shopify/fetchers/update-cart-buyer-identity.ts +32 -0
- package/src/shopify/fetchers/update-cart-codes.ts +32 -0
- package/src/shopify/fetchers/update-cart-lines.ts +42 -0
- package/src/shopify/fragments/article.ts +51 -0
- package/src/shopify/fragments/blog.ts +10 -0
- package/src/shopify/fragments/cart.ts +193 -0
- package/src/shopify/fragments/collection.ts +15 -0
- package/src/shopify/fragments/image.ts +8 -0
- package/src/shopify/fragments/index.ts +11 -0
- package/src/shopify/fragments/metafields.ts +17 -0
- package/src/shopify/fragments/page-info.ts +8 -0
- package/src/shopify/fragments/page.ts +12 -0
- package/src/shopify/fragments/product.ts +71 -0
- package/src/shopify/fragments/seo.ts +6 -0
- package/src/shopify/fragments/variant.ts +29 -0
- package/src/shopify/gql/fragment-masking.ts +85 -0
- package/src/shopify/gql/gql.ts +110 -0
- package/src/shopify/gql/graphql.ts +11780 -0
- package/src/shopify/gql/index.ts +4 -0
- package/src/shopify/hooks/index.ts +1 -0
- package/src/shopify/hooks/useProductsByHandles.ts +24 -0
- package/src/shopify/index.ts +5 -0
- package/src/shopify/mutations/add-cart-lines.ts +16 -0
- package/src/shopify/mutations/create-cart.ts +22 -0
- package/src/shopify/mutations/remove-cart-items.ts +16 -0
- package/src/shopify/mutations/update-cart-attributes.ts +16 -0
- package/src/shopify/mutations/update-cart-buyer-identity.ts +16 -0
- package/src/shopify/mutations/update-cart-discount-code.ts +16 -0
- package/src/shopify/mutations/update-cart-items.ts +16 -0
- package/src/shopify/queries/get-cart.ts +14 -0
- package/src/shopify/queries/get-product-by-handles.ts +32 -0
- package/src/shopify/queries/index.ts +2 -0
- package/src/shopify/types/article.ts +46 -0
- package/src/shopify/types/cart.ts +204 -0
- package/src/shopify/types/checkout.ts +44 -0
- package/src/shopify/types/collection.ts +104 -0
- package/src/shopify/types/common.ts +53 -0
- package/src/shopify/types/config.ts +14 -0
- package/src/shopify/types/customer.ts +31 -0
- package/src/shopify/types/fetcher.ts +67 -0
- package/src/shopify/types/index.ts +11 -0
- package/src/shopify/types/page.ts +45 -0
- package/src/shopify/types/product.ts +176 -0
- package/src/shopify/types/search.ts +62 -0
- package/src/shopify/types/site.ts +38 -0
- package/src/shopify/types/type-helper.ts +5 -0
- package/src/shopify/utils/colors.ts +206 -0
- package/src/shopify/utils/const.ts +115 -0
- package/src/shopify/utils/cookie.ts +28 -0
- package/src/shopify/utils/errors.ts +65 -0
- package/src/shopify/utils/fetch-graphql-api.ts +67 -0
- package/src/shopify/utils/handle-fetch-response.ts +60 -0
- package/src/shopify/utils/helper.ts +89 -0
- package/src/shopify/utils/normalize/cart.ts +106 -0
- package/src/shopify/utils/normalize/customer.ts +18 -0
- package/src/shopify/utils/normalize/index.ts +2 -0
- package/src/shopify/utils/normalize/metafield.ts +69 -0
- package/src/shopify/utils/normalize/product.ts +193 -0
- package/src/shopify/utils/store.ts +5 -0
- package/src/shopify/utils/type-helper.ts +7 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +17 -0
- package/dist/index.esm.js +0 -1669
- package/dist/index.js +0 -1679
- package/dist/index.mjs +0 -1669
package/.gitkeep
ADDED
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
> @anker-in/lib@1.0.0-beta.5 build /Users/anker/Code/headless-ui/packages/lib
|
|
3
|
+
> tsup
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.4.0
|
|
8
|
+
[34mCLI[39m Using tsup config: /Users/anker/Code/headless-ui/packages/lib/tsup.config.ts
|
|
9
|
+
[34mCLI[39m Target: esnext
|
|
10
|
+
[34mCLI[39m Cleaning output folder
|
|
11
|
+
[34mESM[39m Build start
|
|
12
|
+
[34mCJS[39m Build start
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m1.62 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m584.00 B[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 194ms
|
|
16
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m256.00 B[39m
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m511.00 B[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 209ms
|
|
19
|
+
DTS Build start
|
|
20
|
+
DTS ⚡️ Build success in 2522ms
|
|
21
|
+
DTS dist/index.d.mts 263.00 B
|
|
22
|
+
DTS dist/index.d.ts 263.00 B
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var c=(o,e)=>{for(var s in e)n(o,s,{get:e[s],enumerable:!0})},f=(o,e,s,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of u(e))!H.call(o,t)&&t!==s&&n(o,t,{get:()=>e[t],enumerable:!(d=l(e,t))||d.enumerable});return o};var C=o=>f(n({},"__esModule",{value:!0}),o);var g={};c(g,{HeadlessProvider:()=>x,useHeadlessContext:()=>P});module.exports=C(g);var i=require("react/jsx-runtime"),r=require("react");const a=(0,r.createContext)(null),x=({children:o,headlessConfig:e})=>{const s=(0,r.useMemo)(()=>{if(!e)throw new Error("No site configuration or headless configuration found");return e},[e]);return(0,i.jsx)(a.Provider,{value:s,children:o})},P=()=>{const o=(0,r.useContext)(a);if(!o)throw new Error("useHeadlessContext must be used within a HeadlessProvider");return o||{}};
|
|
2
2
|
//# sourceMappingURL=HeadlessProvider.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/context/HeadlessProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContext, useContext, useMemo, ReactNode } from 'react'\n\nimport { HeadlessConfig } from './config'\n\nconst HeadlessContext = createContext<HeadlessConfig | null>(null)\n\ninterface HeadlessProviderProps {\n children: ReactNode\n headlessConfig: HeadlessConfig\n}\n\nexport const HeadlessProvider = ({ children, headlessConfig }: HeadlessProviderProps): JSX.Element => {\n
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,
|
|
4
|
+
"sourcesContent": ["import { createContext, useContext, useMemo, ReactNode } from 'react'\n\nimport { HeadlessConfig } from './config'\n\nconst HeadlessContext = createContext<HeadlessConfig | null>(null)\n\ninterface HeadlessProviderProps {\n children: ReactNode\n headlessConfig: HeadlessConfig\n}\n\nexport const HeadlessProvider = ({ children, headlessConfig }: HeadlessProviderProps): JSX.Element => {\n const contextValue = useMemo((): HeadlessConfig => {\n if (!headlessConfig) {\n throw new Error(`No site configuration or headless configuration found`)\n }\n\n return headlessConfig\n }, [headlessConfig])\n\n return <HeadlessContext.Provider value={contextValue}>{children}</HeadlessContext.Provider>\n}\n\nexport const useHeadlessContext = (): HeadlessConfig => {\n const context = useContext(HeadlessContext)\n if (!context) {\n throw new Error('useHeadlessContext must be used within a HeadlessProvider')\n }\n return context || ({} as HeadlessConfig)\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,GAoBS,IAAAK,EAAA,6BApBTC,EAA8D,iBAI9D,MAAMC,KAAkB,iBAAqC,IAAI,EAOpDL,EAAmB,CAAC,CAAE,SAAAM,EAAU,eAAAC,CAAe,IAA0C,CACpG,MAAMC,KAAe,WAAQ,IAAsB,CACjD,GAAI,CAACD,EACH,MAAM,IAAI,MAAM,uDAAuD,EAGzE,OAAOA,CACT,EAAG,CAACA,CAAc,CAAC,EAEnB,SAAO,OAACF,EAAgB,SAAhB,CAAyB,MAAOG,EAAe,SAAAF,EAAS,CAClE,EAEaL,EAAqB,IAAsB,CACtD,MAAMQ,KAAU,cAAWJ,CAAe,EAC1C,GAAI,CAACI,EACH,MAAM,IAAI,MAAM,2DAA2D,EAE7E,OAAOA,GAAY,CAAC,CACtB",
|
|
6
6
|
"names": ["HeadlessProvider_exports", "__export", "HeadlessProvider", "useHeadlessContext", "__toCommonJS", "import_jsx_runtime", "import_react", "HeadlessContext", "children", "headlessConfig", "contextValue", "context"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadlessProvider.d.ts","sourceRoot":"","sources":["../../src/context/HeadlessProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,SAAS,EAAE,MAAM,OAAO,CAAA;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAIzC,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,SAAS,CAAA;IACnB,cAAc,EAAE,cAAc,CAAA;CAC/B;AAED,eAAO,MAAM,gBAAgB,GAAI,8BAA8B,qBAAqB,KAAG,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"HeadlessProvider.d.ts","sourceRoot":"","sources":["../../src/context/HeadlessProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,SAAS,EAAE,MAAM,OAAO,CAAA;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAIzC,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,SAAS,CAAA;IACnB,cAAc,EAAE,cAAc,CAAA;CAC/B;AAED,eAAO,MAAM,gBAAgB,GAAI,8BAA8B,qBAAqB,KAAG,GAAG,CAAC,OAU1F,CAAA;AAED,eAAO,MAAM,kBAAkB,QAAO,cAMrC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/cart/const.ts"],
|
|
4
|
+
"sourcesContent": ["import { SWRMutationConfiguration } from 'swr/mutation'\n\nexport const currencyCodeMapping = {\n us: 'USD',\n ca: 'CAD',\n gb: 'GBP',\n eu: 'EUR',\n au: 'AUD',\n nz: 'NZD',\n de: 'EUR',\n fr: 'EUR',\n es: 'EUR',\n it: 'EUR',\n nl: 'EUR',\n pl: 'EUR',\n ro: 'EUR',\n} as Record<string, string>\n\nexport const defaultSWRMutationConfiguration: SWRMutationConfiguration<any, any, any, any, any> & {\n throwOnError?: boolean\n} = {\n throwOnError: false,\n}\n"],
|
|
5
|
+
"mappings": "AAEO,MAAMA,EAAsB,CACjC,GAAI,MACJ,GAAI,MACJ,GAAI,MACJ,GAAI,MACJ,GAAI,MACJ,GAAI,MACJ,GAAI,MACJ,GAAI,MACJ,GAAI,MACJ,GAAI,MACJ,GAAI,MACJ,GAAI,MACJ,GAAI,KACN,EAEaC,EAET,CACF,aAAc,EAChB",
|
|
6
|
+
"names": ["currencyCodeMapping", "defaultSWRMutationConfiguration"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useCallback as d}from"react";import l from"swr/mutation";import{createCart as i}from"../../../shopify";import{useHeadlessContext as p}from"../../../context";import{defaultSWRMutationConfiguration as g}from"../../const";const G=({withTrack:o=!0,redirectToCheckout:e=!0}={},s=g)=>{const{storefrontToken:u,storeDomain:m}=p(),f=d(async(w,{arg:y})=>{const{lineItems:n,discountCodes:c,gtmParams:b={},buyerIdentity:C,fbqTrackConfig:B}=y;if(!n)return;const a=n.map(t=>({merchandiseId:t.variant.id,quantity:t.quantity||1,attributes:t.attributes})).filter(t=>t.merchandiseId&&t.quantity);let r;if(a.length>0&&(r=await i({options:{lines:a,buyerIdentity:C,discountCodes:c},config:{storefrontToken:u,storeDomain:m}})),e&&r?.url)window.location.href=r.url;else throw new Error("Failed to buy now");return r},[o,e,i]);return l("buyNow",f,s)};export{G as useBuyNow};
|
|
2
|
+
//# sourceMappingURL=useBuyNow.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/cart/hooks/basic/useBuyNow.ts"],
|
|
4
|
+
"sourcesContent": ["import { Attributes, Cart, CartBuyerIdentity, CartInput } from '../../../shopify'\nimport { useCallback } from 'react'\nimport useSWRMutation, { SWRMutationConfiguration } from 'swr/mutation'\nimport { FbqBuyNowTrackConfig } from '../../track/fbq'\nimport { GtmParams, BuyNowLineItems } from '../../types'\n// import { startInactiveSpan } from '@sentry/nextjs'\nimport { createCart as createCartFetcher } from '../../../shopify'\nimport { useHeadlessContext } from '../../../context'\nimport { defaultSWRMutationConfiguration } from '../../const'\n\ntype UseBuyNowProps = {\n withTrack?: boolean // \u662F\u5426\u9700\u8981\u9ED8\u8BA4\u57CB\u70B9\n redirectToCheckout?: boolean // \u662F\u5426\u91CD\u5B9A\u5411\u5230\u7ED3\u8D26\u9875\n}\n\nexport type BuyNowArgs = {\n lineItems: BuyNowLineItems\n discountCodes?: string[]\n customAttributes?: Attributes[]\n buyerIdentity?: CartBuyerIdentity\n gtmParams?: GtmParams\n fbqTrackConfig?: FbqBuyNowTrackConfig\n}\n\nexport const useBuyNow = (\n { withTrack = true, redirectToCheckout = true }: UseBuyNowProps = {},\n swrOptions: SWRMutationConfiguration<Cart | undefined, Error, string, BuyNowArgs> & {\n throwOnError?: boolean\n } = defaultSWRMutationConfiguration\n) => {\n const { storefrontToken, storeDomain } = useHeadlessContext()\n\n const trigger = useCallback(\n async (_: any, { arg }: { arg: BuyNowArgs }) => {\n const { lineItems, discountCodes, gtmParams = {}, buyerIdentity, fbqTrackConfig } = arg\n\n if (!lineItems) {\n return\n }\n\n // const buyNowSpan = startInactiveSpan({\n // name: 'buyNow',\n // op: 'business',\n // })\n\n const linesToBuyNow = lineItems\n .map(item => ({\n merchandiseId: item.variant.id,\n quantity: item.quantity || 1,\n attributes: item.attributes,\n }))\n .filter(item => item.merchandiseId && item.quantity)\n\n let resultCart: Cart | undefined\n if (linesToBuyNow.length > 0) {\n // const buyNowAPISpan = startInactiveSpan({\n // name: 'buyNowAPI',\n // op: 'business',\n // parentSpan: buyNowSpan,\n // })\n\n // const createCartApiSpan = startInactiveSpan({\n // name: 'createCartAPI',\n // op: 'business',\n // parentSpan: buyNowAPISpan,\n // })\n // \u521B\u5EFA\u8D2D\u7269\u8F66\n const createCartOptions = {\n lines: linesToBuyNow,\n buyerIdentity,\n discountCodes,\n } as CartInput\n resultCart = await createCartFetcher({\n options: createCartOptions,\n config: {\n storefrontToken,\n storeDomain,\n },\n })\n // createCartApiSpan.end()\n\n // buyNowAPISpan.end()\n }\n\n // \u57CB\u70B9\n if (withTrack) {\n // buyNowGa({ lineItems, router, gtmParams })\n // if (fbqTrackConfig) {\n // buyNowFbq({ router, trackConfig: fbqTrackConfig })\n // }\n }\n\n // buyNowSpan.end()\n if (redirectToCheckout && resultCart?.url) {\n window.location.href = resultCart.url\n } else {\n throw new Error('Failed to buy now')\n }\n return resultCart\n },\n [withTrack, redirectToCheckout, createCartFetcher]\n )\n\n return useSWRMutation('buyNow', trigger, swrOptions)\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,eAAAA,MAAmB,QAC5B,OAAOC,MAAkD,eAIzD,OAAS,cAAcC,MAAyB,mBAChD,OAAS,sBAAAC,MAA0B,mBACnC,OAAS,mCAAAC,MAAuC,cAgBzC,MAAMC,EAAY,CACvB,CAAE,UAAAC,EAAY,GAAM,mBAAAC,EAAqB,EAAK,EAAoB,CAAC,EACnEC,EAEIJ,IACD,CACH,KAAM,CAAE,gBAAAK,EAAiB,YAAAC,CAAY,EAAIP,EAAmB,EAEtDQ,EAAUX,EACd,MAAOY,EAAQ,CAAE,IAAAC,CAAI,IAA2B,CAC9C,KAAM,CAAE,UAAAC,EAAW,cAAAC,EAAe,UAAAC,EAAY,CAAC,EAAG,cAAAC,EAAe,eAAAC,CAAe,EAAIL,EAEpF,GAAI,CAACC,EACH,OAQF,MAAMK,EAAgBL,EACnB,IAAIM,IAAS,CACZ,cAAeA,EAAK,QAAQ,GAC5B,SAAUA,EAAK,UAAY,EAC3B,WAAYA,EAAK,UACnB,EAAE,EACD,OAAOA,GAAQA,EAAK,eAAiBA,EAAK,QAAQ,EAErD,IAAIC,EAwCJ,GAvCIF,EAAc,OAAS,IAkBzBE,EAAa,MAAMnB,EAAkB,CACnC,QANwB,CACxB,MAAOiB,EACP,cAAAF,EACA,cAAAF,CACF,EAGE,OAAQ,CACN,gBAAAN,EACA,YAAAC,CACF,CACF,CAAC,GAeCH,GAAsBc,GAAY,IACpC,OAAO,SAAS,KAAOA,EAAW,QAElC,OAAM,IAAI,MAAM,mBAAmB,EAErC,OAAOA,CACT,EACA,CAACf,EAAWC,EAAoBL,CAAiB,CACnD,EAEA,OAAOD,EAAe,SAAUU,EAASH,CAAU,CACrD",
|
|
6
|
+
"names": ["useCallback", "useSWRMutation", "createCartFetcher", "useHeadlessContext", "defaultSWRMutationConfiguration", "useBuyNow", "withTrack", "redirectToCheckout", "swrOptions", "storefrontToken", "storeDomain", "trigger", "_", "arg", "lineItems", "discountCodes", "gtmParams", "buyerIdentity", "fbqTrackConfig", "linesToBuyNow", "item", "resultCart"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/cart/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Context\n\n// Basic Hooks\n\nexport * from './hooks/basic/useBuyNow'\n\n// Feature Hooks\n\n// Types\nexport * from './types'\n\n// Utils\nexport * from './utils'\n\n// Constants\nexport * from './const'\n\n// Tracking\nexport * from './track/fbq'\n"],
|
|
5
|
+
"mappings": "AAIA,WAAc,0BAKd,WAAc,UAGd,WAAc,UAGd,WAAc,UAGd,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=(...t)=>{window.fbq&&window.fbq(...t)},a=(...t)=>{window.gtag&&window.gtag(...t)},c=({lineItems:t=[]})=>{if(t.length&&t[0].variant){const{variant:o,quantity:n,finalPrice:r}=t[0];e("track","AddToCart",{value:r?.amount||o?.price?.amount,num_items:n,currency:o?.price?.currencyCode,content_name:o?.product?.title,content_type:"product_group",content_ids:String(o?.id),content_category:o?.product?.metafields?.global?.trafficType||"public"})}},d=({trackConfig:t,gtagId:o})=>{try{t?.fbqBuyNowEvent&&e("trackCustom",t?.fbqBuyNowEvent),t?.gtagBuyNowLabel&&a("event",t?.gtagBuyNowConversion||"conversion",{send_to:`${o}/${t?.gtagBuyNowLabel}`})}catch{}};export{c as addToCartFbq,d as buyNowFbq,e as fbq,a as gtag};
|
|
2
|
+
//# sourceMappingURL=fbq.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cart/track/fbq.ts"],
|
|
4
|
+
"sourcesContent": ["import { AddToCartLineItems } from '../types'\n\ndeclare global {\n interface Window {\n fbq?: (...args: any) => void\n gtag?: (...args: any) => void\n }\n}\n\n// facebook \u57CB\u70B9\nexport const fbq = (...args: any) => {\n if (window.fbq) {\n window.fbq(...args)\n }\n}\n\nexport const gtag = (...args: any) => {\n if (window.gtag) {\n window.gtag(...args)\n }\n}\n\nexport const addToCartFbq = ({ lineItems = [] }: { lineItems: AddToCartLineItems }) => {\n if (lineItems.length && lineItems[0].variant) {\n const { variant, quantity, finalPrice } = lineItems[0]\n fbq('track', 'AddToCart', {\n value: finalPrice?.amount || variant?.price?.amount,\n num_items: quantity,\n currency: variant?.price?.currencyCode,\n content_name: variant?.product?.title, // \u4EA7\u54C1\u5185\u5BB9\u7684\u540D\u5B57\n content_type: 'product_group',\n content_ids: String(variant?.id), // \u4EA7\u54C1\u7684varaint id\n content_category: variant?.product?.metafields?.global?.trafficType || 'public', // \u4EA7\u54C1\u5206\u7C7B\n })\n }\n}\n\nexport type FbqBuyNowTrackConfig = {\n fbqBuyNowEvent: string\n gtagBuyNowLabel: string\n gtagBuyNowConversion: string\n}\n\nexport const buyNowFbq = ({\n trackConfig,\n gtagId,\n}: {\n router: any\n trackConfig: FbqBuyNowTrackConfig\n gtagId: string\n}) => {\n try {\n if (trackConfig?.fbqBuyNowEvent) {\n fbq('trackCustom', trackConfig?.fbqBuyNowEvent)\n }\n\n if (trackConfig?.gtagBuyNowLabel) {\n gtag('event', trackConfig?.gtagBuyNowConversion || 'conversion', {\n send_to: `${gtagId}/${trackConfig?.gtagBuyNowLabel}`,\n })\n }\n } catch (error) {}\n}\n"],
|
|
5
|
+
"mappings": "AAUO,MAAMA,EAAM,IAAIC,IAAc,CAC/B,OAAO,KACT,OAAO,IAAI,GAAGA,CAAI,CAEtB,EAEaC,EAAO,IAAID,IAAc,CAChC,OAAO,MACT,OAAO,KAAK,GAAGA,CAAI,CAEvB,EAEaE,EAAe,CAAC,CAAE,UAAAC,EAAY,CAAC,CAAE,IAAyC,CACrF,GAAIA,EAAU,QAAUA,EAAU,CAAC,EAAE,QAAS,CAC5C,KAAM,CAAE,QAAAC,EAAS,SAAAC,EAAU,WAAAC,CAAW,EAAIH,EAAU,CAAC,EACrDJ,EAAI,QAAS,YAAa,CACxB,MAAOO,GAAY,QAAUF,GAAS,OAAO,OAC7C,UAAWC,EACX,SAAUD,GAAS,OAAO,aAC1B,aAAcA,GAAS,SAAS,MAChC,aAAc,gBACd,YAAa,OAAOA,GAAS,EAAE,EAC/B,iBAAkBA,GAAS,SAAS,YAAY,QAAQ,aAAe,QACzE,CAAC,CACH,CACF,EAQaG,EAAY,CAAC,CACxB,YAAAC,EACA,OAAAC,CACF,IAIM,CACJ,GAAI,CACED,GAAa,gBACfT,EAAI,cAAeS,GAAa,cAAc,EAG5CA,GAAa,iBACfP,EAAK,QAASO,GAAa,sBAAwB,aAAc,CAC/D,QAAS,GAAGC,CAAM,IAAID,GAAa,eAAe,EACpD,CAAC,CAEL,MAAgB,CAAC,CACnB",
|
|
6
|
+
"names": ["fbq", "args", "gtag", "addToCartFbq", "lineItems", "variant", "quantity", "finalPrice", "buyNowFbq", "trackConfig", "gtagId"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cart/utils/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { Attributes } from '../../shopify'\n\nexport const isAttributesEqual = (oldAttributes: Attributes, newAttributes: Attributes) => {\n // \u6BD4\u5BF9\u4E24\u4E2A\u6570\u636E\u662F\u5426\u5B8C\u5168\u76F8\u540C\n // \u68C0\u67E5\u6570\u7EC4\u957F\u5EA6\u662F\u5426\u76F8\u540C\n if (oldAttributes?.length !== newAttributes?.length) {\n return false\n }\n\n // \u5C06\u6570\u7EC4\u8F6C\u6362\u4E3A Map \u4EE5\u4FBF\u5FEB\u901F\u67E5\u627E\n const oldMap = new Map(oldAttributes.map(attr => [attr.key, attr.value]))\n const newMap = new Map(newAttributes.map(attr => [attr.key, attr.value]))\n\n // \u68C0\u67E5\u6240\u6709 key \u662F\u5426\u90FD\u5B58\u5728\u4E14\u503C\u76F8\u540C\n for (const [key, value] of newMap) {\n if (!oldMap.has(key) || oldMap.get(key) !== value) {\n return false\n }\n }\n\n return true\n}\n"],
|
|
5
|
+
"mappings": "AAEO,MAAMA,EAAoB,CAACC,EAA2BC,IAA8B,CAGzF,GAAID,GAAe,SAAWC,GAAe,OAC3C,MAAO,GAIT,MAAMC,EAAS,IAAI,IAAIF,EAAc,IAAIG,GAAQ,CAACA,EAAK,IAAKA,EAAK,KAAK,CAAC,CAAC,EAClEC,EAAS,IAAI,IAAIH,EAAc,IAAIE,GAAQ,CAACA,EAAK,IAAKA,EAAK,KAAK,CAAC,CAAC,EAGxE,SAAW,CAACE,EAAKC,CAAK,IAAKF,EACzB,GAAI,CAACF,EAAO,IAAIG,CAAG,GAAKH,EAAO,IAAIG,CAAG,IAAMC,EAC1C,MAAO,GAIX,MAAO,EACT",
|
|
6
|
+
"names": ["isAttributesEqual", "oldAttributes", "newAttributes", "oldMap", "attr", "newMap", "key", "value"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as a}from"react/jsx-runtime";import{createContext as t,useContext as n,useMemo as d}from"react";const s=t(null),c=({children:e,headlessConfig:o})=>{const r=d(()=>{if(!o)throw new Error("No site configuration or headless configuration found");return o},[o]);return a(s.Provider,{value:r,children:e})},f=()=>{const e=n(s);if(!e)throw new Error("useHeadlessContext must be used within a HeadlessProvider");return e||{}};export{c as HeadlessProvider,f as useHeadlessContext};
|
|
2
|
+
//# sourceMappingURL=HeadlessProvider.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/context/HeadlessProvider.tsx"],
|
|
4
|
+
"sourcesContent": ["import { createContext, useContext, useMemo, ReactNode } from 'react'\n\nimport { HeadlessConfig } from './config'\n\nconst HeadlessContext = createContext<HeadlessConfig | null>(null)\n\ninterface HeadlessProviderProps {\n children: ReactNode\n headlessConfig: HeadlessConfig\n}\n\nexport const HeadlessProvider = ({ children, headlessConfig }: HeadlessProviderProps): JSX.Element => {\n const contextValue = useMemo((): HeadlessConfig => {\n if (!headlessConfig) {\n throw new Error(`No site configuration or headless configuration found`)\n }\n\n return headlessConfig\n }, [headlessConfig])\n\n return <HeadlessContext.Provider value={contextValue}>{children}</HeadlessContext.Provider>\n}\n\nexport const useHeadlessContext = (): HeadlessConfig => {\n const context = useContext(HeadlessContext)\n if (!context) {\n throw new Error('useHeadlessContext must be used within a HeadlessProvider')\n }\n return context || ({} as HeadlessConfig)\n}\n"],
|
|
5
|
+
"mappings": "AAoBS,cAAAA,MAAA,oBApBT,OAAS,iBAAAC,EAAe,cAAAC,EAAY,WAAAC,MAA0B,QAI9D,MAAMC,EAAkBH,EAAqC,IAAI,EAOpDI,EAAmB,CAAC,CAAE,SAAAC,EAAU,eAAAC,CAAe,IAA0C,CACpG,MAAMC,EAAeL,EAAQ,IAAsB,CACjD,GAAI,CAACI,EACH,MAAM,IAAI,MAAM,uDAAuD,EAGzE,OAAOA,CACT,EAAG,CAACA,CAAc,CAAC,EAEnB,OAAOP,EAACI,EAAgB,SAAhB,CAAyB,MAAOI,EAAe,SAAAF,EAAS,CAClE,EAEaG,EAAqB,IAAsB,CACtD,MAAMC,EAAUR,EAAWE,CAAe,EAC1C,GAAI,CAACM,EACH,MAAM,IAAI,MAAM,2DAA2D,EAE7E,OAAOA,GAAY,CAAC,CACtB",
|
|
6
|
+
"names": ["jsx", "createContext", "useContext", "useMemo", "HeadlessContext", "HeadlessProvider", "children", "headlessConfig", "contextValue", "useHeadlessContext", "context"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export*from"./context";export*from"./shopify/fetchers";export*from"./shopify/hooks";export*from"./shopify/queries";export*from"./shopify/fragments";export*from"./shopify/types";export*from"./cart/hooks/basic/useBuyNow";export*from"./cart/types";export*from"./cart/utils";export*from"./cart/const";export*from"./cart/track/fbq";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// ========================================\n// Context (from shared)\n// ========================================\nexport * from './context'\n\n// ========================================\n// Shopify Integration\n// ========================================\nexport * from './shopify/fetchers'\nexport * from './shopify/hooks'\nexport * from './shopify/queries'\nexport * from './shopify/fragments'\nexport * from './shopify/types'\n\n// ========================================\n// Cart Utilities\n// ========================================\nexport * from './cart/hooks/basic/useBuyNow'\nexport * from './cart/types'\nexport * from './cart/utils'\nexport * from './cart/const'\nexport * from './cart/track/fbq'\n"],
|
|
5
|
+
"mappings": "AAGA,WAAc,YAKd,WAAc,qBACd,WAAc,kBACd,WAAc,oBACd,WAAc,sBACd,WAAc,kBAKd,WAAc,+BACd,WAAc,eACd,WAAc,eACd,WAAc,eACd,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{addCartLinesMutation as a}from"../mutations/add-cart-lines";import{fetchGraphqlApi as s}from"../utils/fetch-graphql-api";import{normalizeCart as d}from"../utils/normalize";const M=async function({options:t,config:o}){const{data:r}=await s({query:a,variables:{cartId:t.cartId,lines:t.lines},config:o});if(r?.cartLinesAdd?.userErrors?.length){const e=r.cartLinesAdd.userErrors.find(n=>n.field?.includes("quantity"));if(e)return Promise.reject(e);throw new Error(JSON.stringify(r?.cartLinesAdd?.userErrors))}const i=r?.cartLinesAdd?.cart;if(i)return d(i,"")};export{M as addCartLines};
|
|
2
|
+
//# sourceMappingURL=add-cart-lines.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fetchers/add-cart-lines.ts"],
|
|
4
|
+
"sourcesContent": ["import { CartLinesAddPayload, MutationCartLinesAddArgs } from '../gql'\nimport { addCartLinesMutation } from '../mutations/add-cart-lines'\nimport type { Cart } from '../types/cart'\nimport { ShopifyFetcher } from '../types/fetcher'\nimport { fetchGraphqlApi } from '../utils/fetch-graphql-api'\nimport { normalizeCart } from '../utils/normalize'\nimport { ShopifyConfig } from '../types/config'\nimport { Optional } from '../types/type-helper'\n/**\n * Adds cart lines to the Shopify cart.\n *\n * @param options - The options for adding cart lines.\n * @param config - The store configuration.\n * @returns The updated cart or undefined if the cart could not be updated.\n */\nexport const addCartLines: ShopifyFetcher<Cart | undefined, MutationCartLinesAddArgs> = async function ({\n options,\n config,\n}: {\n options: MutationCartLinesAddArgs\n config: ShopifyConfig\n}) {\n const { data } = await fetchGraphqlApi<\n { cartLinesAdd: CartLinesAddPayload },\n Optional<MutationCartLinesAddArgs, 'cartId'>\n >({\n query: addCartLinesMutation,\n variables: {\n cartId: options.cartId,\n lines: options.lines,\n },\n config,\n })\n\n if (data?.cartLinesAdd?.userErrors?.length) {\n const errors = data.cartLinesAdd.userErrors\n const quantityError = errors.find(error => error.field?.includes('quantity'))\n if (quantityError) {\n // The quantity of the line item is invalid.\n return Promise.reject(quantityError)\n } else {\n throw new Error(JSON.stringify(data?.cartLinesAdd?.userErrors))\n }\n }\n\n const cart = data?.cartLinesAdd?.cart\n\n if (cart) {\n return normalizeCart(cart, '')\n } else {\n return undefined\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,wBAAAA,MAA4B,8BAGrC,OAAS,mBAAAC,MAAuB,6BAChC,OAAS,iBAAAC,MAAqB,qBAUvB,MAAMC,EAA2E,eAAgB,CACtG,QAAAC,EACA,OAAAC,CACF,EAGG,CACD,KAAM,CAAE,KAAAC,CAAK,EAAI,MAAML,EAGrB,CACA,MAAOD,EACP,UAAW,CACT,OAAQI,EAAQ,OAChB,MAAOA,EAAQ,KACjB,EACA,OAAAC,CACF,CAAC,EAED,GAAIC,GAAM,cAAc,YAAY,OAAQ,CAE1C,MAAMC,EADSD,EAAK,aAAa,WACJ,KAAKE,GAASA,EAAM,OAAO,SAAS,UAAU,CAAC,EAC5E,GAAID,EAEF,OAAO,QAAQ,OAAOA,CAAa,EAEnC,MAAM,IAAI,MAAM,KAAK,UAAUD,GAAM,cAAc,UAAU,CAAC,CAElE,CAEA,MAAMG,EAAOH,GAAM,cAAc,KAEjC,GAAIG,EACF,OAAOP,EAAcO,EAAM,EAAE,CAIjC",
|
|
6
|
+
"names": ["addCartLinesMutation", "fetchGraphqlApi", "normalizeCart", "addCartLines", "options", "config", "data", "quantityError", "error", "cart"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createCartMutation as f}from"../mutations/create-cart";import{fetchGraphqlApi as m}from"../utils/fetch-graphql-api";import{normalizeCart as p}from"../utils/normalize";import{constructMetafieldIdentifiersQueryParams as s}from"../utils/helper";const P=async function({options:o,config:i}){const{comboMetafieldsNamespace:t,metafieldIdentifiers:r,...e}=o;if(!e.lines?.length)throw new Error("Invalid input used for this operation: Miss lines");const{data:n}=await m({query:f,variables:{...e,...r&&{...s(r,t)}},config:i}),a=n?.cartCreate?.cart;if(a)return p(a,t)};export{P as createCart};
|
|
2
|
+
//# sourceMappingURL=create-cart.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fetchers/create-cart.ts"],
|
|
4
|
+
"sourcesContent": ["import { CartCreatePayload, CartInput } from '../gql'\nimport { createCartMutation } from '../mutations/create-cart'\nimport type { Cart } from '../types/cart'\nimport { ShopifyFetcher } from '../types/fetcher'\nimport { fetchGraphqlApi } from '../utils/fetch-graphql-api'\nimport { normalizeCart } from '../utils/normalize'\nimport { GetCartMetafieldQueryRoot } from './get-cart'\nimport { constructMetafieldIdentifiersQueryParams } from '../utils/helper'\n\n/**\n * Creates a cart using the Shopify API.\n *\n * @param options - The options for the cart.\n * @param config - The store configuration.\n * @returns The created cart or undefined if the cart creation fails.\n */\nexport const createCart: ShopifyFetcher<Cart | undefined, CartInput, GetCartMetafieldQueryRoot> = async function ({\n options,\n config,\n}) {\n const { comboMetafieldsNamespace, metafieldIdentifiers, ...rest } = options\n if (!rest.lines?.length) {\n throw new Error('Invalid input used for this operation: Miss lines')\n }\n const { data } = await fetchGraphqlApi<{ cartCreate: CartCreatePayload }, CartInput>({\n query: createCartMutation,\n variables: {\n ...rest,\n ...(metafieldIdentifiers && {\n ...constructMetafieldIdentifiersQueryParams(metafieldIdentifiers, comboMetafieldsNamespace),\n }),\n },\n config,\n })\n\n const cart = data?.cartCreate?.cart\n\n if (cart) {\n return normalizeCart(cart, comboMetafieldsNamespace)\n } else {\n return undefined\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,sBAAAA,MAA0B,2BAGnC,OAAS,mBAAAC,MAAuB,6BAChC,OAAS,iBAAAC,MAAqB,qBAE9B,OAAS,4CAAAC,MAAgD,kBASlD,MAAMC,EAAqF,eAAgB,CAChH,QAAAC,EACA,OAAAC,CACF,EAAG,CACD,KAAM,CAAE,yBAAAC,EAA0B,qBAAAC,EAAsB,GAAGC,CAAK,EAAIJ,EACpE,GAAI,CAACI,EAAK,OAAO,OACf,MAAM,IAAI,MAAM,mDAAmD,EAErE,KAAM,CAAE,KAAAC,CAAK,EAAI,MAAMT,EAA8D,CACnF,MAAOD,EACP,UAAW,CACT,GAAGS,EACH,GAAID,GAAwB,CAC1B,GAAGL,EAAyCK,EAAsBD,CAAwB,CAC5F,CACF,EACA,OAAAD,CACF,CAAC,EAEKK,EAAOD,GAAM,YAAY,KAE/B,GAAIC,EACF,OAAOT,EAAcS,EAAMJ,CAAwB,CAIvD",
|
|
6
|
+
"names": ["createCartMutation", "fetchGraphqlApi", "normalizeCart", "constructMetafieldIdentifiersQueryParams", "createCart", "options", "config", "comboMetafieldsNamespace", "metafieldIdentifiers", "rest", "data", "cart"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{fetchGraphqlApi as f}from"../utils/fetch-graphql-api";import{normalizeCart as s}from"../utils/normalize";import{getCartQuery as p}from"../queries/get-cart";import{constructMetafieldIdentifiersQueryParams as d}from"../utils/helper";const R=async function({options:r,config:a}){const{comboMetafieldsNamespace:t,metafieldIdentifiers:o,cartId:e}=r;if(!e)throw new Error("Invalid input used for this operation: Miss cartId");const{data:i}=await f({query:p,variables:{cartId:e,...d(o,t)},config:a});return s(i.cart,t)};export{R as getCart};
|
|
2
|
+
//# sourceMappingURL=get-cart.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fetchers/get-cart.ts"],
|
|
4
|
+
"sourcesContent": ["import { Cart, GetCartQueryVariables } from '../gql'\nimport type { Cart as ExportCart } from '../types/cart'\nimport {\n HasMetafieldQueryRoot,\n metafieldIdentifiersGroup,\n ShopifyFetcher,\n ShopifyFetcherVariables,\n} from '../types/fetcher'\nimport { fetchGraphqlApi } from '../utils/fetch-graphql-api'\nimport { normalizeCart } from '../utils/normalize'\nimport { getCartQuery } from '../queries/get-cart'\nimport { constructMetafieldIdentifiersQueryParams } from '../utils/helper'\n\nexport type GetCartMetafieldQueryRoot = HasMetafieldQueryRoot.Product | HasMetafieldQueryRoot.Variant\n\nexport type GetCartReq = {\n cartId: string\n} & metafieldIdentifiersGroup<GetCartMetafieldQueryRoot>\n\n/**\n * Fetches the cart from Shopify.\n *\n * @param options - The options for fetching the cart.\n * @param config - The store configuration.\n * @returns The fetched cart or undefined if not found.\n */\nexport const getCart: ShopifyFetcher<ExportCart | undefined, GetCartQueryVariables, GetCartMetafieldQueryRoot> =\n async function ({ options, config }) {\n const { comboMetafieldsNamespace: metafieldsNamespace, metafieldIdentifiers, cartId } = options\n\n if (!cartId) {\n throw new Error('Invalid input used for this operation: Miss cartId')\n }\n\n const { data } = await fetchGraphqlApi<\n { cart: Cart },\n ShopifyFetcherVariables<GetCartQueryVariables, GetCartMetafieldQueryRoot>\n >({\n query: getCartQuery,\n variables: {\n cartId,\n ...constructMetafieldIdentifiersQueryParams(metafieldIdentifiers, metafieldsNamespace),\n },\n config,\n })\n\n return normalizeCart(data.cart, metafieldsNamespace)\n }\n"],
|
|
5
|
+
"mappings": "AAQA,OAAS,mBAAAA,MAAuB,6BAChC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,gBAAAC,MAAoB,sBAC7B,OAAS,4CAAAC,MAAgD,kBAelD,MAAMC,EACX,eAAgB,CAAE,QAAAC,EAAS,OAAAC,CAAO,EAAG,CACnC,KAAM,CAAE,yBAA0BC,EAAqB,qBAAAC,EAAsB,OAAAC,CAAO,EAAIJ,EAExF,GAAI,CAACI,EACH,MAAM,IAAI,MAAM,oDAAoD,EAGtE,KAAM,CAAE,KAAAC,CAAK,EAAI,MAAMV,EAGrB,CACA,MAAOE,EACP,UAAW,CACT,OAAAO,EACA,GAAGN,EAAyCK,EAAsBD,CAAmB,CACvF,EACA,OAAAD,CACF,CAAC,EAED,OAAOL,EAAcS,EAAK,KAAMH,CAAmB,CACrD",
|
|
6
|
+
"names": ["fetchGraphqlApi", "normalizeCart", "getCartQuery", "constructMetafieldIdentifiersQueryParams", "getCart", "options", "config", "metafieldsNamespace", "metafieldIdentifiers", "cartId", "data"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getProductsByHandlesQuery as s}from"../queries/get-product-by-handles";import{fetchGraphqlApi as c}from"../utils/fetch-graphql-api";import{constructMetafieldIdentifiersQueryParams as u}from"../utils/helper";import{normalizeProduct as f}from"../utils/normalize/product";const q=async({options:r,config:o})=>{const{handles:e,metafieldIdentifiers:a,comboMetafieldsNamespace:d}=r;if(!e?.length)throw new Error("Handles are required");const i=await c({query:s(e),variables:{handles:e,...u(a,d)},config:o});return Object.values(i.data).filter(t=>!!t).map(t=>f(t,""))};export{q as getProductsByHandles};
|
|
2
|
+
//# sourceMappingURL=get-products-by-handles.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fetchers/get-products-by-handles.ts"],
|
|
4
|
+
"sourcesContent": ["import { getProductsByHandlesQuery } from '../queries/get-product-by-handles'\nimport { fetchGraphqlApi } from '../utils/fetch-graphql-api'\nimport { constructMetafieldIdentifiersQueryParams } from '../utils/helper'\nimport { normalizeProduct } from '../utils/normalize/product'\nimport { Product as ShopifyProduct } from '../gql'\nimport { HasMetafieldQueryRoot, ShopifyFetcher, ShopifyFetcherVariables } from '../types/fetcher'\nimport { Product } from '../types/product'\n\nexport type GetProductsMetafieldQueryRoot = HasMetafieldQueryRoot.Product | HasMetafieldQueryRoot.Variant\n\nexport type GetProductsByHandlesReq = {\n handles: string[]\n}\n\n/**\n * Gets products by their handles.\n *\n * @param options - The options for getting products.\n * @param config - The store configuration.\n * @returns An array of products.\n */\nexport const getProductsByHandles: ShopifyFetcher<\n Product[],\n GetProductsByHandlesReq,\n GetProductsMetafieldQueryRoot\n> = async ({ options, config }) => {\n const { handles, metafieldIdentifiers, comboMetafieldsNamespace } = options\n\n if (!handles?.length) {\n throw new Error('Handles are required')\n }\n\n const products = await fetchGraphqlApi<\n Record<string, ShopifyProduct>,\n ShopifyFetcherVariables<GetProductsByHandlesReq, GetProductsMetafieldQueryRoot>\n >({\n query: getProductsByHandlesQuery(handles),\n variables: {\n handles,\n ...constructMetafieldIdentifiersQueryParams(metafieldIdentifiers, comboMetafieldsNamespace),\n },\n config,\n })\n\n return Object.values(products.data)\n .filter(item => !!item)\n .map(product => normalizeProduct(product, '')) as Product[]\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,6BAAAA,MAAiC,oCAC1C,OAAS,mBAAAC,MAAuB,6BAChC,OAAS,4CAAAC,MAAgD,kBACzD,OAAS,oBAAAC,MAAwB,6BAkB1B,MAAMC,EAIT,MAAO,CAAE,QAAAC,EAAS,OAAAC,CAAO,IAAM,CACjC,KAAM,CAAE,QAAAC,EAAS,qBAAAC,EAAsB,yBAAAC,CAAyB,EAAIJ,EAEpE,GAAI,CAACE,GAAS,OACZ,MAAM,IAAI,MAAM,sBAAsB,EAGxC,MAAMG,EAAW,MAAMT,EAGrB,CACA,MAAOD,EAA0BO,CAAO,EACxC,UAAW,CACT,QAAAA,EACA,GAAGL,EAAyCM,EAAsBC,CAAwB,CAC5F,EACA,OAAAH,CACF,CAAC,EAED,OAAO,OAAO,OAAOI,EAAS,IAAI,EAC/B,OAAOC,GAAQ,CAAC,CAACA,CAAI,EACrB,IAAIC,GAAWT,EAAiBS,EAAS,EAAE,CAAC,CACjD",
|
|
6
|
+
"names": ["getProductsByHandlesQuery", "fetchGraphqlApi", "constructMetafieldIdentifiersQueryParams", "normalizeProduct", "getProductsByHandles", "options", "config", "handles", "metafieldIdentifiers", "comboMetafieldsNamespace", "products", "item", "product"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getProductsByHandles as r}from"./get-products-by-handles";import{addCartLines as a}from"./add-cart-lines";import{createCart as d}from"./create-cart";import{removeCartLines as s}from"./remove-cart-lines";import{updateCartAttributes as u}from"./update-cart-attributes";import{updateCartLines as C}from"./update-cart-lines";import{getCart as c}from"./get-cart";export{a as addCartLines,d as createCart,c as getCart,r as getProductsByHandles,s as removeCartLines,u as updateCartAttributes,C as updateCartLines};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fetchers/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { getProductsByHandles } from './get-products-by-handles'\nexport { addCartLines } from './add-cart-lines'\nexport { createCart } from './create-cart'\nexport { removeCartLines } from './remove-cart-lines'\nexport { updateCartAttributes } from './update-cart-attributes'\nexport { updateCartLines } from './update-cart-lines'\nexport { getCart } from './get-cart'\n\nexport type { GetProductsByHandlesReq, GetProductsMetafieldQueryRoot } from './get-products-by-handles'\nexport type { GetCartReq, GetCartMetafieldQueryRoot } from './get-cart'\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,wBAAAA,MAA4B,4BACrC,OAAS,gBAAAC,MAAoB,mBAC7B,OAAS,cAAAC,MAAkB,gBAC3B,OAAS,mBAAAC,MAAuB,sBAChC,OAAS,wBAAAC,MAA4B,2BACrC,OAAS,mBAAAC,MAAuB,sBAChC,OAAS,WAAAC,MAAe",
|
|
6
|
+
"names": ["getProductsByHandles", "addCartLines", "createCart", "removeCartLines", "updateCartAttributes", "updateCartLines", "getCart"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{removeCartItemsMutation as a}from"../mutations/remove-cart-items";import{fetchGraphqlApi as o}from"../utils/fetch-graphql-api";import{normalizeCart as i}from"../utils/normalize";const d=async function({options:t,config:e}){const{data:r}=await o({query:a,variables:t,config:e});if(r?.cartLinesRemove?.cart)return i(r.cartLinesRemove.cart,"")};export{d as removeCartLines};
|
|
2
|
+
//# sourceMappingURL=remove-cart-lines.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fetchers/remove-cart-lines.ts"],
|
|
4
|
+
"sourcesContent": ["import { Cart, MutationCartLinesRemoveArgs } from '../gql'\nimport { removeCartItemsMutation } from '../mutations/remove-cart-items'\nimport type { Cart as ExportCart } from '../types/cart'\nimport { ShopifyFetcher } from '../types/fetcher'\nimport { fetchGraphqlApi } from '../utils/fetch-graphql-api'\nimport { normalizeCart } from '../utils/normalize'\n\n/**\n * Removes cart lines from the Shopify API.\n *\n * @param options - The options for removing cart lines.\n * @param config - The store configuration.\n * @returns The normalized cart after removing the cart lines, or undefined if the operation fails.\n */\nexport const removeCartLines: ShopifyFetcher<ExportCart | undefined, MutationCartLinesRemoveArgs> = async function ({\n options,\n config,\n}) {\n const { data } = await fetchGraphqlApi<{ cartLinesRemove: { cart: Cart } }, MutationCartLinesRemoveArgs>({\n query: removeCartItemsMutation,\n variables: options,\n config,\n })\n\n if (data?.cartLinesRemove?.cart) {\n const normalizedCart = normalizeCart(data.cartLinesRemove.cart, '')\n return normalizedCart\n } else {\n return undefined\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,2BAAAA,MAA+B,iCAGxC,OAAS,mBAAAC,MAAuB,6BAChC,OAAS,iBAAAC,MAAqB,qBASvB,MAAMC,EAAuF,eAAgB,CAClH,QAAAC,EACA,OAAAC,CACF,EAAG,CACD,KAAM,CAAE,KAAAC,CAAK,EAAI,MAAML,EAAkF,CACvG,MAAOD,EACP,UAAWI,EACX,OAAAC,CACF,CAAC,EAED,GAAIC,GAAM,iBAAiB,KAEzB,OADuBJ,EAAcI,EAAK,gBAAgB,KAAM,EAAE,CAKtE",
|
|
6
|
+
"names": ["removeCartItemsMutation", "fetchGraphqlApi", "normalizeCart", "removeCartLines", "options", "config", "data"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{fetchGraphqlApi as e}from"../utils/fetch-graphql-api";import{normalizeCart as i}from"../utils/normalize";import{updateCartAttributesMutation as o}from"../mutations/update-cart-attributes";const A=async function({options:r,config:a}){const{data:t}=await e({query:o,variables:r,config:a});if(t?.cartAttributesUpdate?.cart)return i(t.cartAttributesUpdate.cart,"")};export{A as updateCartAttributes};
|
|
2
|
+
//# sourceMappingURL=update-cart-attributes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fetchers/update-cart-attributes.ts"],
|
|
4
|
+
"sourcesContent": ["import { Cart, MutationCartAttributesUpdateArgs } from '../gql'\nimport type { Cart as ExportCart } from '../types/cart'\nimport { ShopifyFetcher } from '../types/fetcher'\nimport { fetchGraphqlApi } from '../utils/fetch-graphql-api'\nimport { normalizeCart } from '../utils/normalize'\nimport { updateCartAttributesMutation } from '../mutations/update-cart-attributes'\n\n/**\n * Updates the attributes of a cart.\n *\n * @param options - The options for updating the cart attributes.\n * @param config - The store configuration.\n * @returns The updated cart or undefined if the update was unsuccessful.\n */\nexport const updateCartAttributes: ShopifyFetcher<ExportCart | undefined, MutationCartAttributesUpdateArgs> =\n async function ({ options, config }) {\n const { data } = await fetchGraphqlApi<{ cartAttributesUpdate: { cart: Cart } }, MutationCartAttributesUpdateArgs>({\n query: updateCartAttributesMutation,\n variables: options,\n config,\n })\n\n if (data?.cartAttributesUpdate?.cart) {\n const normalizedCart = normalizeCart(data.cartAttributesUpdate.cart, '')\n return normalizedCart\n } else {\n return undefined\n }\n }\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,mBAAAA,MAAuB,6BAChC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,gCAAAC,MAAoC,sCAStC,MAAMC,EACX,eAAgB,CAAE,QAAAC,EAAS,OAAAC,CAAO,EAAG,CACnC,KAAM,CAAE,KAAAC,CAAK,EAAI,MAAMN,EAA4F,CACjH,MAAOE,EACP,UAAWE,EACX,OAAAC,CACF,CAAC,EAED,GAAIC,GAAM,sBAAsB,KAE9B,OADuBL,EAAcK,EAAK,qBAAqB,KAAM,EAAE,CAK3E",
|
|
6
|
+
"names": ["fetchGraphqlApi", "normalizeCart", "updateCartAttributesMutation", "updateCartAttributes", "options", "config", "data"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{fetchGraphqlApi as a}from"../utils/fetch-graphql-api";import{normalizeCart as i}from"../utils/normalize";import{updateCartBuyerIdentityMutation as o}from"../mutations/update-cart-buyer-identity";const s=async function({options:r,config:e}){const{data:t}=await a({query:o,variables:r,config:e});if(t?.cartBuyerIdentityUpdate?.cart)return i(t.cartBuyerIdentityUpdate.cart,"")};export{s as updateCartBuyerIdentity};
|
|
2
|
+
//# sourceMappingURL=update-cart-buyer-identity.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fetchers/update-cart-buyer-identity.ts"],
|
|
4
|
+
"sourcesContent": ["import { Cart, MutationCartBuyerIdentityUpdateArgs } from '../gql'\nimport type { Cart as ExportCart } from '../types/cart'\nimport { ShopifyFetcher } from '../types/fetcher'\nimport { fetchGraphqlApi } from '../utils/fetch-graphql-api'\nimport { normalizeCart } from '../utils/normalize'\nimport { updateCartBuyerIdentityMutation } from '../mutations/update-cart-buyer-identity'\n\n/**\n * Updates the buyer identity of a cart.\n *\n * @param options - The options for updating the cart buyer identity.\n * @param config - The store configuration.\n * @returns The updated cart or undefined if the update was unsuccessful.\n */\nexport const updateCartBuyerIdentity: ShopifyFetcher<ExportCart | undefined, MutationCartBuyerIdentityUpdateArgs> =\n async function ({ options, config }) {\n const { data } = await fetchGraphqlApi<\n { cartBuyerIdentityUpdate: { cart: Cart } },\n MutationCartBuyerIdentityUpdateArgs\n >({\n query: updateCartBuyerIdentityMutation,\n variables: options,\n config,\n })\n\n if (data?.cartBuyerIdentityUpdate?.cart) {\n const normalizedCart = normalizeCart(data.cartBuyerIdentityUpdate.cart, '')\n return normalizedCart\n } else {\n return undefined\n }\n }\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,mBAAAA,MAAuB,6BAChC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,mCAAAC,MAAuC,0CASzC,MAAMC,EACX,eAAgB,CAAE,QAAAC,EAAS,OAAAC,CAAO,EAAG,CACnC,KAAM,CAAE,KAAAC,CAAK,EAAI,MAAMN,EAGrB,CACA,MAAOE,EACP,UAAWE,EACX,OAAAC,CACF,CAAC,EAED,GAAIC,GAAM,yBAAyB,KAEjC,OADuBL,EAAcK,EAAK,wBAAwB,KAAM,EAAE,CAK9E",
|
|
6
|
+
"names": ["fetchGraphqlApi", "normalizeCart", "updateCartBuyerIdentityMutation", "updateCartBuyerIdentity", "options", "config", "data"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{fetchGraphqlApi as o}from"../utils/fetch-graphql-api";import{normalizeCart as e}from"../utils/normalize";import{updateCartDiscountCodeMutation as i}from"../mutations/update-cart-discount-code";const m=async function({options:r,config:a}){const{data:t}=await o({query:i,variables:r,config:a});if(t.cartDiscountCodesUpdate.cart)return e(t.cartDiscountCodesUpdate.cart,"")};export{m as updateCartCodes};
|
|
2
|
+
//# sourceMappingURL=update-cart-codes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fetchers/update-cart-codes.ts"],
|
|
4
|
+
"sourcesContent": ["import { Cart, MutationCartDiscountCodesUpdateArgs } from '../gql'\nimport type { Cart as ExportCart } from '../types/cart'\nimport { ShopifyFetcher } from '../types/fetcher'\nimport { fetchGraphqlApi } from '../utils/fetch-graphql-api'\nimport { normalizeCart } from '../utils/normalize'\nimport { updateCartDiscountCodeMutation } from '../mutations/update-cart-discount-code'\n\n/**\n * Updates the discount codes for a cart in the Shopify API.\n *\n * @param options - The options for updating the cart discount codes.\n * @param config - The store configuration.\n * @returns The updated cart or undefined if the update was unsuccessful.\n */\nexport const updateCartCodes: ShopifyFetcher<ExportCart | undefined, MutationCartDiscountCodesUpdateArgs> =\n async function ({ options, config }) {\n const { data } = await fetchGraphqlApi<\n {\n cartDiscountCodesUpdate: { cart: Cart }\n },\n MutationCartDiscountCodesUpdateArgs\n >({\n query: updateCartDiscountCodeMutation,\n variables: options,\n config,\n })\n if (data.cartDiscountCodesUpdate.cart) {\n return normalizeCart(data.cartDiscountCodesUpdate.cart, '')\n } else {\n return undefined\n }\n }\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,mBAAAA,MAAuB,6BAChC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,kCAAAC,MAAsC,yCASxC,MAAMC,EACX,eAAgB,CAAE,QAAAC,EAAS,OAAAC,CAAO,EAAG,CACnC,KAAM,CAAE,KAAAC,CAAK,EAAI,MAAMN,EAKrB,CACA,MAAOE,EACP,UAAWE,EACX,OAAAC,CACF,CAAC,EACD,GAAIC,EAAK,wBAAwB,KAC/B,OAAOL,EAAcK,EAAK,wBAAwB,KAAM,EAAE,CAI9D",
|
|
6
|
+
"names": ["fetchGraphqlApi", "normalizeCart", "updateCartDiscountCodeMutation", "updateCartCodes", "options", "config", "data"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{fetchGraphqlApi as o}from"../utils/fetch-graphql-api";import{normalizeCart as s}from"../utils/normalize";import{updateCartLinesMutation as p}from"../mutations/update-cart-items";const l=async function({options:e,config:a}){const{data:r}=await o({query:p,variables:e,config:a});if(r?.cartLinesUpdate?.userErrors?.length){const t=(r.cartLinesUpdate?.userErrors).find(n=>n.field?.includes("quantity"));if(t)return Promise.reject(t)}if(r?.cartLinesUpdate?.cart)return s(r.cartLinesUpdate.cart,"")};export{l as updateCartLines};
|
|
2
|
+
//# sourceMappingURL=update-cart-lines.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fetchers/update-cart-lines.ts"],
|
|
4
|
+
"sourcesContent": ["import { Cart, MutationCartLinesUpdateArgs } from '../gql'\nimport type { Cart as ExportCart } from '../types/cart'\nimport { ShopifyFetcher } from '../types/fetcher'\nimport { fetchGraphqlApi } from '../utils/fetch-graphql-api'\nimport { normalizeCart } from '../utils/normalize'\nimport { updateCartLinesMutation } from '../mutations/update-cart-items'\n\n/**\n * Updates the cart lines in the Shopify API.\n *\n * @param options - The options for updating the cart lines.\n * @param config - The store configuration.\n * @returns The updated cart or undefined if the update was unsuccessful.\n */\nexport const updateCartLines: ShopifyFetcher<ExportCart | undefined, MutationCartLinesUpdateArgs> = async function ({\n options,\n config,\n}) {\n const { data } = await fetchGraphqlApi<\n { cartLinesUpdate: { cart: Cart; userErrors?: any } },\n MutationCartLinesUpdateArgs\n >({\n query: updateCartLinesMutation,\n variables: options,\n config,\n })\n\n if (data?.cartLinesUpdate?.userErrors?.length) {\n const errors = data.cartLinesUpdate?.userErrors\n const quantityError = errors.find((error: any) => error.field?.includes('quantity'))\n if (quantityError) {\n return Promise.reject(quantityError)\n }\n }\n\n if (data?.cartLinesUpdate?.cart) {\n const normalizedCart = normalizeCart(data.cartLinesUpdate.cart, '')\n return normalizedCart\n } else {\n return undefined\n }\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,mBAAAA,MAAuB,6BAChC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,2BAAAC,MAA+B,iCASjC,MAAMC,EAAuF,eAAgB,CAClH,QAAAC,EACA,OAAAC,CACF,EAAG,CACD,KAAM,CAAE,KAAAC,CAAK,EAAI,MAAMN,EAGrB,CACA,MAAOE,EACP,UAAWE,EACX,OAAAC,CACF,CAAC,EAED,GAAIC,GAAM,iBAAiB,YAAY,OAAQ,CAE7C,MAAMC,GADSD,EAAK,iBAAiB,YACR,KAAME,GAAeA,EAAM,OAAO,SAAS,UAAU,CAAC,EACnF,GAAID,EACF,OAAO,QAAQ,OAAOA,CAAa,CAEvC,CAEA,GAAID,GAAM,iBAAiB,KAEzB,OADuBL,EAAcK,EAAK,gBAAgB,KAAM,EAAE,CAKtE",
|
|
6
|
+
"names": ["fetchGraphqlApi", "normalizeCart", "updateCartLinesMutation", "updateCartLines", "options", "config", "data", "quantityError", "error"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const e=`
|
|
2
|
+
fragment article on Article {
|
|
3
|
+
id
|
|
4
|
+
handle
|
|
5
|
+
title
|
|
6
|
+
seo {
|
|
7
|
+
...seo
|
|
8
|
+
}
|
|
9
|
+
image {
|
|
10
|
+
...image
|
|
11
|
+
}
|
|
12
|
+
tags
|
|
13
|
+
publishedAt
|
|
14
|
+
content
|
|
15
|
+
contentHtml
|
|
16
|
+
excerpt
|
|
17
|
+
excerptHtml
|
|
18
|
+
authorV2 {
|
|
19
|
+
bio
|
|
20
|
+
email
|
|
21
|
+
firstName
|
|
22
|
+
lastName
|
|
23
|
+
name
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`,t=`
|
|
27
|
+
fragment article on Article {
|
|
28
|
+
id
|
|
29
|
+
handle
|
|
30
|
+
title
|
|
31
|
+
seo {
|
|
32
|
+
...seo
|
|
33
|
+
}
|
|
34
|
+
image {
|
|
35
|
+
...image
|
|
36
|
+
}
|
|
37
|
+
tags
|
|
38
|
+
publishedAt
|
|
39
|
+
excerpt
|
|
40
|
+
excerptHtml
|
|
41
|
+
authorV2 {
|
|
42
|
+
bio
|
|
43
|
+
email
|
|
44
|
+
firstName
|
|
45
|
+
lastName
|
|
46
|
+
name
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;export{e as articleFragment,t as articleWithoutContentFragment};
|
|
50
|
+
//# sourceMappingURL=article.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fragments/article.ts"],
|
|
4
|
+
"sourcesContent": ["export const articleFragment = /* GraphQL */ `\n fragment article on Article {\n id\n handle\n title\n seo {\n ...seo\n }\n image {\n ...image\n }\n tags\n publishedAt\n content\n contentHtml\n excerpt\n excerptHtml\n authorV2 {\n bio\n email\n firstName\n lastName\n name\n }\n }\n`\n\nexport const articleWithoutContentFragment = /* GraphQL */ `\n fragment article on Article {\n id\n handle\n title\n seo {\n ...seo\n }\n image {\n ...image\n }\n tags\n publishedAt\n excerpt\n excerptHtml\n authorV2 {\n bio\n email\n firstName\n lastName\n name\n }\n }\n`\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BhCC,EAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": ["articleFragment", "articleWithoutContentFragment"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/shopify/fragments/blog.ts"],
|
|
4
|
+
"sourcesContent": ["export const blogFragment = /* GraphQL */ `\n fragment blog on Blog {\n id\n handle\n title\n seo {\n ...seo\n }\n }\n`\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": ["blogFragment"]
|
|
7
|
+
}
|