@navservice/core 1.56.0 → 1.58.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/build/es/utils/_api.d.ts +11 -13
- package/build/es/utils.js +28 -25
- package/build/lib/utils/_api.d.ts +11 -13
- package/build/lib/utils.cjs +28 -27
- package/package.json +1 -1
package/build/es/utils/_api.d.ts
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { AxiosResponse } from "axios";
|
|
2
|
-
interface ApiClientOptions {
|
|
3
|
-
baseURL?: string;
|
|
4
|
-
withAuth?: boolean;
|
|
5
|
-
}
|
|
6
2
|
export default class api {
|
|
7
|
-
private axios;
|
|
8
|
-
private withAuth;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
get<T = any>({ url, params }: {
|
|
3
|
+
private static axios;
|
|
4
|
+
private static withAuth;
|
|
5
|
+
private static get_headers;
|
|
6
|
+
static get<T = any>({ url, params, setToken }: {
|
|
12
7
|
url: string;
|
|
13
8
|
params?: Record<string, any>;
|
|
9
|
+
setToken?: boolean;
|
|
14
10
|
}): Promise<AxiosResponse<T>>;
|
|
15
|
-
post<T = any>({ url, data }: {
|
|
11
|
+
static post<T = any>({ url, data, setToken }: {
|
|
16
12
|
url: string;
|
|
17
13
|
data?: any;
|
|
14
|
+
setToken?: boolean;
|
|
18
15
|
}): Promise<AxiosResponse<T>>;
|
|
19
|
-
patch<T = any>({ url, data }: {
|
|
16
|
+
static patch<T = any>({ url, data, setToken }: {
|
|
20
17
|
url: string;
|
|
21
18
|
data?: any;
|
|
19
|
+
setToken?: boolean;
|
|
22
20
|
}): Promise<AxiosResponse<T>>;
|
|
23
|
-
delete<T = any>({ url }: {
|
|
21
|
+
static delete<T = any>({ url, setToken }: {
|
|
24
22
|
url: string;
|
|
23
|
+
setToken?: boolean;
|
|
25
24
|
}): Promise<AxiosResponse<T>>;
|
|
26
25
|
}
|
|
27
|
-
export {};
|
package/build/es/utils.js
CHANGED
|
@@ -52,40 +52,43 @@ class config_env {
|
|
|
52
52
|
}
|
|
53
53
|
const src_config_env = config_env;
|
|
54
54
|
class api {
|
|
55
|
-
axios
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
static axios = axios.create({
|
|
56
|
+
baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL,
|
|
57
|
+
headers: {
|
|
58
|
+
"Content-Type": "application/json"
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
static withAuth = true;
|
|
62
|
+
static get_headers(setToken) {
|
|
63
|
+
if (true === setToken && true === this.withAuth) {
|
|
64
|
+
const auth = utils_session_storage.get_item_session_storage("auth_user");
|
|
65
|
+
return {
|
|
66
|
+
headers: {
|
|
67
|
+
Authorization: auth?.data?.usuario?.token ? `Bearer ${auth.data.usuario.token}` : void 0,
|
|
68
|
+
"Content-Type": "application/json"
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
61
73
|
headers: {
|
|
62
74
|
"Content-Type": "application/json"
|
|
63
75
|
}
|
|
64
|
-
}
|
|
65
|
-
this.set_bearer_token();
|
|
66
|
-
}
|
|
67
|
-
set_bearer_token() {
|
|
68
|
-
this.axios.interceptors.request.use((config)=>{
|
|
69
|
-
if (this.withAuth) {
|
|
70
|
-
const auth = utils_session_storage.get_item_session_storage("auth_user");
|
|
71
|
-
if (auth?.data?.usuario?.token) config.headers.Authorization = `Bearer ${auth.data.usuario.token}`;
|
|
72
|
-
}
|
|
73
|
-
return config;
|
|
74
|
-
});
|
|
76
|
+
};
|
|
75
77
|
}
|
|
76
|
-
async get({ url, params }) {
|
|
78
|
+
static async get({ url, params, setToken = true }) {
|
|
77
79
|
return this.axios.get(url, {
|
|
78
|
-
params
|
|
80
|
+
params,
|
|
81
|
+
...this.get_headers(setToken)
|
|
79
82
|
});
|
|
80
83
|
}
|
|
81
|
-
async post({ url, data }) {
|
|
82
|
-
return this.axios.post(url, data);
|
|
84
|
+
static async post({ url, data, setToken = true }) {
|
|
85
|
+
return this.axios.post(url, data, this.get_headers(setToken));
|
|
83
86
|
}
|
|
84
|
-
async patch({ url, data }) {
|
|
85
|
-
return this.axios.patch(url, data);
|
|
87
|
+
static async patch({ url, data, setToken = true }) {
|
|
88
|
+
return this.axios.patch(url, data, this.get_headers(setToken));
|
|
86
89
|
}
|
|
87
|
-
async delete({ url }) {
|
|
88
|
-
return this.axios.delete(url);
|
|
90
|
+
static async delete({ url, setToken = true }) {
|
|
91
|
+
return this.axios.delete(url, this.get_headers(setToken));
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
const _data = class {
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { AxiosResponse } from "axios";
|
|
2
|
-
interface ApiClientOptions {
|
|
3
|
-
baseURL?: string;
|
|
4
|
-
withAuth?: boolean;
|
|
5
|
-
}
|
|
6
2
|
export default class api {
|
|
7
|
-
private axios;
|
|
8
|
-
private withAuth;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
get<T = any>({ url, params }: {
|
|
3
|
+
private static axios;
|
|
4
|
+
private static withAuth;
|
|
5
|
+
private static get_headers;
|
|
6
|
+
static get<T = any>({ url, params, setToken }: {
|
|
12
7
|
url: string;
|
|
13
8
|
params?: Record<string, any>;
|
|
9
|
+
setToken?: boolean;
|
|
14
10
|
}): Promise<AxiosResponse<T>>;
|
|
15
|
-
post<T = any>({ url, data }: {
|
|
11
|
+
static post<T = any>({ url, data, setToken }: {
|
|
16
12
|
url: string;
|
|
17
13
|
data?: any;
|
|
14
|
+
setToken?: boolean;
|
|
18
15
|
}): Promise<AxiosResponse<T>>;
|
|
19
|
-
patch<T = any>({ url, data }: {
|
|
16
|
+
static patch<T = any>({ url, data, setToken }: {
|
|
20
17
|
url: string;
|
|
21
18
|
data?: any;
|
|
19
|
+
setToken?: boolean;
|
|
22
20
|
}): Promise<AxiosResponse<T>>;
|
|
23
|
-
delete<T = any>({ url }: {
|
|
21
|
+
static delete<T = any>({ url, setToken }: {
|
|
24
22
|
url: string;
|
|
23
|
+
setToken?: boolean;
|
|
25
24
|
}): Promise<AxiosResponse<T>>;
|
|
26
25
|
}
|
|
27
|
-
export {};
|
package/build/lib/utils.cjs
CHANGED
|
@@ -117,42 +117,43 @@ class config_env {
|
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
class api {
|
|
120
|
-
axios
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
static axios = external_axios_default().create({
|
|
121
|
+
baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL,
|
|
122
|
+
headers: {
|
|
123
|
+
"Content-Type": "application/json"
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
static withAuth = true;
|
|
127
|
+
static get_headers(setToken) {
|
|
128
|
+
if (setToken === true && this.withAuth === true) {
|
|
129
|
+
const auth = utils_session_storage.get_item_session_storage("auth_user");
|
|
130
|
+
return {
|
|
131
|
+
headers: {
|
|
132
|
+
Authorization: auth?.data?.usuario?.token ? `Bearer ${auth.data.usuario.token}` : undefined,
|
|
133
|
+
"Content-Type": "application/json"
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
126
138
|
headers: {
|
|
127
139
|
"Content-Type": "application/json"
|
|
128
140
|
}
|
|
129
|
-
}
|
|
130
|
-
this.set_bearer_token();
|
|
131
|
-
}
|
|
132
|
-
set_bearer_token() {
|
|
133
|
-
this.axios.interceptors.request.use((config)=>{
|
|
134
|
-
if (this.withAuth) {
|
|
135
|
-
const auth = utils_session_storage.get_item_session_storage("auth_user");
|
|
136
|
-
if (auth?.data?.usuario?.token) {
|
|
137
|
-
config.headers.Authorization = `Bearer ${auth.data.usuario.token}`;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return config;
|
|
141
|
-
});
|
|
141
|
+
};
|
|
142
142
|
}
|
|
143
|
-
async get({ url, params }) {
|
|
143
|
+
static async get({ url, params, setToken = true }) {
|
|
144
144
|
return this.axios.get(url, {
|
|
145
|
-
params
|
|
145
|
+
params,
|
|
146
|
+
...this.get_headers(setToken)
|
|
146
147
|
});
|
|
147
148
|
}
|
|
148
|
-
async post({ url, data }) {
|
|
149
|
-
return this.axios.post(url, data);
|
|
149
|
+
static async post({ url, data, setToken = true }) {
|
|
150
|
+
return this.axios.post(url, data, this.get_headers(setToken));
|
|
150
151
|
}
|
|
151
|
-
async patch({ url, data }) {
|
|
152
|
-
return this.axios.patch(url, data);
|
|
152
|
+
static async patch({ url, data, setToken = true }) {
|
|
153
|
+
return this.axios.patch(url, data, this.get_headers(setToken));
|
|
153
154
|
}
|
|
154
|
-
async delete({ url }) {
|
|
155
|
-
return this.axios.delete(url);
|
|
155
|
+
static async delete({ url, setToken = true }) {
|
|
156
|
+
return this.axios.delete(url, this.get_headers(setToken));
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
|