arkos 1.4.0-canary.7 → 1.4.0-canary.71

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 (364) hide show
  1. package/cli.js +2 -5
  2. package/dist/cjs/app.js +104 -72
  3. package/dist/cjs/app.js.map +1 -1
  4. package/dist/cjs/exports/index.js.map +1 -1
  5. package/dist/cjs/exports/services/index.js +6 -1
  6. package/dist/cjs/exports/services/index.js.map +1 -1
  7. package/dist/cjs/modules/auth/auth.controller.js +31 -40
  8. package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
  9. package/dist/cjs/modules/auth/auth.router.js +29 -21
  10. package/dist/cjs/modules/auth/auth.router.js.map +1 -1
  11. package/dist/cjs/modules/auth/auth.service.js +34 -10
  12. package/dist/cjs/modules/auth/auth.service.js.map +1 -1
  13. package/dist/cjs/modules/auth/utils/services/auth-action.service.js +16 -10
  14. package/dist/cjs/modules/auth/utils/services/auth-action.service.js.map +1 -1
  15. package/dist/cjs/modules/base/base.controller.js +6 -4
  16. package/dist/cjs/modules/base/base.controller.js.map +1 -1
  17. package/dist/cjs/modules/base/base.middlewares.js +102 -19
  18. package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
  19. package/dist/cjs/modules/base/base.router.js +4 -3
  20. package/dist/cjs/modules/base/base.router.js.map +1 -1
  21. package/dist/cjs/modules/base/base.service.js +68 -66
  22. package/dist/cjs/modules/base/base.service.js.map +1 -1
  23. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +17 -40
  24. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  25. package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js +22 -6
  26. package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
  27. package/dist/cjs/modules/debugger/debugger.service.js +11 -4
  28. package/dist/cjs/modules/debugger/debugger.service.js.map +1 -1
  29. package/dist/cjs/modules/debugger/utils/loaded-components-logger.js +1 -1
  30. package/dist/cjs/modules/debugger/utils/loaded-components-logger.js.map +1 -1
  31. package/dist/cjs/modules/email/email.service.js +24 -27
  32. package/dist/cjs/modules/email/email.service.js.map +1 -1
  33. package/dist/cjs/modules/error-handler/error-handler.controller.js +22 -15
  34. package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
  35. package/dist/cjs/modules/error-handler/utils/app-error.js +14 -3
  36. package/dist/cjs/modules/error-handler/utils/app-error.js.map +1 -1
  37. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +1 -1
  38. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  39. package/dist/cjs/modules/file-upload/file-upload.controller.js +9 -6
  40. package/dist/cjs/modules/file-upload/file-upload.controller.js.map +1 -1
  41. package/dist/cjs/modules/file-upload/file-upload.router.js +13 -5
  42. package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
  43. package/dist/cjs/modules/file-upload/file-upload.service.js +38 -48
  44. package/dist/cjs/modules/file-upload/file-upload.service.js.map +1 -1
  45. package/dist/cjs/modules/file-upload/utils/helpers/file-extensions.js +134 -0
  46. package/dist/cjs/modules/file-upload/utils/helpers/file-extensions.js.map +1 -0
  47. package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js +10 -5
  48. package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
  49. package/dist/cjs/modules/swagger/swagger.router.js +11 -5
  50. package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
  51. package/dist/cjs/modules/swagger/utils/helpers/class-validator-to-json-schema.js +53 -0
  52. package/dist/cjs/modules/swagger/utils/helpers/class-validator-to-json-schema.js.map +1 -0
  53. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +10 -10
  54. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
  55. package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +419 -0
  56. package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +1 -0
  57. package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js +3 -3
  58. package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
  59. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +4 -6
  60. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -1
  61. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +4 -4
  62. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -1
  63. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js +1 -1
  64. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js.map +1 -1
  65. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +9 -9
  66. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +1 -1
  67. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js +9 -9
  68. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js.map +1 -1
  69. package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js +6 -8
  70. package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +1 -1
  71. package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js +204 -0
  72. package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js.map +1 -0
  73. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +9 -9
  74. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
  75. package/dist/cjs/server.js +33 -36
  76. package/dist/cjs/server.js.map +1 -1
  77. package/dist/cjs/types/arkos-config.js.map +1 -1
  78. package/dist/cjs/types/index.js.map +1 -1
  79. package/dist/cjs/types/new-arkos-config.js +3 -0
  80. package/dist/cjs/types/new-arkos-config.js.map +1 -0
  81. package/dist/cjs/types/router-config.js.map +1 -1
  82. package/dist/cjs/utils/arkos-router/index.js +89 -37
  83. package/dist/cjs/utils/arkos-router/index.js.map +1 -1
  84. package/dist/cjs/utils/arkos-router/route-config-validator.js +8 -7
  85. package/dist/cjs/utils/arkos-router/route-config-validator.js.map +1 -1
  86. package/dist/cjs/utils/arkos-router/types/index.js.map +1 -1
  87. package/dist/cjs/utils/arkos-router/types/openapi-config.js +3 -0
  88. package/dist/cjs/utils/arkos-router/types/openapi-config.js.map +1 -0
  89. package/dist/cjs/utils/arkos-router/types/upload-config.js +3 -0
  90. package/dist/cjs/utils/arkos-router/types/upload-config.js.map +1 -0
  91. package/dist/cjs/utils/arkos-router/utils/helpers/index.js +24 -6
  92. package/dist/cjs/utils/arkos-router/utils/helpers/index.js.map +1 -1
  93. package/dist/cjs/utils/arkos-router/utils/helpers/upload-manager.js +232 -0
  94. package/dist/cjs/utils/arkos-router/utils/helpers/upload-manager.js.map +1 -0
  95. package/dist/cjs/utils/cli/build.js +9 -13
  96. package/dist/cjs/utils/cli/build.js.map +1 -1
  97. package/dist/cjs/utils/cli/dev.js +7 -7
  98. package/dist/cjs/utils/cli/dev.js.map +1 -1
  99. package/dist/cjs/utils/cli/export-auth-action.js +78 -0
  100. package/dist/cjs/utils/cli/export-auth-action.js.map +1 -0
  101. package/dist/cjs/utils/cli/generate.js +28 -12
  102. package/dist/cjs/utils/cli/generate.js.map +1 -1
  103. package/dist/cjs/utils/cli/index.js +32 -18
  104. package/dist/cjs/utils/cli/index.js.map +1 -1
  105. package/dist/cjs/utils/cli/prisma-generate.js +2 -2
  106. package/dist/cjs/utils/cli/prisma-generate.js.map +1 -1
  107. package/dist/cjs/utils/cli/start.js +12 -52
  108. package/dist/cjs/utils/cli/start.js.map +1 -1
  109. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  110. package/dist/cjs/utils/cli/utils/runtime-cli-commander.js +58 -0
  111. package/dist/cjs/utils/cli/utils/runtime-cli-commander.js.map +1 -0
  112. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +38 -13
  113. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js.map +1 -1
  114. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +44 -17
  115. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js.map +1 -1
  116. package/dist/cjs/utils/cli/utils/template-generator/templates/{controller-template.js → generate-controller-template.js} +12 -2
  117. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +1 -0
  118. package/dist/cjs/utils/cli/utils/template-generator/templates/hooks-template.js +1 -34
  119. package/dist/cjs/utils/cli/utils/template-generator/templates/hooks-template.js.map +1 -1
  120. package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js +97 -265
  121. package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js.map +1 -1
  122. package/dist/cjs/utils/cli/utils/template-generator/templates/query-options-template.js +16 -16
  123. package/dist/cjs/utils/cli/utils/template-generator/templates/query-options-template.js.map +1 -1
  124. package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js +4 -1
  125. package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
  126. package/dist/cjs/utils/cli/utils/template-generator/templates/service-template.js +8 -32
  127. package/dist/cjs/utils/cli/utils/template-generator/templates/service-template.js.map +1 -1
  128. package/dist/cjs/utils/cli/utils/template-generator/templates/zod/create-schema-template.js +3 -5
  129. package/dist/cjs/utils/cli/utils/template-generator/templates/zod/create-schema-template.js.map +1 -1
  130. package/dist/cjs/utils/cli/utils/template-generator/templates/zod/update-schema-template.js +1 -1
  131. package/dist/cjs/utils/cli/utils/template-generator/templates/zod/update-schema-template.js.map +1 -1
  132. package/dist/cjs/utils/cli/utils/template-generators.js +2 -2
  133. package/dist/cjs/utils/cli/utils/template-generators.js.map +1 -1
  134. package/dist/cjs/utils/cli/utils/watermark-stamper.js +14 -5
  135. package/dist/cjs/utils/cli/utils/watermark-stamper.js.map +1 -1
  136. package/dist/cjs/utils/define-config.js +2 -0
  137. package/dist/cjs/utils/define-config.js.map +1 -0
  138. package/dist/cjs/utils/dotenv.helpers.js +2 -1
  139. package/dist/cjs/utils/dotenv.helpers.js.map +1 -1
  140. package/dist/cjs/utils/dynamic-loader.js +3 -2
  141. package/dist/cjs/utils/dynamic-loader.js.map +1 -1
  142. package/dist/cjs/utils/features/port-and-host-allocator.js +28 -4
  143. package/dist/cjs/utils/features/port-and-host-allocator.js.map +1 -1
  144. package/dist/cjs/utils/helpers/arkos-config.helpers.js +45 -0
  145. package/dist/cjs/utils/helpers/arkos-config.helpers.js.map +1 -0
  146. package/dist/cjs/utils/helpers/dynamic-loader.helpers.js +135 -46
  147. package/dist/cjs/utils/helpers/dynamic-loader.helpers.js.map +1 -1
  148. package/dist/cjs/utils/helpers/fs.helpers.js +1 -4
  149. package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
  150. package/dist/cjs/utils/helpers/routers.helpers.js +55 -4
  151. package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -1
  152. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +20 -31
  153. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +1 -1
  154. package/dist/cjs/utils/prisma/prisma-schema-parser.js +3 -4
  155. package/dist/cjs/utils/prisma/prisma-schema-parser.js.map +1 -1
  156. package/dist/cjs/utils/sheu.js.map +1 -1
  157. package/dist/esm/app.js +104 -72
  158. package/dist/esm/app.js.map +1 -1
  159. package/dist/esm/exports/index.js.map +1 -1
  160. package/dist/esm/exports/services/index.js +2 -1
  161. package/dist/esm/exports/services/index.js.map +1 -1
  162. package/dist/esm/modules/auth/auth.controller.js +32 -41
  163. package/dist/esm/modules/auth/auth.controller.js.map +1 -1
  164. package/dist/esm/modules/auth/auth.router.js +32 -24
  165. package/dist/esm/modules/auth/auth.router.js.map +1 -1
  166. package/dist/esm/modules/auth/auth.service.js +34 -10
  167. package/dist/esm/modules/auth/auth.service.js.map +1 -1
  168. package/dist/esm/modules/auth/utils/services/auth-action.service.js +12 -9
  169. package/dist/esm/modules/auth/utils/services/auth-action.service.js.map +1 -1
  170. package/dist/esm/modules/base/base.controller.js +6 -4
  171. package/dist/esm/modules/base/base.controller.js.map +1 -1
  172. package/dist/esm/modules/base/base.middlewares.js +102 -18
  173. package/dist/esm/modules/base/base.middlewares.js.map +1 -1
  174. package/dist/esm/modules/base/base.router.js +4 -3
  175. package/dist/esm/modules/base/base.router.js.map +1 -1
  176. package/dist/esm/modules/base/base.service.js +68 -66
  177. package/dist/esm/modules/base/base.service.js.map +1 -1
  178. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +19 -41
  179. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  180. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +22 -6
  181. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
  182. package/dist/esm/modules/debugger/debugger.service.js +11 -4
  183. package/dist/esm/modules/debugger/debugger.service.js.map +1 -1
  184. package/dist/esm/modules/debugger/utils/loaded-components-logger.js +1 -1
  185. package/dist/esm/modules/debugger/utils/loaded-components-logger.js.map +1 -1
  186. package/dist/esm/modules/email/email.service.js +24 -27
  187. package/dist/esm/modules/email/email.service.js.map +1 -1
  188. package/dist/esm/modules/error-handler/error-handler.controller.js +22 -12
  189. package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
  190. package/dist/esm/modules/error-handler/utils/app-error.js +14 -3
  191. package/dist/esm/modules/error-handler/utils/app-error.js.map +1 -1
  192. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +1 -1
  193. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  194. package/dist/esm/modules/file-upload/file-upload.controller.js +9 -6
  195. package/dist/esm/modules/file-upload/file-upload.controller.js.map +1 -1
  196. package/dist/esm/modules/file-upload/file-upload.router.js +13 -5
  197. package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
  198. package/dist/esm/modules/file-upload/file-upload.service.js +37 -47
  199. package/dist/esm/modules/file-upload/file-upload.service.js.map +1 -1
  200. package/dist/esm/modules/file-upload/utils/helpers/file-extensions.js +131 -0
  201. package/dist/esm/modules/file-upload/utils/helpers/file-extensions.js.map +1 -0
  202. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +9 -5
  203. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
  204. package/dist/esm/modules/swagger/swagger.router.js +11 -5
  205. package/dist/esm/modules/swagger/swagger.router.js.map +1 -1
  206. package/dist/esm/modules/swagger/utils/helpers/class-validator-to-json-schema.js +48 -0
  207. package/dist/esm/modules/swagger/utils/helpers/class-validator-to-json-schema.js.map +1 -0
  208. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +10 -10
  209. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
  210. package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +413 -0
  211. package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +1 -0
  212. package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js +3 -3
  213. package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
  214. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +3 -5
  215. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -1
  216. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +4 -4
  217. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -1
  218. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js +1 -1
  219. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js.map +1 -1
  220. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +9 -9
  221. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +1 -1
  222. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js +9 -9
  223. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js.map +1 -1
  224. package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js +6 -8
  225. package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +1 -1
  226. package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js +199 -0
  227. package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js.map +1 -0
  228. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +9 -9
  229. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
  230. package/dist/esm/server.js +31 -34
  231. package/dist/esm/server.js.map +1 -1
  232. package/dist/esm/types/arkos-config.js.map +1 -1
  233. package/dist/esm/types/index.js.map +1 -1
  234. package/dist/esm/types/new-arkos-config.js +2 -0
  235. package/dist/esm/types/new-arkos-config.js.map +1 -0
  236. package/dist/esm/types/router-config.js.map +1 -1
  237. package/dist/esm/utils/arkos-router/index.js +89 -37
  238. package/dist/esm/utils/arkos-router/index.js.map +1 -1
  239. package/dist/esm/utils/arkos-router/route-config-validator.js +8 -7
  240. package/dist/esm/utils/arkos-router/route-config-validator.js.map +1 -1
  241. package/dist/esm/utils/arkos-router/types/index.js.map +1 -1
  242. package/dist/esm/utils/arkos-router/types/openapi-config.js +2 -0
  243. package/dist/esm/utils/arkos-router/types/openapi-config.js.map +1 -0
  244. package/dist/esm/utils/arkos-router/types/upload-config.js +2 -0
  245. package/dist/esm/utils/arkos-router/types/upload-config.js.map +1 -0
  246. package/dist/esm/utils/arkos-router/utils/helpers/index.js +23 -5
  247. package/dist/esm/utils/arkos-router/utils/helpers/index.js.map +1 -1
  248. package/dist/esm/utils/arkos-router/utils/helpers/upload-manager.js +227 -0
  249. package/dist/esm/utils/arkos-router/utils/helpers/upload-manager.js.map +1 -0
  250. package/dist/esm/utils/cli/build.js +9 -13
  251. package/dist/esm/utils/cli/build.js.map +1 -1
  252. package/dist/esm/utils/cli/dev.js +7 -7
  253. package/dist/esm/utils/cli/dev.js.map +1 -1
  254. package/dist/esm/utils/cli/export-auth-action.js +72 -0
  255. package/dist/esm/utils/cli/export-auth-action.js.map +1 -0
  256. package/dist/esm/utils/cli/generate.js +28 -12
  257. package/dist/esm/utils/cli/generate.js.map +1 -1
  258. package/dist/esm/utils/cli/index.js +32 -18
  259. package/dist/esm/utils/cli/index.js.map +1 -1
  260. package/dist/esm/utils/cli/prisma-generate.js +2 -2
  261. package/dist/esm/utils/cli/prisma-generate.js.map +1 -1
  262. package/dist/esm/utils/cli/start.js +12 -52
  263. package/dist/esm/utils/cli/start.js.map +1 -1
  264. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  265. package/dist/esm/utils/cli/utils/runtime-cli-commander.js +53 -0
  266. package/dist/esm/utils/cli/utils/runtime-cli-commander.js.map +1 -0
  267. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +38 -13
  268. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js.map +1 -1
  269. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +44 -17
  270. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js.map +1 -1
  271. package/dist/esm/utils/cli/utils/template-generator/templates/{controller-template.js → generate-controller-template.js} +12 -2
  272. package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +1 -0
  273. package/dist/esm/utils/cli/utils/template-generator/templates/hooks-template.js +1 -34
  274. package/dist/esm/utils/cli/utils/template-generator/templates/hooks-template.js.map +1 -1
  275. package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js +97 -265
  276. package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js.map +1 -1
  277. package/dist/esm/utils/cli/utils/template-generator/templates/query-options-template.js +16 -16
  278. package/dist/esm/utils/cli/utils/template-generator/templates/query-options-template.js.map +1 -1
  279. package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js +4 -1
  280. package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
  281. package/dist/esm/utils/cli/utils/template-generator/templates/service-template.js +8 -32
  282. package/dist/esm/utils/cli/utils/template-generator/templates/service-template.js.map +1 -1
  283. package/dist/esm/utils/cli/utils/template-generator/templates/zod/create-schema-template.js +3 -5
  284. package/dist/esm/utils/cli/utils/template-generator/templates/zod/create-schema-template.js.map +1 -1
  285. package/dist/esm/utils/cli/utils/template-generator/templates/zod/update-schema-template.js +1 -1
  286. package/dist/esm/utils/cli/utils/template-generator/templates/zod/update-schema-template.js.map +1 -1
  287. package/dist/esm/utils/cli/utils/template-generators.js +1 -1
  288. package/dist/esm/utils/cli/utils/template-generators.js.map +1 -1
  289. package/dist/esm/utils/cli/utils/watermark-stamper.js +11 -5
  290. package/dist/esm/utils/cli/utils/watermark-stamper.js.map +1 -1
  291. package/dist/esm/utils/define-config.js +2 -0
  292. package/dist/esm/utils/define-config.js.map +1 -0
  293. package/dist/esm/utils/dotenv.helpers.js +2 -1
  294. package/dist/esm/utils/dotenv.helpers.js.map +1 -1
  295. package/dist/esm/utils/dynamic-loader.js +4 -3
  296. package/dist/esm/utils/dynamic-loader.js.map +1 -1
  297. package/dist/esm/utils/features/port-and-host-allocator.js +28 -4
  298. package/dist/esm/utils/features/port-and-host-allocator.js.map +1 -1
  299. package/dist/esm/utils/helpers/arkos-config.helpers.js +38 -0
  300. package/dist/esm/utils/helpers/arkos-config.helpers.js.map +1 -0
  301. package/dist/esm/utils/helpers/dynamic-loader.helpers.js +134 -46
  302. package/dist/esm/utils/helpers/dynamic-loader.helpers.js.map +1 -1
  303. package/dist/esm/utils/helpers/fs.helpers.js +1 -4
  304. package/dist/esm/utils/helpers/fs.helpers.js.map +1 -1
  305. package/dist/esm/utils/helpers/routers.helpers.js +53 -4
  306. package/dist/esm/utils/helpers/routers.helpers.js.map +1 -1
  307. package/dist/esm/utils/prisma/prisma-json-schema-generator.js +20 -31
  308. package/dist/esm/utils/prisma/prisma-json-schema-generator.js.map +1 -1
  309. package/dist/esm/utils/prisma/prisma-schema-parser.js +3 -4
  310. package/dist/esm/utils/prisma/prisma-schema-parser.js.map +1 -1
  311. package/dist/esm/utils/sheu.js.map +1 -1
  312. package/dist/types/app.d.ts +2 -2
  313. package/dist/types/exports/index.d.ts +3 -2
  314. package/dist/types/exports/services/index.d.ts +2 -1
  315. package/dist/types/modules/auth/auth.controller.d.ts +2 -2
  316. package/dist/types/modules/auth/auth.router.d.ts +2 -3
  317. package/dist/types/modules/auth/auth.service.d.ts +6 -0
  318. package/dist/types/modules/auth/utils/services/auth-action.service.d.ts +1 -0
  319. package/dist/types/modules/base/base.middlewares.d.ts +1 -2
  320. package/dist/types/modules/base/base.router.d.ts +2 -2
  321. package/dist/types/modules/base/base.service.d.ts +2 -1
  322. package/dist/types/modules/base/utils/helpers/base.router.helpers.d.ts +2 -4
  323. package/dist/types/modules/debugger/debugger.service.d.ts +1 -1
  324. package/dist/types/modules/error-handler/utils/app-error.d.ts +1 -1
  325. package/dist/types/modules/file-upload/file-upload.router.d.ts +2 -2
  326. package/dist/types/modules/file-upload/file-upload.service.d.ts +24 -2
  327. package/dist/types/modules/file-upload/utils/helpers/file-extensions.d.ts +3 -0
  328. package/dist/types/modules/file-upload/utils/helpers/file-upload.helpers.d.ts +2 -1
  329. package/dist/types/modules/swagger/swagger.router.d.ts +1 -1
  330. package/dist/types/modules/swagger/utils/helpers/class-validator-to-json-schema.d.ts +3 -0
  331. package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +2 -2
  332. package/dist/types/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.d.ts +3 -0
  333. package/dist/types/modules/swagger/utils/helpers/get-swagger-default-configs.d.ts +2 -45
  334. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.d.ts +1 -1
  335. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.d.ts +1 -1
  336. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.d.ts +1 -1
  337. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.d.ts +1 -1
  338. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.d.ts +1 -1
  339. package/dist/types/modules/swagger/utils/helpers/missing-json-schemas-generator.d.ts +1 -1
  340. package/dist/types/modules/swagger/utils/helpers/openapi-schema-converter.d.ts +17 -0
  341. package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +3 -3
  342. package/dist/types/server.d.ts +4 -6
  343. package/dist/types/types/arkos-config.d.ts +4 -181
  344. package/dist/types/types/index.d.ts +5 -4
  345. package/dist/types/types/new-arkos-config.d.ts +167 -0
  346. package/dist/types/types/router-config.d.ts +16 -23
  347. package/dist/types/utils/arkos-router/types/index.d.ts +39 -9
  348. package/dist/types/utils/arkos-router/types/openapi-config.d.ts +35 -0
  349. package/dist/types/utils/arkos-router/types/upload-config.d.ts +21 -0
  350. package/dist/types/utils/arkos-router/utils/helpers/upload-manager.d.ts +13 -0
  351. package/dist/types/utils/cli/export-auth-action.d.ts +4 -0
  352. package/dist/types/utils/cli/generate.d.ts +2 -1
  353. package/dist/types/utils/cli/utils/runtime-cli-commander.d.ts +11 -0
  354. package/dist/types/utils/cli/utils/watermark-stamper.d.ts +3 -3
  355. package/dist/types/utils/define-config.d.ts +0 -0
  356. package/dist/types/utils/features/port-and-host-allocator.d.ts +4 -2
  357. package/dist/types/utils/helpers/arkos-config.helpers.d.ts +7 -0
  358. package/dist/types/utils/helpers/dynamic-loader.helpers.d.ts +1 -0
  359. package/dist/types/utils/helpers/routers.helpers.d.ts +8 -0
  360. package/dist/types/utils/prisma/prisma-json-schema-generator.d.ts +1 -1
  361. package/package.json +3 -2
  362. package/dist/cjs/utils/cli/utils/template-generator/templates/controller-template.js.map +0 -1
  363. package/dist/esm/utils/cli/utils/template-generator/templates/controller-template.js.map +0 -1
  364. /package/dist/types/utils/cli/utils/template-generator/templates/{controller-template.d.ts → generate-controller-template.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"arkos-config.js","sourceRoot":"","sources":["../../../src/types/arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import http from \"http\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport cookieParser from \"cookie-parser\";\nimport compression from \"compression\";\nimport { Options as QueryParserOptions } from \"../utils/helpers/query-parser.helpers\";\nimport { ValidatorOptions } from \"class-validator\";\nimport { MsDuration } from \"../modules/auth/utils/helpers/auth.controller.helpers\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport type { ApiReferenceConfiguration } from \"@scalar/express-api-reference\" with { \"resolution-mode\": \"import\" };\nimport nodemailer from \"nodemailer\";\nimport { ModuleComponents } from \"../utils/dynamic-loader\";\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosConfig = {\n /**\n * Allows to configure request configs\n */\n request?: {\n /**\n * Allows to configure request parameters\n */\n parameters?: {\n /**\n * Toggles allowing `VERY DANGEROUS` request paramateres under `req.query` for passing prisma query options.\n *\n * See more\n */\n allowDangerousPrismaQueryOptions?: boolean;\n };\n };\n /** Message you would like to send, as Json and 200 response when\n * ```curl\n * GET /api\n * ```\n *\n * ```json\n * { \"message\": \"Welcome to YourAppName\" }\n * ```\n *\n * default message is: Welcome to our Rest API generated by Arkos, find more about Arkos at www.arkosjs.com.\n *\n *\n * */\n welcomeMessage?: string;\n /**\n * Port where the application will run, can be set in 3 ways:\n *\n * 1. default is 8000\n * 2. PORT under environment variables (Lower precedence)\n * 3. this config option (Higher precedence)\n */\n port?: number | undefined;\n /**\n * Allows to listen on a different host than localhost only\n */\n host?: string;\n /**\n * Defines authentication related configurations, by default is undefined.\n *\n * See [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for details.\n */\n authentication?: {\n /**\n * Defines whether to use Static or Dynamic Role-Based Acess Control\n *\n * Visit [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for more details.\n */\n mode: \"static\" | \"dynamic\";\n /**\n * Defines auth login related configurations to customize the api.\n */\n login?: {\n /**\n * Defines the field that will be used as username by the built-in auth system, by default arkos will look for the field \"username\" in your model User, hence when making login for example you must send:\n *\n * ```json\n * {\n * \"username\": \"johndoe\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n *\n * **Note:** You can also modify the usernameField on the fly by passing it to the request query parameters. example:\n *\n * ```curl\n * POST /api/auth/login?usernameField=email\n * ```\n *\n * See more at [www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds](https://www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds)\n *\n * By specifing here another field for username, for example passing \"email\", \"companyCode\" or something else your json will be like:\n *\n * **Example with email**\n *\n * ```json\n * {\n * \"email\": \"john.doe@example.com\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n */\n allowedUsernames?: string[];\n /** Defines wether to send the access token in response after login or only send as cookie, defeault is both.*/\n sendAccessTokenThrough?: \"cookie-only\" | \"response-only\" | \"both\";\n };\n /**\n * Specifies the regex pattern used by the authentication system to enforce password strength requirements.\n *\n * **Important**: If using validation libraries like Zod or class-validator, this will be completely overwritten.\n *\n * **Default**: ```/^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).+$/``` - Ensures the password contains at least one uppercase letter, one lowercase letter, and one numeric digit.\n *\n * **message**: (Optional) A custom error message to display when the password does not meet the required strength criteria.\n */\n passwordValidation?: { regex: RegExp; message?: string };\n /**\n * Allows to specify the request rate limit for all authentication endpoints but `/api/users/me`.\n * \n * #### Default\n *{\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n *@see This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n requestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * JWT (JSON Web Token) authentication configuration.\n *\n * You can override these values directly in code, or use environment variables:\n *\n * - `JWT_SECRET`: Secret used to sign and verify JWT tokens.\n * - `JWT_EXPIRES_IN`: Duration string or number indicating when the token should expire (e.g. \"30d\", 3600).\n * - `JWT_COOKIE_SECURE`: Whether the cookie is sent only over HTTPS. Default: `true` in production.\n * - `JWT_COOKIE_HTTP_ONLY`: Whether the cookie is HTTP-only. Default: `true`.\n * - `JWT_COOKIE_SAME_SITE`: Can be \"lax\", \"strict\", or \"none\". Defaults to \"lax\" in dev, \"none\" in prod.\n *\n * ⚠️ Values passed here take precedence over environment variables.\n */\n jwt?: {\n /** Secret key used for signing and verifying JWT tokens */\n secret?: string;\n /**\n * Duration after which the JWT token expires.\n * Accepts either a duration string (e.g. \"30d\", \"1h\") or a number in milliseconds.\n * Defaults to \"30d\" if not provided.\n */\n expiresIn?: MsDuration | number;\n\n /**\n * Configuration for the JWT cookie sent to the client\n */\n cookie?: {\n /**\n * Whether the cookie should be marked as secure (sent only over HTTPS).\n * Defaults to `true` in production and `false` in development.\n */\n secure?: boolean;\n\n /**\n * Whether the cookie should be marked as HTTP-only.\n * Default is `true` to prevent access via JavaScript.\n */\n httpOnly?: boolean;\n\n /**\n * Controls the SameSite attribute of the cookie.\n * Defaults to \"none\" in production and \"lax\" in development.\n * Options: \"lax\" | \"strict\" | \"none\"\n */\n sameSite?: \"lax\" | \"strict\" | \"none\";\n };\n };\n };\n /** Allows to customize and toggle the built-in validation, by default it is set to `false`. If true is passed it will use validation with the default resolver set to `class-validator` if you intend to change the resolver to `zod` do the following:\n *\n *```ts\n * // src/app.ts\n * import arkos from 'arkos'\n *\n * arkos.init({\n * validation: {\n * resolver: \"zod\"\n * }\n * })\n * ```\n *\n * @See [www.arkosjs.com/docs/core-concepts/request-data-validation](https://www.arkosjs.com/docs/core-concepts/request-data-validation) for more details.\n */\n validation?: {\n /**\n * Defines whether to use strict request validation, it means in every request using `ArkosRouter()` you must pass the validation options with all options (e.g: query, params, body, etc.).\n *\n * **How It Works:**\n * - If it is true, Arkos will require all the options a stated above on the routes and if you don't pass it will throw an error.\n * **What if you don't want to pass a validator to some options?**\n * - You will need to pass `undefined` to the validator option (see example below), this way Arkos will throw an error if something is passed to `req.query` if you passed undefined as validator into `validation.query`\n *\n * ```ts\n * import { ArkosRouter } from \"arkos\"\n *\n * const router = ArkosRouter()\n *\n * router.get({\n * route: \"/api/posts\",\n * validation: {\n * query: undefined\n * }\n * })\n *\n * ```\n */\n strict?: boolean;\n } & (\n | {\n resolver?: \"class-validator\";\n /**\n * ValidatorOptions to used while validating request data.\n *\n * **Default**:\n * ```ts\n * {\n * whitelist: true\n * }\n * ```\n */\n validationOptions?: ValidatorOptions;\n }\n | {\n resolver?: \"zod\";\n validationOptions?: Record<string, any>;\n }\n );\n /**\n * Defines file upload configurations\n *\n * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)\n */\n fileUpload?: {\n /**\n * Defiens the base file upload directory, default is set to /uploads (on root directory)\n *\n * When setting up a path dir always now that root directory will be the starting reference.\n *\n * #### Example\n * passing `../my-arkos-uploaded-files`\n *\n * Will save uploaded files one level outside the root dir inside `my-arkos-uploaded-files`\n *\n * NB: You must be aware of permissions on your server to acess files outside your project directory.\n *\n */\n baseUploadDir?: string;\n /**\n * Changes the default `/api/uploads` base route for accessing file upload route.\n *\n * #### IMPORTANT\n * Changing this will not affect the `baseUploadDir` folder. You can\n * pass here `/api/files/my-user-files` and `baseUploadDir` be `/uploaded-files`.\n *\n */\n baseRoute?: string;\n /**\n * Defines options for `express.static(somePath, someOptions)`\n *\n * #### Default:\n *\n * ```ts\n *{\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n }\n * ```\n * \n * By passing your custom options have in mind that it\n * will be deepmerged with the default.\n * \n * Visit [https://expressjs.com/en/4x/api.html#express.static](https://expressjs.com/en/4x/api.html#express.static) for more understanding.\n * \n */\n expressStaticOptions?: Parameters<typeof express.static>[1];\n /**\n * Defines upload restrictions for each file type: image, video, document or other.\n *\n * #### Important:\n * Passing an object without overriding everything will only cause it\n * to be deepmerged with the default options.\n *\n * See [www.arkosjs.com/docs/api-reference/default-supported-upload-files](https://www.arkosjs.com/docs/api-reference/default-supported-upload-files) for detailed explanation about default values.\n * ```\n */\n restrictions?: {\n images?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n videos?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n documents?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n files?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n };\n };\n /**\n * Allows to specify the request rate limit for all endpoints.\n * \n * #### Default\n *```ts\n *{\n windowMs: 60 * 1000,\n limit: 1000,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n ```\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n * This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n globalRequestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * Defines options for the built-in express.json() middleware\n * Nothing is passed by default.\n */\n jsonBodyParserOptions?: Parameters<typeof express.json>[0];\n /**\n * Allows to pass paremeters to cookieParser from npm package cookie-parser\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.\n */\n cookieParserParameters?: Parameters<typeof cookieParser>;\n /**\n * Allows to define options for npm package compression\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/compression](https://www.npmjs.com/package/compression) for further details.\n */\n compressionOptions?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * #### for example:\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n * \n * #### Default:\n * \n * {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n }\n * \n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n * \n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParserOptions?: QueryParserOptions;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: cors.CorsOptions;\n /**\n * If you would like to override the entire middleware\n *\n * see\n */\n customHandler?: cors.CorsOptionsDelegate;\n };\n /**\n * Defines express/arkos middlewares configurations\n */\n middlewares?: {\n /**\n * Allows to add an array of custom express middlewares into the default middleware stack.\n *\n * **Tip**: If you would like to acess the express app before everthing use `configureApp` and pass a function.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order](https://www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order)\n *\n * **Note**: If you want to use custom global error handler middleware use `middlewares.replace.globalErrorHandler`.\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.RequestHandler[];\n /**\n * An array containing a list of defaults middlewares to be disabled\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n *\n */\n disable?: (\n | \"compression\"\n | \"global-rate-limit\"\n | \"auth-rate-limit\"\n | \"cors\"\n | \"express-json\"\n | \"cookie-parser\"\n | \"query-parser\"\n | \"request-logger\"\n | \"global-error-handler\"\n )[];\n /**\n * Allows you to replace each of the built-in middlewares with your own implementation\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default compression middleware\n */\n compression?: express.RequestHandler;\n /**\n * Replace the default global rate limit middleware\n */\n globalRateLimit?: express.RequestHandler;\n /**\n * Replace the default authentication rate limit middleware\n */\n authRateLimit?: express.RequestHandler;\n /**\n * Replace the default CORS middleware\n */\n cors?: express.RequestHandler;\n /**\n * Replace the default JSON body parser middleware\n */\n expressJson?: express.RequestHandler;\n /**\n * Replace the default cookie parser middleware\n */\n cookieParser?: express.RequestHandler;\n /**\n * Replace the default query parser middleware\n */\n queryParser?: express.RequestHandler;\n /**\n * Replace the default request logger middleware\n */\n requestLogger?: express.RequestHandler;\n /**\n * Replace the default global error handler middleware\n */\n globalErrorHandler?: express.ErrorRequestHandler;\n };\n };\n /**\n * Defines express/arkos routers configurations\n */\n routers?: {\n /**\n * Strict mode configuration for routing security\n *\n * @default false\n * - all CRUD + Auth (if using auth) endpoits are enabled and avialable by default.\n *\n * When enabled:\n * - If `true`: All CRUD endpoints start disabled and must be explicitly enabled\n * in each model's router configuration\n * - If `'no-bulk'`: Bulk operations (createMany, updateMany, deleteMany) are disabled\n * by default, while individual operations can be enabled per model\n *\n * This provides enhanced security by ensuring no routes are accidentally exposed.\n * Use this in production environments to follow the principle of least privilege.\n *\n * See documentation: https://www.arkosjs.com/docs/guide/security#strict-mode\n */\n strict?: boolean | \"no-bulk\";\n /**\n * Allows to add an array of custom express routers into the default middleware/router stack.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/adding-custom-routers](https://www.arkosjs.com/docs/advanced-guide/adding-custom-routers)\n *\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.Router[];\n disable?: (\n | \"auth-router\"\n | \"prisma-models-router\"\n | \"file-upload\"\n | \"welcome-endpoint\"\n )[];\n /**\n * Allows you to replace each of the built-in routers with your own implementation.\n *\n * **Note**: Doing this you will lose all default middleware chaining, auth control, handlers from the specific router.\n *\n * **Tip**: I you want to disable some prisma models specific endpoint\n * see [www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints](https://www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints)\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default authentication router\n * @param config The original Arkos configuration\n * @returns A router handling authentication endpoints\n */\n authRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default Prisma models router\n * @param config The original Arkos configuration\n * @returns A router handling Prisma model endpoints\n */\n prismaModelsRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default file upload router\n * @param config The original Arkos configuration\n * @returns A router handling file upload endpoints\n */\n fileUpload?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default welcome endpoint handler\n * @param req Express request object\n * @param res Express response object\n * @param next Express next function\n */\n welcomeEndpoint?: express.RequestHandler;\n };\n };\n /**\n * Gives acess to the underlying express app so that you can add custom configurations beyong **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `app.listen` for you.\n *\n * If you want to call `app.listen` by yourself pass port as `undefined` and then use the return app from `arkos.init()`.\n *\n * See how to call `app.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself](https://www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app](https://www.arkosjs.com/docs/guide/accessing-the-express-app) for further details on the method configureApp.\n *\n * @param {express.Express} app\n * @returns {any}\n */\n configureApp?: (app: express.Express) => Promise<any> | any;\n /**\n * Gives access to the underlying HTTP server so that you can add custom configurations beyond **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `server.listen` for you.\n *\n * If you want to call `server.listen` by yourself pass port as `undefined` and then use the return server from `arkos.init()`.\n *\n * See how to call `server.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server) for further details on the method configureServer.\n *\n * @param {http.Server} server - The HTTP server instance\n * @returns {any}\n */\n configureServer?: (server: http.Server) => Promise<any> | any;\n /**\n * Allows to configure email configurations for sending emails through `emailService`\n *\n * See [www.arkosjs.com/docs/core-concepts/sending-emails](https://www.arkosjs.com/docs/core-concepts/sending-emails)\n */\n email?: {\n /**\n * Email name to used like:\n *\n * John Doe\\<john.doe@gmail.com>\n */\n name?: string;\n /**\n * Your email provider url\n */\n host: string;\n /**\n * Email provider SMTP port, Default is `465`\n */\n port?: number;\n /**\n * If smtp connection must be secure, Default is `true`\n */\n secure?: boolean;\n /**\n * Used to authenticate in your smtp server\n */\n auth: {\n /**\n * Email used for auth as well as sending emails\n */\n user: string;\n /**\n * Your SMTP password\n */\n pass: string;\n };\n } & Parameters<typeof nodemailer.createTransport>[0];\n /**\n * Defines Swagger and OpenApi specifications for auto generating swagger documentation UI using whether it is Prisma Schemas, Class-validator DTOs, Zod Schemas or JSON-Schemas.\n *\n * **Important**: Is worth mentioning that this works alongside `@scalar/express-api-reference` npm package, you define it's ApiReferenceConfiguration under ``. also consider checking the package documentation at []\n *\n * **Usage**\n *\n * ```ts\n * // src/app.ts\n *\n * import arkos from \"arkos\"\n *\n * arkos.init({\n * // other configs\n * swagger: {\n * mode: \"zod\",\n * options: {\n * defintion: {\n * info: {\n * openapi: \"3.0.0\",\n * title: \"API Generated By Arkos.js\",\n * description: \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n * }\n * }\n * }\n * }\n * })\n * ```\n * @see {@link https://www.arkosjs.com/docs/core-concepts/swagger-api-documentation}\n */\n swagger?: {\n /**\n * By default Arkos will disable API Documentation when the project is built `npm run build`, it does not matter what node environment is set. If you want to use it even after the `arkos build` command just set this to `true`.\n * */\n enableAfterBuild?: boolean;\n /**\n * Endpoint where the Swagger UI will be available.\n *\n * @default \"/api/api-docs\"\n */\n endpoint?: string;\n /**\n * Determines how your API schemas should be generated.\n *\n * - \"prisma\": Generates schemas based on Prisma models\n * - \"class-validator\": Uses class-validator and class-transformer DTO classes\n * - \"zod\": Uses OpenAPI-compliant schemas directly\n */\n mode: \"prisma\" | \"class-validator\" | \"zod\";\n /**\n * Allows `Arkos.js` to fallback to prisma schema and use them as json schema for defining request body and response data\n * when a given zod Schema or class-validator Class is not found to be transformed to json schema.\n *\n * @default false\n */\n strict?: boolean;\n /**\n * Defines your swagger configurations\n */\n options?: {\n /**\n * Swagger definition according to OpenAPI Specification.\n */\n definition?: {\n /**\n * OpenAPI version.\n *\n * @default \"3.0.0\"\n */\n openapi?: string;\n\n /**\n * Information about your API.\n */\n info?: {\n /**\n * Title of the API documentation.\n *\n *\n * @example \"My API\"\n *\n * @default \"API Generated By Arkos.js\"\n */\n title?: string;\n\n /**\n * Version of the API.\n *\n * @example \"1.0.0\"\n */\n version?: string;\n\n /**\n * Description of the API.\n *\n * @default \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n */\n description?: string;\n };\n\n /**\n * Server configurations for the API.\n *\n * @default [{ url: \"http://localhost:8000\", description: \"Development server\" }]\n *\n * This can be overridden automatically by Arkos based on CLI, .env, or `arkos.init()`.\n */\n servers?: {\n /**\n * Base URL of the server.\n *\n * @example \"http://localhost:8000\"\n */\n url: string;\n\n /**\n * Human-readable description of the server.\n *\n * @example \"Development Server\"\n */\n description?: string;\n }[];\n /**\n * Allows adding more paths for your OpenAPI documentation\n *\n * */\n paths?: OpenAPIV3.PathsObject;\n /**\n * (Optional) Additional metadata such as terms of service, contact, or license.\n *\n * See: https://swagger.io/specification/#infoObject\n */\n termsOfService?: string;\n contact?: {\n name?: string;\n url?: string;\n email?: string;\n };\n license?: {\n name: string;\n url?: string;\n };\n\n /**\n * Tags to group and describe endpoints.\n */\n tags?: {\n name: string;\n description?: string;\n }[];\n\n /**\n * Security definitions (e.g., Bearer Auth).\n */\n components?: {\n securitySchemes?: Record<string, any>;\n schemas?: Record<string, any>;\n };\n\n /**\n * Global security requirements.\n */\n security?: Array<Record<string, string[]>>;\n };\n\n /**\n * Glob patterns defining where Swagger should look for API route definitions and comments.\n *\n * @default \n * ```ts\n * [\"./src/routers/*.router.{ts,js}\", \"./src/modules/**\\/*.router.{ts,js}\"]\n ```\n *\n * Adjust depending on TypeScript or JavaScript usage.\n */\n apis?: string[];\n\n /**\n * Enables deep linking in the Swagger UI.\n *\n * @default true\n */\n deepLinking?: boolean;\n\n /**\n * Enable/disable the \"Try it out\" button globally.\n *\n * @default true\n */\n tryItOutEnabled?: boolean;\n\n /**\n * Whether to persist authorization data across page reloads.\n *\n * @default false\n */\n persistAuthorization?: boolean;\n };\n /**\n * Custom `@scalar/express-api-reference` package options.\n *\n * @see {@link https://guides.scalar.com/scalar/scalar-api-references/integrations/express}\n */\n scalarApiReferenceConfiguration?: Partial<ApiReferenceConfiguration>;\n };\n /**\n * Helps in debugging some of the variables values that are used inside arkos from dynamic loaded components towhat is used into the generated api.\n *\n */\n debugging?: {\n /**\n * Controls debugging over HTTP request level\n */\n requests?: {\n level?: 0 | 1 | 2 | 3;\n filter?: (\n | \"Query\"\n | \"Body\"\n | \"Params\"\n | \"TransformedQuery\"\n | \"ServiceArgs\"\n | \"FinalPrismaQueryArgs\"\n )[];\n };\n /**\n * Controls debugging over the dynamic loaded modules and it's components on app starting\n */\n dynamicLoader?: {\n /**\n * Adjusts logging details\n *\n * 1 - Loaded modules and list of it's components files\n * 2 - All from 1 and detailed inspection per module component\n * 3 - All from 1 and 2, plus the final router component after merged with autho generated router.\n */\n level?: 0 | 1 | 2 | 3;\n filters?: {\n /**\n * Allows filtering by specific modules.\n *\n * Supports only searching for the starting parts of the module name, e.g: If there is`user-profile`, `user`, `posts`, passing `[\"user\"]` will match both `user-profile` and `user`.\n */\n modules?: string[];\n /**\n * Allows filtering by component's names\n */\n components?: keyof ModuleComponents[];\n };\n };\n };\n};\n"]}
