@vesperjs/vue 0.3.1 → 0.3.3
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 +21 -7
- package/dist/index.mjs +9 -8
- package/package.json +19 -19
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,7 @@ type SearchParams = Record<string, any>;
|
|
|
23
23
|
interface QueryAPIOptions {
|
|
24
24
|
query?: SearchParams;
|
|
25
25
|
token?: string | null | undefined;
|
|
26
|
+
baseURL?: string | null | undefined;
|
|
26
27
|
signal?: AbortSignal;
|
|
27
28
|
onRequestError?: ({
|
|
28
29
|
error
|
|
@@ -49,6 +50,7 @@ interface MutationAPIOptions {
|
|
|
49
50
|
method: 'post' | 'put' | 'delete';
|
|
50
51
|
body?: Record<string, any> | FormData;
|
|
51
52
|
token?: string | null;
|
|
53
|
+
baseURL?: string | null;
|
|
52
54
|
onRequestError?: ({
|
|
53
55
|
error
|
|
54
56
|
}: {
|
|
@@ -64,6 +66,7 @@ declare const useMutationApi: <T = unknown, E = any>(url: string, {
|
|
|
64
66
|
method,
|
|
65
67
|
body,
|
|
66
68
|
token,
|
|
69
|
+
baseURL,
|
|
67
70
|
onRequestError,
|
|
68
71
|
onResponseError
|
|
69
72
|
}: MutationAPIOptions) => Promise<{
|
|
@@ -73,26 +76,37 @@ declare const useMutationApi: <T = unknown, E = any>(url: string, {
|
|
|
73
76
|
pending: boolean;
|
|
74
77
|
}>;
|
|
75
78
|
//#endregion
|
|
76
|
-
//#region src/composables/backend/use-
|
|
77
|
-
interface
|
|
79
|
+
//#region src/composables/backend/use-api-error.d.ts
|
|
80
|
+
interface UseApiErrorOptions {
|
|
78
81
|
flash: Ref<Flash>;
|
|
79
|
-
caller?:
|
|
82
|
+
caller?: UseApiErrorCallerType;
|
|
80
83
|
}
|
|
81
|
-
interface
|
|
84
|
+
interface UseApiErrorCallerType {
|
|
82
85
|
externalErrors?: Ref<ErrorMessages<string>>;
|
|
83
86
|
clearAccount?: () => void;
|
|
84
87
|
}
|
|
88
|
+
declare const useApiError: <BER extends object = BackendErrorResource>({
|
|
89
|
+
flash,
|
|
90
|
+
caller
|
|
91
|
+
}: UseApiErrorOptions) => {
|
|
92
|
+
backendErrorInfo: Ref<BackendErrorInfo<BER>, BER>;
|
|
93
|
+
setError: (error: FetchError<ErrorsResource<ErrorMessages<string>> | BER>, options?: {
|
|
94
|
+
off?: boolean;
|
|
95
|
+
}) => void;
|
|
96
|
+
reload: () => void;
|
|
97
|
+
};
|
|
85
98
|
declare const useAlert: <BER extends object = BackendErrorResource>({
|
|
86
99
|
flash,
|
|
87
100
|
caller
|
|
88
|
-
}:
|
|
101
|
+
}: UseApiErrorOptions) => {
|
|
89
102
|
backendErrorInfo: Ref<BackendErrorInfo<BER>, BER>;
|
|
90
103
|
setError: (error: FetchError<ErrorsResource<ErrorMessages<string>> | BER>, options?: {
|
|
91
104
|
off?: boolean;
|
|
92
105
|
}) => void;
|
|
93
106
|
reload: () => void;
|
|
94
107
|
};
|
|
95
|
-
type
|
|
108
|
+
type UseApiErrorType = ReturnType<typeof useApiError>;
|
|
109
|
+
type UseAlertType = UseApiErrorType;
|
|
96
110
|
//#endregion
|
|
97
111
|
//#region src/composables/ui/dom/use-element.d.ts
|
|
98
112
|
declare const useElement: <EL extends Element, P extends string>(el: EL | undefined | null, {
|
|
@@ -137,4 +151,4 @@ declare const i18n: _$vue_i18n0.I18n<{
|
|
|
137
151
|
};
|
|
138
152
|
}, {}, {}, string, false>;
|
|
139
153
|
//#endregion
|
|
140
|
-
export { type BackendErrorInfo, type BackendErrorResource, type ErrorMessages, type ErrorsResource, type Flash, type UseAlertType, type UseFlashType, type UseNanoRouteType, i18n, useAlert, useApiConstants, useDate, useElement, useEntity, useExternalErrors, useFlash, useLocale, useMutationApi, useNanoRoute, useOFetch, useQueryApi };
|
|
154
|
+
export { type BackendErrorInfo, type BackendErrorResource, type ErrorMessages, type ErrorsResource, type Flash, type UseAlertType, type UseApiErrorType, type UseFlashType, type UseNanoRouteType, i18n, useAlert, useApiConstants, useApiError, useDate, useElement, useEntity, useExternalErrors, useFlash, useLocale, useMutationApi, useNanoRoute, useOFetch, useQueryApi };
|
package/dist/index.mjs
CHANGED
|
@@ -88,12 +88,12 @@ const useHttpHeaders = function() {
|
|
|
88
88
|
//#region src/composables/backend/api/use-query-api.ts
|
|
89
89
|
const useQueryApi = async function(url, options) {
|
|
90
90
|
const { commonHeaders } = useHttpHeaders();
|
|
91
|
-
const { baseURL } = useApiConstants();
|
|
91
|
+
const { baseURL: baseUrl } = useApiConstants();
|
|
92
92
|
const tokenRef = ref();
|
|
93
93
|
const headers = commonHeaders.value;
|
|
94
94
|
if (options?.token) headers.Authorization = `Bearer ${options.token}`;
|
|
95
95
|
const getOptions = {
|
|
96
|
-
baseURL: baseURL.value,
|
|
96
|
+
baseURL: options?.baseURL ?? baseUrl.value,
|
|
97
97
|
method: "get",
|
|
98
98
|
query: options?.query ?? {},
|
|
99
99
|
headers,
|
|
@@ -114,9 +114,9 @@ const useQueryApi = async function(url, options) {
|
|
|
114
114
|
};
|
|
115
115
|
//#endregion
|
|
116
116
|
//#region src/composables/backend/api/use-mutation-api.ts
|
|
117
|
-
const useMutationApi = async function(url, { method, body = {}, token = null, onRequestError, onResponseError }) {
|
|
117
|
+
const useMutationApi = async function(url, { method, body = {}, token = null, baseURL = null, onRequestError, onResponseError }) {
|
|
118
118
|
const { commonHeaders } = useHttpHeaders();
|
|
119
|
-
const { baseURL } = useApiConstants();
|
|
119
|
+
const { baseURL: baseUrl } = useApiConstants();
|
|
120
120
|
const headers = commonHeaders.value;
|
|
121
121
|
const tokenRef = ref();
|
|
122
122
|
if (token) {
|
|
@@ -124,7 +124,7 @@ const useMutationApi = async function(url, { method, body = {}, token = null, on
|
|
|
124
124
|
tokenRef.value = token;
|
|
125
125
|
}
|
|
126
126
|
const options = {
|
|
127
|
-
baseURL: baseURL.value,
|
|
127
|
+
baseURL: baseURL ?? baseUrl.value,
|
|
128
128
|
headers,
|
|
129
129
|
method
|
|
130
130
|
};
|
|
@@ -143,8 +143,8 @@ const useMutationApi = async function(url, { method, body = {}, token = null, on
|
|
|
143
143
|
};
|
|
144
144
|
};
|
|
145
145
|
//#endregion
|
|
146
|
-
//#region src/composables/backend/use-
|
|
147
|
-
const
|
|
146
|
+
//#region src/composables/backend/use-api-error.ts
|
|
147
|
+
const useApiError = function({ flash, caller }) {
|
|
148
148
|
const { backendErrorInfo, clearBackendErrorInfo } = useBackendErrorInfo();
|
|
149
149
|
const setError = function(error, options) {
|
|
150
150
|
const off = options?.off ?? false;
|
|
@@ -186,6 +186,7 @@ const useAlert = function({ flash, caller }) {
|
|
|
186
186
|
reload
|
|
187
187
|
};
|
|
188
188
|
};
|
|
189
|
+
const useAlert = useApiError;
|
|
189
190
|
//#endregion
|
|
190
191
|
//#region src/composables/ui/dom/use-element.ts
|
|
191
192
|
const useElement = function(el, { property }) {
|
|
@@ -211,4 +212,4 @@ const useNanoRoute = function(router) {
|
|
|
211
212
|
};
|
|
212
213
|
};
|
|
213
214
|
//#endregion
|
|
214
|
-
export { i18n, useAlert, useApiConstants, useDate, useElement, useEntity, useExternalErrors, useFlash, useLocale, useMutationApi, useNanoRoute, useOFetch, useQueryApi };
|
|
215
|
+
export { i18n, useAlert, useApiConstants, useApiError, useDate, useElement, useEntity, useExternalErrors, useFlash, useLocale, useMutationApi, useNanoRoute, useOFetch, useQueryApi };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesperjs/vue",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"vue.js"
|
|
6
6
|
],
|
|
@@ -20,33 +20,33 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@formkit/tempo": "^1.0.0",
|
|
23
|
-
"@nanostores/persistent": "^1.3.
|
|
23
|
+
"@nanostores/persistent": "^1.3.4",
|
|
24
24
|
"@nanostores/router": "^1.0.0",
|
|
25
|
-
"@vesperjs/shared": "0.3.
|
|
26
|
-
"nanostores": "^1.
|
|
25
|
+
"@vesperjs/shared": "0.3.3",
|
|
26
|
+
"nanostores": "^1.3.0",
|
|
27
27
|
"ofetch": "^1.5.1",
|
|
28
28
|
"undici": "^8.1.0",
|
|
29
|
-
"vue-i18n": "^11.
|
|
29
|
+
"vue-i18n": "^11.4.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@eslint/js": "^10.0.1",
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
34
|
-
"@typescript-eslint/parser": "^8.
|
|
35
|
-
"@typescript-eslint/project-service": "^8.
|
|
36
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
37
|
-
"@typescript-eslint/utils": "^8.
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^8.59.1",
|
|
34
|
+
"@typescript-eslint/parser": "^8.59.1",
|
|
35
|
+
"@typescript-eslint/project-service": "^8.59.1",
|
|
36
|
+
"@typescript-eslint/typescript-estree": "^8.59.1",
|
|
37
|
+
"@typescript-eslint/utils": "^8.59.1",
|
|
38
38
|
"@vue/eslint-config-typescript": "^14.7.0",
|
|
39
|
-
"eslint": "^10.2.
|
|
40
|
-
"eslint-plugin-vue": "^10.
|
|
41
|
-
"oxfmt": "^0.
|
|
42
|
-
"tsdown": "^0.21.
|
|
43
|
-
"typescript": "^6.0.
|
|
39
|
+
"eslint": "^10.2.1",
|
|
40
|
+
"eslint-plugin-vue": "^10.9.0",
|
|
41
|
+
"oxfmt": "^0.47.0",
|
|
42
|
+
"tsdown": "^0.21.10",
|
|
43
|
+
"typescript": "^6.0.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@vue/reactivity": "^3.5.
|
|
47
|
-
"@vue/runtime-core": "^3.5.
|
|
48
|
-
"@vue/runtime-dom": "^3.5.
|
|
49
|
-
"vue": "^3.5.
|
|
46
|
+
"@vue/reactivity": "^3.5.33 || ^3.6.0-beta.10",
|
|
47
|
+
"@vue/runtime-core": "^3.5.33 || ^3.6.0-beta.10",
|
|
48
|
+
"@vue/runtime-dom": "^3.5.33 || ^3.6.0-beta.10",
|
|
49
|
+
"vue": "^3.5.33 || ^3.6.0-beta.10"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsdown --dts",
|