UNPKG

@decaf-ts/db-decorators

Version:

Agnostic database decorators and repository

194 lines (193 loc) 7.06 kB
import { IdOperationHandler, OperationHandler, StandardOperationHandler, UpdateOperationHandler } from "./types"; import { OperationKeys } from "./constants"; /** * @summary Defines a behaviour to set on the defined {@link DBOperations.CREATE_UPDATE} * * @param {OnOperationHandler<any>} handler The method called upon the operation * @param data * @param {any[]} [args] Arguments that will be passed in order to the handler method * * @see on * * @function onCreateUpdate * * @category Decorators */ export declare function onCreateUpdate<V = object>(handler: StandardOperationHandler<any, any, V, any, any> | UpdateOperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set on the defined {@link DBOperations.UPDATE} * * @param {OnOperationHandler<any>} handler The method called upon the operation * @param data * @param {any[]} [args] Arguments that will be passed in order to the handler method * * @see on * * @function onUpdate * * @category Decorators */ export declare function onUpdate<V = object>(handler: UpdateOperationHandler<any, any, V, any>, data?: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set on the defined {@link DBOperations.CREATE} * * @param {OnOperationHandler<any>} handler The method called upon the operation * @param data * * @see on * * @function onCreate * * @category Decorators */ export declare function onCreate<V = object>(handler: StandardOperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set on the defined {@link DBOperations.READ} * * @param {OnOperationHandler<any>} handler The method called upon the operation * @param data * * @see on * * @function onRead * * @category Decorators */ export declare function onRead<V = object>(handler: IdOperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set on the defined {@link DBOperations.DELETE} * * @param {OnOperationHandler<any>} handler The method called upon the operation * @param data * * @see on * * @function onDelete * * @category Decorators */ export declare function onDelete<V = object>(handler: OperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set on the defined {@link DBOperations.DELETE} * * @param {OnOperationHandler<any>} handler The method called upon the operation * @param data * * @see on * * @function onAny * * @category Decorators */ export declare function onAny<V = object>(handler: OperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set on the defined {@link DBOperations} * * @param {OperationKeys[] | DBOperations} op One of {@link DBOperations} * @param {OnOperationHandler<any>} handler The method called upon the operation * @param data * * ex: handler(...args, ...props.map(p => target[p])) * * @function on * * @category Decorators */ export declare function on<V = object>(op: OperationKeys[] | undefined, handler: OperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set after the defined {@link DBOperations.CREATE_UPDATE} * * @param {AfterOperationHandler<any>} handler The method called upon the operation * @param data * * @see after * * @function afterCreateUpdate * * @category Decorators */ export declare function afterCreateUpdate<V = object>(handler: StandardOperationHandler<any, any, V, any, any> | UpdateOperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set after the defined {@link DBOperations.UPDATE} * * @param {AfterOperationHandler<any>} handler The method called upon the operation * @param data * * @see after * * @function afterUpdate * * @category Decorators */ export declare function afterUpdate<V = object>(handler: UpdateOperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set after the defined {@link DBOperations.CREATE} * * @param {AfterOperationHandler<any>} handler The method called upon the operation * @param data * * @see after * * @function afterCreate * * @category Decorators */ export declare function afterCreate<V = object>(handler: StandardOperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set after the defined {@link DBOperations.READ} * * @param {AfterOperationHandler<any>} handler The method called upon the operation * @param data * @param {any[]} [args] Arguments that will be passed in order to the handler method * * @see after * * @function afterRead * * @category Decorators */ export declare function afterRead<V = object>(handler: StandardOperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set after the defined {@link DBOperations.DELETE} * * @param {AfterOperationHandler<any>} handler The method called upon the operation * @param data * @param {any[]} [args] Arguments that will be passed in order to the handler method * * @see after * * @function afterDelete * * @category Decorators */ export declare function afterDelete<V = object>(handler: StandardOperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set after the defined {@link DBOperations.DELETE} * * @param {AfterOperationHandler<any>} handler The method called upon the operation * @param data * @param {any[]} [args] Arguments that will be passed in order to the handler method * * @see after * * @function afterAny * * @category Decorators */ export declare function afterAny<V = object>(handler: StandardOperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void; /** * @summary Defines a behaviour to set on the defined {@link DBOperations} * * @param {OperationKeys[] | DBOperations} op One of {@link DBOperations} * @param {AfterOperationHandler<any>} handler The method called upon the operation * * ex: handler(...args, ...props.map(p => target[p])) * * @param data * @param args * @function after * * @category Decorators */ export declare function after<V = object>(op: OperationKeys[] | undefined, handler: OperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void; export declare function operation<V = object>(baseOp: OperationKeys.ON | OperationKeys.AFTER, operation: OperationKeys[] | undefined, handler: OperationHandler<any, any, V, any, any>, dataToAdd?: V): (target: object, propertyKey?: any) => void;