@hestia-earth/schema-convert 9.0.0 → 9.3.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.
Files changed (2) hide show
  1. package/json.js +25 -14
  2. package/package.json +1 -1
package/json.js CHANGED
@@ -121,13 +121,15 @@ var isEmptyValueType = (_a = {
121
121
  },
122
122
  _a.array = function (value) { return value.filter(function (v) { return !utils_1.isEmpty(v); }).length === 0; },
123
123
  _a.object = function (value, schemas) {
124
- return Array.isArray(value) ?
125
- isEmptyValueType.array(value) :
126
- (value['@type'] || value.type) === schema_1.SchemaType.Term ?
127
- isEmptyValueType[schema_1.SchemaType.Term](value) :
128
- schema_1.isBlankNode(value) ?
129
- isEmptyValueType.BlankNode(value, schemas) :
130
- Object.keys(value).length === 0;
124
+ return value === null
125
+ ? false
126
+ : Array.isArray(value)
127
+ ? isEmptyValueType.array(value)
128
+ : (value['@type'] || value.type) === schema_1.SchemaType.Term
129
+ ? isEmptyValueType[schema_1.SchemaType.Term](value)
130
+ : schema_1.isBlankNode(value)
131
+ ? isEmptyValueType.BlankNode(value, schemas)
132
+ : Object.keys(value).length === 0;
131
133
  },
132
134
  _a);
133
135
  var isEmptyValue = function (value, schemas) {
@@ -223,11 +225,13 @@ var propertyTypeToValue = {
223
225
  },
224
226
  string: function (value) { return exports.cleanStringValue(value || ''); },
225
227
  number: function (value) {
226
- return isEmptyCell(value) ?
227
- undefined :
228
- isNaN(+value) ? (function () {
229
- throw new Error('failed to parse number');
230
- })() : +value;
228
+ return isEmptyCell(value)
229
+ ? undefined
230
+ : isNaN(+value)
231
+ ? (function () {
232
+ throw new Error('failed to parse number');
233
+ })()
234
+ : +value;
231
235
  },
232
236
  integer: function (value) { return isEmptyCell(value) ? undefined : +value; },
233
237
  boolean: function (value) {
@@ -260,8 +264,15 @@ var propertyTypeToValue = {
260
264
  // try to determine the type automatically
261
265
  auto: function (value, schemas, _d, _i) {
262
266
  // iris are mapped as {@id: val}
263
- return utils_1.isIri(value) ? propertyTypeToValue.required(value, schemas, { required: ['@id'] }, _i) : (utils_1.isBoolean(value) ? propertyTypeToValue.boolean(value) : (utils_1.isNumber(value) ? propertyTypeToValue.number(value) :
264
- propertyTypeToValue.string(value)));
267
+ return utils_1.isIri(value)
268
+ ? propertyTypeToValue.required(value, schemas, { required: ['@id'] }, _i)
269
+ : utils_1.isBoolean(value)
270
+ ? propertyTypeToValue.boolean(value)
271
+ : utils_1.isNumber(value)
272
+ ? propertyTypeToValue.number(value)
273
+ : value === 'null'
274
+ ? null
275
+ : propertyTypeToValue.string(value);
265
276
  },
266
277
  required: function (value, _schemas, _a) {
267
278
  var required = _a.required;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/schema-convert",
3
- "version": "9.0.0",
3
+ "version": "9.3.0",
4
4
  "description": "Hestia Schema Converters",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",