Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

Agent

Agent: { email?: string; login: string; name?: string; webId: string }

Agent metadata related to pod generation.

Type declaration

  • Optional email?: string
  • login: string
  • Optional name?: string
  • webId: string

Guarded

Guarded<T>: T & Guard

A stream that is guarded from emitting errors when there are no listeners. If an error occurs while no listener is attached, it will store the error and emit it once a listener is added (or a timeout occurs).

Type parameters

  • T: NodeJS.EventEmitter = NodeJS.EventEmitter

HttpRequest

HttpRequest: Guarded<IncomingMessage>

An incoming HTTP request;

HttpResponse

HttpResponse: ServerResponse

An outgoing HTTP response;

LogLevel

LogLevel: "error" | "warn" | "info" | "verbose" | "debug" | "silly"

Different log levels, from most important to least important.

MetadataIdentifier

MetadataIdentifier: ResourceIdentifier | NamedNode | BlankNode

MetadataOverrideValue

MetadataOverrideValue: NamedNode | Literal | string | (NamedNode | Literal | string)[]

Namespace

Namespace<TKey, TValue>: PrefixResolver<TValue> & RecordOf<TKey, TValue>

Type parameters

  • TKey: any[]

  • TValue

ValuePreferences

ValuePreferences: Record<string, number>

Represents preferred values along a single content negotiation dimension.

The number represents how preferred this value is from 0 to 1. Follows the quality values rule from RFC 7231: "The weight is normalized to a real number in the range 0 through 1, where 0.001 is the least preferred and 1 is the most preferred; a value of 0 means "not acceptable"."

Variables

Const ACL

ACL: PrefixResolver<string> & Record<"default" | "accessTo" | "agent" | "agentClass" | "mode" | "Write" | "Read" | "Append" | "Control", string> & { terms: Namespace<typeof localNames, NamedNode> } = ...

Const APPLICATION_OCTET_STREAM

APPLICATION_OCTET_STREAM: "application/octet-stream" = 'application/octet-stream'

Const APPLICATION_SPARQL_UPDATE

APPLICATION_SPARQL_UPDATE: "application/sparql-update" = 'application/sparql-update'

Const CONTENT_TYPE

CONTENT_TYPE: string = ...

Const CONTENT_TYPE_TERM

CONTENT_TYPE_TERM: NamedNode<string> = ...

Const DC

DC: PrefixResolver<string> & Record<"modified", string> & { terms: Namespace<typeof localNames, NamedNode> } = ...

Const FOAF

FOAF: PrefixResolver<string> & Record<"Agent" | "AuthenticatedAgent", string> & { terms: Namespace<typeof localNames, NamedNode> } = ...

Const HTTP

HTTP: PrefixResolver<string> & Record<"location" | "slug", string> & { terms: Namespace<typeof localNames, NamedNode> } = ...

Const INTERNAL_ALL

INTERNAL_ALL: "internal/*" = 'internal/*'

Const INTERNAL_QUADS

INTERNAL_QUADS: "internal/quads" = 'internal/quads'

Const LDP

LDP: PrefixResolver<string> & Record<"contains" | "BasicContainer" | "Container" | "Resource", string> & { terms: Namespace<typeof localNames, NamedNode> } = ...

Const MA

MA: PrefixResolver<string> & Record<"format", string> & { terms: Namespace<typeof localNames, NamedNode> } = ...

Const PIM

PIM: PrefixResolver<string> & Record<"Storage", string> & { terms: Namespace<typeof localNames, NamedNode> } = ...

Const POSIX

POSIX: PrefixResolver<string> & Record<"mtime" | "size", string> & { terms: Namespace<typeof localNames, NamedNode> } = ...

Const RDF

RDF: PrefixResolver<string> & Record<"type", string> & { terms: Namespace<typeof localNames, NamedNode> } = ...

Const TEXT_TURTLE

TEXT_TURTLE: "text/turtle" = 'text/turtle'

Const XSD

XSD: PrefixResolver<string> & Record<"dateTime" | "integer", string> & { terms: Namespace<typeof localNames, NamedNode> } = ...

Functions

addHeader

  • addHeader(response: ServerResponse, name: string, value: string | string[]): void
  • Adds a header value without overriding previous values.

    Parameters

    • response: ServerResponse
    • name: string
    • value: string | string[]

    Returns void

