Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UpdateManager

The UpdateManager is a helper object for a store. Just as a Fetcher provides the store with the ability to read and write, the Update Manager provides functionality for making small patches in real time, and also looking out for concurrent updates from other agents

Hierarchy

  • UpdateManager

Index

Constructors

constructor

Properties

fps

fps: {}

Type declaration

ifps

ifps: {}

Type declaration

ns

ns: any

Object of namespaces

patchControl

patchControl: []

Index of objects for coordinating incoming and outgoing patches

store

Methods

addDownstreamChangeListener

  • addDownstreamChangeListener(doc: NamedNode, listener: any): void

anonymize

  • anonymize(obj: any): any

anonymizeNT

  • anonymizeNT(stmt: Quad): string

clearUpstreamCount

  • We want to start counting websocket notifications to distinguish the ones from others from our own.

    Parameters

    Returns void

delete_statement

editable

  • Tests whether a file is editable. Files have to have a specific annotation that they are machine written, for safety. We don't actually check for write access on files.

    Parameters

    Returns string | boolean | undefined

    The method string SPARQL or DAV or LOCALFILE or false if known, undefined if not known.

getUpdatesVia

  • getUpdatesVia(doc: NamedNode): string | null

insert_statement

patchControlFor

put

  • put(doc: RDFlibNamedNode, data: string | Quad[], contentType: string, callback: (uri: string, ok: boolean, errorMessage?: undefined | string, response?: unknown) => void): Promise<void>
  • This is suitable for an initial creation of a document.

    Parameters

    • doc: RDFlibNamedNode
    • data: string | Quad[]
    • contentType: string
    • callback: (uri: string, ok: boolean, errorMessage?: undefined | string, response?: unknown) => void
        • (uri: string, ok: boolean, errorMessage?: undefined | string, response?: unknown): void
        • Parameters

          • uri: string
          • ok: boolean
          • Optional errorMessage: undefined | string
          • Optional response: unknown

          Returns void

    Returns Promise<void>

reload

  • Reloads a document.

    Fast and cheap, no metadata. Measure times for the document. Load it provisionally. Don't delete the statements before the load, or it will leave a broken document in the meantime.

    Parameters

    • kb: IndexedFormula
    • doc: docReloadType
    • callbackFunction: (ok: boolean, message?: undefined | string, response?: Error | Response) => {} | void
        • (ok: boolean, message?: undefined | string, response?: Error | Response): {} | void
        • Parameters

          • ok: boolean
          • Optional message: undefined | string
          • Optional response: Error | Response

          Returns {} | void

    Returns void

reloadAndSync

requestDownstreamAction

  • requestDownstreamAction(doc: NamedNode, action: any): void
  • Requests a now or future action to refresh changes coming downstream This is designed to allow the system to re-request the server version, when a websocket has pinged to say there are changes. If the websocket, by contrast, has sent a patch, then this may not be necessary.

    Parameters

    Returns void

serialize

  • serialize(uri: string, data: string | Quad[], contentType: string): string
  • throws

    {Error} On unsupported content type

    Parameters

    • uri: string
    • data: string | Quad[]
    • contentType: string

    Returns string

setRefreshHandler

  • setRefreshHandler(doc: NamedNode, handler: any): boolean
  • Sets up websocket to listen on

    There is coordination between upstream changes and downstream ones so that a reload is not done in the middle of an upstream patch. If you use this API then you get called when a change happens, and you have to reload the file yourself, and then refresh the UI. Alternative is addDownstreamChangeListener(), where you do not have to do the reload yourself. Do mot mix them.

    kb contains the HTTP metadata from previous operations

    Parameters

    Returns boolean

update

  • update(deletions: ReadonlyArray<Statement>, insertions: ReadonlyArray<Statement>, callback?: undefined | ((uri: string | undefined | null, success: boolean, errorBody?: undefined | string, response?: Response | Error) => void), secondTry?: undefined | false | true): void | Promise<void>
  • This high-level function updates the local store iff the web is changed successfully. Deletions, insertions may be undefined or single statements or lists or formulae (may contain bnodes which can be indirectly identified by a where clause). The why property of each statement must be the same and give the web document to be updated.

    Parameters

    • deletions: ReadonlyArray<Statement>

      Statement or statements to be deleted.

    • insertions: ReadonlyArray<Statement>

      Statement or statements to be inserted.

    • Optional callback: undefined | ((uri: string | undefined | null, success: boolean, errorBody?: undefined | string, response?: Response | Error) => void)

      called as callbackFunction(uri, success, errorbody) OR returns a promise

    • Optional secondTry: undefined | false | true

    Returns void | Promise<void>

updateDav

  • updateDav(doc: Quad_Subject, ds: any, is: any, callbackFunction: any): null | Promise<void>

updateLocalFile

  • updateLocalFile(doc: NamedNode, ds: any, is: any, callbackFunction: any): void
  • Likely deprecated, since this lib no longer deals with browser extension

    Parameters

    • doc: NamedNode
    • ds: any
    • is: any
    • callbackFunction: any

    Returns void

update_statement

  • update_statement(statement: Quad): undefined | { statement: undefined | Term[]; statementNT: undefined | string; where: string; set_object: any }
  • return a statemnet updating function

    This does NOT update the statement. It returns an object which includes function which can be used to change the object of the statement.

    Parameters

    Returns undefined | { statement: undefined | Term[]; statementNT: undefined | string; where: string; set_object: any }