Comunica
    Preparing search index...

    An HTTP service that exposes a Comunica engine as a SPARQL endpoint.

    Index

    Constructors

    Properties

    context: any
    contextOverride: boolean
    emitVoid: boolean
    engine: Promise<
        QueryEngineBase<
            IQueryContextCommon,
            QueryStringContext,
            QueryAlgebraContext,
        >,
    >
    freshWorkerPerQuery: boolean
    lastQueryId: number = 0
    port: number
    timeout: number
    voidMetadataEmitter: VoidMetadataEmitter
    workers: number
    ALLOWED_METHODS: "GET, HEAD, OPTIONS, POST, QUERY" = 'GET, HEAD, OPTIONS, POST, QUERY'

    The HTTP methods this service handles, as advertised via the Allow and Access-Control-Allow-Methods headers.

    MIME_HTML: "text/html" = 'text/html'
    MIME_JSON: "application/json" = 'application/json'
    MIME_PLAIN: "text/plain" = 'text/plain'
    MIME_SPARQL_QUERY: "application/sparql-query" = 'application/sparql-query'

    The query format that is accepted in the body of HTTP QUERY requests (RFC 10008).

    Methods

    • Apply the dataset that a request specifies through the SPARQL protocol to the query it contains. The query is returned unchanged if the request does not specify a dataset.

      Parameters

      • engine: QueryEngineBase

        A SPARQL engine.

      • queryBody: IQueryBody

        The query body.

      • requestUrl: UrlWithParsedQuery

        The parsed request URL.

      • context: Record<string, any>

        The query context.

      Returns Promise<string | BaseOperation>

      The query to execute.

    • Handles an HTTP request.

      Parameters

      • engine: QueryEngineBase

        A SPARQL engine.

      • variants: { quality: number; type: string }[]

        Allowed variants.

      • stdout: Writable

        Output stream.

      • stderr: Writable

        Error output stream.

      • request: IncomingMessage

        Request object.

      • response: ServerResponse

        Response object.

      Returns Promise<void>

    • Start the HTTP service.

      Parameters

      • stdout: Writable

        The output stream to log to.

      • stderr: Writable

        The error stream to log errors to.

      Returns Promise<void>

    • Start the HTTP service as master.

      Parameters

      • stdout: Writable

        The output stream to log to.

      • stderr: Writable

        The error stream to log errors to.

      Returns Promise<void>

    • Start the HTTP service as worker.

      Parameters

      • stdout: Writable

        The output stream to log to.

      • stderr: Writable

        The error stream to log errors to.

      Returns Promise<void>

    • Stop after timeout or if the connection is terminated

      Parameters

      • response: ServerResponse

        Response object.

      • queryId: number

        The unique query id.

      • stderr: Writable

        Error stream to write to.

      • OptionaleventEmitter: EventEmitter<DefaultEventMap>

        Query result stream.

      Returns void

    • Writes a 400 response with the given message.

      Parameters

      • stdout: Writable

        Output stream.

      • response: ServerResponse

        Response object.

      • message: string

        The reason why the request was rejected.

      Returns void

    • Writes an HTML view with YASGUI for querying the endpoint.

      Parameters

      • stdout: Writable

        Output stream.

      • request: IncomingMessage

        Request object.

      • response: ServerResponse

        Response object.

      Returns Promise<void>

    • Writes the result of the given SPARQL query.

      Parameters

      • engine: QueryEngineBase

        A SPARQL engine.

      • stdout: Writable

        Output stream.

      • stderr: Writable

        Error output stream.

      • request: IncomingMessage

        Request object.

      • response: ServerResponse

        Response object.

      • queryBody: IQueryBody | undefined

        The query body.

      • mediaType: string

        The requested response media type.

      • headOnly: boolean

        If only the header should be written.

      • readOnly: boolean

        If only data can be read, but not updated. (i.e., if we're in a GET request)

      • queryId: number

        The unique id of this query.

      Returns Promise<void>

    • Parameters

      • engine: QueryEngineBase
      • stdout: Writable
      • stderr: Writable
      • request: IncomingMessage
      • response: ServerResponse
      • mediaType: string
      • headOnly: boolean

      Returns Promise<void>

    • Apply the protocol-specified dataset to the WHERE clauses of an update operation.

      Parameters

      • algebraFactory: AlgebraFactory

        An algebra factory.

      • operation: BaseOperation

        An update operation.

      • dataset: { default: NamedNode<string>[]; named: NamedNode<string>[] }

        The protocol-specified dataset.

        • default: NamedNode<string>[]

          The graphs that form the default graph.

        • named: NamedNode<string>[]

          The named graphs.

      Returns BaseOperation

      The update operation with the dataset applied.

    • Takes parsed commandline arguments and turns them into an object used in the HttpServiceSparqlEndpoint constructor

      Parameters

      • argv: string[]

        The commandline arguments that the script was called with

      • moduleRootPath: string

        The path to the invoking module.

      • env: ProcessEnv

        The process env to get constants from.

      • defaultConfigPath: string

        The path to get the config from if none is defined in the environment.

      • stderr: Writable

        The error stream.

      • exit: (code: number) => void

        An exit process callback.

      • cliArgsHandlers: ICliArgsHandler[]

        Enables manipulation of the CLI arguments and their processing.

      Returns Promise<IHttpServiceSparqlEndpointArgs>

    • Determine the base IRI that relative IRIs in a request are resolved against.

      Parameters

      • request: IncomingMessage

        Request object.

      • port: number

        The port this service is running on.

      Returns string

      The base IRI.

    • Determines the headers with which this service advertises the HTTP methods and query formats it supports.

      Parameters

      • headers: Record<string, string>

        The headers to extend.

      Returns Record<string, string>

      The given headers, extended with the method advertisement headers.

    • Determine the RDF dataset that a request specifies through the SPARQL protocol.

      Parameters

      • requestUrl: UrlWithParsedQuery

        The parsed request URL.

      • type: "query" | "void"

        The type of operation the dataset applies to.

      Returns { default: NamedNode<string>[]; named: NamedNode<string>[] }

      The graphs that form the default graph, and the named graphs.

    • Reads the body of a request as a UTF-8 string.

      Parameters

      • request: IncomingMessage

        Request object.

      Returns Promise<string>

      A promise resolving to the request body.

    • Starts the server

      Parameters

      • argv: string[]

        The commandline arguments that the script was called with

      • stdout: Writable

        The output stream to log to.

      • stderr: Writable

        The error stream to log errors to.

      • moduleRootPath: string

        The path to the invoking module.

      • env: ProcessEnv

        The process env to get constants from.

      • defaultConfigPath: string

        The path to get the config from if none is defined in the environment.

      • exit: (code: number) => void

        The callback to invoke to stop the script.

      • cliArgsHandlers: ICliArgsHandler[] = []

        Enables manipulation of the CLI arguments and their processing.

      Returns Promise<void>

      A promise that resolves when the server has been started.