import type { DB, DBTransaction, LevelPath } from '@matrixai/db'; import type { PermissionId, Permission } from './types.js'; import type { NodeId } from '../ids/types.js'; import type { GestaltAction } from '../gestalts/types.js'; import type { VaultAction, VaultId } from '../vaults/types.js'; import Logger from '@matrixai/logger'; import { createDestroyStartStop } from '@matrixai/async-init'; interface ACL extends createDestroyStartStop.CreateDestroyStartStop { } declare class ACL { static createACL({ db, logger, fresh, }: { db: DB; logger?: Logger; fresh?: boolean; }): Promise; protected logger: Logger; protected db: DB; protected aclDbPath: LevelPath; /** * Perms stores PermissionId -> Ref */ protected aclPermsDbPath: LevelPath; /** * Nodes stores NodeId -> PermissionId */ protected aclNodesDbPath: LevelPath; /** * Vaults stores VaultIdString -> Record * note that the NodeId in each record must be in their own unique gestalt * the NodeId in each record may be missing if it had been previously deleted */ protected aclVaultsDbPath: LevelPath; protected generatePermId: () => PermissionId; constructor({ db, logger }: { db: DB; logger: Logger; }); start({ fresh, }?: { fresh?: boolean; }): Promise; stop(): Promise; destroy(): Promise; sameNodePerm(nodeId1: NodeId, nodeId2: NodeId, tran?: DBTransaction): Promise; getNodePerms(tran?: DBTransaction): Promise>>; getVaultPerms(tran?: DBTransaction): Promise>>; /** * Gets the permission record for a given node id * Any node id is acceptable */ getNodePerm(nodeId: NodeId, tran?: DBTransaction): Promise; /** * Gets the record of node ids to permission for a given vault id * The node ids in the record each represent a unique gestalt * If there are no permissions, then an empty record is returned */ getVaultPerm(vaultId: VaultId, tran?: DBTransaction): Promise>; setNodeAction(nodeId: NodeId, action: GestaltAction, tran?: DBTransaction): Promise; unsetNodeAction(nodeId: NodeId, action: GestaltAction, tran?: DBTransaction): Promise; setVaultAction(vaultId: VaultId, nodeId: NodeId, action: VaultAction, tran?: DBTransaction): Promise; unsetVaultAction(vaultId: VaultId, nodeId: NodeId, action: VaultAction, tran?: DBTransaction): Promise; /** * Sets an array of node ids to a new permission record * This is intended for completely new gestalts * Or for gestalt splitting. */ setNodesPerm(nodeIds: Array, perm: Permission, tran?: DBTransaction): Promise; setNodePerm(nodeId: NodeId, perm: Permission, tran?: DBTransaction): Promise; unsetNodePerm(nodeId: NodeId, tran?: DBTransaction): Promise; unsetVaultPerms(vaultId: VaultId, tran?: DBTransaction): Promise; joinNodePerm(nodeId: NodeId, nodeIdsJoin: Array, perm?: Permission, tran?: DBTransaction): Promise; joinVaultPerms(vaultId: VaultId, vaultIdsJoin: Array, tran?: DBTransaction): Promise; } export default ACL;