@mrxsys/mrx-core 2.7.0 → 2.8.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 (77) hide show
  1. package/CHANGELOG.md +67 -48
  2. package/dist/chunk-7g8k2epn.js +104 -0
  3. package/dist/chunk-kv9hms2z.js +28 -0
  4. package/dist/{chunk-qb6x364m.js → chunk-m18th1g5.js} +1 -1
  5. package/dist/chunk-ncc0m208.js +8 -0
  6. package/dist/chunk-r1kcf1q6.js +62 -0
  7. package/dist/chunk-sepwfqdh.js +6 -0
  8. package/dist/{chunk-z6q192p8.js → chunk-syhskygx.js} +4 -4
  9. package/dist/{chunk-tm71j126.js → chunk-y78xrx17.js} +2 -2
  10. package/dist/chunk-z1skzn1j.js +8 -0
  11. package/dist/modules/data/data.d.ts +1 -1
  12. package/dist/modules/database/index.js +2 -2
  13. package/dist/modules/elysia/cache/cache.d.ts +306 -0
  14. package/dist/modules/elysia/cache/index.d.ts +1 -0
  15. package/dist/modules/elysia/cache/index.js +68 -0
  16. package/dist/modules/elysia/cache/types/cacheItem.d.ts +7 -0
  17. package/dist/modules/elysia/cache/types/cacheOptions.d.ts +21 -0
  18. package/dist/modules/elysia/cache/types/index.d.ts +1 -0
  19. package/dist/modules/elysia/cache/utils/generateCacheKey.d.ts +5 -0
  20. package/dist/modules/elysia/cache/utils/index.d.ts +1 -0
  21. package/dist/modules/elysia/cache/utils/index.js +7 -0
  22. package/dist/modules/elysia/crud/crud.d.ts +1 -1
  23. package/dist/modules/elysia/crud/index.js +13 -10
  24. package/dist/modules/elysia/crud/types/crudOptions.d.ts +2 -0
  25. package/dist/modules/elysia/dbResolver/dbResolver.d.ts +1 -1
  26. package/dist/modules/elysia/dbResolver/index.js +3 -3
  27. package/dist/modules/elysia/error/index.js +11 -2
  28. package/dist/modules/elysia/rateLimit/index.js +15 -95
  29. package/dist/modules/elysia/rateLimit/rateLimit.d.ts +28 -11
  30. package/dist/modules/elysia/rateLimit/types/rateLimitOptions.d.ts +3 -15
  31. package/dist/modules/jwt/enums/index.d.ts +2 -0
  32. package/dist/modules/jwt/enums/index.js +11 -0
  33. package/dist/modules/jwt/enums/jwtErrorKeys.d.ts +5 -0
  34. package/dist/modules/jwt/enums/parseHumanTimeToSecondsErrorKeys.d.ts +3 -0
  35. package/dist/modules/jwt/index.d.ts +1 -0
  36. package/dist/modules/jwt/index.js +58 -0
  37. package/dist/modules/jwt/jwt.d.ts +3 -0
  38. package/dist/modules/jwt/utils/index.d.ts +1 -0
  39. package/dist/modules/jwt/utils/index.js +9 -0
  40. package/dist/modules/jwt/utils/parseHumanTimeToSeconds.d.ts +17 -0
  41. package/dist/modules/kvStore/enums/index.d.ts +1 -0
  42. package/dist/modules/kvStore/enums/index.js +7 -0
  43. package/dist/modules/kvStore/enums/kvStoreErrorKeys.d.ts +5 -0
  44. package/dist/modules/kvStore/ioredis/index.d.ts +1 -0
  45. package/dist/modules/kvStore/ioredis/index.js +102 -0
  46. package/dist/modules/kvStore/ioredis/ioredisStore.d.ts +107 -0
  47. package/dist/modules/kvStore/memory/index.d.ts +1 -0
  48. package/dist/modules/kvStore/memory/index.js +9 -0
  49. package/dist/modules/kvStore/memory/memoryStore.d.ts +119 -0
  50. package/dist/modules/{elysia/rateLimit → kvStore/memory}/types/memoryStoreEntry.d.ts +2 -2
  51. package/dist/modules/kvStore/types/index.d.ts +1 -0
  52. package/dist/modules/kvStore/types/index.js +1 -0
  53. package/dist/modules/kvStore/types/kvStore.d.ts +81 -0
  54. package/dist/modules/repository/index.js +1 -1
  55. package/dist/modules/repository/types/queryOptions.d.ts +5 -1
  56. package/dist/modules/totp/hotp.d.ts +11 -0
  57. package/dist/modules/totp/index.d.ts +3 -1
  58. package/dist/modules/totp/index.js +27 -30
  59. package/dist/modules/totp/otpAuthUri.d.ts +21 -0
  60. package/dist/modules/totp/totp.d.ts +0 -40
  61. package/dist/modules/totp/utils/base32.d.ts +1 -1
  62. package/dist/modules/totp/utils/index.d.ts +3 -2
  63. package/dist/modules/totp/utils/index.js +6 -0
  64. package/dist/modules/totp/utils/timeRemaining.d.ts +9 -0
  65. package/package.json +79 -72
  66. package/dist/chunk-cqw9xq4y.js +0 -7
  67. package/dist/modules/elysia/jwt/enums/index.d.ts +0 -1
  68. package/dist/modules/elysia/jwt/enums/index.js +0 -7
  69. package/dist/modules/elysia/jwt/enums/jwtErrorKeys.d.ts +0 -4
  70. package/dist/modules/elysia/jwt/index.d.ts +0 -1
  71. package/dist/modules/elysia/jwt/index.js +0 -77
  72. package/dist/modules/elysia/jwt/jwt.d.ts +0 -119
  73. package/dist/modules/elysia/jwt/types/index.d.ts +0 -1
  74. package/dist/modules/elysia/jwt/types/jwtOptions.d.ts +0 -98
  75. package/dist/modules/elysia/rateLimit/stores/memoryStore.d.ts +0 -47
  76. package/dist/modules/elysia/rateLimit/types/rateLimitStore.d.ts +0 -21
  77. /package/dist/modules/elysia/{jwt → cache}/types/index.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,79 +1,98 @@
