@commercetools/api-request-builder
Advanced tools
Comparing version 3.7.2 to 3.8.0
@@ -332,3 +332,3 @@ 'use strict'; | ||
// verify params | ||
var knownKeys = ['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']; | ||
var knownKeys = ['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']; | ||
Object.keys(params).forEach(function (key) { | ||
@@ -399,2 +399,5 @@ if (!(knownKeys.indexOf(key) !== -1)) throw new Error('Unknown key "' + key + '"'); | ||
if (hasKey(params, 'version')) this.withVersion(params.version); | ||
// dataErasure | ||
if (hasKey(params, 'dataErasure')) this.withFullDataErasure(); | ||
} | ||
@@ -449,3 +452,4 @@ | ||
cartId = params.cartId, | ||
location = params.location; | ||
location = params.location, | ||
dataErasure = params.dataErasure; | ||
@@ -542,2 +546,4 @@ var queryString = []; | ||
if (dataErasure) queryString.push(dataErasure); | ||
return queryString.join('&'); | ||
@@ -563,3 +569,21 @@ } | ||
/* */ | ||
/** | ||
* Set the `dataErasure` option to the internal state of the service instance | ||
* in order to generate a DELETE uri that guarantees that all personal data related to | ||
* the particular object, including invisible data, is erased, in compliance with the GDPR. | ||
* | ||
* Users are, however, responsible for identifying and deleting all objects that belong to a customer, and deleting them. | ||
* | ||
* More info here: https://docs.commercetools.com/release-notes#releases-2018-05-24-data-erasure | ||
* | ||
* @return {Object} The instance of the service, can be chained. | ||
*/ | ||
function withFullDataErasure() { | ||
this.params.dataErasure = 'dataErasure=true'; | ||
return this; | ||
} | ||
/** | ||
* Set the given `predicate` to the internal state of the service instance. | ||
@@ -1109,3 +1133,4 @@ * | ||
params: getDefaultQueryParams(), | ||
withVersion: withVersion | ||
withVersion: withVersion, | ||
withFullDataErasure: withFullDataErasure | ||
@@ -1112,0 +1137,0 @@ }, features.reduce(function (acc, feature) { |
@@ -328,3 +328,3 @@ /** | ||
// verify params | ||
var knownKeys = ['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']; | ||
var knownKeys = ['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']; | ||
Object.keys(params).forEach(function (key) { | ||
@@ -395,2 +395,5 @@ if (!(knownKeys.indexOf(key) !== -1)) throw new Error('Unknown key "' + key + '"'); | ||
if (hasKey(params, 'version')) this.withVersion(params.version); | ||
// dataErasure | ||
if (hasKey(params, 'dataErasure')) this.withFullDataErasure(); | ||
} | ||
@@ -445,3 +448,4 @@ | ||
cartId = params.cartId, | ||
location = params.location; | ||
location = params.location, | ||
dataErasure = params.dataErasure; | ||
@@ -538,2 +542,4 @@ var queryString = []; | ||
if (dataErasure) queryString.push(dataErasure); | ||
return queryString.join('&'); | ||
@@ -559,3 +565,21 @@ } | ||
/* */ | ||
/** | ||
* Set the `dataErasure` option to the internal state of the service instance | ||
* in order to generate a DELETE uri that guarantees that all personal data related to | ||
* the particular object, including invisible data, is erased, in compliance with the GDPR. | ||
* | ||
* Users are, however, responsible for identifying and deleting all objects that belong to a customer, and deleting them. | ||
* | ||
* More info here: https://docs.commercetools.com/release-notes#releases-2018-05-24-data-erasure | ||
* | ||
* @return {Object} The instance of the service, can be chained. | ||
*/ | ||
function withFullDataErasure() { | ||
this.params.dataErasure = 'dataErasure=true'; | ||
return this; | ||
} | ||
/** | ||
* Set the given `predicate` to the internal state of the service instance. | ||
@@ -1105,3 +1129,4 @@ * | ||
params: getDefaultQueryParams(), | ||
withVersion: withVersion | ||
withVersion: withVersion, | ||
withFullDataErasure: withFullDataErasure | ||
@@ -1108,0 +1133,0 @@ }, features.reduce(function (acc, feature) { |
@@ -334,3 +334,3 @@ (function (global, factory) { | ||
// verify params | ||
var knownKeys = ['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']; | ||
var knownKeys = ['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']; | ||
Object.keys(params).forEach(function (key) { | ||
@@ -401,2 +401,5 @@ if (!(knownKeys.indexOf(key) !== -1)) throw new Error('Unknown key "' + key + '"'); | ||
if (hasKey(params, 'version')) this.withVersion(params.version); | ||
// dataErasure | ||
if (hasKey(params, 'dataErasure')) this.withFullDataErasure(); | ||
} | ||
@@ -451,3 +454,4 @@ | ||
cartId = params.cartId, | ||
location = params.location; | ||
location = params.location, | ||
dataErasure = params.dataErasure; | ||
@@ -544,2 +548,4 @@ var queryString = []; | ||
if (dataErasure) queryString.push(dataErasure); | ||
return queryString.join('&'); | ||
@@ -565,3 +571,21 @@ } | ||
/* */ | ||
/** | ||
* Set the `dataErasure` option to the internal state of the service instance | ||
* in order to generate a DELETE uri that guarantees that all personal data related to | ||
* the particular object, including invisible data, is erased, in compliance with the GDPR. | ||
* | ||
* Users are, however, responsible for identifying and deleting all objects that belong to a customer, and deleting them. | ||
* | ||
* More info here: https://docs.commercetools.com/release-notes#releases-2018-05-24-data-erasure | ||
* | ||
* @return {Object} The instance of the service, can be chained. | ||
*/ | ||
function withFullDataErasure() { | ||
this.params.dataErasure = 'dataErasure=true'; | ||
return this; | ||
} | ||
/** | ||
* Set the given `predicate` to the internal state of the service instance. | ||
@@ -1111,3 +1135,4 @@ * | ||
params: getDefaultQueryParams(), | ||
withVersion: withVersion | ||
withVersion: withVersion, | ||
withFullDataErasure: withFullDataErasure | ||
@@ -1114,0 +1139,0 @@ }, features.reduce(function (acc, feature) { |
@@ -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.CommercetoolsApiRequestBuilder={})}(this,function(e){"use strict";var r="create",t="update",s="delete",i="query",a="queryOne",u="queryExpand",c="queryLocation",p="search",f="projection",h="suggest",n=Object.freeze({create:r,update:t,del:s,query:i,queryOne:a,queryExpand:u,queryLocation:c,search:p,projection:f,suggest:h}),o={login:{type:"login",endpoint:"/login",features:[r]},cartDiscounts:{type:"cart-discounts",endpoint:"/cart-discounts",features:[r,t,s,i,a,u]},carts:{type:"carts",endpoint:"/carts",features:[r,t,s,i,a,u]},categories:{type:"categories",endpoint:"/categories",features:[r,t,s,i,a,u]},channels:{type:"channels",endpoint:"/channels",features:[r,t,s,i,a,u]},customerGroups:{type:"customer-groups",endpoint:"/customer-groups",features:[r,t,s,i,a,u]},customers:{type:"customers",endpoint:"/customers",features:[r,t,s,i,a,u]},customersPassword:{type:"customers-password",endpoint:"/customers/password",features:[r]},customersPasswordToken:{type:"customers-password-token",endpoint:"/customers/password-token",features:[r,a]},customersPasswordReset:{type:"customers-password-reset",endpoint:"/customers/password/reset",features:[r]},customersEmailVerificationToken:{type:"customers-email-verification-token",endpoint:"/customers/customers/email-token",features:[r,a]},customersEmailVerification:{type:"customers-email-verification",endpoint:"/customers/customers/email/confirm",features:[r]},customObjects:{type:"custom-objects",endpoint:"/custom-objects",features:[r,t,s,i,a]},discountCodes:{type:"discount-codes",endpoint:"/discount-codes",features:[r,t,s,i,a,u]},extensions:{type:"extensions",endpoint:"/extensions",features:[r,t,s,i,a,u]},inventory:{type:"inventory",endpoint:"/inventory",features:[r,t,s,i,a,u]},messages:{type:"messages",endpoint:"/messages",features:[i,a,u]},myCarts:{type:"my-carts",endpoint:"/me/carts",features:[r,t,s,i,a,u]},myOrders:{type:"my-orders",endpoint:"/me/orders",features:[r,t,s,i,a,u]},orders:{type:"orders",endpoint:"/orders",features:[r,t,s,i,a,u]},orderImport:{type:"orderImport",endpoint:"/orders/import",features:[r,i]},payments:{type:"payments",endpoint:"/payments",features:[r,t,s,i,a,u]},productDiscounts:{type:"product-discounts",endpoint:"/product-discounts",features:[r,t,s,i,a,u]},productProjections:{type:"product-projections",endpoint:"/product-projections",features:[i,a,u,f]},productProjectionsSearch:{type:"product-projections-search",endpoint:"/product-projections/search",features:[p,a,u,f]},productProjectionsSuggest:{type:"product-projections-suggest",endpoint:"/product-projections/suggest",features:[p,h,a,f]},products:{type:"products",endpoint:"/products",features:[r,t,s,i,a,u]},productTypes:{type:"product-types",endpoint:"/product-types",features:[r,t,s,i,a,u]},project:{type:"project",endpoint:"/",features:[t,i]},reviews:{type:"reviews",endpoint:"/reviews",features:[r,t,s,i,a,u]},shippingMethods:{type:"shipping-methods",endpoint:"/shipping-methods",features:[r,t,s,i,a,u,c]},shoppingLists:{type:"shopping-lists",endpoint:"/shopping-lists",features:[r,t,s,i,a,u]},states:{type:"states",endpoint:"/states",features:[r,t,s,i,a,u]},subscriptions:{type:"subscriptions",endpoint:"/subscriptions",features:[r,t,s,i,a,u]},taxCategories:{type:"tax-categories",endpoint:"/tax-categories",features:[r,t,s,i,a,u]},types:{type:"types",endpoint:"/types",features:[r,t,s,i,a,u]},zones:{type:"zones",endpoint:"/zones",features:[r,t,s,i,a,u]}};var d=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};function y(e){if("number"!=typeof e)throw new Error("A resource version is missing or invalid");return this.params.version=e,this}var m=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 l=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 g=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 w=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 b=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=encodeURIComponent(e+" "+(r?"asc":"desc"));return this.params.pagination.sort.push(t),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}});var v=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 C=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 E=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}}),z=function(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e},I=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},j=["type","endpoint","features"];function q(r){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";if(!r)throw new Error("Cannot create a service without its definition.");if(j.forEach(function(e){if(!r[e])throw new Error("Definition is missing required parameter "+e+".")}),!Array.isArray(r.features)||!r.features.length)throw new Error("Definition requires `features` to be a non empty array.");if(!n)throw new Error("No project defined. Please enter a project key");var e=r.type,o=r.endpoint,t=r.features;return function(r){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],s={};return Object.keys(r).forEach(function(e){Object.defineProperty(s,e,{value:r[e],enumerable:!!t||"function"==typeof r[e]})}),s}(I({type:e,features:t,params:{id:null,expand:[],pagination:{page:null,perPage:null,sort:[]},location:{currency:"",country:"",state:""},query:{operator:"and",where:[]},searchKeywords:[]},withVersion:y},t.reduce(function(e,r){return r===i?I({},e,m,b):r===a?I({},e,l):r===c?I({},e,g):r===u?I({},e,w):r===p?I({},e,E,b,{params:{expand:[],searchKeywords:[],staged:!0,pagination:{page:null,perPage:null,sort:[]},search:{facet:[],filter:[],filterByQuery:[],filterByFacets:[],fuzzy:!1,fuzzyLevel:0,markMatchingVariants:!1,text:null}}}):r===h?I({},e,E,b,C):r===f?I({},e,v):e},{}),{build:function(){var e,r=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{withProjectKey:!0}).withProjectKey,t=function(e){if(!e)throw new Error("Missing options object to build query string.");var r=e.query,t=e.pagination,s=e.search,n=e.expand,o=e.staged,i=e.priceCurrency,a=e.priceCountry,u=e.priceCustomerGroup,c=e.priceChannel,p=e.searchKeywords,f=e.version,h=e.customerId,d=e.cartId,y=e.location,m=[];if(h&&m.push("customerId="+h),d&&m.push("cartId="+d),"boolean"==typeof o&&m.push("staged="+o.toString()),i&&m.push("priceCurrency="+i),a&&m.push("priceCountry="+a),u&&m.push("priceCustomerGroup="+u),c&&m.push("priceChannel="+c),n&&n.length&&(m=m.concat(n.map(function(e){return"expand="+e}))),r){var l=r.operator,g=r.where.join(encodeURIComponent(" "+l+" "));g&&m.push("where="+g)}if(y){var w=y.country,b=y.currency,v=y.state;w&&m.push("country="+w),b&&m.push("currency="+b),v&&m.push("state="+v)}if(t){var C=t.page,E=t.perPage,z=t.sort;if("number"==typeof E&&m.push("limit="+E),C){var I=(E||20)*(C-1);m.push("offset="+I)}z&&z.length&&(m=m.concat(z.map(function(e){return"sort="+e})))}if(s){var j=s.text,q=s.fuzzy,x=s.fuzzyLevel,O=s.markMatchingVariants,R=s.facet,k=s.filter,P=s.filterByQuery,B=s.filterByFacets;j&&m.push("text."+j.lang+"="+j.value),q&&m.push("fuzzy=true"),x&&m.push("fuzzyLevel="+x),m.push("markMatchingVariants="+O.toString()),R.forEach(function(e){return m.push("facet="+e)}),k.forEach(function(e){return m.push("filter="+e)}),P.forEach(function(e){return m.push("filter.query="+e)}),B.forEach(function(e){return m.push("filter.facets="+e)})}return p&&p.forEach(function(e){return m.push("searchKeywords."+e.lang+"="+e.value)}),f&&m.push("version="+f),m.join("&")}(this.params),s=(r?"/"+n:"")+o+((e=this.params).id?"/"+e.id:e.key?"/key="+e.key:"")+(t?"?"+t:"");return function(){this.params.expand=[],-1!==this.features.indexOf(a)&&(this.params.id=null),-1!==this.features.indexOf(i)&&(this.params.pagination={page:null,perPage:null,sort:[]},this.params.query={operator:"and",where:[]}),-1!==this.features.indexOf(p)&&(this.params.staged=!0,this.params.pagination={page:null,perPage:null,sort:[]},this.params.search={facet:[],filter:[],filterByQuery:[],filterByFacets:[],fuzzy:!1,fuzzyLevel:0,markMatchingVariants:!1,text:null}),-1!==this.features.indexOf(c)&&(this.params.location={currency:"",country:"",state:""}),-1!==this.features.indexOf(f)&&(this.params.staged=!0),-1!==this.features.indexOf(h)&&(this.params.searchKeywords=[])}.call(this),s},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"];Object.keys(e).forEach(function(e){if(-1===t.indexOf(e))throw new Error('Unknown key "'+e+'"')}),e.expand&&e.expand.forEach(function(e){r.expand(e)}),d(e,"id")&&this.byId(e.id),d(e,"key")&&this.byKey(e.key),d(e,"customerId")&&this.byCustomerId(e.customerId),d(e,"cartId")&&this.byCartId(e.cartId),d(e,"country")&&this.byCountry(e.country),d(e,"currency")&&this.byCurrency(e.currency),d(e,"state")&&this.byState(e.state),e.sort&&e.sort.forEach(function(e){r.sort(e.by,"asc"===e.direction)}),d(e,"page")&&this.page(e.page),d(e,"perPage")&&this.perPage(e.perPage),d(e,"staged")&&this.staged(e.staged),d(e,"priceCurrency")&&this.priceCurrency(e.priceCurrency),d(e,"priceCountry")&&this.priceCountry(e.priceCountry),d(e,"priceCustomerGroup")&&this.priceCustomerGroup(e.priceCustomerGroup),d(e,"priceChannel")&&this.priceChannel(e.priceChannel),e.text&&this.text(e.text.value,e.text.language),e.fuzzy&&this.fuzzy(),d(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)}),d(e,"whereOperator")&&this.whereOperator(e.whereOperator),d(e,"version")&&this.withVersion(e.version)}.call(this,e),this}}))}e.features=n,e.createRequestBuilder=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},s=I({},o,t.customServices);return Object.keys(s).reduce(function(e,r){return I({},e,z({},r,q(s[r],t.projectKey)))},{})},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.CommercetoolsApiRequestBuilder={})}(this,function(e){"use strict";var r="create",t="update",s="delete",i="query",a="queryOne",u="queryExpand",c="queryLocation",p="search",h="projection",f="suggest",n=Object.freeze({create:r,update:t,del:s,query:i,queryOne:a,queryExpand:u,queryLocation:c,search:p,projection:h,suggest:f}),o={login:{type:"login",endpoint:"/login",features:[r]},cartDiscounts:{type:"cart-discounts",endpoint:"/cart-discounts",features:[r,t,s,i,a,u]},carts:{type:"carts",endpoint:"/carts",features:[r,t,s,i,a,u]},categories:{type:"categories",endpoint:"/categories",features:[r,t,s,i,a,u]},channels:{type:"channels",endpoint:"/channels",features:[r,t,s,i,a,u]},customerGroups:{type:"customer-groups",endpoint:"/customer-groups",features:[r,t,s,i,a,u]},customers:{type:"customers",endpoint:"/customers",features:[r,t,s,i,a,u]},customersPassword:{type:"customers-password",endpoint:"/customers/password",features:[r]},customersPasswordToken:{type:"customers-password-token",endpoint:"/customers/password-token",features:[r,a]},customersPasswordReset:{type:"customers-password-reset",endpoint:"/customers/password/reset",features:[r]},customersEmailVerificationToken:{type:"customers-email-verification-token",endpoint:"/customers/customers/email-token",features:[r,a]},customersEmailVerification:{type:"customers-email-verification",endpoint:"/customers/customers/email/confirm",features:[r]},customObjects:{type:"custom-objects",endpoint:"/custom-objects",features:[r,t,s,i,a]},discountCodes:{type:"discount-codes",endpoint:"/discount-codes",features:[r,t,s,i,a,u]},extensions:{type:"extensions",endpoint:"/extensions",features:[r,t,s,i,a,u]},inventory:{type:"inventory",endpoint:"/inventory",features:[r,t,s,i,a,u]},messages:{type:"messages",endpoint:"/messages",features:[i,a,u]},myCarts:{type:"my-carts",endpoint:"/me/carts",features:[r,t,s,i,a,u]},myOrders:{type:"my-orders",endpoint:"/me/orders",features:[r,t,s,i,a,u]},orders:{type:"orders",endpoint:"/orders",features:[r,t,s,i,a,u]},orderImport:{type:"orderImport",endpoint:"/orders/import",features:[r,i]},payments:{type:"payments",endpoint:"/payments",features:[r,t,s,i,a,u]},productDiscounts:{type:"product-discounts",endpoint:"/product-discounts",features:[r,t,s,i,a,u]},productProjections:{type:"product-projections",endpoint:"/product-projections",features:[i,a,u,h]},productProjectionsSearch:{type:"product-projections-search",endpoint:"/product-projections/search",features:[p,a,u,h]},productProjectionsSuggest:{type:"product-projections-suggest",endpoint:"/product-projections/suggest",features:[p,f,a,h]},products:{type:"products",endpoint:"/products",features:[r,t,s,i,a,u]},productTypes:{type:"product-types",endpoint:"/product-types",features:[r,t,s,i,a,u]},project:{type:"project",endpoint:"/",features:[t,i]},reviews:{type:"reviews",endpoint:"/reviews",features:[r,t,s,i,a,u]},shippingMethods:{type:"shipping-methods",endpoint:"/shipping-methods",features:[r,t,s,i,a,u,c]},shoppingLists:{type:"shopping-lists",endpoint:"/shopping-lists",features:[r,t,s,i,a,u]},states:{type:"states",endpoint:"/states",features:[r,t,s,i,a,u]},subscriptions:{type:"subscriptions",endpoint:"/subscriptions",features:[r,t,s,i,a,u]},taxCategories:{type:"tax-categories",endpoint:"/tax-categories",features:[r,t,s,i,a,u]},types:{type:"types",endpoint:"/types",features:[r,t,s,i,a,u]},zones:{type:"zones",endpoint:"/zones",features:[r,t,s,i,a,u]}};var d=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};function y(e){if("number"!=typeof e)throw new Error("A resource version is missing or invalid");return this.params.version=e,this}function m(){return this.params.dataErasure="dataErasure=true",this}var l=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 g=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 w=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 b=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 v=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=encodeURIComponent(e+" "+(r?"asc":"desc"));return this.params.pagination.sort.push(t),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}});var E=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 C=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 z=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}}),I=function(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e},j=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},q=["type","endpoint","features"];function x(r){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";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 "+e+".")}),!Array.isArray(r.features)||!r.features.length)throw new Error("Definition requires `features` to be a non empty array.");if(!n)throw new Error("No project defined. Please enter a project key");var e=r.type,o=r.endpoint,t=r.features;return function(r){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],s={};return Object.keys(r).forEach(function(e){Object.defineProperty(s,e,{value:r[e],enumerable:!!t||"function"==typeof r[e]})}),s}(j({type:e,features:t,params:{id:null,expand:[],pagination:{page:null,perPage:null,sort:[]},location:{currency:"",country:"",state:""},query:{operator:"and",where:[]},searchKeywords:[]},withVersion:y,withFullDataErasure:m},t.reduce(function(e,r){return r===i?j({},e,l,v):r===a?j({},e,g):r===c?j({},e,w):r===u?j({},e,b):r===p?j({},e,z,v,{params:{expand:[],searchKeywords:[],staged:!0,pagination:{page:null,perPage:null,sort:[]},search:{facet:[],filter:[],filterByQuery:[],filterByFacets:[],fuzzy:!1,fuzzyLevel:0,markMatchingVariants:!1,text:null}}}):r===f?j({},e,z,v,C):r===h?j({},e,E):e},{}),{build:function(){var e,r=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{withProjectKey:!0}).withProjectKey,t=function(e){if(!e)throw new Error("Missing options object to build query string.");var r=e.query,t=e.pagination,s=e.search,n=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=[];if(f&&l.push("customerId="+f),d&&l.push("cartId="+d),"boolean"==typeof o&&l.push("staged="+o.toString()),i&&l.push("priceCurrency="+i),a&&l.push("priceCountry="+a),u&&l.push("priceCustomerGroup="+u),c&&l.push("priceChannel="+c),n&&n.length&&(l=l.concat(n.map(function(e){return"expand="+e}))),r){var g=r.operator,w=r.where.join(encodeURIComponent(" "+g+" "));w&&l.push("where="+w)}if(y){var b=y.country,v=y.currency,E=y.state;b&&l.push("country="+b),v&&l.push("currency="+v),E&&l.push("state="+E)}if(t){var C=t.page,z=t.perPage,I=t.sort;if("number"==typeof z&&l.push("limit="+z),C){var j=(z||20)*(C-1);l.push("offset="+j)}I&&I.length&&(l=l.concat(I.map(function(e){return"sort="+e})))}if(s){var q=s.text,x=s.fuzzy,O=s.fuzzyLevel,R=s.markMatchingVariants,k=s.facet,P=s.filter,B=s.filterByQuery,K=s.filterByFacets;q&&l.push("text."+q.lang+"="+q.value),x&&l.push("fuzzy=true"),O&&l.push("fuzzyLevel="+O),l.push("markMatchingVariants="+R.toString()),k.forEach(function(e){return l.push("facet="+e)}),P.forEach(function(e){return l.push("filter="+e)}),B.forEach(function(e){return l.push("filter.query="+e)}),K.forEach(function(e){return l.push("filter.facets="+e)})}return p&&p.forEach(function(e){return l.push("searchKeywords."+e.lang+"="+e.value)}),h&&l.push("version="+h),m&&l.push(m),l.join("&")}(this.params),s=(r?"/"+n:"")+o+((e=this.params).id?"/"+e.id:e.key?"/key="+e.key:"")+(t?"?"+t:"");return function(){this.params.expand=[],-1!==this.features.indexOf(a)&&(this.params.id=null),-1!==this.features.indexOf(i)&&(this.params.pagination={page:null,perPage:null,sort:[]},this.params.query={operator:"and",where:[]}),-1!==this.features.indexOf(p)&&(this.params.staged=!0,this.params.pagination={page:null,perPage:null,sort:[]},this.params.search={facet:[],filter:[],filterByQuery:[],filterByFacets:[],fuzzy:!1,fuzzyLevel:0,markMatchingVariants:!1,text:null}),-1!==this.features.indexOf(c)&&(this.params.location={currency:"",country:"",state:""}),-1!==this.features.indexOf(h)&&(this.params.staged=!0),-1!==this.features.indexOf(f)&&(this.params.searchKeywords=[])}.call(this),s},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"];Object.keys(e).forEach(function(e){if(-1===t.indexOf(e))throw new Error('Unknown key "'+e+'"')}),e.expand&&e.expand.forEach(function(e){r.expand(e)}),d(e,"id")&&this.byId(e.id),d(e,"key")&&this.byKey(e.key),d(e,"customerId")&&this.byCustomerId(e.customerId),d(e,"cartId")&&this.byCartId(e.cartId),d(e,"country")&&this.byCountry(e.country),d(e,"currency")&&this.byCurrency(e.currency),d(e,"state")&&this.byState(e.state),e.sort&&e.sort.forEach(function(e){r.sort(e.by,"asc"===e.direction)}),d(e,"page")&&this.page(e.page),d(e,"perPage")&&this.perPage(e.perPage),d(e,"staged")&&this.staged(e.staged),d(e,"priceCurrency")&&this.priceCurrency(e.priceCurrency),d(e,"priceCountry")&&this.priceCountry(e.priceCountry),d(e,"priceCustomerGroup")&&this.priceCustomerGroup(e.priceCustomerGroup),d(e,"priceChannel")&&this.priceChannel(e.priceChannel),e.text&&this.text(e.text.value,e.text.language),e.fuzzy&&this.fuzzy(),d(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)}),d(e,"whereOperator")&&this.whereOperator(e.whereOperator),d(e,"version")&&this.withVersion(e.version),d(e,"dataErasure")&&this.withFullDataErasure()}.call(this,e),this}}))}e.features=n,e.createRequestBuilder=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},s=j({},o,t.customServices);return Object.keys(s).reduce(function(e,r){return j({},e,I({},r,x(s[r],t.projectKey)))},{})},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": "3.7.2", | ||
"version": "3.8.0", | ||
"description": "Helper functions to construct API requests URI for the commercetools platform in a declarative way.", | ||
@@ -10,0 +10,0 @@ "keywords": [ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
135010
3221
0