node-dextrin - v0.4.0
    Preparing search index...

    Class export=

    Index
    materializers: Map<
        string,
        (
            name: string,
            version: number,
            fields: { [k: string]: unknown },
        ) => unknown,
    >
    resolver: ((name: string) => export= | export=[] | undefined) | null
    strict: boolean
    structModules: Map<string, Function>
    structs: Map<string, Map<number, export=>>
    tagEncoders: Map<Function, [string, (value: unknown) => unknown]>
    tags: Map<string, (value: unknown) => unknown>
    trusted: boolean
    typeAliases: Map<string, unknown>
    • Loads compiled as a new version of the schema name. A version that is already loaded is refused as schema/duplicate-version (DXN.md §4.8): two documents both claiming to be User v3 is a mistake, not an update.

      Parameters

      Returns export=

    • struct as it is written here: carrying the latest loaded version of its schema (DXN.md §4.8), whatever version it says itself. A struct whose name has no schema keeps its own version, or none. Every writer goes through this — text, the formatter and binary — so encoding never writes a version other than the latest, and never writes one no schema stands behind.

      Parameters

      Returns DXNStruct

    • Parameters

      • name: string

      Returns
          | (
              (
                  name: string,
                  version: number,
                  fields: { [k: string]: unknown },
              ) => unknown
          )
          | undefined

    • The reverse of fetchStructModule: given an application value's own class, finds the schema name it was registered under (if any) — what lets automatic encode-time validation recognize a plain JS class instance as "this is a Foo" without being told so explicitly.

      Parameters

      • klass: Function

      Returns string | undefined

    • Parameters

      • name: string

      Returns Function | undefined

    • Looks up a compiled schema by struct name: the latest version, or with version exactly that one. A name not loaded at all consults the lazy resolver (if any), which loads every version it finds. Whether schemas are all compiled up front or resolved on demand (a resolver reading a file, calling a schema service, ...) is entirely the caller's choice — this is what makes both paths look identical to everything else. A named version never falls back to another: a struct is only ever read with the schema it was written against.

      Parameters

      • name: string
      • Optionalversion: number

      Returns { compiled: export=; registry: export= } | undefined

    • Parameters

      • name: string

      Returns ((value: unknown) => unknown) | undefined

    • Parameters

      • klass: Function

      Returns [string, (value: unknown) => unknown] | undefined

    • Parameters

      • name: string

      Returns unknown

    • Parameters

      • name: string
      • version: number

      Returns boolean

    • A lazy source of schemas, asked on a miss for a name: every version it finds -- one compiled schema or a list of them, all loaded -- or undefined. It throws (schema/compile) when the schemas it found cannot be used: two files with one version, a file that is not the version its name says, ...

      Parameters

      Returns export=

    • Marks this registry as decoding strictly: a schema-backed struct that carries a field its schema does not declare is refused (schema/undeclared-field, DXN.md §4.7) instead of keeping it as an extra field. A config loader decodes strictly; a message consumer does not. decode/decodeBinary take it as strict: true.

      Parameters

      • strict: boolean

      Returns export=

    • Parameters

      • name: string

        The schema's materializer (DXN.md §4.8): called for every decoded struct of name, whatever the version, with the schema's name, the version the fields were read with and the fields keyed by string; it answers the application's latest-version value, which is checked against the latest schema, or throws.

      • materializer: (name: string, version: number, fields: { [k: string]: unknown }) => unknown

      Returns export=

    • Declares which JS class a schema's data is expected to be — used only for {:reference, name} checks during encode-time validation. Decode-time reference checks don't need this: they carry an internal provenance marker regardless of materializer shape (schema/validated.cjs).

      Parameters

      • name: string
      • klass: Function

      Returns export=

    • compiled as version compiled.version of the schema name, whether or not that version was loaded already — the unchecked setter a resolver's answer goes through. Loading a document's schemas goes through addStructSchema, a hot swap through replaceStructSchema.

      Parameters

      Returns export=

    • Parameters

      • name: string
      • decoder: (value: unknown) => unknown

      Returns export=

    • The reverse of putTag: registers how to turn an application value (keyed by its constructor) back into @name value on encode — decode-side dispatch happens by wire tag name, encode needs to dispatch by JS class instead, so the two directions need separate tables.

      Parameters

      • klass: Function
      • name: string
      • encoder: (value: unknown) => unknown

      Returns export=

    • Marks (or unmarks) this registry as decoding a trusted source, vs. an untrusted one -- the default. Currently the one thing this affects is keyword: untrusted (the default) decodes it as DXNKeyword, so no decode path is ever forced through the global symbol registry's never-garbage-collected interning by the input; trusted decodes it as a real, global Symbol.for. A decode's own trusted: option wins over this. symbol is deliberately unaffected either way.

      Parameters

      • trusted: boolean

      Returns export=

    • Replaces version compiled.version of the schema name — the hot swap of a running system. Replace only replaces: a version that is not loaded is refused as schema/not-loaded, so a typo in a hot swap never quietly adds a version instead.

      Parameters

      Returns export=

    • What the resolver answers for name, every version of it loaded -- so an older struct reaches the materializer (DXNS.md §6, §4.8) -- and the latest answered. A resolver's refusal is thrown on.

      Parameters

      • name: string

      Returns { compiled: export=; registry: export= } | undefined