@gravito/core 2.0.6 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PlanetCore.d.ts +6 -0
- package/dist/events/CircuitBreaker.d.ts +12 -0
- package/dist/exceptions/AuthException.d.ts +10 -0
- package/dist/exceptions/AuthenticationException.d.ts +2 -2
- package/dist/exceptions/AuthorizationException.d.ts +2 -2
- package/dist/exceptions/CacheException.d.ts +9 -0
- package/dist/exceptions/CircularDependencyException.d.ts +2 -1
- package/dist/exceptions/ConfigurationException.d.ts +9 -0
- package/dist/exceptions/DatabaseException.d.ts +9 -0
- package/dist/exceptions/DomainException.d.ts +9 -0
- package/dist/exceptions/InfrastructureException.d.ts +17 -0
- package/dist/exceptions/QueueException.d.ts +9 -0
- package/dist/exceptions/StorageException.d.ts +9 -0
- package/dist/exceptions/StreamException.d.ts +9 -0
- package/dist/exceptions/SystemException.d.ts +9 -0
- package/dist/exceptions/ValidationException.d.ts +2 -2
- package/dist/exceptions/index.d.ts +10 -0
- package/dist/index.browser.js +54 -32
- package/dist/index.browser.js.map +9 -7
- package/dist/index.js +159 -41
- package/dist/index.js.map +21 -11
- package/package.json +1 -1
package/dist/PlanetCore.d.ts
CHANGED
|
@@ -183,6 +183,12 @@ export declare class PlanetCore {
|
|
|
183
183
|
private deferredProviders;
|
|
184
184
|
private bootedProviders;
|
|
185
185
|
private isShuttingDown;
|
|
186
|
+
/**
|
|
187
|
+
* Global shutdown timeout in milliseconds (D-10).
|
|
188
|
+
* If the entire shutdown sequence does not complete within this limit,
|
|
189
|
+
* a warning is logged and shutdown is force-completed so the process can exit.
|
|
190
|
+
*/
|
|
191
|
+
private static readonly GLOBAL_SHUTDOWN_TIMEOUT;
|
|
186
192
|
/**
|
|
187
193
|
* Initialize observability asynchronously (metrics, tracing, Prometheus).
|
|
188
194
|
* This is called from constructor but doesn't block initialization.
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event-system CircuitBreaker — standalone copy.
|
|
3
|
+
*
|
|
4
|
+
* NOTE: This is intentionally NOT a re-export from @gravito/resilience
|
|
5
|
+
* to avoid a circular dependency (core <-> resilience):
|
|
6
|
+
* @gravito/core -> @gravito/resilience (peerDep of resilience -> core)
|
|
7
|
+
*
|
|
8
|
+
* The canonical CB implementation lives in @gravito/resilience.
|
|
9
|
+
* Keep this file in sync manually if the canonical CB API changes.
|
|
10
|
+
*
|
|
11
|
+
* Per D-02 decision recorded in 17-RESEARCH.md.
|
|
12
|
+
*/
|
|
1
13
|
/**
|
|
2
14
|
* Circuit Breaker state enum.
|
|
3
15
|
* @public
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ExceptionOptions } from './GravitoException';
|
|
2
|
+
import { DomainException } from './DomainException';
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base class for authentication/authorization-related domain errors.
|
|
5
|
+
* Used by fortify and sentinel packages.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class AuthException extends DomainException {
|
|
9
|
+
constructor(status: number, code: string, options?: ExceptionOptions);
|
|
10
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DomainException } from './DomainException';
|
|
2
2
|
/**
|
|
3
3
|
* Exception thrown when authentication fails.
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export declare class AuthenticationException extends
|
|
6
|
+
export declare class AuthenticationException extends DomainException {
|
|
7
7
|
constructor(message?: string);
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DomainException } from './DomainException';
|
|
2
2
|
/**
|
|
3
3
|
* Exception thrown when user is not authorized to perform an action.
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export declare class AuthorizationException extends
|
|
6
|
+
export declare class AuthorizationException extends DomainException {
|
|
7
7
|
constructor(message?: string);
|
|
8
8
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InfrastructureException, type InfrastructureExceptionOptions } from './InfrastructureException';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for cache/Redis-related infrastructure errors.
|
|
4
|
+
* All plasma error classes extend this instead of bare Error.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class CacheException extends InfrastructureException {
|
|
8
|
+
constructor(status: number, code: string, options?: InfrastructureExceptionOptions);
|
|
9
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ServiceKey } from '../Container';
|
|
2
|
+
import { SystemException } from './SystemException';
|
|
2
3
|
/**
|
|
3
4
|
* CircularDependencyException - Thrown when the container detects an infinite loop.
|
|
4
5
|
*
|
|
5
6
|
* @module @gravito/core
|
|
6
7
|
*/
|
|
7
|
-
export declare class CircularDependencyException extends
|
|
8
|
+
export declare class CircularDependencyException extends SystemException {
|
|
8
9
|
constructor(key: ServiceKey, stack: ServiceKey[]);
|
|
9
10
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ExceptionOptions } from './GravitoException';
|
|
2
|
+
import { SystemException } from './SystemException';
|
|
3
|
+
/**
|
|
4
|
+
* Thrown when the framework encounters an invalid or missing configuration value.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare class ConfigurationException extends SystemException {
|
|
8
|
+
constructor(message: string, options?: Omit<ExceptionOptions, 'message'>);
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InfrastructureException, type InfrastructureExceptionOptions } from './InfrastructureException';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for database-related infrastructure errors.
|
|
4
|
+
* All atlas error classes extend this instead of bare Error.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class DatabaseException extends InfrastructureException {
|
|
8
|
+
constructor(status: number, code: string, options?: InfrastructureExceptionOptions);
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ExceptionOptions, GravitoException } from './GravitoException';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for business logic / domain rule violations.
|
|
4
|
+
* Extend this for exceptions that represent a caller mistake (invalid input, constraint violation, etc.).
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class DomainException extends GravitoException {
|
|
8
|
+
constructor(status: number, code: string, options?: ExceptionOptions);
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ExceptionOptions, GravitoException } from './GravitoException';
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating an InfrastructureException
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface InfrastructureExceptionOptions extends ExceptionOptions {
|
|
7
|
+
retryable?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Abstract base class for infrastructure / I/O errors (database, network, filesystem, etc.).
|
|
11
|
+
* Carries a `retryable` flag that callers can inspect to decide whether the operation should be retried.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class InfrastructureException extends GravitoException {
|
|
15
|
+
readonly retryable: boolean;
|
|
16
|
+
constructor(status: number, code: string, options?: InfrastructureExceptionOptions);
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InfrastructureException, type InfrastructureExceptionOptions } from './InfrastructureException';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for message queue infrastructure errors.
|
|
4
|
+
* Used by quasar and flux packages.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class QueueException extends InfrastructureException {
|
|
8
|
+
constructor(status: number, code: string, options?: InfrastructureExceptionOptions);
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InfrastructureException, type InfrastructureExceptionOptions } from './InfrastructureException';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for file/object storage infrastructure errors.
|
|
4
|
+
* Used by constellation, nebula, nebula-s3, freeze, stasis packages.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class StorageException extends InfrastructureException {
|
|
8
|
+
constructor(status: number, code: string, options?: InfrastructureExceptionOptions);
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InfrastructureException, type InfrastructureExceptionOptions } from './InfrastructureException';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for stream/message processing infrastructure errors.
|
|
4
|
+
* Used by the stream package (Kafka, RabbitMQ, SQS).
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class StreamException extends InfrastructureException {
|
|
8
|
+
constructor(status: number, code: string, options?: InfrastructureExceptionOptions);
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ExceptionOptions, GravitoException } from './GravitoException';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for internal framework / system-level errors.
|
|
4
|
+
* Extend this for exceptions that represent an unexpected or unrecoverable framework state.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class SystemException extends GravitoException {
|
|
8
|
+
constructor(status: number, code: string, options?: ExceptionOptions);
|
|
9
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DomainException } from './DomainException';
|
|
2
2
|
/**
|
|
3
3
|
* Structure of a validation error
|
|
4
4
|
* @public
|
|
@@ -12,7 +12,7 @@ export interface ValidationError {
|
|
|
12
12
|
* Exception thrown when data validation fails.
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
export declare class ValidationException extends
|
|
15
|
+
export declare class ValidationException extends DomainException {
|
|
16
16
|
readonly errors: ValidationError[];
|
|
17
17
|
redirectTo?: string;
|
|
18
18
|
input?: unknown;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
export * from './AuthenticationException';
|
|
2
|
+
export * from './AuthException';
|
|
2
3
|
export * from './AuthorizationException';
|
|
4
|
+
export * from './CacheException';
|
|
3
5
|
export * from './CircularDependencyException';
|
|
6
|
+
export * from './ConfigurationException';
|
|
7
|
+
export * from './DatabaseException';
|
|
8
|
+
export * from './DomainException';
|
|
4
9
|
export * from './GravitoException';
|
|
5
10
|
export * from './HttpException';
|
|
11
|
+
export * from './InfrastructureException';
|
|
6
12
|
export * from './ModelNotFoundException';
|
|
13
|
+
export * from './QueueException';
|
|
14
|
+
export * from './StorageException';
|
|
15
|
+
export * from './StreamException';
|
|
16
|
+
export * from './SystemException';
|
|
7
17
|
export * from './ValidationException';
|
package/dist/index.browser.js
CHANGED
|
@@ -149,7 +149,7 @@ var randomBytes = randomBytesFn;
|
|
|
149
149
|
// package.json
|
|
150
150
|
var package_default = {
|
|
151
151
|
name: "@gravito/core",
|
|
152
|
-
version: "
|
|
152
|
+
version: "3.0.0",
|
|
153
153
|
description: "",
|
|
154
154
|
module: "./dist/index.js",
|
|
155
155
|
main: "./dist/index.js",
|
|
@@ -3609,11 +3609,50 @@ class ConfigManager {
|
|
|
3609
3609
|
}
|
|
3610
3610
|
}
|
|
3611
3611
|
}
|
|
3612
|
+
// src/exceptions/GravitoException.ts
|
|
3613
|
+
class GravitoException extends Error {
|
|
3614
|
+
status;
|
|
3615
|
+
code;
|
|
3616
|
+
i18nKey;
|
|
3617
|
+
i18nParams;
|
|
3618
|
+
constructor(status, code, options2 = {}) {
|
|
3619
|
+
super(options2.message);
|
|
3620
|
+
this.name = "GravitoException";
|
|
3621
|
+
this.status = status;
|
|
3622
|
+
this.cause = options2.cause;
|
|
3623
|
+
this.code = code;
|
|
3624
|
+
if (options2.i18nKey) {
|
|
3625
|
+
this.i18nKey = options2.i18nKey;
|
|
3626
|
+
}
|
|
3627
|
+
if (options2.i18nParams) {
|
|
3628
|
+
this.i18nParams = options2.i18nParams;
|
|
3629
|
+
}
|
|
3630
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3631
|
+
}
|
|
3632
|
+
getLocalizedMessage(t) {
|
|
3633
|
+
if (this.i18nKey) {
|
|
3634
|
+
return t(this.i18nKey, this.i18nParams);
|
|
3635
|
+
}
|
|
3636
|
+
return this.message;
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3640
|
+
// src/exceptions/SystemException.ts
|
|
3641
|
+
class SystemException extends GravitoException {
|
|
3642
|
+
constructor(status, code, options2 = {}) {
|
|
3643
|
+
super(status, code, options2);
|
|
3644
|
+
this.name = "SystemException";
|
|
3645
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
|
|
3612
3649
|
// src/exceptions/CircularDependencyException.ts
|
|
3613
|
-
class CircularDependencyException extends
|
|
3650
|
+
class CircularDependencyException extends SystemException {
|
|
3614
3651
|
constructor(key, stack) {
|
|
3615
3652
|
const path2 = [...stack, key].map(String).join(" -> ");
|
|
3616
|
-
super(
|
|
3653
|
+
super(500, "system.circular_dependency", {
|
|
3654
|
+
message: `Circular dependency detected: ${path2}`
|
|
3655
|
+
});
|
|
3617
3656
|
this.name = "CircularDependencyException";
|
|
3618
3657
|
}
|
|
3619
3658
|
}
|
|
@@ -4107,33 +4146,6 @@ function detectRequestScopeLeaks(context) {
|
|
|
4107
4146
|
};
|
|
4108
4147
|
}
|
|
4109
4148
|
|
|
4110
|
-
// src/exceptions/GravitoException.ts
|
|
4111
|
-
class GravitoException extends Error {
|
|
4112
|
-
status;
|
|
4113
|
-
code;
|
|
4114
|
-
i18nKey;
|
|
4115
|
-
i18nParams;
|
|
4116
|
-
constructor(status, code, options2 = {}) {
|
|
4117
|
-
super(options2.message);
|
|
4118
|
-
this.name = "GravitoException";
|
|
4119
|
-
this.status = status;
|
|
4120
|
-
this.cause = options2.cause;
|
|
4121
|
-
this.code = code;
|
|
4122
|
-
if (options2.i18nKey) {
|
|
4123
|
-
this.i18nKey = options2.i18nKey;
|
|
4124
|
-
}
|
|
4125
|
-
if (options2.i18nParams) {
|
|
4126
|
-
this.i18nParams = options2.i18nParams;
|
|
4127
|
-
}
|
|
4128
|
-
}
|
|
4129
|
-
getLocalizedMessage(t) {
|
|
4130
|
-
if (this.i18nKey) {
|
|
4131
|
-
return t(this.i18nKey, this.i18nParams);
|
|
4132
|
-
}
|
|
4133
|
-
return this.message;
|
|
4134
|
-
}
|
|
4135
|
-
}
|
|
4136
|
-
|
|
4137
4149
|
// src/exceptions/HttpException.ts
|
|
4138
4150
|
class HttpException extends GravitoException {
|
|
4139
4151
|
constructor(status, options2 = {}) {
|
|
@@ -4142,8 +4154,17 @@ class HttpException extends GravitoException {
|
|
|
4142
4154
|
}
|
|
4143
4155
|
}
|
|
4144
4156
|
|
|
4157
|
+
// src/exceptions/DomainException.ts
|
|
4158
|
+
class DomainException extends GravitoException {
|
|
4159
|
+
constructor(status, code, options2 = {}) {
|
|
4160
|
+
super(status, code, options2);
|
|
4161
|
+
this.name = "DomainException";
|
|
4162
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
4163
|
+
}
|
|
4164
|
+
}
|
|
4165
|
+
|
|
4145
4166
|
// src/exceptions/ValidationException.ts
|
|
4146
|
-
class ValidationException extends
|
|
4167
|
+
class ValidationException extends DomainException {
|
|
4147
4168
|
errors;
|
|
4148
4169
|
redirectTo;
|
|
4149
4170
|
input;
|
|
@@ -4152,6 +4173,7 @@ class ValidationException extends GravitoException {
|
|
|
4152
4173
|
message,
|
|
4153
4174
|
i18nKey: "errors.validation.failed"
|
|
4154
4175
|
});
|
|
4176
|
+
this.name = "ValidationException";
|
|
4155
4177
|
this.errors = errors;
|
|
4156
4178
|
}
|
|
4157
4179
|
withRedirect(url) {
|
|
@@ -9030,4 +9052,4 @@ export {
|
|
|
9030
9052
|
Arr
|
|
9031
9053
|
};
|
|
9032
9054
|
|
|
9033
|
-
//# debugId=
|
|
9055
|
+
//# debugId=004674489562A73F64756E2164756E21
|