createNamespace

  • createNamespace<TKey, TValue>(baseUri: string, toValue: (expanded: string) => TValue, ...localNames: TKey[]): Namespace<TKey[], TValue>
  • Creates a function that expands local names from the given base URI, and exports the given local names as properties on the returned object.

    Type parameters

    • TKey: string

    • TValue

    Parameters

    • baseUri: string
    • toValue: (expanded: string) => TValue
        • (expanded: string): TValue
        • Parameters

          • expanded: string

          Returns TValue

    • Rest ...localNames: TKey[]

    Returns Namespace<TKey[], TValue>

createTermNamespace

  • createTermNamespace<T>(baseUri: string, ...localNames: T[]): Namespace<T[], NamedNode<string>>
  • Creates a function that expands local names from the given base URI into named nodes, and exports the given local names as properties on the returned object.

    Type parameters

    • T: string

    Parameters

    • baseUri: string
    • Rest ...localNames: T[]

    Returns Namespace<T[], NamedNode<string>>

createUriAndTermNamespace

  • createUriAndTermNamespace<T>(baseUri: string, ...localNames: T[]): PrefixResolver<string> & Record<T, string> & { terms: Namespace<typeof localNames, NamedNode> }
  • Creates a function that expands local names from the given base URI into string, and exports the given local names as properties on the returned object. Under the terms property, it exposes the expanded local names as named nodes.

    Type parameters

    • T: string

    Parameters

    • baseUri: string
    • Rest ...localNames: T[]

    Returns PrefixResolver<string> & Record<T, string> & { terms: Namespace<typeof localNames, NamedNode> }

createUriNamespace

  • createUriNamespace<T>(baseUri: string, ...localNames: T[]): Namespace<T[], string>
  • Creates a function that expands local names from the given base URI into strings, and exports the given local names as properties on the returned object.

    Type parameters

    • T: string

    Parameters

    • baseUri: string
    • Rest ...localNames: T[]

    Returns Namespace<T[], string>

decodeUriPathComponents

  • decodeUriPathComponents(path: string): string

encodeUriPathComponents

  • encodeUriPathComponents(path: string): string
  • Encodes all (non-slash) special characters in a URI path.

    Parameters

    • path: string

    Returns string

ensureTrailingSlash

  • ensureTrailingSlash(path: string): string
  • Makes sure the input path has exactly 1 slash at the end. Multiple slashes will get merged into one. If there is no slash it will be added.

    Parameters

    • path: string

      Path to check.

    Returns string

    The potentially changed path.

getLoggerFor

  • getLoggerFor(loggable: string | Instance): Logger
  • Gets a logger instance for the given class instance.

    The returned type of logger depends on the configured LoggerFactory in {@link Setup}.

    The following shows a typical pattern on how to create loggers:

    class MyClass {
      protected readonly logger = getLoggerFor(this);
    }
    

    If no class is applicable, a logger can also be created as follows:

    const logger = getLoggerFor('MyFunction');
    

    Parameters

    • loggable: string | Instance

      A class instance or a class string name.

    Returns Logger

guardStream

  • guardStream<T>(stream: T): Guarded<T>
  • Makes sure that listeners always receive the error event of a stream, even if it was thrown before the listener was attached. If the input is already guarded nothing will happen.

    Type parameters

    • T: EventEmitter<T>

    Parameters

    • stream: T

      Stream that can potentially throw an error.

    Returns Guarded<T>

    The stream.

guardedStreamFrom

  • guardedStreamFrom(iterable: Iterable<any>, options?: ReadableOptions): Guarded<Readable>
  • Converts an iterable to a stream and applies an error guard so that it is Guarded.

    Parameters

    • iterable: Iterable<any>

      Data to stream.

    • Optional options: ReadableOptions

      Options to pass to the Readable constructor. See {@link Readable.from}.

    Returns Guarded<Readable>

isContainerIdentifier

isContainerPath

  • isContainerPath(path: string): boolean
  • Checks if the path corresponds to a container path (ending in a /).

    Parameters

    • path: string

      Path to check.

    Returns boolean

isGuarded

  • isGuarded<T>(stream: T): stream is Guarded<T>
  • Determines whether the stream is guarded from emitting errors.

    Type parameters

    • T: EventEmitter<T>

    Parameters

    • stream: T

    Returns stream is Guarded<T>

