@mrxsys/mrx-core 2.11.0-1-and-267-20250925 → 2.11.1-1-and-275-20251023

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 (76) hide show
  1. package/dist/{chunk-fp8xg6kq.js → chunk-441xs5k1.js} +1 -1
  2. package/dist/{chunk-bdcsh435.js → chunk-4v86f7gp.js} +5 -5
  3. package/dist/{chunk-00s6t4tw.js → chunk-7t524zqh.js} +4 -4
  4. package/dist/{chunk-d1vp74n0.js → chunk-afd82epa.js} +2 -2
  5. package/dist/{chunk-v9kvw5x7.js → chunk-afyz8rg5.js} +2 -2
  6. package/dist/{chunk-6sfnrhfs.js → chunk-pjv1ekwr.js} +33 -1
  7. package/dist/chunk-rz5p4j3p.js +13 -0
  8. package/dist/{chunk-h9t48r9q.js → chunk-sqts8vyk.js} +16 -2
  9. package/dist/errors/enums/http-status-codes.d.ts +15 -1
  10. package/dist/errors/enums/index.d.ts +1 -1
  11. package/dist/errors/enums/index.js +3 -3
  12. package/dist/errors/http-error.d.ts +3 -3
  13. package/dist/errors/index.js +2 -2
  14. package/dist/errors/utils/index.js +2 -2
  15. package/dist/modules/database/enums/database-error-keys.d.ts +2 -2
  16. package/dist/modules/database/enums/index.js +1 -1
  17. package/dist/modules/database/index.js +5 -5
  18. package/dist/modules/elysia/cache/cache.d.ts +8 -14
  19. package/dist/modules/elysia/cache/index.js +66 -46
  20. package/dist/modules/elysia/cache/types/cache-item.d.ts +0 -1
  21. package/dist/modules/elysia/cache/types/cache-options.d.ts +2 -11
  22. package/dist/modules/elysia/crud/index.js +16 -16
  23. package/dist/modules/elysia/crud/operations/count.d.ts +1 -1
  24. package/dist/modules/elysia/crud/operations/delete.d.ts +1 -1
  25. package/dist/modules/elysia/crud/operations/deleteOne.d.ts +1 -1
  26. package/dist/modules/elysia/crud/operations/find.d.ts +1 -1
  27. package/dist/modules/elysia/crud/operations/findOne.d.ts +1 -1
  28. package/dist/modules/elysia/crud/operations/index.js +7 -7
  29. package/dist/modules/elysia/crud/operations/insert.d.ts +1 -1
  30. package/dist/modules/elysia/crud/operations/update.d.ts +1 -1
  31. package/dist/modules/elysia/crud/operations/updateOne.d.ts +1 -1
  32. package/dist/modules/elysia/db-resolver/db-resolver.d.ts +1 -1
  33. package/dist/modules/elysia/db-resolver/index.js +6 -6
  34. package/dist/modules/elysia/error/index.js +2 -2
  35. package/dist/modules/elysia/microservice/microservice.d.ts +12 -12
  36. package/dist/modules/elysia/rate-limit/index.js +53 -28
  37. package/dist/modules/elysia/rate-limit/rate-limit.d.ts +361 -32
  38. package/dist/modules/elysia/rate-limit/types/rate-limit-options.d.ts +0 -9
  39. package/dist/modules/jwt/index.js +2 -2
  40. package/dist/modules/kv-store/bun-redis/bun-redis-store.d.ts +25 -0
  41. package/dist/modules/kv-store/bun-redis/index.d.ts +1 -0
  42. package/dist/modules/kv-store/bun-redis/index.js +76 -0
  43. package/dist/modules/kv-store/ioredis/index.js +4 -10
  44. package/dist/modules/kv-store/ioredis/ioredis-store.d.ts +0 -82
  45. package/dist/modules/kv-store/memory/index.js +98 -4
  46. package/dist/modules/kv-store/memory/memory-store.d.ts +0 -84
  47. package/dist/modules/kv-store/types/kv-store.d.ts +2 -2
  48. package/dist/modules/logger/enums/index.js +1 -1
  49. package/dist/modules/logger/enums/logger-error-keys.d.ts +6 -3
  50. package/dist/modules/logger/events/logger-events.d.ts +12 -3
  51. package/dist/modules/logger/index.js +173 -81
  52. package/dist/modules/logger/logger.d.ts +115 -133
  53. package/dist/modules/logger/sinks/console-logger.d.ts +2 -16
  54. package/dist/modules/logger/sinks/devnull-logger.d.ts +8 -0
  55. package/dist/modules/logger/sinks/file-logger/enums/file-logger-error-keys.d.ts +3 -0
  56. package/dist/modules/logger/sinks/file-logger/file-logger.d.ts +25 -0
  57. package/dist/modules/logger/sinks/index.d.ts +4 -2
  58. package/dist/modules/logger/sinks/index.js +54 -31
  59. package/dist/modules/logger/types/index.d.ts +6 -6
  60. package/dist/modules/logger/types/log-levels.d.ts +1 -4
  61. package/dist/modules/logger/types/logger-options.d.ts +41 -0
  62. package/dist/modules/logger/types/logger-sink.d.ts +12 -3
  63. package/dist/modules/logger/types/sink-bodies-intersection.d.ts +2 -0
  64. package/dist/modules/logger/types/sink-body.d.ts +1 -1
  65. package/dist/modules/logger/types/sink-map.d.ts +1 -1
  66. package/dist/modules/repository/index.js +4 -4
  67. package/dist/modules/repository/types/query-options.d.ts +2 -2
  68. package/package.json +30 -25
  69. package/dist/chunk-b23dvm2d.js +0 -29
  70. package/dist/chunk-b96fm9ph.js +0 -10
  71. package/dist/chunk-e30paw8a.js +0 -101
  72. package/dist/modules/elysia/cache/utils/index.d.ts +0 -1
  73. package/dist/modules/elysia/cache/utils/index.js +0 -7
  74. package/dist/modules/logger/sinks/file-logger.d.ts +0 -25
  75. package/dist/modules/logger/types/bodies-intersection.d.ts +0 -2
  76. package/dist/modules/logger/types/log-stream-chunk.d.ts +0 -15
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-8tffnbpn.js";
8
8
  import {
9
9
  MSSQL
10
- } from "./chunk-d1vp74n0.js";
10
+ } from "./chunk-afd82epa.js";
11
11
  import {
12
12
  BaseError
13
13
  } from "./chunk-9cgzhc50.js";
