From 5b6d19b0262c837d0a75442aab76b5c387973445 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Wed, 15 Nov 2023 18:59:04 -0800 Subject: [PATCH] update to latest zenstack + optimistic update --- .gitignore | 1 + components/Todo.tsx | 12 +- lib/hooks/__model_meta.ts | 482 +------------------------- lib/hooks/account.ts | 29 +- lib/hooks/list.ts | 29 +- lib/hooks/space-user.ts | 29 +- lib/hooks/space.ts | 29 +- lib/hooks/todo.ts | 29 +- lib/hooks/user.ts | 29 +- package-lock.json | 455 +++++++++++++++--------- package.json | 11 +- pages/_app.tsx | 4 +- pages/space/[slug]/[listId]/index.tsx | 63 ++-- tailwind.config.js | 2 +- 14 files changed, 508 insertions(+), 696 deletions(-) diff --git a/.gitignore b/.gitignore index 8a77877..a27fa53 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ logs node_modules/ .env.local .next +.zenstack_repl* diff --git a/components/Todo.tsx b/components/Todo.tsx index b7247a7..521f5bd 100644 --- a/components/Todo.tsx +++ b/components/Todo.tsx @@ -7,13 +7,14 @@ import TimeInfo from './TimeInfo'; type Props = { value: Todo & { owner: User }; + optimistic?: boolean; updated?: (value: Todo) => any; deleted?: (value: Todo) => any; }; -export default function TodoComponent({ value }: Props) { - const update = useUpdateTodo(); - const del = useDeleteTodo(); +export default function TodoComponent({ value, optimistic }: Props) { + const update = useUpdateTodo(undefined, true, true); // optimistic + const del = useDeleteTodo(undefined, true, true); // optimistic const deleteTodo = async () => { del.mutate({ where: { id: value.id } }); @@ -33,11 +34,12 @@ export default function TodoComponent({ value }: Props) {

{value.title} + {optimistic && }

, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -20,6 +21,7 @@ export function useCreateAccount( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -45,6 +47,7 @@ export function useCreateAccount( export function useCreateManyAccount( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -56,6 +59,7 @@ export function useCreateManyAccount( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -74,10 +78,11 @@ export function useCreateManyAccount( export function useFindManyAccount( args?: Prisma.SelectSubset, - options?: Omit>>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('Account', `${endpoint}/account/findMany`, args, options, fetch); + return useModelQuery('Account', `${endpoint}/account/findMany`, args, options, fetch, optimisticUpdate); } export function useInfiniteFindManyAccount( @@ -98,23 +103,26 @@ export function useInfiniteFindManyAccount export function useFindUniqueAccount( args: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('Account', `${endpoint}/account/findUnique`, args, options, fetch); + return useModelQuery('Account', `${endpoint}/account/findUnique`, args, options, fetch, optimisticUpdate); } export function useFindFirstAccount( args?: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('Account', `${endpoint}/account/findFirst`, args, options, fetch); + return useModelQuery('Account', `${endpoint}/account/findFirst`, args, options, fetch, optimisticUpdate); } export function useUpdateAccount( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -126,6 +134,7 @@ export function useUpdateAccount( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -151,6 +160,7 @@ export function useUpdateAccount( export function useUpdateManyAccount( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -162,6 +172,7 @@ export function useUpdateManyAccount( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -181,6 +192,7 @@ export function useUpdateManyAccount( export function useUpsertAccount( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -192,6 +204,7 @@ export function useUpsertAccount( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -217,6 +230,7 @@ export function useUpsertAccount( export function useDeleteAccount( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -228,6 +242,7 @@ export function useDeleteAccount( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -253,6 +268,7 @@ export function useDeleteAccount( export function useDeleteManyAccount( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -264,6 +280,7 @@ export function useDeleteManyAccount( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, diff --git a/lib/hooks/list.ts b/lib/hooks/list.ts index b68fa30..41b43d8 100644 --- a/lib/hooks/list.ts +++ b/lib/hooks/list.ts @@ -9,6 +9,7 @@ import metadata from './__model_meta'; export function useCreateList( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -20,6 +21,7 @@ export function useCreateList( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -45,6 +47,7 @@ export function useCreateList( export function useCreateManyList( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -56,6 +59,7 @@ export function useCreateManyList( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -74,10 +78,11 @@ export function useCreateManyList( export function useFindManyList( args?: Prisma.SelectSubset, - options?: Omit>>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('List', `${endpoint}/list/findMany`, args, options, fetch); + return useModelQuery('List', `${endpoint}/list/findMany`, args, options, fetch, optimisticUpdate); } export function useInfiniteFindManyList( @@ -98,23 +103,26 @@ export function useInfiniteFindManyList( export function useFindUniqueList( args: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('List', `${endpoint}/list/findUnique`, args, options, fetch); + return useModelQuery('List', `${endpoint}/list/findUnique`, args, options, fetch, optimisticUpdate); } export function useFindFirstList( args?: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('List', `${endpoint}/list/findFirst`, args, options, fetch); + return useModelQuery('List', `${endpoint}/list/findFirst`, args, options, fetch, optimisticUpdate); } export function useUpdateList( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -126,6 +134,7 @@ export function useUpdateList( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -151,6 +160,7 @@ export function useUpdateList( export function useUpdateManyList( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -162,6 +172,7 @@ export function useUpdateManyList( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -181,6 +192,7 @@ export function useUpdateManyList( export function useUpsertList( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -192,6 +204,7 @@ export function useUpsertList( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -217,6 +230,7 @@ export function useUpsertList( export function useDeleteList( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -228,6 +242,7 @@ export function useDeleteList( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -253,6 +268,7 @@ export function useDeleteList( export function useDeleteManyList( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -264,6 +280,7 @@ export function useDeleteManyList( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, diff --git a/lib/hooks/space-user.ts b/lib/hooks/space-user.ts index 548ab47..57e55e1 100644 --- a/lib/hooks/space-user.ts +++ b/lib/hooks/space-user.ts @@ -9,6 +9,7 @@ import metadata from './__model_meta'; export function useCreateSpaceUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -20,6 +21,7 @@ export function useCreateSpaceUser( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -45,6 +47,7 @@ export function useCreateSpaceUser( export function useCreateManySpaceUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -56,6 +59,7 @@ export function useCreateManySpaceUser( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -78,10 +82,11 @@ export function useCreateManySpaceUser( export function useFindManySpaceUser( args?: Prisma.SelectSubset, - options?: Omit>>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('SpaceUser', `${endpoint}/spaceUser/findMany`, args, options, fetch); + return useModelQuery('SpaceUser', `${endpoint}/spaceUser/findMany`, args, options, fetch, optimisticUpdate); } export function useInfiniteFindManySpaceUser( @@ -102,23 +107,26 @@ export function useInfiniteFindManySpaceUser( args: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('SpaceUser', `${endpoint}/spaceUser/findUnique`, args, options, fetch); + return useModelQuery('SpaceUser', `${endpoint}/spaceUser/findUnique`, args, options, fetch, optimisticUpdate); } export function useFindFirstSpaceUser( args?: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('SpaceUser', `${endpoint}/spaceUser/findFirst`, args, options, fetch); + return useModelQuery('SpaceUser', `${endpoint}/spaceUser/findFirst`, args, options, fetch, optimisticUpdate); } export function useUpdateSpaceUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -130,6 +138,7 @@ export function useUpdateSpaceUser( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -155,6 +164,7 @@ export function useUpdateSpaceUser( export function useUpdateManySpaceUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -166,6 +176,7 @@ export function useUpdateManySpaceUser( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -189,6 +200,7 @@ export function useUpdateManySpaceUser( export function useUpsertSpaceUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -200,6 +212,7 @@ export function useUpsertSpaceUser( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -225,6 +238,7 @@ export function useUpsertSpaceUser( export function useDeleteSpaceUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -236,6 +250,7 @@ export function useDeleteSpaceUser( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -261,6 +276,7 @@ export function useDeleteSpaceUser( export function useDeleteManySpaceUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -272,6 +288,7 @@ export function useDeleteManySpaceUser( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, diff --git a/lib/hooks/space.ts b/lib/hooks/space.ts index 6caaa16..d654af7 100644 --- a/lib/hooks/space.ts +++ b/lib/hooks/space.ts @@ -9,6 +9,7 @@ import metadata from './__model_meta'; export function useCreateSpace( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -20,6 +21,7 @@ export function useCreateSpace( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -45,6 +47,7 @@ export function useCreateSpace( export function useCreateManySpace( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -56,6 +59,7 @@ export function useCreateManySpace( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -74,10 +78,11 @@ export function useCreateManySpace( export function useFindManySpace( args?: Prisma.SelectSubset, - options?: Omit>>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('Space', `${endpoint}/space/findMany`, args, options, fetch); + return useModelQuery('Space', `${endpoint}/space/findMany`, args, options, fetch, optimisticUpdate); } export function useInfiniteFindManySpace( @@ -98,23 +103,26 @@ export function useInfiniteFindManySpace( export function useFindUniqueSpace( args: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('Space', `${endpoint}/space/findUnique`, args, options, fetch); + return useModelQuery('Space', `${endpoint}/space/findUnique`, args, options, fetch, optimisticUpdate); } export function useFindFirstSpace( args?: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('Space', `${endpoint}/space/findFirst`, args, options, fetch); + return useModelQuery('Space', `${endpoint}/space/findFirst`, args, options, fetch, optimisticUpdate); } export function useUpdateSpace( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -126,6 +134,7 @@ export function useUpdateSpace( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -151,6 +160,7 @@ export function useUpdateSpace( export function useUpdateManySpace( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -162,6 +172,7 @@ export function useUpdateManySpace( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -181,6 +192,7 @@ export function useUpdateManySpace( export function useUpsertSpace( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -192,6 +204,7 @@ export function useUpsertSpace( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -217,6 +230,7 @@ export function useUpsertSpace( export function useDeleteSpace( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -228,6 +242,7 @@ export function useDeleteSpace( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -253,6 +268,7 @@ export function useDeleteSpace( export function useDeleteManySpace( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -264,6 +280,7 @@ export function useDeleteManySpace( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, diff --git a/lib/hooks/todo.ts b/lib/hooks/todo.ts index f41f098..bb09cd8 100644 --- a/lib/hooks/todo.ts +++ b/lib/hooks/todo.ts @@ -9,6 +9,7 @@ import metadata from './__model_meta'; export function useCreateTodo( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -20,6 +21,7 @@ export function useCreateTodo( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -45,6 +47,7 @@ export function useCreateTodo( export function useCreateManyTodo( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -56,6 +59,7 @@ export function useCreateManyTodo( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -74,10 +78,11 @@ export function useCreateManyTodo( export function useFindManyTodo( args?: Prisma.SelectSubset, - options?: Omit>>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('Todo', `${endpoint}/todo/findMany`, args, options, fetch); + return useModelQuery('Todo', `${endpoint}/todo/findMany`, args, options, fetch, optimisticUpdate); } export function useInfiniteFindManyTodo( @@ -98,23 +103,26 @@ export function useInfiniteFindManyTodo( export function useFindUniqueTodo( args: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('Todo', `${endpoint}/todo/findUnique`, args, options, fetch); + return useModelQuery('Todo', `${endpoint}/todo/findUnique`, args, options, fetch, optimisticUpdate); } export function useFindFirstTodo( args?: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('Todo', `${endpoint}/todo/findFirst`, args, options, fetch); + return useModelQuery('Todo', `${endpoint}/todo/findFirst`, args, options, fetch, optimisticUpdate); } export function useUpdateTodo( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -126,6 +134,7 @@ export function useUpdateTodo( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -151,6 +160,7 @@ export function useUpdateTodo( export function useUpdateManyTodo( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -162,6 +172,7 @@ export function useUpdateManyTodo( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -181,6 +192,7 @@ export function useUpdateManyTodo( export function useUpsertTodo( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -192,6 +204,7 @@ export function useUpsertTodo( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -217,6 +230,7 @@ export function useUpsertTodo( export function useDeleteTodo( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -228,6 +242,7 @@ export function useDeleteTodo( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -253,6 +268,7 @@ export function useDeleteTodo( export function useDeleteManyTodo( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -264,6 +280,7 @@ export function useDeleteManyTodo( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, diff --git a/lib/hooks/user.ts b/lib/hooks/user.ts index a2fd46d..400dff3 100644 --- a/lib/hooks/user.ts +++ b/lib/hooks/user.ts @@ -9,6 +9,7 @@ import metadata from './__model_meta'; export function useCreateUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -20,6 +21,7 @@ export function useCreateUser( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -45,6 +47,7 @@ export function useCreateUser( export function useCreateManyUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -56,6 +59,7 @@ export function useCreateManyUser( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -74,10 +78,11 @@ export function useCreateManyUser( export function useFindManyUser( args?: Prisma.SelectSubset, - options?: Omit>>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('User', `${endpoint}/user/findMany`, args, options, fetch); + return useModelQuery('User', `${endpoint}/user/findMany`, args, options, fetch, optimisticUpdate); } export function useInfiniteFindManyUser( @@ -98,23 +103,26 @@ export function useInfiniteFindManyUser( export function useFindUniqueUser( args: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('User', `${endpoint}/user/findUnique`, args, options, fetch); + return useModelQuery('User', `${endpoint}/user/findUnique`, args, options, fetch, optimisticUpdate); } export function useFindFirstUser( args?: Prisma.SelectSubset, - options?: Omit>, 'queryKey'>, + options?: Omit & { $optimistic?: boolean }>, 'queryKey'>, + optimisticUpdate: boolean = true, ) { const { endpoint, fetch } = getHooksContext(); - return useModelQuery('User', `${endpoint}/user/findFirst`, args, options, fetch); + return useModelQuery('User', `${endpoint}/user/findFirst`, args, options, fetch, optimisticUpdate); } export function useUpdateUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -126,6 +134,7 @@ export function useUpdateUser( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -151,6 +160,7 @@ export function useUpdateUser( export function useUpdateManyUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -162,6 +172,7 @@ export function useUpdateManyUser( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -181,6 +192,7 @@ export function useUpdateManyUser( export function useUpsertUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -192,6 +204,7 @@ export function useUpsertUser( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -217,6 +230,7 @@ export function useUpsertUser( export function useDeleteUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -228,6 +242,7 @@ export function useDeleteUser( fetch, invalidateQueries, true, + optimisticUpdate, ); const mutation = { ..._mutation, @@ -253,6 +268,7 @@ export function useDeleteUser( export function useDeleteManyUser( options?: Omit, 'mutationFn'>, invalidateQueries: boolean = true, + optimisticUpdate: boolean = false, ) { const { endpoint, fetch } = getHooksContext(); const _mutation = useModelMutation( @@ -264,6 +280,7 @@ export function useDeleteManyUser( fetch, invalidateQueries, false, + optimisticUpdate, ); const mutation = { ..._mutation, diff --git a/package-lock.json b/package-lock.json index 045cfe1..a57ed11 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,12 +12,13 @@ "@next-auth/prisma-adapter": "^1.0.5", "@prisma/client": "^4.9.0", "@tanstack/react-query": "^5.0.5", - "@zenstackhq/runtime": "^1.2.0", - "@zenstackhq/server": "^1.2.0", - "@zenstackhq/tanstack-query": "^1.2.0", + "@tanstack/react-query-devtools": "^5.8.3", + "@zenstackhq/runtime": "^1.3.0", + "@zenstackhq/server": "^1.3.0", + "@zenstackhq/tanstack-query": "^1.3.0", "babel-plugin-superjson-next": "^0.4.5", "bcryptjs": "^2.4.3", - "daisyui": "^2.31.0", + "daisyui": "^4.0.7", "decimal.js": "^10.4.3", "moment": "^2.29.4", "nanoid": "^4.0.0", @@ -42,7 +43,7 @@ "prisma": "^4.9.0", "tailwindcss": "^3.1.8", "typescript": "^5.2.2", - "zenstack": "^1.2.0" + "zenstack": "^1.3.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -58,6 +59,7 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", + "dev": true, "engines": { "node": ">=10" }, @@ -296,6 +298,7 @@ "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, "dependencies": { "@jridgewell/set-array": "^1.0.1", "@jridgewell/sourcemap-codec": "^1.4.10", @@ -309,6 +312,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, "engines": { "node": ">=6.0.0" } @@ -317,6 +321,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, "engines": { "node": ">=6.0.0" } @@ -324,12 +329,14 @@ "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.15", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.18", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "dev": true, "dependencies": { "@jridgewell/resolve-uri": "3.1.0", "@jridgewell/sourcemap-codec": "1.4.14" @@ -338,7 +345,8 @@ "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.14", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true }, "node_modules/@next-auth/prisma-adapter": { "version": "1.0.7", @@ -649,11 +657,11 @@ } }, "node_modules/@prisma/debug": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.5.2.tgz", - "integrity": "sha512-OeyuNABo1dgWHIQuJAdvW5qp5ccFfbI0CKNvdg8D34YWOfo6L+4J0gmnRI/j+h40HvM3S5WH2T8e3W9bPa7EVg==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.6.0.tgz", + "integrity": "sha512-rVQuC5/4FvGvAwUEISumRctLnW2VGCzp8yfzqZhupYtKWWjAhP7amAMYg8wjfuBJ9eARfVDTG88sjelBdboy0g==", "dependencies": { - "@types/debug": "4.1.9", + "@types/debug": "4.1.12", "debug": "4.3.4", "strip-ansi": "6.0.1" } @@ -712,12 +720,12 @@ } }, "node_modules/@prisma/generator-helper": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@prisma/generator-helper/-/generator-helper-5.5.2.tgz", - "integrity": "sha512-qQz4JfhjjMs+C/dbZUoGAU+JV685Qe72iGonDM0c9H05A5s5MCWj5wV2kVi1/DNiy7jkfqGGM7bX8k0/8yO0FQ==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@prisma/generator-helper/-/generator-helper-5.6.0.tgz", + "integrity": "sha512-trrLzQQAhVhpmrr+I33QoZXY+4uY3lJL8qUUm8QAtk6iIY0f9Y2zgoEbHa9UfUkHyx1kujRfgi16C0mUeF+DTA==", "dependencies": { - "@prisma/debug": "5.5.2", - "@types/cross-spawn": "6.0.3", + "@prisma/debug": "5.6.0", + "@types/cross-spawn": "6.0.5", "cross-spawn": "7.0.3", "kleur": "4.1.5" } @@ -809,18 +817,18 @@ }, "node_modules/@prisma/internals-v5": { "name": "@prisma/internals", - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@prisma/internals/-/internals-5.5.2.tgz", - "integrity": "sha512-+2F04bTP6yxijP/kqhyqWEKEplNUXJk+dwqjK8UZ8MzGQC8es/aaSvZW5evFGMFaXxbWkEPoX2sz3asmpG3q9g==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@prisma/internals/-/internals-5.6.0.tgz", + "integrity": "sha512-Zvudz6cPs0rGc2+uxujVPX3vVCPL7Ql4GzfPU/OH1U9rDwaxHMuRVmItDy3I3BwMg3SAyJGC9RrKYJzHCzfjPw==", "dependencies": { "@antfu/ni": "0.21.8", - "@opentelemetry/api": "1.6.0", - "@prisma/debug": "5.5.2", - "@prisma/engines": "5.5.2", - "@prisma/fetch-engine": "5.5.2", - "@prisma/generator-helper": "5.5.2", - "@prisma/get-platform": "5.5.2", - "@prisma/prisma-schema-wasm": "5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a", + "@opentelemetry/api": "1.7.0", + "@prisma/debug": "5.6.0", + "@prisma/engines": "5.6.0", + "@prisma/fetch-engine": "5.6.0", + "@prisma/generator-helper": "5.6.0", + "@prisma/get-platform": "5.6.0", + "@prisma/prisma-schema-wasm": "5.6.0-32.e95e739751f42d8ca026f6b910f5a2dc5adeaeee", "archiver": "6.0.1", "arg": "5.0.2", "checkpoint-client": "1.1.27", @@ -846,7 +854,7 @@ "prompts": "2.4.2", "read-pkg-up": "7.0.1", "replace-string": "3.1.0", - "resolve": "1.22.6", + "resolve": "1.22.8", "string-width": "4.2.3", "strip-ansi": "6.0.1", "strip-indent": "3.0.0", @@ -854,7 +862,7 @@ "tempy": "1.0.1", "terminal-link": "2.1.1", "tmp": "0.2.1", - "ts-pattern": "4.3.0" + "ts-pattern": "5.0.5" } }, "node_modules/@prisma/internals-v5/node_modules/@antfu/ni": { @@ -872,26 +880,26 @@ } }, "node_modules/@prisma/internals-v5/node_modules/@opentelemetry/api": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.6.0.tgz", - "integrity": "sha512-OWlrQAnWn9577PhVgqjUvMr1pg57Bc4jv0iL4w0PRuOSRvq67rvHW9Ie/dZVMvCzhSCB+UxhcY/PmCmFj33Q+g==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.7.0.tgz", + "integrity": "sha512-AdY5wvN0P2vXBi3b29hxZgSFvdhdxPB9+f0B6s//P9Q8nibRWeA3cHm8UmLpio9ABigkVHJ5NMPk+Mz8VCCyrw==", "engines": { "node": ">=8.0.0" } }, "node_modules/@prisma/internals-v5/node_modules/@prisma/engines": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.5.2.tgz", - "integrity": "sha512-Be5hoNF8k+lkB3uEMiCHbhbfF6aj1GnrTBnn5iYFT7GEr3TsOEp1soviEcBR0tYCgHbxjcIxJMhdbvxALJhAqg==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.6.0.tgz", + "integrity": "sha512-Mt2q+GNJpU2vFn6kif24oRSBQv1KOkYaterQsi0k2/lA+dLvhRX6Lm26gon6PYHwUM8/h8KRgXIUMU0PCLB6bw==", "hasInstallScript": true }, "node_modules/@prisma/internals-v5/node_modules/@prisma/fetch-engine": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.5.2.tgz", - "integrity": "sha512-Ab6vZSQhuMeew0jmP6PFzdJOt9YZ957rlu6IU/T0pNZRhk2cKb8IwCq4K1ru1c5iKpFBJIjA2bUw7eTAE0gTDw==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.6.0.tgz", + "integrity": "sha512-B6jfOZMioKyAsSDjYeVkF7P9X7DTfqLJPVUeHt0wnF50cSOqB260GFaVVZLlYwMJUew4YVaI+qmbCuPBBZVAOQ==", "dependencies": { - "@prisma/debug": "5.5.2", - "@prisma/get-platform": "5.5.2", + "@prisma/debug": "5.6.0", + "@prisma/get-platform": "5.6.0", "execa": "5.1.1", "find-cache-dir": "3.3.2", "fs-extra": "11.1.1", @@ -910,11 +918,11 @@ } }, "node_modules/@prisma/internals-v5/node_modules/@prisma/get-platform": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.5.2.tgz", - "integrity": "sha512-Y4jLZYyAtd/kIPGhP3OpxJvroxX0K28wdUv1c94jIfCNelOMMLvWsPx/q3XLe0fzeXvSsdHkw0mPKCh/iupvhQ==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.6.0.tgz", + "integrity": "sha512-Uk9Frvvp32YzQlZAH4m/wWkdAYGmQgGKPmBITsyZwvuTh+tcJIbWix8kt37wNy+oExUG9vopOc+89eZXPgkoVQ==", "dependencies": { - "@prisma/debug": "5.5.2", + "@prisma/debug": "5.6.0", "escape-string-regexp": "4.0.0", "execa": "5.1.1", "fs-jetpack": "5.1.0", @@ -923,7 +931,7 @@ "strip-ansi": "6.0.1", "tempy": "1.0.1", "terminal-link": "2.1.1", - "ts-pattern": "4.3.0" + "ts-pattern": "5.0.5" } }, "node_modules/@prisma/internals-v5/node_modules/archiver": { @@ -1105,9 +1113,9 @@ } }, "node_modules/@prisma/internals-v5/node_modules/resolve": { - "version": "1.22.6", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.6.tgz", - "integrity": "sha512-njhxM7mV12JfufShqGy3Rz8j11RPdLy4xi15UurGJeoHLfJpVXKdh3ueuOqbYUcDZnffr6X739JBo5LzyahEsw==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "dependencies": { "is-core-module": "^2.13.0", "path-parse": "^1.0.7", @@ -1130,6 +1138,11 @@ "streamx": "^2.15.0" } }, + "node_modules/@prisma/internals-v5/node_modules/ts-pattern": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-5.0.5.tgz", + "integrity": "sha512-tL0w8U/pgaacOmkb9fRlYzWEUDCfVjjv9dD4wHTgZ61MjhuMt46VNWTG747NqW6vRzoWIKABVhFSOJ82FvXrfA==" + }, "node_modules/@prisma/internals-v5/node_modules/uuid": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", @@ -1194,9 +1207,9 @@ "integrity": "sha512-g090+dEH7wrdCw359+8J9+TGH84qK28V/dxwINjhhNCtju9lej99z9w/AVsJP9UhhcCPS4psYz4iu8d53uxVpA==" }, "node_modules/@prisma/prisma-schema-wasm": { - "version": "5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a", - "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a.tgz", - "integrity": "sha512-dPOyEqjExFgXsfZTzKOuYM2ycWQbep5WtF/23KP8C+xq+XTr1725CMpERa8KaKQlDlRn+aE53qOON/wqXptGdg==" + "version": "5.6.0-32.e95e739751f42d8ca026f6b910f5a2dc5adeaeee", + "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.6.0-32.e95e739751f42d8ca026f6b910f5a2dc5adeaeee.tgz", + "integrity": "sha512-ZBLFM21ICn5wA/uzvNEpzLsnUGud5P7+O5DjRVI5VRZ6+j/QEDQQkiNxVEmCGYQgVsD76PiI+/BmbruzX+uTbQ==" }, "node_modules/@rushstack/eslint-patch": { "version": "1.3.2", @@ -1222,20 +1235,29 @@ } }, "node_modules/@tanstack/query-core": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.0.5.tgz", - "integrity": "sha512-MThCETMkHDHTnFZHp71L+SqTtD5d6XHftFCVR1xRJdWM3qGrlQ2VCXaj0SKVcyJej2e1Opa2c7iknu1llxCDNQ==", + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.8.3.tgz", + "integrity": "sha512-SWFMFtcHfttLYif6pevnnMYnBvxKf3C+MHMH7bevyYfpXpTMsLB9O6nNGBdWSoPwnZRXFNyNeVZOw25Wmdasow==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/query-devtools": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/@tanstack/query-devtools/-/query-devtools-5.8.3.tgz", + "integrity": "sha512-tgVzqWpIg611UXqoIkyOLjEdrV3uNXg86kPrst0/OUP59znma68mOAHw8OEy/xxjN3t94InOfWhmVtkSQ9E8Lg==", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" } }, "node_modules/@tanstack/react-query": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.0.5.tgz", - "integrity": "sha512-ZG0Q4HZ0iuI8mWiZ2/MdVYPHbrmAVhMn7+gLOkxJh6zLIgCL4luSZlohzN5Xt4MjxfxxWioO1nemwpudaTsmQg==", + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.8.3.tgz", + "integrity": "sha512-EDRrsMgUtKM+SjVmhDYBd4jwWWyHAw3kCaurKLIO90OfPQr/UhpwcqM2l/eQOaUYon9lfDB2ejQi1edHK7zEdA==", "dependencies": { - "@tanstack/query-core": "5.0.5" + "@tanstack/query-core": "5.8.3" }, "funding": { "type": "github", @@ -1255,6 +1277,23 @@ } } }, + "node_modules/@tanstack/react-query-devtools": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/@tanstack/react-query-devtools/-/react-query-devtools-5.8.3.tgz", + "integrity": "sha512-C36SQVh3wEjj+wEage2nyPBXQJj+gMqmbyXvUAVwywUjHC8OdpyYFkTiVQVRlPcxh+Td2qhsrn1IHPxd39YkrQ==", + "dependencies": { + "@tanstack/query-devtools": "5.8.3" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "@tanstack/react-query": "^5.8.3", + "react": "^18.0.0", + "react-dom": "^18.0.0" + } + }, "node_modules/@ts-morph/common": { "version": "0.17.0", "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.17.0.tgz", @@ -1291,17 +1330,17 @@ "integrity": "sha512-LiMQ6EOPob/4yUL66SZzu6Yh77cbzJFYll+ZfaPiPPFswtIlA/Fs1MzdKYA7JApHU49zQTbJGX3PDmCpIdDBRQ==" }, "node_modules/@types/cross-spawn": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/@types/cross-spawn/-/cross-spawn-6.0.3.tgz", - "integrity": "sha512-BDAkU7WHHRHnvBf5z89lcvACsvkz/n7Tv+HyD/uW76O29HoH1Tk/W6iQrepaZVbisvlEek4ygwT8IW7ow9XLAA==", + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/@types/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-wsIMP68FvGXk+RaWhraz6Xp4v7sl4qwzHAmtPaJEN2NRTXXI9LtFawUpeTsBNL/pd6QoLStdytCaAyiK7AEd/Q==", "dependencies": { "@types/node": "*" } }, "node_modules/@types/debug": { - "version": "4.1.9", - "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.9.tgz", - "integrity": "sha512-8Hz50m2eoS56ldRlepxSBa6PWEVCtzUo/92HgLc2qTMnotJNIm7xP+UZhyWoYsyOdd5dxZ+NZLb24rsKyFs2ow==", + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", "dependencies": { "@types/ms": "*" } @@ -1313,9 +1352,9 @@ "dev": true }, "node_modules/@types/ms": { - "version": "0.7.33", - "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.33.tgz", - "integrity": "sha512-AuHIyzR5Hea7ij0P9q7vx7xu4z0C28ucwjAZC0ja7JhINyCnOw8/DnvAPQQ9TfOlCtZAmCERKQX9+o1mgQhuOQ==" + "version": "0.7.34", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", + "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, "node_modules/@types/node": { "version": "14.18.53", @@ -1323,9 +1362,9 @@ "integrity": "sha512-soGmOpVBUq+gaBMwom1M+krC/NNbWlosh4AtGA03SyWNDiqSKtwp7OulO1M6+mg8YkHMvJ/y0AkCeO8d1hNb7A==" }, "node_modules/@types/normalize-package-data": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.3.tgz", - "integrity": "sha512-ehPtgRgaULsFG8x0NeYJvmyH1hmlfsNLujHe9dQEia/7MAJYdzMSi19JtchUHjmBA6XC/75dK55mzZH+RyieSg==" + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz", + "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==" }, "node_modules/@types/prop-types": { "version": "15.7.5", @@ -1478,21 +1517,21 @@ } }, "node_modules/@zenstackhq/language": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@zenstackhq/language/-/language-1.2.0.tgz", - "integrity": "sha512-oucNndXNLIdavkFoUn7nJIjhGcU39Mw1t/+qkwcKhAXf9+G6MLAT+AesOr3D+SjCdbsynMgx26RfjQdt6GvpOg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@zenstackhq/language/-/language-1.3.0.tgz", + "integrity": "sha512-0VgIavtT5RlHm155N793QS3pnre6YdzFZ9+SJwiTFnygPqITQcj3+HZTla/LCWJOQHqz5B/1EaLqPjG64pfkfw==", "dependencies": { "langium": "1.2.0" } }, "node_modules/@zenstackhq/openapi": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@zenstackhq/openapi/-/openapi-1.2.0.tgz", - "integrity": "sha512-ePAgwVExLqhsu51Mer2P2gXhZuDnA/VdUbAGGjfh5Qnio4Mky8Ev3VH4O6PAPQJ2Oz9SKm1oBrI04nYFUe9K8A==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@zenstackhq/openapi/-/openapi-1.3.0.tgz", + "integrity": "sha512-gmsW6/xiTCxlL9/gUFKILyBQwPcfYqr8JDs6USwgYaZDiDyiVMHJ9fpN97LrwjVoOYdHPU3XA7LzfrysiXfqxA==", "dependencies": { "@prisma/generator-helper": "^5.0.0", - "@zenstackhq/runtime": "1.2.0", - "@zenstackhq/sdk": "1.2.0", + "@zenstackhq/runtime": "1.3.0", + "@zenstackhq/sdk": "1.3.0", "change-case": "^4.1.2", "lower-case-first": "^2.0.2", "openapi-types": "^12.1.0", @@ -1504,9 +1543,9 @@ } }, "node_modules/@zenstackhq/runtime": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@zenstackhq/runtime/-/runtime-1.2.0.tgz", - "integrity": "sha512-/dBUJLWPAi6tVjOcpJ2o/45OQcP5BcHfb5iMrcxYTLQ3B8J7weXJHhxf5Z72pHqTxLbiSnO/Y+kbjDYyE5eCUQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@zenstackhq/runtime/-/runtime-1.3.0.tgz", + "integrity": "sha512-KRbjwMGdXnJcMODmsx8FhV8vEZWV4V+14s0Oc+CFYAbmgEHGoFdlni+MYDjvt7Y3cBY7ejT0pyu5jZdS2sxOcA==", "dependencies": { "@types/bcryptjs": "^2.4.2", "bcryptjs": "^2.4.3", @@ -1521,20 +1560,33 @@ "superjson": "^1.11.0", "tslib": "^2.4.1", "upper-case-first": "^2.0.2", + "uuid": "^9.0.0", "zod": "^3.22.4", "zod-validation-error": "^1.5.0" } }, + "node_modules/@zenstackhq/runtime/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@zenstackhq/sdk": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@zenstackhq/sdk/-/sdk-1.2.0.tgz", - "integrity": "sha512-eMl6ZiAQcHElIxfn5gfD6B/jAgIcppePfoPgqWV5bx+l9FVqWvp2sf176k5glwpK6TyOcD5PDpk3JHAELU3HBw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@zenstackhq/sdk/-/sdk-1.3.0.tgz", + "integrity": "sha512-j5wg8r1bru6k36Wmx7eArLwhGkt+pLJX3ZNaNpP+AqCWY/T8c7tXjk4Y0UZm29tdvt/qiDY4e1l6iDntRGjl3A==", "dependencies": { "@prisma/generator-helper": "^5.0.0", "@prisma/internals": "^4.16.0", "@prisma/internals-v5": "npm:@prisma/internals@^5.0.0", - "@zenstackhq/language": "1.2.0", - "@zenstackhq/runtime": "1.2.0", + "@zenstackhq/language": "1.3.0", + "@zenstackhq/runtime": "1.3.0", "lower-case-first": "^2.0.2", "prettier": "^2.8.3", "semver": "^7.3.8", @@ -1543,12 +1595,12 @@ } }, "node_modules/@zenstackhq/server": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@zenstackhq/server/-/server-1.2.0.tgz", - "integrity": "sha512-9nWNuy/rnxyT3dVkNnbODuyW0jBw2QYWDp3ZKj8+KvhQ9Ha75L0+ItWbr6PYm4U5ITyppcXO8uCM7adhMJG8Jg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@zenstackhq/server/-/server-1.3.0.tgz", + "integrity": "sha512-kqQ7f+T5LTSgOPUy940Dh/l/h2Zar5m1ERElvi1C3mpRjA0XDv7J4OnZRxnGXnNxrIw3uPy1ByatXGetfoMrgQ==", "dependencies": { - "@zenstackhq/openapi": "1.2.0", - "@zenstackhq/runtime": "1.2.0", + "@zenstackhq/openapi": "1.3.0", + "@zenstackhq/runtime": "1.3.0", "change-case": "^4.1.2", "lower-case-first": "^2.0.2", "superjson": "^1.11.0", @@ -1561,13 +1613,13 @@ } }, "node_modules/@zenstackhq/tanstack-query": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@zenstackhq/tanstack-query/-/tanstack-query-1.2.0.tgz", - "integrity": "sha512-+KxH0le51ZZ9PoZK6dJQvHFCBfyYQsfSLL/768HwdUmUvxquOcFDfkHMpRauX9CvrPQqG/w5KWV+/CpzOqVy1A==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@zenstackhq/tanstack-query/-/tanstack-query-1.3.0.tgz", + "integrity": "sha512-qnfxCPZThusmtsvcNMEAEHp5tOuQzzsn92IGrlAjWJDdX+hgd9FXjYw1OJ2qvChX4LnZtPskyaOUxukfff01yw==", "dependencies": { "@prisma/generator-helper": "^5.0.0", - "@zenstackhq/runtime": "1.2.0", - "@zenstackhq/sdk": "1.2.0", + "@zenstackhq/runtime": "1.3.0", + "@zenstackhq/sdk": "1.3.0", "change-case": "^4.1.2", "cross-fetch": "^4.0.0", "decimal.js": "^10.4.2", @@ -1697,12 +1749,14 @@ "node_modules/any-promise": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==" + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" @@ -1927,9 +1981,9 @@ } }, "node_modules/async": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", - "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz", + "integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==" }, "node_modules/async-exit-hook": { "version": "2.0.1", @@ -1944,6 +1998,7 @@ "version": "10.4.14", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.14.tgz", "integrity": "sha512-FQzyfOsTlwVzjHxKEqRIAdJx9niO6VCBCoEwax/VLSoQF29ggECcPuBqUMZ+u8jCZOPSy8b8/8KnuFbp0SaFZQ==", + "dev": true, "funding": [ { "type": "opencollective", @@ -2057,6 +2112,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true, "engines": { "node": ">=8" } @@ -2118,6 +2174,7 @@ "version": "4.21.9", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.9.tgz", "integrity": "sha512-M0MFoZzbUrRU4KNfCrDLnvyE7gub+peetoTid3TBIqtunaDJyXlwhakT+/VkvSXcfIzFfK/nkCs4nmyTmxdNSg==", + "dev": true, "funding": [ { "type": "opencollective", @@ -2340,6 +2397,7 @@ "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, "funding": [ { "type": "individual", @@ -2450,18 +2508,6 @@ "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-11.0.3.tgz", "integrity": "sha512-NiujjUFB4SwScJq2bwbYUtXbZhBSlY6vYzm++3Q6oC+U+injTqfPYFK8wS9COOmb2lueqp0ZRB4nK1VYeHgNyw==" }, - "node_modules/color": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", - "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", - "dependencies": { - "color-convert": "^2.0.1", - "color-string": "^1.9.0" - }, - "engines": { - "node": ">=12.5.0" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2478,15 +2524,6 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, - "node_modules/color-string": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", - "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", - "dependencies": { - "color-name": "^1.0.0", - "simple-swizzle": "^0.2.2" - } - }, "node_modules/colors": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", @@ -2499,6 +2536,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, "engines": { "node": ">= 6" } @@ -2677,23 +2715,30 @@ "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", "dev": true }, + "node_modules/culori": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/culori/-/culori-3.2.0.tgz", + "integrity": "sha512-HIEbTSP7vs1mPq/2P9In6QyFE0Tkpevh0k9a+FkjhD+cwsYm9WRSbn4uMdW9O0yXlNYC3ppxL3gWWPOcvEl57w==", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, "node_modules/daisyui": { - "version": "2.52.0", - "resolved": "https://registry.npmjs.org/daisyui/-/daisyui-2.52.0.tgz", - "integrity": "sha512-LQTA5/IVXAJHBMFoeaEMfd7/akAFPPcdQPR3O9fzzcFiczneJFM73CFPnScmW2sOgn/D83cvkP854ep2T9OfTg==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/daisyui/-/daisyui-4.0.7.tgz", + "integrity": "sha512-D84DnNDZKcamwNsxCMrwYaddyz5kC6VO6oe30nM1x67GzCAfarfd3Ar1rpLGXCIqSsEoNZUHO8EcXvX93W2ZkA==", "dependencies": { - "color": "^4.2", - "css-selector-tokenizer": "^0.8.0", - "postcss-js": "^4.0.0", - "tailwindcss": "^3" + "css-selector-tokenizer": "^0.8", + "culori": "^3", + "picocolors": "^1", + "postcss-js": "^4" + }, + "engines": { + "node": ">=16.9.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/daisyui" - }, - "peerDependencies": { - "autoprefixer": "^10.0.2", - "postcss": "^8.1.6" } }, "node_modules/damerau-levenshtein": { @@ -2827,7 +2872,8 @@ "node_modules/didyoumean": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", - "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==" + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", + "dev": true }, "node_modules/dir-glob": { "version": "3.0.1", @@ -2843,7 +2889,8 @@ "node_modules/dlv": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", - "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==" + "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==", + "dev": true }, "node_modules/doctrine": { "version": "3.0.0", @@ -2877,7 +2924,8 @@ "node_modules/electron-to-chromium": { "version": "1.4.466", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.466.tgz", - "integrity": "sha512-TSkRvbXRXD8BwhcGlZXDsbI2lRoP8dvqR7LQnqQNk9KxXBc4tG8O+rTuXgTyIpEdiqSGKEBSqrxdqEntnjNncA==" + "integrity": "sha512-TSkRvbXRXD8BwhcGlZXDsbI2lRoP8dvqR7LQnqQNk9KxXBc4tG8O+rTuXgTyIpEdiqSGKEBSqrxdqEntnjNncA==", + "dev": true }, "node_modules/emoji-regex": { "version": "9.2.2", @@ -2885,6 +2933,21 @@ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "dev": true }, + "node_modules/emphasize": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/emphasize/-/emphasize-4.2.0.tgz", + "integrity": "sha512-yGKvcFUHlBsUPwlxTlzKLR8+zhpbitkFOMCUxN8fTJng9bdH3WNzUGkhdaGdjndSUgqmMPBN7umfwnUdLz5Axg==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "highlight.js": "~10.4.0", + "lowlight": "~1.17.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -3018,6 +3081,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, "engines": { "node": ">=6" } @@ -3570,6 +3634,19 @@ "reusify": "^1.0.4" } }, + "node_modules/fault": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/fault/-/fault-1.0.4.tgz", + "integrity": "sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==", + "dev": true, + "dependencies": { + "format": "^0.2.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -3672,6 +3749,15 @@ "is-callable": "^1.1.3" } }, + "node_modules/format": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz", + "integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==", + "dev": true, + "engines": { + "node": ">=0.4.x" + } + }, "node_modules/fp-ts": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.16.0.tgz", @@ -3681,6 +3767,7 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz", "integrity": "sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==", + "dev": true, "engines": { "node": "*" }, @@ -3789,6 +3876,7 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, "hasInstallScript": true, "optional": true, "os": [ @@ -4148,6 +4236,15 @@ "tslib": "^2.0.3" } }, + "node_modules/highlight.js": { + "version": "10.4.1", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.4.1.tgz", + "integrity": "sha512-yR5lWvNz7c85OhVAEAeFhVCc/GV4C30Fjzc/rCP0aCWzc1UUOPUk55dK/qdwTZHBvMZo+eZ2jpk62ndX/xMFlg==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -4371,6 +4468,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, "dependencies": { "binary-extensions": "^2.0.0" }, @@ -4707,6 +4805,7 @@ "version": "1.19.1", "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.19.1.tgz", "integrity": "sha512-oVhqoRDaBXf7sjkll95LHVS6Myyyb1zaunVwk4Z0+WPSW4gjS0pl01zYKHScTuyEhQsFxV5L4DR5r+YqSyqyyg==", + "dev": true, "bin": { "jiti": "bin/jiti.js" } @@ -4923,6 +5022,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", + "dev": true, "engines": { "node": ">=10" } @@ -5031,6 +5131,20 @@ "tslib": "^2.0.3" } }, + "node_modules/lowlight": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/lowlight/-/lowlight-1.17.0.tgz", + "integrity": "sha512-vmtBgYKD+QVNy7tIa7ulz5d//Il9R4MooOVh4nkOf9R9Cb/Dk5TXMSTieg/vDulkBkIWj59/BIlyFQxT9X1oAQ==", + "dev": true, + "dependencies": { + "fault": "^1.0.0", + "highlight.js": "~10.4.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -5202,6 +5316,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, "dependencies": { "any-promise": "^1.0.0", "object-assign": "^4.0.1", @@ -5348,7 +5463,8 @@ "node_modules/node-releases": { "version": "2.0.13", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", - "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==" + "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", + "dev": true }, "node_modules/normalize-package-data": { "version": "2.5.0", @@ -5381,6 +5497,7 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz", "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -5478,6 +5595,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -5905,6 +6023,7 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -5913,6 +6032,7 @@ "version": "4.0.6", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true, "engines": { "node": ">= 6" } @@ -6015,6 +6135,7 @@ "version": "15.1.0", "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-15.1.0.tgz", "integrity": "sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==", + "dev": true, "dependencies": { "postcss-value-parser": "^4.0.0", "read-cache": "^1.0.0", @@ -6049,6 +6170,7 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.0.1.tgz", "integrity": "sha512-mEp4xPMi5bSWiMbsgoPfcP74lsWLHkQbZc3sY+jWYd65CUwXrUaTp0fmNpa01ZcETKlIgUdFN/MpS2xZtqL9dQ==", + "dev": true, "dependencies": { "postcss-selector-parser": "^6.0.11" }, @@ -6067,6 +6189,7 @@ "version": "6.0.13", "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.13.tgz", "integrity": "sha512-EaV1Gl4mUEV4ddhDnv/xtj7sxwrwxdetHdWUGnT4VJQf+4d05v6lHYZr8N573k5Z0BViss7BDhfWtKS3+sfAqQ==", + "dev": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -6078,7 +6201,8 @@ "node_modules/postcss-value-parser": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", - "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true }, "node_modules/postcss/node_modules/nanoid": { "version": "3.3.6", @@ -6145,6 +6269,21 @@ "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-3.8.0.tgz", "integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew==" }, + "node_modules/pretty-repl": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pretty-repl/-/pretty-repl-4.0.0.tgz", + "integrity": "sha512-2WmwcEXvMDQ3UVb/emuYb0M7dVVU1NSm7L7lf9nwGxvzWovUbLaXWUve8VqOoAO34GQBQ2l+nYcXY0HGllNc5Q==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1", + "chalk": "^4.1.1", + "emphasize": "^4.2.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/prisma": { "version": "4.16.2", "resolved": "https://registry.npmjs.org/prisma/-/prisma-4.16.2.tgz", @@ -6338,6 +6477,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", + "dev": true, "dependencies": { "pify": "^2.3.0" } @@ -6480,6 +6620,7 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, "dependencies": { "picomatch": "^2.2.1" }, @@ -6782,19 +6923,6 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, - "node_modules/simple-swizzle": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", - "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", - "dependencies": { - "is-arrayish": "^0.3.1" - } - }, - "node_modules/simple-swizzle/node_modules/is-arrayish": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", - "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" - }, "node_modules/sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", @@ -6893,9 +7021,9 @@ } }, "node_modules/streamx": { - "version": "2.15.2", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.2.tgz", - "integrity": "sha512-b62pAV/aeMjUoRN2C/9F0n+G8AfcJjNC0zw/ZmOHeFsIe4m4GzjVW9m6VHXVjk536NbdU9JRwKMJRfkc+zUFTg==", + "version": "2.15.5", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.5.tgz", + "integrity": "sha512-9thPGMkKC2GctCzyCUjME3yR03x2xNo0GPKGkRw2UMYN+gqWa9uqpyNWhmsNCutU5zHmkUum0LsCRQTXUgUCAg==", "dependencies": { "fast-fifo": "^1.1.0", "queue-tick": "^1.0.1" @@ -7077,6 +7205,7 @@ "version": "3.34.0", "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.34.0.tgz", "integrity": "sha512-70/LQEZ07TEcxiU2dz51FKaE6hCTWC6vr7FOk3Gr0U60C3shtAN+H+BFr9XlYe5xqf3RA8nrc+VIwzCfnxuXJw==", + "dev": true, "dependencies": { "@jridgewell/gen-mapping": "^0.3.2", "commander": "^4.0.0", @@ -7098,6 +7227,7 @@ "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -7217,6 +7347,7 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.3.tgz", "integrity": "sha512-A0KgSkef7eE4Mf+nKJ83i75TMyq8HqY3qmFIJSWy8bNt0v1lG7jUcpGpoTFxAwYcWOphcTBLPPJg+bDfhDf52w==", + "dev": true, "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", @@ -7253,6 +7384,7 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, "dependencies": { "is-glob": "^4.0.3" }, @@ -7264,6 +7396,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "dev": true, "engines": { "node": ">= 6" } @@ -7272,6 +7405,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.1.tgz", "integrity": "sha512-vEJIc8RdiBRu3oRAI0ymerOn+7rPuMvRXslTvZUKZonDHFIczxztIyJ1urxM1x9JXEikvpWWTUUqal5j/8QgvA==", + "dev": true, "dependencies": { "lilconfig": "^2.0.5", "yaml": "^2.1.1" @@ -7405,6 +7539,7 @@ "version": "3.3.1", "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, "dependencies": { "any-promise": "^1.0.0" } @@ -7413,6 +7548,7 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, "dependencies": { "thenify": ">= 3.1.0 < 4" }, @@ -7509,7 +7645,8 @@ "node_modules/ts-interface-checker": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", - "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==" + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true }, "node_modules/ts-japi": { "version": "1.9.1", @@ -7731,6 +7868,7 @@ "version": "1.0.11", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", + "dev": true, "funding": [ { "type": "opencollective", @@ -8037,16 +8175,16 @@ } }, "node_modules/zenstack": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/zenstack/-/zenstack-1.2.0.tgz", - "integrity": "sha512-HCf0rGsCwRXRYcdIbbYJQO5/Efva39hp51XNx2BzfYch5NsIKXar58Ehy5nHv5ymphuYiXD2tlBr6NdII76/Zg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/zenstack/-/zenstack-1.3.0.tgz", + "integrity": "sha512-U6+tLRWqsde60SWe6haEeHtO/C5SWrFTTBZp7KDURmET+Y9bX9Y0o9b29WvS5rKP4rmEpyFC2n4U91Nt4gAAwA==", "dev": true, "hasInstallScript": true, "dependencies": { "@paralleldrive/cuid2": "^2.2.0", "@prisma/generator-helper": "^5.0.0", - "@zenstackhq/language": "1.2.0", - "@zenstackhq/sdk": "1.2.0", + "@zenstackhq/language": "1.3.0", + "@zenstackhq/sdk": "1.3.0", "async-exit-hook": "^2.0.1", "change-case": "^4.1.2", "colors": "1.4.0", @@ -8058,6 +8196,7 @@ "node-machine-id": "^1.1.12", "ora": "^5.4.1", "pluralize": "^8.0.0", + "pretty-repl": "^4.0.0", "promisify": "^0.0.3", "semver": "^7.3.8", "sleep-promise": "^9.1.0", diff --git a/package.json b/package.json index a966e21..2248f6e 100644 --- a/package.json +++ b/package.json @@ -23,12 +23,13 @@ "@next-auth/prisma-adapter": "^1.0.5", "@prisma/client": "^4.9.0", "@tanstack/react-query": "^5.0.5", - "@zenstackhq/runtime": "^1.2.0", - "@zenstackhq/server": "^1.2.0", - "@zenstackhq/tanstack-query": "^1.2.0", + "@tanstack/react-query-devtools": "^5.8.3", + "@zenstackhq/runtime": "^1.3.0", + "@zenstackhq/server": "^1.3.0", + "@zenstackhq/tanstack-query": "^1.3.0", "babel-plugin-superjson-next": "^0.4.5", "bcryptjs": "^2.4.3", - "daisyui": "^2.31.0", + "daisyui": "^4.0.7", "decimal.js": "^10.4.3", "moment": "^2.29.4", "nanoid": "^4.0.0", @@ -53,6 +54,6 @@ "prisma": "^4.9.0", "tailwindcss": "^3.1.8", "typescript": "^5.2.2", - "zenstack": "^1.2.0" + "zenstack": "^1.3.0" } } diff --git a/pages/_app.tsx b/pages/_app.tsx index 1c5efdb..23aa24d 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -7,14 +7,16 @@ import { ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import { Provider as ZenStackHooksProvider } from '../lib/hooks'; import '../styles/globals.css'; +// import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; const queryClient = new QueryClient(); function App({ Component, pageProps: { session, ...pageProps } }: AppProps) { return ( + {/* */} - +
diff --git a/pages/space/[slug]/[listId]/index.tsx b/pages/space/[slug]/[listId]/index.tsx index 38811ad..5c87eb9 100644 --- a/pages/space/[slug]/[listId]/index.tsx +++ b/pages/space/[slug]/[listId]/index.tsx @@ -1,12 +1,12 @@ import { PlusIcon } from '@heroicons/react/24/outline'; import { useCurrentUser } from '@lib/context'; -import { useCreateTodo, useInfiniteFindManyTodo } from '@lib/hooks'; +import { useCreateTodo, useFindManyTodo } from '@lib/hooks'; import { List, Space } from '@prisma/client'; import BreadCrumb from 'components/BreadCrumb'; import TodoComponent from 'components/Todo'; import WithNavBar from 'components/WithNavBar'; import { GetServerSideProps } from 'next'; -import React, { ChangeEvent, KeyboardEvent, useState } from 'react'; +import { ChangeEvent, KeyboardEvent, useState } from 'react'; import { toast } from 'react-toastify'; import { getEnhancedPrisma } from 'server/enhanced-db'; @@ -20,9 +20,36 @@ const PAGE_SIZE = 5; export default function TodoList(props: Props) { const user = useCurrentUser(); const [title, setTitle] = useState(''); - const create = useCreateTodo(); + const create = useCreateTodo(undefined, true, true); // optimistic - const fetchArgs = { + // const fetchArgs = { + // where: { listId: props.list.id }, + // include: { + // owner: true, + // }, + // orderBy: { + // updatedAt: 'desc' as const, + // }, + // take: PAGE_SIZE, + // }; + + // const { data, fetchNextPage, hasNextPage } = useInfiniteFindManyTodo(fetchArgs, { + // enabled: !!props.list, + // initialPageParam: fetchArgs, + // getNextPageParam: (lastPage, pages) => { + // if (lastPage.length < PAGE_SIZE) { + // return undefined; + // } + // const fetched = pages.flatMap((item) => item).length; + // console.log(`Fetched: ${fetched}`); + // return { + // ...fetchArgs, + // skip: fetched, + // }; + // }, + // }); + + const { data } = useFindManyTodo({ where: { listId: props.list.id }, include: { owner: true, @@ -30,23 +57,6 @@ export default function TodoList(props: Props) { orderBy: { updatedAt: 'desc' as const, }, - take: PAGE_SIZE, - }; - - const { data, fetchNextPage, hasNextPage } = useInfiniteFindManyTodo(fetchArgs, { - enabled: !!props.list, - initialPageParam: fetchArgs, - getNextPageParam: (lastPage, pages) => { - if (lastPage.length < PAGE_SIZE) { - return undefined; - } - const fetched = pages.flatMap((item) => item).length; - console.log(`Fetched: ${fetched}`); - return { - ...fetchArgs, - skip: fetched, - }; - }, }); const _createTodo = async () => { @@ -96,20 +106,23 @@ export default function TodoList(props: Props) {
    - {data?.pages.map((group, i) => ( + {/* {data?.pages.map((group, i) => ( {group.map((todo) => ( ))} + ))} */} + + {data?.map((todo) => ( + ))} - {/* {pages && pages.flatMap((item) => )} */}
- {hasNextPage && ( + {/* {hasNextPage && ( - )} + )} */}
); diff --git a/tailwind.config.js b/tailwind.config.js index f3296d1..2e30d8f 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -6,6 +6,6 @@ module.exports = { }, plugins: [require('daisyui'), require('@tailwindcss/line-clamp')], daisyui: { - themes: false, + themes: ['light'], }, };