// @generated — do not edit
import { createDomainError } from "@tailor-platform/erp-kit/core";

export const InsufficientPermissionError = createDomainError(
  "InsufficientPermissionError", "AUDIT_INSUFFICIENT_PERMISSION",
  (identifier: string) => `Caller lacks the required permission for this operation: ${identifier}`,
);

export const UnauthorizedError = createDomainError(
  "UnauthorizedError", "AUDIT_UNAUTHORIZED",
  (identifier: string) => `Caller's permission scope does not cover the target resource: ${identifier}`,
);

export const PolicyNotFoundError = createDomainError(
  "PolicyNotFoundError", "AUDIT_POLICY_NOT_FOUND",
  (identifier: string) => `Specified policy ID does not exist: ${identifier}`,
);

export const InvalidStateError = createDomainError(
  "InvalidStateError", "AUDIT_INVALID_STATE",
  (identifier: string) => `Target entity is not in a valid status for this operation: ${identifier}`,
);

export const IncompletePolicyError = createDomainError(
  "IncompletePolicyError", "AUDIT_INCOMPLETE_POLICY",
  (identifier: string) => `Policy is missing entity name or operation type: ${identifier}`,
);

export const EntityTypeNotRegisteredError = createDomainError(
  "EntityTypeNotRegisteredError", "AUDIT_ENTITY_TYPE_NOT_REGISTERED",
  (identifier: string) => `Provided entityName/entityType does not match any currently registered auditable entity: ${identifier}`,
);

export const ConflictingActivePolicyError = createDomainError(
  "ConflictingActivePolicyError", "AUDIT_CONFLICTING_ACTIVE_POLICY",
  (identifier: string) => `An ACTIVE policy already exists for the same (entityName, companyId, operationType): ${identifier}`,
);

export const ScopeMismatchError = createDomainError(
  "ScopeMismatchError", "AUDIT_SCOPE_MISMATCH",
  (identifier: string) => `companyId provided for a global entity, or companyId missing for a company-bound entity: ${identifier}`,
);

export const InvalidFieldNameError = createDomainError(
  "InvalidFieldNameError", "AUDIT_INVALID_FIELD_NAME",
  (identifier: string) => `A field name in field-level rules is empty or not in the entity's auditableFields: ${identifier}`,
);

export const DuplicateFieldNameError = createDomainError(
  "DuplicateFieldNameError", "AUDIT_DUPLICATE_FIELD_NAME",
  (identifier: string) => `The same field name appears more than once in field-level rules: ${identifier}`,
);

export const InvalidOperationTypeError = createDomainError(
  "InvalidOperationTypeError", "AUDIT_INVALID_OPERATION_TYPE",
  (identifier: string) => `operationType is missing or not one of CREATE, UPDATE, DELETE: ${identifier}`,
);

export const InvalidSensitivityModeError = createDomainError(
  "InvalidSensitivityModeError", "AUDIT_INVALID_SENSITIVITY_MODE",
  (identifier: string) => `sensitivityMode is not one of CAPTURE, MASK, HASH, EXCLUDE: ${identifier}`,
);

export const InvalidActorError = createDomainError(
  "InvalidActorError", "AUDIT_INVALID_ACTOR",
  (identifier: string) => `actorType is missing or not one of USER, SYSTEM, SERVICE; or actorId is empty: ${identifier}`,
);

export const MissingEntityIdError = createDomainError(
  "MissingEntityIdError", "AUDIT_MISSING_ENTITY_ID",
  (identifier: string) => `entityId is empty or not provided: ${identifier}`,
);

export const MissingEventIdError = createDomainError(
  "MissingEventIdError", "AUDIT_MISSING_EVENT_ID",
  (identifier: string) => `eventId is empty or not a valid UUID: ${identifier}`,
);

export const ValidationErrorError = createDomainError(
  "ValidationErrorError", "AUDIT_VALIDATION_ERROR",
  (identifier: string) => `Input failed validation for this operation: ${identifier}`,
);

export const InvalidEntityNameError = createDomainError(
  "InvalidEntityNameError", "AUDIT_INVALID_ENTITY_NAME",
  (identifier: string) => `entityName is empty or not provided: ${identifier}`,
);

export const DuplicateEntityNameError = createDomainError(
  "DuplicateEntityNameError", "AUDIT_DUPLICATE_ENTITY_NAME",
  (identifier: string) => `An entity with the same name is already registered: ${identifier}`,
);

export const InvalidEntityScopeError = createDomainError(
  "InvalidEntityScopeError", "AUDIT_INVALID_ENTITY_SCOPE",
  (identifier: string) => `entityScope is missing or not one of COMPANY_BOUND, GLOBAL: ${identifier}`,
);

export const InvalidAuditableFieldsError = createDomainError(
  "InvalidAuditableFieldsError", "AUDIT_INVALID_AUDITABLE_FIELDS",
  (identifier: string) => `auditableFields is empty, contains an empty field name, or contains a field with an ineligible fieldType (any type outside scalar, richtext, array, relation, file): ${identifier}`,
);

export const NoActivePolicyToReplaceError = createDomainError(
  "NoActivePolicyToReplaceError", "AUDIT_NO_ACTIVE_POLICY_TO_REPLACE",
  (identifier: string) => `No ACTIVE policy exists for the same entityName; use activateAuditPolicy instead: ${identifier}`,
);

export const TargetMismatchError = createDomainError(
  "TargetMismatchError", "AUDIT_TARGET_MISMATCH",
  (identifier: string) => `The existing ACTIVE policy does not match the replacement's companyId or operationType: ${identifier}`,
);

export const InvalidScopeError = createDomainError(
  "InvalidScopeError", "AUDIT_INVALID_SCOPE",
  (identifier: string) => `scope is not one of COMPANY, GLOBAL, or ALL: ${identifier}`,
);

export const AuditEntryNotFoundError = createDomainError(
  "AuditEntryNotFoundError", "AUDIT_AUDIT_ENTRY_NOT_FOUND",
  (identifier: string) => `Referenced audit entry does not exist: ${identifier}`,
);
