@mrxsys/mrx-core 2.11.0-4-and-276-20251029 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/{chunk-0d0zd2yg.js → chunk-037vwvd4.js} +2 -2
  2. package/dist/{chunk-jksb9ers.js → chunk-10w8mg8e.js} +1 -1
  3. package/dist/{chunk-dre2fgj0.js → chunk-2z8amjqt.js} +1 -1
  4. package/dist/{chunk-p14h6jfs.js → chunk-4g0x6g4j.js} +2 -2
  5. package/dist/chunk-4t7sy5qt.js +10 -0
  6. package/dist/chunk-642xajvx.js +59 -0
  7. package/dist/chunk-6hs00zfd.js +13 -0
  8. package/dist/{chunk-afyz8rg5.js → chunk-7j86h1nd.js} +14 -9
  9. package/dist/chunk-8pw0syzf.js +9 -0
  10. package/dist/{chunk-eeb7yskp.js → chunk-awphtyzp.js} +4 -4
  11. package/dist/{chunk-8tffnbpn.js → chunk-ayyrgqyv.js} +1 -1
  12. package/dist/{chunk-12qzn7jw.js → chunk-dmsev7vs.js} +1 -1
  13. package/dist/{chunk-gtn1kn0z.js → chunk-hv6g22kf.js} +4 -4
  14. package/dist/chunk-hwfebx4x.js +11 -0
  15. package/dist/{chunk-e30paw8a.js → chunk-j7dyc5ks.js} +5 -5
  16. package/dist/chunk-jz3wd472.js +23 -0
  17. package/dist/{chunk-fs3wm3p4.js → chunk-r7yr9p57.js} +6 -6
  18. package/dist/{chunk-afd82epa.js → chunk-sbpj7f3p.js} +13 -13
  19. package/dist/{chunk-pjv1ekwr.js → chunk-tmvj28bq.js} +1 -1
  20. package/dist/chunk-y5dtkmnp.js +8 -0
  21. package/dist/chunk-yrt0ffvf.js +9 -0
  22. package/dist/{chunk-441xs5k1.js → chunk-yzgdqb02.js} +6 -6
  23. package/dist/chunk-zn2nm5gg.js +9 -0
  24. package/dist/{chunk-7t524zqh.js → chunk-zv4ta4fb.js} +3 -3
  25. package/dist/errors/{base-error.d.ts → app-error.d.ts} +2 -1
  26. package/dist/errors/http-error.d.ts +2 -2
  27. package/dist/errors/index.d.ts +2 -1
  28. package/dist/errors/index.js +6 -4
  29. package/dist/errors/internal-error.d.ts +4 -0
  30. package/dist/modules/data/data.d.ts +5 -5
  31. package/dist/modules/data/enums/data-error-keys.d.ts +1 -1
  32. package/dist/modules/data/enums/index.js +1 -1
  33. package/dist/modules/data/index.js +3 -3
  34. package/dist/modules/database/enums/database-error-keys.d.ts +26 -26
  35. package/dist/modules/database/enums/index.js +1 -1
  36. package/dist/modules/database/enums/mssql-error-code.d.ts +23 -23
  37. package/dist/modules/database/index.js +5 -5
  38. package/dist/modules/database/mssql.d.ts +9 -9
  39. package/dist/modules/elysia/cache/index.js +3 -3
  40. package/dist/modules/elysia/crud/index.js +13 -13
  41. package/dist/modules/elysia/crud/operations/count.d.ts +20 -4
  42. package/dist/modules/elysia/crud/operations/delete.d.ts +25 -9
  43. package/dist/modules/elysia/crud/operations/deleteOne.d.ts +25 -9
  44. package/dist/modules/elysia/crud/operations/find.d.ts +25 -9
  45. package/dist/modules/elysia/crud/operations/findOne.d.ts +25 -9
  46. package/dist/modules/elysia/crud/operations/index.js +10 -10
  47. package/dist/modules/elysia/crud/operations/insert.d.ts +25 -9
  48. package/dist/modules/elysia/crud/operations/update.d.ts +25 -19
  49. package/dist/modules/elysia/crud/operations/updateOne.d.ts +25 -19
  50. package/dist/modules/elysia/crud/types/response-200-schema.d.ts +2 -2
  51. package/dist/modules/elysia/crud/utils/create-insert-schema.d.ts +3 -8
  52. package/dist/modules/elysia/crud/utils/index.js +4 -4
  53. package/dist/modules/elysia/db-resolver/enums/db-resolver-error-keys.d.ts +1 -1
  54. package/dist/modules/elysia/db-resolver/enums/index.js +1 -1
  55. package/dist/modules/elysia/db-resolver/index.js +9 -9
  56. package/dist/modules/elysia/error/enums/error.keys.d.ts +4 -4
  57. package/dist/modules/elysia/error/enums/index.js +1 -1
  58. package/dist/modules/elysia/error/error.d.ts +47 -1
  59. package/dist/modules/elysia/error/index.d.ts +1 -1
  60. package/dist/modules/elysia/error/index.js +47 -38
  61. package/dist/modules/elysia/microservice/enums/index.js +1 -1
  62. package/dist/modules/elysia/microservice/enums/microservice-success-keys.d.ts +2 -2
  63. package/dist/modules/elysia/microservice/index.js +1 -1
  64. package/dist/modules/elysia/rate-limit/enums/index.js +1 -1
  65. package/dist/modules/elysia/rate-limit/enums/rate-limit-error-keys.d.ts +1 -1
  66. package/dist/modules/elysia/rate-limit/index.js +5 -5
  67. package/dist/modules/jwt/enums/index.js +2 -2
  68. package/dist/modules/jwt/enums/jwt-error-keys.d.ts +3 -3
  69. package/dist/modules/jwt/enums/parse-human-time-to-seconds-error-keys.d.ts +1 -1
  70. package/dist/modules/jwt/index.js +10 -12
  71. package/dist/modules/jwt/utils/index.js +3 -3
  72. package/dist/modules/jwt/utils/parse-human-time-to-seconds.d.ts +1 -1
  73. package/dist/modules/kv-store/bun-redis/index.js +7 -7
  74. package/dist/modules/kv-store/enums/index.js +1 -1
  75. package/dist/modules/kv-store/enums/kv-store-error-keys.d.ts +3 -3
  76. package/dist/modules/kv-store/ioredis/index.js +7 -7
  77. package/dist/modules/kv-store/memory/index.js +3 -3
  78. package/dist/modules/logger/enums/index.js +1 -1
  79. package/dist/modules/logger/enums/logger-error-keys.d.ts +7 -7
  80. package/dist/modules/logger/events/logger-events.d.ts +4 -4
  81. package/dist/modules/logger/index.js +86 -11
  82. package/dist/modules/logger/logger.d.ts +1 -1
  83. package/dist/modules/logger/sinks/console-logger.d.ts +1 -1
  84. package/dist/modules/logger/sinks/file-logger/enums/file-logger-error-keys.d.ts +1 -1
  85. package/dist/modules/logger/sinks/index.js +7 -7
  86. package/dist/modules/logger/worker-logger.d.ts +1 -0
  87. package/dist/modules/mailer/enums/index.js +1 -1
  88. package/dist/modules/mailer/enums/mailer-error-keys.d.ts +3 -3
  89. package/dist/modules/mailer/index.js +6 -6
  90. package/dist/modules/mailer/smtp.d.ts +4 -4
  91. package/dist/modules/repository/index.js +4 -4
  92. package/dist/modules/repository/repository.d.ts +9 -9
  93. package/dist/modules/singleton-manager/enums/index.js +1 -1
  94. package/dist/modules/singleton-manager/enums/singleton-manager-error-keys.d.ts +2 -2
  95. package/dist/modules/singleton-manager/index.js +3 -3
  96. package/dist/modules/singleton-manager/singleton-manager.d.ts +3 -3
  97. package/dist/modules/totp/enums/index.js +1 -1
  98. package/dist/modules/totp/enums/totp-error-keys.d.ts +5 -5
  99. package/dist/modules/totp/index.js +6 -6
  100. package/dist/modules/totp/otp-auth-uri.d.ts +1 -1
  101. package/dist/modules/totp/utils/base32.d.ts +1 -1
  102. package/dist/modules/totp/utils/generate-secret-bytes.d.ts +1 -1
  103. package/dist/modules/totp/utils/index.js +5 -5
  104. package/dist/shared/utils/env.d.ts +1 -1
  105. package/dist/shared/utils/index.js +3 -3
  106. package/package.json +16 -17
  107. package/CHANGELOG.md +0 -407
  108. package/dist/chunk-4v86f7gp.js +0 -59
  109. package/dist/chunk-6w9ja96e.js +0 -9
  110. package/dist/chunk-9cgzhc50.js +0 -15
  111. package/dist/chunk-9d3zvgp6.js +0 -9
  112. package/dist/chunk-9r5anep5.js +0 -11
  113. package/dist/chunk-rz5p4j3p.js +0 -13
  114. package/dist/chunk-spnh9dzk.js +0 -10
  115. package/dist/chunk-xhhj1gvj.js +0 -9
  116. package/dist/chunk-z0ct35ft.js +0 -8
  117. package/dist/errors/utils/index.d.ts +0 -1
  118. package/dist/errors/utils/index.js +0 -16
  119. package/dist/errors/utils/is-nowarajs-error.ts.d.ts +0 -4
