@constl/bohr-db
Version:
Type-safe databases for orbit-db.
22 lines (21 loc) • 906 B
TypeScript
import { JSONSchemaType, ValidateFunction } from "ajv";
import type { DBElements } from "./types";
import { DagCborEncodable } from "@orbitdb/core";
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;
};
type NoUndefinedField<T> = {
[P in keyof T]-?: NonNullable<T[P]>;
};
export declare const removeUndefinedProperties: <T extends {
[clef: string]: DagCborEncodable | undefined;
}>(objet: T) => NoUndefinedField<T>;
export {};