@lpdjs/firestore-repo-service 3.0.12 → 3.0.13

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 (56) hide show
  1. package/README.md +27 -14
  2. package/dist/{create-servers-BaCe3x4U.d.ts → create-servers-Db1xUY2N.d.ts} +4 -4
  3. package/dist/{create-servers-C_UOfc_Z.d.cts → create-servers-LyRLAOh3.d.cts} +4 -4
  4. package/dist/history/index.cjs +1 -1
  5. package/dist/history/index.cjs.map +1 -1
  6. package/dist/history/index.js +1 -1
  7. package/dist/history/index.js.map +1 -1
  8. package/dist/index.cjs +62 -62
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +19 -15
  11. package/dist/index.d.ts +19 -15
  12. package/dist/index.js +62 -62
  13. package/dist/index.js.map +1 -1
  14. package/dist/llms-full.txt +36 -23
  15. package/dist/llms.txt +2 -2
  16. package/dist/{openapi-BJdsB8kh.d.ts → openapi-CNIA7QRw.d.ts} +1 -1
  17. package/dist/{openapi-D4xT2ilq.d.cts → openapi-QVpqnnes.d.cts} +1 -1
  18. package/dist/{queue-CVnFz30E.d.ts → queue-BEB-ujA3.d.ts} +1 -1
  19. package/dist/{queue-z04IR_Jq.d.cts → queue-CpHe6M5j.d.cts} +1 -1
  20. package/dist/{rules-CEYrlE4J.d.cts → rules-Bu2NB7Eb.d.cts} +1 -1
  21. package/dist/{rules-Dw-Pz8p3.d.ts → rules-Cafrkb9v.d.ts} +1 -1
  22. package/dist/servers/admin/index.cjs +26 -26
  23. package/dist/servers/admin/index.cjs.map +1 -1
  24. package/dist/servers/admin/index.d.cts +3 -1
  25. package/dist/servers/admin/index.d.ts +3 -1
  26. package/dist/servers/admin/index.js +26 -26
  27. package/dist/servers/admin/index.js.map +1 -1
  28. package/dist/servers/crud/index.cjs +2 -2
  29. package/dist/servers/crud/index.cjs.map +1 -1
  30. package/dist/servers/crud/index.d.cts +6 -6
  31. package/dist/servers/crud/index.d.ts +6 -6
  32. package/dist/servers/crud/index.js +2 -2
  33. package/dist/servers/crud/index.js.map +1 -1
  34. package/dist/servers/index.cjs +55 -55
  35. package/dist/servers/index.cjs.map +1 -1
  36. package/dist/servers/index.d.cts +8 -8
  37. package/dist/servers/index.d.ts +8 -8
  38. package/dist/servers/index.js +55 -55
  39. package/dist/servers/index.js.map +1 -1
  40. package/dist/sync/bigquery.d.cts +1 -1
  41. package/dist/sync/bigquery.d.ts +1 -1
  42. package/dist/sync/index.cjs +41 -41
  43. package/dist/sync/index.cjs.map +1 -1
  44. package/dist/sync/index.d.cts +5 -5
  45. package/dist/sync/index.d.ts +5 -5
  46. package/dist/sync/index.js +41 -41
  47. package/dist/sync/index.js.map +1 -1
  48. package/dist/sync/meilisearch.d.cts +1 -1
  49. package/dist/sync/meilisearch.d.ts +1 -1
  50. package/dist/{types-BFbzLuFf.d.cts → types-B51LYvQZ.d.cts} +48 -5
  51. package/dist/{types-DsTJZOfr.d.cts → types-CNseHqF7.d.cts} +4 -2
  52. package/dist/{types-Ds9DUc21.d.ts → types-Ci0dGbuW.d.ts} +48 -5
  53. package/dist/{types-fY1XOBeT.d.ts → types-DGQURFSq.d.ts} +1 -1
  54. package/dist/{types-YP53OtiU.d.ts → types-DmXW_fVz.d.ts} +4 -2
  55. package/dist/{types-_lql12Ez.d.cts → types-VVuLlmfc.d.cts} +1 -1
  56. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- # @lpdjs/firestore-repo-service (v3.0.12) — full documentation
1
+ # @lpdjs/firestore-repo-service (v3.0.13) — 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
 
@@ -78,7 +78,6 @@ const repositoryMapping = {
78
78
  pathKey: "documentPath",
79
79
  createdKey: "createdAt",
80
80
  updatedKey: "updatedAt",
81
- refCb: (db: Firestore, docId: string) => db.collection("users").doc(docId),
82
81
  }),
83
82
 
84
83
  posts: createRepositoryConfig(postSchema)({
@@ -90,7 +89,6 @@ const repositoryMapping = {
90
89
  pathKey: "documentPath",
91
90
  createdKey: "createdAt",
92
91
  updatedKey: "updatedAt",
93
- refCb: (db: Firestore, docId: string) => db.collection("posts").doc(docId),
94
92
  }),
95
93
  };
96
94
 
@@ -146,17 +144,17 @@ console.log(withAuthor.populated.userId); // UserModel | null
146
144
 
