@vulog/aima-client 1.2.30 → 1.2.32

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.mjs CHANGED
@@ -1,293 +1,257 @@
1
- // src/getClient.ts
2
1
  import axios, { AxiosError } from "axios";
3
2
  import { isEqual, trimEnd } from "es-toolkit";
4
3
  import { LRUCache } from "lru-cache";
5
-
6
- // src/CurlHelper.ts
4
+ //#region src/CurlHelper.ts
7
5
  var CurlHelper = class {
8
- request;
9
- constructor(config) {
10
- this.request = config;
11
- }
12
- getHeaders() {
13
- let { headers } = this.request;
14
- let curlHeaders = "";
15
- if (headers.hasOwnProperty("common")) {
16
- headers = this.request.headers[this.request.method];
17
- }
18
- for (const property in this.request.headers) {
19
- if (!["common", "delete", "get", "head", "patch", "post", "put"].includes(property)) {
20
- headers[property] = this.request.headers[property];
21
- }
22
- }
23
- for (const property in headers) {
24
- if ({}.hasOwnProperty.call(headers, property)) {
25
- const header = `${property}:${headers[property]}`;
26
- curlHeaders = `${curlHeaders} -H '${header}'`;
27
- }
28
- }
29
- return curlHeaders.trim();
30
- }
31
- getMethod() {
32
- return `-X ${this.request.method.toUpperCase()}`;
33
- }
34
- getBody() {
35
- if (typeof this.request.data !== "undefined" && this.request.data !== "" && this.request.data !== null && this.request.method.toUpperCase() !== "GET") {
36
- const data = typeof this.request.data === "object" || Object.prototype.toString.call(this.request.data) === "[object Array]" ? JSON.stringify(this.request.data) : this.request.data;
37
- return `--data '${data}'`.trim();
38
- }
39
- return "";
40
- }
41
- getUrl() {
42
- if (this.request.baseURL) {
43
- const baseUrl = this.request.baseURL;
44
- const { url } = this.request;
45
- const finalUrl = url.startsWith("http") ? url : `${baseUrl}/${url}`;
46
- return finalUrl.replace(/\/{2,}/g, "/").replace("http:/", "http://").replace("https:/", "https://");
47
- }
48
- return this.request.url;
49
- }
50
- getQueryString() {
51
- if (this.request.paramsSerializer) {
52
- const params2 = this.request.paramsSerializer(this.request.params);
53
- if (!params2 || params2.length === 0) return "";
54
- if (params2.startsWith("?")) return params2;
55
- return `?${params2}`;
56
- }
57
- let params = "";
58
- let i = 0;
59
- for (const param in this.request.params) {
60
- if ({}.hasOwnProperty.call(this.request.params, param)) {
61
- params += i !== 0 ? `&${param}=${this.request.params[param]}` : `?${param}=${this.request.params[param]}`;
62
- i += 1;
63
- }
64
- }
65
- return params;
66
- }
67
- getBuiltURL() {
68
- let url = this.getUrl();
69
- if (this.getQueryString() !== "") {
70
- url += this.getQueryString();
71
- }
72
- return url.trim();
73
- }
74
- generateCommand() {
75
- return `curl ${this.getMethod()} "${this.getBuiltURL()}" ${this.getHeaders()} ${this.getBody()}`.trim().replace(/\s{2,}/g, " ");
76
- }
6
+ request;
7
+ constructor(config) {
8
+ this.request = config;
9
+ }
10
+ getHeaders() {
11
+ let { headers } = this.request;
12
+ let curlHeaders = "";
13
+ if (headers.hasOwnProperty("common")) headers = this.request.headers[this.request.method];
14
+ for (const property in this.request.headers) if (![
15
+ "common",
16
+ "delete",
17
+ "get",
18
+ "head",
19
+ "patch",
20
+ "post",
21
+ "put"
22
+ ].includes(property)) headers[property] = this.request.headers[property];
23
+ for (const property in headers) if ({}.hasOwnProperty.call(headers, property)) {
24
+ const header = `${property}:${headers[property]}`;
25
+ curlHeaders = `${curlHeaders} -H '${header}'`;
26
+ }
27
+ return curlHeaders.trim();
28
+ }
29
+ getMethod() {
30
+ return `-X ${this.request.method.toUpperCase()}`;
31
+ }
32
+ getBody() {
33
+ if (typeof this.request.data !== "undefined" && this.request.data !== "" && this.request.data !== null && this.request.method.toUpperCase() !== "GET") return `--data '${typeof this.request.data === "object" || Object.prototype.toString.call(this.request.data) === "[object Array]" ? JSON.stringify(this.request.data) : this.request.data}'`.trim();
34
+ return "";
35
+ }
36
+ getUrl() {
37
+ if (this.request.baseURL) {
38
+ const baseUrl = this.request.baseURL;
39
+ const { url } = this.request;
40
+ return (url.startsWith("http") ? url : `${baseUrl}/${url}`).replace(/\/{2,}/g, "/").replace("http:/", "http://").replace("https:/", "https://");
41
+ }
42
+ return this.request.url;
43
+ }
44
+ getQueryString() {
45
+ if (this.request.paramsSerializer) {
46
+ const params = this.request.paramsSerializer(this.request.params);
47
+ if (!params || params.length === 0) return "";
48
+ if (params.startsWith("?")) return params;
49
+ return `?${params}`;
50
+ }
51
+ let params = "";
52
+ let i = 0;
53
+ for (const param in this.request.params) if ({}.hasOwnProperty.call(this.request.params, param)) {
54
+ params += i !== 0 ? `&${param}=${this.request.params[param]}` : `?${param}=${this.request.params[param]}`;
55
+ i += 1;
56
+ }
57
+ return params;
58
+ }
59
+ getBuiltURL() {
60
+ let url = this.getUrl();
61
+ if (this.getQueryString() !== "") url += this.getQueryString();
62
+ return url.trim();
63
+ }
64
+ generateCommand() {
65
+ return `curl ${this.getMethod()} "${this.getBuiltURL()}" ${this.getHeaders()} ${this.getBody()}`.trim().replace(/\s{2,}/g, " ");
66
+ }
77
67
  };
