@xrystal/core 3.10.2 → 3.10.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.10.2",
4
+ "version": "3.10.3",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -1,4 +1,10 @@
1
1
  import { ConfigsService, LoggerService } from '../../../loader';
2
+ type CustomRequestOptions = Omit<RequestInit, 'body'> & {
3
+ body?: any;
4
+ version?: string;
5
+ retries?: number;
6
+ debug?: boolean;
7
+ };
2
8
  export declare class ClientStore {
3
9
  private static _store;
4
10
  static get(clientName: string): any;
@@ -30,11 +36,7 @@ export declare abstract class Client {
30
36
  }
31
37
  export declare class BaseApiClient extends Client {
32
38
  constructor(config: any);
33
- request(path: string, options?: RequestInit & {
34
- version?: string;
35
- retries?: number;
36
- debug?: boolean;
37
- }): Promise<Response>;
39
+ request(path: string, options?: CustomRequestOptions): Promise<Response>;
38
40
  private _execute;
39
41
  }
40
42
  export declare abstract class AuthenticatedApiClient extends BaseApiClient {
@@ -53,3 +55,4 @@ export declare class SoapClient extends Client {
53
55
  constructor(config: any);
54
56
  call(methodName: string, args: any): Promise<any>;
55
57
  }
58
+ export {};
@@ -105,21 +105,21 @@ export class BaseApiClient extends Client {
105
105
  headers.set('x-internal-client', this.clientName);
106
106
  }
107
107
  const isDebugMode = options.debug !== undefined ? options.debug : this.debug;
108
+ const { version, retries, debug, ...fetchOptions } = options;
109
+ if (fetchOptions.body && typeof fetchOptions.body === 'object' && !(fetchOptions.body instanceof FormData)) {
110
+ fetchOptions.body = JSON.stringify(fetchOptions.body);
111
+ }
108
112
  if (isDebugMode) {
109
113
  const logPayload = {
110
114
  method: options.method || 'GET',
111
115
  url,
112
116
  headers: Object.fromEntries(headers.entries()),
113
- body: options.body ? (typeof options.body === 'string' ? JSON.parse(options.body) : options.body) : null
117
+ body: options.body
114
118
  };
115
119
  this.logger.winston.info(`${this.clientName} Request Details: ${JSON.stringify(logPayload, null, 2)}`);
116
120
  }
117
121
  const controller = new AbortController();
118
122
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
119
- const { version, retries, debug, ...fetchOptions } = options;
120
- if (fetchOptions.body && typeof fetchOptions.body === 'object') {
121
- fetchOptions.body = JSON.stringify(fetchOptions.body);
122
- }
123
123
  const response = await fetch(url, { ...fetchOptions, headers, signal: controller.signal });
124
124
  clearTimeout(timeoutId);
125
125
  return response;