arkos 2.0.0-next.13 → 2.0.0-next.16

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 (246) hide show
  1. package/README.md +144 -145
  2. package/cli.js +1 -0
  3. package/dist/cjs/app.js +7 -0
  4. package/dist/cjs/app.js.map +1 -1
  5. package/dist/cjs/exports/error-handler/index.js +15 -0
  6. package/dist/cjs/exports/error-handler/index.js.map +1 -1
  7. package/dist/cjs/modules/auth/auth.router.js +3 -0
  8. package/dist/cjs/modules/auth/auth.router.js.map +1 -1
  9. package/dist/cjs/modules/auth/auth.service.js +2 -0
  10. package/dist/cjs/modules/auth/auth.service.js.map +1 -1
  11. package/dist/cjs/modules/base/base.controller.js +15 -3
  12. package/dist/cjs/modules/base/base.controller.js.map +1 -1
  13. package/dist/cjs/modules/base/base.middlewares.js +19 -12
  14. package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
  15. package/dist/cjs/modules/base/base.service.js +5 -1
  16. package/dist/cjs/modules/base/base.service.js.map +1 -1
  17. package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js +9 -0
  18. package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
  19. package/dist/cjs/modules/error-handler/error-handler.controller.js +25 -42
  20. package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
  21. package/dist/cjs/modules/error-handler/utils/app-error.js +0 -1
  22. package/dist/cjs/modules/error-handler/utils/app-error.js.map +1 -1
  23. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +8 -9
  24. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  25. package/dist/cjs/modules/error-handler/utils/errors.js +158 -0
  26. package/dist/cjs/modules/error-handler/utils/errors.js.map +1 -0
  27. package/dist/cjs/modules/error-handler/utils/multer-error-handler.js +39 -0
  28. package/dist/cjs/modules/error-handler/utils/multer-error-handler.js.map +1 -0
  29. package/dist/cjs/modules/file-upload/file-upload.controller.js +10 -14
  30. package/dist/cjs/modules/file-upload/file-upload.controller.js.map +1 -1
  31. package/dist/cjs/modules/file-upload/file-upload.router.js +2 -0
  32. package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
  33. package/dist/cjs/modules/swagger/swagger.router.js +8 -2
  34. package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
  35. package/dist/cjs/modules/swagger/utils/get-open-api-login-html.js +18 -0
  36. package/dist/cjs/modules/swagger/utils/get-open-api-login-html.js.map +1 -1
  37. package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js +5 -5
  38. package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
  39. package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js +1 -1
  40. package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js.map +1 -1
  41. package/dist/cjs/types/arkos-prisma-input.js.map +1 -1
  42. package/dist/cjs/types/index.js.map +1 -1
  43. package/dist/cjs/types/new-arkos-config.js.map +1 -1
  44. package/dist/cjs/types/router-config.js.map +1 -1
  45. package/dist/cjs/utils/arkos-router/arkos-router-openapi-manager.js +86 -28
  46. package/dist/cjs/utils/arkos-router/arkos-router-openapi-manager.js.map +1 -1
  47. package/dist/cjs/utils/arkos-router/index.js +11 -7
  48. package/dist/cjs/utils/arkos-router/index.js.map +1 -1
  49. package/dist/cjs/utils/arkos-router/types/index.js.map +1 -1
  50. package/dist/cjs/utils/arkos-router/types/upload-config.js.map +1 -1
  51. package/dist/cjs/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js +34 -28
  52. package/dist/cjs/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +1 -1
  53. package/dist/cjs/utils/arkos-router/utils/helpers/index.js +9 -6
  54. package/dist/cjs/utils/arkos-router/utils/helpers/index.js.map +1 -1
  55. package/dist/cjs/utils/arkos-router/utils/helpers/upload-manager.js +334 -77
  56. package/dist/cjs/utils/arkos-router/utils/helpers/upload-manager.js.map +1 -1
  57. package/dist/cjs/utils/bundler.js.map +1 -1
  58. package/dist/cjs/utils/cli/build.js +2 -3
  59. package/dist/cjs/utils/cli/build.js.map +1 -1
  60. package/dist/cjs/utils/cli/dev.js +11 -6
  61. package/dist/cjs/utils/cli/dev.js.map +1 -1
  62. package/dist/cjs/utils/cli/export-auth-action.js +5 -4
  63. package/dist/cjs/utils/cli/export-auth-action.js.map +1 -1
  64. package/dist/cjs/utils/cli/generate.js +6 -8
  65. package/dist/cjs/utils/cli/generate.js.map +1 -1
  66. package/dist/cjs/utils/cli/index.js +22 -19
  67. package/dist/cjs/utils/cli/index.js.map +1 -1
  68. package/dist/cjs/utils/cli/start.js +4 -2
  69. package/dist/cjs/utils/cli/start.js.map +1 -1
  70. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  71. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-controller-template.js +19 -7
  72. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +1 -1
  73. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-multiple-components.js +7 -6
  74. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-multiple-components.js.map +1 -1
  75. package/dist/cjs/utils/cli/utils/template-generator/templates/policy-template.js +4 -4
  76. package/dist/cjs/utils/cli/utils/template-generator/templates/policy-template.js.map +1 -1
  77. package/dist/cjs/utils/cli/utils/template-generators.js +0 -6
  78. package/dist/cjs/utils/cli/utils/template-generators.js.map +1 -1
  79. package/dist/cjs/utils/define-config.js +5 -0
  80. package/dist/cjs/utils/define-config.js.map +1 -1
  81. package/dist/cjs/utils/dotenv.helpers.js +0 -6
  82. package/dist/cjs/utils/dotenv.helpers.js.map +1 -1
  83. package/dist/cjs/utils/features/api.features.js +23 -5
  84. package/dist/cjs/utils/features/api.features.js.map +1 -1
  85. package/dist/cjs/utils/helpers/arkos-config.helpers.js +22 -2
  86. package/dist/cjs/utils/helpers/arkos-config.helpers.js.map +1 -1
  87. package/dist/cjs/utils/helpers/exit-error.js +1 -0
  88. package/dist/cjs/utils/helpers/exit-error.js.map +1 -1
  89. package/dist/cjs/utils/helpers/fs.helpers.js +25 -24
  90. package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
  91. package/dist/cjs/utils/helpers/global.helpers.js +3 -2
  92. package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
  93. package/dist/cjs/utils/helpers/prisma.helpers.js +4 -5
  94. package/dist/cjs/utils/helpers/prisma.helpers.js.map +1 -1
  95. package/dist/cjs/utils/helpers/url-helpers.js +14 -0
  96. package/dist/cjs/utils/helpers/url-helpers.js.map +1 -0
  97. package/dist/cjs/utils/initialize-app.js +35 -6
  98. package/dist/cjs/utils/initialize-app.js.map +1 -1
  99. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +12 -6
  100. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +1 -1
  101. package/dist/cjs/utils/prisma/prisma-schema-parser.js +10 -3
  102. package/dist/cjs/utils/prisma/prisma-schema-parser.js.map +1 -1
  103. package/dist/cjs/utils/setup-app.js +58 -41
  104. package/dist/cjs/utils/setup-app.js.map +1 -1
  105. package/dist/esm/app.js +6 -0
  106. package/dist/esm/app.js.map +1 -1
  107. package/dist/esm/exports/error-handler/index.js +1 -0
  108. package/dist/esm/exports/error-handler/index.js.map +1 -1
  109. package/dist/esm/modules/auth/auth.router.js +3 -0
  110. package/dist/esm/modules/auth/auth.router.js.map +1 -1
  111. package/dist/esm/modules/auth/auth.service.js +2 -0
  112. package/dist/esm/modules/auth/auth.service.js.map +1 -1
  113. package/dist/esm/modules/base/base.controller.js +15 -3
  114. package/dist/esm/modules/base/base.controller.js.map +1 -1
  115. package/dist/esm/modules/base/base.middlewares.js +19 -12
  116. package/dist/esm/modules/base/base.middlewares.js.map +1 -1
  117. package/dist/esm/modules/base/base.service.js +5 -1
  118. package/dist/esm/modules/base/base.service.js.map +1 -1
  119. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +9 -0
  120. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
  121. package/dist/esm/modules/error-handler/error-handler.controller.js +22 -42
  122. package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
  123. package/dist/esm/modules/error-handler/utils/app-error.js +0 -1
  124. package/dist/esm/modules/error-handler/utils/app-error.js.map +1 -1
  125. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +8 -9
  126. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  127. package/dist/esm/modules/error-handler/utils/errors.js +127 -0
  128. package/dist/esm/modules/error-handler/utils/errors.js.map +1 -0
  129. package/dist/esm/modules/error-handler/utils/multer-error-handler.js +34 -0
  130. package/dist/esm/modules/error-handler/utils/multer-error-handler.js.map +1 -0
  131. package/dist/esm/modules/file-upload/file-upload.controller.js +10 -14
  132. package/dist/esm/modules/file-upload/file-upload.controller.js.map +1 -1
  133. package/dist/esm/modules/file-upload/file-upload.router.js +2 -0
  134. package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
  135. package/dist/esm/modules/swagger/swagger.router.js +8 -2
  136. package/dist/esm/modules/swagger/swagger.router.js.map +1 -1
  137. package/dist/esm/modules/swagger/utils/get-open-api-login-html.js +18 -0
  138. package/dist/esm/modules/swagger/utils/get-open-api-login-html.js.map +1 -1
  139. package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js +5 -5
  140. package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
  141. package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js +1 -1
  142. package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js.map +1 -1
  143. package/dist/esm/types/arkos-prisma-input.js.map +1 -1
  144. package/dist/esm/types/index.js.map +1 -1
  145. package/dist/esm/types/new-arkos-config.js.map +1 -1
  146. package/dist/esm/types/router-config.js.map +1 -1
  147. package/dist/esm/utils/arkos-router/arkos-router-openapi-manager.js +86 -28
  148. package/dist/esm/utils/arkos-router/arkos-router-openapi-manager.js.map +1 -1
  149. package/dist/esm/utils/arkos-router/index.js +11 -7
  150. package/dist/esm/utils/arkos-router/index.js.map +1 -1
  151. package/dist/esm/utils/arkos-router/types/index.js.map +1 -1
  152. package/dist/esm/utils/arkos-router/types/upload-config.js.map +1 -1
  153. package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js +34 -28
  154. package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +1 -1
  155. package/dist/esm/utils/arkos-router/utils/helpers/index.js +9 -6
  156. package/dist/esm/utils/arkos-router/utils/helpers/index.js.map +1 -1
  157. package/dist/esm/utils/arkos-router/utils/helpers/upload-manager.js +334 -77
  158. package/dist/esm/utils/arkos-router/utils/helpers/upload-manager.js.map +1 -1
  159. package/dist/esm/utils/bundler.js.map +1 -1
  160. package/dist/esm/utils/cli/build.js +3 -4
  161. package/dist/esm/utils/cli/build.js.map +1 -1
  162. package/dist/esm/utils/cli/dev.js +12 -7
  163. package/dist/esm/utils/cli/dev.js.map +1 -1
  164. package/dist/esm/utils/cli/export-auth-action.js +5 -4
  165. package/dist/esm/utils/cli/export-auth-action.js.map +1 -1
  166. package/dist/esm/utils/cli/generate.js +6 -8
  167. package/dist/esm/utils/cli/generate.js.map +1 -1
  168. package/dist/esm/utils/cli/index.js +22 -19
  169. package/dist/esm/utils/cli/index.js.map +1 -1
  170. package/dist/esm/utils/cli/start.js +4 -2
  171. package/dist/esm/utils/cli/start.js.map +1 -1
  172. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  173. package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js +16 -7
  174. package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +1 -1
  175. package/dist/esm/utils/cli/utils/template-generator/templates/generate-multiple-components.js +7 -6
  176. package/dist/esm/utils/cli/utils/template-generator/templates/generate-multiple-components.js.map +1 -1
  177. package/dist/esm/utils/cli/utils/template-generator/templates/policy-template.js +4 -4
  178. package/dist/esm/utils/cli/utils/template-generator/templates/policy-template.js.map +1 -1
  179. package/dist/esm/utils/cli/utils/template-generators.js +0 -6
  180. package/dist/esm/utils/cli/utils/template-generators.js.map +1 -1
  181. package/dist/esm/utils/define-config.js +5 -0
  182. package/dist/esm/utils/define-config.js.map +1 -1
  183. package/dist/esm/utils/dotenv.helpers.js +0 -6
  184. package/dist/esm/utils/dotenv.helpers.js.map +1 -1
  185. package/dist/esm/utils/features/api.features.js +23 -5
  186. package/dist/esm/utils/features/api.features.js.map +1 -1
  187. package/dist/esm/utils/helpers/arkos-config.helpers.js +20 -2
  188. package/dist/esm/utils/helpers/arkos-config.helpers.js.map +1 -1
  189. package/dist/esm/utils/helpers/exit-error.js +1 -0
  190. package/dist/esm/utils/helpers/exit-error.js.map +1 -1
  191. package/dist/esm/utils/helpers/fs.helpers.js +25 -24
  192. package/dist/esm/utils/helpers/fs.helpers.js.map +1 -1
  193. package/dist/esm/utils/helpers/global.helpers.js +1 -1
  194. package/dist/esm/utils/helpers/global.helpers.js.map +1 -1
  195. package/dist/esm/utils/helpers/prisma.helpers.js +4 -5
  196. package/dist/esm/utils/helpers/prisma.helpers.js.map +1 -1
  197. package/dist/esm/utils/helpers/url-helpers.js +11 -0
  198. package/dist/esm/utils/helpers/url-helpers.js.map +1 -0
  199. package/dist/esm/utils/initialize-app.js +35 -6
  200. package/dist/esm/utils/initialize-app.js.map +1 -1
  201. package/dist/esm/utils/prisma/prisma-json-schema-generator.js +12 -6
  202. package/dist/esm/utils/prisma/prisma-json-schema-generator.js.map +1 -1
  203. package/dist/esm/utils/prisma/prisma-schema-parser.js +10 -3
  204. package/dist/esm/utils/prisma/prisma-schema-parser.js.map +1 -1
  205. package/dist/esm/utils/setup-app.js +59 -42
  206. package/dist/esm/utils/setup-app.js.map +1 -1
  207. package/dist/types/app.d.ts +5 -6
  208. package/dist/types/exports/error-handler/index.d.ts +1 -0
  209. package/dist/types/modules/auth/auth.service.d.ts +2 -6
  210. package/dist/types/modules/base/base.service.d.ts +2 -1
  211. package/dist/types/modules/error-handler/utils/app-error.d.ts +0 -2
  212. package/dist/types/modules/error-handler/utils/error-handler.helpers.d.ts +1 -1
  213. package/dist/types/modules/error-handler/utils/errors.d.ts +176 -0
  214. package/dist/types/modules/error-handler/utils/multer-error-handler.d.ts +7 -0
  215. package/dist/types/modules/file-upload/file-upload.controller.d.ts +0 -1
  216. package/dist/types/modules/swagger/utils/helpers/get-swagger-default-configs.d.ts +48 -2
  217. package/dist/types/types/arkos-prisma-input.d.ts +3 -2
  218. package/dist/types/types/index.d.ts +0 -21
  219. package/dist/types/types/new-arkos-config.d.ts +183 -14
  220. package/dist/types/types/router-config.d.ts +1 -1
  221. package/dist/types/utils/arkos-router/arkos-router-openapi-manager.d.ts +14 -1
  222. package/dist/types/utils/arkos-router/index.d.ts +76 -8
  223. package/dist/types/utils/arkos-router/types/index.d.ts +19 -6
  224. package/dist/types/utils/arkos-router/types/upload-config.d.ts +63 -7
  225. package/dist/types/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.d.ts +1 -1
  226. package/dist/types/utils/arkos-router/utils/helpers/index.d.ts +2 -0
  227. package/dist/types/utils/arkos-router/utils/helpers/upload-manager.d.ts +0 -36
  228. package/dist/types/utils/bundler.d.ts +1 -1
  229. package/dist/types/utils/cli/generate.d.ts +0 -1
  230. package/dist/types/utils/cli/start.d.ts +1 -1
  231. package/dist/types/utils/helpers/arkos-config.helpers.d.ts +2 -0
  232. package/dist/types/utils/helpers/fs.helpers.d.ts +1 -1
  233. package/dist/types/utils/helpers/global.helpers.d.ts +1 -0
  234. package/dist/types/utils/helpers/url-helpers.d.ts +1 -0
  235. package/dist/types/utils/prisma/prisma-schema-parser.d.ts +1 -0
  236. package/package.json +15 -15
  237. package/dist/cjs/utils/cli/utils/template-generator/templates/route-hook.template.js +0 -39
  238. package/dist/cjs/utils/cli/utils/template-generator/templates/route-hook.template.js.map +0 -1
  239. package/dist/cjs/utils/cli/utils/template-generator/templates/service-hook.template.js +0 -32
  240. package/dist/cjs/utils/cli/utils/template-generator/templates/service-hook.template.js.map +0 -1
  241. package/dist/esm/utils/cli/utils/template-generator/templates/route-hook.template.js +0 -36
  242. package/dist/esm/utils/cli/utils/template-generator/templates/route-hook.template.js.map +0 -1
  243. package/dist/esm/utils/cli/utils/template-generator/templates/service-hook.template.js +0 -29
  244. package/dist/esm/utils/cli/utils/template-generator/templates/service-hook.template.js.map +0 -1
  245. package/dist/types/utils/cli/utils/template-generator/templates/route-hook.template.d.ts +0 -2
  246. package/dist/types/utils/cli/utils/template-generator/templates/service-hook.template.d.ts +0 -2
