@mrxsys/mrx-core 2.4.0 → 2.5.1

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 (312) hide show
  1. package/CHANGELOG.md +329 -31
  2. package/README.md +3 -3
  3. package/dist/chunk-1a3wj3m1.js +272 -0
  4. package/dist/chunk-370444pc.js +43 -0
  5. package/dist/chunk-5qtpggzv.js +38 -0
  6. package/dist/chunk-84mqvfsk.js +69 -0
  7. package/dist/chunk-cq973ydc.js +82 -0
  8. package/dist/chunk-f5z7x01b.js +352 -0
  9. package/dist/chunk-pc66jgqv.js +220 -0
  10. package/dist/chunk-s07amdhx.js +77 -0
  11. package/dist/chunk-v8v7982b.js +58 -0
  12. package/dist/chunk-vknq69e0.js +23 -0
  13. package/dist/chunk-yvyahr2h.js +40 -0
  14. package/dist/errors/baseError.d.ts +9 -0
  15. package/dist/errors/enums/httpErrorStatusCodes.d.ts +42 -0
  16. package/dist/errors/httpError.d.ts +14 -0
  17. package/dist/errors/index.d.ts +2 -0
  18. package/dist/errors/index.js +11 -0
  19. package/dist/errors/types/baseErrorOptions.d.ts +15 -0
  20. package/dist/errors/types/httpErrorOptions.d.ts +13 -0
  21. package/dist/errors/types/index.d.ts +2 -0
  22. package/dist/modules/data/data.d.ts +115 -0
  23. package/dist/modules/data/enums/dataErrorKeys.d.ts +3 -0
  24. package/dist/modules/data/index.d.ts +1 -0
  25. package/dist/modules/data/index.js +16 -0
  26. package/dist/modules/data/transformers/camelCase.d.ts +25 -0
  27. package/dist/modules/data/transformers/index.d.ts +4 -0
  28. package/dist/modules/data/transformers/index.js +32 -0
  29. package/dist/modules/data/transformers/kebabCase.d.ts +25 -0
  30. package/dist/modules/data/transformers/pascalCase.d.ts +25 -0
  31. package/dist/modules/data/transformers/snakeCase.d.ts +25 -0
  32. package/dist/modules/data/types/camelCase.d.ts +1 -0
  33. package/dist/modules/data/types/caseTransformer.d.ts +13 -0
  34. package/dist/modules/data/types/index.d.ts +10 -0
  35. package/dist/modules/data/types/kebabCase.d.ts +1 -0
  36. package/dist/modules/data/types/pascalCase.d.ts +2 -0
  37. package/dist/modules/data/types/snakeCase.d.ts +1 -0
  38. package/dist/modules/data/types/transformKeysCamelCase.d.ts +4 -0
  39. package/dist/modules/data/types/transformKeysKebabCase.d.ts +4 -0
  40. package/dist/modules/data/types/transformKeysPascalCase.d.ts +4 -0
  41. package/dist/modules/data/types/transformKeysSnakeCase.d.ts +4 -0
  42. package/dist/modules/data/types/transformObjectKeys.d.ts +9 -0
  43. package/dist/modules/database/enums/databaseErrorKeys.d.ts +28 -0
  44. package/dist/modules/database/enums/mssqlErrorCode.d.ts +25 -0
  45. package/dist/modules/database/events/index.d.ts +2 -0
  46. package/dist/modules/database/events/mssqlEventMap.d.ts +6 -0
  47. package/dist/modules/database/events/tableEventMap.d.ts +7 -0
  48. package/dist/modules/database/index.d.ts +2 -0
  49. package/dist/modules/database/index.js +14 -0
  50. package/dist/{database → modules/database}/mssql.d.ts +21 -25
  51. package/dist/{database → modules/database}/table.d.ts +6 -6
  52. package/dist/modules/database/types/index.d.ts +3 -0
  53. package/dist/{database → modules/database}/types/mssqlDatabaseOption.d.ts +16 -37
  54. package/dist/modules/database/types/mssqlEventLog.d.ts +14 -0
  55. package/dist/modules/database/types/queryContext.d.ts +11 -0
  56. package/dist/modules/elysia/crud/crud.d.ts +46 -0
  57. package/dist/modules/elysia/crud/index.d.ts +1 -0
  58. package/dist/modules/elysia/crud/index.js +299 -0
  59. package/dist/modules/elysia/crud/types/crudOperationBaseOptions.d.ts +6 -0
  60. package/dist/modules/elysia/crud/types/crudOperationCountOptions.d.ts +2 -0
  61. package/dist/modules/elysia/crud/types/crudOperationDeleteOneOptions.d.ts +2 -0
  62. package/dist/modules/elysia/crud/types/crudOperationDeleteOptions.d.ts +2 -0
  63. package/dist/modules/elysia/crud/types/crudOperationFindOneOptions.d.ts +2 -0
  64. package/dist/modules/elysia/crud/types/crudOperationFindOptions.d.ts +2 -0
  65. package/dist/modules/elysia/crud/types/crudOperationInsertOptions.d.ts +2 -0
  66. package/dist/modules/elysia/crud/types/crudOperationUpdateOneOptions.d.ts +2 -0
  67. package/dist/modules/elysia/crud/types/crudOperationUpdateOptions.d.ts +2 -0
  68. package/dist/modules/elysia/crud/types/crudOperationsOptions.d.ts +18 -0
  69. package/dist/modules/elysia/crud/types/crudOptions.d.ts +23 -0
  70. package/dist/modules/elysia/crud/types/index.d.ts +11 -0
  71. package/dist/modules/elysia/crudSchema/crudSchema.d.ts +18 -0
  72. package/dist/modules/elysia/crudSchema/index.d.ts +1 -0
  73. package/dist/modules/elysia/crudSchema/index.js +10 -0
  74. package/dist/modules/elysia/crudSchema/types/adaptiveWhereClauseSchema.d.ts +31 -0
  75. package/dist/modules/elysia/crudSchema/types/crudModelsType.d.ts +14 -0
  76. package/dist/modules/elysia/crudSchema/types/crudSchemaOperations.d.ts +10 -0
  77. package/dist/modules/elysia/crudSchema/types/crudSchemaOptions.d.ts +13 -0
  78. package/dist/modules/elysia/crudSchema/types/index.d.ts +8 -0
  79. package/dist/modules/elysia/crudSchema/types/orderSchema.d.ts +11 -0
  80. package/dist/modules/elysia/crudSchema/types/qSchema.d.ts +15 -0
  81. package/dist/modules/elysia/crudSchema/types/queryOptionsBuilderOptions.d.ts +11 -0
  82. package/dist/modules/elysia/crudSchema/types/selectedFieldSchema.d.ts +6 -0
  83. package/dist/modules/elysia/crudSchema/utils/createAdaptiveWhereClauseSchema.d.ts +17 -0
  84. package/dist/modules/elysia/crudSchema/utils/createCountResponse200Schema.d.ts +11 -0
  85. package/dist/modules/elysia/crudSchema/utils/createCountSchema.d.ts +16 -0
  86. package/dist/modules/elysia/crudSchema/utils/createDeleteSchema.d.ts +18 -0
  87. package/dist/modules/elysia/crudSchema/utils/createFiltersSchema.d.ts +17 -0
  88. package/dist/modules/elysia/crudSchema/utils/createFindSchema.d.ts +22 -0
  89. package/dist/modules/elysia/crudSchema/utils/createIdParamSchema.d.ts +4 -0
  90. package/dist/modules/elysia/crudSchema/utils/createInsertSchema.d.ts +8 -0
  91. package/dist/modules/elysia/crudSchema/utils/createOrderSchema.d.ts +12 -0
  92. package/dist/modules/elysia/crudSchema/utils/createPropertiesSchema.d.ts +12 -0
  93. package/dist/modules/elysia/crudSchema/utils/createQSchema.d.ts +12 -0
  94. package/dist/modules/elysia/crudSchema/utils/createResponse200Schema.d.ts +5 -0
  95. package/dist/modules/elysia/crudSchema/utils/createSelectedFieldsSchema.d.ts +12 -0
  96. package/dist/modules/elysia/crudSchema/utils/createUpdateOneSchema.d.ts +4 -0
  97. package/dist/modules/elysia/crudSchema/utils/createUpdateSchema.d.ts +10 -0
  98. package/dist/modules/elysia/crudSchema/utils/index.d.ts +15 -0
  99. package/dist/modules/elysia/crudSchema/utils/index.js +37 -0
  100. package/dist/modules/elysia/crudSchema/utils/isDateFromElysiaTypeBox.d.ts +2 -0
  101. package/dist/modules/elysia/dbResolver/dbResolver.d.ts +17 -0
  102. package/dist/modules/elysia/dbResolver/enums/dbResolverErrorKeys.d.ts +3 -0
  103. package/dist/modules/elysia/dbResolver/index.d.ts +1 -0
  104. package/dist/modules/elysia/dbResolver/index.js +14 -0
  105. package/dist/modules/elysia/dbResolver/types/dynamicDbOptions.d.ts +7 -0
  106. package/dist/modules/elysia/dbResolver/types/index.d.ts +1 -0
  107. package/dist/modules/elysia/error/error.d.ts +34 -0
  108. package/dist/modules/elysia/error/index.d.ts +1 -0
  109. package/dist/modules/elysia/error/index.js +58 -0
  110. package/dist/modules/elysia/jwt/enums/jwtErrorKeys.d.ts +4 -0
  111. package/dist/modules/elysia/jwt/index.d.ts +1 -0
  112. package/dist/modules/elysia/jwt/index.js +81 -0
  113. package/dist/modules/elysia/jwt/jwt.d.ts +119 -0
  114. package/dist/modules/elysia/jwt/types/index.d.ts +1 -0
  115. package/dist/modules/elysia/jwt/types/jwtOptions.d.ts +98 -0
  116. package/dist/modules/elysia/microservice/index.d.ts +1 -0
  117. package/dist/modules/elysia/microservice/index.js +96 -0
  118. package/dist/{elysia → modules/elysia/microservice}/microservice.d.ts +1 -1
  119. package/dist/modules/elysia/ratelimit/enums/ratelimitErrorKeys.d.ts +3 -0
  120. package/dist/modules/elysia/ratelimit/index.d.ts +1 -0
  121. package/dist/modules/elysia/ratelimit/index.js +55 -0
  122. package/dist/{elysia → modules/elysia/ratelimit}/ratelimit.d.ts +3 -13
  123. package/dist/modules/elysia/ratelimit/types/index.d.ts +1 -0
  124. package/dist/{elysia → modules/elysia/ratelimit}/types/rateLimitOptions.d.ts +6 -16
  125. package/dist/modules/logger/enums/loggerErrorKeys.d.ts +6 -0
  126. package/dist/modules/logger/events/index.d.ts +1 -0
  127. package/dist/modules/logger/events/loggerEvents.d.ts +11 -0
  128. package/dist/modules/logger/index.d.ts +1 -0
  129. package/dist/modules/logger/index.js +139 -0
  130. package/dist/modules/logger/logger.d.ts +189 -0
  131. package/dist/{logger → modules/logger}/strategies/consoleLogger.d.ts +4 -4
  132. package/dist/{logger → modules/logger}/strategies/fileLogger.d.ts +4 -4
  133. package/dist/modules/logger/strategies/index.d.ts +2 -0
  134. package/dist/modules/logger/strategies/index.js +44 -0
  135. package/dist/modules/logger/types/index.d.ts +6 -0
  136. package/dist/modules/logger/types/index.js +1 -0
  137. package/dist/{logger → modules/logger}/types/logStreamChunk.d.ts +4 -4
  138. package/dist/{logger → modules/logger}/types/loggerStrategy.d.ts +1 -1
  139. package/dist/modules/mailer/enums/mailerErrorKeys.d.ts +5 -0
  140. package/dist/modules/mailer/index.d.ts +1 -0
  141. package/dist/modules/mailer/index.js +64 -0
  142. package/dist/{mailer → modules/mailer}/smtp.d.ts +6 -6
  143. package/dist/modules/mailer/types/index.d.ts +3 -0
  144. package/dist/modules/mailer/types/index.js +1 -0
  145. package/dist/{mailer → modules/mailer}/types/smtpCredentials.d.ts +2 -2
  146. package/dist/{mailer → modules/mailer}/types/smtpOptions.d.ts +5 -5
  147. package/dist/{mailer → modules/mailer}/types/smtpPoolOptions.d.ts +1 -1
  148. package/dist/modules/repository/index.d.ts +1 -0
  149. package/dist/modules/repository/index.js +10 -0
  150. package/dist/modules/repository/repository.d.ts +421 -0
  151. package/dist/modules/repository/types/adaptiveWhereClause.d.ts +30 -0
  152. package/dist/modules/repository/types/filter.d.ts +43 -0
  153. package/dist/modules/repository/types/index.d.ts +8 -0
  154. package/dist/modules/repository/types/index.js +1 -0
  155. package/dist/modules/repository/types/orderByItem.d.ts +42 -0
  156. package/dist/modules/repository/types/queryOptions.d.ts +36 -0
  157. package/dist/{repository → modules/repository}/types/queryOptionsExtendPagination.d.ts +2 -2
  158. package/dist/{repository → modules/repository}/types/queryOptionsExtendStream.d.ts +1 -1
  159. package/dist/modules/repository/types/selectedFields.d.ts +37 -0
  160. package/dist/modules/singletonManager/enums/singletonManagerErrorKeys.d.ts +4 -0
  161. package/dist/modules/singletonManager/index.d.ts +1 -0
  162. package/dist/modules/singletonManager/index.js +8 -0
  163. package/dist/modules/singletonManager/singletonManager.d.ts +75 -0
  164. package/dist/modules/typedEventEmitter/index.d.ts +1 -0
  165. package/dist/modules/typedEventEmitter/index.js +7 -0
  166. package/dist/{typedEventEmitter → modules/typedEventEmitter}/typedEventEmitter.d.ts +33 -11
  167. package/dist/modules/typedEventEmitter/types/index.d.ts +1 -0
  168. package/dist/modules/typedEventEmitter/types/index.js +1 -0
  169. package/dist/utils/enums/utilsErrorKeys.d.ts +3 -0
  170. package/dist/utils/env.d.ts +1 -1
  171. package/dist/utils/index.d.ts +3 -3
  172. package/dist/utils/index.js +32 -1
  173. package/dist/utils/isDateString.d.ts +16 -0
  174. package/dist/utils/stream.d.ts +12 -1
  175. package/dist/utils/types/index.d.ts +1 -1
  176. package/dist/utils/types/streamWithAsyncIterable.d.ts +12 -5
  177. package/package.json +157 -128
  178. package/dist/chunk-1c7w5cx7.js +0 -3
  179. package/dist/chunk-40pg2cqx.js +0 -2
  180. package/dist/chunk-4v4tp5qj.js +0 -2
  181. package/dist/chunk-4w7nd4nw.js +0 -2
  182. package/dist/chunk-5nvsx7md.js +0 -2
  183. package/dist/chunk-89mnpfvy.js +0 -2
  184. package/dist/chunk-91srr77d.js +0 -2
  185. package/dist/chunk-9hj714bv.js +0 -2
  186. package/dist/chunk-9rss6865.js +0 -2
  187. package/dist/chunk-df9xr1f5.js +0 -2
  188. package/dist/chunk-dq00mfya.js +0 -2
  189. package/dist/chunk-fnb68m68.js +0 -2
  190. package/dist/chunk-g6a16nyh.js +0 -2
  191. package/dist/chunk-gtgpa8nc.js +0 -2
  192. package/dist/chunk-gxjax5n3.js +0 -2
  193. package/dist/chunk-h9er1sh5.js +0 -2
  194. package/dist/chunk-mwpajm9x.js +0 -2
  195. package/dist/chunk-n5w9cwwg.js +0 -2
  196. package/dist/chunk-pt7wrvtr.js +0 -2
  197. package/dist/chunk-qndyhwdn.js +0 -2
  198. package/dist/chunk-v5dfx8mh.js +0 -2
  199. package/dist/chunk-wgq0yyqw.js +0 -2
  200. package/dist/chunk-wtfcgg9s.js +0 -2
  201. package/dist/chunk-z00b1r18.js +0 -2
  202. package/dist/data/data.d.ts +0 -99
  203. package/dist/data/enums/dataErrorKeys.d.ts +0 -7
  204. package/dist/data/enums/index.d.ts +0 -1
  205. package/dist/data/enums/index.js +0 -2
  206. package/dist/data/index.d.ts +0 -1
  207. package/dist/data/index.js +0 -2
  208. package/dist/data/transformers/camelCase.d.ts +0 -25
  209. package/dist/data/transformers/index.d.ts +0 -4
  210. package/dist/data/transformers/index.js +0 -2
  211. package/dist/data/transformers/kebabCase.d.ts +0 -25
  212. package/dist/data/transformers/pascalCase.d.ts +0 -25
  213. package/dist/data/transformers/snakeCase.d.ts +0 -25
  214. package/dist/data/types/index.d.ts +0 -1
  215. package/dist/data/types/keyTransformer.d.ts +0 -11
  216. package/dist/database/enums/databaseErrorKeys.d.ts +0 -52
  217. package/dist/database/enums/index.d.ts +0 -2
  218. package/dist/database/enums/index.js +0 -2
  219. package/dist/database/enums/mssqlErrorCode.d.ts +0 -25
  220. package/dist/database/events/index.d.ts +0 -2
  221. package/dist/database/events/mssqlEventMap.d.ts +0 -6
  222. package/dist/database/events/tableEventMap.d.ts +0 -7
  223. package/dist/database/index.d.ts +0 -2
  224. package/dist/database/index.js +0 -2
  225. package/dist/database/types/index.d.ts +0 -3
  226. package/dist/database/types/mssqlEventLog.d.ts +0 -29
  227. package/dist/database/types/queryContext.d.ts +0 -11
  228. package/dist/elysia/advancedSearch.d.ts +0 -460
  229. package/dist/elysia/crud.d.ts +0 -609
  230. package/dist/elysia/dynamicDatabaseSelector.d.ts +0 -352
  231. package/dist/elysia/enums/elysiaErrorKeys.d.ts +0 -12
  232. package/dist/elysia/enums/httpStatusCode.d.ts +0 -241
  233. package/dist/elysia/enums/index.d.ts +0 -2
  234. package/dist/elysia/enums/index.js +0 -2
  235. package/dist/elysia/error.d.ts +0 -46
  236. package/dist/elysia/index.d.ts +0 -7
  237. package/dist/elysia/index.js +0 -2
  238. package/dist/elysia/jwt.d.ts +0 -46
  239. package/dist/elysia/schemas/index.d.ts +0 -2
  240. package/dist/elysia/schemas/index.js +0 -2
  241. package/dist/elysia/types/crudOptions.d.ts +0 -126
  242. package/dist/elysia/types/crudRoutes.d.ts +0 -2
  243. package/dist/elysia/types/dynamicDatabaseSelectorPluginOptions.d.ts +0 -30
  244. package/dist/elysia/types/index.d.ts +0 -5
  245. package/dist/elysia/types/jwtOptions.d.ts +0 -92
  246. package/dist/error/coreError.d.ts +0 -89
  247. package/dist/error/index.d.ts +0 -1
  248. package/dist/error/index.js +0 -2
  249. package/dist/error/types/coreErrorOptions.d.ts +0 -21
  250. package/dist/error/types/index.d.ts +0 -1
  251. package/dist/index.d.ts +0 -68
  252. package/dist/index.js +0 -2
  253. package/dist/logger/enums/index.d.ts +0 -1
  254. package/dist/logger/enums/index.js +0 -2
  255. package/dist/logger/enums/loggerErrorKeys.d.ts +0 -6
  256. package/dist/logger/events/index.d.ts +0 -1
  257. package/dist/logger/events/loggerEvents.d.ts +0 -4
  258. package/dist/logger/index.d.ts +0 -1
  259. package/dist/logger/index.js +0 -2
  260. package/dist/logger/logger.d.ts +0 -173
  261. package/dist/logger/strategies/index.d.ts +0 -2
  262. package/dist/logger/strategies/index.js +0 -2
  263. package/dist/logger/types/index.d.ts +0 -6
  264. package/dist/mailer/enums/index.d.ts +0 -1
  265. package/dist/mailer/enums/index.js +0 -2
  266. package/dist/mailer/enums/mailerErrorKeys.d.ts +0 -8
  267. package/dist/mailer/index.d.ts +0 -1
  268. package/dist/mailer/index.js +0 -2
  269. package/dist/mailer/types/index.d.ts +0 -3
  270. package/dist/repository/index.d.ts +0 -1
  271. package/dist/repository/index.js +0 -2
  272. package/dist/repository/repository.d.ts +0 -378
  273. package/dist/repository/types/advancedSearch.d.ts +0 -47
  274. package/dist/repository/types/index.d.ts +0 -8
  275. package/dist/repository/types/orderBy.d.ts +0 -21
  276. package/dist/repository/types/queryOptions.d.ts +0 -33
  277. package/dist/repository/types/selectedFields.d.ts +0 -16
  278. package/dist/repository/types/whereClause.d.ts +0 -15
  279. package/dist/singletonManager/enums/index.d.ts +0 -1
  280. package/dist/singletonManager/enums/index.js +0 -2
  281. package/dist/singletonManager/enums/singletonManagerErrorKeys.d.ts +0 -7
  282. package/dist/singletonManager/index.d.ts +0 -1
  283. package/dist/singletonManager/index.js +0 -2
  284. package/dist/singletonManager/singletonManager.d.ts +0 -112
  285. package/dist/store/index.d.ts +0 -1
  286. package/dist/store/index.js +0 -2
  287. package/dist/store/redis.d.ts +0 -6
  288. package/dist/typedEventEmitter/index.d.ts +0 -1
  289. package/dist/typedEventEmitter/index.js +0 -2
  290. package/dist/typedEventEmitter/types/index.d.ts +0 -1
  291. package/dist/utils/enums/index.d.ts +0 -1
  292. package/dist/utils/enums/index.js +0 -2
  293. package/dist/utils/enums/utilErrorKeys.d.ts +0 -4
  294. package/dist/utils/isIsoDateString.d.ts +0 -1
  295. /package/dist/{data → errors}/types/index.js +0 -0
  296. /package/dist/{database/events → modules/data/types}/index.js +0 -0
  297. /package/dist/{database/types → modules/database/events}/index.js +0 -0
  298. /package/dist/{elysia → modules/database}/types/index.js +0 -0
  299. /package/dist/{error → modules/elysia/crud}/types/index.js +0 -0
  300. /package/dist/{logger/events → modules/elysia/crudSchema/types}/index.js +0 -0
  301. /package/dist/{logger → modules/elysia/dbResolver}/types/index.js +0 -0
  302. /package/dist/{mailer → modules/elysia/jwt}/types/index.js +0 -0
  303. /package/dist/{elysia → modules/elysia/microservice}/schemas/info.d.ts +0 -0
  304. /package/dist/{elysia → modules/elysia/microservice}/schemas/ping.d.ts +0 -0
  305. /package/dist/{repository → modules/elysia/ratelimit}/types/index.js +0 -0
  306. /package/dist/{typedEventEmitter/types → modules/logger/events}/index.js +0 -0
  307. /package/dist/{logger → modules/logger}/types/bodiesIntersection.d.ts +0 -0
  308. /package/dist/{logger → modules/logger}/types/logLevels.d.ts +0 -0
  309. /package/dist/{logger → modules/logger}/types/strategyBody.d.ts +0 -0
  310. /package/dist/{logger → modules/logger}/types/strategyMap.d.ts +0 -0
  311. /package/dist/{repository → modules/repository}/types/transaction.d.ts +0 -0
  312. /package/dist/{typedEventEmitter → modules/typedEventEmitter}/types/eventMap.d.ts +0 -0
