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

@intelligo.ai/object-to-schema

Package Overview
Dependencies
Maintainers
6
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@intelligo.ai/object-to-schema - npm Package Compare versions

Comparing version 1.5.5 to 1.5.6

1

dist/__tests__/__mapper__/data.json

@@ -9,2 +9,3 @@ {

},
"nicknames": ["john, johnny, john-boy, bigJ", "bbj", "mj"],
"addes": [{ "street": "s1", "house": "h1" }, { "street": "s2", "house": "h2" }],

@@ -11,0 +12,0 @@ "addesB": [

@@ -14,3 +14,5 @@ {

"path": "dob",
"predefinedTransformations": ["toDate"]
"predefinedTransformations": [
"toDate"
]
}

@@ -32,10 +34,35 @@ },

"path": "jobs.lastPositions",
"predefinedTransformations": ["titleCase"]
"predefinedTransformations": [
{
"transformation": "titleCase"
},
{
"transformation": "arrayToString",
"transformationArgs": ", "
}
]
}
},
{
"source": "person.nicknames",
"target": {
"path": "names.nicknames",
"predefinedTransformations": [
{
"transformation": "stringToArray",
"transformationArgs": ", "
},
{
"transformation": "titleCase"
}
]
}
},
{
"source": "person.positions.currentPosition",
"target": {
"path": "jobs.currentPosition",
"predefinedTransformations": ["titleCase"]
"predefinedTransformations": [
"titleCase"
]
}

@@ -65,3 +92,5 @@ },

"path": "addresses[].streetAddress",
"predefinedTransformations": ["titleCase"]
"predefinedTransformations": [
"titleCase"
]
}

@@ -68,0 +97,0 @@ },

6

dist/exampleRecordExtractor.js

@@ -20,3 +20,3 @@ "use strict";

if (typeof value == 'string') {
return _b = (_a = JSON.parse(value)) === null || _a === void 0 ? void 0 : _a.example, (_b !== null && _b !== void 0 ? _b : typeToRandomData((_d = (_c = JSON.parse(value)) === null || _c === void 0 ? void 0 : _c.type, (_d !== null && _d !== void 0 ? _d : ''))));
return (_b = (_a = JSON.parse(value)) === null || _a === void 0 ? void 0 : _a.example) !== null && _b !== void 0 ? _b : typeToRandomData((_d = (_c = JSON.parse(value)) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : '');
}

@@ -26,5 +26,5 @@ else if (Array.isArray(value)) {

? [
(_f = (_e = JSON.parse(value[0])) === null || _e === void 0 ? void 0 : _e.example, (_f !== null && _f !== void 0 ? _f : typeToRandomData((_h = (_g = JSON.parse(value[0])) === null || _g === void 0 ? void 0 : _g.type, (_h !== null && _h !== void 0 ? _h : '')))))
(_f = (_e = JSON.parse(value[0])) === null || _e === void 0 ? void 0 : _e.example) !== null && _f !== void 0 ? _f : typeToRandomData((_h = (_g = JSON.parse(value[0])) === null || _g === void 0 ? void 0 : _g.type) !== null && _h !== void 0 ? _h : '')
]
: [extractExampleFromSchema((_j = value[0], (_j !== null && _j !== void 0 ? _j : {})))];
: [extractExampleFromSchema((_j = value[0]) !== null && _j !== void 0 ? _j : {})];
}

@@ -31,0 +31,0 @@ else if (({}).constructor === value.constructor) {

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

var toDate = transform_1.applyToOneOrMany(function (str) { return new Date(str); });
var stringToArray = transform_1.applyToOneOrMany(function (str, separator) { return str.split(separator); });
var strategies = {

@@ -67,2 +68,4 @@ predefinedTransformations: {

toDate: function (str) { return toDate(str); },
arrayToString: function (arr, separator) { return arr.join(separator); },
stringToArray: function (str, separator) { return stringToArray(str, separator); },
}

@@ -121,4 +124,7 @@ };

.predefinedTransformations
.reduce(function (finalValue, transformationName) {
return (strategies.predefinedTransformations[transformationName] || generalUtil_1.identity)(finalValue);
.reduceRight(function (finalValue, predefinedTransformation) {
var _a, _b;
var transformationName = predefinedTransformation === null || predefinedTransformation === void 0 ? void 0 : predefinedTransformation.transformation;
var transformationArgs = (_a = predefinedTransformation === null || predefinedTransformation === void 0 ? void 0 : predefinedTransformation.transformationArgs) !== null && _a !== void 0 ? _a : undefined;
return ((_b = strategies.predefinedTransformations[transformationName]) !== null && _b !== void 0 ? _b : generalUtil_1.identity)(finalValue, transformationArgs);
}, valueToSet);

@@ -125,0 +131,0 @@ }

import { Transform, SomeObj, TreeLeaf } from './types';
export declare function generateTransform(transforms: Transform[]): Iterator<Transform>;
export declare function applyToOneOrMany<P, A>(fn: (oneOrMany: P) => A): (oneOrMany: P | P[]) => A | A[];
export declare function applyToOneOrMany<P, A>(fn: (oneOrMany: P, args?: string | string[]) => A): (oneOrMany: P | P[], args?: string | string[] | undefined) => A | A[];
export declare function assignSchema(schema: SomeObj, key: string, value: any): SomeObj & {

@@ -5,0 +5,0 @@ [x: string]: any;

@@ -58,6 +58,6 @@ "use strict";

function applyToOneOrMany(fn) {
return function withFunction(oneOrMany) {
return function withFunction(oneOrMany, args) {
return Array.isArray(oneOrMany)
? oneOrMany.map(fn)
: fn(oneOrMany);
? oneOrMany.flatMap(function (one) { return fn(one, args); })
: fn(oneOrMany, args);
};

@@ -84,3 +84,3 @@ }

function sortTransformsByPriority(transforms) {
return ramda_1.default.sort(function (ta, tb) { var _a, _b, _c, _d; return (_b = (_a = ta.target) === null || _a === void 0 ? void 0 : _a.priority, (_b !== null && _b !== void 0 ? _b : 1000)) - (_d = (_c = tb.target) === null || _c === void 0 ? void 0 : _c.priority, (_d !== null && _d !== void 0 ? _d : 1000)); }, transforms);
return ramda_1.default.sort(function (ta, tb) { var _a, _b, _c, _d; return ((_b = (_a = ta.target) === null || _a === void 0 ? void 0 : _a.priority) !== null && _b !== void 0 ? _b : 1000) - ((_d = (_c = tb.target) === null || _c === void 0 ? void 0 : _c.priority) !== null && _d !== void 0 ? _d : 1000); }, transforms);
}

@@ -87,0 +87,0 @@ exports.sortTransformsByPriority = sortTransformsByPriority;

@@ -7,3 +7,6 @@ declare type SomeObj = {

};
declare type PredefinedTransformation = 'toUpperCase' | 'toLowerCase' | 'titleCase' | 'toDate';
interface PredefinedTransformation {
transformationArgs?: any;
transformation: 'toUpperCase' | 'toLowerCase' | 'titleCase' | 'toDate' | 'stringToArray' | 'arrayToString';
}
declare type TreeLeaf = [string, Transform['target'][]];

@@ -10,0 +13,0 @@ declare type Transform = {

{
"name": "@intelligo.ai/object-to-schema",
"version": "1.5.5",
"version": "1.5.6",
"description": "",

@@ -27,2 +27,2 @@ "main": "dist/index.js",

}
}
}

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