@lpdjs/firestore-repo-service 3.0.4 → 3.0.5

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.
Files changed (53) hide show
  1. package/dist/{create-servers-2Hw0pkyz.d.ts → create-servers-C-X5e62o.d.ts} +5 -5
  2. package/dist/{create-servers-ASLcxpiS.d.cts → create-servers-CRTjY8sA.d.cts} +5 -5
  3. package/dist/history/index.d.cts +3 -2
  4. package/dist/history/index.d.ts +3 -2
  5. package/dist/index.cjs +18 -18
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +10 -7
  8. package/dist/index.d.ts +10 -7
  9. package/dist/index.js +18 -18
  10. package/dist/index.js.map +1 -1
  11. package/dist/llms-full.txt +1 -1
  12. package/dist/llms.txt +1 -1
  13. package/dist/{openapi-CoKsSOIU.d.cts → openapi-Bp4vtku3.d.cts} +1 -1
  14. package/dist/{openapi-BTu_1vSc.d.ts → openapi-D6hEI2lq.d.ts} +1 -1
  15. package/dist/{queue-B9jCT62h.d.cts → queue-BYbd9y4U.d.cts} +1 -1
  16. package/dist/{queue-BWi6TBmf.d.ts → queue-I7Y1l3Wu.d.ts} +1 -1
  17. package/dist/read-DWUsiHcw.d.cts +164 -0
  18. package/dist/read-_6UEFCDw.d.ts +164 -0
  19. package/dist/{rules-BJMT0N0i.d.ts → rules-6LZ9KkR6.d.ts} +1 -1
  20. package/dist/{rules-B3b-BZLf.d.cts → rules-BB0w7PlS.d.cts} +1 -1
  21. package/dist/servers/admin/index.d.cts +4 -2
  22. package/dist/servers/admin/index.d.ts +4 -2
  23. package/dist/servers/crud/index.d.cts +8 -6
  24. package/dist/servers/crud/index.d.ts +8 -6
  25. package/dist/servers/index.cjs +30 -30
  26. package/dist/servers/index.cjs.map +1 -1
  27. package/dist/servers/index.d.cts +10 -8
  28. package/dist/servers/index.d.ts +10 -8
  29. package/dist/servers/index.js +30 -30
  30. package/dist/servers/index.js.map +1 -1
  31. package/dist/sync/bigquery.d.cts +4 -1
  32. package/dist/sync/bigquery.d.ts +4 -1
  33. package/dist/sync/index.cjs +55 -55
  34. package/dist/sync/index.cjs.map +1 -1
  35. package/dist/sync/index.d.cts +29 -13
  36. package/dist/sync/index.d.ts +29 -13
  37. package/dist/sync/index.js +55 -55
  38. package/dist/sync/index.js.map +1 -1
  39. package/dist/sync/meilisearch.cjs +2 -2
  40. package/dist/sync/meilisearch.cjs.map +1 -1
  41. package/dist/sync/meilisearch.d.cts +33 -11
  42. package/dist/sync/meilisearch.d.ts +33 -11
  43. package/dist/sync/meilisearch.js +2 -2
  44. package/dist/sync/meilisearch.js.map +1 -1
  45. package/dist/{types-LZ8dyfBz.d.cts → types-B48PI0V9.d.cts} +29 -6
  46. package/dist/{read-CTWZjxyh.d.cts → types-BwucrwN0.d.cts} +2 -162
  47. package/dist/{read-CTWZjxyh.d.ts → types-BwucrwN0.d.ts} +2 -162
  48. package/dist/{types-XRjVKN9r.d.ts → types-CXQeSrhO.d.ts} +4 -206
  49. package/dist/{types-B2e-T8EM.d.cts → types-D9Nm-4pg.d.cts} +4 -206
  50. package/dist/types-D_snvgmB.d.cts +207 -0
  51. package/dist/{types-BRPhmKFW.d.ts → types-DbtP8YCJ.d.ts} +29 -6
  52. package/dist/types-DgtfcerG.d.ts +207 -0
  53. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { Timestamp, DocumentReference } from 'firebase-admin/firestore';
1
+ import { Timestamp } from 'firebase-admin/firestore';
2
2
  import { onDocumentWritten } from 'firebase-functions/v2/firestore';
3
3
 
