IF Commons GitHub

files

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-anyfs-gdrive-store FR-003, 0002-anyfs-gdrive-store FR-007

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"

Source: commons/anyfs-gdrive/src/files.ts

4 of 7 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

byAgeconst
const byAge: (a: DriveFile, b: DriveFile) => number

Orders files as the store means them where a name is held more than once: the oldest first, then by identifier.

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

FOLDER_TYPEconstno test imports it
const FOLDER_TYPE: "application/vnd.google-apps.folder"

The type of a folder.

parseFilefunction
function 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.

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

parsePagefunction
function parsePage(json: unknown): Result<Page, string>

A page from parsed JSON, or why it is not one.

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

quotedconst
const quoted: (text: string) => string

A text as a string of a query of Drive: in single quotes, with the backslash and the quote escaped.

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

DriveFiletypeno test imports it
type 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 it
type 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.

Titles, headings, exports, tables, columns and requirements. Esc closes.