New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@datocms/rest-client-utils

Package Overview
Dependencies
Maintainers
0
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datocms/rest-client-utils - npm Package Compare versions

Comparing version 3.3.15 to 3.3.21

23

dist/cjs/__tests__/buildNormalizedParams.test.js

@@ -60,4 +60,23 @@ "use strict";

expect((0, buildNormalizedParams_1.buildNormalizedParams)({
foo: { bar: ['a', 'b', 10] },
})).toMatchInlineSnapshot("\n [\n [\n \"foo[bar][]\",\n \"a\",\n ],\n [\n \"foo[bar][]\",\n \"b\",\n ],\n [\n \"foo[bar][]\",\n \"10\",\n ],\n ]\n ");
filter: {
type: 'product',
fields: {
id: { anyIn: ['a', 'b', 'c'] },
},
},
})).toMatchInlineSnapshot("\n [\n [\n \"filter[type]\",\n \"product\",\n ],\n [\n \"filter[fields][id][anyIn][0]\",\n \"a\",\n ],\n [\n \"filter[fields][id][anyIn][1]\",\n \"b\",\n ],\n [\n \"filter[fields][id][anyIn][2]\",\n \"c\",\n ],\n ]\n ");
expect((0, buildNormalizedParams_1.buildNormalizedParams)({
filter: {
type: 'product',
fields: {
OR: [
{
name: { matches: { pattern: 'sistrall' } },
id: { eq: '123456' },
},
{ productNumber: { matches: { pattern: 'AmOYpJwZ3h' } } },
],
},
},
})).toMatchInlineSnapshot("\n [\n [\n \"filter[type]\",\n \"product\",\n ],\n [\n \"filter[fields][OR][0][name][matches][pattern]\",\n \"sistrall\",\n ],\n [\n \"filter[fields][OR][0][id][eq]\",\n \"123456\",\n ],\n [\n \"filter[fields][OR][1][productNumber][matches][pattern]\",\n \"AmOYpJwZ3h\",\n ],\n ]\n ");
return [2 /*return*/];

@@ -64,0 +83,0 @@ });

25

dist/cjs/buildNormalizedParams.js

@@ -43,23 +43,10 @@ "use strict";

}
else if (typeof value === 'object') {
if (Array.isArray(value)) {
for (var _i = 0, _a = value; _i < _a.length; _i++) {
var innerValue = _a[_i];
for (var _b = 0, _c = buildNormalizedParams(innerValue, __spreadArray(__spreadArray([], path, true), [
ARRAY_INDEX,
], false)); _b < _c.length; _b++) {
var param = _c[_b];
result.push(param);
}
else if (typeof value === 'object' && value) {
for (var _i = 0, _a = Object.entries(value); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], innerValue = _b[1];
for (var _c = 0, _d = buildNormalizedParams(innerValue, __spreadArray(__spreadArray([], path, true), [key], false)); _c < _d.length; _c++) {
var param = _d[_c];
result.push(param);
}
}
else if (value) {
for (var _d = 0, _e = Object.entries(value); _d < _e.length; _d++) {
var _f = _e[_d], key = _f[0], innerValue = _f[1];
for (var _g = 0, _h = buildNormalizedParams(innerValue, __spreadArray(__spreadArray([], path, true), [key], false)); _g < _h.length; _g++) {
var param = _h[_g];
result.push(param);
}
}
}
}

@@ -66,0 +53,0 @@ return result;

@@ -58,4 +58,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

expect(buildNormalizedParams({
foo: { bar: ['a', 'b', 10] },
})).toMatchInlineSnapshot("\n [\n [\n \"foo[bar][]\",\n \"a\",\n ],\n [\n \"foo[bar][]\",\n \"b\",\n ],\n [\n \"foo[bar][]\",\n \"10\",\n ],\n ]\n ");
filter: {
type: 'product',
fields: {
id: { anyIn: ['a', 'b', 'c'] },
},
},
})).toMatchInlineSnapshot("\n [\n [\n \"filter[type]\",\n \"product\",\n ],\n [\n \"filter[fields][id][anyIn][0]\",\n \"a\",\n ],\n [\n \"filter[fields][id][anyIn][1]\",\n \"b\",\n ],\n [\n \"filter[fields][id][anyIn][2]\",\n \"c\",\n ],\n ]\n ");
expect(buildNormalizedParams({
filter: {
type: 'product',
fields: {
OR: [
{
name: { matches: { pattern: 'sistrall' } },
id: { eq: '123456' },
},
{ productNumber: { matches: { pattern: 'AmOYpJwZ3h' } } },
],
},
},
})).toMatchInlineSnapshot("\n [\n [\n \"filter[type]\",\n \"product\",\n ],\n [\n \"filter[fields][OR][0][name][matches][pattern]\",\n \"sistrall\",\n ],\n [\n \"filter[fields][OR][0][id][eq]\",\n \"123456\",\n ],\n [\n \"filter[fields][OR][1][productNumber][matches][pattern]\",\n \"AmOYpJwZ3h\",\n ],\n ]\n ");
return [2 /*return*/];

