/** LFS domain: lock list/create/unlock and the ours/theirs verify split. */ import { unwrapApi } from '@app/lib' import type { EnvelopeLfsLockListResponse, EnvelopeLfsVerifyLocksResponse } from '@app/services/api' import Apis from '@app/services/api' export type LfsLockRow = NonNullable['locks']>[number] export type LfsLockPage = NonNullable export type LfsVerifyPage = NonNullable export const listLfsLocks = (space: string, repo: string, cursor?: string, limit = 50) => unwrapApi( Apis.lfs.list_locks({ pathParams: { space_name: space, repo_name: repo }, params: { cursor: cursor || undefined, limit }, }), ) export const createLfsLock = (space: string, repo: string, path: string, oid?: string) => unwrapApi( Apis.lfs.lock({ pathParams: { space_name: space, repo_name: repo }, data: { path, oid: oid || null }, }), ) export const unlockLfsPath = (space: string, repo: string, path: string, force = false) => unwrapApi( Apis.lfs.unlock({ pathParams: { space_name: space, repo_name: repo }, params: { path, force }, }), ) export const unlockLfsById = (space: string, repo: string, lockId: string, force = false) => unwrapApi( Apis.lfs.unlock_by_id({ pathParams: { space_name: space, repo_name: repo, lock_id: lockId }, params: { force }, }), ) /** Splits locks into ours / theirs, which is what `force` unlocks are for. */ export const verifyLfsLocks = (space: string, repo: string, limit = 50) => unwrapApi( Apis.lfs.verify_locks({ pathParams: { space_name: space, repo_name: repo }, params: { limit }, }), )