@org-quicko/core 1.1.0 → 2.0.0

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.
Files changed (66) hide show
  1. package/README.md +7 -7
  2. package/dist/browser/beans/BaseObject.js.map +1 -1
  3. package/dist/browser/exceptions/BadRequestException.js.map +1 -1
  4. package/dist/browser/exceptions/BaseException.js +1 -21
  5. package/dist/browser/exceptions/BaseException.js.map +1 -1
  6. package/dist/browser/exceptions/ClientException.js.map +1 -1
  7. package/dist/browser/exceptions/ConverterException.js.map +1 -1
  8. package/dist/browser/exceptions/ForbiddenAccessException.js.map +1 -1
  9. package/dist/browser/exceptions/HTTPException.js.map +1 -1
  10. package/dist/browser/exceptions/IllegalArgumentException.js.map +1 -1
  11. package/dist/browser/exceptions/UnauthorizedException.js.map +1 -1
  12. package/dist/browser/types/JSONObject.js.map +1 -1
  13. package/dist/browser/types/LoggingLevel.js.map +1 -1
  14. package/dist/browser/types/SortOrder.js.map +1 -1
  15. package/dist/browser/utils/date/DateUtil.js +3 -40
  16. package/dist/browser/utils/date/DateUtil.js.map +1 -1
  17. package/dist/cjs/beans/BaseObject.cjs.map +1 -1
  18. package/dist/cjs/build/node/index.cjs +0 -1
  19. package/dist/cjs/build/node/index.cjs.map +1 -1
  20. package/dist/cjs/exceptions/BadRequestException.cjs.map +1 -1
  21. package/dist/cjs/exceptions/BaseException.cjs +1 -21
  22. package/dist/cjs/exceptions/BaseException.cjs.map +1 -1
  23. package/dist/cjs/exceptions/ClientException.cjs.map +1 -1
  24. package/dist/cjs/exceptions/ConverterException.cjs.map +1 -1
  25. package/dist/cjs/exceptions/ForbiddenAccessException.cjs.map +1 -1
  26. package/dist/cjs/exceptions/HTTPException.cjs.map +1 -1
  27. package/dist/cjs/exceptions/IllegalArgumentException.cjs.map +1 -1
  28. package/dist/cjs/exceptions/UnauthorizedException.cjs.map +1 -1
  29. package/dist/cjs/logger/LoggerFactory.cjs +96 -22
  30. package/dist/cjs/logger/LoggerFactory.cjs.map +1 -1
  31. package/dist/cjs/logger/format/ErrorFormat.cjs +115 -0
  32. package/dist/cjs/logger/format/ErrorFormat.cjs.map +1 -0
  33. package/dist/cjs/logger/index.cjs +0 -1
  34. package/dist/cjs/logger/index.cjs.map +1 -1
  35. package/dist/cjs/types/JSONObject.cjs.map +1 -1
  36. package/dist/cjs/types/LoggingLevel.cjs.map +1 -1
  37. package/dist/cjs/types/SortOrder.cjs.map +1 -1
  38. package/dist/cjs/utils/date/DateUtil.cjs +3 -40
  39. package/dist/cjs/utils/date/DateUtil.cjs.map +1 -1
  40. package/dist/esm/beans/BaseObject.js.map +1 -1
  41. package/dist/esm/build/node/index.js +1 -1
  42. package/dist/esm/exceptions/BadRequestException.js.map +1 -1
  43. package/dist/esm/exceptions/BaseException.js +1 -21
  44. package/dist/esm/exceptions/BaseException.js.map +1 -1
  45. package/dist/esm/exceptions/ClientException.js.map +1 -1
  46. package/dist/esm/exceptions/ConverterException.js.map +1 -1
  47. package/dist/esm/exceptions/ForbiddenAccessException.js.map +1 -1
  48. package/dist/esm/exceptions/HTTPException.js.map +1 -1
  49. package/dist/esm/exceptions/IllegalArgumentException.js.map +1 -1
  50. package/dist/esm/exceptions/UnauthorizedException.js.map +1 -1
  51. package/dist/esm/logger/LoggerFactory.js +97 -22
  52. package/dist/esm/logger/LoggerFactory.js.map +1 -1
  53. package/dist/esm/logger/format/ErrorFormat.js +113 -0
  54. package/dist/esm/logger/format/ErrorFormat.js.map +1 -0
  55. package/dist/esm/logger/index.js +1 -1
  56. package/dist/esm/types/JSONObject.js.map +1 -1
  57. package/dist/esm/types/LoggingLevel.js.map +1 -1
  58. package/dist/esm/types/SortOrder.js.map +1 -1
  59. package/dist/esm/utils/date/DateUtil.js +3 -40
  60. package/dist/esm/utils/date/DateUtil.js.map +1 -1
  61. package/dist/types/index.d.ts +1 -1
  62. package/dist/types/src/exceptions/BaseException.d.ts +0 -6
  63. package/dist/types/src/logger/LoggerFactory.d.ts +88 -10
  64. package/dist/types/src/logger/index.d.ts +1 -1
  65. package/dist/types/src/utils/date/DateUtil.d.ts +9 -52
  66. package/package.json +140 -136
