{"_id":"@bareblends/shopify-buy","_rev":"1-03fe7796454209e69fbe86d42600f2b8","name":"@bareblends/shopify-buy","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@bareblends/shopify-buy","version":"0.0.1","description":"The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website. It is based on Shopify's API and provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.","main":"index.js","jsnext:main":"index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/Shopify/js-buy-sdk.git"},"publishConfig":{"access":"public","@shopify:registry":"https://registry.npmjs.org/"},"scripts":{"prepublish":"yarn run build","build":"yarn run build:optimized && yarn run build:unoptimized","build:optimized":"rollup -c && yarn run minify-umd:optimized","build:unoptimized":"rollup -c rollup-unoptimized.config.js && yarn run minify-umd:unoptimized","start":"yarn run clean && yarn run setup-paths && concurrently --names DEPS,LIVERELOAD,ROLLUP,HTTP,NOTIFIER 'yarn run test:web-deps' 'yarn run test:livereload-server' 'yarn run test:watch' 'http-server -p 4200 .tmp/test' 'yarn run print-start-message'","clean":"rimraf .tmp index.*","doc:build":"jsdoc -c jsdoc.json","doc:serve":"http-server -p 4201 ./docs","setup-paths":"mkdir -p .tmp/test","test":"yarn run clean && yarn run setup-paths && yarn run test:node-deps && yarn run mocha","test:watch":"rollup -w -c rollup-browser-tests.config.js","test:web-deps":"cp test/index.html node_modules/mocha/mocha.* node_modules/jquery/dist/jquery.slim.min.js .tmp/test/ && cp node_modules/expect.js/index.js .tmp/test/expect.js","test:livereload-server":"node scripts/livereload.js","test:node-deps":"rollup -c rollup-node-tests.config.js","mocha":"mocha -u tdd .tmp/test/node-tests.js","lint":"eslint --max-warnings 0 -c .eslintrc.json $(yarn run lint:reporter-args 2>&1 >/dev/null) src/ test/","lint:reporter-args":"test -n \"${CI}\" && >&2 echo -o $CIRCLE_TEST_REPORTS/junit/eslint.xml -f junit","print-start-message":"wait-on file:.tmp/test/index.html file:.tmp/test/tests.js tcp:35729 tcp:4200 && echo \"\n\n⚡️⚡️⚡️  Good to go at http://localhost:4200 ⚡️⚡️⚡️\"","schema:fetch":"graphql-js-schema-fetch --url 'https://graphql.myshopify.com/api/unstable/graphql' --header 'Authorization: Basic MzUxYzEyMjAxN2QwZjJhOTU3ZDMyYWU3MjhhZDc0OWM=' | jq '.' > schema.json","minify-umd:optimized":"echo \"/*\n$(cat LICENSE.txt)\n*/\" > index.umd.min.js && babel-minify index.umd.js >> index.umd.min.js","minify-umd:unoptimized":"echo \"/*\n$(cat LICENSE.txt)\n*/\" > index.unoptimized.umd.min.js && babel-minify index.unoptimized.umd.js >> index.unoptimized.umd.min.js"},"author":{"name":"Shopify Inc."},"license":"MIT","dependencies":{},"devDependencies":{"aws-sdk":"2.162.0","babel":"6.23.0","babel-core":"6.26.0","babel-minify":"0.2.0","babel-plugin-external-helpers":"6.22.0","babel-preset-env":"1.6.0","concurrently":"3.5.0","eslint":"3.8.1","eslint-plugin-shopify":"14.0.0","eslint-test-generator":"1.0.5","expect.js":"0.3.1","fetch-mock":"5.12.2","fs-extra":"1.0.0","graphql-js-client":"0.12.0","graphql-js-schema":"0.7.1","graphql-js-schema-fetch":"1.1.2","http-server":"0.10.0","jquery":"3.2.1","jsdoc":"3.6.3","jsdoc-export-default-interop":"0.3.1","jsdoc-to-markdown":"5.0.1","mime-types":"2.1.17","minimist":"1.2.0","mocha":"3.5.0","node-fetch":"1.7.2","node-jq":"0.7.0","rimraf":"2.6.1","rollup":"0.47.6","rollup-plugin-babel":"3.0.2","rollup-plugin-commonjs":"8.1.0","rollup-plugin-graphql-js-client-compiler":"0.2.0","rollup-plugin-json":"2.3.0","rollup-plugin-multi-entry":"2.0.1","rollup-plugin-node-builtins":"2.1.2","rollup-plugin-node-globals":"1.1.0","rollup-plugin-node-resolve":"3.0.0","rollup-plugin-remap":"0.0.3","rollup-plugin-sizes":"0.4.0","rollup-pluginutils":"2.0.1","rollup-watch":"4.3.1","selenium-standalone":"5.5.0","tiny-lr":"1.0.5","wait-on":"2.0.2","whatwg-fetch":"2.0.3"},"livereloadPort":35729,"gitHead":"762df4546822795e5207c3752a2f6299b0582c17","bugs":{"url":"https://github.com/Shopify/js-buy-sdk/issues"},"homepage":"https://github.com/Shopify/js-buy-sdk#readme","_id":"@bareblends/shopify-buy@0.0.1","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-Nn76rqAciG2eEQz7Dd7ZiGHwazaxlfwlMjnXrPpRuNd3rMnnBBzV0dNUWMhtMLcGRUCvTpUVZoizdHcL71wDhg==","shasum":"b5891017a0ec2e348cc7a35cf8ec0e5f67e40cfe","tarball":"https://registry.npmjs.org/@bareblends/shopify-buy/-/shopify-buy-0.0.1.tgz","fileCount":27,"unpackedSize":2963016,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4p3MCRA9TVsSAnZWagAAwOMP/169P5Ezy5Sd5zgEjuro\n9SXg/E8G9ni5r1SkYJmZQUfnvJ2kW1rK36r7g7xc+xrjxpPjvOnt2XmnSuKt\nUS+Hm3kLXYjgD/lzJwTPmMVwJ5R79iu2bD7BXmCmtNQOf8fPysJ6cenqbazl\nN5SeDlj474AS9ejMvYT35fF9tSg6xPTIsGh3Oo7vKg+9OeUVbRmJzL//neI1\nLrBD2Ua95d2zYpRBlf004ijW3bUSzuDONGeK3U/lSjgmyyveiqn6S2jj5hIu\nK7WyUTv7I2xhA1ZhHIAZ2NF6cIXjTN/DJ+8pQ2yHOHOrv0BbXKt6PmqbqVmQ\no7mvK2RQ8SmJE2gTzbu7rKi9o0NotEGLFfhYFjjQgQIUdBIN3MudqFcOTI9z\nC/bVyjzt1ahAiVjiA/KVOUokQhCVIopmguNyoqDtscJ+uhoH+LPVBe/zUWC9\nxHbe1ruuG9cCMkzE01dxY/Fd0sc38K6vJASE4PdAMBBRajjhWGQXY+C/cfle\nQrjZQkxMkAXLzLsZ5euZRmbOFhAtPOU9vO3xgBAe+c3RHD1zHebbAI/kKU10\nziyO1z3ZCj/2ZhU7b81B6fqrkhWbhuGA50IRVuVJtK52R0tUdN1WvhaN/ZH7\nw/FnHEB2FtXyOSIQds6y0Cg0z1iI4m50iEnwfLvru9Of06thkmT07wFNxQkg\nULwE\r\n=w5bT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGzKyCu3nmGc92fIPNTXCbcc7RTotGr/klgIvGzA0EdFAiB0LFHI/WwKuW+NSjJCf/7dpwMDnTsto27xDspNgIkryg=="}]},"_npmUser":{"name":"razza","email":"ryan.davis@bareblends.com.au"},"directories":{},"maintainers":[{"name":"oscarmanderj","email":"oscarmanderj@Gmail.com"},{"name":"razza","email":"ryan.davis@bareblends.com.au"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/shopify-buy_0.0.1_1625464267839_0.6587120937715503"},"_hasShrinkwrap":false}},"time":{"created":"2021-07-05T05:51:07.497Z","0.0.1":"2021-07-05T05:51:08.020Z","modified":"2022-04-04T17:43:44.797Z"},"maintainers":[{"name":"oscarmanderj","email":"oscarmanderj@Gmail.com"},{"name":"razza","email":"ryan.davis@bareblends.com.au"}],"description":"The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website. It is based on Shopify's API and provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.","homepage":"https://github.com/Shopify/js-buy-sdk#readme","repository":{"type":"git","url":"git+ssh://git@github.com/Shopify/js-buy-sdk.git"},"author":{"name":"Shopify Inc."},"bugs":{"url":"https://github.com/Shopify/js-buy-sdk/issues"},"license":"MIT","readme":"# [Shopify](https://www.shopify.com) JavaScript Buy SDK\n[![Travis](https://travis-ci.com/Shopify/js-buy-sdk.svg?branch=master)](https://travis-ci.com/Shopify/js-buy-sdk)\n\n**Note**: For help with migrating from v0 of JS Buy SDK to v1 check out the\n[Migration Guide](https://github.com/Shopify/js-buy-sdk/blob/master/tutorials/MIGRATION_GUIDE.md).\n\nThe JS Buy SDK is a lightweight library that allows you to build ecommerce into\nany website. It's based on Shopify's [Storefront API](https://help.shopify.com/api/storefront-api/getting-started)\nand provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.\n\n[Full API docs are available here](https://help.shopify.com/en/api/storefront-api/reference).\n\n## Changelog\n\nView our [Changelog](https://github.com/Shopify/js-buy-sdk/blob/master/CHANGELOG.md) for details about our releases.\n\n## Table Of Contents\n\n- [Installation](#installation)\n- [Builds](#builds)\n- [Examples](#examples)\n  + [Initializing the Client](#initializing-the-client)\n  + [Fetching Products](#fetching-products)\n  + [Fetching Collections](#fetching-collections)\n  + [Creating a Checkout](#creating-a-checkout)\n  + [Updating Checkout Attributes](#updating-checkout-attributes)\n  + [Adding Line Items](#adding-line-items)\n  + [Updating Line Items](#updating-line-items)\n  + [Removing Line Items](#removing-line-items)\n  + [Fetching a Checkout](#fetching-a-checkout)\n  + [Adding a Discount](#adding-a-discount)\n  + [Removing a Discount](#removing-a-discount)\n  + [Updating a Shipping Address](#updating-a-shipping-address)\n  + [Completing a checkout](#completing-a-checkout)\n- [Expanding the SDK](#expanding-the-sdk)\n  + [Initializing the Client](#initializing-the-client-1)\n  + [Fetching Products](#fetching-products-1)\n- [Example Apps](#example-apps)\n- [Documentation](#documentation)\n- [Contributing](#contributing)\n- [Code of Conduct](#code-of-conduct)\n- [License](#license)\n\n## Installation\n**With Yarn:**\n```bash\n$ yarn add shopify-buy\n```\n**With NPM:**\n```bash\n$ npm install shopify-buy\n```\n\n**CDN:**\n\nThere is a minified UMD build available via CDN (see the [Changelog](https://github.com/Shopify/js-buy-sdk/blob/master/CHANGELOG.md) for details about the latest release):\n\n```html\n<script src=\"http://sdks.shopifycdn.com/js-buy-sdk/v2/latest/index.umd.min.js\"></script>\n```\n\nYou can also use a specific release version:\n\n```html\n<script src=\"https://sdks.shopifycdn.com/js-buy-sdk/1.11.0/index.umd.min.js\"></script>\n```\n\nYou can also fetch the unoptimized release for a version (2.0.1 and above). This will be larger than the optimized version, as it will contain all fields that are available in the [Storefront API](https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference):\n\n```html\n<script src=\"https://sdks.shopifycdn.com/js-buy-sdk/2.0.1/index.unoptimized.umd.min.js\"></script>\n```\n\n## Builds\nThe JS Buy SDK has four build versions: ES, CommonJS, AMD, and UMD.\n\n**ES, CommonJS:**\n```javascript\nimport Client from 'shopify-buy';\n```\n**AMD:**\n```javascript\nimport Client from 'shopify-buy/index.amd';\n```\n**UMD:**\n```javascript\nimport Client from 'shopify-buy/index.umd';\n```\n**UMD Unoptimized:**\nThis will be larger than the optimized version, as it will contain all fields that are available in the [Storefront API](https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference). This should only be used when you need to add custom queries to supplement the JS Buy SDK queries.\n\n```javascript\nimport Client from 'shopify-buy/index.unoptimized.umd';\n```\n\n## Examples\n\n### Initializing the Client\nIf your store supports multiple languages, Storefront API can return translated resource types and fields. Learn more about [translating content](https://help.shopify.com/en/api/guides/multi-language/translating-content-api).\n\n```javascript\nimport Client from 'shopify-buy';\n\n// Initializing a client to return content in the store's primary language\nconst client = Client.buildClient({\n  domain: 'your-shop-name.myshopify.com',\n  storefrontAccessToken: 'your-storefront-access-token'\n});\n\n// Initializing a client to return translated content\nconst clientWithTranslatedContent = Client.buildClient({\n  domain: 'your-shop-name.myshopify.com',\n  storefrontAccessToken: 'your-storefront-access-token',\n  language: 'ja-JP'\n});\n```\n\n### Fetching Products\n```javascript\n// Fetch all products in your shop\nclient.product.fetchAll().then((products) => {\n  // Do something with the products\n  console.log(products);\n});\n\n// Fetch a single product by ID\nconst productId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ=';\n\nclient.product.fetch(productId).then((product) => {\n  // Do something with the product\n  console.log(product);\n});\n\n// Fetch a single product by Handle\nconst handle = 'product-handle';\n\nclient.product.fetchByHandle(handle).then((product) => {\n  // Do something with the product\n  console.log(product);\n});\n```\n\n### Fetching Collections\n```javascript\n// Fetch all collections, including their products\nclient.collection.fetchAllWithProducts().then((collections) => {\n  // Do something with the collections\n  console.log(collections);\n  console.log(collections[0].products);\n});\n\n// Fetch a single collection by ID, including its products\nconst collectionId = 'Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzM2OTMxMjU4NA==';\n// Set a parameter for first x products, defaults to 20 if you don't provide a param\n\nclient.collection.fetchWithProducts(collectionId, {productsFirst: 10}).then((collection) => {\n  // Do something with the collection\n  console.log(collection);\n  console.log(collection.products);\n});\n```\n\n### Creating a Checkout\n```javascript\n// Create an empty checkout\nclient.checkout.create().then((checkout) => {\n  // Do something with the checkout\n  console.log(checkout);\n});\n```\n\n### Updating checkout attributes\n```javascript\nconst checkoutId = 'Z2lkOi8vc2hvcGlmeS9DaGVja291dC9kMTZmM2EzMDM4Yjc4N=';\nconst input = {customAttributes: [{key: \"MyKey\", value: \"MyValue\"}]};\n\nclient.checkout.updateAttributes(checkoutId, input).then((checkout) => {\n  // Do something with the updated checkout\n});\n```\n\n### Adding Line Items\n```javascript\nconst checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout\nconst lineItemsToAdd = [\n  {\n    variantId: 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yOTEwNjAyMjc5Mg==',\n    quantity: 5,\n    customAttributes: [{key: \"MyKey\", value: \"MyValue\"}]\n  }\n];\n\n// Add an item to the checkout\nclient.checkout.addLineItems(checkoutId, lineItemsToAdd).then((checkout) => {\n  // Do something with the updated checkout\n  console.log(checkout.lineItems); // Array with one additional line item\n});\n```\n\n### Updating Line Items\n```javascript\nconst checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout\nconst lineItemsToUpdate = [\n  {id: 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ=', quantity: 2}\n];\n\n// Update the line item on the checkout (change the quantity or variant)\nclient.checkout.updateLineItems(checkoutId, lineItemsToUpdate).then((checkout) => {\n  // Do something with the updated checkout\n  console.log(checkout.lineItems); // Quantity of line item 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ=' updated to 2\n});\n```\n\n### Removing Line Items\n```javascript\nconst checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout\nconst lineItemIdsToRemove = [\n  'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ='\n];\n\n// Remove an item from the checkout\nclient.checkout.removeLineItems(checkoutId, lineItemIdsToRemove).then((checkout) => {\n  // Do something with the updated checkout\n  console.log(checkout.lineItems); // Checkout with line item 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ=' removed\n});\n```\n\n### Fetching a Checkout\n```javascript\nconst checkoutId = '2U4NWNkYzI4ZWEyOTdlOD9rZXk9MDVjMzY3Zjk3YWM0YWJjNGRhMTkwMDgwYTUzOGJmYmI='\n\nclient.checkout.fetch(checkoutId).then((checkout) => {\n  // Do something with the checkout\n  console.log(checkout);\n});\n```\n\n### Adding a Discount\n```javascript\nconst checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout\nconst discountCode = 'best-discount-ever';\n\n// Add a discount code to the checkout\nclient.checkout.addDiscount(checkoutId, discountCode).then(checkout => {\n  // Do something with the updated checkout\n  console.log(checkout);\n});\n```\n\n### Removing a Discount\n```javascript\nconst checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout\n\n// Removes the applied discount from an existing checkout.\nclient.checkout.removeDiscount(checkoutId).then(checkout => {\n  // Do something with the updated checkout\n  console.log(checkout);\n});\n```\n\n### Updating a Shipping Address\n```javascript\nconst checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout\n\nconst shippingAddress = {\n   address1: 'Chestnut Street 92',\n   address2: 'Apartment 2',\n   city: 'Louisville',\n   company: null,\n   country: 'United States',\n   firstName: 'Bob',\n   lastName: 'Norman',\n   phone: '555-625-1199',\n   province: 'Kentucky',\n   zip: '40202'\n };\n\n// Update the shipping address for an existing checkout.\nclient.checkout.updateShippingAddress(checkoutId, shippingAddress).then(checkout => {\n  // Do something with the updated checkout\n});\n```\n\n### Completing a checkout\n\nThe simplest way to complete a checkout is to use the [webUrl](https://help.shopify.com/en/api/storefront-api/reference/object/checkout) property that is returned when creating a checkout. This URL redirects the customer to Shopify's [online checkout](https://help.shopify.com/en/manual/checkout-settings) to complete the purchase.\n\n## Expanding the SDK\n\nNot all fields that are available on the [Storefront API](https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference) are exposed through the SDK. If you use the unoptimized version of the SDK, you can easily build your own queries. In order to do this, use the UMD Unoptimized build.\n\n### Initializing the Client\n```javascript\n// fetch the large, unoptimized version of the SDK\nimport Client from 'shopify-buy/index.unoptimized.umd';\n\nconst client = Client.buildClient({\n  domain: 'your-shop-name.myshopify.com',\n  storefrontAccessToken: 'your-storefront-access-token'\n});\n```\n\n### Fetching Products\n```javascript\n// Build a custom products query using the unoptimized version of the SDK\nconst productsQuery = client.graphQLClient.query((root) => {\n  root.addConnection('products', {args: {first: 10}}, (product) => {\n    product.add('title');\n    product.add('tags');// Add fields to be returned\n  });\n});\n\n// Call the send method with the custom products query\nclient.graphQLClient.send(productsQuery).then(({model, data}) => {\n  // Do something with the products\n  console.log(model);\n});\n\n```\n\n## Example Apps\n\nFor more complete examples of using JS Buy SDK, check out our [storefront-api-examples](https://github.com/Shopify/storefront-api-examples) project.\nThere are JS Buy SDK specific example apps in Node, Ember, and React. You can use these examples as a guideline for creating your own custom storefront.\n\n## Documentation\n\n- [Getting started guide](https://help.shopify.com/en/api/storefront-api/tools/js-buy-sdk/getting-started)\n- [API documentation](https://shopify.github.io/js-buy-sdk).\n\n## Contributing\nFor help on setting up the repo locally, building, testing, and contributing\nplease see [CONTRIBUTING.md](https://github.com/Shopify/js-buy-sdk/blob/master/CONTRIBUTING.md).\n\n## Code of Conduct\nAll developers who wish to contribute through code or issues, take a look at the\n[CODE_OF_CONDUCT.md](https://github.com/Shopify/js-buy-sdk/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nMIT, see [LICENSE.md](https://github.com/Shopify/js-buy-sdk/blob/master/LICENSE.txt) for details.\n\n<img src=\"https://cdn.shopify.com/shopify-marketing_assets/builds/19.0.0/shopify-full-color-black.svg\" width=\"200\" />\n","readmeFilename":"README.md"}