feat: release asset upload, transfer, Actions secrets/variables/artifacts, admin, teams/projects, file search, reactions, attachments, package version delete

- client: multipart postForm; expo-document-picker + react-native-webview deps
- release assets: upload (DocumentPicker) and delete; run artifacts list
- repository transfer; Actions secrets + variables management screen
- admin (users/orgs/repos) screen gated on is_admin
- org teams, repo projects (read-only); find-file via recursive git tree
- issue reactions toggle and attachments list; package version delete
- endpoint tests (126 total)
This commit is contained in:
JustZoe101 committed 2026-10-09 18:40:08 +02:00
1 parent b2b44bca73
commit 587bf732b5
31 files changed
+1919 -46

No files matched your search

+76
View File
@@ -177,6 +177,82 @@ export class GiteaClient {
return text;
}
/**
* Uploads a multipart/form-data body (e.g. a release asset) and parses the
* JSON response. The multipart boundary is set by the platform, so we never
* set `Content-Type` ourselves. Errors are normalized like {@link raw}.
*/
async postForm<T>(
path: string,
form: FormData,
options: Omit<RequestOptions, 'method' | 'body'> = {},
): Promise<T> {
const url = `${this.apiRoot}${path}${buildQuery(options.query ?? {})}`;
const headers: Record<string, string> = { Accept: 'application/json' };
if (this.token) headers.Authorization = `token ${this.token}`;
const controller = new AbortController();
let timedOut = false;
const timeoutMs = options.timeoutMs ?? this.timeoutMs ?? 120_000;
const timer = setTimeout(() => {
timedOut = true;
controller.abort();
}, timeoutMs);
const onCallerAbort = () => controller.abort();
if (options.signal) {
if (options.signal.aborted) {
clearTimeout(timer);
throw new ApiError({ kind: 'aborted', status: 0, message: 'Request cancelled.' });
}
options.signal.addEventListener('abort', onCallerAbort);
}
let response: Response;
try {
response = await this.fetchImpl(url, {
method: 'POST',
headers,
body: form as unknown as BodyInit,
signal: controller.signal,
});
} catch (error) {
if (timedOut) {
throw new ApiError({ kind: 'timeout', status: 0, message: 'The upload took too long.' });
}
if (options.signal?.aborted) {
throw new ApiError({ kind: 'aborted', status: 0, message: 'Request cancelled.' });
}
throw toApiError(error);
} finally {
clearTimeout(timer);
options.signal?.removeEventListener('abort', onCallerAbort);
}
const text = await response.text();
let parsed: unknown = undefined;
if (text.length > 0) {
try {
parsed = JSON.parse(text);
} catch {
parsed = undefined;
}
}
if (!response.ok) {
const serverMessage =
parsed && typeof parsed === 'object' && 'message' in parsed
? String((parsed as { message: unknown }).message)
: null;
const kind = ApiError.kindForStatus(response.status);
throw new ApiError({
kind,
status: response.status,
serverMessage,
message: messageForStatus(kind, response.status, serverMessage),
});
}
return parsed as T;
}
/**
* Performs a request and returns data plus pagination metadata.
* `hasMore` uses `X-Total-Count` when present, otherwise a length heuristic