Options
All
  • Public
  • Public/Protected
  • All
Menu

Community Solid Server - v4.0.1

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

CredentialSet: Partial<Record<CredentialGroup, Credential>>

A combination of multiple credentials, where their group is specified by the key.

Expires<T>: { expires?: string; payload: T }

Type parameters

  • T

Type declaration

  • Optional expires?: string
  • payload: T
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: Guarded<IncomingMessage>

An incoming HTTP request;

HttpResponse: ServerResponse

An outgoing HTTP response;

Interaction: NonNullable<KoaContextWithOIDC["oidc"]["entities"]["Interaction"]>
LogLevel: typeof LOG_LEVELS[number]

Different log levels, from most important to least important.

MetadataGraph: NamedNode | BlankNode | DefaultGraph | string
MetadataIdentifier: ResourceIdentifier | NamedNode | BlankNode
MetadataRecord: Record<string, MetadataValue>
MetadataValue: NamedNode | Literal | string | (NamedNode | Literal | string)[]
Namespace<TKey, TValue>: { namespace: TValue } & RecordOf<TKey, TValue>

Type parameters

  • TKey: any[]

  • TValue

PatchHandlerInput<T>: { identifier: ResourceIdentifier; patch: Patch; source: T }

Type parameters

Type declaration

Permission: Partial<Record<AccessMode, boolean>>

A data interface indicating which permissions are required (based on the context).

PermissionSet: Partial<Record<CredentialGroup, Permission>>
TemplateFileName: string
ValidatorInput: { identifier: ResourceIdentifier; representation: Representation }

Type declaration

ValuePreference: { value: string; weight: number }

A single entry of a ValuePreferences object. Useful when doing operations on such an object.

Type declaration

  • value: string
  • weight: number
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"."

YargsArgOptions: Record<string, Options>

Variables

ACL: { namespace: string } & RecordOf<("default" | "accessTo" | "agent" | "agentClass" | "agentGroup" | "AuthenticatedAgent" | "Authorization" | "mode" | "Write" | "Read" | "Append" | "Control")[], string> & { terms: Namespace<("default" | "accessTo" | "agent" | "agentClass" | "agentGroup" | "AuthenticatedAgent" | "Authorization" | "mode" | "Write" | "Read" | "Append" | "Control")[], NamedNode<string>> } = ...
APPLICATION_JSON: "application/json" = 'application/json'
APPLICATION_OCTET_STREAM: "application/octet-stream" = 'application/octet-stream'
APPLICATION_SPARQL_UPDATE: "application/sparql-update" = 'application/sparql-update'
APPLICATION_X_WWW_FORM_URLENCODED: "application/x-www-form-urlencoded" = 'application/x-www-form-urlencoded'
AUTH: { namespace: string } & RecordOf<("userMode" | "publicMode")[], string> & { terms: Namespace<("userMode" | "publicMode")[], NamedNode<string>> } = ...
CONTENT_LENGTH_TERM: NamedNode<string> = ...
CONTENT_TYPE: string = MA.format
CONTENT_TYPE_TERM: NamedNode<string> = MA.terms.format
DC: { namespace: string } & RecordOf<("description" | "modified" | "title")[], string> & { terms: Namespace<("description" | "modified" | "title")[], NamedNode<string>> } = ...
DEFAULT_CUSTOM_TYPES: { acl: string; meta: string } = ...

Type declaration

  • acl: string
  • meta: string
