@hestia-earth/schema-convert 32.1.1 → 32.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/json.js +13 -6
- package/package.json +1 -1
package/json.js
CHANGED
|
@@ -493,18 +493,26 @@ var filterProperties = function (data, excludedProps) {
|
|
|
493
493
|
};
|
|
494
494
|
var nodeType = function (id, type, existingNode) {
|
|
495
495
|
if (existingNode === void 0) { existingNode = false; }
|
|
496
|
-
return type
|
|
496
|
+
return type
|
|
497
|
+
? existingNode
|
|
498
|
+
? (0, schema_1.isTypeNode)(type)
|
|
499
|
+
? { '@type': type, '@id': id }
|
|
500
|
+
: { '@type': type }
|
|
501
|
+
: (0, schema_1.isTypeNode)(type)
|
|
502
|
+
? { type: type, id: id }
|
|
503
|
+
: { type: type }
|
|
504
|
+
: {};
|
|
497
505
|
};
|
|
498
506
|
var extendDataFromSchema = function (_a, schema, type, _b) {
|
|
499
|
-
var id = _a.id, _t = _a.type, data = __rest(_a, ["id", "type"]);
|
|
507
|
+
var id = _a.id, _id = _a["@id"], _t = _a.type, data = __rest(_a, ["id", '@id', "type"]);
|
|
500
508
|
var _c = _b === void 0 ? {} : _b, ignoreInternal = _c.ignoreInternal, addDefaults = _c.addDefaults, convertToExistingNodes = _c.convertToExistingNodes;
|
|
501
|
-
return (0, utils_1.reduceUndefinedValues)(__assign(__assign(__assign({}, filterProperties(data, ignoreInternal ? [] : internalProperties(schema))), (addDefaults && !
|
|
509
|
+
return (0, utils_1.reduceUndefinedValues)(__assign(__assign(__assign({}, filterProperties(data, ignoreInternal ? [] : internalProperties(schema))), (addDefaults && !_id && schema
|
|
502
510
|
? getDefaultProperties(schema, data, ignoreInternal).reduce(function (prev, _a) {
|
|
503
511
|
var property = _a.property, defaultValue = _a.defaultValue;
|
|
504
512
|
prev[property] = defaultValue;
|
|
505
513
|
return prev;
|
|
506
514
|
}, {})
|
|
507
|
-
: {})), nodeType(id, type,
|
|
515
|
+
: {})), nodeType(id || _id, type, !!_id || convertToExistingNodes)), true);
|
|
508
516
|
};
|
|
509
517
|
var validateArrayType = function (schema, def, key, value) {
|
|
510
518
|
return typeof value !== 'object' ||
|
|
@@ -565,8 +573,7 @@ var formatNode = function (schemas, type, data, params) {
|
|
|
565
573
|
if (params === void 0) { params = {}; }
|
|
566
574
|
var schema = type in schemas && exports.acceptedNodeTypes.includes(type) ? schemas[type] : schemaNotFoundError(type);
|
|
567
575
|
var content = mapContent(schemas, schema, params)(data);
|
|
568
|
-
|
|
569
|
-
return (0, utils_1.reduceUndefinedValues)(__assign(__assign({}, (params.convertToExistingNodes ? { '@id': id } : { id: id })), extendDataFromSchema(content, schema, type, params)), true);
|
|
576
|
+
return (0, utils_1.reduceUndefinedValues)(extendDataFromSchema(content, schema, type, params), true);
|
|
570
577
|
};
|
|
571
578
|
exports.formatNode = formatNode;
|
|
572
579
|
var filterEmptyNode = function (schemas, node) {
|