Инвойсы на Drive: раскладка как в «07. Invoices» (Инвойсы / способ оплаты / Месяц ГГГГ / «$сумма Вендор.pdf»), перенос оплаченных; drive_folder
Some checks failed
ci / test (push) Failing after 59s
ci / deploy (push) Has been skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 23:27:04 +03:00
parent dd60da4091
commit db333d6750
7 changed files with 122 additions and 4 deletions

View File

@@ -106,6 +106,20 @@ export class DriveClient implements DriveStore {
return (await res.json()) as { name: string; mimeType: string };
}
/** Переносит файл в другую папку (и при необходимости переименовывает). */
async move(fileId: string, folderId: string, newName?: string): Promise<void> {
const id = encodeURIComponent(fileId);
const cur = (await (await this.call(`${API}/files/${id}?fields=parents&supportsAllDrives=true`)).json()) as { parents?: string[] };
const params = new URLSearchParams({ addParents: folderId, supportsAllDrives: "true", fields: "id" });
const remove = (cur.parents ?? []).filter((p) => p !== folderId);
if (remove.length) params.set("removeParents", remove.join(","));
await this.call(`${API}/files/${id}?${params}`, {
method: "PATCH",
headers: { "content-type": "application/json" },
body: JSON.stringify(newName ? { name: newName } : {}),
});
}
async download(fileId: string): Promise<Buffer> {
const res = await this.call(`${API}/files/${encodeURIComponent(fileId)}?alt=media&supportsAllDrives=true`);
return Buffer.from(await res.arrayBuffer());