1
1
 
2
- ## v2.7.0
2
+ ## v2.8.0
3
3
 
4
- [compare changes](https://github.com/MRX-Systems/MRX-Core/compare/v2.6.0-canary-20250805-40e4647...v2.7.0)
4
+ [compare changes](https://github.com/MRX-Systems/MRX-Core/compare/v2.7.0...v2.8.0)
5
5
 
6
6
  ### 🚀 Enhancements
7
7
 
8
- - **🚀:** AND-228 fix throwIfNoResult custom message ([a1228463](https://github.com/MRX-Systems/MRX-Core/commit/a1228463))
9
- - **🚀:** [add Base32 encoding and decoding utilities] ([e64b06cd](https://github.com/MRX-Systems/MRX-Core/commit/e64b06cd))
10
- - **🚀:** [add createCounterBuffer utility function] ([29af86e4](https://github.com/MRX-Systems/MRX-Core/commit/29af86e4))
11
- - **🚀:** [add generateHmac utility function] ([30142a1e](https://github.com/MRX-Systems/MRX-Core/commit/30142a1e))
12
- - **🚀:** [add unit tests for generateHmac utility function] ([9ff1643a](https://github.com/MRX-Systems/MRX-Core/commit/9ff1643a))
13
- - **🚀:** [add TOTP error keys and generateSecretBytes utility function] ([527008ea](https://github.com/MRX-Systems/MRX-Core/commit/527008ea))
14
- - **🚀:** [add dynamic truncation utility function for HMAC results] ([31c261b0](https://github.com/MRX-Systems/MRX-Core/commit/31c261b0))
15
- - **🚀:** [add utility functions exports for TOTP module] ## Features - Exported utility functions: base32Decode, base32Encode, createCounterBuffer, generateSecretBytes, generateHmac, and dynamicTruncation. ([c92359bd](https://github.com/MRX-Systems/MRX-Core/commit/c92359bd))
16
- - **🚀:** [implement TOTP and HOTP functionalities] ([9a9a3983](https://github.com/MRX-Systems/MRX-Core/commit/9a9a3983))
17
- - **🚀:** [add TOTP module exports for better accessibility] ([aec89c93](https://github.com/MRX-Systems/MRX-Core/commit/aec89c93))
18
- - **🚀:** [add TOTP_ERROR_KEYS export for error handling] ([73e361e3](https://github.com/MRX-Systems/MRX-Core/commit/73e361e3))
19
- - **🚀:** [Add OtpAuth URI type and refactor related code] ([2c2d2b88](https://github.com/MRX-Systems/MRX-Core/commit/2c2d2b88))
20
- - **🚀:** [refactor rate limiting implementation and add MemoryStore] ([158b7ddf](https://github.com/MRX-Systems/MRX-Core/commit/158b7ddf))
8
+ - **🚀:** [Add tags support to CRUD options] ([f38ec111](https://github.com/MRX-Systems/MRX-Core/commit/f38ec111))
9
+ - **🚀:** [Add prefix option to CRUD options] ([6305bcf3](https://github.com/MRX-Systems/MRX-Core/commit/6305bcf3))
10
+ - **🚀:** [Add JWT error keys enumeration] ([5fce607d](https://github.com/MRX-Systems/MRX-Core/commit/5fce607d))
11
+ - **🚀:** [Add parseHumanTimeToSeconds utility function] ([829511bc](https://github.com/MRX-Systems/MRX-Core/commit/829511bc))
12
+ - **🚀:** [Add JWT signing and verification functions] ([82fe48c3](https://github.com/MRX-Systems/MRX-Core/commit/82fe48c3))
13
+ - **🚀:** [Add error keys for human time parsing] ([d566df3e](https://github.com/MRX-Systems/MRX-Core/commit/d566df3e))
14
+ - **🚀:** [Enhance query returning with trigger modifications] ([c5b62b91](https://github.com/MRX-Systems/MRX-Core/commit/c5b62b91))
15
+ - **🚀:** [Add KV_STORE_ERROR_KEYS enum for error handling] ## Features - Introduced `KV_STORE_ERROR_KEYS` enum to standardize error messages. ([45fc7119](https://github.com/MRX-Systems/MRX-Core/commit/45fc7119))
16
+ - **🚀:** [Add IoRedisStore class for Redis-based key-value store] ([0181be2b](https://github.com/MRX-Systems/MRX-Core/commit/0181be2b))
17
+ - **🚀:** [Add MemoryStore class for in-memory key-value storage] ([4342e1f7](https://github.com/MRX-Systems/MRX-Core/commit/4342e1f7))
18
+ - **🚀:** [Add RATE_LIMIT_ERROR_KEYS export] ([1b819bea](https://github.com/MRX-Systems/MRX-Core/commit/1b819bea))
19
+ - **🚀:** [Add generateCacheKey utility for caching requests] ## Features - Introduced `generateCacheKey` function to create a unique cache key based on request properties. ([b80bd5e2](https://github.com/MRX-Systems/MRX-Core/commit/b80bd5e2))
20
+ - **🚀:** [Add caching functionality with cache utility] ([a54cd86f](https://github.com/MRX-Systems/MRX-Core/commit/a54cd86f))
21
+ - **🚀:** [Enhance caching mechanism with route tracking and metadata] ## Features - Implemented route tracking to cache responses based on request method and URL. - Enhanced cache storage to include metadata alongside the response. - Updated cache control headers to reflect cache hits and misses. ([1e77647f](https://github.com/MRX-Systems/MRX-Core/commit/1e77647f))
21
22
 
22
23
  ### 🔧 Fixes
23
24
 
24
- - **🔧:** [Improve error message handling for no results] ([76c297fa](https://github.com/MRX-Systems/MRX-Core/commit/76c297fa))
25
- - **🔧:** [Fix review] ([87c68deb](https://github.com/MRX-Systems/MRX-Core/commit/87c68deb))
25
+ - **🔧:** [Improve error handling in Repository class] ([af8b8ef2](https://github.com/MRX-Systems/MRX-Core/commit/af8b8ef2))
26
+ - **🔧:** [fix add x-cache MISS to the first request] - Added a check to ensure 'x-cache' header is set to 'MISS' if not already defined. - This change enhances the clarity of cache status in responses. ([26eb7929](https://github.com/MRX-Systems/MRX-Core/commit/26eb7929))
27
+ - **🔧:** [Update cache control headers to use metadata TTL] ([d70ce44a](https://github.com/MRX-Systems/MRX-Core/commit/d70ce44a))
26
28
 
27
29
  ### 🧹 Refactors
28
30
 
29
- - **🧹:** [Change in tenary expression] ([4b4c4864](https://github.com/MRX-Systems/MRX-Core/commit/4b4c4864))
30
- - **🧹:** [Update orderBy syntax for query builder] - Refactored the orderBy method to include table name in the query. - Ensured that selected fields are properly referenced with the table name for better clarity and to avoid potential conflicts. ([53eb355e](https://github.com/MRX-Systems/MRX-Core/commit/53eb355e))
31
- - **🧹:** [Refactor query returning and selection logic] ([a6b46fb2](https://github.com/MRX-Systems/MRX-Core/commit/a6b46fb2))
32
- - **🧹:** [Simplify query returning and selection logic] ([b6c04169](https://github.com/MRX-Systems/MRX-Core/commit/b6c04169))
33
- - **🧹:** [Refactor HOTP options parameter initialization] ## Refactoring - Updated the HOTP function's options parameter to provide a default value. ([3937ae22](https://github.com/MRX-Systems/MRX-Core/commit/3937ae22))
34
- - **🧹:** [correct export name for rate limiting module] ([cbb3e9f7](https://github.com/MRX-Systems/MRX-Core/commit/cbb3e9f7))
35
- - **🧹:** [standardize rate limit module exports and structure] ## Refactoring - Corrected export names in the rate limiting module for consistency. - Removed outdated `ratelimitErrorKeys` file and integrated its functionality into the main rate limiting logic. - Updated test cases to reflect the new export structure and ensure proper functionality. - Introduced a new `rateLimit` function with comprehensive documentation. ([f192bb39](https://github.com/MRX-Systems/MRX-Core/commit/f192bb39))
31
+ - **🧹:** [Totp module little clean] ([701c9a3b](https://github.com/MRX-Systems/MRX-Core/commit/701c9a3b))
32
+ - **🧹:** [Enhance error handling structure in error plugin] ## Refactoring - Improved the structure of the error handling in the error plugin. - Updated the validation error response to include detailed error information. ([883a17d2](https://github.com/MRX-Systems/MRX-Core/commit/883a17d2))
33
+ - **🧹:** [Remove JWT plugin and related files for cleanup] ([4805d0d0](https://github.com/MRX-Systems/MRX-Core/commit/4805d0d0))
34
+ - **🧹:** [Rename ResolveDbHeader to dbResolverHeader for consistency] ([239b7898](https://github.com/MRX-Systems/MRX-Core/commit/239b7898))
35
+ - **🧹:** [Refactor like operator to use where clause] ## Refactoring - Changed the implementation of the `$like` operator to use `where` instead of `whereLike`. (for non case sensitive) ([a2cf66d2](https://github.com/MRX-Systems/MRX-Core/commit/a2cf66d2))
36
+ - **🧹:** [Change 'like' operator to use uppercase syntax] ## Refactoring - Updated the 'like' operator in the query builder to use uppercase 'LIKE'. ([19057d82](https://github.com/MRX-Systems/MRX-Core/commit/19057d82))
37
+ - **🧹:** [Remove return await in ioredisStore] ([2019a41c](https://github.com/MRX-Systems/MRX-Core/commit/2019a41c))
38
+ - **🧹:** [Remove rate limiting store implementation] ([aec26501](https://github.com/MRX-Systems/MRX-Core/commit/aec26501))
39
+ - **🧹:** [Refactor rate limiting to use kvStore] ([1d42fb97](https://github.com/MRX-Systems/MRX-Core/commit/1d42fb97))
36
40
 
37
41
  ### 📖 Documentation
38
42
 
39
- - **📖:** [Update documentation for RenameKey type utility] ([379a2403](https://github.com/MRX-Systems/MRX-Core/commit/379a2403))
43
+ - **📖:** [fix tsdoc CoreError to BaseError] ([8db68847](https://github.com/MRX-Systems/MRX-Core/commit/8db68847))
40
44
 
41
45
  ### 📦 Build
42
46
 
43
- - **📦:** [update devDependencies to latest versions] Updated @eslint/js, @stylistic/eslint-plugin, @types/bun, eslint, and typescript-eslint to their latest versions for improved functionality and compatibility. ([1c40c8e7](https://github.com/MRX-Systems/MRX-Core/commit/1c40c8e7))
44
- - **📦:** [add TOTP module paths to builder and package.json] ([d5ad0b26](https://github.com/MRX-Systems/MRX-Core/commit/d5ad0b26))
47
+ - **📦:** [update dependencies in package.json] ([2c69bbb5](https://github.com/MRX-Systems/MRX-Core/commit/2c69bbb5))
48
+ - **📦:** [Update nodemailer type definitions to version 7.0.1] ([387ac697](https://github.com/MRX-Systems/MRX-Core/commit/387ac697))
49
+ - **📦:** [Refactor JWT module paths for better organization] ([9f504873](https://github.com/MRX-Systems/MRX-Core/commit/9f504873))
50
+ - **📦:** [Update JWT module paths and dependencies] ([71eaca98](https://github.com/MRX-Systems/MRX-Core/commit/71eaca98))
51
+ - **📦:** [Update package.json for improved dependency management] ([f48a7fa6](https://github.com/MRX-Systems/MRX-Core/commit/f48a7fa6))
52
+ - **📦:** [Add kvStore module paths to builder] ([3020bf8a](https://github.com/MRX-Systems/MRX-Core/commit/3020bf8a))
53
+ - **📦:** [Update dependencies and add kvStore module paths] ([056c4b2b](https://github.com/MRX-Systems/MRX-Core/commit/056c4b2b))
54
+ - **📦:** [Remove kvStore module from build process] ## Build Changes - Removed './source/modules/kvStore/index.ts' from the build configuration. ([502e25a2](https://github.com/MRX-Systems/MRX-Core/commit/502e25a2))
55
+ - **📦:** [Remove kvStore module from exports] ([b2a02bc6](https://github.com/MRX-Systems/MRX-Core/commit/b2a02bc6))
56
+ - **📦:** [Add cache module to builder configuration] ## Build - Included cache module paths in the builder configuration. ([63681c8b](https://github.com/MRX-Systems/MRX-Core/commit/63681c8b))
57
+ - **📦:** [Add cache module exports to package.json] ([ef662af9](https://github.com/MRX-Systems/MRX-Core/commit/ef662af9))
45
58
 
46
59
  ### 🌊 Types
47
60
 
48
- - **🌊:** [fix TOperations with default CrudOperationsOptions] ([b8b6169d](https://github.com/MRX-Systems/MRX-Core/commit/b8b6169d))
49
- - **🌊:** [add RenameKey type utility for key renaming in objects] ([0d661646](https://github.com/MRX-Systems/MRX-Core/commit/0d661646))
50
- - **🌊:** [Add RenameKey type to type definitions] ## Type Changes - Added `RenameKey` type to the type definitions in `index.ts`. ([e389bcba](https://github.com/MRX-Systems/MRX-Core/commit/e389bcba))
51
- - **🌊:** [add type definitions for TOTP module] ([03917acc](https://github.com/MRX-Systems/MRX-Core/commit/03917acc))
52
- - **🌊:** [Update OtpAuthUri interface for optional properties] ## Type Changes - Made `algorithm`, `digits`, and `period` properties optional in the `OtpAuthUri` interface. ([d1d47681](https://github.com/MRX-Systems/MRX-Core/commit/d1d47681))
61
+ - **🌊:** [Update throwIfNoResult type in QueryOptions interface] Updated the `throwIfNoResult` property in the `QueryOptions` interface to accept an object with optional `message` and `code` properties, enhancing error handling capabilities. ([644ff8be](https://github.com/MRX-Systems/MRX-Core/commit/644ff8be))
62
+ - **🌊:** [Add KvStore interface for key-value store operations] ([ec2c8dea](https://github.com/MRX-Systems/MRX-Core/commit/ec2c8dea))
63
+ - **🌊:** [Add CacheOptions type definition and index export] ([7f17d79b](https://github.com/MRX-Systems/MRX-Core/commit/7f17d79b))
64
+ - **🌊:** [Add CacheItem type definition for caching mechanism] ([a10a15f7](https://github.com/MRX-Systems/MRX-Core/commit/a10a15f7))
53
65
 
54
66
  ### 🦉 Chore
55
67
 
56
- - **🦉:** V2.6.0 ([3a016766](https://github.com/MRX-Systems/MRX-Core/commit/3a016766))
57
- - **🦉:** [clean up CHANGELOG.md for better readability] ([ab70e0fc](https://github.com/MRX-Systems/MRX-Core/commit/ab70e0fc))
68
+ - **🦉:** [Clean up CHANGELOG.md for better readability] ([d66fac36](https://github.com/MRX-Systems/MRX-Core/commit/d66fac36))
58
69
 
59
70
  ### 🧪 Tests
60
71
 
61
- - **🧪:** [Update error message for no result case] ## Tests - Changed the error message for the no result case in the repository tests. ([0f71ce8f](https://github.com/MRX-Systems/MRX-Core/commit/0f71ce8f))
62
- - **🧪:** [add unit tests for Base32 encoding and decoding] ([2b25e11d](https://github.com/MRX-Systems/MRX-Core/commit/2b25e11d))
63
- - **🧪:** [add unit tests for createCounterBuffer function] ([71153e42](https://github.com/MRX-Systems/MRX-Core/commit/71153e42))
64
- - **🧪:** [add unit tests for generateSecretBytes utility function] ([bb33cd78](https://github.com/MRX-Systems/MRX-Core/commit/bb33cd78))
65
- - **🧪:** [add unit tests for dynamic truncation utility function] ([ba6fee56](https://github.com/MRX-Systems/MRX-Core/commit/ba6fee56))
66
- - **🧪:** [add comprehensive unit tests for TOTP functionalities] ([82d5f4d1](https://github.com/MRX-Systems/MRX-Core/commit/82d5f4d1))
67
- - **🧪:** [add comprehensive tests for MemoryStore functionality] ([d1364340](https://github.com/MRX-Systems/MRX-Core/commit/d1364340))
68
- - **🧪:** Enhance rate limiting tests for Redis and memory stores ([2df081e1](https://github.com/MRX-Systems/MRX-Core/commit/2df081e1))
69
-
70
- ### 🤖 CI
71
-
72
- - **🤖:** [Add CI workflows for build, test, and deployment] ([7d98d68b](https://github.com/MRX-Systems/MRX-Core/commit/7d98d68b))
73
- - **🤖:** [update copilot instructions] ([a8540b78](https://github.com/MRX-Systems/MRX-Core/commit/a8540b78))
72
+ - **🧪:** [totp tests little clean] ([238ac25b](https://github.com/MRX-Systems/MRX-Core/commit/238ac25b))
73
+ - **🧪:** [Add test to hande custom code and refacto custom message] ([c7737572](https://github.com/MRX-Systems/MRX-Core/commit/c7737572))
74
+ - **🧪:** [Update validation error handling tests for new structure] ([42184d86](https://github.com/MRX-Systems/MRX-Core/commit/42184d86))
75
+ - **🧪:** [Remove JWT tests for cleanup] ([08ca9a71](https://github.com/MRX-Systems/MRX-Core/commit/08ca9a71))
76
+ - **🧪:** [[Add comprehensive tests for parseHumanTimeToSeconds function] ([8d2c37c1](https://github.com/MRX-Systems/MRX-Core/commit/8d2c37c1))
77
+ - **🧪:** [Add comprehensive tests for JWT signing and verification] ([6c281486](https://github.com/MRX-Systems/MRX-Core/commit/6c281486))
78
+ - **🧪:** [Add tests for parseHumanTimeToSeconds utility function] ([6bf5dbca](https://github.com/MRX-Systems/MRX-Core/commit/6bf5dbca))
79
+ - **🧪:** [Rename ResolveDbHeader to dbResolverHeader for consistency] ([8a5a4dd2](https://github.com/MRX-Systems/MRX-Core/commit/8a5a4dd2))
80
+ - **🧪:** [Add case insensitive Q operator filter test] ## Tests - Introduced a new test case for the Q operator to ensure it is case insensitive. ([fccfb182](https://github.com/MRX-Systems/MRX-Core/commit/fccfb182))
81
+ - **🧪:** [Refactor MSSQL test setup and enhance findByNamePattern] ([e1dcea34](https://github.com/MRX-Systems/MRX-Core/commit/e1dcea34))
82
+ - **🧪:** [Add comprehensive tests for MemoryStore functionality] ([25c165ec](https://github.com/MRX-Systems/MRX-Core/commit/25c165ec))
83
+ - **🧪:** [Refactor rate limit tests to use MemoryStore] ([1311cd07](https://github.com/MRX-Systems/MRX-Core/commit/1311cd07))
84
+ - **🧪:** [Remove MemoryStore test suite] ([e0fe6f39](https://github.com/MRX-Systems/MRX-Core/commit/e0fe6f39))
85
+ - **🧪:** [Add tests for generateCacheKey utility function] ## Tests - Implement unit tests for the `generateCacheKey` function. - Cover scenarios for requests with and without bodies. - Validate that identical requests produce the same cache key. - Ensure different bodies generate different cache keys. ([90562c7a](https://github.com/MRX-Systems/MRX-Core/commit/90562c7a))
86
+ - **🧪:** [Add comprehensive tests for cache module functionality] ([28d28d3d](https://github.com/MRX-Systems/MRX-Core/commit/28d28d3d))
87
+ - **🧪:** [Add test for specific TTL handling in cache logic] - Implemented a test to verify that the cache correctly handles specific TTL values in the `isCached` option. - The test checks that the cache returns a MISS header on the first request and verifies the cache-control header. - It also ensures that after the TTL expires, the cache still returns a MISS header on subsequent requests. ([9ca8a99c](https://github.com/MRX-Systems/MRX-Core/commit/9ca8a99c))
88
+ - **🧪:** [fix test name CoreError to BaseError] ([c02afec2](https://github.com/MRX-Systems/MRX-Core/commit/c02afec2))
89
+
90
+ ### 🎨 Styles
91
+
92
+ - **🎨:** [fix import order in HOTP tests] Rearranged the import statements in the HOTP test file for consistency and improved readability. ([a66d34d6](https://github.com/MRX-Systems/MRX-Core/commit/a66d34d6))
93
+ - **🎨:** [Remove unnecessary blank line in signJWT function] Removed an extra blank line in the signJWT function for improved code readability and consistency. ([8ea44aef](https://github.com/MRX-Systems/MRX-Core/commit/8ea44aef))
74
94
 
75
95
  ### ❤️ Contributors
76
96
 
77
97
  - Ruby <necrelox@proton.me>
78
- - Github-actions <maxime.meriaux@mrxsys.com>
79
98
 
@@ -0,0 +1,104 @@
1
+ import {
2
+ KV_STORE_ERROR_KEYS
3
+ } from "./chunk-z1skzn1j.js";
4
+ import {
5
+ BaseError
6
+ } from "./chunk-vknq69e0.js";
7
+
8
+ // source/modules/kvStore/memory/memoryStore.ts
9
+ class MemoryStore {
10
+ _store = new Map;
11
+ _cleanupInterval;
12
+ _cleanupTimer = null;
13
+ constructor(cleanupIntervalMs) {
14
+ this._cleanupInterval = cleanupIntervalMs ?? 300000;
15
+ this._startCleanup();
16
+ }
17
+ get(key) {
18
+ const entry = this._store.get(key);
19
+ if (!entry)
20
+ return null;
21
+ const now = Date.now();
22
+ if (now > entry.expiresAt && entry.expiresAt !== -1) {
23
+ this._store.delete(key);
24
+ return null;
25
+ }
26
+ return entry.value;
27
+ }
28
+ set(key, value, ttlSec) {
29
+ const expiresAt = ttlSec ? Date.now() + ttlSec * 1000 : -1;
30
+ this._store.set(key, { value, expiresAt });
31
+ }
32
+ increment(key, amount = 1) {
33
+ const current = this.get(key);
34
+ const entry = this._store.get(key);
35
+ if (current !== null && typeof current !== "number")
36
+ throw new BaseError({
37
+ message: KV_STORE_ERROR_KEYS.NOT_INTEGER
38
+ });
39
+ const currentValue = current ?? 0;
40
+ const newValue = currentValue + amount;
41
+ const expiresAt = entry ? entry.expiresAt : -1;
42
+ this._store.set(key, { value: newValue, expiresAt });
43
+ return newValue;
44
+ }
45
+ decrement(key, amount = 1) {
46
+ const current = this.get(key);
47
+ const entry = this._store.get(key);
48
+ if (current !== null && typeof current !== "number")
49
+ throw new BaseError({
50
+ message: KV_STORE_ERROR_KEYS.NOT_INTEGER
51
+ });
52
+ const currentValue = current ?? 0;
53
+ const newValue = currentValue - amount;
54
+ const expiresAt = entry ? entry.expiresAt : -1;
55
+ this._store.set(key, { value: newValue, expiresAt });
56
+ return newValue;
57
+ }
58
+ del(key) {
59
+ return this._store.delete(key);
60
+ }
61
+ expire(key, ttlSec) {
62
+ const entry = this._store.get(key);
63
+ if (!entry)
64
+ return false;
65
+ entry.expiresAt = Date.now() + ttlSec * 1000;
66
+ return true;
67
+ }
68
+ ttl(key) {
69
+ const entry = this._store.get(key);
70
+ if (!entry)
71
+ return -1;
72
+ if (entry.expiresAt === -1)
73
+ return -1;
74
+ const remaining = entry.expiresAt - Date.now();
75
+ return remaining > 0 ? Math.ceil(remaining / 1000) : -1;
76
+ }
77
+ clean() {
78
+ const sizeBefore = this._store.size;
79
+ this._store.clear();
80
+ return sizeBefore;
81
+ }
82
+ _startCleanup() {
83
+ if (this._cleanupTimer)
84
+ return;
85
+ this._cleanupTimer = setInterval(() => {
86
+ this._removeExpiredEntries();
87
+ }, this._cleanupInterval);
88
+ }
89
+ _removeExpiredEntries() {
90
+ const now = Date.now();
91
+ for (const [key, entry] of this._store.entries())
92
+ if (entry.expiresAt !== -1 && now > entry.expiresAt)
93
+ this._store.delete(key);
94
+ }
95
+ destroy() {
96
+ if (this._cleanupTimer) {
97
+ clearInterval(this._cleanupTimer);
98
+ this._cleanupTimer = null;
99
+ }
100
+ this._store.clear();
101
+ }
102
+ }
103
+
104
+ export { MemoryStore };
@@ -0,0 +1,28 @@
1
+ // source/modules/elysia/cache/utils/generateCacheKey.ts
2
+ var _calculateBodyHash = async (body, hasher) => {
3
+ if (!body)
4
+ return;
5
+ const reader = body.getReader();
6
+ try {
7
+ while (true) {
8
+ const { done, value } = await reader.read();
9
+ if (done)
10
+ break;
11
+ if (value)
12
+ hasher.update(new Uint8Array(value));
13
+ }
14
+ } finally {
15
+ reader.releaseLock();
16
+ }
17
+ };
18
+ var generateCacheKey = async (request) => {
19
+ const { method, url, headers } = request;
20
+ const hasher = new Bun.CryptoHasher("sha256");
21
+ hasher.update(method);
22
+ hasher.update(url);
23
+ hasher.update(JSON.stringify(headers));
24
+ await _calculateBodyHash(request.body, hasher);
25
+ return hasher.digest("hex");
26
+ };
27
+
28
+ export { generateCacheKey };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Repository
3
- } from "./chunk-z6q192p8.js";
3
+ } from "./chunk-syhskygx.js";
4
4
  import {
5
5
  TypedEventEmitter
6
6
  } from "./chunk-yvyahr2h.js";
@@ -0,0 +1,8 @@
1
+ // source/modules/jwt/enums/jwtErrorKeys.ts
2
+ var JWT_ERROR_KEYS = {
3
+ JWT_SIGN_ERROR: "jwt.error.sign_error",
4
+ JWT_SECRET_NOT_FOUND: "jwt.error.secret_not_found",
5
+ JWT_EXPIRATION_PASSED: "jwt.error.expiration_passed"
6
+ };
7
+
8
+ export { JWT_ERROR_KEYS };
@@ -0,0 +1,62 @@
1
+ import {
2
+ PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS
3
+ } from "./chunk-sepwfqdh.js";
4
+ import {
5
+ BaseError
6
+ } from "./chunk-vknq69e0.js";
7
+
8
+ // source/modules/jwt/utils/parseHumanTimeToSeconds.ts
9
+ var TIME_UNITS = {
10
+ SECOND: 1,
11
+ MINUTE: 60,
12
+ HOUR: 60 * 60,
13
+ DAY: 60 * 60 * 24,
14
+ WEEK: 60 * 60 * 24 * 7,
15
+ YEAR: 60 * 60 * 24 * 365.25
16
+ };
17
+ var TIME_EXPRESSION_REGEX = /^(\+|-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
18
+ var UNIT_MAPPINGS = {
19
+ s: TIME_UNITS.SECOND,
20
+ sec: TIME_UNITS.SECOND,
21
+ secs: TIME_UNITS.SECOND,
22
+ second: TIME_UNITS.SECOND,
23
+ seconds: TIME_UNITS.SECOND,
24
+ m: TIME_UNITS.MINUTE,
25
+ min: TIME_UNITS.MINUTE,
26
+ mins: TIME_UNITS.MINUTE,
27
+ minute: TIME_UNITS.MINUTE,
28
+ minutes: TIME_UNITS.MINUTE,
29
+ h: TIME_UNITS.HOUR,
30
+ hr: TIME_UNITS.HOUR,
31
+ hrs: TIME_UNITS.HOUR,
32
+ hour: TIME_UNITS.HOUR,
33
+ hours: TIME_UNITS.HOUR,
34
+ d: TIME_UNITS.DAY,
35
+ day: TIME_UNITS.DAY,
36
+ days: TIME_UNITS.DAY,
37
+ w: TIME_UNITS.WEEK,
38
+ week: TIME_UNITS.WEEK,
39
+ weeks: TIME_UNITS.WEEK,
40
+ y: TIME_UNITS.YEAR,
41
+ yr: TIME_UNITS.YEAR,
42
+ yrs: TIME_UNITS.YEAR,
43
+ year: TIME_UNITS.YEAR,
44
+ years: TIME_UNITS.YEAR
45
+ };
46
+ var parseHumanTimeToSeconds = (timeExpression) => {
47
+ const match = TIME_EXPRESSION_REGEX.exec(timeExpression);
48
+ if (!match || match[4] && match[1])
49
+ throw new BaseError({
50
+ message: PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS.INVALID_TIME_EXPRESSION
51
+ });
52
+ const [, sign, valueStr, unitStr, direction] = match;
53
+ const value = parseFloat(valueStr);
54
+ const unit = unitStr.toLowerCase();
55
+ const multiplier = UNIT_MAPPINGS[unit];
56
+ const seconds = Math.round(value * multiplier);
57
+ if (sign === "-" || direction === "ago")
58
+ return -seconds;
59
+ return seconds;
60
+ };
61
+
62
+ export { parseHumanTimeToSeconds };
@@ -0,0 +1,6 @@
1
+ // source/modules/jwt/enums/parseHumanTimeToSecondsErrorKeys.ts
2
+ var PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS = {
3
+ INVALID_TIME_EXPRESSION: "parse_human_time_to_seconds.error.invalid_time_expression"
4
+ };
5
+
6
+ export { PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS };
@@ -27,7 +27,7 @@ var _operators = {
27
27
  const likeValue = `%${v}%`;
28
28
  if (isDateString(v))
29
29
  return q.whereRaw(`CONVERT(VARCHAR, ${c}, 23) LIKE ?`, [likeValue]);
30
- return q.whereLike(c, likeValue);
30
+ return q.where(c, "LIKE", likeValue);
31
31
  },
32
32
  $nlike: (q, c, v) => {
33
33
  const likeValue = `%${v}%`;
@@ -126,7 +126,7 @@ class Repository {
126
126
  const qMethod = query._method;
127
127
  const sanitizedFields = selectedFields ? Array.isArray(selectedFields) ? selectedFields.map((selectedField) => `${selectedField} as ${selectedField}`) : `${selectedFields} as ${selectedFields}` : "*";
128
128
  if (qMethod === "del" || qMethod === "update" || qMethod === "insert")
129
- query.returning(sanitizedFields);
129
+ query.returning(sanitizedFields, { includeTriggerModifications: true });
130
130
  else
131
131
  query.select(sanitizedFields);
132
132
  }
@@ -202,11 +202,11 @@ class Repository {
202
202
  const result = await query;
203
203
  if (throwIfNoResult && result.length === 0)
204
204
  throw new HttpError({
205
- message: typeof throwIfNoResult === "string" ? throwIfNoResult : DATABASE_ERROR_KEYS.MSSQL_NO_RESULT,
205
+ message: typeof throwIfNoResult === "object" && throwIfNoResult.message ? throwIfNoResult.message : DATABASE_ERROR_KEYS.MSSQL_NO_RESULT,
206
206
  cause: {
207
207
  query: query.toSQL().sql
208
208
  },
209
- httpStatusCode: 404
209
+ httpStatusCode: typeof throwIfNoResult === "object" && throwIfNoResult.code ? throwIfNoResult.code : 404
210
210
  });
211
211
  return result;
212
212
  } catch (error) {
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-dwfyt1m6.js";
7
7
  import {
8
8
  MSSQL
9
- } from "./chunk-qb6x364m.js";
9
+ } from "./chunk-m18th1g5.js";
10
10
  import {
11
11
  HttpError
12
12
  } from "./chunk-683sda6e.js";
@@ -42,7 +42,7 @@ var dbResolver = (database) => {
42
42
  }).resolve({ as: "global" }, async ({ headers }) => _resolveDatabaseConnection(database, headers));
43
43
  if (typeof database === "object")
44
44
  app.model({
45
- ResolveDbHeader: t.Object({
45
+ dbResolverHeader: t.Object({
46
46
  "database-using": t.String({
47
47
  description: "The name of the database to be used for the request"
48
48
  })
@@ -0,0 +1,8 @@
1
+ // source/modules/kvStore/enums/kvStoreErrorKeys.ts
2
+ var KV_STORE_ERROR_KEYS = {
3
+ NOT_INTEGER: "kv-store.error.not_integer",
4
+ CONNECTION_FAILED: "kv-store.error.connection_failed",
5
+ CLOSING_CONNECTION_FAILED: "kv-store.error.closing_connection_failed"
6
+ };
7
+
8
+ export { KV_STORE_ERROR_KEYS };
@@ -103,7 +103,7 @@ export declare const filterByValue: <TObject extends Readonly<object>>(data: Rea
103
103
  * @param data - The object whose keys are to be transformed.
104
104
  * @param transformer - The key transformation strategy to use.
105
105
  *
106
- * @throws ({@link CoreError}) - If the provided data object is null or undefined.
106
+ * @throws ({@link BaseError}) - If the provided data object is null or undefined.
107
107
  *
108
108
  * @returns A new object with transformed keys.
109
109
  *
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  MSSQL,
4
4
  Table
5
- } from "../../chunk-qb6x364m.js";
6
- import"../../chunk-z6q192p8.js";
5
+ } from "../../chunk-m18th1g5.js";
6
+ import"../../chunk-syhskygx.js";
7
7
  import"../../chunk-5qtpggzv.js";
8
8
  import"../../chunk-yvyahr2h.js";
9
9
  import"../../chunk-zaje5tv4.js";