@plyaz/types 1.7.18 → 1.7.19

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.
Files changed (73) hide show
  1. package/dist/api/client/enum.d.ts +12 -0
  2. package/dist/api/client/index.d.ts +1 -0
  3. package/dist/api/client/types.d.ts +114 -0
  4. package/dist/api/config/types.d.ts +58 -10
  5. package/dist/api/debugger/enums.d.ts +152 -0
  6. package/dist/api/debugger/factories/index.d.ts +1 -0
  7. package/dist/api/debugger/factories/types.d.ts +191 -0
  8. package/dist/api/debugger/index.d.ts +2 -0
  9. package/dist/api/debugger/types.d.ts +664 -0
  10. package/dist/api/endpoints/campaigns/index.d.ts +1 -0
  11. package/dist/api/endpoints/campaigns/types.d.ts +68 -0
  12. package/dist/api/endpoints/health/index.d.ts +1 -0
  13. package/dist/api/endpoints/health/types.d.ts +127 -0
  14. package/dist/api/endpoints/index.d.ts +3 -0
  15. package/dist/api/endpoints/types.d.ts +5 -0
  16. package/dist/api/errors/enum.d.ts +182 -0
  17. package/dist/api/errors/index.d.ts +1 -0
  18. package/dist/api/errors/types.d.ts +126 -27
  19. package/dist/api/events/enum.d.ts +261 -0
  20. package/dist/api/events/factories/cache/index.d.ts +1 -0
  21. package/dist/api/events/factories/cache/types.d.ts +60 -0
  22. package/dist/api/events/factories/client/index.d.ts +1 -0
  23. package/dist/api/events/factories/client/types.d.ts +120 -0
  24. package/dist/api/events/factories/config/index.d.ts +1 -0
  25. package/dist/api/events/factories/config/types.d.ts +79 -0
  26. package/dist/api/events/factories/debug/index.d.ts +1 -0
  27. package/dist/api/events/factories/debug/types.d.ts +130 -0
  28. package/dist/api/events/factories/errors/index.d.ts +1 -0
  29. package/dist/api/events/factories/errors/types.d.ts +293 -0
  30. package/dist/api/events/factories/headers/index.d.ts +1 -0
  31. package/dist/api/events/factories/headers/types.d.ts +256 -0
  32. package/dist/api/events/factories/index.d.ts +9 -0
  33. package/dist/api/events/factories/network/index.d.ts +1 -0
  34. package/dist/api/events/factories/network/types.d.ts +196 -0
  35. package/dist/api/events/factories/performance/index.d.ts +1 -0
  36. package/dist/api/events/factories/performance/types.d.ts +150 -0
  37. package/dist/api/events/factories/types.d.ts +84 -0
  38. package/dist/api/events/index.d.ts +2 -0
  39. package/dist/api/events/types.d.ts +1 -726
  40. package/dist/api/headers/enum.d.ts +34 -0
  41. package/dist/api/headers/index.d.ts +1 -0
  42. package/dist/api/headers/types.d.ts +456 -0
  43. package/dist/api/hooks/index.d.ts +1 -0
  44. package/dist/api/hooks/types.d.ts +131 -0
  45. package/dist/api/index.d.ts +6 -1
  46. package/dist/api/network/enums.d.ts +75 -5
  47. package/dist/api/network/frameworks/index.d.ts +2 -0
  48. package/dist/api/network/frameworks/nestjs/index.d.ts +1 -0
  49. package/dist/api/network/frameworks/nestjs/types.d.ts +47 -0
  50. package/dist/api/network/frameworks/types.d.ts +76 -0
  51. package/dist/api/network/index.d.ts +1 -0
  52. package/dist/api/network/types.d.ts +347 -39
  53. package/dist/api/performance/types.d.ts +17 -10
  54. package/dist/api/polling/types.d.ts +1 -1
  55. package/dist/api/pubsub/enum.d.ts +12 -0
  56. package/dist/api/pubsub/index.d.ts +2 -0
  57. package/dist/api/pubsub/types.d.ts +61 -0
  58. package/dist/api/queue/types.d.ts +69 -0
  59. package/dist/api/regional/enum.d.ts +75 -0
  60. package/dist/api/regional/index.d.ts +1 -0
  61. package/dist/api/regional/types.d.ts +2 -1
  62. package/dist/api/request/index.d.ts +1 -0
  63. package/dist/api/request/types.d.ts +44 -0
  64. package/dist/api/retry/types.d.ts +31 -0
  65. package/dist/api/strategies/types.d.ts +12 -8
  66. package/dist/errors/index.cjs +69 -0
  67. package/dist/errors/index.cjs.map +1 -1
  68. package/dist/errors/index.d.ts +1 -1
  69. package/dist/errors/index.js +66 -0
  70. package/dist/errors/index.js.map +1 -1
  71. package/dist/features/cache/types.d.ts +5 -0
  72. package/dist/testing/features/api/types.d.ts +355 -4
  73. package/package.json +5 -3
@@ -2,6 +2,7 @@
2
2
  * Performance Optimization Types
3
3
  * Types for performance configuration and monitoring
4
4
  */
5
+ import type { RequestConfig as BaseRequestConfig, FetchResponse as BaseFetchResponse, ResponseError as BaseResponseError } from 'fetchff';
5
6
  /**
6
7
  * Performance preset names for optimized configurations
7
8
  */
@@ -99,27 +100,25 @@ export interface RequestPerformance {
99
100
  * Extended Request Config for Performance Monitoring
100
101
  * Adds performance tracking fields to the base RequestConfig
101
102
  */
102
- export interface PerformanceRequestConfig {
103
+ export interface PerformanceRequestConfig extends BaseRequestConfig {
103
104
  __perfMonitorId?: string;
104
105
  fromCache?: boolean;
105
- [key: string]: unknown;
106
106
  }
107
107
  /**
108
108
  * Extended Fetch Response for Performance Monitoring
109
109
  * Adds performance tracking fields to the base FetchResponse
110
110
  */
111
- export interface PerformanceFetchResponse {
111
+ export interface PerformanceFetchResponse extends Omit<BaseFetchResponse, 'config'> {
112
112
  fromCache?: boolean;
113
113
  deduplicated?: boolean;
114
114
  retried?: boolean;
115
115
  retryCount?: number;
116
116
  config: PerformanceRequestConfig;
117
- [key: string]: unknown;
118
117
  }
119
118
  /**
120
119
  * Extended Response Error for Performance Monitoring
121
120
  */
122
- export interface PerformanceResponseError {
121
+ export interface PerformanceResponseError extends Omit<BaseResponseError, 'config'> {
123
122
  config: PerformanceRequestConfig;
124
123
  code?: string;
125
124
  status: number;
@@ -127,11 +126,19 @@ export interface PerformanceResponseError {
127
126
  isCancelled: boolean;
128
127
  request: PerformanceRequestConfig;
129
128
  response: PerformanceFetchResponse | null;
130
- [key: string]: unknown;
131
129
  }
132
130
  /**
133
- * Type guards for performance monitoring
131
+ * Extended types for performance monitoring
132
+ * We use intersection types to add our monitoring properties
134
133
  */
135
- export declare function isPerformanceRequestConfig(config: unknown): config is PerformanceRequestConfig;
136
- export declare function isPerformanceFetchResponse(response: unknown): response is PerformanceFetchResponse;
137
- export declare function isPerformanceResponseError(error: unknown): error is PerformanceResponseError;
134
+ export type MonitorRequestConfig = BaseRequestConfig & {
135
+ __perfMonitorId?: string;
136
+ fromCache?: boolean;
137
+ };
138
+ export type MonitorResponse = BaseFetchResponse & {
139
+ fromCache?: boolean;
140
+ deduplicated?: boolean;
141
+ retried?: boolean;
142
+ retryCount?: number;
143
+ config?: MonitorRequestConfig;
144
+ };
@@ -71,4 +71,4 @@ export interface ConditionalPollingOptions<T = unknown> {
71
71
  /**
72
72
  * Polling strategy names
73
73
  */
74
- export type PollingStrategyName = 'jobStatus' | 'healthCheck' | 'liveData' | 'longProcess' | 'resourceWait';
74
+ export type PollingStrategyName = 'jobStatus' | 'healthCheck' | 'liveData' | 'notifications' | 'longProcess' | 'resourceWait' | 'dataSync';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Event types for pub/sub system
3
+ */
4
+ export declare const PUB_SUB_EVENT: {
5
+ readonly CacheUpdate: "cache:update";
6
+ readonly CacheDelete: "cache:delete";
7
+ readonly CacheRevalidate: "cache:revalidate";
8
+ readonly RequestStart: "request:start";
9
+ readonly RequestSuccess: "request:success";
10
+ readonly RequestError: "request:error";
11
+ readonly RequestAbort: "request:abort";
12
+ };
@@ -0,0 +1,2 @@
1
+ export type * from './types';
2
+ export * from './enum';
@@ -0,0 +1,61 @@
1
+ import type { FetchResponse } from 'fetchff';
2
+ import type { PUB_SUB_EVENT } from '.';
3
+ import type { JsonPrimitive } from 'type-fest';
4
+ export type PubSubEvent = (typeof PUB_SUB_EVENT)[keyof typeof PUB_SUB_EVENT];
5
+ /**
6
+ * Type for subscription callback using fetchff's FetchResponse
7
+ * The subscription callback receives a partial FetchResponse with commonly used fields
8
+ */
9
+ export type SubscriptionCallback<T = DefaultResponse> = (response: FetchResponse<T>) => void;
10
+ /**
11
+ * Serializable type that accepts common data structures
12
+ * This is more permissive than JsonValue to work with user-defined types
13
+ */
14
+ export type Serializable = JsonPrimitive | {
15
+ [key: string]: Serializable | undefined;
16
+ } | Serializable[] | {
17
+ [K in string | number | symbol]: Serializable | undefined;
18
+ };
19
+ /**
20
+ * Default response type when not specified
21
+ * Uses unknown for type safety with flexibility
22
+ */
23
+ export type DefaultResponse = unknown;
24
+ /**
25
+ * Handler types for flexible configuration
26
+ */
27
+ export type HandlerOrArray<T> = T | T[];
28
+ export type Handler<TArgs extends readonly unknown[] = readonly unknown[], TReturn = unknown> = (...args: TArgs) => TReturn;
29
+ /**
30
+ * Create an event emitter pattern for custom events
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const emitter = createEventEmitter();
35
+ *
36
+ * // Subscribe to custom event
37
+ * const unsub = emitter.on('user:login', (data) => {
38
+ * console.log('User logged in:', data);
39
+ * });
40
+ *
41
+ * // Emit event
42
+ * emitter.emit('user:login', { userId: '123' });
43
+ *
44
+ * // Cleanup
45
+ * unsub();
46
+ * ```
47
+ */
48
+ export interface EventEmitter<T = DefaultResponse> {
49
+ on: <D = T>(event: string, callback: (data: D) => void) => () => void;
50
+ emit: <D = T>(event: string, data: D) => void;
51
+ once: <D = T>(event: string, callback: (data: D) => void) => () => void;
52
+ off: <D = T>(event: string, callback?: (data: D) => void) => void;
53
+ listenerCount: (event?: string) => number;
54
+ listeners: (event: string) => Array<(data: unknown) => void>;
55
+ removeAllListeners: (event?: string) => void;
56
+ addHandlers: <D = T>(event: string, handlers: HandlerOrArray<(data: D) => void>) => () => void;
57
+ mergeHandlers: <H>(existing?: HandlerOrArray<H>, incoming?: HandlerOrArray<H>) => H[];
58
+ chainHandlers: <H extends Handler>(global?: HandlerOrArray<H>, client?: HandlerOrArray<H>) => H | undefined;
59
+ createNamespacedKey: (namespace: string, event: string) => string;
60
+ chainInterceptors: <I>(...interceptors: (I | I[] | undefined)[]) => I | I[] | undefined;
61
+ }
@@ -2,6 +2,7 @@
2
2
  * Queue System Type Definitions
3
3
  */
4
4
  import type { PRIORITY_LEVEL } from './enums';
5
+ import type { ConfigUpdateStrategy, ConfigSource } from '..';
5
6
  /**
6
7
  * Processing strategy for queue operations
7
8
  */
@@ -63,3 +64,71 @@ export type QueueProcessor<T> = (operation: QueueOperation<T>) => void | Promise
63
64
  * Batch processor function
64
65
  */
65
66
  export type BatchQueueProcessor<T> = (operations: QueueOperation<T>[]) => void | Promise<void>;
67
+ /**
68
+ * Base operation structure
69
+ */
70
+ export interface BaseOperation {
71
+ operation: string;
72
+ event: string;
73
+ metadata: Record<string, unknown>;
74
+ timestamp: number;
75
+ source?: string;
76
+ }
77
+ /**
78
+ * Operation priority detection function type
79
+ */
80
+ export type PriorityDetector<T extends BaseOperation> = (operation: T) => typeof PRIORITY_LEVEL;
81
+ /**
82
+ * Source detection function type
83
+ */
84
+ export type SourceDetector = () => string;
85
+ export interface BatchProcessorConfig<T> {
86
+ /** Maximum batch size */
87
+ batchSize: number;
88
+ /** Processing interval in ms */
89
+ interval: number;
90
+ /** Callback for processing batch */
91
+ onBatch: (operations: QueueOperation<T>[]) => void | Promise<void>;
92
+ }
93
+ /**
94
+ * Event-specific queue operation
95
+ */
96
+ export interface EventQueueOperation<TEventData = unknown> extends QueueOperation {
97
+ eventType: string;
98
+ scope?: 'global' | 'client' | 'request' | 'temporary';
99
+ configSource?: ConfigSource;
100
+ updateStrategy?: ConfigUpdateStrategy;
101
+ data: {
102
+ eventData: TEventData;
103
+ metadata?: {
104
+ correlationId?: string;
105
+ source: ConfigSource;
106
+ timestamp: number;
107
+ retryAttempt?: number;
108
+ };
109
+ };
110
+ }
111
+ /**
112
+ * Queue health status
113
+ */
114
+ export interface QueueHealth {
115
+ name: string;
116
+ status: 'healthy' | 'degraded' | 'unhealthy';
117
+ stats: QueueStats;
118
+ warnings: string[];
119
+ }
120
+ /**
121
+ * Orchestrator configuration
122
+ */
123
+ export interface OrchestratorConfig {
124
+ /** Enable auto-scaling based on load */
125
+ autoScale?: boolean;
126
+ /** Enable health monitoring */
127
+ healthCheck?: boolean;
128
+ /** Health check interval in ms */
129
+ healthCheckInterval?: number;
130
+ /** Queue size warning threshold */
131
+ warnThreshold?: number;
132
+ /** Queue size critical threshold */
133
+ criticalThreshold?: number;
134
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Regional detection constants
3
+ */
4
+ export declare const REGION_STORAGE_KEY = "@plyaz/api:userRegion";
5
+ /**
6
+ * Confidence levels for region detection
7
+ */
8
+ export declare const REGIONAL_CONFIDENCE_LEVELS: {
9
+ readonly CDN_HEADER: 0.95;
10
+ readonly TIMEZONE_DIRECT: 0.9;
11
+ readonly TIMEZONE_PREFIX: 0.8;
12
+ readonly HIGH: 0.8;
13
+ readonly LOCALE_DIRECT: 0.7;
14
+ readonly MEDIUM: 0.7;
15
+ readonly GEOLOCATION: 0.6;
16
+ readonly LOCALE_LANGUAGE: 0.5;
17
+ readonly LOW: 0.5;
18
+ readonly GLOBAL_FALLBACK: 0.3;
19
+ readonly UNKNOWN_FALLBACK: 0.2;
20
+ readonly FINAL_FALLBACK: 0.1;
21
+ };
22
+ /**
23
+ * Geographic coordinates for region detection
24
+ */
25
+ export declare const COORDINATES: {
26
+ readonly EU: {
27
+ readonly MIN_LAT: 35;
28
+ readonly MAX_LAT: 70;
29
+ readonly MIN_LON: -10;
30
+ readonly MAX_LON: 40;
31
+ };
32
+ readonly US: {
33
+ readonly MIN_LAT: 25;
34
+ readonly MAX_LAT: 50;
35
+ readonly MIN_LON: -125;
36
+ readonly MAX_LON: -65;
37
+ };
38
+ readonly US_WEST: {
39
+ readonly MIN_LAT: 32;
40
+ readonly MAX_LAT: 42;
41
+ readonly MIN_LON: -125;
42
+ readonly MAX_LON: -114;
43
+ };
44
+ readonly US_EAST: {
45
+ readonly MIN_LAT: 38;
46
+ readonly MAX_LAT: 45;
47
+ readonly MIN_LON: -80;
48
+ readonly MAX_LON: -70;
49
+ };
50
+ readonly ASIA: {
51
+ readonly MIN_LAT: 18;
52
+ readonly MAX_LAT: 54;
53
+ readonly MIN_LON: 73;
54
+ readonly MAX_LON: 135;
55
+ };
56
+ readonly JAPAN: {
57
+ readonly MIN_LAT: 30;
58
+ readonly MAX_LAT: 46;
59
+ readonly MIN_LON: 129;
60
+ readonly MAX_LON: 146;
61
+ };
62
+ };
63
+ export declare const CACHE_DURATION_MS: number;
64
+ /**
65
+ * Map regions to presets
66
+ */
67
+ export declare const REGION_TO_PRESET: {
68
+ readonly eu: "gdpr";
69
+ readonly us: "ccpa";
70
+ readonly 'us-ca': "ccpa";
71
+ readonly cn: "pipl";
72
+ readonly jp: "appi";
73
+ readonly ca: "global";
74
+ readonly global: "global";
75
+ };
@@ -3,3 +3,4 @@
3
3
  * Re-exports all regional-related types for the API package
4
4
  */
5
5
  export type * from './types';
6
+ export * from './enum';
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Regional detection and compliance types
3
3
  */
4
+ import type { IncomingHttpHeaders } from 'http';
4
5
  /**
5
6
  * Regional information with compliance data
6
7
  */
@@ -43,7 +44,7 @@ export interface RegionDetectionOptions {
43
44
  useCDNHeaders?: boolean;
44
45
  useIPDetection?: boolean;
45
46
  useGeolocation?: boolean;
46
- headers?: Record<string, unknown>;
47
+ headers?: IncomingHttpHeaders | Record<string, unknown>;
47
48
  cacheExpiry?: number;
48
49
  fallbackRegion?: string;
49
50
  cache?: RegionalCacheConfig;
@@ -0,0 +1 @@
1
+ export type * from './types';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Context for enriched headers generation
3
+ */
4
+ export interface EnrichedHeadersContext {
5
+ request?: {
6
+ headers?: Record<string, string | string[] | undefined>;
7
+ url?: string;
8
+ method?: string;
9
+ ip?: string;
10
+ [key: string]: unknown;
11
+ };
12
+ client?: {
13
+ userAgent?: string;
14
+ platform?: string;
15
+ };
16
+ [key: string]: unknown;
17
+ }
18
+ /**
19
+ * Router type definitions for popular frameworks
20
+ */
21
+ export interface RequestNextRouter {
22
+ events?: {
23
+ on: (event: string, handler: (url: string) => void) => void;
24
+ off: (event: string, handler: (url: string) => void) => void;
25
+ };
26
+ }
27
+ interface ReactRouterHistory {
28
+ listen?: (handler: (location: Location) => void) => () => void;
29
+ }
30
+ export type RequestRouter = RequestNextRouter | ReactRouterHistory;
31
+ /**
32
+ * Options for route change cleanup
33
+ */
34
+ export interface RouteChangeOptions {
35
+ /** Pattern of requests to abort (default: '*') */
36
+ abortPattern?: string;
37
+ /** Patterns to preserve across route changes */
38
+ preservePatterns?: string[];
39
+ /** Custom handler for route changes */
40
+ customHandler?: (url: string) => void;
41
+ /** Delay before aborting requests (ms) */
42
+ delay?: number;
43
+ }
44
+ export {};
@@ -5,6 +5,37 @@
5
5
  * @module retry/types
6
6
  */
7
7
  import type { RetryConfig as FetchffRetryConfig } from 'fetchff';
8
+ /**
9
+ * Response-like structure for retry conditions
10
+ * Used to evaluate whether a request should be retried based on response characteristics
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const response: RetryResponse = {
15
+ * status: 503,
16
+ * headers: { 'Retry-After': '30' },
17
+ * error: new Error('Service Unavailable'),
18
+ * timeout: false
19
+ * };
20
+ *
21
+ * // Use in retry condition
22
+ * const shouldRetry = response.status === 503 || response.timeout;
23
+ * ```
24
+ */
25
+ export interface RetryResponse {
26
+ /** HTTP status code */
27
+ status?: number;
28
+ /** Response headers */
29
+ headers?: Record<string, string> | Headers;
30
+ /** Response data */
31
+ data?: unknown;
32
+ /** Error object if request failed */
33
+ error?: unknown;
34
+ /** Error code (e.g., 'ECONNREFUSED', 'ETIMEDOUT') */
35
+ code?: string;
36
+ /** Whether the request timed out */
37
+ timeout?: boolean;
38
+ }
8
39
  /**
9
40
  * Retry configuration options
10
41
  * Maps to fetchff's retry mechanism
@@ -2,15 +2,19 @@
2
2
  * Unified API Strategies Types
3
3
  * Type definitions for unified strategies (implementations remain in @plyaz/api)
4
4
  */
5
+ import type { CacheStrategyName } from '../cache';
6
+ import type { RetryStrategyName } from '../retry';
7
+ import type { PollingStrategyName } from '../polling';
8
+ import type { PerformancePresetName } from '../performance';
5
9
  /**
6
10
  * Unified strategy combines strategies from different domains
7
11
  * This provides a convenience layer while keeping individual strategies independent
8
12
  */
9
13
  export interface UnifiedStrategy {
10
- cache: string;
11
- retry: string;
12
- polling?: string;
13
- performance?: string;
14
+ cache: CacheStrategyName;
15
+ retry: RetryStrategyName;
16
+ polling?: PollingStrategyName;
17
+ performance?: PerformancePresetName;
14
18
  }
15
19
  /**
16
20
  * Unified strategy names for common API usage patterns
@@ -20,8 +24,8 @@ export type UnifiedStrategyName = 'realtime' | 'interactive' | 'background' | 's
20
24
  * Configuration object with resolved strategy names
21
25
  */
22
26
  export interface UnifiedStrategyConfig {
23
- cache: string;
24
- retry: string;
25
- polling?: string;
26
- performance?: string;
27
+ cache: CacheStrategyName;
28
+ retry: RetryStrategyName;
29
+ polling?: PollingStrategyName;
30
+ performance?: PerformancePresetName;
27
31
  }
@@ -1,4 +1,73 @@
1
1
  'use strict';
2
2
 
3
+ // @plyaz package - Built with tsup
4
+
5
+ // src/errors/enums.ts
6
+ var ERROR_TYPE = {
7
+ /** A general validation error (e.g., form or input errors). */
8
+ ValidationError: "validation.error",
9
+ /** Error related to schema validation, such as JSON schema or API payload checks. */
10
+ SchemaValidationError: "validation.schema.error",
11
+ /** Unhandled or unexpected system error. */
12
+ InternalError: "system.internal.error",
13
+ /** System dependency is currently unavailable (e.g., database or external API). */
14
+ ServiceUnavailable: "system.service.unavailable",
15
+ /** The request took too long and timed out. */
16
+ TimeoutError: "system.timeout",
17
+ /** Too many requests made in a short period of time. */
18
+ RateLimitExceeded: "system.rate.limit.exceeded"
19
+ };
20
+ var ERROR_SEVERITY = {
21
+ /** Low severity - does not impact functionality significantly. */
22
+ Low: "low",
23
+ /** Medium severity - minor disruption or warning. */
24
+ Medium: "medium",
25
+ /** High severity - major issue requiring attention. */
26
+ High: "high",
27
+ /** Critical severity - blocking or crashing issue. */
28
+ Critical: "critical"
29
+ };
30
+ var ERROR_CATEGORY = {
31
+ /** Client-side error (e.g., invalid request). */
32
+ Client: "client",
33
+ /** Server-side error (e.g., logic failure or exception). */
34
+ Server: "server",
35
+ /** Network-related error (e.g., unreachable endpoint). */
36
+ Network: "network",
37
+ /** Blockchain-related error (e.g., transaction failure, gas limit). */
38
+ Blockchain: "blockchain",
39
+ /** Validation-specific error (e.g., failed constraints or field errors). */
40
+ Validation: "validation",
41
+ /** Authentication-related error (e.g., invalid credentials, expired token). */
42
+ Authentication: "authentication",
43
+ /** Authorization-related error (e.g., insufficient permissions). */
44
+ Authorization: "authorization",
45
+ /** Resource not found error. */
46
+ NotFound: "not.found",
47
+ /** Rate limiting error (too many requests). */
48
+ RateLimit: "rate.limit",
49
+ /** External service error (e.g., third-party API failure). */
50
+ ExternalService: "external.service",
51
+ /** Timeout error (request exceeded time limit). */
52
+ Timeout: "timeout",
53
+ /** Conflict error (e.g., resource state conflict). */
54
+ Conflict: "conflict",
55
+ /** Cache-related error. */
56
+ Cache: "cache",
57
+ /** Headers-related error (e.g., missing or invalid headers). */
58
+ Headers: "headers",
59
+ /** Retry-related error (e.g., max retries exceeded). */
60
+ Retry: "retry",
61
+ /** Strategy-related error (e.g., invalid retry or caching strategy). */
62
+ Strategy: "strategy",
63
+ /** Regional-related error (e.g., region detection failure). */
64
+ Regional: "regional",
65
+ /** Unknown or unclassified error. */
66
+ Unknown: "unknown"
67
+ };
68
+
69
+ exports.ERROR_CATEGORY = ERROR_CATEGORY;
70
+ exports.ERROR_SEVERITY = ERROR_SEVERITY;
71
+ exports.ERROR_TYPE = ERROR_TYPE;
3
72
  //# sourceMappingURL=index.cjs.map
4
73
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
1
+ {"version":3,"sources":["../../src/errors/enums.ts"],"names":[],"mappings":";;;;;AAgBO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,eAAA,EAAiB,kBAAA;AAAA;AAAA,EAGjB,qBAAA,EAAuB,yBAAA;AAAA;AAAA,EAGvB,aAAA,EAAe,uBAAA;AAAA;AAAA,EAGf,kBAAA,EAAoB,4BAAA;AAAA;AAAA,EAGpB,YAAA,EAAc,gBAAA;AAAA;AAAA,EAGd,iBAAA,EAAmB;AACrB;AAcO,IAAM,cAAA,GAAiB;AAAA;AAAA,EAE5B,GAAA,EAAK,KAAA;AAAA;AAAA,EAGL,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,IAAA,EAAM,MAAA;AAAA;AAAA,EAGN,QAAA,EAAU;AACZ;AAcO,IAAM,cAAA,GAAiB;AAAA;AAAA,EAE5B,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,UAAA,EAAY,YAAA;AAAA;AAAA,EAGZ,UAAA,EAAY,YAAA;AAAA;AAAA,EAGZ,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAGhB,aAAA,EAAe,eAAA;AAAA;AAAA,EAGf,QAAA,EAAU,WAAA;AAAA;AAAA,EAGV,SAAA,EAAW,YAAA;AAAA;AAAA,EAGX,eAAA,EAAiB,kBAAA;AAAA;AAAA,EAGjB,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,QAAA,EAAU,UAAA;AAAA;AAAA,EAGV,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,QAAA,EAAU,UAAA;AAAA;AAAA,EAGV,QAAA,EAAU,UAAA;AAAA;AAAA,EAGV,OAAA,EAAS;AACX","file":"index.cjs","sourcesContent":["/**\n * Enum representing standardized error types used across the application.\n * @description These error types help classify different categories of errors such as validation issues and system-level failures.\n *\n * @example\n * ```typescript\n * import { ERROR_TYPE } from '@plyaz/types';\n *\n * const errorType = ERROR_TYPE.ValidationError; // 'validation.error'\n *\n * // Error handling example\n * if (error.type === ERROR_TYPE.RateLimitExceeded) {\n * // Handle rate limiting\n * }\n * ```\n */\nexport const ERROR_TYPE = {\n /** A general validation error (e.g., form or input errors). */\n ValidationError: 'validation.error',\n\n /** Error related to schema validation, such as JSON schema or API payload checks. */\n SchemaValidationError: 'validation.schema.error',\n\n /** Unhandled or unexpected system error. */\n InternalError: 'system.internal.error',\n\n /** System dependency is currently unavailable (e.g., database or external API). */\n ServiceUnavailable: 'system.service.unavailable',\n\n /** The request took too long and timed out. */\n TimeoutError: 'system.timeout',\n\n /** Too many requests made in a short period of time. */\n RateLimitExceeded: 'system.rate.limit.exceeded',\n} as const;\n\n/**\n * Enum representing the severity level of an error.\n * @description This allows categorization of errors by their potential impact on the system or user.\n *\n * @example\n * ```typescript\n * import { ERROR_SEVERITY } from '@plyaz/types';\n *\n * const severity = ERROR_SEVERITY.Critical; // 'critical'\n * const shouldAlert = severity === ERROR_SEVERITY.High || severity === ERROR_SEVERITY.Critical;\n * ```\n */\nexport const ERROR_SEVERITY = {\n /** Low severity - does not impact functionality significantly. */\n Low: 'low',\n\n /** Medium severity - minor disruption or warning. */\n Medium: 'medium',\n\n /** High severity - major issue requiring attention. */\n High: 'high',\n\n /** Critical severity - blocking or crashing issue. */\n Critical: 'critical',\n} as const;\n\n/**\n * Enum representing the category or origin of an error.\n * @description Useful for filtering or logging errors based on their source or nature.\n *\n * @example\n * ```typescript\n * import { ERROR_CATEGORY } from '@plyaz/types';\n *\n * const category = ERROR_CATEGORY.Blockchain; // 'blockchain'\n * const isClientError = category === ERROR_CATEGORY.Client;\n * ```\n */\nexport const ERROR_CATEGORY = {\n /** Client-side error (e.g., invalid request). */\n Client: 'client',\n\n /** Server-side error (e.g., logic failure or exception). */\n Server: 'server',\n\n /** Network-related error (e.g., unreachable endpoint). */\n Network: 'network',\n\n /** Blockchain-related error (e.g., transaction failure, gas limit). */\n Blockchain: 'blockchain',\n\n /** Validation-specific error (e.g., failed constraints or field errors). */\n Validation: 'validation',\n\n /** Authentication-related error (e.g., invalid credentials, expired token). */\n Authentication: 'authentication',\n\n /** Authorization-related error (e.g., insufficient permissions). */\n Authorization: 'authorization',\n\n /** Resource not found error. */\n NotFound: 'not.found',\n\n /** Rate limiting error (too many requests). */\n RateLimit: 'rate.limit',\n\n /** External service error (e.g., third-party API failure). */\n ExternalService: 'external.service',\n\n /** Timeout error (request exceeded time limit). */\n Timeout: 'timeout',\n\n /** Conflict error (e.g., resource state conflict). */\n Conflict: 'conflict',\n\n /** Cache-related error. */\n Cache: 'cache',\n\n /** Headers-related error (e.g., missing or invalid headers). */\n Headers: 'headers',\n\n /** Retry-related error (e.g., max retries exceeded). */\n Retry: 'retry',\n\n /** Strategy-related error (e.g., invalid retry or caching strategy). */\n Strategy: 'strategy',\n\n /** Regional-related error (e.g., region detection failure). */\n Regional: 'regional',\n\n /** Unknown or unclassified error. */\n Unknown: 'unknown',\n} as const;\n"]}
@@ -1,2 +1,2 @@
1
- export type * from './enums';
1
+ export * from './enums';
2
2
  export type * from './types';
@@ -1,3 +1,69 @@
1
+ // @plyaz package - Built with tsup
1
2
 
3
+ // src/errors/enums.ts
4
+ var ERROR_TYPE = {
5
+ /** A general validation error (e.g., form or input errors). */
6
+ ValidationError: "validation.error",
7
+ /** Error related to schema validation, such as JSON schema or API payload checks. */
8
+ SchemaValidationError: "validation.schema.error",
9
+ /** Unhandled or unexpected system error. */
10
+ InternalError: "system.internal.error",
11
+ /** System dependency is currently unavailable (e.g., database or external API). */
12
+ ServiceUnavailable: "system.service.unavailable",
13
+ /** The request took too long and timed out. */
14
+ TimeoutError: "system.timeout",
15
+ /** Too many requests made in a short period of time. */
16
+ RateLimitExceeded: "system.rate.limit.exceeded"
17
+ };
18
+ var ERROR_SEVERITY = {
19
+ /** Low severity - does not impact functionality significantly. */
20
+ Low: "low",
21
+ /** Medium severity - minor disruption or warning. */
22
+ Medium: "medium",
23
+ /** High severity - major issue requiring attention. */
24
+ High: "high",
25
+ /** Critical severity - blocking or crashing issue. */
26
+ Critical: "critical"
27
+ };
28
+ var ERROR_CATEGORY = {
29
+ /** Client-side error (e.g., invalid request). */
30
+ Client: "client",
31
+ /** Server-side error (e.g., logic failure or exception). */
32
+ Server: "server",
33
+ /** Network-related error (e.g., unreachable endpoint). */
34
+ Network: "network",
35
+ /** Blockchain-related error (e.g., transaction failure, gas limit). */
36
+ Blockchain: "blockchain",
37
+ /** Validation-specific error (e.g., failed constraints or field errors). */
38
+ Validation: "validation",
39
+ /** Authentication-related error (e.g., invalid credentials, expired token). */
40
+ Authentication: "authentication",
41
+ /** Authorization-related error (e.g., insufficient permissions). */
42
+ Authorization: "authorization",
43
+ /** Resource not found error. */
44
+ NotFound: "not.found",
45
+ /** Rate limiting error (too many requests). */
46
+ RateLimit: "rate.limit",
47
+ /** External service error (e.g., third-party API failure). */
48
+ ExternalService: "external.service",
49
+ /** Timeout error (request exceeded time limit). */
50
+ Timeout: "timeout",
51
+ /** Conflict error (e.g., resource state conflict). */
52
+ Conflict: "conflict",
53
+ /** Cache-related error. */
54
+ Cache: "cache",
55
+ /** Headers-related error (e.g., missing or invalid headers). */
56
+ Headers: "headers",
57
+ /** Retry-related error (e.g., max retries exceeded). */
58
+ Retry: "retry",
59
+ /** Strategy-related error (e.g., invalid retry or caching strategy). */
60
+ Strategy: "strategy",
61
+ /** Regional-related error (e.g., region detection failure). */
62
+ Regional: "regional",
63
+ /** Unknown or unclassified error. */
64
+ Unknown: "unknown"
65
+ };
66
+
67
+ export { ERROR_CATEGORY, ERROR_SEVERITY, ERROR_TYPE };
2
68
  //# sourceMappingURL=index.js.map
3
69
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"sources":["../../src/errors/enums.ts"],"names":[],"mappings":";;;AAgBO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,eAAA,EAAiB,kBAAA;AAAA;AAAA,EAGjB,qBAAA,EAAuB,yBAAA;AAAA;AAAA,EAGvB,aAAA,EAAe,uBAAA;AAAA;AAAA,EAGf,kBAAA,EAAoB,4BAAA;AAAA;AAAA,EAGpB,YAAA,EAAc,gBAAA;AAAA;AAAA,EAGd,iBAAA,EAAmB;AACrB;AAcO,IAAM,cAAA,GAAiB;AAAA;AAAA,EAE5B,GAAA,EAAK,KAAA;AAAA;AAAA,EAGL,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,IAAA,EAAM,MAAA;AAAA;AAAA,EAGN,QAAA,EAAU;AACZ;AAcO,IAAM,cAAA,GAAiB;AAAA;AAAA,EAE5B,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,UAAA,EAAY,YAAA;AAAA;AAAA,EAGZ,UAAA,EAAY,YAAA;AAAA;AAAA,EAGZ,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAGhB,aAAA,EAAe,eAAA;AAAA;AAAA,EAGf,QAAA,EAAU,WAAA;AAAA;AAAA,EAGV,SAAA,EAAW,YAAA;AAAA;AAAA,EAGX,eAAA,EAAiB,kBAAA;AAAA;AAAA,EAGjB,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,QAAA,EAAU,UAAA;AAAA;AAAA,EAGV,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,QAAA,EAAU,UAAA;AAAA;AAAA,EAGV,QAAA,EAAU,UAAA;AAAA;AAAA,EAGV,OAAA,EAAS;AACX","file":"index.js","sourcesContent":["/**\n * Enum representing standardized error types used across the application.\n * @description These error types help classify different categories of errors such as validation issues and system-level failures.\n *\n * @example\n * ```typescript\n * import { ERROR_TYPE } from '@plyaz/types';\n *\n * const errorType = ERROR_TYPE.ValidationError; // 'validation.error'\n *\n * // Error handling example\n * if (error.type === ERROR_TYPE.RateLimitExceeded) {\n * // Handle rate limiting\n * }\n * ```\n */\nexport const ERROR_TYPE = {\n /** A general validation error (e.g., form or input errors). */\n ValidationError: 'validation.error',\n\n /** Error related to schema validation, such as JSON schema or API payload checks. */\n SchemaValidationError: 'validation.schema.error',\n\n /** Unhandled or unexpected system error. */\n InternalError: 'system.internal.error',\n\n /** System dependency is currently unavailable (e.g., database or external API). */\n ServiceUnavailable: 'system.service.unavailable',\n\n /** The request took too long and timed out. */\n TimeoutError: 'system.timeout',\n\n /** Too many requests made in a short period of time. */\n RateLimitExceeded: 'system.rate.limit.exceeded',\n} as const;\n\n/**\n * Enum representing the severity level of an error.\n * @description This allows categorization of errors by their potential impact on the system or user.\n *\n * @example\n * ```typescript\n * import { ERROR_SEVERITY } from '@plyaz/types';\n *\n * const severity = ERROR_SEVERITY.Critical; // 'critical'\n * const shouldAlert = severity === ERROR_SEVERITY.High || severity === ERROR_SEVERITY.Critical;\n * ```\n */\nexport const ERROR_SEVERITY = {\n /** Low severity - does not impact functionality significantly. */\n Low: 'low',\n\n /** Medium severity - minor disruption or warning. */\n Medium: 'medium',\n\n /** High severity - major issue requiring attention. */\n High: 'high',\n\n /** Critical severity - blocking or crashing issue. */\n Critical: 'critical',\n} as const;\n\n/**\n * Enum representing the category or origin of an error.\n * @description Useful for filtering or logging errors based on their source or nature.\n *\n * @example\n * ```typescript\n * import { ERROR_CATEGORY } from '@plyaz/types';\n *\n * const category = ERROR_CATEGORY.Blockchain; // 'blockchain'\n * const isClientError = category === ERROR_CATEGORY.Client;\n * ```\n */\nexport const ERROR_CATEGORY = {\n /** Client-side error (e.g., invalid request). */\n Client: 'client',\n\n /** Server-side error (e.g., logic failure or exception). */\n Server: 'server',\n\n /** Network-related error (e.g., unreachable endpoint). */\n Network: 'network',\n\n /** Blockchain-related error (e.g., transaction failure, gas limit). */\n Blockchain: 'blockchain',\n\n /** Validation-specific error (e.g., failed constraints or field errors). */\n Validation: 'validation',\n\n /** Authentication-related error (e.g., invalid credentials, expired token). */\n Authentication: 'authentication',\n\n /** Authorization-related error (e.g., insufficient permissions). */\n Authorization: 'authorization',\n\n /** Resource not found error. */\n NotFound: 'not.found',\n\n /** Rate limiting error (too many requests). */\n RateLimit: 'rate.limit',\n\n /** External service error (e.g., third-party API failure). */\n ExternalService: 'external.service',\n\n /** Timeout error (request exceeded time limit). */\n Timeout: 'timeout',\n\n /** Conflict error (e.g., resource state conflict). */\n Conflict: 'conflict',\n\n /** Cache-related error. */\n Cache: 'cache',\n\n /** Headers-related error (e.g., missing or invalid headers). */\n Headers: 'headers',\n\n /** Retry-related error (e.g., max retries exceeded). */\n Retry: 'retry',\n\n /** Strategy-related error (e.g., invalid retry or caching strategy). */\n Strategy: 'strategy',\n\n /** Regional-related error (e.g., region detection failure). */\n Regional: 'regional',\n\n /** Unknown or unclassified error. */\n Unknown: 'unknown',\n} as const;\n"]}
@@ -15,6 +15,11 @@ export interface CacheEntry<T = unknown> extends Partial<WithMetadata<Record<str
15
15
  /** The cached data */
16
16
  data: T;
17
17
  }
18
+ export interface GenericCacheEntry<T = unknown> {
19
+ value: T;
20
+ timestamp: number;
21
+ ttl: number;
22
+ }
18
23
  /**
19
24
  * Cache statistics for monitoring and debugging.
20
25
  */