Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Classes

Interfaces

Type aliases

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

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)[]

Functions

Const 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

Const decodeUriPathComponents

  • decodeUriPathComponents(path: string): string

Const encodeUriPathComponents

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

    Parameters

    • path: string

    Returns string

Const 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.

Const 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

Const 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>

Const isContainerIdentifier

Const 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

Const isRepresentationMetadata

Const isResourceIdentifier

Const isSystemError

Const parseAccept

  • parseAccept(input: string): Accept[]

Const parseAcceptCharset

Const parseAcceptEncoding

Const parseAcceptLanguage

Const parseForwarded

  • Parses a Forwarded header value.

    Parameters

    • value: string = ''

      The Forwarded header value.

    Returns Forwarded

    The parsed Forwarded header.

Const 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.

Const 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.

Const 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.

Const pushQuad

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

    Parameters

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

    Returns number

Const readableToString

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

    Parameters

    • stream: Readable

      Stream of strings.

    Returns Promise<string>

    The joined string.

Const 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

Const 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.

Const setGlobalLoggerFactory

Const 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[]

Const 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

Const 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

Const 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.