@qlover/fe-corekit 2.2.0 → 2.3.1

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.
package/dist/index.d.ts CHANGED
@@ -2476,6 +2476,7 @@ declare class AbortPlugin<TParameters> implements ExecutorPlugin {
2476
2476
  * 5. Sets up timeout timer if `abortTimeout` configured
2477
2477
  * 6. Injects abort signal into configuration
2478
2478
  *
2479
+ * @override
2479
2480
  * @param context - Executor context containing parameters and metadata
2480
2481
  *
2481
2482
  * @example Configuration in context
@@ -2494,6 +2495,7 @@ declare class AbortPlugin<TParameters> implements ExecutorPlugin {
2494
2495
  * Cleans up resources (controller and timeout) for completed operation
2495
2496
  * Ensures no memory leaks from successful operations
2496
2497
  *
2498
+ * @override
2497
2499
  * @param context - Executor context containing parameters and metadata
2498
2500
  *
2499
2501
  * @example
@@ -2514,6 +2516,7 @@ declare class AbortPlugin<TParameters> implements ExecutorPlugin {
2514
2516
  * 2. If abort error: Extract reason from signal, cleanup resources, return `AbortError`
2515
2517
  * 3. If other error: Still cleanup resources to prevent leaks
2516
2518
  *
2519
+ * @override
2517
2520
  * @param context - Executor context containing error, parameters, and metadata
2518
2521
  * @returns `AbortError` if error is abort-related, `void` otherwise
2519
2522
  *
@@ -2810,6 +2813,7 @@ declare class RetryPlugin implements ExecutorPlugin {
2810
2813
  * This method intercepts task execution to add retry capability,
2811
2814
  * executing the task with the configured retry logic.
2812
2815
  *
2816
+ * @override
2813
2817
  * @template T - Type of task return value
2814
2818
  * @param task - Task to be executed with retry support
2815
2819
  * @returns Promise resolving to task result
@@ -3140,6 +3144,9 @@ declare class RequestAdapterFetch implements RequestAdapterInterface<RequestAdap
3140
3144
  * ```
3141
3145
  */
3142
3146
  constructor(config?: Partial<RequestAdapterFetchConfig>);
3147
+ /**
3148
+ * @override
3149
+ */
3143
3150
  getConfig(): RequestAdapterFetchConfig;
3144
3151
  usePlugin(plugin: ExecutorPlugin): void;
3145
3152
  /**
@@ -3191,7 +3198,13 @@ declare class RequestAdapterAxios implements RequestAdapterInterface<AxiosReques
3191
3198
  readonly config: AxiosRequestConfig;
3192
3199
  private axiosInstance;
3193
3200
  constructor(axios: AxiosStatic, config?: AxiosRequestConfig);
3201
+ /**
3202
+ * @override
3203
+ */
3194
3204
  getConfig(): AxiosRequestConfig;
3205
+ /**
3206
+ * @override
3207
+ */
3195
3208
  request<Request, Response>(config: AxiosRequestConfig<Request>): Promise<RequestAdapterResponse<Request, Response>>;
3196
3209
  }
3197
3210
 
@@ -3275,6 +3288,7 @@ declare class FetchAbortPlugin implements ExecutorPlugin {
3275
3288
  * Pre-request hook that sets up abort handling
3276
3289
  * Creates new AbortController and cancels any existing request with same key
3277
3290
  *
3291
+ * @override
3278
3292
  * @param config - Request configuration
3279
3293
  * @returns Modified configuration with abort control
3280
3294
  *
@@ -3284,11 +3298,15 @@ declare class FetchAbortPlugin implements ExecutorPlugin {
3284
3298
  * ```
3285
3299
  */
3286
3300
  onBefore(context: ExecutorContext<RequestAdapterConfig>): void;
3301
+ /**
3302
+ * @override
3303
+ */
3287
3304
  onSuccess({ parameters }: ExecutorContext<RequestAdapterConfig>): void;
3288
3305
  /**
3289
3306
  * Error handling hook for abort scenarios
3290
3307
  * Processes different types of abort errors and cleans up resources
3291
3308
  *
3309
+ * @override
3292
3310
  * @param error - Original error
3293
3311
  * @param config - Request configuration
3294
3312
  * @returns RequestError or void
@@ -3437,6 +3455,7 @@ declare class FetchURLPlugin implements ExecutorPlugin {
3437
3455
  /**
3438
3456
  * Pre-request hook that builds complete URL
3439
3457
  *
3458
+ * @override
3440
3459
  * @param config - Request configuration
3441
3460
  *
3442
3461
  * @example
@@ -3449,6 +3468,7 @@ declare class FetchURLPlugin implements ExecutorPlugin {
3449
3468
  * Success hook that validates response status
3450
3469
  * Throws error for non-OK responses
3451
3470
  *
3471
+ * @override
3452
3472
  * @param result - Fetch response
3453
3473
  * @returns Response if OK
3454
3474
  * @throws {RequestError} If response is not OK
@@ -3463,6 +3483,7 @@ declare class FetchURLPlugin implements ExecutorPlugin {
3463
3483
  * Error handling hook
3464
3484
  * Wraps non-RequestError errors
3465
3485
  *
3486
+ * @override
3466
3487
  * @param error - Original error
3467
3488
  * @returns RequestError
3468
3489
  *
@@ -3806,6 +3827,7 @@ declare class RequestScheduler<Config extends RequestAdapterConfig> extends Requ
3806
3827
  declare class RequestTransaction<Config extends RequestAdapterConfig<unknown>> extends RequestManager<Config> {
3807
3828
  /**
3808
3829
  * Makes an HTTP request with flexible type definitions
3830
+ * @override
3809
3831
  * @template Transaction - Can be either the direct response data type or a RequestTransactionInterface
3810
3832
  * @param config - Request configuration object
3811
3833
  * @returns Promise of response data
@@ -4246,6 +4268,296 @@ interface ExpireOptions {
4246
4268
  expires?: unknown;
4247
4269
  }
4248
4270
 
4271
+ /**
4272
+ * Key-value storage interface for managing a single value with persistence support
4273
+ *
4274
+ * Core concept:
4275
+ * Provides a unified interface for storing and retrieving a single value associated
4276
+ * with a specific key. Supports both in-memory and persistent storage backends,
4277
+ * enabling flexible storage strategies for different use cases.
4278
+ *
4279
+ * **v2.3.0 before this was an abstract class, now it is an interface**
4280
+ *
4281
+ * Main features:
4282
+ * - Single value storage: Store one value per key instance
4283
+ * - Key management: Retrieve the storage key associated with this instance
4284
+ * - Value retrieval: Get stored value from memory or persistent storage
4285
+ * - Value persistence: Save value to underlying storage backend
4286
+ * - Value removal: Clear value from both memory and persistent storage
4287
+ * - Options support: Flexible options parameter for storage-specific configurations
4288
+ *
4289
+ * Typical usage scenarios:
4290
+ * - Token storage: Store authentication tokens with persistence
4291
+ * - User info storage: Persist user information across sessions
4292
+ * - Configuration storage: Store application settings (theme, language, etc.)
4293
+ * - Session data: Manage temporary session-specific data
4294
+ *
4295
+ * Design decisions:
4296
+ * - Returns `null` when value is not found (explicit null handling)
4297
+ * - Options parameter is optional to support simple use cases
4298
+ * - Generic types allow type-safe storage of any value type
4299
+ * - Supports both synchronous and asynchronous storage backends through options
4300
+ *
4301
+ * @template Key - The type of the storage key (e.g., `string`, `number`, `symbol`)
4302
+ * @template Value - The type of value to store
4303
+ * @template Opt - The type of options for storage operations (defaults to `unknown`)
4304
+ *
4305
+ * @example Basic usage with localStorage
4306
+ * ```typescript
4307
+ * const tokenStorage: KeyStorageInterface<string, string> = new KeyStorage('token', {
4308
+ * storage: localStorage
4309
+ * });
4310
+ *
4311
+ * // Store token
4312
+ * tokenStorage.set('abc123token');
4313
+ *
4314
+ * // Retrieve token
4315
+ * const token = tokenStorage.get(); // Returns 'abc123token'
4316
+ *
4317
+ * // Get storage key
4318
+ * const key = tokenStorage.getKey(); // Returns 'token'
4319
+ *
4320
+ * // Remove token
4321
+ * tokenStorage.remove();
4322
+ * ```
4323
+ *
4324
+ * @example User information storage
4325
+ * ```typescript
4326
+ * interface User {
4327
+ * id: string;
4328
+ * name: string;
4329
+ * email: string;
4330
+ * }
4331
+ *
4332
+ * const userStorage: KeyStorageInterface<string, User> = new KeyStorage('user', {
4333
+ * storage: localStorage
4334
+ * });
4335
+ *
4336
+ * const user: User = {
4337
+ * id: '123',
4338
+ * name: 'John Doe',
4339
+ * email: 'john@example.com'
4340
+ * };
4341
+ *
4342
+ * userStorage.set(user);
4343
+ * const storedUser = userStorage.get(); // Returns User object
4344
+ * ```
4345
+ *
4346
+ * @example With custom options
4347
+ * ```typescript
4348
+ * interface StorageOptions {
4349
+ * encrypt?: boolean;
4350
+ * expires?: number;
4351
+ * }
4352
+ *
4353
+ * const secureStorage: KeyStorageInterface<string, string, StorageOptions> =
4354
+ * new KeyStorage('secret', {
4355
+ * storage: localStorage,
4356
+ * encrypt: true
4357
+ * });
4358
+ *
4359
+ * secureStorage.set('sensitive-data', { encrypt: true, expires: 3600 });
4360
+ * ```
4361
+ */
4362
+ interface KeyStorageInterface<Key, Value, Opt = unknown> {
4363
+ /**
4364
+ * Get the storage key associated with this instance
4365
+ *
4366
+ * Returns the key that was used to initialize this storage instance.
4367
+ * This key is used to identify the storage location in the underlying
4368
+ * storage backend.
4369
+ *
4370
+ * @returns The storage key of type `Key`
4371
+ *
4372
+ * @example
4373
+ * ```typescript
4374
+ * const storage = new KeyStorage('my-key', { storage: localStorage });
4375
+ * const key = storage.getKey(); // Returns 'my-key'
4376
+ * ```
4377
+ */
4378
+ getKey(): Key;
4379
+ /**
4380
+ * Get the current in-memory value without accessing persistent storage
4381
+ *
4382
+ * Returns the value currently stored in memory. This method does not
4383
+ * attempt to load from persistent storage. Use `get()` if you want
4384
+ * to retrieve from persistent storage when memory value is null.
4385
+ *
4386
+ * Returns `null` if:
4387
+ * - No value has been set yet
4388
+ * - Value was removed via `remove()`
4389
+ * - Value was never loaded from storage
4390
+ *
4391
+ * @returns The current in-memory value, or `null` if not available
4392
+ *
4393
+ * @example
4394
+ * ```typescript
4395
+ * const storage = new KeyStorage('token', { storage: localStorage });
4396
+ *
4397
+ * // Initially null (not loaded from storage yet)
4398
+ * const memValue = storage.getValue(); // Returns null
4399
+ *
4400
+ * // After setting
4401
+ * storage.set('abc123');
4402
+ * const memValue2 = storage.getValue(); // Returns 'abc123'
4403
+ *
4404
+ * // After removal
4405
+ * storage.remove();
4406
+ * const memValue3 = storage.getValue(); // Returns null
4407
+ * ```
4408
+ */
4409
+ getValue(): Value | null;
4410
+ /**
4411
+ * Retrieve value from storage with optional configuration
4412
+ *
4413
+ * Retrieval strategy:
4414
+ * 1. First checks in-memory value (fast path)
4415
+ * 2. If memory value is null and persistent storage is available,
4416
+ * loads from persistent storage and updates memory cache
4417
+ * 3. Returns null if value doesn't exist in either location
4418
+ *
4419
+ * The `options` parameter allows passing storage-specific configuration
4420
+ * that may override default behavior (e.g., encryption settings, expiration checks).
4421
+ *
4422
+ * @param options - Optional storage operation configuration
4423
+ * @returns The stored value, or `null` if not found
4424
+ *
4425
+ * @example Basic retrieval
4426
+ * ```typescript
4427
+ * const storage = new KeyStorage('token', { storage: localStorage });
4428
+ * storage.set('abc123');
4429
+ * const token = storage.get(); // Returns 'abc123'
4430
+ * ```
4431
+ *
4432
+ * @example With options
4433
+ * ```typescript
4434
+ * interface Options {
4435
+ * decrypt?: boolean;
4436
+ * }
4437
+ *
4438
+ * const storage = new KeyStorage<string, string, Options>('secret', {
4439
+ * storage: localStorage
4440
+ * });
4441
+ *
4442
+ * // Retrieve with decryption
4443
+ * const value = storage.get({ decrypt: true });
4444
+ * ```
4445
+ *
4446
+ * @example Handling null values
4447
+ * ```typescript
4448
+ * const storage = new KeyStorage('data', { storage: localStorage });
4449
+ * const value = storage.get();
4450
+ *
4451
+ * if (value === null) {
4452
+ * console.log('No value stored');
4453
+ * } else {
4454
+ * console.log('Value:', value);
4455
+ * }
4456
+ * ```
4457
+ */
4458
+ get(options?: Opt): Value | null;
4459
+ /**
4460
+ * Store a value with optional configuration
4461
+ *
4462
+ * Storage behavior:
4463
+ * - Updates in-memory value immediately
4464
+ * - Persists to underlying storage backend if available
4465
+ * - Merges provided options with default options
4466
+ * - Overwrites any existing value for this key
4467
+ *
4468
+ * The `options` parameter can be used to pass storage-specific settings
4469
+ * such as encryption, expiration, or other backend-specific configurations.
4470
+ *
4471
+ * @param value - The value to store (can be any type matching `Value`)
4472
+ * @param options - Optional storage operation configuration
4473
+ *
4474
+ * @example Basic storage
4475
+ * ```typescript
4476
+ * const storage = new KeyStorage('token', { storage: localStorage });
4477
+ * storage.set('abc123token');
4478
+ * ```
4479
+ *
4480
+ * @example Storing complex objects
4481
+ * ```typescript
4482
+ * interface User {
4483
+ * id: string;
4484
+ * name: string;
4485
+ * }
4486
+ *
4487
+ * const storage = new KeyStorage<string, User>('user', {
4488
+ * storage: localStorage
4489
+ * });
4490
+ *
4491
+ * storage.set({
4492
+ * id: '123',
4493
+ * name: 'John Doe'
4494
+ * });
4495
+ * ```
4496
+ *
4497
+ * @example With encryption options
4498
+ * ```typescript
4499
+ * interface Options {
4500
+ * encrypt?: boolean;
4501
+ * expires?: number;
4502
+ * }
4503
+ *
4504
+ * const storage = new KeyStorage<string, string, Options>('secret', {
4505
+ * storage: localStorage
4506
+ * });
4507
+ *
4508
+ * storage.set('sensitive-data', {
4509
+ * encrypt: true,
4510
+ * expires: Date.now() + 3600000 // 1 hour
4511
+ * });
4512
+ * ```
4513
+ */
4514
+ set(value: Value, options?: Opt): void;
4515
+ /**
4516
+ * Remove the stored value from both memory and persistent storage
4517
+ *
4518
+ * Removal behavior:
4519
+ * - Clears in-memory value (sets to `null`)
4520
+ * - Removes value from persistent storage backend if available
4521
+ * - Applies any options-specific removal behavior
4522
+ *
4523
+ * After calling `remove()`, subsequent calls to `get()` will return `null`
4524
+ * until a new value is set via `set()`.
4525
+ *
4526
+ * @param options - Optional storage operation configuration
4527
+ *
4528
+ * @example Basic removal
4529
+ * ```typescript
4530
+ * const storage = new KeyStorage('token', { storage: localStorage });
4531
+ * storage.set('abc123');
4532
+ * storage.remove(); // Removes from both memory and localStorage
4533
+ * const token = storage.get(); // Returns null
4534
+ * ```
4535
+ *
4536
+ * @example With options
4537
+ * ```typescript
4538
+ * interface Options {
4539
+ * softDelete?: boolean;
4540
+ * }
4541
+ *
4542
+ * const storage = new KeyStorage<string, string, Options>('data', {
4543
+ * storage: localStorage
4544
+ * });
4545
+ *
4546
+ * // Remove with soft delete option
4547
+ * storage.remove({ softDelete: true });
4548
+ * ```
4549
+ *
4550
+ * @example Clearing user session
4551
+ * ```typescript
4552
+ * const userStorage = new KeyStorage('user', { storage: localStorage });
4553
+ *
4554
+ * // User logs out
4555
+ * userStorage.remove();
4556
+ * ```
4557
+ */
4558
+ remove(options?: Opt): void;
4559
+ }
4560
+
4249
4561
  /**
4250
4562
  * Interface representing a synchronous storage mechanism.
4251
4563
  *
@@ -4309,18 +4621,6 @@ interface KeyStorageOptions<Key, Sopt = unknown> extends ExpireOptions {
4309
4621
  */
4310
4622
  storage?: SyncStorageInterface<Key, Sopt>;
4311
4623
  }
4312
- declare abstract class KeyStorageInterface<Key, Value, Opt extends KeyStorageOptions<Key> = KeyStorageOptions<Key>> {
4313
- readonly key: Key;
4314
- protected options: Opt;
4315
- protected value: Value | null;
4316
- constructor(key: Key, options?: Opt);
4317
- getKey(): Key;
4318
- getValue(): Value | null;
4319
- abstract get(options?: Opt): Value | null;
4320
- abstract set(value: Value, options?: Opt): void;
4321
- abstract remove(options?: Opt): void;
4322
- }
4323
-
4324
4624
  /**
4325
4625
  * KeyStorage is a storage that can be used to store a single value.
4326
4626
  *
@@ -4358,11 +4658,31 @@ declare abstract class KeyStorageInterface<Key, Value, Opt extends KeyStorageOpt
4358
4658
  * tokenStorage.remove(); // remove from localStorage
4359
4659
  * ```
4360
4660
  */
4361
- declare class KeyStorage<Key, Value, Opt extends KeyStorageOptions<Key> = KeyStorageOptions<Key>> extends KeyStorageInterface<Key, Value, Opt> {
4661
+ declare class KeyStorage<Key, Value, Opt extends KeyStorageOptions<Key> = KeyStorageOptions<Key>> implements KeyStorageInterface<Key, Value, Opt> {
4662
+ readonly key: Key;
4663
+ protected options: Opt;
4362
4664
  protected value: Value | null;
4665
+ constructor(key: Key, options?: Opt);
4363
4666
  protected mergeOptions(options?: Opt): Opt;
4667
+ /**
4668
+ * @override
4669
+ */
4670
+ getKey(): Key;
4671
+ /**
4672
+ * @override
4673
+ */
4674
+ getValue(): Value | null;
4675
+ /**
4676
+ * @override
4677
+ */
4364
4678
  get(options?: Opt): Value | null;
4679
+ /**
4680
+ * @override
4681
+ */
4365
4682
  set(token: Value, options?: Opt): void;
4683
+ /**
4684
+ * @override
4685
+ */
4366
4686
  remove(options?: Opt): void;
4367
4687
  }
4368
4688
 
@@ -4543,6 +4863,9 @@ declare class ObjectStorage<Key, ValueType = string, Opt extends ObjectStorageOp
4543
4863
  * ```
4544
4864
  */
4545
4865
  getItem<T>(key: Key, defaultValue?: T): T | null;
4866
+ /**
4867
+ * @override
4868
+ */
4546
4869
  getRawValue<T>(value: unknown, defaultValue?: T): T | null;
4547
4870
  /**
4548
4871
  * Removes a stored item by its key from both memory and persistent storage
@@ -4678,20 +5001,31 @@ declare class SyncStorage<Key, Opt = unknown> implements SyncStorageInterface<Ke
4678
5001
  constructor(storage: SyncStorageInterface<Key, Opt>, pipes?: PipeArg<Key>[] | PipeArg<Key>);
4679
5002
  /**
4680
5003
  * Get the number of storage items
4681
- */
5004
+
5005
+ * @override
5006
+ */
4682
5007
  get length(): number;
5008
+ /**
5009
+ * @override
5010
+ */
4683
5011
  setItem<T>(key: Key, value: T, options?: Opt): void;
5012
+ /**
5013
+ * @override
5014
+ */
4684
5015
  getItem<T>(key: Key, defaultValue?: T, options?: Opt): T | null;
4685
5016
  /**
4686
5017
  * Delete data items, delete from all storage layers
4687
5018
  *
5019
+ * @override
4688
5020
  * @param key - Storage key
4689
5021
  * @param options - Delete options
4690
5022
  */
4691
5023
  removeItem(key: Key, options?: Opt): void;
4692
5024
  /**
4693
5025
  * Clear all data, including storage in the pipeline
4694
- */
5026
+
5027
+ * @override
5028
+ */
4695
5029
  clear(): void;
4696
5030
  }
4697
5031
 
@@ -4723,4 +5057,4 @@ type Intersection<T1, T2> = {
4723
5057
  [P in keyof T1 & keyof T2]: T1[P] | T2[P];
4724
5058
  };
4725
5059
 
4726
- export { ABORT_ERROR_ID, type AbortConfigExtractor, AbortError, AbortPlugin, type AbortPluginConfig, type AbortPluginOptions, AsyncExecutor, type AsyncStorageInterface, Base64Serializer, type Encryptor, Executor, type ExecutorConfigInterface, type ExecutorContext, ExecutorError, type ExecutorPlugin, type ExpireOptions, FetchAbortPlugin, FetchURLPlugin, type HookRuntimes, type HookType, type Intersection, JSONSerializer, type JSONSerializerOptions, KeyStorage, KeyStorageInterface, type KeyStorageOptions, ObjectStorage, type ObjectStorageOptions, type PipeArg, type PromiseTask, RequestAdapterAxios, type RequestAdapterConfig, RequestAdapterFetch, type RequestAdapterFetchConfig, type RequestAdapterInterface, type RequestAdapterResponse, RequestError, RequestErrorID, RequestManager, RequestScheduler, RequestTransaction, type RequestTransactionInterface, type RetryOptions, RetryPlugin, type SerializerIneterface, type StorageValue, SyncExecutor, SyncStorage, type SyncStorageInterface, type SyncTask, type Task, type ValueOf };
5060
+ export { ABORT_ERROR_ID, type AbortConfigExtractor, AbortError, AbortPlugin, type AbortPluginConfig, type AbortPluginOptions, AsyncExecutor, type AsyncStorageInterface, Base64Serializer, type Encryptor, Executor, type ExecutorConfigInterface, type ExecutorContext, ExecutorError, type ExecutorPlugin, type ExpireOptions, FetchAbortPlugin, FetchURLPlugin, type HookRuntimes, type HookType, type Intersection, JSONSerializer, type JSONSerializerOptions, KeyStorage, type KeyStorageInterface, type KeyStorageOptions, ObjectStorage, type ObjectStorageOptions, type PipeArg, type PromiseTask, RequestAdapterAxios, type RequestAdapterConfig, RequestAdapterFetch, type RequestAdapterFetchConfig, type RequestAdapterInterface, type RequestAdapterResponse, RequestError, RequestErrorID, RequestManager, RequestScheduler, RequestTransaction, type RequestTransactionInterface, type RetryOptions, RetryPlugin, type SerializerIneterface, type StorageValue, SyncExecutor, SyncStorage, type SyncStorageInterface, type SyncTask, type Task, type ValueOf };