1
+ {"version":3,"file":"arkos-config.js","sourceRoot":"","sources":["../../../src/types/arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import http from \"http\";\nimport express from \"express\";\nimport { IArkosRouter } from \"../utils/arkos-router/types\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \".\";\n\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosInitConfig = {\n /**\n * Allows to add an array of custom express routers/middlewares into the default middleware/routers stack.\n *\n * **Tip**: If you would like to acess the express app before everthing use `configureApp` and pass a function.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order](https://www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order)\n *\n * **Note**: If you want to use custom global error handler middleware use `middlewares.replace.globalErrorHandler`.\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n use?: IArkosRouter[] | ArkosRequestHandler[] | ArkosErrorRequestHandler[];\n /**\n * Gives acess to the underlying express app so that you can add custom configurations beyong **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `app.listen` for you.\n *\n * If you want to call `app.listen` by yourself pass port as `undefined` and then use the return app from `arkos.init()`.\n *\n * See how to call `app.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself](https://www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app](https://www.arkosjs.com/docs/guide/accessing-the-express-app) for further details on the method configureApp.\n *\n * @param {express.Express} app\n * @returns {any}\n */\n configureApp?: (app: express.Express) => Promise<any> | any;\n /**\n * Gives access to the underlying HTTP server so that you can add custom configurations beyond **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `server.listen` for you.\n *\n * If you want to call `server.listen` by yourself pass port as `undefined` and then use the return server from `arkos.init()`.\n *\n * See how to call `server.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server) for further details on the method configureServer.\n *\n * @param {http.Server} server - The HTTP server instance\n * @returns {any}\n */\n configureServer?: (server: http.Server) => Promise<any> | any;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AA6LA,MAAM,CAAN,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EALW,oBAAoB,KAApB,oBAAoB,QAK/B","sourcesContent":["import {\n ErrorRequestHandler,\n NextFunction,\n Request,\n RequestHandler,\n Response,\n} from \"express\";\n\nexport type PrismaOperations = \"findMany\";\n\n/**\n * Type definition for authentication-related Prisma query operations\n * @template T - The Prisma model delegate type\n */\nexport type AuthPrismaQueryOptions<T extends Record<string, any>> = {\n // User profile endpoints\n /**\n * Options for retrieving the current authenticated user's profile\n */\n getMe?: Partial<Parameters<T[\"findUnique\"]>[0]>;\n /**\n * Options for updating the current authenticated user's profile\n */\n updateMe?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Options for soft deleting or deactivating the current authenticated user's account\n */\n deleteMe?: Partial<Parameters<T[\"update\"]>[0]>;\n // Authentication endpoints\n /**\n * Options for user login authentication queries\n */\n login?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n /**\n * Options for user registration and account creation\n */\n signup?: Partial<Parameters<T[\"create\"]>[0]>;\n /**\n * Options for updating the current authenticated user's password\n */\n updatePassword?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Options for finding multiple auth actions\n */\n findManyAuthAction?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * Options for finding a single auth action\n */\n findOneAuthAction?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n};\n\n/**\n * Base Prisma query options for standard CRUD operations\n * @template T - The Prisma model delegate type\n */\ntype BasePrismaQueryOptions<T extends Record<string, any>> = {\n /**\n * @deprecated Use `global` instead for general query options\n */\n queryOptions?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * Global query options that can be used for all operations\n * Replaces the deprecated queryOptions\n */\n global?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * General find options for findMany and findOne operations\n */\n find?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * General create options for createOne and createMany operations\n */\n create?: Partial<Parameters<T[\"create\"]>[0]>;\n /**\n * General update options for updateOne and updateMany operations\n */\n update?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * General delete options for deleteOne and deleteMany operations\n */\n delete?: Partial<Parameters<T[\"delete\"]>[0]>;\n /**\n * General save options for createOne, createMany, updateOne, updateMany operations\n */\n save?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Save options for single record operations (createOne, updateOne)\n */\n saveOne?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Save options for multiple record operations (createMany, updateMany)\n */\n saveMany?:\n | Partial<Parameters<T[\"createMany\"]>[0]>\n | Partial<Parameters<T[\"updateMany\"]>[0]>;\n /**\n * Options for finding a single record (first match)\n */\n findOne?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n /**\n * Options for finding multiple records\n */\n findMany?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * Options for creating a single record\n */\n createOne?: Partial<Parameters<T[\"create\"]>[0]>;\n /**\n * Options for creating multiple records\n */\n createMany?: Partial<Parameters<T[\"createMany\"]>[0]>;\n /**\n * Options for updating a single record\n */\n updateOne?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Options for updating multiple records\n */\n updateMany?: Partial<Parameters<T[\"updateMany\"]>[0]>;\n /**\n * Options for deleting a single record\n */\n deleteOne?: Partial<Parameters<T[\"delete\"]>[0]>;\n /**\n * Options for deleting multiple records\n */\n deleteMany?: Partial<Parameters<T[\"deleteMany\"]>[0]>;\n};\n\n/**\n * Type definition for Prisma query operations with flexible options\n * Conditionally provides auth-specific options when ModelName is \"auth\"\n * @template T - The Prisma model delegate type\n * @template ModelName - The model name (defaults to string for standard models)\n */\nexport type PrismaQueryOptions<\n T extends Record<string, any>,\n ModelName extends string = string,\n> = ModelName extends \"auth\"\n ? AuthPrismaQueryOptions<T>\n : BasePrismaQueryOptions<T>;\n/**\n * Interface defining the minimum structure required for Prisma model delegates\n * This allows us to constraint TModel without requiring Prisma imports\n */\nexport type PrismaModelDelegate = {\n create: (args: { data: never; [key: string]: never }) => Promise<any>;\n createMany: (args: { data: never; [key: string]: never }) => Promise<any>;\n findMany: (args: { [key: string]: never }) => Promise<any[]>;\n findFirst: (args: { where: never; [key: string]: never }) => Promise<any>;\n findUnique: (args: { where: never; [key: string]: never }) => Promise<any>;\n update: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n updateMany: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n delete: (args: { where: never; [key: string]: never }) => Promise<any>;\n deleteMany: (args: { where: never; [key: string]: never }) => Promise<any>;\n count: (args: { where: never; [key: string]: never }) => Promise<number>;\n};\n\nexport interface UserRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n roleId: string;\n role: AuthRole;\n user: User;\n userId: string;\n}\n\nexport interface AuthRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n name: string;\n permissions: AuthPermission[];\n userRoles: UserRole[];\n}\n\nexport enum AuthPermissionAction {\n Create = \"Create\",\n View = \"View\",\n Update = \"Update\",\n Delete = \"Delete\",\n}\n\nexport interface AuthPermission {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n resource: string;\n action: AuthPermissionAction;\n roleId: string;\n role: AuthRole;\n}\n\nexport interface User {\n id: string;\n isStaff: boolean;\n isSuperUser: boolean;\n password: string;\n passwordChangedAt?: Date;\n deletedSelfAccountAt: Date;\n isActive: boolean;\n roles?: UserRole[] | any[];\n role?: UserRole | any;\n}\n\nexport interface ArkosRequest<Body = any, Query = any> extends Request {\n user?: User & Record<string, any>;\n relationFields?: Record<string, boolean>;\n include?: Record<string, any>;\n responseData?: Record<string, any> | null | undefined;\n additionalData?: Record<string, any> | null | undefined;\n responseStatus?: number | string | null | undefined;\n body: Body;\n prismaQueryOptions?: Record<string, any>;\n // query: Query extends Request['ParsedQs'];\n accessToken?: string;\n /**\n * This represents `req.query` after being handled and transformed.\n */\n transformedQuery?: Record<string, any>;\n /**\n * Return result of APIFeatures.filters\n */\n filters?: Record<string, any>;\n modelName?: string;\n}\n\nexport interface ArkosResponse extends Response {}\nexport interface ArkosNextFunction extends NextFunction {}\nexport interface ArkosRequestHandler extends RequestHandler {}\nexport interface ArkosErrorRequestHandler extends ErrorRequestHandler {}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AA6LA,MAAM,CAAN,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EALW,oBAAoB,KAApB,oBAAoB,QAK/B","sourcesContent":["import {\n ErrorRequestHandler,\n NextFunction,\n Request,\n RequestHandler,\n Response,\n} from \"express\";\n\nexport type PrismaOperations = \"findMany\";\n\n/**\n * Type definition for authentication-related Prisma query operations\n * @template T - The Prisma model delegate type\n */\nexport type AuthPrismaQueryOptions<T extends Record<string, any>> = {\n // User profile endpoints\n /**\n * Options for retrieving the current authenticated user's profile\n */\n getMe?: Partial<Parameters<T[\"findUnique\"]>[0]>;\n /**\n * Options for updating the current authenticated user's profile\n */\n updateMe?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Options for soft deleting or deactivating the current authenticated user's account\n */\n deleteMe?: Partial<Parameters<T[\"update\"]>[0]>;\n // Authentication endpoints\n /**\n * Options for user login authentication queries\n */\n login?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n /**\n * Options for user registration and account creation\n */\n signup?: Partial<Parameters<T[\"create\"]>[0]>;\n /**\n * Options for updating the current authenticated user's password\n */\n updatePassword?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Options for finding multiple auth actions\n */\n findManyAuthAction?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * Options for finding a single auth action\n */\n findOneAuthAction?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n};\n\n/**\n * Base Prisma query options for standard CRUD operations\n * @template T - The Prisma model delegate type\n */\ntype BasePrismaQueryOptions<T extends Record<string, any>> = {\n /**\n * @deprecated Use `global` instead for general query options\n */\n queryOptions?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * Global query options that can be used for all operations\n * Replaces the deprecated queryOptions\n */\n global?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * General find options for findMany and findOne operations\n */\n find?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * General create options for createOne and createMany operations\n */\n create?: Partial<Parameters<T[\"create\"]>[0]>;\n /**\n * General update options for updateOne and updateMany operations\n */\n update?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * General delete options for deleteOne and deleteMany operations\n */\n delete?: Partial<Parameters<T[\"delete\"]>[0]>;\n /**\n * General save options for createOne, createMany, updateOne, updateMany operations\n */\n save?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Save options for single record operations (createOne, updateOne)\n */\n saveOne?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Save options for multiple record operations (createMany, updateMany)\n */\n saveMany?:\n | Partial<Parameters<T[\"createMany\"]>[0]>\n | Partial<Parameters<T[\"updateMany\"]>[0]>;\n /**\n * Options for finding a single record (first match)\n */\n findOne?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n /**\n * Options for finding multiple records\n */\n findMany?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * Options for creating a single record\n */\n createOne?: Partial<Parameters<T[\"create\"]>[0]>;\n /**\n * Options for creating multiple records\n */\n createMany?: Partial<Parameters<T[\"createMany\"]>[0]>;\n /**\n * Options for updating a single record\n */\n updateOne?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Options for updating multiple records\n */\n updateMany?: Partial<Parameters<T[\"updateMany\"]>[0]>;\n /**\n * Options for deleting a single record\n */\n deleteOne?: Partial<Parameters<T[\"delete\"]>[0]>;\n /**\n * Options for deleting multiple records\n */\n deleteMany?: Partial<Parameters<T[\"deleteMany\"]>[0]>;\n};\n\n/**\n * Type definition for Prisma query operations with flexible options\n * Conditionally provides auth-specific options when ModelName is \"auth\"\n * @template T - The Prisma model delegate type\n * @template ModelName - The model name (defaults to string for standard models)\n */\nexport type PrismaQueryOptions<\n T extends Record<string, any>,\n ModelName extends string = string,\n> = ModelName extends \"auth\"\n ? AuthPrismaQueryOptions<T>\n : BasePrismaQueryOptions<T>;\n/**\n * Interface defining the minimum structure required for Prisma model delegates\n * This allows us to constraint TModel without requiring Prisma imports\n */\nexport type PrismaModelDelegate = {\n create: (args: { data: never; [key: string]: never }) => Promise<any>;\n createMany: (args: { data: never; [key: string]: never }) => Promise<any>;\n findMany: (args: { [key: string]: never }) => Promise<any[]>;\n findFirst: (args: { where: never; [key: string]: never }) => Promise<any>;\n findUnique: (args: { where: never; [key: string]: never }) => Promise<any>;\n update: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n updateMany: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n delete: (args: { where: never; [key: string]: never }) => Promise<any>;\n deleteMany: (args: { where: never; [key: string]: never }) => Promise<any>;\n count: (args: { where: never; [key: string]: never }) => Promise<number>;\n};\n\nexport interface UserRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n roleId: string;\n role: AuthRole;\n user: User;\n userId: string;\n}\n\nexport interface AuthRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n name: string;\n permissions: AuthPermission[];\n userRoles: UserRole[];\n}\n\nexport enum AuthPermissionAction {\n Create = \"Create\",\n View = \"View\",\n Update = \"Update\",\n Delete = \"Delete\",\n}\n\nexport interface AuthPermission {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n resource: string;\n action: AuthPermissionAction;\n roleId: string;\n role: AuthRole;\n}\n\nexport interface User {\n id: string;\n isStaff: boolean;\n isSuperUser: boolean;\n password: string;\n passwordChangedAt?: Date;\n deletedSelfAccountAt: Date;\n isActive: boolean;\n roles?: UserRole[] | any[];\n role?: UserRole | any;\n}\n\nexport interface ArkosRequest<\n Params extends Record<string, any> = any,\n Body = any,\n Query extends Record<string, any> = any,\n> extends Request<Params, any, Body, Query> {\n /**\n * Authenticated user with additional fields\n */\n user?: User & Record<string, any>;\n\n /**\n * Fields to include in relational queries\n */\n relationFields?: Record<string, boolean>;\n\n /**\n * Prisma include options for related data\n */\n include?: Record<string, any>;\n\n /**\n * Data to be sent in the response\n */\n responseData?: Record<string, any> | null;\n\n /**\n * Additional context data\n */\n additionalData?: Record<string, any> | null;\n\n /**\n * HTTP status code for the response\n */\n responseStatus?: number;\n\n /**\n * Typed request body\n */\n body: Body;\n\n /**\n * Prisma query options (where, orderBy, select, etc.)\n */\n prismaQueryOptions?: Record<string, any>;\n\n /**\n * Typed query parameters\n */\n query: Query;\n\n /**\n * JWT token used in authentication process\n */\n accessToken?: string;\n\n /**\n * Query parameters after being handled and transformed by middleware\n */\n transformedQuery?: Record<string, any>;\n\n /**\n * Processed filters from APIFeatures.filters\n */\n filters?: Record<string, any>;\n\n /**\n * Name of the Prisma model being queried\n */\n modelName?: string;\n}\n\nexport interface ArkosResponse extends Response {}\nexport interface ArkosNextFunction extends NextFunction {}\nexport interface ArkosRequestHandler extends RequestHandler {}\nexport interface ArkosErrorRequestHandler extends ErrorRequestHandler {}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=new-arkos-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-arkos-config.js","sourceRoot":"","sources":["../../../src/types/new-arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import cors from \"cors\";\nimport express from \"express\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport cookieParser from \"cookie-parser\";\nimport compression from \"compression\";\nimport { Options as QueryParserOptions } from \"../utils/helpers/query-parser.helpers\";\nimport { ValidatorOptions } from \"class-validator\";\nimport { MsDuration } from \"../modules/auth/utils/helpers/auth.controller.helpers\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport type { ApiReferenceConfiguration } from \"@scalar/express-api-reference\" with { \"resolution-mode\": \"import\" };\nimport nodemailer from \"nodemailer\";\nimport { ModuleComponents } from \"../utils/dynamic-loader\";\nimport { ArkosRequestHandler } from \".\";\n\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosConfig = {\n /**\n * Allows to configure request configs\n */\n request?: {\n /**\n * Allows to configure request parameters\n */\n parameters?: {\n /**\n * Toggles allowing `VERY DANGEROUS` request paramateres under `req.query` for passing prisma query options.\n *\n * See more\n */\n allowDangerousPrismaQueryOptions?: boolean;\n };\n };\n /** Message you would like to send, as Json and 200 response when\n * ```curl\n * GET /api\n * ```\n *\n * ```json\n * { \"message\": \"Welcome to YourAppName\" }\n * ```\n *\n * default message is: Welcome to our Rest API generated by Arkos, find more about Arkos at www.arkosjs.com.\n *\n *\n * */\n welcomeMessage?: string;\n /**\n * Port where the application will run, can be set in 3 ways:\n *\n * 1. default is 8000\n * 2. PORT under environment variables (Lower precedence)\n * 3. this config option (Higher precedence)\n */\n port?: number | undefined;\n /**\n * Allows to listen on a different host than localhost only\n */\n host?: string;\n /**\n * Defines authentication related configurations, by default is undefined.\n *\n * See [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for details.\n */\n authentication?: {\n enabled?: boolean;\n /**\n * Defines whether to use Static or Dynamic Role-Based Acess Control\n *\n * Visit [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for more details.\n */\n mode: \"static\" | \"dynamic\";\n /**\n * Defines auth login related configurations to customize the api.\n */\n login?: {\n /**\n * Defines the field that will be used as username by the built-in auth system, by default arkos will look for the field \"username\" in your model User, hence when making login for example you must send:\n *\n * ```json\n * {\n * \"username\": \"johndoe\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n *\n * **Note:** You can also modify the usernameField on the fly by passing it to the request query parameters. example:\n *\n * ```curl\n * POST /api/auth/login?usernameField=email\n * ```\n *\n * See more at [www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds](https://www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds)\n *\n * By specifing here another field for username, for example passing \"email\", \"companyCode\" or something else your json will be like:\n *\n * **Example with email**\n *\n * ```json\n * {\n * \"email\": \"john.doe@example.com\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n */\n allowedUsernames?: string[];\n /** Defines wether to send the access token in response after login or only send as cookie, defeault is both.*/\n sendAccessTokenThrough?: \"cookie-only\" | \"response-only\" | \"both\";\n };\n /**\n * Specifies the regex pattern used by the authentication system to enforce password strength requirements.\n *\n * **Important**: If using validation libraries like Zod or class-validator, this will be completely overwritten.\n *\n * **Default**: ```/^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).+$/``` - Ensures the password contains at least one uppercase letter, one lowercase letter, and one numeric digit.\n *\n * **message**: (Optional) A custom error message to display when the password does not meet the required strength criteria.\n */\n passwordValidation?: { regex: RegExp; message?: string };\n /**\n * Allows to specify the request rate limit for all authentication endpoints but `/api/users/me`.\n * \n * #### Default\n *{\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n *@see This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n requestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * JWT (JSON Web Token) authentication configuration.\n *\n * You can override these values directly in code, or use environment variables:\n *\n * - `JWT_SECRET`: Secret used to sign and verify JWT tokens.\n * - `JWT_EXPIRES_IN`: Duration string or number indicating when the token should expire (e.g. \"30d\", 3600).\n * - `JWT_COOKIE_SECURE`: Whether the cookie is sent only over HTTPS. Default: `true` in production.\n * - `JWT_COOKIE_HTTP_ONLY`: Whether the cookie is HTTP-only. Default: `true`.\n * - `JWT_COOKIE_SAME_SITE`: Can be \"lax\", \"strict\", or \"none\". Defaults to \"lax\" in dev, \"none\" in prod.\n *\n * ⚠️ Values passed here take precedence over environment variables.\n */\n jwt?: {\n /** Secret key used for signing and verifying JWT tokens */\n secret?: string;\n /**\n * Duration after which the JWT token expires.\n * Accepts either a duration string (e.g. \"30d\", \"1h\") or a number in milliseconds.\n * Defaults to \"30d\" if not provided.\n */\n expiresIn?: MsDuration | number;\n\n /**\n * Configuration for the JWT cookie sent to the client\n */\n cookie?: {\n /**\n * Whether the cookie should be marked as secure (sent only over HTTPS).\n * Defaults to `true` in production and `false` in development.\n */\n secure?: boolean;\n\n /**\n * Whether the cookie should be marked as HTTP-only.\n * Default is `true` to prevent access via JavaScript.\n */\n httpOnly?: boolean;\n\n /**\n * Controls the SameSite attribute of the cookie.\n * Defaults to \"none\" in production and \"lax\" in development.\n * Options: \"lax\" | \"strict\" | \"none\"\n */\n sameSite?: \"lax\" | \"strict\" | \"none\";\n };\n };\n };\n /** Allows to customize and toggle the built-in validation, by default it is set to `false`. If true is passed it will use validation with the default resolver set to `class-validator` if you intend to change the resolver to `zod` do the following:\n *\n *```ts\n * // src/app.ts\n * import arkos from 'arkos'\n *\n * arkos.init({\n * validation: {\n * resolver: \"zod\"\n * }\n * })\n * ```\n *\n * @See [www.arkosjs.com/docs/core-concepts/request-data-validation](https://www.arkosjs.com/docs/core-concepts/request-data-validation) for more details.\n */\n validation?: {\n /**\n * Defines whether to use strict request validation, it means in every request using `ArkosRouter()` you must pass the validation options with all options (e.g: query, params, body, etc.).\n *\n * **How It Works:**\n * - If it is true, Arkos will require all the options a stated above on the routes and if you don't pass it will throw an error.\n * **What if you don't want to pass a validator to some options?**\n * - You will need to pass `undefined` to the validator option (see example below), this way Arkos will throw an error if something is passed to `req.query` if you passed undefined as validator into `validation.query`\n *\n * ```ts\n * import { ArkosRouter } from \"arkos\"\n *\n * const router = ArkosRouter()\n *\n * router.get({\n * route: \"/api/posts\",\n * validation: {\n * query: undefined\n * }\n * })\n *\n * ```\n */\n strict?: boolean;\n } & (\n | {\n resolver?: \"class-validator\";\n /**\n * ValidatorOptions to used while validating request data.\n *\n * **Default**:\n * ```ts\n * {\n * whitelist: true\n * }\n * ```\n */\n validationOptions?: ValidatorOptions;\n }\n | {\n resolver?: \"zod\";\n validationOptions?: Record<string, any>;\n }\n );\n /**\n * Defines file upload configurations\n *\n * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)\n */\n fileUpload?: {\n /**\n * Defiens the base file upload directory, default is set to /uploads (on root directory)\n *\n * When setting up a path dir always now that root directory will be the starting reference.\n *\n * #### Example\n * passing `../my-arkos-uploaded-files`\n *\n * Will save uploaded files one level outside the root dir inside `my-arkos-uploaded-files`\n *\n * NB: You must be aware of permissions on your server to acess files outside your project directory.\n *\n */\n baseUploadDir?: string;\n /**\n * Changes the default `/api/uploads` base route for accessing file upload route.\n *\n * #### IMPORTANT\n * Changing this will not affect the `baseUploadDir` folder. You can\n * pass here `/api/files/my-user-files` and `baseUploadDir` be `/uploaded-files`.\n *\n */\n baseRoute?: string;\n /**\n * Defines options for `express.static(somePath, someOptions)`\n *\n * #### Default:\n *\n * ```ts\n *{\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n }\n * ```\n * \n * By passing your custom options have in mind that it\n * will be deepmerged with the default.\n * \n * Visit [https://expressjs.com/en/4x/api.html#express.static](https://expressjs.com/en/4x/api.html#express.static) for more understanding.\n * \n */\n expressStatic?: Parameters<typeof express.static>[1];\n /**\n * Defines upload restrictions for each file type: image, video, document or other.\n *\n * #### Important:\n * Passing an object without overriding everything will only cause it\n * to be deepmerged with the default options.\n *\n * See [www.arkosjs.com/docs/api-reference/default-supported-upload-files](https://www.arkosjs.com/docs/api-reference/default-supported-upload-files) for detailed explanation about default values.\n * ```\n */\n restrictions?: {\n images?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n videos?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n documents?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n files?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n };\n };\n /**\n * Defines express middlewares configurations\n */\n middlewares?: {\n /**\n * Allows to define options for npm package compression\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/compression](https://www.npmjs.com/package/compression) for further details.\n */\n compression?: false | compression.CompressionOptions | ArkosRequestHandler;\n /**\n * Allows to specify the request rate limit for all endpoints.\n * \n * #### Default\n *```ts\n *{\n windowMs: 60 * 1000,\n limit: 1000,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n ```\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n * This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n rateLimit?: false | Partial<RateLimitOptions> | ArkosRequestHandler;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customHandler] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customHandler` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?:\n | false\n | {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: cors.CorsOptions;\n /**\n * If you would like to override the entire middleware\n *\n * see\n */\n customHandler?: cors.CorsOptionsDelegate;\n }\n | ArkosRequestHandler;\n /**\n * Defines options for the built-in express.json() middleware\n * Nothing is passed by default.\n */\n expressJson?:\n | false\n | Parameters<typeof express.json>[0]\n | ArkosRequestHandler;\n /**\n * Allows to pass paremeters to cookieParser from npm package cookie-parser\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.\n */\n cookieParser?:\n | false\n | Parameters<typeof cookieParser>\n | ArkosRequestHandler;\n /**\n * Options to define how query must be parsed.\n *\n * #### for example:\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n * \n * #### Default:\n * \n * {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n parseNumber: true,\n }\n * \n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n * \n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParser?: false | QueryParserOptions | ArkosRequestHandler;\n /**\n * Configuration for request logger middleware.\n *\n * Logs incoming HTTP requests with details such as method, URL, status code, and response time.\n * Useful for debugging and monitoring API traffic.\n */\n requestLogger?: false | ArkosRequestHandler;\n /**\n * Configuration for global error handler middleware.\n *\n * Catches and processes errors thrown in route handlers and other middlewares.\n * Provides a centralized way to format error responses and log errors.\n */\n errorHandler?: false | express.ErrorRequestHandler;\n };\n /**\n * Defines express/arkos routers configurations\n */\n routers?: {\n /**\n * Strict mode configuration for routing security\n *\n * @default false\n * - all CRUD + Auth (if using auth) endpoits are enabled and avialable by default.\n *\n * When enabled:\n * - If `true`: All CRUD endpoints start disabled and must be explicitly enabled\n * in each model's router configuration\n * - If `'no-bulk'`: Bulk operations (createMany, updateMany, deleteMany) are disabled\n * by default, while individual operations can be enabled per model\n *\n * This provides enhanced security by ensuring no routes are accidentally exposed.\n * Use this in production environments to follow the principle of least privilege.\n *\n * See documentation: https://www.arkosjs.com/docs/guide/security#strict-mode\n */\n strict?: boolean | \"no-bulk\";\n /**\n * Replace the default welcome endpoint handler\n * @param req Express request object\n * @param res Express response object\n * @param next Express next function\n */\n welcomeRoute?: false | ArkosRequestHandler;\n };\n /**\n * Allows to configure email configurations for sending emails through `emailService`\n *\n * See [www.arkosjs.com/docs/core-concepts/sending-emails](https://www.arkosjs.com/docs/core-concepts/sending-emails)\n */\n email?: {\n /**\n * Email name to used like:\n *\n * John Doe\\<john.doe@gmail.com>\n */\n name?: string;\n /**\n * Your email provider url\n */\n host: string;\n /**\n * Email provider SMTP port, Default is `465`\n */\n port?: number;\n /**\n * If smtp connection must be secure, Default is `true`\n */\n secure?: boolean;\n /**\n * Used to authenticate in your smtp server\n */\n auth: {\n /**\n * Email used for auth as well as sending emails\n */\n user: string;\n /**\n * Your SMTP password\n */\n pass: string;\n };\n } & Parameters<typeof nodemailer.createTransport>[0];\n /**\n * Defines Swagger and OpenApi specifications for auto generating swagger documentation UI using whether it is Prisma Schemas, Class-validator DTOs, Zod Schemas or JSON-Schemas.\n *\n * **Important**: Is worth mentioning that this works alongside `@scalar/express-api-reference` npm package, you define it's ApiReferenceConfiguration under ``. also consider checking the package documentation at []\n *\n * **Usage**\n *\n * ```ts\n * // src/app.ts\n *\n * import arkos from \"arkos\"\n *\n * arkos.init({\n * // other configs\n * swagger: {\n * mode: \"zod\",\n * options: {\n * defintion: {\n * info: {\n * openapi: \"3.0.0\",\n * title: \"API Generated By Arkos.js\",\n * description: \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n * }\n * }\n * }\n * }\n * })\n * ```\n * @see {@link https://www.arkosjs.com/docs/core-concepts/swagger-api-documentation}\n */\n swagger?: {\n /**\n * By default Arkos will disable API Documentation when the project is built `npm run build`, it does not matter what node environment is set. If you want to use it even after the `arkos build` command just set this to `true`.\n * */\n enableAfterBuild?: boolean;\n /**\n * Endpoint where the Swagger UI will be available.\n *\n * @default \"/api/api-docs\"\n */\n endpoint?: string;\n /**\n * Determines how your API schemas should be generated.\n *\n * - \"prisma\": Generates schemas based on Prisma models\n * - \"class-validator\": Uses class-validator and class-transformer DTO classes\n * - \"zod\": Uses OpenAPI-compliant schemas directly\n */\n mode: \"prisma\" | \"class-validator\" | \"zod\";\n /**\n * Allows `Arkos.js` to fallback to prisma schema and use them as json schema for defining request body and response data\n * when a given zod Schema or class-validator Class is not found to be transformed to json schema.\n *\n * @default false\n */\n strict?: boolean;\n /**\n * Defines your swagger configurations\n */\n options?: {\n /**\n * Swagger definition according to OpenAPI Specification.\n */\n definition?: {\n /**\n * OpenAPI version.\n *\n * @default \"3.0.0\"\n */\n openapi?: string;\n\n /**\n * Information about your API.\n */\n info?: {\n /**\n * Title of the API documentation.\n *\n *\n * @example \"My API\"\n *\n * @default \"API Generated By Arkos.js\"\n */\n title?: string;\n\n /**\n * Version of the API.\n *\n * @example \"1.0.0\"\n */\n version?: string;\n\n /**\n * Description of the API.\n *\n * @default \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n */\n description?: string;\n };\n\n /**\n * Server configurations for the API.\n *\n * @default [{ url: \"http://localhost:8000\", description: \"Development server\" }]\n *\n * This can be overridden automatically by Arkos based on CLI, .env, or `arkos.init()`.\n */\n servers?: {\n /**\n * Base URL of the server.\n *\n * @example \"http://localhost:8000\"\n */\n url: string;\n\n /**\n * Human-readable description of the server.\n *\n * @example \"Development Server\"\n */\n description?: string;\n }[];\n /**\n * Allows adding more paths for your OpenAPI documentation\n *\n * */\n paths?: OpenAPIV3.PathsObject;\n /**\n * (Optional) Additional metadata such as terms of service, contact, or license.\n *\n * See: https://swagger.io/specification/#infoObject\n */\n termsOfService?: string;\n contact?: {\n name?: string;\n url?: string;\n email?: string;\n };\n license?: {\n name: string;\n url?: string;\n };\n\n /**\n * Tags to group and describe endpoints.\n */\n tags?: {\n name: string;\n description?: string;\n }[];\n\n /**\n * Security definitions (e.g., Bearer Auth).\n */\n components?: {\n securitySchemes?: Record<string, any>;\n schemas?: Record<string, any>;\n };\n\n /**\n * Global security requirements.\n */\n security?: Array<Record<string, string[]>>;\n };\n\n /**\n * Glob patterns defining where Swagger should look for API route definitions and comments.\n *\n * @default \n * ```ts\n * [\"./src/routers/*.router.{ts,js}\", \"./src/modules/**\\/*.router.{ts,js}\"]\n ```\n *\n * Adjust depending on TypeScript or JavaScript usage.\n */\n apis?: string[];\n\n /**\n * Enables deep linking in the Swagger UI.\n *\n * @default true\n */\n deepLinking?: boolean;\n\n /**\n * Enable/disable the \"Try it out\" button globally.\n *\n * @default true\n */\n tryItOutEnabled?: boolean;\n\n /**\n * Whether to persist authorization data across page reloads.\n *\n * @default false\n */\n persistAuthorization?: boolean;\n };\n /**\n * Custom `@scalar/express-api-reference` package options.\n *\n * @see {@link https://guides.scalar.com/scalar/scalar-api-references/integrations/express}\n */\n scalarApiReferenceConfiguration?: Partial<ApiReferenceConfiguration>;\n };\n /**\n * Helps in debugging some of the variables values that are used inside arkos from dynamic loaded components towhat is used into the generated api.\n *\n */\n debugging?: {\n /**\n * Controls debugging over HTTP request level\n */\n requests?: {\n level?: 0 | 1 | 2 | 3;\n filter?: (\n | \"Query\"\n | \"Body\"\n | \"Params\"\n | \"TransformedQuery\"\n | \"ServiceArgs\"\n | \"FinalPrismaQueryArgs\"\n )[];\n };\n /**\n * Controls debugging over the dynamic loaded modules and it's components on app starting\n */\n dynamicLoader?: {\n /**\n * Adjusts logging details\n *\n * 1 - Loaded modules and list of it's components files\n * 2 - All from 1 and detailed inspection per module component\n * 3 - All from 1 and 2, plus the final router component after merged with autho generated router.\n */\n level?: 0 | 1 | 2 | 3;\n filters?: {\n /**\n * Allows filtering by specific modules.\n *\n * Supports only searching for the starting parts of the module name, e.g: If there is`user-profile`, `user`, `posts`, passing `[\"user\"]` will match both `user-profile` and `user`.\n */\n modules?: string[];\n /**\n * Allows filtering by component's names\n */\n components?: keyof ModuleComponents[];\n };\n };\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"router-config.js","sourceRoot":"","sources":["../../../src/types/router-config.ts"],"names":[],"mappings":"","sourcesContent":["export type RouterEndpoint =\n | \"createOne\"\n | \"findOne\"\n | \"updateOne\"\n | \"deleteOne\"\n | \"findMany\"\n | \"createMany\"\n | \"updateMany\"\n | \"deleteMany\";\n\n/**\n * Auth module specific endpoint types\n */\nexport type AuthRouterEndpoint =\n | \"getMe\"\n | \"updateMe\"\n | \"deleteMe\"\n | \"login\"\n | \"logout\"\n | \"signup\"\n | \"updatePassword\"\n | \"findManyAuthAction\"\n | \"findOneAuthAction\";\n\n/**\n * File upload module specific endpoint types\n */\nexport type FileUploadRouterEndpoint =\n | \"findFile\"\n | \"uploadFile\"\n | \"updateFile\"\n | \"deleteFile\";\n\n/**\n * Base router configuration for Prisma models\n */\ninterface PrismaBaseRouterConfig {\n /**\n * Allows to configure nested routes.\n *\n * **Example**\n *\n * ```curl\n * GET /api/authors/:id/posts\n * ```\n *\n * Returning only the fields belonging to the passed author id.\n *\n * See more at [https://www.arkosjs.com/docs/guide/adding-custom-routers#2-customizing-prisma-model-routers](https://www.arkosjs.com/docs/guide/adding-custom-routers#2-customizing-prisma-model-routers)\n */\n parent?: {\n /**\n * Your prisma model name in kebab-case and singular.\n */\n model?: string;\n /**\n * Defines the parentId field stores the Id relation. e.g authorId, categoryId, productId.\n *\n * **Note**: By default **Arkos** will look for modelNameId, modelName being the model specified in `parent.model`.\n *\n * **Example**\n * ```prisma\n * model Post {\n * // other fields\n * authorId String\n * author Author @relation(fields: [authorId], references: [id])\n * }\n * ```\n *\n * When passed *`parent.model`* to *`author`* **Arkos** will create an endpoint:\n * ```curl\n * GET /api/authors/:id/posts\n * GET /api/authors/:id/posts/:id\n * POST /api/authors/:id/posts\n * UPDATE /api/authors/:id/posts/:id\n * DELETE /api/authors/:id/posts/:id\n * POST /api/authors/:id/posts/many\n * UPDATE /api/authors/:id/posts/many\n * DELETE /api/authors/:id/posts/many\n * ```\n *\n * If you want to point to a different field pass it here.\n */\n foreignKeyField?: string;\n /**\n * Customizes what endpoints to be created.\n *\n * Default is \"*\" to generate all endpoints\n */\n endpoints?: \"*\" | RouterEndpoint[];\n };\n}\n\n/**\n * Allows to customize the generated routers\n *\n * See docs [https://www.arkosjs.com/docs/guide/adding-custom-routers#2-customizing-prisma-model-routers](https://www.arkosjs.com/docs/guide/adding-custom-routers#2-customizing-prisma-model-routers)\n */\nexport type RouterConfig<T extends string = string> = T extends \"auth\"\n ? {\n /**\n * Use to disable endpoints or the whole router\n *\n * If `true`, will disable all endpoints for the router\n */\n disable?:\n | boolean\n | {\n /**\n * If `true`, will disable:\n *\n * ```curl\n * GET /api/users/me\n * ```\n */\n getMe?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * PATCH /api/users/me\n * ```\n */\n updateMe?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * DELETE /api/users/me\n * ```\n */\n deleteMe?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * POST /api/auth/login\n * ```\n */\n login?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * DELETE /api/auth/logout\n * ```\n */\n logout?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * POST /api/auth/signup\n * ```\n */\n signup?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * POST /api/auth/update-password\n * ```\n */\n updatePassword?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * GET /api/auth-actions\n * ```\n */\n findManyAuthAction?: boolean;\n };\n }\n : T extends \"file-upload\"\n ? {\n /**\n * Use to disable endpoints or the whole router\n *\n * If `true`, will disable all endpoints for the router\n */\n disable?:\n | boolean\n | {\n /**\n * If `true`, will disable:\n *\n * ```curl\n * GET /{basePathname}*\n * ```\n */\n findFile?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * POST /{basePathname}:fileType\n * ```\n */\n uploadFile?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * PATCH /{basePathname}:fileType/:fileName\n * ```\n */\n updateFile?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * DELETE /{basePathname}:fileType/:fileName\n * ```\n */\n deleteFile?: boolean;\n };\n }\n : PrismaBaseRouterConfig & {\n /**\n * Use to disable endpoints or the whole router\n *\n * If `true`, will disable all endpoints for the router\n */\n disable?:\n | boolean\n | {\n /**\n * If `true`, will disable:\n *\n * ```curl\n * POST /api/[model-name]\n * ```\n */\n createOne?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * GET /api/[model-name]/:id\n * ```\n */\n findOne?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * PATCH /api/[model-name]:id\n * ```\n */\n updateOne?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * DELETE /api/[model-name]:id\n * ```\n */\n deleteOne?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * POST /api/[model-name]/many\n * ```\n */\n createMany?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * GET /api/[model-name]\n * ```\n */\n findMany?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * UPDATE /api/[model-name]/many\n * ```\n */\n updateMany?: boolean;\n /**\n * If `true`, will disable:\n *\n * ```curl\n * DELETE /api/[model-name]/many\n * ```\n */\n deleteMany?: boolean;\n };\n };\n"]}
1
+ {"version":3,"file":"router-config.js","sourceRoot":"","sources":["../../../src/types/router-config.ts"],"names":[],"mappings":"","sourcesContent":["import { ArkosRouteConfig } from \"../exports\";\n\nexport type RouterEndpoint =\n | \"createOne\"\n | \"findOne\"\n | \"updateOne\"\n | \"deleteOne\"\n | \"findMany\"\n | \"createMany\"\n | \"updateMany\"\n | \"deleteMany\";\n\nexport type AuthRouterEndpoint =\n | \"getMe\"\n | \"updateMe\"\n | \"deleteMe\"\n | \"login\"\n | \"logout\"\n | \"signup\"\n | \"updatePassword\"\n | \"findManyAuthAction\"\n | \"findOneAuthAction\";\n\nexport type FileUploadRouterEndpoint =\n | \"findFile\"\n | \"uploadFile\"\n | \"updateFile\"\n | \"deleteFile\";\n\ninterface PrismaBaseRouterConfig {\n parent?: {\n model?: string;\n foreignKeyField?: string;\n endpoints?: \"*\" | RouterEndpoint[];\n };\n}\n\ntype BaseRouterConfig = PrismaBaseRouterConfig & {\n /**\n * Backward compatibility (prior 1.4.0-beta) - disables/enables endpoints\n *\n * prefer to rather to use the following:\n *\n * ```ts\n * export const config = {\n * findMany: {\n * disabled: true\n * }\n * }\n * ```\n */\n disable?:\n | boolean\n | {\n [K in RouterEndpoint]?: boolean;\n };\n} & {\n [K in RouterEndpoint]?: Omit<ArkosRouteConfig, \"route\">;\n};\n\ntype AuthRouterConfig = {\n /**\n * Backward compatibility (prior 1.4.0-beta) - disables/enables endpoints\n *\n * prefer to rather to use the following:\n *\n * ```ts\n * export const config = {\n * getMe: {\n * disabled: true\n * }\n * }\n * ```\n */\n disable?:\n | boolean\n | {\n [K in AuthRouterEndpoint]?: boolean;\n };\n} & {\n [K in AuthRouterEndpoint]?: Omit<ArkosRouteConfig, \"route\">;\n};\n\ntype FileUploadRouterConfig = {\n /**\n * Backward compatibility (prior 1.4.0-beta) - disables/enables endpoints\n *\n * prefer to rather to use the following:\n *\n * ```ts\n * export const config = {\n * deleteFile: {\n * disabled: true\n * }\n * }\n * ```\n */\n disable?:\n | boolean\n | {\n [K in FileUploadRouterEndpoint]?: boolean;\n };\n} & {\n [K in FileUploadRouterEndpoint]?: Omit<ArkosRouteConfig, \"route\" | \"uploads\">;\n};\n\nexport type RouterConfig<T extends string = string> = T extends \"auth\"\n ? AuthRouterConfig\n : T extends \"file-upload\"\n ? FileUploadRouterConfig\n : BaseRouterConfig;\n"]}
@@ -4,6 +4,10 @@ import RouteConfigRegistry from "./route-config-registry.js";
4
4
  import { extractArkosRoutes, getMiddlewareStack } from "./utils/helpers/index.js";
5
5
  import { getArkosConfig } from "../../exports/index.js";
6
6
  import { catchAsync } from "../../exports/error-handler/index.js";
7
+ import zodToJsonSchema from "zod-to-json-schema";
8
+ import classValidatorToJsonSchema from "../../modules/swagger/utils/helpers/class-validator-to-json-schema.js";
9
+ import openApiSchemaConverter from "../../modules/swagger/utils/helpers/openapi-schema-converter.js";
10
+ import uploadManager from "./utils/helpers/upload-manager.js";
7
11
  export default function ArkosRouter() {
8
12
  const router = Router();
9
13
  return new Proxy(router, {
@@ -21,35 +25,44 @@ export default function ArkosRouter() {
21
25
  "options",
22
26
  ];
23
27
  if (httpMethods.includes(prop)) {
24
- return function (firstArg, ...handlers) {
25
- let route = firstArg;
26
- if (RouteConfigValidator.isArkosRouteConfig(firstArg)) {
27
- const config = firstArg;
28
- const method = prop;
29
- route = config.route;
30
- if (handlers.length > 0) {
31
- handlers = handlers.map((handler) => catchAsync(handler, {
32
- type: handler.length > 3 ? "error" : "normal",
33
- }));
34
- const finalHandler = handlers[handlers.length - 1];
35
- RouteConfigRegistry.register(finalHandler, config, method);
36
- }
37
- const arkosConfig = getArkosConfig();
38
- const validationConfig = arkosConfig.validation;
39
- const authenticationConfig = arkosConfig.authentication;
40
- if (validationConfig?.strict &&
41
- "validation" in config &&
42
- !config?.validation &&
43
- config?.validation !== undefined)
44
- throw Error("When using strict validation you must either pass { validation: false } in order to explicitly tell that no input will be received, or pass `undefined` for each input type e.g { validation: { query: undefined } } in order to deny the input of given request input.");
45
- if (!validationConfig?.resolver && config.validation)
46
- throw Error("Trying to pass validators into route config validation option without choosing a validation resolver under arkos.init({ validation: { resolver: '' } })");
47
- if (!authenticationConfig?.mode && config.authentication)
48
- throw Error("Trying to authenticate a route without choosing an authentication mode under arkos.init({ authentication: { mode: '' } })");
49
- handlers = [...getMiddlewareStack(config), ...handlers];
28
+ return function (config, ...handlers) {
29
+ if (config.disabled)
30
+ return;
31
+ const route = config.route;
32
+ if (!RouteConfigValidator.isArkosRouteConfig(config))
33
+ throw Error(`First argument of ArkosRouter().${prop}() must be a valid ArkosRouteConfig but recevied ${config}`);
34
+ const method = prop;
35
+ if (handlers.length > 0) {
36
+ handlers = handlers.map((handler) => {
37
+ return typeof handler === "function"
38
+ ? catchAsync(handler, {
39
+ type: handler.length > 3 ? "error" : "normal",
40
+ })
41
+ : handler.map((nesteHandler) => catchAsync(nesteHandler, {
42
+ type: handler.length > 3 ? "error" : "normal",
43
+ }));
44
+ });
45
+ const finalHandler = handlers[handlers.length - 1];
46
+ RouteConfigRegistry.register(finalHandler, config, method);
50
47
  }
51
- else
52
- throw Error(`First argument of ArkosRouter().${prop}() must be a valid ArkosRouteConfig but recevied ${firstArg}`);
48
+ const arkosConfig = getArkosConfig();
49
+ const validationConfig = arkosConfig.validation;
50
+ const authenticationConfig = arkosConfig.authentication;
51
+ const strictValidation = validationConfig?.strict;
52
+ if (strictValidation &&
53
+ (!("validation" in config) ||
54
+ ("validation" in config &&
55
+ !config.validation &&
56
+ config.validation !== undefined)))
57
+ throw Error("When using strict validation you must either pass { validation: false } in order to explicitly tell that no input will be received, or pass `undefined` for each input type e.g { validation: { query: undefined } } in order to deny the input of given request input.");
58
+ if (!validationConfig?.resolver && config.validation)
59
+ throw Error("Trying to pass validators into route config validation option without choosing a validation resolver under arkos.init({ validation: { resolver: '' } })");
60
+ if (config.authentication && !authenticationConfig?.mode)
61
+ throw Error("Trying to authenticate a route without choosing an authentication mode under arkos.init({ authentication: { mode: '' } })");
62
+ handlers = [...getMiddlewareStack(config), ...handlers];
63
+ if (config.experimental?.uploads &&
64
+ config.experimental.uploads.deleteOnError !== false)
65
+ handlers.push(catchAsync(uploadManager.handleFileCleanup(config.experimental.uploads), { type: "error" }));
53
66
  return originalMethod.call(target, route, ...handlers);
54
67
  };
55
68
  }
@@ -59,27 +72,66 @@ export default function ArkosRouter() {
59
72
  }
60
73
  export function generateOpenAPIFromApp(app) {
61
74
  const routes = extractArkosRoutes(app);
62
- const paths = {};
75
+ const arkosConfig = getArkosConfig();
76
+ let paths = {};
63
77
  routes.forEach(({ path, method, config }) => {
64
- if (config?.openapi === false)
78
+ if (config?.experimental?.openapi === false)
65
79
  return;
66
80
  if (!paths[path])
67
81
  paths[path] = {};
68
- if (typeof config?.openapi === "boolean") {
82
+ if (typeof config?.experimental?.openapi === "boolean") {
69
83
  config = {
70
84
  ...config,
71
- openapi: {},
85
+ experimental: {
86
+ ...config.experimental,
87
+ openapi: {},
88
+ },
72
89
  };
73
90
  }
74
- const openapi = typeof config?.openapi === "object" && config.openapi !== null
75
- ? config.openapi
91
+ const openapi = typeof config?.experimental?.openapi === "object" &&
92
+ config.experimental.openapi !== null
93
+ ? config.experimental.openapi
76
94
  : {};
95
+ const validatorToJsonSchema = arkosConfig?.validation?.resolver === "zod"
96
+ ? zodToJsonSchema
97
+ : classValidatorToJsonSchema;
98
+ let parameters = [];
99
+ const validationToParameterMapping = {
100
+ query: "query",
101
+ params: "path",
102
+ headers: "header",
103
+ cookies: "cookie",
104
+ };
105
+ if (typeof config?.validation !== "boolean" && config?.validation) {
106
+ for (const [key, val] of Object.entries(config?.validation)) {
107
+ if (["body"].includes(key))
108
+ continue;
109
+ if ((config?.validation)[key]) {
110
+ const jsonSchema = validatorToJsonSchema(val);
111
+ const params = openApiSchemaConverter.jsonSchemaToOpeApiParameters(validationToParameterMapping[key], jsonSchema);
112
+ parameters.push(...params);
113
+ }
114
+ }
115
+ }
116
+ const convertedOpenAPI = openApiSchemaConverter.convertOpenAPIConfig(openapi);
77
117
  paths[path][method.toLowerCase()] = {
78
118
  summary: openapi?.summary || `${method} ${path}`,
79
119
  description: openapi?.description || `${method} ${path}`,
80
- tags: openapi?.tags || ["Others"],
81
- operationId: `${method}:${path}`,
82
- ...openapi,
120
+ tags: openapi?.tags || ["Defaults"],
121
+ operationId: `${method.toLowerCase()}:${path}`,
122
+ parameters: [...(convertedOpenAPI.parameters || []), ...parameters],
123
+ ...(!convertedOpenAPI.requestBody &&
124
+ config?.validation &&
125
+ config?.validation?.body && {
126
+ requestBody: {
127
+ content: {
128
+ "application/json": {
129
+ schema: validatorToJsonSchema(config?.validation?.body),
130
+ },
131
+ },
132
+ },
133
+ }),
134
+ ...convertedOpenAPI,
83
135
  };
84
136
  });
85
137
  return paths;
@@ -1 +1 @@
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AAC;AACrB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,GAAQ;IAC7C,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,KAAK,GAGP,EAAE,CAAC;IAEP,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE;QAC1C,IAAI,MAAM,EAAE,OAAO,KAAK,KAAK;YAAE,OAAO;QAEtC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnC,IAAI,OAAO,MAAM,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;YACzC,MAAM,GAAG;gBACP,GAAG,MAAM;gBACT,OAAO,EAAE,EAAE;aACZ,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,GACX,OAAO,MAAM,EAAE,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI;YAC5D,CAAC,CAAC,MAAM,CAAC,OAAO;YAChB,CAAC,CAAC,EAAE,CAAC;QAET,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,GAAG;YAClC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,GAAG,MAAM,IAAI,IAAI,EAAE;YAChD,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,GAAG,MAAM,IAAI,IAAI,EAAE;YACxD,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC;YACjC,WAAW,EAAE,GAAG,MAAM,IAAI,IAAI,EAAE;YAChC,GAAG,OAAO;SACX,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { Router } from \"express\";\nimport { IArkosRouter, ArkosRouteConfig } from \"./types\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport RouteConfigValidator from \"./route-config-validator\";\nimport RouteConfigRegistry from \"./route-config-registry\";\nimport { extractArkosRoutes, getMiddlewareStack } from \"./utils/helpers\";\nimport { getArkosConfig } from \"../../exports\";\nimport { catchAsync } from \"../../exports/error-handler\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../types\";\n\n/**\n * Creates an enhanced Express Router with features like OpenAPI documentation capabilities and smart data validation.\n *\n * The ArkosRouter extends the standard Express Router with the ability to\n * automatically capture OpenAPI metadata from route configurations.\n *\n * @example\n * const router = ArkosRouter();\n *\n * router.get(\n * {\n * route: \"/users/:id\",\n * openapi: {\n * summary: \"Get user by ID\",\n * tags: [\"Users\"]\n * }\n * },\n * (req, res) => { ... }\n * );\n *\n * @returns {IArkosRouter} A proxied Express Router instance with enhanced OpenAPI capabilities\n *\n * @see {@link ArkosRouteConfig} for configuration options\n */\nexport default function ArkosRouter(): IArkosRouter {\n const router: IArkosRouter = Router();\n\n return new Proxy(router, {\n get(target, prop, receiver) {\n const originalMethod = Reflect.get(target, prop, receiver);\n\n const httpMethods = [\n \"get\",\n \"post\",\n \"put\",\n \"patch\",\n \"delete\",\n \"all\",\n \"head\",\n \"trace\",\n \"options\",\n ];\n\n if (httpMethods.includes(prop as string)) {\n return function (\n firstArg: any,\n ...handlers: (ArkosRequestHandler | ArkosErrorRequestHandler)[]\n ) {\n let route = firstArg;\n if (RouteConfigValidator.isArkosRouteConfig(firstArg)) {\n const config = firstArg as ArkosRouteConfig;\n const method = prop as string;\n route = config.route;\n\n if (handlers.length > 0) {\n handlers = handlers.map((handler) =>\n catchAsync(handler, {\n type: handler.length > 3 ? \"error\" : \"normal\",\n })\n );\n\n const finalHandler = handlers[handlers.length - 1];\n RouteConfigRegistry.register(finalHandler, config, method);\n }\n\n const arkosConfig = getArkosConfig();\n const validationConfig = arkosConfig.validation;\n const authenticationConfig = arkosConfig.authentication;\n\n if (\n validationConfig?.strict &&\n \"validation\" in config &&\n !config?.validation &&\n config?.validation !== undefined\n )\n throw Error(\n \"When using strict validation you must either pass { validation: false } in order to explicitly tell that no input will be received, or pass `undefined` for each input type e.g { validation: { query: undefined } } in order to deny the input of given request input.\"\n );\n\n if (!validationConfig?.resolver && config.validation)\n throw Error(\n \"Trying to pass validators into route config validation option without choosing a validation resolver under arkos.init({ validation: { resolver: '' } })\"\n );\n\n if (!authenticationConfig?.mode && config.authentication)\n throw Error(\n \"Trying to authenticate a route without choosing an authentication mode under arkos.init({ authentication: { mode: '' } })\"\n );\n\n handlers = [...getMiddlewareStack(config), ...handlers];\n } else\n throw Error(\n `First argument of ArkosRouter().${prop as string}() must be a valid ArkosRouteConfig but recevied ${firstArg}`\n );\n\n return originalMethod.call(target, route, ...handlers);\n };\n }\n return originalMethod;\n },\n }) as IArkosRouter;\n}\n\nexport function generateOpenAPIFromApp(app: any) {\n const routes = extractArkosRoutes(app);\n const paths: Record<\n string,\n Record<string, Partial<OpenAPIV3.OperationObject>>\n > = {};\n\n routes.forEach(({ path, method, config }) => {\n if (config?.openapi === false) return;\n\n if (!paths[path]) paths[path] = {};\n\n if (typeof config?.openapi === \"boolean\") {\n config = {\n ...config,\n openapi: {},\n };\n }\n\n const openapi =\n typeof config?.openapi === \"object\" && config.openapi !== null\n ? config.openapi\n : {};\n\n paths[path][method.toLowerCase()] = {\n summary: openapi?.summary || `${method} ${path}`,\n description: openapi?.description || `${method} ${path}`,\n tags: openapi?.tags || [\"Others\"],\n operationId: `${method}:${path}`,\n ...openapi,\n };\n });\n\n return paths;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/arkos-router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAC5D,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CA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AW,IAAI,GAAG,MAAM,IAAI,IAAI,EAAE;YACxD,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC;YACnC,WAAW,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE;YAC9C,UAAU,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,GAAG,UAAU,CAAC;YACnE,GAAG,CAAC,CAAC,gBAAgB,CAAC,WAAW;gBAC/B,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,UAAU,EAAE,IAAI,IAAI;gBAC1B,WAAW,EAAE;oBACX,OAAO,EAAE;wBACP,kBAAkB,EAAE;4BAClB,MAAM,EAAE,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAW,CAAC;yBAC/D;qBACF;iBACF;aACF,CAAC;YACJ,GAAG,gBAAgB;SACpB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { Router } from \"express\";\nimport { IArkosRouter, ArkosRouteConfig } from \"./types\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport RouteConfigValidator from \"./route-config-validator\";\nimport RouteConfigRegistry from \"./route-config-registry\";\nimport { extractArkosRoutes, getMiddlewareStack } from \"./utils/helpers\";\nimport { getArkosConfig } from \"../../exports\";\nimport { catchAsync } from \"../../exports/error-handler\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../types\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport classValidatorToJsonSchema from \"../../modules/swagger/utils/helpers/class-validator-to-json-schema\";\nimport openApiSchemaConverter from \"../../modules/swagger/utils/helpers/openapi-schema-converter\";\nimport uploadManager from \"./utils/helpers/upload-manager\";\n\n/**\n * Creates an enhanced Express Router with features like OpenAPI documentation capabilities and smart data validation.\n *\n * The ArkosRouter extends the standard Express Router with the ability to\n * automatically capture OpenAPI metadata from route configurations.\n *\n * @example\n * const router = ArkosRouter();\n *\n * router.get(\n * {\n * route: \"/users/:id\",\n * openapi: {\n * summary: \"Get user by ID\",\n * tags: [\"Users\"]\n * }\n * },\n * (req, res) => { ... }\n * );\n *\n * @returns {IArkosRouter} A proxied Express Router instance with enhanced OpenAPI capabilities\n *\n * @see {@link ArkosRouteConfig} for configuration options\n */\nexport default function ArkosRouter(): IArkosRouter {\n const router: IArkosRouter = Router();\n\n return new Proxy(router, {\n get(target, prop, receiver) {\n const originalMethod = Reflect.get(target, prop, receiver);\n\n const httpMethods = [\n \"get\",\n \"post\",\n \"put\",\n \"patch\",\n \"delete\",\n \"all\",\n \"head\",\n \"trace\",\n \"options\",\n ];\n\n type ArkosAnyRequestHandler =\n | ArkosRequestHandler\n | ArkosErrorRequestHandler;\n\n if (httpMethods.includes(prop as string)) {\n return function (\n config: ArkosRouteConfig,\n ...handlers: ArkosAnyRequestHandler[]\n ) {\n if (config.disabled) return;\n\n const route = config.route;\n\n if (!RouteConfigValidator.isArkosRouteConfig(config))\n throw Error(\n `First argument of ArkosRouter().${prop as string}() must be a valid ArkosRouteConfig but recevied ${config}`\n );\n\n const method = prop as string;\n\n if (handlers.length > 0) {\n handlers = handlers.map(\n (handler: ArkosAnyRequestHandler | ArkosAnyRequestHandler[]) => {\n return typeof handler === \"function\"\n ? catchAsync(handler, {\n type: handler.length > 3 ? \"error\" : \"normal\",\n })\n : handler.map((nesteHandler: any) =>\n catchAsync(nesteHandler, {\n type: handler.length > 3 ? \"error\" : \"normal\",\n })\n );\n }\n );\n\n const finalHandler = handlers[handlers.length - 1];\n RouteConfigRegistry.register(finalHandler, config, method);\n }\n\n const arkosConfig = getArkosConfig();\n const validationConfig = arkosConfig.validation;\n const authenticationConfig = arkosConfig.authentication;\n const strictValidation = validationConfig?.strict;\n\n if (\n strictValidation &&\n (!(\"validation\" in config) ||\n (\"validation\" in config &&\n !config.validation &&\n config.validation !== undefined))\n )\n throw Error(\n \"When using strict validation you must either pass { validation: false } in order to explicitly tell that no input will be received, or pass `undefined` for each input type e.g { validation: { query: undefined } } in order to deny the input of given request input.\"\n );\n\n if (!validationConfig?.resolver && config.validation)\n throw Error(\n \"Trying to pass validators into route config validation option without choosing a validation resolver under arkos.init({ validation: { resolver: '' } })\"\n );\n\n if (config.authentication && !authenticationConfig?.mode)\n throw Error(\n \"Trying to authenticate a route without choosing an authentication mode under arkos.init({ authentication: { mode: '' } })\"\n );\n\n handlers = [...getMiddlewareStack(config), ...handlers];\n\n if (\n config.experimental?.uploads &&\n config.experimental.uploads.deleteOnError !== false\n )\n handlers.push(\n catchAsync(\n uploadManager.handleFileCleanup(config.experimental.uploads),\n { type: \"error\" }\n )\n );\n\n return originalMethod.call(target, route, ...handlers);\n };\n }\n // }\n return originalMethod;\n },\n }) as IArkosRouter;\n}\n\nexport function generateOpenAPIFromApp(app: any) {\n const routes = extractArkosRoutes(app);\n const arkosConfig = getArkosConfig();\n\n let paths: Record<\n string,\n Record<string, Partial<OpenAPIV3.OperationObject>>\n > = {};\n\n routes.forEach(({ path, method, config }) => {\n if (config?.experimental?.openapi === false) return;\n\n if (!paths[path]) paths[path] = {};\n\n if (typeof config?.experimental?.openapi === \"boolean\") {\n config = {\n ...config,\n experimental: {\n ...config.experimental,\n openapi: {},\n },\n };\n }\n\n const openapi =\n typeof config?.experimental?.openapi === \"object\" &&\n config.experimental.openapi !== null\n ? config.experimental.openapi\n : {};\n\n const validatorToJsonSchema =\n arkosConfig?.validation?.resolver === \"zod\"\n ? zodToJsonSchema\n : classValidatorToJsonSchema;\n\n let parameters = [];\n const validationToParameterMapping = {\n query: \"query\",\n params: \"path\",\n headers: \"header\",\n cookies: \"cookie\",\n };\n\n if (typeof config?.validation !== \"boolean\" && config?.validation) {\n for (const [key, val] of Object.entries(config?.validation)) {\n if ([\"body\"].includes(key)) continue;\n if ((config?.validation as any)[key]) {\n const jsonSchema = validatorToJsonSchema(val as any);\n const params = openApiSchemaConverter.jsonSchemaToOpeApiParameters(\n (validationToParameterMapping as any)[key],\n jsonSchema\n );\n parameters.push(...params);\n }\n }\n }\n\n const convertedOpenAPI =\n openApiSchemaConverter.convertOpenAPIConfig(openapi);\n\n (paths as any)[path][method.toLowerCase()] = {\n summary: openapi?.summary || `${method} ${path}`,\n description: openapi?.description || `${method} ${path}`,\n tags: openapi?.tags || [\"Defaults\"],\n operationId: `${method.toLowerCase()}:${path}`,\n parameters: [...(convertedOpenAPI.parameters || []), ...parameters],\n ...(!convertedOpenAPI.requestBody &&\n config?.validation &&\n config?.validation?.body && {\n requestBody: {\n content: {\n \"application/json\": {\n schema: validatorToJsonSchema(config?.validation?.body as any),\n },\n },\n },\n }),\n ...convertedOpenAPI,\n };\n });\n\n return paths;\n}\n"]}
@@ -9,9 +9,9 @@ export default class RouteConfigValidator {
9
9
  const swaggerMode = arkosConfig?.swagger?.mode;
10
10
  if (config.validation) {
11
11
  const validators = [
12
- { key: "query", schema: config.validation.query },
13
- { key: "body", schema: config.validation.body },
14
- { key: "params", schema: config.validation.params },
12
+ { key: "query", schema: config.validation?.query },
13
+ { key: "body", schema: config.validation?.body },
14
+ { key: "params", schema: config.validation?.params },
15
15
  ];
16
16
  for (const { key, schema } of validators) {
17
17
  if (!schema)
@@ -28,8 +28,9 @@ export default class RouteConfigValidator {
28
28
  }
29
29
  }
30
30
  }
31
- if (config.validation && typeof config.openapi === "object") {
32
- const openapi = config.openapi;
31
+ if (config.validation && typeof config.experimental?.openapi === "object") {
32
+ const openapi = config.experimental
33
+ .openapi;
33
34
  if (config.validation.query &&
34
35
  openapi.parameters?.some((p) => p.in === "query")) {
35
36
  throw new Error("Duplicate query validation definitions. " +
@@ -37,14 +38,14 @@ export default class RouteConfigValidator {
37
38
  "They will be automatically migrated to OpenAPI specification.");
38
39
  }
39
40
  if (config.validation.params &&
40
- openapi.parameters?.some((p) => p.in === "path")) {
41
+ openapi.parameters?.some((p) => p.in === "params")) {
41
42
  throw new Error("Duplicate path parameter validation definitions. " +
42
43
  "When using validation.params, do not define path parameters in openapi.parameters. " +
43
44
  "They will be automatically migrated to OpenAPI specification.");
44
45
  }
45
46
  if (config.validation.body && openapi.requestBody) {
46
47
  throw new Error("Duplicate request body validation definitions. " +
47
- "When using validation.body, do not define requestBody in openapi. " +
48
+ "When using validation.body, do not define openapi.requestBody in openapi. " +
48
49
  "It will be automatically migrated to OpenAPI specification.");
49
50
  }
50
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"route-config-validator.js","sourceRoot":"","sources":["../../../../src/utils/arkos-router/route-config-validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC,MAAM,CAAC,kBAAkB,CAAC,GAAQ;QAChC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,IAAI,GAAG,CAAC;IACnE,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,MAAwB;QACtC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;QACrC,MAAM,WAAW,GAAG,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC;QAE/C,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,MAAM,UAAU,GAAG;gBACjB,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE;gBACjD,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;gBAC/C,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE;aACpD,CAAC;YAEF,KAAK,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;gBACzC,IAAI,CAAC,MAAM;oBAAE,SAAS;gBAEtB,MAAM,KAAK,G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A6D,CAChE,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { ArkosRouteConfig } from \"./types\";\nimport { isClass, isZodSchema } from \"../dynamic-loader\";\nimport { getArkosConfig } from \"../../exports\";\nimport { OpenAPIV3 } from \"openapi-types\";\n\nexport default class RouteConfigValidator {\n static isArkosRouteConfig(arg: any): arg is ArkosRouteConfig {\n return typeof arg === \"object\" && arg !== null && \"route\" in arg;\n }\n\n static validate(config: ArkosRouteConfig) {\n const arkosConfig = getArkosConfig();\n const swaggerMode = arkosConfig?.swagger?.mode;\n\n if (config.validation) {\n const validators = [\n { key: \"query\", schema: config.validation.query },\n { key: \"body\", schema: config.validation.body },\n { key: \"params\", schema: config.validation.params },\n ];\n\n for (const { key, schema } of validators) {\n if (!schema) continue;\n\n const isZod = isZodSchema(schema);\n const isClassValidator = isClass(schema);\n\n if (isZod && swaggerMode !== \"zod\") {\n throw new Error(\n `Zod schema used in validation.${key} but Swagger mode is '${swaggerMode}'. ` +\n `Zod schemas are only supported when swagger.mode is 'zod'.`\n );\n }\n\n if (isClassValidator && swaggerMode !== \"class-validator\") {\n throw new Error(\n `Class validator used in validation.${key} but Swagger mode is '${swaggerMode}'. ` +\n `Class validators are only supported when swagger.mode is 'class-validator'.`\n );\n }\n }\n }\n\n if (config.validation && typeof config.openapi === \"object\") {\n const openapi = config.openapi as Partial<OpenAPIV3.OperationObject>;\n\n if (\n config.validation.query &&\n openapi.parameters?.some((p: any) => p.in === \"query\")\n ) {\n throw new Error(\n \"Duplicate query validation definitions. \" +\n \"When using validation.query, do not define query parameters in openapi.parameters. \" +\n \"They will be automatically migrated to OpenAPI specification.\"\n );\n }\n\n if (\n config.validation.params &&\n openapi.parameters?.some((p: any) => p.in === \"path\")\n ) {\n throw new Error(\n \"Duplicate path parameter validation definitions. \" +\n \"When using validation.params, do not define path parameters in openapi.parameters. \" +\n \"They will be automatically migrated to OpenAPI specification.\"\n );\n }\n\n if (config.validation.body && openapi.requestBody) {\n throw new Error(\n \"Duplicate request body validation definitions. \" +\n \"When using validation.body, do not define requestBody in openapi. \" +\n \"It will be automatically migrated to OpenAPI specification.\"\n );\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"route-config-validator.js","sourceRoot":"","sources":["../../../../src/utils/arkos-router/route-config-validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC,MAAM,CAAC,kBAAkB,CAAC,GAAQ;QAChC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,IAAI,GAAG,CAAC;IACnE,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,MAAwB;QACtC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;QACrC,MAAM,WAAW,GAAG,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC;QAE/C,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,MAAM,UAAU,GAAG;gBACjB,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE;gBAClD,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE;gBAChD,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE;aACrD,CAAC;YAEF,KAAK,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;gBACzC,IAAI,CAAC,MAAM;oBAAE,SAAS;gBAEtB,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;gBAClC,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;gBAEzC,IAAI,KAAK,IAAI,WA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port { isClass, isZodSchema } from \"../dynamic-loader\";\nimport { getArkosConfig } from \"../../exports\";\nimport { OpenAPIV3 } from \"openapi-types\";\n\nexport default class RouteConfigValidator {\n static isArkosRouteConfig(arg: any): arg is ArkosRouteConfig {\n return typeof arg === \"object\" && arg !== null && \"route\" in arg;\n }\n\n static validate(config: ArkosRouteConfig) {\n const arkosConfig = getArkosConfig();\n const swaggerMode = arkosConfig?.swagger?.mode;\n\n if (config.validation) {\n const validators = [\n { key: \"query\", schema: config.validation?.query },\n { key: \"body\", schema: config.validation?.body },\n { key: \"params\", schema: config.validation?.params },\n ];\n\n for (const { key, schema } of validators) {\n if (!schema) continue;\n\n const isZod = isZodSchema(schema);\n const isClassValidator = isClass(schema);\n\n if (isZod && swaggerMode !== \"zod\") {\n throw new Error(\n `Zod schema used in validation.${key} but Swagger mode is '${swaggerMode}'. ` +\n `Zod schemas are only supported when swagger.mode is 'zod'.`\n );\n }\n\n if (isClassValidator && swaggerMode !== \"class-validator\") {\n throw new Error(\n `Class validator used in validation.${key} but Swagger mode is '${swaggerMode}'. ` +\n `Class validators are only supported when swagger.mode is 'class-validator'.`\n );\n }\n }\n }\n\n if (config.validation && typeof config.experimental?.openapi === \"object\") {\n const openapi = config.experimental\n .openapi as Partial<OpenAPIV3.OperationObject>;\n\n if (\n config.validation.query &&\n openapi.parameters?.some((p: any) => p.in === \"query\")\n ) {\n throw new Error(\n \"Duplicate query validation definitions. \" +\n \"When using validation.query, do not define query parameters in openapi.parameters. \" +\n \"They will be automatically migrated to OpenAPI specification.\"\n );\n }\n\n if (\n config.validation.params &&\n openapi.parameters?.some((p: any) => p.in === \"params\")\n ) {\n throw new Error(\n \"Duplicate path parameter validation definitions. \" +\n \"When using validation.params, do not define path parameters in openapi.parameters. \" +\n \"They will be automatically migrated to OpenAPI specification.\"\n );\n }\n\n if (config.validation.body && openapi.requestBody) {\n throw new Error(\n \"Duplicate request body validation definitions. \" +\n \"When using validation.body, do not define openapi.requestBody in openapi. \" +\n \"It will be automatically migrated to OpenAPI specification.\"\n );\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utils/arkos-router/types/index.ts"],"names":[],"mappings":"","sourcesContent":["import { ErrorRequestHandler, IRouter, RequestHandler } from \"express\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport { ZodSchema } from \"zod\";\n\ntype MethodHandler = (\n configOrPath: ArkosRouteConfig,\n ...handlers: (RequestHandler | ErrorRequestHandler)[]\n) => IArkosRouter;\n\nexport interface IArkosRouter\n extends Omit<\n IRouter,\n | \"get\"\n | \"post\"\n | \"put\"\n | \"patch\"\n | \"delete\"\n | \"options\"\n | \"head\"\n | \"trace\"\n | \"all\"\n > {\n get: MethodHandler;\n post: MethodHandler;\n put: MethodHandler;\n patch: MethodHandler;\n delete: MethodHandler;\n options: MethodHandler;\n head: MethodHandler;\n trace: MethodHandler;\n all: MethodHandler;\n}\n\nexport interface ArkosRouteConfig {\n route: string;\n authentication?:\n | boolean\n | {\n resource: string;\n action: string;\n rule?: any;\n };\n validation?:\n | undefined\n | {\n query?: ZodSchema | (new (...args: any[]) => object) | undefined;\n body?: ZodSchema | (new (...args: any[]) => object) | undefined;\n params?: ZodSchema | (new (...args: any[]) => object) | undefined;\n };\n openapi?: boolean | Partial<OpenAPIV3.OperationObject>;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utils/arkos-router/types/index.ts"],"names":[],"mappings":"","sourcesContent":["import { IRouter } from \"express\";\nimport { ZodSchema } from \"zod\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport { Options as QueryParserOptions } from \"../../../utils/helpers/query-parser.helpers\";\nimport { DetailedAccessControlRule } from \"../../../types/auth\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../../types\";\nimport express from \"express\";\nimport compression from \"compression\";\nimport { OpenApiConfig } from \"./openapi-config\";\nimport { UploadConfig } from \"./upload-config\";\n\n/**\n * Handler function for HTTP methods that accepts route configuration and request handlers.\n *\n * @param {ArkosRouteConfig} config - The route configuration object.\n * @param {...(ArkosRequestHandler | ArkosErrorRequestHandler)[]} handlers - Request and error handlers for the route.\n * @returns {IRouter} The Express router instance.\n */\ntype MethodHandler = (\n config: ArkosRouteConfig,\n ...handlers: (ArkosRequestHandler | ArkosErrorRequestHandler)[]\n) => IRouter;\n\n/**\n * Creates an enhanced Express Router with features like OpenAPI documentation capabilities and smart data validation.\n *\n * The ArkosRouter extends the standard Express Router with the ability to\n * automatically capture OpenAPI metadata from route configurations.\n *\n * @example\n * const router = ArkosRouter();\n *\n * router.get(\n * {\n * route: \"/users/:id\",\n * openapi: {\n * summary: \"Get user by ID\",\n * tags: [\"Users\"]\n * }\n * },\n * (req, res) => { ... }\n * );\n *\n * @returns {IArkosRouter} A proxied Express Router instance with enhanced OpenAPI capabilities\n *\n * @see {@link ArkosRouteConfig} for configuration options\n */\nexport interface IArkosRouter\n extends Omit<\n IRouter,\n | \"get\"\n | \"post\"\n | \"put\"\n | \"patch\"\n | \"delete\"\n | \"options\"\n | \"head\"\n | \"trace\"\n | \"all\"\n > {\n /** GET method handler with route configuration support */\n get: MethodHandler;\n /** POST method handler with route configuration support */\n post: MethodHandler;\n /** PUT method handler with route configuration support */\n put: MethodHandler;\n /** PATCH method handler with route configuration support */\n patch: MethodHandler;\n /** DELETE method handler with route configuration support */\n delete: MethodHandler;\n /** OPTIONS method handler with route configuration support */\n options: MethodHandler;\n /** HEAD method handler with route configuration support */\n head: MethodHandler;\n /** TRACE method handler with route configuration support */\n trace: MethodHandler;\n /** ALL methods handler with route configuration support */\n all: MethodHandler;\n}\n\n/**\n * Configuration object for defining routes in Arkos.js.\n */\nexport interface ArkosRouteConfig {\n /**\n * Disables the route by not mounting it internally.\n */\n disabled?: boolean;\n /**\n * The URL path pattern for the route.\n *\n * @example \"/api/users/:id\"\n */\n route: string;\n /**\n * Authentication and authorization configuration.\n *\n * @remarks\n * - Set to `true` to require authentication without specific permissions.\n * - Set to `false` or omit to allow unauthenticated access.\n * - Provide an object to specify resource-based access control with resource name, action, and optional custom rules.\n */\n authentication?:\n | boolean\n | {\n resource: string;\n action: string;\n rule?: DetailedAccessControlRule | string[];\n };\n /**\n * Request validation configuration using Zod schemas or class constructors.\n *\n * @remarks\n * - Set to `false` to disable all validation.\n * - Provide an object with `query`, `body`, and/or `params` properties to validate specific parts of the request.\n * - Each property accepts a Zod schema, a class constructor, or `false` to disable validation for that part.\n */\n validation?:\n | false\n | {\n query?: ZodSchema | (new (...args: any[]) => object) | false;\n body?: ZodSchema | (new (...args: any[]) => object) | false;\n params?: ZodSchema | (new (...args: any[]) => object) | false;\n };\n\n /**\n * Rate limiting configuration for this route.\n *\n * @see {@link https://www.npmjs.com/package/express-rate-limit express-rate-limit} for available options.\n */\n rateLimit?: Partial<RateLimitOptions>;\n\n /**\n * Allows to define options for npm package compression.\n * Nothing is passed by default.\n *\n * @see {@link https://www.npmjs.com/package/compression compression} for further details.\n */\n compression?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * @example\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n *\n * @default\n * ```\n * {\n * parseNull: true,\n * parseUndefined: true,\n * parseBoolean: true,\n * }\n * ```\n *\n * @remarks\n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n *\n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParser?: QueryParserOptions;\n /**\n * Configuration for request body parsing.\n *\n * @property {(\"json\" | \"urlencoded\" | \"raw\" | \"text\")} parser - The type of body parser to use.\n * @property {object} [options] - Parser-specific options passed to the corresponding Express body parser middleware.\n *\n * @remarks\n * - When `parser` is `\"json\"`, options are passed to `express.json()`.\n * - When `parser` is `\"urlencoded\"`, options are passed to `express.urlencoded()`.\n * - When `parser` is `\"raw\"`, options are passed to `express.raw()`.\n * - When `parser` is `\"text\"`, options are passed to `express.text()`.\n * - Set to `false` to disable body parsing for this route.\n *\n * @see {@link https://expressjs.com/en/api.html#express.json Express body parser documentation}\n */\n bodyParser?:\n | { parser: \"json\"; options?: Parameters<typeof express.json>[0] }\n | {\n parser: \"urlencoded\";\n options?: Parameters<typeof express.urlencoded>[0];\n }\n | { parser: \"raw\"; options?: Parameters<typeof express.raw>[0] }\n | { parser: \"raw\"; options?: Parameters<typeof express.raw>[0] }\n | { parser: \"text\"; options?: Parameters<typeof express.text>[0] }\n | false;\n /**\n * Experimental features to be battled tested before being stable\n *\n * PS: These features may be changed without any previous warning.\n */\n experimental?: {\n /**\n * OpenAPI specification for this route.\n *\n * @remarks\n * - Set to `false` to exclude this route from OpenAPI documentation.\n * - Provide a partial OpenAPI operation object to document the route.\n */\n openapi?: false | OpenApiConfig;\n /**\n * Configuration for file upload handling in routes.\n * Supports single file, multiple files from same field, or multiple fields with files.\n */\n uploads?: UploadConfig;\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=openapi-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi-config.js","sourceRoot":"","sources":["../../../../../src/utils/arkos-router/types/openapi-config.ts"],"names":[],"mappings":"","sourcesContent":["import { OpenAPIV3 } from \"openapi-types\";\nimport { ZodSchema } from \"zod\";\n\n/**\n * Represents a schema-like object that can be used for OpenAPI documentation.\n * Accepts Zod schemas, class constructors (DTOs), or plain JSON Schema objects.\n */\ntype SchemaLike =\n | ZodSchema\n | (new (...args: any[]) => object)\n | OpenAPIV3.SchemaObject;\n\n/**\n * Extended media type object that accepts SchemaLike in addition to standard OpenAPI schemas.\n */\ntype ExtendedMediaTypeObject = Omit<OpenAPIV3.MediaTypeObject, \"schema\"> & {\n schema: SchemaLike;\n};\n\n/**\n * Represents a parameter object with support for Zod schemas, class constructors, or JSON Schema.\n * Extends OpenAPI's ParameterObject to accept SchemaLike types for the schema field.\n *\n * @example\n * // Using JSON Schema (standard OpenAPI)\n * {\n * name: \"userId\",\n * in: \"path\",\n * required: true,\n * schema: { type: \"string\", format: \"uuid\" }\n * }\n *\n * @example\n * // Using Zod schema\n * {\n * name: \"limit\",\n * in: \"query\",\n * schema: z.number().int().min(1).max(100)\n * }\n *\n * @example\n * // Using class constructor (DTO)\n * {\n * name: \"filter\",\n * in: \"query\",\n * schema: FilterDto\n * }\n */\nexport type ExtendedParameterObject = Omit<\n OpenAPIV3.ParameterObject,\n \"schema\"\n> & {\n /**\n * The schema defining the type used for the parameter.\n * Can be a Zod schema, class constructor, or standard JSON Schema object.\n */\n schema?: SchemaLike;\n};\n\n/**\n * Shorthand response definition. Can be:\n * - A SchemaLike (assumes application/json content-type and default description)\n * - An object with `content` as SchemaLike and optional `description`\n * - A full OpenAPI response object with custom content-types\n *\n * @example\n * // Shorthand: Just the schema (assumes application/json + \"Success\" description)\n * 200: ProfileDto\n *\n * @example\n * // Medium: Schema with custom description\n * 404: {\n * content: ErrorDto,\n * description: \"User not found\"\n * }\n *\n * @example\n * // Full: Multiple content-types with custom configuration\n * 500: {\n * content: {\n * \"application/json\": { schema: ErrorDto },\n * \"text/plain\": { schema: PlainErrorDto }\n * },\n * description: \"Internal server error\"\n * }\n */\ntype ResponseDefinition =\n | SchemaLike\n | {\n content: SchemaLike;\n description?: string;\n }\n | (Omit<OpenAPIV3.ResponseObject, \"content\"> & {\n content?: {\n [media: string]: ExtendedMediaTypeObject;\n };\n });\n\n/**\n * Shorthand request body definition. Can be:\n * - A SchemaLike (assumes application/json content-type)\n * - An object with `content` as SchemaLike and optional configuration\n * - A full OpenAPI request body object with custom content-types\n *\n * @example\n * // Shorthand: Just the schema (assumes application/json)\n * requestBody: CreateUserDto\n *\n * @example\n * // Medium: Schema with configuration\n * requestBody: {\n * content: CreateUserDto,\n * required: true,\n * description: \"User creation payload\"\n * }\n *\n * @example\n * // Full: Multiple content-types\n * requestBody: {\n * content: {\n * \"application/json\": { schema: CreateUserDto },\n * \"multipart/form-data\": { schema: CreateUserFormDto }\n * },\n * required: true\n * }\n */\ntype RequestBodyDefinition =\n | SchemaLike\n | {\n content: SchemaLike;\n required?: boolean;\n description?: string;\n }\n | (Omit<OpenAPIV3.RequestBodyObject, \"content\"> & {\n content: {\n [media: string]: ExtendedMediaTypeObject;\n };\n });\n\n/**\n * Extended OpenAPI Operation object with enhanced requestBody and responses.\n *\n * NOTE: If you define validation in the `validation` field, DO NOT redefine\n * the same schemas here. The framework will automatically generate OpenAPI docs\n * from your validation schemas. This field is only for:\n * - Endpoints that don't use validation (docs-only)\n * - Additional metadata (summary, description, tags, etc.)\n *\n * Defining both validation and openapi schemas for the same field will cause\n * a startup error to prevent documentation drift.\n */\ntype ExtendedOperationObject = Omit<\n OpenAPIV3.OperationObject,\n \"responses\" | \"requestBody\"\n> & {\n /**\n * Response definitions keyed by HTTP status code.\n * Supports shorthand, medium, and full OpenAPI formats.\n */\n responses?: {\n [statusCode: number]: ResponseDefinition;\n };\n\n /**\n * Request body definition.\n * Supports shorthand, medium, and full OpenAPI formats.\n *\n * WARNING: Do not define this if you're using `validation.body` -\n * it will be auto-generated from your validation schema.\n */\n requestBody?: RequestBodyDefinition;\n /**\n * Array of parameter definitions for path, query, header, and cookie parameters.\n * Each parameter's schema can be a Zod schema, class constructor, or JSON Schema.\n *\n * WARNING: Do NOT define parameters here if you're using `validation.query`,\n * `validation.params`, `validation.headers`, or `validation.cookies`.\n * Those validation schemas will automatically generate parameter documentation.\n * Defining both will cause a startup error.\n *\n * Only use this field for:\n * - Documentation-only endpoints (no validation)\n * - Routes where you explicitly don't want validation\n *\n * Note: In practice, documenting parameters without validation is rare.\n * Most APIs validate their inputs, so you'll typically use the `validation` field instead.\n *\n * @example\n * // Standard JSON Schema (most common for parameters)\n * parameters: [\n * {\n * name: \"userId\",\n * in: \"path\",\n * required: true,\n * schema: { type: \"string\", format: \"uuid\" }\n * },\n * {\n * name: \"limit\",\n * in: \"query\",\n * schema: { type: \"integer\", minimum: 1, maximum: 100 }\n * }\n * ]\n *\n * @example\n * // Using Zod (less common for parameters, but supported)\n * parameters: [\n * {\n * name: \"page\",\n * in: \"query\",\n * schema: z.number().int().positive()\n * }\n * ]\n */\n parameters?: (ExtendedParameterObject | OpenAPIV3.ReferenceObject)[];\n};\n\n/**\n * OpenAPI configuration for a route.\n * Set to `false` to exclude this route from OpenAPI documentation.\n * Otherwise, provide operation metadata and schema definitions.\n *\n * @example\n * // Exclude from docs\n * openapi: false\n *\n * @example\n * // Simple documentation with shorthand\n * openapi: {\n * summary: \"Get user profile\",\n * responses: {\n * 200: ProfileDto,\n * 404: ErrorDto\n * }\n * }\n *\n * @example\n * // Complex documentation with multiple content-types\n * openapi: {\n * summary: \"Upload file\",\n * requestBody: {\n * content: {\n * \"multipart/form-data\": { schema: FileUploadDto }\n * },\n * required: true\n * },\n * responses: {\n * 200: {\n * content: {\n * \"application/json\": { schema: UploadResultDto }\n * },\n * description: \"File uploaded successfully\"\n * }\n * }\n * }\n */\nexport type OpenApiConfig = false | Partial<ExtendedOperationObject>;\n"]}