UNPKG

@kenniy/godeye-data-contracts

Version:

Enterprise-grade base repository architecture for GOD-EYE microservices with zero overhead and maximum code reuse

163 lines (162 loc) 6.46 kB
"use strict"; /** * Repository Types - Enterprise-Grade Type Safety * * Comprehensive type definitions for the base repository architecture * Supports both TypeORM (PostgreSQL) and Mongoose (MongoDB) patterns */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ENTITY_FIELDS = exports.DEFAULT_REPOSITORY_CONFIG = exports.PERFORMANCE_THRESHOLDS = exports.PAGINATION_CONSTANTS = exports.VerificationStatus = exports.EntityStatus = exports.RepositoryErrorType = exports.QueryOperation = exports.SearchStrategy = exports.SortDirection = exports.ORMType = void 0; // ============================================================================ // ENUMS - Standardized constants for type safety // ============================================================================ /** * Supported ORM types in GOD-EYE ecosystem */ var ORMType; (function (ORMType) { ORMType["TYPEORM"] = "typeorm"; ORMType["MONGOOSE"] = "mongoose"; })(ORMType || (exports.ORMType = ORMType = {})); /** * Database sort directions * Unified across both ORMs */ var SortDirection; (function (SortDirection) { SortDirection["ASC"] = "ASC"; SortDirection["DESC"] = "DESC"; SortDirection[SortDirection["ASCENDING"] = 1] = "ASCENDING"; SortDirection[SortDirection["DESCENDING"] = -1] = "DESCENDING"; })(SortDirection || (exports.SortDirection = SortDirection = {})); /** * Search strategies for intelligent field searching * Backend repositories use these to determine how to match search terms */ var SearchStrategy; (function (SearchStrategy) { SearchStrategy["EXACT"] = "exact"; SearchStrategy["FUZZY"] = "fuzzy"; SearchStrategy["CONTAINS"] = "contains"; SearchStrategy["STARTS_WITH"] = "startsWith"; SearchStrategy["ENDS_WITH"] = "endsWith"; SearchStrategy["SOUNDEX"] = "soundex"; SearchStrategy["SKIP"] = "skip"; // don't search this field for this term })(SearchStrategy || (exports.SearchStrategy = SearchStrategy = {})); /** * Query operation types for monitoring and logging */ var QueryOperation; (function (QueryOperation) { QueryOperation["FIND_ONE"] = "findOne"; QueryOperation["FIND"] = "find"; QueryOperation["FIND_WITH_PAGINATION"] = "findWithPagination"; QueryOperation["CREATE"] = "create"; QueryOperation["CREATE_MANY"] = "createMany"; QueryOperation["UPDATE_BY_ID"] = "updateById"; QueryOperation["UPDATE_MANY"] = "updateMany"; QueryOperation["DELETE_BY_ID"] = "deleteById"; QueryOperation["DELETE_MANY"] = "deleteMany"; QueryOperation["COUNT"] = "count"; QueryOperation["AGGREGATE"] = "aggregate"; QueryOperation["TEXT_SEARCH"] = "textSearch"; QueryOperation["RAW_QUERY"] = "rawQuery"; QueryOperation["TRANSACTION"] = "transaction"; })(QueryOperation || (exports.QueryOperation = QueryOperation = {})); /** * Repository error classification * Enterprise standard error categorization */ var RepositoryErrorType; (function (RepositoryErrorType) { RepositoryErrorType["VALIDATION_ERROR"] = "VALIDATION_ERROR"; RepositoryErrorType["DUPLICATE_ERROR"] = "DUPLICATE_ERROR"; RepositoryErrorType["NOT_FOUND_ERROR"] = "NOT_FOUND_ERROR"; RepositoryErrorType["CONNECTION_ERROR"] = "CONNECTION_ERROR"; RepositoryErrorType["TIMEOUT_ERROR"] = "TIMEOUT_ERROR"; RepositoryErrorType["TRANSACTION_ERROR"] = "TRANSACTION_ERROR"; RepositoryErrorType["PERMISSION_ERROR"] = "PERMISSION_ERROR"; RepositoryErrorType["QUERY_ERROR"] = "QUERY_ERROR"; RepositoryErrorType["NETWORK_ERROR"] = "NETWORK_ERROR"; RepositoryErrorType["RESOURCE_EXHAUSTED"] = "RESOURCE_EXHAUSTED"; })(RepositoryErrorType || (exports.RepositoryErrorType = RepositoryErrorType = {})); /** * Entity status constants * Common across all GOD-EYE entities */ var EntityStatus; (function (EntityStatus) { EntityStatus["ACTIVE"] = "active"; EntityStatus["INACTIVE"] = "inactive"; EntityStatus["DELETED"] = "deleted"; EntityStatus["PENDING"] = "pending"; EntityStatus["ARCHIVED"] = "archived"; })(EntityStatus || (exports.EntityStatus = EntityStatus = {})); /** * Verification status for GOD-EYE business entities */ var VerificationStatus; (function (VerificationStatus) { VerificationStatus["PENDING"] = "pending"; VerificationStatus["VERIFIED"] = "verified"; VerificationStatus["REJECTED"] = "rejected"; VerificationStatus["UNDER_REVIEW"] = "under_review"; VerificationStatus["SUSPENDED"] = "suspended"; })(VerificationStatus || (exports.VerificationStatus = VerificationStatus = {})); // ============================================================================ // CONSTANTS - Performance and configuration defaults // ============================================================================ /** * Default pagination settings * Enterprise-recommended defaults for enterprise applications */ exports.PAGINATION_CONSTANTS = { DEFAULT_PAGE: 1, DEFAULT_LIMIT: 20, MAX_LIMIT: 1000, MIN_LIMIT: 1, }; /** * Performance monitoring thresholds (milliseconds) * Enterprise-grade performance standards */ exports.PERFORMANCE_THRESHOLDS = { FAST_QUERY: 10, // < 10ms - Excellent performance ACCEPTABLE_QUERY: 50, // < 50ms - Good performance SLOW_QUERY: 100, // < 100ms - Needs optimization CRITICAL_QUERY: 500, // > 500ms - Critical performance issue TIMEOUT_QUERY: 30000, // 30s - Query timeout threshold }; /** * Default repository configuration * Production-ready defaults for GOD-EYE services */ exports.DEFAULT_REPOSITORY_CONFIG = { DEFAULT_LIMIT: exports.PAGINATION_CONSTANTS.DEFAULT_LIMIT, MAX_LIMIT: exports.PAGINATION_CONSTANTS.MAX_LIMIT, ENABLE_QUERY_LOGGING: true, SLOW_QUERY_THRESHOLD: exports.PERFORMANCE_THRESHOLDS.SLOW_QUERY, ENABLE_PERFORMANCE_MONITORING: true, ENABLE_CACHING: false, // Disabled by default, enable per service CACHE_TIMEOUT: 300, // 5 minutes default cache CONNECTION_TIMEOUT: 30000, // 30 seconds MAX_RETRY_ATTEMPTS: 3, RETRY_DELAY: 1000, // 1 second initial delay }; /** * GOD-EYE specific entity field names * Standardized field naming across all services */ exports.ENTITY_FIELDS = { ID: "id", CREATED_AT: "createdAt", UPDATED_AT: "updatedAt", DELETED_AT: "deletedAt", CREATED_BY: "createdBy", UPDATED_BY: "updatedBy", STATUS: "status", VERIFICATION_STATUS: "verificationStatus", USER_ID: "userId", EMAIL: "email", PHONE: "phone", };