UNPKG

@knapsack/app

Version:

Build Design Systems on top of knapsack, by Basalt

80 lines (78 loc) 2.84 kB
/** * Copyright (C) 2018 Basalt This file is part of Knapsack. Knapsack is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Knapsack is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Knapsack; if not, see <https://www.gnu.org/licenses>. */ import low from 'lowdb'; import { KnapsackFile } from '@knapsack/core'; import { KnapsackDb } from '../../schemas/misc'; /** * Creates a LoDash powered JSON file database, via `lowdb` that is created using the `_.chain` method. * Each database has all of the power of LoDash for parsing the data. * @link https://www.npmjs.com/package/lowdb * @link https://lodash.com/docs/4.17.11#chain */ export declare class FileDb { db: low.LowdbSync<any>; constructor({ dbDir, name, defaults, }: { dbDir: string; name: string; defaults?: object; }); getDb(): low.LowdbSync<any>; get(key: string): any; getAll(): any; /** * @link https://lodash.com/docs/4.17.11#find */ find(data: any): any; values(): any[]; set(key: string, value: any): any; setAll(data: object): object; update(key: string, func: any): any; } export declare class FileDb2<ConfigType> implements KnapsackDb<ConfigType> { /** * Full path to file used for storage */ filePath: string; private type; validationSchema: object; constructor({ filePath, type, defaults, validationSchema, watch, writeFileIfAbsent, }: { filePath: string; type?: 'json' | 'yml'; /** * Shallow merge */ defaults?: ConfigType; /** * JSON Schema to validate read & writes with at run time */ validationSchema?: object; watch?: boolean; writeFileIfAbsent?: boolean; }); /** * Ensure the data is good during run-time by using provided JSON Schemas to validate * Requires `validationSchema` to be passed in during initial creation * @throws Error if it's not valid */ validateConfig(config: ConfigType): void; serialize(config: ConfigType): Pick<KnapsackFile, 'contents' | 'encoding'>; parse(fileString: string): ConfigType; read(): Promise<ConfigType>; readSync(): ConfigType; savePrep(config: ConfigType): Promise<KnapsackFile[]>; getData(): Promise<ConfigType>; getDataSync(): ConfigType; } //# sourceMappingURL=file-db.d.ts.map