@@ -1,67 +1,76 @@
1
1
  // @bun
2
2
  import {
3
3
  ERROR_KEYS
4
- } from "../../../chunk-spnh9dzk.js";
4
+ } from "../../../chunk-4t7sy5qt.js";
5
5
  import {
6
6
  filterByKeyExclusion
7
- } from "../../../chunk-gtn1kn0z.js";
8
- import"../../../chunk-jksb9ers.js";
7
+ } from "../../../chunk-hv6g22kf.js";
8
+ import"../../../chunk-10w8mg8e.js";
9
9
  import {
10
10
  HttpError
11
- } from "../../../chunk-7t524zqh.js";
11
+ } from "../../../chunk-zv4ta4fb.js";
12
12
  import"../../../chunk-sqts8vyk.js";
13
13
  import {
14
- BaseError
15
- } from "../../../chunk-9cgzhc50.js";
14
+ InternalError
15
+ } from "../../../chunk-jz3wd472.js";
16
16
 
17
17
  // source/modules/elysia/error/error.ts
18
18
  import { Elysia } from "elysia";
19
- var errorManager = new Elysia({
19
+ var error = new Elysia({
20
20
  name: "errorPlugin"
21
21
  }).error({
22
- BaseError,
22
+ InternalError,
23
23
  HttpError
24
- }).onError(({ code, error, set, status }) => {
24
+ }).onError(({ code, error: error2, set }) => {
25
25
  set.headers["content-type"] = "application/json; charset=utf-8";
26
26
  switch (code) {
27
27
  case "HttpError":
28
- return status(error.httpStatusCode, {
29
- message: error.message,
30
- content: error.cause
31
- });
32
- case "BaseError":
33
- return status(500, {
34
- message: ERROR_KEYS.CORE_ERROR_INTERNAL_SERVER_ERROR,
35
- content: error.cause
36
- });
28
+ set.status = error2.httpStatusCode;
29
+ return {
30
+ message: error2.message,
31
+ content: error2.cause
32
+ };
33
+ case "InternalError":
34
+ set.status = 500;
35
+ return {
36
+ message: ERROR_KEYS.INTERNAL_SERVER_ERROR,
37
+ content: error2.uuid
38
+ };
37
39
  case "VALIDATION": {
38
- return status(422, {
39
- on: error.type,
40
- errors: error.all.map((e) => ({
41
- path: e.path,
42
- value: e.value,
43
- summary: e.summary,
44
- message: e.schema?.error,
45
- schema: filterByKeyExclusion(e.schema, ["error"], true)
46
- }))
47
- });
40
+ set.status = 422;
41
+ return {
42
+ message: ERROR_KEYS.VALIDATION,
43
+ content: {
44
+ on: error2.type,
45
+ errors: error2.all.map((e) => ({
46
+ path: e.path,
47
+ value: e.value,
48
+ summary: e.summary,
49
+ message: e.schema?.error,
50
+ schema: filterByKeyExclusion(e.schema, ["error"], true)
51
+ }))
52
+ }
53
+ };
48
54
  }
49
55
  case "NOT_FOUND":
50
- return status(404, {
51
- message: ERROR_KEYS.CORE_ERROR_NOT_FOUND
52
- });
56
+ set.status = 404;
57
+ return {
58
+ message: ERROR_KEYS.NOT_FOUND
59
+ };
53
60
  case "PARSE":
54
- return status(400, {
55
- message: ERROR_KEYS.CORE_ERROR_PARSE
56
- });
61
+ set.status = 400;
62
+ return {
63
+ message: ERROR_KEYS.PARSE
64
+ };
57
65
  case "INTERNAL_SERVER_ERROR":
58
66
  case "UNKNOWN":
59
67
  default:
60
- return status(500, {
61
- message: ERROR_KEYS.CORE_ERROR_INTERNAL_SERVER_ERROR
62
- });
68
+ set.status = 500;
69
+ return {
70
+ message: ERROR_KEYS.INTERNAL_SERVER_ERROR
71
+ };
63
72
  }
64
73
  }).as("global");
65
74
  export {
66
- errorManager
75
+ error
67
76
  };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  MICROSERVICE_SUCCESS_KEYS
4
- } from "../../../../chunk-0d0zd2yg.js";
4
+ } from "../../../../chunk-037vwvd4.js";
5
5
  export {
6
6
  MICROSERVICE_SUCCESS_KEYS
7
7
  };
