import { FetchRepositoryBase } from "../../../shared/index.js"; import { type LockReleaseOutcome } from "./lockOwnership.js"; export interface Lock { id: number; /** Locked resource summary. Null when the lockable no longer exists. */ element: { title: string; type: string; } | null; /** Lock owner. */ user: { id: number; name: string; }; /** Whether the lock is still valid (not expired). */ valid: boolean; account_id: number; created_at: string; updated_at: string; } export interface LocksList { locks: Lock[]; meta: { total_entries: number; per_page: number; current_page: number; total_pages: number; }; } /** * Página de `listLocksTolerant`. `total_entries` y `total_pages` faltan * cuando ninguna posición de la página se pudo leer: el total es desconocido. */ export interface TolerantLocksList { locks: Lock[]; meta: { total_entries: number | undefined; per_page: number; current_page: number; total_pages: number | undefined; }; unreadable: number; } export interface AcquireLockParams { lockable_type: string; lockable_id: number; } /** * Repository for managing locks in Modyo Channels. * Locks are used to prevent concurrent editing of resources like pages, templates, widgets, and entries. */ export declare class LocksRepository extends FetchRepositoryBase { /** Usuario del token, leído una vez por repositorio. */ private currentUserLookup; /** * Gets a specific lock by ID. * @param lockId - The ID of the lock to retrieve * @returns Promise resolving to the lock details */ getLock(lockId: number): Promise; /** * Lists locks of the account, newest first (`sort_by=id`, stable between * pages), optionally filtered by lockable type. */ listLocks(page?: number, perPage?: number, lockableType?: string): Promise; /** * Lista una página y, si la plataforma responde 500, la recorre de a un * registro. * * Medido en `un.modyo.cloud`: algunos locks de la cuenta no se serializan y * cualquier página que los incluya responde 500 (con `per_page=1` falla solo * la posición de ese registro). Se devuelven los que sí se leyeron y cuántas * posiciones quedaron sin leer. */ listLocksTolerant(page: number, perPage: number, lockableType?: string): Promise; /** * Acquires a lock on a resource and returns the lock as read afterwards. * The platform answers 422 when another user holds a valid lock. */ acquireLock(params: AcquireLockParams): Promise; /** * Takes over a lock on a resource, forcibly taking it from its current * owner (POST /locks/take_over → create_lock!(user, force: true)). Returns * the lock as read afterwards. */ takeOverLock(params: AcquireLockParams): Promise; /** Relee el lock que devolvió una escritura; sin id, no hay qué releer. */ private rereadLock; /** * Id del usuario del token: `GET /profile` o, ante un 404, * `GET /admin_users/me` (`CurrentUserLookup`). */ getCurrentUserId(): Promise; /** * Releases a lock only if it belongs to the token user. * * Reads the lock first and compares its owner with the user of the token; a lock * held by another user is left as is (`not_owned`). */ releaseOwnLock(lockId: number): Promise; /** * Releases the token user's lock on a resource. * * The platform does not expose the resource of a lock (`element` only has * title and type), so the lock is located by requesting it: `POST /locks` * answers 201 with the token user's lock (new or refreshed) and 422 when * another user holds a valid one. Only the first case is released. */ releaseOwnLockByLockable(lockableType: string, lockableId: number): Promise; } //# sourceMappingURL=LocksRepository.d.ts.map