@@ -0,0 +1,14 @@
1
+ // @bun
2
+ import {
3
+ MSSQL,
4
+ Table
5
+ } from "../../chunk-pc66jgqv.js";
6
+ import"../../chunk-1a3wj3m1.js";
7
+ import"../../chunk-5qtpggzv.js";
8
+ import"../../chunk-yvyahr2h.js";
9
+ import"../../chunk-84mqvfsk.js";
10
+ import"../../chunk-vknq69e0.js";
11
+ export {
12
+ Table,
13
+ MSSQL
14
+ };
@@ -1,19 +1,19 @@
1
1
  import { type Knex } from 'knex';
2
- import { Repository } from '../repository/repository';
3
- import { TypedEventEmitter } from '../typedEventEmitter/typedEventEmitter';
2
+ import { Repository } from '../../modules/repository/repository';
3
+ import { TypedEventEmitter } from '../../modules/typedEventEmitter/typedEventEmitter';
4
4
  import type { MssqlEventMap } from './events/mssqlEventMap';
5
5
  import { Table } from './table';
6
6
  import type { MSSQLDatabaseOptions } from './types/mssqlDatabaseOption';
7
7
  /**
8
8
  * Manages the connection with an MSSQL database.
9
- * The class extends {@link EventEmitter}.
9
+ * The class extends {@link TypedEventEmitter}<{@link MssqlEventMap}>.
10
10
  *
11
- * - Emits events for logging and table operations.
11
+ * - Emits events.
12
12
  * - Automatically generates repositories and tables for CRUD operations.
13
13
  * - Allows custom repository implementations per table.
14
14
  *
15
- * Example usage:
16
- * ```typescript
15
+ * @example
16
+ * ```ts
17
17
  * const mssql = new MSSQL(options);
18
18
  * await mssql.connect();
19
19
  * const users = await mssql.getRepository('users').find();
@@ -30,29 +30,25 @@ export declare class MSSQL extends TypedEventEmitter<MssqlEventMap> {
30
30
  private readonly _databaseName;
31
31
  /**
32
32
  * A map of tables in the database.
33
- * @see {@link Table}
34
33
  */
