@xrystal/core 3.20.1 → 3.20.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.20.1",
4
+ "version": "3.20.3",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -54,7 +54,7 @@ export default class LoggerService {
54
54
  }
55
55
  load = async ({}) => {
56
56
  const loggersConfigs = this.#systemService.tmp.configs.loaders.loggers;
57
- this.serviceName = this.#systemService.tmp.configs?.serviceName;
57
+ this.serviceName = this.#systemService.tmp.configs.service;
58
58
  const { kafkaBrokers, isKafkaPassive } = this.#configsService.all;
59
59
  const brokers = kafkaBrokers ? String(kafkaBrokers).split(",").map((b) => b.trim()) : [];
60
60
  const isKafkaEnabled = isKafkaPassive === false && brokers.length > 0;
@@ -1,14 +1,13 @@
1
1
  import { IService } from "../../utils";
2
2
  export default class SystemService implements IService {
3
- private _tmp;
3
+ protected _core: Record<string, any>;
4
+ protected _tmp: Record<string, any>;
4
5
  cwd: string;
5
- core: {
6
- _: any;
7
- };
8
- load: ({}: {
9
- tmp: any;
6
+ load: ({ core }: {
7
+ core: any;
10
8
  }) => Promise<void>;
11
9
  private initializeKafkaInfrastructure;
12
10
  private _systemLoader;
11
+ get core(): Record<string, any>;
13
12
  get tmp(): Record<string, any>;
14
13
  }
@@ -1,11 +1,12 @@
1
1
  import { Kafka, logLevel } from "kafkajs";
2
- import { Constants, getTmp } from "../../utils";
2
+ import { Constants } from "../../utils";
3
3
  export default class SystemService {
4
+ _core = {};
4
5
  _tmp = {};
5
6
  cwd = process.cwd();
6
- core = getTmp();
7
- load = async ({}) => {
8
- this._tmp = this.core._;
7
+ load = async ({ core }) => {
8
+ this._core = core;
9
+ this._tmp = this._core._;
9
10
  await this.initializeKafkaInfrastructure();
10
11
  await this._systemLoader({});
11
12
  };
@@ -60,6 +61,9 @@ export default class SystemService {
60
61
  _systemLoader = async ({}) => {
61
62
  return;
62
63
  };
64
+ get core() {
65
+ return this._core;
66
+ }
63
67
  get tmp() {
64
68
  return this._tmp;
65
69
  }
@@ -1,3 +1,6 @@
1
+ export declare const core: {
2
+ _: any;
3
+ };
1
4
  export declare const coreInit: (params: {
2
5
  locales?: Record<string, any>;
3
6
  }) => Promise<void>;
@@ -1,13 +1,14 @@
1
1
  import path from 'path';
2
2
  import { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService, ClientsService, ControllerService } from '../loader';
3
- import { Constants, x, } from '../utils';
3
+ import { Constants, getCore, x, } from '../utils';
4
4
  //
5
- let coreHasRun = false;
5
+ export const core = getCore();
6
6
  export const coreInit = async (params) => {
7
7
  const { locales } = params;
8
8
  if (locales)
9
9
  globalThis.__LOCAL_MESSAGES__ = locales;
10
10
  };
11
+ let coreHasRun = false;
11
12
  const coreLoader = async ({}) => {
12
13
  if (coreHasRun)
13
14
  return {};
@@ -20,7 +21,9 @@ const coreLoader = async ({}) => {
20
21
  .initialize([
21
22
  {
22
23
  service: SystemService,
23
- props: {}
24
+ props: {
25
+ core
26
+ }
24
27
  },
25
28
  {
26
29
  service: ConfigsService,
@@ -1,4 +1,4 @@
1
- export declare const getTmp: () => {
1
+ export declare const getCore: () => {
2
2
  _: any;
3
3
  };
4
4
  export declare const getTmpConfig: ({ root, tmpFileName, ext }: {
@@ -2,7 +2,7 @@ import path from "path";
2
2
  import fs from 'fs';
3
3
  import Handlebars from 'handlebars';
4
4
  import { Constants, TmpFileLoader } from "../../index.js";
5
- export const getTmp = () => {
5
+ export const getCore = () => {
6
6
  const ownerTmpFilePath = findFileRecursively(".", Constants.defaultTmpFileName, Constants.defaultTmpFileExt);
7
7
  if (!ownerTmpFilePath) {
8
8
  throw new Error(`${Constants.defaultTmpFileName} file not found`);
@@ -1,5 +1,5 @@
1
1
  export { default as pic } from "picocolors";
2
- export * from './tmp/index';
2
+ export * from './core/index';
3
3
  export * from './path/index';
4
4
  export * from './is/index';
5
5
  export * from './id/index';
@@ -1,5 +1,5 @@
1
1
  export { default as pic } from "picocolors";
2
- export * from './tmp/index';
2
+ export * from './core/index';
3
3
  export * from './path/index';
4
4
  export * from './is/index';
5
5
  export * from './id/index';
@@ -19,9 +19,9 @@ declare class X<T = {}> {
19
19
  service: any;
20
20
  props?: T;
21
21
  }[], verbose?: boolean): Promise<this>;
22
- get<T>(target: any): T;
23
- get cradle(): any;
24
22
  private isRegistered;
23
+ get<T>(target: (new (...args: any[]) => T) | string): T;
24
+ get cradle(): any;
25
25
  }
26
26
  declare const _default: X<{}>;
27
27
  export default _default;
@@ -128,21 +128,15 @@ class X {
128
128
  }
129
129
  return this;
130
130
  }
131
- get(target) {
132
- try {
133
- const resolveName = typeof target === 'function' ? target.name.charAt(0).toLowerCase() + target.name.slice(1) : target;
134
- return this.container.resolve(resolveName);
135
- }
136
- catch (err) {
137
- if (err.message.includes('Cyclic dependencies')) {
138
- console.error(`\n❌ [DI][CRITICAL] Cyclic dependency detected!\n🔍 Path: ${err.resolutionStack}`);
139
- }
140
- throw err;
141
- }
142
- }
143
- get cradle() { return this.container.cradle; }
144
131
  isRegistered(name) {
145
132
  return !!this.container.registrations[name] && this.container.registrations[name].resolve !== undefined;
146
133
  }
134
+ get(target) {
135
+ const resolveName = typeof target === 'function'
136
+ ? target.name.charAt(0).toLowerCase() + target.name.slice(1)
137
+ : target;
138
+ return this.container.resolve(resolveName);
139
+ }
140
+ get cradle() { return this.container.cradle; }
147
141
  }
148
142
  export default new X();