byAgeconstconst byAge: (a: DriveFile, b: DriveFile) => numberOrders files as the store means them where a name is held more than once: the oldest first, then by identifier.
The files the Drive API answers with, read strictly: a file has an identifier, a name, a type (a folder is the type application/vnd.google-apps.folder; the other types of Google, documents, sheets, slides and shortcuts, have no bytes of their own to keep), a creation time and, for a blob, a size and the digest of its contents; a list has the files and, where there are more, a token for the next page. Everything is read from JSON that is checked, never cast, and a field of another type is a reason and not a guess.
import { parseFile } from "./files.ts";
const f = parseFile({ id: "1", name: "a.txt", mimeType: "text/plain", size: "3", createdTime: "2026-01-01T00:00:00.000Z" });
f.kind === "ok" && f.value.kind; // "blob"byAgeconstconst byAge: (a: DriveFile, b: DriveFile) => numberOrders files as the store means them where a name is held more than once: the oldest first, then by identifier.
FOLDER_TYPEconstno test imports itconst FOLDER_TYPE: "application/vnd.google-apps.folder"The type of a folder.
parseFilefunctionfunction parseFile(json: unknown): Result<DriveFile & { readonly trashed: boolean; }, string>A file from parsed JSON, or why it is not one. A file in the trash is not a file of the store.
parsePagefunctionfunction parsePage(json: unknown): Result<Page, string>A page from parsed JSON, or why it is not one.
quotedconstconst quoted: (text: string) => stringA text as a string of a query of Drive: in single quotes, with the backslash and the quote escaped.
DriveFiletypeno test imports ittype DriveFile =
| { readonly kind: "blob"; readonly id: string; readonly name: string; readonly size: number; readonly created: number; readonly modified?: string; readonly sha256?: string }
| { readonly kind: "folder"; readonly id: string; readonly name: string; readonly created: number }
| { readonly kind: "other"; readonly id: string; readonly name: string; readonly created: number };What a file of Drive is, with what the store needs of it.
Pagetypeno test imports ittype Page = { readonly files: readonly (DriveFile & { readonly trashed: boolean })[]; readonly next?: string };A page of a list of files: the files and the token of the next page where there is one.