Kfg Documentation
    Preparing search index...

    Class JsonDriverBase<Async>Abstract

    Type Parameters

    • Async extends boolean

    Hierarchy (View Summary)

    Index
    async: Async
    comments: Record<string, string> = {}
    forceExit: boolean
    name: string
    • Parameters

      • jsonText: string
      • mode: "expected" | "received"

      Returns string

    • Optional hook for deletion. Use this ONLY if the driver handles atomic deletion. If implemented, Kfg.del() will call this INSTEAD of save().

      Parameters

      • key: string

        The key deleted.

      Returns inPromise<Async, void>

    • Parameters

      • schema: any
      • prefix: string

      Returns Record<string, unknown>

    • Optional hook to format validation errors.

      Parameters

      • errors: any[]

        The array of errors from TypeBox/Value.

      Returns string

      A formatted string or undefined to use default formatting.

    • Parameters

      • data: any
      • comments: Record<string, string>

      Returns void

    • Parameters

      • schema: any
      • key: string
      • OptionaljsonPath: string

      Returns string

    • Saves the configuration to the source.

      Parameters

      • data: Record<string, any>

        The full configuration object.

      • Optionaloptions: { description?: string; path?: string }

        Optional metadata for the save operation (e.g. description for a specific update).

      Returns inPromise<Async, void>

    • Serializes a config object to the on-disk JSON string (comments/keyroot).

      Parameters

      • data: Record<string, any>
      • Optionaloptions: { description?: string; path?: string }

      Returns string

    • Optional transactional read-modify-write. When implemented, Kfg.mutate() uses it to make the whole load→modify→save cycle atomic across processes (preventing lost updates). fn receives the freshly-read raw config and returns the raw config to persist.

      Parameters

      • schema: SchemaDefinition
      • fn: (current: Record<string, any>) => Record<string, any>

      Returns inPromise<Async, void>

    • Optional hook for updates. Use this ONLY if the driver handles atomic updates and doesn't need the full object every time. If implemented, Kfg.set() will call this INSTEAD of save().

      Parameters

      • key: string

        The key updated (dot notation).

      • value: any

        The new value.

      • Optionaldescription: string

      Returns inPromise<Async, void>

    • Safe-write options derived from the driver config.

      Returns {
          backup: string | boolean;
          lockTimeout: number | undefined;
          verify: (content: string) => boolean;
      }