@martinmilo/verve
Version:
TypeScript domain modeling library with field-level authorization, business rule validation, and context-aware access control
34 lines • 1.55 kB
TypeScript
import type { ModelSchema, ModelChangeLog, ModelFields, ModelState, ModelConstructor, ModelKeys } from './types';
import { VerveErrorList } from '../../errors';
import { MODEL_CHANGE_LOG, MODEL_FIELDS, MODEL_INITIAL_STATE, MODEL_INITIALIZER, MODEL_PROXY, MODEL_STATE } from '../../constants';
export declare class Model<S extends ModelSchema | unknown = unknown> {
#private;
static modelName: string;
static schema: ModelSchema;
[MODEL_INITIALIZER](initializer: 'make' | 'from'): void;
[MODEL_INITIAL_STATE](state: ModelState<S>): void;
[MODEL_CHANGE_LOG](change: ModelChangeLog): void;
[MODEL_PROXY](proxyRef?: Model<S>): Model<S>;
[MODEL_STATE](): ModelState<S>;
[MODEL_FIELDS](): ModelFields<S>;
isNew(): boolean;
isExisting(): boolean;
getChanges(): Record<string, any>;
getChangeLog(): ModelChangeLog[];
validate(keys?: ModelKeys<S>): VerveErrorList;
generate(keys?: ModelKeys<S>): this;
unsafeGet(key: keyof S): any;
set(data: Partial<S>): this;
unset(keys: ModelKeys<S>): this;
only(keys: ModelKeys<S>): this;
except(keys: ModelKeys<S>): this;
isValid(): boolean;
hasValid(keys: ModelKeys<S>): boolean;
isEmpty(): boolean;
hasEmpty(keys: ModelKeys<S>): boolean;
isPresent(): boolean;
hasPresent(keys: ModelKeys<S>): boolean;
static Untyped(): ModelConstructor<any>;
static Typed<T extends keyof VerveModels | any = any>(): ModelConstructor<T extends keyof VerveModels ? VerveModels[T] : any>;
}
//# sourceMappingURL=Model.d.ts.map