@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.
- package/.turbo/turbo-build.log +27 -13
- package/dist/react.cjs +35 -33
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +28 -108
- package/dist/react.d.ts +28 -108
- package/dist/react.js +35 -33
- package/dist/react.js.map +1 -1
- package/dist/svelte.cjs +1224 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.cts +381 -0
- package/dist/svelte.d.ts +381 -0
- package/dist/svelte.js +1183 -0
- package/dist/svelte.js.map +1 -0
- package/dist/types-C8iIZD-7.d.cts +99 -0
- package/dist/types-C8iIZD-7.d.ts +99 -0
- package/dist/vue.cjs +1192 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +382 -0
- package/dist/vue.d.ts +382 -0
- package/dist/vue.js +1152 -0
- package/dist/vue.js.map +1 -0
- package/package.json +43 -11
- package/src/react.ts +172 -157
- package/src/svelte.ts +485 -0
- package/src/utils/common.ts +4 -13
- package/src/utils/types.ts +24 -0
- package/src/vue.ts +429 -0
- package/test/react-typing-test.ts +113 -0
- package/test/schemas/basic/input.ts +40 -0
- package/test/schemas/basic/models.ts +2 -0
- package/test/schemas/basic/schema-lite.ts +48 -0
- package/test/schemas/basic/schema.zmodel +11 -1
- package/test/svelte-typing-test.ts +111 -0
- package/test/vue-typing-test.ts +111 -0
- package/tsup.config.ts +2 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @zenstackhq/tanstack-query@3.0.0-beta.
|
|
2
|
+
> @zenstackhq/tanstack-query@3.0.0-beta.19 build /home/runner/work/zenstack-v3/zenstack-v3/packages/clients/tanstack-query
|
|
3
3
|
> tsc --noEmit && tsup-node && pnpm test:generate && pnpm test:typecheck
|
|
4
4
|
|
|
5
|
-
[34mCLI[39m Building entry: {"react":"src/react.ts"}
|
|
5
|
+
[34mCLI[39m Building entry: {"react":"src/react.ts","vue":"src/vue.ts","svelte":"src/svelte.ts"}
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mCLI[39m Using tsup config: /home/runner/work/zenstack-v3/zenstack-v3/packages/clients/tanstack-query/tsup.config.ts
|
|
@@ -10,22 +10,36 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
12
|
[34mESM[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/react.js
|
|
14
|
-
[32mESM[39m [1mdist/
|
|
15
|
-
[32mESM[39m
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
13
|
+
[32mESM[39m [1mdist/react.js [22m[32m39.13 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/vue.js [22m[32m37.17 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/svelte.js [22m[32m37.73 KB[39m
|
|
16
|
+
[32mESM[39m [1mdist/react.js.map [22m[32m100.01 KB[39m
|
|
17
|
+
[32mESM[39m [1mdist/vue.js.map [22m[32m94.11 KB[39m
|
|
18
|
+
[32mESM[39m [1mdist/svelte.js.map [22m[32m95.70 KB[39m
|
|
19
|
+
[32mESM[39m ⚡️ Build success in 203ms
|
|
20
|
+
[32mCJS[39m [1mdist/react.cjs [22m[32m41.61 KB[39m
|
|
21
|
+
[32mCJS[39m [1mdist/vue.cjs [22m[32m39.57 KB[39m
|
|
22
|
+
[32mCJS[39m [1mdist/svelte.cjs [22m[32m40.23 KB[39m
|
|
23
|
+
[32mCJS[39m [1mdist/react.cjs.map [22m[32m99.83 KB[39m
|
|
24
|
+
[32mCJS[39m [1mdist/vue.cjs.map [22m[32m93.99 KB[39m
|
|
25
|
+
[32mCJS[39m [1mdist/svelte.cjs.map [22m[32m95.54 KB[39m
|
|
26
|
+
[32mCJS[39m ⚡️ Build success in 204ms
|
|
19
27
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/react.d.cts
|
|
22
|
-
[32mDTS[39m [1mdist/
|
|
28
|
+
[32mDTS[39m ⚡️ Build success in 7759ms
|
|
29
|
+
[32mDTS[39m [1mdist/react.d.cts [22m[32m28.62 KB[39m
|
|
30
|
+
[32mDTS[39m [1mdist/vue.d.cts [22m[32m24.25 KB[39m
|
|
31
|
+
[32mDTS[39m [1mdist/svelte.d.cts [22m[32m18.74 KB[39m
|
|
32
|
+
[32mDTS[39m [1mdist/types-C8iIZD-7.d.cts [22m[32m3.41 KB[39m
|
|
33
|
+
[32mDTS[39m [1mdist/react.d.ts [22m[32m28.62 KB[39m
|
|
34
|
+
[32mDTS[39m [1mdist/vue.d.ts [22m[32m24.25 KB[39m
|
|
35
|
+
[32mDTS[39m [1mdist/svelte.d.ts [22m[32m18.74 KB[39m
|
|
36
|
+
[32mDTS[39m [1mdist/types-C8iIZD-7.d.ts [22m[32m3.41 KB[39m
|
|
23
37
|
|
|
24
|
-
> @zenstackhq/tanstack-query@3.0.0-beta.
|
|
38
|
+
> @zenstackhq/tanstack-query@3.0.0-beta.19 test:generate /home/runner/work/zenstack-v3/zenstack-v3/packages/clients/tanstack-query
|
|
25
39
|
> tsx scripts/generate.ts
|
|
26
40
|
|
|
27
41
|
Generating TS schema for: /home/runner/work/zenstack-v3/zenstack-v3/packages/clients/tanstack-query/test/schemas/basic/schema.zmodel
|
|
28
42
|
|
|
29
|
-
> @zenstackhq/tanstack-query@3.0.0-beta.
|
|
43
|
+
> @zenstackhq/tanstack-query@3.0.0-beta.19 test:typecheck /home/runner/work/zenstack-v3/zenstack-v3/packages/clients/tanstack-query
|
|
30
44
|
> tsc --noEmit --project tsconfig.test.json
|
|
31
45
|
|
package/dist/react.cjs
CHANGED
|
@@ -795,12 +795,12 @@ __name(deserialize, "deserialize");
|
|
|
795
795
|
|
|
796
796
|
// src/utils/common.ts
|
|
797
797
|
var QUERY_KEY_PREFIX = "zenstack";
|
|
798
|
-
async function fetcher(url, options, customFetch
|
|
798
|
+
async function fetcher(url, options, customFetch) {
|
|
799
799
|
const _fetch = customFetch ?? fetch;
|
|
800
800
|
const res = await _fetch(url, options);
|
|
801
801
|
if (!res.ok) {
|
|
802
802
|
const errData = unmarshal(await res.text());
|
|
803
|
-
if (
|
|
803
|
+
if (errData.error?.rejectedByPolicy && errData.error?.rejectReason === "cannot-read-back") {
|
|
804
804
|
return void 0;
|
|
805
805
|
}
|
|
806
806
|
const error = new Error("An error occurred while fetching the data.");
|
|
@@ -862,8 +862,8 @@ function unmarshal(value) {
|
|
|
862
862
|
}
|
|
863
863
|
}
|
|
864
864
|
__name(unmarshal, "unmarshal");
|
|
865
|
-
function makeUrl(
|
|
866
|
-
const baseUrl = `${
|
|
865
|
+
function makeUrl(endpoint, model, operation, args) {
|
|
866
|
+
const baseUrl = `${endpoint}/${(0, import_common_helpers3.lowerCaseFirst)(model)}/${operation}`;
|
|
867
867
|
if (!args) {
|
|
868
868
|
return baseUrl;
|
|
869
869
|
}
|
|
@@ -1048,49 +1048,49 @@ function useModelQueries(schema, model) {
|
|
|
1048
1048
|
return useInternalSuspenseInfiniteQuery(schema, modelName, "findMany", args, options);
|
|
1049
1049
|
}, "useSuspenseInfiniteFindMany"),
|
|
1050
1050
|
useCreate: /* @__PURE__ */ __name((options) => {
|
|
1051
|
-
return useInternalMutation(schema, modelName, "POST", "create", options
|
|
1051
|
+
return useInternalMutation(schema, modelName, "POST", "create", options);
|
|
1052
1052
|
}, "useCreate"),
|
|
1053
1053
|
useCreateMany: /* @__PURE__ */ __name((options) => {
|
|
1054
|
-
return useInternalMutation(schema, modelName, "POST", "createMany", options
|
|
1054
|
+
return useInternalMutation(schema, modelName, "POST", "createMany", options);
|
|
1055
1055
|
}, "useCreateMany"),
|
|
1056
1056
|
useCreateManyAndReturn: /* @__PURE__ */ __name((options) => {
|
|
1057
|
-
return useInternalMutation(schema, modelName, "POST", "createManyAndReturn", options
|
|
1057
|
+
return useInternalMutation(schema, modelName, "POST", "createManyAndReturn", options);
|
|
1058
1058
|
}, "useCreateManyAndReturn"),
|
|
1059
1059
|
useUpdate: /* @__PURE__ */ __name((options) => {
|
|
1060
|
-
return useInternalMutation(schema, modelName, "PUT", "update", options
|
|
1060
|
+
return useInternalMutation(schema, modelName, "PUT", "update", options);
|
|
1061
1061
|
}, "useUpdate"),
|
|
1062
1062
|
useUpdateMany: /* @__PURE__ */ __name((options) => {
|
|
1063
|
-
return useInternalMutation(schema, modelName, "PUT", "updateMany", options
|
|
1063
|
+
return useInternalMutation(schema, modelName, "PUT", "updateMany", options);
|
|
1064
1064
|
}, "useUpdateMany"),
|
|
1065
1065
|
useUpdateManyAndReturn: /* @__PURE__ */ __name((options) => {
|
|
1066
|
-
return useInternalMutation(schema, modelName, "PUT", "updateManyAndReturn", options
|
|
1066
|
+
return useInternalMutation(schema, modelName, "PUT", "updateManyAndReturn", options);
|
|
1067
1067
|
}, "useUpdateManyAndReturn"),
|
|
1068
1068
|
useUpsert: /* @__PURE__ */ __name((options) => {
|
|
1069
|
-
return useInternalMutation(schema, modelName, "POST", "upsert", options
|
|
1069
|
+
return useInternalMutation(schema, modelName, "POST", "upsert", options);
|
|
1070
1070
|
}, "useUpsert"),
|
|
1071
1071
|
useDelete: /* @__PURE__ */ __name((options) => {
|
|
1072
|
-
return useInternalMutation(schema, modelName, "DELETE", "delete", options
|
|
1072
|
+
return useInternalMutation(schema, modelName, "DELETE", "delete", options);
|
|
1073
1073
|
}, "useDelete"),
|
|
1074
1074
|
useDeleteMany: /* @__PURE__ */ __name((options) => {
|
|
1075
|
-
return useInternalMutation(schema, modelName, "DELETE", "deleteMany", options
|
|
1075
|
+
return useInternalMutation(schema, modelName, "DELETE", "deleteMany", options);
|
|
1076
1076
|
}, "useDeleteMany"),
|
|
1077
|
-
useCount: /* @__PURE__ */ __name((options) => {
|
|
1078
|
-
return useInternalQuery(schema, modelName, "count",
|
|
1077
|
+
useCount: /* @__PURE__ */ __name((args, options) => {
|
|
1078
|
+
return useInternalQuery(schema, modelName, "count", args, options);
|
|
1079
1079
|
}, "useCount"),
|
|
1080
|
-
useSuspenseCount: /* @__PURE__ */ __name((options) => {
|
|
1081
|
-
return useInternalSuspenseQuery(schema, modelName, "count",
|
|
1080
|
+
useSuspenseCount: /* @__PURE__ */ __name((args, options) => {
|
|
1081
|
+
return useInternalSuspenseQuery(schema, modelName, "count", args, options);
|
|
1082
1082
|
}, "useSuspenseCount"),
|
|
1083
|
-
useAggregate: /* @__PURE__ */ __name((options) => {
|
|
1084
|
-
return useInternalQuery(schema, modelName, "aggregate",
|
|
1083
|
+
useAggregate: /* @__PURE__ */ __name((args, options) => {
|
|
1084
|
+
return useInternalQuery(schema, modelName, "aggregate", args, options);
|
|
1085
1085
|
}, "useAggregate"),
|
|
1086
|
-
useSuspenseAggregate: /* @__PURE__ */ __name((options) => {
|
|
1087
|
-
return useInternalSuspenseQuery(schema, modelName, "aggregate",
|
|
1086
|
+
useSuspenseAggregate: /* @__PURE__ */ __name((args, options) => {
|
|
1087
|
+
return useInternalSuspenseQuery(schema, modelName, "aggregate", args, options);
|
|
1088
1088
|
}, "useSuspenseAggregate"),
|
|
1089
|
-
useGroupBy: /* @__PURE__ */ __name((options) => {
|
|
1090
|
-
return useInternalQuery(schema, modelName, "groupBy",
|
|
1089
|
+
useGroupBy: /* @__PURE__ */ __name((args, options) => {
|
|
1090
|
+
return useInternalQuery(schema, modelName, "groupBy", args, options);
|
|
1091
1091
|
}, "useGroupBy"),
|
|
1092
|
-
useSuspenseGroupBy: /* @__PURE__ */ __name((options) => {
|
|
1093
|
-
return useInternalSuspenseQuery(schema, modelName, "groupBy",
|
|
1092
|
+
useSuspenseGroupBy: /* @__PURE__ */ __name((args, options) => {
|
|
1093
|
+
return useInternalSuspenseQuery(schema, modelName, "groupBy", args, options);
|
|
1094
1094
|
}, "useSuspenseGroupBy")
|
|
1095
1095
|
};
|
|
1096
1096
|
}
|
|
@@ -1108,7 +1108,7 @@ function useInternalQuery(_schema, model, operation, args, options) {
|
|
|
1108
1108
|
queryKey,
|
|
1109
1109
|
queryFn: /* @__PURE__ */ __name(({ signal }) => fetcher(reqUrl, {
|
|
1110
1110
|
signal
|
|
1111
|
-
}, fetch2
|
|
1111
|
+
}, fetch2), "queryFn"),
|
|
1112
1112
|
...options
|
|
1113
1113
|
})
|
|
1114
1114
|
};
|
|
@@ -1127,13 +1127,16 @@ function useInternalSuspenseQuery(_schema, model, operation, args, options) {
|
|
|
1127
1127
|
queryKey,
|
|
1128
1128
|
queryFn: /* @__PURE__ */ __name(({ signal }) => fetcher(reqUrl, {
|
|
1129
1129
|
signal
|
|
1130
|
-
}, fetch2
|
|
1130
|
+
}, fetch2), "queryFn"),
|
|
1131
1131
|
...options
|
|
1132
1132
|
})
|
|
1133
1133
|
};
|
|
1134
1134
|
}
|
|
1135
1135
|
__name(useInternalSuspenseQuery, "useInternalSuspenseQuery");
|
|
1136
1136
|
function useInternalInfiniteQuery(_schema, model, operation, args, options) {
|
|
1137
|
+
options = options ?? {
|
|
1138
|
+
getNextPageParam: /* @__PURE__ */ __name(() => void 0, "getNextPageParam")
|
|
1139
|
+
};
|
|
1137
1140
|
const { endpoint, fetch: fetch2 } = useHooksContext();
|
|
1138
1141
|
const queryKey = getQueryKey(model, operation, args, {
|
|
1139
1142
|
infinite: true,
|
|
@@ -1146,7 +1149,7 @@ function useInternalInfiniteQuery(_schema, model, operation, args, options) {
|
|
|
1146
1149
|
queryFn: /* @__PURE__ */ __name(({ pageParam, signal }) => {
|
|
1147
1150
|
return fetcher(makeUrl(endpoint, model, operation, pageParam ?? args), {
|
|
1148
1151
|
signal
|
|
1149
|
-
}, fetch2
|
|
1152
|
+
}, fetch2);
|
|
1150
1153
|
}, "queryFn"),
|
|
1151
1154
|
initialPageParam: args,
|
|
1152
1155
|
...options
|
|
@@ -1167,7 +1170,7 @@ function useInternalSuspenseInfiniteQuery(_schema, model, operation, args, optio
|
|
|
1167
1170
|
queryFn: /* @__PURE__ */ __name(({ pageParam, signal }) => {
|
|
1168
1171
|
return fetcher(makeUrl(endpoint, model, operation, pageParam ?? args), {
|
|
1169
1172
|
signal
|
|
1170
|
-
}, fetch2
|
|
1173
|
+
}, fetch2);
|
|
1171
1174
|
}, "queryFn"),
|
|
1172
1175
|
initialPageParam: args,
|
|
1173
1176
|
...options
|
|
@@ -1175,8 +1178,8 @@ function useInternalSuspenseInfiniteQuery(_schema, model, operation, args, optio
|
|
|
1175
1178
|
};
|
|
1176
1179
|
}
|
|
1177
1180
|
__name(useInternalSuspenseInfiniteQuery, "useInternalSuspenseInfiniteQuery");
|
|
1178
|
-
function useInternalMutation(schema, model, method, operation, options
|
|
1179
|
-
const { endpoint, fetch: fetch2 } = useHooksContext();
|
|
1181
|
+
function useInternalMutation(schema, model, method, operation, options) {
|
|
1182
|
+
const { endpoint, fetch: fetch2, logging } = useHooksContext();
|
|
1180
1183
|
const queryClient = (0, import_react_query.useQueryClient)();
|
|
1181
1184
|
const mutationFn = /* @__PURE__ */ __name((data) => {
|
|
1182
1185
|
const reqUrl = method === "DELETE" ? makeUrl(endpoint, model, operation, data) : makeUrl(endpoint, model, operation);
|
|
@@ -1189,7 +1192,7 @@ function useInternalMutation(schema, model, method, operation, options, checkRea
|
|
|
1189
1192
|
body: marshal(data)
|
|
1190
1193
|
}
|
|
1191
1194
|
};
|
|
1192
|
-
return fetcher(reqUrl, fetchInit, fetch2
|
|
1195
|
+
return fetcher(reqUrl, fetchInit, fetch2);
|
|
1193
1196
|
}, "mutationFn");
|
|
1194
1197
|
const finalOptions = {
|
|
1195
1198
|
...options,
|
|
@@ -1197,7 +1200,6 @@ function useInternalMutation(schema, model, method, operation, options, checkRea
|
|
|
1197
1200
|
};
|
|
1198
1201
|
const invalidateQueries = options?.invalidateQueries !== false;
|
|
1199
1202
|
const optimisticUpdate2 = !!options?.optimisticUpdate;
|
|
1200
|
-
const { logging } = (0, import_react.useContext)(QuerySettingsContext);
|
|
1201
1203
|
if (operation) {
|
|
1202
1204
|
if (invalidateQueries) {
|
|
1203
1205
|
setupInvalidation(model, operation, schema, finalOptions, (predicate) => queryClient.invalidateQueries({
|