@mrxsys/mrx-core 2.11.0-1-and-276-20251029 → 2.11.0-2-and-276-20251029

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 (146) hide show
  1. package/dist/errors/utils/is-nowarajs-error.ts.d.ts +2 -2
  2. package/dist/modules/data/transformers/camel-case.d.ts +2 -2
  3. package/dist/modules/data/transformers/kebab-case.d.ts +2 -2
  4. package/dist/modules/data/transformers/pascal-case.d.ts +2 -2
  5. package/dist/modules/data/transformers/snake-case.d.ts +2 -2
  6. package/dist/modules/data/types/transform-object-keys.d.ts +4 -4
  7. package/dist/modules/database/events/mssql-event-map.d.ts +1 -1
  8. package/dist/modules/database/events/table-event-map.d.ts +1 -1
  9. package/dist/modules/database/mssql.d.ts +2 -2
  10. package/dist/modules/database/table.d.ts +2 -2
  11. package/dist/modules/elysia/cache/cache.d.ts +1 -1
  12. package/dist/modules/elysia/crud/crud.d.ts +2 -2
  13. package/dist/modules/elysia/crud/operations/count.d.ts +3 -3
  14. package/dist/modules/elysia/crud/operations/delete.d.ts +3 -3
  15. package/dist/modules/elysia/crud/operations/deleteOne.d.ts +3 -3
  16. package/dist/modules/elysia/crud/operations/find.d.ts +3 -3
  17. package/dist/modules/elysia/crud/operations/findOne.d.ts +3 -3
  18. package/dist/modules/elysia/crud/operations/insert.d.ts +3 -3
  19. package/dist/modules/elysia/crud/operations/update.d.ts +3 -3
  20. package/dist/modules/elysia/crud/operations/updateOne.d.ts +3 -3
  21. package/dist/modules/elysia/crud/operations/utils/get-db-injection.d.ts +1 -1
  22. package/dist/modules/elysia/crud/types/crud-options.d.ts +1 -1
  23. package/dist/modules/elysia/crud/types/crud-schema-models-type.d.ts +9 -9
  24. package/dist/modules/elysia/crud/types/delete-schema.d.ts +2 -2
  25. package/dist/modules/elysia/crud/types/find-schema.d.ts +3 -3
  26. package/dist/modules/elysia/crud/types/insert-schema.d.ts +1 -1
  27. package/dist/modules/elysia/crud/types/properties-schema.d.ts +1 -1
  28. package/dist/modules/elysia/crud/types/response-200-schema.d.ts +1 -1
  29. package/dist/modules/elysia/crud/types/update-schema.d.ts +2 -2
  30. package/dist/modules/elysia/crud/utils/create-adaptive-where-clause-schema.d.ts +1 -1
  31. package/dist/modules/elysia/crud/utils/create-count-response-200-schema.d.ts +1 -1
  32. package/dist/modules/elysia/crud/utils/create-count-schema.d.ts +1 -1
  33. package/dist/modules/elysia/crud/utils/create-delete-schema.d.ts +1 -1
  34. package/dist/modules/elysia/crud/utils/create-filters-schema.d.ts +1 -1
  35. package/dist/modules/elysia/crud/utils/create-find-schema.d.ts +1 -1
  36. package/dist/modules/elysia/crud/utils/create-id-param-schema.d.ts +1 -1
  37. package/dist/modules/elysia/crud/utils/create-insert-schema.d.ts +1 -1
  38. package/dist/modules/elysia/crud/utils/create-order-schema.d.ts +1 -1
  39. package/dist/modules/elysia/crud/utils/create-properties-schema.d.ts +1 -1
  40. package/dist/modules/elysia/crud/utils/create-q-schema.d.ts +1 -1
  41. package/dist/modules/elysia/crud/utils/create-response-200-schema.d.ts +1 -1
  42. package/dist/modules/elysia/crud/utils/create-selected-fields-schema.d.ts +1 -1
  43. package/dist/modules/elysia/crud/utils/create-update-one-schema.d.ts +1 -1
  44. package/dist/modules/elysia/crud/utils/create-update-schema.d.ts +1 -1
  45. package/dist/modules/elysia/db-resolver/db-resolver.d.ts +2 -2
  46. package/dist/modules/elysia/rate-limit/rate-limit.d.ts +1 -1
  47. package/dist/modules/kv-store/bun-redis/bun-redis-store.d.ts +1 -1
  48. package/dist/modules/kv-store/ioredis/ioredis-store.d.ts +1 -1
  49. package/dist/modules/kv-store/memory/memory-store.d.ts +1 -1
  50. package/dist/modules/logger/events/logger-events.d.ts +1 -1
  51. package/dist/modules/logger/logger.d.ts +1 -1
  52. package/dist/modules/logger/sinks/console-logger.d.ts +2 -2
  53. package/dist/modules/logger/sinks/devnull-logger.d.ts +1 -1
  54. package/dist/modules/logger/sinks/file-logger/file-logger.d.ts +2 -2
  55. package/dist/modules/repository/repository.d.ts +2 -2
  56. package/dist/modules/repository/types/query-options.d.ts +1 -1
  57. package/dist/shared/utils/flatten.d.ts +1 -1
  58. package/package.json +1 -1
  59. package/dist/chunk-0d0zd2yg.js +0 -8
  60. package/dist/chunk-12qzn7jw.js +0 -7
  61. package/dist/chunk-441xs5k1.js +0 -53
  62. package/dist/chunk-4v86f7gp.js +0 -59
  63. package/dist/chunk-6w9ja96e.js +0 -9
  64. package/dist/chunk-7t524zqh.js +0 -26
  65. package/dist/chunk-8tffnbpn.js +0 -7
  66. package/dist/chunk-9cgzhc50.js +0 -15
  67. package/dist/chunk-9d3zvgp6.js +0 -9
  68. package/dist/chunk-9dzsj7f2.js +0 -23
  69. package/dist/chunk-9r5anep5.js +0 -11
  70. package/dist/chunk-afd82epa.js +0 -201
  71. package/dist/chunk-afyz8rg5.js +0 -209
  72. package/dist/chunk-dre2fgj0.js +0 -7
  73. package/dist/chunk-e30paw8a.js +0 -101
  74. package/dist/chunk-eeb7yskp.js +0 -61
  75. package/dist/chunk-fs3wm3p4.js +0 -32
  76. package/dist/chunk-grfyngq0.js +0 -39
  77. package/dist/chunk-gtn1kn0z.js +0 -79
  78. package/dist/chunk-jksb9ers.js +0 -7
  79. package/dist/chunk-m3grz32t.js +0 -27
  80. package/dist/chunk-mvrxngm7.js +0 -41
  81. package/dist/chunk-n0n14mf8.js +0 -7
  82. package/dist/chunk-p14h6jfs.js +0 -365
  83. package/dist/chunk-pjv1ekwr.js +0 -284
  84. package/dist/chunk-rz5p4j3p.js +0 -13
  85. package/dist/chunk-spnh9dzk.js +0 -10
  86. package/dist/chunk-sqts8vyk.js +0 -60
  87. package/dist/chunk-w7h898m3.js +0 -14
  88. package/dist/chunk-xhhj1gvj.js +0 -9
  89. package/dist/chunk-z0ct35ft.js +0 -8
  90. package/dist/errors/enums/index.js +0 -7
  91. package/dist/errors/index.js +0 -12
  92. package/dist/errors/utils/index.js +0 -16
  93. package/dist/modules/data/enums/index.js +0 -7
  94. package/dist/modules/data/index.js +0 -17
  95. package/dist/modules/data/transformers/index.js +0 -32
  96. package/dist/modules/data/types/index.js +0 -1
  97. package/dist/modules/database/enums/index.js +0 -9
  98. package/dist/modules/database/events/index.js +0 -1
  99. package/dist/modules/database/index.js +0 -16
  100. package/dist/modules/database/types/index.js +0 -1
  101. package/dist/modules/elysia/cache/index.js +0 -90
  102. package/dist/modules/elysia/cache/types/index.js +0 -1
  103. package/dist/modules/elysia/crud/enums/index.js +0 -7
  104. package/dist/modules/elysia/crud/index.js +0 -153
  105. package/dist/modules/elysia/crud/operations/index.js +0 -34
  106. package/dist/modules/elysia/crud/types/index.js +0 -1
  107. package/dist/modules/elysia/crud/utils/index.js +0 -41
  108. package/dist/modules/elysia/db-resolver/enums/index.js +0 -7
  109. package/dist/modules/elysia/db-resolver/index.js +0 -18
  110. package/dist/modules/elysia/error/enums/index.js +0 -7
  111. package/dist/modules/elysia/error/error.d.ts +0 -37
  112. package/dist/modules/elysia/error/index.js +0 -73
  113. package/dist/modules/elysia/microservice/enums/index.js +0 -7
  114. package/dist/modules/elysia/microservice/index.js +0 -100
  115. package/dist/modules/elysia/rate-limit/enums/index.js +0 -7
  116. package/dist/modules/elysia/rate-limit/index.js +0 -81
  117. package/dist/modules/elysia/rate-limit/types/index.js +0 -1
  118. package/dist/modules/jwt/enums/index.js +0 -11
  119. package/dist/modules/jwt/index.js +0 -51
  120. package/dist/modules/jwt/utils/index.js +0 -9
  121. package/dist/modules/kv-store/bun-redis/index.js +0 -84
  122. package/dist/modules/kv-store/enums/index.js +0 -7
  123. package/dist/modules/kv-store/ioredis/index.js +0 -86
  124. package/dist/modules/kv-store/memory/index.js +0 -9
  125. package/dist/modules/kv-store/types/index.js +0 -1
  126. package/dist/modules/logger/enums/index.js +0 -7
  127. package/dist/modules/logger/events/index.js +0 -1
  128. package/dist/modules/logger/index.js +0 -208
  129. package/dist/modules/logger/sinks/index.js +0 -66
  130. package/dist/modules/logger/types/index.js +0 -1
  131. package/dist/modules/mailer/enums/index.js +0 -7
  132. package/dist/modules/mailer/index.js +0 -55
  133. package/dist/modules/mailer/types/index.js +0 -1
  134. package/dist/modules/repository/index.js +0 -12
  135. package/dist/modules/repository/types/index.js +0 -1
  136. package/dist/modules/singleton-manager/enums/index.js +0 -7
  137. package/dist/modules/singleton-manager/index.js +0 -9
  138. package/dist/modules/totp/enums/index.js +0 -7
  139. package/dist/modules/totp/index.js +0 -104
  140. package/dist/modules/totp/types/index.js +0 -1
  141. package/dist/modules/totp/utils/index.js +0 -76
  142. package/dist/modules/typed-event-emitter/index.js +0 -7
  143. package/dist/modules/typed-event-emitter/types/index.js +0 -1
  144. package/dist/shared/enums/index.js +0 -7
  145. package/dist/shared/types/index.js +0 -1
  146. package/dist/shared/utils/index.js +0 -30
