@contember/schema-utils
Advanced tools
Comparing version 1.3.0-alpha.2 to 1.3.0-alpha.4
@@ -33,2 +33,3 @@ "use strict"; | ||
const type_schema_1 = require("./type-schema"); | ||
const actions_1 = require("./type-schema/actions"); | ||
__exportStar(require("./definition-generator"), exports); | ||
@@ -48,2 +49,3 @@ __exportStar(require("./lax"), exports); | ||
validation: {}, | ||
actions: { triggers: {}, targets: {} }, | ||
settings: {}, | ||
@@ -55,4 +57,5 @@ }; | ||
validation: type_schema_1.validationSchema, | ||
actions: Typesafe.coalesce(actions_1.actionsSchema, { triggers: {}, targets: {} }), | ||
settings: Typesafe.coalesce(type_schema_1.settingsSchema, {}), | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
const model_1 = require("../model"); | ||
const index_1 = require("../index"); | ||
const simpleColumnTypes = { | ||
@@ -50,5 +51,3 @@ boolean: { type: schema_1.Model.ColumnType.Bool, columnType: 'boolean' }, | ||
return { | ||
acl: { roles: {} }, | ||
settings: {}, | ||
validation: {}, | ||
...index_1.emptySchema, | ||
model: { | ||
@@ -55,0 +54,0 @@ enums: this.enums, |
@@ -1,2 +0,2 @@ | ||
export declare type ValidationErrorCode = 'MODEL_NAME_MISMATCH' | 'MODEL_UNDEFINED_FIELD' | 'MODEL_UNDEFINED_ENTITY' | 'MODEL_RELATION_REQUIRED' | 'MODEL_INVALID_RELATION_DEFINITION' | 'MODEL_INVALID_COLUMN_DEFINITION' | 'MODEL_INVALID_VIEW_USAGE' | 'MODEL_INVALID_IDENTIFIER' | 'MODEL_NAME_COLLISION' | 'ACL_INVALID_CONDITION' | 'ACL_UNDEFINED_VARIABLE' | 'ACL_UNDEFINED_FIELD' | 'ACL_UNDEFINED_PREDICATE' | 'ACL_UNDEFINED_ROLE' | 'ACL_UNDEFINED_ENTITY' | 'VALIDATION_UNDEFINED_ENTITY' | 'VALIDATION_UNDEFINED_FIELD' | 'VALIDATION_NOT_IMPLEMENTED'; | ||
export declare type ValidationErrorCode = 'MODEL_NAME_MISMATCH' | 'MODEL_UNDEFINED_FIELD' | 'MODEL_UNDEFINED_ENTITY' | 'MODEL_RELATION_REQUIRED' | 'MODEL_INVALID_RELATION_DEFINITION' | 'MODEL_INVALID_COLUMN_DEFINITION' | 'MODEL_INVALID_VIEW_USAGE' | 'MODEL_INVALID_IDENTIFIER' | 'MODEL_NAME_COLLISION' | 'ACL_INVALID_CONDITION' | 'ACL_UNDEFINED_VARIABLE' | 'ACL_UNDEFINED_FIELD' | 'ACL_UNDEFINED_PREDICATE' | 'ACL_UNDEFINED_ROLE' | 'ACL_UNDEFINED_ENTITY' | 'ACTIONS_NAME_MISMATCH' | 'ACTIONS_INVALID_CONDITION' | 'ACTIONS_UNDEFINED_FIELD' | 'ACTIONS_UNDEFINED_ENTITY' | 'ACTIONS_UNDEFINED_TRIGGER_TARGET' | 'ACTIONS_INVALID_SELECTION' | 'VALIDATION_UNDEFINED_ENTITY' | 'VALIDATION_UNDEFINED_FIELD' | 'VALIDATION_NOT_IMPLEMENTED'; | ||
export interface ValidationError { | ||
@@ -3,0 +3,0 @@ path: (string | number)[]; |
@@ -88,3 +88,3 @@ "use strict"; | ||
if (!orderByField) { | ||
errors.add('ACL_UNDEFINED_FIELD', `Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not defined`); | ||
errors.add('MODEL_UNDEFINED_FIELD', `Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not defined`); | ||
return; | ||
@@ -91,0 +91,0 @@ } |
@@ -7,2 +7,3 @@ "use strict"; | ||
const ValidationValidator_1 = require("./ValidationValidator"); | ||
const ActionsValidator_1 = require("./ActionsValidator"); | ||
class SchemaValidator { | ||
@@ -16,3 +17,5 @@ static validate(schema, skippedErrors = []) { | ||
const validationErrors = validationValidator.validate(schema.validation); | ||
const allErrors = [...aclErrors, ...modelErrors, ...validationErrors]; | ||
const actionsValidator = new ActionsValidator_1.ActionsValidator(schema.model); | ||
const actionsErrors = actionsValidator.validate(schema.actions); | ||
const allErrors = [...aclErrors, ...modelErrors, ...validationErrors, ...actionsErrors]; | ||
if (skippedErrors.length === 0) { | ||
@@ -19,0 +22,0 @@ return allErrors; |
{ | ||
"name": "@contember/schema-utils", | ||
"version": "1.3.0-alpha.2", | ||
"version": "1.3.0-alpha.4", | ||
"license": "Apache-2.0", | ||
@@ -11,8 +11,9 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"@contember/schema": "^1.3.0-alpha.2", | ||
"@contember/typesafe": "^1.3.0-alpha.2" | ||
"@contember/schema": "^1.3.0-alpha.4", | ||
"@contember/typesafe": "^1.3.0-alpha.4" | ||
}, | ||
"devDependencies": { | ||
"@contember/schema-definition": "^1.3.0-alpha.4", | ||
"@types/node": "^18" | ||
} | ||
} |
@@ -5,2 +5,3 @@ import { Schema } from '@contember/schema' | ||
import { aclSchema, modelSchema, validationSchema, settingsSchema } from './type-schema' | ||
import { actionsSchema } from './type-schema/actions' | ||
@@ -21,2 +22,3 @@ export * from './definition-generator' | ||
validation: {}, | ||
actions: { triggers: {}, targets: {} }, | ||
settings: {}, | ||
@@ -29,3 +31,4 @@ } | ||
validation: validationSchema, | ||
actions: Typesafe.coalesce(actionsSchema, { triggers: {}, targets: {} }), | ||
settings: Typesafe.coalesce(settingsSchema, {}), | ||
}) |
import { Model, Schema, Writable } from '@contember/schema' | ||
import { LaxSchema, LaxSchemaColumn, LaxSchemaEnum, LaxSchemaField, LaxSchemaRelation } from './schema' | ||
import { DefaultNamingConventions, NamingConventions, resolveDefaultColumnType } from '../model' | ||
import { emptySchema } from '../index' | ||
@@ -56,5 +57,3 @@ const simpleColumnTypes: { [K in LaxSchemaColumn['type']]: { type: Model.ColumnType; columnType: string } } = { | ||
return { | ||
acl: { roles: {} }, | ||
settings: {}, | ||
validation: {}, | ||
...emptySchema, | ||
model: { | ||
@@ -61,0 +60,0 @@ enums: this.enums, |
@@ -19,2 +19,9 @@ export type ValidationErrorCode = | ||
| 'ACTIONS_NAME_MISMATCH' | ||
| 'ACTIONS_INVALID_CONDITION' | ||
| 'ACTIONS_UNDEFINED_FIELD' | ||
| 'ACTIONS_UNDEFINED_ENTITY' | ||
| 'ACTIONS_UNDEFINED_TRIGGER_TARGET' | ||
| 'ACTIONS_INVALID_SELECTION' | ||
| 'VALIDATION_UNDEFINED_ENTITY' | ||
@@ -21,0 +28,0 @@ | 'VALIDATION_UNDEFINED_FIELD' |
@@ -97,3 +97,3 @@ import { Model } from '@contember/schema' | ||
if (!orderByField) { | ||
errors.add('ACL_UNDEFINED_FIELD', `Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not defined`) | ||
errors.add('MODEL_UNDEFINED_FIELD', `Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not defined`) | ||
return | ||
@@ -100,0 +100,0 @@ } |
@@ -6,2 +6,3 @@ import { Schema } from '@contember/schema' | ||
import { ValidationValidator } from './ValidationValidator' | ||
import { ActionsValidator } from './ActionsValidator' | ||
@@ -24,3 +25,7 @@ export interface SchemaValidatorSkippedErrors { | ||
const validationErrors = validationValidator.validate(schema.validation) | ||
const allErrors = [...aclErrors, ...modelErrors, ...validationErrors] | ||
const actionsValidator = new ActionsValidator(schema.model) | ||
const actionsErrors = actionsValidator.validate(schema.actions) | ||
const allErrors = [...aclErrors, ...modelErrors, ...validationErrors, ...actionsErrors] | ||
if (skippedErrors.length === 0) { | ||
@@ -27,0 +32,0 @@ return allErrors |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
534088
250
7688
2