@metreeca/qest - v0.10.0
    Preparing search index...

    Function encodeTemplate

    • Encodes a template as a JSON string.

      Serialises a Template into a JSON string, recursively internalising absolute IRIs against the provided base. The output may be additionally transport-encoded as URL-encoded JSON or URL-safe base64url-encoded JSON via the format option.

      Parameters

      • template: Template

        The template to encode

      • options: EncoderOpts & { format?: "url" | "json" | "base64" } = {}

        Encoding options

        Configuration options for encoding operations.

        • Optional Readonlybase?: IRI

          Base IRI for IRI internalisation (must be absolute and hierarchical).

          Converts absolute IRIs to internal (root-relative) form.

          If omitted, IRIs are internalised against app.

        • Optional Readonlyindent?: boolean | number

          Indentation level for pretty-printing encoded output.

          • When true, uses default indentation
          • When a positive number, indents with that many spaces
          • When false or a number less than or equal to 0, disables indentation

          If omitted, output is not indented.

        • Optional Readonlyformat?: "url" | "json" | "base64"

          Output encoding for the serialised template:

          • "json" — plain JSON string (default)
          • "url" — URL-encoded JSON (via encodeURIComponent)
          • "base64" — URL-safe, unpadded base64-encoded JSON (base64url)

      Returns string

      The serialised template with internalised IRIs, encoded according to format

      TypeError If base is not a hierarchical IRI

      encodeTemplate(
      { id: "", name: "", vendor: { id: "https://example.com/vendors/acme", name: "" } },
      { base: "https://example.com/" }
      );
      // → '{"id":"","name":"","vendor":{"id":"/vendors/acme","name":""}}'