@zenstackhq/tanstack-query 3.0.0-beta.16 → 3.0.0-beta.18

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,106 @@
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
+
21
+ check(get(client.user.useFindMany()).data?.[0]?.email);
22
+ check(get(client.user.useInfiniteFindMany()).data?.pages[0]?.[0]?.email);
23
+ check(
24
+ get(
25
+ client.user.useInfiniteFindMany(
26
+ {},
27
+ {
28
+ getNextPageParam: () => ({ id: '2' }),
29
+ },
30
+ ),
31
+ ).data?.pages[1]?.[0]?.email,
32
+ );
33
+
34
+ check(get(client.user.useCount()).data?.toFixed(2));
35
+ check(get(client.user.useCount({ select: { email: true } })).data?.email.toFixed(2));
36
+
37
+ check(get(client.user.useAggregate({ _max: { email: true } })).data?._max.email);
38
+
39
+ check(get(client.user.useGroupBy({ by: ['email'], _max: { name: true } })).data?.[0]?._max.name);
40
+
41
+ // @ts-expect-error missing args
42
+ client.user.useCreate().mutate();
43
+ get(client.user.useCreate()).mutate({ data: { email: 'test@example.com' } });
44
+ get(client.user.useCreate({ optimisticUpdate: true, invalidateQueries: false, retry: 3 })).mutate({
45
+ data: { email: 'test@example.com' },
46
+ });
47
+
48
+ get(client.user.useCreate())
49
+ .mutateAsync({ data: { email: 'test@example.com' }, include: { posts: true } })
50
+ .then((d) => check(d.posts[0]?.title));
51
+
52
+ get(client.user.useCreateMany())
53
+ .mutateAsync({
54
+ data: [{ email: 'test@example.com' }, { email: 'test2@example.com' }],
55
+ skipDuplicates: true,
56
+ })
57
+ .then((d) => d.count);
58
+
59
+ get(client.user.useCreateManyAndReturn())
60
+ .mutateAsync({
61
+ data: [{ email: 'test@example.com' }],
62
+ })
63
+ .then((d) => check(d[0]?.name));
64
+
65
+ get(client.user.useCreateManyAndReturn())
66
+ .mutateAsync({
67
+ data: [{ email: 'test@example.com' }],
68
+ select: { email: true },
69
+ })
70
+ // @ts-expect-error unselected field
71
+ .then((d) => check(d[0].name));
72
+
73
+ get(client.user.useUpdate()).mutate(
74
+ { data: { email: 'updated@example.com' }, where: { id: '1' } },
75
+ {
76
+ onSuccess: (d) => {
77
+ check(d.email);
78
+ },
79
+ },
80
+ );
81
+
82
+ get(client.user.useUpdateMany()).mutate({ data: { email: 'updated@example.com' } });
83
+
84
+ get(client.user.useUpdateManyAndReturn())
85
+ .mutateAsync({ data: { email: 'updated@example.com' } })
86
+ .then((d) => check(d[0]?.email));
87
+
88
+ get(client.user.useUpsert()).mutate({
89
+ where: { id: '1' },
90
+ create: { email: 'new@example.com' },
91
+ update: { email: 'updated@example.com' },
92
+ });
93
+
94
+ get(client.user.useDelete()).mutate({ where: { id: '1' }, include: { posts: true } });
95
+
96
+ get(client.user.useDeleteMany()).mutate({ where: { email: 'test@example.com' } });
97
+
98
+ function check(_value: unknown) {
99
+ // noop
100
+ }
101
+
102
+ // @ts-expect-error delegate model
103
+ client.foo.useCreate();
104
+
105
+ client.foo.useUpdate();
106
+ client.bar.useCreate();
@@ -0,0 +1,107 @@
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
+
20
+ check(client.user.useFindMany().data.value?.[0]?.email);
21
+
22
+ check(client.user.useInfiniteFindMany().data.value?.pages[0]?.[0]?.email);
23
+ check(
24
+ client.user.useInfiniteFindMany(
25
+ {},
26
+ {
27
+ getNextPageParam: () => ({ id: '2' }),
28
+ },
29
+ ).data.value?.pages[1]?.[0]?.email,
30
+ );
31
+
32
+ check(client.user.useCount().data.value?.toFixed(2));
33
+ check(client.user.useCount({ select: { email: true } }).data.value?.email.toFixed(2));
34
+
35
+ check(client.user.useAggregate({ _max: { email: true } }).data.value?._max.email);
36
+
37
+ check(client.user.useGroupBy({ by: ['email'], _max: { name: true } }).data.value?.[0]?._max.name);
38
+
39
+ // @ts-expect-error missing args
40
+ client.user.useCreate().mutate();
41
+ client.user.useCreate().mutate({ data: { email: 'test@example.com' } });
42
+ client.user
43
+ .useCreate({ optimisticUpdate: true, invalidateQueries: false, retry: 3 })
44
+ .mutate({ data: { email: 'test@example.com' } });
45
+
46
+ client.user
47
+ .useCreate()
48
+ .mutateAsync({ data: { email: 'test@example.com' }, include: { posts: true } })
49
+ .then((d) => check(d.posts[0]?.title));
50
+
51
+ client.user
52
+ .useCreateMany()
53
+ .mutateAsync({
54
+ data: [{ email: 'test@example.com' }, { email: 'test2@example.com' }],
55
+ skipDuplicates: true,
56
+ })
57
+ .then((d) => d.count);
58
+
59
+ client.user
60
+ .useCreateManyAndReturn()
61
+ .mutateAsync({
62
+ data: [{ email: 'test@example.com' }],
63
+ })
64
+ .then((d) => check(d[0]?.name));
65
+
66
+ client.user
67
+ .useCreateManyAndReturn()
68
+ .mutateAsync({
69
+ data: [{ email: 'test@example.com' }],
70
+ select: { email: true },
71
+ })
72
+ // @ts-expect-error unselected field
73
+ .then((d) => check(d[0].name));
74
+
75
+ client.user.useUpdate().mutate(
76
+ { data: { email: 'updated@example.com' }, where: { id: '1' } },
77
+ {
78
+ onSuccess: (d) => {
79
+ check(d.email);
80
+ },
81
+ },
82
+ );
83
+
84
+ client.user.useUpdateMany().mutate({ data: { email: 'updated@example.com' } });
85
+
86
+ client.user
87
+ .useUpdateManyAndReturn()
88
+ .mutateAsync({ data: { email: 'updated@example.com' } })
89
+ .then((d) => check(d[0]?.email));
90
+
91
+ client.user
92
+ .useUpsert()
93
+ .mutate({ where: { id: '1' }, create: { email: 'new@example.com' }, update: { email: 'updated@example.com' } });
94
+
95
+ client.user.useDelete().mutate({ where: { id: '1' }, include: { posts: true } });
96
+
97
+ client.user.useDeleteMany().mutate({ where: { email: 'test@example.com' } });
98
+
99
+ function check(_value: unknown) {
100
+ // noop
101
+ }
102
+
103
+ // @ts-expect-error delegate model
104
+ client.foo.useCreate();
105
+
106
+ client.foo.useUpdate();
107
+ 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,
@@ -1,5 +0,0 @@
1
-
2
- 
3
- > @zenstackhq/tanstack-query@3.0.0-alpha.30 lint /Users/yiming/git/zenstack/zenstack-v3/packages/tanstack-query
4
- > eslint src --ext ts
5
-