@explorins/pers-shared 2.1.10 → 2.1.12
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/README.md +0 -0
- package/dist/cjs/index.d.ts +1 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +0 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/token-transaction-input-data.interface.d.ts +2 -1
- package/dist/cjs/interfaces/token-transaction-input-data.interface.d.ts.map +1 -1
- package/dist/cjs/internal/database/index.d.ts +6 -0
- package/dist/cjs/internal/database/index.d.ts.map +1 -0
- package/dist/cjs/internal/database/index.js +24 -0
- package/dist/cjs/internal/database/index.js.map +1 -0
- package/dist/cjs/internal/database/models/base.model.d.ts +7 -0
- package/dist/cjs/internal/database/models/base.model.d.ts.map +1 -0
- package/dist/cjs/internal/database/models/base.model.js +11 -0
- package/dist/cjs/internal/database/models/base.model.js.map +1 -0
- package/dist/cjs/internal/database/models/fixture.model.d.ts +4 -0
- package/dist/cjs/internal/database/models/fixture.model.d.ts.map +1 -0
- package/dist/cjs/internal/database/models/fixture.model.js +8 -0
- package/dist/cjs/internal/database/models/fixture.model.js.map +1 -0
- package/dist/cjs/internal/database/schemas/fixture-fields.schema.d.ts +5 -0
- package/dist/cjs/internal/database/schemas/fixture-fields.schema.d.ts.map +1 -0
- package/dist/cjs/internal/database/schemas/fixture-fields.schema.js +11 -0
- package/dist/cjs/internal/database/schemas/fixture-fields.schema.js.map +1 -0
- package/dist/cjs/internal/database/schemas/shared-fields.schema.d.ts +44 -0
- package/dist/cjs/internal/database/schemas/shared-fields.schema.d.ts.map +1 -0
- package/dist/cjs/internal/database/schemas/shared-fields.schema.js +64 -0
- package/dist/cjs/internal/database/schemas/shared-fields.schema.js.map +1 -0
- package/dist/cjs/internal/database/schemas/tenant-fields.schema.d.ts +51 -0
- package/dist/cjs/internal/database/schemas/tenant-fields.schema.d.ts.map +1 -0
- package/dist/cjs/internal/database/schemas/tenant-fields.schema.js +57 -0
- package/dist/cjs/internal/database/schemas/tenant-fields.schema.js.map +1 -0
- package/dist/cjs/internal/enums/lambda.enum.d.ts +28 -0
- package/dist/cjs/internal/enums/lambda.enum.d.ts.map +1 -0
- package/dist/cjs/internal/enums/lambda.enum.js +34 -0
- package/dist/cjs/internal/enums/lambda.enum.js.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classification-enums.d.ts +118 -0
- package/dist/cjs/internal/exceptions/base/error-classification-enums.d.ts.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classification-enums.js +111 -0
- package/dist/cjs/internal/exceptions/base/error-classification-enums.js.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classification.interface.d.ts +48 -0
- package/dist/cjs/internal/exceptions/base/error-classification.interface.d.ts.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classification.interface.js +6 -0
- package/dist/cjs/internal/exceptions/base/error-classification.interface.js.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classifier.d.ts +23 -0
- package/dist/cjs/internal/exceptions/base/error-classifier.d.ts.map +1 -0
- package/dist/cjs/internal/exceptions/base/error-classifier.js +149 -0
- package/dist/cjs/internal/exceptions/base/error-classifier.js.map +1 -0
- package/dist/cjs/internal/exceptions/index.d.ts +3 -0
- package/dist/cjs/internal/exceptions/index.d.ts.map +1 -0
- package/dist/cjs/internal/exceptions/index.js +24 -0
- package/dist/cjs/internal/exceptions/index.js.map +1 -0
- package/dist/cjs/internal/functions/crypto.functions.d.ts +16 -0
- package/dist/cjs/internal/functions/crypto.functions.d.ts.map +1 -0
- package/dist/cjs/internal/functions/crypto.functions.js +110 -0
- package/dist/cjs/internal/functions/crypto.functions.js.map +1 -0
- package/dist/cjs/internal/functions/helper.functions.d.ts +10 -0
- package/dist/cjs/internal/functions/helper.functions.d.ts.map +1 -0
- package/dist/cjs/internal/functions/helper.functions.js +38 -0
- package/dist/cjs/internal/functions/helper.functions.js.map +1 -0
- package/dist/cjs/internal/functions/index.d.ts +4 -0
- package/dist/cjs/internal/functions/index.d.ts.map +1 -0
- package/dist/cjs/internal/functions/index.js +21 -0
- package/dist/cjs/internal/functions/index.js.map +1 -0
- package/dist/cjs/internal/functions/request.functions.d.ts +14 -0
- package/dist/cjs/internal/functions/request.functions.d.ts.map +1 -0
- package/dist/cjs/internal/functions/request.functions.js +69 -0
- package/dist/cjs/internal/functions/request.functions.js.map +1 -0
- package/dist/cjs/internal/index.d.ts +14 -0
- package/dist/cjs/internal/index.d.ts.map +1 -0
- package/dist/cjs/internal/index.js +42 -0
- package/dist/cjs/internal/index.js.map +1 -0
- package/dist/cjs/internal/interfaces/index.d.ts +3 -0
- package/dist/cjs/internal/interfaces/index.d.ts.map +1 -0
- package/dist/cjs/internal/interfaces/index.js +19 -0
- package/dist/cjs/internal/interfaces/index.js.map +1 -0
- package/dist/cjs/internal/interfaces/request.interface.d.ts +21 -0
- package/dist/cjs/internal/interfaces/request.interface.d.ts.map +1 -0
- package/dist/cjs/internal/interfaces/request.interface.js +15 -0
- package/dist/cjs/internal/interfaces/request.interface.js.map +1 -0
- package/dist/cjs/internal/interfaces/stripe-payment-intent-metadata.interface.d.ts +9 -0
- package/dist/cjs/internal/interfaces/stripe-payment-intent-metadata.interface.d.ts.map +1 -0
- package/dist/cjs/internal/interfaces/stripe-payment-intent-metadata.interface.js +3 -0
- package/dist/cjs/internal/interfaces/stripe-payment-intent-metadata.interface.js.map +1 -0
- package/dist/cjs/internal/internal-index.d.ts +8 -0
- package/dist/cjs/internal/internal-index.d.ts.map +1 -0
- package/dist/cjs/internal/internal-index.js +33 -0
- package/dist/cjs/internal/internal-index.js.map +1 -0
- package/dist/cjs/internal/orchestrators/base-orchestrator.d.ts +90 -0
- package/dist/cjs/internal/orchestrators/base-orchestrator.d.ts.map +1 -0
- package/dist/cjs/internal/orchestrators/base-orchestrator.js +124 -0
- package/dist/cjs/internal/orchestrators/base-orchestrator.js.map +1 -0
- package/dist/cjs/internal/orchestrators/base-workflow.d.ts +50 -0
- package/dist/cjs/internal/orchestrators/base-workflow.d.ts.map +1 -0
- package/dist/cjs/internal/orchestrators/base-workflow.js +68 -0
- package/dist/cjs/internal/orchestrators/base-workflow.js.map +1 -0
- package/dist/cjs/internal/orchestrators/index.d.ts +26 -0
- package/dist/cjs/internal/orchestrators/index.d.ts.map +1 -0
- package/dist/cjs/internal/orchestrators/index.js +46 -0
- package/dist/cjs/internal/orchestrators/index.js.map +1 -0
- package/dist/cjs/internal/utils/index.d.ts +2 -0
- package/dist/cjs/internal/utils/index.d.ts.map +1 -0
- package/dist/cjs/internal/utils/index.js +19 -0
- package/dist/cjs/internal/utils/index.js.map +1 -0
- package/dist/cjs/internal/utils/validation.utils.d.ts +49 -0
- package/dist/cjs/internal/utils/validation.utils.d.ts.map +1 -0
- package/dist/cjs/internal/utils/validation.utils.js +76 -0
- package/dist/cjs/internal/utils/validation.utils.js.map +1 -0
- package/dist/esm/index.d.ts +1 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/token-transaction-input-data.interface.d.ts +2 -1
- package/dist/esm/interfaces/token-transaction-input-data.interface.d.ts.map +1 -1
- package/dist/esm/internal/database/index.d.ts +6 -0
- package/dist/esm/internal/database/index.d.ts.map +1 -0
- package/dist/esm/internal/database/index.js +8 -0
- package/dist/esm/internal/database/index.js.map +1 -0
- package/dist/esm/internal/database/models/base.model.d.ts +7 -0
- package/dist/esm/internal/database/models/base.model.d.ts.map +1 -0
- package/dist/esm/internal/database/models/base.model.js +7 -0
- package/dist/esm/internal/database/models/base.model.js.map +1 -0
- package/dist/esm/internal/database/models/fixture.model.d.ts +4 -0
- package/dist/esm/internal/database/models/fixture.model.d.ts.map +1 -0
- package/dist/esm/internal/database/models/fixture.model.js +4 -0
- package/dist/esm/internal/database/models/fixture.model.js.map +1 -0
- package/dist/esm/internal/database/schemas/fixture-fields.schema.d.ts +5 -0
- package/dist/esm/internal/database/schemas/fixture-fields.schema.d.ts.map +1 -0
- package/dist/esm/internal/database/schemas/fixture-fields.schema.js +8 -0
- package/dist/esm/internal/database/schemas/fixture-fields.schema.js.map +1 -0
- package/dist/esm/internal/database/schemas/shared-fields.schema.d.ts +44 -0
- package/dist/esm/internal/database/schemas/shared-fields.schema.d.ts.map +1 -0
- package/dist/esm/internal/database/schemas/shared-fields.schema.js +61 -0
- package/dist/esm/internal/database/schemas/shared-fields.schema.js.map +1 -0
- package/dist/esm/internal/database/schemas/tenant-fields.schema.d.ts +51 -0
- package/dist/esm/internal/database/schemas/tenant-fields.schema.d.ts.map +1 -0
- package/dist/esm/internal/database/schemas/tenant-fields.schema.js +54 -0
- package/dist/esm/internal/database/schemas/tenant-fields.schema.js.map +1 -0
- package/dist/esm/internal/enums/lambda.enum.d.ts +28 -0
- package/dist/esm/internal/enums/lambda.enum.d.ts.map +1 -0
- package/dist/esm/internal/enums/lambda.enum.js +31 -0
- package/dist/esm/internal/enums/lambda.enum.js.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classification-enums.d.ts +118 -0
- package/dist/esm/internal/exceptions/base/error-classification-enums.d.ts.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classification-enums.js +108 -0
- package/dist/esm/internal/exceptions/base/error-classification-enums.js.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classification.interface.d.ts +48 -0
- package/dist/esm/internal/exceptions/base/error-classification.interface.d.ts.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classification.interface.js +5 -0
- package/dist/esm/internal/exceptions/base/error-classification.interface.js.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classifier.d.ts +23 -0
- package/dist/esm/internal/exceptions/base/error-classifier.d.ts.map +1 -0
- package/dist/esm/internal/exceptions/base/error-classifier.js +145 -0
- package/dist/esm/internal/exceptions/base/error-classifier.js.map +1 -0
- package/dist/esm/internal/exceptions/index.d.ts +3 -0
- package/dist/esm/internal/exceptions/index.d.ts.map +1 -0
- package/dist/esm/internal/exceptions/index.js +6 -0
- package/dist/esm/internal/exceptions/index.js.map +1 -0
- package/dist/esm/internal/functions/crypto.functions.d.ts +16 -0
- package/dist/esm/internal/functions/crypto.functions.d.ts.map +1 -0
- package/dist/esm/internal/functions/crypto.functions.js +67 -0
- package/dist/esm/internal/functions/crypto.functions.js.map +1 -0
- package/dist/esm/internal/functions/helper.functions.d.ts +10 -0
- package/dist/esm/internal/functions/helper.functions.d.ts.map +1 -0
- package/dist/esm/internal/functions/helper.functions.js +32 -0
- package/dist/esm/internal/functions/helper.functions.js.map +1 -0
- package/dist/esm/internal/functions/index.d.ts +4 -0
- package/dist/esm/internal/functions/index.d.ts.map +1 -0
- package/dist/esm/internal/functions/index.js +5 -0
- package/dist/esm/internal/functions/index.js.map +1 -0
- package/dist/esm/internal/functions/request.functions.d.ts +14 -0
- package/dist/esm/internal/functions/request.functions.d.ts.map +1 -0
- package/dist/esm/internal/functions/request.functions.js +61 -0
- package/dist/esm/internal/functions/request.functions.js.map +1 -0
- package/dist/esm/internal/index.d.ts +14 -0
- package/dist/esm/internal/index.d.ts.map +1 -0
- package/dist/esm/internal/index.js +26 -0
- package/dist/esm/internal/index.js.map +1 -0
- package/dist/esm/internal/interfaces/index.d.ts +3 -0
- package/dist/esm/internal/interfaces/index.d.ts.map +1 -0
- package/dist/esm/internal/interfaces/index.js +3 -0
- package/dist/esm/internal/interfaces/index.js.map +1 -0
- package/dist/esm/internal/interfaces/request.interface.d.ts +21 -0
- package/dist/esm/internal/interfaces/request.interface.d.ts.map +1 -0
- package/dist/esm/internal/interfaces/request.interface.js +11 -0
- package/dist/esm/internal/interfaces/request.interface.js.map +1 -0
- package/dist/esm/internal/interfaces/stripe-payment-intent-metadata.interface.d.ts +9 -0
- package/dist/esm/internal/interfaces/stripe-payment-intent-metadata.interface.d.ts.map +1 -0
- package/dist/esm/internal/interfaces/stripe-payment-intent-metadata.interface.js +2 -0
- package/dist/esm/internal/interfaces/stripe-payment-intent-metadata.interface.js.map +1 -0
- package/dist/esm/internal/internal-index.d.ts +8 -0
- package/dist/esm/internal/internal-index.d.ts.map +1 -0
- package/dist/esm/internal/internal-index.js +17 -0
- package/dist/esm/internal/internal-index.js.map +1 -0
- package/dist/esm/internal/orchestrators/base-orchestrator.d.ts +90 -0
- package/dist/esm/internal/orchestrators/base-orchestrator.d.ts.map +1 -0
- package/dist/esm/internal/orchestrators/base-orchestrator.js +116 -0
- package/dist/esm/internal/orchestrators/base-orchestrator.js.map +1 -0
- package/dist/esm/internal/orchestrators/base-workflow.d.ts +50 -0
- package/dist/esm/internal/orchestrators/base-workflow.d.ts.map +1 -0
- package/dist/esm/internal/orchestrators/base-workflow.js +64 -0
- package/dist/esm/internal/orchestrators/base-workflow.js.map +1 -0
- package/dist/esm/internal/orchestrators/index.d.ts +26 -0
- package/dist/esm/internal/orchestrators/index.d.ts.map +1 -0
- package/dist/esm/internal/orchestrators/index.js +30 -0
- package/dist/esm/internal/orchestrators/index.js.map +1 -0
- package/dist/esm/internal/utils/index.d.ts +2 -0
- package/dist/esm/internal/utils/index.d.ts.map +1 -0
- package/dist/esm/internal/utils/index.js +3 -0
- package/dist/esm/internal/utils/index.js.map +1 -0
- package/dist/esm/internal/utils/validation.utils.d.ts +49 -0
- package/dist/esm/internal/utils/validation.utils.d.ts.map +1 -0
- package/dist/esm/internal/utils/validation.utils.js +70 -0
- package/dist/esm/internal/utils/validation.utils.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-Tenant TypeORM Entity Fields
|
|
3
|
+
*
|
|
4
|
+
* MANDATORY for tenant-specific data in PERS Loyalty Backend
|
|
5
|
+
*
|
|
6
|
+
* ✅ ALWAYS INCLUDE tenantFields for:
|
|
7
|
+
* - User-specific data: SigningAccount, UserWallet, UserProfile, UserPreferences
|
|
8
|
+
* - Business domain data: Campaign, Redemption, Transaction, TokenBalance
|
|
9
|
+
* - API keys and authentication: ApiKey, RefreshToken, UserSession
|
|
10
|
+
* - Tenant-specific configuration: BusinessSettings, CampaignTemplates
|
|
11
|
+
* - Any data that varies by tenant/client
|
|
12
|
+
*
|
|
13
|
+
* ❌ EXCLUDE tenantFields for:
|
|
14
|
+
* - System-wide shared data: TokenContract, GeolocationData, SystemSettings
|
|
15
|
+
* - Static reference data: Country codes, currency rates, blockchain configs
|
|
16
|
+
* - Cross-tenant shared resources (explicitly designed to be shared)
|
|
17
|
+
*
|
|
18
|
+
* Usage Pattern:
|
|
19
|
+
* ```typescript
|
|
20
|
+
* export const MySchema = new EntitySchema<MyModel>({
|
|
21
|
+
* columns: {
|
|
22
|
+
* ...sharedFields, // Base fields (id, timestamps, soft delete)
|
|
23
|
+
* ...tenantFields, // Multi-tenant support (tenantId with RLS)
|
|
24
|
+
* // entity-specific fields below
|
|
25
|
+
* }
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* CRITICAL: When using tenantFields, MUST include RLS module:
|
|
30
|
+
* ```typescript
|
|
31
|
+
* @Module({
|
|
32
|
+
* imports: [
|
|
33
|
+
* TypeOrmModule.forFeature([MySchema]),
|
|
34
|
+
* RLSModule.forFeature([MySchema]), // REQUIRED for Row Level Security
|
|
35
|
+
* ],
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* Technical Details:
|
|
40
|
+
* - Provides: tenantId with RLS (Row Level Security) automatic population
|
|
41
|
+
* - RLS Function: Uses current_setting('rls.tenant_id') for automatic tenant isolation
|
|
42
|
+
* - Database-level security: Prevents cross-tenant data leaks automatically
|
|
43
|
+
* - Transparent filtering: All queries automatically filter by current tenant
|
|
44
|
+
*
|
|
45
|
+
* See: /documentation/domain-model-best-practices.md for complete patterns
|
|
46
|
+
*/
|
|
47
|
+
export const tenantFields = {
|
|
48
|
+
tenantId: {
|
|
49
|
+
type: String,
|
|
50
|
+
nullable: true,
|
|
51
|
+
default: () => "current_setting('rls.tenant_id')",
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=tenant-fields.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-fields.schema.js","sourceRoot":"","sources":["../../../../../src/internal/database/schemas/tenant-fields.schema.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,CAAC,MAAM,YAAY,GAAmD;IAC1E,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,GAAG,EAAE,CAAC,kCAAkC;KAClD;CACF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lambda function enums for internal microservice communication
|
|
3
|
+
* Used across multiple domains for lambda-based orchestration
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Domain enum for Lambda function names
|
|
7
|
+
* Contains business-meaningful function categories
|
|
8
|
+
*/
|
|
9
|
+
export declare enum LambdaFunctionName {
|
|
10
|
+
TRANSACTION = "transaction"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Domain enum for specific invokable Lambda functions
|
|
14
|
+
* Represents the business operations available through Lambda
|
|
15
|
+
*/
|
|
16
|
+
export declare enum LambdaInvokableFunctionName {
|
|
17
|
+
RUN_TRANSACTION_ASYNC = "runTransactionAsync",
|
|
18
|
+
SUBMIT_SIGNED_TRANSACTION = "submitSignedTransaction"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Domain enum for Lambda invocation types
|
|
22
|
+
* Business perspective on synchronous vs asynchronous operations
|
|
23
|
+
*/
|
|
24
|
+
export declare enum LambdaInvocationType {
|
|
25
|
+
SYNCHRONOUS = "RequestResponse",
|
|
26
|
+
ASYNCHRONOUS = "Event"
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=lambda.enum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lambda.enum.d.ts","sourceRoot":"","sources":["../../../../src/internal/enums/lambda.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B,WAAW,gBAAgB;CAC5B;AAED;;;GAGG;AACH,oBAAY,2BAA2B;IACrC,qBAAqB,wBAAwB;IAC7C,yBAAyB,4BAA4B;CACtD;AAED;;;GAGG;AACH,oBAAY,oBAAoB;IAC9B,WAAW,oBAAoB;IAC/B,YAAY,UAAU;CACvB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lambda function enums for internal microservice communication
|
|
3
|
+
* Used across multiple domains for lambda-based orchestration
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Domain enum for Lambda function names
|
|
7
|
+
* Contains business-meaningful function categories
|
|
8
|
+
*/
|
|
9
|
+
export var LambdaFunctionName;
|
|
10
|
+
(function (LambdaFunctionName) {
|
|
11
|
+
LambdaFunctionName["TRANSACTION"] = "transaction";
|
|
12
|
+
})(LambdaFunctionName || (LambdaFunctionName = {}));
|
|
13
|
+
/**
|
|
14
|
+
* Domain enum for specific invokable Lambda functions
|
|
15
|
+
* Represents the business operations available through Lambda
|
|
16
|
+
*/
|
|
17
|
+
export var LambdaInvokableFunctionName;
|
|
18
|
+
(function (LambdaInvokableFunctionName) {
|
|
19
|
+
LambdaInvokableFunctionName["RUN_TRANSACTION_ASYNC"] = "runTransactionAsync";
|
|
20
|
+
LambdaInvokableFunctionName["SUBMIT_SIGNED_TRANSACTION"] = "submitSignedTransaction";
|
|
21
|
+
})(LambdaInvokableFunctionName || (LambdaInvokableFunctionName = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Domain enum for Lambda invocation types
|
|
24
|
+
* Business perspective on synchronous vs asynchronous operations
|
|
25
|
+
*/
|
|
26
|
+
export var LambdaInvocationType;
|
|
27
|
+
(function (LambdaInvocationType) {
|
|
28
|
+
LambdaInvocationType["SYNCHRONOUS"] = "RequestResponse";
|
|
29
|
+
LambdaInvocationType["ASYNCHRONOUS"] = "Event";
|
|
30
|
+
})(LambdaInvocationType || (LambdaInvocationType = {}));
|
|
31
|
+
//# sourceMappingURL=lambda.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lambda.enum.js","sourceRoot":"","sources":["../../../../src/internal/enums/lambda.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAEX;AAFD,WAAY,kBAAkB;IAC5B,iDAA2B,CAAA;AAC7B,CAAC,EAFW,kBAAkB,KAAlB,kBAAkB,QAE7B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACrC,4EAA6C,CAAA;IAC7C,oFAAqD,CAAA;AACvD,CAAC,EAHW,2BAA2B,KAA3B,2BAA2B,QAGtC;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,uDAA+B,CAAA;IAC/B,8CAAsB,CAAA;AACxB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Classification Enums and Interfaces
|
|
3
|
+
*
|
|
4
|
+
* This file defines the error categorization system used throughout the application.
|
|
5
|
+
*
|
|
6
|
+
* 🎯 DEVELOPER GUIDANCE:
|
|
7
|
+
*
|
|
8
|
+
* When creating errors, choose the appropriate category:
|
|
9
|
+
*
|
|
10
|
+
* 1. DOMAIN_RULE: Business logic violations
|
|
11
|
+
* → Use BusinessLogicError subclasses (e.g., TokenTypeNotFoundError)
|
|
12
|
+
*
|
|
13
|
+
* 2. TECHNICAL: Application/config issues
|
|
14
|
+
* → Use TechnicalError.withMessage() for meaningful technical errors
|
|
15
|
+
*
|
|
16
|
+
* 3. VALIDATION: Input format/validation failures
|
|
17
|
+
* → Let NestJS validation decorators handle these automatically
|
|
18
|
+
*
|
|
19
|
+
* 4. INFRASTRUCTURE: External system failures
|
|
20
|
+
* → These are usually classified automatically from generic Error() instances
|
|
21
|
+
*
|
|
22
|
+
* 5. SECURITY: Auth/authorization issues
|
|
23
|
+
* → Use NestJS guards and filters for consistent security errors
|
|
24
|
+
*
|
|
25
|
+
* 💡 TIP: Prefer structured errors (BusinessLogicError/TechnicalError) over generic Error()
|
|
26
|
+
* for better user experience and debugging capability.
|
|
27
|
+
*
|
|
28
|
+
* 📊 QUICK REFERENCE TABLE:
|
|
29
|
+
* ┌─────────────────┬─────────────┬─────────────────────────────────────┬───────────┐
|
|
30
|
+
* │ Category │ HTTP Status │ Example │ Retryable │
|
|
31
|
+
* ├─────────────────┼─────────────┼─────────────────────────────────────┼───────────┤
|
|
32
|
+
* │ VALIDATION │ 400 │ "Email format invalid" │ No │
|
|
33
|
+
* │ DOMAIN_RULE │ 422 │ "Insufficient balance" │ No │
|
|
34
|
+
* │ TECHNICAL │ 422 │ "Invalid file format" │ Maybe │
|
|
35
|
+
* │ INFRASTRUCTURE │ 503 │ "Database connection failed" │ Yes │
|
|
36
|
+
* │ SECURITY │ 403 │ "Access denied" │ No │
|
|
37
|
+
* │ RATE_LIMIT │ 429 │ "API rate limit exceeded" │ Yes │
|
|
38
|
+
* │ TIMEOUT │ 504 │ "Request timeout" │ Yes │
|
|
39
|
+
* │ UNKNOWN │ 500 │ Generic Error() instances │ Yes │
|
|
40
|
+
* └─────────────────┴─────────────┴─────────────────────────────────────┴───────────┘
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* Error severity levels for prioritization and alerting
|
|
44
|
+
*
|
|
45
|
+
* Determines the urgency of response and escalation procedures:
|
|
46
|
+
* - Monitoring alert thresholds
|
|
47
|
+
* - On-call escalation policies
|
|
48
|
+
* - SLA response times
|
|
49
|
+
* - Business impact assessment
|
|
50
|
+
*/
|
|
51
|
+
export declare enum ErrorSeverity {
|
|
52
|
+
/**
|
|
53
|
+
* Low severity - Minor issues, degraded experience but service functional
|
|
54
|
+
* Examples: Optional feature failures, cosmetic issues, non-critical warnings
|
|
55
|
+
* Response Time: 24-48 hours
|
|
56
|
+
* Escalation: Development team during business hours
|
|
57
|
+
* Business Impact: Minimal
|
|
58
|
+
*/
|
|
59
|
+
LOW = "LOW",
|
|
60
|
+
/**
|
|
61
|
+
* Medium severity - Noticeable issues, some functionality impaired
|
|
62
|
+
* Examples: Performance degradation, secondary feature failures, data sync delays
|
|
63
|
+
* Response Time: 4-8 hours
|
|
64
|
+
* Escalation: Development team within same day
|
|
65
|
+
* Business Impact: Moderate
|
|
66
|
+
*/
|
|
67
|
+
MEDIUM = "MEDIUM",
|
|
68
|
+
/**
|
|
69
|
+
* High severity - Significant issues, core functionality impaired
|
|
70
|
+
* Examples: Payment failures, authentication issues, critical feature outages
|
|
71
|
+
* Response Time: 1-2 hours
|
|
72
|
+
* Escalation: Immediate development team notification
|
|
73
|
+
* Business Impact: High
|
|
74
|
+
*/
|
|
75
|
+
HIGH = "HIGH",
|
|
76
|
+
/**
|
|
77
|
+
* Critical severity - System down, major business impact
|
|
78
|
+
* Examples: Complete service outage, data corruption, security breaches
|
|
79
|
+
* Response Time: Immediate (< 15 minutes)
|
|
80
|
+
* Escalation: Page on-call engineer, notify leadership
|
|
81
|
+
* Business Impact: Severe
|
|
82
|
+
*/
|
|
83
|
+
CRITICAL = "CRITICAL"
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* API error response format including correlation tracking
|
|
87
|
+
*/
|
|
88
|
+
export interface ApiErrorResponse {
|
|
89
|
+
code: string;
|
|
90
|
+
domain: string;
|
|
91
|
+
message: string;
|
|
92
|
+
developerMessage?: string;
|
|
93
|
+
action?: string;
|
|
94
|
+
timestamp: string;
|
|
95
|
+
category: string;
|
|
96
|
+
correlationId: string;
|
|
97
|
+
retryable: boolean;
|
|
98
|
+
severity: ErrorSeverity;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* HTTP Status codes used by our error classification system
|
|
102
|
+
*
|
|
103
|
+
* Centralized here to maintain consistency across error classification
|
|
104
|
+
* and avoid duplication with NestJS HttpStatus values.
|
|
105
|
+
*/
|
|
106
|
+
export declare enum ErrorHttpStatus {
|
|
107
|
+
BAD_REQUEST = 400,
|
|
108
|
+
UNAUTHORIZED = 401,
|
|
109
|
+
FORBIDDEN = 403,
|
|
110
|
+
NOT_FOUND = 404,
|
|
111
|
+
CONFLICT = 409,
|
|
112
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
113
|
+
TOO_MANY_REQUESTS = 429,
|
|
114
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
115
|
+
SERVICE_UNAVAILABLE = 503,
|
|
116
|
+
GATEWAY_TIMEOUT = 504
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=error-classification-enums.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-classification-enums.d.ts","sourceRoot":"","sources":["../../../../../src/internal/exceptions/base/error-classification-enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAKH;;;;;;;;GAQG;AACH,oBAAY,aAAa;IACvB;;;;;;OAMG;IACH,GAAG,QAAQ;IAEX;;;;;;OAMG;IACH,MAAM,WAAW;IAEjB;;;;;;OAMG;IACH,IAAI,SAAS;IAEb;;;;;;OAMG;IACH,QAAQ,aAAa;CACtB;AAID;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC;CACzB;AAID;;;;;GAKG;AACH,oBAAY,eAAe;IACzB,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,SAAS,MAAM;IACf,SAAS,MAAM;IACf,QAAQ,MAAM;IACd,oBAAoB,MAAM;IAC1B,iBAAiB,MAAM;IACvB,qBAAqB,MAAM;IAC3B,mBAAmB,MAAM;IACzB,eAAe,MAAM;CACtB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Classification Enums and Interfaces
|
|
3
|
+
*
|
|
4
|
+
* This file defines the error categorization system used throughout the application.
|
|
5
|
+
*
|
|
6
|
+
* 🎯 DEVELOPER GUIDANCE:
|
|
7
|
+
*
|
|
8
|
+
* When creating errors, choose the appropriate category:
|
|
9
|
+
*
|
|
10
|
+
* 1. DOMAIN_RULE: Business logic violations
|
|
11
|
+
* → Use BusinessLogicError subclasses (e.g., TokenTypeNotFoundError)
|
|
12
|
+
*
|
|
13
|
+
* 2. TECHNICAL: Application/config issues
|
|
14
|
+
* → Use TechnicalError.withMessage() for meaningful technical errors
|
|
15
|
+
*
|
|
16
|
+
* 3. VALIDATION: Input format/validation failures
|
|
17
|
+
* → Let NestJS validation decorators handle these automatically
|
|
18
|
+
*
|
|
19
|
+
* 4. INFRASTRUCTURE: External system failures
|
|
20
|
+
* → These are usually classified automatically from generic Error() instances
|
|
21
|
+
*
|
|
22
|
+
* 5. SECURITY: Auth/authorization issues
|
|
23
|
+
* → Use NestJS guards and filters for consistent security errors
|
|
24
|
+
*
|
|
25
|
+
* 💡 TIP: Prefer structured errors (BusinessLogicError/TechnicalError) over generic Error()
|
|
26
|
+
* for better user experience and debugging capability.
|
|
27
|
+
*
|
|
28
|
+
* 📊 QUICK REFERENCE TABLE:
|
|
29
|
+
* ┌─────────────────┬─────────────┬─────────────────────────────────────┬───────────┐
|
|
30
|
+
* │ Category │ HTTP Status │ Example │ Retryable │
|
|
31
|
+
* ├─────────────────┼─────────────┼─────────────────────────────────────┼───────────┤
|
|
32
|
+
* │ VALIDATION │ 400 │ "Email format invalid" │ No │
|
|
33
|
+
* │ DOMAIN_RULE │ 422 │ "Insufficient balance" │ No │
|
|
34
|
+
* │ TECHNICAL │ 422 │ "Invalid file format" │ Maybe │
|
|
35
|
+
* │ INFRASTRUCTURE │ 503 │ "Database connection failed" │ Yes │
|
|
36
|
+
* │ SECURITY │ 403 │ "Access denied" │ No │
|
|
37
|
+
* │ RATE_LIMIT │ 429 │ "API rate limit exceeded" │ Yes │
|
|
38
|
+
* │ TIMEOUT │ 504 │ "Request timeout" │ Yes │
|
|
39
|
+
* │ UNKNOWN │ 500 │ Generic Error() instances │ Yes │
|
|
40
|
+
* └─────────────────┴─────────────┴─────────────────────────────────────┴───────────┘
|
|
41
|
+
*/
|
|
42
|
+
// Note: ErrorCategory is now imported from @explorins/pers-shared
|
|
43
|
+
// This library contains only the detailed classification enums and interfaces
|
|
44
|
+
/**
|
|
45
|
+
* Error severity levels for prioritization and alerting
|
|
46
|
+
*
|
|
47
|
+
* Determines the urgency of response and escalation procedures:
|
|
48
|
+
* - Monitoring alert thresholds
|
|
49
|
+
* - On-call escalation policies
|
|
50
|
+
* - SLA response times
|
|
51
|
+
* - Business impact assessment
|
|
52
|
+
*/
|
|
53
|
+
export var ErrorSeverity;
|
|
54
|
+
(function (ErrorSeverity) {
|
|
55
|
+
/**
|
|
56
|
+
* Low severity - Minor issues, degraded experience but service functional
|
|
57
|
+
* Examples: Optional feature failures, cosmetic issues, non-critical warnings
|
|
58
|
+
* Response Time: 24-48 hours
|
|
59
|
+
* Escalation: Development team during business hours
|
|
60
|
+
* Business Impact: Minimal
|
|
61
|
+
*/
|
|
62
|
+
ErrorSeverity["LOW"] = "LOW";
|
|
63
|
+
/**
|
|
64
|
+
* Medium severity - Noticeable issues, some functionality impaired
|
|
65
|
+
* Examples: Performance degradation, secondary feature failures, data sync delays
|
|
66
|
+
* Response Time: 4-8 hours
|
|
67
|
+
* Escalation: Development team within same day
|
|
68
|
+
* Business Impact: Moderate
|
|
69
|
+
*/
|
|
70
|
+
ErrorSeverity["MEDIUM"] = "MEDIUM";
|
|
71
|
+
/**
|
|
72
|
+
* High severity - Significant issues, core functionality impaired
|
|
73
|
+
* Examples: Payment failures, authentication issues, critical feature outages
|
|
74
|
+
* Response Time: 1-2 hours
|
|
75
|
+
* Escalation: Immediate development team notification
|
|
76
|
+
* Business Impact: High
|
|
77
|
+
*/
|
|
78
|
+
ErrorSeverity["HIGH"] = "HIGH";
|
|
79
|
+
/**
|
|
80
|
+
* Critical severity - System down, major business impact
|
|
81
|
+
* Examples: Complete service outage, data corruption, security breaches
|
|
82
|
+
* Response Time: Immediate (< 15 minutes)
|
|
83
|
+
* Escalation: Page on-call engineer, notify leadership
|
|
84
|
+
* Business Impact: Severe
|
|
85
|
+
*/
|
|
86
|
+
ErrorSeverity["CRITICAL"] = "CRITICAL";
|
|
87
|
+
})(ErrorSeverity || (ErrorSeverity = {}));
|
|
88
|
+
// Note: All interfaces moved to @explorins/pers-shared for proper data contract separation
|
|
89
|
+
/**
|
|
90
|
+
* HTTP Status codes used by our error classification system
|
|
91
|
+
*
|
|
92
|
+
* Centralized here to maintain consistency across error classification
|
|
93
|
+
* and avoid duplication with NestJS HttpStatus values.
|
|
94
|
+
*/
|
|
95
|
+
export var ErrorHttpStatus;
|
|
96
|
+
(function (ErrorHttpStatus) {
|
|
97
|
+
ErrorHttpStatus[ErrorHttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
98
|
+
ErrorHttpStatus[ErrorHttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
99
|
+
ErrorHttpStatus[ErrorHttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
100
|
+
ErrorHttpStatus[ErrorHttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
101
|
+
ErrorHttpStatus[ErrorHttpStatus["CONFLICT"] = 409] = "CONFLICT";
|
|
102
|
+
ErrorHttpStatus[ErrorHttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
103
|
+
ErrorHttpStatus[ErrorHttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
104
|
+
ErrorHttpStatus[ErrorHttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
105
|
+
ErrorHttpStatus[ErrorHttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
106
|
+
ErrorHttpStatus[ErrorHttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
107
|
+
})(ErrorHttpStatus || (ErrorHttpStatus = {}));
|
|
108
|
+
//# sourceMappingURL=error-classification-enums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-classification-enums.js","sourceRoot":"","sources":["../../../../../src/internal/exceptions/base/error-classification-enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,kEAAkE;AAClE,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,aAoCX;AApCD,WAAY,aAAa;IACvB;;;;;;OAMG;IACH,4BAAW,CAAA;IAEX;;;;;;OAMG;IACH,kCAAiB,CAAA;IAEjB;;;;;;OAMG;IACH,8BAAa,CAAA;IAEb;;;;;;OAMG;IACH,sCAAqB,CAAA;AACvB,CAAC,EApCW,aAAa,KAAb,aAAa,QAoCxB;AAoBD,2FAA2F;AAE3F;;;;;GAKG;AACH,MAAM,CAAN,IAAY,eAWX;AAXD,WAAY,eAAe;IACzB,qEAAiB,CAAA;IACjB,uEAAkB,CAAA;IAClB,iEAAe,CAAA;IACf,iEAAe,CAAA;IACf,+DAAc,CAAA;IACd,uFAA0B,CAAA;IAC1B,iFAAuB,CAAA;IACvB,yFAA2B,CAAA;IAC3B,qFAAyB,CAAA;IACzB,6EAAqB,CAAA;AACvB,CAAC,EAXW,eAAe,KAAf,eAAe,QAW1B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error classification and response interfaces for domain-driven error handling
|
|
3
|
+
*/
|
|
4
|
+
import { ErrorCategory } from '@explorins/pers-shared';
|
|
5
|
+
import { ErrorSeverity } from './error-classification-enums';
|
|
6
|
+
export interface ErrorClassificationResult {
|
|
7
|
+
category: ErrorCategory;
|
|
8
|
+
severity: ErrorSeverity;
|
|
9
|
+
retryable: boolean;
|
|
10
|
+
userFacing: boolean;
|
|
11
|
+
httpStatusCode: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ApiErrorResponse {
|
|
14
|
+
code: string;
|
|
15
|
+
domain: string;
|
|
16
|
+
message: string;
|
|
17
|
+
developerMessage?: string;
|
|
18
|
+
action?: string;
|
|
19
|
+
timestamp: string;
|
|
20
|
+
category: string;
|
|
21
|
+
correlationId: string;
|
|
22
|
+
retryable?: boolean;
|
|
23
|
+
severity?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface LoggingContext {
|
|
26
|
+
domain: string;
|
|
27
|
+
operation: string;
|
|
28
|
+
errorCode: string;
|
|
29
|
+
severity: ErrorSeverity;
|
|
30
|
+
additionalContext?: Record<string, any>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Interface for self-classifying errors
|
|
34
|
+
*/
|
|
35
|
+
export interface SelfClassifyingError {
|
|
36
|
+
classify(): ErrorClassificationResult;
|
|
37
|
+
toApiResponse(correlationId: string): ApiErrorResponse;
|
|
38
|
+
getLoggingContext(): LoggingContext;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Interface for domain-specific error classifiers
|
|
42
|
+
*/
|
|
43
|
+
export interface DomainErrorClassifier {
|
|
44
|
+
canClassify(error: any): boolean;
|
|
45
|
+
classify(error: any): ErrorClassificationResult;
|
|
46
|
+
formatApiResponse(error: any, correlationId: string): ApiErrorResponse;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=error-classification.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-classification.interface.d.ts","sourceRoot":"","sources":["../../../../../src/internal/exceptions/base/error-classification.interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,aAAa,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,aAAa,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,IAAI,yBAAyB,CAAC;IACtC,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,gBAAgB,CAAC;IACvD,iBAAiB,IAAI,cAAc,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,yBAAyB,CAAC;IAChD,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-classification.interface.js","sourceRoot":"","sources":["../../../../../src/internal/exceptions/base/error-classification.interface.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StructuredError } from '@explorins/pers-shared';
|
|
2
|
+
/**
|
|
3
|
+
* Error classification utilities with 3-path decision logic
|
|
4
|
+
*/
|
|
5
|
+
export declare class ErrorClassifier {
|
|
6
|
+
/**
|
|
7
|
+
* Simplified error classification with 3-path logic
|
|
8
|
+
* 1. BusinessLogicError -> Preserve structure (fast path)
|
|
9
|
+
* 2. TechnicalError -> Preserve message (fast path)
|
|
10
|
+
* 3. Everything else -> Security-first fallback
|
|
11
|
+
*/
|
|
12
|
+
static classify(error: any, domain: string): StructuredError;
|
|
13
|
+
/**
|
|
14
|
+
* Determine if an error message is safe to expose to users
|
|
15
|
+
* Uses a balanced approach: block sensitive system data while allowing business messages
|
|
16
|
+
*/
|
|
17
|
+
private static isSafeForUsers;
|
|
18
|
+
/**
|
|
19
|
+
* Convert structured error to HTTP status code
|
|
20
|
+
*/
|
|
21
|
+
static getHttpStatusCode(structuredError: StructuredError): number;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=error-classifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-classifier.d.ts","sourceRoot":"","sources":["../../../../../src/internal/exceptions/base/error-classifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG5G;;GAEG;AACH,qBAAa,eAAe;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe;IAyD5D;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAgE7B;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM;CAkBnE"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { BusinessLogicError, TechnicalError, ErrorCategory } from '@explorins/pers-shared';
|
|
2
|
+
import { ErrorHttpStatus } from './error-classification-enums';
|
|
3
|
+
/**
|
|
4
|
+
* Error classification utilities with 3-path decision logic
|
|
5
|
+
*/
|
|
6
|
+
export class ErrorClassifier {
|
|
7
|
+
/**
|
|
8
|
+
* Simplified error classification with 3-path logic
|
|
9
|
+
* 1. BusinessLogicError -> Preserve structure (fast path)
|
|
10
|
+
* 2. TechnicalError -> Preserve message (fast path)
|
|
11
|
+
* 3. Everything else -> Security-first fallback
|
|
12
|
+
*/
|
|
13
|
+
static classify(error, domain) {
|
|
14
|
+
// Fast path 1: BusinessLogicError (already structured)
|
|
15
|
+
if (BusinessLogicError.isBusinessError(error)) {
|
|
16
|
+
const response = error.getResponse();
|
|
17
|
+
const responseObj = typeof response === 'object' ? response : {};
|
|
18
|
+
return {
|
|
19
|
+
category: ErrorCategory.DOMAIN_RULE,
|
|
20
|
+
code: responseObj.code || 'BUSINESS_ERROR',
|
|
21
|
+
message: responseObj.message || error.message,
|
|
22
|
+
userMessage: responseObj.message || error.message,
|
|
23
|
+
retryable: false
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// Fast path 2: TechnicalError (preserve meaningful messages)
|
|
27
|
+
if (TechnicalError.isTechnicalError(error)) {
|
|
28
|
+
const response = error.getResponse();
|
|
29
|
+
const responseObj = typeof response === 'object' ? response : {};
|
|
30
|
+
return {
|
|
31
|
+
category: ErrorCategory.INFRASTRUCTURE,
|
|
32
|
+
code: 'TECHNICAL_ERROR',
|
|
33
|
+
message: responseObj.message || error.message,
|
|
34
|
+
userMessage: responseObj.message || error.message,
|
|
35
|
+
retryable: false
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Fast path 3: HttpExceptions with BUSINESS_LOGIC category (for backward compatibility)
|
|
39
|
+
if (typeof error.getStatus === 'function') {
|
|
40
|
+
const response = error.getResponse ? error.getResponse() : null;
|
|
41
|
+
if (typeof response === 'object' && response?.category === 'BUSINESS_LOGIC') {
|
|
42
|
+
const responseObj = response;
|
|
43
|
+
return {
|
|
44
|
+
category: ErrorCategory.DOMAIN_RULE,
|
|
45
|
+
code: responseObj.code || 'BUSINESS_ERROR',
|
|
46
|
+
message: responseObj.message || error.message,
|
|
47
|
+
userMessage: responseObj.message || error.message,
|
|
48
|
+
retryable: false
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Security-first fallback for everything else
|
|
53
|
+
const message = error.message || 'Unknown error';
|
|
54
|
+
// Check if error message is safe to expose to users
|
|
55
|
+
const isSafe = this.isSafeForUsers(message);
|
|
56
|
+
return {
|
|
57
|
+
category: ErrorCategory.UNKNOWN,
|
|
58
|
+
code: 'INTERNAL_ERROR',
|
|
59
|
+
message: isSafe ? message : 'Internal server error',
|
|
60
|
+
userMessage: isSafe ? message : 'An unexpected error occurred. Please try again.',
|
|
61
|
+
retryable: true
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Determine if an error message is safe to expose to users
|
|
66
|
+
* Uses a balanced approach: block sensitive system data while allowing business messages
|
|
67
|
+
*/
|
|
68
|
+
static isSafeForUsers(message) {
|
|
69
|
+
if (!message || message.length < 3 || message.length > 300)
|
|
70
|
+
return false;
|
|
71
|
+
// Allow common business error phrases that are safe for users
|
|
72
|
+
const safeBusinessPatterns = [
|
|
73
|
+
/cannot process payment/i,
|
|
74
|
+
/unable to complete transaction/i,
|
|
75
|
+
/insufficient (balance|funds)/i,
|
|
76
|
+
/user not found/i,
|
|
77
|
+
/token not active/i,
|
|
78
|
+
/wallet not found/i,
|
|
79
|
+
/invalid (amount|address|format)/i,
|
|
80
|
+
/transaction (failed|rejected|expired)/i,
|
|
81
|
+
/account (locked|inactive|suspended)/i,
|
|
82
|
+
/permission denied/i,
|
|
83
|
+
/rate limit exceeded/i,
|
|
84
|
+
/service temporarily unavailable/i
|
|
85
|
+
];
|
|
86
|
+
// If it matches safe business patterns, allow it
|
|
87
|
+
if (safeBusinessPatterns.some(pattern => pattern.test(message))) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
// Block definitely unsafe patterns (system internals and sensitive data)
|
|
91
|
+
const unsafePatterns = [
|
|
92
|
+
// System internals with technical context
|
|
93
|
+
/internal server error/i,
|
|
94
|
+
/database connection (failed|lost|timeout)/i,
|
|
95
|
+
/sql (error|exception|syntax)/i,
|
|
96
|
+
/stack trace|stacktrace/i,
|
|
97
|
+
/undefined (property|method|function)/i,
|
|
98
|
+
/null pointer|reference error/i,
|
|
99
|
+
// Sensitive data indicators
|
|
100
|
+
/secret|password|private.?key|credential/i,
|
|
101
|
+
/jwt.?token|bearer.?token|api.?key/i,
|
|
102
|
+
/localhost|127\.0\.0\.1|192\.168\.|10\.\d+\./i,
|
|
103
|
+
/\.env|config\.json|\.xml|\.yml/i,
|
|
104
|
+
// Technical stack traces and system paths
|
|
105
|
+
/\/var\/|\/etc\/|\/home\/|\/usr\/bin|\/opt\//i,
|
|
106
|
+
/node_modules|package\.json|tsconfig/i,
|
|
107
|
+
/at Object\.|at Function\.|at async/i,
|
|
108
|
+
// Database and system queries
|
|
109
|
+
/SELECT.*FROM|INSERT.*INTO|UPDATE.*SET/i,
|
|
110
|
+
/mongodb|postgresql|redis|elasticsearch/i
|
|
111
|
+
];
|
|
112
|
+
// Block if it matches unsafe patterns
|
|
113
|
+
if (unsafePatterns.some(pattern => pattern.test(message))) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
// For everything else, apply basic safety checks
|
|
117
|
+
// Allow if it looks like a user-friendly business message
|
|
118
|
+
const hasBusinessContext = /\b(user|account|transaction|payment|balance|wallet|token)\b/i.test(message);
|
|
119
|
+
const hasGenericWords = /\b(invalid|missing|required|expired|failed|rejected|denied)\b/i.test(message);
|
|
120
|
+
const noSystemJargon = !/\b(undefined|null|exception|stack|trace|object|function|method|class)\b/i.test(message);
|
|
121
|
+
return (hasBusinessContext || hasGenericWords) && noSystemJargon;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Convert structured error to HTTP status code
|
|
125
|
+
*/
|
|
126
|
+
static getHttpStatusCode(structuredError) {
|
|
127
|
+
switch (structuredError.category) {
|
|
128
|
+
case ErrorCategory.VALIDATION:
|
|
129
|
+
return ErrorHttpStatus.BAD_REQUEST;
|
|
130
|
+
case ErrorCategory.DOMAIN_RULE:
|
|
131
|
+
return ErrorHttpStatus.UNPROCESSABLE_ENTITY;
|
|
132
|
+
case ErrorCategory.SECURITY:
|
|
133
|
+
return ErrorHttpStatus.FORBIDDEN;
|
|
134
|
+
case ErrorCategory.RATE_LIMIT:
|
|
135
|
+
return ErrorHttpStatus.TOO_MANY_REQUESTS;
|
|
136
|
+
case ErrorCategory.TIMEOUT:
|
|
137
|
+
return ErrorHttpStatus.GATEWAY_TIMEOUT;
|
|
138
|
+
case ErrorCategory.INFRASTRUCTURE:
|
|
139
|
+
return ErrorHttpStatus.SERVICE_UNAVAILABLE;
|
|
140
|
+
default:
|
|
141
|
+
return ErrorHttpStatus.INTERNAL_SERVER_ERROR;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=error-classifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-classifier.js","sourceRoot":"","sources":["../../../../../src/internal/exceptions/base/error-classifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EA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,eAAe,CAAC,QAAQ,EAAE,CAAC;YACjC,KAAK,aAAa,CAAC,UAAU;gBAC3B,OAAO,eAAe,CAAC,WAAW,CAAC;YACrC,KAAK,aAAa,CAAC,WAAW;gBAC5B,OAAO,eAAe,CAAC,oBAAoB,CAAC;YAC9C,KAAK,aAAa,CAAC,QAAQ;gBACzB,OAAO,eAAe,CAAC,SAAS,CAAC;YACnC,KAAK,aAAa,CAAC,UAAU;gBAC3B,OAAO,eAAe,CAAC,iBAAiB,CAAC;YAC3C,KAAK,aAAa,CAAC,OAAO;gBACxB,OAAO,eAAe,CAAC,eAAe,CAAC;YACzC,KAAK,aAAa,CAAC,cAAc;gBAC/B,OAAO,eAAe,CAAC,mBAAmB,CAAC;YAC7C;gBACE,OAAO,eAAe,CAAC,qBAAqB,CAAC;QACjD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/internal/exceptions/index.ts"],"names":[],"mappings":"AACA,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Error classification utilities (patterns-specific logic only)
|
|
2
|
+
export * from './base/error-classification-enums';
|
|
3
|
+
export { ErrorClassifier } from './base/error-classifier';
|
|
4
|
+
// Note: All error classes (BusinessLogicError, TechnicalError, domain errors) are exported from @explorins/pers-shared
|
|
5
|
+
// This library only contains error classification logic and patterns
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/exceptions/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,uHAAuH;AACvH,qEAAqE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type KeyFormat = 'pem';
|
|
2
|
+
type KeyType = 'pkcs1' | 'pkcs8';
|
|
3
|
+
export interface EncryptedDataObject {
|
|
4
|
+
encryptedData: string;
|
|
5
|
+
iv: string;
|
|
6
|
+
authTag: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const hashString: (input: string, maxLength?: number | null, algorithm?: "sha256" | "sha512" | "md5") => string;
|
|
9
|
+
export declare const checkMatching: (plainString: string, hashedString: string) => Promise<any>;
|
|
10
|
+
export declare const hashPassword: (password: string, saltRounds?: number) => Promise<string>;
|
|
11
|
+
export declare const generatePseudoRandomData: (size?: number) => string;
|
|
12
|
+
export declare const generateDecryptedPrivateKey: (privateKey: string, passphrase: string | undefined, keyType?: KeyType, keyFormat?: KeyFormat) => string;
|
|
13
|
+
export declare const encryptData: (data: string, encryptionKey: string) => EncryptedDataObject;
|
|
14
|
+
export declare const decryptData: (encryptedDataObject: EncryptedDataObject, encryptionKey: string) => string;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=crypto.functions.d.ts.map
|