@fctc/interface-logic 2.3.3 → 2.3.4

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.
@@ -1,11 +1,11 @@
1
1
  declare const axiosClient: {
2
2
  init(config: any): {
3
- get: (url: string, headers: any) => Promise<any>;
4
- post: (url: string, body: any, headers: any) => Promise<any>;
5
- post_excel: (url: string, body: any, headers: any) => Promise<any>;
6
- put: (url: string, body: any, headers: any) => Promise<any>;
7
- patch: (url: string, body: any) => Promise<any>;
8
- delete: (url: string, body: any) => Promise<any>;
3
+ get: (url: string, headers?: any, serviceName?: string) => Promise<any>;
4
+ post: (url: string, body: any, headers?: any, serviceName?: string) => Promise<any>;
5
+ post_excel: (url: string, body: any, headers?: any, serviceName?: string) => Promise<any>;
6
+ put: (url: string, body: any, headers?: any, serviceName?: string) => Promise<any>;
7
+ patch: (url: string, body: any, headers?: any, serviceName?: string) => Promise<any>;
8
+ delete: (url: string, headers?: any, serviceName?: string) => Promise<any>;
9
9
  };
10
10
  };
11
11
 
package/dist/configs.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  declare const axiosClient: {
2
2
  init(config: any): {
3
- get: (url: string, headers: any) => Promise<any>;
4
- post: (url: string, body: any, headers: any) => Promise<any>;
5
- post_excel: (url: string, body: any, headers: any) => Promise<any>;
6
- put: (url: string, body: any, headers: any) => Promise<any>;
7
- patch: (url: string, body: any) => Promise<any>;
8
- delete: (url: string, body: any) => Promise<any>;
3
+ get: (url: string, headers?: any, serviceName?: string) => Promise<any>;
4
+ post: (url: string, body: any, headers?: any, serviceName?: string) => Promise<any>;
5
+ post_excel: (url: string, body: any, headers?: any, serviceName?: string) => Promise<any>;
6
+ put: (url: string, body: any, headers?: any, serviceName?: string) => Promise<any>;
7
+ patch: (url: string, body: any, headers?: any, serviceName?: string) => Promise<any>;
8
+ delete: (url: string, headers?: any, serviceName?: string) => Promise<any>;
9
9
  };
10
10
  };
11
11
 