FOAF: { namespace: string } & RecordOf<"Agent"[], string> & { terms: Namespace<"Agent"[], NamedNode<string>> } = ...
HH: { namespace: string } & RecordOf<"content-length"[], string> & { terms: Namespace<"content-length"[], NamedNode<string>> } = ...
HTTP: { namespace: string } & RecordOf<"statusCodeNumber"[], string> & { terms: Namespace<"statusCodeNumber"[], NamedNode<string>> } = ...
IANA: { namespace: string } & RecordOf<string[], string> & { terms: Namespace<string[], NamedNode<string>> } = ...
INTERNAL_ALL: "internal/*" = 'internal/*'
INTERNAL_ERROR: "internal/error" = 'internal/error'
INTERNAL_QUADS: "internal/quads" = 'internal/quads'
JSON_LD: { namespace: string } & RecordOf<"context"[], string> & { terms: Namespace<"context"[], NamedNode<string>> } = ...
LDP: { namespace: string } & RecordOf<("contains" | "BasicContainer" | "Container" | "Resource")[], string> & { terms: Namespace<("contains" | "BasicContainer" | "Container" | "Resource")[], NamedNode<string>> } = ...
LOG_LEVELS: readonly ["error", "warn", "info", "verbose", "debug", "silly"] = ...
MA: { namespace: string } & RecordOf<"format"[], string> & { terms: Namespace<"format"[], NamedNode<string>> } = ...
OIDC: { namespace: string } & RecordOf<"redirect_uris"[], string> & { terms: Namespace<"redirect_uris"[], NamedNode<string>> } = ...
PIM: { namespace: string } & RecordOf<"Storage"[], string> & { terms: Namespace<"Storage"[], NamedNode<string>> } = ...
POSIX: { namespace: string } & RecordOf<("mtime" | "size")[], string> & { terms: Namespace<("mtime" | "size")[], NamedNode<string>> } = ...
PREFERRED_PREFIX: string = VANN.preferredNamespacePrefix
PREFERRED_PREFIX_TERM: NamedNode<string> = VANN.terms.preferredNamespacePrefix
RDF: { namespace: string } & RecordOf<"type"[], string> & { terms: Namespace<"type"[], NamedNode<string>> } = ...
RDFS: { namespace: string } & RecordOf<"label"[], string> & { terms: Namespace<"label"[], NamedNode<string>> } = ...
SOLID: { namespace: string } & RecordOf<("deletes" | "inserts" | "oidcIssuer" | "oidcIssuerRegistrationToken" | "oidcRegistration" | "where" | "InsertDeletePatch")[], string> & { terms: Namespace<("deletes" | "inserts" | "oidcIssuer" | "oidcIssuerRegistrationToken" | "oidcRegistration" | "where" | "InsertDeletePatch")[], NamedNode<string>> } = ...
SOLID_ERROR: { namespace: string } & RecordOf<("disallowedMethod" | "errorResponse" | "stack")[], string> & { terms: Namespace<("disallowedMethod" | "errorResponse" | "stack")[], NamedNode<string>> } = ...
SOLID_HTTP: { namespace: string } & RecordOf<("location" | "slug")[], string> & { terms: Namespace<("location" | "slug")[], NamedNode<string>> } = ...
SOLID_META: { namespace: string } & RecordOf<("ResponseMetadata" | "template" | "contentTypeParameter" | "value")[], string> & { terms: Namespace<("ResponseMetadata" | "template" | "contentTypeParameter" | "value")[], NamedNode<string>> } = ...
TEMPLATE: { namespace: string } & RecordOf<"ResourceStore"[], string> & { terms: Namespace<"ResourceStore"[], NamedNode<string>> } = ...
TEMPLATE_VARIABLE: { namespace: string } & RecordOf<("baseUrl" | "rootFilePath" | "sparqlEndpoint" | "templateConfig")[], string> & { terms: Namespace<("baseUrl" | "rootFilePath" | "sparqlEndpoint" | "templateConfig")[], NamedNode<string>> } = ...
TEXT_HTML: "text/html" = 'text/html'
TEXT_MARKDOWN: "text/markdown" = 'text/markdown'
TEXT_N3: "text/n3" = 'text/n3'
TEXT_TURTLE: "text/turtle" = 'text/turtle'
UNIT_BYTES: "bytes" = 'bytes'
VANN: { namespace: string } & RecordOf<"preferredNamespacePrefix"[], string> & { terms: Namespace<"preferredNamespacePrefix"[], NamedNode<string>> } = ...
VCARD: { namespace: string } & RecordOf<"hasMember"[], string> & { terms: Namespace<"hasMember"[], NamedNode<string>> } = ...
XSD: { namespace: string } & RecordOf<("dateTime" | "integer")[], string> & { terms: Namespace<("dateTime" | "integer")[], NamedNode<string>> } = ...
modulePathPlaceholder: "@css:" = '@css:'

A placeholder for the path to the @solid/community-server module root. The resolveAssetPath function will replace this string with the actual path.

