@decaf-ts/db-decorators
Version:
Agnostic database decorators and repository
64 lines (63 loc) • 2.27 kB
TypeScript
import { IRepository } from "../interfaces/IRepository";
import { DecoratorMetadata } from "@decaf-ts/reflection";
import { Constructor, Model } from "@decaf-ts/decorator-validation";
import { Context } from "./Context";
import { RepositoryFlags } from "./types";
export type ContextArgs<F extends RepositoryFlags = RepositoryFlags, C extends Context<F> = Context<F>> = {
context: C;
args: any[];
};
/**
* @summary retrieves the arguments for the handler
* @param {any} dec the decorator
* @param {string} prop the property name
* @param {{}} m the model
* @param {{}} [accum] accumulator used for internal recursiveness
*
* @function getHandlerArgs
* @memberOf module:db-decorators.Repository
*/
export declare const getHandlerArgs: (dec: any, prop: string, m: Constructor<any>, accum?: Record<string, {
args: string[];
}>) => Record<string, {
args: string[];
}> | void;
/**
*
* @param {IRepository<T>} repo
* @param context
* @param {T} model
* @param operation
* @param prefix
*
* @param oldModel
* @function enforceDBPropertyDecoratorsAsync
*
* @memberOf db-decorators.utils
*/
export declare function enforceDBDecorators<M extends Model, R extends IRepository<M, F, C>, V extends object = object, F extends RepositoryFlags = RepositoryFlags, C extends Context<F> = Context<F>>(repo: R, context: C, model: M, operation: string, prefix: string, oldModel?: M): Promise<void>;
/**
* Specific for DB Decorators
* @param {T} model
* @param {string} operation CRUD {@link OperationKeys}
* @param {string} [extraPrefix]
*
* @function getDbPropertyDecorators
*
* @memberOf db-decorators.utils
*/
export declare function getDbDecorators<T extends Model>(model: T, operation: string, extraPrefix?: string): Record<string, DecoratorMetadata[]> | undefined;
/**
* @summary Retrieves the decorators for an object's properties prefixed by {@param prefixes} recursively
* @param model
* @param accum
* @param prefixes
*
* @function getAllPropertyDecoratorsRecursive
* @memberOf module:db-decorators.Repository
*/
export declare const getAllPropertyDecoratorsRecursive: <T extends Model>(model: T, accum: {
[indexer: string]: any[];
} | undefined, ...prefixes: string[]) => {
[indexer: string]: any[];
} | undefined;