/**
 * Organization and multi-tenancy types for SentryAgent.ai AgentIdP.
 * All interfaces and types for the organization/tenant domain live here.
 */

// ============================================================================
// Enumerations / Union Types
// ============================================================================

/** Lifecycle status of an organization. */
export type OrgStatus = 'active' | 'suspended' | 'deleted';

/** Subscription plan tier for an organization. */
export type PlanTier = 'free' | 'pro' | 'enterprise';

/** Role of an agent within an organization. */
export type OrgRole = 'member' | 'admin';

// ============================================================================
// Organization
// ============================================================================

/** Full representation of a registered organization (tenant). */
export interface IOrganization {
  organizationId: string;
  name: string;
  slug: string;
  planTier: PlanTier;
  maxAgents: number;
  maxTokensPerMonth: number;
  status: OrgStatus;
  createdAt: Date;
  updatedAt: Date;
}

/** Request body for creating a new organization. */
export interface ICreateOrgRequest {
  name: string;
  slug: string;
  planTier?: PlanTier;
  maxAgents?: number;
  maxTokensPerMonth?: number;
}

/**
 * Request body for partially updating an organization.
 * Note: status may only be set to 'active' or 'suspended' via update;
 * 'deleted' is applied only through the soft-delete operation.
 */
export interface IUpdateOrgRequest {
  name?: string;
  planTier?: PlanTier;
  maxAgents?: number;
  maxTokensPerMonth?: number;
  status?: 'active' | 'suspended';
}

/** Paginated list of organizations. */
export interface IPaginatedOrgsResponse {
  data: IOrganization[];
  total: number;
  page: number;
  limit: number;
}

/** Query filters for listing organizations. */
export interface IOrgListFilters {
  status?: OrgStatus;
  page: number;
  limit: number;
}

// ============================================================================
// Organization Membership
// ============================================================================

/** An agent's membership record within an organization. */
export interface IOrgMember {
  memberId: string;
  organizationId: string;
  agentId: string;
  role: OrgRole;
  joinedAt: Date;
}

/** Request body for adding an agent to an organization. */
export interface IAddMemberRequest {
  agentId: string;
  role: OrgRole;
}
