tspace-mysql
Version:
Tspace MySQL is a promise-based ORM for Node.js, designed with modern TypeScript and providing type safety for schema databases.
181 lines (180 loc) • 6.05 kB
TypeScript
import { Blueprint } from "./Blueprint";
import type { TPattern, TSave, TValidateSchema } from "../types";
declare const STATE_DEFAULT: {
readonly PRIMARY_KEY: string;
readonly VOID: boolean;
readonly DISTINCT: boolean;
readonly SAVE: TSave | null;
readonly DELETE: boolean | null;
readonly UPDATE: string[] | null;
readonly INSERT: {
columns: string[];
values: string[];
} | null;
readonly SELECT: string[];
readonly ADD_SELECT: string[];
readonly ONLY: string[];
readonly EXCEPTS: string[];
readonly FROM: string[];
readonly JOIN: string[];
readonly WHERE: string[];
readonly GROUP_BY: string[];
readonly ORDER_BY: string[];
readonly LIMIT: number | null;
readonly OFFSET: number | null;
readonly HAVING: string | null;
readonly TABLE_NAME: string | null;
readonly HIDDEN: string[];
readonly DEBUG: boolean;
readonly CTE: string[];
readonly PAGE: number;
readonly AFTER_SAVE: number;
readonly HOOKS: Function[];
readonly ALIAS: string | null;
readonly RAW_ALIAS: string | null;
readonly UNION: string[];
readonly UNION_ALL: string[];
readonly ROW_LEVEL_LOCK: "FOR_UPDATE" | "FOR_SHARE" | null;
};
declare const STATE_DB: {
readonly PRIMARY_KEY: string;
readonly VOID: boolean;
readonly DISTINCT: boolean;
readonly SAVE: TSave | null;
readonly DELETE: boolean | null;
readonly UPDATE: string[] | null;
readonly INSERT: {
columns: string[];
values: string[];
} | null;
readonly SELECT: string[];
readonly ADD_SELECT: string[];
readonly ONLY: string[];
readonly EXCEPTS: string[];
readonly FROM: string[];
readonly JOIN: string[];
readonly WHERE: string[];
readonly GROUP_BY: string[];
readonly ORDER_BY: string[];
readonly LIMIT: number | null;
readonly OFFSET: number | null;
readonly HAVING: string | null;
readonly TABLE_NAME: string | null;
readonly HIDDEN: string[];
readonly DEBUG: boolean;
readonly CTE: string[];
readonly PAGE: number;
readonly AFTER_SAVE: number;
readonly HOOKS: Function[];
readonly ALIAS: string | null;
readonly RAW_ALIAS: string | null;
readonly UNION: string[];
readonly UNION_ALL: string[];
readonly ROW_LEVEL_LOCK: "FOR_UPDATE" | "FOR_SHARE" | null;
};
declare const STATE_MODEL: {
readonly AUDIT: number | null;
readonly AUDIT_METADATA: Record<string, any> | null;
readonly MODEL_NAME: string;
readonly UUID_FORMAT: string;
readonly UUID: boolean;
readonly SOFT_DELETE: boolean;
readonly SOFT_DELETE_FORMAT: string;
readonly SOFT_DELETE_RELATIONS: boolean;
readonly REGISTRY: Record<string, string>;
readonly PATTERN: TPattern;
readonly RELATION: any[];
readonly RELATIONS: any[];
readonly RELATIONS_TRASHED: boolean;
readonly RELATIONS_EXISTS: boolean;
readonly TIMESTAMP: boolean;
readonly TIMESTAMP_FORMAT: {
readonly CREATED_AT: string;
readonly UPDATED_AT: string;
};
readonly LOGGER: boolean;
readonly LOGGER_OPTIONS: {
selected: boolean;
inserted: boolean;
updated: boolean;
deleted: boolean;
} | null;
readonly TABLE_LOGGER: string;
readonly TABLE_AUDIT: string;
readonly VALIDATE_SCHEMA: boolean;
readonly VALIDATE_SCHEMA_DEFINED: TValidateSchema | null;
readonly FUNCTION_RELATION: boolean;
readonly SCHEMA_TABLE: Record<string, Blueprint> | null;
readonly RETRY: number;
readonly OBSERVER: (new () => any) | null;
readonly DATA: any | null;
readonly GLOBAL_SCOPE: boolean;
readonly GLOBAL_SCOPE_QUERY: Function | null;
readonly QUERIES: string[];
readonly META: string | null;
readonly CACHE: {
key: string;
expires: number;
} | null;
readonly MIDDLEWARES: Function[];
readonly TRANSFORMS: Record<string, {
to: (value: unknown) => any | Promise<any>;
from: (value: unknown) => any | Promise<any>;
}> | null;
readonly LIFECYCLE_BEFORE_INSERTS: Function[];
readonly LIFECYCLE_AFTER_INSERTS: Function[];
readonly LIFECYCLE_BEFORE_UPDATES: Function[];
readonly LIFECYCLE_AFTER_UPDATES: Function[];
readonly LIFECYCLE_BEFORE_REMOVES: Function[];
readonly LIFECYCLE_AFTER_REMOVES: Function[];
readonly ON_CREATED_TABLE: Function | null;
readonly ON_SYNC_TABLE: Function | null;
readonly PRIMARY_KEY: string;
readonly VOID: boolean;
readonly DISTINCT: boolean;
readonly SAVE: TSave | null;
readonly DELETE: boolean | null;
readonly UPDATE: string[] | null;
readonly INSERT: {
columns: string[];
values: string[];
} | null;
readonly SELECT: string[];
readonly ADD_SELECT: string[];
readonly ONLY: string[];
readonly EXCEPTS: string[];
readonly FROM: string[];
readonly JOIN: string[];
readonly WHERE: string[];
readonly GROUP_BY: string[];
readonly ORDER_BY: string[];
readonly LIMIT: number | null;
readonly OFFSET: number | null;
readonly HAVING: string | null;
readonly TABLE_NAME: string | null;
readonly HIDDEN: string[];
readonly DEBUG: boolean;
readonly CTE: string[];
readonly PAGE: number;
readonly AFTER_SAVE: number;
readonly HOOKS: Function[];
readonly ALIAS: string | null;
readonly RAW_ALIAS: string | null;
readonly UNION: string[];
readonly UNION_ALL: string[];
readonly ROW_LEVEL_LOCK: "FOR_UPDATE" | "FOR_SHARE" | null;
};
type State = typeof STATE_MODEL & typeof STATE_DB & typeof STATE_DEFAULT;
declare class StateManager {
private STATE;
constructor(state: 'model' | 'db' | 'default');
original(): Map<string, any>;
all(): Map<string, any>;
get<K extends keyof State>(key: K): State[K];
set<K extends keyof State>(key: K, value: State[K]): void;
clone(data: any): void;
reset(): void;
private _assertError;
}
export { StateManager };
export default StateManager;