ml-cache 1.0.0

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 (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +599 -0
  3. package/dist/client.d.ts +175 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +411 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/constants.d.ts +184 -0
  8. package/dist/constants.d.ts.map +1 -0
  9. package/dist/constants.js +236 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/esm/client.d.ts +175 -0
  12. package/dist/esm/client.d.ts.map +1 -0
  13. package/dist/esm/client.js +407 -0
  14. package/dist/esm/client.js.map +1 -0
  15. package/dist/esm/constants.d.ts +184 -0
  16. package/dist/esm/constants.d.ts.map +1 -0
  17. package/dist/esm/constants.js +233 -0
  18. package/dist/esm/constants.js.map +1 -0
  19. package/dist/esm/index.d.ts +58 -0
  20. package/dist/esm/index.d.ts.map +1 -0
  21. package/dist/esm/index.js.map +1 -0
  22. package/dist/esm/queue.d.ts +106 -0
  23. package/dist/esm/queue.d.ts.map +1 -0
  24. package/dist/esm/queue.js +207 -0
  25. package/dist/esm/queue.js.map +1 -0
  26. package/dist/esm/storage/glacier-storage.d.ts +77 -0
  27. package/dist/esm/storage/glacier-storage.d.ts.map +1 -0
  28. package/dist/esm/storage/glacier-storage.js +133 -0
  29. package/dist/esm/storage/glacier-storage.js.map +1 -0
  30. package/dist/esm/storage/index.d.ts +7 -0
  31. package/dist/esm/storage/index.d.ts.map +1 -0
  32. package/dist/esm/storage/index.js +7 -0
  33. package/dist/esm/storage/index.js.map +1 -0
  34. package/dist/esm/storage/s3-storage.d.ts +89 -0
  35. package/dist/esm/storage/s3-storage.d.ts.map +1 -0
  36. package/dist/esm/storage/s3-storage.js +161 -0
  37. package/dist/esm/storage/s3-storage.js.map +1 -0
  38. package/dist/esm/types/index.d.ts +337 -0
  39. package/dist/esm/types/index.d.ts.map +1 -0
  40. package/dist/esm/types/index.js +6 -0
  41. package/dist/esm/types/index.js.map +1 -0
  42. package/dist/esm/utils/helpers.d.ts +132 -0
  43. package/dist/esm/utils/helpers.d.ts.map +1 -0
  44. package/dist/esm/utils/helpers.js +198 -0
  45. package/dist/esm/utils/helpers.js.map +1 -0
  46. package/dist/esm/utils/index.d.ts +8 -0
  47. package/dist/esm/utils/index.d.ts.map +1 -0
  48. package/dist/esm/utils/index.js +8 -0
  49. package/dist/esm/utils/index.js.map +1 -0
  50. package/dist/esm/utils/logger.d.ts +110 -0
  51. package/dist/esm/utils/logger.d.ts.map +1 -0
  52. package/dist/esm/utils/logger.js +177 -0
  53. package/dist/esm/utils/logger.js.map +1 -0
  54. package/dist/esm/utils/validator.d.ts +77 -0
  55. package/dist/esm/utils/validator.d.ts.map +1 -0
  56. package/dist/esm/utils/validator.js +208 -0
  57. package/dist/esm/utils/validator.js.map +1 -0
  58. package/dist/index.d.ts +58 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +100 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/index.mjs +72 -0
  63. package/dist/queue.d.ts +106 -0
  64. package/dist/queue.d.ts.map +1 -0
  65. package/dist/queue.js +211 -0
  66. package/dist/queue.js.map +1 -0
  67. package/dist/storage/glacier-storage.d.ts +77 -0
  68. package/dist/storage/glacier-storage.d.ts.map +1 -0
  69. package/dist/storage/glacier-storage.js +137 -0
  70. package/dist/storage/glacier-storage.js.map +1 -0
  71. package/dist/storage/index.d.ts +7 -0
  72. package/dist/storage/index.d.ts.map +1 -0
  73. package/dist/storage/index.js +12 -0
  74. package/dist/storage/index.js.map +1 -0
  75. package/dist/storage/s3-storage.d.ts +89 -0
  76. package/dist/storage/s3-storage.d.ts.map +1 -0
  77. package/dist/storage/s3-storage.js +165 -0
  78. package/dist/storage/s3-storage.js.map +1 -0
  79. package/dist/types/index.d.ts +337 -0
  80. package/dist/types/index.d.ts.map +1 -0
  81. package/dist/types/index.js +7 -0
  82. package/dist/types/index.js.map +1 -0
  83. package/dist/utils/helpers.d.ts +132 -0
  84. package/dist/utils/helpers.d.ts.map +1 -0
  85. package/dist/utils/helpers.js +215 -0
  86. package/dist/utils/helpers.js.map +1 -0
  87. package/dist/utils/index.d.ts +8 -0
  88. package/dist/utils/index.d.ts.map +1 -0
  89. package/dist/utils/index.js +35 -0
  90. package/dist/utils/index.js.map +1 -0
  91. package/dist/utils/logger.d.ts +110 -0
  92. package/dist/utils/logger.d.ts.map +1 -0
  93. package/dist/utils/logger.js +181 -0
  94. package/dist/utils/logger.js.map +1 -0
  95. package/dist/utils/validator.d.ts +77 -0
  96. package/dist/utils/validator.d.ts.map +1 -0
  97. package/dist/utils/validator.js +221 -0
  98. package/dist/utils/validator.js.map +1 -0
  99. package/package.json +64 -0
@@ -0,0 +1,233 @@
1
+ /**
2
+ * @fileoverview Constants and default values for ml-cache SDK
3
+ * @module ml-cache/constants
4
+ */
5
+ /* ============================================================================
6
+ * SDK Information
7
+ * ============================================================================ */
8
+ /**
9
+ * Current SDK version
10
+ * @constant
11
+ */
12
+ export const SDK_VERSION = '1.0.0';
13
+ /**
14
+ * SDK name identifier
15
+ * @constant
16
+ */
17
+ export const SDK_NAME = 'ml-cache';
18
+ /* ============================================================================
19
+ * Default Configurations
20
+ * ============================================================================ */
21
+ /**
22
+ * Default batch configuration
23
+ * @constant
24
+ */
25
+ export const DEFAULT_BATCH_CONFIG = {
26
+ /** Maximum 100 events per batch */
27
+ maxSize: 100,
28
+ /** Flush every 30 seconds */
29
+ maxWaitMs: 30000,
30
+ /** Batching enabled by default */
31
+ enabled: true,
32
+ };
33
+ /**
34
+ * Default retry configuration
35
+ * @constant
36
+ */
37
+ export const DEFAULT_RETRY_CONFIG = {
38
+ /** Maximum 3 retry attempts */
39
+ maxRetries: 3,
40
+ /** Start with 1 second delay */
41
+ initialDelayMs: 1000,
42
+ /** Maximum 30 second delay */
43
+ maxDelayMs: 30000,
44
+ /** Use exponential backoff */
45
+ exponentialBackoff: true,
46
+ };
47
+ /**
48
+ * Default logging configuration
49
+ * @constant
50
+ */
51
+ export const DEFAULT_LOG_CONFIG = {
52
+ /** Default to info level */
53
+ level: 'info',
54
+ /** Logging enabled by default */
55
+ enabled: true,
56
+ /** No custom logger by default */
57
+ customLogger: undefined,
58
+ };
59
+ /**
60
+ * Default S3 storage class for long-term ML data storage
61
+ * @constant
62
+ */
63
+ export const DEFAULT_S3_STORAGE_CLASS = 'GLACIER';
64
+ /**
65
+ * Default Glacier account ID (uses current account)
66
+ * @constant
67
+ */
68
+ export const DEFAULT_GLACIER_ACCOUNT_ID = '-';
69
+ /* ============================================================================
70
+ * Storage Constants
71
+ * ============================================================================ */
72
+ /**
73
+ * Maximum size of a single event payload in bytes (256 KB)
74
+ * @constant
75
+ */
76
+ export const MAX_EVENT_SIZE_BYTES = 256 * 1024;
77
+ /**
78
+ * Maximum size of a batch payload in bytes (5 MB for S3 PutObject)
79
+ * @constant
80
+ */
81
+ export const MAX_BATCH_SIZE_BYTES = 5 * 1024 * 1024;
82
+ /**
83
+ * Minimum size for S3 multipart upload (5 MB)
84
+ * @constant
85
+ */
86
+ export const S3_MULTIPART_THRESHOLD_BYTES = 5 * 1024 * 1024;
87
+ /**
88
+ * Glacier archive description prefix
89
+ * @constant
90
+ */
91
+ export const GLACIER_ARCHIVE_PREFIX = 'ml-cache-events';
92
+ /**
93
+ * S3 object key date format
94
+ * @constant
95
+ */
96
+ export const S3_KEY_DATE_FORMAT = 'YYYY/MM/DD';
97
+ /**
98
+ * Default S3 object prefix
99
+ * @constant
100
+ */
101
+ export const DEFAULT_S3_PREFIX = 'ml-cache-events';
102
+ /* ============================================================================
103
+ * Event Constants
104
+ * ============================================================================ */
105
+ /**
106
+ * Reserved event property names that cannot be overwritten
107
+ * @constant
108
+ */
109
+ export const RESERVED_EVENT_PROPERTIES = [
110
+ 'eventId',
111
+ 'timestamp',
112
+ 'eventType',
113
+ 'metadata',
114
+ ];
115
+ /**
116
+ * Valid event type pattern (alphanumeric with underscores)
117
+ * @constant
118
+ */
119
+ export const EVENT_TYPE_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]*$/;
120
+ /**
121
+ * Maximum event type length
122
+ * @constant
123
+ */
124
+ export const MAX_EVENT_TYPE_LENGTH = 128;
125
+ /**
126
+ * Maximum property key length
127
+ * @constant
128
+ */
129
+ export const MAX_PROPERTY_KEY_LENGTH = 256;
130
+ /* ============================================================================
131
+ * Timing Constants
132
+ * ============================================================================ */
133
+ /**
134
+ * Health check interval in milliseconds (5 minutes)
135
+ * @constant
136
+ */
137
+ export const HEALTH_CHECK_INTERVAL_MS = 5 * 60 * 1000;
138
+ /**
139
+ * Connection timeout in milliseconds (30 seconds)
140
+ * @constant
141
+ */
142
+ export const CONNECTION_TIMEOUT_MS = 30000;
143
+ /**
144
+ * Request timeout in milliseconds (2 minutes)
145
+ * @constant
146
+ */
147
+ export const REQUEST_TIMEOUT_MS = 2 * 60 * 1000;
148
+ /**
149
+ * Shutdown grace period in milliseconds (10 seconds)
150
+ * @constant
151
+ */
152
+ export const SHUTDOWN_GRACE_PERIOD_MS = 10000;
153
+ /* ============================================================================
154
+ * Error Codes
155
+ * ============================================================================ */
156
+ /**
157
+ * SDK error codes
158
+ * @constant
159
+ */
160
+ export const ERROR_CODES = {
161
+ /** Configuration error */
162
+ CONFIG_ERROR: 'ML_CACHE_CONFIG_ERROR',
163
+ /** Validation error */
164
+ VALIDATION_ERROR: 'ML_CACHE_VALIDATION_ERROR',
165
+ /** S3 storage error */
166
+ S3_ERROR: 'ML_CACHE_S3_ERROR',
167
+ /** Glacier storage error */
168
+ GLACIER_ERROR: 'ML_CACHE_GLACIER_ERROR',
169
+ /** Network error */
170
+ NETWORK_ERROR: 'ML_CACHE_NETWORK_ERROR',
171
+ /** Timeout error */
172
+ TIMEOUT_ERROR: 'ML_CACHE_TIMEOUT_ERROR',
173
+ /** Queue full error */
174
+ QUEUE_FULL_ERROR: 'ML_CACHE_QUEUE_FULL_ERROR',
175
+ /** Event too large error */
176
+ EVENT_TOO_LARGE_ERROR: 'ML_CACHE_EVENT_TOO_LARGE_ERROR',
177
+ /** Batch error */
178
+ BATCH_ERROR: 'ML_CACHE_BATCH_ERROR',
179
+ /** Shutdown error */
180
+ SHUTDOWN_ERROR: 'ML_CACHE_SHUTDOWN_ERROR',
181
+ /** Unknown error */
182
+ UNKNOWN_ERROR: 'ML_CACHE_UNKNOWN_ERROR',
183
+ };
184
+ /* ============================================================================
185
+ * Queue Constants
186
+ * ============================================================================ */
187
+ /**
188
+ * Maximum queue size (number of events)
189
+ * @constant
190
+ */
191
+ export const MAX_QUEUE_SIZE = 10000;
192
+ /**
193
+ * Queue warning threshold (80% of max)
194
+ * @constant
195
+ */
196
+ export const QUEUE_WARNING_THRESHOLD = 0.8;
197
+ /* ============================================================================
198
+ * Content Types
199
+ * ============================================================================ */
200
+ /**
201
+ * Content type for stored events (NDJSON)
202
+ * @constant
203
+ */
204
+ export const CONTENT_TYPE_NDJSON = 'application/x-ndjson';
205
+ /**
206
+ * Content type for compressed events
207
+ * @constant
208
+ */
209
+ export const CONTENT_TYPE_GZIP = 'application/gzip';
210
+ /* ============================================================================
211
+ * Environment Variables
212
+ * ============================================================================ */
213
+ /**
214
+ * Environment variable names for configuration
215
+ * @constant
216
+ */
217
+ export const ENV_VARS = {
218
+ /** AWS access key ID */
219
+ AWS_ACCESS_KEY_ID: 'AWS_ACCESS_KEY_ID',
220
+ /** AWS secret access key */
221
+ AWS_SECRET_ACCESS_KEY: 'AWS_SECRET_ACCESS_KEY',
222
+ /** AWS session token */
223
+ AWS_SESSION_TOKEN: 'AWS_SESSION_TOKEN',
224
+ /** AWS region */
225
+ AWS_REGION: 'AWS_REGION',
226
+ /** S3 bucket name */
227
+ ML_CACHE_S3_BUCKET: 'ML_CACHE_S3_BUCKET',
228
+ /** Glacier vault name */
229
+ ML_CACHE_GLACIER_VAULT: 'ML_CACHE_GLACIER_VAULT',
230
+ /** Debug mode */
231
+ ML_CACHE_DEBUG: 'ML_CACHE_DEBUG',
232
+ };
233
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;kFAEkF;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAEnC;;kFAEkF;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,mCAAmC;IACnC,OAAO,EAAE,GAAG;IACZ,6BAA6B;IAC7B,SAAS,EAAE,KAAK;IAChB,kCAAkC;IAClC,OAAO,EAAE,IAAI;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,+BAA+B;IAC/B,UAAU,EAAE,CAAC;IACb,gCAAgC;IAChC,cAAc,EAAE,IAAI;IACpB,8BAA8B;IAC9B,UAAU,EAAE,KAAK;IACjB,8BAA8B;IAC9B,kBAAkB,EAAE,IAAI;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC3C,4BAA4B;IAC5B,KAAK,EAAE,MAAM;IACb,iCAAiC;IACjC,OAAO,EAAE,IAAI;IACb,kCAAkC;IAClC,YAAY,EAAE,SAAS;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAmB,SAAS,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAE9C;;kFAEkF;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,GAAG,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAEpD;;;GAGG;AACH,MAAM,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,uBAAuB;IACvB,gBAAgB,EAAE,2BAA2B;IAC7C,4BAA4B;IAC5B,qBAAqB,EAAE,gCAAgC;IACvD,kBAAkB;IAClB,WAAW,EAAE,sBAAsB;IACnC,qBAAqB;IACrB,cAAc,EAAE,yBAAyB;IACzC,oBAAoB;IACpB,aAAa,EAAE,wBAAwB;CAC/B,CAAC;AAQX;;kFAEkF;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C;;kFAEkF;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAEpD;;kFAEkF;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,wBAAwB;IACxB,iBAAiB,EAAE,mBAAmB;IACtC,4BAA4B;IAC5B,qBAAqB,EAAE,uBAAuB;IAC9C,wBAAwB;IACxB,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB;IACjB,UAAU,EAAE,YAAY;IACxB,qBAAqB;IACrB,kBAAkB,EAAE,oBAAoB;IACxC,yBAAyB;IACzB,sBAAsB,EAAE,wBAAwB;IAChD,iBAAiB;IACjB,cAAc,EAAE,gBAAgB;CACxB,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @fileoverview ML Cache SDK - Store business events for future ML training
3
+ * @module ml-cache
4
+ * @description
5
+ * ML Cache is a TypeScript SDK designed to collect and store business/product events
6
+ * in cold storage (Amazon S3 Glacier) for future machine learning model training.
7
+ *
8
+ * The core idea is simple: ML training costs are decreasing exponentially, but data
9
+ * collection opportunities are fleeting. Store your data now, train your models later.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { MLCacheClient } from 'ml-cache';
14
+ *
15
+ * const client = new MLCacheClient({
16
+ * credentials: {
17
+ * accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
18
+ * secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
19
+ * },
20
+ * s3: {
21
+ * bucket: 'my-ml-data-bucket',
22
+ * region: 'us-east-1',
23
+ * storageClass: 'GLACIER',
24
+ * },
25
+ * storageMode: 'S3',
26
+ * sourceApp: 'my-app',
27
+ * environment: 'production',
28
+ * });
29
+ *
30
+ * // Track events
31
+ * await client.track({
32
+ * eventType: 'purchase',
33
+ * properties: {
34
+ * productId: 'SKU-123',
35
+ * amount: 99.99,
36
+ * currency: 'USD',
37
+ * },
38
+ * context: {
39
+ * user: { userId: 'user-456' },
40
+ * },
41
+ * });
42
+ *
43
+ * // Graceful shutdown
44
+ * await client.shutdown();
45
+ * ```
46
+ *
47
+ * @author Nicolas Mondain
48
+ * @license MIT
49
+ * @see {@link https://github.com/nicolasmondain/ml-cache}
50
+ */
51
+ export { MLCacheClient } from './client';
52
+ export type { AWSCredentials, S3Config, GlacierConfig, S3StorageClass, BaseEvent, UserContext, DeviceContext, PageContext, CampaignContext, EventContext, MLCacheEvent, EventMetadata, StoredEvent, BatchConfig, RetryConfig, LogConfig, LogLevel, LoggerFunction, StorageMode, MLCacheConfig, TrackResult, FlushResult, HealthStatus, EventCallback, ErrorCallback, FlushCallback, } from './types';
53
+ export { SDK_VERSION, SDK_NAME, DEFAULT_BATCH_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_LOG_CONFIG, DEFAULT_S3_STORAGE_CLASS, MAX_EVENT_SIZE_BYTES, MAX_BATCH_SIZE_BYTES, MAX_QUEUE_SIZE, ERROR_CODES, ENV_VARS, } from './constants';
54
+ export { Logger, ValidationError, validateConfig, validateEvent, generateEventId, generateTimestamp, generateBatchId, enrichEvent, serializeEventsToNDJSON, deserializeEventsFromNDJSON, } from './utils';
55
+ export { S3Storage, type S3StorageResult } from './storage/s3-storage';
56
+ export { GlacierStorage, type GlacierStorageResult } from './storage/glacier-storage';
57
+ export { EventQueue, type BatchReadyCallback } from './queue';
58
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAMH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMzC,YAAY,EAEV,cAAc,EACd,QAAQ,EACR,aAAa,EACb,cAAc,EAGd,SAAS,EACT,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EAGX,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACR,cAAc,EACd,WAAW,EACX,aAAa,EAGb,WAAW,EACX,WAAW,EACX,YAAY,EAGZ,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,SAAS,CAAC;AAMjB,OAAO,EACL,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,QAAQ,GACT,MAAM,aAAa,CAAC;AAMrB,OAAO,EACL,MAAM,EACN,eAAe,EACf,cAAc,EACd,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,SAAS,CAAC;AAMjB,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAMtF,OAAO,EAAE,UAAU,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH;;kFAEkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA4CzC;;kFAEkF;AAElF,OAAO,EACL,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,QAAQ,GACT,MAAM,aAAa,CAAC;AAErB;;kFAEkF;AAElF,OAAO,EACL,MAAM,EACN,eAAe,EACf,cAAc,EACd,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,SAAS,CAAC;AAEjB;;kFAEkF;AAElF,OAAO,EAAE,SAAS,EAAwB,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,cAAc,EAA6B,MAAM,2BAA2B,CAAC;AAEtF;;kFAEkF;AAElF,OAAO,EAAE,UAAU,EAA2B,MAAM,SAAS,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * @fileoverview Event queue for batching and buffering
3
+ * @module ml-cache/queue
4
+ */
5
+ import type { MLCacheEvent, BatchConfig } from './types';
6
+ import { Logger } from './utils';
7
+ /**
8
+ * Batch ready callback type
9
+ * @typedef BatchReadyCallback
10
+ */
11
+ export type BatchReadyCallback = (events: MLCacheEvent[], batchId: string) => Promise<void>;
12
+ /**
13
+ * Event queue for batching events before storage
14
+ * @class EventQueue
15
+ */
16
+ export declare class EventQueue {
17
+ /** @private */
18
+ private queue;
19
+ /** @private */
20
+ private config;
21
+ /** @private */
22
+ private logger;
23
+ /** @private */
24
+ private flushTimer;
25
+ /** @private */
26
+ private onBatchReady;
27
+ /** @private */
28
+ private isFlushing;
29
+ /**
30
+ * Creates a new EventQueue instance
31
+ * @param {Partial<BatchConfig>} [config] - Batch configuration
32
+ * @param {Logger} [logger] - Logger instance
33
+ */
34
+ constructor(config?: Partial<BatchConfig>, logger?: Logger);
35
+ /**
36
+ * Sets the callback for when a batch is ready
37
+ * @param {BatchReadyCallback} callback - Callback function
38
+ */
39
+ setOnBatchReady(callback: BatchReadyCallback): void;
40
+ /**
41
+ * Adds an event to the queue
42
+ * @param {MLCacheEvent} event - Event to add
43
+ * @returns {boolean} Whether the event was added successfully
44
+ */
45
+ enqueue(event: MLCacheEvent): boolean;
46
+ /**
47
+ * Checks if a flush should be triggered
48
+ * @private
49
+ */
50
+ private checkFlush;
51
+ /**
52
+ * Starts the flush timer
53
+ * @private
54
+ */
55
+ private startFlushTimer;
56
+ /**
57
+ * Stops the flush timer
58
+ * @private
59
+ */
60
+ private stopFlushTimer;
61
+ /**
62
+ * Flushes the queue
63
+ * @returns {Promise<MLCacheEvent[]>} Flushed events
64
+ */
65
+ flush(): Promise<MLCacheEvent[]>;
66
+ /**
67
+ * Gets the current queue size
68
+ * @returns {number} Queue size
69
+ */
70
+ size(): number;
71
+ /**
72
+ * Checks if the queue is empty
73
+ * @returns {boolean} Whether the queue is empty
74
+ */
75
+ isEmpty(): boolean;
76
+ /**
77
+ * Checks if the queue is full
78
+ * @returns {boolean} Whether the queue is full
79
+ */
80
+ isFull(): boolean;
81
+ /**
82
+ * Gets all events without removing them
83
+ * @returns {MLCacheEvent[]} All events in queue
84
+ */
85
+ peek(): MLCacheEvent[];
86
+ /**
87
+ * Clears the queue
88
+ * @returns {MLCacheEvent[]} Cleared events
89
+ */
90
+ clear(): MLCacheEvent[];
91
+ /**
92
+ * Updates the batch configuration
93
+ * @param {Partial<BatchConfig>} config - New configuration
94
+ */
95
+ setConfig(config: Partial<BatchConfig>): void;
96
+ /**
97
+ * Gets the current batch configuration
98
+ * @returns {BatchConfig} Current configuration
99
+ */
100
+ getConfig(): BatchConfig;
101
+ /**
102
+ * Destroys the queue
103
+ */
104
+ destroy(): void;
105
+ }
106
+ //# sourceMappingURL=queue.d.ts.map
@@ -0,0 +1 @@
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OvB;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAI7C;;;OAGG;IACH,SAAS,IAAI,WAAW;IAIxB;;OAEG;IACH,OAAO,IAAI,IAAI;CAKhB"}
@@ -0,0 +1,207 @@
1
+ /**
2
+ * @fileoverview Event queue for batching and buffering
3
+ * @module ml-cache/queue
4
+ */
5
+ import { DEFAULT_BATCH_CONFIG, MAX_QUEUE_SIZE, QUEUE_WARNING_THRESHOLD } from './constants';
6
+ import { Logger, generateBatchId } from './utils';
7
+ /**
8
+ * Event queue for batching events before storage
9
+ * @class EventQueue
10
+ */
11
+ export class EventQueue {
12
+ /**
13
+ * Creates a new EventQueue instance
14
+ * @param {Partial<BatchConfig>} [config] - Batch configuration
15
+ * @param {Logger} [logger] - Logger instance
16
+ */
17
+ constructor(config, logger) {
18
+ /** @private */
19
+ this.queue = [];
20
+ /** @private */
21
+ this.flushTimer = null;
22
+ /** @private */
23
+ this.onBatchReady = null;
24
+ /** @private */
25
+ this.isFlushing = false;
26
+ this.config = { ...DEFAULT_BATCH_CONFIG, ...config };
27
+ this.logger = logger || new Logger();
28
+ }
29
+ /**
30
+ * Sets the callback for when a batch is ready
31
+ * @param {BatchReadyCallback} callback - Callback function
32
+ */
33
+ setOnBatchReady(callback) {
34
+ this.onBatchReady = callback;
35
+ }
36
+ /**
37
+ * Adds an event to the queue
38
+ * @param {MLCacheEvent} event - Event to add
39
+ * @returns {boolean} Whether the event was added successfully
40
+ */
41
+ enqueue(event) {
42
+ if (this.queue.length >= MAX_QUEUE_SIZE) {
43
+ this.logger.error('Queue is full, dropping event', {
44
+ eventId: event.eventId,
45
+ queueSize: this.queue.length,
46
+ });
47
+ return false;
48
+ }
49
+ this.queue.push(event);
50
+ if (this.queue.length / MAX_QUEUE_SIZE >= QUEUE_WARNING_THRESHOLD) {
51
+ this.logger.warn('Queue is approaching capacity', {
52
+ queueSize: this.queue.length,
53
+ maxSize: MAX_QUEUE_SIZE,
54
+ });
55
+ }
56
+ this.logger.debug('Event enqueued', {
57
+ eventId: event.eventId,
58
+ queueSize: this.queue.length,
59
+ });
60
+ if (this.config.enabled) {
61
+ this.checkFlush();
62
+ }
63
+ return true;
64
+ }
65
+ /**
66
+ * Checks if a flush should be triggered
67
+ * @private
68
+ */
69
+ checkFlush() {
70
+ if (this.queue.length >= this.config.maxSize) {
71
+ this.logger.debug('Queue reached max size, triggering flush');
72
+ void this.flush();
73
+ }
74
+ else if (!this.flushTimer && this.queue.length > 0) {
75
+ this.startFlushTimer();
76
+ }
77
+ }
78
+ /**
79
+ * Starts the flush timer
80
+ * @private
81
+ */
82
+ startFlushTimer() {
83
+ if (this.flushTimer) {
84
+ return;
85
+ }
86
+ this.flushTimer = setTimeout(() => {
87
+ this.flushTimer = null;
88
+ if (this.queue.length > 0) {
89
+ this.logger.debug('Flush timer triggered');
90
+ void this.flush();
91
+ }
92
+ }, this.config.maxWaitMs);
93
+ }
94
+ /**
95
+ * Stops the flush timer
96
+ * @private
97
+ */
98
+ stopFlushTimer() {
99
+ if (this.flushTimer) {
100
+ clearTimeout(this.flushTimer);
101
+ this.flushTimer = null;
102
+ }
103
+ }
104
+ /**
105
+ * Flushes the queue
106
+ * @returns {Promise<MLCacheEvent[]>} Flushed events
107
+ */
108
+ async flush() {
109
+ if (this.isFlushing) {
110
+ this.logger.debug('Flush already in progress');
111
+ return [];
112
+ }
113
+ if (this.queue.length === 0) {
114
+ this.logger.debug('Queue is empty, nothing to flush');
115
+ return [];
116
+ }
117
+ this.isFlushing = true;
118
+ this.stopFlushTimer();
119
+ const eventsToFlush = this.queue.splice(0, this.config.maxSize);
120
+ const batchId = generateBatchId();
121
+ this.logger.info('Flushing queue', {
122
+ batchId,
123
+ eventCount: eventsToFlush.length,
124
+ remainingInQueue: this.queue.length,
125
+ });
126
+ try {
127
+ if (this.onBatchReady) {
128
+ await this.onBatchReady(eventsToFlush, batchId);
129
+ }
130
+ }
131
+ catch (error) {
132
+ this.logger.error('Error in batch ready callback', {
133
+ batchId,
134
+ error: error instanceof Error ? error.message : String(error),
135
+ });
136
+ this.queue.unshift(...eventsToFlush);
137
+ }
138
+ finally {
139
+ this.isFlushing = false;
140
+ if (this.queue.length > 0 && this.config.enabled) {
141
+ this.startFlushTimer();
142
+ }
143
+ }
144
+ return eventsToFlush;
145
+ }
146
+ /**
147
+ * Gets the current queue size
148
+ * @returns {number} Queue size
149
+ */
150
+ size() {
151
+ return this.queue.length;
152
+ }
153
+ /**
154
+ * Checks if the queue is empty
155
+ * @returns {boolean} Whether the queue is empty
156
+ */
157
+ isEmpty() {
158
+ return this.queue.length === 0;
159
+ }
160
+ /**
161
+ * Checks if the queue is full
162
+ * @returns {boolean} Whether the queue is full
163
+ */
164
+ isFull() {
165
+ return this.queue.length >= MAX_QUEUE_SIZE;
166
+ }
167
+ /**
168
+ * Gets all events without removing them
169
+ * @returns {MLCacheEvent[]} All events in queue
170
+ */
171
+ peek() {
172
+ return [...this.queue];
173
+ }
174
+ /**
175
+ * Clears the queue
176
+ * @returns {MLCacheEvent[]} Cleared events
177
+ */
178
+ clear() {
179
+ this.stopFlushTimer();
180
+ const events = this.queue.splice(0);
181
+ this.logger.info('Queue cleared', { eventCount: events.length });
182
+ return events;
183
+ }
184
+ /**
185
+ * Updates the batch configuration
186
+ * @param {Partial<BatchConfig>} config - New configuration
187
+ */
188
+ setConfig(config) {
189
+ this.config = { ...this.config, ...config };
190
+ }
191
+ /**
192
+ * Gets the current batch configuration
193
+ * @returns {BatchConfig} Current configuration
194
+ */
195
+ getConfig() {
196
+ return { ...this.config };
197
+ }
198
+ /**
199
+ * Destroys the queue
200
+ */
201
+ destroy() {
202
+ this.stopFlushTimer();
203
+ this.queue = [];
204
+ this.onBatchReady = null;
205
+ }
206
+ }
207
+ //# sourceMappingURL=queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAG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