@hestia-earth/schema-convert 32.1.1 → 32.1.2

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.
Files changed (2) hide show
  1. package/json.js +13 -5
  2. 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 ? (existingNode ? { '@type': type } : { id: id, type: 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 && !('@id' in data) && schema
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, '@id' in data || convertToExistingNodes)), true);
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' ||
@@ -566,7 +574,7 @@ var formatNode = function (schemas, type, data, 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
576
  var id = isEmptyCell(data.id) ? undefined : data.id;
569
- return (0, utils_1.reduceUndefinedValues)(__assign(__assign({}, (params.convertToExistingNodes ? { '@id': id } : { id: id })), extendDataFromSchema(content, schema, type, params)), true);
577
+ return (0, utils_1.reduceUndefinedValues)(extendDataFromSchema(content, schema, type, params), true);
570
578
  };
571
579
  exports.formatNode = formatNode;
572
580
  var filterEmptyNode = function (schemas, node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/schema-convert",
3
- "version": "32.1.1",
3
+ "version": "32.1.2",
4
4
  "description": "HESTIA Schema Converters",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",