4
4
  /**
@@ -197,164 +197,4 @@ interface HistoryTriggersConfig<M = Record<string, any>> {
197
197
  repos?: Partial<Record<keyof M & string, HistoryTriggerRepoOverride>>;
198
198
  }
199
199
 
200
- /**
201
- * `repo.history.*` read API.
202
- *
203
- * - `list(docId, opts)` → unified, paginated, normalised entries (v1 + v2).
204
- * - `raw(docId, opts)` → raw Firestore docs (no normalisation).
205
- * - `byField(docId, field, opts)` / `byOperation(docId, op, opts)` →
206
- * convenience wrappers.
207
- * - `recordManual(docId, payload)` → bypass the trigger and write a v2 entry
208
- * synchronously (use sparingly; prefer trigger-based capture).
209
- */
210
-
211
- /**
212
- * Build the `repo.history` API for a given configured repository.
213
- * Returns `null` when history is not enabled — the factory then skips
214
- * exposing the namespace.
215
- */
216
- declare function createHistoryMethods<T>(documentRef: (...args: any[]) => DocumentReference, systemKeys: string[], repoName: string, config: HistoryConfigForModel<T> & {
217
- enabled: boolean;
218
- }): HistoryMethods<T> | null;
219
- /**
220
- * Public, strongly-typed surface of the `repo.history` namespace.
221
- *
222
- * Exposed on a repository **only when** `history.enabled: true` is set in
223
- * its config. Reads from the entity's `history` subcollection (or the custom
224
- * name set via `history.subcollection`) and normalises both schema versions
225
- * (v1 = one doc per modified field, v2 = one doc per write) into a single
226
- * {@link HistoryEntry} shape.
227
- *
228
- * ### Path arguments
229
- *
230
- * Every method's leading positional arguments mirror
231
- * `Parameters<repo.documentRef>`, so the call signature stays consistent with
232
- * the rest of the repo API:
233
- *
234
- * - **Top-level collection** (`documentRef: (db, docId) => …`)
235
- * → `repo.history.list("doc_42", opts?)`
236
- * - **Subcollection** (`documentRef: (db, parentId, docId) => …`)
237
- * → `repo.history.list("parent_1", "doc_42", opts?)`
238
- *
239
- * The trailing options/payload argument keeps the same position whatever the
240
- * depth of the path.
241
- *
242
- * ### Pagination
243
- *
244
- * `list` / `byField` / `byOperation` use real Firestore cursors via the
245
- * `cursor` + `limit` options on {@link HistoryListOptions} — no in-memory
246
- * slicing, safe for large histories.
247
- *
248
- * @example Basic read
249
- * ```ts
250
- * const entries = await repos.residences.history!.list("residence_123", {
251
- * limit: 50,
252
- * direction: "desc",
253
- * });
254
- * for (const e of entries) {
255
- * console.log(e.historySetAt.toDate(), e.operation, e.meta.userId);
256
- * }
257
- * ```
258
- *
259
- * @example Filter by field (autocompleted on `keyof T`)
260
- * ```ts
261
- * const addressChanges = await repos.residences.history!.byField(
262
- * "residence_123",
263
- * "address",
264
- * );
265
- * ```
266
- *
267
- * @template T - The repository's model type. Field-name parameters
268
- * (e.g. `byField`'s `K`) and `HistoryEntry<T>` payloads
269
- * are derived from this.
270
- * @template PathArgs - Tuple of path-segment args inherited from the repo's
271
- * `documentRef`. Defaults to `[string]` (a single
272
- * `docId`) when used standalone.
273
- *
274
- * @see {@link createHistoryMethods} - factory used internally by `createRepository`.
275
- * @see {@link HistoryEntry} - normalised return shape.
276
- * @see {@link HistoryListOptions} - pagination + filter options.
277
- */
278
- interface HistoryMethods<T, PathArgs extends readonly unknown[] = [string]> {
279
- /**
280
- * List normalised history entries for a single document.
281
- *
282
- * Reads both v1 and v2 docs and folds v1 field-per-doc entries that share
283
- * the same author + timestamp (±5 ms) into a single logical entry, so the
284
- * caller never has to care about the storage version.
285
- *
286
- * @param args - `[...pathArgs, options?]`. `pathArgs` mirror the repo's
287
- * `documentRef`. `options` accepts `limit`, `cursor`,
288
- * `direction`, `fields`, `operations`.
289
- * @returns Array of {@link HistoryEntry} ordered by `historySetAt`
290
- * (`direction` defaults to `"desc"`).
291
- */
292
- list(...args: [...PathArgs, HistoryListOptions<T>?]): Promise<HistoryEntry<T>[]>;
293
- /**
294
- * Escape hatch returning **raw** Firestore documents (v1 or v2) without
295
- * normalisation. Use only when {@link list} doesn't expose the field you
296
- * need (custom legacy fields, debugging, migrations).
297
- *
298
- * @param args - `[...pathArgs, options?]`. Supports the same pagination
299
- * options as `list`, minus model-aware filters.
300
- */
301
- raw(...args: [...PathArgs, HistoryRawListOptions?]): Promise<Array<{
302
- id: string;
303
- data: V1HistoryDoc | V2HistoryDoc;
304
- }>>;
305
- /**
306
- * Convenience wrapper around {@link list} that only returns entries
307
- * touching a specific field. Field name is checked against `keyof T` at
308
- * compile time.
309
- *
310
- * @typeParam K - A literal key of the model `T`.
311
- * @param args - `[...pathArgs, field, options?]`.
312
- *
313
- * @example
314
- * ```ts
315
- * await repos.users.history!.byField("user_42", "email");
316
- * ```
317
- */
318
- byField<K extends keyof T & string>(...args: [...PathArgs, K, HistoryListOptions<T>?]): Promise<HistoryEntry<T>[]>;
319
- /**
320
- * Convenience wrapper around {@link list} filtering on the operation type.
321
- *
322
- * @param args - `[...pathArgs, operation, options?]` where `operation` is
323
- * `"create" | "update" | "delete"`.
324
- *
325
- * @example
326
- * ```ts
327
- * await repos.residences.history!.byOperation("residence_123", "delete");
328
- * ```
329
- */
330
- byOperation(...args: [...PathArgs, HistoryOperation, HistoryListOptions<T>?]): Promise<HistoryEntry<T>[]>;
331
- /**
332
- * Synchronously append a custom history entry, bypassing the trigger.
333
- *
334
- * Useful when:
335
- * - You already have richer business context than the trigger can extract
336
- * (e.g. inside an HTTP handler that knows the authenticated user).
337
- * - You want to record an event that isn't a Firestore write (e.g.
338
- * `meta.reason = "exported-to-pdf"`).
339
- *
340
- * Honours the same `include` / `exclude` / meta auto-exclusion rules as
341
- * the trigger. Returns `null` when the diff is empty (no changes recorded).
342
- *
343
- * > ⚠️ Use sparingly — combining manual records with the trigger can
344
- * > produce duplicate entries if both fire for the same write.
345
- *
346
- * @param args - `[...pathArgs, payload]` where `payload` is
347
- * `{ operation, before?, after?, meta? }`.
348
- */
349
- recordManual(...args: [
350
- ...PathArgs,
351
- {
352
- operation: HistoryOperation;
353
- before?: T | null;
354
- after?: T | null;
355
- meta?: HistoryMeta;
356
- }
357
- ]): Promise<HistoryEntry<T> | null>;
358
- }
359
-
360
- export { type HistoryTriggersConfig as H, type V2HistoryDoc as V, type HistoryOperation as a, type HistoryFieldChange as b, type HistoryMeta as c, type HistoryConfigForModel as d, type HistoryValueType as e, type V1HistoryDoc as f, type HistoryEntry as g, createHistoryMethods as h, type HistoryMethods as i, type HistoryConfigBase as j, type HistoryFirestoreTriggersDep as k, type HistoryListOptions as l, type HistoryRawListOptions as m, type HistoryTriggerRepoOverride as n };
200
+ export type { HistoryTriggersConfig as H, V1HistoryDoc as V, HistoryConfigForModel as a, HistoryListOptions as b, HistoryEntry as c, HistoryRawListOptions as d, V2HistoryDoc as e, HistoryOperation as f, HistoryMeta as g, HistoryFieldChange as h, HistoryValueType as i, HistoryConfigBase as j, HistoryFirestoreTriggersDep as k, HistoryTriggerRepoOverride as l };
@@ -1,4 +1,4 @@
1
- import { Timestamp, DocumentReference } from 'firebase-admin/firestore';
1
+ import { Timestamp } from 'firebase-admin/firestore';
2
2
  import { onDocumentWritten } from 'firebase-functions/v2/firestore';