@@ -1,4 +1,4 @@
1
1
  export declare const MICROSERVICE_SUCCESS_KEYS: {
2
- readonly PING_RESPONSE: "mrx-core.microservice.success.ping_response";
3
- readonly INFO_RETRIEVED: "mrx-core.microservice.success.info_retrieved";
2
+ readonly PING_RESPONSE: "mrx.mrx-core.microservice.success.ping_response";
3
+ readonly INFO_RETRIEVED: "mrx.mrx-core.microservice.success.info_retrieved";
4
4
  };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  MICROSERVICE_SUCCESS_KEYS
4
- } from "../../../chunk-0d0zd2yg.js";
4
+ } from "../../../chunk-037vwvd4.js";
5
5
 
6
6
  // source/modules/elysia/microservice/microservice.ts
7
7
  import { Elysia } from "elysia";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  RATE_LIMIT_ERROR_KEYS
4
- } from "../../../../chunk-dre2fgj0.js";
4
+ } from "../../../../chunk-2z8amjqt.js";
5
5
  export {
6
6
  RATE_LIMIT_ERROR_KEYS
7
7
  };
@@ -1,3 +1,3 @@
1
1
  export declare const RATE_LIMIT_ERROR_KEYS: {
2
- readonly RATE_LIMIT_EXCEEDED: "mrx-core.elysia.rate-limit.error.exceeded";
2
+ readonly RATE_LIMIT_EXCEEDED: "mrx.mrx-core.elysia.rate-limit.error.exceeded";
3
3
  };
