object-unpacker
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.createObjectUnpacker = void 0; | ||
var ajv_1 = __importDefault(require("ajv")); | ||
var loglevel_1 = __importDefault(require("loglevel")); | ||
@@ -17,57 +16,2 @@ var ReferencesResolver_1 = require("./ReferencesResolver"); | ||
exports.createObjectUnpacker = createObjectUnpacker; | ||
var ajv = new ajv_1.default({ allowUnionTypes: true }); | ||
var schema = { | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
$id: 'https://modules.numprotocol.com/unpacker-schema.json', | ||
title: 'Root', | ||
type: 'object', | ||
definitions: { | ||
notNullStringNoWhitespace: { | ||
$id: '#root/notNullStringNoWhitespace', | ||
title: 'notNullStringNoWhitespace', | ||
type: 'string', | ||
pattern: '^[^ \t\n\r\f\b]+$', | ||
nullable: false, | ||
minLength: 1, | ||
}, | ||
nullableString: { | ||
$id: '#root/nullableString', | ||
title: 'nullableString', | ||
type: 'string', | ||
nullable: true, | ||
}, | ||
assignKeys: { | ||
$id: '#root/assignKeys', | ||
title: 'assignKeys', | ||
type: 'array', | ||
items: { | ||
$ref: '#root/notNullStringNoWhitespace', | ||
}, | ||
minItems: 1, | ||
}, | ||
rewriteValue: { | ||
$id: '#root/rewriteValue', | ||
title: 'rewriteValue', | ||
type: ['object', 'string', 'array', 'number', 'boolean', 'integer', 'null'], | ||
}, | ||
}, | ||
properties: { | ||
assignKeys: { | ||
$ref: '#root/assignKeys', | ||
}, | ||
replacePair: { | ||
type: ['object', 'string', 'array', 'number', 'boolean', 'integer', 'null'], | ||
}, | ||
rewriteKey: { | ||
$ref: '#root/notNullStringNoWhitespace', | ||
}, | ||
rewriteValue: { | ||
$ref: '#root/rewriteValue', | ||
}, | ||
arrayItems: { | ||
$ref: '#root/notNullStringNoWhitespace', | ||
}, | ||
}, | ||
additionalProperties: true, | ||
}; | ||
var prefix = '%'; | ||
@@ -82,6 +26,2 @@ var postfix = '%'; | ||
try { | ||
var validate = ajv.compile(schema); | ||
if (!validate(rawMapping)) { | ||
throw new Error('The unpacker spec does not match the unpacker schema.'); | ||
} | ||
var mapping = toTransformationInstructions(rawMapping); | ||
@@ -358,3 +298,3 @@ var data = Util_1.transform(rawData, Util_1.prefixReferences); | ||
var newValueObj = {}; | ||
Object.keys(valueObj).forEach(function (k) { | ||
for (var k in valueObj) { | ||
if (mapSpec.additionalKeys.has(k)) { | ||
@@ -368,5 +308,5 @@ var spec = mapSpec.additionalKeys.get(k); | ||
} | ||
}); | ||
} | ||
return newValueObj; | ||
}; | ||
//# sourceMappingURL=ObjectUnpacker.js.map |
{ | ||
"name": "object-unpacker", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "A JSON to JSON mapper in TypeScript", | ||
@@ -8,8 +8,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"deep-eql": "^4.0.0", | ||
"ajv": "^8.0.3", | ||
"fs": "0.0.1-security", | ||
"loglevel": "^1.7.0", | ||
"loglevel-plugin-prefix": "^0.8.4", | ||
"typescript": "^4.0.2" | ||
"loglevel-plugin-prefix": "^0.8.4" | ||
}, | ||
@@ -22,2 +18,4 @@ "devDependencies": { | ||
"chai": "^4.2.0", | ||
"deep-eql": "^4.0.0", | ||
"fs": "0.0.1-security", | ||
"mocha": "^8.1.3", | ||
@@ -28,2 +26,3 @@ "ts-loader": "^7.0.5", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^4.0.2", | ||
"webpack": "^5.23.0" | ||
@@ -30,0 +29,0 @@ }, |
Sorry, the diff of this file is too big to display
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
2
124043
14
20
619
- Removedajv@^8.0.3
- Removeddeep-eql@^4.0.0
- Removedfs@0.0.1-security
- Removedtypescript@^4.0.2
- Removedajv@8.17.1(transitive)
- Removeddeep-eql@4.1.4(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-uri@3.0.3(transitive)
- Removedfs@0.0.1-security(transitive)
- Removedjson-schema-traverse@1.0.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedtype-detect@4.1.0(transitive)
- Removedtypescript@4.9.5(transitive)