@contember/schema-utils
Advanced tools
Comparing version 0.12.0-beta.2 to 1.0.0-alpha.0
@@ -38,3 +38,3 @@ "use strict"; | ||
} | ||
const fieldWhere = model_1.acceptFieldVisitor(this.schema, entity, key, { | ||
const fieldWhere = (0, model_1.acceptFieldVisitor)(this.schema, entity, key, { | ||
visitColumn: (entity, column) => { | ||
@@ -41,0 +41,0 @@ return handler.handleColumn({ entity, column, value: value, path }); |
@@ -47,5 +47,5 @@ "use strict"; | ||
if (entity.primary === column.name) { | ||
return exports.resolvePrimaryGenerator(column, providers)(); | ||
return (0, exports.resolvePrimaryGenerator)(column, providers)(); | ||
} | ||
return exports.resolveDefaultValue(column, providers); | ||
return (0, exports.resolveDefaultValue)(column, providers); | ||
}; | ||
@@ -52,0 +52,0 @@ exports.resolveColumnValue = resolveColumnValue; |
@@ -31,6 +31,6 @@ "use strict"; | ||
const getColumnName = (schema, entity, fieldName) => { | ||
return exports.acceptFieldVisitor(schema, entity, fieldName, { | ||
return (0, exports.acceptFieldVisitor)(schema, entity, fieldName, { | ||
visitColumn: (entity, column) => column.columnName, | ||
visitRelation: (entity, relation) => { | ||
if (utils_1.isIt(relation, 'joiningColumn')) { | ||
if ((0, utils_1.isIt)(relation, 'joiningColumn')) { | ||
return relation.joiningColumn.columnName; | ||
@@ -45,3 +45,3 @@ } | ||
try { | ||
return exports.getColumnName(schema, entity, fieldName); | ||
return (0, exports.getColumnName)(schema, entity, fieldName); | ||
} | ||
@@ -57,8 +57,8 @@ catch (e) { | ||
const getColumnType = (schema, entity, fieldName) => { | ||
return exports.acceptFieldVisitor(schema, entity, fieldName, { | ||
return (0, exports.acceptFieldVisitor)(schema, entity, fieldName, { | ||
// TODO solve enum handling properly maybe we should distinguish between domain and column type | ||
visitColumn: (entity, column) => (column.type === schema_1.Model.ColumnType.Enum ? 'text' : column.columnType), | ||
visitRelation: (entity, relation, targetEntity) => { | ||
if (utils_1.isIt(relation, 'joiningColumn')) { | ||
return exports.getColumnType(schema, targetEntity, targetEntity.primary); | ||
if ((0, utils_1.isIt)(relation, 'joiningColumn')) { | ||
return (0, exports.getColumnType)(schema, targetEntity, targetEntity.primary); | ||
} | ||
@@ -71,3 +71,3 @@ throw new ModelError(ModelErrorCode.NOT_OWNING_SIDE, `Field ${relation.name} of entity ${entity.name} is not an owning side`); | ||
const getTargetEntity = (schema, entity, relationName) => { | ||
return exports.acceptFieldVisitor(schema, entity, relationName, { | ||
return (0, exports.acceptFieldVisitor)(schema, entity, relationName, { | ||
visitColumn: () => null, | ||
@@ -79,3 +79,3 @@ visitRelation: (entity, relation, targetEntity) => targetEntity, | ||
const acceptEveryFieldVisitor = (schema, entity, visitor) => { | ||
const entityObj = typeof entity === 'string' ? exports.getEntity(schema, entity) : entity; | ||
const entityObj = typeof entity === 'string' ? (0, exports.getEntity)(schema, entity) : entity; | ||
if (!entityObj) { | ||
@@ -86,3 +86,3 @@ throw createEntityNotFoundError(typeof entity === 'string' ? entity : 'unknown'); | ||
for (const field in entityObj.fields) { | ||
result[field] = exports.acceptFieldVisitor(schema, entityObj, field, visitor); | ||
result[field] = (0, exports.acceptFieldVisitor)(schema, entityObj, field, visitor); | ||
} | ||
@@ -93,3 +93,3 @@ return result; | ||
const acceptFieldVisitor = (schema, entity, field, visitor) => { | ||
const entityObj = typeof entity === 'string' ? exports.getEntity(schema, entity) : entity; | ||
const entityObj = typeof entity === 'string' ? (0, exports.getEntity)(schema, entity) : entity; | ||
if (!entityObj) { | ||
@@ -102,15 +102,15 @@ throw createEntityNotFoundError(typeof entity === 'string' ? entity : 'unknown'); | ||
} | ||
if (utils_1.isIt(fieldObj, 'columnType')) { | ||
if ((0, utils_1.isIt)(fieldObj, 'columnType')) { | ||
return visitor.visitColumn(entityObj, fieldObj); | ||
} | ||
if (!utils_1.isIt(fieldObj, 'target')) { | ||
if (!(0, utils_1.isIt)(fieldObj, 'target')) { | ||
throw new Error(`Invalid field type`); | ||
} | ||
const targetEntity = exports.getEntity(schema, fieldObj.target); | ||
if (utils_1.isIt(visitor, 'visitRelation')) { | ||
const targetEntity = (0, exports.getEntity)(schema, fieldObj.target); | ||
if ((0, utils_1.isIt)(visitor, 'visitRelation')) { | ||
let targetRelation = null; | ||
if (exports.isOwningRelation(fieldObj)) { | ||
if ((0, exports.isOwningRelation)(fieldObj)) { | ||
targetRelation = fieldObj.inversedBy ? targetEntity.fields[fieldObj.inversedBy] || null : null; | ||
} | ||
else if (exports.isInverseRelation(fieldObj)) { | ||
else if ((0, exports.isInverseRelation)(fieldObj)) { | ||
targetRelation = targetEntity.fields[fieldObj.ownedBy]; | ||
@@ -121,3 +121,3 @@ } | ||
} | ||
if (targetRelation && !utils_1.isIt(targetRelation, 'target')) { | ||
if (targetRelation && !(0, utils_1.isIt)(targetRelation, 'target')) { | ||
throw new Error('Invalid target'); | ||
@@ -127,4 +127,4 @@ } | ||
} | ||
if (utils_1.isIt(visitor, 'visitHasMany')) { | ||
return exports.acceptRelationTypeVisitor(schema, entityObj, fieldObj, { | ||
if ((0, utils_1.isIt)(visitor, 'visitHasMany')) { | ||
return (0, exports.acceptRelationTypeVisitor)(schema, entityObj, fieldObj, { | ||
visitManyHasManyInverse: visitor.visitHasMany.bind(visitor), | ||
@@ -138,4 +138,4 @@ visitManyHasManyOwning: visitor.visitHasMany.bind(visitor), | ||
} | ||
if (utils_1.isIt(visitor, 'visitManyHasManyInverse')) { | ||
return exports.acceptRelationTypeVisitor(schema, entityObj, fieldObj, visitor); | ||
if ((0, utils_1.isIt)(visitor, 'visitManyHasManyInverse')) { | ||
return (0, exports.acceptRelationTypeVisitor)(schema, entityObj, fieldObj, visitor); | ||
} | ||
@@ -146,3 +146,3 @@ throw new Error('Invalid field type'); | ||
const acceptRelationTypeVisitor = (schema, entity, relation, visitor) => { | ||
const entityObj = typeof entity === 'string' ? exports.getEntity(schema, entity) : entity; | ||
const entityObj = typeof entity === 'string' ? (0, exports.getEntity)(schema, entity) : entity; | ||
if (!entityObj) { | ||
@@ -155,9 +155,9 @@ throw createEntityNotFoundError(typeof entity === 'string' ? entity : 'unknown'); | ||
} | ||
if (!exports.isRelation(relationObj)) { | ||
if (!(0, exports.isRelation)(relationObj)) { | ||
throw new ModelError(ModelErrorCode.NOT_RELATION, `Field ${relationObj.name} of entity ${entityObj.name} is not a relation`); | ||
} | ||
const targetEntity = exports.getEntity(schema, relationObj.target); | ||
if (exports.isInverseRelation(relationObj)) { | ||
const targetEntity = (0, exports.getEntity)(schema, relationObj.target); | ||
if ((0, exports.isInverseRelation)(relationObj)) { | ||
const targetRelation = targetEntity.fields[relationObj.ownedBy]; | ||
if (!exports.isRelation(targetRelation)) { | ||
if (!(0, exports.isRelation)(targetRelation)) { | ||
throw new Error('Invalid target relation'); | ||
@@ -174,6 +174,6 @@ } | ||
default: | ||
return utils_1.assertNever(relationObj); | ||
return (0, utils_1.assertNever)(relationObj); | ||
} | ||
} | ||
else if (exports.isOwningRelation(relationObj)) { | ||
else if ((0, exports.isOwningRelation)(relationObj)) { | ||
const targetRelation = relationObj.inversedBy ? targetEntity.fields[relationObj.inversedBy] : null; | ||
@@ -189,3 +189,3 @@ switch (relationObj.type) { | ||
default: | ||
return utils_1.assertNever(relationObj); | ||
return (0, utils_1.assertNever)(relationObj); | ||
} | ||
@@ -197,3 +197,3 @@ } | ||
const isRelation = (field) => { | ||
return utils_1.isIt(field, 'target'); | ||
return (0, utils_1.isIt)(field, 'target'); | ||
}; | ||
@@ -206,8 +206,8 @@ exports.isRelation = isRelation; | ||
const isOwningRelation = (relation) => { | ||
return !exports.isInverseRelation(relation); | ||
return !(0, exports.isInverseRelation)(relation); | ||
}; | ||
exports.isOwningRelation = isOwningRelation; | ||
const isColumn = (field) => utils_1.isIt(field, 'columnType'); | ||
const isColumn = (field) => (0, utils_1.isIt)(field, 'columnType'); | ||
exports.isColumn = isColumn; | ||
exports.emptyModelSchema = { entities: {}, enums: {} }; | ||
//# sourceMappingURL=modelUtils.js.map |
@@ -16,3 +16,3 @@ "use strict"; | ||
let validSchema; | ||
if (!utils_1.isObject(schema)) { | ||
if (!(0, utils_1.isObject)(schema)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -31,3 +31,3 @@ validSchema = { roles: {} }; | ||
validateRoles(roles, errorBuilder) { | ||
if (!utils_1.isObject(roles)) { | ||
if (!(0, utils_1.isObject)(roles)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -53,3 +53,3 @@ return {}; | ||
validateRolePermissions(permissions, roles, errorBuilder) { | ||
if (!utils_1.isObject(permissions)) { | ||
if (!(0, utils_1.isObject)(permissions)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -74,3 +74,3 @@ return; | ||
} | ||
if (!Array.isArray(inherits) || !utils_1.everyIs(inherits, (it) => typeof it === 'string')) { | ||
if (!Array.isArray(inherits) || !(0, utils_1.everyIs)(inherits, (it) => typeof it === 'string')) { | ||
errorBuilder.add('Must be an array of strings'); | ||
@@ -95,3 +95,3 @@ return []; | ||
let validVariables = {}; | ||
if (!utils_1.isObject(variables)) { | ||
if (!(0, utils_1.isObject)(variables)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -112,7 +112,7 @@ return {}; | ||
validateVariable(variable, errorBuilder) { | ||
if (!utils_1.isObject(variable)) { | ||
if (!(0, utils_1.isObject)(variable)) { | ||
errorBuilder.add('Must be an object'); | ||
return; | ||
} | ||
if (!utils_1.hasStringProperty(variable, 'type')) { | ||
if (!(0, utils_1.hasStringProperty)(variable, 'type')) { | ||
errorBuilder.add('Variable type is not defined'); | ||
@@ -123,3 +123,3 @@ return; | ||
case schema_1.Acl.VariableType.entity: | ||
if (!utils_1.hasStringProperty(variable, 'entityName')) { | ||
if (!(0, utils_1.hasStringProperty)(variable, 'entityName')) { | ||
errorBuilder.add('Entity name must be specified for this type of variable'); | ||
@@ -132,3 +132,3 @@ return; | ||
} | ||
const extra = utils_1.checkExtraProperties(variable, ['entityName', 'type']); | ||
const extra = (0, utils_1.checkExtraProperties)(variable, ['entityName', 'type']); | ||
if (extra.length) { | ||
@@ -147,3 +147,3 @@ errorBuilder.add('Unsupported properties found: ' + extra.join(', ')); | ||
} | ||
if (!Array.isArray(stages) || !utils_1.everyIs(stages, (it) => typeof it === 'string')) { | ||
if (!Array.isArray(stages) || !(0, utils_1.everyIs)(stages, (it) => typeof it === 'string')) { | ||
errorBuilder.add('Stages must be either "*" or array of stage names'); | ||
@@ -156,3 +156,3 @@ return []; | ||
validatePermissions(permissions, variables, errorBuilder) { | ||
if (!utils_1.isObject(permissions)) { | ||
if (!(0, utils_1.isObject)(permissions)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -170,3 +170,3 @@ return {}; | ||
} | ||
const entity = model_1.getEntity(this.model, entityName); | ||
const entity = (0, model_1.getEntity)(this.model, entityName); | ||
const entityPermissions = this.validateEntityPermissions(permissions[entityName], entity, variables, errorBuilder.for(entityName)); | ||
@@ -180,7 +180,7 @@ if (entityPermissions) { | ||
validateEntityPermissions(entityPermissions, entity, variables, errorBuilder) { | ||
if (!utils_1.isObject(entityPermissions)) { | ||
if (!(0, utils_1.isObject)(entityPermissions)) { | ||
errorBuilder.add('Must be an object'); | ||
return; | ||
} | ||
const extra = utils_1.checkExtraProperties(entityPermissions, ['predicates', 'operations']); | ||
const extra = (0, utils_1.checkExtraProperties)(entityPermissions, ['predicates', 'operations']); | ||
if (extra.length) { | ||
@@ -194,3 +194,3 @@ errorBuilder.add('Unsupported properties found: ' + extra.join(', ')); | ||
validatePredicates(predicates, entity, variables, errorBuilder) { | ||
if (!utils_1.isObject(predicates)) { | ||
if (!(0, utils_1.isObject)(predicates)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -212,3 +212,3 @@ return {}; | ||
validatePredicateDefinition(predicate, entity, variables, errorBuilder) { | ||
if (!utils_1.isObject(predicate)) { | ||
if (!(0, utils_1.isObject)(predicate)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -246,7 +246,7 @@ return; | ||
validateOperations(operations, entity, predicates, errorBuilder) { | ||
if (!utils_1.isObject(operations)) { | ||
if (!(0, utils_1.isObject)(operations)) { | ||
errorBuilder.add('Must be an object'); | ||
return {}; | ||
} | ||
const extra = utils_1.checkExtraProperties(operations, ['read', 'create', 'update', 'delete', 'customPrimary']); | ||
const extra = (0, utils_1.checkExtraProperties)(operations, ['read', 'create', 'update', 'delete', 'customPrimary']); | ||
if (extra.length) { | ||
@@ -273,3 +273,3 @@ errorBuilder.add('Unsupported properties found: ' + extra.join(', ')); | ||
validateFieldPermissions(permissions, entity, predicates, errorBuilder) { | ||
if (!utils_1.isObject(permissions)) { | ||
if (!(0, utils_1.isObject)(permissions)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -276,0 +276,0 @@ return {}; |
@@ -18,3 +18,3 @@ "use strict"; | ||
let validModel; | ||
if (!utils_1.isObject(model)) { | ||
if (!(0, utils_1.isObject)(model)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -36,3 +36,3 @@ validModel = { entities: {}, enums: {} }; | ||
} | ||
if (!utils_1.isObject(enums)) { | ||
if (!(0, utils_1.isObject)(enums)) { | ||
errors.add('Enums must be an object'); | ||
@@ -43,3 +43,3 @@ return {}; | ||
enums: for (const [enumName, enumValues] of Object.entries(enums)) { | ||
if (!Array.isArray(enumValues) || !utils_1.everyIs(enumValues, (it) => typeof it === 'string')) { | ||
if (!Array.isArray(enumValues) || !(0, utils_1.everyIs)(enumValues, (it) => typeof it === 'string')) { | ||
errors.for(enumName).add('Enum values must be an array of strings'); | ||
@@ -66,3 +66,3 @@ continue; | ||
} | ||
if (!utils_1.isObject(entities)) { | ||
if (!(0, utils_1.isObject)(entities)) { | ||
errors.add('Entities must be an object'); | ||
@@ -87,3 +87,3 @@ return {}; | ||
validateEntity(entity, errors) { | ||
if (!utils_1.isObject(entity)) { | ||
if (!(0, utils_1.isObject)(entity)) { | ||
errors.add('Entity must be an object'); | ||
@@ -112,3 +112,3 @@ return undefined; | ||
const fields = entity.fields; | ||
if (!utils_1.isObject(fields)) { | ||
if (!(0, utils_1.isObject)(fields)) { | ||
errors.add('Fields must be an object'); | ||
@@ -127,3 +127,3 @@ return undefined; | ||
const viewTmp = entity.view; | ||
if (!utils_1.isObject(viewTmp)) { | ||
if (!(0, utils_1.isObject)(viewTmp)) { | ||
errors.for('view').add('View must be an object'); | ||
@@ -152,3 +152,3 @@ return undefined; | ||
const uniqueConstraints = entity.unique; | ||
if (!utils_1.isObject(uniqueConstraints)) { | ||
if (!(0, utils_1.isObject)(uniqueConstraints)) { | ||
errors.add('Unique constraints must be an object'); | ||
@@ -165,3 +165,3 @@ return undefined; | ||
validateUniqueConstraints(uniqueConstraints, fields, errors) { | ||
if (!utils_1.isObject(uniqueConstraints)) { | ||
if (!(0, utils_1.isObject)(uniqueConstraints)) { | ||
errors.add('Unique constraints must be an object'); | ||
@@ -173,3 +173,3 @@ return {}; | ||
const uniqueErrors = errors.for(constraintName); | ||
if (!utils_1.isObject(constraint)) { | ||
if (!(0, utils_1.isObject)(constraint)) { | ||
uniqueErrors.add('Unique constraint must be an object'); | ||
@@ -187,3 +187,3 @@ continue; | ||
if (!Array.isArray(constraint.fields) || | ||
!utils_1.everyIs(constraint.fields, (it) => typeof it === 'string')) { | ||
!(0, utils_1.everyIs)(constraint.fields, (it) => typeof it === 'string')) { | ||
uniqueErrors.add('Every field must be a string'); | ||
@@ -203,3 +203,3 @@ continue; | ||
validateField(partialEntity, field, errors) { | ||
if (!utils_1.isObject(field)) { | ||
if (!(0, utils_1.isObject)(field)) { | ||
errors.add('Field must be an object'); | ||
@@ -244,3 +244,3 @@ return undefined; | ||
if (i + 1 < it.path.length) { | ||
const targetEntity = model_1.getTargetEntity(this.model, entity, orderByField.name); | ||
const targetEntity = (0, model_1.getTargetEntity)(this.model, entity, orderByField.name); | ||
if (!targetEntity) { | ||
@@ -263,3 +263,3 @@ errors.add(`Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not a relation`); | ||
} | ||
if (model_1.isInverseRelation(field)) { | ||
if ((0, model_1.isInverseRelation)(field)) { | ||
// todo | ||
@@ -285,3 +285,3 @@ const ownedBy = field.ownedBy; | ||
} | ||
if (!model_1.isOwningRelation(targetField)) { | ||
if (!(0, model_1.isOwningRelation)(targetField)) { | ||
errors.add(`${relationDescription} not an owning relation`); | ||
@@ -333,3 +333,3 @@ return undefined; | ||
} | ||
if (!model_1.isInverseRelation(targetField)) { | ||
if (!(0, model_1.isInverseRelation)(targetField)) { | ||
errors.add(`${relationDescription} not an inverse relation`); | ||
@@ -389,3 +389,3 @@ return undefined; | ||
const entityErrorBuilder = errorBuilder.for(entity.name); | ||
model_1.acceptEveryFieldVisitor(this.model, entity, { | ||
(0, model_1.acceptEveryFieldVisitor)(this.model, entity, { | ||
visitManyHasManyOwning: (entity, relation) => { | ||
@@ -392,0 +392,0 @@ const joiningTable = relation.joiningTable; |
@@ -19,4 +19,4 @@ "use strict"; | ||
const errors = [...aclErrors, ...modelErrors, ...validationErrors]; | ||
if (errors.length === 0 && !util_1.isDeepStrictEqual(validSchema, schema)) { | ||
const errors = utils_1.deepCompare(validSchema, schema, []); | ||
if (errors.length === 0 && !(0, util_1.isDeepStrictEqual)(validSchema, schema)) { | ||
const errors = (0, utils_1.deepCompare)(validSchema, schema, []); | ||
let message = 'There is something wrong with a schema validator:'; | ||
@@ -23,0 +23,0 @@ for (const err of errors) { |
@@ -15,3 +15,3 @@ "use strict"; | ||
let validSchema; | ||
if (!utils_1.isObject(schema)) { | ||
if (!(0, utils_1.isObject)(schema)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -36,3 +36,3 @@ validSchema = { roles: {} }; | ||
validateEntityRules(errorBuilder, entitySchema, entity) { | ||
if (!utils_1.isObject(entitySchema)) { | ||
if (!(0, utils_1.isObject)(entitySchema)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -55,3 +55,3 @@ return {}; | ||
validateFieldRules(errorBuilder, fieldSchema, entity, field) { | ||
if (!utils_1.isArray(fieldSchema)) { | ||
if (!(0, utils_1.isArray)(fieldSchema)) { | ||
errorBuilder.add('Must be an array'); | ||
@@ -70,7 +70,7 @@ return []; | ||
validateFieldRule(errorBuilder, rule, entity, field) { | ||
if (!utils_1.isObject(rule)) { | ||
if (!(0, utils_1.isObject)(rule)) { | ||
errorBuilder.add('Must be an object'); | ||
return undefined; | ||
} | ||
const errorMessage = model_1.acceptFieldVisitor(this.model, entity, field, { | ||
const errorMessage = (0, model_1.acceptFieldVisitor)(this.model, entity, field, { | ||
visitColumn: () => null, | ||
@@ -97,7 +97,7 @@ visitHasOne: () => null, | ||
validateFieldRuleMessage(errorBuilder, message) { | ||
if (!utils_1.isObject(message)) { | ||
if (!(0, utils_1.isObject)(message)) { | ||
errorBuilder.add('Must be an object'); | ||
return undefined; | ||
} | ||
if (!utils_1.hasStringProperty(message, 'text')) { | ||
if (!(0, utils_1.hasStringProperty)(message, 'text')) { | ||
errorBuilder.for('text').add('Must be a string'); | ||
@@ -108,3 +108,3 @@ return undefined; | ||
if (message.parameters) { | ||
if (!utils_1.hasArrayProperty(message, 'parameters')) { | ||
if (!(0, utils_1.hasArrayProperty)(message, 'parameters')) { | ||
errorBuilder.for('parameters').add('Must be an array'); | ||
@@ -118,3 +118,3 @@ return undefined; | ||
validateValidator(errorBuilder, validator, entity, field) { | ||
if (!utils_1.isObject(validator)) { | ||
if (!(0, utils_1.isObject)(validator)) { | ||
errorBuilder.add('Must be an object'); | ||
@@ -147,3 +147,3 @@ return undefined; | ||
} | ||
if (!utils_1.isArray(patternLiteral.value) || | ||
if (!(0, utils_1.isArray)(patternLiteral.value) || | ||
patternLiteral.value.length !== 2 || | ||
@@ -232,7 +232,7 @@ typeof patternLiteral.value[0] !== 'string' || | ||
validateValidatorArgument(errorBuilder, argument, entity, field) { | ||
if (!utils_1.isObject(argument)) { | ||
if (!(0, utils_1.isObject)(argument)) { | ||
errorBuilder.add('Must be an object'); | ||
return undefined; | ||
} | ||
if (!utils_1.hasStringProperty(argument, 'type') || argument.type !== schema_1.Validation.ArgumentType.validator) { | ||
if (!(0, utils_1.hasStringProperty)(argument, 'type') || argument.type !== schema_1.Validation.ArgumentType.validator) { | ||
errorBuilder.for('type').add(`Invalid value ${argument.type}`); | ||
@@ -248,7 +248,7 @@ return undefined; | ||
validateLiteralArgument(errorBuilder, argument) { | ||
if (!utils_1.isObject(argument)) { | ||
if (!(0, utils_1.isObject)(argument)) { | ||
errorBuilder.add('Must be an object'); | ||
return undefined; | ||
} | ||
if (!utils_1.hasStringProperty(argument, 'type') || argument.type !== schema_1.Validation.ArgumentType.literal) { | ||
if (!(0, utils_1.hasStringProperty)(argument, 'type') || argument.type !== schema_1.Validation.ArgumentType.literal) { | ||
errorBuilder.for('type').add(`Invalid value ${argument.type}`); | ||
@@ -264,19 +264,19 @@ return undefined; | ||
validatePathArgument(errorBuilder, argument, entity) { | ||
if (!utils_1.isObject(argument)) { | ||
if (!(0, utils_1.isObject)(argument)) { | ||
errorBuilder.add('Must be an object'); | ||
return undefined; | ||
} | ||
if (!utils_1.hasStringProperty(argument, 'type') || argument.type !== schema_1.Validation.ArgumentType.path) { | ||
if (!(0, utils_1.hasStringProperty)(argument, 'type') || argument.type !== schema_1.Validation.ArgumentType.path) { | ||
errorBuilder.for('type').add(`Invalid value ${argument.type}`); | ||
return undefined; | ||
} | ||
if (!utils_1.hasArrayProperty(argument, 'path')) { | ||
if (!(0, utils_1.hasArrayProperty)(argument, 'path')) { | ||
errorBuilder.add('Undefined path'); | ||
return undefined; | ||
} | ||
if (!utils_1.everyIs(argument.path, (it) => typeof it === 'string')) { | ||
if (!(0, utils_1.everyIs)(argument.path, (it) => typeof it === 'string')) { | ||
errorBuilder.add('Invalid path'); | ||
return undefined; | ||
} | ||
const isRelation = model_1.acceptFieldVisitor(this.model, entity, argument.path[0], { | ||
const isRelation = (0, model_1.acceptFieldVisitor)(this.model, entity, argument.path[0], { | ||
visitColumn: () => false, | ||
@@ -283,0 +283,0 @@ visitRelation: () => true, |
{ | ||
"name": "@contember/schema-utils", | ||
"version": "0.12.0-beta.2", | ||
"version": "1.0.0-alpha.0", | ||
"license": "Apache-2.0", | ||
@@ -11,7 +11,7 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"@contember/schema": "^0.12.0-beta.2" | ||
"@contember/schema": "^1.0.0-alpha.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^15.12.5" | ||
"@types/node": "^17.0.5" | ||
} | ||
} |
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
248809
+ Added@contember/schema@1.4.6(transitive)
- Removed@contember/schema@0.12.0-beta.2(transitive)