import { Q as QueryOperator, M as MutationOperator } from '../ApprovalOperator-BhmGoAnh.cjs'; export { K as ApprovalFilters, J as ApprovalOperator, L as CreateApprovalInput, B as CreateDiscussionInput, H as CreateDocumentInput, q as CreateMilestoneInput, g as CreateOrgInput, m as CreateProjectInput, C as CreateTaskInput, y as CreateTemplateInput, u as CreateUserInput, j as CreateWorkspaceInput, A as DiscussionFilters, D as DiscussionOperator, G as DocumentFilters, F as DocumentOperator, p as MilestoneFilters, o as MilestoneOperator, c as MutationOptions, d as MutationState, f as OrgFilters, O as OrgOperator, l as ProjectFilters, P as ProjectOperator, a as QueryOptions, b as QueryResult, e as TaskFilters, T as TaskOperator, x as TemplateFilters, w as TemplateOperator, N as UpdateApprovalInput, E as UpdateDiscussionInput, I as UpdateDocumentInput, r as UpdateMilestoneInput, h as UpdateOrgInput, n as UpdateProjectInput, U as UpdateTaskInput, z as UpdateTemplateInput, v as UpdateUserInput, k as UpdateWorkspaceInput, t as UserFilters, s as UserOperator, i as WorkspaceFilters, W as WorkspaceOperator } from '../ApprovalOperator-BhmGoAnh.cjs'; import { RxDatabase } from 'rxdb'; import { R as RoleModel, a as RoleMembershipModel } from '../RoleMembership-CkKSxZZF.cjs'; import '../Workspace-CoUdcswi.cjs'; import '../types-5lxby8F5.cjs'; import 'rxjs'; /** * Filters for querying roles. */ interface RoleFilters { /** Filter by owning organisation ID. */ orgId?: string; /** Filter by role slug (e.g. `'owner'`, `'viewer'`). */ name?: string; /** Filter by built-in flag. */ builtIn?: boolean; /** When true, include archived roles only. When absent, exclude archived roles. */ archived?: boolean; /** Filter by scope type (e.g. `'workspace'`, `'project'`). */ scopeType?: string; /** Filter by scope entity ID. */ scopeId?: string; } /** * Input for creating a new role. */ interface CreateRoleInput { /** Role slug used in permission checks. */ name: string; /** Human-readable display label. */ title: string; /** Optional description of what this role grants. */ description?: string; /** ID of the owning organisation. */ orgId: string; /** Scope type for workspace/project-scoped roles. */ scopeType?: string; /** Scope entity ID (required when scopeType is set). */ scopeId?: string; /** Whether this is a system-seeded built-in role. Defaults to false. */ builtIn?: boolean; } /** * Input for updating an existing role. */ interface UpdateRoleInput { /** ID of the role to update. */ id: string; /** Fields to update. */ updates: Partial; } /** * Operator for querying and mutating the `roles` collection. * * Follows the operator pattern established by `UserOperator` and `OrgOperator`. * All mutations are soft operations — deletion archives rather than removes. * * @example * ```typescript * const op = new RoleOperator(db) * const roles = await op.query({ orgId: 'org_abc', builtIn: true }).exec() * const role = await op.createMutation().execute({ name: 'viewer', title: 'Viewer', orgId: 'org_abc' }) * ``` */ declare class RoleOperator { private db; constructor(db: RxDatabase); /** * Build a query for roles with optional filters and pagination. * * Excludes archived roles by default. Pass `archived: true` to query * only archived roles. * * @param filters - Field filters to apply. * @param options - Pagination and sort options. * @returns A `QueryOperator` ready to `.exec()` or `.observable`. */ query(filters: RoleFilters, options?: { sort?: string; limit?: number; skip?: number; }): QueryOperator; /** * Fetch a single role by its ID. * * @param roleId - The role document ID. * @returns The role as a plain object, or null if not found. */ findOne(roleId: string): Promise; /** * Create a mutation operator for inserting a new role. * * Assigns a generated ID and sets `archived: false` and timestamps * automatically. * * @returns A `MutationOperator` whose `execute()` resolves to the new role. */ createMutation(): MutationOperator; /** * Create a mutation operator for updating role fields. * * Always stamps `updatedAt` on the modified document. * * @returns A `MutationOperator` whose `execute()` resolves to the updated role. */ updateMutation(): MutationOperator; /** * Create a mutation operator for soft-deleting a role. * * Sets `archived: true` rather than removing the document so that * audit trails and existing membership references remain intact. * * @returns A `MutationOperator` whose `execute()` takes the role ID. */ deleteMutation(): MutationOperator; } /** * Filters for querying role memberships. */ interface RoleMembershipFilters { /** Filter by owning organisation ID. */ orgId?: string; /** Filter by member user ID. */ userId?: string; /** Filter by assigned role ID. */ roleId?: string; /** Filter by lifecycle status (`'active'`, `'suspended'`, `'pending'`). */ status?: string; /** Filter by scope type (e.g. `'workspace'`, `'project'`). */ scopeType?: string; /** Filter by scope entity ID. */ scopeId?: string; } /** * Input for assigning a role to a user. */ interface CreateRoleMembershipInput { /** ID of the role being assigned. */ roleId: string; /** ID of the user receiving the role. */ userId: string; /** User ID of the principal granting the role. */ grantedBy: string; /** ID of the owning organisation. */ orgId: string; /** Scope type inherited from the role. */ scopeType?: string; /** Scope entity ID inherited from the role. */ scopeId?: string; /** Optional expiry timestamp for time-limited memberships. */ expiresAt?: string; } /** * Operator for querying and mutating the `rolememberships` collection. * * Role memberships record that a user holds a particular role. * "Deletion" suspends the membership (`status: 'suspended'`) rather than * removing the document, preserving audit history. * * @example * ```typescript * const op = new RoleMembershipOperator(db) * const memberships = await op.query({ orgId: 'org_abc', userId: 'user_123' }).exec() * const m = await op.createMutation().execute({ * roleId: 'role_abc', userId: 'user_123', grantedBy: 'user_456', orgId: 'org_abc', * }) * ``` */ declare class RoleMembershipOperator { private db; constructor(db: RxDatabase); /** * Build a query for role memberships with optional filters and pagination. * * Unlike `RoleOperator.query`, this does not apply an automatic * `archived` filter — callers should pass `status: 'active'` explicitly * when they want only live memberships. * * @param filters - Field filters to apply. * @param options - Pagination and sort options. * @returns A `QueryOperator` ready to `.exec()` or `.observable`. */ query(filters: RoleMembershipFilters, options?: { sort?: string; limit?: number; skip?: number; }): QueryOperator; /** * Fetch a single membership by its ID. * * @param id - The membership document ID. * @returns The membership as a plain object, or null if not found. */ findOne(id: string): Promise; /** * Create a mutation operator for inserting a new role membership. * * Assigns a generated ID, sets `status: 'active'`, and stamps timestamps. * * @returns A `MutationOperator` whose `execute()` resolves to the new membership. */ createMutation(): MutationOperator; /** * Create a mutation operator for soft-removing a role membership. * * Sets `status: 'suspended'` rather than deleting the document so that * audit trails remain intact. * * @returns A `MutationOperator` whose `execute()` takes the membership ID. */ deleteMutation(): MutationOperator; } export { type CreateRoleInput, type CreateRoleMembershipInput, MutationOperator, QueryOperator, type RoleFilters, type RoleMembershipFilters, RoleMembershipOperator, RoleOperator, type UpdateRoleInput };