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

      store: UpdateManagerFormula

      Methods

      addDownstreamChangeListener

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

      anonymize

      • anonymize(obj: any): any

      anonymizeNT

      • anonymizeNT(stmt: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>): string
      • Parameters

        • stmt: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>

        Returns string

      clearUpstreamCount

      • clearUpstreamCount(doc: NamedNode): void
      • We want to start counting websocket notifications to distinguish the ones from others from our own.

        Parameters

        • doc: NamedNode

        Returns void

      delete_statement

      • delete_statement(st: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph> | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[], callbackFunction: CallBackFunction): void
      • Parameters

        • st: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph> | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]
        • callbackFunction: CallBackFunction

        Returns void

      editable

      • editable(uri: string | NamedNode, kb?: Store): undefined | string | boolean
      • Tests whether a file is editable. If the file has a specific annotation that it is machine written, for safety, it is editable (this doesn't actually check for write access) If the file has wac-allow and accept patch headers, those are respected. and local write access is determined by those headers. This version only looks at past HTTP requests, does not make new ones.

        Parameters

        • uri: string | NamedNode
        • Optional kb: Store

        Returns undefined | string | boolean

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

      getUpdatesVia

      • getUpdatesVia(doc: NamedNode): null | string

      insert_statement

      • insert_statement(st: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>, callbackFunction: CallBackFunction): void
      • Parameters

        • st: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>
        • callbackFunction: CallBackFunction

        Returns void

      isHttpUri

      • isHttpUri(uri: string): boolean

      patchControlFor

      • patchControlFor(doc: NamedNode): any

      put

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

        Parameters

        • doc: NamedNode
        • data: string | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]
        • contentType: string
        • callback: (uri: string, ok: boolean, errorMessage?: string, response?: unknown) => void
            • (uri: string, ok: boolean, errorMessage?: string, response?: unknown): void
            • Parameters

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

              Returns void

        Returns Promise<void>

      reload

      • reload(kb: Store, doc: docReloadType, callbackFunction: (ok: boolean, message?: string, response?: Response | Error) => void | {}): void
      • 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: Store
        • doc: docReloadType
        • callbackFunction: (ok: boolean, message?: string, response?: Response | Error) => void | {}
            • (ok: boolean, message?: string, response?: Response | Error): void | {}
            • Parameters

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

              Returns void | {}

        Returns void

      reloadAndSync

      • reloadAndSync(doc: NamedNode): void

      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

        • doc: NamedNode
        • action: any

        Returns void

      serialize

      • serialize(uri: string, data: string | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[], contentType: string): string
      • throws

        {Error} On unsupported content type

        Parameters

        • uri: string
        • data: string | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]
        • 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

        • doc: NamedNode
        • handler: any

        Returns boolean

      update

      • update(deletions: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[], insertions: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[], callback?: (uri: undefined | null | string, success: boolean, errorBody?: string, response?: Response | Error) => void, secondTry?: boolean): 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: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

          Statement or statements to be deleted.

        • insertions: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

          Statement or statements to be inserted.

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

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

            • (uri: undefined | null | string, success: boolean, errorBody?: string, response?: Response | Error): void
            • Parameters

              • uri: undefined | null | string
              • success: boolean
              • Optional errorBody: string
              • Optional response: Response | Error

              Returns void

        • Optional secondTry: boolean

        Returns void | Promise<void>

      updateDav

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

        • doc: Quad_Subject
        • ds: any
        • is: any
        • callbackFunction: any

        Returns 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

      updateMany

      • updateMany(deletions: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[], insertions?: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[]): 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 give the web document to be updated. The statements to be deleted and inserted may span more than one web document.

        Parameters

        • deletions: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

          Statement or statements to be deleted.

        • insertions: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[] = []

          Statement or statements to be inserted.

        Returns Promise<void[]>

        a promise

      update_statement

      • update_statement(statement: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>): undefined | { set_object: (obj: any, callbackFunction: any) => void; statement: undefined | Term[]; statementNT: undefined | string; where: string }
      • 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

        • statement: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>

        Returns undefined | { set_object: (obj: any, callbackFunction: any) => void; statement: undefined | Term[]; statementNT: undefined | string; where: string }

      Generated using TypeDoc