@@ -4,7 +4,7 @@ var DATABASE_ERROR_KEYS = {
4
4
  MSSQL_CONNECTION_ERROR: "mrx-core.mssql.error.database.connection_error",
5
5
  MSSQL_DATABASE_ACCESS_DENIED: "mrx-core.mssql.error.database.access_denied",
6
6
  MSSQL_DATABASE_AMBIGUOUS_COLUMN: "mrx-core.mssql.error.database.ambiguous_column",
7
- MSSQL_DATABASE_AUTHORIZATION8FAILED: "mrx-core.mssql.error.database.authorization_failed",
7
+ MSSQL_DATABASE_AUTHORIZATION_FAILED: "mrx-core.mssql.error.database.authorization_failed",
8
8
  MSSQL_DATABASE_COLUMN_NOT_FOUND: "mrx-core.mssql.error.database.column_not_found",
9
9
  MSSQL_DATABASE_CONVERSION_FAILED: "mrx-core.mssql.error.database.conversion_failed",
10
10
  MSSQL_DATABASE_DATA_TOO_LARGE: "mrx-core.mssql.error.database.data_too_large",
@@ -21,7 +21,7 @@ var DATABASE_ERROR_KEYS = {
21
21
  MSSQL_DATABASE_TRANSACTION_ABORTED: "mrx-core.mssql.error.database.transaction_aborted",
22
22
  MSSQL_DATABASE_TRANSACTION_LOG_FULL: "mrx-core.mssql.error.database.transaction_log_full",
23
23
  MSSQL_DATABASE_UNIQUE_CONSTRAINT_VIOLATION: "mrx-core.mssql.error.database.unique_constraint_violation",
24
- MSSQL_DATABSE_CANNOT_UPDATE_IDENTITY_COLUMN: "mrx-core.mssql.error.database.cannot_update_identity_column",
24
+ MSSQL_DATABASE_CANNOT_UPDATE_IDENTITY_COLUMN: "mrx-core.mssql.error.database.cannot_update_identity_column",
25
25
  MSSQL_DISCONNECT_ERROR: "mrx-core.mssql.error.database.disconnect_error",
26
26
  MSSQL_NO_RESULT: "mrx-core.mssql.error.database.no_result",
27
27
  MSSQL_NOT_CONNECTED: "mrx-core.mssql.error.database.not_connected",
@@ -36,8 +36,8 @@ var MSSQL_ERROR_CODE = {
36
36
  1105: DATABASE_ERROR_KEYS.MSSQL_DATABASE_INSUFFICIENT_STORAGE,
37
37
  1205: DATABASE_ERROR_KEYS.MSSQL_DATABASE_DEADLOCK_DETECTED,
38
38
  1222: DATABASE_ERROR_KEYS.MSSQL_DATABASE_RESOURCE_LOCKED,
39
- 18452: DATABASE_ERROR_KEYS.MSSQL_DATABASE_AUTHORIZATION8FAILED,
40
- 18456: DATABASE_ERROR_KEYS.MSSQL_DATABASE_AUTHORIZATION8FAILED,
39
+ 18452: DATABASE_ERROR_KEYS.MSSQL_DATABASE_AUTHORIZATION_FAILED,
40
+ 18456: DATABASE_ERROR_KEYS.MSSQL_DATABASE_AUTHORIZATION_FAILED,
41
41
  207: DATABASE_ERROR_KEYS.MSSQL_DATABASE_COLUMN_NOT_FOUND,
42
42
  208: DATABASE_ERROR_KEYS.MSSQL_TABLE_NOT_FOUND,
43
43
  209: DATABASE_ERROR_KEYS.MSSQL_DATABASE_AMBIGUOUS_COLUMN,
@@ -49,7 +49,7 @@ var MSSQL_ERROR_CODE = {
49
49
  544: DATABASE_ERROR_KEYS.MSSQL_DATABASE_IDENTITY_INSERT_NOT_ALLOWED,
50
50
  547: DATABASE_ERROR_KEYS.MSSQL_DATABASE_FOREIGN_KEY_VIOLATION,
51
51
  701: DATABASE_ERROR_KEYS.MSSQL_DATABASE_INSUFFICIENT_MEMORY,
52
- 8102: DATABASE_ERROR_KEYS.MSSQL_DATABSE_CANNOT_UPDATE_IDENTITY_COLUMN,
52
+ 8102: DATABASE_ERROR_KEYS.MSSQL_DATABASE_CANNOT_UPDATE_IDENTITY_COLUMN,
53
53
  8152: DATABASE_ERROR_KEYS.MSSQL_DATABASE_DATA_TOO_LARGE,
54
54
  8169: DATABASE_ERROR_KEYS.MSSQL_DATABASE_CONVERSION_FAILED,
55
55
  8645: DATABASE_ERROR_KEYS.MSSQL_DATABASE_QUERY_TIMEOUT,
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
- HTTP_ERROR_STATUS_CODES
4
- } from "./chunk-h9t48r9q.js";
3
+ HTTP_STATUS_CODES
4
+ } from "./chunk-sqts8vyk.js";
5
5
  import {
6
6
  BaseError
7
7
  } from "./chunk-9cgzhc50.js";
@@ -10,8 +10,8 @@ import {
10
10
  class HttpError extends BaseError {
11
11
  httpStatusCode;
12
12
  constructor(message, a, b) {
13
- const isStatus = typeof a === "number" || typeof a === "string" && a in HTTP_ERROR_STATUS_CODES;
14
- const status = isStatus ? typeof a === "number" ? a : HTTP_ERROR_STATUS_CODES[a] : HTTP_ERROR_STATUS_CODES.INTERNAL_SERVER_ERROR;
13
+ const isStatus = typeof a === "number" || typeof a === "string" && a in HTTP_STATUS_CODES;
14
+ const status = isStatus ? typeof a === "number" ? a : HTTP_STATUS_CODES[a] : HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR;
15
15
  super(message, isStatus ? b : a);
16
16
  this.httpStatusCode = status;
17
17
  }
@@ -1,13 +1,13 @@
1
1
  // @bun
2
2
  import {
3
3
  Repository
4
- } from "./chunk-v9kvw5x7.js";
4
+ } from "./chunk-afyz8rg5.js";
5
5
  import {
6
6
  TypedEventEmitter
7
7
  } from "./chunk-mvrxngm7.js";
8
8
  import {
9
9
  DATABASE_ERROR_KEYS
10
- } from "./chunk-bdcsh435.js";
10
+ } from "./chunk-4v86f7gp.js";
11
11
  import {
12
12
  BaseError
13
13
  } from "./chunk-9cgzhc50.js";
@@ -6,10 +6,10 @@ import {
6
6
  import {
7
7
  DATABASE_ERROR_KEYS,
8
8
  MSSQL_ERROR_CODE
9
- } from "./chunk-bdcsh435.js";
9
+ } from "./chunk-4v86f7gp.js";
10
10
  import {
11
11
  HttpError
12
- } from "./chunk-00s6t4tw.js";
12
+ } from "./chunk-7t524zqh.js";
13
13
 
14
14
  // source/modules/repository/repository.ts
15
15
  import { PassThrough } from "stream";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  dbResolver
4
- } from "./chunk-fp8xg6kq.js";
4
+ } from "./chunk-441xs5k1.js";
5
5
  import {
6
6
  CRUD_SUCCESS_KEYS
7
7
  } from "./chunk-w7h898m3.js";
