@zenstackhq/tanstack-query 3.0.0-beta.17 → 3.0.0-beta.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,111 @@
1
+ import { get } from 'svelte/store';
2
+ import { useClientQueries } from '../src/svelte';
3
+ import { schema } from './schemas/basic/schema-lite';
4
+
5
+ const client = useClientQueries(schema);
6
+
7
+ // @ts-expect-error missing args
8
+ client.user.useFindUnique();
9
+
10
+ check(get(client.user.useFindUnique({ where: { id: '1' } })).data?.email);
11
+ check(get(client.user.useFindUnique({ where: { id: '1' } })).queryKey);
12
+ check(get(client.user.useFindUnique({ where: { id: '1' } }, { optimisticUpdate: true, enabled: false })));
13
+
14
+ // @ts-expect-error unselected field
15
+ check(get(client.user.useFindUnique({ select: { email: true } })).data.name);
16
+
17
+ check(get(client.user.useFindUnique({ where: { id: '1' }, include: { posts: true } })).data?.posts[0]?.title);
18
+
19
+ check(get(client.user.useFindFirst()).data?.email);
20
+ check(get(client.user.useFindFirst()).data?.$optimistic);
21
+
22
+ check(get(client.user.useFindMany()).data?.[0]?.email);
23
+ check(get(client.user.useFindMany()).data?.[0]?.$optimistic);
24
+
25
+ check(get(client.user.useInfiniteFindMany()).data?.pages[0]?.[0]?.email);
26
+ check(
27
+ get(
28
+ client.user.useInfiniteFindMany(
29
+ {},
30
+ {
31
+ getNextPageParam: () => ({ id: '2' }),
32
+ },
33
+ ),
34
+ ).data?.pages[1]?.[0]?.email,
35
+ );
36
+ // @ts-expect-error
37
+ check(get(client.user.useInfiniteFindMany()).data?.pages[0]?.[0]?.$optimistic);
38
+
39
+ check(get(client.user.useCount()).data?.toFixed(2));
40
+ check(get(client.user.useCount({ select: { email: true } })).data?.email.toFixed(2));
41
+
42
+ check(get(client.user.useAggregate({ _max: { email: true } })).data?._max.email);
43
+
44
+ check(get(client.user.useGroupBy({ by: ['email'], _max: { name: true } })).data?.[0]?._max.name);
45
+
46
+ // @ts-expect-error missing args
47
+ client.user.useCreate().mutate();
48
+ get(client.user.useCreate()).mutate({ data: { email: 'test@example.com' } });
49
+ get(client.user.useCreate({ optimisticUpdate: true, invalidateQueries: false, retry: 3 })).mutate({
50
+ data: { email: 'test@example.com' },
51
+ });
52
+
53
+ get(client.user.useCreate())
54
+ .mutateAsync({ data: { email: 'test@example.com' }, include: { posts: true } })
55
+ .then((d) => check(d.posts[0]?.title));
56
+
57
+ get(client.user.useCreateMany())
58
+ .mutateAsync({
59
+ data: [{ email: 'test@example.com' }, { email: 'test2@example.com' }],
60
+ skipDuplicates: true,
61
+ })
62
+ .then((d) => d.count);
63
+
64
+ get(client.user.useCreateManyAndReturn())
65
+ .mutateAsync({
66
+ data: [{ email: 'test@example.com' }],
67
+ })
68
+ .then((d) => check(d[0]?.name));
69
+
70
+ get(client.user.useCreateManyAndReturn())
71
+ .mutateAsync({
72
+ data: [{ email: 'test@example.com' }],
73
+ select: { email: true },
74
+ })
75
+ // @ts-expect-error unselected field
76
+ .then((d) => check(d[0].name));
77
+
78
+ get(client.user.useUpdate()).mutate(
79
+ { data: { email: 'updated@example.com' }, where: { id: '1' } },
80
+ {
81
+ onSuccess: (d) => {
82
+ check(d.email);
83
+ },
84
+ },
85
+ );
86
+
87
+ get(client.user.useUpdateMany()).mutate({ data: { email: 'updated@example.com' } });
88
+
89
+ get(client.user.useUpdateManyAndReturn())
90
+ .mutateAsync({ data: { email: 'updated@example.com' } })
91
+ .then((d) => check(d[0]?.email));
92
+
93
+ get(client.user.useUpsert()).mutate({
94
+ where: { id: '1' },
95
+ create: { email: 'new@example.com' },
96
+ update: { email: 'updated@example.com' },
97
+ });
98
+
99
+ get(client.user.useDelete()).mutate({ where: { id: '1' }, include: { posts: true } });
100
+
101
+ get(client.user.useDeleteMany()).mutate({ where: { email: 'test@example.com' } });
102
+
103
+ function check(_value: unknown) {
104
+ // noop
105
+ }
106
+
107
+ // @ts-expect-error delegate model
108
+ client.foo.useCreate();
109
+
110
+ client.foo.useUpdate();
111
+ client.bar.useCreate();
@@ -0,0 +1,111 @@
1
+ import { useClientQueries } from '../src/vue';
2
+ import { schema } from './schemas/basic/schema-lite';
3
+
4
+ const client = useClientQueries(schema);
5
+
6
+ // @ts-expect-error missing args
7
+ client.user.useFindUnique();
8
+
9
+ check(client.user.useFindUnique({ where: { id: '1' } }).data.value?.email);
10
+ check(client.user.useFindUnique({ where: { id: '1' } }).queryKey);
11
+ check(client.user.useFindUnique({ where: { id: '1' } }, { optimisticUpdate: true, enabled: false }));
12
+
13
+ // @ts-expect-error unselected field
14
+ check(client.user.useFindUnique({ select: { email: true } }).data.name);
15
+
16
+ check(client.user.useFindUnique({ where: { id: '1' }, include: { posts: true } }).data.value?.posts[0]?.title);
17
+
18
+ check(client.user.useFindFirst().data.value?.email);
19
+ check(client.user.useFindFirst().data.value?.$optimistic);
20
+
21
+ check(client.user.useFindMany().data.value?.[0]?.email);
22
+ check(client.user.useFindMany().data.value?.[0]?.$optimistic);
23
+
24
+ check(client.user.useInfiniteFindMany().data.value?.pages[0]?.[0]?.email);
25
+ check(
26
+ client.user.useInfiniteFindMany(
27
+ {},
28
+ {
29
+ getNextPageParam: () => ({ id: '2' }),
30
+ },
31
+ ).data.value?.pages[1]?.[0]?.email,
32
+ );
33
+ // @ts-expect-error
34
+ check(client.user.useInfiniteFindMany().data.value?.pages[0]?.[0]?.$optimistic);
35
+
36
+ check(client.user.useCount().data.value?.toFixed(2));
37
+ check(client.user.useCount({ select: { email: true } }).data.value?.email.toFixed(2));
38
+
39
+ check(client.user.useAggregate({ _max: { email: true } }).data.value?._max.email);
40
+
41
+ check(client.user.useGroupBy({ by: ['email'], _max: { name: true } }).data.value?.[0]?._max.name);
42
+
43
+ // @ts-expect-error missing args
44
+ client.user.useCreate().mutate();
45
+ client.user.useCreate().mutate({ data: { email: 'test@example.com' } });
46
+ client.user
47
+ .useCreate({ optimisticUpdate: true, invalidateQueries: false, retry: 3 })
48
+ .mutate({ data: { email: 'test@example.com' } });
49
+
50
+ client.user
51
+ .useCreate()
52
+ .mutateAsync({ data: { email: 'test@example.com' }, include: { posts: true } })
53
+ .then((d) => check(d.posts[0]?.title));
54
+
55
+ client.user
56
+ .useCreateMany()
57
+ .mutateAsync({
58
+ data: [{ email: 'test@example.com' }, { email: 'test2@example.com' }],
59
+ skipDuplicates: true,
60
+ })
61
+ .then((d) => d.count);
62
+
63
+ client.user
64
+ .useCreateManyAndReturn()
65
+ .mutateAsync({
66
+ data: [{ email: 'test@example.com' }],
67
+ })
68
+ .then((d) => check(d[0]?.name));
69
+
70
+ client.user
71
+ .useCreateManyAndReturn()
72
+ .mutateAsync({
73
+ data: [{ email: 'test@example.com' }],
74
+ select: { email: true },
75
+ })
76
+ // @ts-expect-error unselected field
77
+ .then((d) => check(d[0].name));
78
+
79
+ client.user.useUpdate().mutate(
80
+ { data: { email: 'updated@example.com' }, where: { id: '1' } },
81
+ {
82
+ onSuccess: (d) => {
83
+ check(d.email);
84
+ },
85
+ },
86
+ );
87
+
88
+ client.user.useUpdateMany().mutate({ data: { email: 'updated@example.com' } });
89
+
90
+ client.user
91
+ .useUpdateManyAndReturn()
92
+ .mutateAsync({ data: { email: 'updated@example.com' } })
93
+ .then((d) => check(d[0]?.email));
94
+
95
+ client.user
96
+ .useUpsert()
97
+ .mutate({ where: { id: '1' }, create: { email: 'new@example.com' }, update: { email: 'updated@example.com' } });
98
+
99
+ client.user.useDelete().mutate({ where: { id: '1' }, include: { posts: true } });
100
+
101
+ client.user.useDeleteMany().mutate({ where: { email: 'test@example.com' } });
102
+
103
+ function check(_value: unknown) {
104
+ // noop
105
+ }
106
+
107
+ // @ts-expect-error delegate model
108
+ client.foo.useCreate();
109
+
110
+ client.foo.useUpdate();
111
+ client.bar.useCreate();
package/tsup.config.ts CHANGED
@@ -3,6 +3,8 @@ import { defineConfig } from 'tsup';
3
3
  export default defineConfig({
4
4
  entry: {
5
5
  react: 'src/react.ts',
6
+ vue: 'src/vue.ts',
7
+ svelte: 'src/svelte.ts',
6
8
  },
7
9
  outDir: 'dist',
8
10
  splitting: false,