data-prism
Advanced tools
Comparing version 0.0.38 to 0.0.39
@@ -37,3 +37,3 @@ export const columnTypeModifiers = { | ||
// geojson | ||
geojson: { | ||
"data-prism:geojson": { | ||
schemaProperties: { | ||
@@ -40,0 +40,0 @@ type: "object", |
@@ -42,18 +42,18 @@ const attributeTypes = [ | ||
if (!("resources" in schema) || Array.isArray(schema.resources)) { | ||
throw new Error('The schema must have a "resources" object with valid resources as values.'); | ||
throw new Error('Invalid schema. The schema must have a "resources" object with valid resources as values.'); | ||
} | ||
Object.entries(schema.resources).forEach(([resKey, resource]) => { | ||
if (!("attributes" in resource) || Array.isArray(resource.attributes)) { | ||
throw new Error(`Each schema resource must have an "attributes" object with valid resource attributes as values. Check the "${resKey}" resource.`); | ||
throw new Error(`Invalid schema. Each schema resource must have an "attributes" object with valid resource attributes as values. Check the "${resKey}" resource.`); | ||
} | ||
const idAttribute = resource.idAttribute ?? "id"; | ||
if (!(idAttribute in resource.attributes)) { | ||
throw new Error(`An id attribute is required. Please ensure "${idAttribute}" attribute is defined on resource type "${resKey}".`); | ||
throw new Error(`Invalid schema. An id attribute is required. Please ensure "${idAttribute}" attribute is defined on resource type "${resKey}".`); | ||
} | ||
Object.entries(resource.attributes).forEach(([attrKey, attribute]) => { | ||
if (!attribute.type) { | ||
throw new Error(`All attributes must have a type. Check the "${attrKey}" attribute on the "${resKey}" resource type.`); | ||
throw new Error(`Invalid schema. All attributes must have a type. Check the "${attrKey}" attribute on the "${resKey}" resource type.`); | ||
} | ||
if (!attributeTypes.includes(attribute.type)) { | ||
throw new Error(`"${attribute.type}" is not a valid type. Check the "${attrKey}" attribute on the "${resKey}" resource type. Valid types: ${attributeTypes.join(", ")}.`); | ||
throw new Error(`Invalid schema. "${attribute.type}" is not a valid type. Check the "${attrKey}" attribute on the "${resKey}" resource type. Valid types: ${attributeTypes.join(", ")}.`); | ||
} | ||
@@ -63,14 +63,14 @@ }); | ||
Array.isArray(resource.relationships)) { | ||
throw new Error(`Each schema resource must have an "relationships" object with valid resource relationships as values. Check the "${resKey}" resource.`); | ||
throw new Error(`Invalid schema. Each schema resource must have an "relationships" object with valid resource relationships as values. Check the "${resKey}" resource.`); | ||
} | ||
Object.entries(resource.relationships).forEach(([relKey, relationship]) => { | ||
if (!relationship.cardinality || !relationship.type) { | ||
throw new Error(`All relationships must have a cardinality or a type. Check the "${relKey}" relationship on the "${resKey}" resource type.`); | ||
throw new Error(`Invalid schema. All relationships must have a cardinality or a type. Check the "${relKey}" relationship on the "${resKey}" resource type.`); | ||
} | ||
if (relationship.cardinality !== "one" && | ||
relationship.cardinality !== "many") { | ||
throw new Error(`Relationship cardinalities must be either "one" or "many". Check the "${relKey}" relationship on the "${resKey}" resource type.`); | ||
throw new Error(`Invalid schema. Relationship cardinality must be either "one" or "many". Check the "${relKey}" relationship on the "${resKey}" resource type.`); | ||
} | ||
if (!Object.keys(schema.resources).includes(relationship.type)) { | ||
throw new Error(`"${relationship.type}" is not a valid relationship type. Relationship types must be a type of resource defined in the schema. Check the "${relKey}" relationship on the "${resKey}" resource type. Valid resource type: ${Object.keys(schema.resources).join(", ")}`); | ||
throw new Error(`Invalid schema. "${relationship.type}" is not a valid relationship type. Relationship types must be a type of resource defined in the schema. Check the "${relKey}" relationship on the "${resKey}" resource type. Valid resource type: ${Object.keys(schema.resources).join(", ")}`); | ||
} | ||
@@ -77,0 +77,0 @@ }); |
{ | ||
"name": "data-prism", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -58,3 +58,3 @@ type ColumnTypeModifier = { | ||
// geojson | ||
geojson: { | ||
"data-prism:geojson": { | ||
schemaProperties: { | ||
@@ -61,0 +61,0 @@ type: "object", |
@@ -115,3 +115,3 @@ type SchemaAttribute = { | ||
throw new Error( | ||
'The schema must have a "resources" object with valid resources as values.', | ||
'Invalid schema. The schema must have a "resources" object with valid resources as values.', | ||
); | ||
@@ -123,3 +123,3 @@ } | ||
throw new Error( | ||
`Each schema resource must have an "attributes" object with valid resource attributes as values. Check the "${resKey}" resource.`, | ||
`Invalid schema. Each schema resource must have an "attributes" object with valid resource attributes as values. Check the "${resKey}" resource.`, | ||
); | ||
@@ -131,3 +131,3 @@ } | ||
throw new Error( | ||
`An id attribute is required. Please ensure "${idAttribute}" attribute is defined on resource type "${resKey}".`, | ||
`Invalid schema. An id attribute is required. Please ensure "${idAttribute}" attribute is defined on resource type "${resKey}".`, | ||
); | ||
@@ -140,3 +140,3 @@ } | ||
throw new Error( | ||
`All attributes must have a type. Check the "${attrKey}" attribute on the "${resKey}" resource type.`, | ||
`Invalid schema. All attributes must have a type. Check the "${attrKey}" attribute on the "${resKey}" resource type.`, | ||
); | ||
@@ -147,3 +147,3 @@ } | ||
throw new Error( | ||
`"${attribute.type}" is not a valid type. Check the "${attrKey}" attribute on the "${resKey}" resource type. Valid types: ${attributeTypes.join(", ")}.`, | ||
`Invalid schema. "${attribute.type}" is not a valid type. Check the "${attrKey}" attribute on the "${resKey}" resource type. Valid types: ${attributeTypes.join(", ")}.`, | ||
); | ||
@@ -159,3 +159,3 @@ } | ||
throw new Error( | ||
`Each schema resource must have an "relationships" object with valid resource relationships as values. Check the "${resKey}" resource.`, | ||
`Invalid schema. Each schema resource must have an "relationships" object with valid resource relationships as values. Check the "${resKey}" resource.`, | ||
); | ||
@@ -168,3 +168,3 @@ } | ||
throw new Error( | ||
`All relationships must have a cardinality or a type. Check the "${relKey}" relationship on the "${resKey}" resource type.`, | ||
`Invalid schema. All relationships must have a cardinality or a type. Check the "${relKey}" relationship on the "${resKey}" resource type.`, | ||
); | ||
@@ -178,3 +178,3 @@ } | ||
throw new Error( | ||
`Relationship cardinalities must be either "one" or "many". Check the "${relKey}" relationship on the "${resKey}" resource type.`, | ||
`Invalid schema. Relationship cardinality must be either "one" or "many". Check the "${relKey}" relationship on the "${resKey}" resource type.`, | ||
); | ||
@@ -185,3 +185,3 @@ } | ||
throw new Error( | ||
`"${relationship.type}" is not a valid relationship type. Relationship types must be a type of resource defined in the schema. Check the "${relKey}" relationship on the "${resKey}" resource type. Valid resource type: ${Object.keys(schema.resources).join(", ")}`, | ||
`Invalid schema. "${relationship.type}" is not a valid relationship type. Relationship types must be a type of resource defined in the schema. Check the "${relKey}" relationship on the "${resKey}" resource type. Valid resource type: ${Object.keys(schema.resources).join(", ")}`, | ||
); | ||
@@ -188,0 +188,0 @@ } |
Sorry, the diff of this file is not supported yet
480466
10621