2023-08-03 13:18:14 +05:30
|
|
|
import type { Field, FieldType, RawValue } from '../../schemas/types';
|
|
|
|
import type DatabaseCore from './core';
|
|
|
|
import type { DatabaseManager } from './manager';
|
2022-03-24 15:20:40 +05:30
|
|
|
|
2022-03-23 11:46:13 +05:30
|
|
|
export interface GetQueryBuilderOptions {
|
2022-03-25 15:42:39 +05:30
|
|
|
offset?: number;
|
|
|
|
limit?: number;
|
2023-01-05 11:14:05 +05:30
|
|
|
groupBy?: string | string[];
|
|
|
|
orderBy?: string | string[];
|
2022-03-25 15:42:39 +05:30
|
|
|
order?: 'desc' | 'asc';
|
2022-03-23 11:46:13 +05:30
|
|
|
}
|
2022-03-24 15:20:40 +05:30
|
|
|
|
|
|
|
export type ColumnDiff = { added: Field[]; removed: string[] };
|
|
|
|
export type FieldValueMap = Record<
|
|
|
|
string,
|
|
|
|
RawValue | undefined | FieldValueMap[]
|
|
|
|
>;
|
2022-03-24 18:43:59 +05:30
|
|
|
|
2023-07-11 12:41:22 +05:30
|
|
|
export type AlterConfig = {
|
|
|
|
schemaName: string;
|
|
|
|
diff: ColumnDiff;
|
|
|
|
newForeignKeys: Field[];
|
|
|
|
};
|
|
|
|
|
|
|
|
export type NonExtantConfig = {
|
|
|
|
schemaName: string;
|
|
|
|
nonExtant: {
|
|
|
|
fieldname: string;
|
|
|
|
value: RawValue;
|
|
|
|
}[];
|
|
|
|
};
|
|
|
|
|
|
|
|
export type UpdateSinglesConfig = {
|
|
|
|
update: string[];
|
|
|
|
updateNonExtant: NonExtantConfig[];
|
|
|
|
};
|
|
|
|
|
|
|
|
export type MigrationConfig = {
|
|
|
|
pre?: () => Promise<void> | void;
|
|
|
|
post?: () => Promise<void> | void;
|
|
|
|
};
|
|
|
|
|
2022-03-24 18:43:59 +05:30
|
|
|
export interface Patch {
|
|
|
|
name: string;
|
|
|
|
version: string;
|
|
|
|
patch: {
|
2022-03-25 15:42:39 +05:30
|
|
|
execute: (dm: DatabaseManager) => Promise<void>;
|
2022-03-24 18:43:59 +05:30
|
|
|
beforeMigrate?: boolean;
|
|
|
|
};
|
2022-05-25 00:36:54 +05:30
|
|
|
priority?: number;
|
2022-03-24 18:43:59 +05:30
|
|
|
}
|
2022-03-25 15:42:39 +05:30
|
|
|
|
|
|
|
export type KnexColumnType =
|
|
|
|
| 'text'
|
|
|
|
| 'integer'
|
|
|
|
| 'float'
|
|
|
|
| 'boolean'
|
|
|
|
| 'date'
|
|
|
|
| 'datetime'
|
|
|
|
| 'time'
|
|
|
|
| 'binary';
|
2022-03-28 15:31:29 +05:30
|
|
|
|
|
|
|
// Returned by pragma table_info
|
|
|
|
export interface SqliteTableInfo {
|
|
|
|
pk: number;
|
|
|
|
cid: number;
|
|
|
|
name: string;
|
|
|
|
type: string;
|
|
|
|
notnull: number; // 0 | 1
|
|
|
|
dflt_value: string | null;
|
|
|
|
}
|
2022-04-11 11:34:55 +05:30
|
|
|
|
2022-05-25 00:36:54 +05:30
|
|
|
export type BespokeFunction = (
|
|
|
|
db: DatabaseCore,
|
|
|
|
...args: unknown[]
|
|
|
|
) => Promise<unknown>;
|
2023-07-10 14:42:20 +05:30
|
|
|
|
2022-04-18 16:59:20 +05:30
|
|
|
export type SingleValue<T> = {
|
|
|
|
fieldname: string;
|
|
|
|
parent: string;
|
|
|
|
value: T;
|
2022-05-25 00:36:54 +05:30
|
|
|
}[];
|
2023-08-03 13:18:14 +05:30
|
|
|
|
|
|
|
export type RawCustomField = {
|
|
|
|
parent: string;
|
|
|
|
label: string;
|
|
|
|
fieldname: string;
|
|
|
|
fieldtype: FieldType;
|
|
|
|
isRequired?: boolean;
|
|
|
|
section?: string;
|
|
|
|
tab?: string;
|
|
|
|
options?: string;
|
|
|
|
target?: string;
|
|
|
|
references?: string;
|
2023-09-18 15:21:56 +05:30
|
|
|
default?: string;
|
2023-08-03 13:18:14 +05:30
|
|
|
};
|