78
-
79
- // src/getClient.ts
80
- var clientCache = new LRUCache({ max: 100 });
81
- var tokenCache = new LRUCache({ max: 100 });
82
- var getMemoryStore = (options) => ({
83
- getToken: async () => {
84
- const log = options.onLog ?? console.log;
85
- log("getMemoryStore.getToken", options.name ?? options.fleetId);
86
- if (tokenCache.has(options.name ?? options.fleetId)) {
87
- log("getMemoryStore.getToken", tokenCache.get(options.name ?? options.fleetId));
88
- return tokenCache.get(options.name ?? options.fleetId);
89
- }
90
- return void 0;
91
- },
92
- setToken: async (token) => {
93
- const log = options.onLog ?? console.log;
94
- log("getMemoryStore.setToken", options.name ?? options.fleetId, token);
95
- tokenCache.set(options.name ?? options.fleetId, token);
96
- }
68
+ //#endregion
69
+ //#region src/getClient.ts
70
+ const clientCache = new LRUCache({ max: 100 });
71
+ const tokenCache = new LRUCache({ max: 100 });
72
+ const getMemoryStore = (options) => ({
73
+ getToken: async () => {
74
+ const log = options.onLog ?? console.log;
75
+ log("getMemoryStore.getToken", options.name ?? options.fleetId);
76
+ if (tokenCache.has(options.name ?? options.fleetId)) {
77
+ log("getMemoryStore.getToken", tokenCache.get(options.name ?? options.fleetId));
78
+ return tokenCache.get(options.name ?? options.fleetId);
79
+ }
80
+ },
81
+ setToken: async (token) => {
82
+ (options.onLog ?? console.log)("getMemoryStore.setToken", options.name ?? options.fleetId, token);
83
+ tokenCache.set(options.name ?? options.fleetId, token);
84
+ }
97
85
  });
98
- var formatError = (error) => {
99
- if (error instanceof AxiosError) {
100
- return {
101
- originalError: error.toJSON(),
102
- formattedError: {
103
- status: error.response?.status ?? error.status,
104
- data: error.response?.data,
105
- message: error.message
106
- }
107
- };
108
- }
109
- return {
110
- formattedError: {},
111
- originalError: JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error)))
112
- };
86
+ const formatError = (error) => {
87
+ if (error instanceof AxiosError) return {
88
+ originalError: error.toJSON(),
89
+ formattedError: {
90
+ status: error.response?.status ?? error.status,
91
+ data: error.response?.data,
92
+ message: error.message
93
+ }
94
+ };
95
+ return {
96
+ formattedError: {},
97
+ originalError: JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error)))
98
+ };
113
99
  };
