solid-ui
    Preparing search index...

    Class Fetcher

    Fetcher

    The Fetcher object is a helper object for a quadstore which turns it from an offline store to an online store. The fetcher deals with loading data files rom the web,

    • figuring how to parse them. It will also refresh, remove, the data
    • and put back the data to the web.

    Implements

    • CallbackifyInterface
    Index

    Constructors

    Properties

    _fetch: Fetch
    appNode: NamedNode

    Denoting this session

    fetchCallbacks: FetchCallbacks

    fetchCallbacks[uri].push(callback)

    fetchQueue: FetchQueue
    fireCallbacks: Function

    Methods added by calling Util.callbackify in the constructor

    handlers: typeof Handler[]
    lookedUp: BooleanMap
    mediatypes: MediatypesMap
    nonexistent: BooleanMap

    Keep track of explicit 404s -> we can overwrite etc

    ns: { [k: string]: (ln: string) => Quad_Predicate }
    redirectedTo: Record<string, string>

    Redirected from key uri to value uri

    requested: RequestedMap

    this.requested[uri] states: undefined no record of web access or records reset true has been requested, fetch in progress 'done' received, Ok 401 Not logged in 403 HTTP status unauthorized 404 Resource does not exist. Can be created etc. 'redirected' In attempt to counter CORS problems retried. 'parse_error' Parse error 'unsupported_protocol' URI is not a protocol Fetcher can deal with other strings mean various other errors.

    store: Store
    timeout: number
    timeouts: TimeOutsMap

    List of timeouts associated with a requested URL

    CONTENT_TYPE_BY_EXT: Record<string, string>
    crossSiteProxyTemplate: any
    HANDLERS: { [handlerName: number]: Handler }

    Methods

    • Returns string

    • Parameters

      • uri: string
      • callback: UserCallback

      Returns void

    • Parameters

      • handler: typeof Handler

      Returns void

    • Records a status message (as a literal node) by appending it to the request's metadata status collection.

      Parameters

      • req: BlankNode
      • statusMessage: string

      Returns void

    • Parameters

      • rdfType: NamedNode
      • req: Quad_Subject
      • kb: Store
      • locURI: string

      Returns void

    • Parameters

      • originalUri: string
      • _options: any

        DEPRECATED

      • timeout: number

      Returns void

    • Parameters

      • parentURI: string

        URI of parent container

      • folderName: string

        Optional folder name (slug)

      • data: string

        Optional folder metadata

      Returns Promise<Response>

    • Create an empty resource if it really does not exist Be absolutely sure something does not exist before creating a new empty file as otherwise existing could be deleted.

      Parameters

      • doc: NamedNode

        The resource

      • OptionalcontentType: "text/turtle"
      • Optionaldata: string

      Returns Promise<ExtendedResponse>

    • Parameters

      Returns Response

    • Records errors in the system on failure:

      • Adds an entry to the request status collection
      • Adds an error triple with the fail message to the metadata
      • Fires the 'fail' callback
      • Rejects with an error result object, which has a response object if any

      Parameters

      • options: { original: Quad_Subject; req: BlankNode } & Partial<AutoInitOptions>
      • errorMessage: string
      • statusCode: StatusValues
      • Optionalresponse: ExtendedResponse

      Returns Promise<FetchError>

    • Looks up response header.

      Parameters

      • doc: NamedNode
      • header: string

      Returns undefined | string[]

      a list of header values found in a stored HTTP response, or [] if response was found but no header found, or undefined if no response is available. Looks for { [] link:requestedURI ?uri; link:response [ httph:header-name ?value ] }

    • Parameters

      • docuri: string

      Returns any

    • Parameters

      • uri: string

      Returns undefined | ContentType

    • Parameters

      Returns null | Handler

    • Parameters

      • uri: string
      • options: Options

      Returns AutoInitOptions

    • Parameters

      • iri: string | NamedNode

      Returns void

    • Tests whether a request is being made to a cross-site URI (for purposes of retrying with a proxy)

      Parameters

      • uri: string

      Returns boolean

    • Parameters

      • docuri: string

      Returns boolean

    • Parameters

      • originalUri: NamedNode
      • rel: string
      • uri: string
      • why: Quad_Graph
      • Optionalreverse: boolean

      Returns void

    • Promise-based load function

      Loads a web resource or resources into the store.

      A resource may be given as NamedNode object, or as a plain URI. an array of resources will be given, in which they will be fetched in parallel. By default, the HTTP headers are recorded also, in the same store, in a separate graph. This allows code like editable() for example to test things about the resource.

      Type Parameters

      • T extends string | NamedNode | (string | NamedNode)[]

      Parameters

      • uri: T

        {Array|Array|RDFlibNamedNode|string}

      • Optionaloptions: Partial<AutoInitOptions>

        {Object}

        • fetch

          {Function}

        • referringTerm

          {RDFlibNamedNode} Referring term, the resource which referred to this (for tracking bad links)

        • contentType

          {string} Provided content type (for writes)

        • forceContentType

          {string} Override the incoming header to force the data to be treated as this content-type (for reads)

        • force

          {boolean} Load the data even if loaded before. Also sets the Cache-Control: header to no-cache

        • baseURI

          {Node|string} Original uri to preserve through proxying etc (xhr.original).

        • proxyUsed

          {boolean} Whether this request is a retry via a proxy (generally done from an error handler)

        • withCredentials

          {boolean} flag for XHR/CORS etc

        • clearPreviousData

          {boolean} Before we parse new data, clear old, but only on status 200 responses

        • noMeta

          {boolean} Prevents the addition of various metadata triples (about the fetch request) to the store

        • noRDFa

          {boolean}

      Returns T extends (string | NamedNode)[] ? Promise<Response[]> : Promise<Response>

    • Looks up something. Looks up all the URIs a things has.

      Parameters

      • term: Quad_Subject

        canonical term for the thing whose URI is to be dereferenced

      • rterm: Quad_Subject

        the resource which referred to this (for tracking bad links)

      Returns Promise<Response> | Promise<Response>[]

    • Parameters

      Returns null | string

    • Note two nodes are now smushed If only one was flagged as looked up, then the new node is looked up again, which will make sure all the URIs are dereferenced

      Parameters

      • was: Quad_Subject
      • now: Quad_Subject

      Returns void

    • Asks for a doc to be loaded if necessary then calls back

      Calling methods: nowOrWhenFetched (uri, userCallback) nowOrWhenFetched (uri, options, userCallback) nowOrWhenFetched (uri, referringTerm, userCallback, options) <-- old nowOrWhenFetched (uri, referringTerm, userCallback) <-- old

      Options include: referringTerm The document in which this link was found. this is valuable when finding the source of bad URIs force boolean. Never mind whether you have tried before, load this from scratch. forceContentType Override the incoming header to force the data to be treated as this content-type.

      Callback function takes:

      ok True if the fetch worked, and got a 200 response. False if any error happened

      errmessage Text error message if not OK.

      response The fetch Response object (was: XHR) if there was was one includes response.status as the HTTP status if any.

      Parameters

      • uriIn: string | NamedNode
      • Optionalp2: Partial<AutoInitOptions> | UserCallback
      • OptionaluserCallback: UserCallback
      • Optionaloptions: Partial<AutoInitOptions>

      Returns void

    • Parameters

      • term: NamedNode

      Returns void

    • Parameters

      • linkHeader: string
      • originalUri: NamedNode
      • reqNode: Quad_Graph

      Returns void

    • Parameters

      Returns Promise<Response>

    • Writes back to the web what we have in the store for this uri

      Parameters

      Returns Promise<Response>

    • Parameters

      • term: NamedNode
      • OptionaluserCallback: UserCallback

      Returns void

    • Parameters

      • term: NamedNode
      • userCallback: UserCallback

      Returns void

    • Parameters

      • term: Quad_Graph

      Returns void

    • Parameters

      • docuri: string
      • options: any

      Returns Promise<Response>

    • Parameters

      Returns Promise<void>

    • Parameters

      Returns void

    • Parameters

      • response: Response
      • options: { req: BlankNode; resource: Quad_Subject } & Partial<AutoInitOptions>

      Returns BlankNode

    • Parameters

      • uri: string
      • options: { original: Quad_Subject; req: Quad_Subject } & Partial<AutoInitOptions>

      Returns Promise<number | FetchError>

    • Parameters

      • term: NamedNode

      Returns void

    • Parameters

      • here: string
      • there: string
      • contentType: any

      Returns Promise<ExtendedResponse>

    • A generic web operation, at the fetch() level. does not involve the quad store.

      Returns promise of Response If data is returned, copies it to response.responseText before returning

      Parameters

      • method: HTTPMethods
      • uriIn: string | NamedNode
      • Optionaloptions: Partial<AutoInitOptions>

      Returns Promise<ExtendedResponse>

    • Parameters

      • uri: string

      Returns any

    • Parameters

      • uri: string

      Returns string

    • Parameters

      • uri: string

      Returns any

    • Decide on credentials using old XXHR api or new fetch() one

      Parameters

      Returns void

    • Tests whether the uri's protocol is supported by the Fetcher.

      Parameters

      • uri: string

      Returns boolean