@commercetools/api-request-builder
Advanced tools
Comparing version 5.5.0 to 5.6.0
@@ -149,3 +149,3 @@ 'use strict'; | ||
type: 'customers-email-verification-token', | ||
endpoint: '/customers/customers/email-token', | ||
endpoint: '/customers/email-token', | ||
features: [create, queryOne] | ||
@@ -155,3 +155,3 @@ }, | ||
type: 'customers-email-verification', | ||
endpoint: '/customers/customers/email/confirm', | ||
endpoint: '/customers/email/confirm', | ||
features: [create] | ||
@@ -274,2 +274,7 @@ }, | ||
}, | ||
stores: { | ||
type: 'stores', | ||
endpoint: '/stores', | ||
features: [create, update, del, query, queryOne, queryExpand] | ||
}, | ||
subscriptions: { | ||
@@ -1156,3 +1161,3 @@ type: 'subscriptions', | ||
function createService(definition) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var projectKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
if (!definition) throw new Error('Cannot create a service without its definition.'); | ||
@@ -1163,3 +1168,3 @@ requiredDefinitionProps.forEach(function (key) { | ||
if (!Array.isArray(definition.features) || !definition.features.length) throw new Error('Definition requires `features` to be a non empty array.'); | ||
if (!options) throw new Error('No project defined. Please enter a project key'); | ||
if (!projectKey) throw new Error('No project defined. Please enter a project key'); | ||
var type = definition.type, | ||
@@ -1198,3 +1203,3 @@ endpoint = definition.endpoint, | ||
var queryParams = buildQueryString(this.params); | ||
var uri = (withProjectKey ? "/".concat(options) : '') + endpoint + // TODO this can lead to invalid URIs as getIdOrKey can return | ||
var uri = (withProjectKey ? "/".concat(projectKey) : '') + endpoint + // TODO this can lead to invalid URIs as getIdOrKey can return | ||
// "/?customerId", so there can be multiple question marks, | ||
@@ -1201,0 +1206,0 @@ // same for when `queryParams` and `version` are present |
@@ -145,3 +145,3 @@ function _defineProperty(obj, key, value) { | ||
type: 'customers-email-verification-token', | ||
endpoint: '/customers/customers/email-token', | ||
endpoint: '/customers/email-token', | ||
features: [create, queryOne] | ||
@@ -151,3 +151,3 @@ }, | ||
type: 'customers-email-verification', | ||
endpoint: '/customers/customers/email/confirm', | ||
endpoint: '/customers/email/confirm', | ||
features: [create] | ||
@@ -270,2 +270,7 @@ }, | ||
}, | ||
stores: { | ||
type: 'stores', | ||
endpoint: '/stores', | ||
features: [create, update, del, query, queryOne, queryExpand] | ||
}, | ||
subscriptions: { | ||
@@ -1152,3 +1157,3 @@ type: 'subscriptions', | ||
function createService(definition) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var projectKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
if (!definition) throw new Error('Cannot create a service without its definition.'); | ||
@@ -1159,3 +1164,3 @@ requiredDefinitionProps.forEach(function (key) { | ||
if (!Array.isArray(definition.features) || !definition.features.length) throw new Error('Definition requires `features` to be a non empty array.'); | ||
if (!options) throw new Error('No project defined. Please enter a project key'); | ||
if (!projectKey) throw new Error('No project defined. Please enter a project key'); | ||
var type = definition.type, | ||
@@ -1194,3 +1199,3 @@ endpoint = definition.endpoint, | ||
var queryParams = buildQueryString(this.params); | ||
var uri = (withProjectKey ? "/".concat(options) : '') + endpoint + // TODO this can lead to invalid URIs as getIdOrKey can return | ||
var uri = (withProjectKey ? "/".concat(projectKey) : '') + endpoint + // TODO this can lead to invalid URIs as getIdOrKey can return | ||
// "/?customerId", so there can be multiple question marks, | ||
@@ -1197,0 +1202,0 @@ // same for when `queryParams` and `version` are present |
@@ -151,3 +151,3 @@ (function (global, factory) { | ||
type: 'customers-email-verification-token', | ||
endpoint: '/customers/customers/email-token', | ||
endpoint: '/customers/email-token', | ||
features: [create, queryOne] | ||
@@ -157,3 +157,3 @@ }, | ||
type: 'customers-email-verification', | ||
endpoint: '/customers/customers/email/confirm', | ||
endpoint: '/customers/email/confirm', | ||
features: [create] | ||
@@ -276,2 +276,7 @@ }, | ||
}, | ||
stores: { | ||
type: 'stores', | ||
endpoint: '/stores', | ||
features: [create, update, del, query, queryOne, queryExpand] | ||
}, | ||
subscriptions: { | ||
@@ -1158,3 +1163,3 @@ type: 'subscriptions', | ||
function createService(definition) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var projectKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
if (!definition) throw new Error('Cannot create a service without its definition.'); | ||
@@ -1165,3 +1170,3 @@ requiredDefinitionProps.forEach(function (key) { | ||
if (!Array.isArray(definition.features) || !definition.features.length) throw new Error('Definition requires `features` to be a non empty array.'); | ||
if (!options) throw new Error('No project defined. Please enter a project key'); | ||
if (!projectKey) throw new Error('No project defined. Please enter a project key'); | ||
var type = definition.type, | ||
@@ -1200,3 +1205,3 @@ endpoint = definition.endpoint, | ||
var queryParams = buildQueryString(this.params); | ||
var uri = (withProjectKey ? "/".concat(options) : '') + endpoint + // TODO this can lead to invalid URIs as getIdOrKey can return | ||
var uri = (withProjectKey ? "/".concat(projectKey) : '') + endpoint + // TODO this can lead to invalid URIs as getIdOrKey can return | ||
// "/?customerId", so there can be multiple question marks, | ||
@@ -1203,0 +1208,0 @@ // same for when `queryParams` and `version` are present |
@@ -1,1 +0,1 @@ | ||
!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 o(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);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),t.push.apply(t,n)}return t}function s(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?n(Object(t),!0).forEach(function(e){o(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):n(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}var r="create",t="update",i="delete",c="query",p="queryOne",h="queryExpand",f="queryLocation",d="search",y="projection",m="suggest",a=Object.freeze({__proto__:null,create:r,update:t,del:i,query:c,queryOne:p,queryExpand:h,queryLocation:f,search:d,projection:y,suggest:m}),u={login:{type:"login",endpoint:"/login",features:[r]},cartDiscounts:{type:"cart-discounts",endpoint:"/cart-discounts",features:[r,t,i,c,p,h]},carts:{type:"carts",endpoint:"/carts",features:[r,t,i,c,p,h]},categories:{type:"categories",endpoint:"/categories",features:[r,t,i,c,p,h]},channels:{type:"channels",endpoint:"/channels",features:[r,t,i,c,p,h]},customerGroups:{type:"customer-groups",endpoint:"/customer-groups",features:[r,t,i,c,p,h]},customers:{type:"customers",endpoint:"/customers",features:[r,t,i,c,p,h]},customersPassword:{type:"customers-password",endpoint:"/customers/password",features:[r]},customersPasswordToken:{type:"customers-password-token",endpoint:"/customers/password-token",features:[r,p]},customersPasswordReset:{type:"customers-password-reset",endpoint:"/customers/password/reset",features:[r]},customersEmailVerificationToken:{type:"customers-email-verification-token",endpoint:"/customers/customers/email-token",features:[r,p]},customersEmailVerification:{type:"customers-email-verification",endpoint:"/customers/customers/email/confirm",features:[r]},customObjects:{type:"custom-objects",endpoint:"/custom-objects",features:[r,t,i,c,p]},discountCodes:{type:"discount-codes",endpoint:"/discount-codes",features:[r,t,i,c,p,h]},extensions:{type:"extensions",endpoint:"/extensions",features:[r,t,i,c,p,h]},inventory:{type:"inventory",endpoint:"/inventory",features:[r,t,i,c,p,h]},messages:{type:"messages",endpoint:"/messages",features:[c,p,h]},myActiveCart:{type:"my-carts",endpoint:"/me/active-cart",features:[p]},myCarts:{type:"my-carts",endpoint:"/me/carts",features:[r,t,i,c,p,h]},myOrders:{type:"my-orders",endpoint:"/me/orders",features:[r,t,i,c,p,h]},orders:{type:"orders",endpoint:"/orders",features:[r,t,i,c,p,h]},orderEdits:{type:"orders-edits",endpoint:"/orders/edits",features:[r,t,i,c,p,h]},orderImport:{type:"orderImport",endpoint:"/orders/import",features:[r,c]},payments:{type:"payments",endpoint:"/payments",features:[r,t,i,c,p,h]},productDiscounts:{type:"product-discounts",endpoint:"/product-discounts",features:[r,t,i,c,p,h]},productProjections:{type:"product-projections",endpoint:"/product-projections",features:[c,p,h,y]},productProjectionsSearch:{type:"product-projections-search",endpoint:"/product-projections/search",features:[d,p,h,y]},productProjectionsSuggest:{type:"product-projections-suggest",endpoint:"/product-projections/suggest",features:[d,m,p,y]},products:{type:"products",endpoint:"/products",features:[r,t,i,c,p,h]},productTypes:{type:"product-types",endpoint:"/product-types",features:[r,t,i,c,p,h]},project:{type:"project",endpoint:"/",features:[t,c]},reviews:{type:"reviews",endpoint:"/reviews",features:[r,t,i,c,p,h]},shippingMethods:{type:"shipping-methods",endpoint:"/shipping-methods",features:[r,t,i,c,p,h,f]},shoppingLists:{type:"shopping-lists",endpoint:"/shopping-lists",features:[r,t,i,c,p,h]},states:{type:"states",endpoint:"/states",features:[r,t,i,c,p,h]},subscriptions:{type:"subscriptions",endpoint:"/subscriptions",features:[r,t,i,c,p,h]},taxCategories:{type:"tax-categories",endpoint:"/tax-categories",features:[r,t,i,c,p,h]},types:{type:"types",endpoint:"/types",features:[r,t,i,c,p,h]},zones:{type:"zones",endpoint:"/zones",features:[r,t,i,c,p,h]}};function l(){return{id:null,expand:[],pagination:{page:null,perPage:null,sort:[],withTotal:null},location:{currency:"",country:"",state:""},query:{operator:"and",where:[]},searchKeywords:[]}}function g(){return{expand:[],searchKeywords:[],pagination:{page:null,perPage:null,sort:[],withTotal:null},search:{facet:[],filter:[],filterByQuery:[],filterByFacets:[],fuzzy:!1,fuzzyLevel:0,markMatchingVariants:!1,text:null}}}var w=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};function b(e){if("number"!=typeof e)throw new Error("A resource version is missing or invalid");return this.params.version=e,this}function v(){return this.params.dataErasure="dataErasure=true",this}function E(e){if("string"!=typeof e)throw new Error("A resource orderEditId is missing or invalid");return this.params.applyOrderEditTo=e,this}var C=Object.freeze({__proto__:null,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 O=Object.freeze({__proto__:null,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},byOrderNumber:function(e){if("number"!=typeof e)throw new Error("Required argument for `byOrderNumber` is missing or invalid");return this.params.orderNumber=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},byContainerAndKey:function(e,r){if("string"!=typeof e||"string"!=typeof r)throw new Error("Required `container` or `key` argument for `byContainerAndKey` needs to be a string");return this.params.container=e,this.params.key=r,this}});var j=Object.freeze({__proto__:null,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 I=Object.freeze({__proto__:null,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({__proto__:null,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 q=Object.freeze({__proto__:null,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 R=Object.freeze({__proto__:null,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 _=Object.freeze({__proto__:null,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}}),k=["type","endpoint","features"];function x(r,e){var a=1<arguments.length&&void 0!==e?e:"";if(!r)throw new Error("Cannot create a service without its definition.");if(k.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(!a)throw new Error("No project defined. Please enter a project key");var t=r.type,u=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}(s({type:t,features:n,params:l(),withVersion:b,withFullDataErasure:v,applyOrderEditTo:E},n.reduce(function(e,r){return r===c?s({},e,{},C,{},z):r===p?s({},e,{},O):r===f?s({},e,{},j):r===h?s({},e,{},I):r===d?s({},e,{},_,{},z,{params:g()}):r===m?s({},e,{},_,{},z,{},R):r===y?s({},e,{},q):e},{}),{build:function(e){var r,t=0<arguments.length&&void 0!==e?e:{withProjectKey:!0,applyOrderEdit:!1},n=t.withProjectKey,o=t.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,o=e.expand,s=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 s&&g.push("staged=".concat(s.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)),o&&o.length&&(g=g.concat(o.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 O=t.page,j=t.perPage,I=t.sort,z=t.withTotal;if("number"==typeof j&&g.push("limit=".concat(j)),O){var q=(j||20)*(O-1);g.push("offset=".concat(q))}I&&I.length&&(g=g.concat(I.map(function(e){return"sort=".concat(e)}))),"boolean"==typeof z&&g.push("withTotal=".concat(String(z)))}if(n){var R=n.text,_=n.fuzzy,k=n.fuzzyLevel,x=n.markMatchingVariants,P=n.facet,K=n.filter,T=n.filterByQuery,B=n.filterByFacets;R&&g.push("text.".concat(R.lang,"=").concat(R.value)),_&&g.push("fuzzy=true"),k&&g.push("fuzzyLevel=".concat(k)),g.push("markMatchingVariants=".concat(x.toString())),P.forEach(function(e){return g.push("facet=".concat(e))}),K.forEach(function(e){return g.push("filter=".concat(e))}),T.forEach(function(e){return g.push("filter.query=".concat(e))}),B.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),i=(n?"/".concat(a):"")+u+((r=this.params).id?"/".concat(r.id):r.orderNumber?"/order-number=".concat(r.orderNumber):r.key&&!r.container?"/key=".concat(r.key):r.key&&r.container?"/".concat(r.container,"/").concat(r.key):"")+(s&&!o?"?".concat(s):s);return function(){this.params.expand=l().expand,this.params.key=null,this.features.includes(p)&&(this.params.id=l().id),this.features.includes(c)&&(this.params.pagination=l().pagination,this.params.query=l().query),this.features.includes(d)&&(this.params.pagination=g().pagination,this.params.search=g().search),this.features.includes(f)&&(this.params.location=l().location),this.features.includes(m)&&(this.params.searchKeywords=[])}.call(this),i},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","container","orderNumber"];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)}),w(e,"id")&&this.byId(e.id),w(e,"key")&&!w(e,"container")&&this.byKey(e.key),w(e,"customerId")&&this.byCustomerId(e.customerId),w(e,"cartId")&&this.byCartId(e.cartId),w(e,"country")&&this.byCountry(e.country),w(e,"currency")&&this.byCurrency(e.currency),w(e,"state")&&this.byState(e.state),e.sort&&e.sort.forEach(function(e){r.sort(e.by,"asc"===e.direction)}),w(e,"page")&&this.page(e.page),w(e,"perPage")&&this.perPage(e.perPage),w(e,"staged")&&this.staged(e.staged),w(e,"priceCurrency")&&this.priceCurrency(e.priceCurrency),w(e,"priceCountry")&&this.priceCountry(e.priceCountry),w(e,"priceCustomerGroup")&&this.priceCustomerGroup(e.priceCustomerGroup),w(e,"priceChannel")&&this.priceChannel(e.priceChannel),w(e,"orderNumber")&&this.byOrderNumber(e.orderNumber),e.text&&this.text(e.text.value,e.text.language),e.fuzzy&&this.fuzzy(),w(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)}),w(e,"whereOperator")&&this.whereOperator(e.whereOperator),w(e,"version")&&this.withVersion(e.version),w(e,"dataErasure")&&this.withFullDataErasure(),w(e,"withTotal")&&this.withTotal(e.withTotal),w(e,"applyOrderEditTo")&&this.applyOrderEditTo(e.applyOrderEditTo),w(e,"container")&&w(e,"key")&&this.byContainerAndKey(e.container,e.key)}.call(this,e),this}}))}e.createRequestBuilder=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=s({},u,{},t.customServices);return Object.keys(n).reduce(function(e,r){return s({},e,o({},r,x(n[r],t.projectKey)))},{})},e.features=a,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 o(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);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),t.push.apply(t,n)}return t}function s(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?n(Object(t),!0).forEach(function(e){o(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):n(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}var r="create",t="update",i="delete",c="query",p="queryOne",h="queryExpand",f="queryLocation",d="search",y="projection",m="suggest",a=Object.freeze({__proto__:null,create:r,update:t,del:i,query:c,queryOne:p,queryExpand:h,queryLocation:f,search:d,projection:y,suggest:m}),u={login:{type:"login",endpoint:"/login",features:[r]},cartDiscounts:{type:"cart-discounts",endpoint:"/cart-discounts",features:[r,t,i,c,p,h]},carts:{type:"carts",endpoint:"/carts",features:[r,t,i,c,p,h]},categories:{type:"categories",endpoint:"/categories",features:[r,t,i,c,p,h]},channels:{type:"channels",endpoint:"/channels",features:[r,t,i,c,p,h]},customerGroups:{type:"customer-groups",endpoint:"/customer-groups",features:[r,t,i,c,p,h]},customers:{type:"customers",endpoint:"/customers",features:[r,t,i,c,p,h]},customersPassword:{type:"customers-password",endpoint:"/customers/password",features:[r]},customersPasswordToken:{type:"customers-password-token",endpoint:"/customers/password-token",features:[r,p]},customersPasswordReset:{type:"customers-password-reset",endpoint:"/customers/password/reset",features:[r]},customersEmailVerificationToken:{type:"customers-email-verification-token",endpoint:"/customers/email-token",features:[r,p]},customersEmailVerification:{type:"customers-email-verification",endpoint:"/customers/email/confirm",features:[r]},customObjects:{type:"custom-objects",endpoint:"/custom-objects",features:[r,t,i,c,p]},discountCodes:{type:"discount-codes",endpoint:"/discount-codes",features:[r,t,i,c,p,h]},extensions:{type:"extensions",endpoint:"/extensions",features:[r,t,i,c,p,h]},inventory:{type:"inventory",endpoint:"/inventory",features:[r,t,i,c,p,h]},messages:{type:"messages",endpoint:"/messages",features:[c,p,h]},myActiveCart:{type:"my-carts",endpoint:"/me/active-cart",features:[p]},myCarts:{type:"my-carts",endpoint:"/me/carts",features:[r,t,i,c,p,h]},myOrders:{type:"my-orders",endpoint:"/me/orders",features:[r,t,i,c,p,h]},orders:{type:"orders",endpoint:"/orders",features:[r,t,i,c,p,h]},orderEdits:{type:"orders-edits",endpoint:"/orders/edits",features:[r,t,i,c,p,h]},orderImport:{type:"orderImport",endpoint:"/orders/import",features:[r,c]},payments:{type:"payments",endpoint:"/payments",features:[r,t,i,c,p,h]},productDiscounts:{type:"product-discounts",endpoint:"/product-discounts",features:[r,t,i,c,p,h]},productProjections:{type:"product-projections",endpoint:"/product-projections",features:[c,p,h,y]},productProjectionsSearch:{type:"product-projections-search",endpoint:"/product-projections/search",features:[d,p,h,y]},productProjectionsSuggest:{type:"product-projections-suggest",endpoint:"/product-projections/suggest",features:[d,m,p,y]},products:{type:"products",endpoint:"/products",features:[r,t,i,c,p,h]},productTypes:{type:"product-types",endpoint:"/product-types",features:[r,t,i,c,p,h]},project:{type:"project",endpoint:"/",features:[t,c]},reviews:{type:"reviews",endpoint:"/reviews",features:[r,t,i,c,p,h]},shippingMethods:{type:"shipping-methods",endpoint:"/shipping-methods",features:[r,t,i,c,p,h,f]},shoppingLists:{type:"shopping-lists",endpoint:"/shopping-lists",features:[r,t,i,c,p,h]},states:{type:"states",endpoint:"/states",features:[r,t,i,c,p,h]},stores:{type:"stores",endpoint:"/stores",features:[r,t,i,c,p,h]},subscriptions:{type:"subscriptions",endpoint:"/subscriptions",features:[r,t,i,c,p,h]},taxCategories:{type:"tax-categories",endpoint:"/tax-categories",features:[r,t,i,c,p,h]},types:{type:"types",endpoint:"/types",features:[r,t,i,c,p,h]},zones:{type:"zones",endpoint:"/zones",features:[r,t,i,c,p,h]}};function l(){return{id:null,expand:[],pagination:{page:null,perPage:null,sort:[],withTotal:null},location:{currency:"",country:"",state:""},query:{operator:"and",where:[]},searchKeywords:[]}}function g(){return{expand:[],searchKeywords:[],pagination:{page:null,perPage:null,sort:[],withTotal:null},search:{facet:[],filter:[],filterByQuery:[],filterByFacets:[],fuzzy:!1,fuzzyLevel:0,markMatchingVariants:!1,text:null}}}var w=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};function b(e){if("number"!=typeof e)throw new Error("A resource version is missing or invalid");return this.params.version=e,this}function v(){return this.params.dataErasure="dataErasure=true",this}function E(e){if("string"!=typeof e)throw new Error("A resource orderEditId is missing or invalid");return this.params.applyOrderEditTo=e,this}var C=Object.freeze({__proto__:null,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 O=Object.freeze({__proto__:null,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},byOrderNumber:function(e){if("number"!=typeof e)throw new Error("Required argument for `byOrderNumber` is missing or invalid");return this.params.orderNumber=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},byContainerAndKey:function(e,r){if("string"!=typeof e||"string"!=typeof r)throw new Error("Required `container` or `key` argument for `byContainerAndKey` needs to be a string");return this.params.container=e,this.params.key=r,this}});var j=Object.freeze({__proto__:null,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 I=Object.freeze({__proto__:null,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({__proto__:null,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 q=Object.freeze({__proto__:null,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 R=Object.freeze({__proto__:null,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 _=Object.freeze({__proto__:null,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}}),k=["type","endpoint","features"];function x(r,e){var a=1<arguments.length&&void 0!==e?e:"";if(!r)throw new Error("Cannot create a service without its definition.");if(k.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(!a)throw new Error("No project defined. Please enter a project key");var t=r.type,u=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}(s({type:t,features:n,params:l(),withVersion:b,withFullDataErasure:v,applyOrderEditTo:E},n.reduce(function(e,r){return r===c?s({},e,{},C,{},z):r===p?s({},e,{},O):r===f?s({},e,{},j):r===h?s({},e,{},I):r===d?s({},e,{},_,{},z,{params:g()}):r===m?s({},e,{},_,{},z,{},R):r===y?s({},e,{},q):e},{}),{build:function(e){var r,t=0<arguments.length&&void 0!==e?e:{withProjectKey:!0,applyOrderEdit:!1},n=t.withProjectKey,o=t.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,o=e.expand,s=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 s&&g.push("staged=".concat(s.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)),o&&o.length&&(g=g.concat(o.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 O=t.page,j=t.perPage,I=t.sort,z=t.withTotal;if("number"==typeof j&&g.push("limit=".concat(j)),O){var q=(j||20)*(O-1);g.push("offset=".concat(q))}I&&I.length&&(g=g.concat(I.map(function(e){return"sort=".concat(e)}))),"boolean"==typeof z&&g.push("withTotal=".concat(String(z)))}if(n){var R=n.text,_=n.fuzzy,k=n.fuzzyLevel,x=n.markMatchingVariants,P=n.facet,K=n.filter,T=n.filterByQuery,B=n.filterByFacets;R&&g.push("text.".concat(R.lang,"=").concat(R.value)),_&&g.push("fuzzy=true"),k&&g.push("fuzzyLevel=".concat(k)),g.push("markMatchingVariants=".concat(x.toString())),P.forEach(function(e){return g.push("facet=".concat(e))}),K.forEach(function(e){return g.push("filter=".concat(e))}),T.forEach(function(e){return g.push("filter.query=".concat(e))}),B.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),i=(n?"/".concat(a):"")+u+((r=this.params).id?"/".concat(r.id):r.orderNumber?"/order-number=".concat(r.orderNumber):r.key&&!r.container?"/key=".concat(r.key):r.key&&r.container?"/".concat(r.container,"/").concat(r.key):"")+(s&&!o?"?".concat(s):s);return function(){this.params.expand=l().expand,this.params.key=null,this.features.includes(p)&&(this.params.id=l().id),this.features.includes(c)&&(this.params.pagination=l().pagination,this.params.query=l().query),this.features.includes(d)&&(this.params.pagination=g().pagination,this.params.search=g().search),this.features.includes(f)&&(this.params.location=l().location),this.features.includes(m)&&(this.params.searchKeywords=[])}.call(this),i},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","container","orderNumber"];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)}),w(e,"id")&&this.byId(e.id),w(e,"key")&&!w(e,"container")&&this.byKey(e.key),w(e,"customerId")&&this.byCustomerId(e.customerId),w(e,"cartId")&&this.byCartId(e.cartId),w(e,"country")&&this.byCountry(e.country),w(e,"currency")&&this.byCurrency(e.currency),w(e,"state")&&this.byState(e.state),e.sort&&e.sort.forEach(function(e){r.sort(e.by,"asc"===e.direction)}),w(e,"page")&&this.page(e.page),w(e,"perPage")&&this.perPage(e.perPage),w(e,"staged")&&this.staged(e.staged),w(e,"priceCurrency")&&this.priceCurrency(e.priceCurrency),w(e,"priceCountry")&&this.priceCountry(e.priceCountry),w(e,"priceCustomerGroup")&&this.priceCustomerGroup(e.priceCustomerGroup),w(e,"priceChannel")&&this.priceChannel(e.priceChannel),w(e,"orderNumber")&&this.byOrderNumber(e.orderNumber),e.text&&this.text(e.text.value,e.text.language),e.fuzzy&&this.fuzzy(),w(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)}),w(e,"whereOperator")&&this.whereOperator(e.whereOperator),w(e,"version")&&this.withVersion(e.version),w(e,"dataErasure")&&this.withFullDataErasure(),w(e,"withTotal")&&this.withTotal(e.withTotal),w(e,"applyOrderEditTo")&&this.applyOrderEditTo(e.applyOrderEditTo),w(e,"container")&&w(e,"key")&&this.byContainerAndKey(e.container,e.key)}.call(this,e),this}}))}e.createRequestBuilder=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=s({},u,{},t.customServices);return Object.keys(n).reduce(function(e,r){return s({},e,o({},r,x(n[r],t.projectKey)))},{})},e.features=a,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -7,3 +7,3 @@ { | ||
"name": "@commercetools/api-request-builder", | ||
"version": "5.5.0", | ||
"version": "5.6.0", | ||
"description": "Helper functions to construct API requests URI for the commercetools platform in a declarative way.", | ||
@@ -34,3 +34,4 @@ "keywords": [ | ||
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -n CommercetoolsApiRequestBuilder -i ./src/index.js" | ||
} | ||
}, | ||
"gitHead": "c27df40b435f5a6c741413d17c12ed1f587e9139" | ||
} |
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
146824
7
3492
0