35
34
  private readonly _tables;
36
35
  /**
37
36
  * A map of repositories for each table.
38
- * @see {@link Repository}
39
37
  */
40
38
  private readonly _repositories;
41
39
  /**
42
40
  * The Knex instance for the database connection.
43
- * @see {@link Knex}
44
- * @see https://knexjs.org/
45
41
  */
46
42
  private readonly _db;
47
43
  /**
48
44
  * Indicates whether to add basic event listeners for all tables.
49
- * @default false
45
+ * @defaultValue false
50
46
  */
51
47
  private readonly _isEventEnabled;
52
48
  /**
53
49
  * Create a new instance of `MSSQL` with the specified options.
50
+ *
54
51
  * @param options - The configuration options for the MSSQL database connection.
55
- * @see {@link MSSQLDatabaseOptions}
56
52
  */
57
53
  constructor(options: MSSQLDatabaseOptions);
58
54
  /**
@@ -61,27 +57,27 @@ export declare class MSSQL extends TypedEventEmitter<MssqlEventMap> {
61
57
  * If the connection is successful, introspection is performed to retrieve information about tables, columns(fields), and primary keys.
62
58
  * This information is used to create instances of {@link Table} and {@link Repository} for each table in the database.
63
59
  *
64
- * @throws ({@link CoreError}) Thrown if an error occurs during the connection process. ({@link databaseErrorKeys.mssqlConnectionError})
60
+ * @throws ({@link BaseError}) Thrown if an error occurs during the connection process.
65
61
  */
