expresso-macchiato 0.3.8-dev → 0.3.8-dev.2

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
@@ -2,6 +2,7 @@ import { Request, Response as Response$1, RequestHandler, Router, Express } from
2
2
  import { BaseEntity, MixedList, EntitySchema } from 'typeorm';
3
3
  import { Socket, Namespace, Server as Server$1, ServerOptions } from 'socket.io';
4
4
  import http from 'http';
5
+ import * as utils_logger_av from 'utils-logger-av';
5
6
  import { Logger } from 'utils-logger-av';
6
7
 
7
8
  type BackgroundServiceConstructor = {
@@ -467,7 +468,7 @@ type SocketConnectionOk<Metadata = any> = {
467
468
  };
468
469
  type SocketConnectionMiddleware<Metadata extends Record<string, any> = any> = (self: SocketWrapper, client: Socket, commId?: string, metadata?: Metadata) => Promise<SocketConnectionOk<Metadata> | SocketConnectionNok>;
469
470
  type SocketWrapperConstructor<Metadata extends Record<string, any> = any> = {
470
- socket_namespace: string;
471
+ socketNamespace: string;
471
472
  clientConnectionKey?: string;
472
473
  connectionMiddleware?: SocketConnectionMiddleware<Metadata>;
473
474
  afterClientConnect?: (self: SocketWrapper, client: Socket, metadata?: Metadata) => Promise<void>;
@@ -477,7 +478,7 @@ type SocketWrapperConstructor<Metadata extends Record<string, any> = any> = {
477
478
 
478
479
  declare class SocketWrapper<Metadata extends Record<string, any> = any> {
479
480
  protected connectedClients: Map<string, ConnectedSocketClient>;
480
- readonly socket_namespace: string;
481
+ readonly socketNamespace: string;
481
482
  protected readonly data: SocketWrapperConstructor<Metadata>;
482
483
  protected namespace?: Namespace;
483
484
  constructor(data: SocketWrapperConstructor<Metadata>);
@@ -644,6 +645,8 @@ declare class MyLogger extends Logger {
644
645
  fullLogNok: (service: string, ...args: any[]) => void;
645
646
  }
646
647
  declare const log: MyLogger;
648
+ declare const i: Record<utils_logger_av.Icons, string>;
649
+ declare const c: (color: utils_logger_av.LogColors, message: any) => string;
647
650
  declare const fullLogOk: (service: string, message: string) => void;
648
651
  declare const fullLogNok: (service: string, ...args: any[]) => void;
649
652
  declare const apiOk: (res: any, status?: number, contentType?: string) => ExpressReturn;
@@ -651,6 +654,7 @@ declare const apiNok: (err: any, status?: number) => ExpressReturn;
651
654
  declare const errorCatcher: (res: Response$1, err: unknown, errorsList?: ErrorsMapping, errorString?: string) => void;
652
655
  declare const socketOk: <T extends Record<string, any> = any>(newMetadata?: T) => SocketConnectionOk;
653
656
  declare const socketNok: (message: string) => SocketConnectionNok;
657
+ declare const sleep: (ms: number) => Promise<unknown>;
654
658
  declare const getCompiledPath: (__filename: string, __dirname: string, pathsWithoutExtension: string[]) => string[];
655
659
 
656
- export { type ApiKeySecurity, BackgroundService, type BaseFormatContrainedParameter, type BaseOAuthSecurity, type BaseParameter, type BaseSchema, type BaseSecurity, type BasicAuthenticationSecurity, type BodyParameter, type Components, type ConnectedSocketClient, type Contact, type DefaultTokenPayload, type DynamicDbRouterOptions, type DynamicSwaggerOperation, type DynamicSwaggerOperationBody, type DynamicSwaggerPath, type DynamicSwaggerRequestBodyOperation, type ErrorsMapping, type ExpressReturn, type ExternalDocs, type FormDataParameter, type GenericFormat, type Header, type HeaderParameter, type Info, type IntegerFormat, type License, type ListOptions, type MethodPathHandling, type Methods, type NumberFormat, type OAuth2AccessCodeSecurity, type OAuth2ApplicationSecurity, type OAuth2ImplicitSecurity, type OAuth2PasswordSecurity, type OAuthScope, type Operation, type Parameter, type ParameterCollectionFormat, type ParameterType, type Path, type PathParameter, type ProjectConfigs, type QueryParameter, type Reference, type RequestBodyOperation, type Response, RouterWrapper, type RouterWrapperInterface, type Schema, type SchemaFormatConstraints, type SchemaV3, type SearchQuery, type SecureTokenConfig, type Security, type Server, type SocketConnectionMiddleware, type SocketConnectionNok, type SocketConnectionOk, SocketWrapper, type SocketWrapperConstructor, type Spec, Starter, type StarterOptions, type StringFormat, Swagger, type SwaggerMetadataInterface, type Tag, Token, type TokenApiOptions, type TokenConstructor, type XML, apiNok, apiOk, errorCatcher, fullLogNok, fullLogOk, getCompiledPath, log, socketNok, socketOk };
660
+ export { type ApiKeySecurity, BackgroundService, type BaseFormatContrainedParameter, type BaseOAuthSecurity, type BaseParameter, type BaseSchema, type BaseSecurity, type BasicAuthenticationSecurity, type BodyParameter, type Components, type ConnectedSocketClient, type Contact, type DefaultTokenPayload, type DynamicDbRouterOptions, type DynamicSwaggerOperation, type DynamicSwaggerOperationBody, type DynamicSwaggerPath, type DynamicSwaggerRequestBodyOperation, type ErrorsMapping, type ExpressReturn, type ExternalDocs, type FormDataParameter, type GenericFormat, type Header, type HeaderParameter, type Info, type IntegerFormat, type License, type ListOptions, type MethodPathHandling, type Methods, type NumberFormat, type OAuth2AccessCodeSecurity, type OAuth2ApplicationSecurity, type OAuth2ImplicitSecurity, type OAuth2PasswordSecurity, type OAuthScope, type Operation, type Parameter, type ParameterCollectionFormat, type ParameterType, type Path, type PathParameter, type ProjectConfigs, type QueryParameter, type Reference, type RequestBodyOperation, type Response, RouterWrapper, type RouterWrapperInterface, type Schema, type SchemaFormatConstraints, type SchemaV3, type SearchQuery, type SecureTokenConfig, type Security, type Server, type SocketConnectionMiddleware, type SocketConnectionNok, type SocketConnectionOk, SocketWrapper, type SocketWrapperConstructor, type Spec, Starter, type StarterOptions, type StringFormat, Swagger, type SwaggerMetadataInterface, type Tag, Token, type TokenApiOptions, type TokenConstructor, type XML, apiNok, apiOk, c, errorCatcher, fullLogNok, fullLogOk, getCompiledPath, i, log, sleep, socketNok, socketOk };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Request, Response as Response$1, RequestHandler, Router, Express } from
2
2
  import { BaseEntity, MixedList, EntitySchema } from 'typeorm';
3
3
  import { Socket, Namespace, Server as Server$1, ServerOptions } from 'socket.io';
4
4
  import http from 'http';
5
+ import * as utils_logger_av from 'utils-logger-av';
5
6
  import { Logger } from 'utils-logger-av';
6
7
 
7
8
  type BackgroundServiceConstructor = {
@@ -467,7 +468,7 @@ type SocketConnectionOk<Metadata = any> = {
467
468
  };
468
469
  type SocketConnectionMiddleware<Metadata extends Record<string, any> = any> = (self: SocketWrapper, client: Socket, commId?: string, metadata?: Metadata) => Promise<SocketConnectionOk<Metadata> | SocketConnectionNok>;
469
470
  type SocketWrapperConstructor<Metadata extends Record<string, any> = any> = {
470
- socket_namespace: string;
471
+ socketNamespace: string;
471
472
  clientConnectionKey?: string;
472
473
  connectionMiddleware?: SocketConnectionMiddleware<Metadata>;
473
474
  afterClientConnect?: (self: SocketWrapper, client: Socket, metadata?: Metadata) => Promise<void>;
@@ -477,7 +478,7 @@ type SocketWrapperConstructor<Metadata extends Record<string, any> = any> = {
477
478
 
478
479
  declare class SocketWrapper<Metadata extends Record<string, any> = any> {
479
480
  protected connectedClients: Map<string, ConnectedSocketClient>;
480
- readonly socket_namespace: string;
481
+ readonly socketNamespace: string;
481
482
  protected readonly data: SocketWrapperConstructor<Metadata>;
482
483
  protected namespace?: Namespace;
483
484
  constructor(data: SocketWrapperConstructor<Metadata>);
@@ -644,6 +645,8 @@ declare class MyLogger extends Logger {
644
645
  fullLogNok: (service: string, ...args: any[]) => void;
645
646
  }
646
647
  declare const log: MyLogger;
648
+ declare const i: Record<utils_logger_av.Icons, string>;
649
+ declare const c: (color: utils_logger_av.LogColors, message: any) => string;
647
650
  declare const fullLogOk: (service: string, message: string) => void;
648
651
  declare const fullLogNok: (service: string, ...args: any[]) => void;
649
652
  declare const apiOk: (res: any, status?: number, contentType?: string) => ExpressReturn;
@@ -651,6 +654,7 @@ declare const apiNok: (err: any, status?: number) => ExpressReturn;
651
654
  declare const errorCatcher: (res: Response$1, err: unknown, errorsList?: ErrorsMapping, errorString?: string) => void;
652
655
  declare const socketOk: <T extends Record<string, any> = any>(newMetadata?: T) => SocketConnectionOk;
653
656
  declare const socketNok: (message: string) => SocketConnectionNok;
657
+ declare const sleep: (ms: number) => Promise<unknown>;
654
658
  declare const getCompiledPath: (__filename: string, __dirname: string, pathsWithoutExtension: string[]) => string[];
655
659
 
656
- export { type ApiKeySecurity, BackgroundService, type BaseFormatContrainedParameter, type BaseOAuthSecurity, type BaseParameter, type BaseSchema, type BaseSecurity, type BasicAuthenticationSecurity, type BodyParameter, type Components, type ConnectedSocketClient, type Contact, type DefaultTokenPayload, type DynamicDbRouterOptions, type DynamicSwaggerOperation, type DynamicSwaggerOperationBody, type DynamicSwaggerPath, type DynamicSwaggerRequestBodyOperation, type ErrorsMapping, type ExpressReturn, type ExternalDocs, type FormDataParameter, type GenericFormat, type Header, type HeaderParameter, type Info, type IntegerFormat, type License, type ListOptions, type MethodPathHandling, type Methods, type NumberFormat, type OAuth2AccessCodeSecurity, type OAuth2ApplicationSecurity, type OAuth2ImplicitSecurity, type OAuth2PasswordSecurity, type OAuthScope, type Operation, type Parameter, type ParameterCollectionFormat, type ParameterType, type Path, type PathParameter, type ProjectConfigs, type QueryParameter, type Reference, type RequestBodyOperation, type Response, RouterWrapper, type RouterWrapperInterface, type Schema, type SchemaFormatConstraints, type SchemaV3, type SearchQuery, type SecureTokenConfig, type Security, type Server, type SocketConnectionMiddleware, type SocketConnectionNok, type SocketConnectionOk, SocketWrapper, type SocketWrapperConstructor, type Spec, Starter, type StarterOptions, type StringFormat, Swagger, type SwaggerMetadataInterface, type Tag, Token, type TokenApiOptions, type TokenConstructor, type XML, apiNok, apiOk, errorCatcher, fullLogNok, fullLogOk, getCompiledPath, log, socketNok, socketOk };
660
+ export { type ApiKeySecurity, BackgroundService, type BaseFormatContrainedParameter, type BaseOAuthSecurity, type BaseParameter, type BaseSchema, type BaseSecurity, type BasicAuthenticationSecurity, type BodyParameter, type Components, type ConnectedSocketClient, type Contact, type DefaultTokenPayload, type DynamicDbRouterOptions, type DynamicSwaggerOperation, type DynamicSwaggerOperationBody, type DynamicSwaggerPath, type DynamicSwaggerRequestBodyOperation, type ErrorsMapping, type ExpressReturn, type ExternalDocs, type FormDataParameter, type GenericFormat, type Header, type HeaderParameter, type Info, type IntegerFormat, type License, type ListOptions, type MethodPathHandling, type Methods, type NumberFormat, type OAuth2AccessCodeSecurity, type OAuth2ApplicationSecurity, type OAuth2ImplicitSecurity, type OAuth2PasswordSecurity, type OAuthScope, type Operation, type Parameter, type ParameterCollectionFormat, type ParameterType, type Path, type PathParameter, type ProjectConfigs, type QueryParameter, type Reference, type RequestBodyOperation, type Response, RouterWrapper, type RouterWrapperInterface, type Schema, type SchemaFormatConstraints, type SchemaV3, type SearchQuery, type SecureTokenConfig, type Security, type Server, type SocketConnectionMiddleware, type SocketConnectionNok, type SocketConnectionOk, SocketWrapper, type SocketWrapperConstructor, type Spec, Starter, type StarterOptions, type StringFormat, Swagger, type SwaggerMetadataInterface, type Tag, Token, type TokenApiOptions, type TokenConstructor, type XML, apiNok, apiOk, c, errorCatcher, fullLogNok, fullLogOk, getCompiledPath, i, log, sleep, socketNok, socketOk };
package/dist/index.js CHANGED
@@ -13,14 +13,16 @@ var MyLogger = class extends _utilsloggerav.Logger {
13
13
  };
14
14
  this.fullLogNok = (service, ...args) => {
15
15
  let finalString = `[${service.toUpperCase()}]: `;
16
- for (let i = 0; i < args.length; i++) if (i === args.length - 1) finalString += _nullishCoalesce(_optionalChain([args, 'access', _2 => _2[i], 'optionalAccess', _3 => _3.message]), () => ( args[i]));
17
- else finalString += args[i] + " ";
16
+ for (let i2 = 0; i2 < args.length; i2++) if (i2 === args.length - 1) finalString += _nullishCoalesce(_optionalChain([args, 'access', _2 => _2[i2], 'optionalAccess', _3 => _3.message]), () => ( args[i2]));
17
+ else finalString += args[i2] + " ";
18
18
  this.nok(`[${service.toUpperCase()}]: ${finalString}`);
19
19
  this.file(`[${service.toUpperCase()}]: ${finalString}`, "error");
20
20
  };
21
21
  }
22
22
  };
23
23
  var log = new MyLogger({ primaryColor: "cyan", logFilePath: process.env.ERROR_FILE_PATH });
24
+ var i = _utilsloggerav.Logger.icons;
25
+ var c = _utilsloggerav.getStringedColor;
24
26
  var { fullLogOk, fullLogNok } = log;
25
27
  var apiOk = (res, status = 200, contentType) => ({ result: res, status, contentType, isOk: true });
26
28
  var apiNok = (err, status = 500) => ({ result: err, status, isOk: false });
@@ -36,6 +38,7 @@ var errorCatcher = (res, err, errorsList, errorString) => {
36
38
  };
37
39
  var socketOk = (newMetadata) => ({ ok: true, newMetadata });
38
40
  var socketNok = (message) => ({ ok: false, message });
41
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
39
42
  var getCompiledPath = (__filename, __dirname, pathsWithoutExtension) => {
40
43
  const isCompiled = __filename.endsWith(".js");
41
44
  return pathsWithoutExtension.map((p) => _path3.default.join(__dirname, p + (isCompiled ? ".js" : ".ts")).replaceAll("\\", "/"));
@@ -714,7 +717,7 @@ var SocketWrapper = class {
714
717
  this.setupConnection = (io) => {
715
718
  try {
716
719
  if (!this.data.listeners) throw new Error("No listeners provided");
717
- this.namespace = io.of(`/${this.socket_namespace}`);
720
+ this.namespace = io.of(`/${this.socketNamespace}`);
718
721
  if (this.data.connectionMiddleware) {
719
722
  io.use(async (client, next) => {
720
723
  const commId = client.handshake.query.commId;
@@ -734,26 +737,26 @@ var SocketWrapper = class {
734
737
  const metadata = client.handshake.query.metadata;
735
738
  const finalClientId = this.data.clientConnectionKey ? _nullishCoalesce(_optionalChain([metadata, 'optionalAccess', _45 => _45[this.data.clientConnectionKey]]), () => ( client.id)) : client.id;
736
739
  this.connectedClients.set(finalClientId, { socket: client, connectedAt: /* @__PURE__ */ new Date(), metadata });
737
- log.cyan(`[SOCKETWRAPPER] [${this.socket_namespace.toUpperCase()}] Client ${client.id} connected`);
740
+ log.cyan(`[SOCKETWRAPPER] [${this.socketNamespace.toUpperCase()}] Client ${client.id} connected`);
738
741
  if (this.data.afterClientConnect) this.data.afterClientConnect(this, client, metadata);
739
742
  for (const eventName in this.data.listeners) client.on(eventName, (...params) => _optionalChain([this, 'access', _46 => _46.data, 'access', _47 => _47.listeners, 'optionalAccess', _48 => _48[eventName], 'call', _49 => _49(this, client, metadata, ...params)]));
740
743
  client.on("disconnect", () => this.handleDisconnection(client));
741
744
  } catch (err) {
742
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
745
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
743
746
  }
744
747
  });
745
748
  } catch (err) {
746
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
749
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
747
750
  }
748
751
  };
749
752
  this.handleDisconnection = (client) => {
750
753
  try {
751
754
  if (!this.namespace) throw new Error("Socket.IO not initialized");
752
755
  this.connectedClients.delete(client.id);
753
- log.cyan(`[SOCKETWRAPPER] [${this.socket_namespace.toUpperCase()}] Client ${client.id} disconnected`);
756
+ log.cyan(`[SOCKETWRAPPER] [${this.socketNamespace.toUpperCase()}] Client ${client.id} disconnected`);
754
757
  if (this.data.onClientDisconnect) this.data.onClientDisconnect(client);
755
758
  } catch (err) {
756
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
759
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
757
760
  }
758
761
  };
759
762
  // --- SEND METHODS
@@ -762,7 +765,7 @@ var SocketWrapper = class {
762
765
  if (!this.namespace) throw new Error("Socket.IO not initialized");
763
766
  this.namespace.emit(eventName, data);
764
767
  } catch (err) {
765
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
768
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
766
769
  }
767
770
  };
768
771
  this.broadcastExceptClient = (clientId, eventName, data) => {
@@ -771,7 +774,7 @@ var SocketWrapper = class {
771
774
  if (id !== clientId) client.socket.emit(eventName, data);
772
775
  }
773
776
  } catch (err) {
774
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
777
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
775
778
  }
776
779
  };
777
780
  this.sendToClient = (clientId, eventName, data) => {
@@ -780,7 +783,7 @@ var SocketWrapper = class {
780
783
  if (!connectedClient) throw new Error(`Client ${clientId} not found`);
781
784
  connectedClient.socket.emit(eventName, data);
782
785
  } catch (err) {
783
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
786
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
784
787
  }
785
788
  };
786
789
  this.sendToRoom = (room, eventName, data) => {
@@ -788,7 +791,7 @@ var SocketWrapper = class {
788
791
  if (!this.namespace) throw new Error("Socket.IO not initialized");
789
792
  this.namespace.to(room).emit(eventName, data);
790
793
  } catch (err) {
791
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
794
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
792
795
  }
793
796
  };
794
797
  // --- GETTERS
@@ -800,7 +803,7 @@ var SocketWrapper = class {
800
803
  }
801
804
  return void 0;
802
805
  };
803
- this.socket_namespace = data.socket_namespace;
806
+ this.socketNamespace = data.socketNamespace;
804
807
  this.data = data;
805
808
  Object.keys(_nullishCoalesce(data.listeners, () => ( {}))).forEach((key) => {
806
809
  this[key] = _optionalChain([data, 'access', _50 => _50.listeners, 'optionalAccess', _51 => _51[key], 'access', _52 => _52.bind, 'call', _53 => _53(this)]);
@@ -959,4 +962,7 @@ var Token = class {
959
962
 
960
963
 
961
964
 
962
- exports.BackgroundService = BackgroundService; exports.RouterWrapper = RouterWrapper; exports.SocketWrapper = SocketWrapper; exports.Starter = Starter; exports.Swagger = Swagger; exports.Token = Token; exports.apiNok = apiNok; exports.apiOk = apiOk; exports.errorCatcher = errorCatcher; exports.fullLogNok = fullLogNok; exports.fullLogOk = fullLogOk; exports.getCompiledPath = getCompiledPath; exports.log = log; exports.socketNok = socketNok; exports.socketOk = socketOk;
965
+
966
+
967
+
968
+ exports.BackgroundService = BackgroundService; exports.RouterWrapper = RouterWrapper; exports.SocketWrapper = SocketWrapper; exports.Starter = Starter; exports.Swagger = Swagger; exports.Token = Token; exports.apiNok = apiNok; exports.apiOk = apiOk; exports.c = c; exports.errorCatcher = errorCatcher; exports.fullLogNok = fullLogNok; exports.fullLogOk = fullLogOk; exports.getCompiledPath = getCompiledPath; exports.i = i; exports.log = log; exports.sleep = sleep; exports.socketNok = socketNok; exports.socketOk = socketOk;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/_utils.ts
2
2
  import path from "path";
3
- import { Logger } from "utils-logger-av";
3
+ import { Logger, getStringedColor } from "utils-logger-av";
4
4
  var MyLogger = class extends Logger {
5
5
  constructor() {
6
6
  super(...arguments);
@@ -13,14 +13,16 @@ var MyLogger = class extends Logger {
13
13
  };
14
14
  this.fullLogNok = (service, ...args) => {
15
15
  let finalString = `[${service.toUpperCase()}]: `;
16
- for (let i = 0; i < args.length; i++) if (i === args.length - 1) finalString += args[i]?.message ?? args[i];
17
- else finalString += args[i] + " ";
16
+ for (let i2 = 0; i2 < args.length; i2++) if (i2 === args.length - 1) finalString += args[i2]?.message ?? args[i2];
17
+ else finalString += args[i2] + " ";
18
18
  this.nok(`[${service.toUpperCase()}]: ${finalString}`);
19
19
  this.file(`[${service.toUpperCase()}]: ${finalString}`, "error");
20
20
  };
21
21
  }
22
22
  };
23
23
  var log = new MyLogger({ primaryColor: "cyan", logFilePath: process.env.ERROR_FILE_PATH });
24
+ var i = Logger.icons;
25
+ var c = getStringedColor;
24
26
  var { fullLogOk, fullLogNok } = log;
25
27
  var apiOk = (res, status = 200, contentType) => ({ result: res, status, contentType, isOk: true });
26
28
  var apiNok = (err, status = 500) => ({ result: err, status, isOk: false });
@@ -36,6 +38,7 @@ var errorCatcher = (res, err, errorsList, errorString) => {
36
38
  };
37
39
  var socketOk = (newMetadata) => ({ ok: true, newMetadata });
38
40
  var socketNok = (message) => ({ ok: false, message });
41
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
39
42
  var getCompiledPath = (__filename2, __dirname2, pathsWithoutExtension) => {
40
43
  const isCompiled = __filename2.endsWith(".js");
41
44
  return pathsWithoutExtension.map((p) => path.join(__dirname2, p + (isCompiled ? ".js" : ".ts")).replaceAll("\\", "/"));
@@ -714,7 +717,7 @@ var SocketWrapper = class {
714
717
  this.setupConnection = (io) => {
715
718
  try {
716
719
  if (!this.data.listeners) throw new Error("No listeners provided");
717
- this.namespace = io.of(`/${this.socket_namespace}`);
720
+ this.namespace = io.of(`/${this.socketNamespace}`);
718
721
  if (this.data.connectionMiddleware) {
719
722
  io.use(async (client, next) => {
720
723
  const commId = client.handshake.query.commId;
@@ -734,26 +737,26 @@ var SocketWrapper = class {
734
737
  const metadata = client.handshake.query.metadata;
735
738
  const finalClientId = this.data.clientConnectionKey ? metadata?.[this.data.clientConnectionKey] ?? client.id : client.id;
736
739
  this.connectedClients.set(finalClientId, { socket: client, connectedAt: /* @__PURE__ */ new Date(), metadata });
737
- log.cyan(`[SOCKETWRAPPER] [${this.socket_namespace.toUpperCase()}] Client ${client.id} connected`);
740
+ log.cyan(`[SOCKETWRAPPER] [${this.socketNamespace.toUpperCase()}] Client ${client.id} connected`);
738
741
  if (this.data.afterClientConnect) this.data.afterClientConnect(this, client, metadata);
739
742
  for (const eventName in this.data.listeners) client.on(eventName, (...params) => this.data.listeners?.[eventName](this, client, metadata, ...params));
740
743
  client.on("disconnect", () => this.handleDisconnection(client));
741
744
  } catch (err) {
742
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
745
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
743
746
  }
744
747
  });
745
748
  } catch (err) {
746
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
749
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
747
750
  }
748
751
  };
749
752
  this.handleDisconnection = (client) => {
750
753
  try {
751
754
  if (!this.namespace) throw new Error("Socket.IO not initialized");
752
755
  this.connectedClients.delete(client.id);
753
- log.cyan(`[SOCKETWRAPPER] [${this.socket_namespace.toUpperCase()}] Client ${client.id} disconnected`);
756
+ log.cyan(`[SOCKETWRAPPER] [${this.socketNamespace.toUpperCase()}] Client ${client.id} disconnected`);
754
757
  if (this.data.onClientDisconnect) this.data.onClientDisconnect(client);
755
758
  } catch (err) {
756
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
759
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
757
760
  }
758
761
  };
759
762
  // --- SEND METHODS
@@ -762,7 +765,7 @@ var SocketWrapper = class {
762
765
  if (!this.namespace) throw new Error("Socket.IO not initialized");
763
766
  this.namespace.emit(eventName, data);
764
767
  } catch (err) {
765
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
768
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
766
769
  }
767
770
  };
768
771
  this.broadcastExceptClient = (clientId, eventName, data) => {
@@ -771,7 +774,7 @@ var SocketWrapper = class {
771
774
  if (id !== clientId) client.socket.emit(eventName, data);
772
775
  }
773
776
  } catch (err) {
774
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
777
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
775
778
  }
776
779
  };
777
780
  this.sendToClient = (clientId, eventName, data) => {
@@ -780,7 +783,7 @@ var SocketWrapper = class {
780
783
  if (!connectedClient) throw new Error(`Client ${clientId} not found`);
781
784
  connectedClient.socket.emit(eventName, data);
782
785
  } catch (err) {
783
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
786
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
784
787
  }
785
788
  };
786
789
  this.sendToRoom = (room, eventName, data) => {
@@ -788,7 +791,7 @@ var SocketWrapper = class {
788
791
  if (!this.namespace) throw new Error("Socket.IO not initialized");
789
792
  this.namespace.to(room).emit(eventName, data);
790
793
  } catch (err) {
791
- fullLogNok(`SOCKETWRAPPER`, `[${this.socket_namespace.toUpperCase()}]`, err);
794
+ fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
792
795
  }
793
796
  };
794
797
  // --- GETTERS
@@ -800,7 +803,7 @@ var SocketWrapper = class {
800
803
  }
801
804
  return void 0;
802
805
  };
803
- this.socket_namespace = data.socket_namespace;
806
+ this.socketNamespace = data.socketNamespace;
804
807
  this.data = data;
805
808
  Object.keys(data.listeners ?? {}).forEach((key) => {
806
809
  this[key] = data.listeners?.[key].bind(this);
@@ -952,11 +955,14 @@ export {
952
955
  Token,
953
956
  apiNok,
954
957
  apiOk,
958
+ c,
955
959
  errorCatcher,
956
960
  fullLogNok,
957
961
  fullLogOk,
958
962
  getCompiledPath,
963
+ i,
959
964
  log,
965
+ sleep,
960
966
  socketNok,
961
967
  socketOk
962
968
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expresso-macchiato",
3
- "version": "0.3.8-dev",
3
+ "version": "0.3.8-dev.2",
4
4
  "author": "Alessio Velluso",
5
5
  "license": "MIT",
6
6
  "description": "Description",