alepha 0.8.0 → 0.9.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 (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +47 -44
  3. package/batch.d.ts +87 -88
  4. package/bucket.cjs +8 -0
  5. package/bucket.d.ts +194 -0
  6. package/bucket.js +1 -0
  7. package/cache/redis.d.ts +14 -16
  8. package/cache.d.ts +101 -170
  9. package/command.d.ts +70 -77
  10. package/core.d.ts +1043 -887
  11. package/datetime.d.ts +91 -117
  12. package/file.cjs +8 -0
  13. package/file.d.ts +56 -0
  14. package/file.js +1 -0
  15. package/lock/redis.d.ts +11 -13
  16. package/lock.d.ts +125 -117
  17. package/package.json +66 -38
  18. package/postgres.d.ts +232 -275
  19. package/queue/redis.d.ts +13 -15
  20. package/queue.d.ts +88 -116
  21. package/react/auth.d.ts +50 -55
  22. package/react/head.d.ts +5 -8
  23. package/react.d.ts +71 -73
  24. package/redis.d.ts +32 -14
  25. package/retry.d.ts +70 -58
  26. package/router.cjs +8 -0
  27. package/router.d.ts +45 -0
  28. package/router.js +1 -0
  29. package/scheduler.d.ts +54 -96
  30. package/security.d.ts +117 -119
  31. package/server/cache.d.ts +22 -31
  32. package/server/compress.d.ts +16 -7
  33. package/server/cookies.d.ts +70 -61
  34. package/server/cors.d.ts +15 -13
  35. package/server/health.d.ts +23 -26
  36. package/server/helmet.d.ts +17 -20
  37. package/server/links.d.ts +113 -90
  38. package/server/metrics.d.ts +25 -23
  39. package/server/multipart.d.ts +12 -16
  40. package/server/proxy.d.ts +25 -20
  41. package/server/security.cjs +8 -0
  42. package/server/security.d.ts +90 -0
  43. package/server/security.js +1 -0
  44. package/server/static.d.ts +67 -68
  45. package/server/swagger.d.ts +77 -65
  46. package/server.d.ts +265 -308
  47. package/topic/redis.d.ts +25 -26
  48. package/topic.d.ts +76 -122
  49. package/vite.d.ts +52 -36
package/cache.d.ts CHANGED
@@ -1,122 +1,122 @@
1
- import { Alepha, HookDescriptor, KIND, Logger, Module, OPTIONS, Static, TBoolean, TNumber, TObject, TOptional, TString } from "alepha";
1
+ import * as _alepha_core0$1 from "alepha";
2
+ import * as _alepha_core0 from "alepha";
3
+ import { Descriptor, InstantiableClass, KIND } from "alepha";
2
4
  import { DateTimeProvider, DurationLike, Timeout } from "alepha/datetime";
3
5
 
4
6
  //#region src/providers/CacheProvider.d.ts
5
-
6
7
  /**
7
- * Cache provider interface.
8
- *
9
- * All methods are asynchronous and return promises.
10
- * Values are stored as Uint8Array.
11
- */
8
+ * Cache provider interface.
9
+ *
10
+ * All methods are asynchronous and return promises.
11
+ * Values are stored as Uint8Array.
12
+ */
12
13
  declare abstract class CacheProvider {
13
14
  /**
14
- * Get the value of a key.
15
- *
16
- * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
17
- * @param key The key of the value to get.
18
- *
19
- * @return The value of the key, or undefined if the key does not exist.
20
- */
15
+ * Get the value of a key.
16
+ *
17
+ * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
18
+ * @param key The key of the value to get.
19
+ *
20
+ * @return The value of the key, or undefined if the key does not exist.
21
+ */
21
22
  abstract get(name: string, key: string): Promise<Uint8Array | undefined>;
22
23
  /**
23
- * Set the string value of a key.
24
- *
25
- * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
26
- * @param key The key of the value to set.
27
- * @param value The value to set.
28
- * @param ttl The time-to-live of the key, in milliseconds.
29
- *
30
- * @return The value of the key.
31
- */
24
+ * Set the string value of a key.
25
+ *
26
+ * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
27
+ * @param key The key of the value to set.
28
+ * @param value The value to set.
29
+ * @param ttl The time-to-live of the key, in milliseconds.
30
+ *
31
+ * @return The value of the key.
32
+ */
32
33
  abstract set(name: string, key: string, value: Uint8Array, ttl?: number): Promise<Uint8Array>;
33
34
  /**
34
- * Remove the specified keys.
35
- *
36
- * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
37
- * @param keys The keys to delete.
38
- */
35
+ * Remove the specified keys.
36
+ *
37
+ * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
38
+ * @param keys The keys to delete.
39
+ */
39
40
  abstract del(name: string, ...keys: string[]): Promise<void>;
40
41
  abstract has(name: string, key: string): Promise<boolean>;
41
- abstract keys(name: string): Promise<string[]>;
42
+ abstract keys(name: string, filter?: string): Promise<string[]>;
42
43
  }
44
+ //# sourceMappingURL=CacheProvider.d.ts.map
43
45
  //#endregion
44
46
  //#region src/descriptors/$cache.d.ts
45
- declare const KEY = "CACHE";
46
47
  /**
47
- * Cache Descriptor
48
- */
48
+ * Creates a cache storage or a cache function.
49
+ */
49
50
  declare const $cache: {
50
- <TReturn = string, TParameter extends any[] = any[]>(options?: CacheDescriptorOptions<TReturn, TParameter>): CacheDescriptor<TReturn, TParameter>;
51
- [KIND]: string;
51
+ <TReturn = string, TParameter extends any[] = any[]>(options?: CacheDescriptorOptions<TReturn, TParameter>): CacheDescriptorFn<TReturn, TParameter>;
52
+ [KIND]: typeof CacheDescriptor;
52
53
  };
53
- // ---------------------------------------------------------------------------------------------------------------------
54
54
  interface CacheDescriptorOptions<TReturn, TParameter extends any[] = any[]> {
55
55
  /**
56
- * The cache name. This is useful for invalidating multiple caches at once.
57
- *
58
- * Store key as `cache:$name:$key`.
59
- *
60
- * @default ClassName:methodName
61
- */
56
+ * The cache name. This is useful for invalidating multiple caches at once.
57
+ *
58
+ * Store key as `cache:$name:$key`.
59
+ *
60
+ * @default Name of the key of the class.
61
+ */
62
62
  name?: string;
63
63
  /**
64
- * Function which returns cached data.
65
- * @param args Arguments for handler.
66
- */
64
+ * Function which returns cached data.
65
+ */
67
66
  handler?: (...args: TParameter) => TReturn;
68
67
  /**
69
- * The key generator for the cache.
70
- * If not provided, the arguments will be json.stringify().
71
- */
68
+ * The key generator for the cache.
69
+ * If not provided, the arguments will be json.stringify().
70
+ */
72
71
  key?: (...args: TParameter) => string;
73
72
  /**
74
- * The store provider for the cache.
75
- * If not provided, the default store provider will be used.
76
- */
77
- provider?: CacheProvider | (() => CacheProvider) | "memory";
73
+ * The store provider for the cache.
74
+ * If not provided, the default store provider will be used.
75
+ */
76
+ provider?: InstantiableClass<CacheProvider> | "memory";
78
77
  /**
79
- * The time-to-live for the cache in seconds.
80
- * Set 0 to skip expiration.
81
- *
82
- * @default 300 (5 minutes).
83
- */
78
+ * The time-to-live for the cache in seconds.
79
+ * Set 0 to skip expiration.
80
+ *
81
+ * @default 300 (5 minutes).
82
+ */
84
83
  ttl?: DurationLike;
85
84
  /**
86
- * If the cache is disabled.
87
- */
85
+ * If the cache is disabled.
86
+ */
88
87
  disabled?: boolean;
89
88
  }
90
- interface CacheDescriptor<TReturn = any, TParameter extends any[] = any[]> {
91
- [KIND]: typeof KEY;
92
- [OPTIONS]: CacheDescriptorOptions<TReturn, TParameter>;
89
+ declare class CacheDescriptor<TReturn = any, TParameter extends any[] = any[]> extends Descriptor<CacheDescriptorOptions<TReturn, TParameter>> {
90
+ protected readonly env: {
91
+ CACHE_ENABLED: boolean;
92
+ CACHE_DEFAULT_TTL: number;
93
+ };
94
+ protected readonly dateTimeProvider: DateTimeProvider;
95
+ protected readonly provider: CacheProvider;
96
+ protected encoder: TextEncoder;
97
+ protected decoder: TextDecoder;
98
+ protected codes: {
99
+ BINARY: number;
100
+ JSON: number;
101
+ STRING: number;
102
+ };
103
+ get container(): string;
104
+ run(...args: TParameter): Promise<TReturn>;
105
+ key(...args: TParameter): string;
106
+ invalidate(...keys: string[]): Promise<void>;
107
+ set(key: string, value: TReturn, ttl?: DurationLike): Promise<void>;
108
+ get(key: string): Promise<TReturn | undefined>;
109
+ protected serialize<TReturn>(value: TReturn): Uint8Array;
110
+ protected deserialize<TReturn>(uint8Array: Uint8Array): Promise<TReturn>;
111
+ protected $provider(): CacheProvider;
112
+ }
113
+ interface CacheDescriptorFn<TReturn = any, TParameter extends any[] = any[]> extends CacheDescriptor<TReturn, TParameter> {
93
114
  /**
94
- * Cache handler.
95
- */
115
+ * Run the cache descriptor with the provided arguments.
116
+ */
96
117
  (...args: TParameter): Promise<TReturn>;
97
- /**
98
- * Cache key generator.
99
- */
100
- key: (...args: TParameter) => string;
101
- /**
102
- * Invalidate cache by keys.
103
- */
104
- invalidate: (...keys: string[]) => Promise<void>;
105
- /**
106
- * Set cache with key, value and ttl.
107
- *
108
- * @param key
109
- * @param value
110
- * @param ttl
111
- */
112
- set: (key: string, value: TReturn, ttl?: DurationLike) => Promise<void>;
113
- /**
114
- * Get cache by key.
115
- *
116
- * @param key
117
- */
118
- get: (key: string) => Promise<TReturn | undefined>;
119
118
  }
119
+ //# sourceMappingURL=$cache.d.ts.map
120
120
  //#endregion
121
121
  //#region src/providers/MemoryCacheProvider.d.ts
122
122
  type CacheName = string;
@@ -127,99 +127,30 @@ type CacheValue = {
127
127
  };
128
128
  declare class MemoryCacheProvider implements CacheProvider {
129
129
  protected readonly dateTimeProvider: DateTimeProvider;
130
- protected readonly log: Logger;
130
+ protected readonly log: _alepha_core0$1.Logger;
131
131
  protected store: Record<CacheName, Record<CacheKey, CacheValue>>;
132
132
  get(name: string, key: string): Promise<Uint8Array | undefined>;
133
133
  set(name: string, key: string, value: Uint8Array, ttl?: number): Promise<Uint8Array>;
134
134
  del(name: string, ...keys: string[]): Promise<void>;
135
135
  has(name: string, key: string): Promise<boolean>;
136
- keys(name: string): Promise<string[]>;
137
- }
138
- //#endregion
139
- //#region src/providers/CacheDescriptorProvider.d.ts
140
- declare const envSchema: TObject<{
141
- CACHE_DEFAULT_TTL: TNumber;
142
- CACHE_PREFIX: TOptional<TString>;
143
- CACHE_ENABLED: TBoolean;
144
- }>;
145
- declare module "alepha" {
146
- interface Env extends Partial<Static<typeof envSchema>> {}
147
- }
148
- declare class CacheDescriptorProvider {
149
- protected readonly alepha: Alepha;
150
- protected readonly cacheProvider: CacheProvider;
151
- protected readonly memoryCacheProvider: MemoryCacheProvider;
152
- protected readonly dateTimeProvider: DateTimeProvider;
153
- protected readonly env: Static<typeof envSchema>;
154
- protected readonly caches: Cache[];
155
- protected encoder: TextEncoder;
156
- protected decoder: TextDecoder;
157
- protected codes: {
158
- BINARY: number;
159
- JSON: number;
160
- STRING: number;
161
- };
162
- protected readonly configure: HookDescriptor<"configure">;
163
- register(cache: Cache): Cache;
164
- processDescriptors(): void;
165
- getCaches(): Cache[];
166
- /**
167
- * Clear all cache entries.
168
- */
169
- clear(): Promise<void>;
170
- /**
171
- * Get the store provider for the given cache options.
172
- *
173
- * @param options
174
- */
175
- provider(options: Pick<CacheDescriptorOptions<any[], any>, "provider">): CacheProvider;
176
- /**
177
- * Get the cache key for the given state and arguments.
178
- */
179
- key(cache: Cache, ...args: any[]): string;
180
- /**
181
- * Invalidate the cache for the given state and arguments.
182
- */
183
- invalidate(cache: Cache, ...keys: string[]): Promise<void>;
184
- /**
185
- * Run the cache handler with the given state and arguments.
186
- * You must run on a $cache with a handler defined.
187
- */
188
- run<TReturn, TParameter extends any[]>(cache: Cache<TReturn, TParameter>, ...args: TParameter): Promise<TReturn>;
189
- get<TReturn>(cache: Cache<TReturn>, key: string): Promise<TReturn | undefined>;
190
- /**
191
- * Manually set a value in the cache.
192
- * It's used by .run() method, but you will need it when you don't have cache handler defined.
193
- *
194
- * @param cache Cache object with all configuration and options (even TTL).
195
- * @param key Cache key, build with .key() method or manually.
196
- * @param value Value to store in cache.
197
- * @param ttl Override cache.ttl option.
198
- */
199
- set<TReturn>(cache: Cache<TReturn>, key: string, value: TReturn, ttl?: DurationLike): Promise<void>;
200
- protected serialize<TReturn>(value: TReturn): Uint8Array;
201
- protected deserialize<TReturn>(uint8Array: Uint8Array): Promise<TReturn>;
202
- }
203
- interface Cache<TReturn = any, TParameter extends any[] = any[]> {
204
- name: string;
205
- options: CacheDescriptorOptions<TReturn, TParameter>;
136
+ keys(name: string, filter?: string): Promise<string[]>;
206
137
  }
207
138
  //#endregion
208
139
  //#region src/index.d.ts
209
- // ---------------------------------------------------------------------------------------------------------------------
210
140
  /**
211
- * Alepha Cache Module
212
- *
213
- * This module provides a caching mechanism for Alepha applications.
214
- *
215
- * @see {@link $cache}
216
- * @see {@link CacheProvider}
217
- * @module alepha.cache
218
- */
219
- declare class AlephaCache implements Module {
220
- readonly name = "alepha.cache";
221
- readonly $services: (alepha: Alepha) => Alepha;
222
- }
141
+ * Provides high-performance caching capabilities for Alepha applications with configurable TTL and multiple storage backends.
142
+ *
143
+ * The cache module enables declarative caching through the `$cache` descriptor, allowing you to cache method results,
144
+ * API responses, or computed values with automatic invalidation and type safety. It supports both in-memory and
145
+ * persistent storage backends for different performance and durability requirements.
146
+ *
147
+ * @see {@link $cache}
148
+ * @see {@link CacheProvider}
149
+ * @module alepha.cache
150
+ */
151
+ declare const AlephaCache: _alepha_core0.ModuleDescriptor;
152
+ //# sourceMappingURL=index.d.ts.map
153
+
223
154
  //#endregion
224
- export { $cache, AlephaCache, Cache, CacheDescriptor, CacheDescriptorOptions, CacheDescriptorProvider, CacheProvider, MemoryCacheProvider };
155
+ export { $cache, AlephaCache, CacheDescriptor, CacheDescriptorFn, CacheDescriptorOptions, CacheProvider, MemoryCacheProvider };
225
156
  //# sourceMappingURL=index.d.ts.map
package/command.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- import { Alepha, AlephaError, Async, HookDescriptor, KIND, Logger, Module, OPTIONS, Static, TObject, TProperties, TSchema, TString } from "alepha";
1
+ import * as _alepha_core0$1 from "alepha";
2
+ import * as _alepha_core0 from "alepha";
3
+ import { Alepha, AlephaError, Async, Descriptor, KIND, Logger, Static, TObject, TSchema } from "alepha";
2
4
  import * as fs from "node:fs/promises";
3
5
  import { glob } from "node:fs/promises";
6
+ import * as _sinclair_typebox0 from "@sinclair/typebox";
4
7
 
5
8
  //#region src/helpers/Runner.d.ts
6
9
  type Task = {
@@ -23,105 +26,97 @@ declare class Runner {
23
26
  constructor(log: Logger);
24
27
  protected exec(cmd: string): Promise<string>;
25
28
  /**
26
- * Executes one or more tasks.
27
- *
28
- * @param task - A single task or an array of tasks to run in parallel.
29
- */
29
+ * Executes one or more tasks.
30
+ *
31
+ * @param task - A single task or an array of tasks to run in parallel.
32
+ */
30
33
  protected execute(task: Task | Task[]): Promise<string>;
31
34
  /**
32
- * Prints a summary of all executed tasks and their durations.
33
- */
35
+ * Prints a summary of all executed tasks and their durations.
36
+ */
34
37
  summary(): void;
35
38
  protected executeTask(task: Task): Promise<string>;
36
39
  protected renderTable(data: string[][]): void;
37
40
  }
38
41
  //#endregion
39
42
  //#region src/descriptors/$command.d.ts
40
- declare const KEY = "COMMAND";
43
+ /**
44
+ * Declares a CLI command.
45
+ *
46
+ * This descriptor allows you to define a command, its flags, and its handler
47
+ * within your Alepha application structure.
48
+ */
49
+ declare const $command: {
50
+ <T extends TObject>(options: CommandDescriptorOptions<T>): CommandDescriptor<T>;
51
+ [KIND]: typeof CommandDescriptor;
52
+ };
41
53
  interface CommandDescriptorOptions<T extends TObject> {
42
54
  /**
43
- * The handler function to execute when the command is matched.
44
- */
45
- handler: (args: {
46
- flags: Static<T>;
47
- run: RunnerMethod;
48
- glob: typeof glob;
49
- fs: typeof fs;
50
- }) => Async<void>;
55
+ * The handler function to execute when the command is matched.
56
+ */
57
+ handler: (args: CommandHandlerArgs<T>) => Async<void>;
51
58
  /**
52
- * The name of the command. If omitted, the property key is used.
53
- *
54
- * An empty string "" denotes the root command.
55
- */
59
+ * The name of the command. If omitted, the property key is used.
60
+ *
61
+ * An empty string "" denotes the root command.
62
+ */
56
63
  name?: string;
57
64
  /**
58
- * A short description of the command, shown in the help message.
59
- */
65
+ * A short description of the command, shown in the help message.
66
+ */
60
67
  description?: string;
61
68
  /**
62
- * An array of alternative names for the command.
63
- */
69
+ * An array of alternative names for the command.
70
+ */
64
71
  aliases?: string[];
65
72
  /**
66
- * A TypeBox object schema defining the flags for the command.
67
- */
73
+ * A TypeBox object schema defining the flags for the command.
74
+ */
68
75
  flags?: T;
69
76
  }
70
- interface CommandDescriptor<T extends TObject> {
71
- [KIND]: typeof KEY;
72
- [OPTIONS]: CommandDescriptorOptions<T>;
73
- /**
74
- * Executes the command. This is a placeholder and will be replaced by the provider.
75
- */
76
- (flags: Static<T>): Promise<void>;
77
+ declare class CommandDescriptor<T extends TObject = TObject> extends Descriptor<CommandDescriptorOptions<T>> {
78
+ readonly flags: TObject<{}>;
79
+ readonly aliases: string[];
80
+ get name(): string;
77
81
  }
78
- /**
79
- * Declares a CLI command.
80
- *
81
- * This descriptor allows you to define a command, its flags, and its handler
82
- * within your Alepha application structure.
83
- */
84
- declare const $command: {
85
- <T extends TObject>(options: CommandDescriptorOptions<T>): CommandDescriptor<T>;
86
- [KIND]: string;
87
- };
82
+ interface CommandHandlerArgs<T extends TObject> {
83
+ flags: Static<T>;
84
+ run: RunnerMethod;
85
+ glob: typeof glob;
86
+ fs: typeof fs;
87
+ }
88
+ //# sourceMappingURL=$command.d.ts.map
88
89
  //#endregion
89
90
  //#region src/errors/CommandError.d.ts
90
91
  declare class CommandError extends AlephaError {}
92
+ //# sourceMappingURL=CommandError.d.ts.map
91
93
  //#endregion
92
- //#region src/providers/CommandDescriptorProvider.d.ts
93
- interface Command {
94
- key: string;
95
- name: string;
96
- description?: string;
97
- aliases: string[];
98
- flags: TObject<TProperties>;
99
- handler: (flags: any) => Promise<void>;
100
- }
94
+ //#region src/providers/CliProvider.d.ts
101
95
  declare const envSchema: TObject<{
102
- CLI_NAME: TString;
103
- CLI_DESCRIPTION: TString;
96
+ CLI_NAME: _alepha_core0$1.TString;
97
+ CLI_DESCRIPTION: _alepha_core0$1.TString;
104
98
  }>;
105
99
  declare module "alepha" {
106
100
  interface Env extends Partial<Static<typeof envSchema>> {}
107
101
  }
108
- declare class CommandDescriptorProvider {
102
+ declare class CliProvider {
109
103
  protected readonly env: Static<typeof envSchema>;
110
104
  protected readonly alepha: Alepha;
111
105
  protected readonly log: Logger;
112
- protected commands: Command[];
113
106
  options: {
114
107
  name: string;
115
108
  description: string;
116
109
  argv: string[];
117
110
  };
118
- protected readonly globalFlags: Record<string, {
119
- aliases: string[];
120
- description: string;
121
- schema: TSchema;
122
- }>;
123
- protected readonly onConfigure: HookDescriptor<"configure">;
124
- protected readonly onReady: HookDescriptor<"ready">;
111
+ protected readonly globalFlags: {
112
+ help: {
113
+ aliases: string[];
114
+ description: string;
115
+ schema: _sinclair_typebox0.TBoolean;
116
+ };
117
+ };
118
+ protected readonly onReady: _alepha_core0$1.HookDescriptor<"ready">;
119
+ get commands(): CommandDescriptor<any>[];
125
120
  private findCommand;
126
121
  protected parseCommandFlags(argv: string[], schema: TObject): Record<string, any>;
127
122
  protected parseFlags(argv: string[], flagDefs: {
@@ -135,20 +130,18 @@ declare class CommandDescriptorProvider {
135
130
  }
136
131
  //#endregion
137
132
  //#region src/index.d.ts
138
- // ---------------------------------------------------------------------------------------------------------------------
139
133
  /**
140
- * Alepha Command Module
141
- *
142
- * This module provides a powerful way to build command-line interfaces
143
- * directly within your Alepha application, using declarative descriptors.
144
- *
145
- * @see {@link $command}
146
- * @module alepha.command
147
- */
148
- declare class AlephaCommand implements Module {
149
- readonly name = "alepha.command";
150
- readonly $services: (alepha: Alepha) => Alepha;
151
- }
134
+ * This module provides a powerful way to build command-line interfaces
135
+ * directly within your Alepha application, using declarative descriptors.
136
+ *
137
+ * It allows you to define commands using the `$command` descriptor.
138
+ *
139
+ * @see {@link $command}
140
+ * @module alepha.command
141
+ */
142
+ declare const AlephaCommand: _alepha_core0.ModuleDescriptor;
143
+ //# sourceMappingURL=index.d.ts.map
144
+
152
145
  //#endregion
153
- export { $command, AlephaCommand, CommandDescriptor, CommandDescriptorOptions, CommandDescriptorProvider, CommandError, Runner, RunnerMethod, Task };
146
+ export { $command, AlephaCommand, CliProvider, CommandDescriptor, CommandDescriptorOptions, CommandError, CommandHandlerArgs, Runner, RunnerMethod, Task };
154
147
  //# sourceMappingURL=index.d.ts.map