UNPKG

@spree/storefront-api-v2-sdk

Version:

Node module to easily integrate your JavaScript or TypeScript application with Spree Storefront API V2. You can create an entirely custom Storefront in JS/TS with this package including one page checkout, Single Page Apps, PWAs and so on.

2 lines 37.8 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SpreeSDK=t():e.SpreeSDK=t()}(this,(()=>{return e={987:function(e){var t;t=()=>(()=>{"use strict";var e={130:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t){const s={host:globalThis.process&&globalThis.process.env.SPREE_HOST||"http://localhost:3000/"},r=Object.assign(Object.assign({},s),e),o={host:r.host};this.fetcher=r.createFetcher(o);for(const e in t)this[e]=new t[e]({fetcher:this.fetcher})}}},374:function(e,t,s){var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var o=Object.getOwnPropertyDescriptor(t,s);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,o)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&r(t,e,s);return o(t,e),t},a=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(o,n){function a(e){try{u(r.next(e))}catch(e){n(e)}}function i(e){try{u(r.throw(e))}catch(e){n(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,i)}u((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const i=s(216);s(247);const u=n(s(325));t.default=class{constructor({fetcher:e}){this.fetcher=e}spreeResponse(e,t,s={},r={},o="automatic"){return a(this,void 0,void 0,(function*(){try{const n=this.spreeOrderHeaders(s),a={url:t,params:r,method:e,headers:n,responseParsing:o},i=yield this.fetcher.fetch(a);return u.makeSuccess(i.data)}catch(e){return u.makeFail(this.processError(e))}}))}classifySpreeError(e){const{error:t,errors:s}=e.data;return"string"==typeof t?"object"==typeof s?"full":"basic":"limited"}processError(e){if(e.response||e.request){const t=e;return t.response?this.processSpreeError(e):t.request?new i.NoResponseError:new i.MisconfigurationError(e.message)}return new i.SpreeSDKError(e.message)}processSpreeError(e){const{error:t,errors:s}=e.data,r=this.classifySpreeError(e);return"full"===r?new i.ExpandedSpreeError(e.response,t,s):"basic"===r?new i.BasicSpreeError(e.response,t):new i.SpreeError(e.response)}spreeOrderHeaders(e){const t={};return e.orderToken&&(t["X-Spree-Order-Token"]=e.orderToken),e.bearerToken&&(t.Authorization=`Bearer ${e.bearerToken}`),t}}},444:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(s(227));class n extends o.default{constructor(e,t){super(e),Object.setPrototypeOf(this,n.prototype),this.name="BasicSpreeError",this.summary=t}}t.default=n},582:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(s(311));class n extends o.default{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name="CastError"}}t.default=n},424:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(s(311));class n extends o.default{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name="DeserializeError"}}t.default=n},980:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(s(311));class n extends o.default{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name="DocumentRelationshipError"}}t.default=n},776:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),s(453);const o=r(s(444));class n extends o.default{constructor(e,t,s){super(e,t),Object.setPrototypeOf(this,n.prototype),this.name="ExpandedSpreeError",this.errors=Object.keys(s).reduce(((e,t)=>{const r=t.split(".");let o=r.shift(),n=e;for(;o;)n[o]||(0===r.length?n[o]=s[t]:n[o]={}),n=n[o],o=r.shift();return e}),{})}getErrors(e){let t=0,s=this.errors,r=!0;for(;t<e.length&&r;){const o=e[t];o in Object(s)?(s=s[o],t+=1):r=!1}return r?s:null}}t.default=n},247:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(s(311));class n extends o.default{constructor(e,t,s,r){super(r),Object.setPrototypeOf(this,n.prototype),this.name="FetchError",this.response=e,this.request=t,this.data=s}}t.default=n},300:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(s(311));class n extends o.default{constructor(e){super(`Incorrect request setup: ${e}`),Object.setPrototypeOf(this,n.prototype),this.name="MisconfigurationError"}}t.default=n},308:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(s(311));class n extends o.default{constructor(){super("No response received from Spree"),Object.setPrototypeOf(this,n.prototype),this.name="NoResponseError"}}t.default=n},227:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(s(311));class n extends o.default{constructor(e){super(`Spree returned a HTTP ${e.status} error code`),Object.setPrototypeOf(this,n.prototype),this.name="SpreeError",this.serverResponse=e}}t.default=n},311:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class s extends Error{constructor(e){super(e),Object.setPrototypeOf(this,s.prototype),this.name="SpreeSDKError"}}t.default=s},216:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DocumentRelationshipError=t.FetchError=t.SpreeSDKError=t.SpreeError=t.NoResponseError=t.MisconfigurationError=t.ExpandedSpreeError=t.BasicSpreeError=void 0;const o=r(s(444));t.BasicSpreeError=o.default;const n=r(s(776));t.ExpandedSpreeError=n.default;const a=r(s(300));t.MisconfigurationError=a.default;const i=r(s(308));t.NoResponseError=i.default;const u=r(s(227));t.SpreeError=u.default;const c=r(s(311));t.SpreeSDKError=c.default;const d=r(s(247));t.FetchError=d.default;const p=r(s(980));t.DocumentRelationshipError=p.default},619:function(e,t,s){var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var o=Object.getOwnPropertyDescriptor(t,s);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,o)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),o=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||r(t,e,s)};Object.defineProperty(t,"__esModule",{value:!0}),o(s(887),t),o(s(246),t),o(s(325),t),o(s(289),t)},887:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findSingleRelationshipDocument=t.findRelationshipDocuments=t.findDocument=void 0;const r=s(216),o=(e,t)=>e.included&&e.included.find((e=>e.type===t.type&&e.id===t.id))||null;t.findDocument=o;const n=(e,t,s)=>{if(!e.included)return[];const n=(t.relationships[s]||{}).data;if(!n)throw new r.DocumentRelationshipError(`Incorrect relationship ${s}.`);let a;return a=Array.isArray(n)?n:[n],a.map((t=>o(e,t))).filter(Boolean)};t.findRelationshipDocuments=n,t.findSingleRelationshipDocument=(e,t,s)=>{const r=n(e,t,s);return 0===r.length?null:r[0]}},246:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.objectToQuerystring=void 0;const s=(()=>{const e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})(),r=(e,t)=>{if(0===e.length)return e;let r=e;if("symbol"==typeof e?r=Symbol.prototype.toString.call(e):"string"!=typeof e&&(r=String(e)),"iso-8859-1"===t)return escape(r).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));let o="";for(let e=0;e<r.length;++e){let t=r.charCodeAt(e);45===t||46===t||95===t||126===t||t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122?o+=r.charAt(e):t<128?o+=s[t]:t<2048?o+=s[192|t>>6]+s[128|63&t]:t<55296||t>=57344?o+=s[224|t>>12]+s[128|t>>6&63]+s[128|63&t]:(e+=1,t=65536+((1023&t)<<10|1023&r.charCodeAt(e)),o+=s[240|t>>18]+s[128|t>>12&63]+s[128|t>>6&63]+s[128|63&t])}return o},o=Array.isArray,n=Array.prototype.push,a=(e,t)=>{n.apply(e,o(t)?t:[t])},i=e=>String(e),u=(e,t)=>e+"[]",c="utf-8",d=(e,t)=>{var s,n;if(e instanceof Date&&(e=e.toISOString()),null===e&&(e=""),"string"==typeof(n=e)||"number"==typeof n||"boolean"==typeof n||"symbol"==typeof n||"bigint"==typeof n||(s=e)&&"object"==typeof s&&s.constructor&&s.constructor.isBuffer&&s.constructor.isBuffer(s)){const s=r(t,c);return[i(s)+"="+i(r(e,c))]}const p=[];if(void 0===e)return p;const l=Object.keys(e);for(let s=0;s<l.length;++s){const r=l[s],n=e[r],i=o(e)?u(t):t+"["+r+"]";a(p,d(n,i))}return p};t.objectToQuerystring=e=>{const t=[],s=Object.keys(e);for(let r=0;r<s.length;++r){const o=s[r];a(t,d(e[o],o))}return t.join("&")}},325:function(e,t,s){var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var o=Object.getOwnPropertyDescriptor(t,s);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,o)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&r(t,e,s);return o(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractSuccess=t.fromJson=t.toJson=t.makeFail=t.makeSuccess=void 0;const i=n(s(216)),u=a(s(582)),c=a(s(424)),d=e=>({isSuccess:()=>!0,isFail:()=>!1,success:()=>e,fail:()=>{throw new Error("Cannot call fail() on success.")}});t.makeSuccess=d;const p=e=>({isSuccess:()=>!1,isFail:()=>!0,success:()=>{throw new Error("Cannot call success() on fail.")},fail:()=>e});t.makeFail=p,t.toJson=e=>e.isSuccess()?{type:"SpreeSDKResult",subtype:"success",value:e.success()}:{type:"SpreeSDKResult",subtype:"fail",value:Object.assign({},e.fail())},t.fromJson=e=>{if("SpreeSDKResult"===e.type){if("success"===e.subtype)return d(e.value);if("fail"===e.subtype)return p((e=>{if(!(e.name in i))throw new u.default("Error not recognized");return Object.assign(Object.create(i[e.name].prototype),e)})(e.value));throw new c.default("Expected success or fail subtype.")}throw new c.default("Unknown signature.")},t.extractSuccess=e=>e.then((e=>{if(e.isFail())throw e.fail();return e.success()}))},289:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.squashAndPreparePositionalArguments=t.split=void 0,t.split=(e,t)=>{const s=[{},{}];for(const r in e)t.includes(r)?s[1][r]=e[r]:s[0][r]=e[r];return s},t.squashAndPreparePositionalArguments=(e,s)=>{const r=Object.assign({},...[...e].filter(Boolean).map((e=>Object.keys(e).filter((t=>e[t])).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:e[s]})),{}))).filter((e=>Object.keys(e).length)).reverse()),[o,n]=(0,t.split)(r,["order_token","bearer_token","orderToken","bearerToken"]),[a,i]=(0,t.split)(o,s);let u;return("order_token"in n&&"bearer_token"in n||"orderToken"in n&&"bearerToken"in n)&&console.warn("Avoid providing both token types (order token and bearer token) in a request to prevent unexpected results."),u="bearer_token"in n||"bearerToken"in n?{bearerToken:n.bearer_token||n.bearerToken}:"order_token"in n||"orderToken"in n?{orderToken:n.order_token||n.orderToken}:{},Object.assign(Object.assign({token:u},i),{params:a})}},97:function(e,t,s){var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var o=Object.getOwnPropertyDescriptor(t,s);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,o)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),o=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||r(t,e,s)},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Http=t.Client=void 0;const a=n(s(130));t.Client=a.default;const i=n(s(374));t.Http=i.default,o(s(216),t),o(s(619),t)},453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})}},t={};return function s(r){var o=t[r];if(void 0!==o)return o.exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,s),n.exports}(97)})(),e.exports=t()},871:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async create(...e){const[t={}]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("post",n.default.accountPath(),s,r)}async confirm(...e){const[t]=e,{confirmation_token:s,token:r,params:a}=(0,o.squashAndPreparePositionalArguments)(["object"==typeof t?t:{confirmation_token:t}],["confirmation_token"]);return await this.spreeResponse("get",n.default.accountConfirmPath(s),r,a)}async forgotPassword(...e){const[t]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("post",n.default.forgotPasswordPath(),s,r)}async resetPassword(...e){const[t,s]=e,{reset_password_token:r,token:a,params:i}=(0,o.squashAndPreparePositionalArguments)(["object"==typeof t?t:{resetPasswordToken:t},s],["reset_password_token"]);return await this.spreeResponse("patch",n.default.resetPasswordPath(r),a,i)}async update(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.accountPath(),r,a)}async accountInfo(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("get",n.default.accountPath(),r,a)}async creditCardsList(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("get",n.default.accountCreditCardsPath(),r,a)}async defaultCreditCard(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("get",n.default.accountDefaultCreditCardPath(),r,a)}async removeCreditCard(...e){const[t,s,r={}]=e,{id:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([{id:s},t,r],["id"]);return await this.spreeResponse("delete",n.default.accountCreditCardRemovePath(a),i,u)}async completedOrdersList(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("get",n.default.accountCompletedOrdersPath(),r,a)}async completedOrder(...e){const[t,s,r={}]=e,{order_number:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([{order_number:s},t,r],["order_number"]);return await this.spreeResponse("get",n.default.accountCompletedOrderPath(a),i,u)}async addressesList(...e){const[t]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("get",n.default.accountAddressesPath(),s,r)}async showAddress(...e){const[t,s,r={}]=e,{id:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([{id:s},t,r],["id"]);return await this.spreeResponse("get",n.default.accountAddressPath(a),i,u)}async createAddress(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("post",n.default.accountAddressesPath(),r,a)}async removeAddress(...e){const[t,s,r={}]=e,{id:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([{id:s},t,r],["id"]);return await this.spreeResponse("delete",n.default.accountAddressRemovePath(a),i,u)}async updateAddress(...e){const[t,s,r]=e,{id:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([{id:s},t,r],["id"]);return await this.spreeResponse("patch",n.default.accountAddressPath(a),i,u)}}t.default=a},583:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=s(598),a=r(s(211));class i extends o.Http{async getToken(...e){const[t]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("post",a.default.oauthTokenPath(),s,(0,n.authParams)(r))}async refreshToken(...e){const[t]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("post",a.default.oauthTokenPath(),s,(0,n.refreshParams)(r))}async revokeToken(...e){const[t]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("post",a.default.oauthRevokePath(),s,(0,n.revokeParams)(r))}}t.default=i},14:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async create(...e){const[t={},s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("post",n.default.cartPath(),r,a)}async show(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("get",n.default.cartPath(),r,a)}async addItem(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("post",n.default.cartAddItemPath(),r,a)}async setQuantity(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.cartSetItemQuantity(),r,a)}async removeItem(...e){const[t,s,r={}]=e,{id:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([{id:s},t,r],["id"]);return await this.spreeResponse("delete",n.default.cartRemoveItemPath(a),i,u)}async emptyCart(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.cartEmptyPath(),r,a)}async remove(...e){const[t]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("delete",n.default.cartPath(),s,r)}async applyCouponCode(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.cartApplyCodePath(),r,a)}async removeCouponCode(...e){const[t,s=null,r={}]=e,{code:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([{code:s},t,r],["code"]);let c;return c=a?n.default.cartRemoveCodePath(a):n.default.cartRemoveAllCoupons(),await this.spreeResponse("delete",c,i,u)}async removeAllCoupons(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("delete",n.default.cartRemoveAllCoupons(),r,a)}async estimateShippingMethods(e,t){return await this.spreeResponse("get",n.default.cartEstimateShippingMethodsPath(),e,t)}async estimateShippingRates(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("get",n.default.cartEstimateShippingRatesPath(),r,a)}async associateGuestCart(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.cartAssociatePath(),r,a)}async changeCurrency(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.cartChangeCurrencyPath(),r,a)}}t.default=a},549:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987);s(656);const n=r(s(211));class a extends o.Http{async orderUpdate(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.checkoutPath(),r,a)}async orderNext(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.checkoutNextPath(),r,a)}async advance(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.checkoutAdvancePath(),r,a)}async complete(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.checkoutCompletePath(),r,a)}async addStoreCredits(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("post",n.default.checkoutAddStoreCreditsPath(),r,a)}async removeStoreCredits(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("post",n.default.checkoutRemoveStoreCreditsPath(),r,a)}async paymentMethods(...e){const[t]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("get",n.default.checkoutPaymentMethodsPath(),s,r)}async shippingMethods(e,t={}){return await this.spreeResponse("get",n.default.checkoutShippingMethodsPath(),e,t)}async shippingRates(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("get",n.default.checkoutShippingRatesPath(),r,a)}async selectShippingMethod(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("patch",n.default.checkoutSelectShippingMethodPath(),r,a)}async addPayment(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("post",n.default.checkoutAddPaymentPath(),r,a)}async createStripeSession(e){const{token:t,params:s}=(0,o.squashAndPreparePositionalArguments)([e],[]);return await this.spreeResponse("patch",n.default.checkoutCreateStripeSessionPath(),t,s)}}t.default=a},722:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async list(e){const{token:t,params:s}=(0,o.squashAndPreparePositionalArguments)([e||{}],[]);return await this.spreeResponse("get",n.default.countriesPath(),t,s)}async show(...e){const[t,s={}]=e,{iso:r,token:a,params:i}=(0,o.squashAndPreparePositionalArguments)(["object"==typeof t?t:{iso:t},s],["iso"]);return await this.spreeResponse("get",n.default.countryPath(r),a,i)}async default(...e){const[t={}]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("get",n.default.defaultCountryPath(),s,r)}}t.default=a},342:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async download(...e){const[t,s,r={}]=e,{asset_token:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([t,{asset_token:s},r],["asset_token"]);return await this.spreeResponse("get",n.default.digitalAssetsDownloadPath(a),i,u,"stream")}}t.default=a},606:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async list(...e){const[t={}]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("get",n.default.menusPath(),s,r)}async show(...e){const[t,s={}]=e,{id:r,token:a,params:i}=(0,o.squashAndPreparePositionalArguments)(["object"==typeof t?t:{id:t},s],["id"]);return await this.spreeResponse("get",n.default.menuPath(r),a,i)}}t.default=a},908:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async status(...e){const[t,s,r={}]=e,{order_number:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([t,{order_number:s},r],["order_number"]);return await this.spreeResponse("get",n.default.orderStatusPath(a),i,u)}}t.default=a},923:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async list(...e){const[t={}]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("get",n.default.pagesPath(),s,r)}async show(...e){const[t,s={}]=e,{id:r,token:a,params:i}=(0,o.squashAndPreparePositionalArguments)(["object"==typeof t?t:{id:t},s],["id"]);return await this.spreeResponse("get",n.default.pagePath(r),a,i)}}t.default=a},981:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async list(...e){const[t={},s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("get",n.default.productsPath(),r,a)}async show(...e){const[t,s={},r={}]=e,{id:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)(["object"==typeof t?t:{id:t},s,r],["id"]);return await this.spreeResponse("get",n.default.productPath(a),i,u)}}t.default=a},830:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async list(...e){const[t={}]=e,{token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([t],[]);return await this.spreeResponse("get",n.default.taxonsPath(),s,r)}async show(...e){const[t,s={}]=e,{id:r,token:a,params:i}=(0,o.squashAndPreparePositionalArguments)(["object"==typeof t?t:{id:t},s],["id"]);return await this.spreeResponse("get",n.default.taxonPath(r),a,i)}}t.default=a},192:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async list(e={}){const{token:t,params:s}=(0,o.squashAndPreparePositionalArguments)([e],[]);return await this.spreeResponse("get",n.default.vendorsPath(),t,s)}async show(e){const{id:t,token:s,params:r}=(0,o.squashAndPreparePositionalArguments)([e],["id"]);return await this.spreeResponse("get",n.default.vendorPath(t),s,r)}}t.default=a},899:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(987),n=r(s(211));class a extends o.Http{async list(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("get",n.default.wishlistsPath(),r,a)}async show(...e){const[t,s,r={}]=e,{wishlist_token:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([t,{wishlist_token:s},r],["wishlist_token"]);return await this.spreeResponse("get",n.default.wishlistPath(a),i,u)}async default(...e){const[t,s={}]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("get",n.default.defaultWishlistPath(),r,a)}async create(...e){const[t,s]=e,{token:r,params:a}=(0,o.squashAndPreparePositionalArguments)([t,s],[]);return await this.spreeResponse("post",n.default.wishlistsPath(),r,a)}async update(...e){const[t,s,r]=e,{wishlist_token:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([t,{wishlist_token:s},r],["wishlist_token"]);return await this.spreeResponse("patch",n.default.wishlistPath(a),i,u)}async remove(...e){const[t,s]=e,{wishlist_token:r,token:a,params:i}=(0,o.squashAndPreparePositionalArguments)([t,{wishlist_token:s}],["wishlist_token"]);return await this.spreeResponse("delete",n.default.wishlistPath(r),a,i)}async addWishedItem(...e){const[t,s,r]=e,{wishlist_token:a,token:i,params:u}=(0,o.squashAndPreparePositionalArguments)([t,{wishlist_token:s},r],["wishlist_token"]);return await this.spreeResponse("post",n.default.wishlistsAddWishedItemPath(a),i,u)}async updateWishedItem(...e){const[t,s,r,a]=e,{wishlist_token:i,id:u,token:c,params:d}=(0,o.squashAndPreparePositionalArguments)([t,{wishlist_token:s},{id:r},a],["wishlist_token","id"]);return await this.spreeResponse("patch",n.default.wishlistsUpdateWishedItemQuantityPath(i,u),c,d)}async removeWishedItem(...e){const[t,s,r]=e,{wishlist_token:a,id:i,token:u,params:c}=(0,o.squashAndPreparePositionalArguments)([t,{wishlist_token:s},{id:r}],["wishlist_token","id"]);return await this.spreeResponse("delete",n.default.wishlistsRemoveWishedItemPath(a,i),u,c)}}t.default=a},106:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Wishlists=t.Vendors=t.Taxons=t.Products=t.Pages=t.Order=t.Menus=t.DigitalAssets=t.Countries=t.Checkout=t.Cart=t.Authentication=t.Account=void 0;const o=r(s(871));t.Account=o.default;const n=r(s(583));t.Authentication=n.default;const a=r(s(14));t.Cart=a.default;const i=r(s(549));t.Checkout=i.default;const u=r(s(722));t.Countries=u.default;const c=r(s(342));t.DigitalAssets=c.default;const d=r(s(606));t.Menus=d.default;const p=r(s(908));t.Order=p.default;const l=r(s(923));t.Pages=l.default;const h=r(s(981));t.Products=h.default;const f=r(s(830));t.Taxons=f.default;const P=r(s(192));t.Vendors=P.default;const m=r(s(899));t.Wishlists=m.default},598:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.revokeParams=t.refreshParams=t.authParams=void 0,s(967),t.authParams=({username:e,password:t})=>({username:e,password:t,grant_type:"password"}),t.refreshParams=({refresh_token:e})=>({refresh_token:e,grant_type:"refresh_token"}),t.revokeParams=({token:e})=>({token:e})},97:function(e,t,s){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var o=Object.getOwnPropertyDescriptor(t,s);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,o)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||r(t,e,s)},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&r(t,e,s);return o(t,e),t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.storefrontPath=t.routes=t.endpoints=t.makeClient=void 0,n(s(987),t);const u=a(s(211));t.routes=u.default,Object.defineProperty(t,"storefrontPath",{enumerable:!0,get:function(){return u.storefrontPath}});const c=a(s(106));t.endpoints=c;const d=i(s(630));t.makeClient=d.default,n(s(939),t),n(s(447),t),n(s(791),t),n(s(269),t),n(s(382),t),n(s(33),t),n(s(967),t)},967:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),s(987)},656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},939:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},447:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},791:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},382:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),s(987)},33:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),s(939),s(447),s(791),s(269),s(987)},630:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=s(987),o=s(106),n={account:o.Account,authentication:o.Authentication,cart:o.Cart,checkout:o.Checkout,countries:o.Countries,digitalAssets:o.DigitalAssets,menus:o.Menus,order:o.Order,pages:o.Pages,products:o.Products,taxons:o.Taxons,vendors:o.Vendors,wishlists:o.Wishlists};t.default=e=>new r.Client(e,n)},211:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.storefrontPath=void 0,t.storefrontPath="api/v2/storefront";const s={productsPath:()=>`${t.storefrontPath}/products`,productPath:e=>`${t.storefrontPath}/products/${encodeURIComponent(e)}`,taxonsPath:()=>`${t.storefrontPath}/taxons`,taxonPath:e=>`${t.storefrontPath}/taxons/${encodeURIComponent(e)}`,countriesPath:()=>`${t.storefrontPath}/countries`,countryPath:e=>`${t.storefrontPath}/countries/${encodeURIComponent(e)}`,cartPath:()=>`${t.storefrontPath}/cart`,cartAddItemPath:()=>`${t.storefrontPath}/cart/add_item`,cartRemoveItemPath:e=>`${t.storefrontPath}/cart/remove_line_item/${encodeURIComponent(e)}`,cartEmptyPath:()=>`${t.storefrontPath}/cart/empty`,cartSetItemQuantity:()=>`${t.storefrontPath}/cart/set_quantity`,cartApplyCodePath:()=>`${t.storefrontPath}/cart/apply_coupon_code`,cartRemoveCodePath:e=>`${t.storefrontPath}/cart/remove_coupon_code/${encodeURIComponent(e)}`,cartRemoveAllCoupons:()=>`${t.storefrontPath}/cart/remove_coupon_code`,cartEstimateShippingMethodsPath:()=>`${t.storefrontPath}/cart/estimate_shipping_rates`,cartEstimateShippingRatesPath:()=>`${t.storefrontPath}/cart/estimate_shipping_rates`,cartAssociatePath:()=>`${t.storefrontPath}/cart/associate`,cartChangeCurrencyPath:()=>`${t.storefrontPath}/cart/change_currency`,checkoutPath:()=>`${t.storefrontPath}/checkout`,checkoutNextPath:()=>`${t.storefrontPath}/checkout/next`,checkoutAdvancePath:()=>`${t.storefrontPath}/checkout/advance`,checkoutCompletePath:()=>`${t.storefrontPath}/checkout/complete`,checkoutAddStoreCreditsPath:()=>`${t.storefrontPath}/checkout/add_store_credit`,checkoutRemoveStoreCreditsPath:()=>`${t.storefrontPath}/checkout/remove_store_credit`,checkoutPaymentMethodsPath:()=>`${t.storefrontPath}/checkout/payment_methods`,checkoutShippingMethodsPath:()=>`${t.storefrontPath}/checkout/shipping_rates`,checkoutShippingRatesPath:()=>`${t.storefrontPath}/checkout/shipping_rates`,checkoutSelectShippingMethodPath:()=>`${t.storefrontPath}/checkout/select_shipping_method`,checkoutAddPaymentPath:()=>`${t.storefrontPath}/checkout/create_payment`,checkoutCreateStripeSessionPath:()=>`${t.storefrontPath}/checkout/create_stripe_session`,oauthTokenPath:()=>"spree_oauth/token",oauthRevokePath:()=>"spree_oauth/revoke",accountPath:()=>`${t.storefrontPath}/account`,accountAddressPath:e=>`${t.storefrontPath}/account/addresses/${encodeURIComponent(e)}`,accountAddressesPath:()=>`${t.storefrontPath}/account/addresses`,accountAddressRemovePath:e=>`${t.storefrontPath}/account/addresses/${encodeURIComponent(e)}`,accountConfirmPath:e=>`${t.storefrontPath}/account_confirmations/${encodeURIComponent(e)}`,accountCreditCardsPath:()=>`${t.storefrontPath}/account/credit_cards`,accountDefaultCreditCardPath:()=>`${t.storefrontPath}/account/credit_cards/default`,accountCreditCardRemovePath:e=>`${t.storefrontPath}/account/credit_cards/${encodeURIComponent(e)}`,accountCompletedOrdersPath:()=>`${t.storefrontPath}/account/orders`,accountCompletedOrderPath:e=>`${t.storefrontPath}/account/orders/${encodeURIComponent(e)}`,forgotPasswordPath:()=>`${t.storefrontPath}/passwords`,resetPasswordPath:e=>`${t.storefrontPath}/passwords/${encodeURIComponent(e)}`,orderStatusPath:e=>`${t.storefrontPath}/order_status/${encodeURIComponent(e)}`,pagesPath:()=>`${t.storefrontPath}/cms_pages`,pagePath:e=>`${t.storefrontPath}/cms_pages/${encodeURIComponent(e)}`,defaultCountryPath:()=>`${t.storefrontPath}/countries/default`,digitalAssetsDownloadPath:e=>`${t.storefrontPath}/digitals/${encodeURIComponent(e)}`,menusPath:()=>`${t.storefrontPath}/menus`,menuPath:e=>`${t.storefrontPath}/menus/${encodeURIComponent(e)}`,wishlistsPath:()=>`${t.storefrontPath}/wishlists`,wishlistPath:e=>`${t.storefrontPath}/wishlists/${encodeURIComponent(e)}`,defaultWishlistPath:()=>`${t.storefrontPath}/wishlists/default`,wishlistsAddWishedItemPath:e=>`${t.storefrontPath}/wishlists/${encodeURIComponent(e)}/add_item`,wishlistsUpdateWishedItemQuantityPath:(e,s)=>`${t.storefrontPath}/wishlists/${encodeURIComponent(e)}/set_item_quantity/${encodeURIComponent(s)}`,wishlistsRemoveWishedItemPath:(e,s)=>`${t.storefrontPath}/wishlists/${encodeURIComponent(e)}/remove_item/${encodeURIComponent(s)}`,vendorsPath:()=>`${t.storefrontPath}/vendors`,vendorPath:e=>`${t.storefrontPath}/vendors/${encodeURIComponent(e)}`};t.default=s}},t={},function s(r){var o=t[r];if(void 0!==o)return o.exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,s),n.exports}(97);var e,t})); //# sourceMappingURL=index.js.map