@xrystal/core 3.8.7 → 3.8.9

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.7",
4
+ "version": "3.8.9",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -1,8 +1,6 @@
1
- import { BaseApiClient } from '../../utils/index';
2
1
  import ConfigsService from '../configs';
3
2
  export default class ClientsService {
4
3
  static services: Record<string, any>;
5
- apiClient: BaseApiClient;
6
4
  baseApiClientName: string;
7
5
  load({ configs }: {
8
6
  configs: ConfigsService;
@@ -1,13 +1,12 @@
1
1
  import { BaseApiClient } from '../../utils/index';
2
2
  export default class ClientsService {
3
3
  static services = {};
4
- apiClient;
5
4
  baseApiClientName = 'base-api-client';
6
5
  async load({ configs }) {
7
- this.apiClient = new BaseApiClient({
6
+ const baseApiClient = new BaseApiClient({
8
7
  clientName: this.baseApiClientName,
9
8
  baseURL: configs.all.baseApiUri || ''
10
9
  });
11
- ClientsService.services[this.baseApiClientName] = this.apiClient;
10
+ ClientsService.services[this.baseApiClientName] = baseApiClient;
12
11
  }
13
12
  }
@@ -3,4 +3,5 @@ import ConfigsService from "./configs";
3
3
  import LoggerService from "./logger";
4
4
  import EventsService from "./events";
5
5
  import LocalizationsService from "./localizations";
6
- export { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService };
6
+ import ClientsService from "./clients";
7
+ export { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService, ClientsService };
@@ -3,4 +3,5 @@ import ConfigsService from "./configs";
3
3
  import LoggerService from "./logger";
4
4
  import EventsService from "./events";
5
5
  import LocalizationsService from "./localizations";
6
- export { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService };
6
+ import ClientsService from "./clients";
7
+ export { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService, ClientsService };
@@ -1,8 +1,7 @@
1
1
  // => import dependencies
2
2
  import path from 'path';
3
- import { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService } from '../loader/index';
3
+ import { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService, ClientsService } from '../loader/index';
4
4
  import { packageName, tmpFileDefaultName, tmpFileDefaultExt, findFileRecursively, TmpFileLoader, x, kafkaBrokers, systemLoggerLayer, } from '../utils/index';
5
- import ClientsService from 'source/loader/clients';
6
5
  //
7
6
  let coreHasRun = false;
8
7
  export const coreInit = async (params) => {
@@ -27,7 +26,8 @@ const coreLoader = async ({}) => {
27
26
  ConfigsService,
28
27
  LoggerService,
29
28
  EventsService,
30
- LocalizationsService
29
+ LocalizationsService,
30
+ ClientsService
31
31
  ];
32
32
  services.forEach(service => x.set({ service, reference: service }));
33
33
  const system = x.get(SystemService);
@@ -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
  }