import { FirestoreQuery } from '@nu-art/firebase'; import { DBDef_V3, DBProto, Module } from '@nu-art/ts-common'; import { CollectionActionType, FirestoreCollectionV3, PostWriteProcessingData } from '@nu-art/firebase/backend/firestore-v3/FirestoreCollectionV3'; import { DBApiBEConfig } from '../../core/db-def.js'; import { Response_DBSync } from '../../../shared/sync-manager/types.js'; import { Transaction } from 'firebase-admin/firestore'; import { EntityDependencyCollection } from '../collection-actions/dispatcher.js'; import { DBEntityDependencies } from '../../shared.js'; export type BaseDBApiConfigV3 = { projectId?: string; chunksSize: number; }; export type DBApiConfigV3> = BaseDBApiConfigV3 & DBApiBEConfig; /** * An abstract base class used for implementing CRUD operations on a specific collection. * * By default, it exposes API endpoints for creating, deleting, updating, querying and querying for unique document. */ export declare abstract class ModuleBE_BaseDB, ConfigType = any, Config extends ConfigType & DBApiConfigV3 = ConfigType & DBApiConfigV3> extends Module implements EntityDependencyCollection { private readonly ModuleBE_BaseDBV2; collection: FirestoreCollectionV3; dbDef: DBDef_V3; query: FirestoreCollectionV3['query']; create: FirestoreCollectionV3['create']; set: FirestoreCollectionV3['set']; delete: FirestoreCollectionV3['delete']; doc: FirestoreCollectionV3['doc']; runTransaction: FirestoreCollectionV3['runTransaction']; protected constructor(dbDef: DBDef_V3, appConfig?: BaseDBApiConfigV3); __collectEntityDependencies: >(type: T["dbKey"], itemIds: string[], transaction?: Transaction) => Promise; private mapConflicts; /** * Executed during the initialization of the module. * The collection reference is set in this method. */ init(): void; querySync: (syncQuery: FirestoreQuery) => Promise>; private _preWriteProcessing; /** * Override this method to customize the processing that should be done before create, set or update. * * @param transaction - The transaction object. * @param dbInstance - The DB entry for which the uniqueness is being asserted. * @param originalDbInstance - The DB instance fetched from remote firestore. */ protected preWriteProcessing(dbInstance: Proto['uiType'], originalDbInstance: Proto['dbType'], transaction?: Transaction): Promise; private _postWriteProcessing; /** * Override this method to customize processing that should be done after create, set, update or delete. * @param data * @param actionType create/set/update/delete * @param transaction */ protected postWriteProcessing(data: PostWriteProcessingData, actionType: CollectionActionType, transaction?: Transaction): Promise; manipulateQuery(query: FirestoreQuery): FirestoreQuery; preUpsertProcessing: never; /** * Override this method to provide actions or assertions to be executed before the deletion happens. * @param transaction - The transaction object * @param dbItems - The DB entry that is going to be deleted. */ canDeleteItems(dbItems: Proto['dbType'][], transaction?: Transaction): Promise; collectDependencies(dbInstances: Proto['dbType'][], transaction?: Transaction): Promise; private versionUpgrades; /** * Upgrades the entity from the given version to the next one (to the same version if the given version is the latest) * @param version - The version we start from * @param processor */ registerVersionUpgradeProcessor(version: K, processor: (items: Proto['versions']['types'][K][]) => Promise): void; /** * Check if the collection has at least one item without the latest version. Version[0] is the latest version. */ isCollectionUpToDate: () => Promise; upgradeCollection: (force?: boolean) => Promise; processCollection: (processInstances: (instances: Proto["dbType"][]) => Promise) => Promise; upgradeInstances(instances: Proto['dbType'][], force?: boolean): Promise; }