import KeyMap from '../../utils/key-map'; import { RelationDefinition } from './relation'; import { ClassId, ClassKeys, ClassJSON } from '../../types/class'; import { RelationsMap } from '../../types/relations'; import { TriggersList } from '../../types/triggers'; export declare const ClassDefinitionSymbol: unique symbol; export interface ClassDefinition { keys: string[]; timestamps: string[]; relations: RelationsMap; triggers: TriggersList; hidden: string[]; guarded: string[]; computed: string[]; } export interface ClassDefinitionOptions { className?: string; source?: string; } export declare class ClassDefinitionManager { static get(classType: C): { keys: string[]; timestamps: string[]; relations: { [x: string]: RelationDefinition; }; triggers: { type: import("../../types/triggers").TriggerType; action: import("../../types/triggers").TriggerAction; }[]; hidden: string[]; guarded: string[]; computed: string[]; }; static set(classType: C, definition: ClassDefinition): void; } /** * Class definition decorator * @description Defines and initializes the class * @param {String} className * @param {String} source */ export declare function define(constructor: C): any; export declare function define(opts: ClassDefinitionOptions): (constructor: C) => any; /** * Class */ export default class Class { newIdentifier?: ClassId; identifier: ClassId; keys: KeyMap; /** * Constructor * @param {Object} params * @param {Number} id */ constructor(keys?: ClassId | ClassKeys); static readonly className: string; static readonly source: string; /** * @description Check if provided key exists for the class * @param {String} key */ static has(key: string): boolean; static hasRelationKey(key: string): boolean; static withId(id: ClassId): C; statics(): T; readonly isNew: boolean; id: ClassId; createdAt: string; updatedAt: string; deletedAt: string; /** * Set `id` for new objects * @param id */ setNewId(id: ClassId): void; /** * Increment the value of a numeric key * @param classInstance * @param key * @param value */ increment(key: string, value: number): void; /** * Set json values * @param classInstance * @param key * @param path */ json(key: string): { set(path: string, value: any): void; append(path: string, value: any): void; }; /** * toSqlString * @description Executed every time the object is being saved to the database */ toSqlString(): string | number; /** * toJSON * @description Executed every time the object is being stringified to an object literal */ toJSON(type?: string): ClassJSON; }