From 5c761a3ea72e0d0850161f7ed2dec8032bc286cd Mon Sep 17 00:00:00 2001 From: Darryl Norris Date: Tue, 8 Jan 2019 10:36:15 -0800 Subject: [PATCH] Updating back from upstream --- .github/probots.yml | 2 + CHANGELOG.md | 34 +- CONTRIBUTING.md | 9 +- DEPLOYING.md | 20 +- README.md | 23 +- docs/CheckoutResource.html | 410 +- docs/Client.html | 2 +- docs/CollectionResource.html | 2 +- docs/Config.html | 2 +- docs/ImageHelpers.html | 2 +- docs/ImageResource.html | 2 +- docs/ProductHelpers.html | 2 +- docs/ProductResource.html | 2 +- docs/ShopResource.html | 2 +- docs/checkout-resource.js.html | 61 +- docs/client.js.html | 2 +- docs/collection-resource.js.html | 10 +- docs/config.js.html | 2 +- docs/image-helpers.js.html | 2 +- docs/image-resource.js.html | 2 +- docs/index.html | 20 +- docs/product-helpers.js.html | 2 +- docs/product-resource.js.html | 8 +- docs/shop-resource.js.html | 2 +- docs/tutorial-MIGRATION_GUIDE.html | 2 +- fixtures/checkout-create-fixture.js | 1 + ...reate-with-paginated-line-items-fixture.js | 1 + .../checkout-discount-code-apply-fixture.js | 86 + .../checkout-discount-code-remove-fixture.js | 72 + .../checkout-line-items-replace-fixture.js | 79 + .../checkout-update-custom-attrs-fixture.js | 3 +- fixtures/checkout-update-email-fixture.js | 82 + fixtures/collection-by-handle-fixture.js | 62 +- fixtures/collection-with-products-fixture.js | 6 - fixtures/node-null-fixture.js | 5 + fixtures/product-by-handle-fixture.js | 491 +- fixtures/product-fixture.js | 4 +- .../product-with-paginated-images-fixture.js | 135 +- fixtures/query-collection-fixture.js | 22 - fixtures/query-collections-fixture.js | 32 + ...ery-collections-with-pagination-fixture.js | 357 + ...query-collections-with-products-fixture.js | 413 + fixtures/query-product-fixture.js | 24 - fixtures/query-products-fixture.js | 245 + fixtures/shop-with-collections-fixture.js | 34 - ...ith-collections-with-pagination-fixture.js | 366 - ...-with-collections-with-products-fixture.js | 422 - fixtures/shop-with-products-fixture.js | 249 - .../shop-with-sorted-collections-fixture.js | 35 - fixtures/shop-with-sorted-products-fixture.js | 35 - index.amd.js | 2084 +- index.amd.js.map | 2 +- index.es.js | 2084 +- index.es.js.map | 2 +- index.js | 2084 +- index.js.map | 2 +- index.umd.js | 2084 +- index.umd.js.map | 2 +- index.umd.min.js | 2 +- package-lock.json | 10716 +++++++++ package.json | 2 +- schema.json | 19990 ++++++++++------ service.yml | 1 - src/checkout-resource.js | 59 +- src/collection-resource.js | 8 +- src/graphql/CheckoutFragment.graphql | 23 +- src/graphql/CheckoutUserErrorFragment.graphql | 5 + src/graphql/CollectionFragment.graphql | 2 +- .../DiscountApplicationFragment.graphql | 19 + src/graphql/ProductFragment.graphql | 2 +- src/graphql/VariantFragment.graphql | 4 +- .../checkoutAttributesUpdateMutation.graphql | 10 - ...checkoutAttributesUpdateV2Mutation.graphql | 13 + src/graphql/checkoutCreateMutation.graphql | 3 + .../checkoutDiscountCodeApplyMutation.graphql | 10 - ...heckoutDiscountCodeApplyV2Mutation.graphql | 13 + ...checkoutDiscountCodeRemoveMutation.graphql | 3 + .../checkoutEmailUpdateV2Mutation.graphql | 13 + .../checkoutLineItemsReplaceMutation.graphql | 10 + src/graphql/collectionByHandleQuery.graphql | 8 +- src/graphql/collectionConnectionQuery.graphql | 20 +- ...lectionConnectionWithProductsQuery.graphql | 38 +- src/graphql/productByHandleQuery.graphql | 6 +- src/graphql/productConnectionQuery.graphql | 20 +- src/handle-checkout-mutation.js | 4 + src/product-resource.js | 6 +- test/client-checkout-integration-test.js | 113 +- test/client-integration-test.js | 38 +- test/lint-test.js | 21 + yarn.lock | 2109 +- 90 files changed, 34850 insertions(+), 10673 deletions(-) create mode 100644 .github/probots.yml create mode 100644 fixtures/checkout-discount-code-apply-fixture.js create mode 100644 fixtures/checkout-discount-code-remove-fixture.js create mode 100644 fixtures/checkout-line-items-replace-fixture.js create mode 100644 fixtures/checkout-update-email-fixture.js create mode 100644 fixtures/node-null-fixture.js delete mode 100644 fixtures/query-collection-fixture.js create mode 100644 fixtures/query-collections-fixture.js create mode 100644 fixtures/query-collections-with-pagination-fixture.js create mode 100644 fixtures/query-collections-with-products-fixture.js delete mode 100644 fixtures/query-product-fixture.js create mode 100644 fixtures/query-products-fixture.js delete mode 100644 fixtures/shop-with-collections-fixture.js delete mode 100644 fixtures/shop-with-collections-with-pagination-fixture.js delete mode 100644 fixtures/shop-with-collections-with-products-fixture.js delete mode 100644 fixtures/shop-with-products-fixture.js delete mode 100644 fixtures/shop-with-sorted-collections-fixture.js delete mode 100644 fixtures/shop-with-sorted-products-fixture.js create mode 100644 package-lock.json create mode 100644 src/graphql/CheckoutUserErrorFragment.graphql create mode 100644 src/graphql/DiscountApplicationFragment.graphql delete mode 100644 src/graphql/checkoutAttributesUpdateMutation.graphql create mode 100644 src/graphql/checkoutAttributesUpdateV2Mutation.graphql delete mode 100644 src/graphql/checkoutDiscountCodeApplyMutation.graphql create mode 100644 src/graphql/checkoutDiscountCodeApplyV2Mutation.graphql create mode 100644 src/graphql/checkoutEmailUpdateV2Mutation.graphql create mode 100644 src/graphql/checkoutLineItemsReplaceMutation.graphql diff --git a/.github/probots.yml b/.github/probots.yml new file mode 100644 index 000000000..1491d2756 --- /dev/null +++ b/.github/probots.yml @@ -0,0 +1,2 @@ +enabled: + - cla diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e97df425..a332447c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,36 @@ # Changelog +### v2.0.0 (January 3, 2019) +- Fetch `collections`, `products`, `collectionByHandle` and `productByHandle` from the QueryRoot instead of from the Shop object. +- Return `checkoutUserErrors` instead of `userErrors` when present. This will add an extra field called code. +- Expose `checkoutLineItemsReplace` mutation (to replace deprecated `checkoutLineItemsAdd`, `checkoutLineItemsRemove`, and `checkoutLineItemsUpdate` mutations). +- Remove unused fixtures + +### v1.11.0 (November 27, 2018) +- Added availableForSale field to Product query fragment +- Removed tags field from Product query fragment +- Add field aliasing to deprecated fields in affected query fragments: + - availableForSale on VariantFragment + - countryCode on CheckoutFragment + - src on CollectionFragment and VariantFragment + +### v1.10.0 (November 7, 2018) +- Updates deprecated Storefront API methods used for some checkout mutations. + +### v1.9.1 (October 24, 2018) +- Specifies pageInfo for discountApplications connection + +### [UNSAFE] v1.9.0 (October 23, 2018) +- Updates schema.json +- Support checkoutDiscountCodeRemove mutation +- Exposes discounts on the checkout Object +- Allows a null checkout response from CheckoutResource.fetch (#563) + +### v1.8.0 (August 30, 2018) +- Support checkoutEmailUpdate mutation + ### v0.1.3 (March 30, 2016) -- Adds IE9 support for `atob` and `btoa` using polyfills via #52 -- Cleans up some deployment noise (#54). Thanks @tessalt +- Adds IE9 support for `atob` and `btoa` using polyfills via #52 +- Cleans up some deployment noise (#54). Thanks @tessalt ### v0.1.0 (March 22, 2016) - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c95e11f4..f10c88d6b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,10 +64,11 @@ The following documents the folder structure for this project and what the purpo See [here](https://github.com/Shopify/js-buy-sdk/blob/master/examples) for our examples. ## Documentation -If your change affects how people use the project (i.e. adding or -changing arguments to a function, adding a new function, changing the -return value, etc), please ensure the documentation is also updated to -reflect this. The docs live inside the `docs/` folder and are hosted +Please do not update documentation, as this may cause +merge conflicts. After a pull request has been merged, the +maintainers will update documentation and release a new version. + +The docs live inside the `docs/` folder and are hosted at `http://shopify.github.io/js-buy-sdk`. To generate docs run the following: diff --git a/DEPLOYING.md b/DEPLOYING.md index 649dba7b6..028def08e 100644 --- a/DEPLOYING.md +++ b/DEPLOYING.md @@ -5,6 +5,20 @@ * write new version to package.json * create a commit with a commit message matching the version number * create a new tag matching the version number -3. Push the new commit and tags to master with `git push origin master --tags` -4. Create a release on Github. Include changelog in description -5. Deploy built scripts to s3 via [shipit](https://shipit.shopify.io/shopify/js-buy-sdk/production) +3. Push the new commit and tags to master with `git push && git push --tags` +4. Deploy built scripts to s3 via [shipit](https://shipit.shopify.io/shopify/js-buy-sdk/production) + +# Updating Documentation + +If your change affects how people use the project (i.e. adding or +changing arguments to a function, adding a new function, changing the +return value, etc), please ensure the documentation is also updated to +reflect this. The docs live inside the `docs/` folder and are hosted +at `http://shopify.github.io/js-buy-sdk`. + +Please update the docs in a separate PR from the code change. When the two are +updated together, the diff will be huge and it will be difficult to review. + +1. Generate documentation using `npm run doc:build` or `yarn doc:build` +2. Update the [Changelog](https://github.com/Shopify/js-buy-sdk/CHANGELOG.md) with details about the release. +3. Merge your branch into master diff --git a/README.md b/README.md index a1d4f9aaf..c4cd4e807 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ and provides the ability to retrieve products and collections from your shop, ad [Full API docs are available here](https://shopify.github.io/js-buy-sdk). +## Changelog + +View our [Changelog](https://github.com/Shopify/js-buy-sdk/blob/master/CHANGELOG.md) for details about our releases. + ## Table Of Contents - [Installation](#installation) @@ -43,10 +47,16 @@ $ npm install shopify-buy **CDN:** -There is a minified UMD build available via CDN: +There 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): + +```html + +``` + +You can also use a specific release version: ```html - + ``` ## Builds @@ -197,10 +207,19 @@ client.checkout.addDiscount(checkoutId, discountCode).then(checkout => { ### Removing a Discount ```javascript +<<<<<<< HEAD const checkoutId = 'Z2lkOi8vc2hvcGlmeS9DaGVja291dC9kMTZmM2EzMDM4Yjc4N='; client.checkout.removeDiscount(checkoutId).then((checkout) => { // Do something with the updated checkout +======= +const checkoutId = 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0SW1hZ2UvMTgyMTc3ODc1OTI='; // ID of an existing checkout + +// Removes the applied discount from an existing checkout. +client.checkout.removeDiscount(checkoutId).then(checkout => { + // Do something with the updated checkout + console.log(checkout); +>>>>>>> upstream/master }); ``` diff --git a/docs/CheckoutResource.html b/docs/CheckoutResource.html index 774d7496b..08e553cb2 100644 --- a/docs/CheckoutResource.html +++ b/docs/CheckoutResource.html @@ -93,7 +93,7 @@

