@vef-framework/core 1.0.131 → 1.0.133
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/cjs/api/api-client.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var f=require("@tanstack/react-query"),K=require("react"),C=require("./query-client.cjs"),I=require("./request-client.cjs"),R=Object.defineProperty,P=r=>{throw TypeError(r)},x=(r,e,i)=>e in r?R(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i,A=(r,e,i)=>x(r,typeof e!="symbol"?e+"":e,i),q=(r,e,i)=>e.has(r)||P("Cannot "+i),n=(r,e,i)=>(q(r,e,"read from private field"),i?i.call(r):e.get(r)),D=(r,e,i)=>e.has(r)?P("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,i),o=(r,e,i,t)=>(q(r,e,"write to private field"),t?t.call(r,i):e.set(r,i),i),m=(r,e,i)=>(q(r,e,"access private method"),i),c,y,b,h,g,k,M,S,F;class E{constructor(e){this.options=e,D(this,g),A(this,"useApiQuery"),A(this,"useSuspenseApiQuery"),A(this,"useApiMutation"),A(this,"useIsFetching"),A(this,"useIsMutating"),A(this,"QueryClientProvider"),D(this,c),D(this,y),D(this,b),D(this,h),o(this,c,C.createQueryClient(e)),o(this,y,I.createRequestClient(e)),o(this,b,{get:async(t,s)=>{const a=n(this,h);return o(this,h,void 0),await n(this,y).get(t,{...s,signal:a})},post:async(t,s,a)=>{const u=n(this,h);return o(this,h,void 0),await n(this,y).post(t,s,{...a,signal:u})},put:async(t,s,a)=>{const u=n(this,h);return o(this,h,void 0),await n(this,y).put(t,s,{...a,signal:u})},delete:async(t,s)=>{const a=n(this,h);return o(this,h,void 0),await n(this,y).delete(t,{...s,signal:a})},upload:async(t,s,a)=>{const u=n(this,h);return o(this,h,void 0),await n(this,y).upload(t,s,{...a,signal:u})},download:async(t,s)=>{const a=n(this,h);return o(this,h,void 0),await n(this,y).download(t,{...s,signal:a})}});const i=this;this.useApiQuery=function(t,s,a){var u;const{keepPreviousData:p,placeholderData:Q,initialData:l,...v}=a??{},d=f.useQuery({queryKey:[t.key,s],queryFn:({signal:w})=>t(s,{signal:w}),select:m(i,g,k),placeholderData:Q??p===!0?f.keepPreviousData:void 0,initialData:l?{code:0,message:"ok",data:l}:void 0,...v});return m(u=i,g,S).call(u,d)},this.useSuspenseApiQuery=function(t,s,a){const{keepPreviousData:u,initialData:p,...Q}=a??{},{data:l,refetch:v}=f.useSuspenseQuery({queryKey:[t.key,s],queryFn:({signal:d})=>t(s,{signal:d}),select:m(i,g,k),initialData:p?{code:0,message:"ok",data:p}:void 0,...Q});return{data:l,refetch:m(this,g,M).call(this,v)}},this.useApiMutation=function(t){const{isPending:s,isIdle:a,isError:u,isSuccess:p,error:Q,data:l,mutateAsync:v}=f.useMutation({mutationKey:[t.key],mutationFn:d=>t(d)});return{mutate:async d=>await v(d),isPending:s,isIdle:a,isError:u,isSuccess:p,message:l?.message,error:Q??void 0,data:l?.data}},this.useIsFetching=function(t,s){return f.useIsFetching({queryKey:arguments.length>1?[t,s]:[t],type:"active",exact:!1})>0},this.useIsMutating=function(t){return f.useIsMutating({mutationKey:[t],exact:!1})>0},this.QueryClientProvider=function({children:t}){return K.createElement(f.QueryClientProvider,{client:n(i,c)},t)}}async fetchApiQuery(e,i,t){const{initialData:s,...a}=t??{};return(await n(this,c).fetchQuery({queryKey:[e.key,i],queryFn:({signal:u})=>e(i,{signal:u}),initialData:s?{code:0,message:"ok",data:s}:void 0,...a})).data}createQueryApi(e,i){const t=m(this,g,F).call(this,e,i);return t.useQuery=this.useApiQuery.bind(this,t),t.useSuspenseQuery=this.useSuspenseApiQuery.bind(this,t),t.fetchQuery=this.fetchApiQuery.bind(this,t),t.getQueryData=this.getApiQueryData.bind(this,e),t.getQueriesData=this.getApiQueriesData.bind(this,e),t.setQueryData=(s,a)=>this.setApiQueryData(s,e,a),t.ensureQueryData=this.ensureApiQueryData.bind(this,t),t.removeQueries=this.removeApiQueries.bind(this,e),t.invalidateQueries=this.invalidateApiQueries.bind(this,e),t.resetQueries=this.resetApiQueries.bind(this,e),t.refetchQueries=this.refetchApiQueries.bind(this,e),t.cancelQueries=this.cancelApiQueries.bind(this,e),t.isFetching=this.isFetching.bind(this,e),t.useIsFetching=this.useIsFetching.bind(void 0,e),Object.freeze(t)}createMutationApi(e,i,t=[]){const s=m(this,g,F).call(this,e,i);return s.relatedQueries=Object.freeze(t),s.useMutation=this.useApiMutation.bind(this,s),s.refetchRelatedQueries=function(){return Promise.all(t.map(a=>a.refetchQueries()))},s.invalidateRelatedQueries=function(){return Promise.all(t.map(a=>a.invalidateQueries()))},s.isMutating=this.isMutating.bind(this,e),s.useIsMutating=this.useIsMutating.bind(void 0,e),Object.freeze(s)}getApiQueryData(e,i){return n(this,c).getQueryData(arguments.length>1?[e,i]:[e])}getApiQueriesData(e,i){return n(this,c).getQueriesData({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1})}setApiQueryData(e,i,t){n(this,c).setQueryData(arguments.length>2?[i,t]:[i],e)}async ensureApiQueryData(e,i,t){const{initialData:s,...a}=t??{};return(await n(this,c).ensureQueryData({queryKey:[e.key,i],queryFn:({signal:u})=>e(i,{signal:u}),initialData:s?{code:0,message:"ok",data:s}:void 0,...a,revalidateIfStale:!0})).data}removeApiQueries(e,i){n(this,c).removeQueries({type:"all",exact:!1,queryKey:arguments.length>1?[e,i]:[e]})}invalidateApiQueries(e,i){return n(this,c).invalidateQueries({queryKey:arguments.length>1?[e,i]:[e],type:"all",exact:!1,stale:!1,refetchType:"active"},{throwOnError:!1,cancelRefetch:!1})}resetApiQueries(e,i){return n(this,c).resetQueries({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1},{cancelRefetch:!0,throwOnError:!1})}refetchApiQueries(e,i){return n(this,c).refetchQueries({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1},{throwOnError:!1,cancelRefetch:!1})}cancelApiQueries(e,i){return n(this,c).cancelQueries({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1},{revert:!0,silent:!0})}isFetching(e,i){return n(this,c).isFetching({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1})>0}isMutating(e){return n(this,c).isMutating({mutationKey:[e],exact:!1})>0}}c=new WeakMap,y=new WeakMap,b=new WeakMap,h=new WeakMap,g=new WeakSet,k=function(r){return r.data},M=function(r){return async e=>{const i=await r(e);return{isSuccess:i.isSuccess,isError:i.isError,error:i.error,data:i.data}}},S=function({isPending:r,isFetching:e,isLoading:i,isRefetching:t,isSuccess:s,isPlaceholderData:a,isError:u,isLoadingError:p,isRefetchError:Q,isStale:l,error:v,data:d,refetch:w}){return{isPending:r,isSuccess:s,isError:u,isLoadingError:p,isRefetchError:Q,isLoading:i,isFetching:e,isRefetching:t,isPlaceholderData:a,isStale:l,error:v??void 0,data:d,refetch:m(this,g,M).call(this,w)}},F=function(r,e){const i=e(n(this,b)),t=async(s,a)=>(o(this,h,a?.signal),await i(s));return t.key=r,t};function O(r){return Object.freeze(new E(r))}exports.ApiClient=E,exports.createApiClient=O;
|
package/esm/api/api-client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import{useQuery as E,keepPreviousData as K,useSuspenseQuery as I,useMutation as R,useIsFetching as x,useIsMutating as C,QueryClientProvider as O}from"@tanstack/react-query";import{createElement as W}from"react";import{createQueryClient as j}from"./query-client.js";import{createRequestClient as z}from"./request-client.js";var L=Object.defineProperty,F=
|
|
2
|
+
import{useQuery as E,keepPreviousData as K,useSuspenseQuery as I,useMutation as R,useIsFetching as x,useIsMutating as C,QueryClientProvider as O}from"@tanstack/react-query";import{createElement as W}from"react";import{createQueryClient as j}from"./query-client.js";import{createRequestClient as z}from"./request-client.js";var L=Object.defineProperty,F=r=>{throw TypeError(r)},T=(r,e,i)=>e in r?L(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i,m=(r,e,i)=>T(r,typeof e!="symbol"?e+"":e,i),w=(r,e,i)=>e.has(r)||F("Cannot "+i),n=(r,e,i)=>(w(r,e,"read from private field"),i?i.call(r):e.get(r)),A=(r,e,i)=>e.has(r)?F("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,i),o=(r,e,i,t)=>(w(r,e,"write to private field"),t?t.call(r,i):e.set(r,i),i),f=(r,e,i)=>(w(r,e,"access private method"),i),c,y,D,h,g,k,M,P,q;class S{constructor(e){this.options=e,A(this,g),m(this,"useApiQuery"),m(this,"useSuspenseApiQuery"),m(this,"useApiMutation"),m(this,"useIsFetching"),m(this,"useIsMutating"),m(this,"QueryClientProvider"),A(this,c),A(this,y),A(this,D),A(this,h),o(this,c,j(e)),o(this,y,z(e)),o(this,D,{get:async(t,s)=>{const a=n(this,h);return o(this,h,void 0),await n(this,y).get(t,{...s,signal:a})},post:async(t,s,a)=>{const u=n(this,h);return o(this,h,void 0),await n(this,y).post(t,s,{...a,signal:u})},put:async(t,s,a)=>{const u=n(this,h);return o(this,h,void 0),await n(this,y).put(t,s,{...a,signal:u})},delete:async(t,s)=>{const a=n(this,h);return o(this,h,void 0),await n(this,y).delete(t,{...s,signal:a})},upload:async(t,s,a)=>{const u=n(this,h);return o(this,h,void 0),await n(this,y).upload(t,s,{...a,signal:u})},download:async(t,s)=>{const a=n(this,h);return o(this,h,void 0),await n(this,y).download(t,{...s,signal:a})}});const i=this;this.useApiQuery=function(t,s,a){var u;const{keepPreviousData:p,placeholderData:Q,initialData:l,...v}=a??{},d=E({queryKey:[t.key,s],queryFn:({signal:b})=>t(s,{signal:b}),select:f(i,g,k),placeholderData:Q??p===!0?K:void 0,initialData:l?{code:0,message:"ok",data:l}:void 0,...v});return f(u=i,g,P).call(u,d)},this.useSuspenseApiQuery=function(t,s,a){const{keepPreviousData:u,initialData:p,...Q}=a??{},{data:l,refetch:v}=I({queryKey:[t.key,s],queryFn:({signal:d})=>t(s,{signal:d}),select:f(i,g,k),initialData:p?{code:0,message:"ok",data:p}:void 0,...Q});return{data:l,refetch:f(this,g,M).call(this,v)}},this.useApiMutation=function(t){const{isPending:s,isIdle:a,isError:u,isSuccess:p,error:Q,data:l,mutateAsync:v}=R({mutationKey:[t.key],mutationFn:d=>t(d)});return{mutate:async d=>await v(d),isPending:s,isIdle:a,isError:u,isSuccess:p,message:l?.message,error:Q??void 0,data:l?.data}},this.useIsFetching=function(t,s){return x({queryKey:arguments.length>1?[t,s]:[t],type:"active",exact:!1})>0},this.useIsMutating=function(t){return C({mutationKey:[t],exact:!1})>0},this.QueryClientProvider=function({children:t}){return W(O,{client:n(i,c)},t)}}async fetchApiQuery(e,i,t){const{initialData:s,...a}=t??{};return(await n(this,c).fetchQuery({queryKey:[e.key,i],queryFn:({signal:u})=>e(i,{signal:u}),initialData:s?{code:0,message:"ok",data:s}:void 0,...a})).data}createQueryApi(e,i){const t=f(this,g,q).call(this,e,i);return t.useQuery=this.useApiQuery.bind(this,t),t.useSuspenseQuery=this.useSuspenseApiQuery.bind(this,t),t.fetchQuery=this.fetchApiQuery.bind(this,t),t.getQueryData=this.getApiQueryData.bind(this,e),t.getQueriesData=this.getApiQueriesData.bind(this,e),t.setQueryData=(s,a)=>this.setApiQueryData(s,e,a),t.ensureQueryData=this.ensureApiQueryData.bind(this,t),t.removeQueries=this.removeApiQueries.bind(this,e),t.invalidateQueries=this.invalidateApiQueries.bind(this,e),t.resetQueries=this.resetApiQueries.bind(this,e),t.refetchQueries=this.refetchApiQueries.bind(this,e),t.cancelQueries=this.cancelApiQueries.bind(this,e),t.isFetching=this.isFetching.bind(this,e),t.useIsFetching=this.useIsFetching.bind(void 0,e),Object.freeze(t)}createMutationApi(e,i,t=[]){const s=f(this,g,q).call(this,e,i);return s.relatedQueries=Object.freeze(t),s.useMutation=this.useApiMutation.bind(this,s),s.refetchRelatedQueries=function(){return Promise.all(t.map(a=>a.refetchQueries()))},s.invalidateRelatedQueries=function(){return Promise.all(t.map(a=>a.invalidateQueries()))},s.isMutating=this.isMutating.bind(this,e),s.useIsMutating=this.useIsMutating.bind(void 0,e),Object.freeze(s)}getApiQueryData(e,i){return n(this,c).getQueryData(arguments.length>1?[e,i]:[e])}getApiQueriesData(e,i){return n(this,c).getQueriesData({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1})}setApiQueryData(e,i,t){n(this,c).setQueryData(arguments.length>2?[i,t]:[i],e)}async ensureApiQueryData(e,i,t){const{initialData:s,...a}=t??{};return(await n(this,c).ensureQueryData({queryKey:[e.key,i],queryFn:({signal:u})=>e(i,{signal:u}),initialData:s?{code:0,message:"ok",data:s}:void 0,...a,revalidateIfStale:!0})).data}removeApiQueries(e,i){n(this,c).removeQueries({type:"all",exact:!1,queryKey:arguments.length>1?[e,i]:[e]})}invalidateApiQueries(e,i){return n(this,c).invalidateQueries({queryKey:arguments.length>1?[e,i]:[e],type:"all",exact:!1,stale:!1,refetchType:"active"},{throwOnError:!1,cancelRefetch:!1})}resetApiQueries(e,i){return n(this,c).resetQueries({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1},{cancelRefetch:!0,throwOnError:!1})}refetchApiQueries(e,i){return n(this,c).refetchQueries({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1},{throwOnError:!1,cancelRefetch:!1})}cancelApiQueries(e,i){return n(this,c).cancelQueries({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1},{revert:!0,silent:!0})}isFetching(e,i){return n(this,c).isFetching({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1})>0}isMutating(e){return n(this,c).isMutating({mutationKey:[e],exact:!1})>0}}c=new WeakMap,y=new WeakMap,D=new WeakMap,h=new WeakMap,g=new WeakSet,k=function(r){return r.data},M=function(r){return async e=>{const i=await r(e);return{isSuccess:i.isSuccess,isError:i.isError,error:i.error,data:i.data}}},P=function({isPending:r,isFetching:e,isLoading:i,isRefetching:t,isSuccess:s,isPlaceholderData:a,isError:u,isLoadingError:p,isRefetchError:Q,isStale:l,error:v,data:d,refetch:b}){return{isPending:r,isSuccess:s,isError:u,isLoadingError:p,isRefetchError:Q,isLoading:i,isFetching:e,isRefetching:t,isPlaceholderData:a,isStale:l,error:v??void 0,data:d,refetch:f(this,g,M).call(this,b)}},q=function(r,e){const i=e(n(this,D)),t=async(s,a)=>(o(this,h,a?.signal),await i(s));return t.key=r,t};function B(r){return Object.freeze(new S(r))}export{S as ApiClient,B as createApiClient};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vef-framework/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.133",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "The core of the VEF framework",
|
|
7
7
|
"author": "Venus",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"@emotion/cache": "11.14.0",
|
|
24
24
|
"@emotion/react": "11.14.0",
|
|
25
25
|
"@emotion/styled": "11.14.0",
|
|
26
|
-
"antd": "5.24.
|
|
27
|
-
"use-sync-external-store": "^1.
|
|
28
|
-
"@tanstack/react-query": "5.
|
|
29
|
-
"@tanstack/react-router": "1.
|
|
30
|
-
"@vef-framework/shared": "1.0.
|
|
26
|
+
"antd": "5.24.7",
|
|
27
|
+
"use-sync-external-store": "^1.5.0",
|
|
28
|
+
"@tanstack/react-query": "5.74.3",
|
|
29
|
+
"@tanstack/react-router": "1.116.0",
|
|
30
|
+
"@vef-framework/shared": "1.0.133",
|
|
31
31
|
"axios": "1.8.4",
|
|
32
32
|
"qs": "6.14.0"
|
|
33
33
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"./package.json": "./package.json"
|
|
49
49
|
},
|
|
50
50
|
"module": "esm/index.js",
|
|
51
|
-
"packageManager": "pnpm@10.
|
|
51
|
+
"packageManager": "pnpm@10.8.1",
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": "18.3.1",
|
|
54
54
|
"react-dom": "18.3.1"
|
|
@@ -11,6 +11,10 @@ export interface RequestMethods<R = unknown> {
|
|
|
11
11
|
post: <D, P extends ObjectType = ObjectValue, T = R>(url: string, data?: D, options?: Except<RequestOptions<P>, "onProgress" | "signal">) => Promise<ApiResponse<T>>;
|
|
12
12
|
put: <D, P extends ObjectType = ObjectValue, T = R>(url: string, data?: D, options?: Except<RequestOptions<P>, "onProgress" | "signal">) => Promise<ApiResponse<T>>;
|
|
13
13
|
delete: <P extends ObjectType = ObjectValue, T = R>(url: string, options?: Except<RequestOptions<P>, "onProgress" | "signal">) => Promise<ApiResponse<T>>;
|
|
14
|
+
upload: <R = unknown, P extends ObjectType = ObjectValue>(url: string, data: FormData, options?: RequestOptions<P>) => Promise<ApiResponse<R>>;
|
|
15
|
+
download: <P extends ObjectType = ObjectValue>(url: string, options?: RequestOptions<P> & {
|
|
16
|
+
fileName?: string | Mapper<string, string>;
|
|
17
|
+
}) => Promise<void>;
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
16
20
|
* The API client options.
|