@xrystal/core 3.28.2 → 3.28.4

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.28.2",
4
+ "version": "3.28.4",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -61,11 +61,14 @@ export default class Configs {
61
61
  try {
62
62
  const moduleData = await modulePromise;
63
63
  const importedConfigs = moduleData?.default || moduleData?.configs || moduleData || {};
64
- const merged = merge({}, this.#config, importedConfigs || {});
64
+ console.log('1111', this.#config);
65
+ const merged = merge({}, this.#config, importedConfigs);
66
+ console.log('2222', this.#config);
65
67
  this.#config = Object.freeze(merged);
66
68
  }
67
69
  catch (e) {
68
70
  // error
71
+ console.log(e);
69
72
  }
70
73
  };
71
74
  setConfig(newConfigs) {
@@ -5,7 +5,7 @@ import path from "node:path";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { Partitioners } from "kafkajs";
7
7
  import { LoggerLayerEnum } from '../../utils/models/enums/index';
8
- import { LogDto } from "../../utils";
8
+ import { LogDTO } from "../../utils";
9
9
  class KafkaTransport extends Transport {
10
10
  service;
11
11
  constructor(opts, service) {
@@ -154,7 +154,7 @@ export default class Logger {
154
154
  await this.kafkaProducer.send({
155
155
  topic: this.kafkaLogsTopic,
156
156
  messages: [{
157
- value: JSON.stringify(LogDto.getSchema({
157
+ value: JSON.stringify(LogDTO.getSchema({
158
158
  level,
159
159
  service: this.serviceName,
160
160
  message,
@@ -1,5 +1,5 @@
1
1
  import { NodeEnvEnum } from "../enums";
2
- export interface ILogDto {
2
+ export interface ILogDTO {
3
3
  level: string;
4
4
  service: string;
5
5
  message: string;
@@ -9,8 +9,8 @@ export interface ILogDto {
9
9
  id?: string | number;
10
10
  env: NodeEnvEnum;
11
11
  }
12
- export declare class LogDto {
13
- static getSchema({ level, service, message, payload, code, timestamp, id, env }: ILogDto): {
12
+ export declare class LogDTO {
13
+ static getSchema({ level, service, message, payload, code, timestamp, id, env }: ILogDTO): {
14
14
  level: string;
15
15
  service: string;
16
16
  message: string;
@@ -21,24 +21,27 @@ export declare class LogDto {
21
21
  env: NodeEnvEnum;
22
22
  };
23
23
  }
24
- export interface MetadataDto<M = any> {
24
+ export interface IMetadata<E = any> {
25
25
  source: string;
26
26
  eventType: string;
27
27
  timestamp: number;
28
28
  correlationId: string;
29
29
  userId?: string;
30
- extra?: M;
30
+ extraData?: E;
31
31
  }
32
- export interface IQueueDto<P = any, M = any> {
33
- source: string;
34
- eventType: string;
35
- userId?: string;
32
+ export interface IMessageInput<P = any, E = any> {
33
+ metadata: {
34
+ source: string;
35
+ eventType: string;
36
+ userId?: string;
37
+ correlationId?: string;
38
+ extraData?: E;
39
+ };
36
40
  payload: P;
37
- metadata?: M;
38
41
  }
39
- export declare class QueueDto {
40
- static getSchema<P, M>(data: IQueueDto<P, M>): {
41
- metadata: MetadataDto<M>;
42
+ export declare class QueueDTO {
43
+ static getSchema<P, E>(input: IMessageInput<P, E>): {
44
+ metadata: IMetadata<E>;
42
45
  payload: P;
43
46
  };
44
47
  }
@@ -1,4 +1,4 @@
1
- export class LogDto {
1
+ export class LogDTO {
2
2
  static getSchema({ level, service, message, payload, code, timestamp, id, env }) {
3
3
  if (!level || !service || !message || !timestamp || !env) {
4
4
  throw new Error("Missing data other data required!");
@@ -15,22 +15,22 @@ export class LogDto {
15
15
  };
16
16
  }
17
17
  }
18
- export class QueueDto {
19
- static getSchema(data) {
20
- if (!data.source || !data.eventType) {
21
- throw new Error("Source and eventType are required");
18
+ export class QueueDTO {
19
+ static getSchema(input) {
20
+ if (!input.metadata.source || !input.metadata.eventType) {
21
+ throw new Error("Source and eventType are required inside metadata");
22
22
  }
23
- const metadata = {
24
- source: data.source,
25
- eventType: data.eventType,
23
+ const finalMetadata = {
24
+ source: input.metadata.source,
25
+ eventType: input.metadata.eventType,
26
26
  timestamp: Date.now(),
27
- correlationId: Math.random().toString(36).substring(7),
28
- userId: data.userId,
29
- extra: data.metadata
27
+ correlationId: input.metadata.correlationId || Math.random().toString(36).substring(7),
28
+ userId: input.metadata.userId,
29
+ extraData: input.metadata.extraData
30
30
  };
31
31
  return {
32
- metadata,
33
- payload: data.payload
32
+ metadata: finalMetadata,
33
+ payload: input.payload
34
34
  };
35
35
  }
36
36
  }