@forklaunch/core 0.2.36 → 0.3.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 (222) hide show
  1. package/lib/{src/database/mikro/models/entities/base.entity.d.ts → base.entity-DNfmMOgd.d.mts} +3 -2
  2. package/lib/base.entity-DNfmMOgd.d.ts +27 -0
  3. package/lib/{src/cache/redisTtlCache.d.ts → cache/index.d.mts} +67 -4
  4. package/lib/cache/index.d.ts +130 -0
  5. package/lib/cache/index.js +133 -0
  6. package/lib/cache/index.mjs +105 -0
  7. package/lib/controllers/index.d.mts +5 -0
  8. package/lib/controllers/index.d.ts +5 -0
  9. package/lib/controllers/index.js +18 -0
  10. package/lib/controllers/index.mjs +0 -0
  11. package/lib/database/index.d.mts +37 -0
  12. package/lib/{src/database/mikro/models/entities/mongo.base.entity.d.ts → database/index.d.ts} +5 -2
  13. package/lib/database/index.js +78 -0
  14. package/lib/database/index.mjs +53 -0
  15. package/lib/dtoMapper/index.d.mts +215 -0
  16. package/lib/dtoMapper/index.d.ts +215 -0
  17. package/lib/dtoMapper/index.js +230 -0
  18. package/lib/dtoMapper/index.mjs +202 -0
  19. package/lib/http/index.d.mts +910 -0
  20. package/lib/http/index.d.ts +910 -0
  21. package/lib/http/index.js +2181 -0
  22. package/lib/http/index.mjs +2122 -0
  23. package/lib/services/index.d.mts +64 -0
  24. package/lib/services/index.d.ts +64 -0
  25. package/lib/services/index.js +159 -0
  26. package/lib/services/index.mjs +131 -0
  27. package/package.json +39 -26
  28. package/lib/src/cache/index.d.ts +0 -5
  29. package/lib/src/cache/index.d.ts.map +0 -1
  30. package/lib/src/cache/index.js +0 -4
  31. package/lib/src/cache/interfaces/ttlCache.interface.d.ts +0 -48
  32. package/lib/src/cache/interfaces/ttlCache.interface.d.ts.map +0 -1
  33. package/lib/src/cache/interfaces/ttlCache.interface.js +0 -1
  34. package/lib/src/cache/redisTtlCache.d.ts.map +0 -1
  35. package/lib/src/cache/redisTtlCache.js +0 -98
  36. package/lib/src/cache/types/ttlCacheRecord.types.d.ts +0 -14
  37. package/lib/src/cache/types/ttlCacheRecord.types.d.ts.map +0 -1
  38. package/lib/src/cache/types/ttlCacheRecord.types.js +0 -1
  39. package/lib/src/cache/utils/cacheKey.d.ts +0 -2
  40. package/lib/src/cache/utils/cacheKey.d.ts.map +0 -1
  41. package/lib/src/cache/utils/cacheKey.js +0 -3
  42. package/lib/src/controllers/index.d.ts +0 -2
  43. package/lib/src/controllers/index.d.ts.map +0 -1
  44. package/lib/src/controllers/index.js +0 -1
  45. package/lib/src/controllers/interfaces/controller.interface.d.ts +0 -4
  46. package/lib/src/controllers/interfaces/controller.interface.d.ts.map +0 -1
  47. package/lib/src/controllers/interfaces/controller.interface.js +0 -1
  48. package/lib/src/database/index.d.ts +0 -3
  49. package/lib/src/database/index.d.ts.map +0 -1
  50. package/lib/src/database/index.js +0 -2
  51. package/lib/src/database/mikro/models/entities/base.entity.d.ts.map +0 -1
  52. package/lib/src/database/mikro/models/entities/base.entity.js +0 -42
  53. package/lib/src/database/mikro/models/entities/mongo.base.entity.d.ts.map +0 -1
  54. package/lib/src/database/mikro/models/entities/mongo.base.entity.js +0 -51
  55. package/lib/src/dtoMapper/index.d.ts +0 -3
  56. package/lib/src/dtoMapper/index.d.ts.map +0 -1
  57. package/lib/src/dtoMapper/index.js +0 -2
  58. package/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts +0 -18
  59. package/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts.map +0 -1
  60. package/lib/src/dtoMapper/interfaces/dtoMapper.interface.js +0 -1
  61. package/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts +0 -72
  62. package/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts.map +0 -1
  63. package/lib/src/dtoMapper/models/baseDtoMapper.model.js +0 -76
  64. package/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts +0 -68
  65. package/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts.map +0 -1
  66. package/lib/src/dtoMapper/models/requestDtoMapper.model.js +0 -71
  67. package/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts +0 -67
  68. package/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts.map +0 -1
  69. package/lib/src/dtoMapper/models/responseDtoMapper.model.js +0 -68
  70. package/lib/src/dtoMapper/types/dtoMapper.types.d.ts +0 -9
  71. package/lib/src/dtoMapper/types/dtoMapper.types.d.ts.map +0 -1
  72. package/lib/src/dtoMapper/types/dtoMapper.types.js +0 -1
  73. package/lib/src/http/application/expressLikeApplication.d.ts +0 -21
  74. package/lib/src/http/application/expressLikeApplication.d.ts.map +0 -1
  75. package/lib/src/http/application/expressLikeApplication.js +0 -21
  76. package/lib/src/http/guards/isConstrainedForklaunchRouter.d.ts +0 -4
  77. package/lib/src/http/guards/isConstrainedForklaunchRouter.d.ts.map +0 -1
  78. package/lib/src/http/guards/isConstrainedForklaunchRouter.js +0 -5
  79. package/lib/src/http/guards/isExpressLikeSchemaHandler.d.ts +0 -5
  80. package/lib/src/http/guards/isExpressLikeSchemaHandler.d.ts.map +0 -1
  81. package/lib/src/http/guards/isExpressLikeSchemaHandler.js +0 -6
  82. package/lib/src/http/guards/isForklaunchExpressLikeRouter.d.ts +0 -5
  83. package/lib/src/http/guards/isForklaunchExpressLikeRouter.d.ts.map +0 -1
  84. package/lib/src/http/guards/isForklaunchExpressLikeRouter.js +0 -6
  85. package/lib/src/http/guards/isForklaunchRouter.d.ts +0 -4
  86. package/lib/src/http/guards/isForklaunchRouter.d.ts.map +0 -1
  87. package/lib/src/http/guards/isForklaunchRouter.js +0 -7
  88. package/lib/src/http/guards/isHttpContractDetails.d.ts +0 -7
  89. package/lib/src/http/guards/isHttpContractDetails.d.ts.map +0 -1
  90. package/lib/src/http/guards/isHttpContractDetails.js +0 -9
  91. package/lib/src/http/guards/isPathParamContractDetails.d.ts +0 -4
  92. package/lib/src/http/guards/isPathParamContractDetails.d.ts.map +0 -1
  93. package/lib/src/http/guards/isPathParamContractDetails.js +0 -10
  94. package/lib/src/http/guards/isResponseShape.d.ts +0 -3
  95. package/lib/src/http/guards/isResponseShape.d.ts.map +0 -1
  96. package/lib/src/http/guards/isResponseShape.js +0 -7
  97. package/lib/src/http/guards/isTypedHandler.d.ts +0 -5
  98. package/lib/src/http/guards/isTypedHandler.d.ts.map +0 -1
  99. package/lib/src/http/guards/isTypedHandler.js +0 -6
  100. package/lib/src/http/handlers/delete.d.ts +0 -9
  101. package/lib/src/http/handlers/delete.d.ts.map +0 -1
  102. package/lib/src/http/handlers/delete.js +0 -4
  103. package/lib/src/http/handlers/get.d.ts +0 -9
  104. package/lib/src/http/handlers/get.d.ts.map +0 -1
  105. package/lib/src/http/handlers/get.js +0 -4
  106. package/lib/src/http/handlers/head.d.ts +0 -9
  107. package/lib/src/http/handlers/head.d.ts.map +0 -1
  108. package/lib/src/http/handlers/head.js +0 -4
  109. package/lib/src/http/handlers/middleware.d.ts +0 -9
  110. package/lib/src/http/handlers/middleware.d.ts.map +0 -1
  111. package/lib/src/http/handlers/middleware.js +0 -4
  112. package/lib/src/http/handlers/options.d.ts +0 -9
  113. package/lib/src/http/handlers/options.d.ts.map +0 -1
  114. package/lib/src/http/handlers/options.js +0 -4
  115. package/lib/src/http/handlers/patch.d.ts +0 -9
  116. package/lib/src/http/handlers/patch.d.ts.map +0 -1
  117. package/lib/src/http/handlers/patch.js +0 -4
  118. package/lib/src/http/handlers/post.d.ts +0 -9
  119. package/lib/src/http/handlers/post.d.ts.map +0 -1
  120. package/lib/src/http/handlers/post.js +0 -4
  121. package/lib/src/http/handlers/put.d.ts +0 -9
  122. package/lib/src/http/handlers/put.d.ts.map +0 -1
  123. package/lib/src/http/handlers/put.js +0 -4
  124. package/lib/src/http/handlers/trace.d.ts +0 -9
  125. package/lib/src/http/handlers/trace.d.ts.map +0 -1
  126. package/lib/src/http/handlers/trace.js +0 -4
  127. package/lib/src/http/handlers/typedAuthHandler.d.ts +0 -5
  128. package/lib/src/http/handlers/typedAuthHandler.d.ts.map +0 -1
  129. package/lib/src/http/handlers/typedAuthHandler.js +0 -3
  130. package/lib/src/http/handlers/typedHandler.d.ts +0 -21
  131. package/lib/src/http/handlers/typedHandler.d.ts.map +0 -1
  132. package/lib/src/http/handlers/typedHandler.js +0 -30
  133. package/lib/src/http/index.d.ts +0 -23
  134. package/lib/src/http/index.d.ts.map +0 -1
  135. package/lib/src/http/index.js +0 -22
  136. package/lib/src/http/interfaces/expressLikeRouter.interface.d.ts +0 -24
  137. package/lib/src/http/interfaces/expressLikeRouter.interface.d.ts.map +0 -1
  138. package/lib/src/http/interfaces/expressLikeRouter.interface.js +0 -1
  139. package/lib/src/http/middleware/request/auth.middleware.d.ts +0 -16
  140. package/lib/src/http/middleware/request/auth.middleware.d.ts.map +0 -1
  141. package/lib/src/http/middleware/request/auth.middleware.js +0 -143
  142. package/lib/src/http/middleware/request/cors.middleware.d.ts +0 -13
  143. package/lib/src/http/middleware/request/cors.middleware.d.ts.map +0 -1
  144. package/lib/src/http/middleware/request/cors.middleware.js +0 -15
  145. package/lib/src/http/middleware/request/createContext.middleware.d.ts +0 -15
  146. package/lib/src/http/middleware/request/createContext.middleware.d.ts.map +0 -1
  147. package/lib/src/http/middleware/request/createContext.middleware.js +0 -26
  148. package/lib/src/http/middleware/request/enrichDetails.middleware.d.ts +0 -15
  149. package/lib/src/http/middleware/request/enrichDetails.middleware.d.ts.map +0 -1
  150. package/lib/src/http/middleware/request/enrichDetails.middleware.js +0 -19
  151. package/lib/src/http/middleware/request/parse.middleware.d.ts +0 -17
  152. package/lib/src/http/middleware/request/parse.middleware.d.ts.map +0 -1
  153. package/lib/src/http/middleware/request/parse.middleware.js +0 -43
  154. package/lib/src/http/middleware/response/parse.middleware.d.ts +0 -31
  155. package/lib/src/http/middleware/response/parse.middleware.d.ts.map +0 -1
  156. package/lib/src/http/middleware/response/parse.middleware.js +0 -52
  157. package/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts +0 -14
  158. package/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts.map +0 -1
  159. package/lib/src/http/openApiV3Generator/openApiV3Generator.js +0 -169
  160. package/lib/src/http/router/expressLikeRouter.d.ts +0 -138
  161. package/lib/src/http/router/expressLikeRouter.d.ts.map +0 -1
  162. package/lib/src/http/router/expressLikeRouter.js +0 -483
  163. package/lib/src/http/types/apiDefinition.types.d.ts +0 -260
  164. package/lib/src/http/types/apiDefinition.types.d.ts.map +0 -1
  165. package/lib/src/http/types/apiDefinition.types.js +0 -1
  166. package/lib/src/http/types/contractDetails.types.d.ts +0 -211
  167. package/lib/src/http/types/contractDetails.types.d.ts.map +0 -1
  168. package/lib/src/http/types/contractDetails.types.js +0 -1
  169. package/lib/src/http/types/expressLikeRouter.types.d.ts +0 -51
  170. package/lib/src/http/types/expressLikeRouter.types.d.ts.map +0 -1
  171. package/lib/src/http/types/expressLikeRouter.types.js +0 -1
  172. package/lib/src/http/types/router.types.d.ts +0 -32
  173. package/lib/src/http/types/router.types.d.ts.map +0 -1
  174. package/lib/src/http/types/router.types.js +0 -1
  175. package/lib/src/http/types/typedHandler.types.d.ts +0 -10
  176. package/lib/src/http/types/typedHandler.types.d.ts.map +0 -1
  177. package/lib/src/http/types/typedHandler.types.js +0 -1
  178. package/lib/src/http/utils/enrichExpressLikeSend.d.ts +0 -32
  179. package/lib/src/http/utils/enrichExpressLikeSend.d.ts.map +0 -1
  180. package/lib/src/http/utils/enrichExpressLikeSend.js +0 -50
  181. package/lib/src/http/utils/httpStatusCodes.d.ts +0 -75
  182. package/lib/src/http/utils/httpStatusCodes.d.ts.map +0 -1
  183. package/lib/src/http/utils/httpStatusCodes.js +0 -1039
  184. package/lib/src/services/configInjector.d.ts +0 -21
  185. package/lib/src/services/configInjector.d.ts.map +0 -1
  186. package/lib/src/services/configInjector.js +0 -90
  187. package/lib/src/services/index.d.ts +0 -5
  188. package/lib/src/services/index.d.ts.map +0 -1
  189. package/lib/src/services/index.js +0 -4
  190. package/lib/src/services/interfaces/baseService.d.ts +0 -15
  191. package/lib/src/services/interfaces/baseService.d.ts.map +0 -1
  192. package/lib/src/services/interfaces/baseService.js +0 -1
  193. package/lib/src/services/types/configInjector.types.d.ts +0 -25
  194. package/lib/src/services/types/configInjector.types.d.ts.map +0 -1
  195. package/lib/src/services/types/configInjector.types.js +0 -6
  196. package/lib/src/services/types/entityManager.types.d.ts +0 -4
  197. package/lib/src/services/types/entityManager.types.d.ts.map +0 -1
  198. package/lib/src/services/types/entityManager.types.js +0 -1
  199. package/lib/tests/configInjector.test.d.ts +0 -2
  200. package/lib/tests/configInjector.test.d.ts.map +0 -1
  201. package/lib/tests/configInjector.test.js +0 -105
  202. package/lib/tests/dtoMapper.test.d.ts +0 -2
  203. package/lib/tests/dtoMapper.test.d.ts.map +0 -1
  204. package/lib/tests/dtoMapper.test.js +0 -170
  205. package/lib/tests/expressLikeRouterInstantiation.test.d.ts +0 -2
  206. package/lib/tests/expressLikeRouterInstantiation.test.d.ts.map +0 -1
  207. package/lib/tests/expressLikeRouterInstantiation.test.js +0 -118
  208. package/lib/tests/http.middleware.test.d.ts +0 -2
  209. package/lib/tests/http.middleware.test.d.ts.map +0 -1
  210. package/lib/tests/http.middleware.test.js +0 -102
  211. package/lib/tests/openApiV3Generator.test.d.ts +0 -2
  212. package/lib/tests/openApiV3Generator.test.d.ts.map +0 -1
  213. package/lib/tests/openApiV3Generator.test.js +0 -66
  214. package/lib/tests/redisTtlCache.test.d.ts +0 -2
  215. package/lib/tests/redisTtlCache.test.d.ts.map +0 -1
  216. package/lib/tests/redisTtlCache.test.js +0 -49
  217. package/lib/tests/typedHandler.test.d.ts +0 -2
  218. package/lib/tests/typedHandler.test.d.ts.map +0 -1
  219. package/lib/tests/typedHandler.test.js +0 -3
  220. package/lib/vitest.config.d.ts +0 -3
  221. package/lib/vitest.config.d.ts.map +0 -1
  222. package/lib/vitest.config.js +0 -7
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Abstract class representing a base entity.
3
3
  */
