@hestia-earth/schema-convert 7.6.5 → 7.7.1
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 +23 -20
- package/package.json +1 -1
package/json.js
CHANGED
|
@@ -110,6 +110,28 @@ var internalProperties = function (_a) {
|
|
|
110
110
|
};
|
|
111
111
|
var isEmptyCell = function (value) { return value === IGNORE_FIELD_KEY || value === ''; };
|
|
112
112
|
var nonEmptyCell = function (value) { return !isEmptyCell(value); };
|
|
113
|
+
var isEmptyValueType = (_a = {
|
|
114
|
+
undefined: function () { return true; },
|
|
115
|
+
number: function (value) { return isNaN(value); }
|
|
116
|
+
},
|
|
117
|
+
_a[schema_1.SchemaType.Term] = function (value) { return !(value['@id'] || value.id || value.name); },
|
|
118
|
+
_a.BlankNode = function (value, schemas) {
|
|
119
|
+
return Object.values(value).filter(function (value) { return !utils_1.isEmpty(value); }).length <= schemaMinKeys(schemas, value);
|
|
120
|
+
},
|
|
121
|
+
_a.array = function (value) { return value.filter(function (v) { return !utils_1.isEmpty(v); }).length === 0; },
|
|
122
|
+
_a.object = function (value, schemas) {
|
|
123
|
+
return Array.isArray(value) ?
|
|
124
|
+
isEmptyValueType.array(value) :
|
|
125
|
+
(value['@type'] || value.type) === schema_1.SchemaType.Term ?
|
|
126
|
+
isEmptyValueType[schema_1.SchemaType.Term](value) :
|
|
127
|
+
schema_1.isBlankNode(value) ?
|
|
128
|
+
isEmptyValueType.BlankNode(value, schemas) :
|
|
129
|
+
Object.keys(value).length === 0;
|
|
130
|
+
},
|
|
131
|
+
_a);
|
|
132
|
+
var isEmptyValue = function (value, schemas) {
|
|
133
|
+
return (typeof value) in isEmptyValueType ? isEmptyValueType[typeof value](value, schemas) : isEmptyCell(value);
|
|
134
|
+
};
|
|
113
135
|
var compileFullKey = function (key1, key2) {
|
|
114
136
|
// handle arrays
|
|
115
137
|
var joinKey = (key2 || '').startsWith('[') ? '' : '.';
|
|
@@ -209,7 +231,7 @@ var propertyTypeToValue = {
|
|
|
209
231
|
Array.isArray(items.type) ?
|
|
210
232
|
propertyTypeToValue.auto(val, schemas, items, _i) :
|
|
211
233
|
propertyTypeToValue[items.type](val, schemas, items, _i)) : val; }))
|
|
212
|
-
.filter(function (val) { return !
|
|
234
|
+
.filter(function (val) { return !isEmptyValue(val, schemas); });
|
|
213
235
|
},
|
|
214
236
|
// try to determine the type automatically
|
|
215
237
|
auto: function (value, schemas, _d, _i) {
|
|
@@ -283,25 +305,6 @@ var extendDataFromSchema = function (_a, schema, type, ignoreInternal, top) {
|
|
|
283
305
|
}, {}) :
|
|
284
306
|
{})), nodeType(id, type, '@id' in data)), true);
|
|
285
307
|
};
|
|
286
|
-
var isEmptyValueType = (_a = {},
|
|
287
|
-
_a[schema_1.SchemaType.Term] = function (value) { return !(value['@id'] || value.id || value.name); },
|
|
288
|
-
_a.BlankNode = function (value, schemas) {
|
|
289
|
-
return Object.values(value).filter(function (value) { return !utils_1.isEmpty(value); }).length <= schemaMinKeys(schemas, value);
|
|
290
|
-
},
|
|
291
|
-
_a.array = function (value, schemas) { return value.every(function (val) { return isEmptyValue(val, schemas); }); },
|
|
292
|
-
_a.object = function (value, schemas) {
|
|
293
|
-
return Array.isArray(value) ?
|
|
294
|
-
isEmptyValueType.array(value, schemas) :
|
|
295
|
-
(value['@type'] || value.type) === schema_1.SchemaType.Term ?
|
|
296
|
-
isEmptyValueType[schema_1.SchemaType.Term](value) :
|
|
297
|
-
schema_1.isBlankNode(value) ?
|
|
298
|
-
isEmptyValueType.BlankNode(value, schemas) :
|
|
299
|
-
false;
|
|
300
|
-
},
|
|
301
|
-
_a);
|
|
302
|
-
var isEmptyValue = function (value, schemas) {
|
|
303
|
-
return (typeof value) in isEmptyValueType ? isEmptyValueType[typeof value](value, schemas) : isEmptyCell(value);
|
|
304
|
-
};
|
|
305
308
|
var mapContent = function (schemas, schema, ignoreInternal) { return function (json) {
|
|
306
309
|
return Object.keys(json)
|
|
307
310
|
.filter(nonEmptyCell)
|