Kfg Documentation
    Preparing search index...

    Interface KfgApi<D, S>

    The public surface shared by Kfg and KfgPool.

    Both implement this interface with the exact same generics, so a pool can be dropped in wherever a single instance was used before without touching call sites — dot-path autocompletion and return types stay identical.

    interface KfgApi<D extends KfgDriver<any, any>, S extends SchemaDefinition> {
        config: StaticSchema<S>;
        driver: D;
        schema: S;
        conf<P extends string>(path: P): DeepGet<S, P>;
        del<P extends string>(path: P): inPromise<D["async"], void>;
        get<P extends string>(path: P): DeepGet<StaticSchema<S>, P>;
        has<P extends string>(...paths: P[]): boolean;
        inject(data: Partial<StaticSchema<S>>): inPromise<D["async"], void>;
        insert<P extends string>(
            path: P,
            partial: Partial<DeepGet<StaticSchema<S>, P>>,
        ): inPromise<D["async"], void>;
        load(options?: KfgLoadOptions<D>): inPromise<D["async"], void>;
        mutate(
            fn: (draft: StaticSchema<S>) => StaticSchema<S> | undefined,
        ): inPromise<D["async"], void>;
        reload(options?: KfgLoadOptions<D>): inPromise<D["async"], void>;
        root<P extends string>(path: P): DeepGet<StaticSchema<S>, P>;
        save(): inPromise<D["async"], void>;
        schematic<P extends string>(path: P): DeepGet<S, P>;
        set<P extends string>(
            path: P,
            value: DeepGet<StaticSchema<S>, P>,
            descriptionOrOptions?: string | { description?: string },
        ): inPromise<D["async"], void>;
        toJSON(): inPromise<D["async"], StaticSchema<S>>;
        unload(): void;
    }

    Type Parameters

    Implemented by

    Index
    config: StaticSchema<S>

    Read-only proxy over the loaded configuration.

    driver: D

    The driver backing the current configuration.

    schema: S

    The user-defined schema definition.

    • Type Parameters

      • P extends string

      Parameters

      • ...paths: P[]

      Returns boolean

    • Drops the in-memory cache; persisted state is untouched.

      Returns void