@experts_hub/shared 1.0.612 → 1.0.615

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/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import Transport from 'winston-transport';
1
2
  import { MicroserviceOptions } from '@nestjs/microservices';
2
3
 
3
4
  declare const AUTHENTICATION_PATTERN: {
@@ -4139,9 +4140,9 @@ interface WinstonLogInfo {
4139
4140
  error?: string;
4140
4141
  [key: string]: any;
4141
4142
  }
4142
- declare class DiscordTransport {
4143
+ declare class DiscordTransport extends Transport {
4143
4144
  private readonly discordService;
4144
- private readonly options;
4145
+ private readonly transportOptions;
4145
4146
  private logsSent;
4146
4147
  constructor(options: DiscordTransportOptions);
4147
4148
  log(info: WinstonLogInfo, callback: () => void): void;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import Transport from 'winston-transport';
1
2
  import { MicroserviceOptions } from '@nestjs/microservices';
2
3
 
3
4
  declare const AUTHENTICATION_PATTERN: {
@@ -4139,9 +4140,9 @@ interface WinstonLogInfo {
4139
4140
  error?: string;
4140
4141
  [key: string]: any;
4141
4142
  }
4142
- declare class DiscordTransport {
4143
+ declare class DiscordTransport extends Transport {
4143
4144
  private readonly discordService;
4144
- private readonly options;
4145
+ private readonly transportOptions;
4145
4146
  private logsSent;
4146
4147
  constructor(options: DiscordTransportOptions);
4147
4148
  log(info: WinstonLogInfo, callback: () => void): void;
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
  var __decorateClass = (decorators, target, key, kind) => {
19
29
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
@@ -11440,9 +11450,7 @@ var DiscordAlertService = class {
11440
11450
  * Simple logging (doesn't use logger to avoid circular dependencies)
11441
11451
  */
11442
11452
  log(message) {
11443
- if (this.config.environment === "development") {
11444
- console.log(`[DiscordAlertService] ${message}`);
11445
- }
11453
+ console.log(`[DiscordAlertService] ${message}`);
11446
11454
  }
11447
11455
  /**
11448
11456
  * Error logging
@@ -11509,15 +11517,19 @@ var DiscordAlertService = class {
11509
11517
  };
11510
11518
 
11511
11519
  // src/modules/discord/winston-discord.transport.ts
11512
- var DiscordTransport = class {
11520
+ var import_winston_transport = __toESM(require("winston-transport"));
11521
+ var DiscordTransport = class extends import_winston_transport.default {
11513
11522
  /**
11514
11523
  * Creates a new Winston Discord transport
11515
11524
  *
11516
11525
  * @param options - Transport configuration
11517
11526
  */
11518
11527
  constructor(options) {
11528
+ super({
11529
+ level: options.level || "error"
11530
+ });
11519
11531
  this.logsSent = 0;
11520
- this.options = {
11532
+ this.transportOptions = {
11521
11533
  level: options.level || "error",
11522
11534
  microserviceName: options.microserviceName,
11523
11535
  environment: options.environment,
@@ -11527,31 +11539,36 @@ var DiscordTransport = class {
11527
11539
  };
11528
11540
  this.discordService = new DiscordAlertService({
11529
11541
  errorWebhookUrl: options.webhookUrl,
11530
- microserviceName: this.options.microserviceName,
11531
- environment: this.options.environment,
11532
- enabled: this.options.enabled
11542
+ microserviceName: this.transportOptions.microserviceName,
11543
+ environment: this.transportOptions.environment,
11544
+ enabled: this.transportOptions.enabled
11533
11545
  });
11534
11546
  }
11535
11547
  /**
11536
11548
  * Log method called by Winston for each log entry
11549
+ * Required by winston-transport.Transport
11537
11550
  *
11538
11551
  * @param info - Winston log info object
11539
11552
  * @param callback - Callback to call when done
11540
11553
  */
11541
11554
  log(info, callback) {
11542
11555
  setImmediate(() => {
11543
- if (typeof this.emit === "function") {
11544
- this.emit("logged", info);
11545
- }
11556
+ this.emit("logged", info);
11546
11557
  });
11547
- if (!this.options.enabled || !this.shouldLog(info.level)) {
11558
+ console.log(`[DiscordTransport] Received log - Level: ${info.level}, Enabled: ${this.transportOptions.enabled}, ShouldLog: ${this.shouldLog(info.level)}`);
11559
+ if (!this.transportOptions.enabled || !this.shouldLog(info.level)) {
11560
+ console.log(`[DiscordTransport] Skipping - Enabled: ${this.transportOptions.enabled}, ShouldLog: ${this.shouldLog(info.level)}`);
11548
11561
  callback();
11549
11562
  return;
11550
11563
  }
11551
- this.sendLogToDiscord(info).catch((error) => {
11564
+ console.log(`[DiscordTransport] Sending to Discord...`);
11565
+ this.sendLogToDiscord(info).then(() => {
11566
+ console.log(`[DiscordTransport] Successfully sent to Discord`);
11567
+ }).catch((error) => {
11552
11568
  console.error(
11553
11569
  `[DiscordTransport] Failed to send log to Discord:`,
11554
- error instanceof Error ? error.message : String(error)
11570
+ error instanceof Error ? error.message : String(error),
11571
+ error instanceof Error ? error.stack : ""
11555
11572
  );
11556
11573
  }).finally(() => {
11557
11574
  callback();
@@ -11573,7 +11590,7 @@ var DiscordTransport = class {
11573
11590
  debug: 5,
11574
11591
  silly: 6
11575
11592
  };
11576
- const targetLevel = levels[this.options.level] || 0;
11593
+ const targetLevel = levels[this.transportOptions.level] || 0;
11577
11594
  const currentLevel = levels[level] || 999;
11578
11595
  return currentLevel <= targetLevel;
11579
11596
  }
@@ -11605,7 +11622,7 @@ var DiscordTransport = class {
11605
11622
  const severity = this.mapLogLevelToSeverity(info.level);
11606
11623
  await this.discordService.sendAlert({
11607
11624
  severity,
11608
- category: this.options.category,
11625
+ category: this.transportOptions.category,
11609
11626
  title: this.buildTitle(info),
11610
11627
  description: info.message,
11611
11628
  fields: Object.keys(fields).length > 0 ? fields : void 0,
package/dist/index.mjs CHANGED
@@ -11556,9 +11556,7 @@ var DiscordAlertService = class {
11556
11556
  * Simple logging (doesn't use logger to avoid circular dependencies)
11557
11557
  */
11558
11558
  log(message) {
11559
- if (this.config.environment === "development") {
11560
- console.log(`[DiscordAlertService] ${message}`);
11561
- }
11559
+ console.log(`[DiscordAlertService] ${message}`);
11562
11560
  }
11563
11561
  /**
11564
11562
  * Error logging
@@ -11625,15 +11623,19 @@ var DiscordAlertService = class {
11625
11623
  };
11626
11624
 
11627
11625
  // src/modules/discord/winston-discord.transport.ts
11628
- var DiscordTransport = class {
11626
+ import Transport from "winston-transport";
11627
+ var DiscordTransport = class extends Transport {
11629
11628
  /**
11630
11629
  * Creates a new Winston Discord transport
11631
11630
  *
11632
11631
  * @param options - Transport configuration
11633
11632
  */
11634
11633
  constructor(options) {
11634
+ super({
11635
+ level: options.level || "error"
11636
+ });
11635
11637
  this.logsSent = 0;
11636
- this.options = {
11638
+ this.transportOptions = {
11637
11639
  level: options.level || "error",
11638
11640
  microserviceName: options.microserviceName,
11639
11641
  environment: options.environment,
@@ -11643,31 +11645,36 @@ var DiscordTransport = class {
11643
11645
  };
11644
11646
  this.discordService = new DiscordAlertService({
11645
11647
  errorWebhookUrl: options.webhookUrl,
11646
- microserviceName: this.options.microserviceName,
11647
- environment: this.options.environment,
11648
- enabled: this.options.enabled
11648
+ microserviceName: this.transportOptions.microserviceName,
11649
+ environment: this.transportOptions.environment,
11650
+ enabled: this.transportOptions.enabled
11649
11651
  });
11650
11652
  }
11651
11653
  /**
11652
11654
  * Log method called by Winston for each log entry
11655
+ * Required by winston-transport.Transport
11653
11656
  *
11654
11657
  * @param info - Winston log info object
11655
11658
  * @param callback - Callback to call when done
11656
11659
  */
11657
11660
  log(info, callback) {
11658
11661
  setImmediate(() => {
11659
- if (typeof this.emit === "function") {
11660
- this.emit("logged", info);
11661
- }
11662
+ this.emit("logged", info);
11662
11663
  });
11663
- if (!this.options.enabled || !this.shouldLog(info.level)) {
11664
+ console.log(`[DiscordTransport] Received log - Level: ${info.level}, Enabled: ${this.transportOptions.enabled}, ShouldLog: ${this.shouldLog(info.level)}`);
11665
+ if (!this.transportOptions.enabled || !this.shouldLog(info.level)) {
11666
+ console.log(`[DiscordTransport] Skipping - Enabled: ${this.transportOptions.enabled}, ShouldLog: ${this.shouldLog(info.level)}`);
11664
11667
  callback();
11665
11668
  return;
11666
11669
  }
11667
- this.sendLogToDiscord(info).catch((error) => {
11670
+ console.log(`[DiscordTransport] Sending to Discord...`);
11671
+ this.sendLogToDiscord(info).then(() => {
11672
+ console.log(`[DiscordTransport] Successfully sent to Discord`);
11673
+ }).catch((error) => {
11668
11674
  console.error(
11669
11675
  `[DiscordTransport] Failed to send log to Discord:`,
11670
- error instanceof Error ? error.message : String(error)
11676
+ error instanceof Error ? error.message : String(error),
11677
+ error instanceof Error ? error.stack : ""
11671
11678
  );
11672
11679
  }).finally(() => {
11673
11680
  callback();
@@ -11689,7 +11696,7 @@ var DiscordTransport = class {
11689
11696
  debug: 5,
11690
11697
  silly: 6
11691
11698
  };
11692
- const targetLevel = levels[this.options.level] || 0;
11699
+ const targetLevel = levels[this.transportOptions.level] || 0;
11693
11700
  const currentLevel = levels[level] || 999;
11694
11701
  return currentLevel <= targetLevel;
11695
11702
  }
@@ -11721,7 +11728,7 @@ var DiscordTransport = class {
11721
11728
  const severity = this.mapLogLevelToSeverity(info.level);
11722
11729
  await this.discordService.sendAlert({
11723
11730
  severity,
11724
- category: this.options.category,
11731
+ category: this.transportOptions.category,
11725
11732
  title: this.buildTitle(info),
11726
11733
  description: info.message,
11727
11734
  fields: Object.keys(fields).length > 0 ? fields : void 0,
@@ -11787,12 +11794,12 @@ function createDiscordTransport(options) {
11787
11794
 
11788
11795
  // src/adapters/tcp/user.tcp.adapter.ts
11789
11796
  import { config } from "dotenv";
11790
- import { Transport } from "@nestjs/microservices";
11797
+ import { Transport as Transport2 } from "@nestjs/microservices";
11791
11798
  config();
11792
11799
  var UserTCPAdapter = () => {
11793
11800
  return {
11794
11801
  name: "USER_MICROSERVICE",
11795
- transport: Transport.TCP,
11802
+ transport: Transport2.TCP,
11796
11803
  options: {
11797
11804
  host: process.env.USER_MICROSERVICE_TCP_HOST || "localhost",
11798
11805
  port: parseInt(process.env.USER_MICROSERVICE_TCP_PORT || "4001", 10)
@@ -11802,12 +11809,12 @@ var UserTCPAdapter = () => {
11802
11809
 
11803
11810
  // src/adapters/tcp/job.tcp.adapter.ts
11804
11811
  import { config as config2 } from "dotenv";
11805
- import { Transport as Transport2 } from "@nestjs/microservices";
11812
+ import { Transport as Transport3 } from "@nestjs/microservices";
11806
11813
  config2();
11807
11814
  var JobTCPAdapter = () => {
11808
11815
  return {
11809
11816
  name: "JOB_MICROSERVICE",
11810
- transport: Transport2.TCP,
11817
+ transport: Transport3.TCP,
11811
11818
  options: {
11812
11819
  host: process.env.JOB_MICROSERVICE_TCP_HOST || "localhost",
11813
11820
  port: parseInt(process.env.JOB_MICROSERVICE_TCP_PORT || "4002", 10)
@@ -11817,12 +11824,12 @@ var JobTCPAdapter = () => {
11817
11824
 
11818
11825
  // src/adapters/tcp/contract.tcp.adapter.ts
11819
11826
  import { config as config3 } from "dotenv";
11820
- import { Transport as Transport3 } from "@nestjs/microservices";
11827
+ import { Transport as Transport4 } from "@nestjs/microservices";
11821
11828
  config3();
11822
11829
  var ContractTCPAdapter = () => {
11823
11830
  return {
11824
11831
  name: "CONTRACT_MICROSERVICE",
11825
- transport: Transport3.TCP,
11832
+ transport: Transport4.TCP,
11826
11833
  options: {
11827
11834
  host: process.env.CONTRACT_MICROSERVICE_TCP_HOST || "localhost",
11828
11835
  port: parseInt(process.env.CONTRACT_MICROSERVICE_TCP_PORT || "4004", 10)
@@ -11832,12 +11839,12 @@ var ContractTCPAdapter = () => {
11832
11839
 
11833
11840
  // src/adapters/tcp/notification.tcp.adapter.ts
11834
11841
  import { config as config4 } from "dotenv";
11835
- import { Transport as Transport4 } from "@nestjs/microservices";
11842
+ import { Transport as Transport5 } from "@nestjs/microservices";
11836
11843
  config4();
11837
11844
  var NotificationTCPAdapter = () => {
11838
11845
  return {
11839
11846
  name: "NOTIFICATION_MICROSERVICE",
11840
- transport: Transport4.TCP,
11847
+ transport: Transport5.TCP,
11841
11848
  options: {
11842
11849
  host: process.env.NOTIFICATION_MICROSERVICE_TCP_HOST || "localhost",
11843
11850
  port: parseInt(process.env.NOTIFICATION_MICROSERVICE_TCP_PORT || "4003", 10)
@@ -11847,12 +11854,12 @@ var NotificationTCPAdapter = () => {
11847
11854
 
11848
11855
  // src/adapters/tcp/chat.tcp.adapter.ts
11849
11856
  import { config as config5 } from "dotenv";
11850
- import { Transport as Transport5 } from "@nestjs/microservices";
11857
+ import { Transport as Transport6 } from "@nestjs/microservices";
11851
11858
  config5();
11852
11859
  var ChatTCPAdapter = () => {
11853
11860
  return {
11854
11861
  name: "CHAT_MICROSERVICE",
11855
- transport: Transport5.TCP,
11862
+ transport: Transport6.TCP,
11856
11863
  options: {
11857
11864
  host: process.env.CHAT_MICROSERVICE_TCP_HOST || "localhost",
11858
11865
  port: parseInt(process.env.CHAT_MICROSERVICE_TCP_PORT || "4005", 10)
@@ -11862,7 +11869,7 @@ var ChatTCPAdapter = () => {
11862
11869
 
11863
11870
  // src/adapters/rmq/user.rmq.adapter.ts
11864
11871
  import { config as config6 } from "dotenv";
11865
- import { Transport as Transport6 } from "@nestjs/microservices";
11872
+ import { Transport as Transport7 } from "@nestjs/microservices";
11866
11873
  config6();
11867
11874
  var UserRMQAdapter = (mode = "microservice") => {
11868
11875
  const urls = process.env.USER_MICROSERVICE_RMQ_URL?.split(",") || [
@@ -11882,7 +11889,7 @@ var UserRMQAdapter = (mode = "microservice") => {
11882
11889
  );
11883
11890
  const config11 = {
11884
11891
  name: "USER_MICROSERVICE",
11885
- transport: Transport6.RMQ,
11892
+ transport: Transport7.RMQ,
11886
11893
  options: {
11887
11894
  urls,
11888
11895
  queue,
@@ -11919,7 +11926,7 @@ var UserRMQAdapter = (mode = "microservice") => {
11919
11926
 
11920
11927
  // src/adapters/rmq/job.rmq.adapter.ts
11921
11928
  import { config as config7 } from "dotenv";
11922
- import { Transport as Transport7 } from "@nestjs/microservices";
11929
+ import { Transport as Transport8 } from "@nestjs/microservices";
11923
11930
  config7();
11924
11931
  var JobRMQAdapter = (mode = "microservice") => {
11925
11932
  const urls = process.env.JOB_MICROSERVICE_RMQ_URL?.split(",") || [
@@ -11939,7 +11946,7 @@ var JobRMQAdapter = (mode = "microservice") => {
11939
11946
  );
11940
11947
  const config11 = {
11941
11948
  name: "JOB_MICROSERVICE",
11942
- transport: Transport7.RMQ,
11949
+ transport: Transport8.RMQ,
11943
11950
  options: {
11944
11951
  urls,
11945
11952
  queue,
@@ -11976,7 +11983,7 @@ var JobRMQAdapter = (mode = "microservice") => {
11976
11983
 
11977
11984
  // src/adapters/rmq/contract.rmq.adapter.ts
11978
11985
  import { config as config8 } from "dotenv";
11979
- import { Transport as Transport8 } from "@nestjs/microservices";
11986
+ import { Transport as Transport9 } from "@nestjs/microservices";
11980
11987
  config8();
11981
11988
  var ContractRMQAdapter = (mode = "microservice") => {
11982
11989
  const urls = process.env.CONTRACT_MICROSERVICE_RMQ_URL?.split(",") || [
@@ -11996,7 +12003,7 @@ var ContractRMQAdapter = (mode = "microservice") => {
11996
12003
  );
11997
12004
  const config11 = {
11998
12005
  name: "CONTRACT_MICROSERVICE",
11999
- transport: Transport8.RMQ,
12006
+ transport: Transport9.RMQ,
12000
12007
  options: {
12001
12008
  urls,
12002
12009
  queue,
@@ -12033,7 +12040,7 @@ var ContractRMQAdapter = (mode = "microservice") => {
12033
12040
 
12034
12041
  // src/adapters/rmq/notification.rmq.adapter.ts
12035
12042
  import { config as config9 } from "dotenv";
12036
- import { Transport as Transport9 } from "@nestjs/microservices";
12043
+ import { Transport as Transport10 } from "@nestjs/microservices";
12037
12044
  config9();
12038
12045
  var NotificationRMQAdapter = (mode = "microservice") => {
12039
12046
  const urls = process.env.NOTIFICATION_MICROSERVICE_RMQ_URL?.split(",") || [
@@ -12053,7 +12060,7 @@ var NotificationRMQAdapter = (mode = "microservice") => {
12053
12060
  );
12054
12061
  const config11 = {
12055
12062
  name: "NOTIFICATION_MICROSERVICE",
12056
- transport: Transport9.RMQ,
12063
+ transport: Transport10.RMQ,
12057
12064
  options: {
12058
12065
  urls,
12059
12066
  queue,
@@ -12090,7 +12097,7 @@ var NotificationRMQAdapter = (mode = "microservice") => {
12090
12097
 
12091
12098
  // src/adapters/rmq/chat.rmq.adapter.ts
12092
12099
  import { config as config10 } from "dotenv";
12093
- import { Transport as Transport10 } from "@nestjs/microservices";
12100
+ import { Transport as Transport11 } from "@nestjs/microservices";
12094
12101
  config10();
12095
12102
  var ChatRMQAdapter = (mode = "microservice") => {
12096
12103
  const urls = process.env.CHAT_MICROSERVICE_RMQ_URL?.split(",") || [
@@ -12110,7 +12117,7 @@ var ChatRMQAdapter = (mode = "microservice") => {
12110
12117
  );
12111
12118
  const config11 = {
12112
12119
  name: "CHAT_MICROSERVICE",
12113
- transport: Transport10.RMQ,
12120
+ transport: Transport11.RMQ,
12114
12121
  options: {
12115
12122
  urls,
12116
12123
  queue,
@@ -1,3 +1,4 @@
1
+ import Transport from 'winston-transport';
1
2
  import { DiscordAlertService } from './discord-alert.service';
2
3
  import { AlertSeverity, AlertCategory } from './discord-alert.interface';
3
4
  export interface DiscordTransportOptions {
@@ -19,9 +20,9 @@ interface WinstonLogInfo {
19
20
  error?: string;
20
21
  [key: string]: any;
21
22
  }
22
- export declare class DiscordTransport {
23
+ export declare class DiscordTransport extends Transport {
23
24
  private readonly discordService;
24
- private readonly options;
25
+ private readonly transportOptions;
25
26
  private logsSent;
26
27
  constructor(options: DiscordTransportOptions);
27
28
  log(info: WinstonLogInfo, callback: () => void): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@experts_hub/shared",
3
- "version": "1.0.612",
3
+ "version": "1.0.615",
4
4
  "description": "Shared DTOs, interfaces, and utilities for experts hub applications",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -46,7 +46,8 @@
46
46
  "peerDependencies": {
47
47
  "@nestjs/common": "^10.0.0 || ^11.0.0",
48
48
  "class-transformer": "^0.5.1",
49
- "class-validator": "^0.14.0"
49
+ "class-validator": "^0.14.0",
50
+ "winston-transport": "^4.0.0"
50
51
  },
51
52
  "dependencies": {
52
53
  "@nestjs/microservices": "^11.0.19",