@commercetools/api-request-builder
Advanced tools
Comparing version 5.3.1 to 5.3.2
@@ -20,19 +20,29 @@ 'use strict'; | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
keys.push.apply(keys, Object.getOwnPropertySymbols(object)); | ||
} | ||
if (enumerableOnly) keys = keys.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
ownKeys(source, true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(arguments[i])); | ||
ownKeys(source).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
@@ -1002,3 +1012,3 @@ } | ||
function fuzzyLevel(value) { | ||
if (!value) throw new Error('Required argument for `fuzzyLevel` is missing'); | ||
if (value === undefined || value === null) throw new Error('Required argument for `fuzzyLevel` is missing'); | ||
this.params.search.fuzzyLevel = value; | ||
@@ -1005,0 +1015,0 @@ return this; |
@@ -16,19 +16,29 @@ function _defineProperty(obj, key, value) { | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
keys.push.apply(keys, Object.getOwnPropertySymbols(object)); | ||
} | ||
if (enumerableOnly) keys = keys.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
ownKeys(source, true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(arguments[i])); | ||
ownKeys(source).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
@@ -998,3 +1008,3 @@ } | ||
function fuzzyLevel(value) { | ||
if (!value) throw new Error('Required argument for `fuzzyLevel` is missing'); | ||
if (value === undefined || value === null) throw new Error('Required argument for `fuzzyLevel` is missing'); | ||
this.params.search.fuzzyLevel = value; | ||
@@ -1001,0 +1011,0 @@ return this; |
@@ -22,19 +22,29 @@ (function (global, factory) { | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
keys.push.apply(keys, Object.getOwnPropertySymbols(object)); | ||
} | ||
if (enumerableOnly) keys = keys.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
ownKeys(source, true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(arguments[i])); | ||
ownKeys(source).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
@@ -1004,3 +1014,3 @@ } | ||
function fuzzyLevel(value) { | ||
if (!value) throw new Error('Required argument for `fuzzyLevel` is missing'); | ||
if (value === undefined || value === null) throw new Error('Required argument for `fuzzyLevel` is missing'); | ||
this.params.search.fuzzyLevel = value; | ||
@@ -1007,0 +1017,0 @@ return this; |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).CommercetoolsApiRequestBuilder={})}(this,function(e){"use strict";function s(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function o(r){for(var e=1;e<arguments.length;e++)if(e%2){var t=null!=arguments[e]?arguments[e]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(e){s(r,e,t[e])})}else Object.defineProperties(r,Object.getOwnPropertyDescriptors(arguments[e]));return r}var r="create",t="update",n="delete",u="query",c="queryOne",p="queryExpand",h="queryLocation",f="search",d="projection",y="suggest",i=Object.freeze({create:r,update:t,del:n,query:u,queryOne:c,queryExpand:p,queryLocation:h,search:f,projection:d,suggest:y}),a={login:{type:"login",endpoint:"/login",features:[r]},cartDiscounts:{type:"cart-discounts",endpoint:"/cart-discounts",features:[r,t,n,u,c,p]},carts:{type:"carts",endpoint:"/carts",features:[r,t,n,u,c,p]},categories:{type:"categories",endpoint:"/categories",features:[r,t,n,u,c,p]},channels:{type:"channels",endpoint:"/channels",features:[r,t,n,u,c,p]},customerGroups:{type:"customer-groups",endpoint:"/customer-groups",features:[r,t,n,u,c,p]},customers:{type:"customers",endpoint:"/customers",features:[r,t,n,u,c,p]},customersPassword:{type:"customers-password",endpoint:"/customers/password",features:[r]},customersPasswordToken:{type:"customers-password-token",endpoint:"/customers/password-token",features:[r,c]},customersPasswordReset:{type:"customers-password-reset",endpoint:"/customers/password/reset",features:[r]},customersEmailVerificationToken:{type:"customers-email-verification-token",endpoint:"/customers/customers/email-token",features:[r,c]},customersEmailVerification:{type:"customers-email-verification",endpoint:"/customers/customers/email/confirm",features:[r]},customObjects:{type:"custom-objects",endpoint:"/custom-objects",features:[r,t,n,u,c]},discountCodes:{type:"discount-codes",endpoint:"/discount-codes",features:[r,t,n,u,c,p]},extensions:{type:"extensions",endpoint:"/extensions",features:[r,t,n,u,c,p]},inventory:{type:"inventory",endpoint:"/inventory",features:[r,t,n,u,c,p]},messages:{type:"messages",endpoint:"/messages",features:[u,c,p]},myActiveCart:{type:"my-carts",endpoint:"/me/active-cart",features:[c]},myCarts:{type:"my-carts",endpoint:"/me/carts",features:[r,t,n,u,c,p]},myOrders:{type:"my-orders",endpoint:"/me/orders",features:[r,t,n,u,c,p]},orders:{type:"orders",endpoint:"/orders",features:[r,t,n,u,c,p]},orderEdits:{type:"orders-edits",endpoint:"/orders/edits",features:[r,t,n,u,c,p]},orderImport:{type:"orderImport",endpoint:"/orders/import",features:[r,u]},payments:{type:"payments",endpoint:"/payments",features:[r,t,n,u,c,p]},productDiscounts:{type:"product-discounts",endpoint:"/product-discounts",features:[r,t,n,u,c,p]},productProjections:{type:"product-projections",endpoint:"/product-projections",features:[u,c,p,d]},productProjectionsSearch:{type:"product-projections-search",endpoint:"/product-projections/search",features:[f,c,p,d]},productProjectionsSuggest:{type:"product-projections-suggest",endpoint:"/product-projections/suggest",features:[f,y,c,d]},products:{type:"products",endpoint:"/products",features:[r,t,n,u,c,p]},productTypes:{type:"product-types",endpoint:"/product-types",features:[r,t,n,u,c,p]},project:{type:"project",endpoint:"/",features:[t,u]},reviews:{type:"reviews",endpoint:"/reviews",features:[r,t,n,u,c,p]},shippingMethods:{type:"shipping-methods",endpoint:"/shipping-methods",features:[r,t,n,u,c,p,h]},shoppingLists:{type:"shopping-lists",endpoint:"/shopping-lists",features:[r,t,n,u,c,p]},states:{type:"states",endpoint:"/states",features:[r,t,n,u,c,p]},subscriptions:{type:"subscriptions",endpoint:"/subscriptions",features:[r,t,n,u,c,p]},taxCategories:{type:"tax-categories",endpoint:"/tax-categories",features:[r,t,n,u,c,p]},types:{type:"types",endpoint:"/types",features:[r,t,n,u,c,p]},zones:{type:"zones",endpoint:"/zones",features:[r,t,n,u,c,p]}};var m=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};function l(e){if("number"!=typeof e)throw new Error("A resource version is missing or invalid");return this.params.version=e,this}function g(){return this.params.dataErasure="dataErasure=true",this}function w(e){if("string"!=typeof e)throw new Error("A resource orderEditId is missing or invalid");return this.params.applyOrderEditTo=e,this}var b=Object.freeze({where:function(e){if(!e)throw new Error("Required argument for `where` is missing");var r=encodeURIComponent(e);return this.params.query.where.push(r),this},whereOperator:function(e){if(!e)throw new Error("Required argument for `whereOperator` is missing");if("and"!==e&&"or"!==e)throw new Error("Required argument for `whereOperator` is invalid, allowed values are (`and`, `or`)");return this.params.query.operator=e,this}});var v=Object.freeze({byId:function(e){if(!e)throw new Error("Required argument for `byId` is missing");if(this.params.key)throw new Error("A key for this resource has already been set. You cannot use both `byKey` and `byId`.");if(this.params.customerId)throw new Error("A customerId for this resource has already been set. You cannot use both `byId` and `byCustomerId`.");if(this.params.cartId)throw new Error("A cartId for this resource has already been set. You cannot use both `byId` and `byCartId`.");return this.params.id=e,this},byKey:function(e){if(!e)throw new Error("Required argument for `byKey` is missing");if(this.params.id)throw new Error("An ID for this resource has already been set. You cannot use both `byId` and `byKey`.");return this.params.key=e,this},byCustomerId:function(e){if(!e)throw new Error("Required argument for `byCustomerId` is missing");if(this.params.id)throw new Error("An ID for this resource has already been set. You cannot use both `byId` and `byCustomerId`.");return this.params.customerId=e,this},byCartId:function(e){if(!e)throw new Error("Required argument for `byCartId` is missing");if(this.params.id)throw new Error("An ID for this resource has already been set. You cannot use both `byId` and `byCartId`.");return this.params.cartId=e,this}});var E=Object.freeze({byCountry:function(e){if(!e)throw new Error("Required argument for `byCountry` is missing");return this.params.location.country=e,this},byCurrency:function(e){if(!e)throw new Error("Required argument for `byCurrency` is missing");if(!this.params.location.country)throw new Error("A `country` for this resource has not been set. You must set the country in order to use the `byCurrency` method.");return this.params.location.currency=e,this},byState:function(e){if(!e)throw new Error("Required argument for `byState` is missing");if(!this.params.location.country)throw new Error("A `country` for this resource has not been set. You must set the country in order to use the `byState` method.");return this.params.location.state=e,this}});var C=Object.freeze({expand:function(e){if(!e)throw new Error("Required argument for `expand` is missing");var r=encodeURIComponent(e);return this.params.expand.push(r),this}});var z=Object.freeze({sort:function(e){var r=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];if(!e)throw new Error("Required argument for `sort` is missing");var t=r?"asc":"desc",n=encodeURIComponent("".concat(e," ").concat(t));return this.params.pagination.sort.push(n),this},page:function(e){if("number"!=typeof e&&!e)throw new Error("Required argument for `page` is missing or invalid");if("number"!=typeof e||e<1)throw new Error("Required argument for `page` must be a number >= 1");return this.params.pagination.page=e,this},perPage:function(e){if("number"!=typeof e&&!e)throw new Error("Required argument for `perPage` is missing or invalid");if("number"!=typeof e||e<0)throw new Error("Required argument for `perPage` must be a number >= 0");return this.params.pagination.perPage=e,this},withTotal:function(){var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if("boolean"!=typeof e)throw new Error("Required argument for `withTotal` is missing or invalid");return this.params.pagination.withTotal=e,this}});var I=Object.freeze({staged:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0];return this.params.staged=e,this},priceCurrency:function(e){return this.params.priceCurrency=e,this},priceCountry:function(e){return this.params.priceCountry=e,this},priceCustomerGroup:function(e){return this.params.priceCustomerGroup=e,this},priceChannel:function(e){return this.params.priceChannel=e,this}});var j=Object.freeze({searchKeywords:function(e,r){if(!e||!r)throw new Error("Required arguments for `searchKeywords` are missing");return this.params.searchKeywords.push({lang:r,value:encodeURIComponent(e)}),this}});var O=Object.freeze({text:function(e,r){if(!e||!r)throw new Error("Required arguments for `text` are missing");return this.params.search.text={lang:r,value:encodeURIComponent(e)},this},fuzzy:function(){return this.params.search.fuzzy=!0,this},fuzzyLevel:function(e){if(!e)throw new Error("Required argument for `fuzzyLevel` is missing");return this.params.search.fuzzyLevel=e,this},markMatchingVariants:function(){return this.params.search.markMatchingVariants=!0,this},facet:function(e){if(!e)throw new Error("Required argument for `facet` is missing");var r=encodeURIComponent(e);return this.params.search.facet.push(r),this},filter:function(e){if(!e)throw new Error("Required argument for `filter` is missing");var r=encodeURIComponent(e);return this.params.search.filter.push(r),this},filterByQuery:function(e){if(!e)throw new Error("Required argument for `filterByQuery` is missing");var r=encodeURIComponent(e);return this.params.search.filterByQuery.push(r),this},filterByFacets:function(e){if(!e)throw new Error("Required argument for `filterByFacets` is missing");var r=encodeURIComponent(e);return this.params.search.filterByFacets.push(r),this}}),q=["type","endpoint","features"];function R(r,e){var i=1<arguments.length&&void 0!==e?e:"";if(!r)throw new Error("Cannot create a service without its definition.");if(q.forEach(function(e){if(!r[e])throw new Error("Definition is missing required parameter ".concat(e,"."))}),!Array.isArray(r.features)||!r.features.length)throw new Error("Definition requires `features` to be a non empty array.");if(!i)throw new Error("No project defined. Please enter a project key");var t=r.type,a=r.endpoint,n=r.features;return function(r,e){var t=1<arguments.length&&void 0!==e&&e,n={};return Object.keys(r).forEach(function(e){Object.defineProperty(n,e,{value:r[e],enumerable:!!t||"function"==typeof r[e]})}),n}(o({type:t,features:n,params:{id:null,expand:[],pagination:{page:null,perPage:null,sort:[],withTotal:null},location:{currency:"",country:"",state:""},query:{operator:"and",where:[]},searchKeywords:[]},withVersion:l,withFullDataErasure:g,applyOrderEditTo:w},n.reduce(function(e,r){return r===u?o({},e,{},b,{},z):r===c?o({},e,{},v):r===h?o({},e,{},E):r===p?o({},e,{},C):r===f?o({},e,{},O,{},z,{params:{expand:[],searchKeywords:[],pagination:{page:null,perPage:null,sort:[],withTotal:null},search:{facet:[],filter:[],filterByQuery:[],filterByFacets:[],fuzzy:!1,fuzzyLevel:0,markMatchingVariants:!1,text:null}}}):r===y?o({},e,{},O,{},z,{},j):r===d?o({},e,{},I):e},{}),{build:function(e){var r=0<arguments.length&&void 0!==e?e:{withProjectKey:!0,applyOrderEdit:!1},t=r.withProjectKey,n=r.applyOrderEdit,s=function(e){if(!e)throw new Error("Missing options object to build query string.");var r=e.query,t=e.pagination,n=e.search,s=e.expand,o=e.staged,i=e.priceCurrency,a=e.priceCountry,u=e.priceCustomerGroup,c=e.priceChannel,p=e.searchKeywords,h=e.version,f=e.customerId,d=e.cartId,y=e.location,m=e.dataErasure,l=e.applyOrderEditTo,g=[];if(f&&g.push("customerId=".concat(f)),d&&g.push("cartId=".concat(d)),"boolean"==typeof o&&g.push("staged=".concat(o.toString())),i&&g.push("priceCurrency=".concat(i)),a&&g.push("priceCountry=".concat(a)),u&&g.push("priceCustomerGroup=".concat(u)),c&&g.push("priceChannel=".concat(c)),s&&s.length&&(g=g.concat(s.map(function(e){return"expand=".concat(e)}))),r){var w=r.operator,b=r.where.join(encodeURIComponent(" ".concat(w," ")));b&&g.push("where=".concat(b))}if(y){var v=y.country,E=y.currency,C=y.state;v&&g.push("country=".concat(v)),E&&g.push("currency=".concat(E)),C&&g.push("state=".concat(C))}if(t){var z=t.page,I=t.perPage,j=t.sort,O=t.withTotal;if("number"==typeof I&&g.push("limit=".concat(I)),z){var q=(I||20)*(z-1);g.push("offset=".concat(q))}j&&j.length&&(g=g.concat(j.map(function(e){return"sort=".concat(e)}))),"boolean"==typeof O&&g.push("withTotal=".concat(String(O)))}if(n){var R=n.text,x=n.fuzzy,k=n.fuzzyLevel,P=n.markMatchingVariants,T=n.facet,B=n.filter,K=n.filterByQuery,A=n.filterByFacets;R&&g.push("text.".concat(R.lang,"=").concat(R.value)),x&&g.push("fuzzy=true"),k&&g.push("fuzzyLevel=".concat(k)),g.push("markMatchingVariants=".concat(P.toString())),T.forEach(function(e){return g.push("facet=".concat(e))}),B.forEach(function(e){return g.push("filter=".concat(e))}),K.forEach(function(e){return g.push("filter.query=".concat(e))}),A.forEach(function(e){return g.push("filter.facets=".concat(e))})}return p&&p.forEach(function(e){return g.push("searchKeywords.".concat(e.lang,"=").concat(e.value))}),h&&g.push("version=".concat(h)),m&&g.push(m),l&&g.push("/".concat(l,"/apply")),g.join("&")}(this.params),o=(t?"/".concat(i):"")+a+function(e){return e.id?"/".concat(e.id):e.key?"/key=".concat(e.key):""}(this.params)+(s&&!n?"?".concat(s):s);return function(){this.params.expand=[],this.features.includes(c)&&(this.params.id=null),this.features.includes(u)&&(this.params.pagination={page:null,perPage:null,sort:[],withTotal:null},this.params.query={operator:"and",where:[]}),this.features.includes(f)&&(this.params.pagination={page:null,perPage:null,sort:[],withTotal:null},this.params.search={facet:[],filter:[],filterByQuery:[],filterByFacets:[],fuzzy:!1,fuzzyLevel:0,markMatchingVariants:!1,text:null}),this.features.includes(h)&&(this.params.location={currency:"",country:"",state:""}),this.features.includes(y)&&(this.params.searchKeywords=[])}.call(this),o},parse:function(e){return function(e){var r=this,t=["expand","id","key","customerId","cartId","sort","page","perPage","staged","priceCurrency","priceCountry","priceCustomerGroup","priceChannel","text","fuzzy","fuzzyLevel","markMatchingVariants","facet","filter","filterByQuery","filterByFacets","searchKeywords","where","whereOperator","version","country","currency","state","dataErasure","withTotal","applyOrderEditTo"];Object.keys(e).forEach(function(e){if(!t.includes(e))throw new Error('Unknown key "'.concat(e,'"'))}),e.expand&&e.expand.forEach(function(e){r.expand(e)}),m(e,"id")&&this.byId(e.id),m(e,"key")&&this.byKey(e.key),m(e,"customerId")&&this.byCustomerId(e.customerId),m(e,"cartId")&&this.byCartId(e.cartId),m(e,"country")&&this.byCountry(e.country),m(e,"currency")&&this.byCurrency(e.currency),m(e,"state")&&this.byState(e.state),e.sort&&e.sort.forEach(function(e){r.sort(e.by,"asc"===e.direction)}),m(e,"page")&&this.page(e.page),m(e,"perPage")&&this.perPage(e.perPage),m(e,"staged")&&this.staged(e.staged),m(e,"priceCurrency")&&this.priceCurrency(e.priceCurrency),m(e,"priceCountry")&&this.priceCountry(e.priceCountry),m(e,"priceCustomerGroup")&&this.priceCustomerGroup(e.priceCustomerGroup),m(e,"priceChannel")&&this.priceChannel(e.priceChannel),e.text&&this.text(e.text.value,e.text.language),e.fuzzy&&this.fuzzy(),m(e,"fuzzyLevel")&&this.fuzzyLevel(e.fuzzyLevel),e.markMatchingVariants&&this.markMatchingVariants(),e.facet&&e.facet.forEach(function(e){r.facet(e)}),e.filter&&e.filter.forEach(function(e){r.filter(e)}),e.filterByQuery&&e.filterByQuery.forEach(function(e){r.filterByQuery(e)}),e.filterByFacets&&e.filterByFacets.forEach(function(e){r.filterByFacets(e)}),e.searchKeywords&&e.searchKeywords.forEach(function(e){r.searchKeywords(e.value,e.language)}),e.where&&e.where.forEach(function(e){r.where(e)}),m(e,"whereOperator")&&this.whereOperator(e.whereOperator),m(e,"version")&&this.withVersion(e.version),m(e,"dataErasure")&&this.withFullDataErasure(),m(e,"withTotal")&&this.withTotal(e.withTotal),m(e,"applyOrderEditTo")&&this.applyOrderEditTo(e.applyOrderEditTo)}.call(this,e),this}}))}e.createRequestBuilder=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=o({},a,{},t.customServices);return Object.keys(n).reduce(function(e,r){return o({},e,s({},r,R(n[r],t.projectKey)))},{})},e.features=i,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).CommercetoolsApiRequestBuilder={})}(this,function(e){"use strict";function s(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(r,e){var t=Object.keys(r);return Object.getOwnPropertySymbols&&t.push.apply(t,Object.getOwnPropertySymbols(r)),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),t}function o(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?n(t,!0).forEach(function(e){s(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):n(t).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}var r="create",t="update",i="delete",u="query",c="queryOne",p="queryExpand",h="queryLocation",f="search",d="projection",y="suggest",a=Object.freeze({create:r,update:t,del:i,query:u,queryOne:c,queryExpand:p,queryLocation:h,search:f,projection:d,suggest:y}),m={login:{type:"login",endpoint:"/login",features:[r]},cartDiscounts:{type:"cart-discounts",endpoint:"/cart-discounts",features:[r,t,i,u,c,p]},carts:{type:"carts",endpoint:"/carts",features:[r,t,i,u,c,p]},categories:{type:"categories",endpoint:"/categories",features:[r,t,i,u,c,p]},channels:{type:"channels",endpoint:"/channels",features:[r,t,i,u,c,p]},customerGroups:{type:"customer-groups",endpoint:"/customer-groups",features:[r,t,i,u,c,p]},customers:{type:"customers",endpoint:"/customers",features:[r,t,i,u,c,p]},customersPassword:{type:"customers-password",endpoint:"/customers/password",features:[r]},customersPasswordToken:{type:"customers-password-token",endpoint:"/customers/password-token",features:[r,c]},customersPasswordReset:{type:"customers-password-reset",endpoint:"/customers/password/reset",features:[r]},customersEmailVerificationToken:{type:"customers-email-verification-token",endpoint:"/customers/customers/email-token",features:[r,c]},customersEmailVerification:{type:"customers-email-verification",endpoint:"/customers/customers/email/confirm",features:[r]},customObjects:{type:"custom-objects",endpoint:"/custom-objects",features:[r,t,i,u,c]},discountCodes:{type:"discount-codes",endpoint:"/discount-codes",features:[r,t,i,u,c,p]},extensions:{type:"extensions",endpoint:"/extensions",features:[r,t,i,u,c,p]},inventory:{type:"inventory",endpoint:"/inventory",features:[r,t,i,u,c,p]},messages:{type:"messages",endpoint:"/messages",features:[u,c,p]},myActiveCart:{type:"my-carts",endpoint:"/me/active-cart",features:[c]},myCarts:{type:"my-carts",endpoint:"/me/carts",features:[r,t,i,u,c,p]},myOrders:{type:"my-orders",endpoint:"/me/orders",features:[r,t,i,u,c,p]},orders:{type:"orders",endpoint:"/orders",features:[r,t,i,u,c,p]},orderEdits:{type:"orders-edits",endpoint:"/orders/edits",features:[r,t,i,u,c,p]},orderImport:{type:"orderImport",endpoint:"/orders/import",features:[r,u]},payments:{type:"payments",endpoint:"/payments",features:[r,t,i,u,c,p]},productDiscounts:{type:"product-discounts",endpoint:"/product-discounts",features:[r,t,i,u,c,p]},productProjections:{type:"product-projections",endpoint:"/product-projections",features:[u,c,p,d]},productProjectionsSearch:{type:"product-projections-search",endpoint:"/product-projections/search",features:[f,c,p,d]},productProjectionsSuggest:{type:"product-projections-suggest",endpoint:"/product-projections/suggest",features:[f,y,c,d]},products:{type:"products",endpoint:"/products",features:[r,t,i,u,c,p]},productTypes:{type:"product-types",endpoint:"/product-types",features:[r,t,i,u,c,p]},project:{type:"project",endpoint:"/",features:[t,u]},reviews:{type:"reviews",endpoint:"/reviews",features:[r,t,i,u,c,p]},shippingMethods:{type:"shipping-methods",endpoint:"/shipping-methods",features:[r,t,i,u,c,p,h]},shoppingLists:{type:"shopping-lists",endpoint:"/shopping-lists",features:[r,t,i,u,c,p]},states:{type:"states",endpoint:"/states",features:[r,t,i,u,c,p]},subscriptions:{type:"subscriptions",endpoint:"/subscriptions",features:[r,t,i,u,c,p]},taxCategories:{type:"tax-categories",endpoint:"/tax-categories",features:[r,t,i,u,c,p]},types:{type:"types",endpoint:"/types",features:[r,t,i,u,c,p]},zones:{type:"zones",endpoint:"/zones",features:[r,t,i,u,c,p]}};var l=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};function g(e){if("number"!=typeof e)throw new Error("A resource version is missing or invalid");return this.params.version=e,this}function w(){return this.params.dataErasure="dataErasure=true",this}function b(e){if("string"!=typeof e)throw new Error("A resource orderEditId is missing or invalid");return this.params.applyOrderEditTo=e,this}var v=Object.freeze({where:function(e){if(!e)throw new Error("Required argument for `where` is missing");var r=encodeURIComponent(e);return this.params.query.where.push(r),this},whereOperator:function(e){if(!e)throw new Error("Required argument for `whereOperator` is missing");if("and"!==e&&"or"!==e)throw new Error("Required argument for `whereOperator` is invalid, allowed values are (`and`, `or`)");return this.params.query.operator=e,this}});var E=Object.freeze({byId:function(e){if(!e)throw new Error("Required argument for `byId` is missing");if(this.params.key)throw new Error("A key for this resource has already been set. You cannot use both `byKey` and `byId`.");if(this.params.customerId)throw new Error("A customerId for this resource has already been set. You cannot use both `byId` and `byCustomerId`.");if(this.params.cartId)throw new Error("A cartId for this resource has already been set. You cannot use both `byId` and `byCartId`.");return this.params.id=e,this},byKey:function(e){if(!e)throw new Error("Required argument for `byKey` is missing");if(this.params.id)throw new Error("An ID for this resource has already been set. You cannot use both `byId` and `byKey`.");return this.params.key=e,this},byCustomerId:function(e){if(!e)throw new Error("Required argument for `byCustomerId` is missing");if(this.params.id)throw new Error("An ID for this resource has already been set. You cannot use both `byId` and `byCustomerId`.");return this.params.customerId=e,this},byCartId:function(e){if(!e)throw new Error("Required argument for `byCartId` is missing");if(this.params.id)throw new Error("An ID for this resource has already been set. You cannot use both `byId` and `byCartId`.");return this.params.cartId=e,this}});var C=Object.freeze({byCountry:function(e){if(!e)throw new Error("Required argument for `byCountry` is missing");return this.params.location.country=e,this},byCurrency:function(e){if(!e)throw new Error("Required argument for `byCurrency` is missing");if(!this.params.location.country)throw new Error("A `country` for this resource has not been set. You must set the country in order to use the `byCurrency` method.");return this.params.location.currency=e,this},byState:function(e){if(!e)throw new Error("Required argument for `byState` is missing");if(!this.params.location.country)throw new Error("A `country` for this resource has not been set. You must set the country in order to use the `byState` method.");return this.params.location.state=e,this}});var z=Object.freeze({expand:function(e){if(!e)throw new Error("Required argument for `expand` is missing");var r=encodeURIComponent(e);return this.params.expand.push(r),this}});var O=Object.freeze({sort:function(e){var r=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];if(!e)throw new Error("Required argument for `sort` is missing");var t=r?"asc":"desc",n=encodeURIComponent("".concat(e," ").concat(t));return this.params.pagination.sort.push(n),this},page:function(e){if("number"!=typeof e&&!e)throw new Error("Required argument for `page` is missing or invalid");if("number"!=typeof e||e<1)throw new Error("Required argument for `page` must be a number >= 1");return this.params.pagination.page=e,this},perPage:function(e){if("number"!=typeof e&&!e)throw new Error("Required argument for `perPage` is missing or invalid");if("number"!=typeof e||e<0)throw new Error("Required argument for `perPage` must be a number >= 0");return this.params.pagination.perPage=e,this},withTotal:function(){var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if("boolean"!=typeof e)throw new Error("Required argument for `withTotal` is missing or invalid");return this.params.pagination.withTotal=e,this}});var I=Object.freeze({staged:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0];return this.params.staged=e,this},priceCurrency:function(e){return this.params.priceCurrency=e,this},priceCountry:function(e){return this.params.priceCountry=e,this},priceCustomerGroup:function(e){return this.params.priceCustomerGroup=e,this},priceChannel:function(e){return this.params.priceChannel=e,this}});var j=Object.freeze({searchKeywords:function(e,r){if(!e||!r)throw new Error("Required arguments for `searchKeywords` are missing");return this.params.searchKeywords.push({lang:r,value:encodeURIComponent(e)}),this}});var q=Object.freeze({text:function(e,r){if(!e||!r)throw new Error("Required arguments for `text` are missing");return this.params.search.text={lang:r,value:encodeURIComponent(e)},this},fuzzy:function(){return this.params.search.fuzzy=!0,this},fuzzyLevel:function(e){if(null==e)throw new Error("Required argument for `fuzzyLevel` is missing");return this.params.search.fuzzyLevel=e,this},markMatchingVariants:function(){return this.params.search.markMatchingVariants=!0,this},facet:function(e){if(!e)throw new Error("Required argument for `facet` is missing");var r=encodeURIComponent(e);return this.params.search.facet.push(r),this},filter:function(e){if(!e)throw new Error("Required argument for `filter` is missing");var r=encodeURIComponent(e);return this.params.search.filter.push(r),this},filterByQuery:function(e){if(!e)throw new Error("Required argument for `filterByQuery` is missing");var r=encodeURIComponent(e);return this.params.search.filterByQuery.push(r),this},filterByFacets:function(e){if(!e)throw new Error("Required argument for `filterByFacets` is missing");var r=encodeURIComponent(e);return this.params.search.filterByFacets.push(r),this}}),R=["type","endpoint","features"];function x(r,e){var i=1<arguments.length&&void 0!==e?e:"";if(!r)throw new Error("Cannot create a service without its definition.");if(R.forEach(function(e){if(!r[e])throw new Error("Definition is missing required parameter ".concat(e,"."))}),!Array.isArray(r.features)||!r.features.length)throw new Error("Definition requires `features` to be a non empty array.");if(!i)throw new Error("No project defined. Please enter a project key");var t=r.type,a=r.endpoint,n=r.features;return function(r,e){var t=1<arguments.length&&void 0!==e&&e,n={};return Object.keys(r).forEach(function(e){Object.defineProperty(n,e,{value:r[e],enumerable:!!t||"function"==typeof r[e]})}),n}(o({type:t,features:n,params:{id:null,expand:[],pagination:{page:null,perPage:null,sort:[],withTotal:null},location:{currency:"",country:"",state:""},query:{operator:"and",where:[]},searchKeywords:[]},withVersion:g,withFullDataErasure:w,applyOrderEditTo:b},n.reduce(function(e,r){return r===u?o({},e,{},v,{},O):r===c?o({},e,{},E):r===h?o({},e,{},C):r===p?o({},e,{},z):r===f?o({},e,{},q,{},O,{params:{expand:[],searchKeywords:[],pagination:{page:null,perPage:null,sort:[],withTotal:null},search:{facet:[],filter:[],filterByQuery:[],filterByFacets:[],fuzzy:!1,fuzzyLevel:0,markMatchingVariants:!1,text:null}}}):r===y?o({},e,{},q,{},O,{},j):r===d?o({},e,{},I):e},{}),{build:function(e){var r=0<arguments.length&&void 0!==e?e:{withProjectKey:!0,applyOrderEdit:!1},t=r.withProjectKey,n=r.applyOrderEdit,s=function(e){if(!e)throw new Error("Missing options object to build query string.");var r=e.query,t=e.pagination,n=e.search,s=e.expand,o=e.staged,i=e.priceCurrency,a=e.priceCountry,u=e.priceCustomerGroup,c=e.priceChannel,p=e.searchKeywords,h=e.version,f=e.customerId,d=e.cartId,y=e.location,m=e.dataErasure,l=e.applyOrderEditTo,g=[];if(f&&g.push("customerId=".concat(f)),d&&g.push("cartId=".concat(d)),"boolean"==typeof o&&g.push("staged=".concat(o.toString())),i&&g.push("priceCurrency=".concat(i)),a&&g.push("priceCountry=".concat(a)),u&&g.push("priceCustomerGroup=".concat(u)),c&&g.push("priceChannel=".concat(c)),s&&s.length&&(g=g.concat(s.map(function(e){return"expand=".concat(e)}))),r){var w=r.operator,b=r.where.join(encodeURIComponent(" ".concat(w," ")));b&&g.push("where=".concat(b))}if(y){var v=y.country,E=y.currency,C=y.state;v&&g.push("country=".concat(v)),E&&g.push("currency=".concat(E)),C&&g.push("state=".concat(C))}if(t){var z=t.page,O=t.perPage,I=t.sort,j=t.withTotal;if("number"==typeof O&&g.push("limit=".concat(O)),z){var q=(O||20)*(z-1);g.push("offset=".concat(q))}I&&I.length&&(g=g.concat(I.map(function(e){return"sort=".concat(e)}))),"boolean"==typeof j&&g.push("withTotal=".concat(String(j)))}if(n){var R=n.text,x=n.fuzzy,P=n.fuzzyLevel,k=n.markMatchingVariants,T=n.facet,B=n.filter,K=n.filterByQuery,A=n.filterByFacets;R&&g.push("text.".concat(R.lang,"=").concat(R.value)),x&&g.push("fuzzy=true"),P&&g.push("fuzzyLevel=".concat(P)),g.push("markMatchingVariants=".concat(k.toString())),T.forEach(function(e){return g.push("facet=".concat(e))}),B.forEach(function(e){return g.push("filter=".concat(e))}),K.forEach(function(e){return g.push("filter.query=".concat(e))}),A.forEach(function(e){return g.push("filter.facets=".concat(e))})}return p&&p.forEach(function(e){return g.push("searchKeywords.".concat(e.lang,"=").concat(e.value))}),h&&g.push("version=".concat(h)),m&&g.push(m),l&&g.push("/".concat(l,"/apply")),g.join("&")}(this.params),o=(t?"/".concat(i):"")+a+function(e){return e.id?"/".concat(e.id):e.key?"/key=".concat(e.key):""}(this.params)+(s&&!n?"?".concat(s):s);return function(){this.params.expand=[],this.features.includes(c)&&(this.params.id=null),this.features.includes(u)&&(this.params.pagination={page:null,perPage:null,sort:[],withTotal:null},this.params.query={operator:"and",where:[]}),this.features.includes(f)&&(this.params.pagination={page:null,perPage:null,sort:[],withTotal:null},this.params.search={facet:[],filter:[],filterByQuery:[],filterByFacets:[],fuzzy:!1,fuzzyLevel:0,markMatchingVariants:!1,text:null}),this.features.includes(h)&&(this.params.location={currency:"",country:"",state:""}),this.features.includes(y)&&(this.params.searchKeywords=[])}.call(this),o},parse:function(e){return function(e){var r=this,t=["expand","id","key","customerId","cartId","sort","page","perPage","staged","priceCurrency","priceCountry","priceCustomerGroup","priceChannel","text","fuzzy","fuzzyLevel","markMatchingVariants","facet","filter","filterByQuery","filterByFacets","searchKeywords","where","whereOperator","version","country","currency","state","dataErasure","withTotal","applyOrderEditTo"];Object.keys(e).forEach(function(e){if(!t.includes(e))throw new Error('Unknown key "'.concat(e,'"'))}),e.expand&&e.expand.forEach(function(e){r.expand(e)}),l(e,"id")&&this.byId(e.id),l(e,"key")&&this.byKey(e.key),l(e,"customerId")&&this.byCustomerId(e.customerId),l(e,"cartId")&&this.byCartId(e.cartId),l(e,"country")&&this.byCountry(e.country),l(e,"currency")&&this.byCurrency(e.currency),l(e,"state")&&this.byState(e.state),e.sort&&e.sort.forEach(function(e){r.sort(e.by,"asc"===e.direction)}),l(e,"page")&&this.page(e.page),l(e,"perPage")&&this.perPage(e.perPage),l(e,"staged")&&this.staged(e.staged),l(e,"priceCurrency")&&this.priceCurrency(e.priceCurrency),l(e,"priceCountry")&&this.priceCountry(e.priceCountry),l(e,"priceCustomerGroup")&&this.priceCustomerGroup(e.priceCustomerGroup),l(e,"priceChannel")&&this.priceChannel(e.priceChannel),e.text&&this.text(e.text.value,e.text.language),e.fuzzy&&this.fuzzy(),l(e,"fuzzyLevel")&&this.fuzzyLevel(e.fuzzyLevel),e.markMatchingVariants&&this.markMatchingVariants(),e.facet&&e.facet.forEach(function(e){r.facet(e)}),e.filter&&e.filter.forEach(function(e){r.filter(e)}),e.filterByQuery&&e.filterByQuery.forEach(function(e){r.filterByQuery(e)}),e.filterByFacets&&e.filterByFacets.forEach(function(e){r.filterByFacets(e)}),e.searchKeywords&&e.searchKeywords.forEach(function(e){r.searchKeywords(e.value,e.language)}),e.where&&e.where.forEach(function(e){r.where(e)}),l(e,"whereOperator")&&this.whereOperator(e.whereOperator),l(e,"version")&&this.withVersion(e.version),l(e,"dataErasure")&&this.withFullDataErasure(),l(e,"withTotal")&&this.withTotal(e.withTotal),l(e,"applyOrderEditTo")&&this.applyOrderEditTo(e.applyOrderEditTo)}.call(this,e),this}}))}e.createRequestBuilder=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=o({},m,{},t.customServices);return Object.keys(n).reduce(function(e,r){return o({},e,s({},r,x(n[r],t.projectKey)))},{})},e.features=a,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=commercetools-api-request-builder.umd.min.js.map |
@@ -7,3 +7,3 @@ { | ||
"name": "@commercetools/api-request-builder", | ||
"version": "5.3.1", | ||
"version": "5.3.2", | ||
"description": "Helper functions to construct API requests URI for the commercetools platform in a declarative way.", | ||
@@ -39,3 +39,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "b43af701481792e883437b92be227ce8bc2e0130" | ||
"gitHead": "7e40ecd0e158b43b584b15179ff7b5c2dd38655c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
412002
3356