alepha 0.10.5 → 0.10.7

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.
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+ var m = require('@alepha/api-verifications');
3
+ Object.keys(m).forEach(function (k) {
4
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5
+ enumerable: true,
6
+ get: function () { return m[k]; }
7
+ });
8
+ });
@@ -0,0 +1 @@
1
+ export * from '@alepha/api-verifications';
@@ -0,0 +1 @@
1
+ export * from '@alepha/api-verifications'
package/batch.d.ts CHANGED
@@ -281,7 +281,7 @@ declare const $batch: {
281
281
  <TItem extends TSchema, TResponse>(options: BatchDescriptorOptions<TItem, TResponse>): BatchDescriptor<TItem, TResponse>;
282
282
  [KIND]: typeof BatchDescriptor;
283
283
  };
284
- interface BatchDescriptorOptions<TItem extends TSchema, TResponse = any> {
284
+ interface BatchDescriptorOptions<TItem$1 extends TSchema, TResponse$1 = any> {
285
285
  /**
286
286
  * TypeBox schema for validating each item added to the batch.
287
287
  *
@@ -308,7 +308,7 @@ interface BatchDescriptorOptions<TItem extends TSchema, TResponse = any> {
308
308
  * })
309
309
  * ```
310
310
  */
311
- schema: TItem;
311
+ schema: TItem$1;
312
312
  /**
313
313
  * The batch processing handler function that processes arrays of validated items.
314
314
  *
@@ -369,7 +369,7 @@ interface BatchDescriptorOptions<TItem extends TSchema, TResponse = any> {
369
369
  * }
370
370
  * ```
371
371
  */
372
- handler: (items: Static<TItem>[]) => TResponse;
372
+ handler: (items: Static<TItem$1>[]) => TResponse$1;
373
373
  /**
374
374
  * Maximum number of items to collect before automatically flushing the batch.
375
375
  *
@@ -463,7 +463,7 @@ interface BatchDescriptorOptions<TItem extends TSchema, TResponse = any> {
463
463
  * }
464
464
  * ```
465
465
  */
466
- partitionBy?: (item: Static<TItem>) => string;
466
+ partitionBy?: (item: Static<TItem$1>) => string;
467
467
  /**
468
468
  * Maximum number of batch handlers that can execute simultaneously.
469
469
  *
@@ -526,19 +526,19 @@ interface BatchDescriptorOptions<TItem extends TSchema, TResponse = any> {
526
526
  * }
527
527
  * ```
528
528
  */
529
- retry?: Omit<RetryDescriptorOptions<() => Array<Static<TItem>>>, "handler">;
529
+ retry?: Omit<RetryDescriptorOptions<() => Array<Static<TItem$1>>>, "handler">;
530
530
  }
531
- declare class BatchDescriptor<TItem extends TSchema, TResponse = any> extends Descriptor<BatchDescriptorOptions<TItem, TResponse>> {
531
+ declare class BatchDescriptor<TItem$1 extends TSchema, TResponse$1 = any> extends Descriptor<BatchDescriptorOptions<TItem$1, TResponse$1>> {
532
532
  protected readonly log: _alepha_logger0.Logger;
533
533
  protected readonly dateTime: DateTimeProvider;
534
534
  protected readonly partitions: Map<any, any>;
535
535
  protected activeHandlers: PromiseWithResolvers<void>[];
536
- protected retry: _alepha_retry0.RetryDescriptorFn<(items: typebox0.StaticType<[], "Encode", {}, {}, TItem>[]) => TResponse>;
536
+ protected retry: _alepha_retry0.RetryDescriptorFn<(items: typebox0.StaticType<[], "Encode", {}, {}, TItem$1>[]) => TResponse$1>;
537
537
  /**
538
538
  * Pushes an item into the batch. The item will be processed
539
539
  * asynchronously with other items when the batch is flushed.
540
540
  */
541
- push(item: Static<TItem>): Promise<TResponse>;
541
+ push(item: Static<TItem$1>): Promise<TResponse$1>;
542
542
  flush(partitionKey?: string): Promise<void>;
543
543
  protected flushPartition(partitionKey: string): Promise<void>;
544
544
  protected readonly dispose: _alepha_core1.HookDescriptor<"stop">;
package/bucket.d.ts CHANGED
@@ -187,200 +187,6 @@ declare class MemoryFileStorageProvider implements FileStorageProvider {
187
187
  * }
188
188
  * }
189
189
  * ```
190
- *
191
- * @example
192
- * **Cloud storage integration with custom provider:**
193
- * ```ts
194
- * class ProductImageService {
195
- * productImages = $bucket({
196
- * name: "product-images",
197
- * provider: S3FileStorageProvider, // Use AWS S3 for production storage
198
- * description: "Product catalog images and thumbnails",
199
- * mimeTypes: ["image/jpeg", "image/png", "image/webp"],
200
- * maxSize: 10 // 10MB for high-quality product images
201
- * });
202
- *
203
- * thumbnails = $bucket({
204
- * name: "product-thumbnails",
205
- * provider: S3FileStorageProvider,
206
- * description: "Generated product thumbnail images",
207
- * mimeTypes: ["image/jpeg", "image/webp"],
208
- * maxSize: 1 // 1MB for thumbnails
209
- * });
210
- *
211
- * async uploadProductImage(productId: string, file: FileLike): Promise<{ imageId: string; thumbnailId: string }> {
212
- * try {
213
- * // Upload original image
214
- * const imageId = await this.productImages.upload(file);
215
- *
216
- * // Generate and upload thumbnail
217
- * const thumbnailFile = await this.imageProcessor.generateThumbnail(file, {
218
- * width: 300,
219
- * height: 300,
220
- * format: 'webp',
221
- * quality: 80
222
- * });
223
- *
224
- * const thumbnailId = await this.thumbnails.upload(thumbnailFile);
225
- *
226
- * // Update product in database
227
- * await this.database.products.update(productId, {
228
- * imageId,
229
- * thumbnailId,
230
- * imageUpdatedAt: new Date()
231
- * });
232
- *
233
- * console.log(`Product images uploaded for ${productId}: image=${imageId}, thumbnail=${thumbnailId}`);
234
- *
235
- * return { imageId, thumbnailId };
236
- *
237
- * } catch (error) {
238
- * console.error(`Failed to upload product image for ${productId}`, error);
239
- * throw error;
240
- * }
241
- * }
242
- *
243
- * async getProductImage(productId: string, thumbnail: boolean = false): Promise<FileLike> {
244
- * const product = await this.database.products.findById(productId);
245
- * if (!product) {
246
- * throw new Error(`Product ${productId} not found`);
247
- * }
248
- *
249
- * const imageId = thumbnail ? product.thumbnailId : product.imageId;
250
- * if (!imageId) {
251
- * throw new Error(`Product ${productId} has no ${thumbnail ? 'thumbnail' : 'image'}`);
252
- * }
253
- *
254
- * const bucket = thumbnail ? this.thumbnails : this.productImages;
255
- * return await bucket.download(imageId);
256
- * }
257
- * }
258
- * ```
259
- *
260
- * @example
261
- * **Temporary file processing with memory storage:**
262
- * ```ts
263
- * class FileProcessingService {
264
- * tempFiles = $bucket({
265
- * name: "temp-processing",
266
- * provider: "memory", // Use in-memory storage for temporary files
267
- * description: "Temporary files during processing workflows",
268
- * maxSize: 100 // Large limit for processing workflows
269
- * });
270
- *
271
- * async processDataFile(inputFile: FileLike, transformations: string[]): Promise<FileLike> {
272
- * let currentFile = inputFile;
273
- * const intermediateFiles: string[] = [];
274
- *
275
- * try {
276
- * // Upload initial file to temp storage
277
- * let currentFileId = await this.tempFiles.upload(currentFile);
278
- * intermediateFiles.push(currentFileId);
279
- *
280
- * // Apply each transformation
281
- * for (const transformation of transformations) {
282
- * console.log(`Applying transformation: ${transformation}`);
283
- *
284
- * // Download current file
285
- * currentFile = await this.tempFiles.download(currentFileId);
286
- *
287
- * // Apply transformation
288
- * const transformedFile = await this.applyTransformation(currentFile, transformation);
289
- *
290
- * // Upload transformed file
291
- * currentFileId = await this.tempFiles.upload(transformedFile);
292
- * intermediateFiles.push(currentFileId);
293
- * }
294
- *
295
- * // Download final result
296
- * const finalFile = await this.tempFiles.download(currentFileId);
297
- *
298
- * console.log(`File processing completed with ${transformations.length} transformations`);
299
- * return finalFile;
300
- *
301
- * } finally {
302
- * // Clean up all intermediate files
303
- * for (const fileId of intermediateFiles) {
304
- * try {
305
- * await this.tempFiles.delete(fileId);
306
- * } catch (error) {
307
- * console.warn(`Failed to clean up temp file ${fileId}:`, error.message);
308
- * }
309
- * }
310
- * console.log(`Cleaned up ${intermediateFiles.length} temporary files`);
311
- * }
312
- * }
313
- * }
314
- * ```
315
- *
316
- * @example
317
- * **File validation with dynamic configuration:**
318
- * ```ts
319
- * class UserContentService {
320
- * userContent = $bucket({
321
- * name: "user-content",
322
- * description: "User-generated content with flexible validation"
323
- * // Base configuration - can be overridden per operation
324
- * });
325
- *
326
- * async uploadUserFile(file: FileLike, userId: string, contentType: 'avatar' | 'document' | 'media'): Promise<string> {
327
- * // Dynamic validation based on content type
328
- * const validationConfig = this.getValidationConfig(contentType, userId);
329
- *
330
- * try {
331
- * // Upload with specific validation rules
332
- * const fileId = await this.userContent.upload(file, validationConfig);
333
- *
334
- * // Log upload for audit trail
335
- * await this.auditLogger.log({
336
- * action: 'file_upload',
337
- * userId,
338
- * fileId,
339
- * contentType,
340
- * fileName: file.name,
341
- * fileSize: file.size,
342
- * mimeType: file.type
343
- * });
344
- *
345
- * return fileId;
346
- *
347
- * } catch (error) {
348
- * console.error(`File upload failed for user ${userId}`, {
349
- * contentType,
350
- * fileName: file.name,
351
- * error: error.message
352
- * });
353
- * throw error;
354
- * }
355
- * }
356
- *
357
- * private getValidationConfig(contentType: string, userId: string) {
358
- * const baseConfig = {
359
- * avatar: {
360
- * mimeTypes: ['image/jpeg', 'image/png'],
361
- * maxSize: 2 // 2MB for avatars
362
- * },
363
- * document: {
364
- * mimeTypes: ['application/pdf', 'text/plain'],
365
- * maxSize: 10 // 10MB for documents
366
- * },
367
- * media: {
368
- * mimeTypes: ['image/jpeg', 'image/png', 'video/mp4'],
369
- * maxSize: 50 // 50MB for media files
370
- * }
371
- * };
372
- *
373
- * const config = baseConfig[contentType];
374
- *
375
- * // Premium users get higher limits
376
- * if (this.userService.isPremium(userId)) {
377
- * config.maxSize *= 2;
378
- * }
379
- *
380
- * return config;
381
- * }
382
- * }
383
- * ```
384
190
  */
385
191
  declare const $bucket: {
386
192
  (options: BucketDescriptorOptions): BucketDescriptor;
package/cache.d.ts CHANGED
@@ -185,7 +185,7 @@ declare const $cache: {
185
185
  <TReturn = string, TParameter extends any[] = any[]>(options?: CacheDescriptorOptions<TReturn, TParameter>): CacheDescriptorFn<TReturn, TParameter>;
186
186
  [KIND]: typeof CacheDescriptor;
187
187
  };
188
- interface CacheDescriptorOptions<TReturn, TParameter extends any[] = any[]> {
188
+ interface CacheDescriptorOptions<TReturn$1 = any, TParameter$1 extends any[] = any[]> {
189
189
  /**
190
190
  * The cache name. This is useful for invalidating multiple caches at once.
191
191
  *
@@ -197,12 +197,12 @@ interface CacheDescriptorOptions<TReturn, TParameter extends any[] = any[]> {
197
197
  /**
198
198
  * Function which returns cached data.
199
199
  */
200
- handler?: (...args: TParameter) => TReturn;
200
+ handler?: (...args: TParameter$1) => TReturn$1;
201
201
  /**
202
202
  * The key generator for the cache.
203
203
  * If not provided, the arguments will be json.stringify().
204
204
  */
205
- key?: (...args: TParameter) => string;
205
+ key?: (...args: TParameter$1) => string;
206
206
  /**
207
207
  * The store provider for the cache.
208
208
  * If not provided, the default store provider will be used.
@@ -220,7 +220,7 @@ interface CacheDescriptorOptions<TReturn, TParameter extends any[] = any[]> {
220
220
  */
221
221
  disabled?: boolean;
222
222
  }
223
- declare class CacheDescriptor<TReturn = any, TParameter extends any[] = any[]> extends Descriptor<CacheDescriptorOptions<TReturn, TParameter>> {
223
+ declare class CacheDescriptor<TReturn$1 = any, TParameter$1 extends any[] = any[]> extends Descriptor<CacheDescriptorOptions<TReturn$1, TParameter$1>> {
224
224
  protected readonly env: {
225
225
  CACHE_ENABLED: boolean;
226
226
  CACHE_DEFAULT_TTL: number;
@@ -235,20 +235,20 @@ declare class CacheDescriptor<TReturn = any, TParameter extends any[] = any[]> e
235
235
  STRING: number;
236
236
  };
237
237
  get container(): string;
238
- run(...args: TParameter): Promise<TReturn>;
239
- key(...args: TParameter): string;
238
+ run(...args: TParameter$1): Promise<TReturn$1>;
239
+ key(...args: TParameter$1): string;
240
240
  invalidate(...keys: string[]): Promise<void>;
241
- set(key: string, value: TReturn, ttl?: DurationLike): Promise<void>;
242
- get(key: string): Promise<TReturn | undefined>;
243
- protected serialize<TReturn>(value: TReturn): Uint8Array;
244
- protected deserialize<TReturn>(uint8Array: Uint8Array): Promise<TReturn>;
241
+ set(key: string, value: TReturn$1, ttl?: DurationLike): Promise<void>;
242
+ get(key: string): Promise<TReturn$1 | undefined>;
243
+ protected serialize<TReturn>(value: TReturn$1): Uint8Array;
244
+ protected deserialize<TReturn>(uint8Array: Uint8Array): Promise<TReturn$1>;
245
245
  protected $provider(): CacheProvider;
246
246
  }
247
- interface CacheDescriptorFn<TReturn = any, TParameter extends any[] = any[]> extends CacheDescriptor<TReturn, TParameter> {
247
+ interface CacheDescriptorFn<TReturn$1 = any, TParameter$1 extends any[] = any[]> extends CacheDescriptor<TReturn$1, TParameter$1> {
248
248
  /**
249
249
  * Run the cache descriptor with the provided arguments.
250
250
  */
251
- (...args: TParameter): Promise<TReturn>;
251
+ (...args: TParameter$1): Promise<TReturn$1>;
252
252
  }
253
253
  //#endregion
254
254
  //#region src/providers/MemoryCacheProvider.d.ts
package/command.d.ts CHANGED
@@ -7,7 +7,7 @@ import * as readline_promises0 from "readline/promises";
7
7
  import * as typebox0 from "typebox";
8
8
 
9
9
  //#region src/helpers/Asker.d.ts
10
- interface AskOptions<T extends TSchema = TString> {
10
+ interface AskOptions<T$1 extends TSchema = TString> {
11
11
  /**
12
12
  * Response schema expected.
13
13
  *
@@ -26,12 +26,12 @@ interface AskOptions<T extends TSchema = TString> {
26
26
  *
27
27
  * @default TString
28
28
  */
29
- schema?: T;
29
+ schema?: T$1;
30
30
  /**
31
31
  * Custom validation function.
32
32
  * Throws an AlephaError in case of validation failure.
33
33
  */
34
- validate?: (value: Static<T>) => void;
34
+ validate?: (value: Static<T$1>) => void;
35
35
  }
36
36
  interface AskMethod {
37
37
  <T extends TSchema = TString>(question: string, options?: AskOptions<T>): Promise<Static<T>>;
@@ -99,11 +99,11 @@ declare const $command: {
99
99
  <T extends TObject, A extends TSchema>(options: CommandDescriptorOptions<T, A>): CommandDescriptor<T, A>;
100
100
  [KIND]: typeof CommandDescriptor;
101
101
  };
102
- interface CommandDescriptorOptions<T extends TObject, A extends TSchema> {
102
+ interface CommandDescriptorOptions<T$1 extends TObject, A$1 extends TSchema> {
103
103
  /**
104
104
  * The handler function to execute when the command is matched.
105
105
  */
106
- handler: (args: CommandHandlerArgs<T, A>) => Async<void>;
106
+ handler: (args: CommandHandlerArgs<T$1, A$1>) => Async<void>;
107
107
  /**
108
108
  * The name of the command. If omitted, the property key is used.
109
109
  *
@@ -121,7 +121,7 @@ interface CommandDescriptorOptions<T extends TObject, A extends TSchema> {
121
121
  /**
122
122
  * A TypeBox object schema defining the flags for the command.
123
123
  */
124
- flags?: T;
124
+ flags?: T$1;
125
125
  /**
126
126
  * An optional TypeBox schema defining the arguments for the command.
127
127
  *
@@ -138,20 +138,20 @@ interface CommandDescriptorOptions<T extends TObject, A extends TSchema> {
138
138
  * args: t.tuple([t.text(), t.optional(t.number())])
139
139
  * my-cli command <arg1: string> [arg2: number]
140
140
  */
141
- args?: A;
141
+ args?: A$1;
142
142
  /**
143
143
  * If false, skip summary message at the end of the command execution.
144
144
  */
145
145
  summary?: boolean;
146
146
  }
147
- declare class CommandDescriptor<T extends TObject = TObject, A extends TSchema = TSchema> extends Descriptor<CommandDescriptorOptions<T, A>> {
147
+ declare class CommandDescriptor<T$1 extends TObject = TObject, A$1 extends TSchema = TSchema> extends Descriptor<CommandDescriptorOptions<T$1, A$1>> {
148
148
  readonly flags: TObject<{}>;
149
149
  readonly aliases: string[];
150
150
  get name(): string;
151
151
  }
152
- interface CommandHandlerArgs<T extends TObject, A extends TSchema = TSchema> {
153
- flags: Static<T>;
154
- args: A extends TSchema ? Static<A> : undefined;
152
+ interface CommandHandlerArgs<T$1 extends TObject, A$1 extends TSchema = TSchema> {
153
+ flags: Static<T$1>;
154
+ args: A$1 extends TSchema ? Static<A$1> : Array<string>;
155
155
  run: RunnerMethod;
156
156
  ask: AskMethod;
157
157
  glob: typeof glob;