@@ -1,16 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  RATE_LIMIT_ERROR_KEYS
4
- } from "../../../chunk-dre2fgj0.js";
4
+ } from "../../../chunk-2z8amjqt.js";
5
5
  import {
6
6
  MemoryStore
7
- } from "../../../chunk-e30paw8a.js";
8
- import"../../../chunk-xhhj1gvj.js";
7
+ } from "../../../chunk-j7dyc5ks.js";
8
+ import"../../../chunk-8pw0syzf.js";
9
9
  import {
10
10
  HttpError
11
- } from "../../../chunk-7t524zqh.js";
11
+ } from "../../../chunk-zv4ta4fb.js";
12
12
  import"../../../chunk-sqts8vyk.js";
13
- import"../../../chunk-9cgzhc50.js";
13
+ import"../../../chunk-jz3wd472.js";
14
14
 
15
15
  // source/modules/elysia/rate-limit/rate-limit.ts
16
16
  import { Elysia } from "elysia";
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  JWT_ERROR_KEYS
4
- } from "../../../chunk-9d3zvgp6.js";
4
+ } from "../../../chunk-zn2nm5gg.js";
5
5
  import {
6
6
  PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS
7
- } from "../../../chunk-12qzn7jw.js";
7
+ } from "../../../chunk-dmsev7vs.js";
8
8
  export {
9
9
  PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS,
10
10
  JWT_ERROR_KEYS
@@ -1,5 +1,5 @@
1
1
  export declare const JWT_ERROR_KEYS: {
2
- readonly JWT_EXPIRATION_PASSED: "mrx-core.jwt.error.expiration_passed";
3
- readonly JWT_SECRET_NOT_FOUND: "mrx-core.jwt.error.secret_not_found";
4
- readonly JWT_SIGN_ERROR: "mrx-core.jwt.error.sign_error";
2
+ readonly JWT_EXPIRATION_PASSED: "mrx.mrx-core.jwt.error.expiration_passed";
3
+ readonly JWT_SECRET_NOT_FOUND: "mrx.mrx-core.jwt.error.secret_not_found";
4
+ readonly JWT_SIGN_ERROR: "mrx.mrx-core.jwt.error.sign_error";
5
5
  };
@@ -1,3 +1,3 @@
1
1
  export declare const PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS: {
2
- readonly INVALID_TIME_EXPRESSION: "mrx-core.parse_human_time_to_seconds.error.invalid_time_expression";
2
+ readonly INVALID_TIME_EXPRESSION: "mrx.mrx-core.jwt.parse_human_time_to_seconds.error.invalid_time_expression";
3
3
  };
@@ -1,26 +1,24 @@
1
1
  // @bun
2
2
  import {
3
3
  JWT_ERROR_KEYS
4
- } from "../../chunk-9d3zvgp6.js";
4
+ } from "../../chunk-zn2nm5gg.js";
5
5
  import {
6
6
  parseHumanTimeToSeconds
7
- } from "../../chunk-eeb7yskp.js";
8
- import"../../chunk-12qzn7jw.js";
7
+ } from "../../chunk-awphtyzp.js";
8
+ import"../../chunk-dmsev7vs.js";
9
9
  import {
10
- HttpError
11
- } from "../../chunk-7t524zqh.js";
12
- import"../../chunk-sqts8vyk.js";
13
- import"../../chunk-9cgzhc50.js";
10
+ InternalError
11
+ } from "../../chunk-jz3wd472.js";
14
12
 
15
13
  // source/modules/jwt/jwt.ts
16
14
  import {
17
15
  SignJWT,
18
16
  jwtVerify
19
17
  } from "jose";
