@sprucelabs/schema 27.0.0 → 27.0.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.
|
@@ -59,14 +59,16 @@ export default class SchemaField extends AbstractField {
|
|
|
59
59
|
const unions = [];
|
|
60
60
|
idsWithVersion.forEach((idWithVersion) => {
|
|
61
61
|
const { id, version, namespace } = idWithVersion;
|
|
62
|
-
let allMatches = templateItems.filter((item) =>
|
|
62
|
+
let allMatches = templateItems.filter((item) => {
|
|
63
|
+
if (!item.id) {
|
|
64
|
+
throwInvalidReferenceError(item);
|
|
65
|
+
}
|
|
66
|
+
return item.id.toLowerCase() === id.toLowerCase();
|
|
67
|
+
});
|
|
63
68
|
if (namespace) {
|
|
64
69
|
allMatches = allMatches.filter((item) => {
|
|
65
70
|
if (!item.namespace) {
|
|
66
|
-
|
|
67
|
-
code: 'INVALID_SCHEMA_REFERENCE',
|
|
68
|
-
friendlyMessage: `Generating template failed because one of your schema references (the schema a field with 'type=schema' points to) is missing a namespace. Look through your builders for a field pointing to something like:\n\n${JSON.stringify(item, null, 2)}`,
|
|
69
|
-
});
|
|
71
|
+
throwInvalidReferenceError(item);
|
|
70
72
|
}
|
|
71
73
|
return item.namespace.toLowerCase() === namespace.toLowerCase();
|
|
72
74
|
});
|
|
@@ -320,3 +322,9 @@ export default class SchemaField extends AbstractField {
|
|
|
320
322
|
});
|
|
321
323
|
}
|
|
322
324
|
}
|
|
325
|
+
function throwInvalidReferenceError(item) {
|
|
326
|
+
throw new SpruceError({
|
|
327
|
+
code: 'INVALID_SCHEMA_REFERENCE',
|
|
328
|
+
friendlyMessage: `Generating template failed because one of your schema references (the schema a field with 'type=schema' points to) is missing a namespace. Look through your builders for a field pointing to something like:\n\n${JSON.stringify(item, null, 2)}`,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
@@ -64,14 +64,16 @@ class SchemaField extends AbstractField_1.default {
|
|
|
64
64
|
const unions = [];
|
|
65
65
|
idsWithVersion.forEach((idWithVersion) => {
|
|
66
66
|
const { id, version, namespace } = idWithVersion;
|
|
67
|
-
let allMatches = templateItems.filter((item) =>
|
|
67
|
+
let allMatches = templateItems.filter((item) => {
|
|
68
|
+
if (!item.id) {
|
|
69
|
+
throwInvalidReferenceError(item);
|
|
70
|
+
}
|
|
71
|
+
return item.id.toLowerCase() === id.toLowerCase();
|
|
72
|
+
});
|
|
68
73
|
if (namespace) {
|
|
69
74
|
allMatches = allMatches.filter((item) => {
|
|
70
75
|
if (!item.namespace) {
|
|
71
|
-
|
|
72
|
-
code: 'INVALID_SCHEMA_REFERENCE',
|
|
73
|
-
friendlyMessage: `Generating template failed because one of your schema references (the schema a field with 'type=schema' points to) is missing a namespace. Look through your builders for a field pointing to something like:\n\n${JSON.stringify(item, null, 2)}`,
|
|
74
|
-
});
|
|
76
|
+
throwInvalidReferenceError(item);
|
|
75
77
|
}
|
|
76
78
|
return item.namespace.toLowerCase() === namespace.toLowerCase();
|
|
77
79
|
});
|
|
@@ -326,3 +328,9 @@ class SchemaField extends AbstractField_1.default {
|
|
|
326
328
|
}
|
|
327
329
|
}
|
|
328
330
|
exports.default = SchemaField;
|
|
331
|
+
function throwInvalidReferenceError(item) {
|
|
332
|
+
throw new SpruceError_1.default({
|
|
333
|
+
code: 'INVALID_SCHEMA_REFERENCE',
|
|
334
|
+
friendlyMessage: `Generating template failed because one of your schema references (the schema a field with 'type=schema' points to) is missing a namespace. Look through your builders for a field pointing to something like:\n\n${JSON.stringify(item, null, 2)}`,
|
|
335
|
+
});
|
|
336
|
+
}
|