isRepresentationMetadata

isResourceIdentifier

isSystemError

isTerm

  • isTerm(input?: any): input is Term
  • Parameters

    • Optional input: any

      Checks if this is a {@link Term}.

    Returns input is Term

joinFilePath

  • joinFilePath(basePath: string, ...paths: string[]): string
  • Adds the paths to the base path.

    Parameters

    • basePath: string

      The base path (POSIX or Windows).

    • Rest ...paths: string[]

      Subpaths to attach (POSIX).

    Returns string

    The potentially changed path (POSIX).

matchesMediaType

  • matchesMediaType(mediaA: string, mediaB: string): boolean
  • Checks if the given two media types/ranges match each other. Takes wildcards into account.

    Parameters

    • mediaA: string

      Media type to match.

    • mediaB: string

      Media type to match.

    Returns boolean

    True if the media type patterns can match each other.

matchingMediaTypes

  • matchingMediaTypes(preferredTypes?: Record<string, number>, availableTypes?: Record<string, number>): string[]
  • Filters media types based on the given preferences. Based on RFC 7231 - Content negotiation. Will add a default internal/*;q=0 to the preferences to prevent accidental use of internal types. Since more specific media ranges override less specific ones, this will be ignored if there is a specific internal type preference.

    throws

    BadRequestHttpError If the type preferences are undefined or if there are duplicate preferences.

    Parameters

    • preferredTypes: Record<string, number> = ...

      Preferences for output type.

    • availableTypes: Record<string, number> = ...

      Media types to compare to the preferences.

    Returns string[]

    The weighted and filtered list of matching types.

normalizeFilePath

  • normalizeFilePath(path: string): string
  • Resolves relative segments in the path/

    Parameters

    • path: string

      Path to check (POSIX or Windows).

    Returns string

    The potentially changed path (POSIX).

parseAccept

  • parseAccept(input: string): Accept[]

parseAcceptCharset

parseAcceptDateTime

parseAcceptEncoding

parseAcceptLanguage

parseForwarded

  • Parses a Forwarded header value.

    Parameters

    • value: string = ''

      The Forwarded header value.

    Returns Forwarded

    The parsed Forwarded header.

parseParameters

  • parseParameters(parameters: string[], replacements: Record<string, string>): { name: string; value: string }[]
  • Parses a list of split parameters and checks their validity.

    throws

    BadRequestHttpError Thrown on invalid parameter syntax.

    Parameters

    • parameters: string[]

      A list of split parameters (token [ "=" ( token / quoted-string ) ])

    • replacements: Record<string, string>

      The double quoted strings that need to be replaced.

    Returns { name: string; value: string }[]

    An array of name/value objects corresponding to the parameters.

parseQuads

  • parseQuads(readable: Guarded<Readable>, contentType?: string): Promise<Quad[]>
  • Helper function to convert a Readable into an array of quads.

    Parameters

    • readable: Guarded<Readable>

      The readable object.

    • Optional contentType: string

      The content-type of the stream.

    Returns Promise<Quad[]>

    A promise containing the array of quads.

pipeSafely

  • pipeSafely<T>(readable: ReadableStream, destination: T, mapError?: (error: Error) => Error): Guarded<T>
  • Pipes one stream into another and emits errors of the first stream with the second. In case of an error in the first stream the second one will be destroyed with the given error. This will also make the stream Guarded.

    Type parameters

    • T: Writable<T>

    Parameters

    • readable: ReadableStream

      Initial readable stream.

    • destination: T

      The destination for writing data.

    • Optional mapError: (error: Error) => Error

      Optional function that takes the error and converts it to a new error.

        • (error: Error): Error
        • Parameters

          • error: Error

          Returns Error

    Returns Guarded<T>

    The destination stream.

pushQuad

  • pushQuad(quads: Quad[] | PassThrough, subject: string | NamedNode<string>, predicate: string | NamedNode<string>, object: string | Literal | NamedNode<string>): void
  • Generates a quad with the given subject/predicate/object and pushes it to the given array.

    Parameters

    • quads: Quad[] | PassThrough
    • subject: string | NamedNode<string>
    • predicate: string | NamedNode<string>
    • object: string | Literal | NamedNode<string>

    Returns void

readableToString

  • readableToString(stream: Readable): Promise<string>
  • Joins all strings of a stream.

    Parameters

    • stream: Readable

      Stream of strings.

    Returns Promise<string>

    The joined string.

resetGlobalLoggerFactory

  • resetGlobalLoggerFactory(): void
  • Resets the global logger factory to undefined.

    This typically only needs to be called during testing. Call this at your own risk.

    Returns void

serializeQuads

  • serializeQuads(quads: Quad[], contentType?: string): Guarded<Readable>
  • Helper function for serializing an array of quads, with as result a Readable object.

    Parameters

    • quads: Quad[]

      The array of quads.

    • Optional contentType: string

      The content-type to serialize to.

    Returns Guarded<Readable>

    The Readable object.

setGlobalLoggerFactory

splitAndClean

  • splitAndClean(input: string): string[]
  • Splits the input string on commas, trims all parts and filters out empty ones.

    Parameters

    • input: string

      Input header string.

    Returns string[]

supportsMediaTypeConversion

  • supportsMediaTypeConversion(inputType?: string, outputTypes?: Record<string, number>, convertorIn?: Record<string, number>, convertorOut?: Record<string, number>): void
  • Determines whether the given conversion request is supported, given the available content type conversions:

    • Checks if there is a content type for the input.
    • Checks if the input type is supported by the parser.
    • Checks if the parser can produce one of the preferred output types. Throws an error with details if conversion is not possible.

    Parameters

    • inputType: string = 'unknown'

      Actual input type.

    • outputTypes: Record<string, number> = ...

      Acceptable output types.

    • convertorIn: Record<string, number> = ...

      Media types that can be parsed by the converter.

    • convertorOut: Record<string, number> = ...

      Media types that can be produced by the converter.

    Returns void

toCachedNamedNode

  • toCachedNamedNode(name: string | NamedNode<string>): NamedNode<string>
  • Converts the incoming name (URI or shorthand) to a named node. The generated terms get cached to reduce the number of created nodes, so only use this for internal constants!

    Parameters

    • name: string | NamedNode<string>

      Predicate to potentially transform.

    Returns NamedNode<string>

toCanonicalUriPath

  • toCanonicalUriPath(path: string): string
  • Converts a URI path to the canonical version by splitting on slashes, decoding any percent-based encodings, and then encoding any special characters.

    Parameters

    • path: string

    Returns string

toLiteral

  • toLiteral(object: string | number, dataType: NamedNode<string>): Literal
  • Creates a literal by first converting the dataType string to a named node.

    Parameters

    • object: string | number

      Object value.

    • dataType: NamedNode<string>

      Object data type (as string).

    Returns Literal

toObjectTerm

  • toObjectTerm<T>(object: string | T, preferLiteral?: boolean): T
  • Converts an object term when needed.

    Type parameters

    • T: Term

    Parameters

    • object: string | T

      Object to potentially transform.

    • preferLiteral: boolean = false

      Whether strings are converted to literals or named nodes.

    Returns T

Const toPredicateTerm

  • toPredicateTerm(subject: string | NamedNode<string>): NamedNode<string>

toSubjectTerm

  • toSubjectTerm(subject: string | NamedNode<string>): NamedNode<string>
  • Converts a subject to a named node when needed.

    Parameters

    • subject: string | NamedNode<string>

      Subject to potentially transform.

    Returns NamedNode<string>

toSystemFilePath

  • toSystemFilePath(path: string): string
  • Converts the path into an OS-dependent path.

    Parameters

    • path: string

      Path to check (POSIX).

    Returns string

    The potentially changed path (OS-dependent).

transformQuotedStrings

  • transformQuotedStrings(input: string): { replacements: Record<string, string>; result: string }
  • Replaces all double quoted strings in the input string with "0", "1", etc.

    Parameters

    • input: string

      The Accept header string.

    Returns { replacements: Record<string, string>; result: string }

    The transformed string and a map with keys "0", etc. and values the original string that was there.

    • replacements: Record<string, string>
    • result: string

trimTrailingSlashes

  • trimTrailingSlashes(path: string): string
  • Makes sure the input path has no slashes at the end.

    Parameters

    • path: string

      Path to check.

    Returns string

    The potentially changed path.