20
- var signJWT = (secret, payload, expiration = Math.floor(Date.now() / 1000) + 60 * 15) => {
21
- const exp = expiration instanceof Date ? Math.floor(expiration.getTime() / 1000) : typeof expiration === "number" ? expiration : Math.floor(Date.now() / 1000) + parseHumanTimeToSeconds(expiration);
18
+ var signJWT = (secret, payload, expiration = 60 * 15) => {
19
+ const exp = expiration instanceof Date ? Math.floor(expiration.getTime() / 1000) : typeof expiration === "number" ? Math.floor(Date.now() / 1000) + expiration : Math.floor(Date.now() / 1000) + parseHumanTimeToSeconds(expiration);
22
20
  if (exp <= Math.floor(Date.now() / 1000))
23
- throw new HttpError(JWT_ERROR_KEYS.JWT_EXPIRATION_PASSED, "BAD_REQUEST");
21
+ throw new InternalError(JWT_ERROR_KEYS.JWT_EXPIRATION_PASSED);
24
22
  const finalPayload = {
25
23
  iss: "Core-Issuer",
26
24
  sub: "",
@@ -32,10 +30,10 @@ var signJWT = (secret, payload, expiration = Math.floor(Date.now() / 1000) + 60
32
30
  ...payload
33
31
  };
34
32
  try {
35
- const jwt = new SignJWT(finalPayload).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuer(finalPayload.iss).setSubject(finalPayload.sub).setAudience(finalPayload.aud).setJti(finalPayload.jti).setNotBefore(finalPayload.nbf).setIssuedAt(finalPayload.iat).setExpirationTime(expiration).sign(new TextEncoder().encode(secret));
33
+ const jwt = new SignJWT(finalPayload).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuer(finalPayload.iss).setSubject(finalPayload.sub).setAudience(finalPayload.aud).setJti(finalPayload.jti).setNotBefore(finalPayload.nbf).setIssuedAt(finalPayload.iat).setExpirationTime(exp).sign(new TextEncoder().encode(secret));
36
34
  return jwt;
37
35
  } catch (error) {
38
- throw new HttpError(JWT_ERROR_KEYS.JWT_SIGN_ERROR, "INTERNAL_SERVER_ERROR", error);
36
+ throw new InternalError(JWT_ERROR_KEYS.JWT_SIGN_ERROR, error);
39
37
  }
40
38
  };
41
39
  var verifyJWT = async (token, secret) => {
@@ -1,9 +1,9 @@
1
1
  // @bun
2
2
  import {
3
3
  parseHumanTimeToSeconds
4
- } from "../../../chunk-eeb7yskp.js";
5
- import"../../../chunk-12qzn7jw.js";
6
- import"../../../chunk-9cgzhc50.js";
4
+ } from "../../../chunk-awphtyzp.js";
5
+ import"../../../chunk-dmsev7vs.js";
6
+ import"../../../chunk-jz3wd472.js";
7
7
  export {
8
8
  parseHumanTimeToSeconds
9
9
  };
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @param timeExpression - A string representing a time period (e.g., "2 hours", "30 minutes ago", "+1 day")
5
5
  *
6
- * @throws ({@link BaseError}) - If the time expression is invalid or contains an unknown unit
6
+ * @throws ({@link InternalError}) - If the time expression is invalid or contains an unknown unit
7
7
  *
8
8
  * @returns The time period in seconds (negative for past times)
9
9
  *
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  KV_STORE_ERROR_KEYS
4
- } from "../../../chunk-xhhj1gvj.js";
4
+ } from "../../../chunk-8pw0syzf.js";
5
5
  import {
6
- BaseError
7
- } from "../../../chunk-9cgzhc50.js";
6
+ InternalError
7
+ } from "../../../chunk-jz3wd472.js";
8
8
 
9
9
  // source/modules/kv-store/bun-redis/bun-redis-store.ts
10
10
  var {RedisClient } = globalThis.Bun;
@@ -17,14 +17,14 @@ class BunRedisStore {
17
17
  try {
18
18
  await this._client.connect();
19
19
  } catch (e) {
20
- throw new BaseError(KV_STORE_ERROR_KEYS.CONNECTION_FAILED, e);
20
+ throw new InternalError(KV_STORE_ERROR_KEYS.CONNECTION_FAILED, e);
21
21
  }
22
22
  }
23
23
  close() {
24
24
  try {
25
25
  this._client.close();
26
26
  } catch (e) {
27
- throw new BaseError(KV_STORE_ERROR_KEYS.CLOSING_CONNECTION_FAILED, e);
27
+ throw new InternalError(KV_STORE_ERROR_KEYS.CLOSING_CONNECTION_FAILED, e);
28
28
  }
29
29
  }
30
30
  async get(key) {
@@ -49,7 +49,7 @@ class BunRedisStore {
49
49
  const number = await this._client.incrby(key, amount ?? 1);
50
50
  return number;
51
51
  } catch (e) {
52
- throw new BaseError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
52
+ throw new InternalError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
53
53
  }
54
54
  }
55
55
  async decrement(key, amount) {
@@ -57,7 +57,7 @@ class BunRedisStore {
57
57
  const number = await this._client.decrby(key, amount ?? 1);
58
58
  return number;
59
59
  } catch (e) {
60
- throw new BaseError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
60
+ throw new InternalError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
61
61
  }
62
62
  }
