From 4b4efed9517a2da145cdbe447ebfdead99f4a7f4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 8 Apr 2024 16:57:23 +0000 Subject: [PATCH] internal: Publish new version --- .changeset/brave-maps-talk.md | 12 - .changeset/brave-rockets-bake.md | 36 --- .changeset/five-flies-help.md | 5 - .changeset/fresh-rice-provide.md | 39 --- .changeset/funny-avocados-do.md | 5 - .changeset/funny-dragons-hammer.md | 8 - .changeset/gentle-nails-try.md | 14 - .changeset/great-geckos-breathe.md | 20 -- .changeset/little-carpets-drop.md | 38 --- .changeset/lovely-flies-buy.md | 5 - .changeset/mean-cougars-confess.md | 9 - .changeset/mean-mayflies-sleep.md | 5 - .changeset/nasty-items-count.md | 5 - .changeset/neat-moose-applaud.md | 5 - .changeset/nice-sloths-film.md | 8 - .changeset/old-zebras-bake.md | 11 - .changeset/plenty-crews-check.md | 19 -- .changeset/purple-pandas-confess.md | 43 --- .changeset/quick-flies-taste.md | 11 - .changeset/serious-dogs-battle.md | 48 ---- .changeset/sharp-ears-think.md | 35 --- .changeset/sour-apples-sneeze.md | 15 -- .changeset/strange-tomatoes-hunt.md | 16 -- .changeset/stupid-houses-itch.md | 5 - .changeset/sweet-coins-deliver.md | 54 ---- .changeset/thirty-ants-grin.md | 21 -- .changeset/thirty-cherries-melt.md | 18 -- .changeset/three-owls-notice.md | 8 - .changeset/tough-panthers-compare.md | 6 - .changeset/two-foxes-explode.md | 29 --- .changeset/violet-ads-battle.md | 6 - .changeset/violet-numbers-pump.md | 6 - .changeset/warm-tigers-repair.md | 5 - examples/benchmark/CHANGELOG.md | 9 + examples/benchmark/package.json | 2 +- examples/coin-app/CHANGELOG.md | 10 + examples/coin-app/package.json | 10 +- examples/normalizr-github/CHANGELOG.md | 8 + examples/normalizr-github/package.json | 2 +- examples/normalizr-redux/CHANGELOG.md | 7 + examples/normalizr-redux/package.json | 2 +- examples/normalizr-relationships/CHANGELOG.md | 8 + examples/normalizr-relationships/package.json | 2 +- packages/core/CHANGELOG.md | 148 +++++++++++ packages/core/package.json | 4 +- packages/endpoint/CHANGELOG.md | 246 ++++++++++++++++++ packages/endpoint/package.json | 2 +- packages/graphql/CHANGELOG.md | 154 +++++++++++ packages/graphql/package.json | 4 +- packages/hooks/CHANGELOG.md | 7 + packages/hooks/package.json | 4 +- packages/img/CHANGELOG.md | 9 + packages/img/package.json | 4 +- packages/normalizr/CHANGELOG.md | 202 ++++++++++++++ packages/normalizr/package.json | 2 +- packages/react/CHANGELOG.md | 193 ++++++++++++++ packages/react/package.json | 4 +- packages/redux/CHANGELOG.md | 13 + packages/redux/package.json | 4 +- packages/rest/CHANGELOG.md | 177 ++++++++++++- packages/rest/package.json | 4 +- packages/ssr/CHANGELOG.md | 6 + packages/ssr/package.json | 2 +- packages/test/CHANGELOG.md | 8 + packages/test/package.json | 2 +- website/CHANGELOG.md | 12 + yarn.lock | 59 +++-- 67 files changed, 1276 insertions(+), 624 deletions(-) delete mode 100644 .changeset/brave-maps-talk.md delete mode 100644 .changeset/brave-rockets-bake.md delete mode 100644 .changeset/five-flies-help.md delete mode 100644 .changeset/fresh-rice-provide.md delete mode 100644 .changeset/funny-avocados-do.md delete mode 100644 .changeset/funny-dragons-hammer.md delete mode 100644 .changeset/gentle-nails-try.md delete mode 100644 .changeset/great-geckos-breathe.md delete mode 100644 .changeset/little-carpets-drop.md delete mode 100644 .changeset/lovely-flies-buy.md delete mode 100644 .changeset/mean-cougars-confess.md delete mode 100644 .changeset/mean-mayflies-sleep.md delete mode 100644 .changeset/nasty-items-count.md delete mode 100644 .changeset/neat-moose-applaud.md delete mode 100644 .changeset/nice-sloths-film.md delete mode 100644 .changeset/old-zebras-bake.md delete mode 100644 .changeset/plenty-crews-check.md delete mode 100644 .changeset/purple-pandas-confess.md delete mode 100644 .changeset/quick-flies-taste.md delete mode 100644 .changeset/serious-dogs-battle.md delete mode 100644 .changeset/sharp-ears-think.md delete mode 100644 .changeset/sour-apples-sneeze.md delete mode 100644 .changeset/strange-tomatoes-hunt.md delete mode 100644 .changeset/stupid-houses-itch.md delete mode 100644 .changeset/sweet-coins-deliver.md delete mode 100644 .changeset/thirty-ants-grin.md delete mode 100644 .changeset/thirty-cherries-melt.md delete mode 100644 .changeset/three-owls-notice.md delete mode 100644 .changeset/tough-panthers-compare.md delete mode 100644 .changeset/two-foxes-explode.md delete mode 100644 .changeset/violet-ads-battle.md delete mode 100644 .changeset/violet-numbers-pump.md delete mode 100644 .changeset/warm-tigers-repair.md diff --git a/.changeset/brave-maps-talk.md b/.changeset/brave-maps-talk.md deleted file mode 100644 index 2a831211d86c..000000000000 --- a/.changeset/brave-maps-talk.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -"@data-client/normalizr": minor -"@data-client/endpoint": patch -"@data-client/react": patch -"@data-client/core": patch -"@data-client/rest": patch ---- - -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) \ No newline at end of file diff --git a/.changeset/brave-rockets-bake.md b/.changeset/brave-rockets-bake.md deleted file mode 100644 index dc48b9810e7f..000000000000 --- a/.changeset/brave-rockets-bake.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -"@data-client/normalizr": minor -"@data-client/endpoint": minor -"@data-client/react": minor -"@data-client/core": minor -"@data-client/rest": minor -"@data-client/graphql": minor ---- - -BREAKING: new AbortOptimistic() -> [snapshot.abort](https://dataclient/docs/api/Snapshot#abort) - -#### Before - -```ts -getOptimisticResponse(snapshot, { id }) { - const { data } = snapshot.getResponse(Base.get, { id }); - if (!data) throw new AbortOptimistic(); - return { - id, - votes: data.votes + 1, - }; -} -``` - -#### After - -```ts -getOptimisticResponse(snapshot, { id }) { - const { data } = snapshot.getResponse(Base.get, { id }); - if (!data) throw snapshot.abort; - return { - id, - votes: data.votes + 1, - }; -} -``` \ No newline at end of file diff --git a/.changeset/five-flies-help.md b/.changeset/five-flies-help.md deleted file mode 100644 index 6b29d01a49b5..000000000000 --- a/.changeset/five-flies-help.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@data-client/react": minor ---- - -useCache() accepts Endpoints with sideEffects diff --git a/.changeset/fresh-rice-provide.md b/.changeset/fresh-rice-provide.md deleted file mode 100644 index 4c745ac56dfd..000000000000 --- a/.changeset/fresh-rice-provide.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -"@data-client/endpoint": minor -"@data-client/rest": minor -"@data-client/graphql": minor ---- - -BREAKING: new Query -> [new schema.Query](https://dataclient.io/rest/api/Query) - -#### Before - -```jsx -const getUserCount = new Query( - new schema.All(User), - (entries, { isAdmin } = { }) => { - if (isAdmin !== undefined) - return entries.filter(user => user.isAdmin === isAdmin).length; - return entries.length; - }, -); - -const userCount = useCache(getUserCount); -const adminCount = useCache(getUserCount, { isAdmin: true }); -``` - -#### After - -```jsx -const getUserCount = new schema.Query( - new schema.All(User), - (entries, { isAdmin } = { }) => { - if (isAdmin !== undefined) - return entries.filter(user => user.isAdmin === isAdmin).length; - return entries.length; - }, -); - -const userCount = useQuery(getUserCount); -const adminCount = useQuery(getUserCount, { isAdmin: true }); -``` \ No newline at end of file diff --git a/.changeset/funny-avocados-do.md b/.changeset/funny-avocados-do.md deleted file mode 100644 index e28f27ae09d6..000000000000 --- a/.changeset/funny-avocados-do.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@data-client/endpoint": patch ---- - -Slight code reduction in EntitySchema.normalize diff --git a/.changeset/funny-dragons-hammer.md b/.changeset/funny-dragons-hammer.md deleted file mode 100644 index 2db2123b25b4..000000000000 --- a/.changeset/funny-dragons-hammer.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@data-client/normalizr": patch -"@data-client/react": patch -"@data-client/redux": patch -"@data-client/core": patch ---- - -Update description in package.json diff --git a/.changeset/gentle-nails-try.md b/.changeset/gentle-nails-try.md deleted file mode 100644 index b6f780f884bc..000000000000 --- a/.changeset/gentle-nails-try.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -'@data-client/normalizr': minor ---- - -BREAKING CHANGE: buildQueryKey() -> memo.buildQueryKey() - -```ts title="Before" -const results = buildQueryKey(schema, args, state.indexes, state.entities); -``` - -```ts title="After" -const memo = new MemoCached(); -memo.buildQueryKey(key, schema, args, state.entities, state.indexes); -``` diff --git a/.changeset/great-geckos-breathe.md b/.changeset/great-geckos-breathe.md deleted file mode 100644 index 8d9d0c85e00c..000000000000 --- a/.changeset/great-geckos-breathe.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -"@data-client/normalizr": minor ---- - -Add MemoCache - -`MemoCache` is a singleton to store the memoization cache for denormalization methods - -```ts -const memo = new MemoCache(); -const data = memo.query(key, schema, args, state.entities, state.indexes); -const { data, paths } = memo.denormalize(input, schema, state.entities, args); -const queryKey = memo.buildQueryKey( - key, - schema, - args, - state.entities, - state.indexes, -); -``` \ No newline at end of file diff --git a/.changeset/little-carpets-drop.md b/.changeset/little-carpets-drop.md deleted file mode 100644 index 99691839b80f..000000000000 --- a/.changeset/little-carpets-drop.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -"@data-client/normalizr": minor -"@data-client/endpoint": minor -"@data-client/react": minor -"@data-client/core": minor ---- - -BREAKING: Schema.infer -> Schema.queryKey - -```ts title="Before" -class MyEntity extends Entity { - // highlight-next-line - static infer( - args: readonly any[], - indexes: NormalizedIndex, - recurse: any, - entities: any, - ): any { - if (SILLYCONDITION) return undefined; - return super.infer(args, indexes, recurse, entities); - } -} -``` - -```ts title="After" -class MyEntity extends Entity { - // highlight-next-line - static queryKey( - args: readonly any[], - queryKey: (...args: any) => any, - getEntity: GetEntity, - getIndex: GetIndex, - ): any { - if (SILLYCONDITION) return undefined; - return super.queryKey(args, queryKey, getEntity, getIndex); - } -} -``` diff --git a/.changeset/lovely-flies-buy.md b/.changeset/lovely-flies-buy.md deleted file mode 100644 index ec5ffedb33e0..000000000000 --- a/.changeset/lovely-flies-buy.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@data-client/normalizr": patch ---- - -Use same state meta for each entity, rather than duplicating diff --git a/.changeset/mean-cougars-confess.md b/.changeset/mean-cougars-confess.md deleted file mode 100644 index 0d64cd4cbd64..000000000000 --- a/.changeset/mean-cougars-confess.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -"@data-client/react": patch -"@data-client/core": patch ---- - -Improve controller.getResponse() type matching - -Uses function overloading to more precisely match argument -expectations for fetchable Endpoints vs only keyable Endpoints. \ No newline at end of file diff --git a/.changeset/mean-mayflies-sleep.md b/.changeset/mean-mayflies-sleep.md deleted file mode 100644 index 53d979af991b..000000000000 --- a/.changeset/mean-mayflies-sleep.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@data-client/normalizr": patch ---- - -fix: Missing nested entities should appear once they are present (When nesting pk was a number type) diff --git a/.changeset/nasty-items-count.md b/.changeset/nasty-items-count.md deleted file mode 100644 index 7f5725c5917c..000000000000 --- a/.changeset/nasty-items-count.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@data-client/normalizr": minor ---- - -type ResultCache -> EndpointCache diff --git a/.changeset/neat-moose-applaud.md b/.changeset/neat-moose-applaud.md deleted file mode 100644 index 6ec749586c28..000000000000 --- a/.changeset/neat-moose-applaud.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@data-client/rest": patch ---- - -Improve .extend() typing when using loose null checks and no body parameter diff --git a/.changeset/nice-sloths-film.md b/.changeset/nice-sloths-film.md deleted file mode 100644 index 3e088284ce97..000000000000 --- a/.changeset/nice-sloths-film.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@data-client/redux": patch -"@data-client/test": patch -"@data-client/img": patch -"@data-client/ssr": patch ---- - -Support 0.11.0 of @data-client pkgs diff --git a/.changeset/old-zebras-bake.md b/.changeset/old-zebras-bake.md deleted file mode 100644 index 88a48e46711a..000000000000 --- a/.changeset/old-zebras-bake.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -"@data-client/endpoint": patch ---- - -Default Collection Args type is: - -```ts -| [] -| [urlParams: Record] -| [urlParams: Record, body: any] -``` \ No newline at end of file diff --git a/.changeset/plenty-crews-check.md b/.changeset/plenty-crews-check.md deleted file mode 100644 index 877c6aeb5c80..000000000000 --- a/.changeset/plenty-crews-check.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -"@data-client/endpoint": minor -"@data-client/rest": minor -"@data-client/graphql": minor ---- - -BREAKING CHANGE: Remove new AbortOptimistic() in favor of [snapshot.abort](https://dataclient.io/docs/api/Snapshot#abort) - - -```ts -getOptimisticResponse(snapshot, { id }) { - const { data } = snapshot.getResponse(Base.get, { id }); - if (!data) throw snapshot.abort; - return { - id, - votes: data.votes + 1, - }; -} -``` \ No newline at end of file diff --git a/.changeset/purple-pandas-confess.md b/.changeset/purple-pandas-confess.md deleted file mode 100644 index aaecd62097c0..000000000000 --- a/.changeset/purple-pandas-confess.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -"@data-client/react": minor ---- - -Add [useQuery()](https://dataclient.io/docs/api/useQuery) to render [Querable Schemas](https://dataclient.io/docs/api/useQuery#queryable) - -```ts -class User extends Entity { - username = ''; - id = ''; - groupId = ''; - pk() { - return this.id; - } - static index = ['username' as const]; -} - -const bob = useQuery(User, { username: 'bob' }); -``` - -```ts -const getUserCount = new schema.Query( - new schema.All(User), - (entries, { isAdmin } = {}) => { - if (isAdmin !== undefined) - return entries.filter(user => user.isAdmin === isAdmin).length; - return entries.length; - }, -); - -const userCount = useQuery(getUserCount); -const adminCount = useQuery(getUserCount, { isAdmin: true }); -``` - -```ts -const UserCollection = new schema.Collection([User], { - argsKey: (urlParams: { groupId?: string }) => ({ - ...urlParams, - }), -}); - -const usersInGroup = useQuery(UserCollection, { groupId: '5' }); -``` \ No newline at end of file diff --git a/.changeset/quick-flies-taste.md b/.changeset/quick-flies-taste.md deleted file mode 100644 index 3cba84728ca2..000000000000 --- a/.changeset/quick-flies-taste.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -"@data-client/normalizr": patch -"@data-client/endpoint": patch -"@data-client/react": patch -"@data-client/redux": patch -"@data-client/core": patch -"@data-client/rest": patch -"@data-client/test": patch ---- - -Update README diff --git a/.changeset/serious-dogs-battle.md b/.changeset/serious-dogs-battle.md deleted file mode 100644 index 8c6309ed6e62..000000000000 --- a/.changeset/serious-dogs-battle.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -"@data-client/normalizr": patch -'@data-client/endpoint': patch ---- - -Always normalize pk to string type - -Warning: This will affect contents of the store state (some numbers will appear as strings) - -Before: - -```json -{ - "Article": { - "123": { - "author": 8472, - "id": 123, - "title": "A Great Article", - }, - }, - "User": { - "8472": { - "id": 8472, - "name": "Paul", - }, - }, -} -``` - -After: - -```json -{ - "Article": { - "123": { - "author": "8472", - "id": 123, - "title": "A Great Article", - }, - }, - "User": { - "8472": { - "id": 8472, - "name": "Paul", - }, - }, -} -``` \ No newline at end of file diff --git a/.changeset/sharp-ears-think.md b/.changeset/sharp-ears-think.md deleted file mode 100644 index 5bf113b1e560..000000000000 --- a/.changeset/sharp-ears-think.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -"@data-client/endpoint": minor -"@data-client/rest": minor -"@data-client/graphql": minor ---- - -BREAKING: Entity.useIncoming → [Entity.shouldUpdate](https://dataclient.io/rest/api/Entity#shouldupdate)) - -```ts title="Before" -class MyEntity extends Entity { - // highlight-next-line - static useIncoming( - existingMeta: { date: number }, - incomingMeta: { date: number }, - existing: any, - incoming: any, - ) { - return !deepEquals(existing, incoming); - } -} -``` - -```ts title="After" -class MyEntity extends Entity { - // highlight-next-line - static shouldUpdate( - existingMeta: { date: number }, - incomingMeta: { date: number }, - existing: any, - incoming: any, - ) { - return !deepEquals(existing, incoming); - } -} -``` \ No newline at end of file diff --git a/.changeset/sour-apples-sneeze.md b/.changeset/sour-apples-sneeze.md deleted file mode 100644 index 0e2ce7938e59..000000000000 --- a/.changeset/sour-apples-sneeze.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -"@data-client/normalizr": minor ---- - -BREAKING CHANGE: WeakEntityMap -> WeakDependencyMap - -We generalize this data type so it can be used with other dependencies. - -```ts title="Before" -new WeakEntityMap(); -``` - -```ts title="After" -new WeakDependencyMap(); -``` \ No newline at end of file diff --git a/.changeset/strange-tomatoes-hunt.md b/.changeset/strange-tomatoes-hunt.md deleted file mode 100644 index 68660a3c817c..000000000000 --- a/.changeset/strange-tomatoes-hunt.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -'@data-client/normalizr': minor ---- - -BREAKING CHANGE: denormalizeCached() -> new MemoCache().denormalize() - -```ts title="Before" -const endpointCache = new WeakEntityMap(); -const entityCache = {}; -denormalizeCached(input, schema, state.entities, entityCache, endpointCache, args); -``` - -```ts title="After" -const memo = new MemoCached(); -memo.denormalize(input, schema, state.entities, args); -``` diff --git a/.changeset/stupid-houses-itch.md b/.changeset/stupid-houses-itch.md deleted file mode 100644 index 5536f19d743e..000000000000 --- a/.changeset/stupid-houses-itch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@data-client/rest": patch ---- - -fix: Resource.getList.schema args types diff --git a/.changeset/sweet-coins-deliver.md b/.changeset/sweet-coins-deliver.md deleted file mode 100644 index d838f90fa89e..000000000000 --- a/.changeset/sweet-coins-deliver.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -"@data-client/react": minor -"@data-client/core": minor ---- - -Add [controller.get](https://dataclient.io/docs/api/Controller#get) / [snapshot.get](https://dataclient.io/docs/api/Snapshot#get) to directly read [Querable Schemas](https://dataclient.io/docs/api/useQuery#queryable) - -#### Before - -```tsx -export const PostResource = createResource({ - path: '/posts/:id', - schema: Post, -}).extend(Base => ({ - vote: new RestEndpoint({ - path: '/posts/:id/vote', - method: 'POST', - body: undefined, - schema: Post, - getOptimisticResponse(snapshot, { id }) { - const { data } = snapshot.getResponse(Base.get, { id }); - if (!data) throw new AbortOptimistic(); - return { - id, - votes: data.votes + 1, - }; - }, - }), -})); -``` - -#### After - -```tsx -export const PostResource = createResource({ - path: '/posts/:id', - schema: Post, -}).extend('vote', - { - path: '/posts/:id/vote', - method: 'POST', - body: undefined, - schema: Post, - getOptimisticResponse(snapshot, { id }) { - const post = snapshot.get(Post, { id }); - if (!post) throw new AbortOptimistic(); - return { - id, - votes: post.votes + 1, - }; - }, - }, -); -``` diff --git a/.changeset/thirty-ants-grin.md b/.changeset/thirty-ants-grin.md deleted file mode 100644 index 625013561e57..000000000000 --- a/.changeset/thirty-ants-grin.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -"@data-client/endpoint": minor -"@data-client/rest": minor -"@data-client/graphql": minor ---- - -BREAKING: useCache(new Index(MyEntity)) -> useQuery(MyEntity) - -#### Before - -```jsx -const UserIndex = new Index(User) - -const bob = useCache(UserIndex, { username: 'bob' }); -``` - -#### After - -```jsx -const bob = useQuery(User, { username: 'bob' }); -``` \ No newline at end of file diff --git a/.changeset/thirty-cherries-melt.md b/.changeset/thirty-cherries-melt.md deleted file mode 100644 index 17d700437efc..000000000000 --- a/.changeset/thirty-cherries-melt.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -"@data-client/normalizr": minor -"@data-client/react": minor -"@data-client/core": minor ---- - -Add [snapshot.abort](https://dataclient.io/docs/api/Snapshot#abort) - -```ts -getOptimisticResponse(snapshot, { id }) { - const { data } = snapshot.getResponse(Base.get, { id }); - if (!data) throw snapshot.abort; - return { - id, - votes: data.votes + 1, - }; -} -``` \ No newline at end of file diff --git a/.changeset/three-owls-notice.md b/.changeset/three-owls-notice.md deleted file mode 100644 index 1221754999d8..000000000000 --- a/.changeset/three-owls-notice.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@data-client/react": minor ---- - -useDLE() reactive native focus handling - -When using React Navigation, useDLE() will trigger fetches on focus if the data is considered -stale. diff --git a/.changeset/tough-panthers-compare.md b/.changeset/tough-panthers-compare.md deleted file mode 100644 index 9cdca6a8e807..000000000000 --- a/.changeset/tough-panthers-compare.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@data-client/normalizr": patch ---- - -fix: Missing nested entities should appear once they are present - diff --git a/.changeset/two-foxes-explode.md b/.changeset/two-foxes-explode.md deleted file mode 100644 index f447cb5a678c..000000000000 --- a/.changeset/two-foxes-explode.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -'@data-client/endpoint': patch -'@data-client/graphql': patch -'@data-client/rest': patch ---- - -Allow pk() to return numbers - -Before: - -```ts -class MyEntity extends Entity { - id = 0; - pk() { - return `${this.id}`; - } -} -``` - -After: - -```ts -class MyEntity extends Entity { - id = 0; - pk() { - return this.id; - } -} -``` diff --git a/.changeset/violet-ads-battle.md b/.changeset/violet-ads-battle.md deleted file mode 100644 index d02dc168dd15..000000000000 --- a/.changeset/violet-ads-battle.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@data-client/normalizr": minor -"@data-client/core": minor ---- - -BREAKING: inferResults() -> buildQueryKey() diff --git a/.changeset/violet-numbers-pump.md b/.changeset/violet-numbers-pump.md deleted file mode 100644 index 29b5726e0225..000000000000 --- a/.changeset/violet-numbers-pump.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@data-client/react": minor -"@data-client/core": minor ---- - -BREAKING: Internal state.results -> state.endpoints diff --git a/.changeset/warm-tigers-repair.md b/.changeset/warm-tigers-repair.md deleted file mode 100644 index d5207d81ba18..000000000000 --- a/.changeset/warm-tigers-repair.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@data-client/endpoint": patch ---- - -More robustly handle Union queries when the schema cannot be found diff --git a/examples/benchmark/CHANGELOG.md b/examples/benchmark/CHANGELOG.md index 7efbb41dbebb..a5a6096c0c1e 100644 --- a/examples/benchmark/CHANGELOG.md +++ b/examples/benchmark/CHANGELOG.md @@ -1,5 +1,14 @@ # example-benchmark +## 0.4.39 + +### Patch Changes + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`10432b7`](https://github.com/reactive/data-client/commit/10432b7eeab8f1e31ed764d46b0775e36ea74041), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd)]: + - @data-client/normalizr@0.11.0 + - @data-client/endpoint@0.11.0 + - @data-client/core@0.11.0 + ## 0.4.38 ### Patch Changes diff --git a/examples/benchmark/package.json b/examples/benchmark/package.json index d27e9e77a24a..d6dd5a5b91a2 100644 --- a/examples/benchmark/package.json +++ b/examples/benchmark/package.json @@ -1,6 +1,6 @@ { "name": "example-benchmark", - "version": "0.4.38", + "version": "0.4.39", "description": "Benchmark for normalizr", "main": "index.js", "author": "Nathaniel Tucker", diff --git a/examples/coin-app/CHANGELOG.md b/examples/coin-app/CHANGELOG.md index 2316c8552032..d8d77eef0630 100644 --- a/examples/coin-app/CHANGELOG.md +++ b/examples/coin-app/CHANGELOG.md @@ -1,5 +1,15 @@ # coinbase-lite +## 0.0.3 + +### Patch Changes + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`7580500`](https://github.com/reactive/data-client/commit/7580500cecb2c4baa093f4db7b951af4840a0967), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`f6f195d`](https://github.com/reactive/data-client/commit/f6f195d573c7c51dc63361a48b2ef804181a348b), [`ba636a7`](https://github.com/reactive/data-client/commit/ba636a74e77bf5cb8c2b327e161db09f4c4a7192), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`8d42ef6`](https://github.com/reactive/data-client/commit/8d42ef6fae10859bcac1812cdbe637c739afaa6d), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161)]: + - @data-client/react@0.11.0 + - @data-client/rest@0.11.0 + - @data-client/redux@0.11.0 + - @data-client/img@0.11.0 + ## 0.0.2 ### Patch Changes diff --git a/examples/coin-app/package.json b/examples/coin-app/package.json index d89b546a178d..0be31a752540 100644 --- a/examples/coin-app/package.json +++ b/examples/coin-app/package.json @@ -1,6 +1,6 @@ { "name": "coinbase-lite", - "version": "0.0.2", + "version": "0.0.3", "packageManager": "yarn@4.1.1", "description": "Coin App", "scripts": { @@ -41,10 +41,10 @@ "@anansi/core": "^0.18.4", "@anansi/router": "^0.9.1", "@babel/runtime": "^7.22.15", - "@data-client/img": "^0.10.0", - "@data-client/react": "^0.10.0", - "@data-client/redux": "^0.10.0", - "@data-client/rest": "^0.10.0", + "@data-client/img": "^0.11.0", + "@data-client/react": "^0.11.0", + "@data-client/redux": "^0.11.0", + "@data-client/rest": "^0.11.0", "history": "*", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/examples/normalizr-github/CHANGELOG.md b/examples/normalizr-github/CHANGELOG.md index e6380c1d71a4..f34ec196151c 100644 --- a/examples/normalizr-github/CHANGELOG.md +++ b/examples/normalizr-github/CHANGELOG.md @@ -1,5 +1,13 @@ # normalizr-github-example +## 0.1.28 + +### Patch Changes + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`10432b7`](https://github.com/reactive/data-client/commit/10432b7eeab8f1e31ed764d46b0775e36ea74041), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd)]: + - @data-client/normalizr@0.11.0 + - @data-client/endpoint@0.11.0 + ## 0.1.27 ### Patch Changes diff --git a/examples/normalizr-github/package.json b/examples/normalizr-github/package.json index 2137248f8c8b..04cfdcf82848 100644 --- a/examples/normalizr-github/package.json +++ b/examples/normalizr-github/package.json @@ -1,6 +1,6 @@ { "name": "normalizr-github-example", - "version": "0.1.27", + "version": "0.1.28", "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 1888cae54b38..2a040bcacd59 100644 --- a/examples/normalizr-redux/CHANGELOG.md +++ b/examples/normalizr-redux/CHANGELOG.md @@ -1,5 +1,12 @@ # normalizr-redux-example +## 0.1.26 + +### Patch Changes + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd)]: + - @data-client/endpoint@0.11.0 + ## 0.1.25 ### Patch Changes diff --git a/examples/normalizr-redux/package.json b/examples/normalizr-redux/package.json index 0ffc1b6f8d64..0a9d280654c0 100644 --- a/examples/normalizr-redux/package.json +++ b/examples/normalizr-redux/package.json @@ -1,6 +1,6 @@ { "name": "normalizr-redux-example", - "version": "0.1.25", + "version": "0.1.26", "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 b59a9d7ba6c7..68cd78d94846 100644 --- a/examples/normalizr-relationships/CHANGELOG.md +++ b/examples/normalizr-relationships/CHANGELOG.md @@ -1,5 +1,13 @@ # normalizr-relationships +## 0.1.28 + +### Patch Changes + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`10432b7`](https://github.com/reactive/data-client/commit/10432b7eeab8f1e31ed764d46b0775e36ea74041), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd)]: + - @data-client/normalizr@0.11.0 + - @data-client/endpoint@0.11.0 + ## 0.1.27 ### Patch Changes diff --git a/examples/normalizr-relationships/package.json b/examples/normalizr-relationships/package.json index 7b4819da018f..8421fd37c1e7 100644 --- a/examples/normalizr-relationships/package.json +++ b/examples/normalizr-relationships/package.json @@ -1,6 +1,6 @@ { "name": "normalizr-relationships", - "version": "0.1.27", + "version": "0.1.28", "description": "And example of using Normalizr with relationships", "main": "index.js", "author": "Paul Armstrong", diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index ac0addeee0ae..d30311fc0783 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,153 @@ # @data-client/core +## 0.11.0 + +### Minor Changes + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: new AbortOptimistic() -> [snapshot.abort](https://dataclient/docs/api/Snapshot#abort) + + #### Before + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw new AbortOptimistic(); + return { + id, + votes: data.votes + 1, + }; + } + ``` + + #### After + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2977](https://github.com/reactive/data-client/pull/2977) [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Schema.infer -> Schema.queryKey + + ```ts title="Before" + class MyEntity extends Entity { + // highlight-next-line + static infer( + args: readonly any[], + indexes: NormalizedIndex, + recurse: any, + entities: any, + ): any { + if (SILLYCONDITION) return undefined; + return super.infer(args, indexes, recurse, entities); + } + } + ``` + + ```ts title="After" + class MyEntity extends Entity { + // highlight-next-line + static queryKey( + args: readonly any[], + queryKey: (...args: any) => any, + getEntity: GetEntity, + getIndex: GetIndex, + ): any { + if (SILLYCONDITION) return undefined; + return super.queryKey(args, queryKey, getEntity, getIndex); + } + } + ``` + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Add [controller.get](https://dataclient.io/docs/api/Controller#get) / [snapshot.get](https://dataclient.io/docs/api/Snapshot#get) to directly read [Querable Schemas](https://dataclient.io/docs/api/useQuery#queryable) + + #### Before + + ```tsx + export const PostResource = createResource({ + path: "/posts/:id", + schema: Post, + }).extend((Base) => ({ + vote: new RestEndpoint({ + path: "/posts/:id/vote", + method: "POST", + body: undefined, + schema: Post, + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw new AbortOptimistic(); + return { + id, + votes: data.votes + 1, + }; + }, + }), + })); + ``` + + #### After + + ```tsx + export const PostResource = createResource({ + path: "/posts/:id", + schema: Post, + }).extend("vote", { + path: "/posts/:id/vote", + method: "POST", + body: undefined, + schema: Post, + getOptimisticResponse(snapshot, { id }) { + const post = snapshot.get(Post, { id }); + if (!post) throw new AbortOptimistic(); + return { + id, + votes: post.votes + 1, + }; + }, + }); + ``` + +- [#2957](https://github.com/reactive/data-client/pull/2957) [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a) Thanks [@ntucker](https://github.com/ntucker)! - Add [snapshot.abort](https://dataclient.io/docs/api/Snapshot#abort) + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2977](https://github.com/reactive/data-client/pull/2977) [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: inferResults() -> buildQueryKey() + +- [#2971](https://github.com/reactive/data-client/pull/2971) [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Internal state.results -> state.endpoints + +### 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) + +- [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0) Thanks [@ntucker](https://github.com/ntucker)! - Update description in package.json + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Improve controller.getResponse() type matching + + Uses function overloading to more precisely match argument + expectations for fetchable Endpoints vs only keyable Endpoints. + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Update README + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`10432b7`](https://github.com/reactive/data-client/commit/10432b7eeab8f1e31ed764d46b0775e36ea74041), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af)]: + - @data-client/normalizr@0.11.0 + ## 0.10.0 ### Minor Changes diff --git a/packages/core/package.json b/packages/core/package.json index 330a06b13d6c..3cea0549bc84 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/core", - "version": "0.10.0", + "version": "0.11.0", "description": "High performance mutable data framework.", "sideEffects": false, "main": "dist/index.js", @@ -120,7 +120,7 @@ }, "dependencies": { "@babel/runtime": "^7.17.0", - "@data-client/normalizr": "^0.10.0", + "@data-client/normalizr": "^0.11.0", "flux-standard-action": "^2.1.1" }, "devDependencies": { diff --git a/packages/endpoint/CHANGELOG.md b/packages/endpoint/CHANGELOG.md index 6f81aae474d3..28b55c919a7c 100644 --- a/packages/endpoint/CHANGELOG.md +++ b/packages/endpoint/CHANGELOG.md @@ -1,5 +1,251 @@ # @data-client/endpoint +## 0.11.0 + +### Minor Changes + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: new AbortOptimistic() -> [snapshot.abort](https://dataclient/docs/api/Snapshot#abort) + + #### Before + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw new AbortOptimistic(); + return { + id, + votes: data.votes + 1, + }; + } + ``` + + #### After + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: new Query -> [new schema.Query](https://dataclient.io/rest/api/Query) + + #### Before + + ```jsx + const getUserCount = new Query( + new schema.All(User), + (entries, { isAdmin } = {}) => { + if (isAdmin !== undefined) + return entries.filter((user) => user.isAdmin === isAdmin).length; + return entries.length; + }, + ); + + const userCount = useCache(getUserCount); + const adminCount = useCache(getUserCount, { isAdmin: true }); + ``` + + #### After + + ```jsx + const getUserCount = new schema.Query( + new schema.All(User), + (entries, { isAdmin } = {}) => { + if (isAdmin !== undefined) + return entries.filter((user) => user.isAdmin === isAdmin).length; + return entries.length; + }, + ); + + const userCount = useQuery(getUserCount); + const adminCount = useQuery(getUserCount, { isAdmin: true }); + ``` + +- [#2977](https://github.com/reactive/data-client/pull/2977) [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Schema.infer -> Schema.queryKey + + ```ts title="Before" + class MyEntity extends Entity { + // highlight-next-line + static infer( + args: readonly any[], + indexes: NormalizedIndex, + recurse: any, + entities: any, + ): any { + if (SILLYCONDITION) return undefined; + return super.infer(args, indexes, recurse, entities); + } + } + ``` + + ```ts title="After" + class MyEntity extends Entity { + // highlight-next-line + static queryKey( + args: readonly any[], + queryKey: (...args: any) => any, + getEntity: GetEntity, + getIndex: GetIndex, + ): any { + if (SILLYCONDITION) return undefined; + return super.queryKey(args, queryKey, getEntity, getIndex); + } + } + ``` + +- [#2957](https://github.com/reactive/data-client/pull/2957) [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: Remove new AbortOptimistic() in favor of [snapshot.abort](https://dataclient.io/docs/api/Snapshot#abort) + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2972](https://github.com/reactive/data-client/pull/2972) [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Entity.useIncoming → [Entity.shouldUpdate](https://dataclient.io/rest/api/Entity#shouldupdate)) + + ```ts title="Before" + class MyEntity extends Entity { + // highlight-next-line + static useIncoming( + existingMeta: { date: number }, + incomingMeta: { date: number }, + existing: any, + incoming: any, + ) { + return !deepEquals(existing, incoming); + } + } + ``` + + ```ts title="After" + class MyEntity extends Entity { + // highlight-next-line + static shouldUpdate( + existingMeta: { date: number }, + incomingMeta: { date: number }, + existing: any, + incoming: any, + ) { + return !deepEquals(existing, incoming); + } + } + ``` + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: useCache(new Index(MyEntity)) -> useQuery(MyEntity) + + #### Before + + ```jsx + const UserIndex = new Index(User); + + const bob = useCache(UserIndex, { username: "bob" }); + ``` + + #### After + + ```jsx + const bob = useQuery(User, { username: "bob" }); + ``` + +### 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) + +- [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9) Thanks [@ntucker](https://github.com/ntucker)! - Slight code reduction in EntitySchema.normalize + +- [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d) Thanks [@ntucker](https://github.com/ntucker)! - Default Collection Args type is: + + ```ts + | [] + | [urlParams: Record] + | [urlParams: Record, body: any] + ``` + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Update README + +- [#2961](https://github.com/reactive/data-client/pull/2961) [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1) Thanks [@ntucker](https://github.com/ntucker)! - Always normalize pk to string type + + Warning: This will affect contents of the store state (some numbers will appear as strings) + + Before: + + ```json + { + "Article": { + "123": { + "author": 8472, + "id": 123, + "title": "A Great Article" + } + }, + "User": { + "8472": { + "id": 8472, + "name": "Paul" + } + } + } + ``` + + After: + + ```json + { + "Article": { + "123": { + "author": "8472", + "id": 123, + "title": "A Great Article" + } + }, + "User": { + "8472": { + "id": 8472, + "name": "Paul" + } + } + } + ``` + +- [#2961](https://github.com/reactive/data-client/pull/2961) [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1) Thanks [@ntucker](https://github.com/ntucker)! - Allow pk() to return numbers + + Before: + + ```ts + class MyEntity extends Entity { + id = 0; + pk() { + return `${this.id}`; + } + } + ``` + + After: + + ```ts + class MyEntity extends Entity { + id = 0; + pk() { + return this.id; + } + } + ``` + +- [#2978](https://github.com/reactive/data-client/pull/2978) [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd) Thanks [@ntucker](https://github.com/ntucker)! - More robustly handle Union queries when the schema cannot be found + ## 0.10.0 ### Minor Changes diff --git a/packages/endpoint/package.json b/packages/endpoint/package.json index 5b597e79d265..202ae7c0a5a8 100644 --- a/packages/endpoint/package.json +++ b/packages/endpoint/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/endpoint", - "version": "0.10.0", + "version": "0.11.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 9ccc9f294bdc..005c85eae8fc 100644 --- a/packages/graphql/CHANGELOG.md +++ b/packages/graphql/CHANGELOG.md @@ -1,5 +1,159 @@ # @data-client/graphql +## 0.11.0 + +### Minor Changes + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: new AbortOptimistic() -> [snapshot.abort](https://dataclient/docs/api/Snapshot#abort) + + #### Before + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw new AbortOptimistic(); + return { + id, + votes: data.votes + 1, + }; + } + ``` + + #### After + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: new Query -> [new schema.Query](https://dataclient.io/rest/api/Query) + + #### Before + + ```jsx + const getUserCount = new Query( + new schema.All(User), + (entries, { isAdmin } = {}) => { + if (isAdmin !== undefined) + return entries.filter((user) => user.isAdmin === isAdmin).length; + return entries.length; + }, + ); + + const userCount = useCache(getUserCount); + const adminCount = useCache(getUserCount, { isAdmin: true }); + ``` + + #### After + + ```jsx + const getUserCount = new schema.Query( + new schema.All(User), + (entries, { isAdmin } = {}) => { + if (isAdmin !== undefined) + return entries.filter((user) => user.isAdmin === isAdmin).length; + return entries.length; + }, + ); + + const userCount = useQuery(getUserCount); + const adminCount = useQuery(getUserCount, { isAdmin: true }); + ``` + +- [#2957](https://github.com/reactive/data-client/pull/2957) [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: Remove new AbortOptimistic() in favor of [snapshot.abort](https://dataclient.io/docs/api/Snapshot#abort) + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2972](https://github.com/reactive/data-client/pull/2972) [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Entity.useIncoming → [Entity.shouldUpdate](https://dataclient.io/rest/api/Entity#shouldupdate)) + + ```ts title="Before" + class MyEntity extends Entity { + // highlight-next-line + static useIncoming( + existingMeta: { date: number }, + incomingMeta: { date: number }, + existing: any, + incoming: any, + ) { + return !deepEquals(existing, incoming); + } + } + ``` + + ```ts title="After" + class MyEntity extends Entity { + // highlight-next-line + static shouldUpdate( + existingMeta: { date: number }, + incomingMeta: { date: number }, + existing: any, + incoming: any, + ) { + return !deepEquals(existing, incoming); + } + } + ``` + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: useCache(new Index(MyEntity)) -> useQuery(MyEntity) + + #### Before + + ```jsx + const UserIndex = new Index(User); + + const bob = useCache(UserIndex, { username: "bob" }); + ``` + + #### After + + ```jsx + const bob = useQuery(User, { username: "bob" }); + ``` + +### Patch Changes + +- [#2961](https://github.com/reactive/data-client/pull/2961) [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1) Thanks [@ntucker](https://github.com/ntucker)! - Allow pk() to return numbers + + Before: + + ```ts + class MyEntity extends Entity { + id = 0; + pk() { + return `${this.id}`; + } + } + ``` + + After: + + ```ts + class MyEntity extends Entity { + id = 0; + pk() { + return this.id; + } + } + ``` + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd)]: + - @data-client/endpoint@0.11.0 + ## 0.10.0 ### Patch Changes diff --git a/packages/graphql/package.json b/packages/graphql/package.json index 1ac6fbac9e2b..10b67ef3eec8 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/graphql", - "version": "0.10.0", + "version": "0.11.0", "description": "Endpoints for GraphQL APIs", "homepage": "https://dataclient.io/docs/graphql", "repository": { @@ -104,7 +104,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.17.0", - "@data-client/endpoint": "^0.10.0" + "@data-client/endpoint": "^0.11.0" }, "devDependencies": { "@anansi/browserslist-config": "^1.4.2", diff --git a/packages/hooks/CHANGELOG.md b/packages/hooks/CHANGELOG.md index 58fec7becceb..5508e5b8eac9 100644 --- a/packages/hooks/CHANGELOG.md +++ b/packages/hooks/CHANGELOG.md @@ -1,5 +1,12 @@ # @data-client/hooks +## 0.1.8 + +### Patch Changes + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`10432b7`](https://github.com/reactive/data-client/commit/10432b7eeab8f1e31ed764d46b0775e36ea74041), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af)]: + - @data-client/normalizr@0.11.0 + ## 0.1.7 ### Patch Changes diff --git a/packages/hooks/package.json b/packages/hooks/package.json index 270cfdcd153b..74a3675b1bcc 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/hooks", - "version": "0.1.7", + "version": "0.1.8", "description": "Collection of composable data hooks", "homepage": "https://dataclient.io/docs/api/useDebounce", "repository": { @@ -73,7 +73,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.17.0", - "@data-client/normalizr": "^0.10.0" + "@data-client/normalizr": "^0.11.0" }, "peerDependencies": { "@types/react": "^16.8.4 || ^17.0.0 || ^18.0.0-0", diff --git a/packages/img/CHANGELOG.md b/packages/img/CHANGELOG.md index ec6d27bbbaa4..fe6245e58b43 100644 --- a/packages/img/CHANGELOG.md +++ b/packages/img/CHANGELOG.md @@ -1,5 +1,14 @@ # @data-client/img +## 0.11.0 + +### Patch Changes + +- [`ba636a7`](https://github.com/reactive/data-client/commit/ba636a74e77bf5cb8c2b327e161db09f4c4a7192) Thanks [@ntucker](https://github.com/ntucker)! - Support 0.11.0 of @data-client pkgs + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd)]: + - @data-client/endpoint@0.11.0 + ## 0.10.0 ### Patch Changes diff --git a/packages/img/package.json b/packages/img/package.json index ecd76e782030..b9be3dcc73c9 100644 --- a/packages/img/package.json +++ b/packages/img/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/img", - "version": "0.10.0", + "version": "0.11.0", "description": "Suspenseful images", "homepage": "https://dataclient.io/docs/guides/img-media#just-images", "repository": { @@ -69,7 +69,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.17.0", - "@data-client/endpoint": "^0.10.0" + "@data-client/endpoint": "^0.11.0" }, "peerDependencies": { "@data-client/react": "^0.1.0 || ^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0", diff --git a/packages/normalizr/CHANGELOG.md b/packages/normalizr/CHANGELOG.md index 28512f5b083f..a2d5398f2019 100644 --- a/packages/normalizr/CHANGELOG.md +++ b/packages/normalizr/CHANGELOG.md @@ -1,5 +1,207 @@ # Change Log +## 0.11.0 + +### 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) + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: new AbortOptimistic() -> [snapshot.abort](https://dataclient/docs/api/Snapshot#abort) + + #### Before + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw new AbortOptimistic(); + return { + id, + votes: data.votes + 1, + }; + } + ``` + + #### After + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2978](https://github.com/reactive/data-client/pull/2978) [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: buildQueryKey() -> memo.buildQueryKey() + + ```ts title="Before" + const results = buildQueryKey(schema, args, state.indexes, state.entities); + ``` + + ```ts title="After" + const memo = new MemoCached(); + memo.buildQueryKey(key, schema, args, state.entities, state.indexes); + ``` + +- [#2978](https://github.com/reactive/data-client/pull/2978) [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd) Thanks [@ntucker](https://github.com/ntucker)! - Add MemoCache + + `MemoCache` is a singleton to store the memoization cache for denormalization methods + + ```ts + const memo = new MemoCache(); + const data = memo.query(key, schema, args, state.entities, state.indexes); + const { data, paths } = memo.denormalize(input, schema, state.entities, args); + const queryKey = memo.buildQueryKey( + key, + schema, + args, + state.entities, + state.indexes, + ); + ``` + +- [#2977](https://github.com/reactive/data-client/pull/2977) [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Schema.infer -> Schema.queryKey + + ```ts title="Before" + class MyEntity extends Entity { + // highlight-next-line + static infer( + args: readonly any[], + indexes: NormalizedIndex, + recurse: any, + entities: any, + ): any { + if (SILLYCONDITION) return undefined; + return super.infer(args, indexes, recurse, entities); + } + } + ``` + + ```ts title="After" + class MyEntity extends Entity { + // highlight-next-line + static queryKey( + args: readonly any[], + queryKey: (...args: any) => any, + getEntity: GetEntity, + getIndex: GetIndex, + ): any { + if (SILLYCONDITION) return undefined; + return super.queryKey(args, queryKey, getEntity, getIndex); + } + } + ``` + +- [#2971](https://github.com/reactive/data-client/pull/2971) [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161) Thanks [@ntucker](https://github.com/ntucker)! - type ResultCache -> EndpointCache + +- [#2978](https://github.com/reactive/data-client/pull/2978) [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: WeakEntityMap -> WeakDependencyMap + + We generalize this data type so it can be used with other dependencies. + + ```ts title="Before" + new WeakEntityMap(); + ``` + + ```ts title="After" + new WeakDependencyMap(); + ``` + +- [#2978](https://github.com/reactive/data-client/pull/2978) [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: denormalizeCached() -> new MemoCache().denormalize() + + ```ts title="Before" + const endpointCache = new WeakEntityMap(); + const entityCache = {}; + denormalizeCached( + input, + schema, + state.entities, + entityCache, + endpointCache, + args, + ); + ``` + + ```ts title="After" + const memo = new MemoCached(); + memo.denormalize(input, schema, state.entities, args); + ``` + +- [#2957](https://github.com/reactive/data-client/pull/2957) [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a) Thanks [@ntucker](https://github.com/ntucker)! - Add [snapshot.abort](https://dataclient.io/docs/api/Snapshot#abort) + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2977](https://github.com/reactive/data-client/pull/2977) [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: inferResults() -> buildQueryKey() + +### Patch Changes + +- [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0) Thanks [@ntucker](https://github.com/ntucker)! - Update description in package.json + +- [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9) Thanks [@ntucker](https://github.com/ntucker)! - Use same state meta for each entity, rather than duplicating + +- [#2961](https://github.com/reactive/data-client/pull/2961) [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1) Thanks [@ntucker](https://github.com/ntucker)! - fix: Missing nested entities should appear once they are present (When nesting pk was a number type) + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Update README + +- [#2961](https://github.com/reactive/data-client/pull/2961) [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1) Thanks [@ntucker](https://github.com/ntucker)! - Always normalize pk to string type + + Warning: This will affect contents of the store state (some numbers will appear as strings) + + Before: + + ```json + { + "Article": { + "123": { + "author": 8472, + "id": 123, + "title": "A Great Article" + } + }, + "User": { + "8472": { + "id": 8472, + "name": "Paul" + } + } + } + ``` + + After: + + ```json + { + "Article": { + "123": { + "author": "8472", + "id": 123, + "title": "A Great Article" + } + }, + "User": { + "8472": { + "id": 8472, + "name": "Paul" + } + } + } + ``` + +- [#2956](https://github.com/reactive/data-client/pull/2956) [`10432b7`](https://github.com/reactive/data-client/commit/10432b7eeab8f1e31ed764d46b0775e36ea74041) Thanks [@ntucker](https://github.com/ntucker)! - fix: Missing nested entities should appear once they are present + ## 0.10.0 ### Minor Changes diff --git a/packages/normalizr/package.json b/packages/normalizr/package.json index 771ab1e659b5..4eb5c703fc2e 100644 --- a/packages/normalizr/package.json +++ b/packages/normalizr/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/normalizr", - "version": "0.10.0", + "version": "0.11.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 f75720fbfefb..309f6a066175 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -1,5 +1,198 @@ # @data-client/react +## 0.11.0 + +### Minor Changes + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: new AbortOptimistic() -> [snapshot.abort](https://dataclient/docs/api/Snapshot#abort) + + #### Before + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw new AbortOptimistic(); + return { + id, + votes: data.votes + 1, + }; + } + ``` + + #### After + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2963](https://github.com/reactive/data-client/pull/2963) [`7580500`](https://github.com/reactive/data-client/commit/7580500cecb2c4baa093f4db7b951af4840a0967) Thanks [@ntucker](https://github.com/ntucker)! - useCache() accepts Endpoints with sideEffects + +- [#2977](https://github.com/reactive/data-client/pull/2977) [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Schema.infer -> Schema.queryKey + + ```ts title="Before" + class MyEntity extends Entity { + // highlight-next-line + static infer( + args: readonly any[], + indexes: NormalizedIndex, + recurse: any, + entities: any, + ): any { + if (SILLYCONDITION) return undefined; + return super.infer(args, indexes, recurse, entities); + } + } + ``` + + ```ts title="After" + class MyEntity extends Entity { + // highlight-next-line + static queryKey( + args: readonly any[], + queryKey: (...args: any) => any, + getEntity: GetEntity, + getIndex: GetIndex, + ): any { + if (SILLYCONDITION) return undefined; + return super.queryKey(args, queryKey, getEntity, getIndex); + } + } + ``` + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Add [useQuery()](https://dataclient.io/docs/api/useQuery) to render [Querable Schemas](https://dataclient.io/docs/api/useQuery#queryable) + + ```ts + class User extends Entity { + username = ""; + id = ""; + groupId = ""; + pk() { + return this.id; + } + static index = ["username" as const]; + } + + const bob = useQuery(User, { username: "bob" }); + ``` + + ```ts + const getUserCount = new schema.Query( + new schema.All(User), + (entries, { isAdmin } = {}) => { + if (isAdmin !== undefined) + return entries.filter((user) => user.isAdmin === isAdmin).length; + return entries.length; + }, + ); + + const userCount = useQuery(getUserCount); + const adminCount = useQuery(getUserCount, { isAdmin: true }); + ``` + + ```ts + const UserCollection = new schema.Collection([User], { + argsKey: (urlParams: { groupId?: string }) => ({ + ...urlParams, + }), + }); + + const usersInGroup = useQuery(UserCollection, { groupId: "5" }); + ``` + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Add [controller.get](https://dataclient.io/docs/api/Controller#get) / [snapshot.get](https://dataclient.io/docs/api/Snapshot#get) to directly read [Querable Schemas](https://dataclient.io/docs/api/useQuery#queryable) + + #### Before + + ```tsx + export const PostResource = createResource({ + path: "/posts/:id", + schema: Post, + }).extend((Base) => ({ + vote: new RestEndpoint({ + path: "/posts/:id/vote", + method: "POST", + body: undefined, + schema: Post, + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw new AbortOptimistic(); + return { + id, + votes: data.votes + 1, + }; + }, + }), + })); + ``` + + #### After + + ```tsx + export const PostResource = createResource({ + path: "/posts/:id", + schema: Post, + }).extend("vote", { + path: "/posts/:id/vote", + method: "POST", + body: undefined, + schema: Post, + getOptimisticResponse(snapshot, { id }) { + const post = snapshot.get(Post, { id }); + if (!post) throw new AbortOptimistic(); + return { + id, + votes: post.votes + 1, + }; + }, + }); + ``` + +- [#2957](https://github.com/reactive/data-client/pull/2957) [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a) Thanks [@ntucker](https://github.com/ntucker)! - Add [snapshot.abort](https://dataclient.io/docs/api/Snapshot#abort) + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2997](https://github.com/reactive/data-client/pull/2997) [`8d42ef6`](https://github.com/reactive/data-client/commit/8d42ef6fae10859bcac1812cdbe637c739afaa6d) Thanks [@ntucker](https://github.com/ntucker)! - useDLE() reactive native focus handling + + When using React Navigation, useDLE() will trigger fetches on focus if the data is considered + stale. + +- [#2971](https://github.com/reactive/data-client/pull/2971) [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Internal state.results -> state.endpoints + +### 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) + +- [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0) Thanks [@ntucker](https://github.com/ntucker)! - Update description in package.json + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Improve controller.getResponse() type matching + + Uses function overloading to more precisely match argument + expectations for fetchable Endpoints vs only keyable Endpoints. + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Update README + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161)]: + - @data-client/core@0.11.0 + ## 0.10.0 ### Minor Changes diff --git a/packages/react/package.json b/packages/react/package.json index a8f9ec7a59ad..c27bfd151d8a 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/react", - "version": "0.10.0", + "version": "0.11.0", "description": "High performance mutable data rendering in React.", "homepage": "https://dataclient.io", "repository": { @@ -127,7 +127,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.17.0", - "@data-client/core": "^0.10.0", + "@data-client/core": "^0.11.0", "@data-client/use-enhanced-reducer": "^0.1.5" }, "peerDependencies": { diff --git a/packages/redux/CHANGELOG.md b/packages/redux/CHANGELOG.md index 6b058cf12237..e39a7db81aef 100644 --- a/packages/redux/CHANGELOG.md +++ b/packages/redux/CHANGELOG.md @@ -1,5 +1,18 @@ # @data-client/redux +## 0.11.0 + +### Patch Changes + +- [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0) Thanks [@ntucker](https://github.com/ntucker)! - Update description in package.json + +- [`ba636a7`](https://github.com/reactive/data-client/commit/ba636a74e77bf5cb8c2b327e161db09f4c4a7192) Thanks [@ntucker](https://github.com/ntucker)! - Support 0.11.0 of @data-client pkgs + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Update README + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161)]: + - @data-client/core@0.11.0 + ## 0.10.0 ### Patch Changes diff --git a/packages/redux/package.json b/packages/redux/package.json index 28e94c592841..e4e23cc0850f 100644 --- a/packages/redux/package.json +++ b/packages/redux/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/redux", - "version": "0.10.0", + "version": "0.11.0", "description": "Asynchronous data framework for React", "homepage": "https://dataclient.io", "repository": { @@ -107,7 +107,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.17.0", - "@data-client/core": "^0.10.0" + "@data-client/core": "^0.11.0" }, "peerDependencies": { "@data-client/react": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0", diff --git a/packages/rest/CHANGELOG.md b/packages/rest/CHANGELOG.md index 2ae44c29d4e2..8df5dc36795e 100644 --- a/packages/rest/CHANGELOG.md +++ b/packages/rest/CHANGELOG.md @@ -1,5 +1,170 @@ # @data-client/rest +## 0.11.0 + +### Minor Changes + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: new AbortOptimistic() -> [snapshot.abort](https://dataclient/docs/api/Snapshot#abort) + + #### Before + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw new AbortOptimistic(); + return { + id, + votes: data.votes + 1, + }; + } + ``` + + #### After + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: new Query -> [new schema.Query](https://dataclient.io/rest/api/Query) + + #### Before + + ```jsx + const getUserCount = new Query( + new schema.All(User), + (entries, { isAdmin } = {}) => { + if (isAdmin !== undefined) + return entries.filter((user) => user.isAdmin === isAdmin).length; + return entries.length; + }, + ); + + const userCount = useCache(getUserCount); + const adminCount = useCache(getUserCount, { isAdmin: true }); + ``` + + #### After + + ```jsx + const getUserCount = new schema.Query( + new schema.All(User), + (entries, { isAdmin } = {}) => { + if (isAdmin !== undefined) + return entries.filter((user) => user.isAdmin === isAdmin).length; + return entries.length; + }, + ); + + const userCount = useQuery(getUserCount); + const adminCount = useQuery(getUserCount, { isAdmin: true }); + ``` + +- [#2957](https://github.com/reactive/data-client/pull/2957) [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: Remove new AbortOptimistic() in favor of [snapshot.abort](https://dataclient.io/docs/api/Snapshot#abort) + + ```ts + getOptimisticResponse(snapshot, { id }) { + const { data } = snapshot.getResponse(Base.get, { id }); + if (!data) throw snapshot.abort; + return { + id, + votes: data.votes + 1, + }; + } + ``` + +- [#2972](https://github.com/reactive/data-client/pull/2972) [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: Entity.useIncoming → [Entity.shouldUpdate](https://dataclient.io/rest/api/Entity#shouldupdate)) + + ```ts title="Before" + class MyEntity extends Entity { + // highlight-next-line + static useIncoming( + existingMeta: { date: number }, + incomingMeta: { date: number }, + existing: any, + incoming: any, + ) { + return !deepEquals(existing, incoming); + } + } + ``` + + ```ts title="After" + class MyEntity extends Entity { + // highlight-next-line + static shouldUpdate( + existingMeta: { date: number }, + incomingMeta: { date: number }, + existing: any, + incoming: any, + ) { + return !deepEquals(existing, incoming); + } + } + ``` + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING: useCache(new Index(MyEntity)) -> useQuery(MyEntity) + + #### Before + + ```jsx + const UserIndex = new Index(User); + + const bob = useCache(UserIndex, { username: "bob" }); + ``` + + #### After + + ```jsx + const bob = useQuery(User, { username: "bob" }); + ``` + +### 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) + +- [#2962](https://github.com/reactive/data-client/pull/2962) [`f6f195d`](https://github.com/reactive/data-client/commit/f6f195d573c7c51dc63361a48b2ef804181a348b) Thanks [@ntucker](https://github.com/ntucker)! - Improve .extend() typing when using loose null checks and no body parameter + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Update README + +- [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d) Thanks [@ntucker](https://github.com/ntucker)! - fix: Resource.getList.schema args types + +- [#2961](https://github.com/reactive/data-client/pull/2961) [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1) Thanks [@ntucker](https://github.com/ntucker)! - Allow pk() to return numbers + + Before: + + ```ts + class MyEntity extends Entity { + id = 0; + pk() { + return `${this.id}`; + } + } + ``` + + After: + + ```ts + class MyEntity extends Entity { + id = 0; + pk() { + return this.id; + } + } + ``` + +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd)]: + - @data-client/endpoint@0.11.0 + ## 0.10.0 ### Minor Changes @@ -447,13 +612,11 @@ BREAKING: Calling super.getRequestInit() will return a promise - so you must resolve it: ```ts -class AuthdEndpoint< - O extends RestGenerics = any, -> extends RestEndpoint { +class AuthdEndpoint extends RestEndpoint { getRequestInit(body: any): RequestInit { return { ...super.getRequestInit(body), - credentials: 'same-origin', + credentials: "same-origin", }; } } @@ -462,13 +625,11 @@ class AuthdEndpoint< -> ```ts -class AuthdEndpoint< - O extends RestGenerics = any, -> extends RestEndpoint { +class AuthdEndpoint extends RestEndpoint { async getRequestInit(body: any): Promise { return { ...(await super.getRequestInit(body)), - credentials: 'same-origin', + credentials: "same-origin", }; } } diff --git a/packages/rest/package.json b/packages/rest/package.json index 87e1c46de10f..fa2c6665c24f 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/rest", - "version": "0.10.0", + "version": "0.11.0", "description": "Endpoints for REST APIs", "homepage": "https://dataclient.io/rest", "repository": { @@ -126,7 +126,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.17.0", - "@data-client/endpoint": "^0.10.0", + "@data-client/endpoint": "^0.11.0", "path-to-regexp": "^6.2.1" }, "devDependencies": { diff --git a/packages/ssr/CHANGELOG.md b/packages/ssr/CHANGELOG.md index ba716e08a839..42ecda745d6a 100644 --- a/packages/ssr/CHANGELOG.md +++ b/packages/ssr/CHANGELOG.md @@ -1,5 +1,11 @@ # @data-client/ssr +## 0.11.0 + +### Patch Changes + +- [`ba636a7`](https://github.com/reactive/data-client/commit/ba636a74e77bf5cb8c2b327e161db09f4c4a7192) Thanks [@ntucker](https://github.com/ntucker)! - Support 0.11.0 of @data-client pkgs + ## 0.10.0 ### Patch Changes diff --git a/packages/ssr/package.json b/packages/ssr/package.json index 4c656aa2389d..b761e8f6f2a6 100644 --- a/packages/ssr/package.json +++ b/packages/ssr/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/ssr", - "version": "0.10.0", + "version": "0.11.0", "description": "Server Side Rendering helpers for Data Client", "homepage": "https://dataclient.io/docs/guides/ssr", "repository": { diff --git a/packages/test/CHANGELOG.md b/packages/test/CHANGELOG.md index c31490640fb5..feef27e1a576 100644 --- a/packages/test/CHANGELOG.md +++ b/packages/test/CHANGELOG.md @@ -1,5 +1,13 @@ # @data-client/test +## 0.11.0 + +### Patch Changes + +- [`ba636a7`](https://github.com/reactive/data-client/commit/ba636a74e77bf5cb8c2b327e161db09f4c4a7192) Thanks [@ntucker](https://github.com/ntucker)! - Support 0.11.0 of @data-client pkgs + +- [#2921](https://github.com/reactive/data-client/pull/2921) [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa) Thanks [@ntucker](https://github.com/ntucker)! - Update README + ## 0.10.0 ### Patch Changes diff --git a/packages/test/package.json b/packages/test/package.json index 8991ba20bcca..0c9101ecaf16 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -1,6 +1,6 @@ { "name": "@data-client/test", - "version": "0.10.0", + "version": "0.11.0", "description": "Testing utilities for Data Client", "homepage": "https://dataclient.io/docs/guides/storybook", "repository": { diff --git a/website/CHANGELOG.md b/website/CHANGELOG.md index 158fc5d062e8..6cd8385848db 100644 --- a/website/CHANGELOG.md +++ b/website/CHANGELOG.md @@ -4,6 +4,18 @@ ### Patch Changes +- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`7580500`](https://github.com/reactive/data-client/commit/7580500cecb2c4baa093f4db7b951af4840a0967), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`73de27f`](https://github.com/reactive/data-client/commit/73de27fadb214c3c2995ca558daa9736312de7a9), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`f6f195d`](https://github.com/reactive/data-client/commit/f6f195d573c7c51dc63361a48b2ef804181a348b), [`ba636a7`](https://github.com/reactive/data-client/commit/ba636a74e77bf5cb8c2b327e161db09f4c4a7192), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`8d42ef6`](https://github.com/reactive/data-client/commit/8d42ef6fae10859bcac1812cdbe637c739afaa6d), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161), [`f68750f`](https://github.com/reactive/data-client/commit/f68750f8b0cafa66f6d50521e474db5e3d3c9cdd)]: + - @data-client/endpoint@0.11.0 + - @data-client/react@0.11.0 + - @data-client/rest@0.11.0 + - @data-client/graphql@0.11.0 + - @data-client/test@0.11.0 + - @data-client/hooks@0.1.8 + +## null + +### Patch Changes + - Updated dependencies [[`44f9ec2`](https://github.com/reactive/data-client/commit/44f9ec2801fe389a5afb215553a3441143078803), [`922be79`](https://github.com/reactive/data-client/commit/922be79169a3eeea8e336eee519c165431ead474), [`44f9ec2`](https://github.com/reactive/data-client/commit/44f9ec2801fe389a5afb215553a3441143078803), [`053e823`](https://github.com/reactive/data-client/commit/053e82377bd29f200cd7dfbc700da7a3ad7fa8d7), [`922be79`](https://github.com/reactive/data-client/commit/922be79169a3eeea8e336eee519c165431ead474), [`69834b5`](https://github.com/reactive/data-client/commit/69834b50c6d2b33f46d7c63cabdc0744abf160ae), [`bf9c79c`](https://github.com/reactive/data-client/commit/bf9c79cb42e3df091eafe63fee619764a7ae4350)]: - @data-client/rest@0.10.0 - @data-client/test@0.10.0 diff --git a/yarn.lock b/yarn.lock index 6cdd10f7e6b6..eb5befa71022 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3125,19 +3125,19 @@ __metadata: languageName: node linkType: hard -"@data-client/core@npm:^0.10.0, @data-client/core@workspace:^, @data-client/core@workspace:packages/core": +"@data-client/core@npm:^0.11.0, @data-client/core@workspace:^, @data-client/core@workspace:packages/core": version: 0.0.0-use.local resolution: "@data-client/core@workspace:packages/core" dependencies: "@anansi/browserslist-config": "npm:^1.4.2" "@babel/runtime": "npm:^7.17.0" - "@data-client/normalizr": "npm:^0.10.0" + "@data-client/normalizr": "npm:^0.11.0" "@types/node": "npm:^20.0.0" flux-standard-action: "npm:^2.1.1" languageName: unknown linkType: soft -"@data-client/endpoint@npm:^0.10.0, @data-client/endpoint@workspace:*, @data-client/endpoint@workspace:^, @data-client/endpoint@workspace:packages/endpoint": +"@data-client/endpoint@npm:^0.11.0, @data-client/endpoint@workspace:*, @data-client/endpoint@workspace:^, @data-client/endpoint@workspace:packages/endpoint": version: 0.0.0-use.local resolution: "@data-client/endpoint@workspace:packages/endpoint" dependencies: @@ -3154,7 +3154,7 @@ __metadata: dependencies: "@anansi/browserslist-config": "npm:^1.4.2" "@babel/runtime": "npm:^7.17.0" - "@data-client/endpoint": "npm:^0.10.0" + "@data-client/endpoint": "npm:^0.11.0" "@types/node": "npm:^20.0.0" languageName: unknown linkType: soft @@ -3165,7 +3165,7 @@ __metadata: dependencies: "@anansi/browserslist-config": "npm:^1.4.2" "@babel/runtime": "npm:^7.17.0" - "@data-client/normalizr": "npm:^0.10.0" + "@data-client/normalizr": "npm:^0.11.0" "@types/node": "npm:^20.0.0" "@types/react": "npm:^18.0.30" peerDependencies: @@ -3177,13 +3177,13 @@ __metadata: languageName: unknown linkType: soft -"@data-client/img@npm:^0.10.0, @data-client/img@workspace:packages/img": +"@data-client/img@npm:^0.11.0, @data-client/img@workspace:packages/img": version: 0.0.0-use.local resolution: "@data-client/img@workspace:packages/img" dependencies: "@anansi/browserslist-config": "npm:^1.4.2" "@babel/runtime": "npm:^7.17.0" - "@data-client/endpoint": "npm:^0.10.0" + "@data-client/endpoint": "npm:^0.11.0" "@data-client/react": "workspace:*" "@types/node": "npm:^20.0.0" "@types/react": "npm:^18.0.30" @@ -3197,7 +3197,7 @@ __metadata: languageName: unknown linkType: soft -"@data-client/normalizr@npm:^0.10.0, @data-client/normalizr@workspace:*, @data-client/normalizr@workspace:^, @data-client/normalizr@workspace:packages/normalizr": +"@data-client/normalizr@npm:^0.11.0, @data-client/normalizr@workspace:*, @data-client/normalizr@workspace:^, @data-client/normalizr@workspace:packages/normalizr": version: 0.0.0-use.local resolution: "@data-client/normalizr@workspace:packages/normalizr" dependencies: @@ -3208,13 +3208,13 @@ __metadata: languageName: unknown linkType: soft -"@data-client/react@npm:^0.10.0, @data-client/react@workspace:*, @data-client/react@workspace:^, @data-client/react@workspace:packages/react": +"@data-client/react@npm:^0.11.0, @data-client/react@workspace:*, @data-client/react@workspace:^, @data-client/react@workspace:packages/react": version: 0.0.0-use.local resolution: "@data-client/react@workspace:packages/react" dependencies: "@anansi/browserslist-config": "npm:^1.4.2" "@babel/runtime": "npm:^7.17.0" - "@data-client/core": "npm:^0.10.0" + "@data-client/core": "npm:^0.11.0" "@data-client/use-enhanced-reducer": "npm:^0.1.5" "@react-navigation/native": "npm:^6.1.6" "@types/node": "npm:^20.0.0" @@ -3232,13 +3232,13 @@ __metadata: languageName: unknown linkType: soft -"@data-client/redux@npm:^0.10.0, @data-client/redux@workspace:*, @data-client/redux@workspace:packages/redux": +"@data-client/redux@npm:^0.11.0, @data-client/redux@workspace:*, @data-client/redux@workspace:packages/redux": version: 0.0.0-use.local resolution: "@data-client/redux@workspace:packages/redux" dependencies: "@anansi/browserslist-config": "npm:^1.4.2" "@babel/runtime": "npm:^7.17.0" - "@data-client/core": "npm:^0.10.0" + "@data-client/core": "npm:^0.11.0" "@data-client/react": "workspace:*" "@types/node": "npm:^20.0.0" "@types/react": "npm:^18.0.30" @@ -3254,20 +3254,41 @@ __metadata: languageName: unknown linkType: soft -"@data-client/rest@npm:^0.10.0, @data-client/rest@workspace:*, @data-client/rest@workspace:packages/rest": +"@data-client/rest@npm:^0.11.0, @data-client/rest@workspace:*, @data-client/rest@workspace:packages/rest": version: 0.0.0-use.local resolution: "@data-client/rest@workspace:packages/rest" dependencies: "@anansi/browserslist-config": "npm:^1.4.2" "@babel/runtime": "npm:^7.17.0" - "@data-client/endpoint": "npm:^0.10.0" + "@data-client/endpoint": "npm:^0.11.0" "@types/node": "npm:^20.0.0" "@types/path-to-regexp": "npm:^1.7.0" path-to-regexp: "npm:^6.2.1" languageName: unknown linkType: soft -"@data-client/ssr@npm:^0.10.0, @data-client/ssr@workspace:packages/ssr": +"@data-client/ssr@npm:^0.10.0": + version: 0.10.0 + resolution: "@data-client/ssr@npm:0.10.0" + dependencies: + "@babel/runtime": "npm:^7.17.0" + peerDependencies: + "@data-client/react": ^0.1.0 || ^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 + "@data-client/redux": ^0.1.0 || ^0.2.0 || ^0.3.0 || ^0.5.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 + "@types/react": ^16.8.4 || ^17.0.0 || ^18.0.0-0 + next: ">=12.0.0" + react: ^16.8.4 || ^17.0.0 || ^18.0.0-0 + redux: ^4.0.0 || ^5.0.0 + peerDependenciesMeta: + "@types/react": + optional: true + next: + optional: true + checksum: 10c0/9695c73862fa90bdd5ccafe8f0d421ac4fe769275b4bb43d6beb41feb8f9d65bbe1b21ead5c23b21d4d35fafe6e7581defb812a95536362df405b6c4cb75b287 + languageName: node + linkType: hard + +"@data-client/ssr@workspace:packages/ssr": version: 0.0.0-use.local resolution: "@data-client/ssr@workspace:packages/ssr" dependencies: @@ -10363,10 +10384,10 @@ __metadata: "@anansi/webpack-config": "npm:^19.0.0" "@babel/core": "npm:^7.22.15" "@babel/runtime": "npm:^7.22.15" - "@data-client/img": "npm:^0.10.0" - "@data-client/react": "npm:^0.10.0" - "@data-client/redux": "npm:^0.10.0" - "@data-client/rest": "npm:^0.10.0" + "@data-client/img": "npm:^0.11.0" + "@data-client/react": "npm:^0.11.0" + "@data-client/redux": "npm:^0.11.0" + "@data-client/rest": "npm:^0.11.0" "@linaria/babel-preset": "npm:*" "@linaria/core": "npm:*" "@linaria/react": "npm:*"