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

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

export const InvalidStatusTransitionError = createDomainError(
  "InvalidStatusTransitionError", "APPROVAL_INVALID_STATUS_TRANSITION",
  (identifier: string) => `Target entity is not in a status that permits this operation: ${identifier}`,
);

export const PolicyNotReadyToActivateError = createDomainError(
  "PolicyNotReadyToActivateError", "APPROVAL_POLICY_NOT_READY_TO_ACTIVATE",
  (identifier: string) => `Policy has zero steps or at least one step has zero assignees: ${identifier}`,
);

export const ActivePolicyConflictError = createDomainError(
  "ActivePolicyConflictError", "APPROVAL_ACTIVE_POLICY_CONFLICT",
  (identifier: string) => `Another ACTIVE policy already exists for the same (purpose, name) pair: ${identifier}`,
);

export const NotActiveAssigneeError = createDomainError(
  "NotActiveAssigneeError", "APPROVAL_NOT_ACTIVE_ASSIGNEE",
  (identifier: string) => `The actor does not own a PENDING ApprovalStepAssignee row on an IN_PROGRESS ApprovalStep: ${identifier}`,
);

export const ParentRequestNotPendingError = createDomainError(
  "ParentRequestNotPendingError", "APPROVAL_PARENT_REQUEST_NOT_PENDING",
  (identifier: string) => `The parent ApprovalRequest.status is not PENDING: ${identifier}`,
);

export const SelfDecisionNotAllowedError = createDomainError(
  "SelfDecisionNotAllowedError", "APPROVAL_SELF_DECISION_NOT_ALLOWED",
  (identifier: string) => `The actor is the requester of the parent request; segregation of duties prohibits self-decision on APPROVE / REJECT / SEND_BACK / DELEGATE: ${identifier}`,
);

export const RoleHasNoActiveMembersError = createDomainError(
  "RoleHasNoActiveMembersError", "APPROVAL_ROLE_HAS_NO_ACTIVE_MEMBERS",
  (identifier: string) => `A role-based assignee expanded to zero ACTIVE members at step activation: ${identifier}`,
);

export const StepQuorumUnreachableError = createDomainError(
  "StepQuorumUnreachableError", "APPROVAL_STEP_QUORUM_UNREACHABLE",
  (identifier: string) => `A step's runtime assignee count after role expansion is less than its minimumApprovals threshold: ${identifier}`,
);

export const RequestNotFoundError = createDomainError(
  "RequestNotFoundError", "APPROVAL_REQUEST_NOT_FOUND",
  (identifier: string) => `Specified approvalRequestId does not exist: ${identifier}`,
);

export const MissingRequiredFieldError = createDomainError(
  "MissingRequiredFieldError", "APPROVAL_MISSING_REQUIRED_FIELD",
  (identifier: string) => `A required input field is missing or empty: ${identifier}`,
);

export const PolicyHasNoStepsError = createDomainError(
  "PolicyHasNoStepsError", "APPROVAL_POLICY_HAS_NO_STEPS",
  (identifier: string) => `The supplied steps array is empty: ${identifier}`,
);

export const DuplicateStepOrderError = createDomainError(
  "DuplicateStepOrderError", "APPROVAL_DUPLICATE_STEP_ORDER",
  (identifier: string) => `Two or more steps share the same stepOrder: ${identifier}`,
);

export const StepHasNoAssigneesError = createDomainError(
  "StepHasNoAssigneesError", "APPROVAL_STEP_HAS_NO_ASSIGNEES",
  (identifier: string) => `A step has no assignees: ${identifier}`,
);

export const InvalidMinimumApprovalsError = createDomainError(
  "InvalidMinimumApprovalsError", "APPROVAL_INVALID_MINIMUM_APPROVALS",
  (identifier: string) => `A step's minimumApprovals is not a positive integer: ${identifier}`,
);

export const AssigneeUserRoleXorViolatedError = createDomainError(
  "AssigneeUserRoleXorViolatedError", "APPROVAL_ASSIGNEE_USER_ROLE_XOR_VIOLATED",
  (identifier: string) => `An assignee row sets both userId and roleId, or neither: ${identifier}`,
);

export const AssigneeFlagsIncompatibleError = createDomainError(
  "AssigneeFlagsIncompatibleError", "APPROVAL_ASSIGNEE_FLAGS_INCOMPATIBLE",
  (identifier: string) => `An assignee row sets required = true on a role assignee, or sets roleQuorum on a user assignee: ${identifier}`,
);

export const DuplicateUserAssigneeError = createDomainError(
  "DuplicateUserAssigneeError", "APPROVAL_DUPLICATE_USER_ASSIGNEE",
  (identifier: string) => `Two user assignees within the same step target the same userId: ${identifier}`,
);

export const DuplicateRoleAssigneeError = createDomainError(
  "DuplicateRoleAssigneeError", "APPROVAL_DUPLICATE_ROLE_ASSIGNEE",
  (identifier: string) => `Two role assignees within the same step target the same roleId: ${identifier}`,
);

export const CreationModeAmbiguousError = createDomainError(
  "CreationModeAmbiguousError", "APPROVAL_CREATION_MODE_AMBIGUOUS",
  (identifier: string) => `Both policyId and steps were supplied, or neither was supplied: ${identifier}`,
);

export const PolicyNotActiveError = createDomainError(
  "PolicyNotActiveError", "APPROVAL_POLICY_NOT_ACTIVE",
  (identifier: string) => `Source policy is not in ACTIVE status (policy mode only): ${identifier}`,
);

export const SelfDelegationNotAllowedError = createDomainError(
  "SelfDelegationNotAllowedError", "APPROVAL_SELF_DELEGATION_NOT_ALLOWED",
  (identifier: string) => `delegatedToUserId equals ctx.actorId: ${identifier}`,
);

export const CircularDelegationError = createDomainError(
  "CircularDelegationError", "APPROVAL_CIRCULAR_DELEGATION",
  (identifier: string) => `delegatedToUserId is already a PENDING assignee on the same step: ${identifier}`,
);

export const NotRequesterError = createDomainError(
  "NotRequesterError", "APPROVAL_NOT_REQUESTER",
  (identifier: string) => `ctx.actorId does not match ApprovalRequest.requesterId: ${identifier}`,
);

export const InvariantViolationMultipleOpenError = createDomainError(
  "InvariantViolationMultipleOpenError", "APPROVAL_INVARIANT_VIOLATION_MULTIPLE_OPEN",
  (identifier: string) => `Defensive guard — more than one non-terminal request exists for the same target; should be impossible if wrapper commands enforce exclusivity correctly: ${identifier}`,
);