new C
Source:
@@ -271,7 +271,7 @@

Parameters:
Source:
@@ -464,7 +464,7 @@
Parameters:
Source:
@@ -839,7 +839,7 @@
Properties
Source:
@@ -1012,7 +1012,7 @@
Parameters:
Source:
@@ -1179,7 +1179,7 @@
Parameters:
Source:
@@ -1346,7 +1346,7 @@
Parameters:
Source:
@@ -1538,7 +1538,7 @@
Parameters:
Source:
@@ -1607,6 +1607,199 @@
Example
+

replaceLineItems(checkoutId, lineItems) → {Promise|GraphModel}

+ + + + + + +
+

Replace line items on an existing checkout.

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
checkoutId + + +String + + + +

The ID of the checkout to add line items to.

lineItems + + +Array.<Object> + + + +

A list of line items to set on the checkout. See the Storefront API reference for valid input fields for each line item.

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

A promise resolving with the updated checkout.

+
+ + + +
+
+ Type +
+
+ +Promise +| + +GraphModel + + +
+
+ + + + + + +
Example
+ +
const checkoutId = 'Z2lkOi8vc2hvcGlmeS9DaGVja291dC9kMTZmM2EzMDM4Yjc4N=';
+const lineItems = [{variantId: 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yOTEwNjAyMjc5Mg==', quantity: 5}];
+
+client.checkout.replaceLineItems(checkoutId, lineItems).then((checkout) => {
+  // Do something with the updated checkout
+});
+ + + + + + + + +

updateAttributes(checkoutId, inputopt) → {Promise|GraphModel}

@@ -1878,7 +2071,7 @@
Properties
Source:
@@ -1947,6 +2140,199 @@
Example
+

updateEmail(checkoutId, email) → {Promise|GraphModel}

+ + + + + + +
+

Replaces the value of checkout's email address

+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
checkoutId + + +String + + + +

The ID of the checkout to update.

email + + +String + + + +

The email address to apply to the checkout.

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

A promise resolving with the updated checkout.

+
+ + + +
+
+ Type +
+
+ +Promise +| + +GraphModel + + +
+
+ + + + + + +
Example
+ +
const checkoutId = 'Z2lkOi8vc2hvcGlmeS9DaGVja291dC9kMTZmM2EzMDM4Yjc4N=';
+const email = 'user@example.com';
+
+client.checkout.updateEmail(checkoutId, email).then((checkout) => {
+  // Do something with the updated checkout
+});
+ + + + + + + + +

updateLineItems(checkoutId, lineItems) → {Promise|GraphModel}

@@ -2071,7 +2457,7 @@
Parameters:
Source:
@@ -2270,7 +2656,7 @@
Parameters:
Source:
@@ -2367,7 +2753,7 @@

Home

Classes