@hestia-earth/schema-convert 9.2.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.
- package/json.js +25 -14
- 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
|
|
125
|
-
|
|
126
|
-
(value
|
|
127
|
-
isEmptyValueType
|
|
128
|
-
|
|
129
|
-
isEmptyValueType.
|
|
130
|
-
|
|
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)
|
|
229
|
-
|
|
230
|
-
|
|
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)
|
|
264
|
-
propertyTypeToValue.
|
|
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;
|