3
3
 
4
4
  /**
@@ -197,164 +197,4 @@ interface HistoryTriggersConfig<M = Record<string, any>> {
197
197
  repos?: Partial<Record<keyof M & string, HistoryTriggerRepoOverride>>;
198
198
  }
199
199
 
200
- /**
201
- * `repo.history.*` read API.
202
- *
203
- * - `list(docId, opts)` → unified, paginated, normalised entries (v1 + v2).
204
- * - `raw(docId, opts)` → raw Firestore docs (no normalisation).
205
- * - `byField(docId, field, opts)` / `byOperation(docId, op, opts)` →
206
- * convenience wrappers.
207
- * - `recordManual(docId, payload)` → bypass the trigger and write a v2 entry
208
- * synchronously (use sparingly; prefer trigger-based capture).
209
- */
210
-
211
- /**
212
- * Build the `repo.history` API for a given configured repository.
213
- * Returns `null` when history is not enabled — the factory then skips
214
- * exposing the namespace.
215
- */
216
- declare function createHistoryMethods<T>(documentRef: (...args: any[]) => DocumentReference, systemKeys: string[], repoName: string, config: HistoryConfigForModel<T> & {
217
- enabled: boolean;
218
- }): HistoryMethods<T> | null;
219
- /**
220
- * Public, strongly-typed surface of the `repo.history` namespace.
221
- *
222
- * Exposed on a repository **only when** `history.enabled: true` is set in
223
- * its config. Reads from the entity's `history` subcollection (or the custom
224
- * name set via `history.subcollection`) and normalises both schema versions
225
- * (v1 = one doc per modified field, v2 = one doc per write) into a single
226
- * {@link HistoryEntry} shape.
227
- *
228
- * ### Path arguments
229
- *
230
- * Every method's leading positional arguments mirror
231
- * `Parameters<repo.documentRef>`, so the call signature stays consistent with
232
- * the rest of the repo API:
233
- *
234
- * - **Top-level collection** (`documentRef: (db, docId) => …`)
235
- * → `repo.history.list("doc_42", opts?)`
236
- * - **Subcollection** (`documentRef: (db, parentId, docId) => …`)
237
- * → `repo.history.list("parent_1", "doc_42", opts?)`
238
- *
239
- * The trailing options/payload argument keeps the same position whatever the
240
- * depth of the path.
241
- *
242
- * ### Pagination
243
- *
244
- * `list` / `byField` / `byOperation` use real Firestore cursors via the
245
- * `cursor` + `limit` options on {@link HistoryListOptions} — no in-memory
246
- * slicing, safe for large histories.
247
- *
248
- * @example Basic read
249
- * ```ts
250
- * const entries = await repos.residences.history!.list("residence_123", {
251
- * limit: 50,
252
- * direction: "desc",
253
- * });
254
- * for (const e of entries) {
255
- * console.log(e.historySetAt.toDate(), e.operation, e.meta.userId);
256
- * }
257
- * ```
258
- *
259
- * @example Filter by field (autocompleted on `keyof T`)
260
- * ```ts
261
- * const addressChanges = await repos.residences.history!.byField(
262
- * "residence_123",
263
- * "address",
264
- * );
265
- * ```
266
- *
267
- * @template T - The repository's model type. Field-name parameters
268
- * (e.g. `byField`'s `K`) and `HistoryEntry<T>` payloads
269
- * are derived from this.
270
- * @template PathArgs - Tuple of path-segment args inherited from the repo's
271
- * `documentRef`. Defaults to `[string]` (a single
272
- * `docId`) when used standalone.
273
- *
274
- * @see {@link createHistoryMethods} - factory used internally by `createRepository`.
275
- * @see {@link HistoryEntry} - normalised return shape.
276
- * @see {@link HistoryListOptions} - pagination + filter options.
277
- */
278
- interface HistoryMethods<T, PathArgs extends readonly unknown[] = [string]> {
279
- /**
280
- * List normalised history entries for a single document.
281
- *
282
- * Reads both v1 and v2 docs and folds v1 field-per-doc entries that share
283
- * the same author + timestamp (±5 ms) into a single logical entry, so the
284
- * caller never has to care about the storage version.
285
- *
286
- * @param args - `[...pathArgs, options?]`. `pathArgs` mirror the repo's
287
- * `documentRef`. `options` accepts `limit`, `cursor`,
288
- * `direction`, `fields`, `operations`.
289
- * @returns Array of {@link HistoryEntry} ordered by `historySetAt`
290
- * (`direction` defaults to `"desc"`).
291
- */
292
- list(...args: [...PathArgs, HistoryListOptions<T>?]): Promise<HistoryEntry<T>[]>;
293
- /**
294
- * Escape hatch returning **raw** Firestore documents (v1 or v2) without
295
- * normalisation. Use only when {@link list} doesn't expose the field you
296
- * need (custom legacy fields, debugging, migrations).
297
- *
298
- * @param args - `[...pathArgs, options?]`. Supports the same pagination
299
- * options as `list`, minus model-aware filters.
300
- */
301
- raw(...args: [...PathArgs, HistoryRawListOptions?]): Promise<Array<{
302
- id: string;
303
- data: V1HistoryDoc | V2HistoryDoc;
304
- }>>;
305
- /**
306
- * Convenience wrapper around {@link list} that only returns entries
307
- * touching a specific field. Field name is checked against `keyof T` at
308
- * compile time.
309
- *
310
- * @typeParam K - A literal key of the model `T`.
311
- * @param args - `[...pathArgs, field, options?]`.
312
- *
313
- * @example
314
- * ```ts
315
- * await repos.users.history!.byField("user_42", "email");
316
- * ```
317
- */
318
- byField<K extends keyof T & string>(...args: [...PathArgs, K, HistoryListOptions<T>?]): Promise<HistoryEntry<T>[]>;
319
- /**
320
- * Convenience wrapper around {@link list} filtering on the operation type.
321
- *
322
- * @param args - `[...pathArgs, operation, options?]` where `operation` is
323
- * `"create" | "update" | "delete"`.
324
- *
325
- * @example
326
- * ```ts
327
- * await repos.residences.history!.byOperation("residence_123", "delete");
328
- * ```
329
- */
330
- byOperation(...args: [...PathArgs, HistoryOperation, HistoryListOptions<T>?]): Promise<HistoryEntry<T>[]>;
331
- /**
332
- * Synchronously append a custom history entry, bypassing the trigger.
333
- *
334
- * Useful when:
335
- * - You already have richer business context than the trigger can extract
336
- * (e.g. inside an HTTP handler that knows the authenticated user).
337
- * - You want to record an event that isn't a Firestore write (e.g.
338
- * `meta.reason = "exported-to-pdf"`).
339
- *
340
- * Honours the same `include` / `exclude` / meta auto-exclusion rules as
341
- * the trigger. Returns `null` when the diff is empty (no changes recorded).
342
- *
343
- * > ⚠️ Use sparingly — combining manual records with the trigger can
344
- * > produce duplicate entries if both fire for the same write.
345
- *
346
- * @param args - `[...pathArgs, payload]` where `payload` is
347
- * `{ operation, before?, after?, meta? }`.
348
- */
349
- recordManual(...args: [
350
- ...PathArgs,
351
- {
352
- operation: HistoryOperation;
353
- before?: T | null;
354
- after?: T | null;
355
- meta?: HistoryMeta;
356
- }
357
- ]): Promise<HistoryEntry<T> | null>;
358
- }
359
-
360
- export { type HistoryTriggersConfig as H, type V2HistoryDoc as V, type HistoryOperation as a, type HistoryFieldChange as b, type HistoryMeta as c, type HistoryConfigForModel as d, type HistoryValueType as e, type V1HistoryDoc as f, type HistoryEntry as g, createHistoryMethods as h, type HistoryMethods as i, type HistoryConfigBase as j, type HistoryFirestoreTriggersDep as k, type HistoryListOptions as l, type HistoryRawListOptions as m, type HistoryTriggerRepoOverride as n };
200
+ export type { HistoryTriggersConfig as H, V1HistoryDoc as V, HistoryConfigForModel as a, HistoryListOptions as b, HistoryEntry as c, HistoryRawListOptions as d, V2HistoryDoc as e, HistoryOperation as f, HistoryMeta as g, HistoryFieldChange as h, HistoryValueType as i, HistoryConfigBase as j, HistoryFirestoreTriggersDep as k, HistoryTriggerRepoOverride as l };
@@ -1,212 +1,10 @@
1
1
  import { A as AuthUser } from './firebase-auth-Ds5P0kXT.js';
