@alepha/bucket-vercel 0.14.4 → 0.15.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 (3) hide show
  1. package/README.md +8 -0
  2. package/dist/index.d.ts +12 -2022
  3. package/package.json +6 -6
package/dist/index.d.ts CHANGED
@@ -1,2021 +1,11 @@
1
+ import * as alepha1 from "alepha";
2
+ import { Alepha, FileLike, Static } from "alepha";
3
+ import { FileStorageProvider } from "alepha/bucket";
4
+ import { DateTimeProvider } from "alepha/datetime";
5
+ import { FileDetector, FileSystemProvider } from "alepha/file";
6
+ import * as alepha_logger0 from "alepha/logger";
1
7
  import { del, head, put } from "@vercel/blob";
2
- import * as typebox3 from "typebox";
3
- import { Static, StaticDecode as Static$1, StaticEncode, TAny, TArray, TArray as TArray$1, TBoolean, TInteger, TNumber, TObject, TObject as TObject$1, TOptional, TOptionalAdd, TRecord, TSchema, TSchema as TSchema$1, TString, TUnsafe } from "typebox";
4
- import { Readable } from "node:stream";
5
- import { ReadableStream as ReadableStream$1 } from "node:stream/web";
6
- import { AsyncLocalStorage } from "node:async_hooks";
7
- import { Validator } from "typebox/compile";
8
- import dayjsDuration from "dayjs/plugin/duration.js";
9
- import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
10
- import "node:fs";
11
8
 
