@haddowg/json-api-client 1.16.0 → 1.18.0
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 +20 -0
- package/dist/ajv.d.cts +1 -1
- package/dist/ajv.d.mts +1 -1
- package/dist/index.cjs +426 -207
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +423 -208
- package/dist/index.mjs.map +1 -1
- package/dist/{validate-DCMTndv-.d.cts → validate-Cknhw9k7.d.cts} +311 -30
- package/dist/validate-Cknhw9k7.d.cts.map +1 -0
- package/dist/{validate-DCMTndv-.d.mts → validate-Cknhw9k7.d.mts} +311 -30
- package/dist/validate-Cknhw9k7.d.mts.map +1 -0
- package/package.json +1 -1
- package/dist/validate-DCMTndv-.d.cts.map +0 -1
- package/dist/validate-DCMTndv-.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -126,6 +126,26 @@ reads (no single-`get` endpoint advertises it). The client negotiates the Counta
|
|
|
126
126
|
|
|
127
127
|
```ts
|
|
128
128
|
const albums = await client.albums.list({ withCount: ['tracks'] })
|
|
129
|
+
albums[0]!.$count('tracks') // number: the list asked to count tracks
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The server puts each count in the relationship object's `meta.total`. `$count(name)` reads it off
|
|
133
|
+
the resource, even when the relationship carries no data, and a to-many relationship array has
|
|
134
|
+
the same value as `$count`. Both are `undefined` when the server sent no finite number.
|
|
135
|
+
|
|
136
|
+
### `relatedQuery` (the Relationship Queries profile)
|
|
137
|
+
|
|
138
|
+
Where a type's `list` or `get` advertises it, `relatedQuery` filters and sorts a relationship
|
|
139
|
+
from the primary read, keyed by include path. Each entry's `filter` and `sort` take what the
|
|
140
|
+
relation's own related read takes. The client negotiates the profile in `Accept`, beside the
|
|
141
|
+
Countable one when `withCount` is set too.
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
const runs = await client['campaign-template-runs'].list({
|
|
145
|
+
withCount: ['items'],
|
|
146
|
+
relatedQuery: { items: { filter: { state: 'failed' } } },
|
|
147
|
+
})
|
|
148
|
+
runs[0]!.$count('items') // the run's failed items
|
|
129
149
|
```
|
|
130
150
|
|
|
131
151
|
### Pagination & cursor
|
package/dist/ajv.d.cts
CHANGED
package/dist/ajv.d.mts
CHANGED