IF Commons GitHub

store

Written to: 8 requirements: 8 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-anyfs-onedrive-store FR-001, 0002-anyfs-onedrive-store FR-003, 0002-anyfs-onedrive-store FR-006, 0002-anyfs-onedrive-store FR-007, 0002-anyfs-onedrive-store FR-002, 0002-anyfs-onedrive-store FR-004 and 2 more

The store over a drive and a folder of Microsoft Graph. Its objects are the files below the folder, addressed by path (/me/drive/root:/a/b:/content), whole (up to maxBytes, 64 MiB where it is left out; Graph takes 250 MB in one request and an upload session for more is a later capability). The revision of an object is sha256: and the digest of its bytes, the same as in every other store: Graph keeps the digest of the contents of a file as sha256Hash on some drives and not on others, so the store uses it where it is given and reads the bytes where it is not. The entity tag Graph gives is not a revision (it changes at every write, even of the same bytes): it guards a write, which is made with If-Match on the entity tag of the object seen to be at the revision expected, and an object that is expected not to be there is written with conflictBehavior=fail, so that of several writers one wins.

Limits, said once: a read keeps the whole object in memory and asks twice (the item, then the bytes); a listing walks every folder below the prefix and asks about the bytes of a file that carries no digest, so a listing of a drive that gives none is as long as its data is; names are case-insensitive, so two paths that differ only by case are one object; a call is not retried here (the layer retrying does it for a problem that says it is worth one); and the folders that a delete leaves empty are removed on the way up, which is a second request that may fail without the delete failing.

import { openOneDriveStore, staticToken } from "./store.ts";
// const opened = await openOneDriveStore({ place, token: staticToken(process.env.TOKEN ?? "") });
// opened.kind === "ok" && opened.value.capabilities.has("cas"); // true

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

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

CAPABILITIESconst
const CAPABILITIES: readonly ["read", "write", "list", "stat", "delete", "cas"]

The capabilities of the store.

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

openOneDriveStorefunction
function openOneDriveStore(options: OneDriveOptions): Promise<Result<OneDriveStore, string>>

A store on a drive and a folder of Graph, or why there is none. The drive is asked once, so that a token that is not accepted is found here.

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

OneDriveOptionstypeno test imports it
type OneDriveOptions = { /** The drive and the folder: `parsePlace("onedrive://me/fleet")`. */ readonly place: OneDr… (928 characters)
type OneDriveOptions = {
  /** The drive and the folder: `parsePlace("onedrive://me/fleet")`. */
  readonly place: OneDrivePlace;
  readonly token: TokenSource;
  /** Where Graph listens: `https://graph.microsoft.com/v1.0` where it is left out. */
  readonly endpoint?: string;
  /** The most bytes an object may have: 64 MiB where it is left out, and never more than the 250 MB of one request. */
  readonly maxBytes?: number;
  readonly transport?: Transport;
  /** How long a request may take: 30 s where it is left out. */
  readonly timeoutMs?: number;
  /** How many files a listing asks the bytes of at once: 8 where it is left out. */
  readonly listConcurrency?: number;
  /** The most entries a listing walks: 100000 where it is left out. */
  readonly maxEntries?: number;
  /** The most requests a listing makes: 5000 where it is left out. */
  readonly maxRequests?: number;
  readonly consistency?: Consistency;
};

What a store is made with.

OneDrivePlacetypeno test imports it
type OneDrivePlace = Extract<Place, { readonly kind: "onedrive" }>;

The place of a store on OneDrive.

OneDriveStoretypeno test imports it
type OneDriveStore = Store<(typeof CAPABILITIES)[number]>;

The store.

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