import type { AdapterFlags, AllOperationKeys, EventIds, FlagsOf, ObserverFilter, PersistenceObservable, PersistenceObserver } from "../persistence/types"; import { Context } from "../persistence/Context"; import { ContextualArgs, ContextualizedArgs, ContextualLoggedClass, MaybeContextualArg, MethodOrOperation } from "../utils/ContextualLoggedClass"; import { Constructor } from "@decaf-ts/decoration"; import type { Observer } from "../interfaces/Observer"; import { ObserverHandler } from "../persistence/ObserverHandler"; export declare abstract class Service = Context> extends ContextualLoggedClass implements PersistenceObservable, PersistenceObserver { readonly name?: string | undefined; protected observers: Observer[]; protected observerHandler?: ObserverHandler; protected constructor(name?: string | undefined); /** * @description Registers an observer for this repository. * @summary Adds an observer that will be notified of changes to models in this repository. * @param {Observer} observer - The observer to register. * @param {ObserverFilter} [filter] - Optional filter to limit which events the observer receives. * @return {void} * @see {Observable#observe} */ observe(observer: Observer, filter?: ObserverFilter): void; /** * @description Unregisters an observer from this repository. * @summary Removes an observer so it will no longer receive notifications of changes. * @param {Observer} observer - The observer to unregister. * @return {void} * @throws {InternalError} If the observer handler is not initialized. * @see {Observable#unObserve} */ unObserve(observer: Observer): void; /** * @description Notifies all observers of an event. * @summary Updates all registered observers with information about a database event. * @param {string} table - The table name where the event occurred. * @param {OperationKeys|BulkCrudOperationKeys|string} event - The type of event that occurred. * @param {EventIds} id - The ID or IDs of the affected records. * @param {...any[]} args - Additional arguments. * @return {Promise} A promise that resolves when all observers have been notified. * @throws {InternalError} If the observer handler is not initialized. */ updateObservers(table: Constructor | string, event: AllOperationKeys, id: EventIds, ...args: ContextualArgs): Promise; /** * @description Creates repository flags for an operation * @summary Generates a set of flags that describe a database operation, combining default flags with overrides * @template F - The Repository Flags type * @template M - The model type * @param {OperationKeys} operation - The type of operation being performed * @param {Partial} flags - Custom flag overrides * @param {...any[]} args - Additional arguments * @return {Promise} The complete set of flags */ protected flags(operation: string, flags: Partial>, ...args: any[]): Promise>; /** * @description Alias for updateObservers. * @summary Notifies all observers of an event (alias for updateObservers). * @param {string} table - The table name where the event occurred. * @param {OperationKeys|BulkCrudOperationKeys|string} event - The type of event that occurred. * @param {EventIds} id - The ID or IDs of the affected records. * @param {...any[]} args - Additional arguments. * @return {Promise} A promise that resolves when all observers have been notified. */ refresh(table: Constructor | string, event: AllOperationKeys, id: EventIds, ...args: ContextualArgs): Promise; /** * @description The context constructor for this adapter * @summary Reference to the context class constructor used by this adapter */ protected readonly Context: Constructor; context(operation: ((...args: any[]) => any) | string, overrides: Partial>, ...args: MaybeContextualArg>): Promise; protected logCtx = C, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg, operation: METHOD): ContextualizedArgs; protected logCtx = C, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg, operation: METHOD, allowCreate: false, overrides?: Partial>): ContextualizedArgs; protected logCtx = C, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg, operation: METHOD, allowCreate: true, overrides?: Partial>): Promise>; /** * @description Retrieves a Service instance by name/class * @summary Looks up and returns a cached API instance by its name or constructor * @template A Type extending Api * @param {string | Constructor} name - Name of the API or its constructor * @return {A} The requested API instance */ static get(name: string | symbol | Constructor): A; static boot = any>(...args: MaybeContextualArg): Promise; } export declare abstract class ClientBasedService = any> extends Service { protected _client?: CLIENT; protected _config?: CONF; protected constructor(); boot(...args: MaybeContextualArg): Promise; abstract initialize(...args: ContextualArgs): Promise<{ config: CONF; client: CLIENT; }>; protected get config(): CONF; get client(): CLIENT; shutdown(...args: MaybeContextualArg): Promise; }