12
- //#region ../alepha/src/core/constants/KIND.d.ts
13
- /**
14
- * Used for identifying primitives.
15
- *
16
- * @internal
17
- */
18
- declare const KIND: unique symbol;
19
- //#endregion
20
- //#region ../alepha/src/core/interfaces/Service.d.ts
21
- /**
22
- * In Alepha, a service is a class that can be instantiated or an abstract class. Nothing more, nothing less...
23
- */
24
- type Service<T extends object = any> = InstantiableClass<T> | AbstractClass<T> | RunFunction<T>;
25
- type RunFunction<T extends object = any> = (...args: any[]) => T | void;
26
- type InstantiableClass<T extends object = any> = new (...args: any[]) => T;
27
- /**
28
- * Abstract class is a class that cannot be instantiated directly!
29
- * It widely used for defining interfaces.
30
- */
31
- type AbstractClass<T extends object = any> = abstract new (...args: any[]) => T;
32
- /**
33
- * Service substitution allows you to register a class as a different class.
34
- * Providing class A, but using class B instead.
35
- * This is useful for testing, mocking, or providing a different implementation of a service.
36
- *
37
- * class A is mostly an AbstractClass, while class B is an InstantiableClass.
38
- */
39
- interface ServiceSubstitution<T extends object = any> {
40
- /**
41
- * Every time someone asks for this class, it will be provided with the 'use' class.
42
- */
43
- provide: Service<T>;
44
- /**
45
- * Service to use instead of the 'provide' service.
46
- *
47
- * Syntax is inspired by Angular's DI system.
48
- */
49
- use: Service<T>;
50
- /**
51
- * If true, if the service already exists -> just ignore the substitution and do not throw an error.
52
- * Mostly used for plugins to enforce a substitution without throwing an error.
53
- */
54
- optional?: boolean;
55
- }
56
- /**
57
- * Every time you register a service, you can use this type to define it.
58
- *
59
- * alepha.with( ServiceEntry )
60
- * or
61
- * alepha.with( provide: ServiceEntry, use: MyOwnServiceEntry )
62
- *
63
- * And yes, you declare the *type* of the service, not the *instance*.
64
- */
65
- type ServiceEntry<T extends object = any> = Service<T> | ServiceSubstitution<T>;
66
- //#endregion
67
- //#region ../alepha/src/core/helpers/primitive.d.ts
68
- interface PrimitiveArgs<T extends object = {}> {
69
- options: T;
70
- alepha: Alepha;
71
- service: InstantiableClass<Service>;
72
- module?: Service;
73
- }
74
- interface PrimitiveConfig {
75
- propertyKey: string;
76
- service: InstantiableClass<Service>;
77
- module?: Service;
78
- }
79
- declare abstract class Primitive<T extends object = {}> {
80
- protected readonly alepha: Alepha;
81
- readonly options: T;
82
- readonly config: PrimitiveConfig;
83
- constructor(args: PrimitiveArgs<T>);
84
- /**
85
- * Called automatically by Alepha after the primitive is created.
86
- */
87
- protected onInit(): void;
88
- }
89
- type PrimitiveFactoryLike<T extends object = any> = {
90
- (options: T): any;
91
- [KIND]: any;
92
- };
93
- //#endregion
94
- //#region ../alepha/src/core/interfaces/Async.d.ts
95
- /**
96
- * Represents a value that can be either a value or a promise of value.
97
- */
98
- type Async<T> = T | Promise<T>;
99
- //#endregion
100
- //#region ../alepha/src/core/interfaces/LoggerInterface.d.ts
101
- type LogLevel = "ERROR" | "WARN" | "INFO" | "DEBUG" | "TRACE" | "SILENT";
102
- interface LoggerInterface {
103
- trace(message: string, data?: unknown): void;
104
- debug(message: string, data?: unknown): void;
105
- info(message: string, data?: unknown): void;
106
- warn(message: string, data?: unknown): void;
107
- error(message: string, data?: unknown): void;
108
- }
109
- //#endregion
110
- //#region ../alepha/src/core/helpers/FileLike.d.ts
111
- interface FileLike {
112
- /**
113
- * Filename.
114
- * @default "file"
115
- */
116
- name: string;
117
- /**
118
- * Mandatory MIME type of the file.
119
- * @default "application/octet-stream"
120
- */
121
- type: string;
122
- /**
123
- * Size of the file in bytes.
124
- *
125
- * Always 0 for streams, as the size is not known until the stream is fully read.
126
- *
127
- * @default 0
128
- */
129
- size: number;
130
- /**
131
- * Last modified timestamp in milliseconds since epoch.
132
- *
133
- * Always the current timestamp for streams, as the last modified time is not known.
134
- * We use this field to ensure compatibility with File API.
135
- *
136
- * @default Date.now()
137
- */
138
- lastModified: number;
139
- /**
140
- * Returns a ReadableStream or Node.js Readable stream of the file content.
141
- *
142
- * For streams, this is the original stream.
143
- */
144
- stream(): StreamLike;
145
- /**
146
- * Returns the file content as an ArrayBuffer.
147
- *
148
- * For streams, this reads the entire stream into memory.
149
- */
150
- arrayBuffer(): Promise<ArrayBuffer>;
151
- /**
152
- * Returns the file content as a string.
153
- *
154
- * For streams, this reads the entire stream into memory and converts it to a string.
155
- */
156
- text(): Promise<string>;
157
- /**
158
- * Optional file path, if the file is stored on disk.
159
- *
160
- * This is not from the File API, but rather a custom field to indicate where the file is stored.
161
- */
162
- filepath?: string;
163
- }
164
- type StreamLike = ReadableStream | ReadableStream$1 | Readable | NodeJS.ReadableStream;
165
- //#endregion
166
- //#region ../alepha/src/core/providers/TypeProvider.d.ts
167
- declare module "typebox" {
168
- interface TString {
169
- format?: string;
170
- minLength?: number;
171
- maxLength?: number;
172
- }
173
- interface TNumber {
174
- format?: "int64";
175
- }
176
- }
177
- //#endregion
178
- //#region ../alepha/src/core/primitives/$atom.d.ts
179
- type AtomOptions<T extends TAtomObject, N extends string> = {
180
- name: N;
181
- schema: T;
182
- description?: string;
183
- } & (T extends TOptionalAdd<T> ? {
184
- default?: Static$1<T>;
185
- } : {
186
- default: Static$1<T>;
187
- });
188
- declare class Atom<T extends TAtomObject = TObject$1, N extends string = string> {
189
- readonly options: AtomOptions<T, N>;
190
- get schema(): T;
191
- get key(): N;
192
- constructor(options: AtomOptions<T, N>);
193
- }
194
- type TAtomObject = TObject$1<any> | TArray;
195
- type AtomStatic<T extends TAtomObject> = T extends TOptionalAdd<T> ? Static$1<T> | undefined : Static$1<T>;
196
- //#endregion
197
- //#region ../alepha/src/core/primitives/$inject.d.ts
198
- interface InjectOptions<T extends object = any> {
199
- /**
200
- * - 'transient' → Always a new instance on every inject. Zero caching.
201
- * - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)
202
- * - 'scoped' → One instance per AsyncLocalStorage context.
203
- * - A new scope is created when Alepha handles a request, a scheduled job, a queue worker task...
204
- * - You can also start a manual scope via alepha.context.run(() => { ... }).
205
- * - When the scope ends, the scoped registry is discarded.
206
- *
207
- * @default "singleton"
208
- */
209
- lifetime?: "transient" | "singleton" | "scoped";
210
- /**
211
- * Constructor arguments to pass when creating a new instance.
212
- */
213
- args?: ConstructorParameters<InstantiableClass<T>>;
214
- /**
215
- * Parent that requested the instance.
216
- *
217
- * @internal
218
- */
219
- parent?: Service | null;
220
- }
221
- //#endregion
222
- //#region ../alepha/src/core/primitives/$module.d.ts
223
- interface ModulePrimitiveOptions {
224
- /**
225
- * Name of the module.
226
- *
227
- * It should be in the format of `project.module.submodule`.
228
- */
229
- name: string;
230
- /**
231
- * List all services related to this module.
232
- *
233
- * If you don't declare 'register' function, all services will be registered automatically.
234
- * If you declare 'register' function, you must handle the registration of ALL services manually.
235
- */
236
- services?: Array<Service>;
237
- /**
238
- * List of $primitives to register in the module.
239
- */
240
- primitives?: Array<PrimitiveFactoryLike>;
241
- /**
242
- * By default, module will register ALL services.
243
- * You can override this behavior by providing a register function.
244
- * It's useful when you want to register services conditionally or in a specific order.
245
- *
246
- * Again, if you declare 'register', you must handle the registration of ALL services manually.
247
- */
248
- register?: (alepha: Alepha) => void;
249
- }
250
- /**
251
- * Base class for all modules.
252
- */
253
- declare abstract class Module {
254
- abstract readonly options: ModulePrimitiveOptions;
255
- abstract register(alepha: Alepha): void;
256
- static NAME_REGEX: RegExp;
257
- /**
258
- * Check if a Service is a Module.
259
- */
260
- static is(ctor: Service): boolean;
261
- /**
262
- * Get the Module of a Service.
263
- *
264
- * Returns undefined if the Service is not part of a Module.
265
- */
266
- static of(ctor: Service): Service<Module> | undefined;
267
- }
268
- //#endregion
269
- //#region ../alepha/src/core/providers/AlsProvider.d.ts
270
- type AsyncLocalStorageData = any;
271
- declare class AlsProvider {
272
- static create: () => AsyncLocalStorage<AsyncLocalStorageData> | undefined;
273
- als?: AsyncLocalStorage<AsyncLocalStorageData>;
274
- constructor();
275
- createContextId(): string;
276
- run<R>(callback: () => R, data?: Record<string, any>): R;
277
- exists(): boolean;
278
- get<T>(key: string): T | undefined;
279
- set<T>(key: string, value: T): void;
280
- }
281
- //#endregion
282
- //#region ../alepha/src/core/providers/Json.d.ts
283
- /**
284
- * Mimics the JSON global object with stringify and parse methods.
285
- *
286
- * Used across the codebase via dependency injection.
287
- */
288
- declare class Json {
289
- stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
290
- parse(text: string, reviver?: (this: any, key: string, value: any) => any): any;
291
- }
292
- //#endregion
293
- //#region ../alepha/src/core/providers/SchemaCodec.d.ts
294
- declare abstract class SchemaCodec {
295
- /**
296
- * Encode the value to a string format.
297
- */
298
- abstract encodeToString<T extends TSchema$1>(schema: T, value: Static$1<T>): string;
299
- /**
300
- * Encode the value to a binary format.
301
- */
302
- abstract encodeToBinary<T extends TSchema$1>(schema: T, value: Static$1<T>): Uint8Array;
303
- /**
304
- * Decode string, binary, or other formats to the schema type.
305
- */
306
- abstract decode<T>(schema: TSchema$1, value: unknown): T;
307
- }
308
- //#endregion
309
- //#region ../alepha/src/core/providers/JsonSchemaCodec.d.ts
310
- declare class JsonSchemaCodec extends SchemaCodec {
311
- protected readonly json: Json;
312
- protected readonly encoder: TextEncoder;
313
- protected readonly decoder: TextDecoder;
314
- encodeToString<T extends TSchema>(schema: T, value: Static$1<T>): string;
315
- encodeToBinary<T extends TSchema>(schema: T, value: Static$1<T>): Uint8Array;
316
- decode<T>(schema: TSchema, value: unknown): T;
317
- }
318
- //#endregion
319
- //#region ../alepha/src/core/primitives/$hook.d.ts
320
- interface HookOptions<T extends keyof Hooks> {
321
- /**
322
- * The name of the hook. "configure", "start", "ready", "stop", ...
323
- */
324
- on: T;
325
- /**
326
- * The handler to run when the hook is triggered.
327
- */
328
- handler: (args: Hooks[T]) => Async<any>;
329
- /**
330
- * Force the hook to run first or last on the list of hooks.
331
- */
332
- priority?: "first" | "last";
333
- /**
334
- * Empty placeholder, not implemented yet. :-)
335
- */
336
- before?: object | Array<object>;
337
- /**
338
- * Empty placeholder, not implemented yet. :-)
339
- */
340
- after?: object | Array<object>;
341
- }
342
- declare class HookPrimitive<T extends keyof Hooks> extends Primitive<HookOptions<T>> {
343
- called: number;
344
- protected onInit(): void;
345
- }
346
- //#endregion
347
- //#region ../alepha/src/core/providers/SchemaValidator.d.ts
348
- declare class SchemaValidator {
349
- protected cache: Map<TSchema, Validator<typebox3.TProperties, TSchema, unknown, unknown>>;
350
- protected useEval: boolean;
351
- /**
352
- * Validate the value against the provided schema.
353
- *
354
- * Validation create a new value by applying some preprocessing. (e.g., trimming text)
355
- */
356
- validate<T extends TSchema>(schema: T, value: unknown, options?: ValidateOptions): Static$1<T>;
357
- protected getValidator<T extends TSchema>(schema: T): Validator<{}, T>;
358
- /**
359
- * Preprocess the value based on the schema before validation.
360
- *
361
- * - If the value is `null` and the schema does not allow `null`, it converts it to `undefined`.
362
- * - If the value is a string and the schema has a `~options.trim` flag, it trims whitespace from the string.
363
- */
364
- beforeParse(schema: any, value: any, options: ValidateOptions): any;
365
- /**
366
- * Used by `beforeParse` to determine if a schema allows null values.
367
- */
368
- protected isSchemaNullable: (schema: any) => boolean;
369
- protected onConfigure: HookPrimitive<"configure">;
370
- protected canEval(): boolean;
371
- }
372
- interface ValidateOptions {
373
- trim?: boolean;
374
- nullToUndefined?: boolean;
375
- deleteUndefined?: boolean;
376
- }
377
- //#endregion
378
- //#region ../alepha/src/core/providers/CodecManager.d.ts
379
- type Encoding = "object" | "string" | "binary";
380
- interface EncodeOptions<T extends Encoding = Encoding> {
381
- /**
382
- * The output encoding format:
383
- * - 'string': Returns JSON string
384
- * - 'binary': Returns Uint8Array (for protobuf, msgpack, etc.)
385
- *
386
- * @default "string"
387
- */
388
- as?: T;
389
- /**
390
- * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
391
- *
392
- * @default "json"
393
- */
394
- encoder?: string;
395
- /**
396
- * Validation options to apply before encoding.
397
- */
398
- validation?: ValidateOptions | false;
399
- }
400
- type EncodeResult<T extends TSchema, E extends Encoding> = E extends "string" ? string : E extends "binary" ? Uint8Array : StaticEncode<T>;
401
- interface DecodeOptions {
402
- /**
403
- * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
404
- *
405
- * @default "json"
406
- */
407
- encoder?: string;
408
- /**
409
- * Validation options to apply before encoding.
410
- */
411
- validation?: ValidateOptions | false;
412
- }
413
- /**
414
- * CodecManager manages multiple codec formats and provides a unified interface
415
- * for encoding and decoding data with different formats.
416
- */
417
- declare class CodecManager {
418
- protected readonly codecs: Map<string, SchemaCodec>;
419
- protected readonly jsonCodec: JsonSchemaCodec;
420
- protected readonly schemaValidator: SchemaValidator;
421
- default: string;
422
- constructor();
423
- /**
424
- * Register a new codec format.
425
- *
426
- * @param name - The name of the codec (e.g., 'json', 'protobuf')
427
- * @param codec - The codec implementation
428
- */
429
- register(name: string, codec: SchemaCodec): void;
430
- /**
431
- * Get a specific codec by name.
432
- *
433
- * @param name - The name of the codec
434
- * @returns The codec instance
435
- * @throws {AlephaError} If the codec is not found
436
- */
437
- getCodec(name: string): SchemaCodec;
438
- /**
439
- * Encode data using the specified codec and output format.
440
- */
441
- encode<T extends TSchema, E extends Encoding = "object">(schema: T, value: unknown, options?: EncodeOptions<E>): EncodeResult<T, E>;
442
- /**
443
- * Decode data using the specified codec.
444
- */
445
- decode<T extends TSchema>(schema: T, data: any, options?: DecodeOptions): Static$1<T>;
446
- /**
447
- * Validate decoded data against the schema.
448
- *
449
- * This is automatically called before encoding or after decoding.
450
- */
451
- validate<T extends TSchema>(schema: T, value: unknown, options?: ValidateOptions): Static$1<T>;
452
- }
453
- //#endregion
454
- //#region ../alepha/src/core/providers/EventManager.d.ts
455
- declare class EventManager {
456
- logFn?: () => LoggerInterface | undefined;
457
- /**
458
- * List of events that can be triggered. Powered by $hook().
459
- */
460
- protected events: Record<string, Array<Hook>>;
461
- constructor(logFn?: () => LoggerInterface | undefined);
462
- protected get log(): LoggerInterface | undefined;
463
- clear(): void;
464
- /**
465
- * Registers a hook for the specified event.
466
- */
467
- on<T extends keyof Hooks>(event: T, hookOrFunc: Hook<T> | ((payload: Hooks[T]) => Async<void>)): () => void;
468
- /**
469
- * Emits the specified event with the given payload.
470
- */
471
- emit<T extends keyof Hooks>(func: T, payload: Hooks[T], options?: {
472
- /**
473
- * If true, the hooks will be executed in reverse order.
474
- * This is useful for "stop" hooks that should be executed in reverse order.
475
- *
476
- * @default false
477
- */
478
- reverse?: boolean;
479
- /**
480
- * If true, the hooks will be logged with their execution time.
481
- *
482
- * @default false
483
- */
484
- log?: boolean;
485
- /**
486
- * If true, errors will be caught and logged instead of throwing.
487
- *
488
- * @default false
489
- */
490
- catch?: boolean;
491
- }): Promise<void>;
492
- }
493
- //#endregion
494
- //#region ../alepha/src/core/providers/StateManager.d.ts
495
- interface AtomWithValue {
496
- atom: Atom;
497
- value: unknown;
498
- }
499
- declare class StateManager<State$1 extends object = State> {
500
- protected readonly als: AlsProvider;
501
- protected readonly events: EventManager;
502
- protected readonly codec: JsonSchemaCodec;
503
- protected readonly atoms: Map<keyof State$1, Atom<TObject<typebox3.TProperties>, string>>;
504
- protected store: Partial<State$1>;
505
- constructor(store?: Partial<State$1>);
506
- getAtoms(context?: boolean): Array<AtomWithValue>;
507
- register(atom: Atom<any>): this;
508
- /**
509
- * Get a value from the state with proper typing
510
- */
511
- get<T extends TAtomObject>(target: Atom<T>): Static$1<T>;
512
- get<Key extends keyof State$1>(target: Key): State$1[Key] | undefined;
513
- /**
514
- * Set a value in the state
515
- */
516
- set<T extends TAtomObject>(target: Atom<T>, value: AtomStatic<T>, options?: SetStateOptions): this;
517
- set<Key extends keyof State$1>(target: Key, value: State$1[Key] | undefined, options?: SetStateOptions): this;
518
- /**
519
- * Mutate a value in the state.
520
- */
521
- mut<T extends TObject>(target: Atom<T>, mutator: (current: Static$1<T>) => Static$1<T>): this;
522
- mut<Key extends keyof State$1>(target: Key, mutator: (current: State$1[Key] | undefined) => State$1[Key] | undefined): this;
523
- /**
524
- * Check if a key exists in the state
525
- */
526
- has<Key extends keyof State$1>(key: Key): boolean;
527
- /**
528
- * Delete a key from the state (set to undefined)
529
- */
530
- del<Key extends keyof State$1>(key: Key): this;
531
- /**
532
- * Push a value to an array in the state
533
- */
534
- push<Key extends keyof OnlyArray<State$1>>(key: Key, ...value: Array<NonNullable<State$1[Key]> extends Array<infer U> ? U : never>): this;
535
- /**
536
- * Clear all state
537
- */
538
- clear(): this;
539
- /**
540
- * Get all keys that exist in the state
541
- */
542
- keys(): (keyof State$1)[];
543
- }
544
- type OnlyArray<T extends object> = { [K in keyof T]: NonNullable<T[K]> extends Array<any> ? K : never };
545
- interface SetStateOptions {
546
- skipContext?: boolean;
547
- skipEvents?: boolean;
548
- }
549
- //#endregion
550
- //#region ../alepha/src/core/Alepha.d.ts
551
- /**
552
- * Core container of the Alepha framework.
553
- *
554
- * It is responsible for managing the lifecycle of services,
555
- * handling dependency injection,
556
- * and providing a unified interface for the application.
557
- *
558
- * @example
559
- * ```ts
560
- * import { Alepha, run } from "alepha";
561
- *
562
- * class MyService {
563
- * // business logic here
564
- * }
565
- *
566
- * const alepha = Alepha.create({
567
- * // state, env, and other properties
568
- * })
569
- *
570
- * alepha.with(MyService);
571
- *
572
- * run(alepha); // trigger .start (and .stop) automatically
573
- * ```
574
- *
575
- * ### Alepha Factory
576
- *
577
- * Alepha.create() is an enhanced version of new Alepha().
578
- * - It merges `process.env` with the provided state.env when available.
579
- * - It populates the test hooks for Vitest or Jest environments when available.
580
- *
581
- * new Alepha() is fine if you don't need these helpers.
582
- *
583
- * ### Platforms & Environments
584
- *
585
- * Alepha is designed to work in various environments:
586
- * - **Browser**: Runs in the browser, using the global `window` object.
587
- * - **Serverless**: Runs in serverless environments like Vercel or Vite.
588
- * - **Test**: Runs in test environments like Jest or Vitest.
589
- * - **Production**: Runs in production environments, typically with NODE_ENV set to "production".
590
- * * You can check the current environment using the following methods:
591
- *
592
- * - `isBrowser()`: Returns true if the App is running in a browser environment.
593
- * - `isServerless()`: Returns true if the App is running in a serverless environment.
594
- * - `isTest()`: Returns true if the App is running in a test environment.
595
- * - `isProduction()`: Returns true if the App is running in a production environment.
596
- *
597
- * ### State & Environment
598
- *
599
- * The state of the Alepha container is stored in the `store` property.
600
- * Most important property is `store.env`, which contains the environment variables.
601
- *
602
- * ```ts
603
- * const alepha = Alepha.create({ env: { MY_VAR: "value" } });
604
- *
605
- * // You can access the environment variables using alepha.env
606
- * console.log(alepha.env.MY_VAR); // "value"
607
- *
608
- * // But you should use $env() primitive to get typed values from the environment.
609
- * class App {
610
- * env = $env(
611
- * t.object({
612
- * MY_VAR: t.text(),
613
- * })
614
- * );
615
- * }
616
- * ```
617
- *
618
- * ### Modules
619
- *
620
- * Modules are a way to group services together.
621
- * You can register a module using the `$module` primitive.
622
- *
623
- * ```ts
624
- * import { $module } from "alepha";
625
- *
626
- * class MyLib {}
627
- *
628
- * const myModule = $module({
629
- * name: "my.project.module",
630
- * services: [MyLib],
631
- * });
632
- * ```
633
- *
634
- * Do not use modules for small applications.
635
- *
636
- * ### Hooks
637
- *
638
- * Hooks are a way to run async functions from all registered providers/services.
639
- * You can register a hook using the `$hook` primitive.
640
- *
641
- * ```ts
642
- * import { $hook } from "alepha";
643
- *
644
- * class App {
645
- * log = $logger();
646
- * onCustomerHook = $hook({
647
- * on: "my:custom:hook",
648
- * handler: () => {
649
- * this.log?.info("App is being configured");
650
- * },
651
- * });
652
- * }
653
- *
654
- * Alepha.create()
655
- * .with(App)
656
- * .start()
657
- * .then(alepha => alepha.events.emit("my:custom:hook"));
658
- * ```
659
- *
660
- * Hooks are fully typed. You can create your own hooks by using module augmentation:
661
- *
662
- * ```ts
663
- * declare module "alepha" {
664
- * interface Hooks {
665
- * "my:custom:hook": {
666
- * arg1: string;
667
- * }
668
- * }
669
- * }
670
- * ```
671
- *
672
- * @module alepha
673
- */
674
- declare class Alepha {
675
- /**
676
- * Creates a new instance of the Alepha container with some helpers:
677
- *
678
- * - merges `process.env` with the provided state.env when available.
679
- * - populates the test hooks for Vitest or Jest environments when available.
680
- *
681
- * If you are not interested about these helpers, you can use the constructor directly.
682
- */
683
- static create(state?: Partial<State>): Alepha;
684
- /**
685
- * Flag indicating whether the App won't accept any further changes.
686
- * Pass to true when #start() is called.
687
- */
688
- protected locked: boolean;
689
- /**
690
- * True if the App has been configured.
691
- */
692
- protected configured: boolean;
693
- /**
694
- * True if the App has started.
695
- */
696
- protected started: boolean;
697
- /**
698
- * True if the App is ready.
699
- */
700
- protected ready: boolean;
701
- /**
702
- * A promise that resolves when the App has started.
703
- */
704
- protected starting?: PromiseWithResolvers<this>;
705
- /**
706
- * During the instantiation process, we keep a list of pending instantiations.
707
- * > It allows us to detect circular dependencies.
708
- */
709
- protected pendingInstantiations: Service[];
710
- /**
711
- * Cache for environment variables.
712
- * > It allows us to avoid parsing the same schema multiple times.
713
- */
714
- protected cacheEnv: Map<TSchema$1, any>;
715
- /**
716
- * List of modules that are registered in the container.
717
- *
718
- * Modules are used to group services and provide a way to register them in the container.
719
- */
720
- protected modules: Array<Module>;
721
- /**
722
- * List of service substitutions.
723
- *
724
- * Services registered here will be replaced by the specified service when injected.
725
- */
726
- protected substitutions: Map<Service, {
727
- use: Service;
728
- }>;
729
- /**
730
- * Registry of primitives.
731
- */
732
- protected primitiveRegistry: Map<Service<Primitive<{}>>, Primitive<{}>[]>;
733
- /**
734
- * List of all services + how they are provided.
735
- */
736
- protected registry: Map<Service, ServiceDefinition>;
737
- /**
738
- * Node.js feature that allows to store context across asynchronous calls.
739
- *
740
- * This is used for logging, tracing, and other context-related features.
741
- *
742
- * Mocked for browser environments.
743
- */
744
- context: AlsProvider;
745
- /**
746
- * Event manager to handle lifecycle events and custom events.
747
- */
748
- events: EventManager;
749
- /**
750
- * State manager to store arbitrary values.
751
- */
752
- store: StateManager<State>;
753
- /**
754
- * Codec manager for encoding and decoding data with different formats.
755
- *
756
- * Supports multiple codec formats (JSON, Protobuf, etc.) with a unified interface.
757
- */
758
- codec: CodecManager;
759
- /**
760
- * Get logger instance.
761
- */
762
- get log(): LoggerInterface | undefined;
763
- /**
764
- * The environment variables for the App.
765
- */
766
- get env(): Readonly<Env>;
767
- constructor(state?: Partial<State>);
768
- set<T extends TAtomObject>(target: Atom<T>, value: AtomStatic<T>): this;
769
- set<Key extends keyof State>(target: Key, value: State[Key] | undefined): this;
770
- /**
771
- * True when start() is called.
772
- *
773
- * -> No more services can be added, it's over, bye!
774
- */
775
- isLocked(): boolean;
776
- /**
777
- * Returns whether the App is configured.
778
- *
779
- * It means that Alepha#configure() has been called.
780
- *
781
- * > By default, configure() is called automatically when start() is called, but you can also call it manually.
782
- */
783
- isConfigured(): boolean;
784
- /**
785
- * Returns whether the App has started.
786
- *
787
- * It means that #start() has been called but maybe not all services are ready.
788
- */
789
- isStarted(): boolean;
790
- /**
791
- * True if the App is ready. It means that Alepha is started AND ready() hook has beed called.
792
- */
793
- isReady(): boolean;
794
- /**
795
- * True if the App is running in a Continuous Integration environment.
796
- */
797
- isCI(): boolean;
798
- /**
799
- * True if the App is running in a browser environment.
800
- */
801
- isBrowser(): boolean;
802
- /**
803
- * Returns whether the App is running in Vite dev mode.
804
- */
805
- isViteDev(): boolean;
806
- isBun(): boolean;
807
- /**
808
- * Returns whether the App is running in a serverless environment.
809
- */
810
- isServerless(): boolean;
811
- /**
812
- * Returns whether the App is in test mode. (Running in a test environment)
813
- *
814
- * > This is automatically set when running tests with Jest or Vitest.
815
- */
816
- isTest(): boolean;
817
- /**
818
- * Returns whether the App is in production mode. (Running in a production environment)
819
- *
820
- * > This is automatically set by Vite or Vercel. However, you have to set it manually when running Docker apps.
821
- */
822
- isProduction(): boolean;
823
- /**
824
- * Starts the App.
825
- *
826
- * - Lock any further changes to the container.
827
- * - Run "configure" hook for all services. Primitives will be processed.
828
- * - Run "start" hook for all services. Providers will connect/listen/...
829
- * - Run "ready" hook for all services. This is the point where the App is ready to serve requests.
830
- *
831
- * @return A promise that resolves when the App has started.
832
- */
833
- start(): Promise<this>;
834
- /**
835
- * Stops the App.
836
- *
837
- * - Run "stop" hook for all services.
838
- *
839
- * Stop will NOT reset the container.
840
- * Stop will NOT unlock the container.
841
- *
842
- * > Stop is used to gracefully shut down the application, nothing more. There is no "restart".
843
- *
844
- * @return A promise that resolves when the App has stopped.
845
- */
846
- stop(): Promise<void>;
847
- /**
848
- * Check if entry is registered in the container.
849
- */
850
- has(entry: ServiceEntry, opts?: {
851
- /**
852
- * Check if the entry is registered in the pending instantiation stack.
853
- *
854
- * @default true
855
- */
856
- inStack?: boolean;
857
- /**
858
- * Check if the entry is registered in the container registry.
859
- *
860
- * @default true
861
- */
862
- inRegistry?: boolean;
863
- /**
864
- * Check if the entry is registered in the substitutions.
865
- *
866
- * @default true
867
- */
868
- inSubstitutions?: boolean;
869
- /**
870
- * Where to look for registered services.
871
- *
872
- * @default this.registry
873
- */
874
- registry?: Map<Service, ServiceDefinition>;
875
- }): boolean;
876
- /**
877
- * Registers the specified service in the container.
878
- *
879
- * - If the service is ALREADY registered, the method does nothing.
880
- * - If the service is NOT registered, a new instance is created and registered.
881
- *
882
- * Method is chainable, so you can register multiple services in a single call.
883
- *
884
- * > ServiceEntry allows to provide a service **substitution** feature.
885
- *
886
- * @example
887
- * ```ts
888
- * class A { value = "a"; }
889
- * class B { value = "b"; }
890
- * class M { a = $inject(A); }
891
- *
892
- * Alepha.create().with({ provide: A, use: B }).get(M).a.value; // "b"
893
- * ```
894
- *
895
- * > **Substitution** is an advanced feature that allows you to replace a service with another service.
896
- * > It's useful for testing or for providing different implementations of a service.
897
- * > If you are interested in configuring a service, use Alepha#configure() instead.
898
- *
899
- * @param serviceEntry - The service to register in the container.
900
- * @return Current instance of Alepha.
901
- */
902
- with<T extends object>(serviceEntry: ServiceEntry<T> | {
903
- default: ServiceEntry<T>;
904
- }): this;
905
- /**
906
- * Get an instance of the specified service from the container.
907
- *
908
- * @see {@link InjectOptions} for the available options.
909
- */
910
- inject<T extends object>(service: Service<T> | string, opts?: InjectOptions<T>): T;
911
- /**
912
- * Applies environment variables to the provided schema and state object.
913
- *
914
- * It replaces also all templated $ENV inside string values.
915
- *
916
- * @param schema - The schema object to apply environment variables to.
917
- * @return The schema object with environment variables applied.
918
- */
919
- parseEnv<T extends TObject>(schema: T): Static<T>;
920
- /**
921
- * Get all environment variable schemas and their parsed values.
922
- *
923
- * This is useful for DevTools to display all expected environment variables.
924
- */
925
- getEnvSchemas(): Array<{
926
- schema: TSchema$1;
927
- values: Record<string, any>;
928
- }>;
929
- /**
930
- * Dump the current dependency graph of the App.
931
- *
932
- * This method returns a record where the keys are the names of the services.
933
- */
934
- graph(): Record<string, {
935
- from: string[];
936
- as?: string[];
937
- module?: string;
938
- }>;
939
- dump(): AlephaDump;
940
- services<T extends object>(base: Service<T>): Array<T>;
941
- /**
942
- * Get all primitives of the specified type.
943
- */
944
- primitives<TPrimitive extends Primitive>(factory: {
945
- [KIND]: InstantiableClass<TPrimitive>;
946
- } | string): Array<TPrimitive>;
947
- protected new<T extends object>(service: Service<T>, args?: any[]): T;
948
- protected processPrimitive(value: Primitive, propertyKey?: string): void;
949
- }
950
- interface Hook<T extends keyof Hooks = any> {
951
- caller?: Service;
952
- priority?: "first" | "last";
953
- callback: (payload: Hooks[T]) => Async<void>;
954
- }
955
- interface AlephaDump {
956
- env: Record<string, AlephaDumpEnvVariable>;
957
- providers: Record<string, {
958
- from: string[];
959
- as?: string[];
960
- module?: string;
961
- }>;
962
- }
963
- interface AlephaDumpEnvVariable {
964
- description: string;
965
- default?: string;
966
- required?: boolean;
967
- enum?: Array<string>;
968
- }
969
- /**
970
- * This is how we store services in the Alepha container.
971
- */
972
- interface ServiceDefinition<T extends object = any> {
973
- /**
974
- * The instance of the class or type definition.
975
- * Mostly used for caching / singleton but can be used for other purposes like forcing the instance.
976
- */
977
- instance: T;
978
- /**
979
- * List of classes which use this class.
980
- */
981
- parents: Array<Service | null>;
982
- }
983
- interface Env {
984
- [key: string]: string | boolean | number | undefined;
985
- /**
986
- * Optional environment variable that indicates the current environment.
987
- */
988
- NODE_ENV?: string;
989
- /**
990
- * Optional name of the application.
991
- */
992
- APP_NAME?: string;
993
- /**
994
- * Optional root module name.
995
- */
996
- MODULE_NAME?: string;
997
- }
998
- interface State {
999
- /**
1000
- * Environment variables for the application.
1001
- */
1002
- env?: Readonly<Env>;
1003
- /**
1004
- * Logger instance to be used by the Alepha container.
1005
- *
1006
- * @internal
1007
- */
1008
- "alepha.logger"?: LoggerInterface;
1009
- /**
1010
- * If defined, the Alepha container will only register this service and its dependencies.
1011
- *
1012
- * @example
1013
- * ```ts
1014
- * class MigrateCmd {
1015
- * db = $inject(DatabaseProvider);
1016
- * alepha = $inject(Alepha);
1017
- * env = $env(
1018
- * t.object({
1019
- * MIGRATE: t.optional(t.boolean()),
1020
- * }),
1021
- * );
1022
- *
1023
- * constructor() {
1024
- * if (this.env.MIGRATE) {
1025
- * this.alepha.set("alepha.target", MigrateCmd);
1026
- * }
1027
- * }
1028
- *
1029
- * ready = $hook({
1030
- * on: "ready",
1031
- * handler: async () => {
1032
- * if (this.env.MIGRATE) {
1033
- * await this.db.migrate();
1034
- * }
1035
- * },
1036
- * });
1037
- * }
1038
- * ```
1039
- */
1040
- "alepha.target"?: Service;
1041
- /**
1042
- * Bind to Vitest 'beforeAll' hook.
1043
- * Used for testing purposes.
1044
- * This is automatically attached if Alepha#create() detects a test environment and global 'beforeAll' is available.
1045
- */
1046
- "alepha.test.beforeAll"?: (run: any) => any;
1047
- /**
1048
- * Bind to Vitest 'afterAll' hook.
1049
- * Used for testing purposes.
1050
- * This is automatically attached if Alepha#create() detects a test environment and global 'afterAll' is available.
1051
- */
1052
- "alepha.test.afterAll"?: (run: any) => any;
1053
- /**
1054
- * Bind to Vitest 'afterEach' hook.
1055
- * Used for testing purposes.
1056
- * This is automatically attached if Alepha#create() detects a test environment and global 'afterEach' is available.
1057
- */
1058
- "alepha.test.afterEach"?: (run: any) => any;
1059
- /**
1060
- * Bind to Vitest 'onTestFinished' hook.
1061
- * Used for testing purposes.
1062
- * This is automatically attached if Alepha#create() detects a test environment and global 'onTestFinished' is available.
1063
- */
1064
- "alepha.test.onTestFinished"?: (run: any) => any;
1065
- /**
1066
- * List of static assets to be copied to the output directory during the build process.
1067
- *
1068
- * Used for Alepha-based applications that require static assets.
1069
- *
1070
- * See alepha/vite for more details.
1071
- */
1072
- "alepha.build.assets"?: Array<string>;
1073
- }
1074
- interface Hooks {
1075
- /**
1076
- * Used for testing purposes.
1077
- */
1078
- echo: unknown;
1079
- /**
1080
- * Triggered during the configuration phase. Before the start phase.
1081
- */
1082
- configure: Alepha;
1083
- /**
1084
- * Triggered during the start phase. When `Alepha#start()` is called.
1085
- */
1086
- start: Alepha;
1087
- /**
1088
- * Triggered during the ready phase. After the start phase.
1089
- */
1090
- ready: Alepha;
1091
- /**
1092
- * Triggered during the stop phase.
1093
- *
1094
- * - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application. (@see `run()` method)
1095
- *
1096
- */
1097
- stop: Alepha;
1098
- /**
1099
- * Triggered when a state value is mutated.
1100
- */
1101
- "state:mutate": {
1102
- /**
1103
- * The key of the state that was mutated.
1104
- */
1105
- key: keyof State;
1106
- /**
1107
- * The new value of the state.
1108
- */
1109
- value: any;
1110
- /**
1111
- * The previous value of the state.
1112
- */
1113
- prevValue: any;
1114
- };
1115
- }
1116
- //#endregion
1117
- //#region ../alepha/src/core/schemas/pageSchema.d.ts
1118
- declare const pageMetadataSchema: TObject$1<{
1119
- number: TInteger;
1120
- size: TInteger;
1121
- offset: TInteger;
1122
- numberOfElements: TInteger;
1123
- totalElements: TOptional<TInteger>;
1124
- totalPages: TOptional<TInteger>;
1125
- isEmpty: TBoolean;
1126
- isFirst: TBoolean;
1127
- isLast: TBoolean;
1128
- sort: TOptional<TObject$1<{
1129
- sorted: TBoolean;
1130
- fields: TArray$1<TObject$1<{
1131
- field: TString;
1132
- direction: TUnsafe<"asc" | "desc">;
1133
- }>>;
1134
- }>>;
1135
- }>;
1136
- type TPage<T extends TObject$1 | TRecord> = TObject$1<{
1137
- content: TArray$1<T>;
1138
- page: typeof pageMetadataSchema;
1139
- }>;
1140
- declare module "alepha" {
1141
- interface TypeProvider {
1142
- /**
1143
- * Create a schema for a paginated response.
1144
- */
1145
- page<T extends TObject$1 | TRecord>(itemSchema: T): TPage<T>;
1146
- }
1147
- }
1148
- //#endregion
1149
- //#region ../alepha/src/logger/schemas/logEntrySchema.d.ts
1150
- declare const logEntrySchema: TObject$1<{
1151
- level: TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
1152
- message: TString;
1153
- service: TString;
1154
- module: TString;
1155
- context: TOptional<TString>;
1156
- app: TOptional<TString>;
1157
- data: TOptional<TAny>;
1158
- timestamp: TNumber;
1159
- }>;
1160
- type LogEntry = Static$1<typeof logEntrySchema>;
1161
- //#endregion
1162
- //#region ../alepha/src/datetime/providers/DateTimeProvider.d.ts
1163
- type DateTime = DayjsApi.Dayjs;
1164
- type Duration = dayjsDuration.Duration;
1165
- type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
1166
- declare class DateTimeProvider {
1167
- static PLUGINS: Array<PluginFunc<any>>;
1168
- protected alepha: Alepha;
1169
- protected ref: DateTime | null;
1170
- protected readonly timeouts: Timeout[];
1171
- protected readonly intervals: Interval[];
1172
- constructor();
1173
- protected readonly onStart: HookPrimitive<"start">;
1174
- protected readonly onStop: HookPrimitive<"stop">;
1175
- setLocale(locale: string): void;
1176
- isDateTime(value: unknown): value is DateTime;
1177
- /**
1178
- * Create a new UTC DateTime instance.
1179
- */
1180
- utc(date: string | number | Date | Dayjs | null | undefined): DateTime;
1181
- /**
1182
- * Create a new DateTime instance.
1183
- */
1184
- of(date: string | number | Date | Dayjs | null | undefined): DateTime;
1185
- /**
1186
- * Get the current date as a string.
1187
- */
1188
- toISOString(date?: Date | string | DateTime): string;
1189
- /**
1190
- * Get the current date.
1191
- */
1192
- now(): DateTime;
1193
- /**
1194
- * Get the current date as a string.
1195
- *
1196
- * This is much faster than `DateTimeProvider.now().toISOString()` as it avoids creating a DateTime instance.
1197
- */
1198
- nowISOString(): string;
1199
- /**
1200
- * Get the current date as milliseconds since epoch.
1201
- *
1202
- * This is much faster than `DateTimeProvider.now().valueOf()` as it avoids creating a DateTime instance.
1203
- */
1204
- nowMillis(): number;
1205
- /**
1206
- * Get the current date as a string.
1207
- *
1208
- * @protected
1209
- */
1210
- protected getCurrentDate(): DateTime;
1211
- /**
1212
- * Create a new Duration instance.
1213
- */
1214
- duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
1215
- isDurationLike(value: unknown): value is DurationLike;
1216
- /**
1217
- * Return a promise that resolves after the next tick.
1218
- * It uses `setTimeout` with 0 ms delay.
1219
- */
1220
- tick(): Promise<void>;
1221
- /**
1222
- * Wait for a certain duration.
1223
- *
1224
- * You can clear the timeout by using the `AbortSignal` API.
1225
- * Aborted signal will resolve the promise immediately, it does not reject it.
1226
- */
1227
- wait(duration: DurationLike, options?: {
1228
- signal?: AbortSignal;
1229
- now?: number;
1230
- }): Promise<void>;
1231
- createInterval(run: () => unknown, duration: DurationLike, start?: boolean): Interval;
1232
- /**
1233
- * Run a callback after a certain duration.
1234
- */
1235
- createTimeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
1236
- clearTimeout(timeout: Timeout): void;
1237
- clearInterval(interval: Interval): void;
1238
- /**
1239
- * Run a function with a deadline.
1240
- */
1241
- deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
1242
- /**
1243
- * Add time to the current date.
1244
- */
1245
- travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
1246
- /**
1247
- * Stop the time.
1248
- */
1249
- pause(): DateTime;
1250
- /**
1251
- * Reset the reference date.
1252
- */
1253
- reset(): void;
1254
- }
1255
- interface Interval {
1256
- timer?: any;
1257
- duration: number;
1258
- run: () => unknown;
1259
- }
1260
- interface Timeout {
1261
- now: number;
1262
- timer?: any;
1263
- duration: number;
1264
- callback: () => void;
1265
- clear: () => void;
1266
- }
1267
- //#endregion
1268
- //#region ../alepha/src/logger/providers/LogDestinationProvider.d.ts
1269
- declare abstract class LogDestinationProvider {
1270
- abstract write(message: string, entry: LogEntry): void;
1271
- }
1272
- //#endregion
1273
- //#region ../alepha/src/logger/providers/LogFormatterProvider.d.ts
1274
- declare abstract class LogFormatterProvider {
1275
- abstract format(entry: LogEntry): string;
1276
- }
1277
- //#endregion
1278
- //#region ../alepha/src/logger/services/Logger.d.ts
1279
- declare class Logger implements LoggerInterface {
1280
- protected readonly alepha: Alepha;
1281
- protected readonly formatter: LogFormatterProvider;
1282
- protected readonly destination: LogDestinationProvider;
1283
- protected readonly dateTimeProvider: DateTimeProvider;
1284
- protected readonly levels: Record<string, number>;
1285
- protected readonly service: string;
1286
- protected readonly module: string;
1287
- protected readonly app?: string;
1288
- protected appLogLevel: string;
1289
- protected logLevel: LogLevel;
1290
- constructor(service: string, module: string);
1291
- get context(): string | undefined;
1292
- get level(): string;
1293
- parseLevel(level: string, app: string): LogLevel;
1294
- private matchesPattern;
1295
- asLogLevel(something: string): LogLevel;
1296
- error(message: string, data?: unknown): void;
1297
- warn(message: string, data?: unknown): void;
1298
- info(message: string, data?: unknown): void;
1299
- debug(message: string, data?: unknown): void;
1300
- trace(message: string, data?: unknown): void;
1301
- protected log(level: LogLevel, message: string, data?: unknown): void;
1302
- protected emit(entry: LogEntry, message?: string): void;
1303
- }
1304
- //#endregion
1305
- //#region ../alepha/src/logger/index.d.ts
1306
- declare const envSchema$1: TObject$1<{
1307
- /**
1308
- * Default log level for the application.
1309
- *
1310
- * Default by environment:
1311
- * - dev = info
1312
- * - prod = info
1313
- * - test = error
1314
- *
1315
- * Levels are: "trace" | "debug" | "info" | "warn" | "error" | "silent"
1316
- *
1317
- * Level can be set for a specific module:
1318
- *
1319
- * @example
1320
- * LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
1321
- * LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
1322
- */
1323
- LOG_LEVEL: TOptional<TString>;
1324
- /**
1325
- * Built-in log formats.
1326
- * - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
1327
- * - "pretty" - Simple text format, human-readable, with colors. {@link PrettyFormatterProvider}
1328
- * - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
1329
- */
1330
- LOG_FORMAT: TOptional<TUnsafe<"json" | "pretty" | "raw">>;
1331
- }>;
1332
- declare module "alepha" {
1333
- interface Env extends Partial<Static$1<typeof envSchema$1>> {}
1334
- interface State {
1335
- /**
1336
- * Current log level for the application or specific modules.
1337
- */
1338
- "alepha.logger.level"?: string;
1339
- }
1340
- interface Hooks {
1341
- log: {
1342
- message?: string;
1343
- entry: LogEntry;
1344
- };
1345
- }
1346
- }
1347
- //#endregion
1348
- //#region ../alepha/src/bucket/providers/FileStorageProvider.d.ts
1349
- declare abstract class FileStorageProvider {
1350
- /**
1351
- * Uploads a file to the storage.
1352
- *
1353
- * @param bucketName - Container name
1354
- * @param file - File to upload
1355
- * @param fileId - Optional file identifier. If not provided, a unique ID will be generated.
1356
- * @return The identifier of the uploaded file.
1357
- */
1358
- abstract upload(bucketName: string, file: FileLike, fileId?: string): Promise<string>;
1359
- /**
1360
- * Downloads a file from the storage.
1361
- *
1362
- * @param bucketName - Container name
1363
- * @param fileId - Identifier of the file to download
1364
- * @return The downloaded file as a FileLike object.
1365
- */
1366
- abstract download(bucketName: string, fileId: string): Promise<FileLike>;
1367
- /**
1368
- * Check if fileId exists in the storage bucket.
1369
- *
1370
- * @param bucketName - Container name
1371
- * @param fileId - Identifier of the file to stream
1372
- * @return True is the file exists, false otherwise.
1373
- */
1374
- abstract exists(bucketName: string, fileId: string): Promise<boolean>;
1375
- /**
1376
- * Delete permanently a file from the storage.
1377
- *
1378
- * @param bucketName - Container name
1379
- * @param fileId - Identifier of the file to delete
1380
- */
1381
- abstract delete(bucketName: string, fileId: string): Promise<void>;
1382
- }
1383
- //#endregion
1384
- //#region ../alepha/src/file/providers/FileSystemProvider.d.ts
1385
- /**
1386
- * Options for creating a file from a URL
1387
- */
1388
- interface CreateFileFromUrlOptions {
1389
- /**
1390
- * The URL to load the file from (file://, http://, or https://)
1391
- */
1392
- url: string;
1393
- /**
1394
- * The MIME type of the file (optional, will be detected from filename if not provided)
1395
- */
1396
- type?: string;
1397
- /**
1398
- * The name of the file (optional, will be extracted from URL if not provided)
1399
- */
1400
- name?: string;
1401
- }
1402
- /**
1403
- * Options for creating a file from a path (URL with file:// scheme)
1404
- */
1405
- interface CreateFileFromPathOptions {
1406
- /**
1407
- * The path to the file on the local filesystem
1408
- */
1409
- path: string;
1410
- /**
1411
- * The MIME type of the file (optional, will be detected from filename if not provided)
1412
- */
1413
- type?: string;
1414
- /**
1415
- * The name of the file (optional, will be extracted from URL if not provided)
1416
- */
1417
- name?: string;
1418
- }
1419
- /**
1420
- * Options for creating a file from a Buffer
1421
- */
1422
- interface CreateFileFromBufferOptions {
1423
- /**
1424
- * The Buffer containing the file data
1425
- */
1426
- buffer: Buffer;
1427
- /**
1428
- * The MIME type of the file (optional, will be detected from name if not provided)
1429
- */
1430
- type?: string;
1431
- /**
1432
- * The name of the file (required for proper content type detection)
1433
- */
1434
- name?: string;
1435
- }
1436
- /**
1437
- * Options for creating a file from a stream
1438
- */
1439
- interface CreateFileFromStreamOptions {
1440
- /**
1441
- * The readable stream containing the file data
1442
- */
1443
- stream: StreamLike;
1444
- /**
1445
- * The MIME type of the file (optional, will be detected from name if not provided)
1446
- */
1447
- type?: string;
1448
- /**
1449
- * The name of the file (required for proper content type detection)
1450
- */
1451
- name?: string;
1452
- /**
1453
- * The size of the file in bytes (optional)
1454
- */
1455
- size?: number;
1456
- }
1457
- /**
1458
- * Options for creating a file from text content
1459
- */
1460
- interface CreateFileFromTextOptions {
1461
- /**
1462
- * The text content to create the file from
1463
- */
1464
- text: string;
1465
- /**
1466
- * The MIME type of the file (default: text/plain)
1467
- */
1468
- type?: string;
1469
- /**
1470
- * The name of the file (default: "file.txt")
1471
- */
1472
- name?: string;
1473
- }
1474
- interface CreateFileFromResponseOptions {
1475
- /**
1476
- * The Response object containing the file data
1477
- */
1478
- response: Response;
1479
- /**
1480
- * Override the name (optional, uses filename from Content-Disposition header if not provided)
1481
- */
1482
- name?: string;
1483
- /**
1484
- * Override the MIME type (optional, uses file.type if not provided)
1485
- */
1486
- type?: string;
1487
- }
1488
- /**
1489
- * Options for creating a file from a Web File object
1490
- */
1491
- interface CreateFileFromWebFileOptions {
1492
- /**
1493
- * The Web File object
1494
- */
1495
- file: File;
1496
- /**
1497
- * Override the MIME type (optional, uses file.type if not provided)
1498
- */
1499
- type?: string;
1500
- /**
1501
- * Override the name (optional, uses file.name if not provided)
1502
- */
1503
- name?: string;
1504
- /**
1505
- * Override the size (optional, uses file.size if not provided)
1506
- */
1507
- size?: number;
1508
- }
1509
- /**
1510
- * Options for creating a file from an ArrayBuffer
1511
- */
1512
- interface CreateFileFromArrayBufferOptions {
1513
- /**
1514
- * The ArrayBuffer containing the file data
1515
- */
1516
- arrayBuffer: ArrayBuffer;
1517
- /**
1518
- * The MIME type of the file (optional, will be detected from name if not provided)
1519
- */
1520
- type?: string;
1521
- /**
1522
- * The name of the file (required for proper content type detection)
1523
- */
1524
- name?: string;
1525
- }
1526
- /**
1527
- * Union type for all createFile options
1528
- */
1529
- type CreateFileOptions = CreateFileFromUrlOptions | CreateFileFromPathOptions | CreateFileFromBufferOptions | CreateFileFromStreamOptions | CreateFileFromTextOptions | CreateFileFromWebFileOptions | CreateFileFromResponseOptions | CreateFileFromArrayBufferOptions;
1530
- /**
1531
- * Options for rm (remove) operation
1532
- */
1533
- interface RmOptions {
1534
- /**
1535
- * If true, removes directories and their contents recursively
1536
- */
1537
- recursive?: boolean;
1538
- /**
1539
- * If true, no error will be thrown if the path does not exist
1540
- */
1541
- force?: boolean;
1542
- }
1543
- /**
1544
- * Options for cp (copy) operation
1545
- */
1546
- interface CpOptions {
1547
- /**
1548
- * If true, copy directories recursively
1549
- */
1550
- recursive?: boolean;
1551
- /**
1552
- * If true, overwrite existing destination
1553
- */
1554
- force?: boolean;
1555
- }
1556
- /**
1557
- * Options for mkdir operation
1558
- */
1559
- interface MkdirOptions {
1560
- /**
1561
- * If true, creates parent directories as needed
1562
- */
1563
- recursive?: boolean;
1564
- /**
1565
- * File mode (permission and sticky bits)
1566
- */
1567
- mode?: number;
1568
- }
1569
- /**
1570
- * Options for ls (list) operation
1571
- */
1572
- interface LsOptions {
1573
- /**
1574
- * If true, list contents of directories recursively
1575
- */
1576
- recursive?: boolean;
1577
- /**
1578
- * If true, include hidden files (starting with .)
1579
- */
1580
- hidden?: boolean;
1581
- }
1582
- /**
1583
- * FileSystem interface providing utilities for working with files.
1584
- */
1585
- declare abstract class FileSystemProvider {
1586
- /**
1587
- * Joins multiple path segments into a single path.
1588
- *
1589
- * @param paths - The path segments to join
1590
- * @returns The joined path
1591
- */
1592
- abstract join(...paths: string[]): string;
1593
- /**
1594
- * Creates a FileLike object from various sources.
1595
- *
1596
- * @param options - Options for creating the file
1597
- * @returns A FileLike object
1598
- */
1599
- abstract createFile(options: CreateFileOptions): FileLike;
1600
- /**
1601
- * Removes a file or directory.
1602
- *
1603
- * @param path - The path to remove
1604
- * @param options - Remove options
1605
- */
1606
- abstract rm(path: string, options?: RmOptions): Promise<void>;
1607
- /**
1608
- * Copies a file or directory.
1609
- *
1610
- * @param src - Source path
1611
- * @param dest - Destination path
1612
- * @param options - Copy options
1613
- */
1614
- abstract cp(src: string, dest: string, options?: CpOptions): Promise<void>;
1615
- /**
1616
- * Moves/renames a file or directory.
1617
- *
1618
- * @param src - Source path
1619
- * @param dest - Destination path
1620
- */
1621
- abstract mv(src: string, dest: string): Promise<void>;
1622
- /**
1623
- * Creates a directory.
1624
- *
1625
- * @param path - The directory path to create
1626
- * @param options - Mkdir options
1627
- */
1628
- abstract mkdir(path: string, options?: MkdirOptions): Promise<void>;
1629
- /**
1630
- * Lists files in a directory.
1631
- *
1632
- * @param path - The directory path to list
1633
- * @param options - List options
1634
- * @returns Array of filenames
1635
- */
1636
- abstract ls(path: string, options?: LsOptions): Promise<string[]>;
1637
- /**
1638
- * Checks if a file or directory exists.
1639
- *
1640
- * @param path - The path to check
1641
- * @returns True if the path exists, false otherwise
1642
- */
1643
- abstract exists(path: string): Promise<boolean>;
1644
- /**
1645
- * Reads the content of a file.
1646
- *
1647
- * @param path - The file path to read
1648
- * @returns The file content as a Buffer
1649
- */
1650
- abstract readFile(path: string): Promise<Buffer>;
1651
- /**
1652
- * Writes data to a file.
1653
- *
1654
- * @param path - The file path to write to
1655
- * @param data - The data to write (Buffer or string)
1656
- */
1657
- abstract writeFile(path: string, data: Uint8Array | Buffer | string | FileLike): Promise<void>;
1658
- }
1659
- //#endregion
1660
- //#region ../alepha/src/file/services/FileDetector.d.ts
1661
- interface FileTypeResult {
1662
- /**
1663
- * The detected MIME type
1664
- */
1665
- mimeType: string;
1666
- /**
1667
- * The detected file extension
1668
- */
1669
- extension: string;
1670
- /**
1671
- * Whether the file type was verified by magic bytes
1672
- */
1673
- verified: boolean;
1674
- /**
1675
- * The stream (potentially wrapped to allow re-reading)
1676
- */
1677
- stream: Readable;
1678
- }
1679
- /**
1680
- * Service for detecting file types and getting content types.
1681
- *
1682
- * @example
1683
- * ```typescript
1684
- * const detector = alepha.inject(FileDetector);
1685
- *
1686
- * // Get content type from filename
1687
- * const mimeType = detector.getContentType("image.png"); // "image/png"
1688
- *
1689
- * // Detect file type by magic bytes
1690
- * const stream = createReadStream('image.png');
1691
- * const result = await detector.detectFileType(stream, 'image.png');
1692
- * console.log(result.mimeType); // 'image/png'
1693
- * console.log(result.verified); // true if magic bytes match
1694
- * ```
1695
- */
1696
- declare class FileDetector {
1697
- /**
1698
- * Magic byte signatures for common file formats.
1699
- * Each signature is represented as an array of bytes or null (wildcard).
1700
- */
1701
- protected static readonly MAGIC_BYTES: Record<string, {
1702
- signature: (number | null)[];
1703
- mimeType: string;
1704
- }[]>;
1705
- /**
1706
- * All possible format signatures for checking against actual file content
1707
- */
1708
- protected static readonly ALL_SIGNATURES: {
1709
- signature: (number | null)[];
1710
- mimeType: string;
1711
- ext: string;
1712
- }[];
1713
- /**
1714
- * MIME type map for file extensions.
1715
- *
1716
- * Can be used to get the content type of file based on its extension.
1717
- * Feel free to add more mime types in your project!
1718
- */
1719
- static readonly mimeMap: Record<string, string>;
1720
- /**
1721
- * Reverse MIME type map for looking up extensions from MIME types.
1722
- * Prefers shorter, more common extensions when multiple exist.
1723
- */
1724
- protected static readonly reverseMimeMap: Record<string, string>;
1725
- /**
1726
- * Returns the file extension for a given MIME type.
1727
- *
1728
- * @param mimeType - The MIME type to look up
1729
- * @returns The file extension (without dot), or "bin" if not found
1730
- *
1731
- * @example
1732
- * ```typescript
1733
- * const detector = alepha.inject(FileDetector);
1734
- * const ext = detector.getExtensionFromMimeType("image/png"); // "png"
1735
- * const ext2 = detector.getExtensionFromMimeType("application/octet-stream"); // "bin"
1736
- * ```
1737
- */
1738
- getExtensionFromMimeType(mimeType: string): string;
1739
- /**
1740
- * Returns the content type of file based on its filename.
1741
- *
1742
- * @param filename - The filename to check
1743
- * @returns The MIME type
1744
- *
1745
- * @example
1746
- * ```typescript
1747
- * const detector = alepha.inject(FileDetector);
1748
- * const mimeType = detector.getContentType("image.png"); // "image/png"
1749
- * ```
1750
- */
1751
- getContentType(filename: string): string;
1752
- /**
1753
- * Detects the file type by checking magic bytes against the stream content.
1754
- *
1755
- * @param stream - The readable stream to check
1756
- * @param filename - The filename (used to get the extension)
1757
- * @returns File type information including MIME type, extension, and verification status
1758
- *
1759
- * @example
1760
- * ```typescript
1761
- * const detector = alepha.inject(FileDetector);
1762
- * const stream = createReadStream('image.png');
1763
- * const result = await detector.detectFileType(stream, 'image.png');
1764
- * console.log(result.mimeType); // 'image/png'
1765
- * console.log(result.verified); // true if magic bytes match
1766
- * ```
1767
- */
1768
- detectFileType(stream: Readable, filename: string): Promise<FileTypeResult>;
1769
- /**
1770
- * Reads all bytes from a stream and returns the first N bytes along with a new stream containing all data.
1771
- * This approach reads the entire stream upfront to avoid complex async handling issues.
1772
- *
1773
- * @protected
1774
- */
1775
- protected peekBytes(stream: Readable, numBytes: number): Promise<{
1776
- buffer: Buffer;
1777
- stream: Readable;
1778
- }>;
1779
- /**
1780
- * Checks if a buffer matches a magic byte signature.
1781
- *
1782
- * @protected
1783
- */
1784
- protected matchesSignature(buffer: Buffer, signature: (number | null)[]): boolean;
1785
- }
1786
- //#endregion
1787
- //#region ../alepha/src/bucket/providers/MemoryFileStorageProvider.d.ts
1788
- declare class MemoryFileStorageProvider implements FileStorageProvider {
1789
- readonly files: Record<string, FileLike>;
1790
- protected readonly fileSystem: FileSystemProvider;
1791
- protected readonly fileDetector: FileDetector;
1792
- upload(bucketName: string, file: FileLike, fileId?: string): Promise<string>;
1793
- download(bucketName: string, fileId: string): Promise<FileLike>;
1794
- exists(bucketName: string, fileId: string): Promise<boolean>;
1795
- delete(bucketName: string, fileId: string): Promise<void>;
1796
- protected createId(): string;
1797
- }
1798
- //#endregion
1799
- //#region ../alepha/src/bucket/primitives/$bucket.d.ts
1800
- interface BucketPrimitiveOptions extends BucketFileOptions {
1801
- /**
1802
- * File storage provider configuration for the bucket.
1803
- *
1804
- * Options:
1805
- * - **"memory"**: In-memory storage (default for development, lost on restart)
1806
- * - **Service<FileStorageProvider>**: Custom provider class (e.g., S3FileStorageProvider, AzureBlobProvider)
1807
- * - **undefined**: Uses the default file storage provider from dependency injection
1808
- *
1809
- * **Provider Selection Guidelines**:
1810
- * - **Development**: Use "memory" for fast, simple testing without external dependencies
1811
- * - **Production**: Use cloud providers (S3, Azure Blob, Google Cloud Storage) for scalability
1812
- * - **Local deployment**: Use filesystem providers for on-premise installations
1813
- * - **Hybrid**: Use different providers for different bucket types (temp files vs permanent storage)
1814
- *
1815
- * **Provider Capabilities**:
1816
- * - File persistence and durability guarantees
1817
- * - Scalability and performance characteristics
1818
- * - Geographic distribution and CDN integration
1819
- * - Cost implications for storage and bandwidth
1820
- * - Backup and disaster recovery features
1821
- *
1822
- * @default Uses injected FileStorageProvider
1823
- * @example "memory"
1824
- * @example S3FileStorageProvider
1825
- * @example AzureBlobStorageProvider
1826
- */
1827
- provider?: Service<FileStorageProvider> | "memory";
1828
- /**
1829
- * Unique name identifier for the bucket.
1830
- *
1831
- * This name is used for:
1832
- * - Storage backend organization and partitioning
1833
- * - File path generation and URL construction
1834
- * - Logging, monitoring, and debugging
1835
- * - Access control and permissions management
1836
- * - Backup and replication configuration
1837
- *
1838
- * **Naming Conventions**:
1839
- * - Use lowercase with hyphens for consistency
1840
- * - Include purpose or content type in the name
1841
- * - Avoid spaces and special characters
1842
- * - Consider environment prefixes for deployment isolation
1843
- *
1844
- * If not provided, defaults to the property key where the bucket is declared.
1845
- *
1846
- * @example "user-avatars"
1847
- * @example "product-images"
1848
- * @example "legal-documents"
1849
- * @example "temp-processing-files"
1850
- */
1851
- name?: string;
1852
- }
1853
- interface BucketFileOptions {
1854
- /**
1855
- * Human-readable description of the bucket's purpose and contents.
1856
- *
1857
- * Used for:
1858
- * - Documentation generation and API references
1859
- * - Developer onboarding and system understanding
1860
- * - Monitoring dashboards and admin interfaces
1861
- * - Compliance and audit documentation
1862
- *
1863
- * **Description Best Practices**:
1864
- * - Explain what types of files this bucket stores
1865
- * - Mention any special handling or processing requirements
1866
- * - Include information about retention policies if applicable
1867
- * - Note any compliance or security considerations
1868
- *
1869
- * @example "User profile pictures and avatar images"
1870
- * @example "Product catalog images with automated thumbnail generation"
1871
- * @example "Legal documents requiring long-term retention"
1872
- * @example "Temporary files for data processing workflows"
1873
- */
1874
- description?: string;
1875
- /**
1876
- * Array of allowed MIME types for files uploaded to this bucket.
1877
- *
1878
- * When specified, only files with these exact MIME types will be accepted.
1879
- * Files with disallowed MIME types will be rejected with an InvalidFileError.
1880
- *
1881
- * **MIME Type Categories**:
1882
- * - Images: "image/jpeg", "image/png", "image/gif", "image/webp", "image/svg+xml"
1883
- * - Documents: "application/pdf", "text/plain", "text/csv"
1884
- * - Office: "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
1885
- * - Archives: "application/zip", "application/x-tar", "application/gzip"
1886
- * - Media: "video/mp4", "audio/mpeg", "audio/wav"
1887
- *
1888
- * **Security Considerations**:
1889
- * - Always validate MIME types for user uploads
1890
- * - Be cautious with executable file types
1891
- * - Consider using allow-lists rather than deny-lists
1892
- * - Remember that MIME types can be spoofed by malicious users
1893
- *
1894
- * If not specified, all MIME types are allowed (not recommended for user uploads).
1895
- *
1896
- * @example ["image/jpeg", "image/png"] // Only JPEG and PNG images
1897
- * @example ["application/pdf", "text/plain"] // Documents only
1898
- * @example ["video/mp4", "video/webm"] // Video files
1899
- */
1900
- mimeTypes?: string[];
1901
- /**
1902
- * Maximum file size allowed in megabytes (MB).
1903
- *
1904
- * Files larger than this limit will be rejected with an InvalidFileError.
1905
- * This helps prevent:
1906
- * - Storage quota exhaustion
1907
- * - Memory issues during file processing
1908
- * - Long upload times and timeouts
1909
- * - Abuse of storage resources
1910
- *
1911
- * **Size Guidelines by File Type**:
1912
- * - Profile images: 1-5 MB
1913
- * - Product photos: 5-10 MB
1914
- * - Documents: 10-50 MB
1915
- * - Video files: 50-500 MB
1916
- * - Data files: 100-1000 MB
1917
- *
1918
- * **Considerations**:
1919
- * - Consider your storage costs and limits
1920
- * - Factor in network upload speeds for users
1921
- * - Account for processing requirements (thumbnails, compression)
1922
- * - Set reasonable limits based on actual use cases
1923
- *
1924
- * @default 10 MB
1925
- *
1926
- * @example 1 // 1MB for small images
1927
- * @example 25 // 25MB for documents
1928
- * @example 100 // 100MB for media files
1929
- */
1930
- maxSize?: number;
1931
- }
1932
- declare class BucketPrimitive extends Primitive<BucketPrimitiveOptions> {
1933
- readonly provider: FileStorageProvider | MemoryFileStorageProvider;
1934
- private readonly fileSystem;
1935
- get name(): string;
1936
- /**
1937
- * Uploads a file to the bucket.
1938
- */
1939
- upload(file: FileLike, options?: BucketFileOptions): Promise<string>;
1940
- /**
1941
- * Delete permanently a file from the bucket.
1942
- */
1943
- delete(fileId: string, skipHook?: boolean): Promise<void>;
1944
- /**
1945
- * Checks if a file exists in the bucket.
1946
- */
1947
- exists(fileId: string): Promise<boolean>;
1948
- /**
1949
- * Downloads a file from the bucket.
1950
- */
1951
- download(fileId: string): Promise<FileLike>;
1952
- protected $provider(): FileStorageProvider | MemoryFileStorageProvider;
1953
- }
1954
- interface BucketFileOptions {
1955
- /**
1956
- * Optional description of the bucket.
1957
- */
1958
- description?: string;
1959
- /**
1960
- * Allowed MIME types.
1961
- */
1962
- mimeTypes?: string[];
1963
- /**
1964
- * Maximum size of the files in the bucket.
1965
- *
1966
- * @default 10
1967
- */
1968
- maxSize?: number;
1969
- }
1970
- //#endregion
1971
- //#region ../alepha/src/bucket/providers/LocalFileStorageProvider.d.ts
1972
- /**
1973
- * Local file storage configuration atom
1974
- */
1975
- declare const localFileStorageOptions: Atom<TObject$1<{
1976
- storagePath: TString;
1977
- }>, "alepha.bucket.local.options">;
1978
- type LocalFileStorageProviderOptions = Static$1<typeof localFileStorageOptions.schema>;
1979
- declare module "alepha" {
1980
- interface State {
1981
- [localFileStorageOptions.key]: LocalFileStorageProviderOptions;
1982
- }
1983
- }
1984
- //#endregion
1985
- //#region ../alepha/src/bucket/index.d.ts
1986
- declare module "alepha" {
1987
- interface Hooks {
1988
- /**
1989
- * Triggered when a file is uploaded to a bucket.
1990
- * Can be used to perform actions after a file is uploaded, like creating a database record!
1991
- */
1992
- "bucket:file:uploaded": {
1993
- id: string;
1994
- file: FileLike;
1995
- bucket: BucketPrimitive;
1996
- options: BucketFileOptions;
1997
- };
1998
- /**
1999
- * Triggered when a file is deleted from a bucket.
2000
- */
2001
- "bucket:file:deleted": {
2002
- id: string;
2003
- bucket: BucketPrimitive;
2004
- };
2005
- }
2006
- }
2007
- /**
2008
- * Provides file storage capabilities through declarative bucket primitives with support for multiple storage backends.
2009
- *
2010
- * The bucket module enables unified file operations across different storage systems using the `$bucket` primitive
2011
- * on class properties. It abstracts storage provider differences, offering consistent APIs for local filesystem,
2012
- * cloud storage, or in-memory storage for testing environments.
2013
- *
2014
- * @see {@link $bucket}
2015
- * @see {@link FileStorageProvider}
2016
- * @module alepha.bucket
2017
- */
2018
- //#endregion
2019
9
  //#region src/providers/VercelBlobProvider.d.ts