@@ -1,3 +1,4 @@
1
1
  import catchAsync from "../../modules/error-handler/utils/catch-async";
2
2
  import AppError from "../../modules/error-handler/utils/app-error";
3
+ export * from "../../modules/error-handler/utils/errors";
3
4
  export { catchAsync, AppError };
@@ -2,6 +2,7 @@ import { User } from "../../types";
2
2
  import { ArkosRequest, ArkosRequestHandler } from "../../types";
3
3
  import { AuthJwtPayload, AccessAction, AccessControlConfig, AuthenticationControlConfig, DetailedAccessControlRule } from "../../types/auth";
4
4
  import { MsDuration } from "./utils/helpers/auth.controller.helpers";
5
+ import { CookieOptions } from "express";
5
6
  /**
6
7
  * Handles various authentication-related tasks such as JWT signing, password hashing, and verifying user credentials.
7
8
  */
@@ -66,12 +67,7 @@ export declare class AuthService {
66
67
  * res.cookie('jwt', token, cookieOptions);
67
68
  * ```
68
69
  */
69
- getJwtCookieOptions(req: ArkosRequest): {
70
- expires: Date;
71
- httpOnly: boolean;
72
- secure: boolean;
73
- sameSite: "none" | "strict" | "lax";
74
- };
70
+ getJwtCookieOptions(req: ArkosRequest): CookieOptions;
75
71
  /**
76
72
  * Is used by default internally by Arkos under `BaseService` class to check if the password is already hashed.
77
73
  *
@@ -30,8 +30,9 @@ export interface ServiceOperationHooks {
30
30
  export declare class BaseService<TModelName extends keyof Models = keyof Models> {
31
31
  modelName: TModelName;
32
32
  relationFields: ModelGroupRelationFields;
33
- prisma: PrismaClient;
33
+ private prismaInstace?;
34
34
  constructor(modelName: TModelName);
35
+ get prisma(): PrismaClient;
35
36
  private getServiceHook;
36
37
  private executeOperation;
37
38
  private executeTransactionOperation;
@@ -5,7 +5,6 @@
5
5
  *
6
6
  * @property {number} statusCode - HTTP status code of the error.
7
7
  * @property {string} status - Status message derived from the status code (`fail` for 4xx, `error` for 5xx).
8
- * @property {boolean} [missing=false] - Flag to indicate if a resource is missing.
9
8
  * @property {boolean} isOperational - Indicates if the error is operational (intended for client visibility).
10
9
  * @property {string} [code] - Optional error code for categorization.
11
10
  * @property {Record<string, any>} [meta] - Additional metadata related to the error.
@@ -33,7 +32,6 @@
33
32
  declare class AppError extends Error {
34
33
  statusCode: number;
35
34
  status: string;
36
- missing?: boolean;
37
35
  isOperational: boolean;
38
36
  code?: string;
39
37
  meta?: Record<string, any>;
@@ -8,7 +8,7 @@ export declare function handleConnectionTimeoutError(_: AppError): AppError;
8
8
  export declare function handleDatabaseNotFoundError(_: AppError): AppError;
9
9
  export declare function handleFieldValueTooLargeError(err: AppError): AppError;
10
10
  export declare function handleRecordNotFoundError(_: AppError): AppError;
11
- export declare function handleUniqueConstraintError(err: AppError): AppError;
11
+ export declare function handleUniqueConstraintError(err: any): AppError;
12
12
  export declare function handleForeignKeyConstraintError(_: AppError): AppError;
13
13
  export declare function handleConstraintFailedError(err: AppError): AppError;
14
14
  export declare function handleSchemaCreationFailedError(_: AppError): AppError;
@@ -0,0 +1,176 @@
1
+ import AppError from "./app-error";
2
+ /**
3
+ * 400 - Bad Request
4
+ * @example throw new BadRequestError("Invalid input", "InvalidInput", { field: "email" })
5
+ */
6
+ export declare class BadRequestError extends AppError {
7
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
8
+ }
9
+ /**
10
+ * 401 - Unauthorized
11
+ * @example throw new UnauthorizedError("Invalid token", "InvalidToken")
12
+ */
13
+ export declare class UnauthorizedError extends AppError {
14
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
15
+ }
16
+ /**
17
+ * 402 - Payment Required
18
+ * @example throw new PaymentRequiredError("Subscription expired", "PaymentRequired")
19
+ */
20
+ export declare class PaymentRequiredError extends AppError {
21
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
22
+ }
23
+ /**
24
+ * 403 - Forbidden
25
+ * @example throw new ForbiddenError("Access denied", "Forbidden", { resource: "admin" })
26
+ */
27
+ export declare class ForbiddenError extends AppError {
28
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
29
+ }
30
+ /**
31
+ * 404 - Not Found
32
+ * @example throw new NotFoundError("User not found", "NotFound", { id: 123 })
33
+ */
34
+ export declare class NotFoundError extends AppError {
35
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
36
+ }
37
+ /**
38
+ * 405 - Method Not Allowed
39
+ * @example throw new MethodNotAllowedError("POST not allowed", "MethodNotAllowed")
40
+ */
41
+ export declare class MethodNotAllowedError extends AppError {
42
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
43
+ }
44
+ /**
45
+ * 406 - Not Acceptable
46
+ * @example throw new NotAcceptableError("Unsupported format", "NotAcceptable")
47
+ */
48
+ export declare class NotAcceptableError extends AppError {
49
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
50
+ }
51
+ /**
52
+ * 408 - Request Timeout
53
+ * @example throw new RequestTimeoutError("Upload took too long", "RequestTimeout")
54
+ */
55
+ export declare class RequestTimeoutError extends AppError {
56
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
57
+ }
58
+ /**
59
+ * 409 - Conflict
60
+ * @example throw new ConflictError("Duplicate entry", "Conflict", { field: "email" })
61
+ */
62
+ export declare class ConflictError extends AppError {
63
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
64
+ }
65
+ /**
66
+ * 410 - Gone
67
+ * @example throw new GoneError("Resource deleted", "Gone")
68
+ */
69
+ export declare class GoneError extends AppError {
70
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
71
+ }
72
+ /**
73
+ * 411 - Length Required
74
+ * @example throw new LengthRequiredError("Content-Length missing", "LengthRequired")
75
+ */
76
+ export declare class LengthRequiredError extends AppError {
77
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
78
+ }
79
+ /**
80
+ * 412 - Precondition Failed
81
+ * @example throw new PreconditionFailedError("ETag mismatch", "PreconditionFailed")
82
+ */
83
+ export declare class PreconditionFailedError extends AppError {
84
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
85
+ }
86
+ /**
87
+ * 413 - Payload Too Large
88
+ * @example throw new PayloadTooLargeError("File exceeds 10MB", "PayloadTooLarge", { max: "10MB" })
89
+ */
90
+ export declare class PayloadTooLargeError extends AppError {
91
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
92
+ }
93
+ /**
94
+ * 414 - URI Too Long
95
+ * @example throw new UriTooLongError("Query string too long", "UriTooLong")
96
+ */
97
+ export declare class UriTooLongError extends AppError {
98
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
99
+ }
100
+ /**
101
+ * 415 - Unsupported Media Type
102
+ * @example throw new UnsupportedMediaTypeError("Expected JSON", "UnsupportedMediaType")
103
+ */
104
+ export declare class UnsupportedMediaTypeError extends AppError {
105
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
106
+ }
107
+ /**
108
+ * 416 - Range Not Satisfiable
109
+ * @example throw new RangeNotSatisfiableError("Invalid byte range", "RangeNotSatisfiable")
110
+ */
111
+ export declare class RangeNotSatisfiableError extends AppError {
112
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
113
+ }
114
+ /**
115
+ * 417 - Expectation Failed
116
+ * @example throw new ExpectationFailedError("Expect header failed", "ExpectationFailed")
117
+ */
118
+ export declare class ExpectationFailedError extends AppError {
119
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
120
+ }
121
+ /**
122
+ * 418 - I'm a teapot
123
+ * @example throw new ImATeapotError("Cannot brew coffee", "ImATeapot")
124
+ */
125
+ export declare class ImATeapotError extends AppError {
126
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
127
+ }
128
+ /**
129
+ * 422 - Unprocessable Content
130
+ * @example throw new UnprocessableContentError("Validation failed", "ValidationFailed", { errors: [...] })
131
+ */
132
+ export declare class UnprocessableContentError extends AppError {
133
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
134
+ }
135
+ /**
136
+ * 429 - Too Many Requests
137
+ * @example throw new TooManyRequestsError("Rate limit exceeded", "RateLimitExceeded", { retryAfter: 60 })
138
+ */
139
+ export declare class TooManyRequestsError extends AppError {
140
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
141
+ }
142
+ /**
143
+ * 500 - Internal Server Error
144
+ * @example throw new InternalServerError("Database connection failed", "DatabaseError")
145
+ */
146
+ export declare class InternalServerError extends AppError {
147
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
148
+ }
149
+ /**
150
+ * 501 - Not Implemented
151
+ * @example throw new NotImplementedError("Feature coming soon", "NotImplemented")
152
+ */
153
+ export declare class NotImplementedError extends AppError {
154
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
155
+ }
156
+ /**
157
+ * 502 - Bad Gateway
158
+ * @example throw new BadGatewayError("Upstream timeout", "BadGateway")
159
+ */
160
+ export declare class BadGatewayError extends AppError {
161
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
162
+ }
163
+ /**
164
+ * 503 - Service Unavailable
165
+ * @example throw new ServiceUnavailableError("Maintenance mode", "ServiceUnavailable", { retryAfter: 300 })
166
+ */
167
+ export declare class ServiceUnavailableError extends AppError {
168
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
169
+ }
170
+ /**
171
+ * 504 - Gateway Timeout
172
+ * @example throw new GatewayTimeoutError("Upstream timeout", "GatewayTimeout")
173
+ */
174
+ export declare class GatewayTimeoutError extends AppError {
175
+ constructor(message?: string, code?: string, meta?: Record<string, any>);
176
+ }
@@ -0,0 +1,7 @@
1
+ import multer from "multer";
2
+ import AppError from "./app-error";
3
+ declare class MulterErrorHandler {
4
+ handle(err: multer.MulterError): AppError;
5
+ }
6
+ declare const multerErrorHandler: MulterErrorHandler;
7
+ export default multerErrorHandler;
@@ -2,7 +2,6 @@
2
2
  * Handles file uploads and allows to be extended via route hooks.
3
3
  */
4
4
  export declare class FileUploadController {
5
- private handleUploadError;
6
5
  private getRouteHook;
7
6
  private getAfterHook;
8
7
  /**
@@ -1,2 +1,48 @@
1
- import { ArkosConfig } from "../../../../exports";
2
- export default function getSwaggerDefaultConfig(defaultModelsPaths: Record<string, any>): ArkosConfig["swagger"];
1
+ export default function getSwaggerDefaultConfig(defaultModelsPaths: Record<string, any>): {
2
+ endpoint: string;
3
+ mode: string;
4
+ strict: boolean;
5
+ options: {
6
+ definition: {
7
+ openapi: string;
8
+ info: {
9
+ title: string;
10
+ version: string;
11
+ description: string;
12
+ };
13
+ servers: {
14
+ url: string;
15
+ description: string;
16
+ }[];
17
+ paths: Record<string, any>;
18
+ components: {
19
+ securitySchemes: {
20
+ BearerAuth: {
21
+ type: string;
22
+ scheme: string;
23
+ bearerFormat: string;
24
+ };
25
+ };
26
+ };
27
+ security: never[];
28
+ };
29
+ apis: string[];
30
+ deepLinking: boolean;
31
+ tryItOutEnabled: boolean;
32
+ persistAuthorization: boolean;
33
+ };
34
+ scalarApiReferenceConfiguration: {
35
+ theme: string;
36
+ darkMode: boolean;
37
+ layout: string;
38
+ showSidebar: boolean;
39
+ hideDownloadButton: boolean;
40
+ cdn: string;
41
+ metaData: {
42
+ title: string;
43
+ description: string;
44
+ };
45
+ pageTitle: string;
46
+ customCss: string;
47
+ };
48
+ };
@@ -131,9 +131,10 @@ type StripPrismaFilters<T> = T extends {
131
131
  OR?: any;
132
132
  } | {
133
133
  NOT?: any;
134
- } ? never : T;
134
+ } ? Omit<T, "equals" | "in" | "notIn" | "lt" | "lte" | "gt" | "gte" | "AND" | "OR" | "NOT"> : T;
135
+ type StripToScalar<T> = T extends string | number | boolean | Date | null | undefined ? T : never;
135
136
  type FlattenRelations<T> = {
136
- [K in keyof T]: IsArrayRelation<T[K]> extends true ? FlattenArrayRelation<T[K]> : IsObjectRelation<T[K]> extends true ? XOR<FlattenObjectRelation<T[K]>, T[K]> : StripPrismaFilters<T[K]> extends never ? never : T[K] extends object ? T[K] extends Date | null | undefined ? T[K] : FlattenRelations<StripPrismaFilters<T[K]>> : StripPrismaFilters<T[K]>;
137
+ [K in keyof T]: IsArrayRelation<T[K]> extends true ? FlattenArrayRelation<T[K]> | undefined : IsObjectRelation<T[K]> extends true ? XOR<FlattenObjectRelation<T[K]> | undefined, T[K]> : StripPrismaFilters<T[K]> extends never ? never : T[K] extends object ? T[K] extends Date | null | undefined ? T[K] : FlattenRelations<StripPrismaFilters<T[K]>> | undefined : StripToScalar<T[K]> extends never ? StripPrismaFilters<T[K]> : StripToScalar<T[K]>;
137
138
  };
138
139
  /**
139
140
  * Flattens Prisma relation inputs into a simpler, developer-friendly format
@@ -140,27 +140,6 @@ export type UserRole = User extends {
140
140
  role: infer R;
141
141
  } ? R : string;
142
142
  export interface ArkosRequest<P extends Record<string, any> = any, ResBody = any, ReqBody = any, Query extends Record<string, any> = any> extends Request<P, ResBody, ReqBody, Query> {
143
- /**
144
- * Request signals used to control Arkos's built-in request handling pipeline.
145
- *
146
- * @since v1.6.0-beta
147
- */
148
- signals?: {
149
- /**
150
- * When set to `true` in a `before` hook, Arkos skips its built-in logic for the current pipeline step (e.g. CRUD, authentication, authorization).
151
- * Automatically reset to `false` after the step completes.
152
- *
153
- * @example
154
- * ```ts
155
- * before: (req, res, next) => {
156
- * req.user = myCustomAuth(req);
157
- * req.signals.skip = true;
158
- * next();
159
- * }
160
- * ```
161
- */
162
- skip?: boolean;
163
- };
164
143
  /**
165
144
  * Authenticated user
166
145
  */
@@ -1,5 +1,5 @@
1
1
  import cors from "cors";
2
- import express from "express";
2
+ import express, { CookieOptions } from "express";
3
3
  import { Options as RateLimitOptions } from "express-rate-limit";
4
4
  import cookieParser from "cookie-parser";
5
5
  import compression from "compression";
@@ -16,6 +16,41 @@ import { AuthenticateHookHandler, AuthenticateAfterHookHandler, AuthenticateErro
16
16
  * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.
17
17
  */
18
18
  export type ArkosConfig = {
19
+ /**
20
+ * Configuration for resolving your Arkos application's source files at runtime.
21
+ *
22
+ * @since 1.6.1-canary.2
23
+ *
24
+ */
25
+ source?: {
26
+ /**
27
+ * The entry point file of your Arkos application, resolved at runtime.
28
+ *
29
+ * This should point to the file where `app.listen()` or `app.listen(server)`
30
+ * is called to start the HTTP server.
31
+ *
32
+ * Supports both TypeScript and JavaScript projects.
33
+ *
34
+ * @type {string}
35
+ *
36
+ * @default "src/app.ts" (TypeScript) | "src/app.js" (JavaScript)
37
+ *
38
+ * @since 1.6.1-canary.2
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * // TypeScript project
43
+ * entryPoint: "src/app.ts"
44
+ *
45
+ * // JavaScript project
46
+ * entryPoint: "src/app.js"
47
+ *
48
+ * // Custom path
49
+ * entryPoint: "src/server/main.ts"
50
+ * ```
51
+ */
52
+ entryPoint?: string;
53
+ };
19
54
  /**
20
55
  * The global prefixer for the whole application
21
56
  *
@@ -297,20 +332,42 @@ export type ArkosConfig = {
297
332
  /**
298
333
  * Whether the cookie should be marked as secure (sent only over HTTPS).
299
334
  * Defaults to `true` in production and `false` in development.
335
+ *
336
+ * @env `JWT_COOKIE_SECURE`
300
337
  */