114
- var getClient = (options) => {
115
- if (clientCache.has(options.name ?? options.fleetId)) {
116
- const { options: cachedOptions, client: client2 } = clientCache.get(options.fleetId);
117
- if (isEqual(cachedOptions, options)) {
118
- return client2;
119
- }
120
- }
121
- const client = axios.create({
122
- baseURL: trimEnd(options.baseUrl, "/"),
123
- timeout: 3e4,
124
- headers: {
125
- "Cache-Control": "no-cache",
126
- "Content-Type": "application/json",
127
- "X-Api-Key": options.apiKey,
128
- "User-Agent": options.userAgent ?? `aima-node/${"1.2.30"} ${options.fleetId}`
129
- },
130
- withCredentials: false
131
- });
132
- client.clientOptions = options;
133
- const clientCredentialsAuthentification = async () => {
134
- const params = new URLSearchParams();
135
- params.append("client_id", options.clientId);
136
- params.append("client_secret", options.clientSecret);
137
- params.append("securityOptions", "SSL_OP_NO_SSLv3");
138
- params.append("grant_type", "client_credentials");
139
- const { data: token } = await axios.post(
140
- `${trimEnd(options.baseUrl, "/")}/auth/realms/${options.fleetMaster ?? options.fleetId}/protocol/openid-connect/token`,
141
- params,
142
- {
143
- timeout: 3e4,
144
- headers: {
145
- "Content-Type": "application/x-www-form-urlencoded"
146
- },
147
- withCredentials: false
148
- }
149
- );
150
- const store = options.store ?? getMemoryStore(options);
151
- await store.setToken({
152
- accessToken: token.access_token,
153
- refreshToken: token.refresh_token
154
- });
155
- return token.access_token;
156
- };
157
- const refreshTokenAuthentification = async () => {
158
- const store = options.store ?? getMemoryStore(options);
159
- const oldToken = await store.getToken();
160
- if (!oldToken?.refreshToken) {
161
- throw new Error("No refresh token available");
162
- }
163
- const params = new URLSearchParams();
164
- params.append("client_id", options.clientId);
165
- params.append("client_secret", options.clientSecret);
166
- params.append("securityOptions", "SSL_OP_NO_SSLv3");
167
- params.append("grant_type", "refresh_token");
168
- params.append("refresh_token", oldToken.refreshToken);
169
- const { data: token } = await axios.post(
170
- `${trimEnd(options.baseUrl, "/")}/auth/realms/${options.fleetMaster ?? options.fleetId}/protocol/openid-connect/token`,
171
- params,
172
- {
173
- timeout: 3e4,
174
- headers: {
175
- "Content-Type": "application/x-www-form-urlencoded"
176
- },
177
- withCredentials: false
178
- }
179
- );
180
- await store.setToken({
181
- accessToken: token.access_token,
182
- refreshToken: token.refresh_token
183
- });
184
- return token.access_token;
185
- };
186
- client.signInWithPassword = async (username, password) => {
187
- if (!options.secure) {
188
- throw new Error("Not secure");
189
- }
190
- const params = new URLSearchParams();
191
- params.append("client_id", options.clientId);
192
- params.append("client_secret", options.clientSecret);
193
- params.append("securityOptions", "SSL_OP_NO_SSLv3");
194
- params.append("grant_type", "password");
195
- params.append("username", username);
196
- params.append("password", password);
197
- const { data: token } = await axios.post(
198
- `${trimEnd(options.baseUrl, "/")}/auth/realms/${options.fleetMaster ?? options.fleetId}/protocol/openid-connect/token`,
199
- params,
200
- {
201
- timeout: 3e4,
202
- headers: {
203
- "Content-Type": "application/x-www-form-urlencoded"
204
- },
205
- withCredentials: false
206
- }
207
- );
208
- const newToken = {
209
- accessToken: token.access_token,
210
- refreshToken: token.refresh_token
211
- };
212
- const store = options.store ?? getMemoryStore(options);
213
- await store.setToken(newToken);
214
- return newToken;
215
- };
216
- client.interceptors.request.use(async (request) => {
217
- const newRequest = request;
218
- const store = options.store ?? getMemoryStore(options);
219
- const token = await store.getToken();
220
- if (token?.accessToken) {
221
- newRequest.headers.Authorization = `Bearer ${token.accessToken}`;
222
- }
223
- if (options.logCurl) {
224
- const curl = new CurlHelper(newRequest).generateCommand();
225
- if (options.onLog) options.onLog({ curl, message: "getClient > Curl command" });
226
- else console.log({ curl, message: "getClient > Curl command" });
227
- }
228
- return newRequest;
229
- });
230
- let isRefreshing = false;
231
- let refreshSubscribers = [];
232
- const executorRefresh = (config) => {
233
- return new Promise((resolve, reject) => {
234
- refreshSubscribers.push((token, error) => {
235
- if (error) {
236
- reject(formatError(error));
237
- return;
238
- }
239
- resolve(client.request(config));
240
- });
241
- });
242
- };
243
- client.interceptors.response.use(
244
- (response) => {
245
- if (options.logResponse) {
246
- const finalUrl = new CurlHelper(response.config).getBuiltURL();
247
- const { data, headers } = response;
248
- const dataLog = response.config.responseType !== "arraybuffer" && response.config.responseType !== "blob" ? data : "ArrayBuffer or blob";
249
- if (options.onLog) options.onLog({ finalUrl, data: dataLog, headers, message: "getClient > Response" });
250
- else console.log({ finalUrl, data: dataLog, headers, message: "getClient > Response" });
251
- }
252
- return response;
253
- },
254
- (error) => {
255
- const { config, response: { status } = { status: 500 } } = error;
256
- const originalRequest = config;
257
- if (originalRequest.attemptCount === void 0) {
258
- originalRequest.attemptCount = 0;
259
- }
260
- if (originalRequest.attemptCount === 5) {
261
- return Promise.reject(formatError(error));
262
- }
263
- if (status === 401) {
264
- originalRequest.attemptCount += 1;
265
- if (!isRefreshing) {
266
- isRefreshing = true;
267
- let authentification;
268
- if (options.secure) {
269
- authentification = refreshTokenAuthentification;
270
- } else {
271
- authentification = clientCredentialsAuthentification;
272
- }
273
- authentification().then((accessToken) => {
274
- refreshSubscribers.forEach((cb) => cb(accessToken));
275
- }).catch((errorAuth) => {
276
- refreshSubscribers.forEach((cb) => cb(void 0, errorAuth));
277
- }).finally(() => {
278
- isRefreshing = false;
279
- refreshSubscribers = [];
280
- });
281
- }
282
- return executorRefresh(originalRequest);
283
- }
284
- return Promise.reject(formatError(error));
285
- }
286
- );
287
- clientCache.set(options.name ?? options.fleetId, { options, client });
288
- return client;
289
- };
290
- var getClient_default = getClient;
291
- export {
292
- getClient_default as getClient
100
+ const getClient = (options) => {
101
+ if (clientCache.has(options.name ?? options.fleetId)) {
102
+ const { options: cachedOptions, client } = clientCache.get(options.fleetId);
103
+ if (isEqual(cachedOptions, options)) return client;
104
+ }
105
+ const client = axios.create({
106
+ baseURL: trimEnd(options.baseUrl, "/"),
107
+ timeout: 3e4,
108
+ headers: {
109
+ "Cache-Control": "no-cache",
110
+ "Content-Type": "application/json",
111
+ "X-Api-Key": options.apiKey,
112
+ "User-Agent": options.userAgent ?? `aima-node/1.2.32 ${options.fleetId}`
113
+ },
114
+ withCredentials: false
115
+ });
116
+ client.clientOptions = options;
117
+ const clientCredentialsAuthentification = async () => {
118
+ const params = new URLSearchParams();
119
+ params.append("client_id", options.clientId);
120
+ params.append("client_secret", options.clientSecret);
121
+ params.append("securityOptions", "SSL_OP_NO_SSLv3");
122
+ params.append("grant_type", "client_credentials");
123
+ const { data: token } = await axios.post(`${trimEnd(options.baseUrl, "/")}/auth/realms/${options.fleetMaster ?? options.fleetId}/protocol/openid-connect/token`, params, {
124
+ timeout: 3e4,
125
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
126
+ withCredentials: false
127
+ });
128
+ await (options.store ?? getMemoryStore(options)).setToken({
129
+ accessToken: token.access_token,
130
+ refreshToken: token.refresh_token
131
+ });
132
+ return token.access_token;
133
+ };
134
+ const refreshTokenAuthentification = async () => {
135
+ const store = options.store ?? getMemoryStore(options);
136
+ const oldToken = await store.getToken();
137
+ if (!oldToken?.refreshToken) throw new Error("No refresh token available");
138
+ const params = new URLSearchParams();
139
+ params.append("client_id", options.clientId);
140
+ params.append("client_secret", options.clientSecret);
141
+ params.append("securityOptions", "SSL_OP_NO_SSLv3");
142
+ params.append("grant_type", "refresh_token");
143
+ params.append("refresh_token", oldToken.refreshToken);
144
+ const { data: token } = await axios.post(`${trimEnd(options.baseUrl, "/")}/auth/realms/${options.fleetMaster ?? options.fleetId}/protocol/openid-connect/token`, params, {
145
+ timeout: 3e4,
146
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
147
+ withCredentials: false
148
+ });
149
+ await store.setToken({
150
+ accessToken: token.access_token,
151
+ refreshToken: token.refresh_token
152
+ });
153
+ return token.access_token;
154
+ };
155
+ client.signInWithPassword = async (username, password) => {
156
+ if (!options.secure) throw new Error("Not secure");
157
+ const params = new URLSearchParams();
158
+ params.append("client_id", options.clientId);
159
+ params.append("client_secret", options.clientSecret);
160
+ params.append("securityOptions", "SSL_OP_NO_SSLv3");
161
+ params.append("grant_type", "password");
162
+ params.append("username", username);
163
+ params.append("password", password);
164
+ const { data: token } = await axios.post(`${trimEnd(options.baseUrl, "/")}/auth/realms/${options.fleetMaster ?? options.fleetId}/protocol/openid-connect/token`, params, {
165
+ timeout: 3e4,
166
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
167
+ withCredentials: false
168
+ });
169
+ const newToken = {
170
+ accessToken: token.access_token,
171
+ refreshToken: token.refresh_token
172
+ };
173
+ await (options.store ?? getMemoryStore(options)).setToken(newToken);
174
+ return newToken;
175
+ };
176
+ client.interceptors.request.use(async (request) => {
177
+ const newRequest = request;
178
+ const token = await (options.store ?? getMemoryStore(options)).getToken();
179
+ if (token?.accessToken) newRequest.headers.Authorization = `Bearer ${token.accessToken}`;
180
+ if (options.logCurl) {
181
+ const curl = new CurlHelper(newRequest).generateCommand();
182
+ if (options.onLog) options.onLog({
183
+ curl,
184
+ message: "getClient > Curl command"
185
+ });
186
+ else console.log({
187
+ curl,
188
+ message: "getClient > Curl command"
189
+ });
190
+ }
191
+ return newRequest;
192
+ });
193
+ let isRefreshing = false;
194
+ let refreshSubscribers = [];
195
+ const executorRefresh = (config) => {
196
+ return new Promise((resolve, reject) => {
197
+ refreshSubscribers.push((token, error) => {
198
+ if (error) {
199
+ reject(formatError(error));
200
+ return;
201
+ }
202
+ resolve(client.request(config));
203
+ });
204
+ });
205
+ };
206
+ client.interceptors.response.use((response) => {
207
+ if (options.logResponse) {
208
+ const finalUrl = new CurlHelper(response.config).getBuiltURL();
209
+ const { data, headers } = response;
210
+ const dataLog = response.config.responseType !== "arraybuffer" && response.config.responseType !== "blob" ? data : "ArrayBuffer or blob";
211
+ if (options.onLog) options.onLog({
212
+ finalUrl,
213
+ data: dataLog,
214
+ headers,
215
+ message: "getClient > Response"
216
+ });
217
+ else console.log({
218
+ finalUrl,
219
+ data: dataLog,
220
+ headers,
221
+ message: "getClient > Response"
222
+ });
223
+ }
224
+ return response;
225
+ }, (error) => {
226
+ const { config, response: { status } = { status: 500 } } = error;
227
+ const originalRequest = config;
228
+ if (originalRequest.attemptCount === void 0) originalRequest.attemptCount = 0;
229
+ if (originalRequest.attemptCount === 5) return Promise.reject(formatError(error));
230
+ if (status === 401) {
231
+ originalRequest.attemptCount += 1;
232
+ if (!isRefreshing) {
233
+ isRefreshing = true;
234
+ let authentification;
235
+ if (options.secure) authentification = refreshTokenAuthentification;
236
+ else authentification = clientCredentialsAuthentification;
237
+ authentification().then((accessToken) => {
238
+ refreshSubscribers.forEach((cb) => cb(accessToken));
239
+ }).catch((errorAuth) => {
240
+ refreshSubscribers.forEach((cb) => cb(void 0, errorAuth));
241
+ }).finally(() => {
242
+ isRefreshing = false;
243
+ refreshSubscribers = [];
244
+ });
245
+ }
246
+ return executorRefresh(originalRequest);
247
+ }
248
+ return Promise.reject(formatError(error));
249
+ });
250
+ clientCache.set(options.name ?? options.fleetId, {
251
+ options,
252
+ client
253
+ });
254
+ return client;
293
255
  };
256
+ //#endregion
257
+ export { getClient };
package/package.json CHANGED
@@ -1,12 +1,25 @@
1
1
  {
2
2
  "name": "@vulog/aima-client",
3
- "version": "1.2.30",
4
- "main": "dist/index.js",
3
+ "type": "module",
4
+ "version": "1.2.32",
5
+ "main": "dist/index.cjs",
5
6
  "module": "dist/index.mjs",
6
- "types": "dist/index.d.ts",
7
+ "types": "dist/index.d.cts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.mts",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.cts",
16
+ "default": "./dist/index.cjs"
17
+ }
18
+ }
19
+ },
7
20
  "scripts": {
8
- "build": "tsup",
9
- "dev": "tsup --watch",
21
+ "build": "tsdown",
22
+ "dev": "tsdown --watch",
10
23
  "test": "vitest run",
11
24
  "test:watch": "vitest",
12
25
  "lint": "eslint src/**/* --ext .ts"
@@ -1,4 +1,4 @@
1
- import { defineConfig } from 'tsup';
1
+ import { defineConfig } from 'tsdown';
2
2
  import { readFileSync } from 'fs';
3
3
 
4
4
  const packageJson = JSON.parse(readFileSync('./package.json', 'utf-8'));
package/vitest.config.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { defineConfig } from 'vitest/config';
2
2
 
3
3
  export default defineConfig({
4
+ define: {
5
+ __VERSION__: JSON.stringify('1.1.98'),
6
+ },
4
7
  test: {
5
8
  globals: true,
6
9
  environment: 'node',
7
- env: {
8
- VERSION: '1.1.98',
9
- },
10
10
  },
11
11
  });
package/dist/index.d.ts DELETED
@@ -1,41 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
-
3
- type Token = {
4
- accessToken: string;
5
- refreshToken: string;
6
- };
7
- type Store = {
8
- getToken: () => Promise<Token | undefined>;
9
- setToken: (token: Token) => Promise<void>;
10
- };
11
- type ClientOptions = {
12
- fleetId: string;
13
- name?: string;
14
- fleetMaster?: string;
15
- baseUrl: string;
16
- clientId: string;
17
- clientSecret: string;
18
- apiKey: string;
19
- secure?: boolean;
20
- logCurl?: boolean;
21
- logResponse?: boolean;
22
- store?: Store;
23
- onLog?: (...args: any[]) => void;
24
- userAgent?: string;
25
- };
26
- type ClientError = {
27
- formattedError: {
28
- status?: number;
29
- data?: any;
30
- message?: string;
31
- };
32
- originalError: any;
33
- };
34
- type Client = AxiosInstance & {
35
- signInWithPassword: (username: string, password: string) => Promise<Token>;
36
- clientOptions: ClientOptions;
37
- };
38
-
39
- declare const getClient: (options: ClientOptions) => Client;
40
-
41
- export { type Client, type ClientError, type ClientOptions, type Store, type Token, getClient };