63
63
  async del(key) {
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  KV_STORE_ERROR_KEYS
4
- } from "../../../chunk-xhhj1gvj.js";
4
+ } from "../../../chunk-8pw0syzf.js";
5
5
  export {
6
6
  KV_STORE_ERROR_KEYS
7
7
  };
@@ -1,5 +1,5 @@
1
1
  export declare const KV_STORE_ERROR_KEYS: {
2
- readonly CLOSING_CONNECTION_FAILED: "mrx-core.kv-store.error.closing_connection_failed";
3
- readonly CONNECTION_FAILED: "mrx-core.kv-store.error.connection_failed";
4
- readonly NOT_INTEGER: "mrx-core.kv-store.error.not_integer";
2
+ readonly CLOSING_CONNECTION_FAILED: "mrx.mrx-core.kv-store.error.closing_connection_failed";
3
+ readonly CONNECTION_FAILED: "mrx.mrx-core.kv-store.error.connection_failed";
4
+ readonly NOT_INTEGER: "mrx.mrx-core.kv-store.error.not_integer";
5
5
  };
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  KV_STORE_ERROR_KEYS
4
- } from "../../../chunk-xhhj1gvj.js";
4
+ } from "../../../chunk-8pw0syzf.js";
5
5
  import {
6
- BaseError
7
- } from "../../../chunk-9cgzhc50.js";
6
+ InternalError
7
+ } from "../../../chunk-jz3wd472.js";
8
8
 
9
9
  // source/modules/kv-store/ioredis/ioredis-store.ts
10
10
  import { Redis } from "ioredis";
@@ -20,14 +20,14 @@ class IoRedisStore {
20
20
  try {
21
21
  await this._client.connect();
22
22
  } catch (e) {
23
- throw new BaseError(KV_STORE_ERROR_KEYS.CONNECTION_FAILED, e);
23
+ throw new InternalError(KV_STORE_ERROR_KEYS.CONNECTION_FAILED, e);
24
24
  }
25
25
  }
26
26
  async close() {
27
27
  try {
28
28
  await this._client.quit();
29
29
  } catch (e) {
30
- throw new BaseError(KV_STORE_ERROR_KEYS.CLOSING_CONNECTION_FAILED, e);
30
+ throw new InternalError(KV_STORE_ERROR_KEYS.CLOSING_CONNECTION_FAILED, e);
31
31
  }
32
32
  }
33
33
  async get(key) {
@@ -52,7 +52,7 @@ class IoRedisStore {
52
52
  const number = await this._client.incrby(key, amount);
53
53
  return number;
54
54
  } catch (e) {
55
- throw new BaseError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
55
+ throw new InternalError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
56
56
  }
57
57
  }
58
58
  async decrement(key, amount = 1) {
@@ -60,7 +60,7 @@ class IoRedisStore {
60
60
  const number = await this._client.decrby(key, amount);
61
61
  return number;
62
62
  } catch (e) {
63
- throw new BaseError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
63
+ throw new InternalError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
64
64
  }
65
65
  }
66
66
  async del(key) {
@@ -1,9 +1,9 @@
1
1
  // @bun
2
2
  import {
3
3
  MemoryStore
4
- } from "../../../chunk-e30paw8a.js";
5
- import"../../../chunk-xhhj1gvj.js";
6
- import"../../../chunk-9cgzhc50.js";
4
+ } from "../../../chunk-j7dyc5ks.js";
5
+ import"../../../chunk-8pw0syzf.js";
6
+ import"../../../chunk-jz3wd472.js";
7
7
  export {
8
8
  MemoryStore
9
9
  };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  LOGGER_ERROR_KEYS
4
- } from "../../../chunk-rz5p4j3p.js";
4
+ } from "../../../chunk-6hs00zfd.js";
5
5
  export {
6
6
  LOGGER_ERROR_KEYS
7
7
  };
@@ -1,9 +1,9 @@
1
1
  export declare const LOGGER_ERROR_KEYS: {
2
- readonly BEFORE_EXIT_CLOSE_ERROR: "mrx-core.logger.error.before_exit_close_error";
3
- readonly BEFORE_EXIT_FLUSH_ERROR: "mrx-core.logger.error.before_exit_flush_error";
4
- readonly NO_SINKS_PROVIDED: "mrx-core.logger.error.no_sinks_provided";
5
- readonly REGISTER_SINK_ERROR: "mrx-core.logger.error.register_sink_error";
6
- readonly SINK_ALREADY_ADDED: "mrx-core.logger.error.sink_already_added";
7
- readonly SINK_CLOSE_ERROR: "mrx-core.logger.error.sink_close_error";
8
- readonly SINK_LOG_ERROR: "mrx-core.logger.error.sink_log_error";
2
+ readonly BEFORE_EXIT_CLOSE_ERROR: "mrx.mrx-core.logger.error.before_exit_close_error";
3
+ readonly BEFORE_EXIT_FLUSH_ERROR: "mrx.mrx-core.logger.error.before_exit_flush_error";
4
+ readonly NO_SINKS_PROVIDED: "mrx.mrx-core.logger.error.no_sinks_provided";
5
+ readonly REGISTER_SINK_ERROR: "mrx.mrx-core.logger.error.register_sink_error";
6
+ readonly SINK_ALREADY_ADDED: "mrx.mrx-core.logger.error.sink_already_added";
7
+ readonly SINK_CLOSE_ERROR: "mrx.mrx-core.logger.error.sink_close_error";
8
+ readonly SINK_LOG_ERROR: "mrx.mrx-core.logger.error.sink_log_error";
9
9
  };
