@palmares/databases
Version:
Add support for working with databases with palmares framework
125 lines (123 loc) • 5.5 kB
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// src/models/exceptions.ts
var ModelNoUniqueFieldsError = class _ModelNoUniqueFieldsError extends Error {
static {
__name(this, "ModelNoUniqueFieldsError");
}
constructor(modelName) {
super(`Model ${modelName} has no unique fields, it should have at least one unique field. If it's an abstract model, you need to set "abstract" to true in the model options.`);
this.name = _ModelNoUniqueFieldsError.name;
}
};
var ModelNoPrimaryKeyFieldError = class _ModelNoPrimaryKeyFieldError extends Error {
static {
__name(this, "ModelNoPrimaryKeyFieldError");
}
constructor(modelName) {
super(`Model ${modelName} has no primary key field, it should have at least one primary key. If it's an abstract model, you need to set "abstract" to true in the model options.`);
this.name = _ModelNoPrimaryKeyFieldError.name;
}
};
var ModelCircularAbstractError = class extends Error {
static {
__name(this, "ModelCircularAbstractError");
}
constructor(originalModelName, abstractModelName) {
super(`Model ${originalModelName} have a circular abstract dependency with ${abstractModelName}`);
}
};
var ModelInvalidAbstractFieldError = class extends Error {
static {
__name(this, "ModelInvalidAbstractFieldError");
}
constructor(modelName, abstractModelName, fieldName) {
super(`The abstract model '${abstractModelName}' already have a field named '${fieldName}', please rename the field ${fieldName} in the '${modelName}' model or remove the abstract`);
}
};
var ModelInvalidAbstractManagerError = class _ModelInvalidAbstractManagerError extends Error {
static {
__name(this, "ModelInvalidAbstractManagerError");
}
constructor(modelName, abstractModelName, managerName) {
super(`The abstract model ${abstractModelName} already have a manager named ${managerName}, please rename the manager '${managerName}' in the ${modelName} model`);
this.name = _ModelInvalidAbstractManagerError.name;
}
};
var ManagerEngineInstanceNotFoundError = class _ManagerEngineInstanceNotFoundError extends Error {
static {
__name(this, "ManagerEngineInstanceNotFoundError");
}
constructor(engineName) {
super(`The engine ${engineName} is not found in the manager. Make sure that this model is available for that engine.`);
this.name = _ManagerEngineInstanceNotFoundError.name;
}
};
var ShouldAssignAllInstancesException = class _ShouldAssignAllInstancesException extends Error {
static {
__name(this, "ShouldAssignAllInstancesException");
}
constructor() {
super("You have translated the model before. And you have assigned `instance` to the model options. You should assign `instance` to all model options.");
this.name = _ShouldAssignAllInstancesException.name;
}
};
var EngineDoesNotSupportFieldTypeException = class _EngineDoesNotSupportFieldTypeException extends Error {
static {
__name(this, "EngineDoesNotSupportFieldTypeException");
}
constructor(engineName, fieldType) {
super(`The engine '${engineName}' does not support the field of type: '${fieldType}'. If you are using a custom field, make sure that you are using the 'TranslatableField' class.`);
this.name = _EngineDoesNotSupportFieldTypeException.name;
}
};
var RelatedModelFromForeignKeyIsNotFromEngineException = class _RelatedModelFromForeignKeyIsNotFromEngineException extends Error {
static {
__name(this, "RelatedModelFromForeignKeyIsNotFromEngineException");
}
constructor(engineName, modelName, foreignKeyFieldName, foreignKeyFieldModelName, fieldName) {
super(`The related model '${modelName}' from the foreign key field '${foreignKeyFieldName}' of the model '${foreignKeyFieldModelName}' is not from the engine '${engineName}' that is being used. This is not a problem, but you need to make sure that the field '${fieldName}' it is relating to exists on the model '${modelName}' it is related to.`);
this.name = _RelatedModelFromForeignKeyIsNotFromEngineException.name;
}
};
var MissingWhereClauseException = class _MissingWhereClauseException extends Error {
static {
__name(this, "MissingWhereClauseException");
}
constructor(fun) {
super(`You must provide a '.where()' clause query to update a model or use 'force' as true on the '.${fun}()' action.`);
this.name = _MissingWhereClauseException.name;
}
};
var ModelMissingException = class _ModelMissingException extends Error {
static {
__name(this, "ModelMissingException");
}
constructor(modelName) {
super(`The model ${modelName} was not found in the engine.`);
this.name = _ModelMissingException.name;
}
};
var FieldFromModelMissingException = class _FieldFromModelMissingException extends Error {
static {
__name(this, "FieldFromModelMissingException");
}
constructor(modelName, fieldName) {
super(`The field ${fieldName} was not found in the model ${modelName}.`);
this.name = _FieldFromModelMissingException.name;
}
};
export {
EngineDoesNotSupportFieldTypeException,
FieldFromModelMissingException,
ManagerEngineInstanceNotFoundError,
MissingWhereClauseException,
ModelCircularAbstractError,
ModelInvalidAbstractFieldError,
ModelInvalidAbstractManagerError,
ModelMissingException,
ModelNoPrimaryKeyFieldError,
ModelNoUniqueFieldsError,
RelatedModelFromForeignKeyIsNotFromEngineException,
ShouldAssignAllInstancesException
};