@data-client/core 0.15.0-beta-20251006024044-92bd01c4976f2921993b8c9f1e4dbb87af87ba7b → 0.15.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +1191 -0
  2. package/dist/index.umd.min.js +1 -1
  3. package/legacy/manager/SubscriptionManager.js +1 -1
  4. package/legacy/middlewareTypes.js +1 -1
  5. package/legacy/mock/MockController.js +124 -0
  6. package/legacy/mock/collapseFixture.js +19 -0
  7. package/legacy/mock/createFixtureMap.js +23 -0
  8. package/legacy/mock/fixtureTypes.js +2 -0
  9. package/legacy/mock/index.js +5 -0
  10. package/legacy/mock/mockState.js +44 -0
  11. package/legacy/mock/mockTypes.js +2 -0
  12. package/lib/manager/SubscriptionManager.d.ts.map +1 -1
  13. package/lib/manager/SubscriptionManager.js +1 -1
  14. package/lib/middlewareTypes.d.ts.map +1 -1
  15. package/lib/middlewareTypes.js +1 -1
  16. package/lib/mock/MockController.d.ts +4 -0
  17. package/lib/mock/MockController.d.ts.map +1 -0
  18. package/lib/mock/MockController.js +125 -0
  19. package/lib/mock/collapseFixture.d.ts +6 -0
  20. package/lib/mock/collapseFixture.d.ts.map +1 -0
  21. package/lib/mock/collapseFixture.js +19 -0
  22. package/lib/mock/createFixtureMap.d.ts +3 -0
  23. package/lib/mock/createFixtureMap.d.ts.map +1 -0
  24. package/lib/mock/createFixtureMap.js +23 -0
  25. package/lib/mock/fixtureTypes.d.ts +99 -0
  26. package/lib/mock/fixtureTypes.d.ts.map +1 -0
  27. package/lib/mock/fixtureTypes.js +2 -0
  28. package/lib/mock/index.d.ts +7 -0
  29. package/lib/mock/index.d.ts.map +1 -0
  30. package/lib/mock/index.js +5 -0
  31. package/lib/mock/mockState.d.ts +4 -0
  32. package/lib/mock/mockState.d.ts.map +1 -0
  33. package/lib/mock/mockState.js +44 -0
  34. package/lib/mock/mockTypes.d.ts +6 -0
  35. package/lib/mock/mockTypes.d.ts.map +1 -0
  36. package/lib/mock/mockTypes.js +2 -0
  37. package/package.json +16 -6
  38. package/src/manager/SubscriptionManager.ts +1 -2
  39. package/src/middlewareTypes.ts +3 -2
  40. package/src/mock/MockController.ts +146 -0
  41. package/src/mock/collapseFixture.ts +21 -0
  42. package/src/mock/createFixtureMap.ts +26 -0
  43. package/src/mock/fixtureTypes.ts +121 -0
  44. package/src/mock/index.ts +16 -0
  45. package/src/mock/mockState.ts +56 -0
  46. package/src/mock/mockTypes.ts +6 -0
  47. package/ts3.4/mock/MockController.d.ts +4 -0
  48. package/ts3.4/mock/collapseFixture.d.ts +6 -0
  49. package/ts3.4/mock/createFixtureMap.d.ts +6 -0
  50. package/ts3.4/mock/fixtureTypes.d.ts +99 -0
  51. package/ts3.4/mock/index.d.ts +7 -0
  52. package/ts3.4/mock/mockState.d.ts +4 -0
  53. package/ts3.4/mock/mockTypes.d.ts +6 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,1191 @@