@@ -62,0 +81,0 @@ });

@@ -40,23 +40,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {

}
else if (typeof value === 'object') {
if (Array.isArray(value)) {
for (var _i = 0, _a = value; _i < _a.length; _i++) {
var innerValue = _a[_i];
for (var _b = 0, _c = buildNormalizedParams(innerValue, __spreadArray(__spreadArray([], path, true), [
ARRAY_INDEX,
], false)); _b < _c.length; _b++) {
var param = _c[_b];
result.push(param);
}
else if (typeof value === 'object' && value) {
for (var _i = 0, _a = Object.entries(value); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], innerValue = _b[1];
for (var _c = 0, _d = buildNormalizedParams(innerValue, __spreadArray(__spreadArray([], path, true), [key], false)); _c < _d.length; _c++) {
var param = _d[_c];
result.push(param);
}
}
else if (value) {
for (var _d = 0, _e = Object.entries(value); _d < _e.length; _d++) {
var _f = _e[_d], key = _f[0], innerValue = _f[1];
for (var _g = 0, _h = buildNormalizedParams(innerValue, __spreadArray(__spreadArray([], path, true), [key], false)); _g < _h.length; _g++) {
var param = _h[_g];
result.push(param);
}
}
}
}

@@ -63,0 +50,0 @@ return result;

{
"name": "@datocms/rest-client-utils",
"version": "3.3.15",
"version": "3.3.21",
"description": "Utilities for DatoCMS REST API clients",

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

},
"gitHead": "eb1ec37186876ac65ca0b21a23be00513b42b087",
"gitHead": "713848cc43e9c00294f580f0c80667f992f129e5",
"devDependencies": {

@@ -44,0 +44,0 @@ "@types/qs": "^6.9.7"

@@ -86,3 +86,8 @@ import { buildNormalizedParams } from '../buildNormalizedParams';

buildNormalizedParams({
foo: { bar: ['a', 'b', 10] },
filter: {
type: 'product',
fields: {
id: { anyIn: ['a', 'b', 'c'] },
},
},
}),

@@ -92,16 +97,56 @@ ).toMatchInlineSnapshot(`

[
"foo[bar][]",
"filter[type]",
"product",
],
[
"filter[fields][id][anyIn][0]",
"a",
],
[
"foo[bar][]",
"filter[fields][id][anyIn][1]",
"b",
],
[
"foo[bar][]",
"10",
"filter[fields][id][anyIn][2]",
"c",
],
]
`);
expect(
buildNormalizedParams({
filter: {
type: 'product',
fields: {
OR: [
{
name: { matches: { pattern: 'sistrall' } },
id: { eq: '123456' },
},
{ productNumber: { matches: { pattern: 'AmOYpJwZ3h' } } },
],
},
},
}),
).toMatchInlineSnapshot(`
[
[
"filter[type]",
"product",
],
[
"filter[fields][OR][0][name][matches][pattern]",
"sistrall",
],
[
"filter[fields][OR][0][id][eq]",
"123456",
],
[
"filter[fields][OR][1][productNumber][matches][pattern]",
"AmOYpJwZ3h",
],
]
`);
});
});

@@ -43,18 +43,7 @@ const ARRAY_INDEX = '__ARRAY_INDEX__';

result.push([buildKey(path), serializeValue(value)]);
} else if (typeof value === 'object') {
if (Array.isArray(value)) {
for (const innerValue of value as unknown[]) {
for (const param of buildNormalizedParams(innerValue, [
...path,
ARRAY_INDEX,
])) {
result.push(param);
}
} else if (typeof value === 'object' && value) {
for (const [key, innerValue] of Object.entries(value)) {
for (const param of buildNormalizedParams(innerValue, [...path, key])) {
result.push(param);
}
} else if (value) {
for (const [key, innerValue] of Object.entries(value)) {
for (const param of buildNormalizedParams(innerValue, [...path, key])) {
result.push(param);
}
}
}

@@ -61,0 +50,0 @@ }

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