@@ -1 +1 @@
1
- {"version":3,"file":"ForbiddenAccessException.js","sources":["../../../src/exceptions/ForbiddenAccessException.ts"],"sourcesContent":["import { HTTPException } from './HTTPException';\r\n\r\n/**\r\n * Exception thrown when access to a resource is forbidden.\r\n * Typically used for HTTP 403 errors.\r\n */\r\nexport class ForbiddenAccessException extends HTTPException {\r\n\r\n constructor(message: string, cause?: unknown) {\r\n super(message, cause, 403);\r\n }\r\n}\r\n\r\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,MAAO,wBAAyB,SAAQ,aAAa,CAAA;IAEvD,WAAY,CAAA,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;;AAEjC;;;;"}
1
+ {"version":3,"file":"ForbiddenAccessException.js","sources":["../../../src/exceptions/ForbiddenAccessException.ts"],"sourcesContent":["import { HTTPException } from './HTTPException';\n\n/**\n * Exception thrown when access to a resource is forbidden.\n * Typically used for HTTP 403 errors.\n */\nexport class ForbiddenAccessException extends HTTPException {\n\n constructor(message: string, cause?: unknown) {\n super(message, cause, 403);\n }\n}\n\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,MAAO,wBAAyB,SAAQ,aAAa,CAAA;IAEvD,WAAA,CAAY,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;IAC9B;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"HTTPException.js","sources":["../../../src/exceptions/HTTPException.ts"],"sourcesContent":["import { BaseException } from './BaseException';\r\n\r\n/**\r\n * Base class for HTTP-related exceptions.\r\n * Provides support for HTTP status codes.\r\n */\r\nexport abstract class HTTPException extends BaseException {\r\n\r\n constructor(message: string, cause?: unknown, code: number = 500) {\r\n super(message, cause, code);\r\n }\r\n\r\n}"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,MAAgB,aAAc,SAAQ,aAAa,CAAA;AAErD,IAAA,WAAA,CAAY,OAAe,EAAE,KAAe,EAAE,OAAe,GAAG,EAAA;AAC5D,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;;AAGlC;;;;"}
1
+ {"version":3,"file":"HTTPException.js","sources":["../../../src/exceptions/HTTPException.ts"],"sourcesContent":["import { BaseException } from './BaseException';\n\n/**\n * Base class for HTTP-related exceptions.\n * Provides support for HTTP status codes.\n */\nexport abstract class HTTPException extends BaseException {\n\n constructor(message: string, cause?: unknown, code: number = 500) {\n super(message, cause, code);\n }\n\n}"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,MAAgB,aAAc,SAAQ,aAAa,CAAA;AAErD,IAAA,WAAA,CAAY,OAAe,EAAE,KAAe,EAAE,OAAe,GAAG,EAAA;AAC5D,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;IAC/B;AAEH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"IllegalArgumentException.js","sources":["../../../src/exceptions/IllegalArgumentException.ts"],"sourcesContent":["import { BaseException } from './BaseException';\r\n\r\n/**\r\n * Exception thrown when an illegal or inappropriate argument is passed.\r\n */\r\nexport class IllegalArgumentException extends BaseException {\r\n\r\n constructor(message: string, cause?: unknown) {\r\n super(message, cause, 500);\r\n }\r\n}\r\n\r\n"],"names":[],"mappings":";;AAEA;;AAEG;AACG,MAAO,wBAAyB,SAAQ,aAAa,CAAA;IAEvD,WAAY,CAAA,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;;AAEjC;;;;"}
1
+ {"version":3,"file":"IllegalArgumentException.js","sources":["../../../src/exceptions/IllegalArgumentException.ts"],"sourcesContent":["import { BaseException } from './BaseException';\n\n/**\n * Exception thrown when an illegal or inappropriate argument is passed.\n */\nexport class IllegalArgumentException extends BaseException {\n\n constructor(message: string, cause?: unknown) {\n super(message, cause, 500);\n }\n}\n\n"],"names":[],"mappings":";;AAEA;;AAEG;AACG,MAAO,wBAAyB,SAAQ,aAAa,CAAA;IAEvD,WAAA,CAAY,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;IAC9B;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"UnauthorizedException.js","sources":["../../../src/exceptions/UnauthorizedException.ts"],"sourcesContent":["import { HTTPException } from './HTTPException';\r\n\r\n/**\r\n * Exception thrown when a request is unauthorized.\r\n * Typically used for HTTP 401 errors.\r\n */\r\nexport class UnauthorizedException extends HTTPException {\r\n\r\n constructor(message: string, cause?: unknown) {\r\n super(message, cause, 401);\r\n }\r\n}\r\n\r\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,MAAO,qBAAsB,SAAQ,aAAa,CAAA;IAEpD,WAAY,CAAA,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;;AAEjC;;;;"}
1
+ {"version":3,"file":"UnauthorizedException.js","sources":["../../../src/exceptions/UnauthorizedException.ts"],"sourcesContent":["import { HTTPException } from './HTTPException';\n\n/**\n * Exception thrown when a request is unauthorized.\n * Typically used for HTTP 401 errors.\n */\nexport class UnauthorizedException extends HTTPException {\n\n constructor(message: string, cause?: unknown) {\n super(message, cause, 401);\n }\n}\n\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,MAAO,qBAAsB,SAAQ,aAAa,CAAA;IAEpD,WAAA,CAAY,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;IAC9B;AACH;;;;"}
@@ -1,41 +1,116 @@
1
1
  import winston from 'winston';
2
- import { ClientException } from '../exceptions/ClientException.js';
2
+ import { BaseException } from '../exceptions/BaseException.js';
3
+ import { ErrorFormat } from './format/ErrorFormat.js';
3
4
  import { LoggingLevel } from '../types/LoggingLevel.js';
4
5
  import '../types/SortOrder.js';
5
6
 
6
7
  /**
7
- * A factory class for managing logger instances.
8
- * Provides methods to retrieve and store loggers in a shared storage.
8
+ * Factory class for creating and managing Winston logger instances.
9
+ *
10
+ * @description
11
+ * Provides a factory for creating Winston logger instances with consistent configuration.
12
+ * Supports custom logging levels, formats, and transports with a default format pipeline
13
+ * that includes timestamp, error handling with cause chains, and JSON formatting.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Create a logger with custom configuration
18
+ * const logger = LoggerFactory.createLogger({
19
+ * level: 'info',
20
+ * transports: [new winston.transports.Console()]
21
+ * });
22
+ *
23
+ * // Create another logger and add a label to it
24
+ * const apiLogger = LoggerFactory.getLogger('api-service');
25
+ * apiLogger.info('Server started');
26
+ * ```
9
27
  */
10
- const loggers = new Map();
11
28
  class LoggerFactory {
12
29
  /**
13
- * Retrieves a logger instance by its name.
30
+ * Creates and initializes a new logger instance with the provided configuration.
14
31
  *
15
- * @param name The name of the logger to retrieve.
16
- * @returns The logger instance if found, otherwise `undefined`.
32
+ * @description
33
+ * Creates a new Winston logger with a consistent default format pipeline that includes
34
+ * timestamp, error handling with stack traces and cause chains, custom error formatting,
35
+ * and JSON output. Custom formats are combined with the defaults. If no transports are
36
+ * specified, defaults to Console transport.
37
+ *
38
+ * @param {LoggerOptions} [options] - Optional Winston logger configuration options
39
+ * @param {LoggingLevel} [options.level='info'] - Logging level (error, warn, info, http, debug, verbose, silly)
40
+ * @param {winston.LogFormat} [options.format] - Additional custom format to combine with defaults
41
+ * @param {object} [options.defaultMeta] - Default metadata to include in all log entries from this logger
42
+ * @param {winston.transport[]} [options.transports] - Transport instances (defaults to Console)
43
+ *
44
+ * @returns {winston.Logger} Configured logger instance
45
+ *
46
+ * @throws {BaseException} If logger initialization fails
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // Create a logger with custom configuration
51
+ * const logger = LoggerFactory.createLogger({
52
+ * level: 'debug',
53
+ * defaultMeta: { service: 'api' },
54
+ * transports: [
55
+ * new winston.transports.Console(),
56
+ * new winston.transports.File({ filename: 'combined.log' })
57
+ * ]
58
+ * });
59
+ * ```
17
60
  */
18
- static createLogger(name, level = LoggingLevel.info, format) {
19
- const label = typeof name === "string" ? name : "Unknown";
20
- if (loggers.has(label)) {
21
- return loggers.get(label);
22
- }
61
+ static createLogger(options) {
23
62
  try {
24
- const defaultFormat = winston.format.combine(winston.format.timestamp(), winston.format.json());
25
- const logger = winston.createLogger({
26
- level: level,
27
- format: format ? winston.format.combine(format, defaultFormat) : defaultFormat,
28
- defaultMeta: { label },
29
- transports: [new winston.transports.Console()],
63
+ const defaultFormat = winston.format.combine(winston.format.timestamp(), winston.format.errors({ stack: true, cause: true }), ErrorFormat(), winston.format.json());
64
+ LoggerFactory.logger = winston.createLogger({
65
+ level: options?.level ?? LoggingLevel.info,
66
+ format: options?.format
67
+ ? winston.format.combine(options.format, defaultFormat)
68
+ : defaultFormat,
69
+ defaultMeta: options?.defaultMeta,
70
+ transports: options?.transports
71
+ ? options.transports
72
+ : [new winston.transports.Console()],
30
73
  });
31
- loggers.set(label, logger);
32
- return logger;
74
+ return LoggerFactory.logger;
33
75
  }
34
76
  catch (error) {
35
- throw new ClientException(`Error creating logger`, error, 500);
77
+ throw new BaseException(`Error creating logger`, error, 500);
78
+ }
79
+ }
80
+ /**
81
+ * Gets a logger instance with a label added to the metadata.
82
+ *
83
+ * @description
84
+ * Returns a logger instance that is a child of the base logger with the provided label
85
+ * added as metadata. Each call creates a new child logger with the specified label.
86
+ * This is useful for identifying the source of log messages by module or service name.
87
+ *
88
+ * @param {string} label - Unique identifier for the logger to include in metadata (e.g., module name, service name)
89
+ *
90
+ * @returns {winston.Logger} Child logger instance with the label in metadata
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * // Create a logger with a label for the UserService module
95
+ * const logger = LoggerFactory.getLogger('UserService');
96
+ *
97
+ * // Another module can create its own labeled logger
98
+ * const apiLogger = LoggerFactory.getLogger('APIHandler');
99
+ *
100
+ * logger.info('Processing user request'); // Log includes { label: 'UserService' }
101
+ * ```
102
+ */
103
+ static getLogger(label) {
104
+ let baseLogger;
105
+ if (LoggerFactory.logger) {
106
+ baseLogger = LoggerFactory.logger;
107
+ }
108
+ else {
109
+ baseLogger = LoggerFactory.createLogger();
36
110
  }
111
+ return baseLogger.child({ label });
37
112
  }
38
113
  }
39
114
 
40
- export { LoggerFactory, loggers };
115
+ export { LoggerFactory };
41
116
  //# sourceMappingURL=LoggerFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoggerFactory.js","sources":["../../../src/logger/LoggerFactory.ts"],"sourcesContent":["import winston from \"winston\";\r\nimport { ClientException } from \"../exceptions\";\r\nimport { LoggingLevel } from \"../types\";\r\n\r\n/**\r\n * A factory class for managing logger instances.\r\n * Provides methods to retrieve and store loggers in a shared storage.\r\n */\r\nexport const loggers: Map<string, winston.Logger> = new Map<string, winston.Logger>();\r\n\r\nexport class LoggerFactory {\r\n /**\r\n * Retrieves a logger instance by its name.\r\n *\r\n * @param name The name of the logger to retrieve.\r\n * @returns The logger instance if found, otherwise `undefined`.\r\n */\r\n static createLogger(\r\n name: string,\r\n level: LoggingLevel = LoggingLevel.info,\r\n format?: winston.Logform.Format\r\n ): winston.Logger {\r\n\r\n const label = typeof name === \"string\" ? name : \"Unknown\";\r\n\r\n if (loggers.has(label)) {\r\n return loggers.get(label)!;\r\n }\r\n\r\n try {\r\n\r\n const defaultFormat = winston.format.combine(\r\n winston.format.timestamp(),\r\n winston.format.json()\r\n );\r\n\r\n const logger = winston.createLogger({\r\n level: level,\r\n format: format ? winston.format.combine(format, defaultFormat) : defaultFormat,\r\n defaultMeta: { label },\r\n transports: [new winston.transports.Console()],\r\n });\r\n\r\n loggers.set(label, logger);\r\n\r\n return logger;\r\n } catch (error) {\r\n throw new ClientException(`Error creating logger`, error, 500);\r\n }\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;AAIA;;;AAGG;AACU,MAAA,OAAO,GAAgC,IAAI,GAAG;MAE9C,aAAa,CAAA;AACxB;;;;;AAKG;IACH,OAAO,YAAY,CACjB,IAAY,EACZ,QAAsB,YAAY,CAAC,IAAI,EACvC,MAA+B,EAAA;AAG/B,QAAA,MAAM,KAAK,GAAG,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG,SAAS;AAEzD,QAAA,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;AACtB,YAAA,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAE;;AAG5B,QAAA,IAAI;YAEF,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAC1C,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,EAC1B,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CACtB;AAED,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;AAClC,gBAAA,KAAK,EAAE,KAAK;AACZ,gBAAA,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,aAAa;gBAC9E,WAAW,EAAE,EAAE,KAAK,EAAE;gBACtB,UAAU,EAAE,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;AAC/C,aAAA,CAAC;AAEF,YAAA,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC;AAE1B,YAAA,OAAO,MAAM;;QACb,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,eAAe,CAAC,CAAA,qBAAA,CAAuB,EAAE,KAAK,EAAE,GAAG,CAAC;;;AAGnE;;;;"}
1
+ {"version":3,"file":"LoggerFactory.js","sources":["../../../src/logger/LoggerFactory.ts"],"sourcesContent":["import winston, { Logger, LoggerOptions } from \"winston\";\nimport { BaseException } from \"../exceptions\";\nimport { ErrorFormat } from \"./format/ErrorFormat\";\nimport { LoggingLevel } from \"../types\";\n\n/**\n * Factory class for creating and managing Winston logger instances.\n *\n * @description\n * Provides a factory for creating Winston logger instances with consistent configuration.\n * Supports custom logging levels, formats, and transports with a default format pipeline\n * that includes timestamp, error handling with cause chains, and JSON formatting.\n *\n * @example\n * ```typescript\n * // Create a logger with custom configuration\n * const logger = LoggerFactory.createLogger({\n * level: 'info',\n * transports: [new winston.transports.Console()]\n * });\n *\n * // Create another logger and add a label to it\n * const apiLogger = LoggerFactory.getLogger('api-service');\n * apiLogger.info('Server started');\n * ```\n */\nexport class LoggerFactory {\n /**\n * Base logger instance used by the factory.\n *\n * @description\n * Currently stores a single base logger instance per execution context.\n * This design can be extended in the future to support multiple base loggers\n * by replacing this single instance with a Map-based container (similar to Winston's Container API)\n * to manage multiple named logger configurations.\n *\n * @type {winston.Logger}\n * @private\n */\n private static logger: winston.Logger;\n\n /**\n * Creates and initializes a new logger instance with the provided configuration.\n *\n * @description\n * Creates a new Winston logger with a consistent default format pipeline that includes\n * timestamp, error handling with stack traces and cause chains, custom error formatting,\n * and JSON output. Custom formats are combined with the defaults. If no transports are\n * specified, defaults to Console transport.\n *\n * @param {LoggerOptions} [options] - Optional Winston logger configuration options\n * @param {LoggingLevel} [options.level='info'] - Logging level (error, warn, info, http, debug, verbose, silly)\n * @param {winston.LogFormat} [options.format] - Additional custom format to combine with defaults\n * @param {object} [options.defaultMeta] - Default metadata to include in all log entries from this logger\n * @param {winston.transport[]} [options.transports] - Transport instances (defaults to Console)\n *\n * @returns {winston.Logger} Configured logger instance\n *\n * @throws {BaseException} If logger initialization fails\n *\n * @example\n * ```typescript\n * // Create a logger with custom configuration\n * const logger = LoggerFactory.createLogger({\n * level: 'debug',\n * defaultMeta: { service: 'api' },\n * transports: [\n * new winston.transports.Console(),\n * new winston.transports.File({ filename: 'combined.log' })\n * ]\n * });\n * ```\n */\n static createLogger(options?: LoggerOptions): winston.Logger {\n try {\n const defaultFormat = winston.format.combine(\n winston.format.timestamp(),\n winston.format.errors({ stack: true, cause: true }),\n ErrorFormat(),\n winston.format.json()\n );\n\n LoggerFactory.logger = winston.createLogger({\n level: options?.level ?? LoggingLevel.info,\n format: options?.format\n ? winston.format.combine(options.format, defaultFormat)\n : defaultFormat,\n defaultMeta: options?.defaultMeta,\n transports: options?.transports\n ? options.transports\n : [new winston.transports.Console()],\n });\n\n return LoggerFactory.logger;\n } catch (error) {\n throw new BaseException(`Error creating logger`, error, 500);\n }\n }\n\n /**\n * Gets a logger instance with a label added to the metadata.\n *\n * @description\n * Returns a logger instance that is a child of the base logger with the provided label\n * added as metadata. Each call creates a new child logger with the specified label.\n * This is useful for identifying the source of log messages by module or service name.\n *\n * @param {string} label - Unique identifier for the logger to include in metadata (e.g., module name, service name)\n *\n * @returns {winston.Logger} Child logger instance with the label in metadata\n *\n * @example\n * ```typescript\n * // Create a logger with a label for the UserService module\n * const logger = LoggerFactory.getLogger('UserService');\n *\n * // Another module can create its own labeled logger\n * const apiLogger = LoggerFactory.getLogger('APIHandler');\n *\n * logger.info('Processing user request'); // Log includes { label: 'UserService' }\n * ```\n */\n static getLogger(label: string): winston.Logger {\n let baseLogger: winston.Logger;\n if (LoggerFactory.logger) {\n baseLogger = LoggerFactory.logger!;\n } else {\n baseLogger = LoggerFactory.createLogger();\n }\n\n return baseLogger.child({ label });\n }\n \n}\n"],"names":[],"mappings":";;;;;;AAKA;;;;;;;;;;;;;;;;;;;;AAoBG;MACU,aAAa,CAAA;AAexB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;IACH,OAAO,YAAY,CAAC,OAAuB,EAAA;AACzC,QAAA,IAAI;AACF,YAAA,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAC1C,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,EAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACnD,WAAW,EAAE,EACb,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CACtB;AAED,YAAA,aAAa,CAAC,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;AAC1C,gBAAA,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,YAAY,CAAC,IAAI;gBAC1C,MAAM,EAAE,OAAO,EAAE;AACf,sBAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa;AACtD,sBAAE,aAAa;gBACjB,WAAW,EAAE,OAAO,EAAE,WAAW;gBACjC,UAAU,EAAE,OAAO,EAAE;sBACjB,OAAO,CAAC;sBACR,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;AACvC,aAAA,CAAC;YAEF,OAAO,aAAa,CAAC,MAAM;QAC7B;QAAE,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,aAAa,CAAC,CAAA,qBAAA,CAAuB,EAAE,KAAK,EAAE,GAAG,CAAC;QAC9D;IACF;AAEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;IACH,OAAO,SAAS,CAAC,KAAa,EAAA;AAC5B,QAAA,IAAI,UAA0B;AAC9B,QAAA,IAAI,aAAa,CAAC,MAAM,EAAE;AACxB,YAAA,UAAU,GAAG,aAAa,CAAC,MAAO;QACpC;aAAO;AACL,YAAA,UAAU,GAAG,aAAa,CAAC,YAAY,EAAE;QAC3C;QAEA,OAAO,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;IACpC;AAED;;;;"}
@@ -0,0 +1,113 @@
1
+ import winston from 'winston';
2
+
3
+ /**
4
+ * Winston log format for handling Error objects with cause chains.
5
+ *
6
+ * @description
7
+ * ES2022 supports adding a `cause` property to Error objects for better error context.
8
+ * While `console.log(err)` prints the entire cause chain automatically, Winston only logs
9
+ * the top-level error, losing the cause chain context.
10
+ *
11
+ * This format ensures that error cause chains are fully serialized and included in log output,
12
+ * preserving the complete error context for better debugging and error tracking.
13
+ *
14
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause | MDN: Error.cause}
15
+ * @see {@link https://github.com/winstonjs/winston/issues/2533 | Winston Issue #2533}
16
+ *
17
+ * @param {TransformableInfo} info - The log entry information from Winston
18
+ * @returns {TransformableInfo} The formatted log entry with serialized error chains
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const logger = winston.createLogger({
23
+ * format: winston.format.combine(
24
+ * ErrorFormat,
25
+ * winston.format.json()
26
+ * ),
27
+ * transports: [new winston.transports.Console()]
28
+ * });
29
+ *
30
+ * try {
31
+ * throw new Error("Original error");
32
+ * } catch (err) {
33
+ * throw new Error("Wrapper error", { cause: err });
34
+ * }
35
+ * ```
36
+ */
37
+ const ErrorFormat = winston.format((info) => {
38
+ // If the log entry itself is an error
39
+ if (info instanceof Error) {
40
+ const seen = new WeakSet();
41
+ const serialized = serialize(info, seen);
42
+ // Preserve Winston semantics by setting standard error properties
43
+ info.message = serialized.message;
44
+ info.stack = serialized.stack;
45
+ info.cause = serialized.cause;
46
+ // Copy all other enumerable properties from serialized error
47
+ for (const key of Object.keys(serialized)) {
48
+ if (!["message", "stack", "name", "cause"].includes(key)) {
49
+ info[key] = serialized[key];
50
+ }
51
+ }
52
+ return info;
53
+ }
54
+ // For normal log entries, serialize any nested error fields
55
+ const seen = new WeakSet();
56
+ for (const key of Object.keys(info)) {
57
+ info[key] = serialize(info[key], seen);
58
+ }
59
+ return info;
60
+ });
61
+ /**
62
+ * Recursively serializes values that may contain Error objects.
63
+ *
64
+ * @description
65
+ * Handles all types of values including Error instances, nested objects, arrays,
66
+ * and primitives. Ensures that Error objects are fully serialized with their
67
+ * stack traces, messages, and cause chains preserved. Includes circular reference
68
+ * detection to prevent infinite recursion.
69
+ *
70
+ * @param {any} value - The value to serialize. Can be any type (Error, object, array, primitive)
71
+ * @param {WeakSet<object>} seen - Set tracking objects already visited to detect circular references
72
+ * @returns {any} The serialized value with all Error objects converted to plain objects
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const error = new Error("Test");
77
+ * const seen = new WeakSet<object>();
78
+ * const serialized = serialize(error, seen);
79
+ * // Returns: { message: "Test", name: "Error", stack: "...", cause: undefined }
80
+ * ```
81
+ */
82
+ function serialize(value, seen = new WeakSet()) {
83
+ // Handle null/undefined
84
+ if (value == null) {
85
+ return value;
86
+ }
87
+ // Error instance - convert to serializable object
88
+ if (value instanceof Error) {
89
+ // Check for circular reference
90
+ if (seen.has(value)) {
91
+ return "[Circular Reference]";
92
+ }
93
+ seen.add(value);
94
+ const serialized = {
95
+ message: value.message,
96
+ name: value.name,
97
+ stack: value.stack,
98
+ cause: value.cause instanceof Error ? serialize(value.cause, seen) : value.cause,
99
+ };
100
+ // Copy enumerable custom properties (e.g., error.code, error.statusCode)
101
+ for (const key of Object.keys(value)) {
102
+ if (!(key in serialized)) {
103
+ serialized[key] = serialize(value[key], seen);
104
+ }
105
+ }
106
+ return serialized;
107
+ }
108
+ // Primitive value - return as-is
109
+ return value;
110
+ }
111
+
112
+ export { ErrorFormat };
113
+ //# sourceMappingURL=ErrorFormat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorFormat.js","sources":["../../../../src/logger/format/ErrorFormat.ts"],"sourcesContent":["import winston from \"winston\";\nimport { TransformableInfo } from \"logform\";\n\n/**\n * Winston log format for handling Error objects with cause chains.\n *\n * @description\n * ES2022 supports adding a `cause` property to Error objects for better error context.\n * While `console.log(err)` prints the entire cause chain automatically, Winston only logs\n * the top-level error, losing the cause chain context.\n *\n * This format ensures that error cause chains are fully serialized and included in log output,\n * preserving the complete error context for better debugging and error tracking.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause | MDN: Error.cause}\n * @see {@link https://github.com/winstonjs/winston/issues/2533 | Winston Issue #2533}\n *\n * @param {TransformableInfo} info - The log entry information from Winston\n * @returns {TransformableInfo} The formatted log entry with serialized error chains\n *\n * @example\n * ```typescript\n * const logger = winston.createLogger({\n * format: winston.format.combine(\n * ErrorFormat,\n * winston.format.json()\n * ),\n * transports: [new winston.transports.Console()]\n * });\n *\n * try {\n * throw new Error(\"Original error\");\n * } catch (err) {\n * throw new Error(\"Wrapper error\", { cause: err });\n * }\n * ```\n */\nexport const ErrorFormat = winston.format((info: TransformableInfo) => {\n // If the log entry itself is an error\n if (info instanceof Error) {\n const seen = new WeakSet<object>();\n const serialized = serialize(info, seen);\n\n // Preserve Winston semantics by setting standard error properties\n info.message = serialized.message;\n info.stack = serialized.stack;\n info.cause = serialized.cause;\n\n // Copy all other enumerable properties from serialized error\n for (const key of Object.keys(serialized)) {\n if (![\"message\", \"stack\", \"name\", \"cause\"].includes(key)) {\n info[key] = serialized[key];\n }\n }\n\n return info;\n }\n\n // For normal log entries, serialize any nested error fields\n const seen = new WeakSet<object>();\n for (const key of Object.keys(info)) {\n info[key] = serialize(info[key], seen);\n }\n\n return info;\n});\n\n/**\n * Recursively serializes values that may contain Error objects.\n *\n * @description\n * Handles all types of values including Error instances, nested objects, arrays,\n * and primitives. Ensures that Error objects are fully serialized with their\n * stack traces, messages, and cause chains preserved. Includes circular reference\n * detection to prevent infinite recursion.\n *\n * @param {any} value - The value to serialize. Can be any type (Error, object, array, primitive)\n * @param {WeakSet<object>} seen - Set tracking objects already visited to detect circular references\n * @returns {any} The serialized value with all Error objects converted to plain objects\n *\n * @example\n * ```typescript\n * const error = new Error(\"Test\");\n * const seen = new WeakSet<object>();\n * const serialized = serialize(error, seen);\n * // Returns: { message: \"Test\", name: \"Error\", stack: \"...\", cause: undefined }\n * ```\n */\nfunction serialize(value: any, seen: WeakSet<object> = new WeakSet<object>()): any {\n // Handle null/undefined\n if (value == null) {\n return value;\n }\n\n // Error instance - convert to serializable object\n if (value instanceof Error) {\n // Check for circular reference\n if (seen.has(value)) {\n return \"[Circular Reference]\";\n }\n seen.add(value);\n\n const serialized: any = {\n message: value.message,\n name: value.name,\n stack: value.stack,\n cause: value.cause instanceof Error ? serialize(value.cause, seen) : value.cause,\n };\n\n // Copy enumerable custom properties (e.g., error.code, error.statusCode)\n for (const key of Object.keys(value)) {\n if (!(key in serialized)) {\n serialized[key] = serialize(value[key], seen);\n }\n }\n\n return serialized;\n }\n\n\n // Primitive value - return as-is\n return value;\n}"],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCG;AACI,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,IAAuB,KAAI;;AAEpE,IAAA,IAAI,IAAI,YAAY,KAAK,EAAE;AACzB,QAAA,MAAM,IAAI,GAAG,IAAI,OAAO,EAAU;QAClC,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC;;AAGxC,QAAA,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO;AACjC,QAAA,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK;AAC7B,QAAA,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK;;QAG7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;AACzC,YAAA,IAAI,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBACxD,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC;YAC7B;QACF;AAEA,QAAA,OAAO,IAAI;IACb;;AAGA,IAAA,MAAM,IAAI,GAAG,IAAI,OAAO,EAAU;IAClC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AACnC,QAAA,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IACxC;AAEA,IAAA,OAAO,IAAI;AACb,CAAC;AAED;;;;;;;;;;;;;;;;;;;;AAoBG;AACH,SAAS,SAAS,CAAC,KAAU,EAAE,IAAA,GAAwB,IAAI,OAAO,EAAU,EAAA;;AAE1E,IAAA,IAAI,KAAK,IAAI,IAAI,EAAE;AACjB,QAAA,OAAO,KAAK;IACd;;AAGA,IAAA,IAAI,KAAK,YAAY,KAAK,EAAE;;AAE1B,QAAA,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;AACnB,YAAA,OAAO,sBAAsB;QAC/B;AACA,QAAA,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;AAEf,QAAA,MAAM,UAAU,GAAQ;YACtB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK,YAAY,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK;SACjF;;QAGD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AACpC,YAAA,IAAI,EAAE,GAAG,IAAI,UAAU,CAAC,EAAE;AACxB,gBAAA,UAAU,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;YAC/C;QACF;AAEA,QAAA,OAAO,UAAU;IACnB;;AAIA,IAAA,OAAO,KAAK;AACd;;;;"}
@@ -1,2 +1,2 @@
1
- export { LoggerFactory, loggers } from './LoggerFactory.js';
1
+ export { LoggerFactory } from './LoggerFactory.js';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"JSONObject.js","sources":["../../../src/types/JSONObject.ts"],"sourcesContent":["import { BaseException, IllegalArgumentException } from '../exceptions';\r\n\r\nexport type JSONValue =\r\n | string\r\n | number\r\n | boolean\r\n | null\r\n | undefined\r\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\r\n | Object\r\n\r\nexport class JSONObject extends Map<string, JSONValue> {\r\n\r\n\r\n constructor(object?: { [x: string]: JSONValue }) {\r\n super()\r\n if (object) {\r\n for (const [key, value] of Object.entries(object)) {\r\n if (value === null || value === undefined) {\r\n // ignore\r\n } else if (value.constructor == Object) {\r\n this.set(key, new JSONObject(value as { [x: string]: JSONValue }));\r\n } else if (value.constructor == Array) {\r\n this.set(key, new JSONArray(value));\r\n } else {\r\n this.set(key, value)\r\n }\r\n }\r\n }\r\n\r\n\r\n }\r\n\r\n getJSONObject(key: string): JSONObject {\r\n if (super.has(key)) {\r\n if (super.get(key) instanceof JSONObject) {\r\n return super.get(key) as JSONObject\r\n } else {\r\n throw new IllegalArgumentException('Value cannot be converted to JSONObject')\r\n }\r\n }\r\n\r\n throw new BaseException(`Value for Key: '${key}' not found`);\r\n }\r\n\r\n getString(key: string): string {\r\n if (super.has(key)) {\r\n try {\r\n if (typeof super.get(key) === 'string') {\r\n return super.get(key) as string;\r\n }\r\n\r\n throw new IllegalArgumentException('Value cannot be converted to string')\r\n } catch (e) {\r\n throw new IllegalArgumentException('Value cannot be converted to string', e)\r\n }\r\n }\r\n throw new BaseException(`Value for Key: '${key}' not found`);\r\n }\r\n\r\n getNumber(key: string): number {\r\n if (super.has(key)) {\r\n const number = Number(super.get(key));\r\n if (!isNaN(number)) {\r\n return number;\r\n }\r\n throw new IllegalArgumentException('Value cannot be converted to number')\r\n }\r\n throw new BaseException(`Value for Key: '${key}' not found`);\r\n }\r\n\r\n getBoolean(key: string): boolean {\r\n if (super.has(key)) {\r\n if (typeof super.get(key) === 'boolean') {\r\n return super.get(key) as boolean;\r\n } else if (super.get(key) === 'true' || super.get(key) === 'false') {\r\n return Boolean(super.get(key));\r\n }\r\n throw new IllegalArgumentException('Value cannot be converted to boolean')\r\n }\r\n throw new BaseException(`Value for Key: '${key}' not found`);\r\n }\r\n\r\n getArray(key: string): JSONArray {\r\n if (super.has(key)) {\r\n if (super.get(key) instanceof JSONArray) {\r\n return super.get(key) as JSONArray;\r\n }\r\n else if (super.get(key) instanceof Array) {\r\n return new JSONArray(super.get(key) as Array<JSONValue>);\r\n }\r\n throw new IllegalArgumentException('Value cannot be converted to array')\r\n }\r\n throw new BaseException(`Value for Key: '${key}' not found`);\r\n }\r\n\r\n public toJSON(): { [x: string]: JSONValue } {\r\n const obj: { [x: string]: JSONValue } = {};\r\n for (const [key, value] of this.entries()) {\r\n if (value == null) {\r\n obj[key] = value;\r\n } else if (value instanceof JSONObject || value instanceof JSONArray) {\r\n obj[key] = value.toJSON();\r\n } else {\r\n obj[key] = value\r\n }\r\n }\r\n return obj;\r\n }\r\n}\r\n\r\n\r\nexport class JSONArray extends Array<JSONValue> {\r\n\r\n constructor(array?: Array<JSONValue>) {\r\n super();\r\n if (array) {\r\n for (let item of Object.values(array)) {\r\n item = JSON.parse(JSON.stringify(item))\r\n\r\n if (item == null) {\r\n this.push(item);\r\n }\r\n else if (item.constructor == Object) {\r\n this.push(new JSONObject(item as { [x: string]: JSONValue }));\r\n }\r\n else if (item.constructor == Array) {\r\n this.push(new JSONArray(item));\r\n }\r\n else {\r\n this.push(item)\r\n }\r\n }\r\n }\r\n }\r\n\r\n public toJSON(): Array<JSONValue> {\r\n const arr: Array<JSONValue> = [];\r\n for (const value of this) {\r\n if (value == null) {\r\n arr.push(value);\r\n } else if (value instanceof JSONObject || value instanceof JSONArray) {\r\n arr.push(value.toJSON());\r\n } else {\r\n arr.push(value)\r\n }\r\n }\r\n return arr;\r\n }\r\n}"],"names":[],"mappings":";;;AAWM,MAAO,UAAW,SAAQ,GAAsB,CAAA;AAGlD,IAAA,WAAA,CAAY,MAAmC,EAAA;AAC3C,QAAA,KAAK,EAAE;QACP,IAAI,MAAM,EAAE;AACR,YAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBAC/C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAA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I,CAAC,CAAC;;qBAE7B;AACD,oBAAA,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;IAMxB,MAAM,GAAA;QACT,MAAM,GAAG,GAAqB,EAAE;AAChC,QAAA,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE;AACtB,YAAA,IAAI,KAAK,IAAI,IAAI,EAAE;AACf,gBAAA,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;;iBACZ,IAAI,KAAK,YAAY,UAAU,IAAI,KAAK,YAAY,SAAS,EAAE;gBAClE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;;iBACrB;AACH,gBAAA,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;;;AAGvB,QAAA,OAAO,GAAG;;AAEjB;;;;"}
1
+ {"version":3,"file":"JSONObject.js","sources":["../../../src/types/JSONObject.ts"],"sourcesContent":["import { BaseException, IllegalArgumentException } from '../exceptions';\n\nexport type JSONValue =\n | string\n | number\n | boolean\n | null\n | undefined\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\n | Object\n\nexport class JSONObject extends Map<string, JSONValue> {\n\n\n constructor(object?: { [x: string]: JSONValue }) {\n super()\n if (object) {\n for (const [key, value] of Object.entries(object)) {\n if (value === null || value === undefined) {\n // ignore\n } else if (value.constructor == Object) {\n this.set(key, new JSONObject(value as { [x: string]: JSONValue }));\n } else if (value.constructor == Array) {\n this.set(key, new JSONArray(value));\n } else {\n this.set(key, value)\n }\n }\n }\n\n\n }\n\n getJSONObject(key: string): JSONObject {\n if (super.has(key)) {\n if (super.get(key) instanceof JSONObject) {\n return super.get(key) as JSONObject\n } else {\n throw new IllegalArgumentException('Value cannot be converted to JSONObject')\n }\n }\n\n throw new BaseException(`Value for Key: '${key}' not found`);\n }\n\n getString(key: string): string {\n if (super.has(key)) {\n try {\n if (typeof super.get(key) === 'string') {\n return super.get(key) as string;\n }\n\n throw new IllegalArgumentException('Value cannot be converted to string')\n } catch (e) {\n throw new IllegalArgumentException('Value cannot be converted to string', e)\n }\n }\n throw new BaseException(`Value for Key: '${key}' not found`);\n }\n\n getNumber(key: string): number {\n if (super.has(key)) {\n const number = Number(super.get(key));\n if (!isNaN(number)) {\n return number;\n }\n throw new IllegalArgumentException('Value cannot be converted to number')\n }\n throw new BaseException(`Value for Key: '${key}' not found`);\n }\n\n getBoolean(key: string): boolean {\n if (super.has(key)) {\n if (typeof super.get(key) === 'boolean') {\n return super.get(key) as boolean;\n } else if (super.get(key) === 'true' || super.get(key) === 'false') {\n return Boolean(super.get(key));\n }\n throw new IllegalArgumentException('Value cannot be converted to boolean')\n }\n throw new BaseException(`Value for Key: '${key}' not found`);\n }\n\n getArray(key: string): JSONArray {\n if (super.has(key)) {\n if (super.get(key) instanceof JSONArray) {\n return super.get(key) as JSONArray;\n }\n else if (super.get(key) instanceof Array) {\n return new JSONArray(super.get(key) as Array<JSONValue>);\n }\n throw new IllegalArgumentException('Value cannot be converted to array')\n }\n throw new BaseException(`Value for Key: '${key}' not found`);\n }\n\n public toJSON(): { [x: string]: JSONValue } {\n const obj: { [x: string]: JSONValue } = {};\n for (const [key, value] of this.entries()) {\n if (value == null) {\n obj[key] = value;\n } else if (value instanceof JSONObject || value instanceof JSONArray) {\n obj[key] = value.toJSON();\n } else {\n obj[key] = value\n }\n }\n return obj;\n }\n}\n\n\nexport class JSONArray extends Array<JSONValue> {\n\n constructor(array?: Array<JSONValue>) {\n super();\n if (array) {\n for (let item of Object.values(array)) {\n item = JSON.parse(JSON.stringify(item))\n\n if (item == null) {\n this.push(item);\n }\n else if (item.constructor == Object) {\n this.push(new JSONObject(item as { [x: string]: JSONValue }));\n }\n else if (item.constructor == Array) {\n this.push(new JSONArray(item));\n }\n else {\n this.push(item)\n }\n }\n }\n }\n\n public toJSON(): Array<JSONValue> {\n const arr: Array<JSONValue> = [];\n for (const value of this) {\n if (value == null) {\n arr.push(value);\n } else if (value instanceof JSONObject || value instanceof JSONArray) {\n arr.push(value.toJSON());\n } else {\n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AAM,CAAC,KAAK,CAAC,EAAE;AACnC,gBAAA,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAEvC,gBAAA,IAAI,IAAI,IAAI,IAAI,EAAE;AACd,oBAAA,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBACnB;AACK,qBAAA,IAAI,IAAI,CAAC,WAAW,IAAI,MAAM,EAAE;oBACjC,IAAI,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAkC,CAAC,CAAC;gBACjE;AACK,qBAAA,IAAI,IAAI,CAAC,WAAW,IAAI,KAAK,EAAE;oBAChC,IAAI,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;gBAClC;qBACK;AACD,oBAAA,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBACnB;YACJ;QACJ;IACJ;IAEO,MAAM,GAAA;QACT,MAAM,GAAG,GAAqB,EAAE;AAChC,QAAA,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE;AACtB,YAAA,IAAI,KAAK,IAAI,IAAI,EAAE;AACf,gBAAA,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;YACnB;iBAAO,IAAI,KAAK,YAAY,UAAU,IAAI,KAAK,YAAY,SAAS,EAAE;gBAClE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAC5B;iBAAO;AACH,gBAAA,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;YACnB;QACJ;AACA,QAAA,OAAO,GAAG;IACd;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"LoggingLevel.js","sources":["../../../src/types/LoggingLevel.ts"],"sourcesContent":["export enum LoggingLevel {\r\n silly = 'silly',\r\n debug = 'debug',\r\n verbose = 'verbose',\r\n info = 'info',\r\n warn = 'warn',\r\n error = 'error',\r\n}"],"names":[],"mappings":"IAAY;AAAZ,CAAA,UAAY,YAAY,EAAA;AACpB,IAAA,YAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,YAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,YAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,YAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACnB,CAAC,EAPW,YAAY,KAAZ,YAAY,GAOvB,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"LoggingLevel.js","sources":["../../../src/types/LoggingLevel.ts"],"sourcesContent":["export enum LoggingLevel {\n silly = 'silly',\n debug = 'debug',\n verbose = 'verbose',\n info = 'info',\n warn = 'warn',\n error = 'error',\n}"],"names":[],"mappings":"IAAY;AAAZ,CAAA,UAAY,YAAY,EAAA;AACpB,IAAA,YAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,YAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,YAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,YAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACnB,CAAC,EAPW,YAAY,KAAZ,YAAY,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SortOrder.js","sources":["../../../src/types/SortOrder.ts"],"sourcesContent":["/**\r\n * @export\r\n * @enum {number}\r\n */\r\nexport enum SortOrder {\r\n ASC = 'asc',\r\n DESC = 'desc'\r\n}"],"names":[],"mappings":"AAAA;;;AAGG;IACS;AAAZ,CAAA,UAAY,SAAS,EAAA;AACjB,IAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACjB,CAAC,EAHW,SAAS,KAAT,SAAS,GAGpB,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"SortOrder.js","sources":["../../../src/types/SortOrder.ts"],"sourcesContent":["/**\n * @export\n * @enum {number}\n */\nexport enum SortOrder {\n ASC = 'asc',\n DESC = 'desc'\n}"],"names":[],"mappings":"AAAA;;;AAGG;IACS;AAAZ,CAAA,UAAY,SAAS,EAAA;AACjB,IAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACjB,CAAC,EAHW,SAAS,KAAT,SAAS,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -6,7 +6,7 @@ import { IllegalArgumentException } from '../../exceptions/IllegalArgumentExcept
6
6
  * Utility class for date and time operations. Provides methods for parsing,
7
7
  * formatting, and performing calculations with dates and times.
8
8
  */
9
- class BaseDateUtil {
9
+ class DateUtil {
10
10
  static { this.ISO_8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSxxx"; }
11
11
  /**
12
12
  * Gets the current date and time in the specified time zone.
@@ -58,7 +58,7 @@ class BaseDateUtil {
58
58
  */
59
59
  static isValidDate(dateString, dateFormat) {
60
60
  try {
61
- DateUtil.readDate(dateString, dateFormat);
61
+ DateUtil.readDate(dateString, dateFormat, "UTC");
62
62
  return true;
63
63
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
64
64
  }
@@ -96,7 +96,7 @@ class BaseDateUtil {
96
96
  * @returns `true` if the year is a leap year, otherwise `false`.
97
97
  */
98
98
  static isLeapYear(year) {
99
- return isLeapYear(DateUtil.readDate(year.toString(), 'yyyy'));
99
+ return isLeapYear(DateUtil.readDate(year.toString(), 'yyyy', "UTC"));
100
100
  }
101
101
  /**
102
102
  * Converts a timestamp (in milliseconds) to a Date object.
@@ -115,43 +115,6 @@ class BaseDateUtil {
115
115
  return date.getTime();
116
116
  }
117
117
  }
118
- /**
119
- * Utility class for handling date operations in a fixed time zone.
120
- * Extends BaseDateUtil with default settings for the 'Asia/Kolkata' time zone.
121
- */
122
- class DateUtil extends BaseDateUtil {
123
- /** Default time zone used for all date operations. */
124
- static { this.TIMEZONE = 'Asia/Kolkata'; }
125
- /**
126
- * Gets the current date and time in the default time zone.
127
- * @returns Current date and time as a Date object.
128
- */
129
- static now() {
130
- return BaseDateUtil.now(this.TIMEZONE);
131
- }
132
- /**
133
- * Parses a date string into a Date object using the default time zone.
134
- * @param dateString The date string to parse.
135
- * @param dateFormat Optional format of the date string (default: ISO_8601_FORMAT).
136
- * @throws {IllegalArgumentException} If the date string is invalid.
137
- * @returns Parsed Date object.
138
- */
139
- static readDate(dateString, dateFormat) {
140
- return BaseDateUtil.readDate(dateString, dateFormat || DateUtil.ISO_8601_FORMAT, this.TIMEZONE);
141
- }
142
- static printDate(date, dateFormat = DateUtil.ISO_8601_FORMAT) {
143
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
144
- return BaseDateUtil.printDate(normalizedDate, this.TIMEZONE, dateFormat);
145
- }
146
- static getStartOfDay(date) {
147
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
148
- return BaseDateUtil.getStartOfDay(normalizedDate, this.TIMEZONE);
149
- }
150
- static getEndOfDay(date) {
151
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
152
- return BaseDateUtil.getEndOfDay(normalizedDate, this.TIMEZONE);
153
- }
154
- }
155
118
 
156
119
  export { DateUtil };
157
120
  //# sourceMappingURL=DateUtil.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateUtil.js","sources":["../../../../src/utils/date/DateUtil.ts"],"sourcesContent":["import { TZDate } from '@date-fns/tz';\r\nimport { add, compareAsc, differenceInCalendarDays, differenceInCalendarMonths, differenceInCalendarYears, Duration, endOfDay, format, isLeapYear, isValid, parse, startOfDay } from 'date-fns';\r\nimport { IllegalArgumentException } from '../../exceptions';\r\n\r\n/**\r\n * Utility class for date and time operations. Provides methods for parsing,\r\n * formatting, and performing calculations with dates and times.\r\n */\r\nclass BaseDateUtil {\r\n\r\n static readonly ISO_8601_FORMAT = \"yyyy-MM-dd'T'HH:mm:ss.SSSxxx\"\r\n\r\n /**\r\n * Gets the current date and time in the specified time zone.\r\n * @param timeZone The IANA time zone identifier.\r\n * @returns Current date and time in the specified time zone.\r\n */\r\n protected static now(timeZone: string): Date {\r\n return new TZDate(new Date(), timeZone);\r\n }\r\n\r\n /**\r\n * Gets the current time in milliseconds since the Unix epoch.\r\n * @returns Current time in milliseconds.\r\n */\r\n static nowInMillis(): number {\r\n return Date.now();\r\n }\r\n\r\n /**\r\n * Parses a date string into a Date object.\r\n * @param dateString The date string to parse.\r\n * @param dateFormat The format of the date string (default: ISO_8601_FORMAT).\r\n * @param timeZone The IANA time zone identifier.\r\n * @throws {IllegalArgumentException} If the date string is invalid.\r\n * @returns Parsed Date object.\r\n */\r\n protected static readDate(dateString: string, dateFormat = this.ISO_8601_FORMAT, timeZone: string): Date {\r\n const date = parse(dateString, dateFormat, TZDate.tz(timeZone));\r\n if (!isValid(date)) {\r\n throw new IllegalArgumentException('Invalid date string or date format');\r\n }\r\n return date;\r\n }\r\n\r\n /**\r\n * Formats a Date or timestamp into a string.\r\n * @param date The date or timestamp to format.\r\n * @param timeZone The IANA time zone identifier.\r\n * @param dateFormat The desired output format (default: ISO_8601_FORMAT).\r\n * @returns Formatted date string.\r\n */\r\n protected static printDate(date: Date, timeZone: string, dateFormat?: string): string;\r\n protected static printDate(date: number, timeZone: string, dateFormat?: string): string;\r\n protected static printDate(date: Date | number, timeZone: string, dateFormat: string = this.ISO_8601_FORMAT): string {\r\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\r\n return format(new TZDate(normalizedDate, timeZone), dateFormat);\r\n }\r\n\r\n /**\r\n * Gets the start of the day for a given date or timestamp.\r\n * @param date The date or timestamp to calculate from.\r\n * @param timeZone The IANA time zone identifier.\r\n * @returns The start of the day as a Date object.\r\n */\r\n protected static getStartOfDay(date: Date, timeZone: string): Date;\r\n protected static getStartOfDay(date: number, timeZone: string): Date;\r\n protected static getStartOfDay(date: Date | number, timeZone: string): Date {\r\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\r\n return startOfDay(new TZDate(normalizedDate, timeZone));\r\n }\r\n\r\n /**\r\n * Gets the end of the day for a given date or timestamp.\r\n * @param date The date or timestamp to calculate from.\r\n * @param timeZone The IANA time zone identifier.\r\n * @returns The end of the day as a Date object.\r\n */\r\n protected static getEndOfDay(date: Date, timeZone: string): Date;\r\n protected static getEndOfDay(date: number, timeZone: string): Date;\r\n protected static getEndOfDay(date: Date | number, timeZone: string): Date {\r\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\r\n return endOfDay(new TZDate(normalizedDate, timeZone));\r\n }\r\n\r\n /**\r\n * Checks if a date string is valid according to the specified format.\r\n * @param dateString The date string to validate.\r\n * @param dateFormat Optional date format (default: ISO_8601_FORMAT).\r\n * @returns True if the date is valid, false otherwise.\r\n */\r\n static isValidDate(dateString: string, dateFormat?: string): boolean {\r\n try {\r\n DateUtil.readDate(dateString, dateFormat);\r\n return true;\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Calculates the absolute number of days between two dates or timestamps.\r\n * @param firstDate The first date or timestamp.\r\n * @param secondDate The second date or timestamp.\r\n * @returns Number of days between the two dates.\r\n */\r\n static daysInBetween(firstDate: Date, secondDate: Date): number;\r\n static daysInBetween(firstDate: number, secondDate: number): number;\r\n static daysInBetween(firstDate: Date | number, secondDate: Date | number): number {\r\n const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;\r\n const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;\r\n return Math.abs(differenceInCalendarDays(first, second));\r\n }\r\n\r\n /**\r\n * Calculates the absolute number of months between two dates or timestamps.\r\n * @param firstDate The first date or timestamp.\r\n * @param secondDate The second date or timestamp.\r\n * @returns The number of months between the two dates.\r\n */\r\n static monthsInBetween(firstDate: Date, secondDate: Date): number;\r\n static monthsInBetween(firstDate: number, secondDate: number): number;\r\n static monthsInBetween(firstDate: Date | number, secondDate: Date | number): number {\r\n const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;\r\n const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;\r\n return Math.abs(differenceInCalendarMonths(first, second));\r\n }\r\n\r\n /**\r\n * Calculates the absolute number of years between two dates or timestamps.\r\n * @param firstDate The first date or timestamp.\r\n * @param secondDate The second date or timestamp.\r\n * @returns The number of years between the two dates.\r\n */\r\n static yearsInBetween(firstDate: Date, secondDate: Date): number;\r\n static yearsInBetween(firstDate: number, secondDate: number): number;\r\n static yearsInBetween(firstDate: Date | number, secondDate: Date | number): number {\r\n const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;\r\n const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;\r\n return Math.abs(differenceInCalendarYears(first, second));\r\n }\r\n\r\n /**\r\n * Compares two dates or timestamps.\r\n * @param firstDate The first date or timestamp.\r\n * @param secondDate The second date or timestamp.\r\n * @returns `-1` if the first date is earlier, `1` if it is later, or `0` if the two dates are equal.\r\n */\r\n static compareDates(firstDate: Date, secondDate: Date): -1 | 0 | 1;\r\n static compareDates(firstDate: number, secondDate: number): -1 | 0 | 1;\r\n static compareDates(firstDate: Date | number, secondDate: Date | number): -1 | 0 | 1 {\r\n const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;\r\n const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;\r\n\r\n return compareAsc(first, second) as -1 | 0 | 1;\r\n }\r\n\r\n /**\r\n * Adds a duration (e.g., days, months, years) to a given date or timestamp.\r\n * @param date The base date or timestamp to which the duration will be added.\r\n * @param duration An object specifying the duration (e.g., `{ days: 1, months: 2 }`).\r\n * @returns A new Date object with the duration added.\r\n */\r\n static addDuration(date: Date, duration: Duration): Date;\r\n static addDuration(date: number, duration: Duration): Date;\r\n static addDuration(date: Date | number, duration: Duration): Date {\r\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\r\n return add(normalizedDate, duration);\r\n }\r\n\r\n /**\r\n * Determines whether a given year is a leap year.\r\n * @param year The year to check.\r\n * @returns `true` if the year is a leap year, otherwise `false`.\r\n */\r\n static isLeapYear(year: number): boolean {\r\n return isLeapYear(DateUtil.readDate(year.toString(), 'yyyy'));\r\n }\r\n\r\n\r\n /**\r\n * Converts a timestamp (in milliseconds) to a Date object.\r\n * @param milliseconds The timestamp in milliseconds since the Unix epoch.\r\n * @returns A Date object representing the provided timestamp.\r\n */\r\n static fromMillis(milliseconds: number): Date {\r\n return new Date(milliseconds);\r\n }\r\n\r\n /**\r\n * Converts a Date object to a timestamp (in milliseconds).\r\n * @param date The Date object to convert.\r\n * @returns The timestamp in milliseconds since the Unix epoch.\r\n */\r\n static toMillis(date: Date): number {\r\n return date.getTime();\r\n }\r\n}\r\n\r\n/**\r\n * Utility class for handling date operations in a fixed time zone.\r\n * Extends BaseDateUtil with default settings for the 'Asia/Kolkata' time zone.\r\n */\r\nexport class DateUtil extends BaseDateUtil {\r\n /** Default time zone used for all date operations. */\r\n static readonly TIMEZONE = 'Asia/Kolkata';\r\n /**\r\n * Gets the current date and time in the default time zone.\r\n * @returns Current date and time as a Date object.\r\n */\r\n static override now(): Date {\r\n return BaseDateUtil.now(this.TIMEZONE);\r\n }\r\n\r\n /**\r\n * Parses a date string into a Date object using the default time zone.\r\n * @param dateString The date string to parse.\r\n * @param dateFormat Optional format of the date string (default: ISO_8601_FORMAT).\r\n * @throws {IllegalArgumentException} If the date string is invalid.\r\n * @returns Parsed Date object.\r\n */\r\n static override readDate(dateString: string, dateFormat?: string): Date {\r\n return BaseDateUtil.readDate(dateString, dateFormat || DateUtil.ISO_8601_FORMAT, this.TIMEZONE);\r\n }\r\n\r\n /**\r\n * Formats a Date or timestamp into a string using the default time zone.\r\n * @param date The date or timestamp to format.\r\n * @param dateFormat Optional desired output format (default: ISO_8601_FORMAT).\r\n * @returns Formatted date string.\r\n */\r\n static override printDate(date: Date, dateFormat?: string): string;\r\n static override printDate(date: number, dateFormat?: string): string;\r\n static override printDate(date: Date | number, dateFormat = DateUtil.ISO_8601_FORMAT): string {\r\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\r\n return BaseDateUtil.printDate(normalizedDate, this.TIMEZONE, dateFormat);\r\n }\r\n\r\n /**\r\n * Gets the start of the day for a given date or timestamp using the default time zone.\r\n * @param date The date or timestamp to calculate from.\r\n * @returns A Date object representing the start of the day.\r\n */\r\n static override getStartOfDay(date: Date): Date;\r\n static override getStartOfDay(date: number): Date;\r\n static override getStartOfDay(date: Date | number): Date {\r\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\r\n return BaseDateUtil.getStartOfDay(normalizedDate, this.TIMEZONE);\r\n }\r\n\r\n /**\r\n * Gets the end of the day for a given date or timestamp using the default time zone.\r\n * @param date The date or timestamp to calculate from.\r\n * @returns A Date object representing the end of the day.\r\n */\r\n static override getEndOfDay(date: Date): Date;\r\n static override getEndOfDay(date: number): Date;\r\n static override getEndOfDay(date: Date | number): Date {\r\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\r\n return BaseDateUtil.getEndOfDay(normalizedDate, this.TIMEZONE);\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;AAIA;;;AAGG;AACH,MAAM,YAAY,CAAA;aAEE,IAAe,CAAA,eAAA,GAAG,8BAA8B,CAAA;AAEhE;;;;AAIG;IACO,OAAO,GAAG,CAAC,QAAgB,EAAA;QACjC,OAAO,IAAI,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,QAAQ,CAAC;;AAG3C;;;AAGG;AACH,IAAA,OAAO,WAAW,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,GAAG,EAAE;;AAGrB;;;;;;;AAOG;IACO,OAAO,QAAQ,CAAC,UAAkB,EAAE,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,QAAgB,EAAA;AAC7F,QAAA,MAAM,IAAI,GAAG,KAAK,CAAC,UAA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AAC,GAAG,IAAI;AACvE,QAAA,OAAO,YAAY,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;;IAU5E,OAAgB,aAAa,CAAC,IAAmB,EAAA;AAC7C,QAAA,MAAM,cAAc,GAAG,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI;QACvE,OAAO,YAAY,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC;;IAUpE,OAAgB,WAAW,CAAC,IAAmB,EAAA;AAC3C,QAAA,MAAM,cAAc,GAAG,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI;QACvE,OAAO,YAAY,CAAC,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC;;;;;;"}
1
+ {"version":3,"file":"DateUtil.js","sources":["../../../../src/utils/date/DateUtil.ts"],"sourcesContent":["import { TZDate } from '@date-fns/tz';\nimport { add, compareAsc, differenceInCalendarDays, differenceInCalendarMonths, differenceInCalendarYears, Duration, endOfDay, format, isLeapYear, isValid, parse, startOfDay } from 'date-fns';\nimport { IllegalArgumentException } from '../../exceptions';\n\n/**\n * Utility class for date and time operations. Provides methods for parsing,\n * formatting, and performing calculations with dates and times.\n */\nexport class DateUtil {\n\n static readonly ISO_8601_FORMAT = \"yyyy-MM-dd'T'HH:mm:ss.SSSxxx\"\n\n /**\n * Gets the current date and time in the specified time zone.\n * @param timeZone The IANA time zone identifier.\n * @returns Current date and time in the specified time zone.\n */\n static now(timeZone: string): Date {\n return new TZDate(new Date(), timeZone);\n }\n\n /**\n * Gets the current time in milliseconds since the Unix epoch.\n * @returns Current time in milliseconds.\n */\n static nowInMillis(): number {\n return Date.now();\n }\n\n /**\n * Parses a date string into a Date object.\n * @param dateString The date string to parse.\n * @param dateFormat The format of the date string (default: ISO_8601_FORMAT).\n * @param timeZone The IANA time zone identifier.\n * @throws {IllegalArgumentException} If the date string is invalid.\n * @returns Parsed Date object.\n */\n static readDate(dateString: string, dateFormat = this.ISO_8601_FORMAT, timeZone: string): Date {\n const date = parse(dateString, dateFormat, TZDate.tz(timeZone));\n if (!isValid(date)) {\n throw new IllegalArgumentException('Invalid date string or date format');\n }\n return date;\n }\n\n /**\n * Formats a Date or timestamp into a string.\n * @param date The date or timestamp to format.\n * @param timeZone The IANA time zone identifier.\n * @param dateFormat The desired output format (default: ISO_8601_FORMAT).\n * @returns Formatted date string.\n */\n static printDate(date: Date, timeZone: string, dateFormat?: string): string;\n static printDate(date: number, timeZone: string, dateFormat?: string): string;\n static printDate(date: Date | number, timeZone: string, dateFormat: string = this.ISO_8601_FORMAT): string {\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\n return format(new TZDate(normalizedDate, timeZone), dateFormat);\n }\n\n /**\n * Gets the start of the day for a given date or timestamp.\n * @param date The date or timestamp to calculate from.\n * @param timeZone The IANA time zone identifier.\n * @returns The start of the day as a Date object.\n */\n static getStartOfDay(date: Date, timeZone: string): Date;\n static getStartOfDay(date: number, timeZone: string): Date;\n static getStartOfDay(date: Date | number, timeZone: string): Date {\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\n return startOfDay(new TZDate(normalizedDate, timeZone));\n }\n\n /**\n * Gets the end of the day for a given date or timestamp.\n * @param date The date or timestamp to calculate from.\n * @param timeZone The IANA time zone identifier.\n * @returns The end of the day as a Date object.\n */\n static getEndOfDay(date: Date, timeZone: string): Date;\n static getEndOfDay(date: number, timeZone: string): Date;\n static getEndOfDay(date: Date | number, timeZone: string): Date {\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\n return endOfDay(new TZDate(normalizedDate, timeZone));\n }\n\n /**\n * Checks if a date string is valid according to the specified format.\n * @param dateString The date string to validate.\n * @param dateFormat Optional date format (default: ISO_8601_FORMAT).\n * @returns True if the date is valid, false otherwise.\n */\n static isValidDate(dateString: string, dateFormat?: string): boolean {\n try {\n DateUtil.readDate(dateString, dateFormat, \"UTC\");\n return true;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (error) {\n return false;\n }\n }\n\n /**\n * Calculates the absolute number of days between two dates or timestamps.\n * @param firstDate The first date or timestamp.\n * @param secondDate The second date or timestamp.\n * @returns Number of days between the two dates.\n */\n static daysInBetween(firstDate: Date, secondDate: Date): number;\n static daysInBetween(firstDate: number, secondDate: number): number;\n static daysInBetween(firstDate: Date | number, secondDate: Date | number): number {\n const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;\n const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;\n return Math.abs(differenceInCalendarDays(first, second));\n }\n\n /**\n * Calculates the absolute number of months between two dates or timestamps.\n * @param firstDate The first date or timestamp.\n * @param secondDate The second date or timestamp.\n * @returns The number of months between the two dates.\n */\n static monthsInBetween(firstDate: Date, secondDate: Date): number;\n static monthsInBetween(firstDate: number, secondDate: number): number;\n static monthsInBetween(firstDate: Date | number, secondDate: Date | number): number {\n const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;\n const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;\n return Math.abs(differenceInCalendarMonths(first, second));\n }\n\n /**\n * Calculates the absolute number of years between two dates or timestamps.\n * @param firstDate The first date or timestamp.\n * @param secondDate The second date or timestamp.\n * @returns The number of years between the two dates.\n */\n static yearsInBetween(firstDate: Date, secondDate: Date): number;\n static yearsInBetween(firstDate: number, secondDate: number): number;\n static yearsInBetween(firstDate: Date | number, secondDate: Date | number): number {\n const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;\n const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;\n return Math.abs(differenceInCalendarYears(first, second));\n }\n\n /**\n * Compares two dates or timestamps.\n * @param firstDate The first date or timestamp.\n * @param secondDate The second date or timestamp.\n * @returns `-1` if the first date is earlier, `1` if it is later, or `0` if the two dates are equal.\n */\n static compareDates(firstDate: Date, secondDate: Date): -1 | 0 | 1;\n static compareDates(firstDate: number, secondDate: number): -1 | 0 | 1;\n static compareDates(firstDate: Date | number, secondDate: Date | number): -1 | 0 | 1 {\n const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;\n const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;\n\n return compareAsc(first, second) as -1 | 0 | 1;\n }\n\n /**\n * Adds a duration (e.g., days, months, years) to a given date or timestamp.\n * @param date The base date or timestamp to which the duration will be added.\n * @param duration An object specifying the duration (e.g., `{ days: 1, months: 2 }`).\n * @returns A new Date object with the duration added.\n */\n static addDuration(date: Date, duration: Duration): Date;\n static addDuration(date: number, duration: Duration): Date;\n static addDuration(date: Date | number, duration: Duration): Date {\n const normalizedDate = typeof date === 'number' ? new Date(date) : date;\n return add(normalizedDate, duration);\n }\n\n /**\n * Determines whether a given year is a leap year.\n * @param year The year to check.\n * @returns `true` if the year is a leap year, otherwise `false`.\n */\n static isLeapYear(year: number): boolean {\n return isLeapYear(DateUtil.readDate(year.toString(), 'yyyy', \"UTC\"));\n }\n\n\n /**\n * Converts a timestamp (in milliseconds) to a Date object.\n * @param milliseconds The timestamp in milliseconds since the Unix epoch.\n * @returns A Date object representing the provided timestamp.\n */\n static fromMillis(milliseconds: number): Date {\n return new Date(milliseconds);\n }\n\n /**\n * Converts a Date object to a timestamp (in milliseconds).\n * @param date The Date object to convert.\n * @returns The timestamp in milliseconds since the Unix epoch.\n */\n static toMillis(date: Date): number {\n return date.getTime();\n }\n}\n"],"names":[],"mappings":";;;;AAIA;;;AAGG;MACU,QAAQ,CAAA;aAED,IAAA,CAAA,eAAe,GAAG,8BAA8B,CAAA;AAEhE;;;;AAIG;IACH,OAAO,GAAG,CAAC,QAAgB,EAAA;QACvB,OAAO,IAAI,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,QAAQ,CAAC;IAC3C;AAEA;;;AAGG;AACH,IAAA,OAAO,WAAW,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,GAAG,EAAE;IACrB;AAEA;;;;;;;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E,UAAyB,EAAA;AACnE,QAAA,MAAM,KAAK,GAAG,OAAO,SAAS,KAAK,QAAQ,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,SAAS;AAC7E,QAAA,MAAM,MAAM,GAAG,OAAO,UAAU,KAAK,QAAQ,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,UAAU;AAEjF,QAAA,OAAO,UAAU,CAAC,KAAK,EAAE,MAAM,CAAe;IAClD;AAUA,IAAA,OAAO,WAAW,CAAC,IAAmB,EAAE,QAAkB,EAAA;AACtD,QAAA,MAAM,cAAc,GAAG,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI;AACvE,QAAA,OAAO,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC;IACxC;AAEA;;;;AAIG;IACH,OAAO,UAAU,CAAC,IAAY,EAAA;AAC1B,QAAA,OAAO,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACxE;AAGA;;;;AAIG;IACH,OAAO,UAAU,CAAC,YAAoB,EAAA;AAClC,QAAA,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC;IACjC;AAEA;;;;AAIG;IACH,OAAO,QAAQ,CAAC,IAAU,EAAA;AACtB,QAAA,OAAO,IAAI,CAAC,OAAO,EAAE;IACzB;;;;;"}
@@ -6,7 +6,7 @@ export { HTTPException } from './src/exceptions/HTTPException.js';
6
6
  export { IllegalArgumentException } from './src/exceptions/IllegalArgumentException.js';
7
7
  export { UnauthorizedException } from './src/exceptions/UnauthorizedException.js';
8
8
  export { ConverterException } from './src/exceptions/ConverterException.js';
9
- export { LoggerFactory, loggers } from './src/logger/LoggerFactory.js';
9
+ export { LoggerFactory } from './src/logger/LoggerFactory.js';
10
10
  export { JSONArray, JSONObject, JSONValue } from './src/types/JSONObject.js';
11
11
  export { LoggingLevel } from './src/types/LoggingLevel.js';
12
12
  export { SortOrder } from './src/types/SortOrder.js';
@@ -4,13 +4,7 @@
4
4
  */
5
5
  declare class BaseException extends Error {
6
6
  code?: number;
7
- cause?: unknown;
8
7
  constructor(message: string, cause?: unknown, code?: number);
9
- /**
10
- * Retrieves the full stack trace of the exception, including causes.
11
- * @returns A string representation of the stack trace.
12
- */
13
- getStackTrace(): string;
14
8
  }
15
9
 
16
10
  export { BaseException };