1
+ # @data-client/core
2
+
3
+ ## 0.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#3449](https://github.com/reactive/data-client/pull/3449) [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: schema.normalize(...args, addEntity, getEntity, checkLoop) -> schema.normalize(...args, delegate)
8
+
9
+ We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument.
10
+
11
+ ```ts
12
+ /** Helpers during schema.normalize() */
13
+ export interface INormalizeDelegate {
14
+ /** Action meta-data for this normalize call */
15
+ readonly meta: { fetchedAt: number; date: number; expiresAt: number };
16
+ /** Gets any previously normalized entity from store */
17
+ getEntity: GetEntity;
18
+ /** Updates an entity using merge lifecycles when it has previously been set */
19
+ mergeEntity(
20
+ schema: Mergeable & { indexes?: any },
21
+ pk: string,
22
+ incomingEntity: any,
23
+ ): void;
24
+ /** Sets an entity overwriting any previously set values */
25
+ setEntity(
26
+ schema: { key: string; indexes?: any },
27
+ pk: string,
28
+ entity: any,
29
+ meta?: { fetchedAt: number; date: number; expiresAt: number },
30
+ ): void;
31
+ /** Returns true when we're in a cycle, so we should not continue recursing */
32
+ checkLoop(key: string, pk: string, input: object): boolean;
33
+ }
34
+ ```
35
+
36
+ #### Before
37
+
38
+ ```ts
39
+ addEntity(this, processedEntity, id);
40
+ ```
41
+
42
+ #### After
43
+
44
+ ```ts
45
+ delegate.mergeEntity(this, id, processedEntity);
46
+ ```
47
+
48
+ - [#3451](https://github.com/reactive/data-client/pull/3451) [`4939456`](https://github.com/reactive/data-client/commit/4939456598c213ee81c1abef476a1aaccd19f82d) Thanks [@ntucker](https://github.com/ntucker)! - state.entityMeta -> state.entitiesMeta
49
+
50
+ - [#3394](https://github.com/reactive/data-client/pull/3394) [`d44d36a`](https://github.com/reactive/data-client/commit/d44d36a7de0a18817486c4f723bf2f0e86ac9677) Thanks [@ntucker](https://github.com/ntucker)! - Change NetworkManager bookkeeping data structure for inflight fetches
51
+
52
+ BREAKING CHANGE: NetworkManager.fetched, NetworkManager.rejectors, NetworkManager.resolvers, NetworkManager.fetchedAt
53
+ -> NetworkManager.fetching
54
+
55
+ #### Before
56
+
57
+ ```ts
58
+ if (action.key in this.fetched)
59
+ ```
60
+
61
+ #### After
62
+
63
+ ```ts
64
+ if (this.fetching.has(action.key))
65
+ ```
66
+
67
+ - [#3449](https://github.com/reactive/data-client/pull/3449) [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: schema.queryKey(args, queryKey, getEntity, getIndex) -> schema.queryKey(args, unvisit, delegate)
68
+ BREAKING CHANGE: delegate.getIndex() returns the index directly, rather than object.
69
+
70
+ We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument.
71
+
72
+ Our recursive call is renamed from queryKey to unvisit, and does not require the last two arguments.
73
+
74
+ ```ts
75
+ /** Accessors to the currently processing state while building query */
76
+ export interface IQueryDelegate {
77
+ getEntity: GetEntity;
78
+ getIndex: GetIndex;
79
+ }
80
+ ```
81
+
82
+ #### Before
83
+
84
+ ```ts
85
+ queryKey(args, queryKey, getEntity, getIndex) {
86
+ getIndex(schema.key, indexName, value)[value];
87
+ getEntity(this.key, id);
88
+ return queryKey(this.schema, args, getEntity, getIndex);
89
+ }
90
+ ```
91
+
92
+ #### After
93
+
94
+ ```ts
95
+ queryKey(args, unvisit, delegate) {
96
+ delegate.getIndex(schema.key, indexName, value);
97
+ delegate.getEntity(this.key, id);
98
+ return unvisit(this.schema, args);
99
+ }
100
+ ```
101
+
102
+ ### Patch Changes
103
+
104
+ - [`a4092a1`](https://github.com/reactive/data-client/commit/a4092a14999bfe3aa5cf613bb009264ec723ff99) Thanks [@ntucker](https://github.com/ntucker)! - Add mockInitialState to /mock
105
+
106
+ ```ts
107
+ import { mockInitialState } from '@data-client/react/mock';
108
+ import { ArticleResource } from './resources';
109
+
110
+ const state = mockInitialState([
111
+ {
112
+ endpoint: ArticleResource.get,
113
+ args: [{ id: 5 }],
114
+ response: { id: 5, title: 'Hello', content: 'World' },
115
+ },
116
+ ]);
117
+ ```
118
+
119
+ - [#3622](https://github.com/reactive/data-client/pull/3622) [`ad3964d`](https://github.com/reactive/data-client/commit/ad3964d65d245c459809f64afe17ebdf5fda5042) Thanks [@ntucker](https://github.com/ntucker)! - Add @data-client/core/mock
120
+
121
+ New exports:
122
+ - `MockController` - Controller wrapper for mocking endpoints
123
+ - `collapseFixture` - Resolves fixture responses (handles function responses)
124
+ - `createFixtureMap` - Separates fixtures into static map and interceptors
125
+ - Types: `MockProps`, `Fixture`, `SuccessFixture`, `ErrorFixture`, `Interceptor`, `ResponseInterceptor`, `FetchInterceptor`, `FixtureEndpoint`, `SuccessFixtureEndpoint`, `ErrorFixtureEndpoint`
126
+
127
+ - [#3449](https://github.com/reactive/data-client/pull/3449) [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7) Thanks [@ntucker](https://github.com/ntucker)! - Fix controller.get and controller.getQueryMeta 'state' argument types
128
+
129
+ - [#3558](https://github.com/reactive/data-client/pull/3558) [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f) Thanks [@ntucker](https://github.com/ntucker)! - Normalize delegate.invalidate() first argument only has `key` param.
130
+
131
+ `indexes` optional param no longer provided as it was never used.
132
+
133
+ ```ts
134
+ normalize(
135
+ input: any,
136
+ parent: any,
137
+ key: string | undefined,
138
+ args: any[],
139
+ visit: (...args: any) => any,
140
+ delegate: INormalizeDelegate,
141
+ ): string {
142
+ delegate.invalidate({ key: this._entity.key }, pk);
143
+ return pk;
144
+ }
145
+ ```
146
+
147
+ - [#3468](https://github.com/reactive/data-client/pull/3468) [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895) Thanks [@ntucker](https://github.com/ntucker)! - Improve performance of get/denormalize for small responses
148
+ - 10-20% performance improvement due to removing immutablejs check for every call
149
+
150
+ - Updated dependencies [[`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`246cde6`](https://github.com/reactive/data-client/commit/246cde6dbeca59eafd10e59d8cd05a6f232fb219), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`269b45e`](https://github.com/reactive/data-client/commit/269b45e835251cff847776078e51c0a593b62715), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`66e1906`](https://github.com/reactive/data-client/commit/66e19064d21225c70639f3b4799e54c259ce6905), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`4939456`](https://github.com/reactive/data-client/commit/4939456598c213ee81c1abef476a1aaccd19f82d), [`25b153a`](https://github.com/reactive/data-client/commit/25b153a9d80db1bcd17ab5558dfa13b333f112b8), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7)]:
151
+ - @data-client/normalizr@0.15.0
152
+
153
+ ## 0.14.24
154
+
155
+ ### Patch Changes
156
+
157
+ - [`d41f658`](https://github.com/reactive/data-client/commit/d41f6582478f9392bcbcbcc1213f7a2d9646e9c4) Thanks [@ntucker](https://github.com/ntucker)! - Improve performance by using Map() instead of Object for unbounded keys [#3390](https://github.com/reactive/data-client/pull/3390)
158
+
159
+ ## 0.14.23
160
+
161
+ ### Patch Changes
162
+
163
+ - [`9bf7e7a`](https://github.com/reactive/data-client/commit/9bf7e7ab783eda767dd9f17bbf65c4b85c05d522) Thanks [@ntucker](https://github.com/ntucker)! - Improve performance by using Map() instead of Object for unbounded keys [#3390](https://github.com/reactive/data-client/pull/3390)
164
+
165
+ ## 0.14.21
166
+
167
+ ### Patch Changes
168
+
169
+ - [#3384](https://github.com/reactive/data-client/pull/3384) [`24ad679`](https://github.com/reactive/data-client/commit/24ad679f58c7eb0d0e6917790b4ebb5ee234e1d3) Thanks [@ntucker](https://github.com/ntucker)! - Reduce bundle sizes by 30% by removing unneeded polyfills
170
+
171
+ - Updated dependencies [[`24ad679`](https://github.com/reactive/data-client/commit/24ad679f58c7eb0d0e6917790b4ebb5ee234e1d3)]:
172
+ - @data-client/normalizr@0.14.21
173
+
174
+ ## 0.14.20
175
+
176
+ ### Patch Changes
177
+
178
+ - [`c3514c6`](https://github.com/reactive/data-client/commit/c3514c6afa2cd76dafa02adcfad6f6481a34b5de) Thanks [@ntucker](https://github.com/ntucker)! - Remove unnecessary polyfills in build
179
+
180
+ - Updated dependencies [[`c3514c6`](https://github.com/reactive/data-client/commit/c3514c6afa2cd76dafa02adcfad6f6481a34b5de)]:
181
+ - @data-client/normalizr@0.14.20
182
+
183
+ ## 0.14.19
184
+
185
+ ### Patch Changes
186
+
187
+ - [#3343](https://github.com/reactive/data-client/pull/3343) [`1df829e`](https://github.com/reactive/data-client/commit/1df829e0a005f5973d59669aaf0a226250346a40) Thanks [@ntucker](https://github.com/ntucker)! - Add initManager()
188
+
189
+ - [#3373](https://github.com/reactive/data-client/pull/3373) [`f796b6c`](https://github.com/reactive/data-client/commit/f796b6cbd33cce1f258bd5e95a7d6b1d51365f2f) Thanks [@ntucker](https://github.com/ntucker)! - Add Controller.getQueryMeta and Controller.getResponseMeta
190
+
191
+ - [#3373](https://github.com/reactive/data-client/pull/3373) [`f796b6c`](https://github.com/reactive/data-client/commit/f796b6cbd33cce1f258bd5e95a7d6b1d51365f2f) Thanks [@ntucker](https://github.com/ntucker)! - Controller.snapshot() methods have stronger argument typing
192
+
193
+ - [#3365](https://github.com/reactive/data-client/pull/3365) [`66e7336`](https://github.com/reactive/data-client/commit/66e7336bab0f6768d93c76882188894d36f84f88) Thanks [@ntucker](https://github.com/ntucker)! - internal: Controller.bindMiddleware() to be used in applyMiddleware.
194
+
195
+ This API is not intended to be used elsewhere, but will become the standard interface between
196
+ Controller's and applyMiddleware.
197
+
198
+ - [#3343](https://github.com/reactive/data-client/pull/3343) [`1df829e`](https://github.com/reactive/data-client/commit/1df829e0a005f5973d59669aaf0a226250346a40) Thanks [@ntucker](https://github.com/ntucker)! - Add GCPolicy to control Garbage Collection of data in the store.
199
+
200
+ This can be configured with constructor options, or custom GCPolicies implemented by extending
201
+ or simply building your own. Use `ImmortalGCPolicy` to never GC (to maintain existing behavior).
202
+
203
+ ### constructor
204
+
205
+ #### intervalMS = 60 \* 1000 \* 5
206
+
207
+ How long between low priority GC sweeps.
208
+
209
+ Longer values may result in more memory usage, but less performance impact.
210
+
211
+ #### expiryMultiplier = 2
212
+
213
+ Used in the default `hasExpired` policy.
214
+
215
+ Represents how many 'stale' lifetimes data should persist before being
216
+ garbage collected.
217
+
218
+ #### expiresAt
219
+
220
+ ```typescript
221
+ expiresAt({
222
+ fetchedAt,
223
+ expiresAt,
224
+ }: {
225
+ expiresAt: number;
226
+ date: number;
227
+ fetchedAt: number;
228
+ }): number {
229
+ return (
230
+ Math.max(
231
+ (expiresAt - fetchedAt) * this.options.expiryMultiplier,
232
+ 120000,
233
+ ) + fetchedAt
234
+ );
235
+ }
236
+ ```
237
+
238
+ Indicates at what timestamp it is acceptable to remove unused data from the store.
239
+
240
+ Data not currently rendered in any components is considered unused. However, unused
241
+ data may be used again in the future (as a cache).
242
+
243
+ This results in a tradeoff between memory usage and cache hit rate (and thus performance).
244
+
245
+ - [#3371](https://github.com/reactive/data-client/pull/3371) [`679d76a`](https://github.com/reactive/data-client/commit/679d76a36234dcf5993c0358f94d7e1db0505cc6) Thanks [@ntucker](https://github.com/ntucker)! - Add react-native entry to package.json exports
246
+
247
+ - [#3353](https://github.com/reactive/data-client/pull/3353) [`165afed`](https://github.com/reactive/data-client/commit/165afed083c0c63e9356bc8d1ee30dee8b916ed6) Thanks [@renovate](https://github.com/apps/renovate)! - Polyfills no longer pollute global scope
248
+
249
+ - Updated dependencies [[`679d76a`](https://github.com/reactive/data-client/commit/679d76a36234dcf5993c0358f94d7e1db0505cc6), [`165afed`](https://github.com/reactive/data-client/commit/165afed083c0c63e9356bc8d1ee30dee8b916ed6)]:
250
+ - @data-client/normalizr@0.14.19
251
+
252
+ ## 0.14.18
253
+
254
+ ### Patch Changes
255
+
256
+ - [`3906fc2`](https://github.com/reactive/data-client/commit/3906fc2fec2b958a44d718934919b524e851f298) Thanks [@ntucker](https://github.com/ntucker)! - SUBSCRIBE action field ordering consistent with other actions
257
+
258
+ ## 0.14.16
259
+
260
+ ### Patch Changes
261
+
262
+ - [#3244](https://github.com/reactive/data-client/pull/3244) [`109c922`](https://github.com/reactive/data-client/commit/109c922919ef401dee3c3c34d705819271f9e140) Thanks [@ntucker](https://github.com/ntucker)! - Add [actionTypes](https://dataclient.io/docs/api/Actions) without \_TYPE suffix
263
+
264
+ (Not breaking - we keep the old actionTypes name as well.)
265
+
266
+ ```ts title="Before"
267
+ import type { Manager, Middleware } from '@data-client/react';
268
+ import { actionTypes } from '@data-client/react';
269
+
270
+ export default class LoggingManager implements Manager {
271
+ middleware: Middleware = controller => next => async action => {
272
+ switch (action.type) {
273
+ case actionTypes.SET_RESPONSE_TYPE:
274
+ console.info(
275
+ `${action.endpoint.name} ${JSON.stringify(action.response)}`,
276
+ );
277
+ default:
278
+ return next(action);
279
+ }
280
+ };
281
+
282
+ cleanup() {}
283
+ }
284
+ ```
285
+
286
+ ```ts title="After"
287
+ import type { Manager, Middleware } from '@data-client/react';
288
+ import { actionTypes } from '@data-client/react';
289
+
290
+ export default class LoggingManager implements Manager {
291
+ middleware: Middleware = controller => next => async action => {
292
+ switch (action.type) {
293
+ case actionTypes.SET_RESPONSE:
294
+ console.info(
295
+ `${action.endpoint.name} ${JSON.stringify(action.response)}`,
296
+ );
297
+ default:
298
+ return next(action);
299
+ }
300
+ };
301
+
302
+ cleanup() {}
303
+ }
304
+ ```
305
+
306
+ - Updated dependencies [[`43a955c`](https://github.com/reactive/data-client/commit/43a955c18684b4e0f5c1d79b2504e8ad2910816b)]:
307
+ - @data-client/normalizr@0.14.16
308
+
309
+ ## 0.14.13
310
+
311
+ ### Patch Changes
312
+
313
+ - [`191716f`](https://github.com/reactive/data-client/commit/191716fa120c24bf63b8c960b7d5ee505f5f0fdb) Thanks [@ntucker](https://github.com/ntucker)! - README: Update logo
314
+
315
+ ## 0.14.10
316
+
317
+ ### Patch Changes
318
+
319
+ - [#3188](https://github.com/reactive/data-client/pull/3188) [`cde7121`](https://github.com/reactive/data-client/commit/cde71212706a46bbfd13dd76e8cfc478b22fe2ab) Thanks [@ntucker](https://github.com/ntucker)! - Update README to remove Entity.pk() when it is default ('id')
320
+
321
+ - Updated dependencies [[`cde7121`](https://github.com/reactive/data-client/commit/cde71212706a46bbfd13dd76e8cfc478b22fe2ab)]:
322
+ - @data-client/normalizr@0.14.10
323
+
324
+ ## 0.14.8
325
+
326
+ ### Patch Changes
327
+
328
+ - [`bad1fb9`](https://github.com/reactive/data-client/commit/bad1fb909f8d60f19450bbf40df00d90e03a61c2) Thanks [@ntucker](https://github.com/ntucker)! - Update package description
329
+
330
+ ## 0.14.6
331
+
332
+ ### Patch Changes
333
+
334
+ - [#3165](https://github.com/reactive/data-client/pull/3165) [`3fa9eb9`](https://github.com/reactive/data-client/commit/3fa9eb907d8760171da065168796b87e802d6666) Thanks [@ntucker](https://github.com/ntucker)! - [Query](https://dataclient.io/rest/api/Query) can take [Object Schemas](https://dataclient.io/rest/api/Object)
335
+
336
+ This enables joining arbitrary objects (whose pk works with the same arguments.)
337
+
338
+ ```ts
339
+ class Ticker extends Entity {
340
+ product_id = '';
341
+ price = 0;
342
+
343
+ pk(): string {
344
+ return this.product_id;
345
+ }
346
+ }
347
+ class Stats extends Entity {
348
+ product_id = '';
349
+ last = 0;
350
+
351
+ pk(): string {
352
+ return this.product_id;
353
+ }
354
+ }
355
+ const queryPrice = new schema.Query(
356
+ { ticker: Ticker, stats: Stats },
357
+ ({ ticker, stats }) => ticker?.price ?? stats?.last,
358
+ );
359
+ ```
360
+
361
+ - Updated dependencies [[`3fa9eb9`](https://github.com/reactive/data-client/commit/3fa9eb907d8760171da065168796b87e802d6666)]:
362
+ - @data-client/normalizr@0.14.6
363
+
364
+ ## 0.14.5
365
+
366
+ ### Patch Changes
367
+
368
+ - [#3164](https://github.com/reactive/data-client/pull/3164) [`ffea6fc`](https://github.com/reactive/data-client/commit/ffea6fcfe142e966d1b9527bf2505a5695b98300) Thanks [@ntucker](https://github.com/ntucker)! - Manager.getMiddleware() -> Manager.middleware
369
+
370
+ `getMiddleware()` is still supported to make this change non-breaking
371
+
372
+ - [`82fbb85`](https://github.com/reactive/data-client/commit/82fbb8595d3bec835b3cd4a41f154b7935ccaee2) Thanks [@ntucker](https://github.com/ntucker)! - Middleware types include union of possible actions
373
+
374
+ - [`262587c`](https://github.com/reactive/data-client/commit/262587c0c3e4bc8b779b1ff22ac84d4bddddf5bc) Thanks [@ntucker](https://github.com/ntucker)! - Add SchemaClass type export
375
+
376
+ ## 0.14.4
377
+
378
+ ### Patch Changes
379
+
380
+ - [#3161](https://github.com/reactive/data-client/pull/3161) [`b932dca`](https://github.com/reactive/data-client/commit/b932dca45a4fcf60c00db8da509162f253065769) Thanks [@ntucker](https://github.com/ntucker)! - Add jsdocs to IdlingNetworkManager
381
+
382
+ - [`e4751d9`](https://github.com/reactive/data-client/commit/e4751d9cd0ee26567d7632ea4707ca181901ff89) Thanks [@ntucker](https://github.com/ntucker)! - NetworkManager constructor uses keyword args
383
+
384
+ #### Before
385
+
386
+ ```ts
387
+ new NetworkManager(42, 7);
388
+ ```
389
+
390
+ #### After
391
+
392
+ ```ts
393
+ new NetworkManager({ dataExpiryLength: 42, errorExpiryLength: 7 });
394
+ ```
395
+
396
+ - [`09ad848`](https://github.com/reactive/data-client/commit/09ad848879db55bb441d93336dd7442d3f484d49) Thanks [@ntucker](https://github.com/ntucker)! - state.endpoints moved above indexes
397
+
398
+ `entites` and `endpoints` are the most commonly inspected
399
+ parts of state when debugging, so it is better to have endpoints
400
+ above indexes.
401
+
402
+ ## 0.14.2
403
+
404
+ ### Patch Changes
405
+
406
+ - [`597a1b2`](https://github.com/reactive/data-client/commit/597a1b228c81940bdbaf15900ab1e624be3f520e) Thanks [@ntucker](https://github.com/ntucker)! - Disable devtools dispatch feature as it is not usable
407
+
408
+ - [`d8666bf`](https://github.com/reactive/data-client/commit/d8666bf9e059a24b35c8f22b7525ce55c23c84f3) Thanks [@ntucker](https://github.com/ntucker)! - Minor store creation optimizations
409
+
410
+ - [`597a1b2`](https://github.com/reactive/data-client/commit/597a1b228c81940bdbaf15900ab1e624be3f520e) Thanks [@ntucker](https://github.com/ntucker)! - fix: Devtools correctly logs fetch actions
411
+
412
+ We inspect fetches against inflight to see if they are throttled;
413
+ However, we previously did this after we sent the action to NetworkManager, which
414
+ meant it would also skip logging any throttlable fetches - even if they were not throttled.
415
+
416
+ - [`d84b43c`](https://github.com/reactive/data-client/commit/d84b43cf728d714da7182f2c19b39f49e0ec0366) Thanks [@ntucker](https://github.com/ntucker)! - Move NetworkManager missing detection to initialization (applyManager())
417
+
418
+ - [`06df291`](https://github.com/reactive/data-client/commit/06df291a1f1d91afa331310dfb8319bc8d1a3ba8) Thanks [@ntucker](https://github.com/ntucker)! - Reorder action members for easier debuggability
419
+ - `key` at top - easiest to read 'subject'
420
+ - `response` or `value` after - 'object' being set
421
+
422
+ - [`597a1b2`](https://github.com/reactive/data-client/commit/597a1b228c81940bdbaf15900ab1e624be3f520e) Thanks [@ntucker](https://github.com/ntucker)! - Improve typing for devtools options
423
+
424
+ ## 0.14.1
425
+
426
+ ### Patch Changes
427
+
428
+ - [`7427519`](https://github.com/reactive/data-client/commit/742751933f799c77b12cec7f8a7e4582db4cd779) Thanks [@ntucker](https://github.com/ntucker)! - Update README
429
+
430
+ - Updated dependencies [[`428d618`](https://github.com/reactive/data-client/commit/428d618ce057d4eef23592a64ec9d1c6fb82f43f)]:
431
+ - @data-client/normalizr@0.14.1
432
+
433
+ ## 0.14.0
434
+
435
+ ### Minor Changes
436
+
437
+ - [#3141](https://github.com/reactive/data-client/pull/3141) [`d225595`](https://github.com/reactive/data-client/commit/d2255959489b71cfdfcaf4be72fd272231d392f1) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: setResponseAction.payload -> setResponseAction.response
438
+
439
+ This only affects those writing custom [Managers](https://dataclient.io/docs/concepts/managers) that
440
+ handle [SET_RESPONSE](/docs/api/Actions#set_response).
441
+
442
+ #### Before
443
+
444
+ ```ts
445
+ import {
446
+ SET_RESPONSE_TYPE,
447
+ type Manager,
448
+ type Middleware,
449
+ } from '@data-client/react';
450
+
451
+ export default class MyManager implements Manager {
452
+ getMiddleware = (): Middleware => controller => next => async action => {
453
+ switch (action.type) {
454
+ case SET_RESPONSE_TYPE:
455
+ console.log('Resolved with value', action.payload);
456
+ return next(action);
457
+ default:
458
+ return next(action);
459
+ }
460
+ };
461
+
462
+ cleanup() {}
463
+ }
464
+ ```
465
+
466
+ #### After
467
+
468
+ ```ts
469
+ import {
470
+ SET_RESPONSE_TYPE,
471
+ type Manager,
472
+ type Middleware,
473
+ } from '@data-client/react';
474
+
475
+ export default class MyManager implements Manager {
476
+ getMiddleware = (): Middleware => controller => next => async action => {
477
+ switch (action.type) {
478
+ case SET_RESPONSE_TYPE:
479
+ console.log('Resolved with value', action.response);
480
+ return next(action);
481
+ default:
482
+ return next(action);
483
+ }
484
+ };
485
+
486
+ cleanup() {}
487
+ }
488
+ ```
489
+
490
+ - [`96f7eb0`](https://github.com/reactive/data-client/commit/96f7eb0c97db75bd0ec663d0fb0db8cf3ee808d5) Thanks [@ntucker](https://github.com/ntucker)! - Renamed FETCH action.meta.createdAt to fetchedAt to be consistent with other actions like
491
+ SET_RESPONSE.
492
+
493
+ BREAKING CHANGE: fetchAction.meta.createdAt -> fetchAction.meta.fetchedAt
494
+
495
+ - [#3138](https://github.com/reactive/data-client/pull/3138) [`ee509fb`](https://github.com/reactive/data-client/commit/ee509fb9c7681f060521f358f76b55ca0cb600ec) Thanks [@ntucker](https://github.com/ntucker)! - Remove throttle from FETCH_TYPE action
496
+
497
+ BREAKING CHANGE: action.meta.throttle -> !action.endpoint.sideEffect
498
+
499
+ - [#3143](https://github.com/reactive/data-client/pull/3143) [`f4cf8a4`](https://github.com/reactive/data-client/commit/f4cf8a4df3dfe852d98058abd06178f751ae8716) Thanks [@ntucker](https://github.com/ntucker)! - action.meta.args -> action.args
500
+
501
+ - [#3143](https://github.com/reactive/data-client/pull/3143) [`f4cf8a4`](https://github.com/reactive/data-client/commit/f4cf8a4df3dfe852d98058abd06178f751ae8716) Thanks [@ntucker](https://github.com/ntucker)! - Add `actions` export
502
+
503
+ `actions` is a namespace for all action creators. It is typically
504
+ preferred to use [Controller's](https://dataclient.io/docs/api/Controller) type-safe dispatch methods, as
505
+ members of this namespace could have breaking changes in a minor release.
506
+
507
+ ```ts
508
+ import { actions, type Manager, type Middleware } from '@data-client/core';
509
+
510
+ export default class MyManager implements Manager {
511
+ getMiddleware = (): Middleware => controller => next => {
512
+ const todo = { id: '5', title: 'my first todo' };
513
+
514
+ // These do the same thing
515
+ controller.dispatch(
516
+ actions.createSet(Todo, { args: [{ id: todo.id }], value: todo }),
517
+ );
518
+ // This is simpler; type-enforced; and will only change in major versions
519
+ controller.set(Todo, { id: todo.id }, todo);
520
+
521
+ return async action => next(action);
522
+ };
523
+
524
+ cleanup() {}
525
+ }
526
+ ```
527
+
528
+ BREAKING CHANGE: Removed `createFetch`, `createSet`, `createSetResponse` from export. Use action.createFetch instead.
529
+
530
+ - [#3141](https://github.com/reactive/data-client/pull/3141) [`d225595`](https://github.com/reactive/data-client/commit/d2255959489b71cfdfcaf4be72fd272231d392f1) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: remove fetchAction.payload
531
+
532
+ This only affects those writing custom [Managers](https://dataclient.io/docs/concepts/managers) that
533
+ handle [FETCH](/docs/api/Actions#fetch).
534
+
535
+ #### Before
536
+
537
+ ```ts
538
+ import {
539
+ FETCH_TYPE,
540
+ type Manager,
541
+ type Middleware,
542
+ } from '@data-client/react';
543
+
544
+ export default class MyManager implements Manager {
545
+ getMiddleware = (): Middleware => controller => next => async action => {
546
+ switch (action.type) {
547
+ case FETCH_TYPE:
548
+ // consume fetch, and print the resolution
549
+ action.payload().then(response => console.log(response));
550
+ default:
551
+ return next(action);
552
+ }
553
+ };
554
+
555
+ cleanup() {}
556
+ }
557
+ ```
558
+
559
+ #### After
560
+
561
+ ```ts
562
+ import {
563
+ FETCH_TYPE,
564
+ type Manager,
565
+ type Middleware,
566
+ } from '@data-client/react';
567
+
568
+ export default class MyManager implements Manager {
569
+ getMiddleware = (): Middleware => controller => next => async action => {
570
+ switch (action.type) {
571
+ case FETCH_TYPE:
572
+ // consume fetch, and print the resolution
573
+ action
574
+ .endpoint(...action.meta.args)
575
+ .then(response => console.log(response));
576
+ default:
577
+ return next(action);
578
+ }
579
+ };
580
+
581
+ cleanup() {}
582
+ }
583
+ ```
584
+
585
+ - [#3143](https://github.com/reactive/data-client/pull/3143) [`f4cf8a4`](https://github.com/reactive/data-client/commit/f4cf8a4df3dfe852d98058abd06178f751ae8716) Thanks [@ntucker](https://github.com/ntucker)! - action.meta.key -> action.key
586
+
587
+ - [#3139](https://github.com/reactive/data-client/pull/3139) [`9df0f7c`](https://github.com/reactive/data-client/commit/9df0f7c670c919d956312d2535c298d2553f5840) Thanks [@ntucker](https://github.com/ntucker)! - Get rid of fetch action.meta.nm. This is not used anywhere.
588
+
589
+ ### Patch Changes
590
+
591
+ - [`3ffa454`](https://github.com/reactive/data-client/commit/3ffa454def38b35a23520444f80b307732a8a89b) Thanks [@ntucker](https://github.com/ntucker)! - internal: Simplify fetchReducer code
592
+
593
+ - [#3134](https://github.com/reactive/data-client/pull/3134) [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36) Thanks [@ntucker](https://github.com/ntucker)! - Change Schema.normalize `visit()` interface; removing non-contextual arguments.
594
+
595
+ ```ts
596
+ /** Visits next data + schema while recurisvely normalizing */
597
+ export interface Visit {
598
+ (schema: any, value: any, parent: any, key: any, args: readonly any[]): any;
599
+ creating?: boolean;
600
+ }
601
+ ```
602
+
603
+ This results in a 10% normalize performance boost.
604
+
605
+ ```ts title="Before"
606
+ processedEntity[key] = visit(
607
+ processedEntity[key],
608
+ processedEntity,
609
+ key,
610
+ this.schema[key],
611
+ addEntity,
612
+ visitedEntities,
613
+ storeEntities,
614
+ args,
615
+ );
616
+ ```
617
+
618
+ ```ts title="After"
619
+ processedEntity[key] = visit(
620
+ this.schema[key],
621
+ processedEntity[key],
622
+ processedEntity,
623
+ key,
624
+ args,
625
+ );
626
+ ```
627
+
628
+ The information needed from these arguments are provided by [closing](<https://en.wikipedia.org/wiki/Closure_(computer_programming)>) `visit()` around them.
629
+
630
+ - [#3134](https://github.com/reactive/data-client/pull/3134) [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36) Thanks [@ntucker](https://github.com/ntucker)! - Change Schema.normalize interface from direct data access, to using functions like `getEntity`
631
+
632
+ ```ts
633
+ interface SchemaSimple {
634
+ normalize(
635
+ input: any,
636
+ parent: any,
637
+ key: any,
638
+ args: any[],
639
+ visit: (
640
+ schema: any,
641
+ value: any,
642
+ parent: any,
643
+ key: any,
644
+ args: readonly any[],
645
+ ) => any,
646
+ addEntity: (...args: any) => any,
647
+ getEntity: (...args: any) => any,
648
+ checkLoop: (...args: any) => any,
649
+ ): any;
650
+ }
651
+ ```
652
+
653
+ We also add `checkLoop()`, which moves some logic in [Entity](https://dataclient.io/rest/api/Entity)
654
+ to the core normalize algorithm.
655
+
656
+ ```ts
657
+ /** Returns true if a circular reference is found */
658
+ export interface CheckLoop {
659
+ (entityKey: string, pk: string, input: object): boolean;
660
+ }
661
+ ```
662
+
663
+ - [#3134](https://github.com/reactive/data-client/pull/3134) [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36) Thanks [@ntucker](https://github.com/ntucker)! - Change Schema.denormalize `unvisit` to have [schema](https://dataclient.io/rest/api/schema) argument first.
664
+
665
+ ```ts
666
+ interface SchemaSimple {
667
+ denormalize(
668
+ input: {},
669
+ args: readonly any[],
670
+ unvisit: (schema: any, input: any) => any,
671
+ ): T;
672
+ }
673
+ ```
674
+
675
+ - Updated dependencies [[`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36), [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36), [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36), [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36), [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36), [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36)]:
676
+ - @data-client/normalizr@0.14.0
677
+
678
+ ## 0.13.5
679
+
680
+ ### Patch Changes
681
+
682
+ - [#3129](https://github.com/reactive/data-client/pull/3129) [`2503402`](https://github.com/reactive/data-client/commit/2503402c28a51b2a686bf61132b74d673950e63e) Thanks [@ntucker](https://github.com/ntucker)! - Allow ctrl.set() value to be a function
683
+
684
+ This [prevents race conditions](https://react.dev/reference/react/useState#updating-state-based-on-the-previous-state).
685
+
686
+ ```ts
687
+ const id = '2';
688
+ ctrl.set(Article, { id }, article => ({ id, votes: article.votes + 1 }));
689
+ ```
690
+
691
+ Note: the response must include values sufficient to compute Entity.pk()
692
+
693
+ - [#3127](https://github.com/reactive/data-client/pull/3127) [`c18fbf7`](https://github.com/reactive/data-client/commit/c18fbf7fdc7c421d15dc26cc5add3b5840ddca6d) Thanks [@ntucker](https://github.com/ntucker)! - Remove RIC export
694
+
695
+ - [#3127](https://github.com/reactive/data-client/pull/3127) [`c18fbf7`](https://github.com/reactive/data-client/commit/c18fbf7fdc7c421d15dc26cc5add3b5840ddca6d) Thanks [@ntucker](https://github.com/ntucker)! - Add NetworkManager.idleCallback overridable method
696
+
697
+ This allows platform specific implementations by overriding the method.
698
+ For instance, on web:
699
+
700
+ ```ts
701
+ import { NetworkManager } from '@data-client/core';
702
+
703
+ export default class WebNetworkManager extends NetworkManager {
704
+ static {
705
+ if (typeof requestIdleCallback === 'function') {
706
+ WebNetworkManager.prototype.idleCallback = requestIdleCallback;
707
+ }
708
+ }
709
+ }
710
+ ```
711
+
712
+ ## 0.13.1
713
+
714
+ ### Patch Changes
715
+
716
+ - [`327d666`](https://github.com/reactive/data-client/commit/327d6668958e45119eb075f6af4de7239fc1dda6) Thanks [@ntucker](https://github.com/ntucker)! - Add ctrl.set() to README
717
+
718
+ ## 0.13.0
719
+
720
+ ### Minor Changes
721
+
722
+ - [#3105](https://github.com/reactive/data-client/pull/3105) [`cf770de`](https://github.com/reactive/data-client/commit/cf770de244ad890b286c59ac305ceb6c3b1288ea) Thanks [@ntucker](https://github.com/ntucker)! - Add controller.set()
723
+
724
+ ```ts
725
+ ctrl.set(
726
+ Todo,
727
+ { id: '5' },
728
+ { id: '5', title: 'tell me friends how great Data Client is' },
729
+ );
730
+ ```
731
+
732
+ BREAKING CHANGE:
733
+ - actionTypes.SET_TYPE -> actionTypes.SET_RESPONSE_TYPE
734
+ - SetAction -> SetResponseAction
735
+
736
+ ## 0.12.5
737
+
738
+ ### Patch Changes
739
+
740
+ - [`e4d5f01`](https://github.com/reactive/data-client/commit/e4d5f019f7c3817fb740094244e8ce17ccd5452d) Thanks [@ntucker](https://github.com/ntucker)! - [DevToolsManager](https://dataclient.io/docs/api/DevToolsManager) uses [maxAge](https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/API/Arguments.md#maxage) to set buffer size
741
+
742
+ - [`c3481ad`](https://github.com/reactive/data-client/commit/c3481ad578c77a6dc73f45f1afcec353ba032534) Thanks [@ntucker](https://github.com/ntucker)! - Fix DevToolsManager() config parameter correctly sets devtools config
743
+
744
+ ## 0.12.3
745
+
746
+ ### Patch Changes
747
+
748
+ - [`00d4205`](https://github.com/reactive/data-client/commit/00d4205f03562cfe4acd18215718e23ae5466b8d) Thanks [@ntucker](https://github.com/ntucker)! - Add funding package.json field
749
+
750
+ - [`8a8634c`](https://github.com/reactive/data-client/commit/8a8634c7a263cf99e9ce426b2c9b92fd2a12a259) Thanks [@ntucker](https://github.com/ntucker)! - Reduce GC pressure by reusing AbortOptimistic instance
751
+
752
+ - Updated dependencies [[`00d4205`](https://github.com/reactive/data-client/commit/00d4205f03562cfe4acd18215718e23ae5466b8d)]:
753
+ - @data-client/normalizr@0.12.3
754
+
755
+ ## 0.12.1
756
+
757
+ ### Patch Changes
758
+
759
+ - [#3043](https://github.com/reactive/data-client/pull/3043) [`5b64cbf`](https://github.com/reactive/data-client/commit/5b64cbf3126c404b70853960a4bdedc268e3328c) Thanks [@ntucker](https://github.com/ntucker)! - Improve [controller](https://dataclient.io/docs/api/Controller) type matching for its methods
760
+
761
+ ## 0.11.5
762
+
763
+ ### Patch Changes
764
+
765
+ - [#3033](https://github.com/reactive/data-client/pull/3033) [`2152b41`](https://github.com/reactive/data-client/commit/2152b41afc56027175bd36e7ef89c433a2e5e025) Thanks [@ntucker](https://github.com/ntucker)! - Environments without RequestIdleCallback will call immediately
766
+
767
+ ## 0.11.4
768
+
769
+ ### Patch Changes
770
+
771
+ - [#3020](https://github.com/reactive/data-client/pull/3020) [`dcb6b2f`](https://github.com/reactive/data-client/commit/dcb6b2fd4a5015242f43edc155352da6789cdb5d) Thanks [@ntucker](https://github.com/ntucker)! - Add NI<> utility type that is back-compat NoInfer<>
772
+
773
+ - Updated dependencies [[`dcb6b2f`](https://github.com/reactive/data-client/commit/dcb6b2fd4a5015242f43edc155352da6789cdb5d)]:
774
+ - @data-client/normalizr@0.11.4
775
+
776
+ ## 0.11.0
777
+
778
+ [Release notes and migration guide](https://dataclient.io/blog/2024/04/08/v0.11-queries-querable-usequery)
779
+
780
+ ### Minor Changes
781
+
782
+ - [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: new AbortOptimistic() -> [snapshot.abort](https://dataclient/docs/api/Snapshot#abort)
783
+
784
+ #### Before
785
+
786
+ ```ts
787
+ getOptimisticResponse(snapshot, { id }) {
788
+ const { data } = snapshot.getResponse(Base.get, { id });
789
+ if (!data) throw new AbortOptimistic();
790
+ return {
791
+ id,
792
+ votes: data.votes + 1,
793
+ };
794
+ }
795
+ ```
796
+
797
+ #### After
798
+
799
+ ```ts
800
+ getOptimisticResponse(snapshot, { id }) {
801
+ const { data } = snapshot.getResponse(Base.get, { id });
802
+ if (!data) throw snapshot.abort;
803
+ return {
804
+ id,
805
+ votes: data.votes + 1,
806
+ };
807
+ }
808
+ ```
809
+
810
+ - [#2977](https://github.com/reactive/data-client/pull/2977) [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Schema.infer -> Schema.queryKey
811
+
812
+ ```ts title="Before"
813
+ class MyEntity extends Entity {
814
+ // highlight-next-line
815
+ static infer(
816
+ args: readonly any[],
817
+ indexes: NormalizedIndex,
818
+ recurse: any,
819
+ entities: any,
820
+ ): any {
821
+ if (SILLYCONDITION) return undefined;
822
+ return super.infer(args, indexes, recurse, entities);
823
+ }
824
+ }
825
+ ```
826
+
827
+ ```ts title="After"
828
+ class MyEntity extends Entity {
829
+ // highlight-next-line
830
+ static queryKey(
831
+ args: readonly any[],
832
+ queryKey: (...args: any) => any,
833
+ getEntity: GetEntity,
834
+ getIndex: GetIndex,
835
+ ): any {
836
+ if (SILLYCONDITION) return undefined;
837
+ return super.queryKey(args, queryKey, getEntity, getIndex);
838
+ }
839
+ }
840
+ ```
841
+
842
+ - [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Add [controller.get](https://dataclient.io/docs/api/Controller#get) / [snapshot.get](https://dataclient.io/docs/api/Snapshot#get) to directly read [Querable Schemas](https://dataclient.io/docs/api/useQuery#queryable)
843
+
844
+ #### Before
845
+
846
+ ```tsx
847
+ export const PostResource = createResource({
848
+ path: '/posts/:id',
849
+ schema: Post,
850
+ }).extend(Base => ({
851
+ vote: new RestEndpoint({
852
+ path: '/posts/:id/vote',
853
+ method: 'POST',
854
+ body: undefined,
855
+ schema: Post,
856
+ getOptimisticResponse(snapshot, { id }) {
857
+ const { data } = snapshot.getResponse(Base.get, { id });
858
+ if (!data) throw new AbortOptimistic();
859
+ return {
860
+ id,
861
+ votes: data.votes + 1,
862
+ };
863
+ },
864
+ }),
865
+ }));
866
+ ```
867
+
868
+ #### After
869
+
870
+ ```tsx
871
+ export const PostResource = createResource({
872
+ path: '/posts/:id',
873
+ schema: Post,
874
+ }).extend('vote', {
875
+ path: '/posts/:id/vote',
876
+ method: 'POST',
877
+ body: undefined,
878
+ schema: Post,
879
+ getOptimisticResponse(snapshot, { id }) {
880
+ const post = snapshot.get(Post, { id });
881
+ if (!post) throw new AbortOptimistic();
882
+ return {
883
+ id,
884
+ votes: post.votes + 1,
885
+ };
886
+ },
887
+ });
888
+ ```
889
+
890
+ - [#2957](https://github.com/reactive/data-client/pull/2957) [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a) Thanks [@ntucker](https://github.com/ntucker)! - Add [snapshot.abort](https://dataclient.io/docs/api/Snapshot#abort)
891
+
892
+ ```ts
893
+ getOptimisticResponse(snapshot, { id }) {
894
+ const { data } = snapshot.getResponse(Base.get, { id });
895
+ if (!data) throw snapshot.abort;
896
+ return {
897
+ id,
898
+ votes: data.votes + 1,
899
+ };
900
+ }
901
+ ```
902
+
903
+ - [#2977](https://github.com/reactive/data-client/pull/2977) [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: inferResults() -> buildQueryKey()
904
+
905
+ - [#2971](https://github.com/reactive/data-client/pull/2971) [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Internal state.results -> state.endpoints
906
+
907
+ ### Patch Changes
908
+
909
+ - [`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4) Thanks [@ntucker](https://github.com/ntucker)! - Fix schema.All denormalize INVALID case should also work when class name mangling is performed in production builds
910
+ - `unvisit()` always returns `undefined` with `undefined` as input.
911
+ - `All` returns INVALID from `queryKey()` to invalidate what was previously a special case in `unvisit()` (when there is no table entry for the given entity)
912
+
913
+ - [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0) Thanks [@ntucker](https://github.com/ntucker)! - Update description in package.json
914
+
915
+ - [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Improve controller.getResponse() type matching
916
+
917
+ Uses function overloading to more precisely match argument
918
+ expectations for fetchable Endpoints vs only keyable Endpoints.
919
+
920
+ - [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Update README
921
+
922
+ - Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`10432b7`](https://github.com/reactive/data-client/commit/10432b7eeab8f1e31ed764d46b0775e36ea74041), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af)]:
923
+ - @data-client/normalizr@0.11.0
924
+
925
+ ## 0.10.0
926
+
927
+ ### Minor Changes
928
+
929
+ - [#2912](https://github.com/reactive/data-client/pull/2912) [`922be79`](https://github.com/reactive/data-client/commit/922be79169a3eeea8e336eee519c165431ead474) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: `null` inputs are no longer filtered from Array or Object
930
+ - `[]` and [schema.Array](https://dataclient.io/rest/api/Array) now behave in the same manner.
931
+ - `null` values are now consistently handled everywhere (being retained).
932
+ - These were already being retained in [nested Entities](https://dataclient.io/rest/guides/relational-data#nesting)
933
+ - `undefined` is still filtered out.
934
+
935
+ ### Patch Changes
936
+
937
+ - [`4e6a39e`](https://github.com/reactive/data-client/commit/4e6a39ea2bfdb1390051f12781e899488609e1a8) Thanks [@ntucker](https://github.com/ntucker)! - Limit DevToolsManager action buffer depth to 100
938
+
939
+ This will avoid memory leaks in long running applications, or ones with frequent updates.
940
+
941
+ - [`69834b5`](https://github.com/reactive/data-client/commit/69834b50c6d2b33f46d7c63cabdc0744abf160ae) Thanks [@ntucker](https://github.com/ntucker)! - Update README with API links
942
+
943
+ - Updated dependencies [[`67f4e0b`](https://github.com/reactive/data-client/commit/67f4e0b45068da32d20e250267cb1cd2cea51226), [`053e823`](https://github.com/reactive/data-client/commit/053e82377bd29f200cd7dfbc700da7a3ad7fa8d7), [`922be79`](https://github.com/reactive/data-client/commit/922be79169a3eeea8e336eee519c165431ead474)]:
944
+ - @data-client/normalizr@0.10.0
945
+
946
+ ## 0.9.7
947
+
948
+ ### Patch Changes
949
+
950
+ - [`6c6678bd9d`](https://github.com/reactive/data-client/commit/6c6678bd9d0051c3bf1996c064457ca6f2389c62) Thanks [@ntucker](https://github.com/ntucker)! - docs: README uses svg version of logo
951
+
952
+ ## 0.9.4
953
+
954
+ ### Patch Changes
955
+
956
+ - [`d1b51af7ac`](https://github.com/reactive/data-client/commit/d1b51af7ac4a8a7c0559f478cc9503be8e61514c) Thanks [@ntucker](https://github.com/ntucker)! - Fix unpkg bundles by ensuring dependencies are built in order
957
+
958
+ - Updated dependencies [[`d1b51af7ac`](https://github.com/reactive/data-client/commit/d1b51af7ac4a8a7c0559f478cc9503be8e61514c)]:
959
+ - @data-client/normalizr@0.9.4
960
+
961
+ ## 0.9.3
962
+
963
+ ### Patch Changes
964
+
965
+ - [#2818](https://github.com/reactive/data-client/pull/2818) [`fc0092883f`](https://github.com/reactive/data-client/commit/fc0092883f5af42a5d270250482b7f0ba9845e95) Thanks [@ntucker](https://github.com/ntucker)! - Fix unpkg bundles and update names
966
+ - Client packages namespace into RDC
967
+ - @data-client/react - RDC
968
+ - @data-client/core - RDC.Core
969
+ - @data-client/redux - RDC.Redux
970
+ - Definition packages namespace top level
971
+ - @data-client/rest - Rest
972
+ - @data-client/graphql - GraphQL
973
+ - @data-client/img - Img
974
+ - @data-client/endpoint - Endpoint
975
+ - Utility
976
+ - @data-client/normalizr - normalizr
977
+ - @data-client/use-enhanced-reducer - EnhancedReducer
978
+
979
+ - [`327b94bedc`](https://github.com/reactive/data-client/commit/327b94bedc280e25c1766b3a51cc20078bfa1739) Thanks [@ntucker](https://github.com/ntucker)! - docs: Add logo to readme
980
+
981
+ - Updated dependencies [[`fc0092883f`](https://github.com/reactive/data-client/commit/fc0092883f5af42a5d270250482b7f0ba9845e95)]:
982
+ - @data-client/normalizr@0.9.3
983
+
984
+ ## 0.9.2
985
+
986
+ ### Patch Changes
987
+
988
+ - [`c9ca31f3f4`](https://github.com/reactive/data-client/commit/c9ca31f3f4f2f6e3174c74172ebc194edbe56bb2) Thanks [@ntucker](https://github.com/ntucker)! - Better track state changes between each action
989
+
990
+ Since React 18 batches updates, the real state can
991
+ sometimes update from multiple actions, making it harder
992
+ to debug. When devtools are open, instead of getting
993
+ the real state - track a shadow state that accurately reflects
994
+ changes from each action.
995
+
996
+ - [`4ea0bc83f6`](https://github.com/reactive/data-client/commit/4ea0bc83f65f49cb2155f6aecdc5f8d1b168fd5e) Thanks [@ntucker](https://github.com/ntucker)! - Docs: Update repo links to reactive organization
997
+
998
+ - Updated dependencies [[`4ea0bc83f6`](https://github.com/reactive/data-client/commit/4ea0bc83f65f49cb2155f6aecdc5f8d1b168fd5e)]:
999
+ - @data-client/normalizr@0.9.2
1000
+
1001
+ ## 0.9.0
1002
+
1003
+ ### Patch Changes
1004
+
1005
+ - [`a7da00e82d`](https://github.com/reactive/data-client/commit/a7da00e82d5473f12881b85c9736a79e016ee526) Thanks [@ntucker](https://github.com/ntucker)! - Endpoint properties fully visible in devtool
1006
+
1007
+ - [`2d2e94126e`](https://github.com/reactive/data-client/commit/2d2e94126e5962511e250df5d813d056646de41b) Thanks [@ntucker](https://github.com/ntucker)! - DevTools no longer forgets history if not open on page load
1008
+
1009
+ - [#2803](https://github.com/reactive/data-client/pull/2803) [`386372ed4d`](https://github.com/reactive/data-client/commit/386372ed4d0b454687847ba2b8eed4369ef7cdf7) Thanks [@ntucker](https://github.com/ntucker)! - DevtoolsManager closing start queueing messages to improve efficiency
1010
+
1011
+ ## 0.8.1
1012
+
1013
+ ### Patch Changes
1014
+
1015
+ - [#2797](https://github.com/reactive/data-client/pull/2797) [`c6ee872c7d`](https://github.com/reactive/data-client/commit/c6ee872c7d4bb669fa7b08a5343b24419c797cee) Thanks [@ntucker](https://github.com/ntucker)! - Fix published dependency range
1016
+
1017
+ ## 0.8.0
1018
+
1019
+ ### Minor Changes
1020
+
1021
+ - [`837cf57883`](https://github.com/reactive/data-client/commit/837cf57883544c7640344a01f43bf6d9e3369083) Thanks [@ntucker](https://github.com/ntucker)! - Remove newActions export
1022
+
1023
+ (All members continue to be exported at top level)
1024
+
1025
+ - [`f65cf832f0`](https://github.com/reactive/data-client/commit/f65cf832f0cdc4d01cb2f389a2dc2b37f1e5cf04) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Remove all /next exports
1026
+
1027
+ - [#2786](https://github.com/reactive/data-client/pull/2786) [`c865415ce5`](https://github.com/reactive/data-client/commit/c865415ce598d2b882262f795c4a816b2aa0808a) Thanks [@ntucker](https://github.com/ntucker)! - [Middleware](https://dataclient.io/docs/api/Manager#getmiddleware) no longer gets `controller` prop.
1028
+
1029
+ The entire API is controller itself:
1030
+ `({controller}) => next => async action => {}` ->
1031
+ `(controller) => next => async action => {}`
1032
+
1033
+ ```ts
1034
+ class LoggingManager implements Manager {
1035
+ getMiddleware = (): Middleware => controller => next => async action => {
1036
+ console.log('before', action, controller.getState());
1037
+ await next(action);
1038
+ console.log('after', action, controller.getState());
1039
+ };
1040
+
1041
+ cleanup() {}
1042
+ }
1043
+ ```
1044
+
1045
+ Note this has been possible for some time this simply drops
1046
+ legacy compatibility.
1047
+
1048
+ - [#2784](https://github.com/reactive/data-client/pull/2784) [`c535f6c0ac`](https://github.com/reactive/data-client/commit/c535f6c0ac915b5242c1c7694308b7ee7aab16a1) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGES:
1049
+ - DELETE removed -> INVALIDATE
1050
+ - drop all support for legacy schemas
1051
+ - entity.expiresAt removed
1052
+ - Collections.infer does entity check
1053
+ - all Entity overrides for backcompat are removed - operates just like EntitySchema, except with extra validation
1054
+
1055
+ - [#2782](https://github.com/reactive/data-client/pull/2782) [`d3343d42b9`](https://github.com/reactive/data-client/commit/d3343d42b970d075eda201cb85d201313120807c) Thanks [@ntucker](https://github.com/ntucker)! - Remove all 'receive' action names (use 'set' instead)
1056
+
1057
+ BREAKING CHANGE:
1058
+ - remove ReceiveAction
1059
+ - ReceiveTypes -> SetTypes
1060
+ - remove Controller.receive Controller.receiveError
1061
+ - NetworkManager.handleReceive -> handleSet
1062
+
1063
+ - [#2781](https://github.com/reactive/data-client/pull/2781) [`5ff1d65eb5`](https://github.com/reactive/data-client/commit/5ff1d65eb526306f2a78635b659f29554625e853) Thanks [@ntucker](https://github.com/ntucker)! - Prefix action types with 'rdc'
1064
+
1065
+ BREAKING CHANGE: Action types have new names
1066
+
1067
+ ### Patch Changes
1068
+
1069
+ - [#2779](https://github.com/reactive/data-client/pull/2779) [`ff51e71f45`](https://github.com/reactive/data-client/commit/ff51e71f45857eb172f3fe05829e34c9abb68252) Thanks [@ntucker](https://github.com/ntucker)! - Update jsdocs references to dataclient.io
1070
+
1071
+ - Updated dependencies [[`ff51e71f45`](https://github.com/reactive/data-client/commit/ff51e71f45857eb172f3fe05829e34c9abb68252), [`c535f6c0ac`](https://github.com/reactive/data-client/commit/c535f6c0ac915b5242c1c7694308b7ee7aab16a1), [`79e286109b`](https://github.com/reactive/data-client/commit/79e286109b5566f8e7acfdf0f44201263072d1d1), [`35ccedceb5`](https://github.com/reactive/data-client/commit/35ccedceb53d91dd54dd996990c7c75719be2b85)]:
1072
+ - @data-client/normalizr@0.8.0
1073
+
1074
+ ## 0.4.3
1075
+
1076
+ ### Patch Changes
1077
+
1078
+ - f95dbc64d1: [Collections](https://dataclient.io/rest/api/Collection) can filter based on FormData arguments
1079
+
1080
+ ```ts
1081
+ ctrl.fetch(getPosts.push, { group: 'react' }, new FormData(e.currentTarget));
1082
+ ```
1083
+
1084
+ Say our FormData contained an `author` field. Now that newly created
1085
+ item will be properly added to the [collection list](https://dataclient.io/rest/api/Collection) for that author.
1086
+
1087
+ ```ts
1088
+ useSuspense(getPosts, {
1089
+ group: 'react',
1090
+ author: 'bob',
1091
+ });
1092
+ ```
1093
+
1094
+ In this case if `FormData.get('author') === 'bob'`, it will show
1095
+ up in that [useSuspense()](https://dataclient.io/docs/api/useSuspense) call.
1096
+
1097
+ See more in the [Collection nonFilterArgumentKeys example](https://dataclient.io/rest/api/Collection#nonfilterargumentkeys)
1098
+
1099
+ ## 0.4.2
1100
+
1101
+ ### Patch Changes
1102
+
1103
+ - b60a4a558e: Change internal organization of some types
1104
+
1105
+ ## 0.4.1
1106
+
1107
+ ### Patch Changes
1108
+
1109
+ - a097d25e7a: controller.fetchIfStale() resolves to data from store if it does not fetch
1110
+
1111
+ ## 0.4.0
1112
+
1113
+ ### Minor Changes
1114
+
1115
+ - 5cedd4485e: Add controller.fetchIfStale()
1116
+
1117
+ Fetches only if endpoint is considered '[stale](../concepts/expiry-policy.md#stale)'; otherwise returns undefined.
1118
+
1119
+ This can be useful when prefetching data, as it avoids overfetching fresh data.
1120
+
1121
+ An [example](https://stackblitz.com/github/reactive/data-client/tree/master/examples/github-app?file=src%2Frouting%2Froutes.tsx) with a fetch-as-you-render router:
1122
+
1123
+ ```ts
1124
+ {
1125
+ name: 'IssueList',
1126
+ component: lazyPage('IssuesPage'),
1127
+ title: 'issue list',
1128
+ resolveData: async (
1129
+ controller: Controller,
1130
+ { owner, repo }: { owner: string; repo: string },
1131
+ searchParams: URLSearchParams,
1132
+ ) => {
1133
+ const q = searchParams?.get('q') || 'is:issue is:open';
1134
+ await controller.fetchIfStale(IssueResource.search, {
1135
+ owner,
1136
+ repo,
1137
+ q,
1138
+ });
1139
+ },
1140
+ },
1141
+ ```
1142
+
1143
+ ## 0.3.0
1144
+
1145
+ ### Minor Changes
1146
+
1147
+ - 6fd842e464: Add controller.expireAll() that sets all responses to _STALE_
1148
+
1149
+ ```ts
1150
+ controller.expireAll(ArticleResource.getList);
1151
+ ```
1152
+
1153
+ This is like controller.invalidateAll(); but will continue showing
1154
+ stale data while it is refetched.
1155
+
1156
+ This is sometimes useful to trigger refresh of only data presently shown
1157
+ when there are many parameterizations in cache.
1158
+
1159
+ ## 0.2.1
1160
+
1161
+ ### Patch Changes
1162
+
1163
+ - 7b835f113a: Improve package tags
1164
+ - Updated dependencies [7b835f113a]
1165
+ - @data-client/normalizr@0.2.2
1166
+
1167
+ ## 0.2.0
1168
+
1169
+ ### Minor Changes
1170
+
1171
+ - bf141cb5a5: Removed deprecated Endpoint.optimisticUpdate -> use Endpoint.getOptimisticResponse
1172
+ - bf141cb5a5: legacyActions were removed. use action imports directly
1173
+ New action types match previously exported newActions and have different form
1174
+ This will likely require updating any custom Managers
1175
+ - bf141cb5a5: Deprecations:
1176
+ - controller.receive, controller.receiveError
1177
+ - RECEIVE_TYPE
1178
+ - MiddlewareAPI.controller (MiddlewareAPI is just controller itself)
1179
+ - ({controller}) => {} -> (controller) => {}
1180
+ - bf141cb5a5: NetworkManager interface changed to only support new actions
1181
+ SubscriptionManager/PollingSubscription interfaces simplified based on new actions
1182
+ - bf141cb5a5: reducer -> createReducer(new Controller())
1183
+ - 9788090c55: Controller.fetch() returns denormalized form when Endpoint has a Schema
1184
+ - bf141cb5a5: resetAction requires a date
1185
+ - bf141cb5a5: state.lastReset must be number
1186
+
1187
+ ### Patch Changes
1188
+
1189
+ - Updated dependencies [bf141cb5a5]
1190
+ - Updated dependencies [87475a0cae]
1191
+ - @data-client/normalizr@0.2.0