66
62
  connect(): Promise<void>;
67
63
  /**
68
64
  * Closes the connection to the MSSQL database.
69
65
  *
70
- * @throws ({@link CoreError}) Thrown if the database is not connected. ({@link databaseErrorKeys.mssqlNotConnected})
71
- * @throws ({@link CoreError}) Thrown if an error occurs during the disconnection process. ({@link databaseErrorKeys.mssqlDisconnectError})
66
+ * @throws ({@link BaseError}) Thrown if the database is not connected.
67
+ * @throws ({@link BaseError}) Thrown if an error occurs during the disconnection process.
72
68
  */
73
69
  disconnect(): Promise<void>;
74
70
  /**
75
71
  * Retrieves a repository for a specific table.
76
72
  *
77
- * @param tableName - The name of the table to retrieve the repository for.
78
- * @param customRepository - Optional custom repository class to use for the table. The class must extend {@link Repository}.
73
+ * @template TModel - The type of the model for the repository.
74
+ * @template TRepo - The repository to retrieve.
79
75
  *
80
- * @throws ({@link CoreError}) Thrown if the database is not connected. ({@link databaseErrorKeys.mssqlNotConnected})
81
- * @throws ({@link CoreError}) Thrown if the specified table is not found. ({@link databaseErrorKeys.mssqlTableNotFound})
76
+ * @param tableName - The name of the table to retrieve the repository for.
77
+ * @param customRepository - Optional custom repository class to use for the table.
82
78
  *
83
- * @template TModel - The type of the model for the repository.
84
- * @template TRepo - The repository to retrieve extends {@link Repository}.
79
+ * @throws ({@link BaseError}) Thrown if the database is not connected.
80
+ * @throws ({@link BaseError}) Thrown if the specified table is not found.
85
81
  *
86
82
  * @returns The {@link Repository} for the specified table.
87
83
  */