package/dist/configs.js CHANGED
@@ -2208,7 +2208,6 @@ var sessionStorageUtils = () => {
2208
2208
  // src/configs/axios-client.ts
2209
2209
  var axiosClient = {
2210
2210
  init(config) {
2211
- console.log("config", config);
2212
2211
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
2213
2212
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
2214
2213
  const db = config?.db;
@@ -2227,21 +2226,25 @@ var axiosClient = {
2227
2226
  };
2228
2227
  const instance = import_axios.default.create({
2229
2228
  adapter: import_axios.default.defaults.adapter,
2230
- baseURL: config.baseUrl,
2229
+ baseURL: config?.baseUrl,
2231
2230
  timeout: 5e4,
2232
2231
  paramsSerializer: (params) => new URLSearchParams(params).toString()
2233
2232
  });
2234
2233
  instance.interceptors.request.use(async (config2) => {
2235
2234
  const { useRefreshToken, useActionToken, actionToken } = config2;
2235
+ let token = null;
2236
2236
  if (useActionToken && actionToken) {
2237
- config2.headers["Action-Token"] = actionToken;
2237
+ token = actionToken;
2238
+ } else {
2239
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2240
+ token = await getToken?.();
2241
+ }
2242
+ if (token) {
2243
+ config2.headers["Authorization"] = `Bearer ${token}`;
2238
2244
  }
2239
2245
  if (database) {
2240
2246
  config2.headers["DATABASE"] = database;
2241
2247
  }
2242
- console.log("database", database);
2243
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2244
- const token = await getToken?.();
2245
2248
  if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2246
2249
  return config2;
2247
2250
  }, Promise.reject);
@@ -2297,7 +2300,7 @@ var axiosClient = {
2297
2300
  );
2298
2301
  return new Promise(function(resolve) {
2299
2302
  import_axios.default.post(
2300
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2303
+ `${config?.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2301
2304
  payload,
2302
2305
  {
2303
2306
  headers: {
@@ -2365,20 +2368,47 @@ var axiosClient = {
2365
2368
  function formatUrl(url, db2) {
2366
2369
  return url + (db2 ? "?db=" + db2 : "");
2367
2370
  }
2371
+ const getBaseUrl = (baseUrl, serviceName) => {
2372
+ const service = serviceName || config?.default_service;
2373
+ return config?.default_service === "" ? `${baseUrl.replace(/\/$/, "")}/api/v2` : `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
2374
+ };
2368
2375
  const responseBody = (response) => response;
2369
2376
  const requests = {
2370
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2371
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2372
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2373
- responseType: "arraybuffer",
2374
- headers: {
2375
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2376
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2377
+ get: (url, headers, serviceName) => instance.get(
2378
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2379
+ headers
2380
+ ).then(responseBody),
2381
+ post: (url, body, headers, serviceName) => instance.post(
2382
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2383
+ body,
2384
+ headers
2385
+ ).then(responseBody),
2386
+ post_excel: (url, body, headers, serviceName) => instance.post(
2387
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2388
+ body,
2389
+ {
2390
+ responseType: "arraybuffer",
2391
+ headers: {
2392
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2393
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
2394
+ ...headers
2395
+ }
2377
2396
  }
2378
- }).then(responseBody),
2379
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2380
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2381
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2397
+ ).then(responseBody),
2398
+ put: (url, body, headers, serviceName) => instance.put(
2399
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2400
+ body,
2401
+ headers
2402
+ ).then(responseBody),
2403
+ patch: (url, body, headers, serviceName) => instance.patch(
2404
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2405
+ body,
2406
+ headers
2407
+ ).then(responseBody),
2408
+ delete: (url, headers, serviceName) => instance.delete(
2409
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2410
+ headers
2411
+ ).then(responseBody)
2382
2412
  };
2383
2413
  return requests;
2384
2414
  }
package/dist/configs.mjs CHANGED
@@ -2172,7 +2172,6 @@ var sessionStorageUtils = () => {
2172
2172
  // src/configs/axios-client.ts
2173
2173
  var axiosClient = {
2174
2174
  init(config) {
2175
- console.log("config", config);
2176
2175
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
2177
2176
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
2178
2177
  const db = config?.db;
@@ -2191,21 +2190,25 @@ var axiosClient = {
2191
2190
  };
2192
2191
  const instance = axios.create({
2193
2192
  adapter: axios.defaults.adapter,
2194
- baseURL: config.baseUrl,
2193
+ baseURL: config?.baseUrl,
2195
2194
  timeout: 5e4,
2196
2195
  paramsSerializer: (params) => new URLSearchParams(params).toString()
2197
2196
  });
2198
2197
  instance.interceptors.request.use(async (config2) => {
2199
2198
  const { useRefreshToken, useActionToken, actionToken } = config2;
2199
+ let token = null;
2200
2200
  if (useActionToken && actionToken) {
2201
- config2.headers["Action-Token"] = actionToken;
2201
+ token = actionToken;
2202
+ } else {
2203
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2204
+ token = await getToken?.();
2205
+ }
2206
+ if (token) {
2207
+ config2.headers["Authorization"] = `Bearer ${token}`;
2202
2208
  }
2203
2209
  if (database) {
2204
2210
  config2.headers["DATABASE"] = database;
2205
2211
  }
2206
- console.log("database", database);
2207
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2208
- const token = await getToken?.();
2209
2212
  if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2210
2213
  return config2;
2211
2214
  }, Promise.reject);
@@ -2261,7 +2264,7 @@ var axiosClient = {
2261
2264
  );
2262
2265
  return new Promise(function(resolve) {
2263
2266
  axios.post(
2264
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2267
+ `${config?.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2265
2268
  payload,
2266
2269
  {
2267
2270
  headers: {
@@ -2329,20 +2332,47 @@ var axiosClient = {
2329
2332
  function formatUrl(url, db2) {
2330
2333
  return url + (db2 ? "?db=" + db2 : "");
2331
2334
  }
2335
+ const getBaseUrl = (baseUrl, serviceName) => {
2336
+ const service = serviceName || config?.default_service;
2337
+ return config?.default_service === "" ? `${baseUrl.replace(/\/$/, "")}/api/v2` : `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
2338
+ };
2332
2339
  const responseBody = (response) => response;
2333
2340
  const requests = {
2334
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2335
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2336
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2337
- responseType: "arraybuffer",
2338
- headers: {
2339
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2340
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2341
+ get: (url, headers, serviceName) => instance.get(
2342
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2343
+ headers
2344
+ ).then(responseBody),
2345
+ post: (url, body, headers, serviceName) => instance.post(
2346
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2347
+ body,
2348
+ headers
2349
+ ).then(responseBody),
2350
+ post_excel: (url, body, headers, serviceName) => instance.post(
2351
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2352
+ body,
2353
+ {
2354
+ responseType: "arraybuffer",
2355
+ headers: {
2356
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2357
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
2358
+ ...headers
2359
+ }
2341
2360
  }
2342
- }).then(responseBody),
2343
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2344
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2345
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2361
+ ).then(responseBody),
2362
+ put: (url, body, headers, serviceName) => instance.put(
2363
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2364
+ body,
2365
+ headers
2366
+ ).then(responseBody),
2367
+ patch: (url, body, headers, serviceName) => instance.patch(
2368
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2369
+ body,
2370
+ headers
2371
+ ).then(responseBody),
2372
+ delete: (url, headers, serviceName) => instance.delete(
2373
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2374
+ headers
2375
+ ).then(responseBody)
2346
2376
  };
2347
2377
  return requests;
2348
2378
  }
@@ -35,7 +35,8 @@ declare enum UriConstants {
35
35
  LOAD_ACTION = "/load_action",
36
36
  REPORT_PATH = "/report",
37
37
  RUN_ACTION_PATH = "/run_action",
38
- UPLOAD_FILE_PATH = "/upload/file",
38
+ UPLOAD_FILE_EXCEL_PATH = "/upload/file",
39
+ UPLOAD_FILE_PATH = "/web/binary/upload_attachment",
39
40
  GET_MESSAGE = "/chatter/thread/messages",
40
41
  SENT_MESSAGE = "/chatter/message/post",
41
42
  UPLOAD_IMAGE = "/mail/attachment/upload",
@@ -43,6 +44,7 @@ declare enum UriConstants {
43
44
  IMAGE_PATH = "/web/image",
44
45
  LOAD_MESSAGE = "/load_message_failures",
45
46
  TOKEN = "/check_token",
47
+ VALIDATE_ACTION_TOKEN = "/action-token/validate",
46
48
  CREATE_UPDATE_PATH = "/create_update",
47
49
  TWOFA_METHOD_PATH = "/id/api/v2/call",
48
50
  SIGNIN_SSO = "/signin-sso/oauth",
@@ -35,7 +35,8 @@ declare enum UriConstants {
35
35
  LOAD_ACTION = "/load_action",
36
36
  REPORT_PATH = "/report",
37
37
  RUN_ACTION_PATH = "/run_action",
38
- UPLOAD_FILE_PATH = "/upload/file",
38
+ UPLOAD_FILE_EXCEL_PATH = "/upload/file",
39
+ UPLOAD_FILE_PATH = "/web/binary/upload_attachment",
39
40
  GET_MESSAGE = "/chatter/thread/messages",
40
41
  SENT_MESSAGE = "/chatter/message/post",
41
42
  UPLOAD_IMAGE = "/mail/attachment/upload",
@@ -43,6 +44,7 @@ declare enum UriConstants {
43
44
  IMAGE_PATH = "/web/image",
44
45
  LOAD_MESSAGE = "/load_message_failures",
45
46
  TOKEN = "/check_token",
47
+ VALIDATE_ACTION_TOKEN = "/action-token/validate",
46
48
  CREATE_UPDATE_PATH = "/create_update",
47
49
  TWOFA_METHOD_PATH = "/id/api/v2/call",
48
50
  SIGNIN_SSO = "/signin-sso/oauth",
package/dist/constants.js CHANGED
@@ -78,7 +78,8 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
78
78
  UriConstants2["LOAD_ACTION"] = `/load_action`;
79
79
  UriConstants2["REPORT_PATH"] = `/report`;
80
80
  UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
81
- UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
81
+ UriConstants2["UPLOAD_FILE_EXCEL_PATH"] = `/upload/file`;
82
+ UriConstants2["UPLOAD_FILE_PATH"] = `/web/binary/upload_attachment`;
82
83
  UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
83
84
  UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
84
85
  UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
@@ -86,6 +87,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
86
87
  UriConstants2["IMAGE_PATH"] = `/web/image`;
87
88
  UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
88
89
  UriConstants2["TOKEN"] = `/check_token`;
90
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = `/action-token/validate`;
89
91
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
90
92
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
91
93
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
@@ -40,7 +40,8 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
40
40
  UriConstants2["LOAD_ACTION"] = `/load_action`;
41
41
  UriConstants2["REPORT_PATH"] = `/report`;
42
42
  UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
43
- UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
43
+ UriConstants2["UPLOAD_FILE_EXCEL_PATH"] = `/upload/file`;
44
+ UriConstants2["UPLOAD_FILE_PATH"] = `/web/binary/upload_attachment`;
44
45
  UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
45
46
  UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
46
47
  UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
@@ -48,6 +49,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
48
49
  UriConstants2["IMAGE_PATH"] = `/web/image`;
49
50
  UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
50
51
  UriConstants2["TOKEN"] = `/check_token`;
52
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = `/action-token/validate`;
51
53
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
52
54
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
53
55
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
@@ -2210,7 +2210,6 @@ var sessionStorageUtils = () => {
2210
2210
  // src/configs/axios-client.ts
2211
2211
  var axiosClient = {
2212
2212
  init(config) {
2213
- console.log("config", config);
2214
2213
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
2215
2214
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
2216
2215
  const db = config?.db;
@@ -2229,21 +2228,25 @@ var axiosClient = {
2229
2228
  };
2230
2229
  const instance = import_axios.default.create({
2231
2230
  adapter: import_axios.default.defaults.adapter,
2232
- baseURL: config.baseUrl,
2231
+ baseURL: config?.baseUrl,
2233
2232
  timeout: 5e4,
2234
2233
  paramsSerializer: (params) => new URLSearchParams(params).toString()
2235
2234
  });
2236
2235
  instance.interceptors.request.use(async (config2) => {
2237
2236
  const { useRefreshToken, useActionToken, actionToken } = config2;
2237
+ let token = null;
2238
2238
  if (useActionToken && actionToken) {
2239
- config2.headers["Action-Token"] = actionToken;
2239
+ token = actionToken;
2240
+ } else {
2241
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2242
+ token = await getToken?.();
2243
+ }
2244
+ if (token) {
2245
+ config2.headers["Authorization"] = `Bearer ${token}`;
2240
2246
  }
2241
2247
  if (database) {
2242
2248
  config2.headers["DATABASE"] = database;
2243
2249
  }
2244
- console.log("database", database);
2245
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2246
- const token = await getToken?.();
2247
2250
  if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2248
2251
  return config2;
2249
2252
  }, Promise.reject);
@@ -2299,7 +2302,7 @@ var axiosClient = {
2299
2302
  );
2300
2303
  return new Promise(function(resolve) {
2301
2304
  import_axios.default.post(
2302
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2305
+ `${config?.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2303
2306
  payload,
2304
2307
  {
2305
2308
  headers: {
@@ -2367,20 +2370,47 @@ var axiosClient = {
2367
2370
  function formatUrl(url, db2) {
2368
2371
  return url + (db2 ? "?db=" + db2 : "");
2369
2372
  }
2373
+ const getBaseUrl = (baseUrl, serviceName) => {
2374
+ const service = serviceName || config?.default_service;
2375
+ return config?.default_service === "" ? `${baseUrl.replace(/\/$/, "")}/api/v2` : `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
2376
+ };
2370
2377
  const responseBody = (response) => response;
2371
2378
  const requests = {
2372
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2373
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2374
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2375
- responseType: "arraybuffer",
2376
- headers: {
2377
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2378
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2379
+ get: (url, headers, serviceName) => instance.get(
2380
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2381
+ headers
2382
+ ).then(responseBody),
2383
+ post: (url, body, headers, serviceName) => instance.post(
2384
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2385
+ body,
2386
+ headers
2387
+ ).then(responseBody),
2388
+ post_excel: (url, body, headers, serviceName) => instance.post(
2389
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2390
+ body,
2391
+ {
2392
+ responseType: "arraybuffer",
2393
+ headers: {
2394
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2395
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
2396
+ ...headers
2397
+ }
2379
2398
  }
2380
- }).then(responseBody),
2381
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2382
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2383
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2399
+ ).then(responseBody),
2400
+ put: (url, body, headers, serviceName) => instance.put(
2401
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2402
+ body,
2403
+ headers
2404
+ ).then(responseBody),
2405
+ patch: (url, body, headers, serviceName) => instance.patch(
2406
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2407
+ body,
2408
+ headers
2409
+ ).then(responseBody),
2410
+ delete: (url, headers, serviceName) => instance.delete(
2411
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2412
+ headers
2413
+ ).then(responseBody)
2384
2414
  };
2385
2415
  return requests;
2386
2416
  }
@@ -2172,7 +2172,6 @@ var sessionStorageUtils = () => {
2172
2172
  // src/configs/axios-client.ts
2173
2173
  var axiosClient = {
2174
2174
  init(config) {
2175
- console.log("config", config);
2176
2175
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
2177
2176
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
2178
2177
  const db = config?.db;
@@ -2191,21 +2190,25 @@ var axiosClient = {
2191
2190
  };
2192
2191
  const instance = axios.create({
2193
2192
  adapter: axios.defaults.adapter,
2194
- baseURL: config.baseUrl,
2193
+ baseURL: config?.baseUrl,
2195
2194
  timeout: 5e4,
2196
2195
  paramsSerializer: (params) => new URLSearchParams(params).toString()
2197
2196
  });
2198
2197
  instance.interceptors.request.use(async (config2) => {
2199
2198
  const { useRefreshToken, useActionToken, actionToken } = config2;
2199
+ let token = null;
2200
2200
  if (useActionToken && actionToken) {
2201
- config2.headers["Action-Token"] = actionToken;
2201
+ token = actionToken;
2202
+ } else {
2203
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2204
+ token = await getToken?.();
2205
+ }
2206
+ if (token) {
2207
+ config2.headers["Authorization"] = `Bearer ${token}`;
2202
2208
  }
2203
2209
  if (database) {
2204
2210
  config2.headers["DATABASE"] = database;
2205
2211
  }
2206
- console.log("database", database);
2207
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2208
- const token = await getToken?.();
2209
2212
  if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2210
2213
  return config2;
2211
2214
  }, Promise.reject);
@@ -2261,7 +2264,7 @@ var axiosClient = {
2261
2264
  );
2262
2265
  return new Promise(function(resolve) {
2263
2266
  axios.post(
2264
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2267
+ `${config?.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2265
2268
  payload,
2266
2269
  {
2267
2270
  headers: {
@@ -2329,20 +2332,47 @@ var axiosClient = {
2329
2332
  function formatUrl(url, db2) {
2330
2333
  return url + (db2 ? "?db=" + db2 : "");
2331
2334
  }
2335
+ const getBaseUrl = (baseUrl, serviceName) => {
2336
+ const service = serviceName || config?.default_service;
2337
+ return config?.default_service === "" ? `${baseUrl.replace(/\/$/, "")}/api/v2` : `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
2338
+ };
2332
2339
  const responseBody = (response) => response;
2333
2340
  const requests = {
2334
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2335
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2336
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2337
- responseType: "arraybuffer",
2338
- headers: {
2339
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2340
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2341
+ get: (url, headers, serviceName) => instance.get(
2342
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2343
+ headers
2344
+ ).then(responseBody),
2345
+ post: (url, body, headers, serviceName) => instance.post(
2346
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2347
+ body,
2348
+ headers
2349
+ ).then(responseBody),
2350
+ post_excel: (url, body, headers, serviceName) => instance.post(
2351
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2352
+ body,
2353
+ {
2354
+ responseType: "arraybuffer",
2355
+ headers: {
2356
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2357
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
2358
+ ...headers
2359
+ }
2341
2360
  }
2342
- }).then(responseBody),
2343
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2344
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2345
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2361
+ ).then(responseBody),
2362
+ put: (url, body, headers, serviceName) => instance.put(
2363
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2364
+ body,
2365
+ headers
2366
+ ).then(responseBody),
2367
+ patch: (url, body, headers, serviceName) => instance.patch(
2368
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2369
+ body,
2370
+ headers
2371
+ ).then(responseBody),
2372
+ delete: (url, headers, serviceName) => instance.delete(
2373
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
2374
+ headers
2375
+ ).then(responseBody)
2346
2376
  };
2347
2377
  return requests;
2348
2378
  }