/** * Remotes domain: remote CRUD plus fetch / push / mirror-import. * Tokens are per-request only — the server never stores them. */ import { unwrapApi } from '@app/lib' import type { EnvelopeFetchResultDto, EnvelopeImportResultDto, EnvelopePushResultDto, EnvelopeVecRemoteDto, } from '@app/services/api' import Apis from '@app/services/api' export type RemoteRow = NonNullable[number] export type FetchResult = NonNullable export type PushResult = NonNullable export type ImportResult = NonNullable export const listRemotes = (space: string, repo: string) => unwrapApi(Apis.remotes.list_remotes({ pathParams: { space_name: space, repo_name: repo } })) export const upsertRemote = (space: string, repo: string, name: string, url: string) => unwrapApi( Apis.remotes.upsert_remote({ pathParams: { space_name: space, repo_name: repo, name }, data: { url }, }), ) export const removeRemote = (space: string, repo: string, name: string) => unwrapApi(Apis.remotes.remove({ pathParams: { space_name: space, repo_name: repo, name } })) /** `token` is sent per request only — it is never stored on the server. */ export const fetchRemote = (space: string, repo: string, name: string, token?: string) => unwrapApi( Apis.remotes.fetch({ pathParams: { space_name: space, repo_name: repo }, data: { remote: name, auth: token ? { token } : null }, }), ) export const pushRemote = (space: string, repo: string, name: string, refspec?: string, token?: string) => unwrapApi( Apis.remotes.push({ pathParams: { space_name: space, repo_name: repo }, data: { remote: name, refspec: refspec || null, auth: token ? { token } : null }, }), ) /** Mirror-import every ref from an external URL into this repo. */ export const importRemote = (space: string, repo: string, url: string, token?: string) => unwrapApi( Apis.remotes.clone_import({ pathParams: { space_name: space, repo_name: repo }, data: { url, auth: token ? { token } : null }, }), )