@@ -92,11 +88,11 @@ export declare class MSSQL extends TypedEventEmitter<MssqlEventMap> {
92
88
  *
93
89
  * @param tableName - The name of the table to retrieve.
94
90
  *
95
- * @throws ({@link CoreError}) Thrown if the database is not connected. ({@link databaseErrorKeys.mssqlNotConnected})
96
- * @throws ({@link CoreError}) Thrown if the specified table is not found. ({@link databaseErrorKeys.mssqlTableNotFound})
91
+ * @throws ({@link BaseError}) Thrown if the database is not connected.
92
+ * @throws ({@link BaseError}) Thrown if the specified table is not found.
97
93
  *
98
94
  * @returns The {@link Table} object for the specified table.
99
- */
95
+ */
100
96
  getTable(tableName: string): Table;
101
97
  /**
102
98
  * Retrieves the name of the database.
@@ -125,7 +121,7 @@ export declare class MSSQL extends TypedEventEmitter<MssqlEventMap> {
125
121
  /**
126
122
  * Retrieves the Knex instance for the database connection.
127
123
  *
128
- * @throws ({@link CoreError}) Thrown if the database is not connected. ({@link databaseErrorKeys.mssqlNotConnected})
124
+ * @throws ({@link BaseError}) Thrown if the database is not connected.
129
125
  *
130
126
  * @returns The {@link Knex} instance for the database connection.
131
127
  */
@@ -1,15 +1,15 @@
1
- import type { TableEventMap } from '../database/events/tableEventMap';
2
- import { TypedEventEmitter } from '../typedEventEmitter/typedEventEmitter';
1
+ import type { TableEventMap } from '../../modules/database/events/tableEventMap';
2
+ import { TypedEventEmitter } from '../../modules/typedEventEmitter/typedEventEmitter';
3
3
  /**
4
4
  * Represents a database table and provides access to its metadata (name, fields, primary key).
5
+ * The class extends `TypedEventEmitter`<{@link TableEventMap}> to allow for event-driven programming.
5
6
  *
6
- * - Emits events for table operations (e.g., SELECTED, CREATED, UPDATED, DELETED).
7
- * - Used for query construction and event handling in the database layer.
7
+ * Can emit events for table operations (e.g., SELECTED, CREATED, UPDATED, DELETED). when is attach to {@link MSSQL} class.
8
8
  *
9
9
  * Example:
10
- * ```typescript
10
+ * ```ts
11
11
  * const table = new Table('db', 'users', ['id', 'name'], ['id', 'NUMBER']);
12
- * table.on('SELECTED', data => console.log(data));
12
+ * table.on('selected', data => console.log(data));
13
13
  * ```
14
14
  */
15
15
  export declare class Table extends TypedEventEmitter<TableEventMap> {
@@ -0,0 +1,3 @@
1
+ export type { MSSQLDatabaseOptions } from './mssqlDatabaseOption';
2
+ export type { MssqlEventLog } from './mssqlEventLog';
3
+ export type { QueryContext } from './queryContext';
@@ -1,41 +1,24 @@
1
1
  /**
2
2
  * Options to configure the MSSQL database connection.
3
- *
4
- * @example
5
- * ```typescript
6
- * const options: MSSQLDatabaseOptions = {
7
- * databaseName: 'my_database',
8
- * host: 'localhost',
9
- * port: 1433,
10
- * user: 'sa',
11
- * password: 'Password123',
12
- * encrypt: true,
13
- * poolMin: 5,
14
- * poolMax: 20,
15
- * debug: true,
16
- * pulse: true
17
- * };
18
- * ```
19
3
  */
20
4
  export interface MSSQLDatabaseOptions {
21
5
  /** The name of the database to connect to. */
22
- databaseName: string;
6
+ readonly databaseName: string;
23
7
  /** The host of the database server. */
24
- host: string;
8
+ readonly host: string;
25
9
  /** The port number for the database connection. */
26
- port: number;
10
+ readonly port: number;
27
11
  /** The username for authenticating with the database. */
28
- user: string;
12
+ readonly user: string;
29
13
  /** The password for authenticating with the database. */
30
- password: string;
14
+ readonly password: string;
31
15
  /**
32
16
  * Whether to encrypt the database connection.
33
17
  * When enabled, communication between the client and server will be encrypted,
34
- * providing increased security but potentially slight performance impact.
35
18
  *
36
19
  * @defaultValue true
37
20
  */
38
- encrypt?: boolean;
21
+ readonly encrypt?: boolean;
39
22
  /**
40
23
  * Minimum number of connections in the connection pool.
41
24
  * This represents the minimum number of connections that will be maintained in the pool,
@@ -44,7 +27,7 @@ export interface MSSQLDatabaseOptions {
44
27
  *
45
28
  * @defaultValue 2
46
29
  */
47
- poolMin?: number;
30
+ readonly poolMin?: number;
48
31
  /**
49
32
  * Maximum number of connections in the connection pool.
50
33
  * This limits how many concurrent connections can be established to the database.
@@ -53,32 +36,28 @@ export interface MSSQLDatabaseOptions {
53
36
  *
54
37
  * @defaultValue 10
55
38
  */
56
- poolMax?: number;
39
+ readonly poolMax?: number;
57
40
  /**
58
41
  * The timeout in milliseconds for acquiring a connection.
59
42
  * If a connection cannot be acquired within this timeframe, an error will be thrown.
60
43
  *
61
44
  * @defaultValue 20000
62
45
  */
63
- connectionTimeout?: number;
46
+ readonly connectionTimeout?: number;
64
47
  /**
65
- * If set to true, adds basic event listeners for all tables.
66
- * This automatically sets up event listeners to track database operations
67
- * (select, create, update, delete) for all tables, allowing for easy monitoring
68
- * and event-driven programming.
69
- *
70
- * [TODO] - Change this section when working on the AND-169 ticket.
48
+ * If set to true, emits events for database operations.
49
+ * (select, create, update, delete) for all tables.
71
50
  *
72
51
  * @defaultValue false
73
52
  * @example
74
- * ```typescript
53
+ * ```ts
75
54
  * const mssql = new MSSQL(options);
76
55
  * await mssql.connect();
77
- * // SELECTED, CREATED, UPDATED, DELETED
78
- * mssql.table('table_name').on(EVENT_TABLE.SELECTED, (data: unknown) => {
79
- * console.log(data); // data is the response from the query
56
+ * // selected, inserted, updated, deleted
57
+ * mssql.table('table_name').on('selected', (data: unknown) => {
58
+ * console.log(data); // data is the response from the query
80
59
  * });
81
60
  * ```
82
61
  */
83
- isEventEnabled?: boolean;
62
+ readonly isEventEnabled?: boolean;
84
63
  }
@@ -0,0 +1,14 @@
1
+ export interface MssqlEventLog {
2
+ /** The name of the database where the query was executed. */
3
+ readonly database: string;
4
+ /** A list of tables affected by the query. */
5
+ readonly tables: string[];
6
+ /** A unique identifier for the executed query. */
7
+ readonly queryUuid: string;
8
+ /** The method used in the query (e.g., `SELECT`, `INSERT`, `UPDATE`, `DELETE`). */
9
+ readonly method: string;
10
+ /** The raw SQL query string. */
11
+ readonly sql: string;
12
+ /** The parameters or bindings used in the query. */
13
+ readonly bindings: unknown[];
14
+ }
@@ -0,0 +1,11 @@
1
+ export interface QueryContext {
2
+ readonly method: string;
3
+ readonly options: Record<string, unknown>;
4
+ readonly timeout: number;
5
+ readonly cancelOnTimeout: boolean;
6
+ readonly bindings: unknown[];
7
+ readonly sql: string;
8
+ readonly queryContext: Record<string, unknown>;
9
+ readonly __knexUid: string;
10
+ readonly __knexQueryUid: string;
11
+ }
@@ -0,0 +1,46 @@
1
+ import type { TObject, TString } from '@sinclair/typebox';
2
+ import { Elysia, type SingletonBase } from 'elysia';
3
+ import type { MSSQL } from '../../../modules/database/mssql';
4
+ import type { CrudModelsType } from '../../../modules/elysia/crudSchema/types/crudModelsType';
5
+ import type { DynamicDbOptions } from '../../../modules/elysia/dbResolver/types/dynamicDbOptions';
6
+ import type { CrudOperationCountOptions } from './types/crudOperationCountOptions';
7
+ import type { CrudOperationDeleteOneOptions } from './types/crudOperationDeleteOneOptions';
8
+ import type { CrudOperationDeleteOptions } from './types/crudOperationDeleteOptions';
9
+ import type { CrudOperationFindOneOptions } from './types/crudOperationFindOneOptions';
10
+ import type { CrudOperationFindOptions } from './types/crudOperationFindOptions';
11
+ import type { CrudOperationInsertOptions } from './types/crudOperationInsertOptions';
12
+ import type { CrudOperationsOptions } from './types/crudOperationsOptions';
13
+ import type { CrudOperationUpdateOneOptions } from './types/crudOperationUpdateOneOptions';
14
+ import type { CrudOperationUpdateOptions } from './types/crudOperationUpdateOptions';
15
+ import type { CrudOptions } from './types/crudOptions';
16
+ export declare const crud: <const TDatabase extends DynamicDbOptions | string, const TTableName extends string, const TSourceSchema extends TObject, const TOperations extends CrudOperationsOptions = {
17
+ find: true;
18
+ findOne: true;
19
+ insert: true;
20
+ update: true;
21
+ updateOne: true;
22
+ delete: true;
23
+ deleteOne: true;
24
+ count: true;
25
+ }, const TSourceFindSchema extends TObject = TSourceSchema, const TSourceCountSchema extends TObject = TSourceSchema, const TSourceInsertSchema extends TObject = TSourceSchema, const TSourceUpdateSchema extends TObject = TSourceSchema, const TSourceDeleteSchema extends TObject = TSourceSchema, const TSourceResponseSchema extends TObject = TSourceSchema>({ database, tableName, schema, operations }: CrudOptions<TDatabase, TTableName, TSourceSchema, TOperations, TSourceFindSchema, TSourceCountSchema, TSourceInsertSchema, TSourceUpdateSchema, TSourceDeleteSchema, TSourceResponseSchema>) => Elysia<TTableName, {
26
+ decorator: SingletonBase["decorator"];
27
+ store: SingletonBase["store"];
28
+ derive: SingletonBase["derive"];
29
+ resolve: Record<TDatabase extends string ? "staticDB" : "dynamicDB", MSSQL>;
30
+ }, {
31
+ typebox: CrudModelsType<TTableName, {
32
+ find: TOperations["find"] extends true | CrudOperationFindOptions ? true : false;
33
+ findOne: TOperations["findOne"] extends true | CrudOperationFindOneOptions ? true : false;
34
+ insert: TOperations["insert"] extends true | CrudOperationInsertOptions ? true : false;
35
+ update: TOperations["update"] extends true | CrudOperationUpdateOptions ? true : false;
36
+ updateOne: TOperations["updateOne"] extends true | CrudOperationUpdateOneOptions ? true : false;
37
+ delete: TOperations["delete"] extends true | CrudOperationDeleteOptions ? true : false;
38
+ deleteOne: TOperations["deleteOne"] extends true | CrudOperationDeleteOneOptions ? true : false;
39
+ count: TOperations["count"] extends true | CrudOperationCountOptions ? true : false;
40
+ }, TSourceInsertSchema, TSourceFindSchema, TSourceCountSchema, TSourceUpdateSchema, TSourceDeleteSchema, TSourceResponseSchema> & {
41
+ ResolveDbHeader: TObject<{
42
+ "database-using": TString;
43
+ }>;
44
+ };
45
+ error: {};
46
+ }>;
@@ -0,0 +1 @@
1
+ export { crud } from './crud';
@@ -0,0 +1,299 @@
1
+ // @bun
2
+ import {
3
+ crudSchema
4
+ } from "../../../chunk-s07amdhx.js";
5
+ import"../../../chunk-f5z7x01b.js";
6
+ import {
7
+ dbResolver
8
+ } from "../../../chunk-v8v7982b.js";
9
+ import"../../../chunk-370444pc.js";
10
+ import"../../../chunk-cq973ydc.js";
11
+ import"../../../chunk-pc66jgqv.js";
12
+ import"../../../chunk-1a3wj3m1.js";
13
+ import"../../../chunk-5qtpggzv.js";
14
+ import"../../../chunk-yvyahr2h.js";
15
+ import"../../../chunk-84mqvfsk.js";
16
+ import"../../../chunk-vknq69e0.js";
17
+
18
+ // source/modules/elysia/crud/crud.ts
19
+ import { Elysia, t } from "elysia";
20
+ var _createDefaultOperationsWithHandlers = (tableName, database) => {
21
+ const _requiredHeaderDatabase = typeof database === "object" ? { headers: "dbSelectorHeader" } : {};
22
+ return {
23
+ insert: {
24
+ method: "POST",
25
+ path: "/",
26
+ hook: {
27
+ ..._requiredHeaderDatabase,
28
+ body: `${tableName}Insert`,
29
+ response: `${tableName}Response200`
30
+ },
31
+ handler: async (ctx) => {
32
+ const db = ctx.dynamicDB || ctx.staticDB;
33
+ const body = ctx.body;
34
+ const selectedFields = body.queryOptions?.selectedFields ?? "*";
35
+ const data = await db.getRepository(tableName).insert(body.data, {
36
+ selectedFields,
37
+ throwIfNoResult: true
38
+ });
39
+ return {
40
+ message: `Inserted record into ${tableName}`,
41
+ content: data
42
+ };
43
+ }
44
+ },
45
+ find: {
46
+ method: "POST",
47
+ path: "/search",
48
+ hook: {
49
+ ..._requiredHeaderDatabase,
50
+ body: `${tableName}Find`,
51
+ response: `${tableName}Response200`
52
+ },
53
+ handler: async (ctx) => {
54
+ const db = ctx.dynamicDB || ctx.staticDB;
55
+ const body = ctx.body;
56
+ const data = await db.getRepository(tableName).find({
57
+ ...body.queryOptions,
58
+ throwIfNoResult: true
59
+ });
60
+ return {
61
+ message: `Found ${data.length} records for ${tableName}`,
62
+ content: data
63
+ };
64
+ }
65
+ },
66
+ findOne: {
67
+ method: "GET",
68
+ path: "/:id",
69
+ hook: {
70
+ ..._requiredHeaderDatabase,
71
+ params: t.Object({
72
+ id: t.Union([
73
+ t.String({
74
+ format: "uuid"
75
+ }),
76
+ t.Number({
77
+ minimum: 1,
78
+ maximum: Number.MAX_SAFE_INTEGER
79
+ })
80
+ ])
81
+ }),
82
+ response: `${tableName}Response200`
83
+ },
84
+ handler: async (ctx) => {
85
+ const db = ctx.dynamicDB || ctx.staticDB;
86
+ const { id } = ctx.params;
87
+ const [primaryKey] = db.getTable(tableName).primaryKey;
88
+ const data = await db.getRepository(tableName).find({
89
+ filters: {
90
+ [primaryKey]: id
91
+ },
92
+ throwIfNoResult: true
93
+ });
94
+ return {
95
+ message: `Found record with id ${id} in ${tableName}`,
96
+ content: data
97
+ };
98
+ }
99
+ },
100
+ count: {
101
+ method: "POST",
102
+ path: "/count",
103
+ hook: {
104
+ ..._requiredHeaderDatabase,
105
+ body: `${tableName}Count`,
106
+ response: `${tableName}CountResponse200`
107
+ },
108
+ handler: async (ctx) => {
109
+ const db = ctx.dynamicDB || ctx.staticDB;
110
+ const body = ctx.body;
111
+ const data = await db.getRepository(tableName).count({
112
+ ...body.queryOptions,
113
+ throwIfNoResult: true
114
+ });
115
+ return {
116
+ message: `Counted records in ${tableName}`,
117
+ content: data
118
+ };
119
+ }
120
+ },
121
+ update: {
122
+ method: "PATCH",
123
+ path: "/",
124
+ hook: {
125
+ ..._requiredHeaderDatabase,
126
+ body: `${tableName}Update`,
127
+ response: `${tableName}Response200`
128
+ },
129
+ handler: async (ctx) => {
130
+ const db = ctx.dynamicDB || ctx.staticDB;
131
+ const body = ctx.body;
132
+ const data = await db.getRepository(tableName).update(body.data, {
133
+ filters: body.queryOptions.filters,
134
+ selectedFields: body.queryOptions.selectedFields ?? "*",
135
+ throwIfNoResult: true
136
+ });
137
+ return {
138
+ message: data.length === 0 ? `No records updated in ${tableName}` : `Updated records in ${tableName}`,
139
+ content: data
140
+ };
141
+ }
142
+ },
143
+ updateOne: {
144
+ method: "PATCH",
145
+ path: "/:id",
146
+ hook: {
147
+ ..._requiredHeaderDatabase,
148
+ params: t.Object({
149
+ id: t.Union([
150
+ t.String({
151
+ format: "uuid"
152
+ }),
153
+ t.Number({
154
+ minimum: 1,
155
+ maximum: Number.MAX_SAFE_INTEGER
156
+ })
157
+ ])
158
+ }),
159
+ body: `${tableName}UpdateOne`,
160
+ response: `${tableName}Response200`
161
+ },
162
+ handler: async (ctx) => {
163
+ const db = ctx.dynamicDB || ctx.staticDB;
164
+ const { id } = ctx.params;
165
+ const body = ctx.body;
166
+ const [primaryKey] = db.getTable(tableName).primaryKey;
167
+ const data = await db.getRepository(tableName).update(body.data, {
168
+ selectedFields: "*",
169
+ filters: {
170
+ [primaryKey]: id
171
+ },
172
+ throwIfNoResult: true
173
+ });
174
+ return {
175
+ message: `Updated record with id ${id} in ${tableName}`,
176
+ content: data
177
+ };
178
+ }
179
+ },
180
+ delete: {
181
+ method: "DELETE",
182
+ path: "/",
183
+ hook: {
184
+ ..._requiredHeaderDatabase,
185
+ body: `${tableName}Delete`,
186
+ response: `${tableName}Response200`
187
+ },
188
+ handler: async (ctx) => {
189
+ const db = ctx.dynamicDB || ctx.staticDB;
190
+ const body = ctx.body;
191
+ const selectedFields = body.queryOptions?.selectedFields ?? "*";
192
+ const data = await db.getRepository(tableName).delete({
193
+ filters: body.queryOptions.filters,
194
+ selectedFields,
195
+ throwIfNoResult: true
196
+ });
197
+ return {
198
+ message: `Deleted records from ${tableName}`,
199
+ content: data
200
+ };
201
+ }
202
+ },
203
+ deleteOne: {
204
+ method: "DELETE",
205
+ path: "/:id",
206
+ hook: {
207
+ ..._requiredHeaderDatabase,
208
+ params: t.Object({
209
+ id: t.Union([
210
+ t.String({
211
+ format: "uuid"
212
+ }),
213
+ t.Number({
214
+ minimum: 1,
215
+ maximum: Number.MAX_SAFE_INTEGER
216
+ })
217
+ ])
218
+ }),
219
+ body: `${tableName}DeleteOne`,
220
+ response: `${tableName}Response200`
221
+ },
222
+ handler: async (ctx) => {
223
+ const db = ctx.dynamicDB || ctx.staticDB;
224
+ const { id } = ctx.params;
225
+ const body = ctx.body;
226
+ const selectedFields = body.queryOptions?.selectedFields ?? "*";
227
+ const data = await db.getRepository(tableName).delete({
228
+ filters: body.queryOptions.filters,
229
+ selectedFields,
230
+ throwIfNoResult: true
231
+ });
232
+ return {
233
+ message: `Deleted record with id ${id} from ${tableName}`,
234
+ content: data
235
+ };
236
+ }
237
+ }
238
+ };
239
+ };
240
+ var _addRoutesByOperations = (tableName, database, operations) => {
241
+ const app = new Elysia;
242
+ const _defaultOperations = _createDefaultOperationsWithHandlers(tableName, database);
243
+ for (const operationKey in operations) {
244
+ const operation = operations[operationKey];
245
+ const defaultOperation = _defaultOperations[operationKey];
246
+ if (!operation || !defaultOperation)
247
+ continue;
248
+ if (typeof operation === "boolean") {
249
+ app.route(defaultOperation.method, defaultOperation.path, (ctx) => defaultOperation.handler(ctx), defaultOperation.hook);
250
+ } else if (typeof operation === "object") {
251
+ const mergedOperation = {
252
+ ...defaultOperation,
253
+ ...operation
254
+ };
255
+ app.route(mergedOperation.method, mergedOperation.path, (ctx) => defaultOperation.handler(ctx), mergedOperation.hook);
256
+ }
257
+ }
258
+ return app;
259
+ };
260
+ var crud = ({
261
+ database,
262
+ tableName,
263
+ schema,
264
+ operations = {
265
+ find: true,
266
+ findOne: true,
267
+ insert: true,
268
+ update: true,
269
+ updateOne: true,
270
+ delete: true,
271
+ deleteOne: true,
272
+ count: true
273
+ }
274
+ }) => new Elysia({
275
+ name: `crudPlugin[${tableName}]`,
276
+ tags: [tableName]
277
+ }).use(dbResolver(database)).use(crudSchema({
278
+ sourceSchemaName: tableName,
279
+ sourceSchema: schema.sourceSchema,
280
+ sourceInsertSchema: schema.sourceInsertSchema || schema.sourceSchema,
281
+ sourceFindSchema: schema.sourceFindSchema || schema.sourceSchema,
282
+ sourceCountSchema: schema.sourceCountSchema || schema.sourceSchema,
283
+ sourceUpdateSchema: schema.sourceUpdateSchema || schema.sourceSchema,
284
+ sourceDeleteSchema: schema.sourceDeleteSchema || schema.sourceSchema,
285
+ sourceResponseSchema: schema.sourceResponseSchema || schema.sourceSchema,
286
+ operations: {
287
+ find: operations.find ? true : false,
288
+ findOne: operations.findOne ? true : false,
289
+ insert: operations.insert ? true : false,
290
+ update: operations.update ? true : false,
291
+ updateOne: operations.updateOne ? true : false,
292
+ delete: operations.delete ? true : false,
293
+ deleteOne: operations.deleteOne ? true : false,
294
+ count: operations.count ? true : false
295
+ }
296
+ })).use(_addRoutesByOperations(tableName, database, operations));
297
+ export {
298
+ crud
299
+ };
@@ -0,0 +1,6 @@
1
+ import type { BaseMacro, InputSchema, LocalHook, RouteSchema, SingletonBase } from 'elysia/types';
2
+ export interface CrudOperationBaseOptions {
3
+ readonly path?: string;
4
+ readonly method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
5
+ readonly hook?: LocalHook<InputSchema, RouteSchema, SingletonBase, Record<string, Error>, BaseMacro>;
6
+ }
@@ -0,0 +1,2 @@
1
+ import type { CrudOperationBaseOptions } from './crudOperationBaseOptions';
2
+ export type CrudOperationCountOptions = CrudOperationBaseOptions;
@@ -0,0 +1,2 @@
1
+ import type { CrudOperationBaseOptions } from './crudOperationBaseOptions';
2
+ export type CrudOperationDeleteOneOptions = CrudOperationBaseOptions;
@@ -0,0 +1,2 @@
1
+ import type { CrudOperationBaseOptions } from './crudOperationBaseOptions';
2
+ export type CrudOperationDeleteOptions = CrudOperationBaseOptions;
@@ -0,0 +1,2 @@
1
+ import type { CrudOperationBaseOptions } from './crudOperationBaseOptions';
2
+ export type CrudOperationFindOneOptions = CrudOperationBaseOptions;
@@ -0,0 +1,2 @@
1
+ import type { CrudOperationBaseOptions } from './crudOperationBaseOptions';
2
+ export type CrudOperationFindOptions = CrudOperationBaseOptions;
@@ -0,0 +1,2 @@
1
+ import type { CrudOperationBaseOptions } from './crudOperationBaseOptions';
2
+ export type CrudOperationInsertOptions = CrudOperationBaseOptions;