arkos 1.4.12-beta → 1.4.14-beta

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 (106) hide show
  1. package/dist/cjs/app.js +4 -1
  2. package/dist/cjs/app.js.map +1 -1
  3. package/dist/cjs/modules/auth/auth.router.js +3 -0
  4. package/dist/cjs/modules/auth/auth.router.js.map +1 -1
  5. package/dist/cjs/modules/base/base.middlewares.js +2 -1
  6. package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
  7. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +3 -0
  8. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  9. package/dist/cjs/modules/error-handler/error-handler.controller.js +18 -39
  10. package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
  11. package/dist/cjs/modules/error-handler/utils/app-error.js +0 -1
  12. package/dist/cjs/modules/error-handler/utils/app-error.js.map +1 -1
  13. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +8 -7
  14. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  15. package/dist/cjs/modules/error-handler/utils/errors.js +158 -0
  16. package/dist/cjs/modules/error-handler/utils/errors.js.map +1 -0
  17. package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js +1 -1
  18. package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js.map +1 -1
  19. package/dist/cjs/types/arkos-config/utils.js.map +1 -1
  20. package/dist/cjs/types/new-arkos-config.js.map +1 -1
  21. package/dist/cjs/utils/arkos-router/index.js +2 -1
  22. package/dist/cjs/utils/arkos-router/index.js.map +1 -1
  23. package/dist/cjs/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js +1 -1
  24. package/dist/cjs/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +1 -1
  25. package/dist/cjs/utils/arkos-router/utils/helpers/upload-manager.js +0 -1
  26. package/dist/cjs/utils/arkos-router/utils/helpers/upload-manager.js.map +1 -1
  27. package/dist/cjs/utils/cli/build.js +1 -1
  28. package/dist/cjs/utils/cli/build.js.map +1 -1
  29. package/dist/cjs/utils/cli/dev.js +3 -1
  30. package/dist/cjs/utils/cli/dev.js.map +1 -1
  31. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  32. package/dist/cjs/utils/dotenv.helpers.js +0 -6
  33. package/dist/cjs/utils/dotenv.helpers.js.map +1 -1
  34. package/dist/cjs/utils/helpers/arkos-config.helpers.js +17 -0
  35. package/dist/cjs/utils/helpers/arkos-config.helpers.js.map +1 -1
  36. package/dist/cjs/utils/helpers/exit-error.js +1 -0
  37. package/dist/cjs/utils/helpers/exit-error.js.map +1 -1
  38. package/dist/cjs/utils/helpers/prisma.helpers.js +6 -7
  39. package/dist/cjs/utils/helpers/prisma.helpers.js.map +1 -1
  40. package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -1
  41. package/dist/cjs/utils/helpers/url-helpers.js +14 -0
  42. package/dist/cjs/utils/helpers/url-helpers.js.map +1 -0
  43. package/dist/cjs/utils/initialize-app.js +8 -10
  44. package/dist/cjs/utils/initialize-app.js.map +1 -1
  45. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +12 -6
  46. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +1 -1
  47. package/dist/cjs/utils/prisma/prisma-schema-parser.js +10 -3
  48. package/dist/cjs/utils/prisma/prisma-schema-parser.js.map +1 -1
  49. package/dist/esm/app.js +5 -2
  50. package/dist/esm/app.js.map +1 -1
  51. package/dist/esm/modules/auth/auth.router.js +3 -0
  52. package/dist/esm/modules/auth/auth.router.js.map +1 -1
  53. package/dist/esm/modules/base/base.middlewares.js +2 -1
  54. package/dist/esm/modules/base/base.middlewares.js.map +1 -1
  55. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +3 -0
  56. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  57. package/dist/esm/modules/error-handler/error-handler.controller.js +18 -39
  58. package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
  59. package/dist/esm/modules/error-handler/utils/app-error.js +0 -1
  60. package/dist/esm/modules/error-handler/utils/app-error.js.map +1 -1
  61. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +8 -7
  62. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  63. package/dist/esm/modules/error-handler/utils/errors.js +127 -0
  64. package/dist/esm/modules/error-handler/utils/errors.js.map +1 -0
  65. package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js +1 -1
  66. package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js.map +1 -1
  67. package/dist/esm/types/arkos-config/utils.js.map +1 -1
  68. package/dist/esm/types/new-arkos-config.js.map +1 -1
  69. package/dist/esm/utils/arkos-router/index.js +2 -1
  70. package/dist/esm/utils/arkos-router/index.js.map +1 -1
  71. package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js +1 -1
  72. package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +1 -1
  73. package/dist/esm/utils/arkos-router/utils/helpers/upload-manager.js +0 -1
  74. package/dist/esm/utils/arkos-router/utils/helpers/upload-manager.js.map +1 -1
  75. package/dist/esm/utils/cli/build.js +1 -1
  76. package/dist/esm/utils/cli/build.js.map +1 -1
  77. package/dist/esm/utils/cli/dev.js +3 -1
  78. package/dist/esm/utils/cli/dev.js.map +1 -1
  79. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  80. package/dist/esm/utils/dotenv.helpers.js +0 -6
  81. package/dist/esm/utils/dotenv.helpers.js.map +1 -1
  82. package/dist/esm/utils/helpers/arkos-config.helpers.js +15 -0
  83. package/dist/esm/utils/helpers/arkos-config.helpers.js.map +1 -1
  84. package/dist/esm/utils/helpers/exit-error.js +1 -0
  85. package/dist/esm/utils/helpers/exit-error.js.map +1 -1
  86. package/dist/esm/utils/helpers/prisma.helpers.js +6 -7
  87. package/dist/esm/utils/helpers/prisma.helpers.js.map +1 -1
  88. package/dist/esm/utils/helpers/routers.helpers.js.map +1 -1
  89. package/dist/esm/utils/helpers/url-helpers.js +11 -0
  90. package/dist/esm/utils/helpers/url-helpers.js.map +1 -0
  91. package/dist/esm/utils/initialize-app.js +7 -10
  92. package/dist/esm/utils/initialize-app.js.map +1 -1
  93. package/dist/esm/utils/prisma/prisma-json-schema-generator.js +12 -6
  94. package/dist/esm/utils/prisma/prisma-json-schema-generator.js.map +1 -1
  95. package/dist/esm/utils/prisma/prisma-schema-parser.js +10 -3
  96. package/dist/esm/utils/prisma/prisma-schema-parser.js.map +1 -1
  97. package/dist/types/modules/error-handler/utils/app-error.d.ts +0 -2
  98. package/dist/types/modules/error-handler/utils/error-handler.helpers.d.ts +1 -1
  99. package/dist/types/modules/error-handler/utils/errors.d.ts +176 -0
  100. package/dist/types/types/arkos-config/utils.d.ts +58 -21
  101. package/dist/types/types/new-arkos-config.d.ts +23 -0
  102. package/dist/types/utils/helpers/arkos-config.helpers.d.ts +2 -0
  103. package/dist/types/utils/helpers/url-helpers.d.ts +1 -0
  104. package/dist/types/utils/initialize-app.d.ts +1 -0
  105. package/dist/types/utils/prisma/prisma-schema-parser.d.ts +1 -0
  106. package/package.json +1 -1
