@lpdjs/firestore-repo-service 3.0.19 → 3.0.21

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 (44) hide show
  1. package/README.md +1 -1
  2. package/dist/{create-servers-DydjOOOS.d.cts → create-servers-TfGVAXBQ.d.cts} +3 -3
  3. package/dist/{create-servers-bMJVVjPj.d.ts → create-servers-z-dCkmv2.d.ts} +3 -3
  4. package/dist/{effects-BYvL8JUK.d.ts → effects-DLBSYKuA.d.ts} +1 -1
  5. package/dist/{effects-DcM19dy4.d.cts → effects-DsI4cSpI.d.cts} +1 -1
  6. package/dist/index.cjs +108 -102
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +11 -7
  9. package/dist/index.d.ts +11 -7
  10. package/dist/index.js +108 -102
  11. package/dist/index.js.map +1 -1
  12. package/dist/llms-full.txt +5 -5
  13. package/dist/llms.txt +1 -1
  14. package/dist/queue-Bh7O8NnJ.d.ts +117 -0
  15. package/dist/queue-CEg5KSo1.d.cts +117 -0
  16. package/dist/servers/admin/index.cjs +51 -51
  17. package/dist/servers/admin/index.cjs.map +1 -1
  18. package/dist/servers/admin/index.d.cts +9 -1
  19. package/dist/servers/admin/index.d.ts +9 -1
  20. package/dist/servers/admin/index.js +51 -51
  21. package/dist/servers/admin/index.js.map +1 -1
  22. package/dist/servers/crud/index.cjs +1 -1
  23. package/dist/servers/crud/index.cjs.map +1 -1
  24. package/dist/servers/crud/index.d.cts +4 -4
  25. package/dist/servers/crud/index.d.ts +4 -4
  26. package/dist/servers/crud/index.js +1 -1
  27. package/dist/servers/crud/index.js.map +1 -1
  28. package/dist/servers/index.cjs +115 -109
  29. package/dist/servers/index.cjs.map +1 -1
  30. package/dist/servers/index.d.cts +6 -6
  31. package/dist/servers/index.d.ts +6 -6
  32. package/dist/servers/index.js +115 -109
  33. package/dist/servers/index.js.map +1 -1
  34. package/dist/sync/index.cjs +67 -61
  35. package/dist/sync/index.cjs.map +1 -1
  36. package/dist/sync/index.d.cts +2 -2
  37. package/dist/sync/index.d.ts +2 -2
  38. package/dist/sync/index.js +67 -61
  39. package/dist/sync/index.js.map +1 -1
  40. package/dist/{types-5Q7JDDba.d.ts → types-6jjeTvcm.d.ts} +7 -2
  41. package/dist/{types-BYPdlGSL.d.cts → types-BLHo_PdM.d.cts} +7 -2
  42. package/package.json +1 -1
  43. package/dist/queue-NFod6hTT.d.ts +0 -62
  44. package/dist/queue-zw2B7GPx.d.cts +0 -62
@@ -1,4 +1,4 @@
1
- # @lpdjs/firestore-repo-service (v3.0.19) — full documentation
1
+ # @lpdjs/firestore-repo-service (v3.0.21) — full documentation
2
2
 
3
3
  > ⚡ Type-safe Firestore ORM with auto-generated repositories, advanced queries, relations with typed select, pagination with include, batch/bulk operations, aggregations and transactions.
4
4
 
