@commercetools/frontend-sdk
Advanced tools
Comparing version 1.12.3 to 1.13.0
## Version 1.13.0 (2024-06-19) | ||
* Added compatability for all JSON serialisable types in query | ||
## Version 1.12.3 (2024-06-17) | ||
@@ -3,0 +8,0 @@ |
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -18,2 +20,10 @@ var __export = (target, all) => { | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -28,2 +38,3 @@ | ||
module.exports = __toCommonJS(urlHelpers_exports); | ||
var import_qs = __toESM(require("qs")); | ||
var normaliseUrl = function(url) { | ||
@@ -50,27 +61,40 @@ let protocolSplit = url.split("//"); | ||
}; | ||
var nullOrUndefinedToString = (value) => { | ||
switch (value) { | ||
case void 0: | ||
return "undefined"; | ||
case null: | ||
return "null"; | ||
default: | ||
return ""; | ||
} | ||
}; | ||
var toQueryObject = function(key, value) { | ||
let obj = {}; | ||
obj[key] = value; | ||
return obj; | ||
}; | ||
var toQueryString = function(obj) { | ||
return import_qs.default.stringify(obj, { | ||
arrayFormat: "indices", | ||
encodeValuesOnly: true, | ||
format: "RFC3986" | ||
}); | ||
}; | ||
var generateQueryString = function(query) { | ||
let queryString = ""; | ||
let arrayParams = []; | ||
const params = new URLSearchParams(); | ||
let queryString = "?"; | ||
Object.keys(query).forEach((key) => { | ||
let value = query[key]; | ||
if (value !== void 0) { | ||
if (Array.isArray(value)) { | ||
arrayParams.push(key); | ||
value.forEach((currentValue) => { | ||
params.append(key, currentValue.toString()); | ||
}); | ||
} else { | ||
params.set(key, query[key].toString()); | ||
if (value === null || value === void 0) { | ||
queryString += `${toQueryString( | ||
toQueryObject(key, nullOrUndefinedToString(value)) | ||
)}&`; | ||
} else { | ||
if (typeof value !== "function") { | ||
queryString += `${toQueryString(toQueryObject(key, value))}&`; | ||
} | ||
} | ||
}); | ||
queryString = params.toString(); | ||
arrayParams.forEach((arrayParam) => { | ||
queryString = queryString.replaceAll( | ||
`${arrayParam}=`, | ||
`${arrayParam}[]=` | ||
); | ||
}); | ||
return queryString ? `?${queryString}` : ""; | ||
queryString = queryString.substring(0, queryString.length - 1); | ||
return queryString; | ||
}; | ||
@@ -77,0 +101,0 @@ // Annotate the CommonJS export names for ESM import in node: |
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -18,2 +20,10 @@ var __export = (target, all) => { | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -579,2 +589,3 @@ | ||
// src/helpers/urlHelpers.ts | ||
var import_qs = __toESM(require("qs")); | ||
var normaliseUrl = function(url) { | ||
@@ -601,27 +612,40 @@ let protocolSplit = url.split("//"); | ||
}; | ||
var nullOrUndefinedToString = (value) => { | ||
switch (value) { | ||
case void 0: | ||
return "undefined"; | ||
case null: | ||
return "null"; | ||
default: | ||
return ""; | ||
} | ||
}; | ||
var toQueryObject = function(key, value) { | ||
let obj = {}; | ||
obj[key] = value; | ||
return obj; | ||
}; | ||
var toQueryString = function(obj) { | ||
return import_qs.default.stringify(obj, { | ||
arrayFormat: "indices", | ||
encodeValuesOnly: true, | ||
format: "RFC3986" | ||
}); | ||
}; | ||
var generateQueryString = function(query) { | ||
let queryString = ""; | ||
let arrayParams = []; | ||
const params = new URLSearchParams(); | ||
let queryString = "?"; | ||
Object.keys(query).forEach((key) => { | ||
let value = query[key]; | ||
if (value !== void 0) { | ||
if (Array.isArray(value)) { | ||
arrayParams.push(key); | ||
value.forEach((currentValue) => { | ||
params.append(key, currentValue.toString()); | ||
}); | ||
} else { | ||
params.set(key, query[key].toString()); | ||
if (value === null || value === void 0) { | ||
queryString += `${toQueryString( | ||
toQueryObject(key, nullOrUndefinedToString(value)) | ||
)}&`; | ||
} else { | ||
if (typeof value !== "function") { | ||
queryString += `${toQueryString(toQueryObject(key, value))}&`; | ||
} | ||
} | ||
}); | ||
queryString = params.toString(); | ||
arrayParams.forEach((arrayParam) => { | ||
queryString = queryString.replaceAll( | ||
`${arrayParam}=`, | ||
`${arrayParam}[]=` | ||
); | ||
}); | ||
return queryString ? `?${queryString}` : ""; | ||
queryString = queryString.substring(0, queryString.length - 1); | ||
return queryString; | ||
}; | ||
@@ -628,0 +652,0 @@ |
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -18,2 +20,10 @@ var __export = (target, all) => { | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -359,2 +369,3 @@ | ||
// src/helpers/urlHelpers.ts | ||
var import_qs = __toESM(require("qs")); | ||
var normaliseUrl = function(url) { | ||
@@ -381,27 +392,40 @@ let protocolSplit = url.split("//"); | ||
}; | ||
var nullOrUndefinedToString = (value) => { | ||
switch (value) { | ||
case void 0: | ||
return "undefined"; | ||
case null: | ||
return "null"; | ||
default: | ||
return ""; | ||
} | ||
}; | ||
var toQueryObject = function(key, value) { | ||
let obj = {}; | ||
obj[key] = value; | ||
return obj; | ||
}; | ||
var toQueryString = function(obj) { | ||
return import_qs.default.stringify(obj, { | ||
arrayFormat: "indices", | ||
encodeValuesOnly: true, | ||
format: "RFC3986" | ||
}); | ||
}; | ||
var generateQueryString = function(query) { | ||
let queryString = ""; | ||
let arrayParams = []; | ||
const params = new URLSearchParams(); | ||
let queryString = "?"; | ||
Object.keys(query).forEach((key) => { | ||
let value = query[key]; | ||
if (value !== void 0) { | ||
if (Array.isArray(value)) { | ||
arrayParams.push(key); | ||
value.forEach((currentValue) => { | ||
params.append(key, currentValue.toString()); | ||
}); | ||
} else { | ||
params.set(key, query[key].toString()); | ||
if (value === null || value === void 0) { | ||
queryString += `${toQueryString( | ||
toQueryObject(key, nullOrUndefinedToString(value)) | ||
)}&`; | ||
} else { | ||
if (typeof value !== "function") { | ||
queryString += `${toQueryString(toQueryObject(key, value))}&`; | ||
} | ||
} | ||
}); | ||
queryString = params.toString(); | ||
arrayParams.forEach((arrayParam) => { | ||
queryString = queryString.replaceAll( | ||
`${arrayParam}=`, | ||
`${arrayParam}[]=` | ||
); | ||
}); | ||
return queryString ? `?${queryString}` : ""; | ||
queryString = queryString.substring(0, queryString.length - 1); | ||
return queryString; | ||
}; | ||
@@ -408,0 +432,0 @@ |
type BasicTypes = string | number | boolean; | ||
type AcceptedQueryValueTypes = BasicTypes | AcceptedQueryValueTypes[] | { | ||
[key: string]: AcceptedQueryValueTypes; | ||
}; | ||
type AcceptedQueryTypes = { | ||
[key: string]: BasicTypes | Array<BasicTypes>; | ||
[key: string]: AcceptedQueryValueTypes; | ||
}; | ||
export { AcceptedQueryTypes }; | ||
export { AcceptedQueryTypes, AcceptedQueryValueTypes }; |
{ | ||
"name": "@commercetools/frontend-sdk", | ||
"version": "1.12.3", | ||
"version": "1.13.0", | ||
"license": "UNLICENSED", | ||
@@ -16,3 +16,4 @@ "main": "lib/index.js", | ||
"@frontastic/extension-types": "^0.0.11", | ||
"cookie": "^0.5.0" | ||
"cookie": "^0.5.0", | ||
"qs": "^6.12.1" | ||
}, | ||
@@ -23,2 +24,3 @@ "devDependencies": { | ||
"@types/node": "^18.14.0", | ||
"@types/qs": "^6.9.15", | ||
"cross-fetch": "^3.1.6", | ||
@@ -25,0 +27,0 @@ "prettier": "2.7.1", |
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
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
494071
6199
3
9
+ Addedqs@^6.12.1
+ Addedcall-bind@1.0.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)