@hestia-earth/schema-convert 14.0.0 → 14.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/csv-pivot.js CHANGED
@@ -68,7 +68,7 @@ var termId = function (term) { return term ? term['@id'] || term.id : undefined;
68
68
  var convertTerm = function (term) { return term ? { methodModel: termId(term) } : {}; };
69
69
  var pivotList = function (values) { return values.reduce(function (prev, _a) {
70
70
  var _b;
71
- var type = _a.type, _t = _a["@type"], term = _a.term, methodModel = _a.methodModel, value = _a.value;
71
+ var _t = _a["@type"], term = _a.term, methodModel = _a.methodModel, value = _a.value;
72
72
  var key = termId(term);
73
73
  var data = utils_1.reduceUndefinedValues(__assign(__assign({}, convertTerm(methodModel)), { value: convertValue(value) }));
74
74
  return __assign(__assign({}, prev), (key && Object.keys(data).length ? (_b = {}, _b[key] = (prev[key] || []).concat([data]), _b) : {}));
package/json.d.ts CHANGED
@@ -14,7 +14,7 @@ interface ICSVHeader {
14
14
  }
15
15
  export interface ICSVError {
16
16
  message: string;
17
- schema?: SchemaType;
17
+ schema?: SchemaType | string;
18
18
  schemaKey?: string;
19
19
  key?: string;
20
20
  property?: string;
package/json.js CHANGED
@@ -245,12 +245,19 @@ var validateGeoJSONFormat = function (value) {
245
245
  };
246
246
  /**
247
247
  * If the user provided a non-object where an object was expected, assume it was meant to be the `name` property.
248
- * For non-Terms, we assume it is the `id`.
248
+ * For Blank Nodes, we assume it is the `term.name`.
249
+ * For non-Term Nodes, we assume it is the `id`.
249
250
  *
250
251
  * @param value The value mapped as a Ref
251
252
  */
252
- var schemaRefValue = function (value, schemaType) {
253
- return typeof value === 'object' ? value : schemaType === schema_1.SchemaType.Term ? { name: value } : { id: value };
253
+ var schemaRefValue = function (value, type) {
254
+ return typeof value === 'object'
255
+ ? value
256
+ : type === schema_1.SchemaType.Term
257
+ ? { name: value }
258
+ : schema_1.isBlankNode({ type: type })
259
+ ? { term: { name: value } }
260
+ : { id: value };
254
261
  };
255
262
  exports.cleanStringValue = function (value) { return (value.match(/^[\d]+\.[\d]+\.[\d]+$/) === null ? value.replace(/\.0$/, '') : value).trim(); };
256
263
  var propertyTypeToValue = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/schema-convert",
3
- "version": "14.0.0",
3
+ "version": "14.2.0",
4
4
  "description": "Hestia Schema Converters",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",