IF Commons GitHub

items

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

The items Graph answers with, read strictly: a drive item has an id, a name, a size, an entity tag and a time, and is a file (with the hashes of its contents where Graph keeps them), a folder, or something that is neither (a package such as a OneNote notebook, a shortcut); a page of children has the items and, where there are more, the address of 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 { parseItem } from "./items.ts";
const item = parseItem({ id: "1", name: "a.txt", size: 3, eTag: "\"{X},1\"", file: { hashes: { sha256Hash: "AB" } } });
item.kind === "ok" && item.value.kind; // "file"

Source: commons/anyfs-onedrive/src/items.ts

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

parseItemfunction
function parseItem(json: unknown): Result<Item, string>

An item from parsed JSON, or why it is not one.

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

Itemtypeno test imports it
type Item =
  | { readonly kind: "file"; readonly id: string; readonly name: string; readonly size: number; readonly eTag: string; readonly modified?: string; readonly sha256?: string }
  | { readonly kind: "folder"; readonly id: string; readonly name: string }
  | { readonly kind: "other"; readonly id: string; readonly name: string };

What an item is.

Pagetypeno test imports it
type Page = { readonly items: readonly Item[]; readonly next?: string };

A page of the children of a folder: its items, and the address of the next page where there is one.

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