From 91e65894e3909c543624b4af0622debbcc9776ed Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 03:26:26 +0000 Subject: [PATCH] internal: Publish new version --- .changeset/big-impalas-tap.md | 28 -- .changeset/brave-bats-itch.md | 9 - .changeset/breezy-humans-go.md | 19 -- .changeset/chilly-towns-run.md | 27 -- .changeset/clever-geckos-smash.md | 5 - .changeset/clever-houses-beam.md | 11 - .changeset/cold-walls-like.md | 6 - .changeset/cuddly-masks-yawn.md | 5 - .changeset/dirty-regions-dance.md | 5 - .changeset/forty-masks-join.md | 7 - .changeset/gentle-heads-rule.md | 68 ---- .changeset/giant-cycles-follow.md | 7 - .changeset/grumpy-dogs-decide.md | 36 -- .changeset/icy-hairs-go.md | 28 -- .changeset/invalidate-union-support.md | 26 -- .changeset/kind-garlics-poke.md | 5 - .changeset/large-walls-accept.md | 7 - .changeset/legal-files-fly.md | 24 -- .changeset/lucky-paws-jog.md | 16 - .changeset/major-boxes-glow.md | 26 -- .changeset/nice-teams-lose.md | 21 -- .changeset/open-shrimps-warn.md | 38 --- .changeset/performance-optimizations.md | 10 - .changeset/pink-waves-judge.md | 17 - .changeset/plenty-regions-visit.md | 27 -- .changeset/plenty-sloths-battle.md | 6 - .changeset/poor-jobs-turn.md | 41 --- .changeset/proud-insects-smile.md | 49 --- .changeset/proud-rooms-pick.md | 5 - .changeset/proud-taxes-bake.md | 42 --- .changeset/shiny-olives-behave.md | 5 - .changeset/shy-bugs-melt.md | 28 -- .changeset/sixty-monkeys-open.md | 7 - .changeset/small-wasps-win.md | 5 - .changeset/smart-dodos-hear.md | 5 - .changeset/smooth-rice-switch.md | 5 - .changeset/sour-horses-give.md | 22 -- .changeset/stale-socks-accept.md | 18 - .changeset/ten-lions-retire.md | 9 - .changeset/thirty-dolls-wear.md | 5 - .changeset/thirty-islands-hope.md | 8 - .changeset/tiny-wolves-thank.md | 5 - .changeset/tough-areas-show.md | 9 - .changeset/tricky-olives-wash.md | 12 - .changeset/two-bees-scream.md | 6 - .changeset/weak-grapes-kiss.md | 25 -- .changeset/wicked-bags-appear.md | 43 --- .changeset/wicked-feet-cheat.md | 7 - examples/benchmark/CHANGELOG.md | 9 + examples/benchmark/package.json | 2 +- examples/normalizr-github/CHANGELOG.md | 8 + examples/normalizr-github/package.json | 2 +- examples/normalizr-redux/CHANGELOG.md | 8 + examples/normalizr-redux/package.json | 2 +- examples/normalizr-relationships/CHANGELOG.md | 8 + examples/normalizr-relationships/package.json | 2 +- examples/test-bundlesize/CHANGELOG.md | 10 + examples/test-bundlesize/package.json | 2 +- packages/core/CHANGELOG.md | 157 ++++++++- packages/core/package.json | 2 +- packages/endpoint/CHANGELOG.md | 271 ++++++++++++++- packages/endpoint/package.json | 2 +- packages/graphql/CHANGELOG.md | 222 ++++++++++++- packages/graphql/package.json | 2 +- packages/img/CHANGELOG.md | 14 +- packages/img/package.json | 2 +- packages/normalizr/CHANGELOG.md | 314 +++++++++++++++++- packages/normalizr/package.json | 2 +- packages/react/CHANGELOG.md | 169 +++++++++- packages/react/package.json | 2 +- packages/rest/CHANGELOG.md | 267 ++++++++++++++- packages/rest/package.json | 2 +- packages/test/CHANGELOG.md | 27 ++ packages/test/package.json | 2 +- packages/vue/CHANGELOG.md | 160 +++++++++ packages/vue/package.json | 2 +- 76 files changed, 1626 insertions(+), 891 deletions(-) delete mode 100644 .changeset/big-impalas-tap.md delete mode 100644 .changeset/brave-bats-itch.md delete mode 100644 .changeset/breezy-humans-go.md delete mode 100644 .changeset/chilly-towns-run.md delete mode 100644 .changeset/clever-geckos-smash.md delete mode 100644 .changeset/clever-houses-beam.md delete mode 100644 .changeset/cold-walls-like.md delete mode 100644 .changeset/cuddly-masks-yawn.md delete mode 100644 .changeset/dirty-regions-dance.md delete mode 100644 .changeset/forty-masks-join.md delete mode 100644 .changeset/gentle-heads-rule.md delete mode 100644 .changeset/giant-cycles-follow.md delete mode 100644 .changeset/grumpy-dogs-decide.md delete mode 100644 .changeset/icy-hairs-go.md delete mode 100644 .changeset/invalidate-union-support.md delete mode 100644 .changeset/kind-garlics-poke.md delete mode 100644 .changeset/large-walls-accept.md delete mode 100644 .changeset/legal-files-fly.md delete mode 100644 .changeset/lucky-paws-jog.md delete mode 100644 .changeset/major-boxes-glow.md delete mode 100644 .changeset/nice-teams-lose.md delete mode 100644 .changeset/open-shrimps-warn.md delete mode 100644 .changeset/performance-optimizations.md delete mode 100644 .changeset/pink-waves-judge.md delete mode 100644 .changeset/plenty-regions-visit.md delete mode 100644 .changeset/plenty-sloths-battle.md delete mode 100644 .changeset/poor-jobs-turn.md delete mode 100644 .changeset/proud-insects-smile.md delete mode 100644 .changeset/proud-rooms-pick.md delete mode 100644 .changeset/proud-taxes-bake.md delete mode 100644 .changeset/shiny-olives-behave.md delete mode 100644 .changeset/shy-bugs-melt.md delete mode 100644 .changeset/sixty-monkeys-open.md delete mode 100644 .changeset/small-wasps-win.md delete mode 100644 .changeset/smart-dodos-hear.md delete mode 100644 .changeset/smooth-rice-switch.md delete mode 100644 .changeset/sour-horses-give.md delete mode 100644 .changeset/stale-socks-accept.md delete mode 100644 .changeset/ten-lions-retire.md delete mode 100644 .changeset/thirty-dolls-wear.md delete mode 100644 .changeset/thirty-islands-hope.md delete mode 100644 .changeset/tiny-wolves-thank.md delete mode 100644 .changeset/tough-areas-show.md delete mode 100644 .changeset/tricky-olives-wash.md delete mode 100644 .changeset/two-bees-scream.md delete mode 100644 .changeset/weak-grapes-kiss.md delete mode 100644 .changeset/wicked-bags-appear.md delete mode 100644 .changeset/wicked-feet-cheat.md create mode 100644 examples/test-bundlesize/CHANGELOG.md create mode 100644 packages/vue/CHANGELOG.md 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/breezy-humans-go.md b/.changeset/breezy-humans-go.md deleted file mode 100644 index 8e7ea9013f46..000000000000 --- a/.changeset/breezy-humans-go.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -'@data-client/core': patch -'@data-client/react': patch ---- - -Add mockInitialState to /mock - -```ts -import { mockInitialState } from '@data-client/react/mock'; -import { ArticleResource } from './resources'; - -const state = mockInitialState([ - { - endpoint: ArticleResource.get, - args: [{ id: 5 }], - response: { id: 5, title: 'Hello', content: 'World' }, - }, -]); -``` 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/clever-houses-beam.md b/.changeset/clever-houses-beam.md deleted file mode 100644 index de00afc41ad5..000000000000 --- a/.changeset/clever-houses-beam.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -'@data-client/core': patch ---- - -Add @data-client/core/mock - -New exports: -- `MockController` - Controller wrapper for mocking endpoints -- `collapseFixture` - Resolves fixture responses (handles function responses) -- `createFixtureMap` - Separates fixtures into static map and interceptors -- Types: `MockProps`, `Fixture`, `SuccessFixture`, `ErrorFixture`, `Interceptor`, `ResponseInterceptor`, `FetchInterceptor`, `FixtureEndpoint`, `SuccessFixtureEndpoint`, `ErrorFixtureEndpoint` 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/gentle-heads-rule.md b/.changeset/gentle-heads-rule.md deleted file mode 100644 index 62bd3dbb2731..000000000000 --- a/.changeset/gentle-heads-rule.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -'@data-client/vue': patch ---- - -Add MockPlugin - -Example usage: - -```ts -import { createApp } from 'vue'; -import { DataClientPlugin } from '@data-client/vue'; -import { MockPlugin } from '@data-client/vue/test'; - -const app = createApp(App); -app.use(DataClientPlugin); -app.use(MockPlugin, { - fixtures: [ - { - endpoint: MyResource.get, - args: [{ id: 1 }], - response: { id: 1, name: 'Test' }, - }, - ], -}); -app.mount('#app'); -``` - -Interceptors allow dynamic responses based on request arguments: - -```ts -app.use(MockPlugin, { - fixtures: [ - { - endpoint: MyResource.get, - response: (...args) => { - const [{ id }] = args; - return { - id, - name: `Dynamic ${id}`, - }; - }, - }, - ], -}); -``` - -Interceptors can also maintain state across calls: - -```ts -const interceptorData = { count: 0 }; - -app.use(MockPlugin, { - fixtures: [ - { - endpoint: MyResource.get, - response: function (this: { count: number }, ...args) { - this.count++; - const [{ id }] = args; - return { - id, - name: `Call ${this.count}`, - }; - }, - }, - ], - getInitialInterceptorData: () => interceptorData, -}); -``` 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/invalidate-union-support.md b/.changeset/invalidate-union-support.md deleted file mode 100644 index 8b07a9bdc4bd..000000000000 --- a/.changeset/invalidate-union-support.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -'@data-client/endpoint': minor -'@data-client/rest': minor -'@data-client/graphql': minor ---- - -Add [Union](https://dataclient.io/rest/api/Union) support to [schema.Invalidate](https://dataclient.io/rest/api/Invalidate) -and [resource().delete](https://dataclient.io/rest/api/resource#delete) for polymorphic delete operations. - -[resource()](https://dataclient.io/rest/api/resource) with Union schema now automatically -wraps the delete endpoint schema in Invalidate: - -```ts -const FeedResource = resource({ - path: '/feed/:id', - schema: FeedUnion, // Union of Post, Comment, etc. -}); -// FeedResource.delete automatically uses Invalidate(FeedUnion) -await ctrl.fetch(FeedResource.delete, { id: '123' }); -``` - -For standalone endpoints, use `schema.Invalidate` directly: - -```ts -new schema.Invalidate(MyUnionSchema) -``` 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/lucky-paws-jog.md b/.changeset/lucky-paws-jog.md deleted file mode 100644 index 6863e7483025..000000000000 --- a/.changeset/lucky-paws-jog.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -'@data-client/rest': patch ---- - -Fix `getPage` types when paginationField is in body - -```ts -const ep = new RestEndpoint({ - path: '/rpc', - method: 'POST', - body: {} as { page?: number; method: string }, - paginationField: 'page', -}); -// Before: ep.getPage({ page: 2 }, { method: 'get' }) ❌ -// After: ep.getPage({ page: 2, method: 'get' }) ✓ -``` 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/nice-teams-lose.md b/.changeset/nice-teams-lose.md deleted file mode 100644 index 102533f01c45..000000000000 --- a/.changeset/nice-teams-lose.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -'@data-client/normalizr': minor ---- - -Add `normalize()` to `@data-client/normalizr/imm` for ImmutableJS state - -New exports: -- `normalize` - Normalizes data directly into ImmutableJS Map structures -- `ImmNormalizeDelegate` - Delegate class for custom ImmutableJS normalization -- `ImmutableStoreData`, `ImmutableNormalizedSchema`, `ImmutableJSMutableTable` - Types - -```js -import { normalize } from '@data-client/normalizr/imm'; -import { fromJS } from 'immutable'; - -const result = normalize(Article, responseData, args, { - entities: fromJS({}), - indexes: fromJS({}), - entitiesMeta: fromJS({}), -}); -``` 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/performance-optimizations.md b/.changeset/performance-optimizations.md deleted file mode 100644 index 3c36472d11e7..000000000000 --- a/.changeset/performance-optimizations.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -'@data-client/endpoint': patch -'@data-client/normalizr': patch -'@data-client/rest': patch -'@data-client/graphql': patch -'@data-client/react': patch -'@data-client/vue': patch ---- - -Optimize normalization performance with faster loops and Set-based cycle detection 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/shy-bugs-melt.md b/.changeset/shy-bugs-melt.md deleted file mode 100644 index 6f75427977e2..000000000000 --- a/.changeset/shy-bugs-melt.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -'@data-client/rest': patch ---- - -Add RestEndpoint.remove - -Creates a PATCH endpoint that both removes an entity from a Collection and updates the entity with the provided body data. - -```ts -const getTodos = new RestEndpoint({ - path: '/todos', - schema: new schema.Collection([Todo]), -}); - -// Removes Todo from collection AND updates it with new data -await ctrl.fetch(getTodos.remove, {}, { id: '123', title: 'Done', completed: true }); -``` - -```ts -// Remove user from group list and update their group -await ctrl.fetch( - UserResource.getList.remove, - { group: 'five' }, - { id: 2, username: 'user2', group: 'newgroup' } -); -// User is removed from the 'five' group list -// AND the user entity is updated with group: 'newgroup' -``` 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/smooth-rice-switch.md b/.changeset/smooth-rice-switch.md deleted file mode 100644 index 82ab8f99a380..000000000000 --- a/.changeset/smooth-rice-switch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/test': patch ---- - -@testing-library/react-native as optional peerDep 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-dolls-wear.md b/.changeset/thirty-dolls-wear.md deleted file mode 100644 index 506d293b8a86..000000000000 --- a/.changeset/thirty-dolls-wear.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/vue': patch ---- - -Update README with MockPlugin 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/tiny-wolves-thank.md b/.changeset/tiny-wolves-thank.md deleted file mode 100644 index bc9e971a8f7c..000000000000 --- a/.changeset/tiny-wolves-thank.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@data-client/vue': patch ---- - -Improve dependency injection console message 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..d5918093ab2c 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), [`a4092a1`](https://github.com/reactive/data-client/commit/a4092a14999bfe3aa5cf613bb009264ec723ff99), [`ad3964d`](https://github.com/reactive/data-client/commit/ad3964d65d245c459809f64afe17ebdf5fda5042), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61), [`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), [`269b45e`](https://github.com/reactive/data-client/commit/269b45e835251cff847776078e51c0a593b62715), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f), [`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 445c7ea9a784..1ca5ba54c517 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..3124b5b33bc9 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), [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61), [`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), [`269b45e`](https://github.com/reactive/data-client/commit/269b45e835251cff847776078e51c0a593b62715), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f), [`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..c5a17a0f9563 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), [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61), [`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), [`269b45e`](https://github.com/reactive/data-client/commit/269b45e835251cff847776078e51c0a593b62715), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f), [`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 464e134ebed5..52a7af860f2d 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..bb36e650750b 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), [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61), [`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), [`269b45e`](https://github.com/reactive/data-client/commit/269b45e835251cff847776078e51c0a593b62715), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f), [`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..f7613627cfca --- /dev/null +++ b/examples/test-bundlesize/CHANGELOG.md @@ -0,0 +1,10 @@ +# test-bundlesize + +## 0.1.1 + +### Patch Changes + +- Updated dependencies [[`a4092a1`](https://github.com/reactive/data-client/commit/a4092a14999bfe3aa5cf613bb009264ec723ff99), [`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), [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61), [`e2fff91`](https://github.com/reactive/data-client/commit/e2fff911e21864620dba8d9470142af9130aafed), [`63ee107`](https://github.com/reactive/data-client/commit/63ee107be9d559e6ccbcb2f9c6fd7bf83165e551), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f), [`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), [`8be3b17`](https://github.com/reactive/data-client/commit/8be3b1725707c4bcbf0fdd6e72ddd78d85fd125f), [`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 e73f1e41dcbc..e453e9c8ec97 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.12.0", "description": "Testing Bundled Size", "scripts": { diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 3422ddf2937a..28043d770302 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,155 @@ # @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 + +- [`a4092a1`](https://github.com/reactive/data-client/commit/a4092a14999bfe3aa5cf613bb009264ec723ff99) Thanks [@ntucker](https://github.com/ntucker)! - Add mockInitialState to /mock + + ```ts + import { mockInitialState } from '@data-client/react/mock'; + import { ArticleResource } from './resources'; + + const state = mockInitialState([ + { + endpoint: ArticleResource.get, + args: [{ id: 5 }], + response: { id: 5, title: 'Hello', content: 'World' }, + }, + ]); + ``` + +- [#3622](https://github.com/reactive/data-client/pull/3622) [`ad3964d`](https://github.com/reactive/data-client/commit/ad3964d65d245c459809f64afe17ebdf5fda5042) Thanks [@ntucker](https://github.com/ntucker)! - Add @data-client/core/mock + + New exports: + - `MockController` - Controller wrapper for mocking endpoints + - `collapseFixture` - Resolves fixture responses (handles function responses) + - `createFixtureMap` - Separates fixtures into static map and interceptors + - Types: `MockProps`, `Fixture`, `SuccessFixture`, `ErrorFixture`, `Interceptor`, `ResponseInterceptor`, `FetchInterceptor`, `FixtureEndpoint`, `SuccessFixtureEndpoint`, `ErrorFixtureEndpoint` + +- [#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), [`269b45e`](https://github.com/reactive/data-client/commit/269b45e835251cff847776078e51c0a593b62715), [`939a4b0`](https://github.com/reactive/data-client/commit/939a4b01127ea1df9b4653931593487e4b0c23a2), [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f), [`fcb7d7d`](https://github.com/reactive/data-client/commit/fcb7d7db8061c2a7e12632071ecb9c6ddd8d154f), [`66e1906`](https://github.com/reactive/data-client/commit/66e19064d21225c70639f3b4799e54c259ce6905), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`4939456`](https://github.com/reactive/data-client/commit/4939456598c213ee81c1abef476a1aaccd19f82d), [`25b153a`](https://github.com/reactive/data-client/commit/25b153a9d80db1bcd17ab5558dfa13b333f112b8), [`4dde1d6`](https://github.com/reactive/data-client/commit/4dde1d616e38d59b645573b12bbaba2f9cac7895), [`1f491a9`](https://github.com/reactive/data-client/commit/1f491a9e0082dca64ad042aaf7d377e17f459ae7)]: + - @data-client/normalizr@0.15.0 + ## 0.14.24 ### Patch Changes @@ -266,7 +416,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 +730,6 @@ ``` BREAKING CHANGE: - - actionTypes.SET_TYPE -> actionTypes.SET_RESPONSE_TYPE - SetAction -> SetResponseAction @@ -759,7 +907,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 +927,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 +963,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 +1046,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 +1055,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 c86afa14e00e..9e964b61067a 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..7553979168dd 100644 --- a/packages/endpoint/CHANGELOG.md +++ b/packages/endpoint/CHANGELOG.md @@ -1,5 +1,270 @@ # @data-client/endpoint +## 0.15.0 + +### Minor Changes + +- [#3685](https://github.com/reactive/data-client/pull/3685) [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61) Thanks [@ntucker](https://github.com/ntucker)! - Add [Union](https://dataclient.io/rest/api/Union) support to [schema.Invalidate](https://dataclient.io/rest/api/Invalidate) + and [resource().delete](https://dataclient.io/rest/api/resource#delete) for polymorphic delete operations. + + [resource()](https://dataclient.io/rest/api/resource) with Union schema now automatically + wraps the delete endpoint schema in Invalidate: + + ```ts + const FeedResource = resource({ + path: '/feed/:id', + schema: FeedUnion, // Union of Post, Comment, etc. + }); + // FeedResource.delete automatically uses Invalidate(FeedUnion) + await ctrl.fetch(FeedResource.delete, { id: '123' }); + ``` + + For standalone endpoints, use `schema.Invalidate` directly: + + ```ts + new schema.Invalidate(MyUnionSchema); + ``` + +- [#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 + +- [#3684](https://github.com/reactive/data-client/pull/3684) [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f) Thanks [@ntucker](https://github.com/ntucker)! - Optimize normalization performance with faster loops and Set-based cycle detection + +- [#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 +580,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 +752,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 +842,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 +885,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 +917,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 +929,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..bd8fc493064c 100644 --- a/packages/graphql/CHANGELOG.md +++ b/packages/graphql/CHANGELOG.md @@ -1,5 +1,224 @@ # @data-client/graphql +## 0.15.0 + +### Minor Changes + +- [#3685](https://github.com/reactive/data-client/pull/3685) [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61) Thanks [@ntucker](https://github.com/ntucker)! - Add [Union](https://dataclient.io/rest/api/Union) support to [schema.Invalidate](https://dataclient.io/rest/api/Invalidate) + and [resource().delete](https://dataclient.io/rest/api/resource#delete) for polymorphic delete operations. + + [resource()](https://dataclient.io/rest/api/resource) with Union schema now automatically + wraps the delete endpoint schema in Invalidate: + + ```ts + const FeedResource = resource({ + path: '/feed/:id', + schema: FeedUnion, // Union of Post, Comment, etc. + }); + // FeedResource.delete automatically uses Invalidate(FeedUnion) + await ctrl.fetch(FeedResource.delete, { id: '123' }); + ``` + + For standalone endpoints, use `schema.Invalidate` directly: + + ```ts + new schema.Invalidate(MyUnionSchema); + ``` + +- [#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 + +- [#3684](https://github.com/reactive/data-client/pull/3684) [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f) Thanks [@ntucker](https://github.com/ntucker)! - Optimize normalization performance with faster loops and Set-based cycle detection + +- [#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), [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61), [`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), [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f), [`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 +574,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 +778,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 +817,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..47913ba9c430 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), [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61), [`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), [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f), [`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 ed931204ddc0..b50fbd3cafc4 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..59690bec973d 100644 --- a/packages/normalizr/CHANGELOG.md +++ b/packages/normalizr/CHANGELOG.md @@ -1,5 +1,315 @@ # 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; + } + ``` + +- [#3686](https://github.com/reactive/data-client/pull/3686) [`269b45e`](https://github.com/reactive/data-client/commit/269b45e835251cff847776078e51c0a593b62715) Thanks [@ntucker](https://github.com/ntucker)! - Add `normalize()` to `@data-client/normalizr/imm` for ImmutableJS state + + New exports: + - `normalize` - Normalizes data directly into ImmutableJS Map structures + - `ImmNormalizeDelegate` - Delegate class for custom ImmutableJS normalization + - `ImmutableStoreData`, `ImmutableNormalizedSchema`, `ImmutableJSMutableTable` - Types + + ```js + import { normalize } from '@data-client/normalizr/imm'; + import { fromJS } from 'immutable'; + + const result = normalize(Article, responseData, args, { + entities: fromJS({}), + indexes: fromJS({}), + entitiesMeta: fromJS({}), + }); + ``` + +- [#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); + ``` + +- [#3684](https://github.com/reactive/data-client/pull/3684) [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f) Thanks [@ntucker](https://github.com/ntucker)! - Optimize normalization performance with faster loops and Set-based cycle detection + +- [#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 +548,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 +749,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 +777,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 +801,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..af76440a2f90 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -1,5 +1,167 @@ # @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 + +- [`a4092a1`](https://github.com/reactive/data-client/commit/a4092a14999bfe3aa5cf613bb009264ec723ff99) Thanks [@ntucker](https://github.com/ntucker)! - Add mockInitialState to /mock + + ```ts + import { mockInitialState } from '@data-client/react/mock'; + import { ArticleResource } from './resources'; + + const state = mockInitialState([ + { + endpoint: ArticleResource.get, + args: [{ id: 5 }], + response: { id: 5, title: 'Hello', content: 'World' }, + }, + ]); + ``` + +- [#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 + +- [#3684](https://github.com/reactive/data-client/pull/3684) [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f) Thanks [@ntucker](https://github.com/ntucker)! - Optimize normalization performance with faster loops and Set-based cycle detection + +- [#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 [[`a4092a1`](https://github.com/reactive/data-client/commit/a4092a14999bfe3aa5cf613bb009264ec723ff99), [`ad3964d`](https://github.com/reactive/data-client/commit/ad3964d65d245c459809f64afe17ebdf5fda5042), [`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 +570,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 +895,6 @@ ``` BREAKING CHANGE: - - actionTypes.SET_TYPE -> actionTypes.SET_RESPONSE_TYPE - SetAction -> SetResponseAction @@ -1169,7 +1329,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 +1349,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 +1403,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 +1514,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 +1523,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 b64a4c6848c4..b61c1486b7ec 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..a571333dc112 100644 --- a/packages/rest/CHANGELOG.md +++ b/packages/rest/CHANGELOG.md @@ -1,5 +1,268 @@ # @data-client/rest +## 0.15.0 + +### Minor Changes + +- [#3685](https://github.com/reactive/data-client/pull/3685) [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61) Thanks [@ntucker](https://github.com/ntucker)! - Add [Union](https://dataclient.io/rest/api/Union) support to [schema.Invalidate](https://dataclient.io/rest/api/Invalidate) + and [resource().delete](https://dataclient.io/rest/api/resource#delete) for polymorphic delete operations. + + [resource()](https://dataclient.io/rest/api/resource) with Union schema now automatically + wraps the delete endpoint schema in Invalidate: + + ```ts + const FeedResource = resource({ + path: '/feed/:id', + schema: FeedUnion, // Union of Post, Comment, etc. + }); + // FeedResource.delete automatically uses Invalidate(FeedUnion) + await ctrl.fetch(FeedResource.delete, { id: '123' }); + ``` + + For standalone endpoints, use `schema.Invalidate` directly: + + ```ts + new schema.Invalidate(MyUnionSchema); + ``` + +- [#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 + +- [#3635](https://github.com/reactive/data-client/pull/3635) [`63ee107`](https://github.com/reactive/data-client/commit/63ee107be9d559e6ccbcb2f9c6fd7bf83165e551) Thanks [@ntucker](https://github.com/ntucker)! - Fix `getPage` types when paginationField is in body + + ```ts + const ep = new RestEndpoint({ + path: '/rpc', + method: 'POST', + body: {} as { page?: number; method: string }, + paginationField: 'page', + }); + // Before: ep.getPage({ page: 2 }, { method: 'get' }) ❌ + // After: ep.getPage({ page: 2, method: 'get' }) ✓ + ``` + +- [#3684](https://github.com/reactive/data-client/pull/3684) [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f) Thanks [@ntucker](https://github.com/ntucker)! - Optimize normalization performance with faster loops and Set-based cycle detection + +- [#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; + } + ``` + +- [#3623](https://github.com/reactive/data-client/pull/3623) [`8be3b17`](https://github.com/reactive/data-client/commit/8be3b1725707c4bcbf0fdd6e72ddd78d85fd125f) Thanks [@ntucker](https://github.com/ntucker)! - Add RestEndpoint.remove + + Creates a PATCH endpoint that both removes an entity from a Collection and updates the entity with the provided body data. + + ```ts + const getTodos = new RestEndpoint({ + path: '/todos', + schema: new schema.Collection([Todo]), + }); + + // Removes Todo from collection AND updates it with new data + await ctrl.fetch( + getTodos.remove, + {}, + { id: '123', title: 'Done', completed: true }, + ); + ``` + + ```ts + // Remove user from group list and update their group + await ctrl.fetch( + UserResource.getList.remove, + { group: 'five' }, + { id: 2, username: 'user2', group: 'newgroup' }, + ); + // User is removed from the 'five' group list + // AND the user entity is updated with group: 'newgroup' + ``` + +- [#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), [`56d575e`](https://github.com/reactive/data-client/commit/56d575e0219d5455df74321aee7bf85c2d490a61), [`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), [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f), [`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 +743,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 +891,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 +1006,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 +1045,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..1ba6225e754c 100644 --- a/packages/test/CHANGELOG.md +++ b/packages/test/CHANGELOG.md @@ -1,5 +1,32 @@ # @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 + +### Patch Changes + +- [#3663](https://github.com/reactive/data-client/pull/3663) [`73f5a61`](https://github.com/reactive/data-client/commit/73f5a614828c1bc1de660d3836c39a85e67b5a00) Thanks [@ntucker](https://github.com/ntucker)! - @testing-library/react-native as optional peerDep + ## 0.14.22 ### Patch Changes diff --git a/packages/test/package.json b/packages/test/package.json index 32e5b6adb5f8..cf66ee1f2558 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..538f3890e0ef --- /dev/null +++ b/packages/vue/CHANGELOG.md @@ -0,0 +1,160 @@ +# @data-client/vue + +## 0.15.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 + +- [#3622](https://github.com/reactive/data-client/pull/3622) [`ad3964d`](https://github.com/reactive/data-client/commit/ad3964d65d245c459809f64afe17ebdf5fda5042) Thanks [@ntucker](https://github.com/ntucker)! - Add MockPlugin + + Example usage: + + ```ts + import { createApp } from 'vue'; + import { DataClientPlugin } from '@data-client/vue'; + import { MockPlugin } from '@data-client/vue/test'; + + const app = createApp(App); + app.use(DataClientPlugin); + app.use(MockPlugin, { + fixtures: [ + { + endpoint: MyResource.get, + args: [{ id: 1 }], + response: { id: 1, name: 'Test' }, + }, + ], + }); + app.mount('#app'); + ``` + + Interceptors allow dynamic responses based on request arguments: + + ```ts + app.use(MockPlugin, { + fixtures: [ + { + endpoint: MyResource.get, + response: (...args) => { + const [{ id }] = args; + return { + id, + name: `Dynamic ${id}`, + }; + }, + }, + ], + }); + ``` + + Interceptors can also maintain state across calls: + + ```ts + const interceptorData = { count: 0 }; + + app.use(MockPlugin, { + fixtures: [ + { + endpoint: MyResource.get, + response: function (this: { count: number }, ...args) { + this.count++; + const [{ id }] = args; + return { + id, + name: `Call ${this.count}`, + }; + }, + }, + ], + getInitialInterceptorData: () => interceptorData, + }); + ``` + +- [`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 + +- [#3684](https://github.com/reactive/data-client/pull/3684) [`53de2ee`](https://github.com/reactive/data-client/commit/53de2eefb891a4783e3f1c7724dc25dc9e6a8e1f) Thanks [@ntucker](https://github.com/ntucker)! - Optimize normalization performance with faster loops and Set-based cycle detection + +- [#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() + +- [`1c945bb`](https://github.com/reactive/data-client/commit/1c945bbc4cd290a186914f16b9afd9e7501198ed) Thanks [@ntucker](https://github.com/ntucker)! - Update README with MockPlugin + +- [`b03fa99`](https://github.com/reactive/data-client/commit/b03fa99f1327e91ffad840b90d4ac5ef05a358d3) Thanks [@ntucker](https://github.com/ntucker)! - Improve dependency injection console message + +- Updated dependencies [[`a4092a1`](https://github.com/reactive/data-client/commit/a4092a14999bfe3aa5cf613bb009264ec723ff99), [`ad3964d`](https://github.com/reactive/data-client/commit/ad3964d65d245c459809f64afe17ebdf5fda5042), [`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 7d30349aa2f2..9b1db78aebf9 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/vue", - "version": "0.14.0", + "version": "0.15.0", "description": "Async State Management without the Management. REST, GraphQL, SSE, Websockets, Fetch", "homepage": "https://dataclient.io", "repository": {