mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-08-06 07:00:12 +00:00
Use resource sync notifications in the web client
This commit is contained in:
@@ -67,6 +67,17 @@ export async function getSends(authedFetch: AuthedFetch): Promise<Send[]> {
|
||||
return body?.data || [];
|
||||
}
|
||||
|
||||
export async function getSendById(authedFetch: AuthedFetch, sendId: string): Promise<Send> {
|
||||
const id = String(sendId || '').trim();
|
||||
if (!id) throw new Error('Send id is required');
|
||||
const resp = await authedFetch(`/api/sends/${encodeURIComponent(id)}`);
|
||||
if (resp.status === 404) throw createApiError('Send not found', 404);
|
||||
if (!resp.ok) throw new Error(await parseErrorMessage(resp, 'Load send failed'));
|
||||
const body = await parseJson<Send>(resp);
|
||||
if (!body?.id) throw new Error('Load send failed');
|
||||
return body;
|
||||
}
|
||||
|
||||
export async function createSend(
|
||||
authedFetch: AuthedFetch,
|
||||
session: SessionState,
|
||||
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
import {
|
||||
BULK_API_CHUNK_SIZE,
|
||||
chunkArray,
|
||||
createApiError,
|
||||
parseErrorMessage,
|
||||
parseJson,
|
||||
uploadDirectEncryptedPayload,
|
||||
@@ -27,6 +28,17 @@ export async function getFolders(authedFetch: AuthedFetch, cacheKey: string): Pr
|
||||
return body.folders || [];
|
||||
}
|
||||
|
||||
export async function getFolderById(authedFetch: AuthedFetch, folderId: string): Promise<Folder> {
|
||||
const id = String(folderId || '').trim();
|
||||
if (!id) throw new Error('Folder id is required');
|
||||
const resp = await authedFetch(`/api/folders/${encodeURIComponent(id)}`);
|
||||
if (resp.status === 404) throw createApiError('Folder not found', 404);
|
||||
if (!resp.ok) throw new Error(await parseErrorMessage(resp, 'Load folder failed'));
|
||||
const body = await parseJson<Folder>(resp);
|
||||
if (!body?.id) throw new Error('Load folder failed');
|
||||
return body;
|
||||
}
|
||||
|
||||
export async function createFolder(
|
||||
authedFetch: AuthedFetch,
|
||||
session: SessionState,
|
||||
@@ -100,6 +112,17 @@ export async function getCiphers(authedFetch: AuthedFetch, cacheKey: string): Pr
|
||||
return body.ciphers || [];
|
||||
}
|
||||
|
||||
export async function getCipherById(authedFetch: AuthedFetch, cipherId: string): Promise<Cipher> {
|
||||
const id = String(cipherId || '').trim();
|
||||
if (!id) throw new Error('Cipher id is required');
|
||||
const resp = await authedFetch(`/api/ciphers/${encodeURIComponent(id)}`);
|
||||
if (resp.status === 404) throw createApiError('Cipher not found', 404);
|
||||
if (!resp.ok) throw new Error(await parseErrorMessage(resp, 'Load cipher failed'));
|
||||
const body = await parseJson<Cipher>(resp);
|
||||
if (!body?.id) throw new Error('Load cipher failed');
|
||||
return body;
|
||||
}
|
||||
|
||||
export interface CiphersImportPayload {
|
||||
ciphers: Array<Record<string, unknown>>;
|
||||
folders: Array<{ name: string }>;
|
||||
|
||||
Reference in New Issue
Block a user