2
2
  import { H as HonoServerOptions, O as OpenAPIConfig } from './types-DSMiiOrU.js';
3
- import * as zod from 'zod';
4
3
  import { z } from 'zod';
5
4
  import { HttpsOptions } from 'firebase-functions/v2/https';
6
- import { d as HistoryConfigForModel, i as HistoryMethods } from './read-CTWZjxyh.js';
7
- import { DocumentReference, Firestore, DocumentSnapshot, WhereFilterOp, Query, CollectionReference, WriteBatch, Transaction } from 'firebase-admin/firestore';
8
-
9
- /**
10
- * Extract the documentRef signature from refCb (without the db parameter)
11
- * @internal
12
- */
13
- type ExtractDocumentRefSignature<T> = T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: P) => DocumentReference : never;
14
- /**
15
- * Extract the update signature from refCb
16
- * @internal
17
- */
18
- type ExtractUpdateSignature<T, TType> = T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: [...P, Partial<TType>]) => Promise<TType> : never;
19
- /**
20
- * Check if a type is a plain object (not Date, Array, Function, etc.)
21
- * @internal
22
- */
23
- type IsPlainObject<T> = NonNullable<T> extends Date ? false : NonNullable<T> extends Array<any> ? false : NonNullable<T> extends Function ? false : NonNullable<T> extends object ? true : false;
24
- /**
25
- * Recursively generates dot-notation paths for nested plain objects only
26
- * Stops at primitives, Date, Array, Function, etc.
27
- * @template T - The object type to traverse
28
- * @template Prefix - Current path prefix
29
- * @template Depth - Recursion depth limit
30
- * @example
31
- * type User = { address: { city: string; zip: number }; createdAt: Date }
32
- * // NestedPaths<User> = "address" | "address.city" | "address.zip" | "createdAt"
33
- */
34
- type NestedPaths<T, Prefix extends string = "", Depth extends number[] = []> = Depth["length"] extends 5 ? Prefix : {
35
- [K in keyof T & string]: IsPlainObject<T[K]> extends true ? Prefix extends "" ? K | NestedPaths<NonNullable<T[K]>, K, [...Depth, 1]> : `${Prefix}.${K}` | NestedPaths<NonNullable<T[K]>, `${Prefix}.${K}`, [...Depth, 1]> : Prefix extends "" ? K : `${Prefix}.${K}`;
36
- }[keyof T & string];
37
- /**
38
- * Gets the type at a dot-notation path
39
- * @template T - The object type
40
- * @template Path - The dot-notation path string
41
- * @example
42
- * type User = { address: { city: string } }
43
- * // PathValue<User, "address.city"> = string
44
- */
45
- type PathValue<T, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof NonNullable<T> ? PathValue<NonNullable<T>[Key], Rest> : never : Path extends keyof T ? T[Path] : Path extends keyof NonNullable<T> ? NonNullable<T>[Path] : never;
46
- /**
47
- * All possible field paths including nested paths
48
- * @template T - Data model type
49
- */
50
- type FieldPath<T> = NestedPaths<T>;
51
- /**
52
- * Type for a where condition as a tuple [field, operator, value]
53
- * Supports dot-notation for nested fields with proper value typing
54
- * @template T - Data model type
55
- * @example
56
- * // For type User = { name: string; address: { city: string } }
57
- * // Valid: ["name", "==", "John"]
58
- * // Valid: ["address.city", "==", "Paris"]
59
- */
60
- type WhereClause<T = any> = {
61
- [P in FieldPath<T>]: [P, WhereFilterOp, PathValue<T, P> | PathValue<T, P>[]];
62
- }[FieldPath<T>];
63
- /**
64
- * Query options for filtering, sorting and paginating results
65
- * @template T - Data model type
66
- */
67
- interface QueryOptions<T = any> {
68
- where?: WhereClause<T>[];
69
- /**
70
- * Simple OR: each clause is independently OR'd with the others.
71
- * Under the hood, generates one Firestore query per clause and merges results.
72
- * Base `where` conditions are applied to every OR branch.
73
- *
74
- * @example
75
- * ```ts
76
- * // Posts where status==draft OR status==published
77
- * orWhere: [["status", "==", "draft"], ["status", "==", "published"]]
78
- * ```
79
- */
80
- orWhere?: WhereClause<T>[];
81
- /**
82
- * Advanced OR: each element is a GROUP of AND conditions.
83
- * Groups are OR'd together. Base `where` conditions are applied to every group.
84
- *
85
- * @example
86
- * ```ts
87
- * // (status==published AND views>100) OR (status==draft AND userId=="abc")
88
- * orWhereGroups: [
89
- * [["status", "==", "published"], ["views", ">", 100]],
90
- * [["status", "==", "draft"], ["userId", "==", "abc"]],
91
- * ]
92
- * ```
93
- */
94
- orWhereGroups?: WhereClause<T>[][];
95
- orderBy?: {
96
- field: FieldPath<T>;
97
- direction?: "asc" | "desc";
98
- }[];
99
- limit?: number;
100
- offset?: number;
101
- startAt?: DocumentSnapshot | any[];
102
- startAfter?: DocumentSnapshot | any[];
103
- endAt?: DocumentSnapshot | any[];
104
- endBefore?: DocumentSnapshot | any[];
105
- /** Fields to select (Firestore select) - reduces network transfer */
106
- select?: (keyof T | FieldPath<T>)[];
107
- }
108
- /**
109
- * Options for get.by* methods
110
- * @template T - Data model type
111
- */
112
- interface GetOptions<T = any> {
113
- /** Fields to select (Firestore .select) — reduces network transfer */
114
- select?: (keyof T | string)[];
115
- /** Return the raw DocumentSnapshot alongside data */
116
- returnDoc?: boolean;
117
- }
118
- /**
119
- * Extracts the boolean value from a ReturnDoc parameter or options object
120
- * @internal
121
- */
122
- type ExtractReturnDoc<O> = O extends true ? true : O extends {
123
- returnDoc: true;
124
- } ? true : false;
125
- /**
126
- * Result type for get operations with optional document snapshot
127
- * @internal
128
- */
129
- type GetResult<T, O> = ExtractReturnDoc<O> extends true ? {
130
- data: T;
131
- doc: DocumentSnapshot;
132
- } | null : T | null;
133
- /**
134
- * Relation configuration for a field with strict typing
135
- * @template TRepoKey - Target repository name (key from mapping)
136
- * @template TForeignKey - Target foreign key name
137
- * @template TType - Relation type: "one" for one-to-one, "many" for one-to-many
138
- * @template TTargetModel - Type of the target model (inferred from mapping)
139
- */
140
- interface RelationConfig<TRepoKey extends string = string, TForeignKey extends string = string, TType extends "one" | "many" = "one" | "many", TTargetModel = any> {
141
- repo: TRepoKey;
142
- key: TForeignKey;
143
- type: TType;
144
- sourceKey?: string;
145
- targetType?: TTargetModel;
146
- }
147
- /**
148
- * Relational key mapping between repositories with strict typing
149
- * Maps a field from the current model to a target repository and foreign key
150
- * @template T - Current model type
151
- * @template TMapping - All repositories mapping for validation
152
- * @example { userId: { repo: "users", key: "docId", type: "one" } }
153
- * @example { events: { repo: "events", key: "residenceId", type: "many", sourceKey: "docId" } }
154
- */
155
- type RelationalKeys<T = any, TMapping = any> = {
156
- [K in string]?: TMapping extends Record<string, any> ? {
157
- [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<any, infer FKeys extends readonly any[], infer QKeys extends readonly any[], any, any, any, any, any, any, any, any> ? ({
158
- repo: R;
159
- key: FKeys[number];
160
- type: "one";
161
- sourceKey?: keyof T;
162
- } | {
163
- repo: R;
164
- key: QKeys[number];
165
- type: "many";
166
- sourceKey?: keyof T;
167
- }) : never;
168
- }[keyof TMapping] : RelationConfig;
169
- };
170
- /**
171
- * Configuration interface for repositories with strict literal type inference
172
- * @template T - The data model type
173
- * @template TForeignKeys - Foreign keys used for unique document retrieval
174
- * @template TQueryKeys - Query keys used for multiple document searches
175
- * @template TIsGroup - Whether this is a collection group query
176
- * @template TRefCb - Callback function signature for creating document references
177
- * @template TRelationalKeys - Relational keys mapping to other repositories
178
- * @template TDocumentKey - The field name to store the document ID
179
- * @template TPathKey - The field name to store the document path (optional)
180
- * @template TCreatedKey - The field name to store the creation timestamp (optional)
181
- * @template TUpdatedKey - The field name to store the update timestamp (optional)
182
- */
183
- interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryKeys extends readonly (keyof T)[], TIsGroup extends boolean = boolean, TRefCb = any, TRelationalKeys = {}, TDocumentKey extends keyof T = keyof T, TPathKey extends keyof T | undefined = undefined, TCreatedKey extends keyof T | undefined = undefined, TUpdatedKey extends keyof T | undefined = undefined, THistoryEnabled extends boolean = false> {
184
- path: string;
185
- isGroup: TIsGroup;
186
- foreignKeys: TForeignKeys;
187
- queryKeys: TQueryKeys;
188
- documentKey: TDocumentKey;
189
- pathKey?: TPathKey;
190
- createdKey?: TCreatedKey;
191
- updatedKey?: TUpdatedKey;
192
- type: T;
193
- /** Zod schema attached when using createRepositoryConfig(schema)(config). Used by the admin server. */
194
- schema?: zod.ZodObject<any>;
195
- refCb?: TRefCb;
196
- relationalKeys?: TRelationalKeys;
197
- /**
198
- * Optional change-history configuration. When `enabled: true`, the
199
- * `repo.history.*` read API is exposed and `createHistoryTriggers(...)`
200
- * will register Firestore triggers for this repo.
201
- *
202
- * @see import("../history/types").HistoryConfigForModel
203
- */
204
- history?: HistoryConfigForModel<T> & {
205
- enabled: THistoryEnabled;
206
- };
207
- documentRef: TRefCb extends undefined ? TIsGroup extends true ? (...pathSegments: string[]) => DocumentReference : (docId: string) => DocumentReference : ExtractDocumentRefSignature<TRefCb>;
208
- update: TRefCb extends undefined ? TIsGroup extends true ? (...args: [...string[], Partial<T>]) => Promise<T> : (docId: string, data: Partial<T>) => Promise<T> : ExtractUpdateSignature<TRefCb, T>;
209
- }
5
+ import { H as HistoryMethods } from './read-_6UEFCDw.js';
6
+ import { DocumentSnapshot, Query, CollectionReference, WriteBatch, Transaction, DocumentReference } from 'firebase-admin/firestore';
7
+ import { Q as QueryOptions, R as RepositoryConfig, G as GetOptions, c as GetResult, e as ExtractReturnDoc, a as RelationConfig, F as FieldPath } from './types-DgtfcerG.js';
210
8
 
211
9
  /**
212
10
  * Pagination result with data and cursor information
@@ -1246,4 +1044,4 @@ interface QueryRequestBody {
1246
1044
  withTotal?: boolean;
1247
1045
  }
1248
1046
 
1249
- export { type ApiResponse as A, createPaginationIterator as B, type ConfiguredRepository as C, type DeepDiffReturn as D, type ExtractDocumentRefSignature as E, type FieldRole as F, type GetOptions as G, executePaginatedQuery as H, type IndexErrorCallback as I, type PaginationResult as J, type SystemBackfillFailure as K, type ListResponseData as L, type SystemBackfillOptions as M, type SystemBackfillResult as N, type OpenAPISpecOptions as O, type PageOptions as P, type QueryRequestBody as Q, type RepoFieldPath as R, type SecurityHeadersOptions as S, type GenerateGetMethods as T, type UserFieldPath as U, type GenerateQueryMethods as V, type WhereClause as W, type IncludeConfigTyped as X, type PaginationWithIncludeOptionsTyped as Y, type PopulateOptionsTyped as Z, type CrudServerOptions as a, type CrudRepoConfig as b, type CrudRepoEntry as c, type CrudRepoRegistry as d, type CrudRules as e, type CrudUpdateRuleContext as f, type IndexErrorContext as g, type RepoRelationKeys as h, type Rule as i, type RuleResult as j, type RulesMap as k, type RepositoryConfig as l, type RelationalFieldMeta as m, type FieldPath as n, type ColumnMeta as o, type FilterState as p, type SortState as q, type QueryError as r, DEFAULT_HTML_CSP as s, securityHeaders as t, type QueryOptions as u, type PaginationOptions as v, type RelationConfig as w, type ExtractUpdateSignature as x, type GetResult as y, type RelationalKeys as z };
1047
+ export { type ApiResponse as A, type IncludeConfigTyped as B, type ConfiguredRepository as C, type DeepDiffReturn as D, type PaginationWithIncludeOptionsTyped as E, type FieldRole as F, type GenerateGetMethods as G, type PopulateOptionsTyped as H, type IndexErrorCallback as I, type ListResponseData as L, type OpenAPISpecOptions as O, type PageOptions as P, type QueryRequestBody as Q, type RepoFieldPath as R, type SecurityHeadersOptions as S, type UserFieldPath as U, type CrudServerOptions as a, type CrudRepoConfig as b, type CrudRepoEntry as c, type CrudRepoRegistry as d, type CrudRules as e, type CrudUpdateRuleContext as f, type IndexErrorContext as g, type RepoRelationKeys as h, type Rule as i, type RuleResult as j, type RulesMap as k, type RelationalFieldMeta as l, type ColumnMeta as m, type FilterState as n, type SortState as o, type QueryError as p, DEFAULT_HTML_CSP as q, type PaginationOptions as r, securityHeaders as s, createPaginationIterator as t, executePaginatedQuery as u, type PaginationResult as v, type SystemBackfillFailure as w, type SystemBackfillOptions as x, type SystemBackfillResult as y, type GenerateQueryMethods as z };