147
145
  ## `createRepositoryConfig()`
148
146
 
149
- | Parameter | Type | Default | Description |
150
- |---------------|------------|-------------------|---------------------------------------------------|
151
- | `path` | `string` | — | Firestore collection path |
152
- | `isGroup` | `boolean` | — | `true` for collection group queries |
153
- | `foreignKeys` | `string[]` | — | Keys for `get.by*` (unique retrieval) |
154
- | `queryKeys` | `string[]` | — | Keys for `query.by*` (list retrieval) |
155
- | `refCb` | Function | — | Builds the `DocumentReference` |
156
- | `documentKey` | `string` | `"docId"` | Field auto-injected with the Firestore document ID |
157
- | `pathKey` | `string` | `"documentPath"` | Field auto-injected with the full Firestore path |
158
- | `createdKey` | `string` | `"createdAt"` | Field auto-set on creation |
159
- | `updatedKey` | `string` | `"updatedAt"` | Field auto-updated on every write |
147
+ | Parameter | Type | Default | Description |
148
+ |---------------|------------|-------------------|--------------------------------------------------------------------------------------------------|
149
+ | `path` | `string` | — | Firestore collection path or typed template (e.g. `"users"` or `"posts/{postId}/comments"`) |
150
+ | `isGroup` | `boolean` | — | `true` for collection group / subcollection queries |
151
+ | `foreignKeys` | `string[]` | — | Keys for `get.by*` (unique retrieval) |
152
+ | `queryKeys` | `string[]` | — | Keys for `query.by*` (list retrieval) |
153
+ | `documentKey` | `string` | `"docId"` | Field auto-injected with the Firestore document ID |
154
+ | `pathKey` | `string` | `"documentPath"` | Field auto-injected with the full Firestore path |
155
+ | `createdKey` | `string` | `"createdAt"` | Field auto-set on creation (in `create()` and `set()` when omitted) |
156
+ | `updatedKey` | `string` | `"updatedAt"` | Field auto-updated on every write |
157
+ | `refCb` | Function | *(optional)* | **Deprecated** — Legacy callback building `DocumentReference` (now auto-derived from `path`) |
160
158
 
161
159
  ### Simple collection
162
160
 
@@ -170,17 +168,17 @@ users: createRepositoryConfig(userSchema)({
170
168
  pathKey: "documentPath",
171
169
  createdKey: "createdAt",
172
170
  updatedKey: "updatedAt",
173
- refCb: (db: Firestore, docId: string) => db.collection("users").doc(docId),
174
171
  });
175
172
  ```
176
173
 
177
- ### Sub-collection
174
+ ### Sub-collection (Typed Path Template)
178
175
 
179
- The `refCb` receives parent IDs in order, then the document ID last.
176
+ Instead of writing a manual `refCb`, use a path template with `{param}` placeholders.
177
+ Every `{param}` is strictly validated at compile-time against `keyof Model`, and its left-to-right order automatically types `documentRef`, `set`, `update`, and `delete`:
180
178
 
181
179
  ```typescript
