@org-quicko/core 2.0.4 → 2.0.6

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 (49) hide show
  1. package/README.md +56 -8
  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.map +1 -1
  5. package/dist/browser/exceptions/ClientException.js.map +1 -1
  6. package/dist/browser/exceptions/ConverterException.js.map +1 -1
  7. package/dist/browser/exceptions/ForbiddenAccessException.js.map +1 -1
  8. package/dist/browser/exceptions/HTTPException.js.map +1 -1
  9. package/dist/browser/exceptions/IllegalArgumentException.js.map +1 -1
  10. package/dist/browser/exceptions/UnauthorizedException.js.map +1 -1
  11. package/dist/browser/types/JSONObject.js.map +1 -1
  12. package/dist/browser/types/LoggingLevel.js.map +1 -1
  13. package/dist/browser/types/SortOrder.js.map +1 -1
  14. package/dist/browser/utils/date/DateUtil.js +32 -25
  15. package/dist/browser/utils/date/DateUtil.js.map +1 -1
  16. package/dist/cjs/beans/BaseObject.cjs.map +1 -1
  17. package/dist/cjs/exceptions/BadRequestException.cjs.map +1 -1
  18. package/dist/cjs/exceptions/BaseException.cjs.map +1 -1
  19. package/dist/cjs/exceptions/ClientException.cjs.map +1 -1
  20. package/dist/cjs/exceptions/ConverterException.cjs.map +1 -1
  21. package/dist/cjs/exceptions/ForbiddenAccessException.cjs.map +1 -1
  22. package/dist/cjs/exceptions/HTTPException.cjs.map +1 -1
  23. package/dist/cjs/exceptions/IllegalArgumentException.cjs.map +1 -1
  24. package/dist/cjs/exceptions/UnauthorizedException.cjs.map +1 -1
  25. package/dist/cjs/logger/LoggerFactory.cjs.map +1 -1
  26. package/dist/cjs/logger/format/ErrorFormat.cjs.map +1 -1
  27. package/dist/cjs/types/JSONObject.cjs.map +1 -1
  28. package/dist/cjs/types/LoggingLevel.cjs.map +1 -1
  29. package/dist/cjs/types/SortOrder.cjs.map +1 -1
  30. package/dist/cjs/utils/date/DateUtil.cjs +32 -25
  31. package/dist/cjs/utils/date/DateUtil.cjs.map +1 -1
  32. package/dist/esm/beans/BaseObject.js.map +1 -1
  33. package/dist/esm/exceptions/BadRequestException.js.map +1 -1
  34. package/dist/esm/exceptions/BaseException.js.map +1 -1
  35. package/dist/esm/exceptions/ClientException.js.map +1 -1
  36. package/dist/esm/exceptions/ConverterException.js.map +1 -1
  37. package/dist/esm/exceptions/ForbiddenAccessException.js.map +1 -1
  38. package/dist/esm/exceptions/HTTPException.js.map +1 -1
  39. package/dist/esm/exceptions/IllegalArgumentException.js.map +1 -1
  40. package/dist/esm/exceptions/UnauthorizedException.js.map +1 -1
  41. package/dist/esm/logger/LoggerFactory.js.map +1 -1
  42. package/dist/esm/logger/format/ErrorFormat.js.map +1 -1
  43. package/dist/esm/types/JSONObject.js.map +1 -1
  44. package/dist/esm/types/LoggingLevel.js.map +1 -1
  45. package/dist/esm/types/SortOrder.js.map +1 -1
  46. package/dist/esm/utils/date/DateUtil.js +32 -25
  47. package/dist/esm/utils/date/DateUtil.js.map +1 -1
  48. package/dist/types/src/utils/date/DateUtil.d.ts +39 -17
  49. package/package.json +123 -140
