@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 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
@@ -1,4 +1,4 @@
1
- import { a as Validator, n as SchemaMap } from "./validate-DCMTndv-.cjs";
1
+ import { a as Validator, n as SchemaMap } from "./validate-Cknhw9k7.cjs";
2
2
  import { ValidateFunction } from "ajv";
3
3
 
4
4
  //#region src/ajv.d.ts
package/dist/ajv.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Validator, n as SchemaMap } from "./validate-DCMTndv-.mjs";
1
+ import { a as Validator, n as SchemaMap } from "./validate-Cknhw9k7.mjs";
2
2
  import { ValidateFunction } from "ajv";
3
3
 
4
4
  //#region src/ajv.d.ts