@xrystal/core 3.8.8 → 3.9.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.8.8",
4
+ "version": "3.9.0",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -2,6 +2,7 @@ import { LoggerLayerEnum } from '../../utils/index';
2
2
  export default class EventsService {
3
3
  logger;
4
4
  load = ({ logger, }) => {
5
+ this.logger = logger;
5
6
  this._globalLoader();
6
7
  };
7
8
  _globalLoader = () => {
@@ -1,5 +1,5 @@
1
1
  import nodemailer from 'nodemailer';
2
- import { ConfigsService, LoggerService } from 'source/loader';
2
+ import { ConfigsService, LoggerService } from '../../../loader';
3
3
  export declare abstract class Service {
4
4
  protected configService: ConfigsService;
5
5
  protected logger: LoggerService;
@@ -29,7 +29,9 @@ export declare class BaseApiClient extends Service {
29
29
  version?: string;
30
30
  timeout?: number;
31
31
  });
32
- request(path: string, options?: RequestInit): Promise<Response>;
32
+ request(path: string, options?: RequestInit & {
33
+ version?: string;
34
+ }): Promise<Response>;
33
35
  }
34
36
  export declare abstract class AuthenticatedApiClient extends BaseApiClient {
35
37
  accessToken?: string;
@@ -39,7 +41,9 @@ export declare abstract class AuthenticatedApiClient extends BaseApiClient {
39
41
  version?: string;
40
42
  timeout?: number;
41
43
  });
42
- request(path: string, options?: RequestInit): Promise<Response>;
44
+ request(path: string, options?: RequestInit & {
45
+ version?: string;
46
+ }): Promise<Response>;
43
47
  abstract authentication(): Promise<any>;
44
48
  }
45
49
  export declare class EmailClient extends Service {
@@ -3,8 +3,8 @@ import path from 'node:path';
3
3
  import nodemailer from 'nodemailer';
4
4
  import hbs from 'nodemailer-express-handlebars';
5
5
  import soap from 'soap';
6
- import { ConfigsService, LoggerService } from 'source/loader';
7
- import { TokensEnum, x } from '..';
6
+ import { ConfigsService, LoggerService } from '../../../loader';
7
+ import { TokensEnum, x } from '../../index';
8
8
  export class Service {
9
9
  configService = x.get(ConfigsService);
10
10
  logger = x.get(LoggerService);
@@ -34,9 +34,12 @@ export class BaseApiClient extends Service {
34
34
  constructor(config) {
35
35
  super(config);
36
36
  }
37
+ // version opsiyonel yapıldı, default constructor'dan gelir ama istek anında ezilebilir
37
38
  async request(path, options = {}) {
38
39
  const base = this.baseURL.replace(/\/$/, '');
39
- const ver = this.version ? `/${this.version.replace(/^\//, '')}` : '';
40
+ // İstekte versiyon varsa onu, yoksa sınıftaki default versiyonu kullan
41
+ const activeVersion = options.version !== undefined ? options.version : this.version;
42
+ const ver = activeVersion ? `/${activeVersion.replace(/^\//, '')}` : '';
40
43
  const url = `${base}${ver}${path}`;
41
44
  const store = LoggerService.storage.getStore();
42
45
  const correlationId = store?.get('correlationId');
@@ -50,7 +53,9 @@ export class BaseApiClient extends Service {
50
53
  const controller = new AbortController();
51
54
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
52
55
  try {
53
- const response = await fetch(url, { ...options, headers, signal: controller.signal });
56
+ // version alanını fetch options'dan ayıklıyoruz
57
+ const { version, ...fetchOptions } = options;
58
+ const response = await fetch(url, { ...fetchOptions, headers, signal: controller.signal });
54
59
  clearTimeout(timeoutId);
55
60
  return response;
56
61
  }