Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@commercetools/frontend-sdk

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools/frontend-sdk - npm Package Compare versions

Comparing version 1.12.3 to 1.13.0

lib/chunk-I7E6EANH.mjs

5

CHANGELOG.md
## 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 @@

62

lib/helpers/urlHelpers.js
"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

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