@@ -1,73 +0,0 @@
1
- // @bun
2
- import {
3
- ERROR_KEYS
4
- } from "../../../chunk-spnh9dzk.js";
5
- import {
6
- filterByKeyExclusion
7
- } from "../../../chunk-gtn1kn0z.js";
8
- import"../../../chunk-jksb9ers.js";
9
- import {
10
- HttpError
11
- } from "../../../chunk-7t524zqh.js";
12
- import"../../../chunk-sqts8vyk.js";
13
- import {
14
- BaseError
15
- } from "../../../chunk-9cgzhc50.js";
16
-
17
- // source/modules/elysia/error/error.ts
18
- import { Elysia } from "elysia";
19
- var error = new Elysia({
20
- name: "errorPlugin"
21
- }).error({
22
- BaseError,
23
- HttpError
24
- }).onError(({ code, error: error2, set, status }) => {
25
- set.headers["content-type"] = "application/json; charset=utf-8";
26
- switch (code) {
27
- case "HttpError":
28
- status(error2.httpStatusCode, {
29
- message: error2.message,
30
- content: error2.cause
31
- });
32
- break;
33
- case "BaseError":
34
- status(500, {
35
- message: ERROR_KEYS.CORE_ERROR_INTERNAL_SERVER_ERROR,
36
- content: error2.cause
37
- });
38
- break;
39
- case "VALIDATION": {
40
- status(422, {
41
- on: error2.type,
42
- errors: error2.all.map((e) => ({
43
- path: e.path,
44
- value: e.value,
45
- summary: e.summary,
46
- message: e.schema?.error,
47
- schema: filterByKeyExclusion(e.schema, ["error"], true)
48
- }))
49
- });
50
- break;
51
- }
52
- case "NOT_FOUND":
53
- status(404, {
54
- message: ERROR_KEYS.CORE_ERROR_NOT_FOUND
55
- });
56
- break;
57
- case "PARSE":
58
- status(400, {
59
- message: ERROR_KEYS.CORE_ERROR_PARSE
60
- });
61
- break;
62
- case "INTERNAL_SERVER_ERROR":
63
- case "UNKNOWN":
64
- default:
65
- status(500, {
66
- message: ERROR_KEYS.CORE_ERROR_INTERNAL_SERVER_ERROR
67
- });
68
- break;
69
- }
70
- }).as("global");
71
- export {
72
- error
73
- };
@@ -1,7 +0,0 @@
1
- // @bun
2
- import {
3
- MICROSERVICE_SUCCESS_KEYS
4
- } from "../../../../chunk-0d0zd2yg.js";
5
- export {
6
- MICROSERVICE_SUCCESS_KEYS
7
- };
@@ -1,100 +0,0 @@
1
- // @bun
2
- import {
3
- MICROSERVICE_SUCCESS_KEYS
4
- } from "../../../chunk-0d0zd2yg.js";
5
-
6
- // source/modules/elysia/microservice/microservice.ts
7
- import { Elysia } from "elysia";
8
- import { existsSync } from "fs";
9
- import { platform } from "os";
10
-
11
- // source/modules/elysia/microservice/schemas/info.ts
12
- import { t } from "elysia";
13
- var infoResponse200Schema = t.Object({
14
- message: t.String({
15
- description: "Message",
16
- example: "Microservice Information"
17
- }),
18
- content: t.Object({
19
- author: t.String({
20
- description: "Author",
21
- example: "Ruby"
22
- }),
23
- name: t.String({
24
- description: "Name",
25
- example: "API"
26
- }),
27
- version: t.String({
28
- description: "Version",
29
- example: "1.0.0"
30
- }),
31
- description: t.String({
32
- description: "Description",
33
- example: "Is a microservice that provides a RESTful API for the application."
34
- })
35
- })
36
- });
37
-
38
- // source/modules/elysia/microservice/schemas/ping.ts
39
- import { t as t2 } from "elysia";
40
- var pingResponse200Schema = t2.Object({
41
- message: t2.String({
42
- description: "Message",
43
- example: "pong"
44
- })
45
- });
46
-
47
- // source/modules/elysia/microservice/microservice.ts
48
- var findPackageJson = (path) => {
49
- const isWin = platform() === "win32";
50
- const separator = isWin ? "\\" : "/";
51
- if (isWin && /^[A-Z]:\\$/i.test(path) || !isWin && path === "/")
52
- return "";
53
- const packageJsonPath = path + separator + "package.json";
54
- if (existsSync(packageJsonPath))
55
- return packageJsonPath;
56
- const pathParts = path.split(separator);
57
- if (pathParts.length <= 1)
58
- return "";
59
- const newPath = pathParts.slice(0, -1).join(separator);
60
- if (newPath === "")
61
- return "";
62
- return findPackageJson(newPath);
63
- };
64
- var packageJson = await import(findPackageJson(Bun.main));
65
- var microservice = new Elysia({
66
- name: "microservicePlugin",
67
- prefix: "/microservice",
68
- detail: {
69
- tags: ["Microservice"],
70
- security: []
71
- }
72
- }).model({
73
- infoResponse200: infoResponse200Schema,
74
- pingResponse200: pingResponse200Schema
75
- }).get("/ping", () => ({
76
- message: MICROSERVICE_SUCCESS_KEYS.PING_RESPONSE
77
- }), {
78
- detail: {
79
- summary: "Ping",
80
- description: "Ping the microservice to check if it is alive"
81
- },
82
- response: "pingResponse200"
83
- }).get("/info", () => ({
84
- message: MICROSERVICE_SUCCESS_KEYS.INFO_RETRIEVED,
85
- content: {
86
- name: packageJson.default.name,
87
- version: packageJson.default.version,
88
- description: packageJson.default.description,
89
- author: packageJson.default.author
90
- }
91
- }), {
92
- detail: {
93
- summary: "Info",
94
- description: "Get information about the microservice"
95
- },
96
- response: "infoResponse200"
97
- }).as("scoped");
98
- export {
99
- microservice
100
- };
@@ -1,7 +0,0 @@
1
- // @bun
2
- import {
3
- RATE_LIMIT_ERROR_KEYS
4
- } from "../../../../chunk-dre2fgj0.js";
5
- export {
6
- RATE_LIMIT_ERROR_KEYS
7
- };
@@ -1,81 +0,0 @@
1
- // @bun
2
- import {
3
- RATE_LIMIT_ERROR_KEYS
4
- } from "../../../chunk-dre2fgj0.js";
5
- import {
6
- MemoryStore
7
- } from "../../../chunk-e30paw8a.js";
8
- import"../../../chunk-xhhj1gvj.js";
9
- import {
10
- HttpError
11
- } from "../../../chunk-7t524zqh.js";
12
- import"../../../chunk-sqts8vyk.js";
13
- import"../../../chunk-9cgzhc50.js";
14
-
15
- // source/modules/elysia/rate-limit/rate-limit.ts
16
- import { Elysia } from "elysia";
17
- var rateLimit = (store) => {
18
- const restrictedRoutes = new Map;
19
- store = store || new MemoryStore;
20
- const rateLimitCheck = async (key, limit, window, set) => {
21
- if (set.headers["X-RateLimit-Limit"])
22
- return;
23
- let count = await store.get(key) ?? 0;
24
- if (count === 0) {
25
- await store.set(key, 1, window);
26
- count = 1;
27
- } else {
28
- count = await store.increment(key);
29
- }
30
- const remaining = Math.max(0, limit - count);
31
- const resetTime = await store.ttl(key);
32
- set.headers = {
33
- "X-RateLimit-Limit": limit.toString(),
34
- "X-RateLimit-Remaining": remaining.toString(),
35
- "X-RateLimit-Reset": resetTime.toString()
36
- };
37
- if (count > limit) {
38
- set.status = 429;
39
- throw new HttpError(RATE_LIMIT_ERROR_KEYS.RATE_LIMIT_EXCEEDED, "TOO_MANY_REQUESTS", {
40
- limit,
41
- window,
42
- remaining: 0,
43
- reset: resetTime
44
- });
45
- }
46
- };
47
- return new Elysia({
48
- name: "rateLimit",
49
- seed: {
50
- store
51
- }
52
- }).macro({
53
- rateLimit: ({ limit, window }) => ({
54
- transform: ({ request }) => {
55
- const route = `${request.method}:${new URL(request.url).pathname}`;
56
- if (!restrictedRoutes.has(route)) {
57
- restrictedRoutes.set(route, { limit, window });
58
- } else if (restrictedRoutes.has(route)) {
59
- const existing = restrictedRoutes.get(route);
60
- if (limit != existing.limit || window != existing.window)
61
- restrictedRoutes.set(route, {
62
- limit,
63
- window
64
- });
65
- }
66
- },
67
- beforeHandle: async ({ set, request, server }) => {
68
- const route = `${request.method}:${new URL(request.url).pathname}`;
69
- if (restrictedRoutes.has(route)) {
70
- const { limit: limit2, window: window2 } = restrictedRoutes.get(route);
71
- const ip = request.headers.get("x-forwarded-for") || request.headers.get("x-real-ip") || server?.requestIP(request)?.address || "127.0.0.1";
72
- const key = `ratelimit:${route}:${ip}`;
73
- await rateLimitCheck(key, limit2, window2, set);
74
- }
75
- }
76
- })
77
- }).as("global");
78
- };
79
- export {
80
- rateLimit
81
- };
@@ -1 +0,0 @@
1
- // @bun
@@ -1,11 +0,0 @@
1
- // @bun
2
- import {
3
- JWT_ERROR_KEYS
4
- } from "../../../chunk-9d3zvgp6.js";
5
- import {
6
- PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS
7
- } from "../../../chunk-12qzn7jw.js";
8
- export {
9
- PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS,
10
- JWT_ERROR_KEYS
11
- };
@@ -1,51 +0,0 @@
1
- // @bun
2
- import {
3
- JWT_ERROR_KEYS
4
- } from "../../chunk-9d3zvgp6.js";
5
- import {
6
- parseHumanTimeToSeconds
7
- } from "../../chunk-eeb7yskp.js";
8
- import"../../chunk-12qzn7jw.js";
9
- import {
10
- HttpError
11
- } from "../../chunk-7t524zqh.js";
12
- import"../../chunk-sqts8vyk.js";
13
- import"../../chunk-9cgzhc50.js";
14
-
15
- // source/modules/jwt/jwt.ts
16
- import {
17
- SignJWT,
18
- jwtVerify
19
- } 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);
22
- if (exp <= Math.floor(Date.now() / 1000))
23
- throw new HttpError(JWT_ERROR_KEYS.JWT_EXPIRATION_PASSED, "BAD_REQUEST");
24
- const finalPayload = {
25
- iss: "Core-Issuer",
26
- sub: "",
27
- aud: ["Core-Audience"],
28
- jti: Bun.randomUUIDv7(),
29
- nbf: Math.floor(Date.now() / 1000),
30
- iat: Math.floor(Date.now() / 1000),
31
- exp,
32
- ...payload
33
- };
34
- 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));
36
- return jwt;
37
- } catch (error) {
38
- throw new HttpError(JWT_ERROR_KEYS.JWT_SIGN_ERROR, "INTERNAL_SERVER_ERROR", error);
39
- }
40
- };
41
- var verifyJWT = async (token, secret) => {
42
- try {
43
- return await jwtVerify(token, new TextEncoder().encode(secret));
44
- } catch {
45
- return false;
46
- }
47
- };
48
- export {
49
- verifyJWT,
50
- signJWT
51
- };
@@ -1,9 +0,0 @@
1
- // @bun
2
- import {
3
- parseHumanTimeToSeconds
4
- } from "../../../chunk-eeb7yskp.js";
5
- import"../../../chunk-12qzn7jw.js";
6
- import"../../../chunk-9cgzhc50.js";
7
- export {
8
- parseHumanTimeToSeconds
9
- };
@@ -1,84 +0,0 @@
1
- // @bun
2
- import {
3
- KV_STORE_ERROR_KEYS
4
- } from "../../../chunk-xhhj1gvj.js";
5
- import {
6
- BaseError
7
- } from "../../../chunk-9cgzhc50.js";
8
-
9
- // source/modules/kv-store/bun-redis/bun-redis-store.ts
10
- var {RedisClient } = globalThis.Bun;
11
- class BunRedisStore {
12
- _client;
13
- constructor(url, options) {
14
- this._client = new RedisClient(url, options);
15
- }
16
- async connect() {
17
- try {
18
- await this._client.connect();
19
- } catch (e) {
20
- throw new BaseError(KV_STORE_ERROR_KEYS.CONNECTION_FAILED, e);
21
- }
22
- }
23
- close() {
24
- try {
25
- this._client.close();
26
- } catch (e) {
27
- throw new BaseError(KV_STORE_ERROR_KEYS.CLOSING_CONNECTION_FAILED, e);
28
- }
29
- }
30
- async get(key) {
31
- const value = await this._client.get(key);
32
- if (value === null)
33
- return null;
34
- try {
35
- return JSON.parse(value);
36
- } catch {
37
- return value;
38
- }
39
- }
40
- async set(key, value, ttlSec) {
41
- const serialized = typeof value === "string" ? value : JSON.stringify(value);
42
- if (ttlSec)
43
- await this._client.set(key, serialized, "EX", ttlSec);
44
- else
45
- await this._client.set(key, serialized);
46
- }
47
- async increment(key, amount) {
48
- try {
49
- const number = await this._client.incrby(key, amount ?? 1);
50
- return number;
51
- } catch (e) {
52
- throw new BaseError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
53
- }
54
- }
55
- async decrement(key, amount) {
56
- try {
57
- const number = await this._client.decrby(key, amount ?? 1);
58
- return number;
59
- } catch (e) {
60
- throw new BaseError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
61
- }
62
- }
63
- async del(key) {
64
- const res = await this._client.del(key);
65
- return res === 1;
66
- }
67
- async expire(key, ttlSec) {
68
- const res = await this._client.expire(key, ttlSec);
69
- return res === 1;
70
- }
71
- async ttl(key) {
72
- const res = await this._client.ttl(key);
73
- return res;
74
- }
75
- async clean() {
76
- const keys = await this._client.keys("*");
77
- if (keys.length === 0)
78
- return 0;
79
- return this._client.del(...keys);
80
- }
81
- }
82
- export {
83
- BunRedisStore
84
- };
@@ -1,7 +0,0 @@
1
- // @bun
2
- import {
3
- KV_STORE_ERROR_KEYS
4
- } from "../../../chunk-xhhj1gvj.js";
5
- export {
6
- KV_STORE_ERROR_KEYS
7
- };
@@ -1,86 +0,0 @@
1
- // @bun
2
- import {
3
- KV_STORE_ERROR_KEYS
4
- } from "../../../chunk-xhhj1gvj.js";
5
- import {
6
- BaseError
7
- } from "../../../chunk-9cgzhc50.js";
8
-
9
- // source/modules/kv-store/ioredis/ioredis-store.ts
10
- import { Redis } from "ioredis";
11
- class IoRedisStore {
12
- _client;
13
- constructor(options) {
14
- this._client = new Redis({
15
- ...options,
16
- lazyConnect: true
17
- });
18
- }
19
- async connect() {
20
- try {
21
- await this._client.connect();
22
- } catch (e) {
23
- throw new BaseError(KV_STORE_ERROR_KEYS.CONNECTION_FAILED, e);
24
- }
25
- }
26
- async close() {
27
- try {
28
- await this._client.quit();
29
- } catch (e) {
30
- throw new BaseError(KV_STORE_ERROR_KEYS.CLOSING_CONNECTION_FAILED, e);
31
- }
32
- }
33
- async get(key) {
34
- const value = await this._client.get(key);
35
- if (value === null)
36
- return null;
37
- try {
38
- return JSON.parse(value);
39
- } catch {
40
- return value;
41
- }
42
- }
43
- async set(key, value, ttlSec) {
44
- const serialized = typeof value === "string" ? value : JSON.stringify(value);
45
- if (ttlSec)
46
- await this._client.setex(key, ttlSec, serialized);
47
- else
48
- await this._client.set(key, serialized);
49
- }
50
- async increment(key, amount = 1) {
51
- try {
52
- const number = await this._client.incrby(key, amount);
53
- return number;
54
- } catch (e) {
55
- throw new BaseError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
56
- }
57
- }
58
- async decrement(key, amount = 1) {
59
- try {
60
- const number = await this._client.decrby(key, amount);
61
- return number;
62
- } catch (e) {
63
- throw new BaseError(KV_STORE_ERROR_KEYS.NOT_INTEGER, e);
64
- }
65
- }
66
- async del(key) {
67
- const result = await this._client.del(key);
68
- return result === 1;
69
- }
70
- async expire(key, ttlSec) {
71
- const result = await this._client.expire(key, ttlSec);
72
- return result === 1;
73
- }
74
- ttl(key) {
75
- return this._client.ttl(key);
76
- }
77
- async clean() {
78
- const keys = await this._client.keys("*");
79
- if (keys.length === 0)
80
- return 0;
81
- return this._client.del(...keys);
82
- }
83
- }
84
- export {
85
- IoRedisStore
86
- };
@@ -1,9 +0,0 @@
1
- // @bun
2
- import {
3
- MemoryStore
4
- } from "../../../chunk-e30paw8a.js";
5
- import"../../../chunk-xhhj1gvj.js";
6
- import"../../../chunk-9cgzhc50.js";
7
- export {
8
- MemoryStore
9
- };
@@ -1 +0,0 @@
1
- // @bun
@@ -1,7 +0,0 @@
1
- // @bun
2
- import {
3
- LOGGER_ERROR_KEYS
4
- } from "../../../chunk-rz5p4j3p.js";
5
- export {
6
- LOGGER_ERROR_KEYS
7
- };
@@ -1 +0,0 @@
1
- // @bun