301
338
  secure?: boolean;
302
339
  /**
303
340
  * Whether the cookie should be marked as HTTP-only.
304
341
  * Default is `true` to prevent access via JavaScript.
342
+ *
343
+ * @env `JWT_COOKIE_HTTP_ONLY`
305
344
  */
306
345
  httpOnly?: boolean;
307
346
  /**
308
347
  * Controls the SameSite attribute of the cookie.
309
348
  * Defaults to "none" in production and "lax" in development.
310
349
  * Options: "lax" | "strict" | "none"
350
+ *
351
+ * @env `JWT_COOKIE_SAME_SITE`
311
352
  */
312
353
  sameSite?: "lax" | "strict" | "none";
313
- };
354
+ /**
355
+ * Expiry date of the cookie in GMT. If not specified (undefined), creates a session cookie.
356
+ *
357
+ * @default `now() + authentication.jwt.expireIn | JWT_EXPIRES_IN`
358
+ *
359
+ * @since 1.5.11-beta
360
+ */
361
+ expires?: Date | undefined;
362
+ /**
363
+ * Domain for the cookie. Use a leading dot (e.g. `.example.com`) to include all subdomains.
364
+ *
365
+ * @env `JWT_COOKIE_DOMAIN`
366
+ *
367
+ * @since 1.5.11-beta
368
+ */
369
+ domain?: string | undefined;
370
+ } & Omit<CookieOptions, "secure" | "httpOnly" | "sameSite" | "expires" | "domain">;
314
371
  };
