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

@wix/sdk-runtime

Package Overview
Dependencies
Maintainers
21
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wix/sdk-runtime - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

14

build/index.d.ts

@@ -0,1 +1,13 @@

/**
* Recursively rename nested keys provided in `renameMap` in the given object.
* Providing a list of paths to ignore will prevent renaming of keys in nested objects.
*
* Paths are provided in the format of 'path.to.nested.field'
* @param payload The object to rename keys for
* @param renameMap A map of keys to rename, where the key is the original key and the value is the new key
* @param ignorePaths Paths of nested fields to ignore while traversing the object
* @returns The object with renamed keys
*/
declare function renameAllNestedKeys(payload: Record<string, unknown> | null | undefined, renameMap: Record<string, string>, ignorePaths: string[]): Record<string, unknown> | null | undefined;
type ValidationErrorResponse = {

@@ -36,2 +48,2 @@ details: {

export { ApplicationErrorResponse, HTTPClientError, ValidationErrorResponse, transformError };
export { type ApplicationErrorResponse, type HTTPClientError, type ValidationErrorResponse, renameAllNestedKeys, transformError };

47

build/index.js

@@ -23,2 +23,3 @@ "use strict";

__export(src_exports, {
renameAllNestedKeys: () => renameAllNestedKeys,
transformError: () => transformError

@@ -28,15 +29,41 @@ });

// src/rename-all-nested-keys.ts
function renameAllNestedKeys(payload, renameMap, ignorePaths) {
const isIgnored = (path) => ignorePaths.includes(path);
const traverse = (obj, path) => {
if (Array.isArray(obj)) {
obj.forEach((item) => {
traverse(item, path);
});
} else if (typeof obj === "object" && obj !== null) {
const objAsRecord = obj;
Object.keys(objAsRecord).forEach((key) => {
const newPath = path === "" ? key : `${path}.${key}`;
if (isIgnored(newPath)) {
return;
}
if (key in renameMap) {
objAsRecord[renameMap[key]] = objAsRecord[key];
delete objAsRecord[key];
}
traverse(objAsRecord[key], newPath);
});
}
};
traverse(payload, "");
return payload;
}
// ../../node_modules/change-case/dist/index.js
var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
var SPLIT_NUMBER_LOWER_RE = /(\d)(\p{Ll})/gu;
var SPLIT_LETTER_NUMBER_RE = /(\p{L})(\d)/gu;
var SPLIT_LOWER_UPPER_RE = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu");
var SPLIT_UPPER_UPPER_RE = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu");
var SPLIT_NUMBER_LOWER_RE = new RegExp("(\\d)(\\p{Ll})", "gu");
var SPLIT_LETTER_NUMBER_RE = new RegExp("(\\p{L})(\\d)", "gu");
var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
var SPLIT_REPLACE_VALUE = "$1\0$2";
var DEFAULT_PREFIX_CHARACTERS = "";
function split(input, options = {}) {
const { separateNumbers } = options;
function split(input, options) {
let result = input.trim();
result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
if (separateNumbers) {
if (options?.separateNumbers) {
result = result.replace(SPLIT_NUMBER_LOWER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_LETTER_NUMBER_RE, SPLIT_REPLACE_VALUE);

@@ -57,4 +84,3 @@ }

const prefix = getPrefix(input, options?.prefixCharacters);
const upper = upperFactory(options?.locale);
return prefix + split(input, options).map(upper).join("_");
return prefix + split(input, options).map(upperFactory(options?.locale)).join(options?.delimiter ?? "_");
}

@@ -77,3 +103,3 @@ function upperFactory(locale) {

// src/index.ts
// src/transform-error.ts
var isValidationError = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});

@@ -242,3 +268,4 @@ var isApplicationError = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});

0 && (module.exports = {
renameAllNestedKeys,
transformError
});
{
"name": "@wix/sdk-runtime",
"version": "0.0.1",
"version": "0.0.2",
"license": "UNLICENSED",

@@ -29,3 +29,3 @@ "main": "build/index.js",

"@types/is-ci": "^3.0.4",
"change-case": "^5.1.2",
"change-case": "^5.2.0",
"eslint": "^7.32.0",

@@ -35,6 +35,6 @@ "eslint-config-sdk": "0.0.0",

"jsdom": "^22.1.0",
"tsup": "^7.2.0",
"typescript": "~4.9.5",
"tsup": "^7.3.0",
"typescript": "^5.3.2",
"vitest": "^0.34.6",
"vitest-teamcity-reporter": "^0.2.0"
"vitest-teamcity-reporter": "^0.2.1"
},

@@ -58,3 +58,3 @@ "eslintConfig": {

},
"falconPackageHash": "3f8074687cb414c48bce5d1ec23d04127e5a27cd74abd3a0184138bb"
"falconPackageHash": "e1ca616ab57085bd69366eaf0d15913e417a86c257c2283bb10fa1e1"
}

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