@vesperjs/vue 0.5.0 → 0.7.0
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/dist/index.d.mts +2 -0
- package/dist/index.mjs +13 -4
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -19,7 +19,9 @@ declare const useOFetch: <T = unknown, E = any>(url: string, options?: FetchOpti
|
|
|
19
19
|
//#region src/composables/backend/api/use-query-api.d.ts
|
|
20
20
|
type SearchParams = Record<string, any>;
|
|
21
21
|
interface QueryAPIOptions {
|
|
22
|
+
method?: 'get' | 'query';
|
|
22
23
|
query?: SearchParams;
|
|
24
|
+
body?: Record<string, any> | FormData;
|
|
23
25
|
token?: string | null | undefined;
|
|
24
26
|
baseURL?: string | null | undefined;
|
|
25
27
|
signal?: AbortSignal;
|
package/dist/index.mjs
CHANGED
|
@@ -94,13 +94,22 @@ const useQueryApi = async function(url, options) {
|
|
|
94
94
|
if (options?.token) headers.Authorization = `Bearer ${options.token}`;
|
|
95
95
|
const queryOptions = {
|
|
96
96
|
baseURL: options?.baseURL ?? baseUrl.value,
|
|
97
|
-
method: "get",
|
|
98
|
-
query: options?.query ?? {},
|
|
99
97
|
headers,
|
|
100
98
|
onResponse({ response }) {
|
|
101
99
|
tokenRef.value = response.headers.get("Authorization")?.split(" ")[1] ?? options?.token;
|
|
102
100
|
}
|
|
103
101
|
};
|
|
102
|
+
if (options?.method) {
|
|
103
|
+
queryOptions.method = options.method;
|
|
104
|
+
if (options.method === "get") queryOptions.query = options.query ?? {};
|
|
105
|
+
if (options.method === "query") queryOptions.body = options.body ?? {};
|
|
106
|
+
} else if (options?.query) {
|
|
107
|
+
queryOptions.method = "get";
|
|
108
|
+
queryOptions.query = options.query;
|
|
109
|
+
} else if (options?.body) {
|
|
110
|
+
queryOptions.method = "query";
|
|
111
|
+
queryOptions.body = options.body;
|
|
112
|
+
}
|
|
104
113
|
if (options?.retry) queryOptions.retry = options.retry;
|
|
105
114
|
if (options?.retryDelay) queryOptions.retryDelay = options.retryDelay;
|
|
106
115
|
if (options?.retryStatusCodes) queryOptions.retryStatusCodes = options.retryStatusCodes;
|
|
@@ -145,7 +154,7 @@ const useMutationApi = async function(url, options) {
|
|
|
145
154
|
if (timeout) mutOptions.timeout = timeout;
|
|
146
155
|
if (onRequestError) mutOptions.onRequestError = onRequestError;
|
|
147
156
|
if (onResponseError) mutOptions.onResponseError = onResponseError;
|
|
148
|
-
if (method
|
|
157
|
+
if (method === "post" || method === "put") mutOptions.body = body;
|
|
149
158
|
mutOptions.onResponse = ({ response }) => {
|
|
150
159
|
tokenRef.value = response.headers.get("Authorization")?.split(" ")[1] ?? token;
|
|
151
160
|
};
|
|
@@ -191,7 +200,7 @@ const useApiError = function({ flash, caller }) {
|
|
|
191
200
|
}
|
|
192
201
|
};
|
|
193
202
|
const reload = () => {
|
|
194
|
-
if (backendErrorInfo.value.status
|
|
203
|
+
if (backendErrorInfo.value.status === 404) globalThis.setTimeout(() => {
|
|
195
204
|
globalThis.location.reload();
|
|
196
205
|
}, 1e3);
|
|
197
206
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesperjs/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"vue.js"
|
|
6
6
|
],
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"@formkit/tempo": "^1.0.0",
|
|
23
23
|
"@nanostores/persistent": "^1.3.4",
|
|
24
24
|
"@nanostores/router": "^1.0.0",
|
|
25
|
-
"@vesperjs/shared": "0.
|
|
25
|
+
"@vesperjs/shared": "0.7.0",
|
|
26
26
|
"nanostores": "^1.3.0",
|
|
27
27
|
"ofetch": "^1.5.1",
|
|
28
28
|
"undici": "^8.2.0",
|
|
29
|
-
"vue-i18n": "^11.4.
|
|
29
|
+
"vue-i18n": "^11.4.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@eslint/js": "^10.0.1",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"@typescript-eslint/parser": "^8.59.2",
|
|
35
35
|
"@vue/eslint-config-typescript": "^14.7.0",
|
|
36
36
|
"eslint": "^10.3.0",
|
|
37
|
-
"eslint-plugin-vue": "^10.9.
|
|
38
|
-
"oxfmt": "^0.
|
|
39
|
-
"tsdown": "^0.
|
|
37
|
+
"eslint-plugin-vue": "^10.9.1",
|
|
38
|
+
"oxfmt": "^0.48.0",
|
|
39
|
+
"tsdown": "^0.22.0",
|
|
40
40
|
"typescript": "^6.0.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@vue/reactivity": "^3.5.
|
|
44
|
-
"@vue/runtime-core": "^3.5.
|
|
45
|
-
"@vue/runtime-dom": "^3.5.
|
|
46
|
-
"vue": "^3.5.
|
|
43
|
+
"@vue/reactivity": "^3.5.34 || ^3.6.0-beta.11",
|
|
44
|
+
"@vue/runtime-core": "^3.5.34 || ^3.6.0-beta.11",
|
|
45
|
+
"@vue/runtime-dom": "^3.5.34 || ^3.6.0-beta.11",
|
|
46
|
+
"vue": "^3.5.34 || ^3.6.0-beta.11"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsdown --dts",
|