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

    Function decodeTemplate

    • Decodes a template from an encoded string.

      Parses an encoded string into a Template, recursively resolving internal IRIs against the provided base. The input encoding is auto-detected, accepting any of the output formats produced by encodeTemplate. The decoded template is validated and deeply frozen unless lenient is true.

      Parameters

      • encoded: string

        The encoded Template, in any of the formats produced by encodeTemplate

      • options: DecoderOpts = {}

        Decoding options

        Configuration options for decoding operations.

        • Optional Readonlybase?: IRI

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

          Resolves internal IRIs to absolute form.

          If omitted, IRIs are resolved against app.

        • Optional Readonlylenient?: boolean

          Disables structural validation after decoding.

          Allows the caller to handle validation independently using more advanced or specialised tools, for example for improved error reporting.

          • When true, structural checks are skipped and only syntax errors are reported through exceptions
          • When false, both syntax and structural errors are reported through exceptions

          If omitted, decoders apply internal structural validators to the input.

      Returns Template

      The decoded deeply immutable template with resolved IRIs

      TypeError If base is not a hierarchical IRI

      TypeError If the decoded value fails structural validation (unless lenient is true)

      SyntaxError If encoded cannot be parsed as JSON, URL-encoded JSON, or base64url-encoded JSON

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