@intelligo.ai/object-to-schema
Advanced tools
Comparing version 2.2.15 to 2.3.0
@@ -81,5 +81,6 @@ "use strict"; | ||
var transform = transformGenerator.next(); | ||
var valueToSet = object_path_1.default.get(originalObj, (0, stringUtil_1.unUnidotify)(transform.value.source)) || transform.value.target.defaultValue || null; | ||
var got = object_path_1.default.get(originalObj, (0, stringUtil_1.unUnidotify)(transform.value.source)); | ||
var valueToSet = got !== null && got !== void 0 ? got : (transform.value.target.defaultValue || null); | ||
while (!transform.done | ||
&& !(object_path_1.default.has(originalObj, (0, stringUtil_1.unUnidotify)(transform.value.source)) | ||
&& ((object_path_1.default.has(originalObj, (0, stringUtil_1.unUnidotify)(transform.value.source)) == undefined && object_path_1.default.has(originalObj, (0, stringUtil_1.unUnidotify)(transform.value.source)) == null) | ||
&& (!((_a = transform.value.target.predefinedTransformations) === null || _a === void 0 ? void 0 : _a.length) | ||
@@ -92,5 +93,7 @@ || getValueAfterTransformations(transform.value.target, valueToSet))) | ||
} | ||
valueToSet = object_path_1.default.get(originalObj, (0, stringUtil_1.unUnidotify)(transform.value.source)) || transform.value.target.defaultValue || null; | ||
var got_1 = object_path_1.default.get(originalObj, (0, stringUtil_1.unUnidotify)(transform.value.source)); | ||
valueToSet = got_1 !== null && got_1 !== void 0 ? got_1 : (transform.value.target.defaultValue || null); | ||
} | ||
return transform.done ? [] : [transform.value]; | ||
var returnvalue = transform.done ? [] : [transform.value]; | ||
return returnvalue; | ||
}; | ||
@@ -137,3 +140,4 @@ } | ||
var options = predefinedTransformation === null || predefinedTransformation === void 0 ? void 0 : predefinedTransformation.options; | ||
return ((_a = predefinedTransformations_1.strategies.predefinedTransformations[transformationName]) !== null && _a !== void 0 ? _a : generalUtil_1.identity)(finalValue, transformationArgs || options); | ||
var returnValue = ((_a = predefinedTransformations_1.strategies.predefinedTransformations[transformationName]) !== null && _a !== void 0 ? _a : generalUtil_1.identity)(finalValue, transformationArgs || options); | ||
return returnValue; | ||
}, valueToSet); | ||
@@ -148,3 +152,3 @@ } | ||
var value = object_path_1.default.get(originalObj, (0, stringUtil_1.unUnidotify)(source)); | ||
var valueToSet = value === 0 ? value : (value || target.defaultValue || null); | ||
var valueToSet = (value === 0 || value === false) ? value : (value || target.defaultValue || null); | ||
if (target.predefinedTransformations) { | ||
@@ -218,3 +222,3 @@ valueToSet = getValueAfterTransformations(target, valueToSet); | ||
function groupExtractionsByPath(transformations) { | ||
var _a = __read(ramda_1.default.partition(function (transform) { return transform.source.includes('[]'); }, transformations), 2), furtherProcessing = _a[0], noProcessing = _a[1]; | ||
var _a = __read(ramda_1.default.partition(function (transform) { var _a; return (_a = transform.source) === null || _a === void 0 ? void 0 : _a.includes('[]'); }, transformations), 2), furtherProcessing = _a[0], noProcessing = _a[1]; | ||
return { | ||
@@ -221,0 +225,0 @@ group: groupBySourcePrefix()(furtherProcessing), |
@@ -7,4 +7,8 @@ declare function fromTracerDate(tracerDate: number): string | undefined; | ||
declare function arrayObjectKeyToArrayString(value: any, options: any): any[]; | ||
declare function stringArrayToObjectArray(stringArrayValue: string[], options: { | ||
targetPath: string; | ||
}): (Record<string, any> | undefined)[] | undefined; | ||
declare function companyAddressType(addressType: string): any; | ||
declare function fieldConditionMapping(value: any, options: any): any; | ||
declare function invertBooleanValue(value: boolean): boolean | undefined; | ||
declare function joinObjectKeysToString(value: any, options: any): string; | ||
@@ -29,2 +33,4 @@ export declare const strategies: { | ||
joinObjectKeysToString: typeof joinObjectKeysToString; | ||
invertBooleanValue: typeof invertBooleanValue; | ||
stringArrayToObjectArray: typeof stringArrayToObjectArray; | ||
}; | ||
@@ -31,0 +37,0 @@ }; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
@@ -16,3 +39,3 @@ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
var transform_1 = require("./transform"); | ||
var object_path_1 = require("object-path"); | ||
var object_path_1 = __importStar(require("object-path")); | ||
var toLowerCase = (0, transform_1.applyToOneOrMany)(function (str) { return str.toLowerCase(); }); | ||
@@ -137,2 +160,12 @@ var toUpperCase = (0, transform_1.applyToOneOrMany)(function (str) { return str.toUpperCase(); }); | ||
} | ||
function stringArrayToObjectArray(stringArrayValue, options) { | ||
if (!stringArrayValue || !Array.isArray(stringArrayValue)) { | ||
return undefined; | ||
} | ||
return stringArrayValue.map(function (str) { | ||
var original = {}; | ||
object_path_1.default.set(original, options.targetPath, str); | ||
return original; | ||
}); | ||
} | ||
function companyAddressType(addressType) { | ||
@@ -159,3 +192,3 @@ var value; | ||
function fieldConditionMapping(value, options) { | ||
var pathToCheck = options.pathToCheck, condition = options.condition, conditionValue = options.conditionValue, valueToMap = options.valueToMap, pathToMap = options.pathToMap; | ||
var pathToCheck = options.pathToCheck, condition = options.condition, conditionValue = options.conditionValue, valueToMap = options.valueToMap, pathToMap = options.pathToMap, keepOriginalValue = options.keepOriginalValue; | ||
var valueToCheck = (0, object_path_1.get)(value, pathToCheck); | ||
@@ -169,6 +202,6 @@ var pass; | ||
case 'equals': | ||
pass = (valueToCheck && conditionValue === valueToCheck); | ||
pass = ((valueToCheck !== undefined && valueToCheck !== null) && conditionValue === valueToCheck); | ||
break; | ||
case 'contains': | ||
pass = (valueToCheck && (valueToCheck || '').toLowerCase().includes(conditionValue.toLowerCase())); | ||
pass = ((valueToCheck !== undefined && valueToCheck !== null) && (valueToCheck || '').toLowerCase().includes(conditionValue.toLowerCase())); | ||
; | ||
@@ -180,3 +213,3 @@ break; | ||
case 'notContain': | ||
pass = (valueToCheck && !(valueToCheck || '').toLowerCase().includes(conditionValue.toLowerCase())); | ||
pass = ((valueToCheck !== undefined && valueToCheck !== null) && !(valueToCheck || '').toLowerCase().includes(conditionValue.toLowerCase())); | ||
; | ||
@@ -189,4 +222,10 @@ break; | ||
valueToMap : | ||
undefined; | ||
keepOriginalValue ? value : undefined; | ||
} | ||
function invertBooleanValue(value) { | ||
if (typeof value !== 'boolean') { | ||
return undefined; | ||
} | ||
return !value; | ||
} | ||
function joinObjectKeysToString(value, options) { | ||
@@ -255,5 +294,7 @@ var e_1, _a; | ||
fieldConditionMapping: fieldConditionMapping, | ||
joinObjectKeysToString: joinObjectKeysToString | ||
joinObjectKeysToString: joinObjectKeysToString, | ||
invertBooleanValue: invertBooleanValue, | ||
stringArrayToObjectArray: stringArrayToObjectArray | ||
} | ||
}; | ||
//# sourceMappingURL=predefinedTransformations.js.map |
@@ -0,0 +0,0 @@ module.exports = { |
{ | ||
"name": "@intelligo.ai/object-to-schema", | ||
"version": "2.2.15", | ||
"version": "2.3.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -0,0 +0,0 @@ # object-to-schema-mapper |
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
Unstable ownership
Supply chain riskA new collaborator has begun publishing package versions. Package stability and security risk may be elevated.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
107826
60
1612
1
1