From c09810418e1f3962ea4fa7a8405af2abfaf91b27 Mon Sep 17 00:00:00 2001 From: Hage Yaapa Date: Mon, 24 Feb 2020 20:32:56 +0530 Subject: [PATCH] chore: typings for operation hooks in LB4 Added typings for supporting operation hooks in LB4. Signed-off-by: Hage Yaapa --- types/observer-mixin.d.ts | 6 +++++- types/persisted-model.d.ts | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/types/observer-mixin.d.ts b/types/observer-mixin.d.ts index 769a00bc5..6a020e6cd 100644 --- a/types/observer-mixin.d.ts +++ b/types/observer-mixin.d.ts @@ -5,7 +5,11 @@ import {Callback, PromiseOrVoid} from './common'; -export type Listener = (ctx: object, next: (err?: any) => void) => void; +export interface OperationHookContext { + [property: string]: any; +} + +export type Listener = (ctx: OperationHookContext, next: (err?: any) => void) => void; export interface ObserverMixin { /** diff --git a/types/persisted-model.d.ts b/types/persisted-model.d.ts index a5e1b5cb1..dd4af1ad8 100644 --- a/types/persisted-model.d.ts +++ b/types/persisted-model.d.ts @@ -5,6 +5,7 @@ import {Callback, Options, PromiseOrVoid} from './common'; import {ModelBase, ModelData} from './model'; +import {Listener} from './observer-mixin'; import {Filter, Where} from './query'; /** @@ -519,6 +520,10 @@ export declare class PersistedModel extends ModelBase { * @returns {String} The `id` property name */ static getIdName(): string; + + definePersistedModel(entityClass: T): PersistedModel; + + static observe(operation: string, handler: Listener): void; } export type PersistedModelClass = typeof PersistedModel;