Socket
Socket
Sign inDemoInstall

@commercetools/api-request-builder

Package Overview
Dependencies
Maintainers
9
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools/api-request-builder - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

12

dist/commercetools-api-request-builder.cjs.js

@@ -404,4 +404,4 @@ 'use strict';

});
if (params.filterByQuery) params.filterByQuery.forEach(function (query$$1) {
_this.filterByQuery(query$$1);
if (params.filterByQuery) params.filterByQuery.forEach(function (query) {
_this.filterByQuery(query);
});

@@ -1073,10 +1073,10 @@ if (params.filterByFacets) params.filterByFacets.forEach(function (facet) {

endpoint = definition.endpoint,
features = definition.features;
features$1 = definition.features;
return classify(_objectSpread({
type: type,
features: features,
features: features$1,
params: getDefaultQueryParams(),
withVersion: withVersion,
withFullDataErasure: withFullDataErasure
}, features.reduce(function (acc, feature) {
}, features$1.reduce(function (acc, feature) {
if (feature === query) return _objectSpread({}, acc, query$1, queryPage);

@@ -1149,4 +1149,4 @@ if (feature === queryOne) return _objectSpread({}, acc, queryId);

exports.createRequestBuilder = createRequestBuilder;
exports.features = features;
exports.createRequestBuilder = createRequestBuilder;
//# sourceMappingURL=commercetools-api-request-builder.cjs.js.map

@@ -400,4 +400,4 @@ function _defineProperty(obj, key, value) {

});
if (params.filterByQuery) params.filterByQuery.forEach(function (query$$1) {
_this.filterByQuery(query$$1);
if (params.filterByQuery) params.filterByQuery.forEach(function (query) {
_this.filterByQuery(query);
});

@@ -1069,10 +1069,10 @@ if (params.filterByFacets) params.filterByFacets.forEach(function (facet) {

endpoint = definition.endpoint,
features = definition.features;
features$1 = definition.features;
return classify(_objectSpread({
type: type,
features: features,
features: features$1,
params: getDefaultQueryParams(),
withVersion: withVersion,
withFullDataErasure: withFullDataErasure
}, features.reduce(function (acc, feature) {
}, features$1.reduce(function (acc, feature) {
if (feature === query) return _objectSpread({}, acc, query$1, queryPage);

@@ -1145,3 +1145,3 @@ if (feature === queryOne) return _objectSpread({}, acc, queryId);

export { features, createRequestBuilder };
export { createRequestBuilder, features };
//# sourceMappingURL=commercetools-api-request-builder.es.js.map

@@ -406,4 +406,4 @@ (function (global, factory) {

});
if (params.filterByQuery) params.filterByQuery.forEach(function (query$$1) {
_this.filterByQuery(query$$1);
if (params.filterByQuery) params.filterByQuery.forEach(function (query) {
_this.filterByQuery(query);
});

@@ -1075,10 +1075,10 @@ if (params.filterByFacets) params.filterByFacets.forEach(function (facet) {

endpoint = definition.endpoint,
features = definition.features;
features$1 = definition.features;
return classify(_objectSpread({
type: type,
features: features,
features: features$1,
params: getDefaultQueryParams(),
withVersion: withVersion,
withFullDataErasure: withFullDataErasure
}, features.reduce(function (acc, feature) {
}, features$1.reduce(function (acc, feature) {
if (feature === query) return _objectSpread({}, acc, query$1, queryPage);

@@ -1151,4 +1151,4 @@ if (feature === queryOne) return _objectSpread({}, acc, queryId);

exports.createRequestBuilder = createRequestBuilder;
exports.features = features;
exports.createRequestBuilder = createRequestBuilder;

@@ -1155,0 +1155,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -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 i(r){for(var e=1;e<arguments.length;e++){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])})}return r}var r="create",t="update",n="delete",a="query",u="queryOne",c="queryExpand",p="queryLocation",h="search",f="projection",d="suggest",o=Object.freeze({create:r,update:t,del:n,query:a,queryOne:u,queryExpand:c,queryLocation:p,search:h,projection:f,suggest:d}),y={login:{type:"login",endpoint:"/login",features:[r]},cartDiscounts:{type:"cart-discounts",endpoint:"/cart-discounts",features:[r,t,n,a,u,c]},carts:{type:"carts",endpoint:"/carts",features:[r,t,n,a,u,c]},categories:{type:"categories",endpoint:"/categories",features:[r,t,n,a,u,c]},channels:{type:"channels",endpoint:"/channels",features:[r,t,n,a,u,c]},customerGroups:{type:"customer-groups",endpoint:"/customer-groups",features:[r,t,n,a,u,c]},customers:{type:"customers",endpoint:"/customers",features:[r,t,n,a,u,c]},customersPassword:{type:"customers-password",endpoint:"/customers/password",features:[r]},customersPasswordToken:{type:"customers-password-token",endpoint:"/customers/password-token",features:[r,u]},customersPasswordReset:{type:"customers-password-reset",endpoint:"/customers/password/reset",features:[r]},customersEmailVerificationToken:{type:"customers-email-verification-token",endpoint:"/customers/customers/email-token",features:[r,u]},customersEmailVerification:{type:"customers-email-verification",endpoint:"/customers/customers/email/confirm",features:[r]},customObjects:{type:"custom-objects",endpoint:"/custom-objects",features:[r,t,n,a,u]},discountCodes:{type:"discount-codes",endpoint:"/discount-codes",features:[r,t,n,a,u,c]},extensions:{type:"extensions",endpoint:"/extensions",features:[r,t,n,a,u,c]},inventory:{type:"inventory",endpoint:"/inventory",features:[r,t,n,a,u,c]},messages:{type:"messages",endpoint:"/messages",features:[a,u,c]},myCarts:{type:"my-carts",endpoint:"/me/carts",features:[r,t,n,a,u,c]},myOrders:{type:"my-orders",endpoint:"/me/orders",features:[r,t,n,a,u,c]},orders:{type:"orders",endpoint:"/orders",features:[r,t,n,a,u,c]},orderImport:{type:"orderImport",endpoint:"/orders/import",features:[r,a]},payments:{type:"payments",endpoint:"/payments",features:[r,t,n,a,u,c]},productDiscounts:{type:"product-discounts",endpoint:"/product-discounts",features:[r,t,n,a,u,c]},productProjections:{type:"product-projections",endpoint:"/product-projections",features:[a,u,c,f]},productProjectionsSearch:{type:"product-projections-search",endpoint:"/product-projections/search",features:[h,u,c,f]},productProjectionsSuggest:{type:"product-projections-suggest",endpoint:"/product-projections/suggest",features:[h,d,u,f]},products:{type:"products",endpoint:"/products",features:[r,t,n,a,u,c]},productTypes:{type:"product-types",endpoint:"/product-types",features:[r,t,n,a,u,c]},project:{type:"project",endpoint:"/",features:[t,a]},reviews:{type:"reviews",endpoint:"/reviews",features:[r,t,n,a,u,c]},shippingMethods:{type:"shipping-methods",endpoint:"/shipping-methods",features:[r,t,n,a,u,c,p]},shoppingLists:{type:"shopping-lists",endpoint:"/shopping-lists",features:[r,t,n,a,u,c]},states:{type:"states",endpoint:"/states",features:[r,t,n,a,u,c]},subscriptions:{type:"subscriptions",endpoint:"/subscriptions",features:[r,t,n,a,u,c]},taxCategories:{type:"tax-categories",endpoint:"/tax-categories",features:[r,t,n,a,u,c]},types:{type:"types",endpoint:"/types",features:[r,t,n,a,u,c]},zones:{type:"zones",endpoint:"/zones",features:[r,t,n,a,u,c]}};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}var w=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 b=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 v=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 E=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 C=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 z=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 I=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 j=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){var s=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 ".concat(e,"."))}),!Array.isArray(r.features)||!r.features.length)throw new Error("Definition requires `features` to be a non empty array.");if(!s)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],n={};return Object.keys(r).forEach(function(e){Object.defineProperty(n,e,{value:r[e],enumerable:!!t||"function"==typeof r[e]})}),n}(i({type:e,features:t,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},t.reduce(function(e,r){return r===a?i({},e,w,C):r===u?i({},e,b):r===p?i({},e,v):r===c?i({},e,E):r===h?i({},e,j,C,{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===d?i({},e,j,C,I):r===f?i({},e,z):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,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=[];if(f&&l.push("customerId=".concat(f)),d&&l.push("cartId=".concat(d)),"boolean"==typeof o&&l.push("staged=".concat(o.toString())),i&&l.push("priceCurrency=".concat(i)),a&&l.push("priceCountry=".concat(a)),u&&l.push("priceCustomerGroup=".concat(u)),c&&l.push("priceChannel=".concat(c)),s&&s.length&&(l=l.concat(s.map(function(e){return"expand=".concat(e)}))),r){var g=r.operator,w=r.where.join(encodeURIComponent(" ".concat(g," ")));w&&l.push("where=".concat(w))}if(y){var b=y.country,v=y.currency,E=y.state;b&&l.push("country=".concat(b)),v&&l.push("currency=".concat(v)),E&&l.push("state=".concat(E))}if(t){var C=t.page,z=t.perPage,I=t.sort,j=t.withTotal;if("number"==typeof z&&l.push("limit=".concat(z)),C){var q=(z||20)*(C-1);l.push("offset=".concat(q))}I&&I.length&&(l=l.concat(I.map(function(e){return"sort=".concat(e)}))),"boolean"==typeof j&&l.push("withTotal=".concat(String(j)))}if(n){var R=n.text,x=n.fuzzy,O=n.fuzzyLevel,k=n.markMatchingVariants,P=n.facet,B=n.filter,K=n.filterByQuery,T=n.filterByFacets;R&&l.push("text.".concat(R.lang,"=").concat(R.value)),x&&l.push("fuzzy=true"),O&&l.push("fuzzyLevel=".concat(O)),l.push("markMatchingVariants=".concat(k.toString())),P.forEach(function(e){return l.push("facet=".concat(e))}),B.forEach(function(e){return l.push("filter=".concat(e))}),K.forEach(function(e){return l.push("filter.query=".concat(e))}),T.forEach(function(e){return l.push("filter.facets=".concat(e))})}return p&&p.forEach(function(e){return l.push("searchKeywords.".concat(e.lang,"=").concat(e.value))}),h&&l.push("version=".concat(h)),m&&l.push(m),l.join("&")}(this.params),n=(r?"/".concat(s):"")+o+((e=this.params).id?"/".concat(e.id):e.key?"/key=".concat(e.key):"")+(t?"?".concat(t):"");return function(){this.params.expand=[],this.features.includes(u)&&(this.params.id=null),this.features.includes(a)&&(this.params.pagination={page:null,perPage:null,sort:[],withTotal:null},this.params.query={operator:"and",where:[]}),this.features.includes(h)&&(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(p)&&(this.params.location={currency:"",country:"",state:""}),this.features.includes(d)&&(this.params.searchKeywords=[])}.call(this),n},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"];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)}.call(this,e),this}}))}e.features=o,e.createRequestBuilder=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=i({},y,t.customServices);return Object.keys(n).reduce(function(e,r){return i({},e,s({},r,R(n[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=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 i(r){for(var e=1;e<arguments.length;e++){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])})}return r}var r="create",t="update",n="delete",a="query",u="queryOne",c="queryExpand",p="queryLocation",h="search",f="projection",d="suggest",o=Object.freeze({create:r,update:t,del:n,query:a,queryOne:u,queryExpand:c,queryLocation:p,search:h,projection:f,suggest:d}),y={login:{type:"login",endpoint:"/login",features:[r]},cartDiscounts:{type:"cart-discounts",endpoint:"/cart-discounts",features:[r,t,n,a,u,c]},carts:{type:"carts",endpoint:"/carts",features:[r,t,n,a,u,c]},categories:{type:"categories",endpoint:"/categories",features:[r,t,n,a,u,c]},channels:{type:"channels",endpoint:"/channels",features:[r,t,n,a,u,c]},customerGroups:{type:"customer-groups",endpoint:"/customer-groups",features:[r,t,n,a,u,c]},customers:{type:"customers",endpoint:"/customers",features:[r,t,n,a,u,c]},customersPassword:{type:"customers-password",endpoint:"/customers/password",features:[r]},customersPasswordToken:{type:"customers-password-token",endpoint:"/customers/password-token",features:[r,u]},customersPasswordReset:{type:"customers-password-reset",endpoint:"/customers/password/reset",features:[r]},customersEmailVerificationToken:{type:"customers-email-verification-token",endpoint:"/customers/customers/email-token",features:[r,u]},customersEmailVerification:{type:"customers-email-verification",endpoint:"/customers/customers/email/confirm",features:[r]},customObjects:{type:"custom-objects",endpoint:"/custom-objects",features:[r,t,n,a,u]},discountCodes:{type:"discount-codes",endpoint:"/discount-codes",features:[r,t,n,a,u,c]},extensions:{type:"extensions",endpoint:"/extensions",features:[r,t,n,a,u,c]},inventory:{type:"inventory",endpoint:"/inventory",features:[r,t,n,a,u,c]},messages:{type:"messages",endpoint:"/messages",features:[a,u,c]},myCarts:{type:"my-carts",endpoint:"/me/carts",features:[r,t,n,a,u,c]},myOrders:{type:"my-orders",endpoint:"/me/orders",features:[r,t,n,a,u,c]},orders:{type:"orders",endpoint:"/orders",features:[r,t,n,a,u,c]},orderImport:{type:"orderImport",endpoint:"/orders/import",features:[r,a]},payments:{type:"payments",endpoint:"/payments",features:[r,t,n,a,u,c]},productDiscounts:{type:"product-discounts",endpoint:"/product-discounts",features:[r,t,n,a,u,c]},productProjections:{type:"product-projections",endpoint:"/product-projections",features:[a,u,c,f]},productProjectionsSearch:{type:"product-projections-search",endpoint:"/product-projections/search",features:[h,u,c,f]},productProjectionsSuggest:{type:"product-projections-suggest",endpoint:"/product-projections/suggest",features:[h,d,u,f]},products:{type:"products",endpoint:"/products",features:[r,t,n,a,u,c]},productTypes:{type:"product-types",endpoint:"/product-types",features:[r,t,n,a,u,c]},project:{type:"project",endpoint:"/",features:[t,a]},reviews:{type:"reviews",endpoint:"/reviews",features:[r,t,n,a,u,c]},shippingMethods:{type:"shipping-methods",endpoint:"/shipping-methods",features:[r,t,n,a,u,c,p]},shoppingLists:{type:"shopping-lists",endpoint:"/shopping-lists",features:[r,t,n,a,u,c]},states:{type:"states",endpoint:"/states",features:[r,t,n,a,u,c]},subscriptions:{type:"subscriptions",endpoint:"/subscriptions",features:[r,t,n,a,u,c]},taxCategories:{type:"tax-categories",endpoint:"/tax-categories",features:[r,t,n,a,u,c]},types:{type:"types",endpoint:"/types",features:[r,t,n,a,u,c]},zones:{type:"zones",endpoint:"/zones",features:[r,t,n,a,u,c]}};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}var w=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 b=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 v=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 E=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 C=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 z=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 I=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 j=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){var s=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 ".concat(e,"."))}),!Array.isArray(r.features)||!r.features.length)throw new Error("Definition requires `features` to be a non empty array.");if(!s)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],n={};return Object.keys(r).forEach(function(e){Object.defineProperty(n,e,{value:r[e],enumerable:!!t||"function"==typeof r[e]})}),n}(i({type:e,features:t,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},t.reduce(function(e,r){return r===a?i({},e,w,C):r===u?i({},e,b):r===p?i({},e,v):r===c?i({},e,E):r===h?i({},e,j,C,{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===d?i({},e,j,C,I):r===f?i({},e,z):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,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=[];if(f&&l.push("customerId=".concat(f)),d&&l.push("cartId=".concat(d)),"boolean"==typeof o&&l.push("staged=".concat(o.toString())),i&&l.push("priceCurrency=".concat(i)),a&&l.push("priceCountry=".concat(a)),u&&l.push("priceCustomerGroup=".concat(u)),c&&l.push("priceChannel=".concat(c)),s&&s.length&&(l=l.concat(s.map(function(e){return"expand=".concat(e)}))),r){var g=r.operator,w=r.where.join(encodeURIComponent(" ".concat(g," ")));w&&l.push("where=".concat(w))}if(y){var b=y.country,v=y.currency,E=y.state;b&&l.push("country=".concat(b)),v&&l.push("currency=".concat(v)),E&&l.push("state=".concat(E))}if(t){var C=t.page,z=t.perPage,I=t.sort,j=t.withTotal;if("number"==typeof z&&l.push("limit=".concat(z)),C){var q=(z||20)*(C-1);l.push("offset=".concat(q))}I&&I.length&&(l=l.concat(I.map(function(e){return"sort=".concat(e)}))),"boolean"==typeof j&&l.push("withTotal=".concat(String(j)))}if(n){var R=n.text,x=n.fuzzy,O=n.fuzzyLevel,k=n.markMatchingVariants,P=n.facet,B=n.filter,K=n.filterByQuery,T=n.filterByFacets;R&&l.push("text.".concat(R.lang,"=").concat(R.value)),x&&l.push("fuzzy=true"),O&&l.push("fuzzyLevel=".concat(O)),l.push("markMatchingVariants=".concat(k.toString())),P.forEach(function(e){return l.push("facet=".concat(e))}),B.forEach(function(e){return l.push("filter=".concat(e))}),K.forEach(function(e){return l.push("filter.query=".concat(e))}),T.forEach(function(e){return l.push("filter.facets=".concat(e))})}return p&&p.forEach(function(e){return l.push("searchKeywords.".concat(e.lang,"=").concat(e.value))}),h&&l.push("version=".concat(h)),m&&l.push(m),l.join("&")}(this.params),n=(r?"/".concat(s):"")+o+((e=this.params).id?"/".concat(e.id):e.key?"/key=".concat(e.key):"")+(t?"?".concat(t):"");return function(){this.params.expand=[],this.features.includes(u)&&(this.params.id=null),this.features.includes(a)&&(this.params.pagination={page:null,perPage:null,sort:[],withTotal:null},this.params.query={operator:"and",where:[]}),this.features.includes(h)&&(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(p)&&(this.params.location={currency:"",country:"",state:""}),this.features.includes(d)&&(this.params.searchKeywords=[])}.call(this),n},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"];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)}.call(this,e),this}}))}e.createRequestBuilder=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=i({},y,t.customServices);return Object.keys(n).reduce(function(e,r){return i({},e,s({},r,R(n[r],t.projectKey)))},{})},e.features=o,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.0.0",
"version": "5.1.0",
"description": "Helper functions to construct API requests URI for the commercetools platform in a declarative way.",

@@ -39,3 +39,3 @@ "keywords": [

},
"gitHead": "313ea01030d33fb6c262c9cce428d19b5008ec9f"
"gitHead": "4dc966050b39b73e3875d7bd32a89c82f92fdfa2"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc