/** * Shared Constants for postgres.do packages * * This module provides named constants for commonly used magic numbers * throughout the codebase. Using named constants improves code readability, * maintainability, and ensures consistency across packages. * * @module @dotdo/postgres-shared/constants */ /** * Milliseconds per second * Used for converting between seconds and milliseconds */ export declare const MS_PER_SECOND = 1000; /** * Milliseconds per minute (60,000 ms) * Used for timeout and TTL configurations */ export declare const MS_PER_MINUTE: number; /** * Milliseconds per hour (3,600,000 ms) * Used for longer TTL and expiration configurations */ export declare const MS_PER_HOUR: number; /** * Milliseconds per day (86,400,000 ms) * Used for retention policies and long-lived caches */ export declare const MS_PER_DAY: number; /** * Milliseconds per week (604,800,000 ms) * Used for retention policies */ export declare const MS_PER_WEEK: number; /** * Default connection timeout: 10 seconds (10,000 ms) * Used for establishing WebSocket and RPC connections */ export declare const DEFAULT_CONNECT_TIMEOUT_MS = 10000; /** * Default request/socket timeout: 30 seconds (30,000 ms) * Used for HTTP requests, database queries, and RPC calls */ export declare const DEFAULT_REQUEST_TIMEOUT_MS = 30000; /** * Default pool acquire timeout: 30 seconds (30,000 ms) * Used when waiting to acquire a connection from a pool */ export declare const DEFAULT_ACQUIRE_TIMEOUT_MS = 30000; /** * Short timeout for quick operations: 5 seconds (5,000 ms) * Used for health checks, pings, and validation operations */ export declare const SHORT_TIMEOUT_MS = 5000; /** * Long timeout for expensive operations: 60 seconds (60,000 ms) * Used for WASM loading, bulk operations, and complex queries */ export declare const LONG_TIMEOUT_MS = 60000; /** * Circuit breaker reset timeout: 30 seconds (30,000 ms) * Time to wait before moving from OPEN to HALF_OPEN state */ export declare const CIRCUIT_BREAKER_RESET_TIMEOUT_MS = 30000; /** * Circuit breaker failure window: 60 seconds (60,000 ms) * Time window for counting failures before tripping the circuit */ export declare const CIRCUIT_BREAKER_FAILURE_WINDOW_MS = 60000; /** * Maximum circuit breaker reset timeout: 5 minutes (300,000 ms) * Cap for exponential backoff in circuit breaker recovery */ export declare const CIRCUIT_BREAKER_MAX_RESET_TIMEOUT_MS = 300000; /** * Extension load timeout: 10 seconds (10,000 ms) * Maximum time to wait for PostgreSQL extension loading */ export declare const EXTENSION_LOAD_TIMEOUT_MS = 10000; /** * Default cache TTL: 60 seconds (60,000 ms) * Standard TTL for in-memory caches */ export declare const DEFAULT_CACHE_TTL_MS = 60000; /** * Default token cache TTL: 60 seconds (60,000 ms) * TTL for caching validated authentication tokens */ export declare const DEFAULT_TOKEN_CACHE_TTL_MS = 60000; /** * Invalid token TTL: 5 seconds (5,000 ms) * Short TTL for caching invalid token results to prevent abuse */ export declare const INVALID_TOKEN_TTL_MS = 5000; /** * Default cache cleanup interval: 60 seconds (60,000 ms) * Interval for removing expired entries from caches */ export declare const DEFAULT_CACHE_CLEANUP_INTERVAL_MS = 60000; /** * Schema cache TTL: 60 seconds (60,000 ms) * TTL for cached database schema information */ export declare const SCHEMA_CACHE_TTL_MS = 60000; /** * Default cache max size: 1,000 entries * Maximum number of entries in bounded caches */ export declare const DEFAULT_CACHE_MAX_SIZE = 1000; /** * Default query result limit: 1,000 rows * Default LIMIT for queries without explicit limits */ export declare const DEFAULT_QUERY_LIMIT = 1000; /** * Default batch size: 1,000 items * Default size for batch processing operations */ export declare const DEFAULT_BATCH_SIZE = 1000; /** * Maximum tracked pages: 10,000 entries * Limit for access pattern tracking to prevent memory issues */ export declare const MAX_TRACKED_PAGES = 10000; /** * Default retry count: 3 attempts * Number of retry attempts for failed operations */ export declare const DEFAULT_MAX_RETRIES = 3; /** * Default retry delay: 1 second (1,000 ms) * Base delay between retry attempts */ export declare const DEFAULT_RETRY_DELAY_MS = 1000; /** * Maximum retry delay: 30 seconds (30,000 ms) * Cap for exponential backoff in retries */ export declare const MAX_RETRY_DELAY_MS = 30000; /** * Exponential backoff multiplier: 2x * Factor to multiply delay by for each retry */ export declare const EXPONENTIAL_BACKOFF_MULTIPLIER = 2; /** * Default failure threshold: 5 failures * Number of consecutive failures before opening the circuit */ export declare const CIRCUIT_BREAKER_FAILURE_THRESHOLD = 5; /** * Half-open success threshold: 3 successes * Number of successful requests in HALF_OPEN to close the circuit */ export declare const CIRCUIT_BREAKER_HALF_OPEN_SUCCESS_THRESHOLD = 3; /** * Bytes per kilobyte */ export declare const BYTES_PER_KB = 1024; /** * Bytes per megabyte (1,048,576 bytes) */ export declare const BYTES_PER_MB: number; /** * Bytes per gigabyte (1,073,741,824 bytes) */ export declare const BYTES_PER_GB: number; /** * Cloudflare Workers memory limit: 128 MB (134,217,728 bytes) * Hard limit for Worker memory consumption */ export declare const CLOUDFLARE_WORKERS_MEMORY_LIMIT_BYTES: number; /** * Default target file size: 128 MB (134,217,728 bytes) * Target size for Parquet and Iceberg data files */ export declare const DEFAULT_TARGET_FILE_SIZE_BYTES: number; /** * Default target row group size: 128 MB (134,217,728 bytes) * Target size for Parquet row groups */ export declare const DEFAULT_TARGET_ROW_GROUP_SIZE_BYTES: number; /** * Default target page size: 1 MB (1,048,576 bytes) * Target size for Parquet data pages */ export declare const DEFAULT_TARGET_PAGE_SIZE_BYTES: number; /** * Maximum document size: 16 MB (16,777,216 bytes) * Maximum size for MongoDB-compatible documents */ export declare const MAX_DOCUMENT_SIZE_BYTES: number; /** * PostgreSQL default page size: 8 KB (8,192 bytes) * Standard PostgreSQL data page size */ export declare const PG_PAGE_SIZE_BYTES: number; /** * Input buffer size: 1 MB (1,048,576 bytes) * Default size for input data buffers */ export declare const DEFAULT_INPUT_BUFFER_SIZE_BYTES: number; /** * Rebalance threshold: 512 MB (536,870,912 bytes) * Size threshold triggering shard rebalancing */ export declare const SHARD_REBALANCE_THRESHOLD_BYTES: number; /** * PostgreSQL default port: 5432 */ export declare const POSTGRES_DEFAULT_PORT = 5432; /** * WebSocket normal close code: 1000 * Used when closing WebSocket connections cleanly */ export declare const WEBSOCKET_NORMAL_CLOSE_CODE = 1000; /** * Default health check interval: 30 seconds (30,000 ms) * Interval between health monitoring checks */ export declare const DEFAULT_HEALTH_CHECK_INTERVAL_MS = 30000; /** * Idle connection timeout: 30 seconds (30,000 ms) * Time before closing an idle pooled connection */ export declare const DEFAULT_IDLE_TIMEOUT_MS = 30000; /** * Default queue max retries: 3 attempts * Number of message delivery attempts before moving to DLQ */ export declare const DEFAULT_QUEUE_MAX_RETRIES = 3; /** * Default visibility timeout: 30 seconds * Time before an unacknowledged message becomes visible again */ export declare const DEFAULT_VISIBILITY_TIMEOUT_SECONDS = 30; /** * Default search result limit: 1,000 results * Maximum results returned from search operations */ export declare const DEFAULT_SEARCH_LIMIT = 1000; /** * Search cleanup delay: 5 minutes (300,000 ms) * Delay before cleaning up completed search resources */ export declare const SEARCH_CLEANUP_DELAY_MS: number; /** * WebSocket reconnect delay: 1 second (1,000 ms) * Initial delay before attempting WebSocket reconnection */ export declare const DEFAULT_RECONNECT_DELAY_MS = 1000; /** * Throughput calculation window: 5 seconds (5,000 ms) * Rolling window for calculating sync throughput metrics */ export declare const THROUGHPUT_WINDOW_MS = 5000; /** * Expected changes for sync progress: 10,000 changes * Default estimate for calculating sync progress percentage */ export declare const DEFAULT_EXPECTED_CHANGES = 10000; /** * Hot tier default TTL: 5 minutes (300,000 ms) * Default time data stays in fastest storage tier */ export declare const HOT_TIER_DEFAULT_TTL_MS: number; /** * Warm tier default TTL: 1 hour (3,600,000 ms) * Default time data stays in warm storage tier */ export declare const WARM_TIER_DEFAULT_TTL_MS: number; /** * Warm to hot promotion time window: 60 seconds (60,000 ms) * Time window for detecting frequent access patterns */ export declare const WARM_TO_HOT_TIME_WINDOW_MS: number; /** * Default rate limit window: 60 seconds (60,000 ms) * Standard time window for rate limiting calculations */ export declare const DEFAULT_RATE_LIMIT_WINDOW_MS = 60000; /** * Default virtual nodes per shard: 150 * Number of virtual nodes for consistent hashing */ export declare const DEFAULT_VIRTUAL_NODES = 150; /** * Maximum shards: 1,024 * Upper limit for shard count in distributed systems */ export declare const MAX_SHARDS = 1024; /** * Iceberg partition field ID base: 1000 * Starting ID for partition fields in Iceberg schemas */ export declare const ICEBERG_PARTITION_FIELD_ID_BASE = 1000; /** * Heartbeat interval for Electric stream consumers. * Sends periodic heartbeats to maintain connection liveness. * * @see packages/electric/src/streams/consumer.ts */ export declare const ELECTRIC_HEARTBEAT_INTERVAL_MS = 5000; /** * Polling interval for Electric streams and shape managers. * Used for checking stream state and ready conditions. * * @see packages/electric/src/streams/stream.ts * @see packages/electric/src/shapes/manager.ts */ export declare const ELECTRIC_POLLING_INTERVAL_MS = 100; /** * Default batch size for Electric sync engine operations. * * @see packages/electric/src/sync/engine.ts */ export declare const ELECTRIC_DEFAULT_BATCH_SIZE = 100; /** * Maximum size for the Electric offline queue. * Prevents unbounded memory growth during offline operations. * * @see packages/electric/src/sync/offline-queue.ts */ export declare const ELECTRIC_OFFLINE_QUEUE_MAX_SIZE = 10000; /** * GDPR data retention deadline in milliseconds (72 hours). * European GDPR requires deletion requests be honored within 72 hours. * * @see packages/postgres.do/src/retention.ts */ export declare const GDPR_RETENTION_DEADLINE_MS: number; /** * Maximum event listeners for CDC event emitters. * Prevents memory leaks from excessive listeners. * * @see packages/postgres.do/src/cdc/event-emitter.ts */ export declare const CDC_MAX_LISTENERS = 100; /** * Maximum batch size for CDC batch processor. * * @see packages/postgres.do/src/cdc/batch-processor.ts */ export declare const CDC_MAX_BATCH_SIZE = 100; /** * Default histogram buckets for latency metrics (in milliseconds). * Standard percentile-friendly distribution for observability. * * @see packages/postgres.do/src/middleware.ts */ export declare const DEFAULT_HISTOGRAM_BUCKETS: number[]; /** * MongoDB Wire Protocol operation codes. * These are standardized codes from the MongoDB Wire Protocol specification. * * @see https://www.mongodb.com/docs/manual/reference/mongodb-wire-protocol/ * @see packages/documentdb/src/types/index.ts */ export declare const MONGODB_OP_CODES: { readonly OP_UPDATE: 2001; readonly OP_INSERT: 2002; readonly OP_QUERY: 2004; readonly OP_GET_MORE: 2005; readonly OP_DELETE: 2006; readonly OP_KILL_CURSORS: 2007; readonly OP_COMPRESSED: 2012; readonly OP_MSG: 2013; }; /** * Maximum batch size for MongoDB bulk operations. * * @see packages/documentdb/src/client.ts */ export declare const MONGODB_MAX_BATCH_SIZE = 100000; /** * Default query limit for MongoDB find operations. * * @see packages/documentdb/src/worker/index.ts */ export declare const MONGODB_DEFAULT_QUERY_LIMIT = 100; /** * Target shard size for PGLake data distribution (512MB). * Optimal size for parallel query processing and storage efficiency. * * @see packages/pg-lake/src/catalog/router.ts */ export declare const PGLAKE_TARGET_SHARD_SIZE_BYTES: number; /** * Maximum message size for PGLake protocol (10MB). * Prevents excessive memory allocation for single messages. * * @see packages/pg-lake/src/protocol/index.ts */ export declare const PGLAKE_MAX_MESSAGE_SIZE_BYTES: number; /** * Default Parquet block size for data encoding. * * @see packages/pg-lake/src/ingest/parquet-writer.ts */ export declare const PARQUET_DEFAULT_BLOCK_SIZE = 128; /** * WebAssembly page size (64KB). * Standard WASM memory page size as per WebAssembly specification. * * @see https://webassembly.github.io/spec/core/exec/runtime.html#page-size * @see packages/postgres/src/observability/memory-metrics.ts */ export declare const WASM_PAGE_SIZE_BYTES: number; /** * Iceberg time-travel retention window (30 days). * Default retention period for historical snapshots. * * @see packages/postgres/src/iceberg/time-travel-api.ts */ export declare const ICEBERG_RETENTION_WINDOW_MS: number; /** * Analytics sampling interval (24 hours). * Interval for collecting analytics data points. * * @see packages/postgres/src/iceberg/analytics.ts */ export declare const ANALYTICS_SAMPLING_INTERVAL_MS: number; /** * Maximum chunk size for DOVFS operations (16MB). * Balances memory usage with I/O efficiency. * * @see packages/postgres/src/pglite/dovfs.ts */ export declare const DOVFS_MAX_CHUNK_SIZE_BYTES: number; /** * PostgreSQL catalog overhead (10MB). * Reserved memory for PostgreSQL system catalogs and metadata. * * @see packages/postgres/src/observability/memory-metrics.ts */ export declare const PG_CATALOG_OVERHEAD_BYTES: number; /** * FNV-1a hash offset basis (32-bit). * Initial value for FNV-1a hash computation. * * @see https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function * @see packages/shared/src/sync-primitives.ts */ export declare const FNV_OFFSET_BASIS = 2166136261; /** * FNV-1a hash prime (32-bit). * Multiplier for FNV-1a hash computation. * * @see https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function * @see packages/shared/src/sync-primitives.ts */ export declare const FNV_PRIME = 16777619; /** * MurmurHash3 hash multiplier. * Used in hybrid Bloom filter implementations. * * @see packages/shared/src/sync-primitives.ts */ export declare const MURMUR_HASH_MULTIPLIER = 2654435761; /** * Default decay half-life for access frequency tracking (5 minutes). * Controls how quickly old access patterns fade in importance. * * @see packages/shared/src/access-pattern-tracker.ts */ export declare const ACCESS_PATTERN_DECAY_HALF_LIFE_MS: number; /** * Default sliding window for access pattern analysis (1 minute). * Window size for computing recent access statistics. * * @see packages/shared/src/access-pattern-tracker.ts */ export declare const ACCESS_PATTERN_SLIDING_WINDOW_MS: number; /** * Correlation window for detecting related page accesses (100ms). * Accesses within this window are considered potentially correlated. * * @see packages/shared/src/access-pattern-tracker.ts */ export declare const ACCESS_PATTERN_CORRELATION_WINDOW_MS = 100; /** * Interval between access tracker pruning operations (5 minutes). * Removes stale entries to prevent unbounded memory growth. * * @see packages/shared/src/access-pattern-tracker.ts */ export declare const ACCESS_PATTERN_PRUNE_INTERVAL_MS: number; /** * Metadata for all constants including documentation, units, and rationale. * This provides programmatic access to constant documentation for tooling, * introspection, and runtime validation. */ export declare const CONSTANTS_METADATA: { readonly MS_PER_SECOND: { readonly description: "Milliseconds per second - fundamental time unit conversion"; readonly unit: "milliseconds"; readonly defaultValue: 1000; readonly category: "time"; }; readonly MS_PER_MINUTE: { readonly description: "Milliseconds per minute - derived from MS_PER_SECOND"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "time"; }; readonly MS_PER_HOUR: { readonly description: "Milliseconds per hour - derived from MS_PER_MINUTE"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "time"; }; readonly MS_PER_DAY: { readonly description: "Milliseconds per day - derived from MS_PER_HOUR"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "time"; }; readonly MS_PER_WEEK: { readonly description: "Milliseconds per week - derived from MS_PER_DAY"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "time"; }; readonly DEFAULT_CONNECT_TIMEOUT_MS: { readonly description: "Default connection timeout for establishing WebSocket and RPC connections"; readonly unit: "milliseconds"; readonly defaultValue: 10000; readonly category: "timeout"; }; readonly DEFAULT_REQUEST_TIMEOUT_MS: { readonly description: "Default request/socket timeout for HTTP requests, database queries, and RPC calls"; readonly unit: "milliseconds"; readonly defaultValue: 30000; readonly category: "timeout"; }; readonly DEFAULT_ACQUIRE_TIMEOUT_MS: { readonly description: "Default pool acquire timeout when waiting to acquire a connection from a pool"; readonly unit: "milliseconds"; readonly defaultValue: 30000; readonly category: "timeout"; }; readonly SHORT_TIMEOUT_MS: { readonly description: "Short timeout for quick operations like health checks, pings, and validation"; readonly unit: "milliseconds"; readonly defaultValue: 5000; readonly category: "timeout"; }; readonly LONG_TIMEOUT_MS: { readonly description: "Long timeout for expensive operations like WASM loading, bulk operations, and complex queries"; readonly unit: "milliseconds"; readonly defaultValue: 60000; readonly category: "timeout"; }; readonly CIRCUIT_BREAKER_RESET_TIMEOUT_MS: { readonly description: "Time to wait before moving circuit breaker from OPEN to HALF_OPEN state"; readonly unit: "milliseconds"; readonly defaultValue: 30000; readonly category: "circuit-breaker"; }; readonly CIRCUIT_BREAKER_FAILURE_WINDOW_MS: { readonly description: "Time window for counting failures before tripping the circuit"; readonly unit: "milliseconds"; readonly defaultValue: 60000; readonly category: "circuit-breaker"; }; readonly CIRCUIT_BREAKER_MAX_RESET_TIMEOUT_MS: { readonly description: "Cap for exponential backoff in circuit breaker recovery"; readonly unit: "milliseconds"; readonly defaultValue: 300000; readonly category: "circuit-breaker"; }; readonly CIRCUIT_BREAKER_FAILURE_THRESHOLD: { readonly description: "Number of consecutive failures before opening the circuit"; readonly unit: "count"; readonly defaultValue: 5; readonly category: "circuit-breaker"; }; readonly CIRCUIT_BREAKER_HALF_OPEN_SUCCESS_THRESHOLD: { readonly description: "Number of successful requests in HALF_OPEN to close the circuit"; readonly unit: "count"; readonly defaultValue: 3; readonly category: "circuit-breaker"; }; readonly DEFAULT_CACHE_TTL_MS: { readonly description: "Standard TTL for in-memory caches"; readonly unit: "milliseconds"; readonly defaultValue: 60000; readonly category: "cache"; }; readonly DEFAULT_TOKEN_CACHE_TTL_MS: { readonly description: "TTL for caching validated authentication tokens"; readonly unit: "milliseconds"; readonly defaultValue: 60000; readonly category: "cache"; }; readonly INVALID_TOKEN_TTL_MS: { readonly description: "Short TTL for caching invalid token results to prevent abuse"; readonly unit: "milliseconds"; readonly defaultValue: 5000; readonly category: "cache"; }; readonly DEFAULT_CACHE_CLEANUP_INTERVAL_MS: { readonly description: "Interval for removing expired entries from caches"; readonly unit: "milliseconds"; readonly defaultValue: 60000; readonly category: "cache"; }; readonly SCHEMA_CACHE_TTL_MS: { readonly description: "TTL for cached database schema information"; readonly unit: "milliseconds"; readonly defaultValue: 60000; readonly category: "cache"; }; readonly DEFAULT_CACHE_MAX_SIZE: { readonly description: "Maximum number of entries in bounded caches"; readonly unit: "count"; readonly defaultValue: 1000; readonly category: "cache"; }; readonly DEFAULT_QUERY_LIMIT: { readonly description: "Default LIMIT for queries without explicit limits"; readonly unit: "rows"; readonly defaultValue: 1000; readonly category: "limits"; }; readonly DEFAULT_BATCH_SIZE: { readonly description: "Default size for batch processing operations"; readonly unit: "count"; readonly defaultValue: 1000; readonly category: "limits"; }; readonly MAX_TRACKED_PAGES: { readonly description: "Limit for access pattern tracking to prevent memory issues"; readonly unit: "count"; readonly defaultValue: 10000; readonly category: "limits"; }; readonly DEFAULT_MAX_RETRIES: { readonly description: "Number of retry attempts for failed operations"; readonly unit: "count"; readonly defaultValue: 3; readonly category: "retry"; }; readonly DEFAULT_RETRY_DELAY_MS: { readonly description: "Base delay between retry attempts"; readonly unit: "milliseconds"; readonly defaultValue: 1000; readonly category: "retry"; }; readonly MAX_RETRY_DELAY_MS: { readonly description: "Cap for exponential backoff in retries"; readonly unit: "milliseconds"; readonly defaultValue: 30000; readonly category: "retry"; }; readonly EXPONENTIAL_BACKOFF_MULTIPLIER: { readonly description: "Factor to multiply delay by for each retry"; readonly unit: "multiplier"; readonly defaultValue: 2; readonly category: "retry"; }; readonly BYTES_PER_KB: { readonly description: "Bytes per kilobyte - fundamental memory unit conversion"; readonly unit: "bytes"; readonly defaultValue: 1024; readonly category: "memory"; }; readonly BYTES_PER_MB: { readonly description: "Bytes per megabyte - derived from BYTES_PER_KB"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "memory"; }; readonly BYTES_PER_GB: { readonly description: "Bytes per gigabyte - derived from BYTES_PER_MB"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "memory"; }; readonly DEFAULT_TARGET_FILE_SIZE_BYTES: { readonly description: "Target size for Parquet and Iceberg data files"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "storage"; }; readonly DEFAULT_TARGET_ROW_GROUP_SIZE_BYTES: { readonly description: "Target size for Parquet row groups"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "storage"; }; readonly DEFAULT_TARGET_PAGE_SIZE_BYTES: { readonly description: "Target size for Parquet data pages"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "storage"; }; readonly MAX_DOCUMENT_SIZE_BYTES: { readonly description: "Maximum size for MongoDB-compatible documents"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "storage"; }; readonly PG_PAGE_SIZE_BYTES: { readonly description: "Standard PostgreSQL data page size"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "postgres"; }; readonly DEFAULT_INPUT_BUFFER_SIZE_BYTES: { readonly description: "Default size for input data buffers"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "storage"; }; readonly SHARD_REBALANCE_THRESHOLD_BYTES: { readonly description: "Size threshold triggering shard rebalancing"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "storage"; }; readonly POSTGRES_DEFAULT_PORT: { readonly description: "Default PostgreSQL port number"; readonly unit: "port"; readonly defaultValue: 5432; readonly category: "network"; }; readonly WEBSOCKET_NORMAL_CLOSE_CODE: { readonly description: "WebSocket normal close code for clean disconnections"; readonly unit: "code"; readonly defaultValue: 1000; readonly category: "network"; }; readonly DEFAULT_HEALTH_CHECK_INTERVAL_MS: { readonly description: "Interval between health monitoring checks"; readonly unit: "milliseconds"; readonly defaultValue: 30000; readonly category: "network"; }; readonly DEFAULT_IDLE_TIMEOUT_MS: { readonly description: "Time before closing an idle pooled connection"; readonly unit: "milliseconds"; readonly defaultValue: 30000; readonly category: "network"; }; readonly DEFAULT_QUEUE_MAX_RETRIES: { readonly description: "Number of message delivery attempts before moving to DLQ"; readonly unit: "count"; readonly defaultValue: 3; readonly category: "queue"; }; readonly DEFAULT_VISIBILITY_TIMEOUT_SECONDS: { readonly description: "Time before an unacknowledged message becomes visible again"; readonly unit: "seconds"; readonly defaultValue: 30; readonly category: "queue"; }; readonly DEFAULT_SEARCH_LIMIT: { readonly description: "Maximum results returned from search operations"; readonly unit: "count"; readonly defaultValue: 1000; readonly category: "search"; }; readonly SEARCH_CLEANUP_DELAY_MS: { readonly description: "Delay before cleaning up completed search resources"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "search"; }; readonly DEFAULT_RECONNECT_DELAY_MS: { readonly description: "Initial delay before attempting WebSocket reconnection"; readonly unit: "milliseconds"; readonly defaultValue: 1000; readonly category: "network"; }; readonly THROUGHPUT_WINDOW_MS: { readonly description: "Rolling window for calculating sync throughput metrics"; readonly unit: "milliseconds"; readonly defaultValue: 5000; readonly category: "sync"; }; readonly DEFAULT_EXPECTED_CHANGES: { readonly description: "Default estimate for calculating sync progress percentage"; readonly unit: "count"; readonly defaultValue: 10000; readonly category: "sync"; }; readonly HOT_TIER_DEFAULT_TTL_MS: { readonly description: "Default time data stays in fastest storage tier"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "storage-policy"; }; readonly WARM_TIER_DEFAULT_TTL_MS: { readonly description: "Default time data stays in warm storage tier"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "storage-policy"; }; readonly WARM_TO_HOT_TIME_WINDOW_MS: { readonly description: "Time window for detecting frequent access patterns"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "storage-policy"; }; readonly DEFAULT_RATE_LIMIT_WINDOW_MS: { readonly description: "Standard time window for rate limiting calculations"; readonly unit: "milliseconds"; readonly defaultValue: 60000; readonly category: "rate-limiting"; }; readonly DEFAULT_VIRTUAL_NODES: { readonly description: "Number of virtual nodes for consistent hashing"; readonly unit: "count"; readonly defaultValue: 150; readonly category: "hash-ring"; }; readonly MAX_SHARDS: { readonly description: "Upper limit for shard count in distributed systems"; readonly unit: "count"; readonly defaultValue: 1024; readonly category: "hash-ring"; readonly rationale: "1024 = 2^10, optimal for bitwise operations in consistent hashing"; }; readonly ICEBERG_PARTITION_FIELD_ID_BASE: { readonly description: "Starting ID for partition fields in Iceberg schemas"; readonly unit: "id"; readonly defaultValue: 1000; readonly category: "iceberg"; }; readonly EXTENSION_LOAD_TIMEOUT_MS: { readonly description: "Maximum time to wait for PostgreSQL extension loading"; readonly unit: "milliseconds"; readonly defaultValue: 10000; readonly category: "timeout"; }; readonly ELECTRIC_HEARTBEAT_INTERVAL_MS: { readonly description: "Heartbeat interval for Electric stream consumers to maintain connection liveness"; readonly unit: "milliseconds"; readonly defaultValue: 5000; readonly category: "electric"; }; readonly ELECTRIC_POLLING_INTERVAL_MS: { readonly description: "Polling interval for Electric streams and shape managers"; readonly unit: "milliseconds"; readonly defaultValue: 100; readonly category: "electric"; }; readonly ELECTRIC_DEFAULT_BATCH_SIZE: { readonly description: "Default batch size for Electric sync engine operations"; readonly unit: "count"; readonly defaultValue: 100; readonly category: "electric"; }; readonly ELECTRIC_OFFLINE_QUEUE_MAX_SIZE: { readonly description: "Maximum size for the Electric offline queue"; readonly unit: "count"; readonly defaultValue: 10000; readonly category: "electric"; }; readonly GDPR_RETENTION_DEADLINE_MS: { readonly description: "GDPR data retention deadline - European regulation requires deletion within 72 hours"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "compliance"; readonly rationale: "72 hours is the maximum time allowed by GDPR for honoring deletion requests"; }; readonly CDC_MAX_LISTENERS: { readonly description: "Maximum event listeners for CDC event emitters"; readonly unit: "count"; readonly defaultValue: 100; readonly category: "cdc"; }; readonly CDC_MAX_BATCH_SIZE: { readonly description: "Maximum batch size for CDC batch processor"; readonly unit: "count"; readonly defaultValue: 100; readonly category: "cdc"; }; readonly DEFAULT_HISTOGRAM_BUCKETS: { readonly description: "Default histogram buckets for latency metrics"; readonly unit: "milliseconds"; readonly defaultValue: number[]; readonly category: "observability"; }; readonly MONGODB_OP_CODES: { readonly description: "MongoDB Wire Protocol operation codes for client-server communication"; readonly unit: "opcode"; readonly defaultValue: { readonly OP_UPDATE: 2001; readonly OP_INSERT: 2002; readonly OP_QUERY: 2004; readonly OP_GET_MORE: 2005; readonly OP_DELETE: 2006; readonly OP_KILL_CURSORS: 2007; readonly OP_COMPRESSED: 2012; readonly OP_MSG: 2013; }; readonly category: "protocol"; readonly reference: "MongoDB Wire Protocol specification: https://www.mongodb.com/docs/manual/reference/mongodb-wire-protocol/"; }; readonly MONGODB_MAX_BATCH_SIZE: { readonly description: "Maximum batch size for MongoDB bulk operations"; readonly unit: "count"; readonly defaultValue: 100000; readonly category: "mongodb"; }; readonly MONGODB_DEFAULT_QUERY_LIMIT: { readonly description: "Default query limit for MongoDB find operations"; readonly unit: "count"; readonly defaultValue: 100; readonly category: "mongodb"; }; readonly PGLAKE_TARGET_SHARD_SIZE_BYTES: { readonly description: "Target shard size for PGLake data distribution"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "storage"; }; readonly PGLAKE_MAX_MESSAGE_SIZE_BYTES: { readonly description: "Maximum message size for PGLake protocol"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "protocol"; }; readonly PARQUET_DEFAULT_BLOCK_SIZE: { readonly description: "Default Parquet block size for data encoding"; readonly unit: "count"; readonly defaultValue: 128; readonly category: "storage"; }; readonly WASM_PAGE_SIZE_BYTES: { readonly description: "WebAssembly page size as per WASM specification"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "wasm"; }; readonly ICEBERG_RETENTION_WINDOW_MS: { readonly description: "Iceberg time-travel retention window for historical snapshots"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "storage"; }; readonly ANALYTICS_SAMPLING_INTERVAL_MS: { readonly description: "Analytics sampling interval for collecting data points"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "observability"; }; readonly DOVFS_MAX_CHUNK_SIZE_BYTES: { readonly description: "Maximum chunk size for DOVFS operations"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "storage"; }; readonly PG_CATALOG_OVERHEAD_BYTES: { readonly description: "PostgreSQL catalog overhead for system catalogs and metadata"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "postgres"; }; readonly CLOUDFLARE_WORKERS_MEMORY_LIMIT_BYTES: { readonly description: "Cloudflare Workers memory limit"; readonly unit: "bytes"; readonly defaultValue: number; readonly category: "cloudflare"; }; readonly FNV_OFFSET_BASIS: { readonly description: "FNV-1a hash offset basis (32-bit) - initial value for hash computation"; readonly unit: "numeric"; readonly defaultValue: 2166136261; readonly category: "hash"; readonly algorithm: "FNV-1a"; }; readonly FNV_PRIME: { readonly description: "FNV-1a hash prime (32-bit) - multiplier for hash computation"; readonly unit: "numeric"; readonly defaultValue: 16777619; readonly category: "hash"; readonly algorithm: "FNV-1a"; }; readonly MURMUR_HASH_MULTIPLIER: { readonly description: "MurmurHash3 multiplier for hybrid Bloom filter implementations"; readonly unit: "numeric"; readonly defaultValue: 2654435761; readonly category: "hash"; readonly algorithm: "MurmurHash3"; }; readonly ACCESS_PATTERN_DECAY_HALF_LIFE_MS: { readonly description: "Decay half-life for access frequency tracking"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "caching"; }; readonly ACCESS_PATTERN_SLIDING_WINDOW_MS: { readonly description: "Sliding window for access pattern analysis"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "caching"; }; readonly ACCESS_PATTERN_CORRELATION_WINDOW_MS: { readonly description: "Correlation window for detecting related page accesses"; readonly unit: "milliseconds"; readonly defaultValue: 100; readonly category: "caching"; }; readonly ACCESS_PATTERN_PRUNE_INTERVAL_MS: { readonly description: "Interval between access tracker pruning operations"; readonly unit: "milliseconds"; readonly defaultValue: number; readonly category: "caching"; }; }; /** * Validates timeout configuration values. * * @param config - Configuration object with timeout value * @param options - Validation options with min/max constraints * @throws Error if timeout is outside valid range */ export declare function validateTimeoutConfig(config: { timeout: number; }, options: { min: number; max: number; }): void; /** * Validates size configuration values against Cloudflare Workers constraints. * * @param config - Configuration object with size value * @throws Error if size exceeds worker memory limit */ export declare function validateSizeConfig(config: { targetSize: number; }): void; /** * Validates batch configuration values. * * @param config - Configuration object with batch size * @throws Error if batch size is not a positive integer */ export declare function validateBatchConfig(config: { batchSize: number; }): void; /** * Validates retry configuration consistency. * * @param config - Retry configuration object * @throws Error if configuration is inconsistent */ export declare function validateRetryConfig(config: { maxRetries: number; initialDelay: number; maxDelay: number; }): void; /** * Predefined environment configurations. */ export declare const ENVIRONMENT_CONFIGS: { readonly development: { readonly requestTimeout: 60000; readonly maxBatchSize: 1000; readonly maxMemoryBytes: number; readonly doIdleTimeout: 300000; readonly doWarmupTime: 5000; readonly retryDelay: 1000; }; readonly staging: { readonly requestTimeout: 45000; readonly maxBatchSize: 500; readonly maxMemoryBytes: number; readonly doIdleTimeout: 120000; readonly doWarmupTime: 3000; readonly retryDelay: 500; }; readonly production: { readonly requestTimeout: 30000; readonly maxBatchSize: 100; readonly maxMemoryBytes: number; readonly doIdleTimeout: 60000; readonly doWarmupTime: 1000; readonly retryDelay: 100; }; readonly test: { readonly requestTimeout: 5000; readonly maxBatchSize: 10; readonly maxMemoryBytes: number; readonly doIdleTimeout: 10000; readonly doWarmupTime: 100; readonly retryDelay: 10; }; }; export type EnvironmentName = keyof typeof ENVIRONMENT_CONFIGS; /** * Gets configuration for a specific environment. * * @param env - Environment name * @returns Configuration object for the environment */ export declare function getConfigForEnvironment(env: string): { requestTimeout: number; maxBatchSize: number; maxMemoryBytes: number; doIdleTimeout: number; doWarmupTime: number; retryDelay: number; }; /** * Gets configuration with custom overrides applied. * * @param env - Environment name * @param overrides - Custom overrides to apply * @returns Merged configuration object */ export declare function getConfigWithOverrides(env: string, overrides?: Record): { requestTimeout: number; maxBatchSize: number; maxMemoryBytes: number; doIdleTimeout: number; doWarmupTime: number; retryDelay: number; }; /** * Creates a timeout configuration for specific operations. * * @param options - Options for creating the timeout config * @returns Timeout configuration object */ export declare function createTimeoutConfig(options?: { operation?: string; environment?: string; }): { connect: number; request: number; idle: number; }; /** * Creates a retry configuration for specific operations. * * @param options - Options for creating the retry config * @returns Retry configuration object */ export declare function createRetryConfig(options?: { operation?: string; environment?: string; }): { maxRetries: number; initialDelay: number; maxDelay: number; backoffMultiplier: number; }; /** * Creates a storage configuration for specific tiers. * * @param options - Options for creating the storage config * @returns Storage configuration object */ export declare function createStorageConfig(options?: { tier?: 'hot' | 'warm' | 'cold'; environment?: string; }): { ttlMs: number; maxSize: number; cleanupInterval: number; }; /** * Map of deprecated constants to their replacements. */ export declare const DEPRECATED_CONSTANTS: { readonly 'postgres.WORKER_MEMORY_LIMIT_BYTES': { readonly replacement: "CLOUDFLARE_WORKERS_MEMORY_LIMIT_BYTES"; readonly deprecatedIn: "1.0.0"; readonly removeIn: "2.0.0"; readonly location: "packages/postgres/src/observability/memory-metrics.ts"; }; }; /** * Gets a migration guide for a deprecated constant. * * @param name - Name of the deprecated constant (e.g., 'postgres.WORKER_MEMORY_LIMIT_BYTES') * @returns Migration guide string with instructions */ export declare function getMigrationGuide(name: string): string; /** * Validates TTL configuration values. * * @param config - Configuration object with TTL value in milliseconds * @param options - Validation options (optional min/max constraints) * @throws Error if TTL is invalid */ export declare function validateTTLConfig(config: { ttlMs: number; }, options?: { minMs?: number; maxMs?: number; }): void; /** * Validates port configuration values. * * @param config - Configuration object with port number * @throws Error if port is invalid */ export declare function validatePortConfig(config: { port: number; }): void; /** * Validates memory configuration values. * * @param config - Configuration object with memory size in bytes * @param options - Validation options (optional limit) * @throws Error if memory configuration is invalid */ export declare function validateMemoryConfig(config: { memoryBytes: number; }, options?: { maxBytes?: number; }): void; /** * Validates cache configuration values. * * @param config - Cache configuration object * @throws Error if cache configuration is invalid */ export declare function validateCacheConfig(config: { maxSize?: number; ttlMs?: number; cleanupIntervalMs?: number; }): void; /** * Validates circuit breaker configuration values. * * @param config - Circuit breaker configuration object * @throws Error if circuit breaker configuration is invalid */ export declare function validateCircuitBreakerConfig(config: { failureThreshold?: number; resetTimeoutMs?: number; halfOpenSuccessThreshold?: number; failureWindowMs?: number; }): void; /** * Validates hash ring configuration values. * * @param config - Hash ring configuration object * @throws Error if hash ring configuration is invalid */ export declare function validateHashRingConfig(config: { virtualNodes?: number; shardCount?: number; }): void; /** * Validates histogram bucket configuration for metrics. * * @param buckets - Array of bucket boundaries * @throws Error if histogram bucket configuration is invalid */ export declare function validateHistogramBuckets(buckets: number[]): void; /** * Validates shard configuration values. * * @param config - Shard configuration object * @throws Error if shard configuration is invalid */ export declare function validateShardConfig(config: { targetSizeBytes?: number; rebalanceThresholdBytes?: number; }): void; /** * Validates access pattern tracker configuration. * * @param config - Access pattern tracker configuration object * @throws Error if configuration is invalid */ export declare function validateAccessPatternConfig(config: { decayHalfLifeMs?: number; slidingWindowMs?: number; correlationWindowMs?: number; maxTrackedPages?: number; pruneIntervalMs?: number; }): void; /** * Validates MongoDB operation code. * * @param opCode - MongoDB operation code to validate * @throws Error if opCode is not a valid MongoDB operation code */ export declare function validateMongoDBOpCode(opCode: number): void; /** * Gets all constant categories defined in CONSTANTS_METADATA. * * @returns Array of unique category names */ export declare function getConstantCategories(): string[]; /** * Gets all constants for a specific category. * * @param category - Category name to filter by * @returns Object containing constants for the category */ export declare function getConstantsByCategory(category: string): Record; //# sourceMappingURL=constants.d.ts.map