@sidekick-coder/db
Version:
Cli Tool to manipulate data from diferent sources
110 lines (102 loc) • 5.92 kB
TypeScript
import * as valibot from 'valibot';
import { InferOutput } from 'valibot';
import { FilesystemOptions } from './core/filesystem/types.js';
interface DestroyOptions extends InferOutput<typeof schema$4> {
}
declare const schema$4: valibot.ObjectSchema<{
readonly where: valibot.OptionalSchema<valibot.SchemaWithPipe<[valibot.AnySchema, valibot.TransformAction<any, any>]>, undefined>;
readonly limit: valibot.OptionalSchema<valibot.NumberSchema<undefined>, undefined>;
}, undefined>;
declare function destroy(provider: DataProvider, payload: DestroyOptions): Promise<{
count: number;
}>;
interface FindOptions extends InferOutput<typeof schema$3> {
}
declare const schema$3: valibot.ObjectWithRestSchema<{
readonly where: valibot.OptionalSchema<valibot.SchemaWithPipe<[valibot.AnySchema, valibot.TransformAction<any, any>]>, undefined>;
readonly include: valibot.OptionalSchema<valibot.SchemaWithPipe<[valibot.AnySchema, valibot.TransformAction<any, any[]>, valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>]>, undefined>;
readonly exclude: valibot.OptionalSchema<valibot.SchemaWithPipe<[valibot.AnySchema, valibot.TransformAction<any, any[]>, valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>]>, undefined>;
}, valibot.AnySchema, undefined>;
declare function find(provider: DataProvider, payload: FindOptions): Promise<DataItem>;
interface UpdateOptions extends InferOutput<typeof schema$2> {
}
declare const schema$2: valibot.ObjectWithRestSchema<{
readonly data: valibot.SchemaWithPipe<[valibot.RecordSchema<valibot.StringSchema<undefined>, valibot.AnySchema, undefined>, valibot.TransformAction<{
[x: string]: any;
}, Record<string, any>>]>;
readonly where: valibot.OptionalSchema<valibot.SchemaWithPipe<[valibot.AnySchema, valibot.TransformAction<any, any>]>, undefined>;
readonly limit: valibot.OptionalSchema<valibot.NumberSchema<undefined>, undefined>;
}, valibot.AnySchema, undefined>;
declare function update(provider: DataProvider, payload: UpdateOptions): Promise<{
count: number;
}>;
interface ListOptions extends InferOutput<typeof schema$1> {
}
declare const schema$1: valibot.ObjectWithRestSchema<{
readonly where: valibot.OptionalSchema<valibot.SchemaWithPipe<[valibot.AnySchema, valibot.TransformAction<any, any>]>, undefined>;
readonly limit: valibot.OptionalSchema<valibot.NumberSchema<undefined>, undefined>;
readonly page: valibot.OptionalSchema<valibot.NumberSchema<undefined>, undefined>;
readonly cursor: valibot.OptionalSchema<valibot.StringSchema<undefined>, undefined>;
readonly include: valibot.OptionalSchema<valibot.SchemaWithPipe<[valibot.AnySchema, valibot.TransformAction<any, any[]>, valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>]>, undefined>;
readonly exclude: valibot.OptionalSchema<valibot.SchemaWithPipe<[valibot.AnySchema, valibot.TransformAction<any, any[]>, valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>]>, undefined>;
readonly sortBy: valibot.OptionalSchema<valibot.SchemaWithPipe<[valibot.UnionSchema<[valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, valibot.StringSchema<undefined>], undefined>, valibot.TransformAction<string | string[], ((string | string[]) & any[]) | (string | string[])[]>, valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>]>, undefined>;
readonly sortDesc: valibot.OptionalSchema<valibot.SchemaWithPipe<[valibot.UnionSchema<[valibot.ArraySchema<valibot.BooleanSchema<undefined>, undefined>, valibot.BooleanSchema<undefined>], undefined>, valibot.TransformAction<boolean | boolean[], ((boolean | boolean[]) & any[]) | (boolean | boolean[])[]>, valibot.ArraySchema<valibot.BooleanSchema<undefined>, undefined>]>, undefined>;
}, valibot.AnySchema, undefined>;
declare function list(provider: DataProvider, payload: ListOptions): Promise<ListResponse>;
interface WhereCondition {
field: string;
operator?: string;
value: any;
}
interface WhereGroup {
or?: WhereCondition[];
and?: WhereCondition[];
}
interface Where {
[key: string]: any;
and?: Where[];
or?: Where[];
}
interface Field {
exclude?: string[];
include?: string[];
}
interface Sort {
sortBy: string | string[];
sortDesc?: boolean | boolean[];
}
interface DataItem {
[key: string]: any;
}
interface ListResponse {
meta: any;
data: DataItem[];
}
interface DataProvider {
list: (options?: ListOptions) => Promise<ListResponse>;
find: (options?: FindOptions) => Promise<DataItem | null>;
create: (options: CreateOptions) => Promise<DataItem>;
update: (options: UpdateOptions) => Promise<{
count: number;
}>;
destroy: (options: DestroyOptions) => Promise<{
count: number;
}>;
}
interface DataProviderInstanceOptions {
root: string;
fs?: FilesystemOptions['fs'];
path?: FilesystemOptions['path'];
}
interface MountDataProvider {
(config: any, instanceConfig: DataProviderInstanceOptions): Partial<DataProvider>;
}
interface CreateOptions extends InferOutput<typeof schema> {
}
declare const schema: valibot.ObjectWithRestSchema<{
readonly data: valibot.SchemaWithPipe<[valibot.RecordSchema<valibot.StringSchema<undefined>, valibot.AnySchema, undefined>, valibot.TransformAction<{
[x: string]: any;
}, Record<string, any>>]>;
}, valibot.AnySchema, undefined>;
declare function create(provider: DataProvider, payload: CreateOptions): Promise<DataItem>;
export { type CreateOptions as C, type DestroyOptions as D, type FindOptions as F, type ListOptions as L, type MountDataProvider as M, type Sort as S, type UpdateOptions as U, type WhereCondition as W, type ListResponse as a, type DataItem as b, type Where as c, type DataProviderInstanceOptions as d, type WhereGroup as e, type Field as f, type DataProvider as g, destroy as h, find as i, create as j, list as l, update as u };