@intelligo.ai/object-to-schema
Advanced tools
Comparing version 2.1.2 to 2.1.3
@@ -9,2 +9,31 @@ "use strict"; | ||
exports.extractExampleFromSchema = exampleRecordExtractor_1.extractExampleFromSchema; | ||
var aa = { | ||
"notes": [ | ||
{ | ||
"note": "note 1", | ||
"comment": "bla bla" | ||
}, | ||
{ | ||
"note": "note 2", | ||
"comment": "bla bla 2" | ||
}, | ||
], | ||
}; | ||
var a = mapper_1.mapObject(aa, [ | ||
{ | ||
"source": "notes", | ||
"target": { | ||
"path": "furtherInformation", | ||
"predefinedTransformations": [ | ||
{ | ||
"transformation": "arrayObjectKeyToString", | ||
"options": { | ||
"separator": '; ', | ||
"path": 'note' | ||
} | ||
} | ||
] | ||
} | ||
} | ||
]); | ||
//# sourceMappingURL=index.js.map |
@@ -131,6 +131,7 @@ "use strict"; | ||
.reduceRight(function (finalValue, predefinedTransformation) { | ||
var _a, _b; | ||
var _a; | ||
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 = predefinedTransformations_1.strategies.predefinedTransformations[transformationName]) !== null && _b !== void 0 ? _b : generalUtil_1.identity)(finalValue, transformationArgs); | ||
var transformationArgs = predefinedTransformation === null || predefinedTransformation === void 0 ? void 0 : predefinedTransformation.transformationArgs; | ||
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); | ||
}, valueToSet); | ||
@@ -137,0 +138,0 @@ } |
@@ -5,2 +5,3 @@ declare function fromTracerDate(tracerDate: number): string | undefined; | ||
declare function dateToYear(date: string): number | undefined; | ||
declare function arrayObjectKeyToString(value: any, options: any): string; | ||
declare function companyAddressType(addressType: string): any; | ||
@@ -20,2 +21,3 @@ export declare const strategies: { | ||
dateToYear: typeof dateToYear; | ||
arrayObjectKeyToString: typeof arrayObjectKeyToString; | ||
}; | ||
@@ -22,0 +24,0 @@ }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var transform_1 = require("./transform"); | ||
var object_path_1 = require("object-path"); | ||
var toLowerCase = transform_1.applyToOneOrMany(function (str) { return str.toLowerCase(); }); | ||
@@ -71,2 +72,11 @@ var toUpperCase = transform_1.applyToOneOrMany(function (str) { return str.toUpperCase(); }); | ||
} | ||
function arrayObjectKeyToString(value, options) { | ||
var path = options.path, separator = options.separator; | ||
if (!Array.isArray(value)) { | ||
throw new Error('the value is not array'); | ||
} | ||
return value | ||
.map(function (entry) { return object_path_1.get(entry, path); }) | ||
.join(separator); | ||
} | ||
function companyAddressType(addressType) { | ||
@@ -104,5 +114,6 @@ var value; | ||
companyAddressType: companyAddressType, | ||
dateToYear: dateToYear | ||
dateToYear: dateToYear, | ||
arrayObjectKeyToString: arrayObjectKeyToString | ||
} | ||
}; | ||
//# sourceMappingURL=predefinedTransformations.js.map |
@@ -9,3 +9,6 @@ declare type SomeObj = { | ||
transformationArgs?: any; | ||
transformation: 'toUpperCase' | 'toLowerCase' | 'titleCase' | 'toDate' | 'stringToArray' | 'arrayToString' | 'fromTracerDate'; | ||
transformation: string; | ||
options?: { | ||
[key: string]: any; | ||
}; | ||
} | ||
@@ -12,0 +15,0 @@ declare type TreeLeaf = [string, Transform['target'][]]; |
{ | ||
"name": "@intelligo.ai/object-to-schema", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "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
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
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
346608
6748