@@ -1 +1 @@
1
- {"version":3,"file":"JSONObject.cjs","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 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 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 i = 0; i < array.length; i++) {\r\n let item = array[i];\r\n\r\n if (item === undefined) {\r\n this.push(undefined);\r\n continue;\r\n }\r\n\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":["IllegalArgumentException","BaseException"],"mappings":";;;;;AAWM,MAAO,UAAW,SAAQ,GAAsB,CAAA;AAElD,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,KAAK,SAAS,EAAE;AAEpC,qBAAA,IAAI,KAAK,CAAC,WAAW,IAAI,MAAM,EAAE;oBACpC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,UAAU,CAAC,KAAmC,CAAC,CAAC;gBACtE;AAAO,qBAAA,IAAI,KAAK,CAAC,WAAW,IAAI,K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AAC,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
+ {"version":3,"file":"JSONObject.cjs","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 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 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 i = 0; i < array.length; i++) {\n let item = array[i];\n\n if (item === undefined) {\n this.push(undefined);\n continue;\n }\n\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 arr.push(value)\n }\n }\n return arr;\n }\n}"],"names":["IllegalArgumentException","BaseException"],"mappings":";;;;;AAWM,MAAO,UAAW,SAAQ,GAAsB,CAAA;AAElD,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,KAAK,SAAS,EAAE;AAEpC,qBAAA,IAAI,KAAK,CAAC,WAAW,IAAI,MAAM,EAAE;oBACpC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,UAAU,CAAC,KAAmC,CAAC,CAAC;gBACtE;AAAO,qBAAA,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,EAAE;oBACnC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;gBACvC;qBAAO;AACH,oBAAA,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;gBACxB;YACJ;QACJ;IACJ;AAEA,IAAA,aAAa,CAAC,GAAW,EAAA;AACrB,QAAA,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAChB,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,UAAU,EAAE;AACtC,gBAAA,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAe;YACvC;iBAAO;AACH,gBAAA,MAAM,IAAIA,iDAAwB,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Y,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.cjs","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":["LoggingLevel"],"mappings":";;AAAYA;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,EAPWA,oBAAY,KAAZA,oBAAY,GAAA,EAAA,CAAA,CAAA;;"}
1
+ {"version":3,"file":"LoggingLevel.cjs","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":["LoggingLevel"],"mappings":";;AAAYA;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,EAPWA,oBAAY,KAAZA,oBAAY,GAAA,EAAA,CAAA,CAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SortOrder.cjs","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":["SortOrder"],"mappings":";;AAAA;;;AAGG;AACSA;AAAZ,CAAA,UAAY,SAAS,EAAA;AACjB,IAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACjB,CAAC,EAHWA,iBAAS,KAATA,iBAAS,GAAA,EAAA,CAAA,CAAA;;"}
1
+ {"version":3,"file":"SortOrder.cjs","sources":["../../../src/types/SortOrder.ts"],"sourcesContent":["/**\n * @export\n * @enum {number}\n */\nexport enum SortOrder {\n ASC = 'asc',\n DESC = 'desc'\n}"],"names":["SortOrder"],"mappings":";;AAAA;;;AAGG;AACSA;AAAZ,CAAA,UAAY,SAAS,EAAA;AACjB,IAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACjB,CAAC,EAHWA,iBAAS,KAATA,iBAAS,GAAA,EAAA,CAAA,CAAA;;"}
@@ -10,6 +10,7 @@ var IllegalArgumentException = require('../../exceptions/IllegalArgumentExceptio
10
10
  */
11
11
  class DateUtil {
12
12
  static { this.ISO_8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSxxx"; }
13
+ static { this.TIMEZONE = "UTC"; }
13
14
  /**
14
15
  * Gets the current date and time in the specified time zone.
15
16
  * @param timeZone The IANA time zone identifier.
@@ -41,15 +42,15 @@ class DateUtil {
41
42
  return date;
42
43
  }
43
44
  static printDate(date, timeZone, dateFormat = this.ISO_8601_FORMAT) {
44
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
45
+ const normalizedDate = this.normalizeDate(date);
45
46
  return dateFns.format(new tz.TZDate(normalizedDate, timeZone), dateFormat);
46
47
  }
47
48
  static getStartOfDay(date, timeZone) {
48
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
49
+ const normalizedDate = this.normalizeDate(date);
49
50
  return dateFns.startOfDay(new tz.TZDate(normalizedDate, timeZone));
50
51
  }
51
52
  static getEndOfDay(date, timeZone) {
52
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
53
+ const normalizedDate = this.normalizeDate(date);
53
54
  return dateFns.endOfDay(new tz.TZDate(normalizedDate, timeZone));
54
55
  }
55
56
  /**
@@ -62,45 +63,48 @@ class DateUtil {
62
63
  try {
63
64
  DateUtil.readDate(dateString, dateFormat, "UTC");
64
65
  return true;
65
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
66
66
  }
67
67
  catch (error) {
68
68
  return false;
69
69
  }
70
70
  }
71
- static daysInBetween(firstDate, secondDate) {
72
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
73
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
74
- return Math.abs(dateFns.differenceInCalendarDays(first, second));
71
+ static daysInBetween(firstDate, secondDate, timeZone) {
72
+ const first = this.normalizeDate(firstDate);
73
+ const second = this.normalizeDate(secondDate);
74
+ const effectiveTimeZone = timeZone || this.TIMEZONE;
75
+ return Math.abs(dateFns.differenceInCalendarDays(new tz.TZDate(first, effectiveTimeZone), new tz.TZDate(second, effectiveTimeZone)));
75
76
  }
76
- static monthsInBetween(firstDate, secondDate) {
77
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
78
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
79
- return Math.abs(dateFns.differenceInCalendarMonths(first, second));
77
+ static monthsInBetween(firstDate, secondDate, timeZone) {
78
+ const first = this.normalizeDate(firstDate);
79
+ const second = this.normalizeDate(secondDate);
80
+ const effectiveTimeZone = timeZone || this.TIMEZONE;
81
+ return Math.abs(dateFns.differenceInCalendarMonths(new tz.TZDate(first, effectiveTimeZone), new tz.TZDate(second, effectiveTimeZone)));
80
82
  }
81
- static yearsInBetween(firstDate, secondDate) {
82
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
83
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
84
- return Math.abs(dateFns.differenceInCalendarYears(first, second));
83
+ static yearsInBetween(firstDate, secondDate, timeZone) {
84
+ const first = this.normalizeDate(firstDate);
85
+ const second = this.normalizeDate(secondDate);
86
+ const effectiveTimeZone = timeZone || this.TIMEZONE;
87
+ return Math.abs(dateFns.differenceInCalendarYears(new tz.TZDate(first, effectiveTimeZone), new tz.TZDate(second, effectiveTimeZone)));
85
88
  }
86
89
  static hoursInBetween(firstDate, secondDate) {
87
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
88
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
90
+ const first = this.normalizeDate(firstDate);
91
+ const second = this.normalizeDate(secondDate);
89
92
  return Math.abs(dateFns.differenceInHours(first, second));
90
93
  }
91
94
  static secondsInBetween(firstDate, secondDate) {
92
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
93
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
95
+ const first = this.normalizeDate(firstDate);
96
+ const second = this.normalizeDate(secondDate);
94
97
  return Math.abs(dateFns.differenceInSeconds(first, second));
95
98
  }
96
99
  static compareDates(firstDate, secondDate) {
97
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
98
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
100
+ const first = this.normalizeDate(firstDate);
101
+ const second = this.normalizeDate(secondDate);
99
102
  return dateFns.compareAsc(first, second);
100
103
  }
101
- static addDuration(date, duration) {
102
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
103
- return dateFns.add(normalizedDate, duration);
104
+ static addDuration(date, duration, timeZone) {
105
+ const normalizedDate = this.normalizeDate(date);
106
+ const effectiveTimeZone = timeZone || this.TIMEZONE;
107
+ return dateFns.add(new tz.TZDate(normalizedDate, effectiveTimeZone), duration);
104
108
  }
105
109
  /**
106
110
  * Determines whether a given year is a leap year.
@@ -118,6 +122,9 @@ class DateUtil {
118
122
  static fromMillis(milliseconds) {
119
123
  return new Date(milliseconds);
120
124
  }
125
+ static normalizeDate(date) {
126
+ return typeof date === 'number' ? this.fromMillis(date) : date;
127
+ }
121
128
  /**
122
129
  * Converts a Date object to a timestamp (in milliseconds).
123
130
  * @param date The Date object to convert.
@@ -1 +1 @@
1
- {"version":3,"file":"DateUtil.cjs","sources":["../../../../src/utils/date/DateUtil.ts"],"sourcesContent":["import { TZDate } from '@date-fns/tz';\r\nimport { add, compareAsc, differenceInCalendarDays, differenceInCalendarMonths, differenceInCalendarYears, differenceInHours, differenceInSeconds, 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\nexport class DateUtil {\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 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 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 static printDate(date: Date, timeZone: string, dateFormat?: string): string;\r\n static printDate(date: number, timeZone: string, dateFormat?: string): string;\r\n 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 static getStartOfDay(date: Date, timeZone: string): Date;\r\n static getStartOfDay(date: number, timeZone: string): Date;\r\n 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 static getEndOfDay(date: Date, timeZone: string): Date;\r\n static getEndOfDay(date: number, timeZone: string): Date;\r\n 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, \"UTC\");\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 * Calculates the absolute number of hours 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 hours between the two dates.\r\n */\r\n static hoursInBetween(firstDate: Date, secondDate: Date): number;\r\n static hoursInBetween(firstDate: number, secondDate: number): number;\r\n static hoursInBetween(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(differenceInHours(first, second));\r\n }\r\n\r\n /**\r\n * Calculates the absolute number of seconds 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 seconds between the two dates.\r\n */\r\n static secondsInBetween(firstDate: Date, secondDate: Date): number;\r\n static secondsInBetween(firstDate: number, secondDate: number): number;\r\n static secondsInBetween(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(differenceInSeconds(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', \"UTC\"));\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"],"names":["TZDate","parse","isValid","IllegalArgumentException","format","startOfDay","endOfDay","differenceInCalendarDays","differenceInCalendarMonths","differenceInCalendarYears","differenceInHours","differenceInSeconds","compareAsc","add","isLeapYear"],"mappings":";;;;;;AAIA;;;AAGG;MACU,QAAQ,CAAA;aAED,IAAA,CAAA,eAAe,GAAG,8BAA8B,CAAA;AAEhE;;;;AAIG;IACH,OAAO,GAAG,CAAC,QAAgB,EAAA;QACvB,OAAO,IAAIA,SAAM,CAAC,IAAI,IAAI,EAAE,EAAE,QAAQ,CAAC;IAC3C;AAEA;;;AAGG;AACH,IAAA,OAAO,WAAW,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,GAAG,EAAE;IACrB;AAEA;;;;;;;AAOG;IAC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IG;IACH,OAAO,UAAU,CAAC,IAAY,EAAA;AAC1B,QAAA,OAAOC,kBAAU,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;;;;;"}
1
+ {"version":3,"file":"DateUtil.cjs","sources":["../../../../src/utils/date/DateUtil.ts"],"sourcesContent":["import { TZDate } from '@date-fns/tz';\nimport { add, compareAsc, differenceInCalendarDays, differenceInCalendarMonths, differenceInCalendarYears, differenceInHours, differenceInSeconds, 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 static readonly TIMEZONE = \"UTC\"\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 = this.normalizeDate(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 = this.normalizeDate(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 = this.normalizeDate(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 } catch (error) {\n return false;\n }\n }\n\n /**\n * Calculates the absolute number of calendar days between two dates or timestamps.\n * Since day boundaries depend on a calendar, callers can optionally provide a time zone\n * so the same pair of instants is interpreted consistently across machines.\n *\n * @param firstDate The first date or timestamp.\n * @param secondDate The second date or timestamp.\n * @param timeZone Optional IANA time zone identifier used for calendar comparisons.\n * @returns Number of days between the two dates.\n */\n static daysInBetween(firstDate: Date, secondDate: Date, timeZone?: string): number;\n static daysInBetween(firstDate: number, secondDate: number, timeZone?: string): number;\n static daysInBetween(firstDate: Date | number, secondDate: Date | number, timeZone?: string): number {\n const first = this.normalizeDate(firstDate);\n const second = this.normalizeDate(secondDate);\n const effectiveTimeZone = timeZone || this.TIMEZONE;\n return Math.abs(\n differenceInCalendarDays(\n new TZDate(first, effectiveTimeZone),\n new TZDate(second, effectiveTimeZone),\n )\n );\n }\n\n /**\n * Calculates the absolute number of calendar months between two dates or timestamps.\n * Since month boundaries depend on a calendar, callers can optionally provide a time zone\n * so the same pair of instants is interpreted consistently across machines.\n *\n * @param firstDate The first date or timestamp.\n * @param secondDate The second date or timestamp.\n * @param timeZone Optional IANA time zone identifier used for calendar comparisons.\n * @returns The number of months between the two dates.\n */\n static monthsInBetween(firstDate: Date, secondDate: Date, timeZone?: string): number;\n static monthsInBetween(firstDate: number, secondDate: number, timeZone?: string): number;\n static monthsInBetween(firstDate: Date | number, secondDate: Date | number, timeZone?: string): number {\n const first = this.normalizeDate(firstDate);\n const second = this.normalizeDate(secondDate);\n const effectiveTimeZone = timeZone || this.TIMEZONE;\n return Math.abs(\n differenceInCalendarMonths(\n new TZDate(first, effectiveTimeZone),\n new TZDate(second, effectiveTimeZone),\n )\n );\n }\n\n /**\n * Calculates the absolute number of calendar years between two dates or timestamps.\n * Since year boundaries depend on a calendar, callers can optionally provide a time zone\n * so the same pair of instants is interpreted consistently across machines.\n *\n * @param firstDate The first date or timestamp.\n * @param secondDate The second date or timestamp.\n * @param timeZone Optional IANA time zone identifier used for calendar comparisons.\n * @returns The number of years between the two dates.\n */\n static yearsInBetween(firstDate: Date, secondDate: Date, timeZone?: string): number;\n static yearsInBetween(firstDate: number, secondDate: number, timeZone?: string): number;\n static yearsInBetween(firstDate: Date | number, secondDate: Date | number, timeZone?: string): number {\n const first = this.normalizeDate(firstDate);\n const second = this.normalizeDate(secondDate);\n const effectiveTimeZone = timeZone || this.TIMEZONE;\n return Math.abs(\n differenceInCalendarYears(\n new TZDate(first, effectiveTimeZone),\n new TZDate(second, effectiveTimeZone),\n )\n );\n }\n\n /**\n * Calculates the absolute elapsed number of hours between two dates or timestamps.\n * This is duration-based, not calendar-based, so it is independent of time zone.\n *\n * @param firstDate The first date or timestamp.\n * @param secondDate The second date or timestamp.\n * @returns The number of hours between the two dates.\n */\n static hoursInBetween(firstDate: Date, secondDate: Date): number;\n static hoursInBetween(firstDate: number, secondDate: number): number;\n static hoursInBetween(firstDate: Date | number, secondDate: Date | number): number {\n const first = this.normalizeDate(firstDate);\n const second = this.normalizeDate(secondDate);\n return Math.abs(differenceInHours(first, second));\n }\n\n /**\n * Calculates the absolute elapsed number of seconds between two dates or timestamps.\n * This is duration-based, not calendar-based, so it is independent of time zone.\n *\n * @param firstDate The first date or timestamp.\n * @param secondDate The second date or timestamp.\n * @returns The number of seconds between the two dates.\n */\n static secondsInBetween(firstDate: Date, secondDate: Date): number;\n static secondsInBetween(firstDate: number, secondDate: number): number;\n static secondsInBetween(firstDate: Date | number, secondDate: Date | number): number {\n const first = this.normalizeDate(firstDate);\n const second = this.normalizeDate(secondDate);\n return Math.abs(differenceInSeconds(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 = this.normalizeDate(firstDate);\n const second = this.normalizeDate(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 * When a time zone is provided, the duration is applied using calendar arithmetic\n * in that time zone so month-end or day-boundary business rules stay aligned locally.\n *\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 * @param timeZone Optional IANA time zone identifier used for calendar math.\n * @returns A new Date object with the duration added.\n */\n static addDuration(date: Date, duration: Duration, timeZone?: string): Date;\n static addDuration(date: number, duration: Duration, timeZone?: string): Date;\n static addDuration(date: Date | number, duration: Duration, timeZone?: string): Date {\n const normalizedDate = this.normalizeDate(date);\n const effectiveTimeZone = timeZone || this.TIMEZONE;\n return add(new TZDate(normalizedDate, effectiveTimeZone), 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 protected static normalizeDate(date: Date | number): Date {\n return typeof date === 'number' ? this.fromMillis(date) : date;\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":["TZDate","parse","isValid","IllegalArgumentException","format","startOfDay","endOfDay","differenceInCalendarDays","differenceInCalendarMonths","differenceInCalendarYears","differenceInHours","differenceInSeconds","compareAsc","add","isLeapYear"],"mappings":";;;;;;AAIA;;;AAGG;MACU,QAAQ,CAAA;aAED,IAAA,CAAA,eAAe,GAAG,8BAA8B,CAAA;aAChD,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAA;AAEhC;;;;AAIG;IACH,OAAO,GAAG,CAAC,QAAgB,EAAA;QACvB,OAAO,IA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AM,CAAC,cAAc,EAAE,iBAAiB,CAAC,EAAE,QAAQ,CAAC;IACvE;AAEA;;;;AAIG;IACH,OAAO,UAAU,CAAC,IAAY,EAAA;AAC1B,QAAA,OAAOc,kBAAU,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;IAEU,OAAO,aAAa,CAAC,IAAmB,EAAA;AAC9C,QAAA,OAAO,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI;IAClE;AAEA;;;;AAIG;IACH,OAAO,QAAQ,CAAC,IAAU,EAAA;AACtB,QAAA,OAAO,IAAI,CAAC,OAAO,EAAE;IACzB;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BaseObject.js","sources":["../../../src/beans/BaseObject.ts"],"sourcesContent":["import { Expose } from 'class-transformer';\r\nimport { IsNumber, IsString } from 'class-validator';\r\n\r\n/**\r\n * The `BaseObject` class serves as a base model for objects with common properties\r\n * such as `id`, `description`, `createdAt`, and `updatedAt`. It includes validation\r\n * and transformation decorators for serialization and deserialization.\r\n *\r\n * Properties:\r\n * - `id` (string | undefined): A unique identifier for the object.\r\n * - `description` (string | undefined): A brief description of the object.\r\n * - `createdAt` (number | undefined): The timestamp when the object was created.\r\n * - `updatedAt` (number | undefined): The timestamp when the object was last updated.\r\n *\r\n * Methods:\r\n * - `getId()`: Returns the `id` of the object.\r\n * - `setId(value: string | undefined)`: Sets the `id` of the object.\r\n * - `getDescription()`: Returns the `description` of the object.\r\n * - `setDescription(value: string | undefined)`: Sets the `description` of the object.\r\n * - `getCreatedAt()`: Returns the `createdAt` timestamp of the object.\r\n * - `setCreatedAt(value?: number)`: Sets the `createdAt` timestamp of the object.\r\n * - `getUpdatedAt()`: Returns the `updatedAt` timestamp of the object.\r\n * - `setUpdatedAt(value?: number)`: Sets the `updatedAt` timestamp of the object.\r\n */\r\nexport class BaseObject {\r\n\r\n @Expose({ name: 'id' })\r\n @IsString()\r\n private id?: string;\r\n\r\n @Expose({ name: 'description' })\r\n @IsString()\r\n private description?: string;\r\n\r\n @Expose({ name: 'created_at' })\r\n @IsNumber()\r\n private createdAt?: number;\r\n\r\n @Expose({ name: 'updated_at' })\r\n @IsNumber()\r\n private updatedAt?: number;\r\n\r\n getId() {\r\n return this.id;\r\n }\r\n\r\n setId(value: string | undefined) {\r\n this.id = value;\r\n }\r\n\r\n getCreatedAt() {\r\n return this.createdAt;\r\n }\r\n\r\n setCreatedAt(value?: number) {\r\n this.createdAt = value;\r\n }\r\n\r\n getUpdatedAt() {\r\n return this.updatedAt;\r\n }\r\n\r\n setUpdatedAt(value?: number) {\r\n this.updatedAt = value;\r\n }\r\n\r\n getDescription() {\r\n return this.description;\r\n }\r\n\r\n setDescription(value?: string) {\r\n this.description = value;\r\n }\r\n}"],"names":[],"mappings":";;;;AAGA;;;;;;;;;;;;;;;;;;;;AAoBG;MACU,UAAU,CAAA;IAkBnB,KAAK,GAAA;QACD,OAAO,IAAI,CAAC,EAAE;IAClB;AAEA,IAAA,KAAK,CAAC,KAAyB,EAAA;AAC3B,QAAA,IAAI,CAAC,EAAE,GAAG,KAAK;IACnB;IAEA,YAAY,GAAA;QACR,OAAO,IAAI,CAAC,SAAS;IACzB;AAEA,IAAA,YAAY,CAAC,KAAc,EAAA;AACvB,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK;IAC1B;IAEA,YAAY,GAAA;QACR,OAAO,IAAI,CAAC,SAAS;IACzB;AAEA,IAAA,YAAY,CAAC,KAAc,EAAA;AACvB,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK;IAC1B;IAEA,cAAc,GAAA;QACV,OAAO,IAAI,CAAC,WAAW;IAC3B;AAEA,IAAA,cAAc,CAAC,KAAc,EAAA;AACzB,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK;IAC5B;AACH;AA7CW,UAAA,CAAA;AAFP,IAAA,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACtB,IAAA,QAAQ,EAAE;;AACS,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,IAAA,EAAA,MAAA,CAAA;AAIZ,UAAA,CAAA;AAFP,IAAA,MAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AAC/B,IAAA,QAAQ,EAAE;;AACkB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAIrB,UAAA,CAAA;AAFP,IAAA,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AAC9B,IAAA,QAAQ,EAAE;;AACgB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAInB,UAAA,CAAA;AAFP,IAAA,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AAC9B,IAAA,QAAQ,EAAE;;AACgB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;;;;"}
1
+ {"version":3,"file":"BaseObject.js","sources":["../../../src/beans/BaseObject.ts"],"sourcesContent":["import { Expose } from 'class-transformer';\nimport { IsNumber, IsString } from 'class-validator';\n\n/**\n * The `BaseObject` class serves as a base model for objects with common properties\n * such as `id`, `description`, `createdAt`, and `updatedAt`. It includes validation\n * and transformation decorators for serialization and deserialization.\n *\n * Properties:\n * - `id` (string | undefined): A unique identifier for the object.\n * - `description` (string | undefined): A brief description of the object.\n * - `createdAt` (number | undefined): The timestamp when the object was created.\n * - `updatedAt` (number | undefined): The timestamp when the object was last updated.\n *\n * Methods:\n * - `getId()`: Returns the `id` of the object.\n * - `setId(value: string | undefined)`: Sets the `id` of the object.\n * - `getDescription()`: Returns the `description` of the object.\n * - `setDescription(value: string | undefined)`: Sets the `description` of the object.\n * - `getCreatedAt()`: Returns the `createdAt` timestamp of the object.\n * - `setCreatedAt(value?: number)`: Sets the `createdAt` timestamp of the object.\n * - `getUpdatedAt()`: Returns the `updatedAt` timestamp of the object.\n * - `setUpdatedAt(value?: number)`: Sets the `updatedAt` timestamp of the object.\n */\nexport class BaseObject {\n\n @Expose({ name: 'id' })\n @IsString()\n private id?: string;\n\n @Expose({ name: 'description' })\n @IsString()\n private description?: string;\n\n @Expose({ name: 'created_at' })\n @IsNumber()\n private createdAt?: number;\n\n @Expose({ name: 'updated_at' })\n @IsNumber()\n private updatedAt?: number;\n\n getId() {\n return this.id;\n }\n\n setId(value: string | undefined) {\n this.id = value;\n }\n\n getCreatedAt() {\n return this.createdAt;\n }\n\n setCreatedAt(value?: number) {\n this.createdAt = value;\n }\n\n getUpdatedAt() {\n return this.updatedAt;\n }\n\n setUpdatedAt(value?: number) {\n this.updatedAt = value;\n }\n\n getDescription() {\n return this.description;\n }\n\n setDescription(value?: string) {\n this.description = value;\n }\n}"],"names":[],"mappings":";;;;AAGA;;;;;;;;;;;;;;;;;;;;AAoBG;MACU,UAAU,CAAA;IAkBnB,KAAK,GAAA;QACD,OAAO,IAAI,CAAC,EAAE;IAClB;AAEA,IAAA,KAAK,CAAC,KAAyB,EAAA;AAC3B,QAAA,IAAI,CAAC,EAAE,GAAG,KAAK;IACnB;IAEA,YAAY,GAAA;QACR,OAAO,IAAI,CAAC,SAAS;IACzB;AAEA,IAAA,YAAY,CAAC,KAAc,EAAA;AACvB,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK;IAC1B;IAEA,YAAY,GAAA;QACR,OAAO,IAAI,CAAC,SAAS;IACzB;AAEA,IAAA,YAAY,CAAC,KAAc,EAAA;AACvB,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK;IAC1B;IAEA,cAAc,GAAA;QACV,OAAO,IAAI,CAAC,WAAW;IAC3B;AAEA,IAAA,cAAc,CAAC,KAAc,EAAA;AACzB,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK;IAC5B;AACH;AA7CW,UAAA,CAAA;AAFP,IAAA,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACtB,IAAA,QAAQ,EAAE;;AACS,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,IAAA,EAAA,MAAA,CAAA;AAIZ,UAAA,CAAA;AAFP,IAAA,MAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AAC/B,IAAA,QAAQ,EAAE;;AACkB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAIrB,UAAA,CAAA;AAFP,IAAA,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AAC9B,IAAA,QAAQ,EAAE;;AACgB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAInB,UAAA,CAAA;AAFP,IAAA,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AAC9B,IAAA,QAAQ,EAAE;;AACgB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BadRequestException.js","sources":["../../../src/exceptions/BadRequestException.ts"],"sourcesContent":["import { HTTPException } from './HTTPException';\r\n\r\n/**\r\n * Exception thrown when a bad request is made to the server.\r\n * Typically used for HTTP 400 errors.\r\n */\r\nexport class BadRequestException extends HTTPException {\r\n\r\n constructor(message: string, cause?: unknown, code: number = 400) {\r\n super(message, cause, code)\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,MAAO,mBAAoB,SAAQ,aAAa,CAAA;AAElD,IAAA,WAAA,CAAY,OAAe,EAAE,KAAe,EAAE,OAAe,GAAG,EAAA;AAC5D,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;IAC/B;AACH;;;;"}
1
+ {"version":3,"file":"BadRequestException.js","sources":["../../../src/exceptions/BadRequestException.ts"],"sourcesContent":["import { HTTPException } from './HTTPException';\n\n/**\n * Exception thrown when a bad request is made to the server.\n * Typically used for HTTP 400 errors.\n */\nexport class BadRequestException extends HTTPException {\n\n constructor(message: string, cause?: unknown, code: number = 400) {\n super(message, cause, code)\n }\n}\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,MAAO,mBAAoB,SAAQ,aAAa,CAAA;AAElD,IAAA,WAAA,CAAY,OAAe,EAAE,KAAe,EAAE,OAAe,GAAG,EAAA;AAC5D,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;IAC/B;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BaseException.js","sources":["../../../src/exceptions/BaseException.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\r\n/**\r\n * Base class for all custom exceptions in the application.\r\n * Provides support for error codes and chained exceptions.\r\n */\r\nexport class BaseException extends Error {\r\n code?: number;\r\n\r\n constructor(message: string, cause?: unknown, code?: number) {\r\n super(message,{ cause });\r\n this.code = code;\r\n this.name = this.constructor.name;\r\n }\r\n}"],"names":[],"mappings":"AAAA;AACA;;;AAGG;AACG,MAAO,aAAc,SAAQ,KAAK,CAAA;AAGpC,IAAA,WAAA,CAAY,OAAe,EAAE,KAAe,EAAE,IAAa,EAAA;AACvD,QAAA,KAAK,CAAC,OAAO,EAAC,EAAE,KAAK,EAAE,CAAC;AACxB,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;IACrC;AACH;;;;"}
1
+ {"version":3,"file":"BaseException.js","sources":["../../../src/exceptions/BaseException.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Base class for all custom exceptions in the application.\n * Provides support for error codes and chained exceptions.\n */\nexport class BaseException extends Error {\n code?: number;\n\n constructor(message: string, cause?: unknown, code?: number) {\n super(message,{ cause });\n this.code = code;\n this.name = this.constructor.name;\n }\n}"],"names":[],"mappings":"AAAA;AACA;;;AAGG;AACG,MAAO,aAAc,SAAQ,KAAK,CAAA;AAGpC,IAAA,WAAA,CAAY,OAAe,EAAE,KAAe,EAAE,IAAa,EAAA;AACvD,QAAA,KAAK,CAAC,OAAO,EAAC,EAAE,KAAK,EAAE,CAAC;AACxB,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;IACrC;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ClientException.js","sources":["../../../src/exceptions/ClientException.ts"],"sourcesContent":["import { HTTPException } from './HTTPException';\r\n\r\n/**\r\n * Exception thrown for client-side errors.\r\n * Typically used for HTTP 4xx errors.\r\n */\r\nexport class ClientException extends HTTPException {\r\n\r\n constructor(message: string, cause?: unknown, code: number = 500) {\r\n super(message, cause, code);\r\n }\r\n}\r\n\r\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,MAAO,eAAgB,SAAQ,aAAa,CAAA;AAE9C,IAAA,WAAA,CAAY,OAAe,EAAE,KAAe,EAAE,OAAe,GAAG,EAAA;AAC5D,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;IAC/B;AACH;;;;"}
1
+ {"version":3,"file":"ClientException.js","sources":["../../../src/exceptions/ClientException.ts"],"sourcesContent":["import { HTTPException } from './HTTPException';\n\n/**\n * Exception thrown for client-side errors.\n * Typically used for HTTP 4xx errors.\n */\nexport class ClientException extends HTTPException {\n\n constructor(message: string, cause?: unknown, code: number = 500) {\n super(message, cause, code);\n }\n}\n\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,MAAO,eAAgB,SAAQ,aAAa,CAAA;AAE9C,IAAA,WAAA,CAAY,OAAe,EAAE,KAAe,EAAE,OAAe,GAAG,EAAA;AAC5D,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;IAC/B;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConverterException.js","sources":["../../../src/exceptions/ConverterException.ts"],"sourcesContent":["import { BaseException } from \"./BaseException\";\r\n\r\n/**\r\n * Exception thrown when a conversion operation fails.\r\n */\r\nexport class ConverterException 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,kBAAmB,SAAQ,aAAa,CAAA;IAEjD,WAAA,CAAY,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;IAC9B;AACH;;;;"}
1
+ {"version":3,"file":"ConverterException.js","sources":["../../../src/exceptions/ConverterException.ts"],"sourcesContent":["import { BaseException } from \"./BaseException\";\n\n/**\n * Exception thrown when a conversion operation fails.\n */\nexport class ConverterException extends BaseException {\n\n constructor(message: string, cause?: unknown) {\n super(message, cause, 500);\n }\n}\n\n"],"names":[],"mappings":";;AAEA;;AAEG;AACG,MAAO,kBAAmB,SAAQ,aAAa,CAAA;IAEjD,WAAA,CAAY,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;IAC9B;AACH;;;;"}
@@ -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,WAAA,CAAY,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;IAC9B;AACH;;;;"}
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;IAC/B;AAEH;;;;"}
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,WAAA,CAAY,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;IAC9B;AACH;;;;"}
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,WAAA,CAAY,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;IAC9B;AACH;;;;"}
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 +1 @@
1
- {"version":3,"file":"LoggerFactory.js","sources":["../../../src/logger/LoggerFactory.ts"],"sourcesContent":["import winston, { Logger, LoggerOptions } from \"winston\";\r\nimport { BaseException } from \"../exceptions\";\r\nimport { ErrorFormat } from \"./format/ErrorFormat\";\r\nimport { LoggingLevel } from \"../types\";\r\n\r\n/**\r\n * Factory class for creating and managing Winston logger instances.\r\n *\r\n * @description\r\n * Provides a factory for creating Winston logger instances with consistent configuration.\r\n * Supports custom logging levels, formats, and transports with a default format pipeline\r\n * that includes timestamp, error handling with cause chains, and JSON formatting.\r\n *\r\n * @example\r\n * ```typescript\r\n * // Create a logger with custom configuration\r\n * const logger = LoggerFactory.createLogger({\r\n * level: 'info',\r\n * transports: [new winston.transports.Console()]\r\n * });\r\n *\r\n * // Create another logger and add a label to it\r\n * const apiLogger = LoggerFactory.getLogger('api-service');\r\n * apiLogger.info('Server started');\r\n * ```\r\n */\r\nexport class LoggerFactory {\r\n /**\r\n * Base logger instance used by the factory.\r\n *\r\n * @description\r\n * Currently stores a single base logger instance per execution context.\r\n * This design can be extended in the future to support multiple base loggers\r\n * by replacing this single instance with a Map-based container (similar to Winston's Container API)\r\n * to manage multiple named logger configurations.\r\n *\r\n * @type {winston.Logger}\r\n * @private\r\n */\r\n private static logger: winston.Logger;\r\n\r\n /**\r\n * Creates and initializes a new logger instance with the provided configuration.\r\n *\r\n * @description\r\n * Creates a new Winston logger with a consistent default format pipeline that includes\r\n * timestamp, error handling with stack traces and cause chains, custom error formatting,\r\n * and JSON output. Custom formats are combined with the defaults. If no transports are\r\n * specified, defaults to Console transport.\r\n *\r\n * @param {LoggerOptions} [options] - Optional Winston logger configuration options\r\n * @param {LoggingLevel} [options.level='info'] - Logging level (error, warn, info, http, debug, verbose, silly)\r\n * @param {winston.LogFormat} [options.format] - Additional custom format to combine with defaults\r\n * @param {object} [options.defaultMeta] - Default metadata to include in all log entries from this logger\r\n * @param {winston.transport[]} [options.transports] - Transport instances (defaults to Console)\r\n *\r\n * @returns {winston.Logger} Configured logger instance\r\n *\r\n * @throws {BaseException} If logger initialization fails\r\n *\r\n * @example\r\n * ```typescript\r\n * // Create a logger with custom configuration\r\n * const logger = LoggerFactory.createLogger({\r\n * level: 'debug',\r\n * defaultMeta: { service: 'api' },\r\n * transports: [\r\n * new winston.transports.Console(),\r\n * new winston.transports.File({ filename: 'combined.log' })\r\n * ]\r\n * });\r\n * ```\r\n */\r\n static createLogger(options?: LoggerOptions): winston.Logger {\r\n try {\r\n const defaultFormat = winston.format.combine(\r\n winston.format.timestamp(),\r\n winston.format.errors({ stack: true, cause: true }),\r\n ErrorFormat(),\r\n winston.format.json()\r\n );\r\n\r\n LoggerFactory.logger = winston.createLogger({\r\n level: options?.level ?? LoggingLevel.info,\r\n format: options?.format\r\n ? winston.format.combine(options.format, defaultFormat)\r\n : defaultFormat,\r\n defaultMeta: options?.defaultMeta,\r\n transports: options?.transports\r\n ? options.transports\r\n : [new winston.transports.Console()],\r\n });\r\n\r\n return LoggerFactory.logger;\r\n } catch (error) {\r\n throw new BaseException(`Error creating logger`, error, 500);\r\n }\r\n }\r\n\r\n /**\r\n * Gets a logger instance with a label added to the metadata.\r\n *\r\n * @description\r\n * Returns a logger instance that is a child of the base logger with the provided label\r\n * added as metadata. Each call creates a new child logger with the specified label.\r\n * This is useful for identifying the source of log messages by module or service name.\r\n *\r\n * @param {string} label - Unique identifier for the logger to include in metadata (e.g., module name, service name)\r\n *\r\n * @returns {winston.Logger} Child logger instance with the label in metadata\r\n *\r\n * @example\r\n * ```typescript\r\n * // Create a logger with a label for the UserService module\r\n * const logger = LoggerFactory.getLogger('UserService');\r\n *\r\n * // Another module can create its own labeled logger\r\n * const apiLogger = LoggerFactory.getLogger('APIHandler');\r\n *\r\n * logger.info('Processing user request'); // Log includes { label: 'UserService' }\r\n * ```\r\n */\r\n static getLogger(label: string): winston.Logger {\r\n let baseLogger: winston.Logger;\r\n if (LoggerFactory.logger) {\r\n baseLogger = LoggerFactory.logger!;\r\n } else {\r\n baseLogger = LoggerFactory.createLogger();\r\n }\r\n\r\n return baseLogger.child({ label });\r\n }\r\n \r\n}\r\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;;;;"}
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;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorFormat.js","sources":["../../../../src/logger/format/ErrorFormat.ts"],"sourcesContent":["import winston from \"winston\";\r\nimport { TransformableInfo } from \"logform\";\r\n\r\n/**\r\n * Winston log format for handling Error objects with cause chains.\r\n *\r\n * @description\r\n * ES2022 supports adding a `cause` property to Error objects for better error context.\r\n * While `console.log(err)` prints the entire cause chain automatically, Winston only logs\r\n * the top-level error, losing the cause chain context.\r\n *\r\n * This format ensures that error cause chains are fully serialized and included in log output,\r\n * preserving the complete error context for better debugging and error tracking.\r\n *\r\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause | MDN: Error.cause}\r\n * @see {@link https://github.com/winstonjs/winston/issues/2533 | Winston Issue #2533}\r\n *\r\n * @param {TransformableInfo} info - The log entry information from Winston\r\n * @returns {TransformableInfo} The formatted log entry with serialized error chains\r\n *\r\n * @example\r\n * ```typescript\r\n * const logger = winston.createLogger({\r\n * format: winston.format.combine(\r\n * ErrorFormat,\r\n * winston.format.json()\r\n * ),\r\n * transports: [new winston.transports.Console()]\r\n * });\r\n *\r\n * try {\r\n * throw new Error(\"Original error\");\r\n * } catch (err) {\r\n * throw new Error(\"Wrapper error\", { cause: err });\r\n * }\r\n * ```\r\n */\r\nexport const ErrorFormat = winston.format((info: TransformableInfo) => {\r\n // If the log entry itself is an error\r\n if (info instanceof Error) {\r\n const seen = new WeakSet<object>();\r\n const serialized = serialize(info, seen);\r\n\r\n // Preserve Winston semantics by setting standard error properties\r\n info.message = serialized.message;\r\n info.stack = serialized.stack;\r\n info.cause = serialized.cause;\r\n\r\n // Copy all other enumerable properties from serialized error\r\n for (const key of Object.keys(serialized)) {\r\n if (![\"message\", \"stack\", \"name\", \"cause\"].includes(key)) {\r\n info[key] = serialized[key];\r\n }\r\n }\r\n\r\n return info;\r\n }\r\n\r\n // For normal log entries, serialize any nested error fields\r\n const seen = new WeakSet<object>();\r\n for (const key of Object.keys(info)) {\r\n info[key] = serialize(info[key], seen);\r\n }\r\n\r\n return info;\r\n});\r\n\r\n/**\r\n * Recursively serializes values that may contain Error objects.\r\n *\r\n * @description\r\n * Handles all types of values including Error instances, nested objects, arrays,\r\n * and primitives. Ensures that Error objects are fully serialized with their\r\n * stack traces, messages, and cause chains preserved. Includes circular reference\r\n * detection to prevent infinite recursion.\r\n *\r\n * @param {any} value - The value to serialize. Can be any type (Error, object, array, primitive)\r\n * @param {WeakSet<object>} seen - Set tracking objects already visited to detect circular references\r\n * @returns {any} The serialized value with all Error objects converted to plain objects\r\n *\r\n * @example\r\n * ```typescript\r\n * const error = new Error(\"Test\");\r\n * const seen = new WeakSet<object>();\r\n * const serialized = serialize(error, seen);\r\n * // Returns: { message: \"Test\", name: \"Error\", stack: \"...\", cause: undefined }\r\n * ```\r\n */\r\nfunction serialize(value: any, seen: WeakSet<object> = new WeakSet<object>()): any {\r\n // Handle null/undefined\r\n if (value == null) {\r\n return value;\r\n }\r\n\r\n // Error instance - convert to serializable object\r\n if (value instanceof Error) {\r\n // Check for circular reference\r\n if (seen.has(value)) {\r\n return \"[Circular Reference]\";\r\n }\r\n seen.add(value);\r\n\r\n const serialized: any = {\r\n message: value.message,\r\n name: value.name,\r\n stack: value.stack,\r\n cause: value.cause instanceof Error ? serialize(value.cause, seen) : value.cause,\r\n };\r\n\r\n // Copy enumerable custom properties (e.g., error.code, error.statusCode)\r\n for (const key of Object.keys(value)) {\r\n if (!(key in serialized)) {\r\n serialized[key] = serialize(value[key], seen);\r\n }\r\n }\r\n\r\n return serialized;\r\n }\r\n\r\n\r\n // Primitive value - return as-is\r\n return value;\r\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,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AIA,IAAA,OAAO,KAAK;AACd;;;;"}
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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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 +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 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 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 i = 0; i < array.length; i++) {\r\n let item = array[i];\r\n\r\n if (item === undefined) {\r\n this.push(undefined);\r\n continue;\r\n }\r\n\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;AAElD,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,KAAK,SAAS,EAAE;AAEpC,qBAAA,IAAI,KAAK,CAAC,WAAW,IAAI,MAAM,EAAE;oBACpC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,UAAU,CAAC,KAAmC,CAAC,CAAC;gBACtE;AAAO,qBAAA,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,EAAE;oBACnC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;gBACvC;qBAAO;AACH,oBAAA,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;gBACxB;YACJ;QACJ;IACJ;AAEA,IAAA,aAAa,CAAC,GAAW,EAAA;AACrB,QAAA,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAChB,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,UAAU,EAAE;AACtC,gBAAA,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAe;YACvC;iBAAO;AACH,gBAAA,MAAM,IAAI,wBAAwB,CAAC,yCAAyC,CAAC;YACjF;QACJ;AAEA,QAAA,MAAM,IAAI,aAAa,CAAC,mBAAmB,GAAG,CAAA,WAAA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iBAAO;AACH,gBAAA,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;YACnB;QACJ;AACA,QAAA,OAAO,GAAG;IACd;AACH;;;;"}
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 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 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 i = 0; i < array.length; i++) {\n let item = array[i];\n\n if (item === undefined) {\n this.push(undefined);\n continue;\n }\n\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 arr.push(value)\n }\n }\n return arr;\n }\n}"],"names":[],"mappings":";;;AAWM,MAAO,UAAW,SAAQ,GAAsB,CAAA;AAElD,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,KAAK,SAAS,EAA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AAI,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,GAAA,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,GAAA,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;;;;"}
@@ -8,6 +8,7 @@ import { IllegalArgumentException } from '../../exceptions/IllegalArgumentExcept
8
8
  */
9
9
  class DateUtil {
10
10
  static { this.ISO_8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSxxx"; }
11
+ static { this.TIMEZONE = "UTC"; }
11
12
  /**
12
13
  * Gets the current date and time in the specified time zone.
13
14
  * @param timeZone The IANA time zone identifier.
@@ -39,15 +40,15 @@ class DateUtil {
39
40
  return date;
40
41
  }
41
42
  static printDate(date, timeZone, dateFormat = this.ISO_8601_FORMAT) {
42
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
43
+ const normalizedDate = this.normalizeDate(date);
43
44
  return format(new TZDate(normalizedDate, timeZone), dateFormat);
44
45
  }
45
46
  static getStartOfDay(date, timeZone) {
46
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
47
+ const normalizedDate = this.normalizeDate(date);
47
48
  return startOfDay(new TZDate(normalizedDate, timeZone));
48
49
  }
49
50
  static getEndOfDay(date, timeZone) {
50
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
51
+ const normalizedDate = this.normalizeDate(date);
51
52
  return endOfDay(new TZDate(normalizedDate, timeZone));
52
53
  }
53
54
  /**
@@ -60,45 +61,48 @@ class DateUtil {
60
61
  try {
61
62
  DateUtil.readDate(dateString, dateFormat, "UTC");
62
63
  return true;
63
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
64
64
  }
65
65
  catch (error) {
66
66
  return false;
67
67
  }
68
68
  }
69
- static daysInBetween(firstDate, secondDate) {
70
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
71
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
72
- return Math.abs(differenceInCalendarDays(first, second));
69
+ static daysInBetween(firstDate, secondDate, timeZone) {
70
+ const first = this.normalizeDate(firstDate);
71
+ const second = this.normalizeDate(secondDate);
72
+ const effectiveTimeZone = timeZone || this.TIMEZONE;
73
+ return Math.abs(differenceInCalendarDays(new TZDate(first, effectiveTimeZone), new TZDate(second, effectiveTimeZone)));
73
74
  }
74
- static monthsInBetween(firstDate, secondDate) {
75
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
76
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
77
- return Math.abs(differenceInCalendarMonths(first, second));
75
+ static monthsInBetween(firstDate, secondDate, timeZone) {
76
+ const first = this.normalizeDate(firstDate);
77
+ const second = this.normalizeDate(secondDate);
78
+ const effectiveTimeZone = timeZone || this.TIMEZONE;
79
+ return Math.abs(differenceInCalendarMonths(new TZDate(first, effectiveTimeZone), new TZDate(second, effectiveTimeZone)));
78
80
  }
79
- static yearsInBetween(firstDate, secondDate) {
80
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
81
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
82
- return Math.abs(differenceInCalendarYears(first, second));
81
+ static yearsInBetween(firstDate, secondDate, timeZone) {
82
+ const first = this.normalizeDate(firstDate);
83
+ const second = this.normalizeDate(secondDate);
84
+ const effectiveTimeZone = timeZone || this.TIMEZONE;
85
+ return Math.abs(differenceInCalendarYears(new TZDate(first, effectiveTimeZone), new TZDate(second, effectiveTimeZone)));
83
86
  }
84
87
  static hoursInBetween(firstDate, secondDate) {
85
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
86
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
88
+ const first = this.normalizeDate(firstDate);
89
+ const second = this.normalizeDate(secondDate);
87
90
  return Math.abs(differenceInHours(first, second));
88
91
  }
89
92
  static secondsInBetween(firstDate, secondDate) {
90
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
91
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
93
+ const first = this.normalizeDate(firstDate);
94
+ const second = this.normalizeDate(secondDate);
92
95
  return Math.abs(differenceInSeconds(first, second));
93
96
  }
94
97
  static compareDates(firstDate, secondDate) {
95
- const first = typeof firstDate === 'number' ? new Date(firstDate) : firstDate;
96
- const second = typeof secondDate === 'number' ? new Date(secondDate) : secondDate;
98
+ const first = this.normalizeDate(firstDate);
99
+ const second = this.normalizeDate(secondDate);
97
100
  return compareAsc(first, second);
98
101
  }
99
- static addDuration(date, duration) {
100
- const normalizedDate = typeof date === 'number' ? new Date(date) : date;
101
- return add(normalizedDate, duration);
102
+ static addDuration(date, duration, timeZone) {
103
+ const normalizedDate = this.normalizeDate(date);
104
+ const effectiveTimeZone = timeZone || this.TIMEZONE;
105
+ return add(new TZDate(normalizedDate, effectiveTimeZone), duration);
102
106
  }
103
107
  /**
104
108
  * Determines whether a given year is a leap year.
@@ -116,6 +120,9 @@ class DateUtil {
116
120
  static fromMillis(milliseconds) {
117
121
  return new Date(milliseconds);
118
122
  }
123
+ static normalizeDate(date) {
124
+ return typeof date === 'number' ? this.fromMillis(date) : date;
125
+ }
119
126
  /**
120
127
  * Converts a Date object to a timestamp (in milliseconds).
121
128
  * @param date The Date object to convert.