UNPKG

@constl/bohr-db

Version:

Type-safe databases for OrbitDB.

26 lines 1.22 kB
import { type JSONSchemaType, type ValidateFunction } from "ajv"; import type { DBElements, ExtractKeys, ExtractKeysAsList } from "./types.ts"; import type { DagCborEncodable } from "@orbitdb/core"; type NestedValueObject = { [key: string]: DagCborEncodable | NestedValueObject; }; export declare const generateListValidator: <T extends DBElements>(schema: JSONSchemaType<T>) => { validate: ValidateFunction<T>; }; export declare const generateDictValidator: <T extends { [clef: string]: DBElements; }>(schema: JSONSchemaType<Partial<T>>) => { validateRoot: ValidateFunction<Partial<T>>; getKeyValidator: <K extends keyof T>(key: K) => ValidateFunction<T[K]>; validateKey: <K extends keyof T>(v: unknown, key: K) => v is T[K]; supportedKey: <K extends string>(key: K) => boolean; }; export type NoUndefinedField<T> = { [P in keyof T]-?: T[P] extends undefined ? never : T[P]; }; export declare const removeUndefinedProperties: <T extends { [clef: string]: DagCborEncodable | undefined; }>(objet: T) => NoUndefinedField<T>; export declare const getJoinedKey: <T extends NestedValueObject>(key: ExtractKeysAsList<T>) => ExtractKeys<T>; export {}; //# sourceMappingURL=utils.d.ts.map