@@ -1,16 +1,16 @@
1
- import type { BaseError } from '../../../errors/base-error';
1
+ import type { InternalError } from '../../../errors/internal-error';
2
2
  export interface LoggerEvent {
3
- onBeforeExitError: [BaseError<{
3
+ onBeforeExitError: [InternalError<{
4
4
  error: Error;
5
5
  }>];
6
6
  registerSinkError: [
7
- BaseError<{
7
+ InternalError<{
8
8
  sinkName: string;
9
9
  error: Error;
10
10
  }>
11
11
  ];
12
12
  sinkError: [
13
- BaseError<{
13
+ InternalError<{
14
14
  sinkName: string;
15
15
  object?: unknown;
16
16
  error: Error;
@@ -1,13 +1,88 @@
1
1
  // @bun
2
+ import"../typed-event-emitter/index.js";
2
3
  import {
3
4
  LOGGER_ERROR_KEYS
4
- } from "../../chunk-rz5p4j3p.js";
5
+ } from "../../chunk-6hs00zfd.js";
5
6
  import {
6
7
  TypedEventEmitter
7
8
  } from "../../chunk-mvrxngm7.js";
8
9
  import {
9
- BaseError
10
- } from "../../chunk-9cgzhc50.js";
10
+ InternalError
11
+ } from "../../chunk-jz3wd472.js";
12
+
13
+ // source/modules/logger/worker-logger.ts
14
+ var workerFunction = () => {
15
+ const sinks = {};
16
+ const self = globalThis;
17
+ const processLogEntry = async (log) => {
18
+ await Promise.all(log.sinkNames.map(async (sinkName) => {
19
+ const sink = sinks[sinkName];
20
+ if (!sink)
21
+ return;
22
+ try {
23
+ await sink.log(log.level, log.timestamp, log.object);
24
+ } catch (error) {
25
+ self.postMessage({
26
+ type: "SINK_LOG_ERROR",
27
+ sinkName,
28
+ error,
29
+ object: log.object
30
+ });
31
+ }
32
+ }));
33
+ };
34
+ self.addEventListener("message", async (event) => {
35
+ switch (event.data.type) {
36
+ case "REGISTER_SINK": {
37
+ const {
38
+ sinkName,
39
+ sinkClassName,
40
+ sinkClassString,
41
+ sinkArgs
42
+ } = event.data;
43
+ try {
44
+ const factory = new Function("sinkArgs", `
45
+ ${sinkClassString}
46
+ return new ${sinkClassName}(...sinkArgs);
47
+ `);
48
+ sinks[sinkName] = factory(sinkArgs);
49
+ } catch (error) {
50
+ self.postMessage({
51
+ type: "REGISTER_SINK_ERROR",
52
+ sinkName,
53
+ error
54
+ });
55
+ }
56
+ break;
57
+ }
58
+ case "LOG_BATCH": {
59
+ const { logs } = event.data;
60
+ try {
61
+ for (const log of logs)
62
+ await processLogEntry(log);
63
+ } finally {
64
+ self.postMessage({ type: "BATCH_COMPLETE" });
65
+ }
66
+ break;
67
+ }
68
+ case "CLOSE": {
69
+ await Promise.all(Object.entries(sinks).map(async ([name, sink]) => {
70
+ try {
71
+ await sink.close?.();
72
+ } catch (error) {
73
+ self.postMessage({
74
+ type: "SINK_CLOSE_ERROR",
75
+ sinkName: name,
76
+ error
77
+ });
78
+ }
79
+ }));
80
+ self.postMessage({ type: "CLOSE_COMPLETE" });
81
+ break;
82
+ }
83
+ }
84
+ });
85
+ };
11
86
 
12
87
  // source/modules/logger/logger.ts
13
88
  class Logger extends TypedEventEmitter {
@@ -51,14 +126,14 @@ class Logger extends TypedEventEmitter {
51
126
  this._batchTimeout = batchTimeout;
52
127
  this._autoEnd = autoEnd;
53
128
  this._flushOnBeforeExit = flushOnBeforeExit;
54
- this._worker = new Worker(new URL("worker-logger.ts", import.meta.url).href, { type: "module" });
129
+ this._worker = new Worker(URL.createObjectURL(new Blob([`(${workerFunction.toString()})()`], { type: "application/javascript" })), { type: "module" });
55
130
  this._setupWorkerMessages();
56
131
  if (this._autoEnd)
57
132
  this._setupAutoEnd();
58
133
  }
59
134
  registerSink(sinkName, sinkConstructor, ...sinkArgs) {
60
135
  if (this._sinks[sinkName])
61
- throw new BaseError(LOGGER_ERROR_KEYS.SINK_ALREADY_ADDED);
136
+ throw new InternalError(LOGGER_ERROR_KEYS.SINK_ALREADY_ADDED);
62
137
  this._worker.postMessage({
63
138
  type: "REGISTER_SINK",
64
139
  sinkName,
@@ -105,7 +180,7 @@ class Logger extends TypedEventEmitter {
105
180
  }
106
181
  _enqueue(level, object, sinkNames) {
107
182
  if (this._sinkKeys.length === 0)
108
- throw new BaseError(LOGGER_ERROR_KEYS.NO_SINKS_PROVIDED, { level, object });
183
+ throw new InternalError(LOGGER_ERROR_KEYS.NO_SINKS_PROVIDED, { level, object });
109
184
  if (this._pendingLogs.length >= this._maxPendingLogs)
110
185
  return;
111
186
  this._pendingLogs.push({
@@ -168,14 +243,14 @@ class Logger extends TypedEventEmitter {
168
243
  }
169
244
  break;
170
245
  case "SINK_LOG_ERROR":
171
- this.emit("sinkError", new BaseError(LOGGER_ERROR_KEYS.SINK_LOG_ERROR, event.data));
246
+ this.emit("sinkError", new InternalError(LOGGER_ERROR_KEYS.SINK_LOG_ERROR, event.data));
172
247
  this._releaseBatch();
173
248
  break;
174
249
  case "SINK_CLOSE_ERROR":
175
- this.emit("sinkError", new BaseError(LOGGER_ERROR_KEYS.SINK_CLOSE_ERROR, event.data));
250
+ this.emit("sinkError", new InternalError(LOGGER_ERROR_KEYS.SINK_CLOSE_ERROR, event.data));
176
251
  break;
177
252
  case "REGISTER_SINK_ERROR":
178
- this.emit("registerSinkError", new BaseError(LOGGER_ERROR_KEYS.REGISTER_SINK_ERROR, event.data));
253
+ this.emit("registerSinkError", new InternalError(LOGGER_ERROR_KEYS.REGISTER_SINK_ERROR, event.data));
179
254
  break;
180
255
  case "CLOSE_COMPLETE":
181
256
  this._worker.terminate();
@@ -195,11 +270,11 @@ class Logger extends TypedEventEmitter {
195
270
  _handleBeforeExit = () => {
196
271
  if (this._flushOnBeforeExit)
197
272
  this.flush().then(() => this.close()).catch((error) => {
198
- this.emit("onBeforeExitError", new BaseError(LOGGER_ERROR_KEYS.BEFORE_EXIT_FLUSH_ERROR, { error }));
273
+ this.emit("onBeforeExitError", new InternalError(LOGGER_ERROR_KEYS.BEFORE_EXIT_FLUSH_ERROR, { error }));
199
274
  });
200
275
  else
201
276
  this.close().catch((error) => {
202
- this.emit("onBeforeExitError", new BaseError(LOGGER_ERROR_KEYS.BEFORE_EXIT_CLOSE_ERROR, { error }));
277
+ this.emit("onBeforeExitError", new InternalError(LOGGER_ERROR_KEYS.BEFORE_EXIT_CLOSE_ERROR, { error }));
203
278
  });
204
279
  };
205
280
  }
@@ -1,4 +1,4 @@
1
- import { TypedEventEmitter } from '../../modules/typed-event-emitter/typed-event-emitter';
1
+ import { TypedEventEmitter } from '../../modules/typed-event-emitter';
2
2
  import type { LoggerEvent } from './events/logger-events';
3
3
  import type { LoggerOptions } from './types/logger-options';
4
4
  import type { LoggerSink } from './types/logger-sink';
@@ -4,5 +4,5 @@ import type { LoggerSink } from '../../../modules/logger/types/logger-sink';
4
4
  * ConsoleLoggerSink implements LoggerSink to provide logging functionality to the console.
5
5
  */
6
6
  export declare class ConsoleLoggerSink<TLogObject = unknown> implements LoggerSink<TLogObject> {
7
- log(level: LogLevels, timestamp: number, object: TLogObject): Promise<void>;
7
+ log(level: LogLevels, timestamp: number, object: TLogObject): void;
8
8
  }
@@ -1,3 +1,3 @@
1
1
  export declare const FILE_LOGGER_ERROR_KEYS: {
2
- readonly FAILED_TO_CLOSE_STREAM: "mrx-core.file_logger.error.failed_to_close_stream";
2
+ readonly FAILED_TO_CLOSE_STREAM: "nowarajs.logger.file_logger.error.failed_to_close_stream";
3
3
  };