import type { Firestore, DocumentReference, DocumentData, CollectionReference } from "firebase/firestore"; import type { FirebaseOptions } from "firebase/app"; import type { FirebaseStorage } from "firebase/storage"; import { BaseModel } from "./base.model"; import { ModelInterface } from "./interfaces/model.interface"; import { ElasticSqlResponse } from "./interfaces/elastic.sql.response.interface"; import { GlobalConfig } from "./interfaces/global.config.interface"; /** * Represents a repository for Firestore ORM. */ export declare class FirestoreOrmRepository { protected firestore: Firestore | any; static globalFirestores: {}; static globalWait: {}; static globalPaths: {}; static documentsRequiredFields: {}; static DEFAULT_KEY_NAME: string; static ormFieldsStructure: {}; static elasticSearchConnections: {}; static globalFirebaseStoages: {}; static isReady: boolean; static readyPromises: { [key: string]: Promise; }; static globalConfig: GlobalConfig; static usedPathIds: Set; private setupPromise; constructor(firestore: Firestore | any); private setupClientSDKCompatibility; /** * Initializes a global connection for Firestore ORM. * @param firestore - The Firestore instance. * @param key - The key to identify the global connection (optional). * @returns A promise that resolves when the connection is fully initialized. */ static initGlobalConnection(firestore: Firestore | any, key?: string): Promise; /** * Initializes the Firebase app and sets up a global connection for Firestore ORM. * @param options - The Firebase app options. * @param name - The name of the Firebase app (optional). * @returns The initialized Firebase app. */ static initializeApp(options: FirebaseOptions, name?: string | undefined): Promise; /** * Initializes a global storage for Firestore ORM. * @param storage - The Firebase storage instance. * @param key - The key to identify the global storage (optional). */ static initGlobalStorage(storage: FirebaseStorage | any, key?: string): void; /** * Initializes a global Elasticsearch connection for Firestore ORM. * @param url - The Elasticsearch URL. * @param key - The key to identify the global Elasticsearch connection (optional). */ static initGlobalElasticsearchConnection(url: string, key?: string): void; /** * Retrieves the global Firebase storage instance. * @param key - The key to identify the global storage (optional). * @returns The global Firebase storage instance. * @throws An error if the global Firebase storage is undefined. */ static getGlobalStorage(key?: string): FirebaseStorage | any; /** * Retrieves the global Elasticsearch connection. * @param key - The key to identify the global Elasticsearch connection (optional). * @returns The global Elasticsearch connection. * @throws An error if the global Elasticsearch connection is undefined. */ static getGlobalElasticsearchConnection(key?: string): any; /** * Retrieves the global Firestore connection. * @param key - The key to identify the global Firestore connection (optional). * @returns The global Firestore connection. * @throws An error if the global Firestore connection is undefined. */ static getGlobalConnection(key?: string): FirestoreOrmRepository; /** * Waits for the global Firestore connection to be ready. * @param key - The key to identify the global Firestore connection (optional). * @returns A promise that resolves to the global Firestore connection. */ static waitForGlobalConnection(key?: string): Promise; /** * Returns a promise that resolves when the global connection is ready. * This method provides a clean way to ensure initialization is complete. * @param key - The key to identify the global connection (optional). * @returns A promise that resolves when the connection is ready. */ static ready(key?: string): Promise; /** * Initializes a global path for Firestore ORM. * @param pathIdKey - The key to identify the global path. * @param pathIdValue - The value of the global path. */ static initGlobalPath(pathIdKey: string, pathIdValue: string): void; /** * Retrieves the global path by its key. * @param pathIdKey - The key of the global path. * @returns The value of the global path, or null if it is not defined. */ static getGlobalPath(pathIdKey: string): any; /** * Sets the global configuration for the ORM. * @param config - The global configuration options. */ static setGlobalConfig(config: Partial): void; /** * Gets the current global configuration. * @returns The current global configuration. */ static getGlobalConfig(): GlobalConfig; /** * Registers a path_id and validates it's unique globally. * @param pathId - The path_id to register. * @param modelName - The name of the model for error reporting. * @throws An error if the path_id is already in use. */ static registerPathId(pathId: string, modelName: string): void; /** * Clears all registered path_ids. Useful for testing. */ static clearRegisteredPathIds(): void; /** * Ensures the repository setup is complete before using Firebase functions. * @returns A promise that resolves when setup is complete. */ private ensureSetupComplete; /** * Retrieves the collection or document reference based on the model object (synchronous version). * This method will throw an error if the setup is not complete. * Use getCollectionReferenceByModelAsync for proper async handling. * @param object - The model object. * @param isDoc - Indicates whether the reference should be a document reference (optional, default: false). * @param customId - The custom ID for the document reference (optional). * @returns The collection or document reference, or null if the path cannot be determined. */ getCollectionReferenceByModel(object: any, isDoc?: boolean, customId?: string): DocumentReference | CollectionReference | null; /** * Retrieves the collection or document reference based on the model object (async version). * @param object - The model object. * @param isDoc - Indicates whether the reference should be a document reference (optional, default: false). * @param customId - The custom ID for the document reference (optional). * @returns The collection or document reference, or null if the path cannot be determined. */ getCollectionReferenceByModelAsync(object: any, isDoc?: boolean, customId?: string): Promise | CollectionReference | null>; /** * Retrieves the document reference based on the model object (synchronous version). * @param object - The model object. * @param customId - The custom ID for the document reference (optional). * @returns The document reference, or null if the path cannot be determined. */ getDocReferenceByModel(object: any, customId?: string): DocumentReference | null; /** * Retrieves the document reference based on the model object (async version). * @param object - The model object. * @param customId - The custom ID for the document reference (optional). * @returns The document reference, or null if the path cannot be determined. */ getDocReferenceByModelAsync(object: any, customId?: string): Promise | null>; /** * Retrieves the Firestore instance. * @returns The Firestore instance. */ getFirestore(): Firestore | any; /** * Retrieves the model object based on the model class. * @param model - The model class. * @returns The model object. * @throws Error if model is not a valid constructor */ getModel(model: { new (): T; }): T & BaseModel; /** * Loads a model object by its ID. * @param object - The model class. * @param id - The ID of the model object. * @param params - The path parameters (optional). * @returns A promise that resolves to the model object. */ load(object: any, id: string, params?: { [key: string]: string; }): Promise; /** * Saves the model object. * @param model - The model object. * @param customId - The custom ID for the document reference (optional). * @returns A promise that resolves to the saved model object. */ save(model: any, customId?: string): Promise; /** * Executes an Elasticsearch SQL query. * @param this - The model class. * @param sql - The SQL query (optional). * @param limit - The maximum number of results to retrieve (optional). * @param filters - The filters to apply to the query (optional). * @param cursor - The cursor for pagination (optional). * @param columns - The columns to retrieve (optional). * @returns A promise that resolves to the Elasticsearch SQL response. */ static elasticSql(this: { new (): T; }, sql?: string, limit?: number, filters?: any, cursor?: any, columns?: any): Promise; }