@hestia-earth/schema-convert 22.3.0 → 23.0.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 +20 -1
- package/package.json +1 -1
package/json.js
CHANGED
|
@@ -202,6 +202,17 @@ var propertyInvalidFormat = function (schema, key, value, func) {
|
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
};
|
|
205
|
+
var validateDuplicatedIdFields = function (schema, key, value) {
|
|
206
|
+
return typeof value === 'object' && [value.id, value['@id']].every(function (v) { return !!v && nonEmptyCell(v); })
|
|
207
|
+
? (0, exports.throwCSVError)({
|
|
208
|
+
schema: schema.title,
|
|
209
|
+
message: 'duplicated-id-fields',
|
|
210
|
+
schemaKey: key,
|
|
211
|
+
key: key,
|
|
212
|
+
value: value
|
|
213
|
+
})
|
|
214
|
+
: null;
|
|
215
|
+
};
|
|
205
216
|
var handleArrayError = function (func) { return function (value, index) {
|
|
206
217
|
try {
|
|
207
218
|
return func(value, index);
|
|
@@ -441,7 +452,13 @@ var filterProperties = function (data, excludedProps) {
|
|
|
441
452
|
};
|
|
442
453
|
var nodeType = function (id, type, existingNode) {
|
|
443
454
|
if (existingNode === void 0) { existingNode = false; }
|
|
444
|
-
return type
|
|
455
|
+
return type
|
|
456
|
+
? (0, schema_1.isTypeNode)(type)
|
|
457
|
+
? existingNode
|
|
458
|
+
? { '@type': type }
|
|
459
|
+
: { id: id, type: type }
|
|
460
|
+
: { type: type }
|
|
461
|
+
: {};
|
|
445
462
|
};
|
|
446
463
|
var extendDataFromSchema = function (_a, schema, type, ignoreInternal, addDefaults) {
|
|
447
464
|
var id = _a.id, _t = _a.type, data = __rest(_a, ["id", "type"]);
|
|
@@ -470,6 +487,8 @@ var mapContent = function (schemas, schema, ignoreInternal) { return function (j
|
|
|
470
487
|
.reduce(function (prev, key) {
|
|
471
488
|
var _a;
|
|
472
489
|
var value = json[key];
|
|
490
|
+
// make sure we are not using both `id` and `@id` fields
|
|
491
|
+
validateDuplicatedIdFields(schema, key, value);
|
|
473
492
|
var propertyDefinition = getPropertyDefinition(schema, key, false, json);
|
|
474
493
|
var valueType = getValueType(schema, json);
|
|
475
494
|
var type = getPropertyType(propertyDefinition, key, valueType);
|