@xrystal/core 3.11.0 → 3.11.5

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.11.0",
4
+ "version": "3.11.5",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -1,4 +1,3 @@
1
- import { ConfigsService, LoggerService } from '../../../loader';
2
1
  type CustomRequestOptions = Omit<RequestInit, 'body'> & {
3
2
  body?: any;
4
3
  version?: string;
@@ -11,14 +10,14 @@ export declare class ClientStore {
11
10
  static set(clientName: string, data: Record<string, any>): void;
12
11
  }
13
12
  export declare abstract class Client {
13
+ protected loggerService: any;
14
+ protected configsService: any;
14
15
  clientName: string;
15
16
  protected baseURL: string;
16
17
  protected version: string | null;
17
18
  protected timeout: number;
18
19
  protected debug: boolean;
19
20
  protected authConfigs: any;
20
- protected loggerService: LoggerService;
21
- protected configsService: ConfigsService;
22
21
  protected breaker: {
23
22
  failures: number;
24
23
  lastFailure: number;
@@ -26,7 +25,7 @@ export declare abstract class Client {
26
25
  threshold: number;
27
26
  cooldown: number;
28
27
  };
29
- constructor({ loggerService, configsService, clientName, baseURL, version, timeout, auth, debug }: any);
28
+ constructor({ clientName, baseURL, version, timeout, auth, debug }: any);
30
29
  protected resolvePath(obj: any, path: string): any;
31
30
  static cryptoHashGenerate: ({ algorithm, input, digest }: {
32
31
  algorithm: string;
@@ -1,7 +1,7 @@
1
1
  import { createHash, createHmac } from 'node:crypto';
2
2
  import soap from 'soap';
3
- import { LoggerService } from '../../../loader';
4
- import { LoggerLayerEnum } from '../../index';
3
+ import { ConfigsService, LoggerService } from '../../../loader';
4
+ import { LoggerLayerEnum, x } from '../../index';
5
5
  export class ClientStore {
6
6
  static _store = {};
7
7
  static get(clientName) { return this._store[clientName] || {}; }
@@ -10,14 +10,14 @@ export class ClientStore {
10
10
  }
11
11
  }
12
12
  export class Client {
13
+ loggerService = x.get(LoggerService);
14
+ configsService = x.get(ConfigsService);
13
15
  clientName;
14
16
  baseURL;
15
17
  version = null;
16
18
  timeout = 15000;
17
- debug = false;
19
+ debug = Number(this.configsService.all.debug) >= LoggerLayerEnum.DEBUG;
18
20
  authConfigs;
19
- loggerService;
20
- configsService;
21
21
  breaker = {
22
22
  failures: 0,
23
23
  lastFailure: 0,
@@ -25,10 +25,7 @@ export class Client {
25
25
  threshold: 5,
26
26
  cooldown: 30000
27
27
  };
28
- constructor({ loggerService, configsService, clientName, baseURL, version, timeout, auth, debug }) {
29
- this.loggerService = loggerService;
30
- this.configsService = configsService;
31
- this.debug = Number(this.configsService.all.debug) >= LoggerLayerEnum.DEBUG;
28
+ constructor({ clientName, baseURL, version, timeout, auth, debug }) {
32
29
  this.debug = debug ?? this.debug;
33
30
  this.clientName = clientName;
34
31
  this.baseURL = baseURL;
@@ -1,16 +1,16 @@
1
1
  export declare class X {
2
2
  private container;
3
3
  constructor();
4
- registerService(ServiceClass: any): void;
5
- registerServices(services: any[]): void;
6
- registerInstance(name: string, instance: any): void;
4
+ registerService(ServiceClass: any): this;
5
+ registerServices(services: any[]): this;
6
+ registerInstance(name: string, instance: any): this;
7
7
  initialize(input: {
8
8
  service: any;
9
9
  props?: any;
10
10
  } | {
11
11
  service: any;
12
12
  props?: any;
13
- }[]): Promise<void>;
13
+ }[]): Promise<this>;
14
14
  get<T>(name: string | any): T;
15
15
  get cradle(): any;
16
16
  }
@@ -12,16 +12,19 @@ export class X {
12
12
  this.container.register({
13
13
  [name]: asClass(ServiceClass).singleton()
14
14
  });
15
+ return this;
15
16
  }
16
17
  registerServices(services) {
17
18
  services.forEach(ServiceClass => {
18
19
  this.registerService(ServiceClass);
19
20
  });
21
+ return this;
20
22
  }
21
23
  registerInstance(name, instance) {
22
24
  this.container.register({
23
25
  [name]: asValue(instance)
24
26
  });
27
+ return this;
25
28
  }
26
29
  async initialize(input) {
27
30
  const items = Array.isArray(input) ? input : [input];
@@ -31,6 +34,7 @@ export class X {
31
34
  await instance.load(item.props);
32
35
  }
33
36
  }
37
+ return this;
34
38
  }
35
39
  get(name) {
36
40
  const resolveName = typeof name === 'function'