@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.
@@ -1,32 +1,45 @@
1
-
2
- 
3
- > @zenstackhq/tanstack-query@3.0.0-beta.16 build /Users/yiming/git/zenstack/zenstack-v3/packages/clients/tanstack-query
4
- > tsc --noEmit && tsup-node && pnpm test:generate && pnpm test:typecheck
5
-
6
- CLI Building entry: {"react":"src/react.ts"}
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.5.0
9
- CLI Using tsup config: /Users/yiming/git/zenstack/zenstack-v3/packages/clients/tanstack-query/tsup.config.ts
10
- CLI Target: esnext
11
- CLI Cleaning output folder
12
- CJS Build start
13
- ESM Build start
14
- ESM dist/react.js 39.18 KB
15
- ESM dist/react.js.map 98.16 KB
16
- ESM ⚡️ Build success in 40ms
17
- CJS dist/react.cjs 41.69 KB
18
- CJS dist/react.cjs.map 97.98 KB
19
- CJS ⚡️ Build success in 40ms
20
- DTS Build start
21
- DTS ⚡️ Build success in 1664ms
22
- DTS dist/react.d.cts 30.16 KB
23
- DTS dist/react.d.ts 30.16 KB
24
-
25
- > @zenstackhq/tanstack-query@3.0.0-beta.16 test:generate /Users/yiming/git/zenstack/zenstack-v3/packages/clients/tanstack-query
26
- > tsx scripts/generate.ts
27
-
28
- Generating TS schema for: /Users/yiming/git/zenstack/zenstack-v3/packages/clients/tanstack-query/test/schemas/basic/schema.zmodel
29
-
30
- > @zenstackhq/tanstack-query@3.0.0-beta.16 test:typecheck /Users/yiming/git/zenstack/zenstack-v3/packages/clients/tanstack-query
31
- > tsc --noEmit --project tsconfig.test.json
32
-
1
+
2
+ > @zenstackhq/tanstack-query@3.0.0-beta.18 build /home/runner/work/zenstack-v3/zenstack-v3/packages/clients/tanstack-query
3
+ > tsc --noEmit && tsup-node && pnpm test:generate && pnpm test:typecheck
4
+
5
+ CLI Building entry: {"react":"src/react.ts","vue":"src/vue.ts","svelte":"src/svelte.ts"}
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.5.0
8
+ CLI Using tsup config: /home/runner/work/zenstack-v3/zenstack-v3/packages/clients/tanstack-query/tsup.config.ts
9
+ CLI Target: esnext
10
+ CLI Cleaning output folder
11
+ CJS Build start
12
+ ESM Build start
13
+ ESM dist/react.js 39.13 KB
14
+ ESM dist/vue.js 37.17 KB
15
+ ESM dist/svelte.js 37.73 KB
16
+ ESM dist/react.js.map 99.64 KB
17
+ ESM dist/vue.js.map 93.76 KB
18
+ ESM dist/svelte.js.map 95.33 KB
19
+ ESM ⚡️ Build success in 213ms
20
+ CJS dist/react.cjs 41.61 KB
21
+ CJS dist/vue.cjs 39.57 KB
22
+ CJS dist/svelte.cjs 40.23 KB
23
+ CJS dist/react.cjs.map 99.45 KB
24
+ CJS dist/vue.cjs.map 93.64 KB
25
+ CJS dist/svelte.cjs.map 95.18 KB
26
+ CJS ⚡️ Build success in 221ms
27
+ DTS Build start
28
+ DTS ⚡️ Build success in 7710ms
29
+ DTS dist/react.d.cts 28.57 KB
30
+ DTS dist/vue.d.cts 24.21 KB
31
+ DTS dist/svelte.d.cts 18.71 KB
32
+ DTS dist/types-BRIDXxNC.d.cts 3.12 KB
33
+ DTS dist/react.d.ts 28.57 KB
34
+ DTS dist/vue.d.ts 24.21 KB
35
+ DTS dist/svelte.d.ts 18.70 KB
36
+ DTS dist/types-BRIDXxNC.d.ts 3.12 KB
37
+
38
+ > @zenstackhq/tanstack-query@3.0.0-beta.18 test:generate /home/runner/work/zenstack-v3/zenstack-v3/packages/clients/tanstack-query
39
+ > tsx scripts/generate.ts
40
+
41
+ Generating TS schema for: /home/runner/work/zenstack-v3/zenstack-v3/packages/clients/tanstack-query/test/schemas/basic/schema.zmodel
42
+
43
+ > @zenstackhq/tanstack-query@3.0.0-beta.18 test:typecheck /home/runner/work/zenstack-v3/zenstack-v3/packages/clients/tanstack-query
44
+ > tsc --noEmit --project tsconfig.test.json
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, checkReadBack) {
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 (checkReadBack !== false && errData.error?.rejectedByPolicy && errData.error?.rejectReason === "cannot-read-back") {
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(url, model, operation, args) {
866
- const baseUrl = `${url}/${(0, import_common_helpers3.lowerCaseFirst)(model)}/${operation}`;
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, true);
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, false);
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, true);
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, true);
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, false);
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, true);
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, true);
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, true);
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, false);
1075
+ return useInternalMutation(schema, modelName, "DELETE", "deleteMany", options);
1076
1076
  }, "useDeleteMany"),
1077
- useCount: /* @__PURE__ */ __name((options) => {
1078
- return useInternalQuery(schema, modelName, "count", void 0, options);
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", void 0, options);
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", void 0, options);
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", void 0, options);
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", void 0, options);
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", void 0, options);
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, false), "queryFn"),
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, false), "queryFn"),
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, false);
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, false);
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, checkReadBack) {
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, checkReadBack);
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({