@decaf-ts/db-decorators
Version:
Agnostic database decorators and repository
194 lines (193 loc) • 6.85 kB
TypeScript
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<T>(handler: StandardOperationHandler<any, any, T, any> | UpdateOperationHandler<any, any, T, any>, data?: T): (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<T>(handler: UpdateOperationHandler<any, any, T, any>, data?: T): (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<T>(handler: StandardOperationHandler<any, any, T, any>, data?: T): (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<T>(handler: IdOperationHandler<any, any, T, any>, data: T): (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<T>(handler: OperationHandler<any, any, T, any>, data: T): (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<T>(handler: OperationHandler<any, any, T, any>, data: T): (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<T>(op: OperationKeys[] | undefined, handler: OperationHandler<any, any, T, any>, data?: T): (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<T>(handler: StandardOperationHandler<any, any, T, any> | UpdateOperationHandler<any, any, T, any>, data: T): (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<T>(handler: UpdateOperationHandler<any, any, T, any>, data: T): (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<T>(handler: StandardOperationHandler<any, any, T, any>, data: T): (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<T>(handler: StandardOperationHandler<any, any, T, any>, data?: T): (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<T>(handler: StandardOperationHandler<any, any, T, any>, data?: T): (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<T>(handler: StandardOperationHandler<any, any, T, any>, data?: T): (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<T>(op: OperationKeys[] | undefined, handler: OperationHandler<any, any, T, any>, data?: T): (target: object, propertyKey?: any) => void;
export declare function operation<T>(baseOp: OperationKeys.ON | OperationKeys.AFTER, operation: OperationKeys[] | undefined, handler: OperationHandler<any, any, T, any>, dataToAdd?: T): (target: object, propertyKey?: any) => void;