rmapi-js
    Preparing search index...

    Class Library

    every item of an account, kept where the platform's stores keep it, so it reads and edits offline and sends the edits on a sync

    load shares a client with the library. Its items are handed out as Document, Folder and LibraryTemplate handles, from root, document and the like; an edit applies at once and is queued, and a sync merges the queue with the account and sends it. Save with save; the next load rebuilds the library from it.

    using library = await Library.load(client);
    await library.sync();
    const reading = library.root().createFolder("reading");
    await library.save();
    await library.sync();

    Implements

    • Disposable
    Index
    • let go of the library without saving

      Returns void

    • each new version, as the library moves past the one before, starting after since, the current version by default; ends when signal aborts or the library is let go of

      Parameters

      Returns AsyncGenerator<LibraryVersion, void>

    • every item as it is now, with the edits not yet sent, in id order; version read in the same turn is the version they are at

      Returns Entry[]

    entry

    • entry(id: string): Entry | undefined

      the item id, if the library holds one

      Parameters

      • id: string

      Returns Entry | undefined

    • the folder id, if the library holds one

      Parameters

      • id: string

      Returns Folder | undefined

    • when a fetch last finished, if one has

      Returns Date | undefined

    • delete blobs in the store that no listed item, queued edit or open page refers to

      Returns Promise<void>

    • save what changed since the last save to the platform's state store

      Returns Promise<void>

    • empty the store, the cache and the saved state, and drop the library with its queued edits, ending each changes() loop first; a LibraryInUseError while an open page holds it or another call on it runs

      The client forgets its session and device token, so every later call through it, a file read through it or a batch fails unsent with an UnauthorizedError, though a push with no edits still succeeds, and an open Notifications of it ends with that error.

      Returns Promise<void>

    • sync until every edit made before the call is in the account, or timeoutMs pass, which throws a TimedOutError; Infinity waits without a limit

      Parameters

      • timeoutMs: number
      • __namedParameters: Pick<SyncOptions, "onProgress"> = {}

      Returns Promise<SyncOutcome>

      TypeError if timeoutMs is not a number, and RangeError if it is NaN or below 0

    • every tag name on a document, folder or page outside the trash

      Returns Promise<string[]>

    • what template draws on a page of size: a paper of the tablet's as rmapi's version of it, and a template item as its definition with the edits not yet sent

      Parameters

      Returns Promise<TemplateDrawing>

      a NotHeldError for a template item the library does not hold, and an OnTabletError for a template "onTablet", which rmapi has no version of

    • the number of local edits waiting to be sent

      Returns number

    • empty the platform's store and saved state, as signOut does, with no library loaded, as for one that would not load; a client of the platform stays signed in

      Parameters

      Returns Promise<void>