182
- comments: createRepositoryConfig<CommentModel>()({
183
- path: "comments",
180
+ comments: createRepositoryConfig(commentSchema)({
181
+ path: "posts/{postId}/comments",
184
182
  isGroup: true,
185
183
  foreignKeys: ["docId", "postId", "userId"] as const,
186
184
  queryKeys: ["postId", "userId"] as const,
@@ -188,11 +186,24 @@ comments: createRepositoryConfig<CommentModel>()({
188
186
  pathKey: "documentPath",
189
187
  createdKey: "createdAt",
190
188
  updatedKey: "updatedAt",
191
- refCb: (db: Firestore, postId: string, commentId: string) =>
192
- db.collection("posts").doc(postId).collection("comments").doc(commentId),
193
189
  });
190
+
191
+ // Create on a sub-collection: parent keys ("postId") are extracted from data,
192
+ // while docId and documentPath ("posts/p1/comments/<autoId>") are generated on the fly!
193
+ const comment = await repos.comments.create({
194
+ postId: "p1",
195
+ userId: "u1",
196
+ content: "Great post!",
197
+ });
198
+
199
+ // Update / Delete receive parent IDs in template order, followed by docId:
200
+ await repos.comments.update("p1", comment.docId, { content: "Edited" });
201
+ await repos.comments.delete("p1", comment.docId);
194
202
  ```
195
203
 
204
+ **Static transit documents**
205
+ If your sub-collection sits under a fixed singleton/transit document (e.g. `"prevention/prev_rules/prev_workshops/{workshopId}/prev_events"`), simply write the static document ID (`prev_rules`) without `{...}` braces. It will be traversed in Firestore paths automatically without requiring an extra argument in `documentRef`, `update`, or `delete`.
206
+
196
207
  ## `buildRepositoryRelations()`
197
208
 
198
209
  Declares relationships between repositories.
@@ -1476,7 +1487,7 @@ const triggers = createHistoryTriggers(repos, {
1476
1487
  export const { residences_onHistory } = triggers;
1477
1488
  ```
1478
1489
 
1479
- For `collectionGroup` repos, set `triggerPath` in the per-repo override (same constraint as sync triggers).
1490
+ For `collectionGroup` repos (`isGroup: true`), the trigger path is **automatically derived** when `path` is a template (e.g. `path: "residences/{residenceId}/res_events"` → `"residences/{residenceId}/res_events/{docId}"`). You only need to set `triggerPath` in the per-repo override if `path` only contains the leaf collection name.
1480
1491
 
1481
1492
  ### 3. Read history from your code
1482
1493
 
@@ -1723,7 +1734,9 @@ adapters: [
1723
1734
 
1724
1735
  ### Collection Groups (`triggerPath`)
1725
1736
 
1726
- For repos with `isGroup: true`, you **must** provide a `triggerPath`:
1737
+ For repos with `isGroup: true`, if your repository config uses a full path template (e.g. `path: "posts/{postId}/comments"`), the trigger path (`"posts/{postId}/comments/{docId}"`) is **inferred automatically**!
1738
+
1739
+ If your repository config only specifies the leaf collection name (`path: "comments"`), or if you want to override the pattern, provide `triggerPath`:
1727
1740
 
1728
1741
  ```typescript
1729
1742
  repos: {
package/dist/llms.txt CHANGED
@@ -1,4 +1,4 @@
1
- # @lpdjs/firestore-repo-service (v3.0.12)
1
+ # @lpdjs/firestore-repo-service (v3.0.13)
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
 
@@ -6,7 +6,7 @@ Type-safe Firestore ORM + servers (admin UI, CRUD REST, Hono file-based API, Fir
6
6
 
7
7
  ## Guides
8
8
  - [Getting Started](https://frs.lpdjs.fr/guide/getting-started): Using Zod gives you automatic schema inference — no need to declare the model interface separately.
9
- - [Configuration](https://frs.lpdjs.fr/guide/configuration): The refCb receives parent IDs in order, then the document ID last.
9
+ - [Configuration](https://frs.lpdjs.fr/guide/configuration): Instead of writing a manual refCb, use a path template with {param} placeholders.
10
10
  - [Relations & Populate](https://frs.lpdjs.fr/guide/relations): Each entry maps a field in the source model to a target repository:
11
11
  - [Querying](https://frs.lpdjs.fr/guide/querying): Retrieve a single document by a foreign key.
12
12
  - [Advanced Usage](https://frs.lpdjs.fr/guide/advanced): Creates or replaces a document with a specific ID.
@@ -1,4 +1,4 @@
1
- import { d as CrudRepoRegistry, O as OpenAPISpecOptions } from './types-YP53OtiU.js';
1
+ import { d as CrudRepoRegistry, O as OpenAPISpecOptions } from './types-DmXW_fVz.js';
2
2
 
3
3
  /**
4
4
  * OpenAPI 3.1 specification generator for the CRUD server.
@@ -1,4 +1,4 @@
1
- import { d as CrudRepoRegistry, O as OpenAPISpecOptions } from './types-DsTJZOfr.cjs';
1
+ import { d as CrudRepoRegistry, O as OpenAPISpecOptions } from './types-CNseHqF7.cjs';
2
2
 
3
3
  /**
4
4
  * OpenAPI 3.1 specification generator for the CRUD server.
@@ -1,4 +1,4 @@
1
- import { a as SyncAdapter, S as SyncEvent } from './types-fY1XOBeT.js';
1
+ import { a as SyncAdapter, S as SyncEvent } from './types-DGQURFSq.js';
2
2
 
3
3
  /**
4
4
  * Per-repo in-memory batch buffer.
@@ -1,4 +1,4 @@
1
- import { a as SyncAdapter, S as SyncEvent } from './types-_lql12Ez.cjs';
1
+ import { a as SyncAdapter, S as SyncEvent } from './types-VVuLlmfc.cjs';
2
2
 
3
3
  /**
4
4
  * Per-repo in-memory batch buffer.
@@ -1,5 +1,5 @@
1
1
  import { b as AuthUser } from './firebase-auth-nG3prKoj.cjs';
2
- import { D as DeepDiffReturn, k as RulesMap, f as CrudUpdateRuleContext } from './types-DsTJZOfr.cjs';
2
+ import { D as DeepDiffReturn, k as RulesMap, f as CrudUpdateRuleContext } from './types-CNseHqF7.cjs';
3
3
 
4
4
  /**
5
5
  * Computes a typed diff between the existing document (`before`) and the incoming partial changes (`changesInput`).
@@ -1,5 +1,5 @@
1
1
  import { b as AuthUser } from './firebase-auth-nG3prKoj.js';
2
- import { D as DeepDiffReturn, k as RulesMap, f as CrudUpdateRuleContext } from './types-YP53OtiU.js';
2
+ import { D as DeepDiffReturn, k as RulesMap, f as CrudUpdateRuleContext } from './types-DmXW_fVz.js';
3
3
 
4
4
  /**
5
5
  * Computes a typed diff between the existing document (`before`) and the incoming partial changes (`changesInput`).