@@ -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
+ }
@@ -1,31 +1,68 @@
1
1
  import { ArkosRequest } from "..";
2
- /**
3
- * Context object passed to `before` auth hooks.
4
- */
5
- export interface AuthBeforeHookContext {
2
+ import { AccessAction, DetailedAccessControlRule } from "../auth";
3
+ /** Context passed to `before` hooks of `authenticate`. */
4
+ export interface AuthenticateBeforeHookContext {
5
+ /** The incoming request object. */
6
6
  req: ArkosRequest;
7
- /**
8
- * Bypasses core logic and jumps directly to `after` hooks.
9
- */
7
+ /** Bypasses core logic and jumps directly to `after` hooks. */
10
8
  skip: () => void;
11
9
  }
12
- /**
13
- * Context object passed to `after` auth hooks.
14
- */
15
- export interface AuthAfterHookContext {
10
+ /** Context passed to `after` hooks of `authenticate`. */
11
+ export interface AuthenticateAfterHookContext {
12
+ /** The incoming request object. */
16
13
  req: ArkosRequest;
17
14
  }
18
- /**
19
- * Context object passed to `onError` auth hooks.
20
- */
21
- export interface AuthErrorHookContext {
15
+ /** Context passed to `onError` hooks of `authenticate`. */
16
+ export interface AuthenticateErrorHookContext {
17
+ /** The incoming request object. */
22
18
  req: ArkosRequest;
19
+ /** The error thrown during authentication. */
23
20
  error: unknown;
24
- /**
25
- * Suppress the error and jump to `after` hooks.
26
- */
21
+ /** Suppresses the error and jumps to `after` hooks. */
27
22
  skip: () => void;
28
23
  }
29
- export type AuthHookHandler = (ctx: AuthBeforeHookContext) => void | Promise<void>;
30
- export type AuthAfterHookHandler = (ctx: AuthAfterHookContext) => void | Promise<void>;
31
- export type AuthErrorHookHandler = (ctx: AuthErrorHookContext) => void | Promise<void>;
24
+ export type AuthenticateHookHandler = (ctx: AuthenticateBeforeHookContext) => void | Promise<void>;
25
+ export type AuthenticateAfterHookHandler = (ctx: AuthenticateAfterHookContext) => void | Promise<void>;
26
+ export type AuthenticateErrorHookHandler = (ctx: AuthenticateErrorHookContext) => void | Promise<void>;
27
+ /** Context passed to `before` hooks of `authorize`. */
28
+ export interface AuthorizeBeforeHookContext {
29
+ /** The incoming request object. */
30
+ req: ArkosRequest;
31
+ /** The action being authorized (e.g. `"Create"`, `"Delete"`). */
32
+ action: AccessAction;
33
+ /** The resource being accessed in kebab-case (e.g. `"post"`, `"cart-item"`). */
34
+ resource: string;
35
+ /** The access control rule for this action. */
36
+ rule?: string[] | DetailedAccessControlRule | "*";
37
+ /** Bypasses core logic and jumps directly to `after` hooks. */
38
+ skip: () => void;
39
+ }
40
+ /** Context passed to `after` hooks of `authorize`. */
41
+ export interface AuthorizeAfterHookContext {
42
+ /** The incoming request object. */
43
+ req: ArkosRequest;
44
+ /** The action that was authorized (e.g. `"Create"`, `"Delete"`). */
45
+ action: AccessAction;
46
+ /** The resource that was accessed in kebab-case (e.g. `"post"`, `"cart-item"`). */
47
+ resource: string;
48
+ /** The access control rule that was applied. */
49
+ rule?: string[] | DetailedAccessControlRule | "*";
50
+ }
51
+ /** Context passed to `onError` hooks of `authorize`. */
52
+ export interface AuthorizeErrorHookContext {
53
+ /** The incoming request object. */
54
+ req: ArkosRequest;
55
+ /** The error thrown during authorization. */
56
+ error: unknown;
57
+ /** The action being authorized (e.g. `"Create"`, `"Delete"`). */
58
+ action: AccessAction;
59
+ /** The resource being accessed in kebab-case (e.g. `"post"`, `"cart-item"`). */
60
+ resource: string;
61
+ /** The access control rule for this action. */
62
+ rule?: string[] | DetailedAccessControlRule | "*";
63
+ /** Suppresses the error and jumps to `after` hooks. */
64
+ skip: () => void;
65
+ }
66
+ export type AuthorizeHookHandler = (ctx: AuthorizeBeforeHookContext) => void | Promise<void>;
67
+ export type AuthorizeAfterHookHandler = (ctx: AuthorizeAfterHookContext) => void | Promise<void>;
68
+ export type AuthorizeErrorHookHandler = (ctx: AuthorizeErrorHookContext) => void | Promise<void>;
@@ -731,4 +731,27 @@ export type ArkosConfig = {
731
731
  };
732
732
  };
733
733
  };
734
+ /**
735
+ * Allows to suppress specific warnings emitted by Arkos at startup or runtime.
736
+ */
737
+ warnings?: {
738
+ /**
739
+ * Suppresses specific warning messages.
740
+ */
741
+ suppress?: {
742
+ /**
743
+ * Suppresses Prisma-related warnings.
744
+ */
745
+ prisma?: {
746
+ /**
747
+ * Suppresses the warning emitted when no Prisma instance is found.
748
+ */
749
+ noInstanceFound?: boolean;
750
+ /**
751
+ * Suppresses the warning emitted when no Prisma schema is found.
752
+ */
753
+ noSchemaFound?: boolean;
754
+ };
755
+ };
756
+ };
734
757
  };