315
372
  };
316
373
  /** 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:
@@ -385,9 +442,15 @@ export type ArkosConfig = {
385
442
  /**
386
443
  * Defines file upload configurations
387
444
  *
388
- * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)
445
+ * See {@link https://www.arkosjs.com/docs/guides/file-handling/file-uploads/setup}
389
446
  */
390
447
  fileUpload?: {
448
+ /**
449
+ * Disables built-in file upload
450
+ *
451
+ * @since 1.5.11-beta
452
+ */
453
+ enabled?: boolean;
391
454
  /**
392
455
  * Defiens the base file upload directory, default is set to /uploads (on root directory)
393
456
  *
@@ -501,25 +564,35 @@ export type ArkosConfig = {
501
564
  /**
502
565
  * Configuration for CORS (Cross-Origin Resource Sharing).
503
566
  *
504
- * @property {string | string[] | "all"} [allowedOrigins] - List of allowed origins. If set to `"all"`, all origins are accepted.
505
- * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.
506
- * @property {import('cors').CorsOptionsDelegate} [customHandler] - A custom middleware function that overrides the default behavior.
567
+ * Accepts:
568
+ * - `false` disables CORS middleware entirely.
569
+ * - `cors.CorsOptions` passed directly to the `cors` middleware.
570
+ * - `cors.CorsOptionsDelegate` — a delegate function passed directly to the `cors` middleware.
571
+ * - `ArkosRequestHandler` — a full Express middleware that replaces the cors middleware entirely.
572
+ * - An object with deprecated `allowedOrigins`, `options`, and `customHandler` properties.
507
573
  *
508
- * @remarks
509
- * If `customHandler` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.
574
+ * In development, defaults to `origin: true, credentials: true`.
575
+ * In production, defaults to `origin: "*"` (equivalent to plain `cors()`).
510
576
  *
511
577
  * See https://www.npmjs.com/package/cors
512
578
  */
513
- cors?: false | {
579
+ cors?: false | cors.CorsOptions | cors.CorsOptionsDelegate | {
514
580
  /**
515
- * Defines allowed origins to acess the API.
581
+ * Defines allowed origins to access the API.
582
+ *
583
+ * @deprecated Use `cors: { origin: string | string[] }` (cors.CorsOptions) directly instead.
584
+ */
585
+ allowedOrigins?: string | string[] | "*" | true;
586
+ /**
587
+ * Additional cors options.
588
+ *
589
+ * @deprecated Pass cors.CorsOptions directly instead: `cors: { origin: "...", credentials: true }`.
516
590
  */
517
- allowedOrigins?: string | string[] | "*";
518
591
  options?: cors.CorsOptions;
519
592
  /**
520
- * If you would like to override the entire middleware
593
+ * If you would like to override the entire middleware.
521
594
  *
522
- * see
595
+ * @deprecated Pass the handler directly instead: `cors: myCorsHandler`.
523
596
  */
524
597
  customHandler?: cors.CorsOptionsDelegate;
525
598
  } | ArkosRequestHandler;
@@ -534,7 +607,10 @@ export type ArkosConfig = {
534
607
  *
535
608
  * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.
536
609
  */
537
- cookieParser?: false | Parameters<typeof cookieParser> | ArkosRequestHandler;
610
+ cookieParser?: false | {
611
+ secret?: string | string[];
612
+ options?: Parameters<typeof cookieParser>[1];
613
+ } | ArkosRequestHandler;
538
614
  /**
539
615
  * Options to define how query must be parsed.
540
616
  *
@@ -867,4 +943,97 @@ export type ArkosConfig = {
867
943
  */
868
944
  instance: PrismaClient;
869
945
  };
946
+ /**
947
+ * Allows to suppress specific warnings emitted by Arkos at startup or runtime.
948
+ *
949
+ * @since 1.5.10-beta
950
+ */
951
+ warnings?: {
952
+ /**
953
+ * Suppresses specific warning messages.
954
+ */
955
+ suppress?: {
956
+ /**
957
+ * Suppresses Prisma-related warnings.
958
+ */
959
+ prisma?: {
960
+ /**
961
+ * Suppresses the warning emitted when no Prisma instance is found.
962
+ */
963
+ noInstanceFound?: boolean;
964
+ /**
965
+ * Suppresses the warning emitted when no Prisma schema is found.
966
+ */
967
+ noSchemaFound?: boolean;
968
+ };
969
+ };
970
+ };
971
+ /**
972
+ * Defines static file serving configurations.
973
+ *
974
+ * Arkos will automatically serve files from the configured folder using `express.static`.
975
+ * If the folder does not exist at startup, a warning will be emitted.
976
+ *
977
+ * **Note:** The static files route is **not** prefixed with the `globalPrefix`.
978
+ *
979
+ * @since 1.7.0-canary.16
980
+ *
981
+ * @example
982
+ * ```ts
983
+ * import { defineConfig } from "arkos"
984
+ *
985
+ * export default defineConfig({
986
+ * staticFiles: {
987
+ * folder: "assets",
988
+ * prefix: "/static",
989
+ * }
990
+ * }) */
991
+ staticFiles?: {
992
+ /**
993
+ * Whether to enable static file serving.
994
+ *
995
+ * Set to `false` to disable static file serving entirely and suppress
996
+ * the warning when the folder is not found.
997
+ *
998
+ * @default true
999
+ */
1000
+ enabled?: boolean;
1001
+ /**
1002
+ * The folder to serve static files from, relative to the project root.
1003
+ *
1004
+ * @default "public"
1005
+ */
1006
+ folder?: string;
1007
+ /**
1008
+ * The URL path prefix under which static files will be served.
1009
+ *
1010
+ * **Note:** This is not affected by `globalPrefix`.
1011
+ *
1012
+ * @default "/"
1013
+ *
1014
+ * @example "/static" // files served at /static/image.png
1015
+ */
1016
+ prefix?: string;
1017
+ /**
1018
+ * Options passed directly to `express.static()`.
1019
+ *
1020
+ * By passing custom options, they will be deep merged with the defaults.
1021
+ *
1022
+ * #### Default:
1023
+ * ```ts
1024
+ * {
1025
+ * maxAge: "1y",
1026
+ * etag: true,
1027
+ * lastModified: true,
1028
+ * dotfiles: "ignore",
1029
+ * fallthrough: true,
1030
+ * index: false,
1031
+ * cacheControl: true,
1032
+ * }
1033
+ * ```
1034
+ *
1035
+ * @see {@link https://expressjs.com/en/4x/api.html#express.static}
1036
+ */
1037
+ expressStatic?: Parameters<typeof express.static>[1];
1038
+ };
870
1039
  };
@@ -63,7 +63,7 @@ type FileUploadRouterConfig = {
63
63
  [K in FileUploadRouterEndpoint]?: Omit<ArkosRouteConfig, "path" | "uploads">;
64
64
  };
65
65
  /**
66
- * @deprecated use RouteHook instead
66
+ * @deprecated use 'import { RouteHook } from "arkos"' instead
67
67
  */
68
68
  export type RouterConfig<T extends string = string> = T extends "auth" ? AuthRouterConfig : T extends "file-upload" ? FileUploadRouterConfig : BaseRouterConfig;
69
69
  /**
@@ -1,6 +1,7 @@
1
1
  import { OpenAPIV3 } from "openapi-types";
2
2
  import { UploadConfig } from "./types/upload-config";
3
3
  declare class ArkosRouterOpenAPIManager {
4
+ private resolveSchemaFieldName;
4
5
  /**
5
6
  * Generates OpenAPI schema for file upload fields in multipart/form-data requests.
6
7
  * Converts upload configuration into OpenAPI-compliant schema and merges with existing body schema.
@@ -20,9 +21,21 @@ declare class ArkosRouterOpenAPIManager {
20
21
  *
21
22
  * @example
22
23
  * // Multiple fields upload
23
- * addUploadFields({ type: 'fields', fields: [{ name: 'avatar', maxCount: 1 }, { name: 'resume', maxCount: 1 }] })
24
+ * addUploadFields({
25
+ * type: 'fields',
26
+ * fields: [
27
+ * { name: 'avatar', type: 'single', uploadDir: 'images' },
28
+ * { name: 'gallery', type: 'array', maxCount: 6, uploadDir: 'gallery' },
29
+ * { name: 'banners[][images]', type: 'array', maxCount: 5, uploadDir: 'banners' }
30
+ * ]
31
+ * })
24
32
  */
25
33
  addUploadFields(uploadConfig: UploadConfig, existingSchema?: OpenAPIV3.SchemaObject): OpenAPIV3.SchemaObject;
34
+ /**
35
+ * Builds the OpenAPI property schema for a single field entry.
36
+ * Legacy entries (no type) are treated as array.
37
+ */
38
+ private buildFieldSchema;
26
39
  /**
27
40
  * Validates that a user-defined multipart/form-data schema includes all required upload fields
28
41
  * with correct types, formats, and required flags.