4
- export declare abstract class BaseEntity {
4
+ declare abstract class BaseEntity {
5
5
  /**
6
6
  * The unique identifier for the entity.
7
7
  *
@@ -23,4 +23,5 @@ export declare abstract class BaseEntity {
23
23
  */
24
24
  updatedAt: Date;
25
25
  }
26
- //# sourceMappingURL=base.entity.d.ts.map
26
+
27
+ export { BaseEntity as B };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Abstract class representing a base entity.
3
+ */
4
+ declare abstract class BaseEntity {
5
+ /**
6
+ * The unique identifier for the entity.
7
+ *
8
+ * @type {string}
9
+ * @readonly
10
+ */
11
+ id: string;
12
+ /**
13
+ * The date when the entity was created.
14
+ *
15
+ * @type {Date}
16
+ */
17
+ createdAt: Date;
18
+ /**
19
+ * The date when the entity was last updated.
20
+ *
21
+ * @type {Date}
22
+ * @readonly
23
+ */
24
+ updatedAt: Date;
25
+ }
26
+
27
+ export { BaseEntity as B };
@@ -1,11 +1,71 @@
1
1
  import { RedisClientOptions } from 'redis';
2
- import { TtlCache } from './interfaces/ttlCache.interface';
3
- import { TtlCacheRecord } from './types/ttlCacheRecord.types';
2
+
3
+ /**
4
+ * Type representing a TTL (Time-To-Live) cache record.
5
+ *
6
+ * @typedef {Object} TtlCacheRecord
7
+ * @property {string} key - The key of the cache record.
8
+ * @property {any} value - The value of the cache record.
9
+ * @property {number} ttlMilliseconds - The time-to-live of the cache record in milliseconds.
10
+ */
11
+ type TtlCacheRecord<T> = {
12
+ key: string;
13
+ value: T;
14
+ ttlMilliseconds: number;
15
+ };
16
+
17
+ /**
18
+ * Interface representing a TTL (Time-To-Live) cache.
19
+ */
20
+ interface TtlCache {
21
+ /**
22
+ * Puts a record into the cache.
23
+ *
24
+ * @param {TtlCacheRecord} cacheRecord - The cache record to put into the cache.
25
+ * @returns {Promise<void>} - A promise that resolves when the record is put into the cache.
26
+ */
27
+ putRecord<T>(cacheRecord: TtlCacheRecord<T>): Promise<void>;
28
+ /**
29
+ * Deletes a record from the cache.
30
+ *
31
+ * @param {string} cacheRecordKey - The key of the cache record to delete.
32
+ * @returns {Promise<void>} - A promise that resolves when the record is deleted from the cache.
33
+ */
34
+ deleteRecord(cacheRecordKey: string): Promise<void>;
35
+ /**
36
+ * Reads a record from the cache.
37
+ *
38
+ * @param {string} cacheRecordKey - The key of the cache record to read.
39
+ * @returns {Promise<TtlCacheRecord>} - A promise that resolves with the cache record.
40
+ */
41
+ readRecord<T>(cacheRecordKey: string): Promise<TtlCacheRecord<T>>;
42
+ /**
43
+ * Peeks at a record in the cache to check if it exists.
44
+ *
45
+ * @param {string} cacheRecordKey - The key of the cache record to peek at.
46
+ * @returns {Promise<boolean>} - A promise that resolves with a boolean indicating if the record exists.
47
+ */
48
+ peekRecord(cacheRecordKey: string): Promise<boolean>;
49
+ /**
50
+ * Gets the TTL (Time-To-Live) in milliseconds.
51
+ *
52
+ * @returns {number} - The TTL in milliseconds.
53
+ */
54
+ getTtlMilliseconds(): number;
55
+ /**
56
+ * Lists the keys in the cache that match a pattern prefix.
57
+ *
58
+ * @param {string} pattern_prefix - The pattern prefix to match.
59
+ * @returns {Promise<string[]>} - A promise that resolves with an array of keys matching the pattern prefix.
60
+ */
61
+ listKeys(pattern_prefix: string): Promise<string[]>;
62
+ }
63
+
4
64
  /**
5
65
  * Class representing a Redis-based TTL (Time-To-Live) cache.
6
66
  * Implements the TtlCache interface.
7
67
  */
8
- export declare class RedisTtlCache implements TtlCache {
68
+ declare class RedisTtlCache implements TtlCache {
9
69
  private ttlMilliseconds;
10
70
  private client;
11
71
  /**
@@ -64,4 +124,7 @@ export declare class RedisTtlCache implements TtlCache {
64
124
  */
65
125
  getTtlMilliseconds(): number;
66
126
  }
67
- //# sourceMappingURL=redisTtlCache.d.ts.map
127
+
128
+ declare const createCacheKey: (cacheKeyPrefix: string) => (id: string) => string;
129
+
130
+ export { RedisTtlCache, type TtlCache, type TtlCacheRecord, createCacheKey };
@@ -0,0 +1,130 @@
1
+ import { RedisClientOptions } from 'redis';
2
+
3
+ /**
4
+ * Type representing a TTL (Time-To-Live) cache record.
5
+ *
6
+ * @typedef {Object} TtlCacheRecord
7
+ * @property {string} key - The key of the cache record.
8
+ * @property {any} value - The value of the cache record.
9
+ * @property {number} ttlMilliseconds - The time-to-live of the cache record in milliseconds.
10
+ */
11
+ type TtlCacheRecord<T> = {
12
+ key: string;
13
+ value: T;
14
+ ttlMilliseconds: number;
15
+ };
16
+
17
+ /**
18
+ * Interface representing a TTL (Time-To-Live) cache.
19
+ */
20
+ interface TtlCache {
21
+ /**
22
+ * Puts a record into the cache.
23
+ *
24
+ * @param {TtlCacheRecord} cacheRecord - The cache record to put into the cache.
25
+ * @returns {Promise<void>} - A promise that resolves when the record is put into the cache.
26
+ */
27
+ putRecord<T>(cacheRecord: TtlCacheRecord<T>): Promise<void>;
28
+ /**
29
+ * Deletes a record from the cache.
30
+ *
31
+ * @param {string} cacheRecordKey - The key of the cache record to delete.
32
+ * @returns {Promise<void>} - A promise that resolves when the record is deleted from the cache.
33
+ */
34
+ deleteRecord(cacheRecordKey: string): Promise<void>;
35
+ /**
36
+ * Reads a record from the cache.
37
+ *
38
+ * @param {string} cacheRecordKey - The key of the cache record to read.
39
+ * @returns {Promise<TtlCacheRecord>} - A promise that resolves with the cache record.
40
+ */
41
+ readRecord<T>(cacheRecordKey: string): Promise<TtlCacheRecord<T>>;
42
+ /**
43
+ * Peeks at a record in the cache to check if it exists.
44
+ *
45
+ * @param {string} cacheRecordKey - The key of the cache record to peek at.
46
+ * @returns {Promise<boolean>} - A promise that resolves with a boolean indicating if the record exists.
47
+ */
48
+ peekRecord(cacheRecordKey: string): Promise<boolean>;
49
+ /**
50
+ * Gets the TTL (Time-To-Live) in milliseconds.
51
+ *
52
+ * @returns {number} - The TTL in milliseconds.
53
+ */
54
+ getTtlMilliseconds(): number;
55
+ /**
56
+ * Lists the keys in the cache that match a pattern prefix.
57
+ *
58
+ * @param {string} pattern_prefix - The pattern prefix to match.
59
+ * @returns {Promise<string[]>} - A promise that resolves with an array of keys matching the pattern prefix.
60
+ */
61
+ listKeys(pattern_prefix: string): Promise<string[]>;
62
+ }
63
+
64
+ /**
65
+ * Class representing a Redis-based TTL (Time-To-Live) cache.
66
+ * Implements the TtlCache interface.
67
+ */
68
+ declare class RedisTtlCache implements TtlCache {
69
+ private ttlMilliseconds;
70
+ private client;
71
+ /**
72
+ * Creates an instance of RedisTtlCache.
73
+ *
74
+ * @param {number} ttlMilliseconds - The default TTL in milliseconds.
75
+ * @param {RedisClientOptions} [hostingOptions] - The Redis client options.
76
+ */
77
+ constructor(ttlMilliseconds: number, hostingOptions?: RedisClientOptions);
78
+ /**
79
+ * Puts a record into the Redis cache.
80
+ *
81
+ * @param {TtlCacheRecord} param0 - The cache record to put into the cache.
82
+ * @returns {Promise<void>} - A promise that resolves when the record is put into the cache.
83
+ */
84
+ putRecord<T>({ key, value, ttlMilliseconds }: TtlCacheRecord<T>): Promise<void>;
85
+ /**
86
+ * Deletes a record from the Redis cache.
87
+ *
88
+ * @param {string} cacheRecordKey - The key of the cache record to delete.
89
+ * @returns {Promise<void>} - A promise that resolves when the record is deleted from the cache.
90
+ */
91
+ deleteRecord(cacheRecordKey: string): Promise<void>;
92
+ /**
93
+ * Reads a record from the Redis cache.
94
+ *
95
+ * @param {string} cacheRecordKey - The key of the cache record to read.
96
+ * @returns {Promise<TtlCacheRecord>} - A promise that resolves with the cache record.
97
+ * @throws {Error} - Throws an error if the record is not found.
98
+ */
99
+ readRecord<T>(cacheRecordKey: string): Promise<TtlCacheRecord<T>>;
100
+ /**
101
+ * Lists the keys in the Redis cache that match a pattern prefix.
102
+ *
103
+ * @param {string} pattern_prefix - The pattern prefix to match.
104
+ * @returns {Promise<string[]>} - A promise that resolves with an array of keys matching the pattern prefix.
105
+ */
106
+ listKeys(pattern_prefix: string): Promise<string[]>;
107
+ /**
108
+ * Peeks at a record in the Redis cache to check if it exists.
109
+ *
110
+ * @param {string} cacheRecordKey - The key of the cache record to peek at.
111
+ * @returns {Promise<boolean>} - A promise that resolves with a boolean indicating if the record exists.
112
+ */
113
+ peekRecord(cacheRecordKey: string): Promise<boolean>;
114
+ /**
115
+ * Disconnects the Redis client.
116
+ *
117
+ * @returns {Promise<void>} - A promise that resolves when the client is disconnected.
118
+ */
119
+ disconnect(): Promise<void>;
120
+ /**
121
+ * Gets the default TTL (Time-To-Live) in milliseconds.
122
+ *
123
+ * @returns {number} - The TTL in milliseconds.
124
+ */
125
+ getTtlMilliseconds(): number;
126
+ }
127
+
128
+ declare const createCacheKey: (cacheKeyPrefix: string) => (id: string) => string;
129
+
130
+ export { RedisTtlCache, type TtlCache, type TtlCacheRecord, createCacheKey };
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/cache/index.ts
21
+ var cache_exports = {};
22
+ __export(cache_exports, {
23
+ RedisTtlCache: () => RedisTtlCache,
24
+ createCacheKey: () => createCacheKey
25
+ });
26
+ module.exports = __toCommonJS(cache_exports);
27
+
28
+ // src/cache/redisTtlCache.ts
29
+ var import_redis = require("redis");
30
+ var RedisTtlCache = class {
31
+ /**
32
+ * Creates an instance of RedisTtlCache.
33
+ *
34
+ * @param {number} ttlMilliseconds - The default TTL in milliseconds.
35
+ * @param {RedisClientOptions} [hostingOptions] - The Redis client options.
36
+ */
37
+ constructor(ttlMilliseconds, hostingOptions) {
38
+ this.ttlMilliseconds = ttlMilliseconds;
39
+ this.client = (0, import_redis.createClient)(hostingOptions);
40
+ this.client.on("error", (err) => console.error("Redis Client Error", err));
41
+ this.client.connect().catch(console.error);
42
+ }
43
+ client;
44
+ /**
45
+ * Puts a record into the Redis cache.
46
+ *
47
+ * @param {TtlCacheRecord} param0 - The cache record to put into the cache.
48
+ * @returns {Promise<void>} - A promise that resolves when the record is put into the cache.
49
+ */
50
+ async putRecord({
51
+ key,
52
+ value,
53
+ ttlMilliseconds = this.ttlMilliseconds
54
+ }) {
55
+ await this.client.set(key, JSON.stringify(value), {
56
+ PX: ttlMilliseconds
57
+ });
58
+ }
59
+ /**
60
+ * Deletes a record from the Redis cache.
61
+ *
62
+ * @param {string} cacheRecordKey - The key of the cache record to delete.
63
+ * @returns {Promise<void>} - A promise that resolves when the record is deleted from the cache.
64
+ */
65
+ async deleteRecord(cacheRecordKey) {
66
+ await this.client.del(cacheRecordKey);
67
+ }
68
+ /**
69
+ * Reads a record from the Redis cache.
70
+ *
71
+ * @param {string} cacheRecordKey - The key of the cache record to read.
72
+ * @returns {Promise<TtlCacheRecord>} - A promise that resolves with the cache record.
73
+ * @throws {Error} - Throws an error if the record is not found.
74
+ */
75
+ async readRecord(cacheRecordKey) {
76
+ const value = await this.client.get(cacheRecordKey);
77
+ if (value === null) {
78
+ throw new Error(`Record not found for key: ${cacheRecordKey}`);
79
+ }
80
+ const ttl = await this.client.ttl(cacheRecordKey);
81
+ return {
82
+ key: cacheRecordKey,
83
+ value: JSON.parse(value),
84
+ ttlMilliseconds: ttl * 1e3
85
+ };
86
+ }
87
+ /**
88
+ * Lists the keys in the Redis cache that match a pattern prefix.
89
+ *
90
+ * @param {string} pattern_prefix - The pattern prefix to match.
91
+ * @returns {Promise<string[]>} - A promise that resolves with an array of keys matching the pattern prefix.
92
+ */
93
+ async listKeys(pattern_prefix) {
94
+ const keys = await this.client.keys(pattern_prefix + "*");
95
+ return keys;
96
+ }
97
+ /**
98
+ * Peeks at a record in the Redis cache to check if it exists.
99
+ *
100
+ * @param {string} cacheRecordKey - The key of the cache record to peek at.
101
+ * @returns {Promise<boolean>} - A promise that resolves with a boolean indicating if the record exists.
102
+ */
103
+ async peekRecord(cacheRecordKey) {
104
+ const result = await this.client.exists(cacheRecordKey);
105
+ return result === 1;
106
+ }
107
+ /**
108
+ * Disconnects the Redis client.
109
+ *
110
+ * @returns {Promise<void>} - A promise that resolves when the client is disconnected.
111
+ */
112
+ async disconnect() {
113
+ await this.client.quit();
114
+ }
115
+ /**
116
+ * Gets the default TTL (Time-To-Live) in milliseconds.
117
+ *
118
+ * @returns {number} - The TTL in milliseconds.
119
+ */
120
+ getTtlMilliseconds() {
121
+ return this.ttlMilliseconds;
122
+ }
123
+ };
124
+
125
+ // src/cache/utils/cacheKey.ts
126
+ var createCacheKey = (cacheKeyPrefix) => (id) => {
127
+ return `${cacheKeyPrefix}:${id}`;
128
+ };
129
+ // Annotate the CommonJS export names for ESM import in node:
130
+ 0 && (module.exports = {
131
+ RedisTtlCache,
132
+ createCacheKey
133
+ });
@@ -0,0 +1,105 @@
1
+ // src/cache/redisTtlCache.ts
2
+ import { createClient } from "redis";
3
+ var RedisTtlCache = class {
4
+ /**
5
+ * Creates an instance of RedisTtlCache.
6
+ *
7
+ * @param {number} ttlMilliseconds - The default TTL in milliseconds.
8
+ * @param {RedisClientOptions} [hostingOptions] - The Redis client options.
9
+ */
10
+ constructor(ttlMilliseconds, hostingOptions) {
11
+ this.ttlMilliseconds = ttlMilliseconds;
12
+ this.client = createClient(hostingOptions);
13
+ this.client.on("error", (err) => console.error("Redis Client Error", err));
14
+ this.client.connect().catch(console.error);
15
+ }
16
+ client;
17
+ /**
18
+ * Puts a record into the Redis cache.
19
+ *
20
+ * @param {TtlCacheRecord} param0 - The cache record to put into the cache.
21
+ * @returns {Promise<void>} - A promise that resolves when the record is put into the cache.
22
+ */
23
+ async putRecord({
24
+ key,
25
+ value,
26
+ ttlMilliseconds = this.ttlMilliseconds
27
+ }) {
28
+ await this.client.set(key, JSON.stringify(value), {
29
+ PX: ttlMilliseconds
30
+ });
31
+ }
32
+ /**
33
+ * Deletes a record from the Redis cache.
34
+ *
35
+ * @param {string} cacheRecordKey - The key of the cache record to delete.
36
+ * @returns {Promise<void>} - A promise that resolves when the record is deleted from the cache.
37
+ */
38
+ async deleteRecord(cacheRecordKey) {
39
+ await this.client.del(cacheRecordKey);
40
+ }
41
+ /**
42
+ * Reads a record from the Redis cache.
43
+ *
44
+ * @param {string} cacheRecordKey - The key of the cache record to read.
45
+ * @returns {Promise<TtlCacheRecord>} - A promise that resolves with the cache record.
46
+ * @throws {Error} - Throws an error if the record is not found.
47
+ */
48
+ async readRecord(cacheRecordKey) {
49
+ const value = await this.client.get(cacheRecordKey);
50
+ if (value === null) {
51
+ throw new Error(`Record not found for key: ${cacheRecordKey}`);
52
+ }
53
+ const ttl = await this.client.ttl(cacheRecordKey);
54
+ return {
55
+ key: cacheRecordKey,
56
+ value: JSON.parse(value),
57
+ ttlMilliseconds: ttl * 1e3
58
+ };
59
+ }
60
+ /**
61
+ * Lists the keys in the Redis cache that match a pattern prefix.
62
+ *
63
+ * @param {string} pattern_prefix - The pattern prefix to match.
64
+ * @returns {Promise<string[]>} - A promise that resolves with an array of keys matching the pattern prefix.
65
+ */
66
+ async listKeys(pattern_prefix) {
67
+ const keys = await this.client.keys(pattern_prefix + "*");
68
+ return keys;
69
+ }
70
+ /**
71
+ * Peeks at a record in the Redis cache to check if it exists.
72
+ *
73
+ * @param {string} cacheRecordKey - The key of the cache record to peek at.
74
+ * @returns {Promise<boolean>} - A promise that resolves with a boolean indicating if the record exists.
75
+ */
76
+ async peekRecord(cacheRecordKey) {
77
+ const result = await this.client.exists(cacheRecordKey);
78
+ return result === 1;
79
+ }
80
+ /**
81
+ * Disconnects the Redis client.
82
+ *
83
+ * @returns {Promise<void>} - A promise that resolves when the client is disconnected.
84
+ */
85
+ async disconnect() {
86
+ await this.client.quit();
87
+ }
88
+ /**
89
+ * Gets the default TTL (Time-To-Live) in milliseconds.
90
+ *
91
+ * @returns {number} - The TTL in milliseconds.
92
+ */
93
+ getTtlMilliseconds() {
94
+ return this.ttlMilliseconds;
95
+ }
96
+ };
97
+
98
+ // src/cache/utils/cacheKey.ts
99
+ var createCacheKey = (cacheKeyPrefix) => (id) => {
100
+ return `${cacheKeyPrefix}:${id}`;
101
+ };
102
+ export {
103
+ RedisTtlCache,
104
+ createCacheKey
105
+ };
@@ -0,0 +1,5 @@
1
+ type Controller<Service> = {
2
+ [K in keyof Service]: unknown;
3
+ };
4
+
5
+ export type { Controller };
@@ -0,0 +1,5 @@
1
+ type Controller<Service> = {
2
+ [K in keyof Service]: unknown;
3
+ };
4
+
5
+ export type { Controller };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/controllers/index.ts
17
+ var controllers_exports = {};
18
+ module.exports = __toCommonJS(controllers_exports);
File without changes
@@ -0,0 +1,37 @@
1
+ export { B as BaseEntity } from '../base.entity-DNfmMOgd.mjs';
2
+ import { ObjectId } from '@mikro-orm/mongodb';
3
+
4
+ /**
5
+ * Abstract class representing a base entity.
6
+ */
7
+ declare abstract class MongoBaseEntity {
8
+ /**
9
+ * The serialized unique identifier for the entity.
10
+ *
11
+ * @type {string}
12
+ * @readonly
13
+ */
14
+ _id: ObjectId;
15
+ /**
16
+ * The unique identifier for the entity.
17
+ *
18
+ * @type {string}
19
+ * @readonly
20
+ */
21
+ id: string;
22
+ /**
23
+ * The date when the entity was created.
24
+ *
25
+ * @type {Date}
26
+ */
27
+ createdAt: Date;
28
+ /**
29
+ * The date when the entity was last updated.
30
+ *
31
+ * @type {Date}
32
+ * @readonly
33
+ */
34
+ updatedAt: Date;
35
+ }
36
+
37
+ export { MongoBaseEntity };
@@ -1,8 +1,10 @@
1
+ export { B as BaseEntity } from '../base.entity-DNfmMOgd.js';
1
2
  import { ObjectId } from '@mikro-orm/mongodb';
3
+
2
4
  /**
3
5
  * Abstract class representing a base entity.
4
6
  */
5
- export declare abstract class MongoBaseEntity {
7
+ declare abstract class MongoBaseEntity {
6
8
  /**
7
9
  * The serialized unique identifier for the entity.
8
10
  *
@@ -31,4 +33,5 @@ export declare abstract class MongoBaseEntity {
31
33
  */
32
34
  updatedAt: Date;
33
35
  }
34
- //# sourceMappingURL=mongo.base.entity.d.ts.map
36
+
37
+ export { MongoBaseEntity };
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __decorateClass = (decorators, target, key, kind) => {
20
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
21
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
22
+ if (decorator = decorators[i])
23
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
24
+ if (kind && result) __defProp(target, key, result);
25
+ return result;
26
+ };
27
+
28
+ // src/database/index.ts
29
+ var database_exports = {};
30
+ __export(database_exports, {
31
+ BaseEntity: () => BaseEntity,
32
+ MongoBaseEntity: () => MongoBaseEntity
33
+ });
34
+ module.exports = __toCommonJS(database_exports);
35
+
36
+ // src/database/mikro/models/entities/base.entity.ts
37
+ var import_uuid = require("uuid");
38
+ var import_core = require("@mikro-orm/core");
39
+ var BaseEntity = class {
40
+ id = (0, import_uuid.v4)();
41
+ createdAt = /* @__PURE__ */ new Date();
42
+ updatedAt = /* @__PURE__ */ new Date();
43
+ };
44
+ __decorateClass([
45
+ (0, import_core.PrimaryKey)({ type: "uuid" })
46
+ ], BaseEntity.prototype, "id", 2);
47
+ __decorateClass([
48
+ (0, import_core.Property)()
49
+ ], BaseEntity.prototype, "createdAt", 2);
50
+ __decorateClass([
51
+ (0, import_core.Property)({ onUpdate: () => /* @__PURE__ */ new Date() })
52
+ ], BaseEntity.prototype, "updatedAt", 2);
53
+
54
+ // src/database/mikro/models/entities/mongo.base.entity.ts
55
+ var import_core2 = require("@mikro-orm/core");
56
+ var MongoBaseEntity = class {
57
+ _id;
58
+ id;
59
+ createdAt = /* @__PURE__ */ new Date();
60
+ updatedAt = /* @__PURE__ */ new Date();
61
+ };
62
+ __decorateClass([
63
+ (0, import_core2.PrimaryKey)()
64
+ ], MongoBaseEntity.prototype, "_id", 2);
65
+ __decorateClass([
66
+ (0, import_core2.SerializedPrimaryKey)()
67
+ ], MongoBaseEntity.prototype, "id", 2);
68
+ __decorateClass([
69
+ (0, import_core2.Property)()
70
+ ], MongoBaseEntity.prototype, "createdAt", 2);
71
+ __decorateClass([
72
+ (0, import_core2.Property)({ onUpdate: () => /* @__PURE__ */ new Date() })
73
+ ], MongoBaseEntity.prototype, "updatedAt", 2);
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ BaseEntity,
77
+ MongoBaseEntity
78
+ });