@@ -10,3 +10,5 @@ export declare const defaultArkosConfig: ArkosConfig & {
10
10
  * @returns {ArkosConfig}
11
11
  */
12
12
  export declare function getArkosConfig(): ArkosConfig;
13
+ export declare function isProduction(): boolean;
14
+ export declare function validateArkosConfig(): void;
@@ -0,0 +1 @@
1
+ export declare function lenientDecode(str: string): string;
@@ -1,2 +1,3 @@
1
1
  import { Arkos } from "../types/arkos";
2
2
  export default function initializeApp(app: Arkos): Arkos;
3
+ export declare function addGlobalErrorHandler(app: Arkos): Arkos;
@@ -29,6 +29,7 @@ export declare class PrismaSchemaParser {
29
29
  prismaSchemasContent: string;
30
30
  parsed: boolean;
31
31
  config: SchemaConfig;
32
+ warningNotLogged: boolean;
32
33
  constructor();
33
34
  /**
34
35
  * Parses the Prisma schema and extracts all models and enums.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkos",
3
- "version": "1.4.12-beta",
3
+ "version": "1.4.14-beta",
4
4
  "description": "The Express & Prisma RESTful Framework",
5
5
  "main": "dist/cjs/exports/index.js",
6
6
  "module": "dist/esm/exports/index.js",