@beethovn/errors 1.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/LICENSE +21 -0
- package/README.md +375 -0
- package/dist/auth/AuthError.d.ts +95 -0
- package/dist/auth/AuthError.d.ts.map +1 -0
- package/dist/auth/AuthError.js +109 -0
- package/dist/auth/AuthError.js.map +1 -0
- package/dist/base/BeethovnError.d.ts +51 -0
- package/dist/base/BeethovnError.d.ts.map +1 -0
- package/dist/base/BeethovnError.js +79 -0
- package/dist/base/BeethovnError.js.map +1 -0
- package/dist/domain/DomainError.d.ts +88 -0
- package/dist/domain/DomainError.d.ts.map +1 -0
- package/dist/domain/DomainError.js +100 -0
- package/dist/domain/DomainError.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/InfrastructureError.d.ts +98 -0
- package/dist/infrastructure/InfrastructureError.d.ts.map +1 -0
- package/dist/infrastructure/InfrastructureError.js +144 -0
- package/dist/infrastructure/InfrastructureError.js.map +1 -0
- package/dist/integration/IntegrationError.d.ts +71 -0
- package/dist/integration/IntegrationError.d.ts.map +1 -0
- package/dist/integration/IntegrationError.js +111 -0
- package/dist/integration/IntegrationError.js.map +1 -0
- package/dist/utils/errorFactory.d.ts +96 -0
- package/dist/utils/errorFactory.d.ts.map +1 -0
- package/dist/utils/errorFactory.js +116 -0
- package/dist/utils/errorFactory.js.map +1 -0
- package/dist/utils/errorGuards.d.ts +133 -0
- package/dist/utils/errorGuards.d.ts.map +1 -0
- package/dist/utils/errorGuards.js +152 -0
- package/dist/utils/errorGuards.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Beethovn errors
|
|
3
|
+
*
|
|
4
|
+
* Provides structured error information for logging, monitoring, and debugging.
|
|
5
|
+
* All custom errors in the Beethovn platform should extend this class.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* class MyCustomError extends BeethovnError {
|
|
10
|
+
* constructor(message: string) {
|
|
11
|
+
* super(message, 'MY_CUSTOM_ERROR', 400, { custom: 'metadata' });
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export class BeethovnError extends Error {
|
|
17
|
+
/** Unique error code for categorization and monitoring */
|
|
18
|
+
code;
|
|
19
|
+
/** HTTP status code (for API errors) */
|
|
20
|
+
statusCode;
|
|
21
|
+
/** Additional contextual metadata for debugging */
|
|
22
|
+
metadata;
|
|
23
|
+
/** Timestamp when error occurred */
|
|
24
|
+
timestamp;
|
|
25
|
+
/** Is this error recoverable with retry logic? */
|
|
26
|
+
recoverable;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new BeethovnError
|
|
29
|
+
*
|
|
30
|
+
* @param message - Human-readable error message
|
|
31
|
+
* @param code - Unique error code (e.g., 'VALIDATION_ERROR')
|
|
32
|
+
* @param statusCode - HTTP status code (default: 500)
|
|
33
|
+
* @param metadata - Additional context for debugging
|
|
34
|
+
* @param recoverable - Can this error be retried? (default: false)
|
|
35
|
+
*/
|
|
36
|
+
constructor(message, code, statusCode = 500, metadata = {}, recoverable = false) {
|
|
37
|
+
super(message);
|
|
38
|
+
this.name = this.constructor.name;
|
|
39
|
+
this.code = code;
|
|
40
|
+
this.statusCode = statusCode;
|
|
41
|
+
this.metadata = metadata;
|
|
42
|
+
this.timestamp = new Date();
|
|
43
|
+
this.recoverable = recoverable;
|
|
44
|
+
// Maintains proper stack trace for where error was thrown
|
|
45
|
+
Error.captureStackTrace(this, this.constructor);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Serialize error for logging and monitoring
|
|
49
|
+
*
|
|
50
|
+
* @returns Plain object representation of the error
|
|
51
|
+
*/
|
|
52
|
+
toJSON() {
|
|
53
|
+
return {
|
|
54
|
+
name: this.name,
|
|
55
|
+
code: this.code,
|
|
56
|
+
message: this.message,
|
|
57
|
+
statusCode: this.statusCode,
|
|
58
|
+
metadata: this.metadata,
|
|
59
|
+
timestamp: this.timestamp.toISOString(),
|
|
60
|
+
recoverable: this.recoverable,
|
|
61
|
+
stack: this.stack,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get a sanitized version of the error for client responses
|
|
66
|
+
* (Excludes stack traces and sensitive metadata)
|
|
67
|
+
*
|
|
68
|
+
* @returns Sanitized error object safe for API responses
|
|
69
|
+
*/
|
|
70
|
+
toClient() {
|
|
71
|
+
return {
|
|
72
|
+
code: this.code,
|
|
73
|
+
message: this.message,
|
|
74
|
+
statusCode: this.statusCode,
|
|
75
|
+
timestamp: this.timestamp.toISOString(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=BeethovnError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeethovnError.js","sourceRoot":"","sources":["../../src/base/BeethovnError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAgB,aAAc,SAAQ,KAAK;IAC/C,0DAA0D;IAC1C,IAAI,CAAS;IAE7B,wCAAwC;IACxB,UAAU,CAAS;IAEnC,mDAAmD;IACnC,QAAQ,CAA0B;IAElD,oCAAoC;IACpB,SAAS,CAAO;IAEhC,kDAAkD;IAClC,WAAW,CAAU;IAErC;;;;;;;;OAQG;IACH,YACE,OAAe,EACf,IAAY,EACZ,aAAqB,GAAG,EACxB,WAAoC,EAAE,EACtC,cAAuB,KAAK;QAE5B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,0DAA0D;QAC1D,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;YACvC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACN,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;SACxC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { BeethovnError } from '../base/BeethovnError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for domain/business logic errors
|
|
4
|
+
*
|
|
5
|
+
* Domain errors represent business rule violations, validation failures,
|
|
6
|
+
* and other application-level issues. These are typically user-fixable.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class DomainError extends BeethovnError {
|
|
9
|
+
constructor(message: string, code: string, metadata?: Record<string, unknown>);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validation error - input doesn't meet requirements
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* if (!email.includes('@')) {
|
|
17
|
+
* throw new ValidationError('Invalid email format', 'email');
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class ValidationError extends DomainError {
|
|
22
|
+
constructor(message: string, field?: string, metadata?: Record<string, unknown>);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Business rule violation
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* if (balance < amount) {
|
|
30
|
+
* throw new BusinessRuleError(
|
|
31
|
+
* 'Insufficient balance',
|
|
32
|
+
* 'MINIMUM_BALANCE',
|
|
33
|
+
* { balance, required: amount }
|
|
34
|
+
* );
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class BusinessRuleError extends DomainError {
|
|
39
|
+
constructor(message: string, rule: string, metadata?: Record<string, unknown>);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resource not found
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const user = await db.getUser(id);
|
|
47
|
+
* if (!user) {
|
|
48
|
+
* throw new NotFoundError('User', id, { tenantId });
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare class NotFoundError extends BeethovnError {
|
|
53
|
+
constructor(resource: string, id: string, metadata?: Record<string, unknown>);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resource already exists (conflict)
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* if (existingUser) {
|
|
61
|
+
* throw new ConflictError(
|
|
62
|
+
* 'User with this email already exists',
|
|
63
|
+
* { email }
|
|
64
|
+
* );
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare class ConflictError extends BeethovnError {
|
|
69
|
+
constructor(message: string, metadata?: Record<string, unknown>);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Invalid state transition
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* if (order.status === 'cancelled') {
|
|
77
|
+
* throw new InvalidStateError(
|
|
78
|
+
* 'Cannot modify cancelled order',
|
|
79
|
+
* 'cancelled',
|
|
80
|
+
* 'modify'
|
|
81
|
+
* );
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare class InvalidStateError extends DomainError {
|
|
86
|
+
constructor(message: string, currentState: string, attemptedAction: string, metadata?: Record<string, unknown>);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=DomainError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainError.d.ts","sourceRoot":"","sources":["../../src/domain/DomainError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;;;;GAKG;AACH,8BAAsB,WAAY,SAAQ,aAAa;gBAEnD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAIzC;AAED;;;;;;;;;GASG;AACH,qBAAa,eAAgB,SAAQ,WAAW;gBAE5C,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAQzC;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;gBAE9C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAIzC;AAED;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,SAAQ,aAAa;gBAE5C,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAUzC;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAc,SAAQ,aAAa;gBAE5C,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAIzC;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;gBAE9C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,EACvB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAQzC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { BeethovnError } from '../base/BeethovnError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for domain/business logic errors
|
|
4
|
+
*
|
|
5
|
+
* Domain errors represent business rule violations, validation failures,
|
|
6
|
+
* and other application-level issues. These are typically user-fixable.
|
|
7
|
+
*/
|
|
8
|
+
export class DomainError extends BeethovnError {
|
|
9
|
+
constructor(message, code, metadata = {}) {
|
|
10
|
+
super(message, code, 400, metadata, false);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validation error - input doesn't meet requirements
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* if (!email.includes('@')) {
|
|
19
|
+
* throw new ValidationError('Invalid email format', 'email');
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class ValidationError extends DomainError {
|
|
24
|
+
constructor(message, field, metadata = {}) {
|
|
25
|
+
super(message, 'VALIDATION_ERROR', field ? { ...metadata, field } : metadata);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Business rule violation
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* if (balance < amount) {
|
|
34
|
+
* throw new BusinessRuleError(
|
|
35
|
+
* 'Insufficient balance',
|
|
36
|
+
* 'MINIMUM_BALANCE',
|
|
37
|
+
* { balance, required: amount }
|
|
38
|
+
* );
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class BusinessRuleError extends DomainError {
|
|
43
|
+
constructor(message, rule, metadata = {}) {
|
|
44
|
+
super(message, 'BUSINESS_RULE_VIOLATION', { ...metadata, rule });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resource not found
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const user = await db.getUser(id);
|
|
53
|
+
* if (!user) {
|
|
54
|
+
* throw new NotFoundError('User', id, { tenantId });
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export class NotFoundError extends BeethovnError {
|
|
59
|
+
constructor(resource, id, metadata = {}) {
|
|
60
|
+
super(`${resource} not found: ${id}`, 'NOT_FOUND', 404, { ...metadata, resource, id }, false);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resource already exists (conflict)
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* if (existingUser) {
|
|
69
|
+
* throw new ConflictError(
|
|
70
|
+
* 'User with this email already exists',
|
|
71
|
+
* { email }
|
|
72
|
+
* );
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export class ConflictError extends BeethovnError {
|
|
77
|
+
constructor(message, metadata = {}) {
|
|
78
|
+
super(message, 'CONFLICT', 409, metadata, false);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Invalid state transition
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* if (order.status === 'cancelled') {
|
|
87
|
+
* throw new InvalidStateError(
|
|
88
|
+
* 'Cannot modify cancelled order',
|
|
89
|
+
* 'cancelled',
|
|
90
|
+
* 'modify'
|
|
91
|
+
* );
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export class InvalidStateError extends DomainError {
|
|
96
|
+
constructor(message, currentState, attemptedAction, metadata = {}) {
|
|
97
|
+
super(message, 'INVALID_STATE', { ...metadata, currentState, attemptedAction });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=DomainError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainError.js","sourceRoot":"","sources":["../../src/domain/DomainError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,OAAgB,WAAY,SAAQ,aAAa;IACrD,YACE,OAAe,EACf,IAAY,EACZ,WAAoC,EAAE;QAEtC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC9C,YACE,OAAe,EACf,KAAc,EACd,WAAoC,EAAE;QAEtC,KAAK,CACH,OAAO,EACP,kBAAkB,EAClB,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAC1C,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,YACE,OAAe,EACf,IAAY,EACZ,WAAoC,EAAE;QAEtC,KAAK,CAAC,OAAO,EAAE,yBAAyB,EAAE,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,YACE,QAAgB,EAChB,EAAU,EACV,WAAoC,EAAE;QAEtC,KAAK,CACH,GAAG,QAAQ,eAAe,EAAE,EAAE,EAC9B,WAAW,EACX,GAAG,EACH,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,EAC7B,KAAK,CACN,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,YACE,OAAe,EACf,WAAoC,EAAE;QAEtC,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,YACE,OAAe,EACf,YAAoB,EACpB,eAAuB,EACvB,WAAoC,EAAE;QAEtC,KAAK,CACH,OAAO,EACP,eAAe,EACf,EAAE,GAAG,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,CAC/C,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @beethovn/errors
|
|
3
|
+
*
|
|
4
|
+
* Standardized error types for the Beethovn platform.
|
|
5
|
+
* Provides structured, typed errors with rich metadata for better
|
|
6
|
+
* debugging, logging, and monitoring.
|
|
7
|
+
*/
|
|
8
|
+
export { BeethovnError } from './base/BeethovnError.js';
|
|
9
|
+
export { DomainError, ValidationError, BusinessRuleError, NotFoundError, ConflictError, InvalidStateError, } from './domain/DomainError.js';
|
|
10
|
+
export { InfrastructureError, DatabaseError, NetworkError, ExternalServiceError, TimeoutError, RateLimitError, UnknownError, } from './infrastructure/InfrastructureError.js';
|
|
11
|
+
export { AuthError, InvalidCredentialsError, TokenExpiredError, InvalidTokenError, PermissionDeniedError, ForbiddenError, UnauthenticatedError, } from './auth/AuthError.js';
|
|
12
|
+
export { IntegrationError, EventPublishError, MessageQueueError, WebSocketError, EventSubscriptionError, } from './integration/IntegrationError.js';
|
|
13
|
+
export { ErrorFactory } from './utils/errorFactory.js';
|
|
14
|
+
export { isBeethovnError, isDomainError, isInfrastructureError, isAuthError, isIntegrationError, isRecoverableError, isClientSafeError, getErrorStatusCode, } from './utils/errorGuards.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EACL,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACL,SAAS,EACT,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,sBAAsB,GACvB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @beethovn/errors
|
|
3
|
+
*
|
|
4
|
+
* Standardized error types for the Beethovn platform.
|
|
5
|
+
* Provides structured, typed errors with rich metadata for better
|
|
6
|
+
* debugging, logging, and monitoring.
|
|
7
|
+
*/
|
|
8
|
+
// Base error
|
|
9
|
+
export { BeethovnError } from './base/BeethovnError.js';
|
|
10
|
+
// Domain errors
|
|
11
|
+
export { DomainError, ValidationError, BusinessRuleError, NotFoundError, ConflictError, InvalidStateError, } from './domain/DomainError.js';
|
|
12
|
+
// Infrastructure errors
|
|
13
|
+
export { InfrastructureError, DatabaseError, NetworkError, ExternalServiceError, TimeoutError, RateLimitError, UnknownError, } from './infrastructure/InfrastructureError.js';
|
|
14
|
+
// Auth errors
|
|
15
|
+
export { AuthError, InvalidCredentialsError, TokenExpiredError, InvalidTokenError, PermissionDeniedError, ForbiddenError, UnauthenticatedError, } from './auth/AuthError.js';
|
|
16
|
+
// Integration errors
|
|
17
|
+
export { IntegrationError, EventPublishError, MessageQueueError, WebSocketError, EventSubscriptionError, } from './integration/IntegrationError.js';
|
|
18
|
+
// Utilities
|
|
19
|
+
export { ErrorFactory } from './utils/errorFactory.js';
|
|
20
|
+
export { isBeethovnError, isDomainError, isInfrastructureError, isAuthError, isIntegrationError, isRecoverableError, isClientSafeError, getErrorStatusCode, } from './utils/errorGuards.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,aAAa;AACb,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,gBAAgB;AAChB,OAAO,EACL,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,wBAAwB;AACxB,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,yCAAyC,CAAC;AAEjD,cAAc;AACd,OAAO,EACL,SAAS,EACT,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,qBAAqB;AACrB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,sBAAsB,GACvB,MAAM,mCAAmC,CAAC;AAE3C,YAAY;AACZ,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { BeethovnError } from '../base/BeethovnError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for infrastructure/technical errors
|
|
4
|
+
*
|
|
5
|
+
* Infrastructure errors represent technical failures like database issues,
|
|
6
|
+
* network problems, or external service failures. These are typically recoverable.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class InfrastructureError extends BeethovnError {
|
|
9
|
+
constructor(message: string, code: string, metadata?: Record<string, unknown>, recoverable?: boolean);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Database operation error
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* try {
|
|
17
|
+
* await db.query(sql, params);
|
|
18
|
+
* } catch (error: unknown) {
|
|
19
|
+
* throw new DatabaseError('saveUser', error);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class DatabaseError extends InfrastructureError {
|
|
24
|
+
constructor(operation: string, originalError?: unknown, metadata?: Record<string, unknown>);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Network/connectivity error
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* try {
|
|
32
|
+
* await fetch(url);
|
|
33
|
+
* } catch (error: unknown) {
|
|
34
|
+
* throw new NetworkError('Failed to fetch user data', { url });
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class NetworkError extends InfrastructureError {
|
|
39
|
+
constructor(message: string, metadata?: Record<string, unknown>);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* External service error
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* try {
|
|
47
|
+
* await stripeClient.charge(amount);
|
|
48
|
+
* } catch (error: unknown) {
|
|
49
|
+
* throw new ExternalServiceError(
|
|
50
|
+
* 'Stripe',
|
|
51
|
+
* 'createCharge',
|
|
52
|
+
* error,
|
|
53
|
+
* { amount, currency }
|
|
54
|
+
* );
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare class ExternalServiceError extends InfrastructureError {
|
|
59
|
+
constructor(service: string, operation: string, originalError?: unknown, metadata?: Record<string, unknown>);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Timeout error
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* throw new TimeoutError('Database query', 5000, { query: 'SELECT ...' });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare class TimeoutError extends InfrastructureError {
|
|
70
|
+
constructor(operation: string, timeoutMs: number, metadata?: Record<string, unknown>);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Rate limit exceeded error
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* if (requestCount > limit) {
|
|
78
|
+
* throw new RateLimitError(limit, requestCount, 60);
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare class RateLimitError extends BeethovnError {
|
|
83
|
+
constructor(limit: number, current: number, retryAfterSeconds?: number, metadata?: Record<string, unknown>);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Unknown error - for errors that don't fit other categories
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* catch (error: unknown) {
|
|
91
|
+
* throw new UnknownError(error, 'processPayment');
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare class UnknownError extends InfrastructureError {
|
|
96
|
+
constructor(originalError: unknown, context?: string, metadata?: Record<string, unknown>);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=InfrastructureError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfrastructureError.d.ts","sourceRoot":"","sources":["../../src/infrastructure/InfrastructureError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;;;;GAKG;AACH,8BAAsB,mBAAoB,SAAQ,aAAa;gBAE3D,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACtC,WAAW,GAAE,OAAc;CAI9B;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,aAAc,SAAQ,mBAAmB;gBAElD,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,OAAO,EACvB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAiBzC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,YAAa,SAAQ,mBAAmB;gBAEjD,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAIzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,oBAAqB,SAAQ,mBAAmB;gBAEzD,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,OAAO,EACvB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAkBzC;AAED;;;;;;;GAOG;AACH,qBAAa,YAAa,SAAQ,mBAAmB;gBAEjD,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CASzC;AAED;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,aAAa;gBAE7C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,iBAAiB,CAAC,EAAE,MAAM,EAC1B,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAezC;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAa,SAAQ,mBAAmB;gBAEjD,aAAa,EAAE,OAAO,EACtB,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAuBzC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { BeethovnError } from '../base/BeethovnError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for infrastructure/technical errors
|
|
4
|
+
*
|
|
5
|
+
* Infrastructure errors represent technical failures like database issues,
|
|
6
|
+
* network problems, or external service failures. These are typically recoverable.
|
|
7
|
+
*/
|
|
8
|
+
export class InfrastructureError extends BeethovnError {
|
|
9
|
+
constructor(message, code, metadata = {}, recoverable = true) {
|
|
10
|
+
super(message, code, 503, metadata, recoverable);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Database operation error
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* try {
|
|
19
|
+
* await db.query(sql, params);
|
|
20
|
+
* } catch (error: unknown) {
|
|
21
|
+
* throw new DatabaseError('saveUser', error);
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export class DatabaseError extends InfrastructureError {
|
|
26
|
+
constructor(operation, originalError, metadata = {}) {
|
|
27
|
+
const errorMessage = originalError instanceof Error
|
|
28
|
+
? originalError.message
|
|
29
|
+
: String(originalError);
|
|
30
|
+
super(`Database ${operation} failed: ${errorMessage}`, 'DATABASE_ERROR', {
|
|
31
|
+
...metadata,
|
|
32
|
+
operation,
|
|
33
|
+
originalError: errorMessage,
|
|
34
|
+
}, true);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Network/connectivity error
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* try {
|
|
43
|
+
* await fetch(url);
|
|
44
|
+
* } catch (error: unknown) {
|
|
45
|
+
* throw new NetworkError('Failed to fetch user data', { url });
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export class NetworkError extends InfrastructureError {
|
|
50
|
+
constructor(message, metadata = {}) {
|
|
51
|
+
super(message, 'NETWORK_ERROR', metadata, true);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* External service error
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* try {
|
|
60
|
+
* await stripeClient.charge(amount);
|
|
61
|
+
* } catch (error: unknown) {
|
|
62
|
+
* throw new ExternalServiceError(
|
|
63
|
+
* 'Stripe',
|
|
64
|
+
* 'createCharge',
|
|
65
|
+
* error,
|
|
66
|
+
* { amount, currency }
|
|
67
|
+
* );
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export class ExternalServiceError extends InfrastructureError {
|
|
72
|
+
constructor(service, operation, originalError, metadata = {}) {
|
|
73
|
+
const errorMessage = originalError instanceof Error
|
|
74
|
+
? originalError.message
|
|
75
|
+
: String(originalError);
|
|
76
|
+
super(`${service} ${operation} failed: ${errorMessage}`, 'EXTERNAL_SERVICE_ERROR', {
|
|
77
|
+
...metadata,
|
|
78
|
+
service,
|
|
79
|
+
operation,
|
|
80
|
+
originalError: errorMessage,
|
|
81
|
+
}, true);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Timeout error
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* throw new TimeoutError('Database query', 5000, { query: 'SELECT ...' });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export class TimeoutError extends InfrastructureError {
|
|
93
|
+
constructor(operation, timeoutMs, metadata = {}) {
|
|
94
|
+
super(`${operation} timed out after ${timeoutMs}ms`, 'TIMEOUT_ERROR', { ...metadata, operation, timeoutMs }, true);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Rate limit exceeded error
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* if (requestCount > limit) {
|
|
103
|
+
* throw new RateLimitError(limit, requestCount, 60);
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export class RateLimitError extends BeethovnError {
|
|
108
|
+
constructor(limit, current, retryAfterSeconds, metadata = {}) {
|
|
109
|
+
super(`Rate limit exceeded: ${current}/${limit} requests`, 'RATE_LIMIT_ERROR', 429, {
|
|
110
|
+
...metadata,
|
|
111
|
+
limit,
|
|
112
|
+
current,
|
|
113
|
+
retryAfterSeconds,
|
|
114
|
+
}, true);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Unknown error - for errors that don't fit other categories
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* catch (error: unknown) {
|
|
123
|
+
* throw new UnknownError(error, 'processPayment');
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export class UnknownError extends InfrastructureError {
|
|
128
|
+
constructor(originalError, context, metadata = {}) {
|
|
129
|
+
const message = originalError instanceof Error
|
|
130
|
+
? originalError.message
|
|
131
|
+
: String(originalError);
|
|
132
|
+
const stack = originalError instanceof Error
|
|
133
|
+
? originalError.stack
|
|
134
|
+
: undefined;
|
|
135
|
+
super(message || 'An unknown error occurred', 'UNKNOWN_ERROR', {
|
|
136
|
+
...metadata,
|
|
137
|
+
originalError: message,
|
|
138
|
+
errorType: typeof originalError,
|
|
139
|
+
context,
|
|
140
|
+
stack,
|
|
141
|
+
}, false);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=InfrastructureError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfrastructureError.js","sourceRoot":"","sources":["../../src/infrastructure/InfrastructureError.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BeethovnError } from '../base/BeethovnError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for integration errors
|
|
4
|
+
*
|
|
5
|
+
* Integration errors represent failures in event publishing, message queues,
|
|
6
|
+
* and other inter-service communication mechanisms.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class IntegrationError extends BeethovnError {
|
|
9
|
+
constructor(message: string, code: string, metadata?: Record<string, unknown>, recoverable?: boolean);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Event publishing error
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* try {
|
|
17
|
+
* await eventBus.publish(event);
|
|
18
|
+
* } catch (error: unknown) {
|
|
19
|
+
* throw new EventPublishError(event.type, error, { eventId: event.id });
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class EventPublishError extends IntegrationError {
|
|
24
|
+
constructor(eventType: string, originalError?: unknown, metadata?: Record<string, unknown>);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Message queue error
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* try {
|
|
32
|
+
* await messageQueue.send(message);
|
|
33
|
+
* } catch (error: unknown) {
|
|
34
|
+
* throw new MessageQueueError('send', 'payment-queue', error);
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class MessageQueueError extends IntegrationError {
|
|
39
|
+
constructor(operation: string, queue: string, originalError?: unknown, metadata?: Record<string, unknown>);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* WebSocket connection error
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* try {
|
|
47
|
+
* await ws.connect();
|
|
48
|
+
* } catch (error: unknown) {
|
|
49
|
+
* throw new WebSocketError('connect', error, { url });
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare class WebSocketError extends IntegrationError {
|
|
54
|
+
constructor(operation: string, originalError?: unknown, metadata?: Record<string, unknown>);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Event subscription error
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* try {
|
|
62
|
+
* eventBus.subscribe('OrderCreated', handler);
|
|
63
|
+
* } catch (error: unknown) {
|
|
64
|
+
* throw new EventSubscriptionError('OrderCreated', error);
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare class EventSubscriptionError extends IntegrationError {
|
|
69
|
+
constructor(eventType: string, originalError?: unknown, metadata?: Record<string, unknown>);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=IntegrationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntegrationError.d.ts","sourceRoot":"","sources":["../../src/integration/IntegrationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;;;;GAKG;AACH,8BAAsB,gBAAiB,SAAQ,aAAa;gBAExD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACtC,WAAW,GAAE,OAAc;CAI9B;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAkB,SAAQ,gBAAgB;gBAEnD,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,OAAO,EACvB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAiBzC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAkB,SAAQ,gBAAgB;gBAEnD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,OAAO,EACvB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAkBzC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,cAAe,SAAQ,gBAAgB;gBAEhD,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,OAAO,EACvB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAiBzC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,sBAAuB,SAAQ,gBAAgB;gBAExD,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,OAAO,EACvB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAiBzC"}
|