alepha 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/files.d.ts +1 -439
- package/api/jobs.d.ts +1 -218
- package/api/notifications.d.ts +1 -264
- package/api/users.d.ts +1 -924
- package/batch.d.ts +1 -585
- package/bucket.d.ts +1 -507
- package/cache/redis.d.ts +1 -40
- package/cache.d.ts +1 -288
- package/command.d.ts +1 -238
- package/core.d.ts +1 -1564
- package/datetime.d.ts +2 -1
- package/devtools.d.ts +1 -368
- package/email.d.ts +1 -144
- package/fake.cjs +8 -0
- package/fake.d.ts +1 -0
- package/fake.js +1 -0
- package/file.d.ts +1 -53
- package/lock/redis.d.ts +1 -24
- package/lock.d.ts +1 -552
- package/logger.d.ts +1 -284
- package/package.json +63 -49
- package/postgres.d.ts +1 -1931
- package/queue/redis.d.ts +1 -29
- package/queue.d.ts +1 -760
- package/react/auth.d.ts +1 -499
- package/react/form.d.ts +1 -188
- package/react/head.d.ts +1 -120
- package/react/i18n.d.ts +1 -143
- package/react.d.ts +1 -929
- package/redis.d.ts +1 -82
- package/scheduler.d.ts +1 -145
- package/security.d.ts +1 -586
- package/server/cache.d.ts +1 -163
- package/server/compress.d.ts +1 -32
- package/server/cookies.d.ts +1 -144
- package/server/cors.d.ts +1 -27
- package/server/health.d.ts +1 -59
- package/server/helmet.d.ts +1 -69
- package/server/links.d.ts +1 -316
- package/server/metrics.d.ts +1 -35
- package/server/multipart.d.ts +1 -42
- package/server/proxy.d.ts +1 -234
- package/server/security.d.ts +1 -87
- package/server/static.d.ts +1 -119
- package/server/swagger.d.ts +1 -148
- package/server.d.ts +1 -849
- package/topic/redis.d.ts +1 -42
- package/topic.d.ts +1 -819
- package/ui.cjs +8 -0
- package/ui.d.ts +1 -0
- package/ui.js +1 -0
- package/vite.d.ts +1 -197
package/cache.d.ts
CHANGED
|
@@ -1,288 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Descriptor, InstantiableClass, KIND } from "alepha";
|
|
3
|
-
import { DateTimeProvider, DurationLike, Timeout } from "alepha/datetime";
|
|
4
|
-
import * as _alepha_logger0 from "alepha/logger";
|
|
5
|
-
|
|
6
|
-
//#region src/providers/CacheProvider.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Cache provider interface.
|
|
9
|
-
*
|
|
10
|
-
* All methods are asynchronous and return promises.
|
|
11
|
-
* Values are stored as Uint8Array.
|
|
12
|
-
*/
|
|
13
|
-
declare abstract class CacheProvider {
|
|
14
|
-
/**
|
|
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
|
-
*/
|
|
22
|
-
abstract get(name: string, key: string): Promise<Uint8Array | undefined>;
|
|
23
|
-
/**
|
|
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
|
-
*/
|
|
33
|
-
abstract set(name: string, key: string, value: Uint8Array, ttl?: number): Promise<Uint8Array>;
|
|
34
|
-
/**
|
|
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
|
-
*/
|
|
40
|
-
abstract del(name: string, ...keys: string[]): Promise<void>;
|
|
41
|
-
abstract has(name: string, key: string): Promise<boolean>;
|
|
42
|
-
abstract keys(name: string, filter?: string): Promise<string[]>;
|
|
43
|
-
/**
|
|
44
|
-
* Remove all keys from all cache names.
|
|
45
|
-
*/
|
|
46
|
-
abstract clear(): Promise<void>;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/descriptors/$cache.d.ts
|
|
50
|
-
/**
|
|
51
|
-
* Creates a cache descriptor for high-performance data caching with automatic cache management.
|
|
52
|
-
*
|
|
53
|
-
* This descriptor provides a powerful caching layer that can significantly improve application performance
|
|
54
|
-
* by storing frequently accessed data in memory or external cache stores like Redis. It supports both
|
|
55
|
-
* function result caching and manual cache operations with intelligent serialization and TTL management.
|
|
56
|
-
*
|
|
57
|
-
* **Key Features**
|
|
58
|
-
*
|
|
59
|
-
* - **Function Result Caching**: Automatically cache function results based on input parameters
|
|
60
|
-
* - **Multiple Storage Backends**: Support for in-memory, Redis, and custom cache providers
|
|
61
|
-
* - **Intelligent Serialization**: Automatic handling of JSON, strings, and binary data
|
|
62
|
-
* - **TTL Management**: Configurable time-to-live with automatic expiration
|
|
63
|
-
* - **Cache Invalidation**: Pattern-based cache invalidation with wildcard support
|
|
64
|
-
* - **Environment Controls**: Enable/disable caching via environment variables
|
|
65
|
-
* - **Type Safety**: Full TypeScript support with generic type parameters
|
|
66
|
-
*
|
|
67
|
-
* ## Cache Strategies
|
|
68
|
-
*
|
|
69
|
-
* ### 1. Function Result Caching (Memoization)
|
|
70
|
-
* Automatically cache the results of expensive operations based on input parameters.
|
|
71
|
-
*
|
|
72
|
-
* ### 2. Manual Cache Operations
|
|
73
|
-
* Direct cache operations for custom caching logic and data storage.
|
|
74
|
-
*
|
|
75
|
-
* ## Storage Backends
|
|
76
|
-
*
|
|
77
|
-
* - **Memory**: Fast in-memory cache (default for development)
|
|
78
|
-
* - **Redis**: Distributed cache for production environments
|
|
79
|
-
* - **Custom Providers**: Implement your own cache storage backend
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* **Basic function result caching:**
|
|
83
|
-
* ```ts
|
|
84
|
-
* import { $cache } from "alepha/cache";
|
|
85
|
-
*
|
|
86
|
-
* class DataService {
|
|
87
|
-
* // Cache expensive database queries
|
|
88
|
-
* getUserData = $cache({
|
|
89
|
-
* name: "user-data",
|
|
90
|
-
* ttl: [10, "minutes"],
|
|
91
|
-
* handler: async (userId: string) => {
|
|
92
|
-
* // Expensive database operation
|
|
93
|
-
* return await database.users.findById(userId);
|
|
94
|
-
* }
|
|
95
|
-
* });
|
|
96
|
-
*
|
|
97
|
-
* async getUser(id: string) {
|
|
98
|
-
* // This will hit cache on subsequent calls with same ID
|
|
99
|
-
* return await this.getUserData(id);
|
|
100
|
-
* }
|
|
101
|
-
* }
|
|
102
|
-
* ```
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* **API response caching with custom key generation:**
|
|
106
|
-
* ```ts
|
|
107
|
-
* class ApiService {
|
|
108
|
-
* fetchUserPosts = $cache({
|
|
109
|
-
* name: "user-posts",
|
|
110
|
-
* ttl: [5, "minutes"],
|
|
111
|
-
* key: (userId: string, page: number) => `${userId}:page:${page}`,
|
|
112
|
-
* handler: async (userId: string, page: number = 1) => {
|
|
113
|
-
* const response = await fetch(`/api/users/${userId}/posts?page=${page}`);
|
|
114
|
-
* return await response.json();
|
|
115
|
-
* }
|
|
116
|
-
* });
|
|
117
|
-
* }
|
|
118
|
-
* ```
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* **Manual cache operations for custom logic:**
|
|
122
|
-
* ```ts
|
|
123
|
-
* class SessionService {
|
|
124
|
-
* sessionCache = $cache<UserSession>({
|
|
125
|
-
* name: "user-sessions",
|
|
126
|
-
* ttl: [1, "hour"],
|
|
127
|
-
* provider: "memory" // Use memory cache for sessions
|
|
128
|
-
* });
|
|
129
|
-
*
|
|
130
|
-
* async storeSession(sessionId: string, session: UserSession) {
|
|
131
|
-
* await this.sessionCache.set(sessionId, session);
|
|
132
|
-
* }
|
|
133
|
-
*
|
|
134
|
-
* async getSession(sessionId: string): Promise<UserSession | undefined> {
|
|
135
|
-
* return await this.sessionCache.get(sessionId);
|
|
136
|
-
* }
|
|
137
|
-
*
|
|
138
|
-
* async invalidateUserSessions(userId: string) {
|
|
139
|
-
* // Invalidate all sessions for a user using wildcards
|
|
140
|
-
* await this.sessionCache.invalidate(`user:${userId}:*`);
|
|
141
|
-
* }
|
|
142
|
-
* }
|
|
143
|
-
* ```
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* **Redis-backed caching for production:**
|
|
147
|
-
* ```ts
|
|
148
|
-
* class ProductService {
|
|
149
|
-
* productCache = $cache({
|
|
150
|
-
* name: "products",
|
|
151
|
-
* ttl: [1, "hour"],
|
|
152
|
-
* provider: RedisCacheProvider, // Use Redis for distributed caching
|
|
153
|
-
* handler: async (productId: string) => {
|
|
154
|
-
* return await this.database.products.findById(productId);
|
|
155
|
-
* }
|
|
156
|
-
* });
|
|
157
|
-
*
|
|
158
|
-
* async invalidateProduct(productId: string) {
|
|
159
|
-
* await this.productCache.invalidate(productId);
|
|
160
|
-
* }
|
|
161
|
-
*
|
|
162
|
-
* async invalidateAllProducts() {
|
|
163
|
-
* await this.productCache.invalidate("*");
|
|
164
|
-
* }
|
|
165
|
-
* }
|
|
166
|
-
* ```
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* **Conditional caching with environment controls:**
|
|
170
|
-
* ```ts
|
|
171
|
-
* class ExpensiveService {
|
|
172
|
-
* computation = $cache({
|
|
173
|
-
* name: "heavy-computation",
|
|
174
|
-
* ttl: [1, "day"],
|
|
175
|
-
* disabled: process.env.NODE_ENV === "development", // Disable in dev
|
|
176
|
-
* handler: async (input: ComplexInput) => {
|
|
177
|
-
* // Very expensive computation that should be cached in production
|
|
178
|
-
* return await performHeavyComputation(input);
|
|
179
|
-
* }
|
|
180
|
-
* });
|
|
181
|
-
* }
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
declare const $cache: {
|
|
185
|
-
<TReturn = string, TParameter extends any[] = any[]>(options?: CacheDescriptorOptions<TReturn, TParameter>): CacheDescriptorFn<TReturn, TParameter>;
|
|
186
|
-
[KIND]: typeof CacheDescriptor;
|
|
187
|
-
};
|
|
188
|
-
interface CacheDescriptorOptions<TReturn = any, TParameter extends any[] = any[]> {
|
|
189
|
-
/**
|
|
190
|
-
* The cache name. This is useful for invalidating multiple caches at once.
|
|
191
|
-
*
|
|
192
|
-
* Store key as `cache:$name:$key`.
|
|
193
|
-
*
|
|
194
|
-
* @default Name of the key of the class.
|
|
195
|
-
*/
|
|
196
|
-
name?: string;
|
|
197
|
-
/**
|
|
198
|
-
* Function which returns cached data.
|
|
199
|
-
*/
|
|
200
|
-
handler?: (...args: TParameter) => TReturn;
|
|
201
|
-
/**
|
|
202
|
-
* The key generator for the cache.
|
|
203
|
-
* If not provided, the arguments will be json.stringify().
|
|
204
|
-
*/
|
|
205
|
-
key?: (...args: TParameter) => string;
|
|
206
|
-
/**
|
|
207
|
-
* The store provider for the cache.
|
|
208
|
-
* If not provided, the default store provider will be used.
|
|
209
|
-
*/
|
|
210
|
-
provider?: InstantiableClass<CacheProvider> | "memory";
|
|
211
|
-
/**
|
|
212
|
-
* The time-to-live for the cache in seconds.
|
|
213
|
-
* Set 0 to skip expiration.
|
|
214
|
-
*
|
|
215
|
-
* @default 300 (5 minutes).
|
|
216
|
-
*/
|
|
217
|
-
ttl?: DurationLike;
|
|
218
|
-
/**
|
|
219
|
-
* If the cache is disabled.
|
|
220
|
-
*/
|
|
221
|
-
disabled?: boolean;
|
|
222
|
-
}
|
|
223
|
-
declare class CacheDescriptor<TReturn = any, TParameter extends any[] = any[]> extends Descriptor<CacheDescriptorOptions<TReturn, TParameter>> {
|
|
224
|
-
protected readonly env: {
|
|
225
|
-
CACHE_ENABLED: boolean;
|
|
226
|
-
CACHE_DEFAULT_TTL: number;
|
|
227
|
-
};
|
|
228
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
229
|
-
protected readonly provider: CacheProvider;
|
|
230
|
-
protected encoder: TextEncoder;
|
|
231
|
-
protected decoder: TextDecoder;
|
|
232
|
-
protected codes: {
|
|
233
|
-
BINARY: number;
|
|
234
|
-
JSON: number;
|
|
235
|
-
STRING: number;
|
|
236
|
-
};
|
|
237
|
-
get container(): string;
|
|
238
|
-
run(...args: TParameter): Promise<TReturn>;
|
|
239
|
-
key(...args: TParameter): string;
|
|
240
|
-
invalidate(...keys: string[]): Promise<void>;
|
|
241
|
-
set(key: string, value: TReturn, ttl?: DurationLike): Promise<void>;
|
|
242
|
-
get(key: string): Promise<TReturn | undefined>;
|
|
243
|
-
protected serialize<TReturn>(value: TReturn): Uint8Array;
|
|
244
|
-
protected deserialize<TReturn>(uint8Array: Uint8Array): Promise<TReturn>;
|
|
245
|
-
protected $provider(): CacheProvider;
|
|
246
|
-
}
|
|
247
|
-
interface CacheDescriptorFn<TReturn = any, TParameter extends any[] = any[]> extends CacheDescriptor<TReturn, TParameter> {
|
|
248
|
-
/**
|
|
249
|
-
* Run the cache descriptor with the provided arguments.
|
|
250
|
-
*/
|
|
251
|
-
(...args: TParameter): Promise<TReturn>;
|
|
252
|
-
}
|
|
253
|
-
//#endregion
|
|
254
|
-
//#region src/providers/MemoryCacheProvider.d.ts
|
|
255
|
-
type CacheName = string;
|
|
256
|
-
type CacheKey = string;
|
|
257
|
-
type CacheValue = {
|
|
258
|
-
data?: Uint8Array;
|
|
259
|
-
timeout?: Timeout;
|
|
260
|
-
};
|
|
261
|
-
declare class MemoryCacheProvider implements CacheProvider {
|
|
262
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
263
|
-
protected readonly log: _alepha_logger0.Logger;
|
|
264
|
-
protected store: Record<CacheName, Record<CacheKey, CacheValue>>;
|
|
265
|
-
get(name: string, key: string): Promise<Uint8Array | undefined>;
|
|
266
|
-
set(name: string, key: string, value: Uint8Array, ttl?: number): Promise<Uint8Array>;
|
|
267
|
-
del(name: string, ...keys: string[]): Promise<void>;
|
|
268
|
-
has(name: string, key: string): Promise<boolean>;
|
|
269
|
-
keys(name: string, filter?: string): Promise<string[]>;
|
|
270
|
-
clear(): Promise<void>;
|
|
271
|
-
}
|
|
272
|
-
//#endregion
|
|
273
|
-
//#region src/index.d.ts
|
|
274
|
-
/**
|
|
275
|
-
* Provides high-performance caching capabilities for Alepha applications with configurable TTL and multiple storage backends.
|
|
276
|
-
*
|
|
277
|
-
* The cache module enables declarative caching through the `$cache` descriptor, allowing you to cache method results,
|
|
278
|
-
* API responses, or computed values with automatic invalidation and type safety. It supports both in-memory and
|
|
279
|
-
* persistent storage backends for different performance and durability requirements.
|
|
280
|
-
*
|
|
281
|
-
* @see {@link $cache}
|
|
282
|
-
* @see {@link CacheProvider}
|
|
283
|
-
* @module alepha.cache
|
|
284
|
-
*/
|
|
285
|
-
declare const AlephaCache: _alepha_core0.Service<_alepha_core0.Module<{}>>;
|
|
286
|
-
//#endregion
|
|
287
|
-
export { $cache, AlephaCache, CacheDescriptor, CacheDescriptorFn, CacheDescriptorOptions, CacheProvider, MemoryCacheProvider };
|
|
288
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export * from '@alepha/cache';
|
package/command.d.ts
CHANGED
|
@@ -1,238 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Alepha, AlephaError, Async, Descriptor, KIND, Static, TObject, TSchema, TString } from "alepha";
|
|
3
|
-
import * as _alepha_logger0 from "alepha/logger";
|
|
4
|
-
import * as fs from "node:fs/promises";
|
|
5
|
-
import { glob } from "node:fs/promises";
|
|
6
|
-
import * as readline_promises0 from "readline/promises";
|
|
7
|
-
import * as typebox0 from "typebox";
|
|
8
|
-
|
|
9
|
-
//#region src/helpers/Asker.d.ts
|
|
10
|
-
interface AskOptions<T extends TSchema = TString> {
|
|
11
|
-
/**
|
|
12
|
-
* Response schema expected.
|
|
13
|
-
*
|
|
14
|
-
* Recommended schemas:
|
|
15
|
-
* - t.text() - for free text input
|
|
16
|
-
* - t.number() - for numeric input
|
|
17
|
-
* - t.boolean() - for yes/no input (accepts "true", "false", "1", "0")
|
|
18
|
-
* - t.enum(["option1", "option2"]) - for predefined options
|
|
19
|
-
*
|
|
20
|
-
* You can use schema.default to provide a default value.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* ask("What is your name?", { schema: t.text({ default: "John Doe" }) })
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @default TString
|
|
28
|
-
*/
|
|
29
|
-
schema?: T;
|
|
30
|
-
/**
|
|
31
|
-
* Custom validation function.
|
|
32
|
-
* Throws an AlephaError in case of validation failure.
|
|
33
|
-
*/
|
|
34
|
-
validate?: (value: Static<T>) => void;
|
|
35
|
-
}
|
|
36
|
-
interface AskMethod {
|
|
37
|
-
<T extends TSchema = TString>(question: string, options?: AskOptions<T>): Promise<Static<T>>;
|
|
38
|
-
}
|
|
39
|
-
declare class Asker {
|
|
40
|
-
protected readonly log: _alepha_logger0.Logger;
|
|
41
|
-
readonly ask: AskMethod;
|
|
42
|
-
protected readonly alepha: Alepha;
|
|
43
|
-
constructor();
|
|
44
|
-
protected createAskMethod(): AskMethod;
|
|
45
|
-
protected prompt<T extends TSchema = TString>(question: string, options: AskOptions<T>): Promise<Static<T>>;
|
|
46
|
-
protected createPromptInterface(): readline_promises0.Interface;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/helpers/Runner.d.ts
|
|
50
|
-
type Task = {
|
|
51
|
-
name: string;
|
|
52
|
-
handler: () => any;
|
|
53
|
-
};
|
|
54
|
-
interface Timer {
|
|
55
|
-
name: string;
|
|
56
|
-
duration: string;
|
|
57
|
-
}
|
|
58
|
-
interface RunOptions {
|
|
59
|
-
/**
|
|
60
|
-
* Rename the command for logging purposes.
|
|
61
|
-
*/
|
|
62
|
-
alias?: string;
|
|
63
|
-
}
|
|
64
|
-
interface RunnerMethod {
|
|
65
|
-
(cmd: string | Task | Array<string | Task>, options?: RunOptions | (() => any)): Promise<string>;
|
|
66
|
-
rm: (glob: string | string[], options?: RunOptions) => Promise<string>;
|
|
67
|
-
cp: (source: string, dest: string, options?: RunOptions) => Promise<string>;
|
|
68
|
-
}
|
|
69
|
-
declare class Runner {
|
|
70
|
-
protected readonly log: _alepha_logger0.Logger;
|
|
71
|
-
protected readonly timers: Timer[];
|
|
72
|
-
protected readonly startTime: number;
|
|
73
|
-
readonly run: RunnerMethod;
|
|
74
|
-
constructor();
|
|
75
|
-
protected createRunMethod(): RunnerMethod;
|
|
76
|
-
protected exec(cmd: string): Promise<string>;
|
|
77
|
-
/**
|
|
78
|
-
* Executes one or more tasks.
|
|
79
|
-
*
|
|
80
|
-
* @param task - A single task or an array of tasks to run in parallel.
|
|
81
|
-
*/
|
|
82
|
-
protected execute(task: Task | Task[]): Promise<string>;
|
|
83
|
-
/**
|
|
84
|
-
* Prints a summary of all executed tasks and their durations.
|
|
85
|
-
*/
|
|
86
|
-
summary(): void;
|
|
87
|
-
protected executeTask(task: Task): Promise<string>;
|
|
88
|
-
protected renderTable(data: string[][]): void;
|
|
89
|
-
}
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/descriptors/$command.d.ts
|
|
92
|
-
/**
|
|
93
|
-
* Declares a CLI command.
|
|
94
|
-
*
|
|
95
|
-
* This descriptor allows you to define a command, its flags, and its handler
|
|
96
|
-
* within your Alepha application structure.
|
|
97
|
-
*/
|
|
98
|
-
declare const $command: {
|
|
99
|
-
<T extends TObject, A extends TSchema>(options: CommandDescriptorOptions<T, A>): CommandDescriptor<T, A>;
|
|
100
|
-
[KIND]: typeof CommandDescriptor;
|
|
101
|
-
};
|
|
102
|
-
interface CommandDescriptorOptions<T extends TObject, A extends TSchema> {
|
|
103
|
-
/**
|
|
104
|
-
* The handler function to execute when the command is matched.
|
|
105
|
-
*/
|
|
106
|
-
handler: (args: CommandHandlerArgs<T, A>) => Async<void>;
|
|
107
|
-
/**
|
|
108
|
-
* The name of the command. If omitted, the property key is used.
|
|
109
|
-
*
|
|
110
|
-
* An empty string "" denotes the root command.
|
|
111
|
-
*/
|
|
112
|
-
name?: string;
|
|
113
|
-
/**
|
|
114
|
-
* A short description of the command, shown in the help message.
|
|
115
|
-
*/
|
|
116
|
-
description?: string;
|
|
117
|
-
/**
|
|
118
|
-
* An array of alternative names for the command.
|
|
119
|
-
*/
|
|
120
|
-
aliases?: string[];
|
|
121
|
-
/**
|
|
122
|
-
* A TypeBox object schema defining the flags for the command.
|
|
123
|
-
*/
|
|
124
|
-
flags?: T;
|
|
125
|
-
/**
|
|
126
|
-
* An optional TypeBox schema defining the arguments for the command.
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* args: t.text()
|
|
130
|
-
* my-cli command <arg1: string>
|
|
131
|
-
*
|
|
132
|
-
* args: t.optional(t.text())
|
|
133
|
-
* my-cli command [arg1: string]
|
|
134
|
-
*
|
|
135
|
-
* args: t.tuple([t.text(), t.number()])
|
|
136
|
-
* my-cli command <arg1: string> <arg2: number>
|
|
137
|
-
*
|
|
138
|
-
* args: t.tuple([t.text(), t.optional(t.number())])
|
|
139
|
-
* my-cli command <arg1: string> [arg2: number]
|
|
140
|
-
*/
|
|
141
|
-
args?: A;
|
|
142
|
-
/**
|
|
143
|
-
* If false, skip summary message at the end of the command execution.
|
|
144
|
-
*/
|
|
145
|
-
summary?: boolean;
|
|
146
|
-
}
|
|
147
|
-
declare class CommandDescriptor<T extends TObject = TObject, A extends TSchema = TSchema> extends Descriptor<CommandDescriptorOptions<T, A>> {
|
|
148
|
-
readonly flags: TObject<{}>;
|
|
149
|
-
readonly aliases: string[];
|
|
150
|
-
get name(): string;
|
|
151
|
-
}
|
|
152
|
-
interface CommandHandlerArgs<T extends TObject, A extends TSchema = TSchema> {
|
|
153
|
-
flags: Static<T>;
|
|
154
|
-
args: A extends TSchema ? Static<A> : Array<string>;
|
|
155
|
-
run: RunnerMethod;
|
|
156
|
-
ask: AskMethod;
|
|
157
|
-
glob: typeof glob;
|
|
158
|
-
fs: typeof fs;
|
|
159
|
-
}
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region src/errors/CommandError.d.ts
|
|
162
|
-
declare class CommandError extends AlephaError {
|
|
163
|
-
readonly name = "CommandError";
|
|
164
|
-
}
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region src/providers/CliProvider.d.ts
|
|
167
|
-
declare const envSchema: TObject<{
|
|
168
|
-
CLI_NAME: _alepha_core1.TString;
|
|
169
|
-
CLI_DESCRIPTION: _alepha_core1.TString;
|
|
170
|
-
}>;
|
|
171
|
-
declare module "alepha" {
|
|
172
|
-
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
173
|
-
}
|
|
174
|
-
declare class CliProvider {
|
|
175
|
-
protected readonly env: {
|
|
176
|
-
CLI_NAME: string;
|
|
177
|
-
CLI_DESCRIPTION: string;
|
|
178
|
-
};
|
|
179
|
-
protected readonly alepha: Alepha;
|
|
180
|
-
protected readonly log: _alepha_logger0.Logger;
|
|
181
|
-
protected readonly runner: Runner;
|
|
182
|
-
protected readonly asker: Asker;
|
|
183
|
-
options: {
|
|
184
|
-
name: string;
|
|
185
|
-
description: string;
|
|
186
|
-
argv: string[];
|
|
187
|
-
};
|
|
188
|
-
protected readonly globalFlags: {
|
|
189
|
-
help: {
|
|
190
|
-
aliases: string[];
|
|
191
|
-
description: string;
|
|
192
|
-
schema: typebox0.TBoolean;
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
protected readonly onReady: _alepha_core1.HookDescriptor<"ready">;
|
|
196
|
-
get commands(): CommandDescriptor<any>[];
|
|
197
|
-
private findCommand;
|
|
198
|
-
protected parseCommandFlags(argv: string[], schema: TObject): Record<string, any>;
|
|
199
|
-
protected parseFlags(argv: string[], flagDefs: {
|
|
200
|
-
key: string;
|
|
201
|
-
aliases: string[];
|
|
202
|
-
schema: TSchema;
|
|
203
|
-
}[]): Record<string, any>;
|
|
204
|
-
protected parseCommandArgs(argv: string[], schema?: TSchema): any;
|
|
205
|
-
protected parseArgumentValue(value: string, schema: TSchema): any;
|
|
206
|
-
protected generateArgsUsage(schema?: TSchema): string;
|
|
207
|
-
protected getTypeName(schema: TSchema): string;
|
|
208
|
-
printHelp(command?: CommandDescriptor<any>): void;
|
|
209
|
-
private getMaxCmdLength;
|
|
210
|
-
private getMaxFlagLength;
|
|
211
|
-
}
|
|
212
|
-
//#endregion
|
|
213
|
-
//#region src/index.d.ts
|
|
214
|
-
/**
|
|
215
|
-
* This module provides a powerful way to build command-line interfaces
|
|
216
|
-
* directly within your Alepha application, using declarative descriptors.
|
|
217
|
-
*
|
|
218
|
-
* It allows you to define commands using the `$command` descriptor.
|
|
219
|
-
*
|
|
220
|
-
* @see {@link $command}
|
|
221
|
-
* @module alepha.command
|
|
222
|
-
*/
|
|
223
|
-
declare const AlephaCommand: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
224
|
-
declare module "typebox" {
|
|
225
|
-
interface StringOptions {
|
|
226
|
-
/**
|
|
227
|
-
* Additional aliases for the flags.
|
|
228
|
-
*
|
|
229
|
-
* @module alepha.command
|
|
230
|
-
*/
|
|
231
|
-
aliases?: string[];
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
//# sourceMappingURL=index.d.ts.map
|
|
235
|
-
|
|
236
|
-
//#endregion
|
|
237
|
-
export { $command, AlephaCommand, AskMethod, AskOptions, Asker, CliProvider, CommandDescriptor, CommandDescriptorOptions, CommandError, CommandHandlerArgs, RunOptions, Runner, RunnerMethod, Task };
|
|
238
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export * from '@alepha/command';
|