@forklaunch/core 0.8.2 → 0.8.4

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.
@@ -1,8 +1,3 @@
1
- import { RedisClientOptions } from 'redis';
2
- import { O as OpenTelemetryCollector, M as MetricsDefinition, T as TelemetryOptions } from '../../openTelemetryCollector-DQC2FfOu.mjs';
3
- import '@opentelemetry/api';
4
- import 'pino';
5
-
6
1
  /**
7
2
  * Creates a function that generates cache keys with a given prefix.
8
3
  *
@@ -146,175 +141,4 @@ interface TtlCache {
146
141
  listKeys(pattern_prefix: string): Promise<string[]>;
147
142
  }
148
143
 
149
- /**
150
- * Class representing a Redis-based TTL (Time-To-Live) cache.
151
- * Implements the TtlCache interface to provide caching functionality with automatic expiration.
152
- */
153
- declare class RedisTtlCache implements TtlCache {
154
- private ttlMilliseconds;
155
- private openTelemetryCollector;
156
- private client;
157
- private telemetryOptions;
158
- /**
159
- * Creates an instance of RedisTtlCache.
160
- *
161
- * @param {number} ttlMilliseconds - The default Time-To-Live in milliseconds for cache entries
162
- * @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics
163
- * @param {RedisClientOptions} hostingOptions - Configuration options for the Redis client
164
- * @param {TelemetryOptions} telemetryOptions - Configuration options for telemetry
165
- */
166
- constructor(ttlMilliseconds: number, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, hostingOptions: RedisClientOptions, telemetryOptions: TelemetryOptions);
167
- /**
168
- * Parses a raw Redis reply into the expected type.
169
- * Handles null values, arrays, buffers, and JSON strings.
170
- *
171
- * @template T - The expected type of the parsed value
172
- * @param {RedisCommandRawReply} value - The raw value from Redis to parse
173
- * @returns {T} The parsed value cast to type T
174
- */
175
- private parseValue;
176
- /**
177
- * Puts a record into the Redis cache.
178
- *
179
- * @template T - The type of value being cached
180
- * @param {TtlCacheRecord<T>} param0 - The cache record containing key, value and optional TTL
181
- * @param {string} param0.key - The key to store the value under
182
- * @param {T} param0.value - The value to cache
183
- * @param {number} [param0.ttlMilliseconds] - Optional TTL in milliseconds, defaults to constructor value
184
- * @returns {Promise<void>} A promise that resolves when the value is cached
185
- */
186
- putRecord<T>({ key, value, ttlMilliseconds }: TtlCacheRecord<T>): Promise<void>;
187
- /**
188
- * Puts multiple records into the Redis cache in a single transaction.
189
- *
190
- * @template T - The type of values being cached
191
- * @param {TtlCacheRecord<T>[]} cacheRecords - Array of cache records to store
192
- * @returns {Promise<void>} A promise that resolves when all values are cached
193
- */
194
- putBatchRecords<T>(cacheRecords: TtlCacheRecord<T>[]): Promise<void>;
195
- /**
196
- * Adds a value to the left end of a Redis list.
197
- *
198
- * @template T - The type of value being enqueued
199
- * @param {string} queueName - The name of the Redis list
200
- * @param {T} value - The value to add to the list
201
- * @returns {Promise<void>} A promise that resolves when the value is enqueued
202
- */
203
- enqueueRecord<T>(queueName: string, value: T): Promise<void>;
204
- /**
205
- * Adds multiple values to the left end of a Redis list in a single transaction.
206
- *
207
- * @template T - The type of values being enqueued
208
- * @param {string} queueName - The name of the Redis list
209
- * @param {T[]} values - Array of values to add to the list
210
- * @returns {Promise<void>} A promise that resolves when all values are enqueued
211
- */
212
- enqueueBatchRecords<T>(queueName: string, values: T[]): Promise<void>;
213
- /**
214
- * Deletes a record from the Redis cache.
215
- *
216
- * @param {string} cacheRecordKey - The key of the record to delete
217
- * @returns {Promise<void>} A promise that resolves when the record is deleted
218
- */
219
- deleteRecord(cacheRecordKey: string): Promise<void>;
220
- /**
221
- * Deletes multiple records from the Redis cache in a single transaction.
222
- *
223
- * @param {string[]} cacheRecordKeys - Array of keys to delete
224
- * @returns {Promise<void>} A promise that resolves when all records are deleted
225
- */
226
- deleteBatchRecords(cacheRecordKeys: string[]): Promise<void>;
227
- /**
228
- * Removes and returns the rightmost element from a Redis list.
229
- *
230
- * @template T - The type of value being dequeued
231
- * @param {string} queueName - The name of the Redis list
232
- * @returns {Promise<T>} A promise that resolves with the dequeued value
233
- * @throws {Error} If the queue is empty
234
- */
235
- dequeueRecord<T>(queueName: string): Promise<T>;
236
- /**
237
- * Removes and returns multiple elements from the right end of a Redis list.
238
- *
239
- * @template T - The type of values being dequeued
240
- * @param {string} queueName - The name of the Redis list
241
- * @param {number} pageSize - Maximum number of elements to dequeue
242
- * @returns {Promise<T[]>} A promise that resolves with an array of dequeued values
243
- */
244
- dequeueBatchRecords<T>(queueName: string, pageSize: number): Promise<T[]>;
245
- /**
246
- * Reads a record from the Redis cache.
247
- *
248
- * @template T - The type of value being read
249
- * @param {string} cacheRecordKey - The key of the record to read
250
- * @returns {Promise<TtlCacheRecord<T>>} A promise that resolves with the cache record
251
- * @throws {Error} If the record is not found
252
- */
253
- readRecord<T>(cacheRecordKey: string): Promise<TtlCacheRecord<T>>;
254
- /**
255
- * Reads multiple records from the Redis cache.
256
- *
257
- * @template T - The type of values being read
258
- * @param {string[] | string} cacheRecordKeysOrPrefix - Array of keys to read, or a prefix pattern
259
- * @returns {Promise<TtlCacheRecord<T>[]>} A promise that resolves with an array of cache records
260
- */
261
- readBatchRecords<T>(cacheRecordKeysOrPrefix: string[] | string): Promise<TtlCacheRecord<T>[]>;
262
- /**
263
- * Lists all keys in the Redis cache that match a pattern prefix.
264
- *
265
- * @param {string} pattern_prefix - The prefix pattern to match keys against
266
- * @returns {Promise<string[]>} A promise that resolves with an array of matching keys
267
- */
268
- listKeys(pattern_prefix: string): Promise<string[]>;
269
- /**
270
- * Checks if a record exists in the Redis cache.
271
- *
272
- * @param {string} cacheRecordKey - The key to check
273
- * @returns {Promise<boolean>} A promise that resolves with true if the record exists, false otherwise
274
- */
275
- peekRecord(cacheRecordKey: string): Promise<boolean>;
276
- /**
277
- * Checks if multiple records exist in the Redis cache.
278
- *
279
- * @param {string[] | string} cacheRecordKeysOrPrefix - Array of keys to check, or a prefix pattern
280
- * @returns {Promise<boolean[]>} A promise that resolves with an array of existence booleans
281
- */
282
- peekBatchRecords(cacheRecordKeysOrPrefix: string[] | string): Promise<boolean[]>;
283
- /**
284
- * Peeks at a record in the Redis cache.
285
- *
286
- * @template T - The type of value being peeked at
287
- * @param {string} queueName - The name of the Redis queue
288
- * @returns {Promise<T>} A promise that resolves with the peeked value
289
- */
290
- peekQueueRecord<T>(queueName: string): Promise<T>;
291
- /**
292
- * Peeks at multiple records in the Redis cache.
293
- *
294
- * @template T - The type of values being peeked at
295
- * @param {string} queueName - The name of the Redis queue
296
- * @param {number} pageSize - The number of records to peek at
297
- * @returns {Promise<T[]>} A promise that resolves with an array of peeked values
298
- */
299
- peekQueueRecords<T>(queueName: string, pageSize: number): Promise<T[]>;
300
- /**
301
- * Gracefully disconnects from the Redis server.
302
- *
303
- * @returns {Promise<void>} A promise that resolves when the connection is closed
304
- */
305
- disconnect(): Promise<void>;
306
- /**
307
- * Gets the default Time-To-Live value in milliseconds.
308
- *
309
- * @returns {number} The default TTL in milliseconds
310
- */
311
- getTtlMilliseconds(): number;
312
- /**
313
- * Gets the underlying Redis client instance.
314
- *
315
- * @returns {typeof this.client} The Redis client instance
316
- */
317
- getClient(): typeof this.client;
318
- }
319
-
320
- export { RedisTtlCache, type TtlCache, type TtlCacheRecord, createCacheKey };
144
+ export { type TtlCache, type TtlCacheRecord, createCacheKey };
@@ -1,8 +1,3 @@
1
- import { RedisClientOptions } from 'redis';
2
- import { O as OpenTelemetryCollector, M as MetricsDefinition, T as TelemetryOptions } from '../../openTelemetryCollector-DQC2FfOu.js';
3
- import '@opentelemetry/api';
4
- import 'pino';
5
-
6
1
  /**
7
2
  * Creates a function that generates cache keys with a given prefix.
8
3
  *
@@ -146,175 +141,4 @@ interface TtlCache {
146
141
  listKeys(pattern_prefix: string): Promise<string[]>;
147
142
  }
148
143
 
149
- /**
150
- * Class representing a Redis-based TTL (Time-To-Live) cache.
151
- * Implements the TtlCache interface to provide caching functionality with automatic expiration.
152
- */
153
- declare class RedisTtlCache implements TtlCache {
154
- private ttlMilliseconds;
155
- private openTelemetryCollector;
156
- private client;
157
- private telemetryOptions;
158
- /**
159
- * Creates an instance of RedisTtlCache.
160
- *
161
- * @param {number} ttlMilliseconds - The default Time-To-Live in milliseconds for cache entries
162
- * @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics
163
- * @param {RedisClientOptions} hostingOptions - Configuration options for the Redis client
164
- * @param {TelemetryOptions} telemetryOptions - Configuration options for telemetry
165
- */
166
- constructor(ttlMilliseconds: number, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, hostingOptions: RedisClientOptions, telemetryOptions: TelemetryOptions);
167
- /**
168
- * Parses a raw Redis reply into the expected type.
169
- * Handles null values, arrays, buffers, and JSON strings.
170
- *
171
- * @template T - The expected type of the parsed value
172
- * @param {RedisCommandRawReply} value - The raw value from Redis to parse
173
- * @returns {T} The parsed value cast to type T
174
- */
175
- private parseValue;
176
- /**
177
- * Puts a record into the Redis cache.
178
- *
179
- * @template T - The type of value being cached
180
- * @param {TtlCacheRecord<T>} param0 - The cache record containing key, value and optional TTL
181
- * @param {string} param0.key - The key to store the value under
182
- * @param {T} param0.value - The value to cache
183
- * @param {number} [param0.ttlMilliseconds] - Optional TTL in milliseconds, defaults to constructor value
184
- * @returns {Promise<void>} A promise that resolves when the value is cached
185
- */
186
- putRecord<T>({ key, value, ttlMilliseconds }: TtlCacheRecord<T>): Promise<void>;
187
- /**
188
- * Puts multiple records into the Redis cache in a single transaction.
189
- *
190
- * @template T - The type of values being cached
191
- * @param {TtlCacheRecord<T>[]} cacheRecords - Array of cache records to store
192
- * @returns {Promise<void>} A promise that resolves when all values are cached
193
- */
194
- putBatchRecords<T>(cacheRecords: TtlCacheRecord<T>[]): Promise<void>;
195
- /**
196
- * Adds a value to the left end of a Redis list.
197
- *
198
- * @template T - The type of value being enqueued
199
- * @param {string} queueName - The name of the Redis list
200
- * @param {T} value - The value to add to the list
201
- * @returns {Promise<void>} A promise that resolves when the value is enqueued
202
- */
203
- enqueueRecord<T>(queueName: string, value: T): Promise<void>;
204
- /**
205
- * Adds multiple values to the left end of a Redis list in a single transaction.
206
- *
207
- * @template T - The type of values being enqueued
208
- * @param {string} queueName - The name of the Redis list
209
- * @param {T[]} values - Array of values to add to the list
210
- * @returns {Promise<void>} A promise that resolves when all values are enqueued
211
- */
212
- enqueueBatchRecords<T>(queueName: string, values: T[]): Promise<void>;
213
- /**
214
- * Deletes a record from the Redis cache.
215
- *
216
- * @param {string} cacheRecordKey - The key of the record to delete
217
- * @returns {Promise<void>} A promise that resolves when the record is deleted
218
- */
219
- deleteRecord(cacheRecordKey: string): Promise<void>;
220
- /**
221
- * Deletes multiple records from the Redis cache in a single transaction.
222
- *
223
- * @param {string[]} cacheRecordKeys - Array of keys to delete
224
- * @returns {Promise<void>} A promise that resolves when all records are deleted
225
- */
226
- deleteBatchRecords(cacheRecordKeys: string[]): Promise<void>;
227
- /**
228
- * Removes and returns the rightmost element from a Redis list.
229
- *
230
- * @template T - The type of value being dequeued
231
- * @param {string} queueName - The name of the Redis list
232
- * @returns {Promise<T>} A promise that resolves with the dequeued value
233
- * @throws {Error} If the queue is empty
234
- */
235
- dequeueRecord<T>(queueName: string): Promise<T>;
236
- /**
237
- * Removes and returns multiple elements from the right end of a Redis list.
238
- *
239
- * @template T - The type of values being dequeued
240
- * @param {string} queueName - The name of the Redis list
241
- * @param {number} pageSize - Maximum number of elements to dequeue
242
- * @returns {Promise<T[]>} A promise that resolves with an array of dequeued values
243
- */
244
- dequeueBatchRecords<T>(queueName: string, pageSize: number): Promise<T[]>;
245
- /**
246
- * Reads a record from the Redis cache.
247
- *
248
- * @template T - The type of value being read
249
- * @param {string} cacheRecordKey - The key of the record to read
250
- * @returns {Promise<TtlCacheRecord<T>>} A promise that resolves with the cache record
251
- * @throws {Error} If the record is not found
252
- */
253
- readRecord<T>(cacheRecordKey: string): Promise<TtlCacheRecord<T>>;
254
- /**
255
- * Reads multiple records from the Redis cache.
256
- *
257
- * @template T - The type of values being read
258
- * @param {string[] | string} cacheRecordKeysOrPrefix - Array of keys to read, or a prefix pattern
259
- * @returns {Promise<TtlCacheRecord<T>[]>} A promise that resolves with an array of cache records
260
- */
261
- readBatchRecords<T>(cacheRecordKeysOrPrefix: string[] | string): Promise<TtlCacheRecord<T>[]>;
262
- /**
263
- * Lists all keys in the Redis cache that match a pattern prefix.
264
- *
265
- * @param {string} pattern_prefix - The prefix pattern to match keys against
266
- * @returns {Promise<string[]>} A promise that resolves with an array of matching keys
267
- */
268
- listKeys(pattern_prefix: string): Promise<string[]>;
269
- /**
270
- * Checks if a record exists in the Redis cache.
271
- *
272
- * @param {string} cacheRecordKey - The key to check
273
- * @returns {Promise<boolean>} A promise that resolves with true if the record exists, false otherwise
274
- */
275
- peekRecord(cacheRecordKey: string): Promise<boolean>;
276
- /**
277
- * Checks if multiple records exist in the Redis cache.
278
- *
279
- * @param {string[] | string} cacheRecordKeysOrPrefix - Array of keys to check, or a prefix pattern
280
- * @returns {Promise<boolean[]>} A promise that resolves with an array of existence booleans
281
- */
282
- peekBatchRecords(cacheRecordKeysOrPrefix: string[] | string): Promise<boolean[]>;
283
- /**
284
- * Peeks at a record in the Redis cache.
285
- *
286
- * @template T - The type of value being peeked at
287
- * @param {string} queueName - The name of the Redis queue
288
- * @returns {Promise<T>} A promise that resolves with the peeked value
289
- */
290
- peekQueueRecord<T>(queueName: string): Promise<T>;
291
- /**
292
- * Peeks at multiple records in the Redis cache.
293
- *
294
- * @template T - The type of values being peeked at
295
- * @param {string} queueName - The name of the Redis queue
296
- * @param {number} pageSize - The number of records to peek at
297
- * @returns {Promise<T[]>} A promise that resolves with an array of peeked values
298
- */
299
- peekQueueRecords<T>(queueName: string, pageSize: number): Promise<T[]>;
300
- /**
301
- * Gracefully disconnects from the Redis server.
302
- *
303
- * @returns {Promise<void>} A promise that resolves when the connection is closed
304
- */
305
- disconnect(): Promise<void>;
306
- /**
307
- * Gets the default Time-To-Live value in milliseconds.
308
- *
309
- * @returns {number} The default TTL in milliseconds
310
- */
311
- getTtlMilliseconds(): number;
312
- /**
313
- * Gets the underlying Redis client instance.
314
- *
315
- * @returns {typeof this.client} The Redis client instance
316
- */
317
- getClient(): typeof this.client;
318
- }
319
-
320
- export { RedisTtlCache, type TtlCache, type TtlCacheRecord, createCacheKey };
144
+ export { type TtlCache, type TtlCacheRecord, createCacheKey };