@@ -550,7 +550,7 @@ const page1 = await repos.posts.query.paginate({
550
550
  // page1.nextCursor → DocumentSnapshot | undefined
551
551
  // page1.prevCursor → DocumentSnapshot | undefined
552
552
  // page1.totalCount → number (e.g. 142)
553
- // page1.totalCountIsExact → boolean (true for AND queries, false for OR queries)
553
+ // page1.totalCountIsExact → boolean (true when exact incl. native Filter.or, false on fallback)
554
554
 
555
555
  // Next page
556
556
  const page2 = await repos.posts.query.paginate({
@@ -568,7 +568,7 @@ const prev = await repos.posts.query.paginate({
568
568
  ```
569
569
 
570
570
  **Server-side count performance (`withTotal`)**
571
- When `withTotal: true` is passed, total document count is computed via Firestore's native `.count()` server-side aggregation (**1 index read per 1,000 documents**). For `orWhere` and `orWhereGroups`, counts across branches are aggregated in parallel (fast estimation without fetching document payloads).
571
+ When `withTotal: true` is passed, total document count is computed via Firestore's native `.count()` server-side aggregation (**1 index read per 1,000 documents**). For `orWhere` and `orWhereGroups`, Firestore's native `Filter.or()` is used automatically when eligible (≤ 30 DNF disjunctions) to return an exact, deduplicated count (`totalCountIsExact: true`), falling back to parallel per-branch `.count()` estimation (`totalCountIsExact: false`) otherwise.
572
572
 
573
573
  ### Paginate with filters and OR
574
574
 
@@ -1303,8 +1303,8 @@ Send complex filter conditions including `where` (AND), `orWhere` (simple OR), a
1303
1303
  ```
1304
1304
 
1305
1305
  **Total Count Behavior (`withTotal`):**
1306
- - **Pure AND queries & split `in` clauses**: Uses server-side `.count()` aggregation. `totalCountIsExact` is `true`.
1307
- - **OR queries (`orWhere`, `orWhereGroups`)**: Executes parallel server-side `.count()` queries across OR branches. Fast and lightweight (`1000 docs = 1 index read`). `totalCountIsExact` is `false` (estimated due to potential branch overlap).
1306
+ - **Pure AND queries & split `in` clauses**: Uses server-side `.count()` aggregation. `totalCountIsExact` is `true` (for split `array-contains-any` > 30 values, `totalCountIsExact` is `false`).
1307
+ - **OR queries (`orWhere`, `orWhereGroups`)**: Uses Firestore's native `Filter.or()` server-side `.count()` aggregation when eligible (≤ 30 DNF disjunctions, compatible operators, composite indexes present) — deduplicated on the server with `totalCountIsExact: true`. Automatically falls back to parallel per-branch `.count()` aggregation (`totalCountIsExact: false`) when Firestore limits or missing composite indexes prevent native `Filter.or()`.
1308
1308
 
1309
1309
  ---
1310
1310
 
package/dist/llms.txt CHANGED
@@ -1,4 +1,4 @@
1
- # @lpdjs/firestore-repo-service (v3.0.19)
1
+ # @lpdjs/firestore-repo-service (v3.0.21)
2
2
 
3
3
  > ⚡ Type-safe Firestore ORM with auto-generated repositories, advanced queries, relations with typed select, pagination with include, batch/bulk operations, aggregations and transactions.
4
4
 
@@ -0,0 +1,117 @@
1
+ import { a as SyncAdapter, S as SyncEvent } from './types-B_FrzmO4.js';
2
+
3
+ /**
4
+ * Per-repo in-memory batch buffer.
5
+ *
6
+ * Accumulates {@link SyncEvent}s and flushes them in batches to a
7
+ * {@link SqlAdapter}. On flush failure the events are re-published
8
+ * to PubSub for retry (if a PubSub re-publisher is provided).
9
+ */
10
+
11
+ interface SyncQueueOptions {
12
+ /** Target adapter to flush data to */
13
+ adapter: SyncAdapter;
14
+ /** SQL table name or Search index UID */
15
+ tableName: string;
16
+ /** Primary key column/field name */
17
+ primaryKey: string;
18
+ /** Max rows per flush (default: 100) */
19
+ batchSize?: number;
20
+ /** Auto-flush interval in ms (default: 5_000). 0 = manual only. */
21
+ flushIntervalMs?: number;
22
+ /** Called on flush failure with the failed events. Typically re-publishes to PubSub. */
23
+ onFlushError?: (events: SyncEvent[], error: unknown) => Promise<void>;
24
+ }
25
+ interface SyncQueueErrorEntry {
26
+ /** Monotonic error sequence number for this queue instance */
27
+ seq: number;
28
+ /** Error message string */
29
+ message: string;
30
+ /** Number of events in the failed batch */
31
+ count: number;
32
+ /** Epoch millis when the failure occurred */
33
+ timestamp: number;
34
+ }
35
+ interface SyncQueueStats {
36
+ /** Total events successfully flushed to the adapter */
37
+ flushedEvents: number;
38
+ /** Total events whose flush failed */
39
+ failedEvents: number;
40
+ /** Total batches successfully flushed */
41
+ flushedBatches: number;
42
+ /** Total batches whose flush failed */
43
+ failedBatches: number;
44
+ /** Monotonic sequence counter of recorded flush errors */
45
+ errorSeq: number;
46
+ /** Recent flush error entries (capped ring buffer) */
47
+ recentErrors: SyncQueueErrorEntry[];
48
+ }
49
+ interface SyncQueueFlushReport {
50
+ /** Events successfully flushed during this flush call */
51
+ flushed: number;
52
+ /** Events that failed during this flush call */
53
+ failed: number;
54
+ /** Error messages recorded during this flush call */
55
+ errors: string[];
56
+ }
57
+ /**
58
+ * In-memory buffer that batches sync events per-repo and flushes them
59
+ * to a target adapter.
60
+ */
61
+ declare class SyncQueue {
62
+ private static readonly MAX_RECENT_ERRORS;
63
+ private buffer;
64
+ private flushing;
65
+ private lastFlushFailed;
66
+ private flushPromise;
67
+ private timer;
68
+ private flushedEvents;
69
+ private failedEvents;
70
+ private flushedBatches;
71
+ private failedBatches;
72
+ private errorSeq;
73
+ private recentErrors;
74
+ private readonly adapter;
75
+ private readonly tableName;
76
+ private readonly primaryKey;
77
+ private readonly batchSize;
78
+ private readonly onFlushError?;
79
+ constructor(opts: SyncQueueOptions);
80
+ /** Number of events waiting in the buffer. */
81
+ get size(): number;
82
+ /** Snapshot cumulative flush statistics for this queue. */
83
+ getStats(): SyncQueueStats;
84
+ /** Push one or more events into the buffer. Triggers auto-flush if batchSize reached. */
85
+ enqueue(...events: SyncEvent[]): void;
86
+ /**
87
+ * Auto-flush full batches triggered by `enqueue()`.
88
+ * Only drains complete batches of `batchSize` so events trickling in during
89
+ * an async flush are not sent as tiny 1-2 row micro-batches.
90
+ */
91
+ private _autoFlush;
92
+ /**
93
+ * Flush all buffered events to the target adapter.
94
+ * Upserts and deletes are batched separately.
95
+ */
96
+ flush(): Promise<void>;
97
+ /**
98
+ * Flush all buffered events and return the delta of flushed/failed counts
99
+ * and error messages recorded while draining.
100
+ */
101
+ flushWithReport(): Promise<SyncQueueFlushReport>;
102
+ /**
103
+ * Drain the buffer. When `fullBatchesOnly` is true, stops once fewer than
104
+ * `batchSize` events remain so partial batches wait for explicit `flush()`
105
+ * or the periodic timer.
106
+ */
107
+ private _drain;
108
+ /**
109
+ * Flush a single batch (up to `batchSize` events) to the adapter.
110
+ */
111
+ private _doFlush;
112
+ /** Stop the auto-flush timer and flush remaining events. */
113
+ shutdown(): Promise<void>;
114
+ }
115
+
116
+ export { SyncQueue as S };
117
+ export type { SyncQueueOptions as a };
@@ -0,0 +1,117 @@
1
+ import { a as SyncAdapter, S as SyncEvent } from './types-D78FPJeF.cjs';
2
+
3
+ /**
4
+ * Per-repo in-memory batch buffer.
5
+ *
6
+ * Accumulates {@link SyncEvent}s and flushes them in batches to a
7
+ * {@link SqlAdapter}. On flush failure the events are re-published
8
+ * to PubSub for retry (if a PubSub re-publisher is provided).
9
+ */
10
+
11
+ interface SyncQueueOptions {
12
+ /** Target adapter to flush data to */
13
+ adapter: SyncAdapter;
14
+ /** SQL table name or Search index UID */
15
+ tableName: string;
16
+ /** Primary key column/field name */
17
+ primaryKey: string;
18
+ /** Max rows per flush (default: 100) */
19
+ batchSize?: number;
20
+ /** Auto-flush interval in ms (default: 5_000). 0 = manual only. */
21
+ flushIntervalMs?: number;
22
+ /** Called on flush failure with the failed events. Typically re-publishes to PubSub. */
23
+ onFlushError?: (events: SyncEvent[], error: unknown) => Promise<void>;
24
+ }
25
+ interface SyncQueueErrorEntry {
26
+ /** Monotonic error sequence number for this queue instance */
27
+ seq: number;
28
+ /** Error message string */
29
+ message: string;
30
+ /** Number of events in the failed batch */
31
+ count: number;
32
+ /** Epoch millis when the failure occurred */
33
+ timestamp: number;
34
+ }
35
+ interface SyncQueueStats {
36
+ /** Total events successfully flushed to the adapter */
37
+ flushedEvents: number;
38
+ /** Total events whose flush failed */
39
+ failedEvents: number;
40
+ /** Total batches successfully flushed */
41
+ flushedBatches: number;
42
+ /** Total batches whose flush failed */
43
+ failedBatches: number;
44
+ /** Monotonic sequence counter of recorded flush errors */
45
+ errorSeq: number;
46
+ /** Recent flush error entries (capped ring buffer) */
47
+ recentErrors: SyncQueueErrorEntry[];
48
+ }
49
+ interface SyncQueueFlushReport {
50
+ /** Events successfully flushed during this flush call */
51
+ flushed: number;
52
+ /** Events that failed during this flush call */
53
+ failed: number;
54
+ /** Error messages recorded during this flush call */
55
+ errors: string[];
56
+ }
57
+ /**
58
+ * In-memory buffer that batches sync events per-repo and flushes them
59
+ * to a target adapter.
60
+ */
61
+ declare class SyncQueue {
62
+ private static readonly MAX_RECENT_ERRORS;
63
+ private buffer;
64
+ private flushing;
65
+ private lastFlushFailed;
66
+ private flushPromise;
67
+ private timer;
68
+ private flushedEvents;
69
+ private failedEvents;
70
+ private flushedBatches;
71
+ private failedBatches;
72
+ private errorSeq;
73
+ private recentErrors;
74
+ private readonly adapter;
75
+ private readonly tableName;
76
+ private readonly primaryKey;
77
+ private readonly batchSize;
78
+ private readonly onFlushError?;
79
+ constructor(opts: SyncQueueOptions);
80
+ /** Number of events waiting in the buffer. */
81
+ get size(): number;
82
+ /** Snapshot cumulative flush statistics for this queue. */
83
+ getStats(): SyncQueueStats;
84
+ /** Push one or more events into the buffer. Triggers auto-flush if batchSize reached. */
85
+ enqueue(...events: SyncEvent[]): void;
86
+ /**
87
+ * Auto-flush full batches triggered by `enqueue()`.
88
+ * Only drains complete batches of `batchSize` so events trickling in during
89
+ * an async flush are not sent as tiny 1-2 row micro-batches.
90
+ */
91
+ private _autoFlush;
92
+ /**
93
+ * Flush all buffered events to the target adapter.
94
+ * Upserts and deletes are batched separately.
95
+ */
96
+ flush(): Promise<void>;
97
+ /**
98
+ * Flush all buffered events and return the delta of flushed/failed counts
99
+ * and error messages recorded while draining.
100
+ */
101
+ flushWithReport(): Promise<SyncQueueFlushReport>;
102
+ /**
103
+ * Drain the buffer. When `fullBatchesOnly` is true, stops once fewer than
104
+ * `batchSize` events remain so partial batches wait for explicit `flush()`
105
+ * or the periodic timer.
106
+ */
107
+ private _drain;
108
+ /**
109
+ * Flush a single batch (up to `batchSize` events) to the adapter.
110
+ */
111
+ private _doFlush;
112
+ /** Stop the auto-flush timer and flush remaining events. */
113
+ shutdown(): Promise<void>;
114
+ }
115
+
116
+ export { SyncQueue as S };
117
+ export type { SyncQueueOptions as a };