@lpdjs/firestore-repo-service 3.0.11 → 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.
- package/README.md +27 -14
- package/dist/{create-servers-KRf2J2fi.d.ts → create-servers-Db1xUY2N.d.ts} +4 -4
- package/dist/{create-servers-DQBvtkBM.d.cts → create-servers-LyRLAOh3.d.cts} +4 -4
- package/dist/history/index.cjs +1 -1
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.js +1 -1
- package/dist/history/index.js.map +1 -1
- package/dist/index.cjs +69 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -15
- package/dist/index.d.ts +19 -15
- package/dist/index.js +69 -69
- package/dist/index.js.map +1 -1
- package/dist/llms-full.txt +36 -23
- package/dist/llms.txt +2 -2
- package/dist/{openapi-CzrvqcOE.d.ts → openapi-CNIA7QRw.d.ts} +1 -1
- package/dist/{openapi-DK7pS1zN.d.cts → openapi-QVpqnnes.d.cts} +1 -1
- package/dist/{queue-HoGBozpD.d.ts → queue-BEB-ujA3.d.ts} +1 -1
- package/dist/{queue-CdmBSUNN.d.cts → queue-CpHe6M5j.d.cts} +1 -1
- package/dist/{rules-Bu2WJoLI.d.cts → rules-Bu2NB7Eb.d.cts} +1 -1
- package/dist/{rules-gKR5VFhO.d.ts → rules-Cafrkb9v.d.ts} +1 -1
- package/dist/servers/admin/index.cjs +26 -26
- package/dist/servers/admin/index.cjs.map +1 -1
- package/dist/servers/admin/index.d.cts +3 -1
- package/dist/servers/admin/index.d.ts +3 -1
- package/dist/servers/admin/index.js +26 -26
- package/dist/servers/admin/index.js.map +1 -1
- package/dist/servers/crud/index.cjs +2 -2
- package/dist/servers/crud/index.cjs.map +1 -1
- package/dist/servers/crud/index.d.cts +6 -6
- package/dist/servers/crud/index.d.ts +6 -6
- package/dist/servers/crud/index.js +2 -2
- package/dist/servers/crud/index.js.map +1 -1
- package/dist/servers/hono/index.cjs +12 -12
- package/dist/servers/hono/index.cjs.map +1 -1
- package/dist/servers/hono/index.js +12 -12
- package/dist/servers/hono/index.js.map +1 -1
- package/dist/servers/index.cjs +88 -88
- package/dist/servers/index.cjs.map +1 -1
- package/dist/servers/index.d.cts +8 -8
- package/dist/servers/index.d.ts +8 -8
- package/dist/servers/index.js +88 -88
- package/dist/servers/index.js.map +1 -1
- package/dist/sync/bigquery.d.cts +1 -1
- package/dist/sync/bigquery.d.ts +1 -1
- package/dist/sync/index.cjs +41 -41
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +5 -5
- package/dist/sync/index.d.ts +5 -5
- package/dist/sync/index.js +41 -41
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/meilisearch.d.cts +1 -1
- package/dist/sync/meilisearch.d.ts +1 -1
- package/dist/{types-DZoEAKT7.d.cts → types-B51LYvQZ.d.cts} +58 -7
- package/dist/{types-8Yoacm2k.d.cts → types-CNseHqF7.d.cts} +4 -2
- package/dist/{types-DiGFAWPA.d.ts → types-Ci0dGbuW.d.ts} +58 -7
- package/dist/{types-DzJ9WrcY.d.ts → types-DGQURFSq.d.ts} +1 -1
- package/dist/{types-DRKB8gTA.d.ts → types-DmXW_fVz.d.ts} +4 -2
- package/dist/{types-KEVZXCF4.d.cts → types-VVuLlmfc.d.cts} +1 -1
- package/package.json +3 -2
package/dist/llms-full.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @lpdjs/firestore-repo-service (v3.0.
|
|
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
|
-
| `
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
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
|
-
|
|
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
|
|
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
|
|
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`,
|
|
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.
|
|
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):
|
|
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,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-
|
|
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-
|
|
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`).
|