@@ -35,6 +35,10 @@ var count = (database, tableName, {
35
35
  content: data
36
36
  };
37
37
  }, {
38
+ detail: {
39
+ summary: "Count",
40
+ description: `Count ${tableName} records based on query options.`
41
+ },
38
42
  ...getDbInjection(database),
39
43
  body: `${tableName}Count`,
40
44
  response: `${tableName}CountResponse200`,
@@ -63,6 +67,10 @@ var batchDelete = (database, tableName, {
63
67
  content: data
64
68
  };
65
69
  }, {
70
+ detail: {
71
+ summary: "Delete",
72
+ description: `Delete ${tableName} records based on query options.`
73
+ },
66
74
  ...getDbInjection(database),
67
75
  body: `${tableName}Delete`,
68
76
  response: `${tableName}Response200`,
@@ -96,6 +104,10 @@ var deleteOne = (database, tableName, {
96
104
  content: data
97
105
  };
98
106
  }, {
107
+ detail: {
108
+ summary: "Delete One",
109
+ description: `Delete a single ${tableName} record by its primary key.`
110
+ },
99
111
  ...getDbInjection(database),
100
112
  params: `${tableName}IdParam`,
101
113
  response: `${tableName}Response200`,
@@ -122,6 +134,10 @@ var find = (database, tableName, {
122
134
  content: data
123
135
  };
124
136
  }, {
137
+ detail: {
138
+ summary: "Find",
139
+ description: `Find ${tableName} records based on query options.`
140
+ },
125
141
  ...getDbInjection(database),
126
142
  body: `${tableName}Find`,
127
143
  response: `${tableName}Response200`,
@@ -154,6 +170,10 @@ var findOne = (database, tableName, {
154
170
  content: data
155
171
  };
156
172
  }, {
173
+ detail: {
174
+ summary: "Find One",
175
+ description: `Find a single ${tableName} record by its primary key.`
176
+ },
157
177
  ...getDbInjection(database),
158
178
  params: `${tableName}IdParam`,
159
179
  response: `${tableName}Response200`,
@@ -181,6 +201,10 @@ var insert = (database, tableName, {
181
201
  content: data
182
202
  };
183
203
  }, {
204
+ detail: {
205
+ summary: "Insert",
206
+ description: `Insert one or more records into the ${tableName} table.`
207
+ },
184
208
  ...getDbInjection(database),
185
209
  body: `${tableName}Insert`,
186
210
  response: `${tableName}Response200`,
@@ -208,6 +232,10 @@ var update = (database, tableName, {
208
232
  content: data
209
233
  };
210
234
  }, {
235
+ detail: {
236
+ summary: "Update",
237
+ description: `Update one or more ${tableName} records based on query options.`
238
+ },
211
239
  ...getDbInjection(database),
212
240
  body: `${tableName}Update`,
213
241
  response: `${tableName}Response200`,
@@ -242,6 +270,10 @@ var updateOne = (database, tableName, {
242
270
  content: data
243
271
  };
244
272
  }, {
273
+ detail: {
274
+ summary: "Update Single Record",
275
+ description: `Update a single record in the ${tableName} table by its primary key.`
276
+ },
245
277
  ...getDbInjection(database),
246
278
  params: `${tableName}IdParam`,
247
279
  body: `${tableName}UpdateOne`,
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ // source/modules/logger/enums/logger-error-keys.ts
3
+ var LOGGER_ERROR_KEYS = {
4
+ BEFORE_EXIT_CLOSE_ERROR: "mrx-core.logger.error.before_exit_close_error",
5
+ BEFORE_EXIT_FLUSH_ERROR: "mrx-core.logger.error.before_exit_flush_error",
6
+ NO_SINKS_PROVIDED: "mrx-core.logger.error.no_sinks_provided",
7
+ REGISTER_SINK_ERROR: "mrx-core.logger.error.register_sink_error",
8
+ SINK_ALREADY_ADDED: "mrx-core.logger.error.sink_already_added",
9
+ SINK_CLOSE_ERROR: "mrx-core.logger.error.sink_close_error",
10
+ SINK_LOG_ERROR: "mrx-core.logger.error.sink_log_error"
11
+ };
12
+
13
+ export { LOGGER_ERROR_KEYS };
@@ -1,6 +1,20 @@
1
1
  // @bun
2
2
  // source/errors/enums/http-status-codes.ts
3
- var HTTP_ERROR_STATUS_CODES = {
3
+ var HTTP_STATUS_CODES = {
4
+ CONTINUE: 100,
5
+ SWITCHING_PROTOCOLS: 101,
6
+ PROCESSING: 102,
7
+ EARLY_HINTS: 103,
8
+ OK: 200,
9
+ CREATED: 201,
10
+ ACCEPTED: 202,
11
+ NON_AUTHORITATIVE_INFORMATION: 203,
12
+ NO_CONTENT: 204,
13
+ RESET_CONTENT: 205,
14
+ PARTIAL_CONTENT: 206,
15
+ MULTI_STATUS: 207,
16
+ ALREADY_REPORTED: 208,
17
+ IM_USED: 226,
4
18
  BAD_REQUEST: 400,
5
19
  UNAUTHORIZED: 401,
6
20
  PAYMENT_REQUIRED: 402,
@@ -43,4 +57,4 @@ var HTTP_ERROR_STATUS_CODES = {
43
57
  NETWORK_AUTHENTICATION_REQUIRED: 511
44
58
  };
45
59
 
46
- export { HTTP_ERROR_STATUS_CODES };
60
+ export { HTTP_STATUS_CODES };
@@ -1,4 +1,18 @@
1
- export declare const HTTP_ERROR_STATUS_CODES: {
1
+ export declare const HTTP_STATUS_CODES: {
2
+ readonly CONTINUE: 100;
3
+ readonly SWITCHING_PROTOCOLS: 101;
4
+ readonly PROCESSING: 102;
5
+ readonly EARLY_HINTS: 103;
6
+ readonly OK: 200;
7
+ readonly CREATED: 201;
8
+ readonly ACCEPTED: 202;
9
+ readonly NON_AUTHORITATIVE_INFORMATION: 203;
10
+ readonly NO_CONTENT: 204;
11
+ readonly RESET_CONTENT: 205;
12
+ readonly PARTIAL_CONTENT: 206;
13
+ readonly MULTI_STATUS: 207;
14
+ readonly ALREADY_REPORTED: 208;
15
+ readonly IM_USED: 226;
2
16
  readonly BAD_REQUEST: 400;
3
17
  readonly UNAUTHORIZED: 401;
4
18
  readonly PAYMENT_REQUIRED: 402;
@@ -1 +1 @@
1
- export { HTTP_ERROR_STATUS_CODES } from './http-status-codes';
1
+ export { HTTP_STATUS_CODES } from './http-status-codes';
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
- HTTP_ERROR_STATUS_CODES
4
- } from "../../chunk-h9t48r9q.js";
3
+ HTTP_STATUS_CODES
4
+ } from "../../chunk-sqts8vyk.js";
5
5
  export {
6
- HTTP_ERROR_STATUS_CODES
6
+ HTTP_STATUS_CODES
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import { BaseError } from './base-error';
2
- import { HTTP_ERROR_STATUS_CODES } from './enums/http-status-codes';
3
- export type HttpStatusKey = keyof typeof HTTP_ERROR_STATUS_CODES;
4
- export type HttpStatusCode = typeof HTTP_ERROR_STATUS_CODES[HttpStatusKey];
2
+ import { HTTP_STATUS_CODES } from './enums/http-status-codes';
3
+ export type HttpStatusKey = keyof typeof HTTP_STATUS_CODES;
4
+ export type HttpStatusCode = typeof HTTP_STATUS_CODES[HttpStatusKey];
5
5
  export declare class HttpError<const TCause = unknown> extends BaseError<TCause> {
6
6
  readonly httpStatusCode: number;
7
7
  constructor(message: string, cause?: TCause);
@@ -1,8 +1,8 @@
1
1
  // @bun
2
2
  import {
3
3
  HttpError
4
- } from "../chunk-00s6t4tw.js";
5
- import"../chunk-h9t48r9q.js";
4
+ } from "../chunk-7t524zqh.js";
5
+ import"../chunk-sqts8vyk.js";
6
6
  import {
7
7
  BaseError
8
8
  } from "../chunk-9cgzhc50.js";
@@ -1,8 +1,8 @@
1
1
  // @bun
2
2
  import {
3
3
  HttpError
4
- } from "../../chunk-00s6t4tw.js";
5
- import"../../chunk-h9t48r9q.js";
4
+ } from "../../chunk-7t524zqh.js";
5
+ import"../../chunk-sqts8vyk.js";
6
6
  import {
7
7
  BaseError
8
8
  } from "../../chunk-9cgzhc50.js";
@@ -2,7 +2,7 @@ export declare const DATABASE_ERROR_KEYS: {
2
2
  readonly MSSQL_CONNECTION_ERROR: "mrx-core.mssql.error.database.connection_error";
3
3
  readonly MSSQL_DATABASE_ACCESS_DENIED: "mrx-core.mssql.error.database.access_denied";
4
4
  readonly MSSQL_DATABASE_AMBIGUOUS_COLUMN: "mrx-core.mssql.error.database.ambiguous_column";
5
- readonly MSSQL_DATABASE_AUTHORIZATION8FAILED: "mrx-core.mssql.error.database.authorization_failed";
5
+ readonly MSSQL_DATABASE_AUTHORIZATION_FAILED: "mrx-core.mssql.error.database.authorization_failed";
6
6
  readonly MSSQL_DATABASE_COLUMN_NOT_FOUND: "mrx-core.mssql.error.database.column_not_found";
7
7
  readonly MSSQL_DATABASE_CONVERSION_FAILED: "mrx-core.mssql.error.database.conversion_failed";
8
8
  readonly MSSQL_DATABASE_DATA_TOO_LARGE: "mrx-core.mssql.error.database.data_too_large";
@@ -19,7 +19,7 @@ export declare const DATABASE_ERROR_KEYS: {
19
19
  readonly MSSQL_DATABASE_TRANSACTION_ABORTED: "mrx-core.mssql.error.database.transaction_aborted";
20
20
  readonly MSSQL_DATABASE_TRANSACTION_LOG_FULL: "mrx-core.mssql.error.database.transaction_log_full";
21
21
  readonly MSSQL_DATABASE_UNIQUE_CONSTRAINT_VIOLATION: "mrx-core.mssql.error.database.unique_constraint_violation";
22
- readonly MSSQL_DATABSE_CANNOT_UPDATE_IDENTITY_COLUMN: "mrx-core.mssql.error.database.cannot_update_identity_column";
22
+ readonly MSSQL_DATABASE_CANNOT_UPDATE_IDENTITY_COLUMN: "mrx-core.mssql.error.database.cannot_update_identity_column";
23
23
  readonly MSSQL_DISCONNECT_ERROR: "mrx-core.mssql.error.database.disconnect_error";
24
24
  readonly MSSQL_NO_RESULT: "mrx-core.mssql.error.database.no_result";
25
25
  readonly MSSQL_NOT_CONNECTED: "mrx-core.mssql.error.database.not_connected";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  DATABASE_ERROR_KEYS,
4
4
  MSSQL_ERROR_CODE
5
- } from "../../../chunk-bdcsh435.js";
5
+ } from "../../../chunk-4v86f7gp.js";
6
6
  export {
7
7
  MSSQL_ERROR_CODE,
8
8
  DATABASE_ERROR_KEYS
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  MSSQL,
4
4
  Table
5
- } from "../../chunk-d1vp74n0.js";
6
- import"../../chunk-v9kvw5x7.js";
5
+ } from "../../chunk-afd82epa.js";
6
+ import"../../chunk-afyz8rg5.js";
7
7
  import"../../chunk-grfyngq0.js";
8
8
  import"../../chunk-mvrxngm7.js";
9
- import"../../chunk-bdcsh435.js";
10
- import"../../chunk-00s6t4tw.js";
11
- import"../../chunk-h9t48r9q.js";
9
+ import"../../chunk-4v86f7gp.js";
10
+ import"../../chunk-7t524zqh.js";
11
+ import"../../chunk-sqts8vyk.js";
12
12
  import"../../chunk-9cgzhc50.js";
13
13
  export {
14
14
  Table,
@@ -1,12 +1,9 @@
1
1
  import { Elysia } from 'elysia';
2
- import { MemoryStore } from '../../../modules/kv-store/memory/memory-store';
2
+ import type { KvStore } from '../../../modules/kv-store/types';
3
3
  import type { CacheOptions } from './types/cache-options';
4
- export declare const cache: ({ defaultTtl, prefix, store }?: CacheOptions) => Elysia<"", {
4
+ export declare const cache: (store?: KvStore) => Elysia<"", {
5
5
  decorator: {};
6
- store: {
7
- kvStore: import("../../kv-store/types").KvStore | MemoryStore;
8
- _cachedRoutes: Set<string>;
9
- };
6
+ store: {};
10
7
  derive: {};
11
8
  resolve: {};
12
9
  }, {
@@ -16,11 +13,11 @@ export declare const cache: ({ defaultTtl, prefix, store }?: CacheOptions) => El
16
13
  schema: {};
17
14
  standaloneSchema: {};
18
15
  macro: Partial<{
19
- readonly isCached: number | boolean;
16
+ readonly isCached: CacheOptions;
20
17
  }>;
21
18
  macroFn: {
22
- readonly isCached: (enable: boolean | number) => {
23
- readonly afterHandle: ({ set, responseValue, store, request }: {
19
+ readonly isCached: ({ ttl, prefix }: CacheOptions) => {
20
+ readonly afterHandle: ({ set, responseValue, request }: {
24
21
  body: unknown;
25
22
  query: Record<string, string>;
26
23
  params: {};
@@ -37,11 +34,8 @@ export declare const cache: ({ defaultTtl, prefix, store }?: CacheOptions) => El
37
34
  path: string;
38
35
  route: string;
39
36
  request: Request;
40
- store: {
41
- kvStore: import("../../kv-store/types").KvStore | MemoryStore;
42
- _cachedRoutes: Set<string>;
43
- };
44
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | 100 | 102 | 207 | 208 | 101 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 420 ? {
37
+ store: {};
38
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 420 ? {
45
39
  readonly 100: "Continue";
46
40
  readonly 101: "Switching Protocols";
47
41
  readonly 102: "Processing";
@@ -1,70 +1,90 @@
1
1
  // @bun
2
2
  import {
3
3
  MemoryStore
4
- } from "../../../chunk-e30paw8a.js";
4
+ } from "../../kv-store/memory/index.js";
5
5
  import"../../../chunk-xhhj1gvj.js";
6
- import {
7
- generateCacheKey
8
- } from "../../../chunk-b23dvm2d.js";
9
6
  import"../../../chunk-9cgzhc50.js";
10
7
 
11
8
  // source/modules/elysia/cache/cache.ts
12
9
  import { Elysia } from "elysia";
13
- var cache = ({
14
- defaultTtl = 60,
15
- prefix = "",
16
- store = ":memory:"
17
- } = {}) => new Elysia().state({
18
- kvStore: store === ":memory:" ? new MemoryStore : store
19
- }).state({
20
- _cachedRoutes: new Set
21
- }).onRequest(async ({ request, store: store2, set }) => {
22
- const sanitizeUrl = new URL(request.url).pathname;
23
- if (store2._cachedRoutes.has(`${request.method}:${sanitizeUrl}`)) {
24
- const cacheKey = await generateCacheKey(request.clone());
25
- const cachedData = await store2.kvStore.get(`${prefix}${cacheKey}`);
26
- if (cachedData && typeof cachedData === "object" && "response" in cachedData && "metadata" in cachedData) {
27
- const { response, metadata } = cachedData;
28
- set.headers["cache-control"] = `max-age=${metadata.ttl}, public`;
29
- set.headers["x-cache"] = "HIT";
30
- set.headers["etag"] = `"${prefix}${cacheKey}"`;
31
- set.headers["expires"] = new Date(Date.now() + metadata.ttl * 1000).toUTCString();
32
- set.headers["last-modified"] = metadata.createdAt;
33
- if (response instanceof Response)
34
- return response.clone();
35
- return response;
10
+
11
+ // source/modules/elysia/cache/utils/generate-cache-key.ts
12
+ var _calculateBodyHash = async (body, hasher) => {
13
+ if (!body)
14
+ return;
15
+ const reader = body.getReader();
16
+ try {
17
+ while (true) {
18
+ const { done, value } = await reader.read();
19
+ if (done)
20
+ break;
21
+ if (value)
22
+ hasher.update(new Uint8Array(value));
36
23
  }
37
- set.headers["x-cache"] = "MISS";
24
+ } finally {
25
+ reader.releaseLock();
38
26
  }
39
- return;
40
- }).macro({
41
- isCached: (enable) => {
42
- const ttl = typeof enable === "number" ? enable : enable ? defaultTtl : 0;
43
- return {
44
- async afterHandle({ set, responseValue, store: store2, request }) {
45
- const sanitizeUrl = new URL(request.url).pathname;
46
- if (!store2._cachedRoutes.has(`${request.method}:${sanitizeUrl}`))
47
- store2._cachedRoutes.add(`${request.method}:${sanitizeUrl}`);
27
+ };
28
+ var generateCacheKey = async (request) => {
29
+ const { method, url, headers } = request;
30
+ const hasher = new Bun.CryptoHasher("sha256");
31
+ hasher.update(method);
32
+ hasher.update(url);
33
+ hasher.update(JSON.stringify(headers));
34
+ await _calculateBodyHash(request.body, hasher);
35
+ return hasher.digest("hex");
36
+ };
37
+
38
+ // source/modules/elysia/cache/cache.ts
39
+ var cache = (store = new MemoryStore) => {
40
+ const cachedRoutes = new Map;
41
+ return new Elysia().onRequest(async ({ request, set }) => {
42
+ const route = `${request.method}:${new URL(request.url).pathname}`;
43
+ if (cachedRoutes.has(route)) {
44
+ const { ttl, prefix } = cachedRoutes.get(route);
45
+ const cacheKey = await generateCacheKey(request.clone());
46
+ const cacheItem = await store.get(`${prefix}${cacheKey}`);
47
+ if (cacheItem && typeof cacheItem === "object" && "response" in cacheItem && "metadata" in cacheItem) {
48
+ const createdAt = new Date(cacheItem.metadata.createdAt);
49
+ const expiresAt = new Date(createdAt.getTime() + ttl * 1000);
50
+ const now = Date.now();
51
+ const remaining = Math.max(0, Math.ceil((expiresAt.getTime() - now) / 1000));
52
+ set.headers["cache-control"] = `max-age=${remaining}, public`;
53
+ set.headers["etag"] = `"${prefix}${cacheKey}"`;
54
+ set.headers["last-modified"] = cacheItem.metadata.createdAt;
55
+ set.headers["expires"] = expiresAt.toUTCString();
56
+ set.headers["x-cache"] = "HIT";
57
+ if (cacheItem.response instanceof Response)
58
+ return cacheItem.response.clone();
59
+ return cacheItem.response;
60
+ }
61
+ set.headers["x-cache"] = "MISS";
62
+ }
63
+ return;
64
+ }).macro({
65
+ isCached: ({ ttl, prefix = "" }) => ({
66
+ async afterHandle({ set, responseValue, request }) {
67
+ const route = `${request.method}:${new URL(request.url).pathname}`;
68
+ if (!cachedRoutes.has(route))
69
+ cachedRoutes.set(route, { ttl, prefix });
48
70
  const cacheKey = await generateCacheKey(request.clone());
49
71
  const now = new Date;
50
72
  set.headers["cache-control"] = `max-age=${ttl}, public`;
51
73
  set.headers["etag"] = `"${prefix}${cacheKey}"`;
52
74
  set.headers["last-modified"] = now.toUTCString();
53
75
  set.headers["expires"] = new Date(now.getTime() + ttl * 1000).toUTCString();
54
- if (!set.headers["x-cache"])
55
- set.headers["x-cache"] = "MISS";
56
- const cacheData = {
76
+ set.headers["x-cache"] = "MISS";
77
+ const cacheItem = {
57
78
  response: responseValue instanceof Response ? responseValue.clone() : responseValue,
58
79
  metadata: {
59
- createdAt: now.toUTCString(),
60
- ttl
80
+ createdAt: now.toUTCString()
61
81
  }
62
82
  };
63
- await store2.kvStore.set(`${prefix}${cacheKey}`, cacheData, ttl);
83
+ await store.set(`${prefix}${cacheKey}`, cacheItem, ttl);
64
84
  }
65
- };
66
- }
67
- });
85
+ })
86
+ });
87
+ };
68
88
  export {
69
89
  cache
70
90
  };
@@ -2,6 +2,5 @@ export interface CacheItem {
2
2
  response: unknown;
3
3
  metadata: {
4
4
  createdAt: string;
5
- ttl: number;
6
5
  };
7
6
  }
@@ -1,21 +1,12 @@
1
- import type { KvStore } from '../../../../modules/kv-store/types/kv-store';
2
1
  export interface CacheOptions {
3
2
  /**
4
- * Default TTL in seconds
5
- *
6
- * @defaultValue 60
3
+ * TTL in seconds
7
4
  */
8
- defaultTtl?: number;
5
+ ttl: number;
9
6
  /**
10
7
  * Cache key prefix
11
8
  *
12
9
  * @defaultValue ''
13
10
  */
14
11
  prefix?: string;
15
- /**
16
- * Storage backend
17
- *
18
- * @defaultValue ':memory:'
19
- */
20
- store?: ':memory:' | KvStore;
21
12
  }
@@ -1,14 +1,4 @@
1
1
  // @bun
2
- import {
3
- batchDelete,
4
- count,
5
- deleteOne,
6
- find,
7
- findOne,
8
- insert,
9
- update,
10
- updateOne
11
- } from "../../../chunk-6sfnrhfs.js";
12
2
  import {
13
3
  createCountResponse200Schema,
14
4
  createCountSchema,
@@ -21,20 +11,30 @@ import {
21
11
  createUpdateSchema
22
12
  } from "../../../chunk-p14h6jfs.js";
23
13
  import"../../../chunk-9dzsj7f2.js";
24
- import"../../../chunk-fp8xg6kq.js";
14
+ import {
15
+ batchDelete,
16
+ count,
17
+ deleteOne,
18
+ find,
19
+ findOne,
20
+ insert,
21
+ update,
22
+ updateOne
23
+ } from "../../../chunk-pjv1ekwr.js";
24
+ import"../../../chunk-441xs5k1.js";
25
25
  import"../../../chunk-fs3wm3p4.js";
26
26
  import"../../../chunk-z0ct35ft.js";
27
27
  import"../../../chunk-8tffnbpn.js";
28
28
  import"../../../chunk-w7h898m3.js";
29
29
  import"../../../chunk-gtn1kn0z.js";
30
30
  import"../../../chunk-jksb9ers.js";
31
- import"../../../chunk-d1vp74n0.js";
32
- import"../../../chunk-v9kvw5x7.js";
31
+ import"../../../chunk-afd82epa.js";
32
+ import"../../../chunk-afyz8rg5.js";
33
33
  import"../../../chunk-grfyngq0.js";
34
34
  import"../../../chunk-mvrxngm7.js";
35
- import"../../../chunk-bdcsh435.js";
36
- import"../../../chunk-00s6t4tw.js";
37
- import"../../../chunk-h9t48r9q.js";
35
+ import"../../../chunk-4v86f7gp.js";
36
+ import"../../../chunk-7t524zqh.js";
37
+ import"../../../chunk-sqts8vyk.js";
38
38
  import"../../../chunk-9cgzhc50.js";
39
39
 
40
40
  // source/modules/elysia/crud/crud.ts
@@ -43,7 +43,7 @@ export declare const count: <const TDatabase extends Omit<MSSQLDatabaseOptions,
43
43
  route: string;
44
44
  request: Request;
45
45
  store: {};
46
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | 100 | 102 | 207 | 208 | 101 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 420 ? {
46
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 420 ? {
47
47
  readonly 100: "Continue";
48
48
  readonly 101: "Switching Protocols";
49
49
  readonly 102: "Processing";
@@ -43,7 +43,7 @@ export declare const batchDelete: <const TDatabase extends Omit<MSSQLDatabaseOpt
43
43
  route: string;
44
44
  request: Request;
45
45
  store: {};
46
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | 100 | 102 | 207 | 208 | 101 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 420 ? {
46
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 420 ? {
47
47
  readonly 100: "Continue";
48
48
  readonly 101: "Switching Protocols";
49
49
  readonly 102: "Processing";