Functions

  • absoluteFilePath(path: string): string
  • Resolves a path to its absolute form. Absolute inputs will not be changed (except changing Windows to POSIX). Relative inputs will be interpreted relative to process.cwd().

    Parameters

    • path: string

      Path to check (POSIX or Windows).

    Returns string

    The potentially changed path (POSIX).

  • 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

  • Helper function to generate type quads for a Container or Resource.

    Parameters

    • metadata: RepresentationMetadata

      Metadata to add to.

    • isContainer: boolean

      If the identifier corresponds to a container.

    Returns void

    The generated quads.

  • Links a template file with a given content-type to the metadata using the SOLID_META.template predicate.

    Parameters

    • metadata: RepresentationMetadata

      Metadata to update.

    • templateFile: string

      Path to the template.

    • contentType: string

      Content-type of the template after it is rendered.

    Returns void

  • allFulfilled<T>(promises: Promise<T>[], ignoreErrors?: boolean): Promise<T[]>
  • Obtains the values of all fulfilled promises. If there are rejections (and ignoreErrors is false), throws a combined error of all rejected promises.

    Type parameters

    • T

    Parameters

    • promises: Promise<T>[]
    • ignoreErrors: boolean = false

    Returns Promise<T[]>

  • assertError(error: unknown): asserts error is Error
  • Asserts that the input is a native error. If not the input will be re-thrown.

    Parameters

    • error: unknown

    Returns asserts error is Error

  • assertPassword(password: any, confirmPassword: any): asserts password is string
  • Cleans incoming preferences to prevent unwanted behaviour. Makes sure internal types have weight 0, unless specifically requested in the preferences, and interprets empty preferences as accepting everything.

    Parameters

    Returns ValuePreferences

    A copy of the the preferences with the necessary updates.

  • Helper function to clone a representation, the original representation can still be used. This function loads the entire stream in memory.

    Parameters

    Returns Promise<BasicRepresentation>

    The cloned representation.

  • createAggregateError(errors: Error[], messagePrefix?: string): HttpError
  • Combines a list of errors into a single HttpErrors. Status code depends on the input errors. If they all share the same status code that code will be re-used. If they are all within the 4xx range, 400 will be used, otherwise 500.

    Parameters

    • errors: Error[]

      Errors to combine.

    • messagePrefix: string = 'No handler supports the given input:'

      Prefix for the aggregate error message. Will be followed with an array of all the messages.

    Returns HttpError

  • createErrorMessage(error: unknown): string
  • createNamespace<TKey, TValue>(baseUri: string, toValue: (expanded: string) => TValue, ...localNames: TKey[]): Namespace<typeof localNames, 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<typeof localNames, TValue>

  • createSubdomainRegexp(baseUrl: string): RegExp
  • Creates a regular expression that matches URLs containing the given baseUrl, or a subdomain of the given baseUrl. In case there is a subdomain, the first match of the regular expression will be that subdomain.

    Examples with baseUrl http://test.com/foo/:

    • Will match http://test.com/foo/
    • Will match http://test.com/foo/bar/baz
    • Will match http://alice.bob.test.com/foo/bar/baz, first match result will be alice.bob
    • Will not match http://test.com/
    • Will not match http://alicetest.com/foo/

    Parameters

    • baseUrl: string

      Base URL for the regular expression.

    Returns RegExp

  • createTermNamespace<T>(baseUri: string, ...localNames: T[]): Namespace<typeof localNames, NamedNode>
  • 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<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 Namespace<typeof localNames, string> & { terms: Namespace<typeof localNames, NamedNode> }

  • createUriNamespace<T>(baseUri: string, ...localNames: T[]): Namespace<typeof localNames, 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<typeof localNames, string>

  • decodeUriPathComponents(path: string): string
  • This function is used when converting a URI to a file path. Decodes all components of a URI path, with the exception of encoded slash characters, as this would lead to unexpected file locations being targeted (resulting in erroneous behaviour of the file based backend).

    Parameters

    • path: string

      The path to decode the URI path components of.

    Returns string

    A decoded copy of the provided URI path (ignoring encoded slash characters).

  • encodeUriPathComponents(path: string): string
  • This function is used in the process of converting a file path to a URI. Encodes all (non-slash) special characters in a URI path, with the exception of encoded slash characters, as this would lead to unnecessary double encoding, resulting in a URI that differs from the expected result.

    Parameters

    • path: string

      The path to encode the URI path components of.

    Returns string

    An encoded copy of the provided URI path (ignoring encoded slash characters).

  • endOfStream(arg1: Stream): Promise<void>
  • ensureLeadingSlash(path: string): string
  • Makes sure the input path has exactly 1 slash at the beginning. 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.

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

  • extractScheme(url: string): { rest: string; scheme: string }
  • Splits a URL (or similar) string into a part containing its scheme and one containing the rest. E.g., http://test.com/ results in { scheme: 'http://', rest: 'test.com/' }.

    Parameters

    • url: string

      String to parse.

    Returns { rest: string; scheme: string }

    • rest: string
    • scheme: string
  • Fetches an RDF dataset from the given URL.

    Response will be a Representation with content-type internal/quads.

    Parameters

    • url: string

    Returns Promise<Representation>

  • Filters a list of handlers to only keep those that can handle the input. Will error if no matching handlers are found.

    Type parameters

    • TIn

    • TOut

    Parameters

    • handlers: AsyncHandler<TIn, TOut>[]

      Handlers to filter.

    • input: TIn

      Input that needs to be supported.

    Returns Promise<AsyncHandler<TIn, TOut>[]>

  • Finds a handler that can handle the given input data. Otherwise an error gets thrown.

    Type parameters

    • TIn

    • TOut

    Parameters

    • handlers: AsyncHandler<TIn, TOut>[]

      List of handlers to search in.

    • input: TIn

      The input data.

    Returns Promise<AsyncHandler<TIn, TOut>>

    A promise resolving to a handler that supports the data or otherwise rejecting.

  • generateHttpErrorClass<TCode>(statusCode: TCode, name: string): HttpErrorClass<TCode>
  • Generates a new HttpError class with the given status code and name. In general, status codes are used to uniquely identify error types, so there should be no 2 classes with the same value there.

    To make sure Components.js can work with these newly generated classes, the generated class should be called BaseHttpError as that name is an entry in .componentsignore. The actual class should then extend BaseHttpError and have a correct constructor, so the Components.js generator can generate the correct components JSON-LD file during build.

    Type parameters

    • TCode: number

    Parameters

    • statusCode: TCode
    • name: string

    Returns HttpErrorClass<TCode>

  • generateHttpErrorUri(statusCode: number): NamedNode
  • For a media type converter that can generate the given types, this function tries to find the type that best matches the given preferences.

    This function combines several other conversion utility functions to determine what output a converter should generate: it cleans the preferences with cleanPreferences to support empty preferences and to prevent the accidental generation of internal types, after which the best match gets found based on the weights.

    Parameters

    Returns string | undefined

    The best match. Undefined if there is no match.

  • Generates an ETag based on the last modified date of a resource.

    Parameters

    Returns string | undefined

    the generated ETag. Undefined if no last modified date was found.

  • getExtension(path: string): string
  • Extracts the extension (without dot) from a path. Custom function since path.extname does not work on all cases (e.g. ".acl")

    Parameters

    • path: string

      Input path to parse.

    Returns string

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

    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

  • getModuleRoot(): string
  • Returns the folder corresponding to the root of the Community Solid Server module

    Returns string

  • Creates a relative URL by removing the base URL. Will throw an error in case the resulting target is not withing the base URL scope.

    Parameters

    • baseUrl: string

      Base URL.

    • request: HttpRequest

      Incoming request of which the target needs to be extracted.

    • targetExtractor: TargetExtractor

      Will extract the target from the request.

    Returns Promise<string>

  • getSingleItem(stream: Readable): Promise<unknown>
  • Converts the stream to a single object. This assumes the stream is in object mode and only contains a single element, otherwise an error will be thrown.

    Parameters

    • stream: Readable

      Object stream with single entry.

    Returns Promise<unknown>

  • getStatusCode(error: Error): number
  • getTemplateFilePath(template?: Template): string | undefined
  • Tries to match the given type to the given preferences. In case there are multiple matches the most specific one will be chosen as per RFC 7231.

    Parameters

    • type: string

      Type for which the matching weight is needed.

    • preferred: ValuePreferences

      Preferences to match the type to.

    Returns number

    The corresponding weight from the preferences or 0 if there is no match.

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

    When guarding a stream it is assumed that error listeners already attached should be ignored, only error listeners attached after the stream is guarded will prevent an error from being logged.

    If the input is already guarded the guard will be reset, which means ignoring error listeners already attached.

    Type parameters

    • T: EventEmitter<T>

    Parameters

    • stream: T

      Stream that can potentially throw an error.

    Returns Guarded<T>

    The stream.

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

    Parameters

    • contents: string | Iterable<any>

      Data to stream.

    • Optional options: ReadableOptions

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

    Returns Guarded<Readable>

  • hasScheme(url: string, ...schemes: string[]): boolean
  • Checks if the scheme part of the specified url matches at least one of the provided options.

    Parameters

    • url: string

      A string representing the URL.

    • Rest ...schemes: string[]

      Scheme value options (the function will check if at least one matches the URL scheme).

    Returns boolean

    True if the URL scheme matches at least one of the provided options, false otherwise.

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

    Parameters

    • path: string

      Path to check.

    Returns boolean

  • isError(error: any): error is Error
  • 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>

  • isInternalContentType(contentType?: string): boolean
  • Checks if the given content type is an internal content type such as internal/quads. Response will be false if the input type is undefined.

    Do not use this for media ranges.

    Parameters

    • Optional contentType: string

      Type to check.

    Returns boolean

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

    • Optional input: any

      Checks if this is a {@link Term}.

    Returns input is Term

  • isValidFileName(name: string): boolean
  • Checks the validity of a file name. A valid name consists of word characters, '-' or '.'.

    Parameters

    • name: string

      The name of the file to validate.

    Returns boolean

    True if the filename is valid, false otherwise.

  • isValidVariable(variable: string): boolean
  • Checks if the given variable is one that is supported. This can be used to weed out irrelevant parameters in an object.

    Parameters

    • variable: string

    Returns boolean

  • 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).

  • joinUrl(...parts: string[]): string
  • joinUrl(parts: string[]): string
  • Concatenates all the given strings into a normalized URL. Will place slashes between input strings if necessary.

    Parameters

    • Rest ...parts: string[]

    Returns string

  • Concatenates all the given strings into a normalized URL. Will place slashes between input strings if necessary.

    Parameters

    • parts: string[]

    Returns string

  • matchesAuthorizationScheme(scheme: string, authorization?: string): boolean
  • Checks if the value of an HTTP Authorization header matches a specific scheme (e.g. Basic, Bearer, etc).

    Parameters

    • scheme: string

      Name of the authorization scheme (case insensitive).

    • Optional authorization: string

      The value of the Authorization header (may be undefined).

    Returns boolean

    True if the Authorization header uses the specified scheme, false otherwise.

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

  • modulePath(relativePath?: string): string
  • Creates a path starting from the @solid/community-server module root, to be resolved by the resolveAssetPath function.

    Parameters

    • relativePath: string = ''

    Returns string

  • 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(input: string): Accept[]
  • parseForwarded(headers: IncomingHttpHeaders): Forwarded
  • Parses a Forwarded header value and will fall back to X-Forwarded-* headers.

    Parameters

    • headers: IncomingHttpHeaders

      The incoming HTTP headers.

    Returns Forwarded

    The parsed Forwarded header.

  • parseLinkHeader(link?: string | string[]): LinkEntry[]
  • Parses the link header(s) and returns an array of LinkEntry objects.

    Parameters

    • link: string | string[] = []

      A single link header or an array of link headers

    Returns LinkEntry[]

    A LinkEntry array, LinkEntry contains a link and a params Record<string,string>

  • 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(readable: Guarded<Readable>, options?: ParserOptions): Promise<Quad[]>
  • Helper function to convert a Readable into an array of quads.

    Parameters

    • readable: Guarded<Readable>

      The readable object.

    • options: ParserOptions = {}

      Options for the parser.

    Returns Promise<Quad[]>

    A promise containing the array of quads.

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

  • promiseSome(predicates: Promise<boolean>[]): Promise<boolean>
  • A function that simulates the Array.some behaviour but on an array of Promises. Returns true if at least one promise returns true. Returns false if all promises return false or error.

    remarks

    Predicates provided as input must be implemented considering the following points:

    1. if they throw an error, it won't be propagated;
    2. throwing an error should be logically equivalent to returning false.

    Parameters

    • predicates: Promise<boolean>[]

    Returns Promise<boolean>

  • readJsonStream(stream: Readable): Promise<NodeJS.Dict<any>>
  • Interprets the stream as JSON and converts it to a Dict.

    Parameters

    • stream: Readable

      Stream of JSON data.

    Returns Promise<NodeJS.Dict<any>>

    The parsed object.

  • readPackageJson(): Promise<Record<string, any>>
  • readTemplate(template?: Template): Promise<string>
  • readableToQuads(stream: Readable): Promise<Store>
  • Imports quads from a stream into a Store.

    Parameters

    • stream: Readable

      Stream of quads.

    Returns Promise<Store>

    A Store containing all the quads.

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

    Parameters

    • stream: Readable

      Stream of strings.

    Returns Promise<string>

    The joined string.

  • resolveAssetPath(path?: string): string
  • Converts file path inputs into absolute paths. Works similar to absoluteFilePath but paths that start with the modulePathPlaceholder will be relative to the module directory instead of the cwd.

    Parameters

    • path: string = modulePathPlaceholder

    Returns string

  • resolveModulePath(relativePath?: string): string
  • Creates an absolute path starting from the @solid/community-server module root.

    Parameters

    • relativePath: string = ''

    Returns string

  • Converts a given Response (from a request that was already made) to an RDF dataset. In case the given Response object was already parsed its body can be passed along as a string.

    The converter will be used to convert the response body to RDF.

    Response will be a Representation with content-type internal/quads.

    Parameters

    Returns Promise<Representation>

  • sanitizeUrlPart(urlPart: string): string
  • Sanitizes part of a URL by replacing non-word content with a '-'.

    Parameters

    • urlPart: string

      The URL part to sanitize.

    Returns string

    The sanitized output.

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

  • setSafeInterval(logger: Logger, message: string, callback: (...cbArgs: any[]) => void, ms?: number, ...args: any[]): NodeJS.Timeout
  • Wraps the callback for {@link setInterval} so errors get caught and logged. Parameters are identical to the {@link setInterval} parameters starting from the 3rd argument. The logger and message will be used when the callback throws an error. Supports asynchronous callback functions.

    Parameters

    • logger: Logger
    • message: string
    • callback: (...cbArgs: any[]) => void
        • (...cbArgs: any[]): void
        • Parameters

          • Rest ...cbArgs: any[]

          Returns void

    • Optional ms: number
    • Rest ...args: any[]

    Returns NodeJS.Timeout

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

  • splitCommaSeparated(input: string): string[]
  • Splits a string by comma.

    Parameters

    • input: string

      String instance to split.

    Returns string[]

    A String array containining the split parts.

  • 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. This function is used to clean unwanted characters in the components of the provided path.

    Parameters

    • path: string

      The path to convert to its canonical URI path form.

    Returns string

    The canonical URI path form of the provided path.

  • 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

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

    Parameters

    • subject: string

      Subject to potentially transform.

    Returns NamedNode

  • Type parameters

    • T: Term

    Parameters

    • subject: T

    Returns T

  • Type parameters

    • T: Term

    Parameters

    • subject: string | T

    Returns T | NamedNode

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

    Parameters

    • object: string

      Object to potentially transform.

    • Optional preferLiteral: boolean

      Whether strings are converted to literals or named nodes.

    Returns NamedNode

  • Type parameters

    • T: Term

    Parameters

    • object: T
    • Optional preferLiteral: boolean

    Returns T

  • Type parameters

    • T: Term

    Parameters

    • object: string | T
    • Optional preferLiteral: boolean

    Returns T | NamedNode

  • toPredicateTerm(subject: string): NamedNode
  • toPredicateTerm<T>(subject: T): T
  • toPredicateTerm<T>(subject: string | T): T | NamedNode
  • 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
  • Transforms a stream, ensuring that all errors are forwarded.

    Type parameters

    • T = any

    Parameters

    • source: ReadableStream

      The stream to be transformed

    • options: AsyncTransformOptions<T> = {}

      The transformation options

    Returns Guarded<Transform>

    The transformed stream

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

  • uniqueQuads(quads: Quad[]): Quad[]
  • Filter out duplicate quads from an array.

    Parameters

    • quads: Quad[]

      Quads to filter.

    Returns Quad[]

    A new array containing the unique quads.