@lpdjs/firestore-repo-service 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/query-builder.ts","../src/pagination.ts","../src/shared/utils.ts","../src/methods/query.ts","../src/methods/aggregate.ts","../src/methods/batch.ts","../src/methods/bulk.ts","../src/methods/crud.ts","../src/methods/get.ts","../src/methods/relations.ts","../src/methods/transaction.ts","../src/repositories/factory.ts","../index.ts"],"names":["q","chunkArray","applyQueryOptions","doc","data","capitalize"],"mappings":";;;AAMA,SAAS,UAAA,CAAc,OAAY,IAAA,EAAqB;AACtD,EAAA,MAAM,SAAgB,EAAC;AACvB,EAAA,KAAA,IAAS,IAAI,CAAA,EAAG,CAAA,GAAI,KAAA,CAAM,MAAA,EAAQ,KAAK,IAAA,EAAM;AAC3C,IAAA,MAAA,CAAO,KAAK,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,CAAA,GAAI,IAAI,CAAC,CAAA;AAAA,EACtC;AACA,EAAA,OAAO,MAAA;AACT;AAKA,SAAS,sBAAA,CAA0B,GAAU,OAAA,EAAiC;AAC5E,EAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,IAAA,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,CAAC,CAAA,KAAM;AAC7B,MAAA,CAAA,GAAI,CAAA,CAAE,QAAQ,MAAA,CAAO,CAAA,CAAE,KAAK,CAAA,EAAG,CAAA,CAAE,aAAa,KAAK,CAAA;AAAA,IACrD,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,IAAI,QAAQ,KAAA,EAAO;AACjB,IAAA,CAAA,GAAI,CAAA,CAAE,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAAA,EAC3B;AAEA,EAAA,IAAI,QAAQ,MAAA,EAAQ;AAClB,IAAA,CAAA,GAAI,CAAA,CAAE,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA;AAAA,E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C3C,MAAA,IAAA,CAAK,eAAA,CAAgB,GAAG,CAAA,GAAI,gBAAA;AAAA,QAC1B,IAAA,CAAK,EAAA;AAAA,QACL,IAAA,CAAK,QAAQ,GAAG,CAAA;AAAA,QAChB,IAAA,CAAK;AAAA,OACP;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cAAiC,GAAA,EAAoC;AACnE,IAAA,OAAO,IAAA,CAAK,gBAAgB,GAAa,CAAA;AAAA,EAC3C;AACF;AAiCO,SAAS,uBAAA,CACd,IACA,OAAA,EACuE;AACvE,EAAA,MAAM,QAAA,GAAW,IAAI,iBAAA,CAAkB,EAAA,EAAI,OAAO,CAAA;AAGlD,EAAA,OAAO,IAAI,MAAM,QAAA,EAAU;AAAA,IACzB,GAAA,CAAI,QAAQ,IAAA,EAAM;AAChB,MAAA,IAAI,OAAO,IAAA,KAAS,QAAA,IAAY,IAAA,IAAQ,OAAA,EAAS;AAC/C,QAAA,OAAO,MAAA,CAAO,cAAc,IAAe,CAAA;AAAA,MAC7C;AACA,MAAA,OAAQ,OAAe,IAAI,CAAA;AAAA,IAC7B;AAAA,GACD,CAAA;AACH","file":"index.cjs","sourcesContent":["import type { Query, QuerySnapshot } from \"firebase-admin/firestore\";\nimport type { QueryOptions, WhereClause } from \"./shared/types\";\n\n/**\n * Chunk array into smaller arrays\n */\nfunction chunkArray<T>(array: T[], size: number): T[][] {\n const chunks: T[][] = [];\n for (let i = 0; i < array.length; i += size) {\n chunks.push(array.slice(i, i + size));\n }\n return chunks;\n}\n\n/**\n * Apply basic query options (orderBy, limit, offset, cursors)\n */\nfunction applyBasicQueryOptions<T>(q: Query, options: QueryOptions<T>): Query {\n if (options.orderBy) {\n options.orderBy.forEach((o) => {\n q = q.orderBy(String(o.field), o.direction || \"asc\");\n });\n }\n\n if (options.limit) {\n q = q.limit(options.limit);\n }\n\n if (options.offset) {\n q = q.offset(options.offset);\n }\n\n // Cursor-based pagination\n if (options.startAt) {\n q = Array.isArray(options.startAt)\n ? q.startAt(...options.startAt)\n : q.startAt(options.startAt);\n }\n\n if (options.startAfter) {\n q = Array.isArray(options.startAfter)\n ? q.startAfter(...options.startAfter)\n : q.startAfter(options.startAfter);\n }\n\n if (options.endAt) {\n q = Array.isArray(options.endAt)\n ? q.endAt(...options.endAt)\n : q.endAt(options.endAt);\n }\n\n if (options.endBefore) {\n q = Array.isArray(options.endBefore)\n ? q.endBefore(...options.endBefore)\n : q.endBefore(options.endBefore);\n }\n\n return q;\n}\n\n/**\n * Check if a where clause needs splitting (in or array-contains-any with > 30 values)\n */\nfunction needsSplitting<T>(clause: WhereClause<T>): boolean {\n const { operator, value } = clause;\n return (\n (operator === \"in\" || operator === \"array-contains-any\") &&\n Array.isArray(value) &&\n value.length > 30\n );\n}\n\n/**\n * Split a where clause into multiple clauses (for in/array-contains-any)\n */\nfunction splitWhereClause<T>(clause: WhereClause<T>): WhereClause<T>[] {\n const { field, operator, value } = clause;\n\n if (!needsSplitting(clause)) {\n return [clause];\n }\n\n // Split array into chunks of 30\n const chunks = chunkArray(value as any[], 30);\n return chunks.map((chunk) => ({\n field,\n operator,\n value: chunk,\n }));\n}\n\n/**\n * Apply where clauses to a query, handling splits for in/array-contains-any\n */\nfunction applyWhereClausesToQuery<T>(\n baseQuery: Query,\n whereClauses: WhereClause<T>[]\n): Query {\n let q = baseQuery;\n\n for (const clause of whereClauses) {\n q = q.where(String(clause.field), clause.operator, clause.value);\n }\n\n return q;\n}\n\n/**\n * Execute multiple queries in parallel and merge results\n */\nasync function executeAndMergeQueries(\n queries: Query[]\n): Promise<QuerySnapshot> {\n const snapshots = await Promise.all(queries.map((q) => q.get()));\n\n // Merge all documents, removing duplicates by ID\n const docsMap = new Map();\n snapshots.forEach((snapshot) => {\n snapshot.docs.forEach((doc) => {\n if (!docsMap.has(doc.id)) {\n docsMap.set(doc.id, doc);\n }\n });\n });\n\n // Return first snapshot with merged docs\n const firstSnapshot = snapshots[0];\n if (!firstSnapshot) {\n throw new Error(\"No snapshots returned\");\n }\n\n // Create a merged snapshot-like object\n return {\n ...firstSnapshot,\n docs: Array.from(docsMap.values()),\n size: docsMap.size,\n empty: docsMap.size === 0,\n } as QuerySnapshot;\n}\n\n/**\n * Build and execute query with automatic splitting for in/array-contains-any\n * Handles both simple AND conditions and complex OR conditions\n */\nexport async function buildAndExecuteQuery<T>(\n baseQuery: Query,\n options: QueryOptions<T>\n): Promise<QuerySnapshot> {\n // Case 1: Simple AND query with where\n if (options.where && !options.orWhere) {\n // Check if any clause needs splitting\n const needsSplit = options.where.some(needsSplitting);\n\n if (!needsSplit) {\n // Simple case: no splitting needed\n let q = applyWhereClausesToQuery(baseQuery, options.where);\n q = applyBasicQueryOptions(q, options);\n return q.get();\n }\n\n // Split clauses that need it\n const splitClauses: WhereClause<T>[][] =\n options.where.map(splitWhereClause);\n\n // Generate all combinations (Cartesian product)\n const combinations = cartesianProduct(splitClauses);\n\n // Create queries for each combination\n const queries = combinations.map((combination) => {\n let q = applyWhereClausesToQuery(baseQuery, combination);\n q = applyBasicQueryOptions(q, options);\n return q;\n });\n\n return executeAndMergeQueries(queries);\n }\n\n // Case 2: OR query with orWhere\n if (options.orWhere) {\n const allQueries: Query[] = [];\n\n for (const orGroup of options.orWhere) {\n // Check if any clause in this OR group needs splitting\n const needsSplit = orGroup.some(needsSplitting);\n\n if (!needsSplit) {\n // Simple case for this OR group\n let q = applyWhereClausesToQuery(baseQuery, orGroup);\n q = applyBasicQueryOptions(q, options);\n allQueries.push(q);\n } else {\n // Split clauses that need it\n const splitClauses = orGroup.map(splitWhereClause);\n\n // Generate all combinations for this OR group\n const combinations = cartesianProduct(splitClauses);\n\n // Create queries for each combination\n const groupQueries = combinations.map((combination) => {\n let q = applyWhereClausesToQuery(baseQuery, combination);\n q = applyBasicQueryOptions(q, options);\n return q;\n });\n\n allQueries.push(...groupQueries);\n }\n }\n\n return executeAndMergeQueries(allQueries);\n }\n\n // Case 3: No where clauses, just apply basic options\n const q = applyBasicQueryOptions(baseQuery, options);\n return q.get();\n}\n\n/**\n * Generate Cartesian product of arrays\n * Example: [[a,b], [1,2]] => [[a,1], [a,2], [b,1], [b,2]]\n */\nfunction cartesianProduct<T>(arrays: T[][]): T[][] {\n if (arrays.length === 0) return [[]];\n\n const first = arrays[0];\n if (arrays.length === 1 && first) {\n return first.map((item) => [item]);\n }\n\n if (!first) return [[]];\n\n const rest = arrays.slice(1);\n const restProduct = cartesianProduct(rest);\n\n const result: T[][] = [];\n for (const item of first) {\n for (const combo of restProduct) {\n result.push([item, ...combo]);\n }\n }\n\n return result;\n}\n","import type { DocumentSnapshot, Query } from \"firebase-admin/firestore\";\nimport { buildAndExecuteQuery } from \"./query-builder\";\nimport type { QueryOptions } from \"./shared/types\";\n\n/**\n * Pagination result with data and cursor information\n * @template T - Data model type\n */\nexport interface PaginationResult<T> {\n /** Array of documents for the current page */\n data: T[];\n /** Cursor to the next page (undefined if no more pages) */\n nextCursor?: DocumentSnapshot;\n /** Cursor to the previous page (undefined if on first page) */\n prevCursor?: DocumentSnapshot;\n /** Whether there are more pages after this one */\n hasNextPage: boolean;\n /** Whether there are pages before this one */\n hasPrevPage: boolean;\n /** Total number of items in current page */\n pageSize: number;\n}\n\n/**\n * Pagination options for cursor-based pagination\n * @template T - Data model type\n */\nexport interface PaginationOptions<T> extends Omit<QueryOptions<T>, \"limit\"> {\n /** Number of items per page */\n pageSize: number;\n /** Cursor to start after (for next page) */\n cursor?: DocumentSnapshot;\n /** Direction of pagination */\n direction?: \"next\" | \"prev\";\n}\n\n/**\n * Helper to apply query options to a Firestore query\n */\nexport function applyQueryOptions<T>(\n q: Query,\n options: QueryOptions<T>\n): Query {\n if (options.where) {\n options.where.forEach((w) => {\n q = q.where(String(w.field), w.operator, w.value);\n });\n }\n\n if (options.orderBy) {\n options.orderBy.forEach((o) => {\n q = q.orderBy(String(o.field), o.direction || \"asc\");\n });\n }\n\n if (options.limit) {\n q = q.limit(options.limit);\n }\n\n if (options.offset) {\n q = q.offset(options.offset);\n }\n\n // Cursor-based pagination\n if (options.startAt) {\n q = Array.isArray(options.startAt)\n ? q.startAt(...options.startAt)\n : q.startAt(options.startAt);\n }\n\n if (options.startAfter) {\n q = Array.isArray(options.startAfter)\n ? q.startAfter(...options.startAfter)\n : q.startAfter(options.startAfter);\n }\n\n if (options.endAt) {\n q = Array.isArray(options.endAt)\n ? q.endAt(...options.endAt)\n : q.endAt(options.endAt);\n }\n\n if (options.endBefore) {\n q = Array.isArray(options.endBefore)\n ? q.endBefore(...options.endBefore)\n : q.endBefore(options.endBefore);\n }\n\n return q;\n}\n\n/**\n * Executes a paginated query and returns results with pagination info\n * Uses the advanced query builder that handles OR conditions and automatic splitting\n * @template T - Data model type\n * @param baseQuery - Base Firestore query\n * @param options - Pagination options\n * @returns Pagination result with data and cursor information\n */\nexport async function executePaginatedQuery<T>(\n baseQuery: Query,\n options: PaginationOptions<T>\n): Promise<PaginationResult<T>> {\n // Prepare options with cursor-based pagination\n const queryOptions: QueryOptions<T> = {\n ...options,\n limit: options.pageSize + 1, // Fetch one extra to check if there's a next page\n };\n\n // Apply cursor\n if (options.cursor) {\n if (options.direction === \"prev\") {\n queryOptions.endBefore = options.cursor;\n } else {\n queryOptions.startAfter = options.cursor;\n }\n }\n\n // Use the advanced query builder (handles OR and auto-splitting)\n const snapshot = await buildAndExecuteQuery(baseQuery, queryOptions);\n const docs = snapshot.docs;\n\n // Check if there are more pages\n const hasMore = docs.length > options.pageSize;\n const actualDocs = hasMore ? docs.slice(0, options.pageSize) : docs;\n\n const data = actualDocs.map((doc) => ({\n ...doc.data(),\n docId: doc.id,\n })) as T[];\n\n return {\n data,\n nextCursor: hasMore ? actualDocs[actualDocs.length - 1] : undefined,\n prevCursor: actualDocs[0],\n hasNextPage: hasMore,\n hasPrevPage: !!options.cursor,\n pageSize: data.length,\n };\n}\n\n/**\n * Creates an async generator for iterating through all pages\n * @template T - Data model type\n * @param baseQuery - Base Firestore query\n * @param options - Pagination options (without cursor)\n * @yields Pagination results for each page\n * @example\n * ```typescript\n * const pageIterator = createPaginationIterator(query, { pageSize: 10 });\n * for await (const page of pageIterator) {\n * console.log(`Page with ${page.pageSize} items`);\n * page.data.forEach(item => console.log(item));\n * if (!page.hasNextPage) break;\n * }\n * ```\n */\nexport async function* createPaginationIterator<T>(\n baseQuery: Query,\n options: Omit<PaginationOptions<T>, \"cursor\" | \"direction\">\n): AsyncGenerator<PaginationResult<T>, void, unknown> {\n let cursor: DocumentSnapshot | undefined;\n let hasMore = true;\n\n while (hasMore) {\n const result = await executePaginatedQuery<T>(baseQuery, {\n ...options,\n cursor,\n direction: \"next\",\n });\n\n yield result;\n\n hasMore = result.hasNextPage;\n cursor = result.nextCursor;\n }\n}\n","/**\n * Split an array into chunks of specified size\n */\nexport function chunkArray<T>(array: T[], size: number): T[][] {\n const chunks: T[][] = [];\n for (let i = 0; i < array.length; i += size) {\n chunks.push(array.slice(i, i + size));\n }\n return chunks;\n}\n\n/**\n * Capitalize first letter of a string\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n","import type { Query, QuerySnapshot } from \"firebase-admin/firestore\";\nimport {\n createPaginationIterator,\n executePaginatedQuery,\n type PaginationOptions,\n} from \"../pagination\";\nimport type { QueryOptions } from \"../shared/types\";\nimport { capitalize } from \"../shared/utils\";\n\n/**\n * Apply query options to a Firestore query\n */\nexport function applyQueryOptions(q: Query, options: QueryOptions): Query {\n if (options.where) {\n options.where.forEach((w) => {\n q = q.where(String(w.field), w.operator, w.value);\n });\n }\n\n if (options.orderBy) {\n options.orderBy.forEach((o) => {\n q = q.orderBy(String(o.field), o.direction || \"asc\");\n });\n }\n\n if (options.limit) {\n q = q.limit(options.limit);\n }\n\n if (options.offset) {\n q = q.offset(options.offset);\n }\n\n // Cursor-based pagination\n if (options.startAt) {\n q = Array.isArray(options.startAt)\n ? q.startAt(...options.startAt)\n : q.startAt(options.startAt);\n }\n\n if (options.startAfter) {\n q = Array.isArray(options.startAfter)\n ? q.startAfter(...options.startAfter)\n : q.startAfter(options.startAfter);\n }\n\n if (options.endAt) {\n q = Array.isArray(options.endAt)\n ? q.endAt(...options.endAt)\n : q.endAt(options.endAt);\n }\n\n if (options.endBefore) {\n q = Array.isArray(options.endBefore)\n ? q.endBefore(...options.endBefore)\n : q.endBefore(options.endBefore);\n }\n\n return q;\n}\n\n/**\n * Creates query.by* methods for query keys\n */\nexport function createQueryMethods(\n collectionRef: Query,\n queryKeys: readonly string[]\n) {\n const queryMethods: any = {};\n\n // Generate query.by* methods for each query key\n queryKeys.forEach((queryKey: string) => {\n const methodName = `by${capitalize(String(queryKey))}`;\n queryMethods[methodName] = async (\n value: string,\n options: QueryOptions = {}\n ): Promise<any[]> => {\n let q: Query = collectionRef as any;\n q = q.where(String(queryKey), \"==\", value);\n q = applyQueryOptions(q, options);\n const snapshot: QuerySnapshot = await q.get();\n return snapshot.docs.map((doc) => ({ ...doc.data(), docId: doc.id }));\n };\n });\n\n // Generic query.by method\n queryMethods.by = async (options: QueryOptions): Promise<any[]> => {\n let q: Query = collectionRef as any;\n q = applyQueryOptions(q, options);\n const snapshot: QuerySnapshot = await q.get();\n return snapshot.docs.map((doc) => ({ ...doc.data(), docId: doc.id }));\n };\n\n // getAll - retrieve all documents\n queryMethods.getAll = async (options: QueryOptions = {}): Promise<any[]> => {\n let q: Query = collectionRef as any;\n q = applyQueryOptions(q, options);\n const snapshot: QuerySnapshot = await q.get();\n return snapshot.docs.map((doc) => ({ ...doc.data(), docId: doc.id }));\n };\n\n // onSnapshot - real-time listener\n queryMethods.onSnapshot = (\n options: QueryOptions,\n onNext: (data: any[]) => void,\n onError?: (error: Error) => void\n ): (() => void) => {\n let q: Query = collectionRef as any;\n q = applyQueryOptions(q, options);\n\n return q.onSnapshot((snapshot) => {\n const data = snapshot.docs.map((doc) => ({\n ...doc.data(),\n docId: doc.id,\n }));\n onNext(data);\n }, onError);\n };\n\n // Pagination methods\n queryMethods.paginate = async (options: PaginationOptions<any>) => {\n return executePaginatedQuery(collectionRef as Query, options);\n };\n\n queryMethods.paginateAll = (\n options: Omit<PaginationOptions<any>, \"cursor\" | \"direction\">\n ) => {\n return createPaginationIterator(collectionRef as Query, options);\n };\n\n return queryMethods;\n}\n","import type { Query } from \"firebase-admin/firestore\";\nimport type { QueryOptions } from \"../shared/types\";\nimport { applyQueryOptions } from \"./query\";\n\n/**\n * Creates aggregate methods for server-side computations\n */\nexport function createAggregateMethods(collectionRef: Query) {\n return {\n // Count documents matching query options\n count: async (options: QueryOptions = {}): Promise<number> => {\n let q: Query = collectionRef as any;\n q = applyQueryOptions(q, options);\n const snapshot = await q.count().get();\n return snapshot.data().count;\n },\n\n // Sum of a numeric field\n sum: async (field: string, options: QueryOptions = {}): Promise<number> => {\n let q: Query = collectionRef as any;\n q = applyQueryOptions(q, options);\n const snapshot = await q.get();\n\n let total = 0;\n snapshot.forEach((doc) => {\n const value = doc.data()[field];\n if (typeof value === \"number\") {\n total += value;\n }\n });\n\n return total;\n },\n\n // Average of a numeric field\n average: async (\n field: string,\n options: QueryOptions = {}\n ): Promise<number | null> => {\n let q: Query = collectionRef as any;\n q = applyQueryOptions(q, options);\n const snapshot = await q.get();\n\n if (snapshot.empty) return null;\n\n let total = 0;\n let count = 0;\n\n snapshot.forEach((doc) => {\n const value = doc.data()[field];\n if (typeof value === \"number\") {\n total += value;\n count++;\n }\n });\n\n return count > 0 ? total / count : null;\n },\n };\n}\n","import type { Firestore, WriteBatch } from \"firebase-admin/firestore\";\n\n/**\n * Creates batch operation methods\n */\nexport function createBatchMethods(\n db: Firestore,\n documentRef: (...args: any[]) => any\n) {\n return {\n create: () => {\n const batch: WriteBatch = db.batch();\n return {\n batch,\n set: (...args: any[]) => {\n const lastArg = args[args.length - 1];\n const hasOptions =\n typeof lastArg === \"object\" &&\n lastArg !== null &&\n \"merge\" in lastArg;\n\n const data = hasOptions\n ? args[args.length - 2]\n : args[args.length - 1];\n const pathArgs = hasOptions ? args.slice(0, -2) : args.slice(0, -1);\n const mergeOption = hasOptions ? lastArg : { merge: true };\n\n const docRef = documentRef(...pathArgs);\n batch.set(docRef, data, mergeOption);\n },\n update: (...args: any[]) => {\n const data = args.pop();\n const pathArgs = args;\n const docRef = documentRef(...pathArgs);\n batch.update(docRef, data);\n },\n delete: (...args: any[]) => {\n const docRef = documentRef(...args);\n batch.delete(docRef);\n },\n commit: async () => {\n await batch.commit();\n },\n };\n },\n };\n}\n","import type { DocumentReference, Firestore } from \"firebase-admin/firestore\";\n\n/**\n * Creates bulk operation methods using BulkWriter\n */\nexport function createBulkMethods(db: Firestore) {\n return {\n // Set multiple documents with automatic batching (500 ops per flush)\n set: async (\n items: Array<{\n docRef: DocumentReference;\n data: any;\n merge?: boolean;\n }>\n ) => {\n const bulkWriter = db.bulkWriter();\n let pendingOps = 0;\n\n for (const item of items) {\n if (!item) continue;\n const { docRef, data, merge = true } = item;\n bulkWriter.set(docRef, data, { merge });\n pendingOps++;\n\n if (pendingOps >= 500) {\n await bulkWriter.flush();\n pendingOps = 0;\n }\n }\n\n await bulkWriter.close();\n },\n\n // Update multiple documents with automatic batching\n update: async (items: Array<{ docRef: DocumentReference; data: any }>) => {\n const bulkWriter = db.bulkWriter();\n let pendingOps = 0;\n\n for (const item of items) {\n if (!item) continue;\n const { docRef, data } = item;\n bulkWriter.update(docRef, data);\n pendingOps++;\n\n if (pendingOps >= 500) {\n await bulkWriter.flush();\n pendingOps = 0;\n }\n }\n\n await bulkWriter.close();\n },\n\n // Delete multiple documents with automatic batching\n delete: async (docRefs: DocumentReference[]) => {\n const bulkWriter = db.bulkWriter();\n let pendingOps = 0;\n\n for (const docRef of docRefs) {\n if (!docRef) continue;\n bulkWriter.delete(docRef);\n pendingOps++;\n\n if (pendingOps >= 500) {\n await bulkWriter.flush();\n pendingOps = 0;\n }\n }\n\n await bulkWriter.close();\n },\n };\n}\n","import type { CollectionReference } from \"firebase-admin/firestore\";\n\n/**\n * Creates CRUD methods (create, set, update, delete)\n */\nexport function createCrudMethods(\n actualCollection: CollectionReference | null,\n documentRef: (...args: any[]) => any\n) {\n // Create - adds a new document with auto-generated ID\n const create = async (data: any): Promise<any> => {\n if (!actualCollection) {\n throw new Error(\n \"Cannot use create() on collection groups. Use set() with a specific document ID instead.\"\n );\n }\n const docRef = await actualCollection.add(data);\n const createdDoc = await docRef.get();\n return { ...createdDoc.data(), docId: docRef.id };\n };\n\n // Set - creates or replaces a document\n const set = async (...args: any[]): Promise<any> => {\n const lastArg = args[args.length - 1];\n const hasOptions =\n typeof lastArg === \"object\" && lastArg !== null && \"merge\" in lastArg;\n\n const data = hasOptions ? args[args.length - 2] : args[args.length - 1];\n const pathArgs = hasOptions ? args.slice(0, -2) : args.slice(0, -1);\n const mergeOption = hasOptions ? lastArg : { merge: true };\n\n const docRef = documentRef(...pathArgs);\n await docRef.set(data, mergeOption);\n\n const setDocument = await docRef.get();\n return { ...setDocument.data(), docId: docRef.id };\n };\n\n // Update - updates a document and returns the merged object\n const update = async (...args: any[]): Promise<any> => {\n const data = args.pop();\n const pathArgs = args;\n\n const docRef = documentRef(...pathArgs);\n await docRef.update(data);\n\n const updatedDoc = await docRef.get();\n return { ...updatedDoc.data(), docId: docRef.id };\n };\n\n // Delete - removes a document\n const deleteMethod = async (...args: any[]): Promise<void> => {\n const docRef = documentRef(...args);\n await docRef.delete();\n };\n\n return {\n create,\n set,\n update,\n delete: deleteMethod,\n };\n}\n","import type {\n CollectionReference,\n DocumentReference,\n Query,\n QuerySnapshot,\n} from \"firebase-admin/firestore\";\nimport { capitalize, chunkArray } from \"../shared/utils\";\n\n/**\n * Creates get.by* methods for foreign keys\n */\nexport function createGetMethods(\n collectionRef: Query,\n foreignKeys: readonly string[],\n actualCollection: CollectionReference | null,\n documentRef: (...args: any[]) => DocumentReference\n) {\n const getMethods: any = {};\n\n // get.byList - retrieve multiple documents by list of values\n getMethods.byList = async (\n key: string,\n values: any[],\n operator: \"in\" | \"array-contains-any\" = \"in\",\n returnDoc = false\n ): Promise<any[]> => {\n if (values.length === 0) return [];\n\n const results: any[] = [];\n const chunks = chunkArray(values, 30); // Firestore limits 'in' to 30 elements\n\n for (const chunk of chunks) {\n let q: Query = collectionRef as any;\n q = q.where(key, operator, chunk);\n const snapshot: QuerySnapshot = await q.get();\n\n snapshot.forEach((doc) => {\n const data = doc.data();\n results.push(returnDoc ? { data, doc } : { ...data, docId: doc.id });\n });\n }\n\n return results;\n };\n\n // Generate get.by* methods for each foreign key\n foreignKeys.forEach((foreignKey: string) => {\n const methodName = `by${capitalize(String(foreignKey))}`;\n getMethods[methodName] = async (\n value: string,\n returnDoc = false\n ): Promise<any | null> => {\n // Special case: if foreignKey is \"docId\", use direct document reference\n if (String(foreignKey) === \"docId\") {\n const docRef = documentRef(value);\n const doc = await docRef.get();\n if (!doc.exists) return null;\n const data = doc.data();\n return returnDoc ? { data, doc } : { ...data, docId: doc.id };\n }\n\n // For other keys, query by field value\n let q: Query = collectionRef as any;\n q = q.where(String(foreignKey), \"==\", value).limit(1);\n const snapshot: QuerySnapshot = await q.get();\n if (snapshot.empty) return null;\n const doc = snapshot.docs[0];\n if (!doc) return null;\n const data = doc.data();\n return returnDoc ? { data, doc } : { ...data, docId: doc.id };\n };\n });\n\n return getMethods;\n}\n","import type { RelationConfig, RepositoryConfig } from \"../shared/types\";\n\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never;\n\ntype PopulatedData<\n TRelationalKeys,\n K extends keyof TRelationalKeys\n> = TRelationalKeys[K] extends RelationConfig<infer TRepo, any, infer TType>\n ? TType extends \"one\"\n ? { [R in TRepo]: any | null }\n : { [R in TRepo]: any[] }\n : never;\n\n/**\n * Creates populate methods for resolving relations between repositories\n * @internal\n */\nexport function createPopulateMethods<\n T,\n TForeignKeys extends readonly (keyof T)[],\n TQueryKeys extends readonly (keyof T)[],\n TIsGroup extends boolean,\n TRefCb,\n TRelationalKeys extends Record<string, any>,\n TConfig extends RepositoryConfig<\n T,\n TForeignKeys,\n TQueryKeys,\n TIsGroup,\n TRefCb,\n TRelationalKeys\n >\n>(\n config: TConfig,\n allRepositories: Record<string, any>\n): {\n populate: <K extends keyof NonNullable<TConfig[\"relationalKeys\"]>>(\n document: T,\n relationKey: K | K[]\n ) => Promise<\n T & {\n populated: UnionToIntersection<\n PopulatedData<NonNullable<TConfig[\"relationalKeys\"]>, K>\n >;\n }\n >;\n} {\n return {\n populate: async (document: any, relationKey: any) => {\n if (!config.relationalKeys) {\n return { ...document, populated: {} };\n }\n\n const keys = Array.isArray(relationKey) ? relationKey : [relationKey];\n const result = { ...document };\n const populated: Record<string, any> = {};\n\n for (const key of keys) {\n const relation: RelationConfig | undefined =\n config.relationalKeys?.[key as string];\n if (!relation) {\n console.warn(\n `[populate] Relation \"${String(key)}\" not found in config`\n );\n continue;\n }\n\n const targetRepo = allRepositories[relation.repo];\n if (!targetRepo) {\n console.warn(\n `[populate] Repository \"${relation.repo}\" not found in mapping`\n );\n continue;\n }\n\n const fieldValue = document[key];\n if (fieldValue === undefined || fieldValue === null) {\n populated[relation.repo] = relation.type === \"one\" ? null : [];\n continue;\n }\n\n try {\n if (relation.type === \"one\") {\n // One-to-one: Get single document\n const getMethod = `by${capitalize(relation.key)}`;\n if (typeof targetRepo.get?.[getMethod] === \"function\") {\n populated[relation.repo] = await targetRepo.get[getMethod](\n fieldValue\n );\n } else {\n console.warn(\n `[populate] Method \"get.${getMethod}\" not found in ${relation.repo}`\n );\n populated[relation.repo] = null;\n }\n } else {\n // One-to-many: Query multiple documents\n const queryMethod = `by${capitalize(relation.key)}`;\n if (typeof targetRepo.query[queryMethod] === \"function\") {\n populated[relation.repo] = await targetRepo.query[queryMethod](\n fieldValue\n );\n } else {\n console.warn(\n `[populate] Method \"query.${queryMethod}\" not found in ${relation.repo}`\n );\n populated[relation.repo] = [];\n }\n }\n } catch (error) {\n console.error(`[populate] Error populating \"${String(key)}\":`, error);\n populated[relation.repo] = relation.type === \"one\" ? null : [];\n }\n }\n\n return { ...result, populated };\n },\n };\n}\n\n/**\n * Utility to capitalize first letter\n */\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n","import type { Firestore } from \"firebase-admin/firestore\";\n\n/**\n * Creates transaction operation methods\n */\nexport function createTransactionMethods(\n db: Firestore,\n documentRef: (...args: any[]) => any\n) {\n return {\n run: async <R>(\n updateFunction: (transaction: any) => Promise<R>\n ): Promise<R> => {\n return db.runTransaction(async (rawTransaction) => {\n const typedTransaction = {\n // Type-safe get method\n get: async (...args: any[]) => {\n const docRef = documentRef(...args);\n const docSnap = (await rawTransaction.get(docRef)) as any;\n if (!docSnap.exists) return null;\n return { ...docSnap.data(), docId: docSnap.id } as any;\n },\n\n // Type-safe set method\n set: (...args: any[]) => {\n const options = args[args.length - 1];\n const hasOptions =\n typeof options === \"object\" &&\n options !== null &&\n \"merge\" in options;\n\n const data = hasOptions\n ? args[args.length - 2]\n : args[args.length - 1];\n const pathArgs = hasOptions ? args.slice(0, -2) : args.slice(0, -1);\n const mergeOption = hasOptions ? options : { merge: true };\n\n const docRef = documentRef(...pathArgs);\n rawTransaction.set(docRef, data, mergeOption);\n },\n\n // Type-safe update method\n update: (...args: any[]) => {\n const data = args[args.length - 1];\n const pathArgs = args.slice(0, -1);\n const docRef = documentRef(...pathArgs);\n rawTransaction.update(docRef, data);\n },\n\n // Delete method\n delete: (...args: any[]) => {\n const docRef = documentRef(...args);\n rawTransaction.delete(docRef);\n },\n\n // Access to raw transaction\n raw: rawTransaction,\n };\n\n return updateFunction(typedTransaction);\n });\n },\n };\n}\n","import type {\n CollectionReference,\n Firestore,\n Query,\n} from \"firebase-admin/firestore\";\nimport { createAggregateMethods } from \"../methods/aggregate\";\nimport { createBatchMethods } from \"../methods/batch\";\nimport { createBulkMethods } from \"../methods/bulk\";\nimport { createCrudMethods } from \"../methods/crud\";\nimport { createGetMethods } from \"../methods/get\";\nimport { createQueryMethods } from \"../methods/query\";\nimport { createPopulateMethods } from \"../methods/relations\";\nimport { createTransactionMethods } from \"../methods/transaction\";\nimport type { RepositoryConfig } from \"../shared/types\";\nimport type { ConfiguredRepository } from \"./types\";\n\n/**\n * Creates a configured repository instance with all methods\n */\nexport function createRepository<\n T extends RepositoryConfig<any, any, any, any>\n>(\n db: Firestore,\n config: T,\n allRepositories: Record<string, any> = {}\n): ConfiguredRepository<T> {\n // Create collection reference\n const collectionRef: CollectionReference | Query = config.isGroup\n ? db.collectionGroup(config.path)\n : db.collection(config.path);\n\n // Keep actual collection for create operations\n const actualCollection = config.isGroup ? null : db.collection(config.path);\n\n // Create document reference function\n const documentRef = (...args: any[]) => (config.refCb as any)(db, ...args);\n\n // Create all method groups\n const getMethods = createGetMethods(\n collectionRef as Query,\n config.foreignKeys,\n actualCollection,\n documentRef\n );\n const queryMethods = createQueryMethods(\n collectionRef as Query,\n config.queryKeys\n );\n const aggregateMethods = createAggregateMethods(collectionRef as Query);\n const crudMethods = createCrudMethods(actualCollection, documentRef);\n const batchMethods = createBatchMethods(db, documentRef);\n const transactionMethods = createTransactionMethods(db, documentRef);\n const bulkMethods = createBulkMethods(db);\n const populateMethods = createPopulateMethods(config, allRepositories);\n\n return {\n ref: collectionRef,\n documentRef,\n get: getMethods,\n query: queryMethods,\n aggregate: aggregateMethods,\n ...crudMethods,\n batch: batchMethods,\n transaction: transactionMethods,\n bulk: bulkMethods,\n ...populateMethods,\n } as unknown as ConfiguredRepository<T>;\n}\n","/* eslint-disable @typescript-eslint/no-empty-object-type */\n\nimport type { Firestore } from \"firebase-admin/firestore\";\n\n// ============================================\n// Re-exports from modules\n// ============================================\n\n// Shared types\nexport type {\n ExtractDocumentRefSignature,\n ExtractUpdateSignature,\n GetResult,\n QueryOptions,\n RelationalKeys,\n RelationConfig,\n RepositoryConfig,\n WhereClause,\n} from \"./src/shared/types\";\n\n// Pagination\nexport {\n applyQueryOptions as applyPaginationQueryOptions,\n createPaginationIterator,\n executePaginatedQuery,\n} from \"./src/pagination\";\nexport type { PaginationOptions, PaginationResult } from \"./src/pagination\";\n\n// Query builder\nexport { buildAndExecuteQuery } from \"./src/query-builder\";\n\n// Repository types\nexport type {\n ConfiguredRepository,\n GenerateGetMethods,\n GenerateQueryMethods,\n} from \"./src/repositories/types\";\n\n// ============================================\n// Imports for internal use\n// ============================================\n\nimport { createRepository } from \"./src/repositories/factory\";\nimport type { ConfiguredRepository } from \"./src/repositories/types\";\nimport type { RelationConfig, RepositoryConfig } from \"./src/shared/types\";\n\n// ============================================\n// Repository Configuration Helper\n// ============================================\n\n/**\n * Helper to create a typed repository configuration with literal type preservation\n * Uses currying pattern to allow type parameter inference\n * @template T - The data model type\n * @returns Builder function that accepts repository configuration with withRelations method\n * @example\n * ```typescript\n * const mapping = {\n * users: createRepositoryConfig<UserModel>()({\n * path: \"users\",\n * foreignKeys: [\"docId\", \"email\"] as const,\n * queryKeys: [\"isActive\"] as const,\n * refCb: (db, docId: string) => db.collection(\"users\").doc(docId),\n * }),\n * posts: createRepositoryConfig<PostModel>()({\n * path: \"posts\",\n * foreignKeys: [\"docId\", \"userId\"] as const,\n * queryKeys: [\"status\"] as const,\n * refCb: (db, docId: string) => db.collection(\"posts\").doc(docId),\n * }).withRelations<typeof mapping>()({\n * userId: { repo: \"users\", key: \"docId\", type: \"one\" as const }\n * })\n * };\n * ```\n */\nexport function createRepositoryConfig<T>() {\n return <\n const TForeignKeys extends readonly (keyof T)[],\n const TQueryKeys extends readonly (keyof T)[],\n const TIsGroup extends boolean,\n TRefCb = undefined\n >(config: {\n path: string;\n isGroup: TIsGroup;\n foreignKeys: TForeignKeys;\n queryKeys: TQueryKeys;\n refCb: TRefCb;\n }): RepositoryConfig<T, TForeignKeys, TQueryKeys, TIsGroup, TRefCb, {}> => {\n return {\n ...config,\n type: null as any as T,\n documentRef: null as any,\n update: null as any,\n } as any;\n };\n}\n\n/**\n * Helper type to resolve a single relation configuration\n * Extracts the target model type from the mapping\n */\ntype ResolveRelation<TMapping, TRelationConfig> = TRelationConfig extends {\n repo: infer R;\n key: infer FK;\n type: infer RT;\n}\n ? R extends keyof TMapping\n ? TMapping[R] extends { type: infer TTarget }\n ? RelationConfig<R & string, FK & string, RT & (\"one\" | \"many\"), TTarget>\n : never\n : never\n : never;\n\n/**\n * Helper to add relations to a repository mapping with full type validation\n * Validates that repo names and foreign keys exist in the mapping\n * @template TMapping - The complete repository mapping for validation\n * @template TRelations - Relations configuration with strict typing\n * @param mapping - The base repository mapping\n * @param relations - Relations configuration for each repository\n * @returns Updated mapping with relations and full type safety\n * @example\n * ```typescript\n * const mapping = {\n * users: createRepositoryConfig<UserModel>()({ ... }),\n * posts: createRepositoryConfig<PostModel>()({ ... }),\n * };\n *\n * const mappingWithRelations = buildRepositoryRelations(mapping, {\n * posts: {\n * userId: { repo: \"users\", key: \"docId\", type: \"one\" as const }\n * }\n * });\n *\n * const repos = createRepositoryMapping(db, mappingWithRelations);\n * ```\n */\nexport function buildRepositoryRelations<\n TMapping extends Record<string, any>,\n const TRelations extends {\n [K in keyof TMapping]?: TMapping[K] extends RepositoryConfig<\n infer T,\n any,\n any,\n any,\n any,\n any\n >\n ? {\n [RK in keyof T]?: {\n [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<\n infer TTargetModel,\n infer TForeignKeys,\n any,\n any,\n any,\n any\n >\n ? {\n repo: R;\n key: TForeignKeys[number];\n type: \"one\" | \"many\";\n }\n : never;\n }[keyof TMapping];\n }\n : never;\n }\n>(\n mapping: TMapping,\n relations: TRelations\n): {\n [K in keyof TMapping]: K extends keyof TRelations\n ? TMapping[K] extends RepositoryConfig<\n infer T,\n infer TForeignKeys,\n infer TQueryKeys,\n infer TIsGroup,\n infer TRefCb,\n any\n >\n ? RepositoryConfig<\n T,\n TForeignKeys,\n TQueryKeys,\n TIsGroup,\n TRefCb,\n {\n [RK in keyof TRelations[K]]: ResolveRelation<\n TMapping,\n TRelations[K][RK]\n >;\n }\n >\n : TMapping[K]\n : TMapping[K];\n} {\n const result: any = { ...mapping };\n\n for (const repoKey in relations) {\n if (relations[repoKey]) {\n result[repoKey] = {\n ...mapping[repoKey],\n relationalKeys: relations[repoKey],\n };\n }\n }\n\n return result as any;\n}\n\n// ============================================\n// Repository Mapping Class\n// ============================================\n\n/**\n * Repository mapping class that manages Firestore repositories with type safety\n * @template T - Record of repository configurations\n */\nexport class RepositoryMapping<T extends Record<string, any>> {\n private db: Firestore;\n private repositoryCache = new Map<string, any>();\n private mapping: T;\n private allRepositories: Record<string, any> = {};\n\n /**\n * Creates a new RepositoryMapping instance\n * @param db - Firestore instance from firebase-admin\n * @param mapping - Repository configuration mapping\n */\n constructor(db: Firestore, mapping: T) {\n this.db = db;\n this.mapping = mapping;\n // Pre-initialize all repositories to allow cross-references\n this.initializeRepositories();\n }\n\n /**\n * Initialize all repositories in two passes to handle circular dependencies\n * @private\n */\n private initializeRepositories() {\n // Pass 1: Create all repositories without populate methods\n for (const key of Object.keys(this.mapping)) {\n this.allRepositories[key] = createRepository(\n this.db,\n this.mapping[key],\n {}\n );\n }\n\n // Pass 2: Update all repositories with complete allRepositories map\n for (const key of Object.keys(this.mapping)) {\n this.allRepositories[key] = createRepository(\n this.db,\n this.mapping[key],\n this.allRepositories\n );\n }\n }\n\n /**\n * Gets a repository (already initialized)\n * @template K - Repository key\n * @param key - Repository identifier\n * @returns Configured repository instance\n */\n getRepository<K extends keyof T>(key: K): ConfiguredRepository<T[K]> {\n return this.allRepositories[key as string];\n }\n}\n\n// ============================================\n// Repository Mapping Factory\n// ============================================\n\n/**\n * Helper function to create a RepositoryMapping instance with full typing\n * @template T - Record of repository configurations\n * @param db - Firestore instance from firebase-admin\n * @param mapping - Repository configurations\n * @returns RepositoryMapping instance with repository access via getters\n * @example\n * ```typescript\n * import * as admin from 'firebase-admin';\n *\n * admin.initializeApp();\n * const db = admin.firestore();\n *\n * const repos = createRepositoryMapping(db, {\n * users: createRepositoryConfig<UserModel>()({\n * path: \"users\",\n * isGroup: false,\n * foreignKeys: [\"docId\", \"email\"] as const,\n * queryKeys: [\"isActive\"] as const,\n * refCb: (db, docId: string) => db.collection(\"users\").doc(docId),\n * }),\n * });\n *\n * // Access repositories directly\n * const user = await repos.users.get.byDocId(\"123\");\n * ```\n */\nexport function createRepositoryMapping<T extends Record<string, any>>(\n db: Firestore,\n mapping: T\n): RepositoryMapping<T> & { [K in keyof T]: ConfiguredRepository<T[K]> } {\n const instance = new RepositoryMapping(db, mapping);\n\n // Create a Proxy to dynamically generate getters\n return new Proxy(instance, {\n get(target, prop) {\n if (typeof prop === \"string\" && prop in mapping) {\n return target.getRepository(prop as keyof T);\n }\n return (target as any)[prop];\n },\n }) as any;\n}\n"]}
@@ -0,0 +1,420 @@
1
+ import { DocumentReference, Firestore, DocumentSnapshot, WhereFilterOp, Query, QuerySnapshot, CollectionReference, WriteBatch, Transaction } from 'firebase-admin/firestore';
2
+
3
+ /**
4
+ * Extract the documentRef signature from refCb (without the db parameter)
5
+ * @internal
6
+ */
7
+ type ExtractDocumentRefSignature<T> = T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: P) => DocumentReference : never;
8
+ /**
9
+ * Extract the update signature from refCb
10
+ * @internal
11
+ */
12
+ type ExtractUpdateSignature<T, TType> = T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: [...P, Partial<TType>]) => Promise<TType> : never;
13
+ /**
14
+ * Type for a where condition with strict value typing based on the field
15
+ * @template T - Data model type
16
+ */
17
+ type WhereClause<T = any> = {
18
+ [K in keyof T]: {
19
+ field: K;
20
+ operator: WhereFilterOp;
21
+ value: T[K] | T[K][];
22
+ };
23
+ }[keyof T];
24
+ /**
25
+ * Query options for filtering, sorting and paginating results
26
+ * @template T - Data model type
27
+ */
28
+ interface QueryOptions<T = any> {
29
+ where?: WhereClause<T>[];
30
+ orWhere?: WhereClause<T>[][];
31
+ orderBy?: {
32
+ field: keyof T;
33
+ direction?: "asc" | "desc";
34
+ }[];
35
+ limit?: number;
36
+ offset?: number;
37
+ startAt?: DocumentSnapshot | any[];
38
+ startAfter?: DocumentSnapshot | any[];
39
+ endAt?: DocumentSnapshot | any[];
40
+ endBefore?: DocumentSnapshot | any[];
41
+ }
42
+ /**
43
+ * Result type for get operations with optional document snapshot
44
+ * @internal
45
+ */
46
+ type GetResult<T, ReturnDoc extends boolean> = ReturnDoc extends true ? {
47
+ data: T;
48
+ doc: DocumentSnapshot;
49
+ } | null : T | null;
50
+ /**
51
+ * Relation configuration for a field with strict typing
52
+ * @template TRepoKey - Target repository name (key from mapping)
53
+ * @template TForeignKey - Target foreign key name
54
+ * @template TType - Relation type: "one" for one-to-one, "many" for one-to-many
55
+ * @template TTargetModel - Type of the target model (inferred from mapping)
56
+ */
57
+ interface RelationConfig<TRepoKey extends string = string, TForeignKey extends string = string, TType extends "one" | "many" = "one" | "many", TTargetModel = any> {
58
+ repo: TRepoKey;
59
+ key: TForeignKey;
60
+ type: TType;
61
+ targetType?: TTargetModel;
62
+ }
63
+ /**
64
+ * Relational key mapping between repositories with strict typing
65
+ * Maps a field from the current model to a target repository and foreign key
66
+ * @template T - Current model type
67
+ * @template TMapping - All repositories mapping for validation
68
+ * @example { userId: { repo: "users", key: "docId", type: "one" } }
69
+ *
70
+ * IMPORTANT: Keys must exist in T (the current model)
71
+ * This prevents creating relations on non-existent fields
72
+ */
73
+ type RelationalKeys<T = any, TMapping = any> = {
74
+ [K in keyof T]?: TMapping extends Record<string, any> ? {
75
+ [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<any, infer FKeys, any, any, any, any> ? {
76
+ repo: R;
77
+ key: FKeys[number];
78
+ type: "one" | "many";
79
+ } : never;
80
+ }[keyof TMapping] : RelationConfig;
81
+ };
82
+ /**
83
+ * Configuration interface for repositories with strict literal type inference
84
+ * @template T - The data model type
85
+ * @template TForeignKeys - Foreign keys used for unique document retrieval
86
+ * @template TQueryKeys - Query keys used for multiple document searches
87
+ * @template TIsGroup - Whether this is a collection group query
88
+ * @template TRefCb - Callback function signature for creating document references
89
+ * @template TRelationalKeys - Relational keys mapping to other repositories
90
+ */
91
+ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryKeys extends readonly (keyof T)[], TIsGroup extends boolean = boolean, TRefCb = any, TRelationalKeys = {}> {
92
+ path: string;
93
+ isGroup: TIsGroup;
94
+ foreignKeys: TForeignKeys;
95
+ queryKeys: TQueryKeys;
96
+ type: T;
97
+ refCb?: TRefCb;
98
+ relationalKeys?: TRelationalKeys;
99
+ documentRef: TRefCb extends undefined ? TIsGroup extends true ? (...pathSegments: string[]) => DocumentReference : (docId: string) => DocumentReference : ExtractDocumentRefSignature<TRefCb>;
100
+ update: TRefCb extends undefined ? TIsGroup extends true ? (...args: [...string[], Partial<T>]) => Promise<T> : (docId: string, data: Partial<T>) => Promise<T> : ExtractUpdateSignature<TRefCb, T>;
101
+ }
102
+
103
+ /**
104
+ * Pagination result with data and cursor information
105
+ * @template T - Data model type
106
+ */
107
+ interface PaginationResult<T> {
108
+ /** Array of documents for the current page */
109
+ data: T[];
110
+ /** Cursor to the next page (undefined if no more pages) */
111
+ nextCursor?: DocumentSnapshot;
112
+ /** Cursor to the previous page (undefined if on first page) */
113
+ prevCursor?: DocumentSnapshot;
114
+ /** Whether there are more pages after this one */
115
+ hasNextPage: boolean;
116
+ /** Whether there are pages before this one */
117
+ hasPrevPage: boolean;
118
+ /** Total number of items in current page */
119
+ pageSize: number;
120
+ }
121
+ /**
122
+ * Pagination options for cursor-based pagination
123
+ * @template T - Data model type
124
+ */
125
+ interface PaginationOptions<T> extends Omit<QueryOptions<T>, "limit"> {
126
+ /** Number of items per page */
127
+ pageSize: number;
128
+ /** Cursor to start after (for next page) */
129
+ cursor?: DocumentSnapshot;
130
+ /** Direction of pagination */
131
+ direction?: "next" | "prev";
132
+ }
133
+ /**
134
+ * Helper to apply query options to a Firestore query
135
+ */
136
+ declare function applyQueryOptions<T>(q: Query, options: QueryOptions<T>): Query;
137
+ /**
138
+ * Executes a paginated query and returns results with pagination info
139
+ * Uses the advanced query builder that handles OR conditions and automatic splitting
140
+ * @template T - Data model type
141
+ * @param baseQuery - Base Firestore query
142
+ * @param options - Pagination options
143
+ * @returns Pagination result with data and cursor information
144
+ */
145
+ declare function executePaginatedQuery<T>(baseQuery: Query, options: PaginationOptions<T>): Promise<PaginationResult<T>>;
146
+ /**
147
+ * Creates an async generator for iterating through all pages
148
+ * @template T - Data model type
149
+ * @param baseQuery - Base Firestore query
150
+ * @param options - Pagination options (without cursor)
151
+ * @yields Pagination results for each page
152
+ * @example
153
+ * ```typescript
154
+ * const pageIterator = createPaginationIterator(query, { pageSize: 10 });
155
+ * for await (const page of pageIterator) {
156
+ * console.log(`Page with ${page.pageSize} items`);
157
+ * page.data.forEach(item => console.log(item));
158
+ * if (!page.hasNextPage) break;
159
+ * }
160
+ * ```
161
+ */
162
+ declare function createPaginationIterator<T>(baseQuery: Query, options: Omit<PaginationOptions<T>, "cursor" | "direction">): AsyncGenerator<PaginationResult<T>, void, unknown>;
163
+
164
+ /**
165
+ * Build and execute query with automatic splitting for in/array-contains-any
166
+ * Handles both simple AND conditions and complex OR conditions
167
+ */
168
+ declare function buildAndExecuteQuery<T>(baseQuery: Query, options: QueryOptions<T>): Promise<QuerySnapshot>;
169
+
170
+ /**
171
+ * Helper type to extract populated data structure from a single relation
172
+ * @internal
173
+ */
174
+ type ExtractPopulatedFromRelation<TRelation> = TRelation extends RelationConfig<infer TRepo, any, infer TType, infer TTargetModel> ? {
175
+ [P in TRepo]: TType extends "one" ? TTargetModel | null : TTargetModel[];
176
+ } : Record<string, never>;
177
+ /**
178
+ * Helper type to merge multiple populated objects into one
179
+ * @internal
180
+ */
181
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
182
+ /**
183
+ * Generates get.by* methods from foreign keys
184
+ * @internal
185
+ */
186
+ type GenerateGetMethods<TConfig extends RepositoryConfig<any, any, any, any, any, any>> = {
187
+ [K in TConfig["foreignKeys"][number] as K extends string ? `by${Capitalize<K>}` : never]: <ReturnDoc extends boolean = false>(value: TConfig["type"][K], returnDoc?: ReturnDoc) => Promise<GetResult<TConfig["type"], ReturnDoc>>;
188
+ };
189
+ /**
190
+ * Generates query.by* methods from query keys
191
+ * @internal
192
+ */
193
+ type GenerateQueryMethods<TConfig extends RepositoryConfig<any, any, any, any, any, any>> = {
194
+ [K in TConfig["queryKeys"][number] as K extends string ? `by${Capitalize<K>}` : never]: (value: TConfig["type"][K], options?: QueryOptions<TConfig["type"]>) => Promise<TConfig["type"][]>;
195
+ };
196
+ /**
197
+ * Configured repository with organized methods
198
+ */
199
+ type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, any>> = {
200
+ ref: CollectionReference | Query;
201
+ get: GenerateGetMethods<T> & {
202
+ byList: <K extends keyof T["type"], ReturnDoc extends boolean = false>(key: K, values: T["type"][K][], operator?: "in" | "array-contains-any", returnDoc?: ReturnDoc) => Promise<ReturnDoc extends true ? Array<{
203
+ data: T["type"];
204
+ doc: DocumentSnapshot;
205
+ }> : T["type"][]>;
206
+ };
207
+ query: GenerateQueryMethods<T> & {
208
+ by: (options: QueryOptions<T["type"]>) => Promise<T["type"][]>;
209
+ getAll: (options?: QueryOptions<T["type"]>) => Promise<T["type"][]>;
210
+ onSnapshot: (options: QueryOptions<T["type"]>, onNext: (data: T["type"][]) => void, onError?: (error: Error) => void) => () => void;
211
+ paginate: (options: PaginationOptions<T["type"]>) => ReturnType<typeof executePaginatedQuery<T["type"]>>;
212
+ paginateAll: (options: Omit<PaginationOptions<T["type"]>, "cursor" | "direction">) => ReturnType<typeof createPaginationIterator<T["type"]>>;
213
+ };
214
+ aggregate: {
215
+ count: (options?: QueryOptions<T["type"]>) => Promise<number>;
216
+ sum: <K extends keyof T["type"]>(field: K, options?: QueryOptions<T["type"]>) => Promise<number>;
217
+ average: <K extends keyof T["type"]>(field: K, options?: QueryOptions<T["type"]>) => Promise<number | null>;
218
+ };
219
+ documentRef: T["documentRef"];
220
+ create: (data: Partial<T["type"]>) => Promise<T["type"] & {
221
+ docId: string;
222
+ }>;
223
+ set: (...args: [
224
+ ...Parameters<T["documentRef"]>,
225
+ Partial<T["type"]>,
226
+ {
227
+ merge?: boolean;
228
+ }?
229
+ ]) => Promise<T["type"]>;
230
+ update: T["update"];
231
+ delete: (...args: Parameters<T["documentRef"]>) => Promise<void>;
232
+ batch: {
233
+ create: () => {
234
+ batch: WriteBatch;
235
+ set: (...args: [
236
+ ...Parameters<T["documentRef"]>,
237
+ Partial<T["type"]>,
238
+ {
239
+ merge?: boolean;
240
+ }?
241
+ ]) => void;
242
+ update: (...args: [...Parameters<T["documentRef"]>, Partial<T["type"]>]) => void;
243
+ delete: (...args: Parameters<T["documentRef"]>) => void;
244
+ commit: () => Promise<void>;
245
+ };
246
+ };
247
+ transaction: {
248
+ run: <R>(updateFunction: (transaction: {
249
+ get: (...args: Parameters<T["documentRef"]>) => Promise<T["type"] | null>;
250
+ set: (...args: [
251
+ ...Parameters<T["documentRef"]>,
252
+ Partial<T["type"]>,
253
+ {
254
+ merge?: boolean;
255
+ }?
256
+ ]) => void;
257
+ update: (...args: [...Parameters<T["documentRef"]>, Partial<T["type"]>]) => void;
258
+ delete: (...args: Parameters<T["documentRef"]>) => void;
259
+ raw: Transaction;
260
+ }) => Promise<R>) => Promise<R>;
261
+ };
262
+ bulk: {
263
+ set: (items: Array<{
264
+ docRef: DocumentReference;
265
+ data: Partial<T["type"]>;
266
+ merge?: boolean;
267
+ }>) => Promise<void>;
268
+ update: (items: Array<{
269
+ docRef: DocumentReference;
270
+ data: Partial<T["type"]>;
271
+ }>) => Promise<void>;
272
+ delete: (docRefs: DocumentReference[]) => Promise<void>;
273
+ };
274
+ populate: <K extends keyof NonNullable<T["relationalKeys"]>>(document: T["type"], relationKey: K | K[]) => Promise<T["type"] & {
275
+ populated: UnionToIntersection<K extends keyof NonNullable<T["relationalKeys"]> ? ExtractPopulatedFromRelation<NonNullable<T["relationalKeys"]>[K]> : Record<string, never>>;
276
+ }>;
277
+ };
278
+
279
+ /**
280
+ * Helper to create a typed repository configuration with literal type preservation
281
+ * Uses currying pattern to allow type parameter inference
282
+ * @template T - The data model type
283
+ * @returns Builder function that accepts repository configuration with withRelations method
284
+ * @example
285
+ * ```typescript
286
+ * const mapping = {
287
+ * users: createRepositoryConfig<UserModel>()({
288
+ * path: "users",
289
+ * foreignKeys: ["docId", "email"] as const,
290
+ * queryKeys: ["isActive"] as const,
291
+ * refCb: (db, docId: string) => db.collection("users").doc(docId),
292
+ * }),
293
+ * posts: createRepositoryConfig<PostModel>()({
294
+ * path: "posts",
295
+ * foreignKeys: ["docId", "userId"] as const,
296
+ * queryKeys: ["status"] as const,
297
+ * refCb: (db, docId: string) => db.collection("posts").doc(docId),
298
+ * }).withRelations<typeof mapping>()({
299
+ * userId: { repo: "users", key: "docId", type: "one" as const }
300
+ * })
301
+ * };
302
+ * ```
303
+ */
304
+ declare function createRepositoryConfig<T>(): <const TForeignKeys extends readonly (keyof T)[], const TQueryKeys extends readonly (keyof T)[], const TIsGroup extends boolean, TRefCb = undefined>(config: {
305
+ path: string;
306
+ isGroup: TIsGroup;
307
+ foreignKeys: TForeignKeys;
308
+ queryKeys: TQueryKeys;
309
+ refCb: TRefCb;
310
+ }) => RepositoryConfig<T, TForeignKeys, TQueryKeys, TIsGroup, TRefCb, {}>;
311
+ /**
312
+ * Helper type to resolve a single relation configuration
313
+ * Extracts the target model type from the mapping
314
+ */
315
+ type ResolveRelation<TMapping, TRelationConfig> = TRelationConfig extends {
316
+ repo: infer R;
317
+ key: infer FK;
318
+ type: infer RT;
319
+ } ? R extends keyof TMapping ? TMapping[R] extends {
320
+ type: infer TTarget;
321
+ } ? RelationConfig<R & string, FK & string, RT & ("one" | "many"), TTarget> : never : never : never;
322
+ /**
323
+ * Helper to add relations to a repository mapping with full type validation
324
+ * Validates that repo names and foreign keys exist in the mapping
325
+ * @template TMapping - The complete repository mapping for validation
326
+ * @template TRelations - Relations configuration with strict typing
327
+ * @param mapping - The base repository mapping
328
+ * @param relations - Relations configuration for each repository
329
+ * @returns Updated mapping with relations and full type safety
330
+ * @example
331
+ * ```typescript
332
+ * const mapping = {
333
+ * users: createRepositoryConfig<UserModel>()({ ... }),
334
+ * posts: createRepositoryConfig<PostModel>()({ ... }),
335
+ * };
336
+ *
337
+ * const mappingWithRelations = buildRepositoryRelations(mapping, {
338
+ * posts: {
339
+ * userId: { repo: "users", key: "docId", type: "one" as const }
340
+ * }
341
+ * });
342
+ *
343
+ * const repos = createRepositoryMapping(db, mappingWithRelations);
344
+ * ```
345
+ */
346
+ declare function buildRepositoryRelations<TMapping extends Record<string, any>, const TRelations extends {
347
+ [K in keyof TMapping]?: TMapping[K] extends RepositoryConfig<infer T, any, any, any, any, any> ? {
348
+ [RK in keyof T]?: {
349
+ [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<infer TTargetModel, infer TForeignKeys, any, any, any, any> ? {
350
+ repo: R;
351
+ key: TForeignKeys[number];
352
+ type: "one" | "many";
353
+ } : never;
354
+ }[keyof TMapping];
355
+ } : never;
356
+ }>(mapping: TMapping, relations: TRelations): {
357
+ [K in keyof TMapping]: K extends keyof TRelations ? TMapping[K] extends RepositoryConfig<infer T, infer TForeignKeys, infer TQueryKeys, infer TIsGroup, infer TRefCb, any> ? RepositoryConfig<T, TForeignKeys, TQueryKeys, TIsGroup, TRefCb, {
358
+ [RK in keyof TRelations[K]]: ResolveRelation<TMapping, TRelations[K][RK]>;
359
+ }> : TMapping[K] : TMapping[K];
360
+ };
361
+ /**
362
+ * Repository mapping class that manages Firestore repositories with type safety
363
+ * @template T - Record of repository configurations
364
+ */
365
+ declare class RepositoryMapping<T extends Record<string, any>> {
366
+ private db;
367
+ private repositoryCache;
368
+ private mapping;
369
+ private allRepositories;
370
+ /**
371
+ * Creates a new RepositoryMapping instance
372
+ * @param db - Firestore instance from firebase-admin
373
+ * @param mapping - Repository configuration mapping
374
+ */
375
+ constructor(db: Firestore, mapping: T);
376
+ /**
377
+ * Initialize all repositories in two passes to handle circular dependencies
378
+ * @private
379
+ */
380
+ private initializeRepositories;
381
+ /**
382
+ * Gets a repository (already initialized)
383
+ * @template K - Repository key
384
+ * @param key - Repository identifier
385
+ * @returns Configured repository instance
386
+ */
387
+ getRepository<K extends keyof T>(key: K): ConfiguredRepository<T[K]>;
388
+ }
389
+ /**
390
+ * Helper function to create a RepositoryMapping instance with full typing
391
+ * @template T - Record of repository configurations
392
+ * @param db - Firestore instance from firebase-admin
393
+ * @param mapping - Repository configurations
394
+ * @returns RepositoryMapping instance with repository access via getters
395
+ * @example
396
+ * ```typescript
397
+ * import * as admin from 'firebase-admin';
398
+ *
399
+ * admin.initializeApp();
400
+ * const db = admin.firestore();
401
+ *
402
+ * const repos = createRepositoryMapping(db, {
403
+ * users: createRepositoryConfig<UserModel>()({
404
+ * path: "users",
405
+ * isGroup: false,
406
+ * foreignKeys: ["docId", "email"] as const,
407
+ * queryKeys: ["isActive"] as const,
408
+ * refCb: (db, docId: string) => db.collection("users").doc(docId),
409
+ * }),
410
+ * });
411
+ *
412
+ * // Access repositories directly
413
+ * const user = await repos.users.get.byDocId("123");
414
+ * ```
415
+ */
416
+ declare function createRepositoryMapping<T extends Record<string, any>>(db: Firestore, mapping: T): RepositoryMapping<T> & {
417
+ [K in keyof T]: ConfiguredRepository<T[K]>;
418
+ };
419
+
420
+ export { type ConfiguredRepository, type ExtractDocumentRefSignature, type ExtractUpdateSignature, type GenerateGetMethods, type GenerateQueryMethods, type GetResult, type PaginationOptions, type PaginationResult, type QueryOptions, type RelationConfig, type RelationalKeys, type RepositoryConfig, RepositoryMapping, type WhereClause, applyQueryOptions as applyPaginationQueryOptions, buildAndExecuteQuery, buildRepositoryRelations, createPaginationIterator, createRepositoryConfig, createRepositoryMapping, executePaginatedQuery };