- Salesforce: add validation/duplicate/access/storage error classes and restore classification in error handler (400/409/403/503 vs generic 502) - Freebit: add auth/rate-limit/validation/network error classes and restore result-code-based classification (215, 381, 382) - Portal: replace unsafe string→enum casts with typed state variables - BaseRepository: narrow orderBy from unknown to Record<string, "asc"|"desc"> - WHMCS: narrow WhmcsNotFoundError.providerCode from string to union type - Remove unused UnitOfWork service from PrismaModule
81 lines
2.1 KiB
TypeScript
81 lines
2.1 KiB
TypeScript
/**
|
|
* Provider-specific error codes for structured error detection.
|
|
*
|
|
* These codes identify known error conditions from external providers.
|
|
* Used by provider error classes in the BFF to replace brittle string matching.
|
|
*/
|
|
|
|
export const WhmcsProviderError = {
|
|
// Authentication
|
|
AUTH_FAILED: "WHMCS_AUTH_FAILED",
|
|
INVALID_CREDENTIALS: "WHMCS_INVALID_CREDENTIALS",
|
|
|
|
// Not found
|
|
CLIENT_NOT_FOUND: "WHMCS_CLIENT_NOT_FOUND",
|
|
INVOICE_NOT_FOUND: "WHMCS_INVOICE_NOT_FOUND",
|
|
PRODUCT_NOT_FOUND: "WHMCS_PRODUCT_NOT_FOUND",
|
|
|
|
// Validation
|
|
VALIDATION_ERROR: "WHMCS_VALIDATION_ERROR",
|
|
|
|
// Network/Infrastructure
|
|
TIMEOUT: "WHMCS_TIMEOUT",
|
|
NETWORK_ERROR: "WHMCS_NETWORK_ERROR",
|
|
RATE_LIMITED: "WHMCS_RATE_LIMITED",
|
|
HTTP_ERROR: "WHMCS_HTTP_ERROR",
|
|
|
|
// Generic
|
|
API_ERROR: "WHMCS_API_ERROR",
|
|
} as const;
|
|
|
|
export type WhmcsProviderErrorCode = (typeof WhmcsProviderError)[keyof typeof WhmcsProviderError];
|
|
|
|
export const SalesforceProviderError = {
|
|
// Authentication
|
|
SESSION_EXPIRED: "SF_SESSION_EXPIRED",
|
|
AUTH_FAILED: "SF_AUTH_FAILED",
|
|
|
|
// Query
|
|
QUERY_ERROR: "SF_QUERY_ERROR",
|
|
RECORD_NOT_FOUND: "SF_RECORD_NOT_FOUND",
|
|
|
|
// Validation
|
|
VALIDATION_ERROR: "SF_VALIDATION_ERROR",
|
|
DUPLICATE_RECORD: "SF_DUPLICATE_RECORD",
|
|
ACCESS_DENIED: "SF_ACCESS_DENIED",
|
|
STORAGE_LIMIT: "SF_STORAGE_LIMIT",
|
|
|
|
// Network/Infrastructure
|
|
TIMEOUT: "SF_TIMEOUT",
|
|
NETWORK_ERROR: "SF_NETWORK_ERROR",
|
|
RATE_LIMITED: "SF_RATE_LIMITED",
|
|
|
|
// Generic
|
|
API_ERROR: "SF_API_ERROR",
|
|
} as const;
|
|
|
|
export type SalesforceProviderErrorCode =
|
|
(typeof SalesforceProviderError)[keyof typeof SalesforceProviderError];
|
|
|
|
export const FreebitProviderError = {
|
|
// Not found
|
|
ACCOUNT_NOT_FOUND: "FREEBIT_ACCOUNT_NOT_FOUND",
|
|
|
|
// Authentication
|
|
AUTH_FAILED: "FREEBIT_AUTH_FAILED",
|
|
|
|
// Validation
|
|
VALIDATION_ERROR: "FREEBIT_VALIDATION_ERROR",
|
|
|
|
// Network/Infrastructure
|
|
TIMEOUT: "FREEBIT_TIMEOUT",
|
|
NETWORK_ERROR: "FREEBIT_NETWORK_ERROR",
|
|
RATE_LIMITED: "FREEBIT_RATE_LIMITED",
|
|
|
|
// Generic
|
|
API_ERROR: "FREEBIT_API_ERROR",
|
|
} as const;
|
|
|
|
export type FreebitProviderErrorCode =
|
|
(typeof FreebitProviderError)[keyof typeof FreebitProviderError];
|