2020
10
  declare class VercelBlobApi {
2021
11
  put: typeof put;
@@ -2024,17 +14,17 @@ declare class VercelBlobApi {
2024
14
  }
2025
15
  //#endregion
2026
16
  //#region src/providers/VercelFileStorageProvider.d.ts
2027
- declare const envSchema: TObject$1<{
2028
- BLOB_READ_WRITE_TOKEN: TString;
17
+ declare const envSchema: alepha1.TObject<{
18
+ BLOB_READ_WRITE_TOKEN: alepha1.TString;
2029
19
  }>;
2030
20
  declare module "alepha" {
2031
- interface Env extends Partial<Static$1<typeof envSchema>> {}
21
+ interface Env extends Partial<Static<typeof envSchema>> {}
2032
22
  }
2033
23
  /**
2034
24
  * Vercel Blob Storage implementation of File Storage Provider.
2035
25
  */
2036
26
  declare class VercelFileStorageProvider implements FileStorageProvider {
2037
- protected readonly log: Logger;
27
+ protected readonly log: alepha_logger0.Logger;
2038
28
  protected readonly env: {
2039
29
  BLOB_READ_WRITE_TOKEN: string;
2040
30
  };
@@ -2044,7 +34,7 @@ declare class VercelFileStorageProvider implements FileStorageProvider {
2044
34
  protected readonly fileDetector: FileDetector;
2045
35
  protected readonly stores: Set<string>;
2046
36
  protected readonly vercelBlobApi: VercelBlobApi;
2047
- protected readonly onStart: HookPrimitive<"start">;
37
+ protected readonly onStart: alepha1.HookPrimitive<"start">;
2048
38
  convertName(name: string): string;
2049
39
  protected createId(mimeType: string): string;
2050
40
  upload(bucketName: string, file: FileLike, fileId?: string): Promise<string>;
@@ -2060,7 +50,7 @@ declare class VercelFileStorageProvider implements FileStorageProvider {
2060
50
  * @see {@link VercelFileStorageProvider}
2061
51
  * @module alepha.bucket.vercel
2062
52
  */
2063
- declare const AlephaBucketVercel: Service<Module>;
53
+ declare const AlephaBucketVercel: alepha1.Service<alepha1.Module>;
2064
54
  //#endregion
2065
55
  export { AlephaBucketVercel, VercelFileStorageProvider };
2066
56
  //# sourceMappingURL=index.d.ts.map