diff --git a/.changeset/big-impalas-tap.md b/.changeset/big-impalas-tap.md deleted file mode 100644 index 41e74d826def..000000000000 --- a/.changeset/big-impalas-tap.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -'@data-client/normalizr': patch ---- - -Add /imm exports path for handling ImmutableJS state - -#### MemoCache - -```ts -import { MemoCache } from '@data-client/normalizr'; -import { MemoPolicy } from '@data-client/normalizr/imm'; - -const memo = new MemoCache(MemoPolicy); - -// entities is an ImmutableJS Map -const value = MemoCache.denormalize(Todo, '1', entities); -``` - -#### denormalize - -non-memoized denormalize - -```ts -import { denormalize } from '@data-client/normalizr/imm'; - -// entities is an ImmutableJS Map -const value = denormalize(Todo, '1', entities); -``` \ No newline at end of file diff --git a/.changeset/brave-bats-itch.md b/.changeset/brave-bats-itch.md deleted file mode 100644 index e8dfbefe7cdd..000000000000 --- a/.changeset/brave-bats-itch.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'@data-client/normalizr': minor ---- - -BREAKING CHANGE: Denormalize always transforms immutablejs entities into the class - -Previously using ImmutableJS structures when calling denormalize() would maintain -nested schemas as immutablejs structures still. Now everything is converted to normal JS. -This is how the types have always been specified. diff --git a/.changeset/chilly-towns-run.md b/.changeset/chilly-towns-run.md deleted file mode 100644 index e224ba654164..000000000000 --- a/.changeset/chilly-towns-run.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -'@data-client/vue': minor ---- - -Never wrap renderDataCompose().result in ref. Just passthrough the return value directly. Always. - -### Before -```ts -const { result, cleanup } = await renderDataCompose(() => - useSuspense(CoolerArticleResource.get, { id: payload.id }), -); - -const articleRef = await result.value; -expect(articleRef.value.title).toBe(payload.title); -expect(articleRef.value.content).toBe(payload.content); -``` - -### After -```ts -const { result, cleanup } = await renderDataCompose(() => - useSuspense(CoolerArticleResource.get, { id: payload.id }), -); - -const articleRef = await result; -expect(articleRef.value.title).toBe(payload.title); -expect(articleRef.value.content).toBe(payload.content); -``` \ No newline at end of file diff --git a/.changeset/clever-geckos-smash.md b/.changeset/clever-geckos-smash.md deleted file mode 100644 index 21b07f92a9b0..000000000000 --- a/.changeset/clever-geckos-smash.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/vue': patch ---- - -Fixed race condition in useSuspense() where args change while initial suspense is not complete diff --git a/.changeset/cold-walls-like.md b/.changeset/cold-walls-like.md deleted file mode 100644 index 406600556ad3..000000000000 --- a/.changeset/cold-walls-like.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@data-client/core': patch -'@data-client/react': patch ---- - -Fix controller.get and controller.getQueryMeta 'state' argument types diff --git a/.changeset/cuddly-masks-yawn.md b/.changeset/cuddly-masks-yawn.md deleted file mode 100644 index 38d8c4042a05..000000000000 --- a/.changeset/cuddly-masks-yawn.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/vue': minor ---- - -@data-client/vue first release diff --git a/.changeset/dirty-regions-dance.md b/.changeset/dirty-regions-dance.md deleted file mode 100644 index 05b10bfb7902..000000000000 --- a/.changeset/dirty-regions-dance.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/vue': patch ---- - -Only run manager start/stop for app lifecycle - not every component mount diff --git a/.changeset/forty-masks-join.md b/.changeset/forty-masks-join.md deleted file mode 100644 index 8c0742b95ecb..000000000000 --- a/.changeset/forty-masks-join.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@data-client/endpoint': patch -'@data-client/graphql': patch -'@data-client/rest': patch ---- - -Fix: ensure string id in Entity set when process returns undefined (meaning INVALID) diff --git a/.changeset/giant-cycles-follow.md b/.changeset/giant-cycles-follow.md deleted file mode 100644 index 09a601f79875..000000000000 --- a/.changeset/giant-cycles-follow.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@data-client/vue': patch ---- - -renderDataClient -> renderDataCompose - -This keeps naming conventions closer to the React version \ No newline at end of file diff --git a/.changeset/grumpy-dogs-decide.md b/.changeset/grumpy-dogs-decide.md deleted file mode 100644 index 0aad634d55fd..000000000000 --- a/.changeset/grumpy-dogs-decide.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -'@data-client/react': minor ---- - -BREAKING CHANGE: useDebounce() returns [val, isPending] - -This was previously exported in `@data-client/react/next` to make migrations easy. This will -still be available there. - -#### Before - -```ts -import { useDebounce } from '@data-client/react'; -const debouncedQuery = useDebounce(query, 100); -``` - -#### After - -```ts -import { useDebounce } from '@data-client/react'; -const [debouncedQuery] = useDebounce(query, 100); -``` - -#### Before - -```ts -import { useDebounce } from '@data-client/react/next'; -const [debouncedQuery, isPending] = useDebounce(query, 100); -``` - -#### After - -```ts -import { useDebounce } from '@data-client/react'; -const [debouncedQuery, isPending] = useDebounce(query, 100); -``` \ No newline at end of file diff --git a/.changeset/icy-hairs-go.md b/.changeset/icy-hairs-go.md deleted file mode 100644 index b9bdc532b71e..000000000000 --- a/.changeset/icy-hairs-go.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -'@data-client/vue': minor ---- - -`renderDataCompose()` awaits until the composable runs - -### Before - -```ts -const { result, cleanup } = renderDataCompose(() => - useCache(CoolerArticleResource.get, { id: payload.id }), -); - -// Wait for initial render -await waitForNextUpdate(); - -expect(result.current).toBeDefined(); -``` - -### After - -```ts -const { result, cleanup } = await renderDataCompose(() => - useCache(CoolerArticleResource.get, { id: payload.id }), -); - -expect(result.value).toBeDefined(); -``` \ No newline at end of file diff --git a/.changeset/kind-garlics-poke.md b/.changeset/kind-garlics-poke.md deleted file mode 100644 index 20a4fe1b7273..000000000000 --- a/.changeset/kind-garlics-poke.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/vue': minor ---- - -`renderDataCompose().result` is now simply passes the composable result if it's a ref, or wraps it as computable ref diff --git a/.changeset/large-walls-accept.md b/.changeset/large-walls-accept.md deleted file mode 100644 index 082bb6c042a2..000000000000 --- a/.changeset/large-walls-accept.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@data-client/endpoint': patch -'@data-client/graphql': patch -'@data-client/rest': patch ---- - -fix: Collection.remove with Unions \ No newline at end of file diff --git a/.changeset/legal-files-fly.md b/.changeset/legal-files-fly.md deleted file mode 100644 index b59f2aa1981e..000000000000 --- a/.changeset/legal-files-fly.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -'@data-client/normalizr': minor ---- - -BREAKING: denormalize no longer detects ImmutableJS state - -Use `/imm` exports to handle ImmutableJS state - -#### Before - -```ts -import { MemoCache, denormalize } from '@data-client/normalizr'; - -const memo = new MemoCache(); -``` - -#### After - -```ts -import { MemoCache } from '@data-client/normalizr'; -import { MemoPolicy, denormalize } from '@data-client/normalizr/imm'; - -const memo = new MemoCache(MemoPolicy); -``` diff --git a/.changeset/major-boxes-glow.md b/.changeset/major-boxes-glow.md deleted file mode 100644 index 262b40d0f24a..000000000000 --- a/.changeset/major-boxes-glow.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -'@data-client/normalizr': minor -'@data-client/endpoint': minor -'@data-client/rest': minor -'@data-client/graphql': minor ---- - -Add delegate.INVALID to queryKey - -This is used in schema.All.queryKey(). - -#### Before - -```ts -queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { - if (!found) return INVALID; -} -``` - -#### After - -```ts -queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { - if (!found) return delegate.INVALID; -} -``` diff --git a/.changeset/open-shrimps-warn.md b/.changeset/open-shrimps-warn.md deleted file mode 100644 index 423b862f1887..000000000000 --- a/.changeset/open-shrimps-warn.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -'@data-client/normalizr': minor -'@data-client/endpoint': minor -'@data-client/rest': minor -'@data-client/graphql': minor ---- - -Add delegate.invalidate() to normalization - -#### Before - -```ts -normalize( - input: any, - parent: any, - key: string | undefined, - args: any[], - visit: (...args: any) => any, - delegate: INormalizeDelegate, -): string { - delegate.setEntity(this as any, pk, INVALID); -} -``` - -#### After - -```ts -normalize( - input: any, - parent: any, - key: string | undefined, - args: any[], - visit: (...args: any) => any, - delegate: INormalizeDelegate, -): string { - delegate.invalidate(this as any, pk); -} -``` \ No newline at end of file diff --git a/.changeset/pink-waves-judge.md b/.changeset/pink-waves-judge.md deleted file mode 100644 index c4538cc41312..000000000000 --- a/.changeset/pink-waves-judge.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -'@data-client/endpoint': patch -'@data-client/graphql': patch -'@data-client/rest': patch ---- - -Add Collection.remove - -```ts -ctrl.set(MyResource.getList.schema.remove, { id }); -``` - -```ts -const removeItem = MyResource.delete.extend({ - schema: MyResource.getList.schema.remove -}) -``` \ No newline at end of file diff --git a/.changeset/plenty-regions-visit.md b/.changeset/plenty-regions-visit.md deleted file mode 100644 index 68b502b3438c..000000000000 --- a/.changeset/plenty-regions-visit.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -'@data-client/normalizr': patch -'@data-client/endpoint': patch -'@data-client/react': patch -'@data-client/core': patch -'@data-client/rest': patch -'@data-client/graphql': patch ---- - -Normalize delegate.invalidate() first argument only has `key` param. - -`indexes` optional param no longer provided as it was never used. - - -```ts -normalize( - input: any, - parent: any, - key: string | undefined, - args: any[], - visit: (...args: any) => any, - delegate: INormalizeDelegate, -): string { - delegate.invalidate({ key: this._entity.key }, pk); - return pk; -} -``` \ No newline at end of file diff --git a/.changeset/plenty-sloths-battle.md b/.changeset/plenty-sloths-battle.md deleted file mode 100644 index b3518ce988ae..000000000000 --- a/.changeset/plenty-sloths-battle.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@data-client/vue': patch ---- - -renderDataClient -> mountDataClient -renderDataComposable -> renderDataClient \ No newline at end of file diff --git a/.changeset/poor-jobs-turn.md b/.changeset/poor-jobs-turn.md deleted file mode 100644 index a39580602188..000000000000 --- a/.changeset/poor-jobs-turn.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -'@data-client/normalizr': minor ---- - -BREAKING CHANGE: MemoCache.query() and MemoCache.buildQueryKey() take state as one argument - -#### Before - -```ts -this.memo.buildQueryKey( - schema, - args, - state.entities, - state.indexes, - key, -); -``` - - -#### After - -```ts -this.memo.buildQueryKey( - schema, - args, - state, - key, -); -``` - -#### Before - -```ts -this.memo.query(schema, args, state.entities, state.indexes); -``` - -#### After - -```ts -this.memo.query(schema, args, state); -``` \ No newline at end of file diff --git a/.changeset/proud-insects-smile.md b/.changeset/proud-insects-smile.md deleted file mode 100644 index 4d4999da6293..000000000000 --- a/.changeset/proud-insects-smile.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -'@data-client/normalizr': minor -'@data-client/endpoint': minor -'@data-client/core': minor -'@data-client/graphql': minor -'@data-client/react': minor -'@data-client/rest': minor ---- - -BREAKING CHANGE: schema.normalize(...args, addEntity, getEntity, checkLoop) -> schema.normalize(...args, delegate) - -We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. - -```ts -/** Helpers during schema.normalize() */ -export interface INormalizeDelegate { - /** Action meta-data for this normalize call */ - readonly meta: { fetchedAt: number; date: number; expiresAt: number }; - /** Gets any previously normalized entity from store */ - getEntity: GetEntity; - /** Updates an entity using merge lifecycles when it has previously been set */ - mergeEntity( - schema: Mergeable & { indexes?: any }, - pk: string, - incomingEntity: any, - ): void; - /** Sets an entity overwriting any previously set values */ - setEntity( - schema: { key: string; indexes?: any }, - pk: string, - entity: any, - meta?: { fetchedAt: number; date: number; expiresAt: number }, - ): void; - /** Returns true when we're in a cycle, so we should not continue recursing */ - checkLoop(key: string, pk: string, input: object): boolean; -} -``` - -#### Before - -```ts -addEntity(this, processedEntity, id); -``` - -#### After - -```ts -delegate.mergeEntity(this, id, processedEntity); -``` \ No newline at end of file diff --git a/.changeset/proud-rooms-pick.md b/.changeset/proud-rooms-pick.md deleted file mode 100644 index 2e4361dfe8c4..000000000000 --- a/.changeset/proud-rooms-pick.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/vue': patch ---- - -Make composables reactive to computed props diff --git a/.changeset/proud-taxes-bake.md b/.changeset/proud-taxes-bake.md deleted file mode 100644 index 7861fbb90a2a..000000000000 --- a/.changeset/proud-taxes-bake.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -'@data-client/normalizr': minor -'@data-client/endpoint': minor ---- - -delegate.getEntity(key) -> delegate.getEntities(this.key) - -Return value is a restricted interface with keys() and entries() iterator methods. -This applies to both schema.queryKey and schema.normalize method delegates. - -```ts -const entities = delegate.getEntities(key); - -// foreach on keys -for (const key of entities.keys()) {} -// Object.keys() (convert to array) -return [...entities.keys()]; -// foreach on full entry -for (const [key, entity] of entities.entries()) {} -``` - -#### Before - -```ts -const entities = delegate.getEntity(this.key); -if (entities) - Object.keys(entities).forEach(collectionPk => { - if (!filterCollections(JSON.parse(collectionPk))) return; - delegate.mergeEntity(this, collectionPk, normalizedValue); - }); -``` - -#### After - -```ts -const entities = delegate.getEntities(this.key); -if (entities) - for (const collectionKey of entities.keys()) { - if (!filterCollections(JSON.parse(collectionKey))) continue; - delegate.mergeEntity(this, collectionKey, normalizedValue); - } -``` \ No newline at end of file diff --git a/.changeset/shiny-olives-behave.md b/.changeset/shiny-olives-behave.md deleted file mode 100644 index 7e6dddb88ad9..000000000000 --- a/.changeset/shiny-olives-behave.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/endpoint': patch ---- - -fix: export types needed for EntityMixin diff --git a/.changeset/sixty-monkeys-open.md b/.changeset/sixty-monkeys-open.md deleted file mode 100644 index 5693a0ecae32..000000000000 --- a/.changeset/sixty-monkeys-open.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@data-client/normalizr': minor -'@data-client/react': minor -'@data-client/core': minor ---- - -state.entityMeta -> state.entitiesMeta diff --git a/.changeset/small-wasps-win.md b/.changeset/small-wasps-win.md deleted file mode 100644 index 9e4c40cbb55c..000000000000 --- a/.changeset/small-wasps-win.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/vue': patch ---- - -Add useCache() diff --git a/.changeset/smart-dodos-hear.md b/.changeset/smart-dodos-hear.md deleted file mode 100644 index 524304af1349..000000000000 --- a/.changeset/smart-dodos-hear.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/img': patch ---- - -Update readme example to useSuspense() diff --git a/.changeset/sour-horses-give.md b/.changeset/sour-horses-give.md deleted file mode 100644 index 7bb77527def9..000000000000 --- a/.changeset/sour-horses-give.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -'@data-client/core': minor -'@data-client/test': minor ---- - -Change NetworkManager bookkeeping data structure for inflight fetches - -BREAKING CHANGE: NetworkManager.fetched, NetworkManager.rejectors, NetworkManager.resolvers, NetworkManager.fetchedAt - -> NetworkManager.fetching - - -#### Before - -```ts -if (action.key in this.fetched) -``` - -#### After - -```ts -if (this.fetching.has(action.key)) -``` \ No newline at end of file diff --git a/.changeset/stale-socks-accept.md b/.changeset/stale-socks-accept.md deleted file mode 100644 index 6180a04613bf..000000000000 --- a/.changeset/stale-socks-accept.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -'@data-client/normalizr': minor ---- - -MemoCache.query returns `{ data, paths }` just like denormalize. `data` could be INVALID - -#### Before - -```ts -return this.memo.query(schema, args, state); -``` - -#### After - -```ts -const { data } = this.memo.query(schema, args, state); -return typeof data === 'symbol' ? undefined : (data as any); -``` \ No newline at end of file diff --git a/.changeset/ten-lions-retire.md b/.changeset/ten-lions-retire.md deleted file mode 100644 index c1d0f26c37c1..000000000000 --- a/.changeset/ten-lions-retire.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'@data-client/normalizr': patch -'@data-client/core': patch -'@data-client/react': patch ---- - -Improve performance of get/denormalize for small responses - -- 10-20% performance improvement due to removing immutablejs check for every call \ No newline at end of file diff --git a/.changeset/thirty-islands-hope.md b/.changeset/thirty-islands-hope.md deleted file mode 100644 index 68c5d1c102f6..000000000000 --- a/.changeset/thirty-islands-hope.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -'@data-client/endpoint': patch ---- - -Fix: schema.All() polymorphic handling of Invalidated entities - -In case an Entity is invalidated, schema.All will continue to properly -filter it out of its list. \ No newline at end of file diff --git a/.changeset/tough-areas-show.md b/.changeset/tough-areas-show.md deleted file mode 100644 index 255e85185a7d..000000000000 --- a/.changeset/tough-areas-show.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'@data-client/endpoint': minor -'@data-client/graphql': minor -'@data-client/rest': minor ---- - -Remove `INVALID` symbol export - -Schemas can use delegate.invalidate() in normalize() or return delegate.INVALID in queryKey(). \ No newline at end of file diff --git a/.changeset/tricky-olives-wash.md b/.changeset/tricky-olives-wash.md deleted file mode 100644 index cf7a20254c22..000000000000 --- a/.changeset/tricky-olives-wash.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -'@data-client/vue': minor ---- - -Add useDLE() - -```ts -const { date, loading, error } = useDLE( - CoolerArticleResource.get, - computed(() => (props.id !== null ? { id: props.id } : null)), -); -``` \ No newline at end of file diff --git a/.changeset/two-bees-scream.md b/.changeset/two-bees-scream.md deleted file mode 100644 index a8422c9b3481..000000000000 --- a/.changeset/two-bees-scream.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@data-client/test': minor -'@data-client/img': minor ---- - -Support 0.15 of @data-client/react diff --git a/.changeset/weak-grapes-kiss.md b/.changeset/weak-grapes-kiss.md deleted file mode 100644 index 69e5aedfdb78..000000000000 --- a/.changeset/weak-grapes-kiss.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -'@data-client/endpoint': patch -'@data-client/rest': patch -'@data-client/graphql': patch ---- - -Unions can query() without type discriminator - -#### Before -```tsx -// @ts-expect-error -const event = useQuery(EventUnion, { id }); -// event is undefined -const newsEvent = useQuery(EventUnion, { id, type: 'news' }); -// newsEvent is found -``` - -#### After - -```tsx -const event = useQuery(EventUnion, { id }); -// event is found -const newsEvent = useQuery(EventUnion, { id, type: 'news' }); -// newsEvent is found -``` \ No newline at end of file diff --git a/.changeset/wicked-bags-appear.md b/.changeset/wicked-bags-appear.md deleted file mode 100644 index 0f0e970c1c41..000000000000 --- a/.changeset/wicked-bags-appear.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -'@data-client/normalizr': minor -'@data-client/endpoint': minor -'@data-client/core': minor -'@data-client/graphql': minor -'@data-client/react': minor -'@data-client/rest': minor ---- - -BREAKING CHANGE: schema.queryKey(args, queryKey, getEntity, getIndex) -> schema.queryKey(args, unvisit, delegate) -BREAKING CHANGE: delegate.getIndex() returns the index directly, rather than object. - -We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. - -Our recursive call is renamed from queryKey to unvisit, and does not require the last two arguments. - -```ts -/** Accessors to the currently processing state while building query */ -export interface IQueryDelegate { - getEntity: GetEntity; - getIndex: GetIndex; -} -``` - -#### Before - -```ts -queryKey(args, queryKey, getEntity, getIndex) { - getIndex(schema.key, indexName, value)[value]; - getEntity(this.key, id); - return queryKey(this.schema, args, getEntity, getIndex); -} -``` - -#### After - -```ts -queryKey(args, unvisit, delegate) { - delegate.getIndex(schema.key, indexName, value); - delegate.getEntity(this.key, id); - return unvisit(this.schema, args); -} -``` diff --git a/.changeset/wicked-feet-cheat.md b/.changeset/wicked-feet-cheat.md deleted file mode 100644 index 4fee53442d54..000000000000 --- a/.changeset/wicked-feet-cheat.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@data-client/endpoint': patch -'@data-client/react': patch -'@data-client/rest': patch ---- - -Include GPT link badge in readme diff --git a/examples/benchmark/CHANGELOG.md b/examples/benchmark/CHANGELOG.md index 0201158adc44..a116c148f365 100644 --- a/examples/benchmark/CHANGELOG.md +++ b/examples/benchmark/CHANGELOG.md @@ -1,5 +1,14 @@ # example-benchmark +## 0.4.75 + +### Patch Changes + +- Updated dependencies [[`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`246cde6`](https://github.com/reactive/data-client/commit/246cde6dbeca59eafd10e59d8cd05a6f232fb219), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290), [`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), [`bab907c`](https://github.com/reactive/data-client/commit/bab907ce824c0f7da961d74c9fb8b64ce7c95141), [`4939456`](https://github.com/reactive/data-client/commit/4939456598c213ee81c1abef476a1aaccd19f82d), [`d44d36a`](https://github.com/reactive/data-client/commit/d44d36a7de0a18817486c4f723bf2f0e86ac9677), [`25b153a`](https://github.com/reactive/data-client/commit/25b153a9d80db1bcd17ab5558dfa13b333f112b8), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`5699005`](https://github.com/reactive/data-client/commit/5699005700206306bc70ff8237bf7ceaac241b82), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8)]: + - @data-client/normalizr@0.15.0 + - @data-client/core@0.15.0 + - @data-client/endpoint@0.15.0 + ## 0.4.74 ### Patch Changes diff --git a/examples/benchmark/package.json b/examples/benchmark/package.json index 86eef4823c0d..9e325b773fc7 100644 --- a/examples/benchmark/package.json +++ b/examples/benchmark/package.json @@ -1,6 +1,6 @@ { "name": "example-benchmark", - "version": "0.4.74", + "version": "0.4.75", "description": "Benchmark for normalizr", "main": "index.js", "author": "Nathaniel Tucker", diff --git a/examples/normalizr-github/CHANGELOG.md b/examples/normalizr-github/CHANGELOG.md index d0b246c77c8a..c10da618be66 100644 --- a/examples/normalizr-github/CHANGELOG.md +++ b/examples/normalizr-github/CHANGELOG.md @@ -1,5 +1,13 @@ # normalizr-github-example +## 0.1.51 + +### Patch Changes + +- Updated dependencies [[`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`246cde6`](https://github.com/reactive/data-client/commit/246cde6dbeca59eafd10e59d8cd05a6f232fb219), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290), [`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), [`bab907c`](https://github.com/reactive/data-client/commit/bab907ce824c0f7da961d74c9fb8b64ce7c95141), [`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), [`5699005`](https://github.com/reactive/data-client/commit/5699005700206306bc70ff8237bf7ceaac241b82), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8)]: + - @data-client/normalizr@0.15.0 + - @data-client/endpoint@0.15.0 + ## 0.1.50 ### Patch Changes diff --git a/examples/normalizr-github/package.json b/examples/normalizr-github/package.json index 55183f6c72af..510095ae3b8b 100644 --- a/examples/normalizr-github/package.json +++ b/examples/normalizr-github/package.json @@ -1,6 +1,6 @@ { "name": "normalizr-github-example", - "version": "0.1.50", + "version": "0.1.51", "description": "And example of using Normalizr with github", "main": "index.js", "author": "Paul Armstrong", diff --git a/examples/normalizr-redux/CHANGELOG.md b/examples/normalizr-redux/CHANGELOG.md index e4801ba8088c..064f50458848 100644 --- a/examples/normalizr-redux/CHANGELOG.md +++ b/examples/normalizr-redux/CHANGELOG.md @@ -1,5 +1,13 @@ # normalizr-redux-example +## 0.1.49 + +### Patch Changes + +- Updated dependencies [[`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`246cde6`](https://github.com/reactive/data-client/commit/246cde6dbeca59eafd10e59d8cd05a6f232fb219), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290), [`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), [`bab907c`](https://github.com/reactive/data-client/commit/bab907ce824c0f7da961d74c9fb8b64ce7c95141), [`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), [`5699005`](https://github.com/reactive/data-client/commit/5699005700206306bc70ff8237bf7ceaac241b82), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8)]: + - @data-client/normalizr@0.15.0 + - @data-client/endpoint@0.15.0 + ## 0.1.48 ### Patch Changes diff --git a/examples/normalizr-redux/package.json b/examples/normalizr-redux/package.json index 02f1b50dc08b..cc607aa4838a 100644 --- a/examples/normalizr-redux/package.json +++ b/examples/normalizr-redux/package.json @@ -1,6 +1,6 @@ { "name": "normalizr-redux-example", - "version": "0.1.48", + "version": "0.1.49", "description": "And example of using Normalizr with Redux", "main": "index.js", "author": "Paul Armstrong", diff --git a/examples/normalizr-relationships/CHANGELOG.md b/examples/normalizr-relationships/CHANGELOG.md index 21c1fc06e3a3..00f173d86a12 100644 --- a/examples/normalizr-relationships/CHANGELOG.md +++ b/examples/normalizr-relationships/CHANGELOG.md @@ -1,5 +1,13 @@ # normalizr-relationships +## 0.1.51 + +### Patch Changes + +- Updated dependencies [[`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`246cde6`](https://github.com/reactive/data-client/commit/246cde6dbeca59eafd10e59d8cd05a6f232fb219), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290), [`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), [`bab907c`](https://github.com/reactive/data-client/commit/bab907ce824c0f7da961d74c9fb8b64ce7c95141), [`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), [`5699005`](https://github.com/reactive/data-client/commit/5699005700206306bc70ff8237bf7ceaac241b82), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8)]: + - @data-client/normalizr@0.15.0 + - @data-client/endpoint@0.15.0 + ## 0.1.50 ### Patch Changes diff --git a/examples/normalizr-relationships/package.json b/examples/normalizr-relationships/package.json index 384e505252c3..d623e582ac98 100644 --- a/examples/normalizr-relationships/package.json +++ b/examples/normalizr-relationships/package.json @@ -1,6 +1,6 @@ { "name": "normalizr-relationships", - "version": "0.1.50", + "version": "0.1.51", "description": "And example of using Normalizr with relationships", "main": "index.js", "author": "Paul Armstrong", diff --git a/examples/test-bundlesize/CHANGELOG.md b/examples/test-bundlesize/CHANGELOG.md new file mode 100644 index 000000000000..b2848e831ae1 --- /dev/null +++ b/examples/test-bundlesize/CHANGELOG.md @@ -0,0 +1,10 @@ +# test-bundlesize + +## 0.1.1 + +### Patch Changes + +- Updated dependencies [[`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`997ca20`](https://github.com/reactive/data-client/commit/997ca209d36e8503ab7684bccc6ddc29d179a0b5), [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`4939456`](https://github.com/reactive/data-client/commit/4939456598c213ee81c1abef476a1aaccd19f82d), [`b978362`](https://github.com/reactive/data-client/commit/b97836216eb9e8d9a403dd1ed88797f2db777dbb), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`769cb78`](https://github.com/reactive/data-client/commit/769cb78966aed032c90864c701dae2bac0cc1e4d), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8)]: + - @data-client/react@0.15.0 + - @data-client/rest@0.15.0 + - @data-client/img@0.15.0 diff --git a/examples/test-bundlesize/package.json b/examples/test-bundlesize/package.json index 356bab43620a..c4ae033753b8 100644 --- a/examples/test-bundlesize/package.json +++ b/examples/test-bundlesize/package.json @@ -1,6 +1,6 @@ { "name": "test-bundlesize", - "version": "0.1.0", + "version": "0.1.1", "packageManager": "yarn@4.11.0", "description": "Testing Bundled Size", "scripts": { diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 3422ddf2937a..ec7655ba9ac5 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,132 @@ # @data-client/core +## 0.15.0 + +### Minor Changes + +- [#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) + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + ```ts + /** Helpers during schema.normalize() */ + export interface INormalizeDelegate { + /** Action meta-data for this normalize call */ + readonly meta: { fetchedAt: number; date: number; expiresAt: number }; + /** Gets any previously normalized entity from store */ + getEntity: GetEntity; + /** Updates an entity using merge lifecycles when it has previously been set */ + mergeEntity( + schema: Mergeable & { indexes?: any }, + pk: string, + incomingEntity: any, + ): void; + /** Sets an entity overwriting any previously set values */ + setEntity( + schema: { key: string; indexes?: any }, + pk: string, + entity: any, + meta?: { fetchedAt: number; date: number; expiresAt: number }, + ): void; + /** Returns true when we're in a cycle, so we should not continue recursing */ + checkLoop(key: string, pk: string, input: object): boolean; + } + ``` + + #### Before + + ```ts + addEntity(this, processedEntity, id); + ``` + + #### After + + ```ts + delegate.mergeEntity(this, id, processedEntity); + ``` + +- [#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 + +- [#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 + + BREAKING CHANGE: NetworkManager.fetched, NetworkManager.rejectors, NetworkManager.resolvers, NetworkManager.fetchedAt + -> NetworkManager.fetching + + #### Before + + ```ts + if (action.key in this.fetched) + ``` + + #### After + + ```ts + if (this.fetching.has(action.key)) + ``` + +- [#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) + BREAKING CHANGE: delegate.getIndex() returns the index directly, rather than object. + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + Our recursive call is renamed from queryKey to unvisit, and does not require the last two arguments. + + ```ts + /** Accessors to the currently processing state while building query */ + export interface IQueryDelegate { + getEntity: GetEntity; + getIndex: GetIndex; + } + ``` + + #### Before + + ```ts + queryKey(args, queryKey, getEntity, getIndex) { + getIndex(schema.key, indexName, value)[value]; + getEntity(this.key, id); + return queryKey(this.schema, args, getEntity, getIndex); + } + ``` + + #### After + + ```ts + queryKey(args, unvisit, delegate) { + delegate.getIndex(schema.key, indexName, value); + delegate.getEntity(this.key, id); + return unvisit(this.schema, args); + } + ``` + +### Patch Changes + +- [#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 + +- [#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. + + `indexes` optional param no longer provided as it was never used. + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.invalidate({ key: this._entity.key }, pk); + return pk; + } + ``` + +- [#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 + - 10-20% performance improvement due to removing immutablejs check for every call + +- 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), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`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)]: + - @data-client/normalizr@0.15.0 + ## 0.14.24 ### Patch Changes @@ -266,7 +393,6 @@ - [`d84b43c`](https://github.com/reactive/data-client/commit/d84b43cf728d714da7182f2c19b39f49e0ec0366) Thanks [@ntucker](https://github.com/ntucker)! - Move NetworkManager missing detection to initialization (applyManager()) - [`06df291`](https://github.com/reactive/data-client/commit/06df291a1f1d91afa331310dfb8319bc8d1a3ba8) Thanks [@ntucker](https://github.com/ntucker)! - Reorder action members for easier debuggability - - `key` at top - easiest to read 'subject' - `response` or `value` after - 'object' being set @@ -581,7 +707,6 @@ ``` BREAKING CHANGE: - - actionTypes.SET_TYPE -> actionTypes.SET_RESPONSE_TYPE - SetAction -> SetResponseAction @@ -759,7 +884,6 @@ ### Patch Changes - [`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 - - `unvisit()` always returns `undefined` with `undefined` as input. - `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) @@ -780,7 +904,6 @@ ### Minor Changes - [#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 - - `[]` and [schema.Array](https://dataclient.io/rest/api/Array) now behave in the same manner. - `null` values are now consistently handled everywhere (being retained). - These were already being retained in [nested Entities](https://dataclient.io/rest/guides/relational-data#nesting) @@ -817,7 +940,6 @@ ### Patch Changes - [#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 - - Client packages namespace into RDC - @data-client/react - RDC - @data-client/core - RDC.Core @@ -901,7 +1023,6 @@ legacy compatibility. - [#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: - - DELETE removed -> INVALIDATE - drop all support for legacy schemas - entity.expiresAt removed @@ -911,7 +1032,6 @@ - [#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) BREAKING CHANGE: - - remove ReceiveAction - ReceiveTypes -> SetTypes - remove Controller.receive Controller.receiveError diff --git a/packages/core/package.json b/packages/core/package.json index f921a4af71b6..78bbef21c530 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/core", - "version": "0.14.24", + "version": "0.15.0", "description": "Async State Management without the Management. REST, GraphQL, SSE, Websockets, Fetch", "sideEffects": false, "main": "dist/index.js", diff --git a/packages/endpoint/CHANGELOG.md b/packages/endpoint/CHANGELOG.md index 05396a0319eb..69f4911a68d5 100644 --- a/packages/endpoint/CHANGELOG.md +++ b/packages/endpoint/CHANGELOG.md @@ -1,5 +1,247 @@ # @data-client/endpoint +## 0.15.0 + +### Minor Changes + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Add delegate.INVALID to queryKey + + This is used in schema.All.queryKey(). + + #### Before + + ```ts + queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { + if (!found) return INVALID; + } + ``` + + #### After + + ```ts + queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { + if (!found) return delegate.INVALID; + } + ``` + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Add delegate.invalidate() to normalization + + #### Before + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.setEntity(this as any, pk, INVALID); + } + ``` + + #### After + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.invalidate(this as any, pk); + } + ``` + +- [#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) + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + ```ts + /** Helpers during schema.normalize() */ + export interface INormalizeDelegate { + /** Action meta-data for this normalize call */ + readonly meta: { fetchedAt: number; date: number; expiresAt: number }; + /** Gets any previously normalized entity from store */ + getEntity: GetEntity; + /** Updates an entity using merge lifecycles when it has previously been set */ + mergeEntity( + schema: Mergeable & { indexes?: any }, + pk: string, + incomingEntity: any, + ): void; + /** Sets an entity overwriting any previously set values */ + setEntity( + schema: { key: string; indexes?: any }, + pk: string, + entity: any, + meta?: { fetchedAt: number; date: number; expiresAt: number }, + ): void; + /** Returns true when we're in a cycle, so we should not continue recursing */ + checkLoop(key: string, pk: string, input: object): boolean; + } + ``` + + #### Before + + ```ts + addEntity(this, processedEntity, id); + ``` + + #### After + + ```ts + delegate.mergeEntity(this, id, processedEntity); + ``` + +- [#3468](https://github.com/reactive/data-client/pull/3468) [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895) Thanks [@ntucker](https://github.com/ntucker)! - delegate.getEntity(key) -> delegate.getEntities(this.key) + + Return value is a restricted interface with keys() and entries() iterator methods. + This applies to both schema.queryKey and schema.normalize method delegates. + + ```ts + const entities = delegate.getEntities(key); + + // foreach on keys + for (const key of entities.keys()) { + } + // Object.keys() (convert to array) + return [...entities.keys()]; + // foreach on full entry + for (const [key, entity] of entities.entries()) { + } + ``` + + #### Before + + ```ts + const entities = delegate.getEntity(this.key); + if (entities) + Object.keys(entities).forEach(collectionPk => { + if (!filterCollections(JSON.parse(collectionPk))) return; + delegate.mergeEntity(this, collectionPk, normalizedValue); + }); + ``` + + #### After + + ```ts + const entities = delegate.getEntities(this.key); + if (entities) + for (const collectionKey of entities.keys()) { + if (!filterCollections(JSON.parse(collectionKey))) continue; + delegate.mergeEntity(this, collectionKey, normalizedValue); + } + ``` + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Remove `INVALID` symbol export + + Schemas can use delegate.invalidate() in normalize() or return delegate.INVALID in queryKey(). + +- [#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) + BREAKING CHANGE: delegate.getIndex() returns the index directly, rather than object. + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + Our recursive call is renamed from queryKey to unvisit, and does not require the last two arguments. + + ```ts + /** Accessors to the currently processing state while building query */ + export interface IQueryDelegate { + getEntity: GetEntity; + getIndex: GetIndex; + } + ``` + + #### Before + + ```ts + queryKey(args, queryKey, getEntity, getIndex) { + getIndex(schema.key, indexName, value)[value]; + getEntity(this.key, id); + return queryKey(this.schema, args, getEntity, getIndex); + } + ``` + + #### After + + ```ts + queryKey(args, unvisit, delegate) { + delegate.getIndex(schema.key, indexName, value); + delegate.getEntity(this.key, id); + return unvisit(this.schema, args); + } + ``` + +### Patch Changes + +- [#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: ensure string id in Entity set when process returns undefined (meaning INVALID) + +- [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed) Thanks [@ntucker](https://github.com/ntucker)! - fix: Collection.remove with Unions + +- [#3560](https://github.com/reactive/data-client/pull/3560) [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290) Thanks [@ntucker](https://github.com/ntucker)! - Add Collection.remove + + ```ts + ctrl.set(MyResource.getList.schema.remove, { id }); + ``` + + ```ts + const removeItem = MyResource.delete.extend({ + schema: MyResource.getList.schema.remove, + }); + ``` + +- [#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. + + `indexes` optional param no longer provided as it was never used. + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.invalidate({ key: this._entity.key }, pk); + return pk; + } + ``` + +- [#3480](https://github.com/reactive/data-client/pull/3480) [`bab907c`](https://github.com/reactive/data-client/commit/bab907ce824c0f7da961d74c9fb8b64ce7c95141) Thanks [@Tomaszal](https://github.com/Tomaszal)! - fix: export types needed for EntityMixin + +- [#3501](https://github.com/reactive/data-client/pull/3501) [`5699005`](https://github.com/reactive/data-client/commit/5699005700206306bc70ff8237bf7ceaac241b82) Thanks [@ntucker](https://github.com/ntucker)! - Fix: schema.All() polymorphic handling of Invalidated entities + + In case an Entity is invalidated, schema.All will continue to properly + filter it out of its list. + +- [#3558](https://github.com/reactive/data-client/pull/3558) [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f) Thanks [@ntucker](https://github.com/ntucker)! - Unions can query() without type discriminator + + #### Before + + ```tsx + // @ts-expect-error + const event = useQuery(EventUnion, { id }); + // event is undefined + const newsEvent = useQuery(EventUnion, { id, type: 'news' }); + // newsEvent is found + ``` + + #### After + + ```tsx + const event = useQuery(EventUnion, { id }); + // event is found + const newsEvent = useQuery(EventUnion, { id, type: 'news' }); + // newsEvent is found + ``` + +- [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8) Thanks [@ntucker](https://github.com/ntucker)! - Include GPT link badge in readme + ## 0.14.25 ### Patch Changes @@ -315,7 +557,6 @@ ### Patch Changes - [#3017](https://github.com/reactive/data-client/pull/3017) [`ce164d2`](https://github.com/reactive/data-client/commit/ce164d286c8afcb2593a86abbf23948a08aa40ba) Thanks [@ntucker](https://github.com/ntucker)! - Queries pass-through suspense rather than ever being undefined - - [useSuspense()](https://dataclient.io/docs/api/useSuspense) return values will not be nullable - [useQuery()](https://dataclient.io/docs/api/useQuery) will still be nullable due to it handling `INVALID` as `undefined` return - [Query.process](https://dataclient.io/rest/api/Query#process) does not need to handle nullable cases @@ -488,7 +729,6 @@ ### Patch Changes - [`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 - - `unvisit()` always returns `undefined` with `undefined` as input. - `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) @@ -579,7 +819,6 @@ ### Minor Changes - [#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 - - `[]` and [schema.Array](https://dataclient.io/rest/api/Array) now behave in the same manner. - `null` values are now consistently handled everywhere (being retained). - These were already being retained in [nested Entities](https://dataclient.io/rest/guides/relational-data#nesting) @@ -623,7 +862,6 @@ ### Patch Changes - [#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 - - Client packages namespace into RDC - @data-client/react - RDC - @data-client/core - RDC.Core @@ -656,7 +894,6 @@ - [`664d3eacff`](https://github.com/reactive/data-client/commit/664d3eacff08c3c75e8ed7c3ccc64ee21faa6f7f) Thanks [@ntucker](https://github.com/ntucker)! - Remove dev warning for old versions of client - [#2799](https://github.com/reactive/data-client/pull/2799) [`26a3843d1b`](https://github.com/reactive/data-client/commit/26a3843d1b61900c385d8626d7062d6f0424c137) Thanks [@ntucker](https://github.com/ntucker)! - Removed some forms of automatic entity validation - - Now allow missing schemas making it easier to declare partials - Removed logic for certain keys found out of defaults @@ -669,7 +906,6 @@ ### Minor Changes - [#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: - - DELETE removed -> INVALIDATE - drop all support for legacy schemas - entity.expiresAt removed diff --git a/packages/endpoint/package.json b/packages/endpoint/package.json index 6348053d6d2b..7b2dde9ed50e 100644 --- a/packages/endpoint/package.json +++ b/packages/endpoint/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/endpoint", - "version": "0.14.25", + "version": "0.15.0", "description": "Declarative Network Interface Definitions", "homepage": "https://dataclient.io/docs/guides/custom-protocol", "keywords": [ diff --git a/packages/graphql/CHANGELOG.md b/packages/graphql/CHANGELOG.md index 6267173bc208..7504d639008c 100644 --- a/packages/graphql/CHANGELOG.md +++ b/packages/graphql/CHANGELOG.md @@ -1,5 +1,201 @@ # @data-client/graphql +## 0.15.0 + +### Minor Changes + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Add delegate.INVALID to queryKey + + This is used in schema.All.queryKey(). + + #### Before + + ```ts + queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { + if (!found) return INVALID; + } + ``` + + #### After + + ```ts + queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { + if (!found) return delegate.INVALID; + } + ``` + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Add delegate.invalidate() to normalization + + #### Before + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.setEntity(this as any, pk, INVALID); + } + ``` + + #### After + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.invalidate(this as any, pk); + } + ``` + +- [#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) + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + ```ts + /** Helpers during schema.normalize() */ + export interface INormalizeDelegate { + /** Action meta-data for this normalize call */ + readonly meta: { fetchedAt: number; date: number; expiresAt: number }; + /** Gets any previously normalized entity from store */ + getEntity: GetEntity; + /** Updates an entity using merge lifecycles when it has previously been set */ + mergeEntity( + schema: Mergeable & { indexes?: any }, + pk: string, + incomingEntity: any, + ): void; + /** Sets an entity overwriting any previously set values */ + setEntity( + schema: { key: string; indexes?: any }, + pk: string, + entity: any, + meta?: { fetchedAt: number; date: number; expiresAt: number }, + ): void; + /** Returns true when we're in a cycle, so we should not continue recursing */ + checkLoop(key: string, pk: string, input: object): boolean; + } + ``` + + #### Before + + ```ts + addEntity(this, processedEntity, id); + ``` + + #### After + + ```ts + delegate.mergeEntity(this, id, processedEntity); + ``` + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Remove `INVALID` symbol export + + Schemas can use delegate.invalidate() in normalize() or return delegate.INVALID in queryKey(). + +- [#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) + BREAKING CHANGE: delegate.getIndex() returns the index directly, rather than object. + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + Our recursive call is renamed from queryKey to unvisit, and does not require the last two arguments. + + ```ts + /** Accessors to the currently processing state while building query */ + export interface IQueryDelegate { + getEntity: GetEntity; + getIndex: GetIndex; + } + ``` + + #### Before + + ```ts + queryKey(args, queryKey, getEntity, getIndex) { + getIndex(schema.key, indexName, value)[value]; + getEntity(this.key, id); + return queryKey(this.schema, args, getEntity, getIndex); + } + ``` + + #### After + + ```ts + queryKey(args, unvisit, delegate) { + delegate.getIndex(schema.key, indexName, value); + delegate.getEntity(this.key, id); + return unvisit(this.schema, args); + } + ``` + +### Patch Changes + +- [#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: ensure string id in Entity set when process returns undefined (meaning INVALID) + +- [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed) Thanks [@ntucker](https://github.com/ntucker)! - fix: Collection.remove with Unions + +- [#3560](https://github.com/reactive/data-client/pull/3560) [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290) Thanks [@ntucker](https://github.com/ntucker)! - Add Collection.remove + + ```ts + ctrl.set(MyResource.getList.schema.remove, { id }); + ``` + + ```ts + const removeItem = MyResource.delete.extend({ + schema: MyResource.getList.schema.remove, + }); + ``` + +- [#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. + + `indexes` optional param no longer provided as it was never used. + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.invalidate({ key: this._entity.key }, pk); + return pk; + } + ``` + +- [#3558](https://github.com/reactive/data-client/pull/3558) [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f) Thanks [@ntucker](https://github.com/ntucker)! - Unions can query() without type discriminator + + #### Before + + ```tsx + // @ts-expect-error + const event = useQuery(EventUnion, { id }); + // event is undefined + const newsEvent = useQuery(EventUnion, { id, type: 'news' }); + // newsEvent is found + ``` + + #### After + + ```tsx + const event = useQuery(EventUnion, { id }); + // event is found + const newsEvent = useQuery(EventUnion, { id, type: 'news' }); + // newsEvent is found + ``` + +- Updated dependencies [[`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`bab907c`](https://github.com/reactive/data-client/commit/bab907ce824c0f7da961d74c9fb8b64ce7c95141), [`5699005`](https://github.com/reactive/data-client/commit/5699005700206306bc70ff8237bf7ceaac241b82), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8)]: + - @data-client/endpoint@0.15.0 + ## 0.14.25 ### Patch Changes @@ -355,7 +551,6 @@ ### Patch Changes - [#3017](https://github.com/reactive/data-client/pull/3017) [`ce164d2`](https://github.com/reactive/data-client/commit/ce164d286c8afcb2593a86abbf23948a08aa40ba) Thanks [@ntucker](https://github.com/ntucker)! - Queries pass-through suspense rather than ever being undefined - - [useSuspense()](https://dataclient.io/docs/api/useSuspense) return values will not be nullable - [useQuery()](https://dataclient.io/docs/api/useQuery) will still be nullable due to it handling `INVALID` as `undefined` return - [Query.process](https://dataclient.io/rest/api/Query#process) does not need to handle nullable cases @@ -560,7 +755,6 @@ ### Patch Changes - [#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 - - Client packages namespace into RDC - @data-client/react - RDC - @data-client/core - RDC.Core @@ -600,7 +794,6 @@ - [`664d3eacff`](https://github.com/reactive/data-client/commit/664d3eacff08c3c75e8ed7c3ccc64ee21faa6f7f) Thanks [@ntucker](https://github.com/ntucker)! - Remove dev warning for old versions of client - [#2799](https://github.com/reactive/data-client/pull/2799) [`26a3843d1b`](https://github.com/reactive/data-client/commit/26a3843d1b61900c385d8626d7062d6f0424c137) Thanks [@ntucker](https://github.com/ntucker)! - Removed some forms of automatic entity validation - - Now allow missing schemas making it easier to declare partials - Removed logic for certain keys found out of defaults diff --git a/packages/graphql/package.json b/packages/graphql/package.json index 12a1e29131b7..5aad22a3451c 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/graphql", - "version": "0.14.25", + "version": "0.15.0", "description": "Quickly define typed GraphQL resources and endpoints", "homepage": "https://dataclient.io/docs/graphql", "repository": { diff --git a/packages/img/CHANGELOG.md b/packages/img/CHANGELOG.md index 2102fc416b8f..60e83d38b974 100644 --- a/packages/img/CHANGELOG.md +++ b/packages/img/CHANGELOG.md @@ -1,5 +1,18 @@ # @data-client/img +## 0.15.0 + +### Minor Changes + +- [`769cb78`](https://github.com/reactive/data-client/commit/769cb78966aed032c90864c701dae2bac0cc1e4d) Thanks [@ntucker](https://github.com/ntucker)! - Support 0.15 of @data-client/react + +### Patch Changes + +- [`b978362`](https://github.com/reactive/data-client/commit/b97836216eb9e8d9a403dd1ed88797f2db777dbb) Thanks [@ntucker](https://github.com/ntucker)! - Update readme example to useSuspense() + +- Updated dependencies [[`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`bab907c`](https://github.com/reactive/data-client/commit/bab907ce824c0f7da961d74c9fb8b64ce7c95141), [`5699005`](https://github.com/reactive/data-client/commit/5699005700206306bc70ff8237bf7ceaac241b82), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8)]: + - @data-client/endpoint@0.15.0 + ## 0.14.21 ### Patch Changes @@ -128,7 +141,6 @@ ### Patch Changes - [#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 - - Client packages namespace into RDC - @data-client/react - RDC - @data-client/core - RDC.Core diff --git a/packages/img/package.json b/packages/img/package.json index c7f291e77fb0..173aef289d4c 100644 --- a/packages/img/package.json +++ b/packages/img/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/img", - "version": "0.14.21", + "version": "0.15.0", "description": "Suspenseful images", "homepage": "https://dataclient.io/docs/guides/img-media#just-images", "repository": { diff --git a/packages/normalizr/CHANGELOG.md b/packages/normalizr/CHANGELOG.md index 63f8e4f4e4b8..8b3c00d487d6 100644 --- a/packages/normalizr/CHANGELOG.md +++ b/packages/normalizr/CHANGELOG.md @@ -1,5 +1,295 @@ # Change Log +## 0.15.0 + +### Minor Changes + +- [#3421](https://github.com/reactive/data-client/pull/3421) [`246cde6`](https://github.com/reactive/data-client/commit/246cde6dbeca59eafd10e59d8cd05a6f232fb219) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: Denormalize always transforms immutablejs entities into the class + + Previously using ImmutableJS structures when calling denormalize() would maintain + nested schemas as immutablejs structures still. Now everything is converted to normal JS. + This is how the types have always been specified. + +- [#3468](https://github.com/reactive/data-client/pull/3468) [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: denormalize no longer detects ImmutableJS state + + Use `/imm` exports to handle ImmutableJS state + + #### Before + + ```ts + import { MemoCache, denormalize } from '@data-client/normalizr'; + + const memo = new MemoCache(); + ``` + + #### After + + ```ts + import { MemoCache } from '@data-client/normalizr'; + import { MemoPolicy, denormalize } from '@data-client/normalizr/imm'; + + const memo = new MemoCache(MemoPolicy); + ``` + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Add delegate.INVALID to queryKey + + This is used in schema.All.queryKey(). + + #### Before + + ```ts + queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { + if (!found) return INVALID; + } + ``` + + #### After + + ```ts + queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { + if (!found) return delegate.INVALID; + } + ``` + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Add delegate.invalidate() to normalization + + #### Before + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.setEntity(this as any, pk, INVALID); + } + ``` + + #### After + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.invalidate(this as any, pk); + } + ``` + +- [#3454](https://github.com/reactive/data-client/pull/3454) [`66e1906`](https://github.com/reactive/data-client/commit/66e19064d21225c70639f3b4799e54c259ce6905) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: MemoCache.query() and MemoCache.buildQueryKey() take state as one argument + + #### Before + + ```ts + this.memo.buildQueryKey(schema, args, state.entities, state.indexes, key); + ``` + + #### After + + ```ts + this.memo.buildQueryKey(schema, args, state, key); + ``` + + #### Before + + ```ts + this.memo.query(schema, args, state.entities, state.indexes); + ``` + + #### After + + ```ts + this.memo.query(schema, args, state); + ``` + +- [#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) + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + ```ts + /** Helpers during schema.normalize() */ + export interface INormalizeDelegate { + /** Action meta-data for this normalize call */ + readonly meta: { fetchedAt: number; date: number; expiresAt: number }; + /** Gets any previously normalized entity from store */ + getEntity: GetEntity; + /** Updates an entity using merge lifecycles when it has previously been set */ + mergeEntity( + schema: Mergeable & { indexes?: any }, + pk: string, + incomingEntity: any, + ): void; + /** Sets an entity overwriting any previously set values */ + setEntity( + schema: { key: string; indexes?: any }, + pk: string, + entity: any, + meta?: { fetchedAt: number; date: number; expiresAt: number }, + ): void; + /** Returns true when we're in a cycle, so we should not continue recursing */ + checkLoop(key: string, pk: string, input: object): boolean; + } + ``` + + #### Before + + ```ts + addEntity(this, processedEntity, id); + ``` + + #### After + + ```ts + delegate.mergeEntity(this, id, processedEntity); + ``` + +- [#3468](https://github.com/reactive/data-client/pull/3468) [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895) Thanks [@ntucker](https://github.com/ntucker)! - delegate.getEntity(key) -> delegate.getEntities(this.key) + + Return value is a restricted interface with keys() and entries() iterator methods. + This applies to both schema.queryKey and schema.normalize method delegates. + + ```ts + const entities = delegate.getEntities(key); + + // foreach on keys + for (const key of entities.keys()) { + } + // Object.keys() (convert to array) + return [...entities.keys()]; + // foreach on full entry + for (const [key, entity] of entities.entries()) { + } + ``` + + #### Before + + ```ts + const entities = delegate.getEntity(this.key); + if (entities) + Object.keys(entities).forEach(collectionPk => { + if (!filterCollections(JSON.parse(collectionPk))) return; + delegate.mergeEntity(this, collectionPk, normalizedValue); + }); + ``` + + #### After + + ```ts + const entities = delegate.getEntities(this.key); + if (entities) + for (const collectionKey of entities.keys()) { + if (!filterCollections(JSON.parse(collectionKey))) continue; + delegate.mergeEntity(this, collectionKey, normalizedValue); + } + ``` + +- [#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 + +- [#3372](https://github.com/reactive/data-client/pull/3372) [`25b153a`](https://github.com/reactive/data-client/commit/25b153a9d80db1bcd17ab5558dfa13b333f112b8) Thanks [@ntucker](https://github.com/ntucker)! - MemoCache.query returns `{ data, paths }` just like denormalize. `data` could be INVALID + + #### Before + + ```ts + return this.memo.query(schema, args, state); + ``` + + #### After + + ```ts + const { data } = this.memo.query(schema, args, state); + return typeof data === 'symbol' ? undefined : (data as any); + ``` + +- [#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) + BREAKING CHANGE: delegate.getIndex() returns the index directly, rather than object. + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + Our recursive call is renamed from queryKey to unvisit, and does not require the last two arguments. + + ```ts + /** Accessors to the currently processing state while building query */ + export interface IQueryDelegate { + getEntity: GetEntity; + getIndex: GetIndex; + } + ``` + + #### Before + + ```ts + queryKey(args, queryKey, getEntity, getIndex) { + getIndex(schema.key, indexName, value)[value]; + getEntity(this.key, id); + return queryKey(this.schema, args, getEntity, getIndex); + } + ``` + + #### After + + ```ts + queryKey(args, unvisit, delegate) { + delegate.getIndex(schema.key, indexName, value); + delegate.getEntity(this.key, id); + return unvisit(this.schema, args); + } + ``` + +### Patch Changes + +- [#3468](https://github.com/reactive/data-client/pull/3468) [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895) Thanks [@ntucker](https://github.com/ntucker)! - Add /imm exports path for handling ImmutableJS state + + #### MemoCache + + ```ts + import { MemoCache } from '@data-client/normalizr'; + import { MemoPolicy } from '@data-client/normalizr/imm'; + + const memo = new MemoCache(MemoPolicy); + + // entities is an ImmutableJS Map + const value = MemoCache.denormalize(Todo, '1', entities); + ``` + + #### denormalize + + non-memoized denormalize + + ```ts + import { denormalize } from '@data-client/normalizr/imm'; + + // entities is an ImmutableJS Map + const value = denormalize(Todo, '1', entities); + ``` + +- [#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. + + `indexes` optional param no longer provided as it was never used. + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.invalidate({ key: this._entity.key }, pk); + return pk; + } + ``` + +- [#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 + - 10-20% performance improvement due to removing immutablejs check for every call + ## 0.14.22 ### Patch Changes @@ -238,7 +528,6 @@ ### Minor Changes - [`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 - - `unvisit()` always returns `undefined` with `undefined` as input. - `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) @@ -440,7 +729,6 @@ ### Minor Changes - [#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 - - `[]` and [schema.Array](https://dataclient.io/rest/api/Array) now behave in the same manner. - `null` values are now consistently handled everywhere (being retained). - These were already being retained in [nested Entities](https://dataclient.io/rest/guides/relational-data#nesting) @@ -469,7 +757,6 @@ ### Patch Changes - [#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 - - Client packages namespace into RDC - @data-client/react - RDC - @data-client/core - RDC.Core @@ -494,7 +781,6 @@ ### Minor Changes - [#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: - - DELETE removed -> INVALIDATE - drop all support for legacy schemas - entity.expiresAt removed diff --git a/packages/normalizr/package.json b/packages/normalizr/package.json index 708fcf9cb0d6..9d3aa359f2e3 100644 --- a/packages/normalizr/package.json +++ b/packages/normalizr/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/normalizr", - "version": "0.14.22", + "version": "0.15.0", "description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications", "homepage": "https://dataclient.io/docs/concepts/normalization", "keywords": [ diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index b4c21df345f2..544b3e2e6a87 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -1,5 +1,150 @@ # @data-client/react +## 0.15.0 + +### Minor Changes + +- [#3459](https://github.com/reactive/data-client/pull/3459) [`997ca20`](https://github.com/reactive/data-client/commit/997ca209d36e8503ab7684bccc6ddc29d179a0b5) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: useDebounce() returns [val, isPending] + + This was previously exported in `@data-client/react/next` to make migrations easy. This will + still be available there. + + #### Before + + ```ts + import { useDebounce } from '@data-client/react'; + const debouncedQuery = useDebounce(query, 100); + ``` + + #### After + + ```ts + import { useDebounce } from '@data-client/react'; + const [debouncedQuery] = useDebounce(query, 100); + ``` + + #### Before + + ```ts + import { useDebounce } from '@data-client/react/next'; + const [debouncedQuery, isPending] = useDebounce(query, 100); + ``` + + #### After + + ```ts + import { useDebounce } from '@data-client/react'; + const [debouncedQuery, isPending] = useDebounce(query, 100); + ``` + +- [#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) + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + ```ts + /** Helpers during schema.normalize() */ + export interface INormalizeDelegate { + /** Action meta-data for this normalize call */ + readonly meta: { fetchedAt: number; date: number; expiresAt: number }; + /** Gets any previously normalized entity from store */ + getEntity: GetEntity; + /** Updates an entity using merge lifecycles when it has previously been set */ + mergeEntity( + schema: Mergeable & { indexes?: any }, + pk: string, + incomingEntity: any, + ): void; + /** Sets an entity overwriting any previously set values */ + setEntity( + schema: { key: string; indexes?: any }, + pk: string, + entity: any, + meta?: { fetchedAt: number; date: number; expiresAt: number }, + ): void; + /** Returns true when we're in a cycle, so we should not continue recursing */ + checkLoop(key: string, pk: string, input: object): boolean; + } + ``` + + #### Before + + ```ts + addEntity(this, processedEntity, id); + ``` + + #### After + + ```ts + delegate.mergeEntity(this, id, processedEntity); + ``` + +- [#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 + +- [#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) + BREAKING CHANGE: delegate.getIndex() returns the index directly, rather than object. + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + Our recursive call is renamed from queryKey to unvisit, and does not require the last two arguments. + + ```ts + /** Accessors to the currently processing state while building query */ + export interface IQueryDelegate { + getEntity: GetEntity; + getIndex: GetIndex; + } + ``` + + #### Before + + ```ts + queryKey(args, queryKey, getEntity, getIndex) { + getIndex(schema.key, indexName, value)[value]; + getEntity(this.key, id); + return queryKey(this.schema, args, getEntity, getIndex); + } + ``` + + #### After + + ```ts + queryKey(args, unvisit, delegate) { + delegate.getIndex(schema.key, indexName, value); + delegate.getEntity(this.key, id); + return unvisit(this.schema, args); + } + ``` + +### Patch Changes + +- [#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 + +- [#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. + + `indexes` optional param no longer provided as it was never used. + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.invalidate({ key: this._entity.key }, pk); + return pk; + } + ``` + +- [#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 + - 10-20% performance improvement due to removing immutablejs check for every call + +- [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8) Thanks [@ntucker](https://github.com/ntucker)! - Include GPT link badge in readme + +- Updated dependencies [[`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`4939456`](https://github.com/reactive/data-client/commit/4939456598c213ee81c1abef476a1aaccd19f82d), [`d44d36a`](https://github.com/reactive/data-client/commit/d44d36a7de0a18817486c4f723bf2f0e86ac9677), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7)]: + - @data-client/core@0.15.0 + ## 0.14.25 ### Patch Changes @@ -408,7 +553,6 @@ - [`d84b43c`](https://github.com/reactive/data-client/commit/d84b43cf728d714da7182f2c19b39f49e0ec0366) Thanks [@ntucker](https://github.com/ntucker)! - Move NetworkManager missing detection to initialization (applyManager()) - [`06df291`](https://github.com/reactive/data-client/commit/06df291a1f1d91afa331310dfb8319bc8d1a3ba8) Thanks [@ntucker](https://github.com/ntucker)! - Reorder action members for easier debuggability - - `key` at top - easiest to read 'subject' - `response` or `value` after - 'object' being set @@ -734,7 +878,6 @@ ``` BREAKING CHANGE: - - actionTypes.SET_TYPE -> actionTypes.SET_RESPONSE_TYPE - SetAction -> SetResponseAction @@ -1169,7 +1312,6 @@ ### Patch Changes - [`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 - - `unvisit()` always returns `undefined` with `undefined` as input. - `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) @@ -1190,7 +1332,6 @@ ### Minor Changes - [#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 - - `[]` and [schema.Array](https://dataclient.io/rest/api/Array) now behave in the same manner. - `null` values are now consistently handled everywhere (being retained). - These were already being retained in [nested Entities](https://dataclient.io/rest/guides/relational-data#nesting) @@ -1245,7 +1386,6 @@ ### Patch Changes - [#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 - - Client packages namespace into RDC - @data-client/react - RDC - @data-client/core - RDC.Core @@ -1357,7 +1497,6 @@ ``` - [#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: - - DELETE removed -> INVALIDATE - drop all support for legacy schemas - entity.expiresAt removed @@ -1367,7 +1506,6 @@ - [#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) BREAKING CHANGE: - - remove ReceiveAction - ReceiveTypes -> SetTypes - remove Controller.receive Controller.receiveError diff --git a/packages/react/package.json b/packages/react/package.json index 9181b5958a0d..210e77633fdb 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/react", - "version": "0.14.25", + "version": "0.15.0", "description": "Async State Management without the Management. REST, GraphQL, SSE, Websockets, Fetch", "homepage": "https://dataclient.io", "repository": { diff --git a/packages/rest/CHANGELOG.md b/packages/rest/CHANGELOG.md index 46f019d836cc..7512f71b1a7d 100644 --- a/packages/rest/CHANGELOG.md +++ b/packages/rest/CHANGELOG.md @@ -1,5 +1,203 @@ # @data-client/rest +## 0.15.0 + +### Minor Changes + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Add delegate.INVALID to queryKey + + This is used in schema.All.queryKey(). + + #### Before + + ```ts + queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { + if (!found) return INVALID; + } + ``` + + #### After + + ```ts + queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { + if (!found) return delegate.INVALID; + } + ``` + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Add delegate.invalidate() to normalization + + #### Before + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.setEntity(this as any, pk, INVALID); + } + ``` + + #### After + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.invalidate(this as any, pk); + } + ``` + +- [#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) + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + ```ts + /** Helpers during schema.normalize() */ + export interface INormalizeDelegate { + /** Action meta-data for this normalize call */ + readonly meta: { fetchedAt: number; date: number; expiresAt: number }; + /** Gets any previously normalized entity from store */ + getEntity: GetEntity; + /** Updates an entity using merge lifecycles when it has previously been set */ + mergeEntity( + schema: Mergeable & { indexes?: any }, + pk: string, + incomingEntity: any, + ): void; + /** Sets an entity overwriting any previously set values */ + setEntity( + schema: { key: string; indexes?: any }, + pk: string, + entity: any, + meta?: { fetchedAt: number; date: number; expiresAt: number }, + ): void; + /** Returns true when we're in a cycle, so we should not continue recursing */ + checkLoop(key: string, pk: string, input: object): boolean; + } + ``` + + #### Before + + ```ts + addEntity(this, processedEntity, id); + ``` + + #### After + + ```ts + delegate.mergeEntity(this, id, processedEntity); + ``` + +- [#3461](https://github.com/reactive/data-client/pull/3461) [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2) Thanks [@ntucker](https://github.com/ntucker)! - Remove `INVALID` symbol export + + Schemas can use delegate.invalidate() in normalize() or return delegate.INVALID in queryKey(). + +- [#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) + BREAKING CHANGE: delegate.getIndex() returns the index directly, rather than object. + + We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument. + + Our recursive call is renamed from queryKey to unvisit, and does not require the last two arguments. + + ```ts + /** Accessors to the currently processing state while building query */ + export interface IQueryDelegate { + getEntity: GetEntity; + getIndex: GetIndex; + } + ``` + + #### Before + + ```ts + queryKey(args, queryKey, getEntity, getIndex) { + getIndex(schema.key, indexName, value)[value]; + getEntity(this.key, id); + return queryKey(this.schema, args, getEntity, getIndex); + } + ``` + + #### After + + ```ts + queryKey(args, unvisit, delegate) { + delegate.getIndex(schema.key, indexName, value); + delegate.getEntity(this.key, id); + return unvisit(this.schema, args); + } + ``` + +### Patch Changes + +- [#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: ensure string id in Entity set when process returns undefined (meaning INVALID) + +- [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed) Thanks [@ntucker](https://github.com/ntucker)! - fix: Collection.remove with Unions + +- [#3560](https://github.com/reactive/data-client/pull/3560) [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290) Thanks [@ntucker](https://github.com/ntucker)! - Add Collection.remove + + ```ts + ctrl.set(MyResource.getList.schema.remove, { id }); + ``` + + ```ts + const removeItem = MyResource.delete.extend({ + schema: MyResource.getList.schema.remove, + }); + ``` + +- [#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. + + `indexes` optional param no longer provided as it was never used. + + ```ts + normalize( + input: any, + parent: any, + key: string | undefined, + args: any[], + visit: (...args: any) => any, + delegate: INormalizeDelegate, + ): string { + delegate.invalidate({ key: this._entity.key }, pk); + return pk; + } + ``` + +- [#3558](https://github.com/reactive/data-client/pull/3558) [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f) Thanks [@ntucker](https://github.com/ntucker)! - Unions can query() without type discriminator + + #### Before + + ```tsx + // @ts-expect-error + const event = useQuery(EventUnion, { id }); + // event is undefined + const newsEvent = useQuery(EventUnion, { id, type: 'news' }); + // newsEvent is found + ``` + + #### After + + ```tsx + const event = useQuery(EventUnion, { id }); + // event is found + const newsEvent = useQuery(EventUnion, { id, type: 'news' }); + // newsEvent is found + ``` + +- [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8) Thanks [@ntucker](https://github.com/ntucker)! - Include GPT link badge in readme + +- Updated dependencies [[`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`ba31c9b`](https://github.com/reactive/data-client/commit/ba31c9b2d3c4ec5620bb64e49daf9b18994b9290), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`bab907c`](https://github.com/reactive/data-client/commit/bab907ce824c0f7da961d74c9fb8b64ce7c95141), [`5699005`](https://github.com/reactive/data-client/commit/5699005700206306bc70ff8237bf7ceaac241b82), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`35552c7`](https://github.com/reactive/data-client/commit/35552c716e3b688d69212654f9f95a05ea26a7f8)]: + - @data-client/endpoint@0.15.0 + ## 0.14.25 ### Patch Changes @@ -480,7 +678,6 @@ ### Patch Changes - [#3017](https://github.com/reactive/data-client/pull/3017) [`ce164d2`](https://github.com/reactive/data-client/commit/ce164d286c8afcb2593a86abbf23948a08aa40ba) Thanks [@ntucker](https://github.com/ntucker)! - Queries pass-through suspense rather than ever being undefined - - [useSuspense()](https://dataclient.io/docs/api/useSuspense) return values will not be nullable - [useQuery()](https://dataclient.io/docs/api/useQuery) will still be nullable due to it handling `INVALID` as `undefined` return - [Query.process](https://dataclient.io/rest/api/Query#process) does not need to handle nullable cases @@ -629,7 +826,6 @@ ### Patch Changes - [`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 - - `unvisit()` always returns `undefined` with `undefined` as input. - `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) @@ -745,7 +941,6 @@ ### Patch Changes - [#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 - - Client packages namespace into RDC - @data-client/react - RDC - @data-client/core - RDC.Core @@ -785,7 +980,6 @@ - [`664d3eacff`](https://github.com/reactive/data-client/commit/664d3eacff08c3c75e8ed7c3ccc64ee21faa6f7f) Thanks [@ntucker](https://github.com/ntucker)! - Remove dev warning for old versions of client - [#2799](https://github.com/reactive/data-client/pull/2799) [`26a3843d1b`](https://github.com/reactive/data-client/commit/26a3843d1b61900c385d8626d7062d6f0424c137) Thanks [@ntucker](https://github.com/ntucker)! - Removed some forms of automatic entity validation - - Now allow missing schemas making it easier to declare partials - Removed logic for certain keys found out of defaults diff --git a/packages/rest/package.json b/packages/rest/package.json index 672e2a36fad7..92480e347d8f 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/rest", - "version": "0.14.25", + "version": "0.15.0", "description": "Quickly define typed REST resources and endpoints", "homepage": "https://dataclient.io/rest", "repository": { diff --git a/packages/test/CHANGELOG.md b/packages/test/CHANGELOG.md index 4d8251c10107..3e694d9d4b4c 100644 --- a/packages/test/CHANGELOG.md +++ b/packages/test/CHANGELOG.md @@ -1,5 +1,28 @@ # @data-client/test +## 0.15.0 + +### Minor Changes + +- [#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 + + BREAKING CHANGE: NetworkManager.fetched, NetworkManager.rejectors, NetworkManager.resolvers, NetworkManager.fetchedAt + -> NetworkManager.fetching + + #### Before + + ```ts + if (action.key in this.fetched) + ``` + + #### After + + ```ts + if (this.fetching.has(action.key)) + ``` + +- [`769cb78`](https://github.com/reactive/data-client/commit/769cb78966aed032c90864c701dae2bac0cc1e4d) Thanks [@ntucker](https://github.com/ntucker)! - Support 0.15 of @data-client/react + ## 0.14.22 ### Patch Changes diff --git a/packages/test/package.json b/packages/test/package.json index 410cb23ba6be..be095077aacb 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/test", - "version": "0.14.22", + "version": "0.15.0", "description": "Testing utilities for Data Client", "homepage": "https://dataclient.io/docs/guides/storybook", "repository": { diff --git a/packages/vue/CHANGELOG.md b/packages/vue/CHANGELOG.md new file mode 100644 index 000000000000..d789c091fc55 --- /dev/null +++ b/packages/vue/CHANGELOG.md @@ -0,0 +1,89 @@ +# @data-client/vue + +## 0.4.0 + +### Minor Changes + +- [`733091f`](https://github.com/reactive/data-client/commit/733091f09b503ef7bb7d435a1d86dd7cbcfd96bb) Thanks [@ntucker](https://github.com/ntucker)! - Never wrap renderDataCompose().result in ref. Just passthrough the return value directly. Always. + + ### Before + + ```ts + const { result, cleanup } = await renderDataCompose(() => + useSuspense(CoolerArticleResource.get, { id: payload.id }), + ); + + const articleRef = await result.value; + expect(articleRef.value.title).toBe(payload.title); + expect(articleRef.value.content).toBe(payload.content); + ``` + + ### After + + ```ts + const { result, cleanup } = await renderDataCompose(() => + useSuspense(CoolerArticleResource.get, { id: payload.id }), + ); + + const articleRef = await result; + expect(articleRef.value.title).toBe(payload.title); + expect(articleRef.value.content).toBe(payload.content); + ``` + +- [`354b44c`](https://github.com/reactive/data-client/commit/354b44ca60a95cca64619d19c3314090d8edb29e) Thanks [@ntucker](https://github.com/ntucker)! - @data-client/vue first release + +- [#3591](https://github.com/reactive/data-client/pull/3591) [`aecd59b`](https://github.com/reactive/data-client/commit/aecd59becae7fb722eee4bd5035f2a654e75d5d8) Thanks [@ntucker](https://github.com/ntucker)! - `renderDataCompose()` awaits until the composable runs + + ### Before + + ```ts + const { result, cleanup } = renderDataCompose(() => + useCache(CoolerArticleResource.get, { id: payload.id }), + ); + + // Wait for initial render + await waitForNextUpdate(); + + expect(result.current).toBeDefined(); + ``` + + ### After + + ```ts + const { result, cleanup } = await renderDataCompose(() => + useCache(CoolerArticleResource.get, { id: payload.id }), + ); + + expect(result.value).toBeDefined(); + ``` + +- [#3591](https://github.com/reactive/data-client/pull/3591) [`aecd59b`](https://github.com/reactive/data-client/commit/aecd59becae7fb722eee4bd5035f2a654e75d5d8) Thanks [@ntucker](https://github.com/ntucker)! - `renderDataCompose().result` is now simply passes the composable result if it's a ref, or wraps it as computable ref + +- [#3592](https://github.com/reactive/data-client/pull/3592) [`4c9465b`](https://github.com/reactive/data-client/commit/4c9465bdcb139d79ca7205925e93fc45d37f3281) Thanks [@ntucker](https://github.com/ntucker)! - Add useDLE() + + ```ts + const { date, loading, error } = useDLE( + CoolerArticleResource.get, + computed(() => (props.id !== null ? { id: props.id } : null)), + ); + ``` + +### Patch Changes + +- [`d52fa38`](https://github.com/reactive/data-client/commit/d52fa38115950db8d3f3fde2d364c9f0ad8aaf65) Thanks [@ntucker](https://github.com/ntucker)! - Fixed race condition in useSuspense() where args change while initial suspense is not complete + +- [#3584](https://github.com/reactive/data-client/pull/3584) [`6809480`](https://github.com/reactive/data-client/commit/68094805498056ff3353507478908b87bb03209a) Thanks [@ntucker](https://github.com/ntucker)! - Only run manager start/stop for app lifecycle - not every component mount + +- [`eae4fe4`](https://github.com/reactive/data-client/commit/eae4fe4004ff506a020fac0ca7b322d7eda0aac2) Thanks [@ntucker](https://github.com/ntucker)! - renderDataClient -> renderDataCompose + + This keeps naming conventions closer to the React version + +- [#3585](https://github.com/reactive/data-client/pull/3585) [`7408964`](https://github.com/reactive/data-client/commit/7408964419152da48cfb4ac13221aa1009796bea) Thanks [@ntucker](https://github.com/ntucker)! - renderDataClient -> mountDataClient + renderDataComposable -> renderDataClient + +- [#3585](https://github.com/reactive/data-client/pull/3585) [`7408964`](https://github.com/reactive/data-client/commit/7408964419152da48cfb4ac13221aa1009796bea) Thanks [@ntucker](https://github.com/ntucker)! - Make composables reactive to computed props + +- [#3585](https://github.com/reactive/data-client/pull/3585) [`7408964`](https://github.com/reactive/data-client/commit/7408964419152da48cfb4ac13221aa1009796bea) Thanks [@ntucker](https://github.com/ntucker)! - Add useCache() + +- Updated dependencies [[`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`4939456`](https://github.com/reactive/data-client/commit/4939456598c213ee81c1abef476a1aaccd19f82d), [`d44d36a`](https://github.com/reactive/data-client/commit/d44d36a7de0a18817486c4f723bf2f0e86ac9677), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7)]: + - @data-client/core@0.15.0 diff --git a/packages/vue/package.json b/packages/vue/package.json index d72ff600c106..bfc7af19999b 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/vue", - "version": "0.3.1", + "version": "0.4.0", "description": "Async State Management without the Management. REST, GraphQL, SSE, Websockets, Fetch", "homepage": "https://dataclient.io", "repository": {