lazypock 0.10.1 → 0.10.2
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 +25 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +145 -37
- package/dist/index.d.ts +145 -37
- package/dist/index.global.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/collection.ts +34 -18
- package/src/types.ts +261 -38
package/README.md
CHANGED
|
@@ -230,35 +230,52 @@ operators) at compile time — your editor suggests valid fields as you type:
|
|
|
230
230
|
```typescript
|
|
231
231
|
await postsSvc.getList(1, 20, { sort: '-title' }); // ✓ suggests title/published/…
|
|
232
232
|
await postsSvc.getList(1, 20, { sort: '-nope' }); // ✗ compile error
|
|
233
|
+
await postsSvc.getList(1, 20, { sort: 'title, nope' }); // ✗ every token checked
|
|
233
234
|
|
|
234
235
|
await postsSvc.getList(1, 20, {
|
|
235
|
-
filter: "title ~ 'x' && published = true", // ✓ field + operator checked
|
|
236
|
+
filter: "title ~ 'x' && published = true", // ✓ every clause field + operator checked
|
|
236
237
|
});
|
|
237
238
|
await postsSvc.getList(1, 20, { filter: `title=${search}` }); // ✓ spaces optional
|
|
238
239
|
await postsSvc.getList(1, 20, { filter: "(title = 'a' || title = 'b')" }); // ✓ parens
|
|
239
240
|
await postsSvc.getList(1, 20, { filter: "author.email = 'x'" }); // ✓ relation dot-path
|
|
240
241
|
await postsSvc.getList(1, 20, { filter: 'nope = 1' }); // ✗ compile error
|
|
242
|
+
await postsSvc.getList(1, 20, {
|
|
243
|
+
filter: "title = 'a' && nope = 'y'", // ✗ EVERY clause is validated
|
|
244
|
+
});
|
|
241
245
|
|
|
242
246
|
await postsSvc.getList(1, 20, { expand: 'author' }); // ✓ field suggested
|
|
243
247
|
await postsSvc.getList(1, 20, { expand: 'author.user' }); // ✓ nested dot-path
|
|
248
|
+
await postsSvc.getList(1, 20, { expand: 'author, nope' }); // ✗ every token checked
|
|
244
249
|
await postsSvc.getOne('abc', { expand: 'author' });
|
|
250
|
+
|
|
251
|
+
// Expanded records carry an `expand` property keyed by the requested fields:
|
|
252
|
+
const posts = await postsSvc.getFullList({ expand: 'author' });
|
|
253
|
+
posts[0].expand?.author; // ✓ the expanded relation (shape is `unknown`)
|
|
245
254
|
```
|
|
246
255
|
|
|
247
256
|
- `filter` — `field op value` clauses with `= != ~ !~ > >= < <=` operators
|
|
248
257
|
(spaces around the operator optional); `&&`, `||`, `!`, and parentheses are
|
|
249
|
-
allowed
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
258
|
+
allowed; relation dot-paths like `author.email = 'x'` typecheck. **Every**
|
|
259
|
+
clause's field name and operator are validated — a typo in any clause is a
|
|
260
|
+
compile error, and quoted values may contain `&&`/`||` (e.g.
|
|
261
|
+
`title ~ 'a && b'`). Field names and operators are suggested as you type.
|
|
262
|
+
- `sort` — `field`, `-field` (desc), `+field`, or comma-separated. **Every**
|
|
263
|
+
token is validated.
|
|
253
264
|
- `expand` — comma-separated relation field names, including nested dot-paths
|
|
254
|
-
(`author.user`); non-relation fields warn at
|
|
255
|
-
available.
|
|
265
|
+
(`author.user`); **every** token is validated; non-relation fields warn at
|
|
266
|
+
runtime when a schema is available.
|
|
267
|
+
|
|
268
|
+
**Expanded records are typed.** When a list/read is called with `expand`,
|
|
269
|
+
the returned records include an optional `expand` object whose keys are the
|
|
270
|
+
requested top-level relation fields (`record.expand.author` — dot-paths
|
|
271
|
+
collapse to their first segment). The expanded value's shape belongs to the
|
|
272
|
+
target collection, so it is typed `unknown`.
|
|
256
273
|
|
|
257
274
|
**Hidden fields are queryable.** A hidden relation is excluded from the read
|
|
258
275
|
model (no `record.user`) but the server still resolves it for
|
|
259
276
|
`filter`/`sort`/`expand`/`select` — the generated `*QueryFields` type keeps
|
|
260
277
|
those keys accepted, so `getFullList({ expand: "user" })` typechecks for a
|
|
261
|
-
hidden relation.
|
|
278
|
+
hidden relation (and `record.expand?.user` is typed on the result).
|
|
262
279
|
|
|
263
280
|
- The **untyped** client (`client.collection('posts')` without `typed<T>()`)
|
|
264
281
|
still accepts any string — suggestions kick in once the service is typed.
|