rmapi-js
    Preparing search index...

    Class ClientMetadata<R>

    an item's .metadata read through a Client, with the item's reference, to edit and push back

    It reads and edits as a Metadata does. push writes the edits and moves item on to what was written, pull merges the edits onto the account's newer copy, and the client's pushAll and pullAll do so for many files at once. intoInner gives the reference and the plain file back, for the client's put calls. Until a push or pull settles, an edit of it or another push or pull throws a PutRunningError.

    const metadata = await client.metadata(item);
    metadata.setStarred(true);
    const starred = await metadata.push("merge");

    Type Parameters

    Hierarchy (View Summary)

    Index
    • get createdTime(): Date | undefined

      when it was made

      Returns Date | undefined

    • get deleted(): boolean | undefined

      the deleted flag

      Returns boolean | undefined

    • get hasEdits(): boolean

      whether an edit changes the file from the version as read

      Returns boolean

    • get isNew(): boolean | undefined

      the new flag

      Returns boolean | undefined

    • get item(): R

      the item's reference, as of the read or the last push or pull

      Returns R

    • get lastModified(): Date

      when it last changed

      Returns Date

    • get lastOpened(): Date | undefined

      when it was last opened

      Returns Date | undefined

    • get lastOpenedPage(): number | undefined

      the page it was last open at, from zero

      Returns number | undefined

    • get metadataModified(): boolean | undefined

      the metadatamodified flag

      Returns boolean | undefined

    • get modified(): boolean | undefined

      the modified flag

      Returns boolean | undefined

    • get name(): string

      the name shown

      Returns string

    • get parent(): string

      "" for the root, "trash", or the id of the folder it is in

      Returns string

    • get source(): string | undefined

      where it came from

      Returns string | undefined

    • get starred(): boolean

      whether it is starred

      Returns boolean

    • get synced(): boolean | undefined

      the synced flag

      Returns boolean | undefined

    • get version(): number | undefined

      the version count

      Returns number | undefined

    • put this file's edits on newer, a copy read since, and hold that, returning the keys both changed to different values, where this side's value was kept

      Parameters

      Returns string[]

    • read the account's copy and merge the edits onto it, as merge does, to hold with the item's reference as the account lists it now; it writes nothing

      Returns Promise<void>

      NotFoundError if the account no longer lists the item, and a merge error as push does; a failed pull leaves the file and its reference as they were

    • write the edits, and resolve to the item's new reference

      It writes the file and the item's .metadata, dated now, in one root write, as long as the account's copy of the file is still the one read, and then holds the new reference and what was written. A file with no edits writes nothing and succeeds, whatever the account holds, and stays as it was.

      Parameters

      Returns Promise<R>

      NotFoundError if the account no longer lists the item, HashChangedError if its file changed since the read and onConflict is "fail" or the merges ran out, and ContentMergeError or MergeError if a merge failed; a failed push leaves the file and its reference as they were

    • remove a key of the file: a key the core reads clears its field, or sets it to what a file without the key reads it as

      Parameters

      • key: string

      Returns this

      Warning: as for setExtra, this can leave the file at odds with itself. Prefer the field's own setter.

      ValidationError if key names a field the file must have; the file is left as it was

    • set a key of the file: a key the core reads sets its field, and any other is kept in extra

      Parameters

      • key: string
      • value: Json

      Returns this

      Warning: a key the core reads is written as given, past the rules its own setter keeps, so it can leave the file at odds with itself, such as a pageCount that does not count the pages listed. Prefer the field's own setter, such as setPages for the page keys.

      ValidationError if value is not a value of the field key names; the file is left as it was

    • set when it last changed

      Parameters

      • time: Date

      Returns this

      RangeError if time is an invalid date or one before 1970

    • set when it was last opened, or clear it

      Parameters

      • time: Date | undefined

      Returns this

      RangeError if time is an invalid date or one before 1970

    • set the page it was last open at, or clear it

      Parameters

      • page: number | undefined

      Returns this

      RangeError if page is not an integer from 0 to 2^32 - 1

    • the file with its edits made, as the account holds it

      Returns Uint8Array

    • read a .metadata from what toJSON gave, or a copy of it; the core checks every field

      Parameters

      • value: unknown

      Returns Metadata

      TypeError if value is not an object