alepha 0.7.6 → 0.8.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.
- package/LICENSE +21 -21
- package/README.md +44 -44
- package/batch.cjs +8 -0
- package/batch.d.ts +114 -0
- package/batch.js +1 -0
- package/cache/redis.d.ts +15 -18
- package/cache.d.ts +115 -119
- package/command.cjs +8 -0
- package/command.d.ts +154 -0
- package/command.js +1 -0
- package/core.d.ts +800 -795
- package/datetime.d.ts +76 -76
- package/lock/redis.d.ts +12 -12
- package/lock.d.ts +70 -75
- package/package.json +102 -29
- package/postgres.d.ts +385 -278
- package/queue/redis.d.ts +15 -13
- package/queue.d.ts +16 -13
- package/react/auth.d.ts +16 -16
- package/react/head.cjs +8 -0
- package/react/head.d.ts +92 -0
- package/react/head.js +1 -0
- package/react.d.ts +90 -116
- package/redis.d.ts +20 -27
- package/retry.d.ts +74 -54
- package/scheduler.d.ts +14 -13
- package/security.d.ts +38 -41
- package/server/cache.d.ts +9 -7
- package/server/compress.cjs +8 -0
- package/server/compress.d.ts +26 -0
- package/server/compress.js +1 -0
- package/server/cookies.d.ts +71 -14
- package/server/cors.cjs +8 -0
- package/server/cors.d.ts +29 -0
- package/server/cors.js +1 -0
- package/server/health.cjs +8 -0
- package/server/health.d.ts +42 -0
- package/server/health.js +1 -0
- package/server/helmet.cjs +8 -0
- package/server/helmet.d.ts +72 -0
- package/server/helmet.js +1 -0
- package/server/links.cjs +8 -0
- package/server/links.d.ts +179 -0
- package/server/links.js +1 -0
- package/server/metrics.cjs +8 -0
- package/server/metrics.d.ts +37 -0
- package/server/metrics.js +1 -0
- package/server/multipart.cjs +8 -0
- package/server/multipart.d.ts +48 -0
- package/server/multipart.js +1 -0
- package/server/proxy.cjs +8 -0
- package/server/proxy.d.ts +41 -0
- package/server/proxy.js +1 -0
- package/server/static.d.ts +63 -51
- package/server/swagger.d.ts +50 -50
- package/server.d.ts +220 -437
- package/topic/redis.d.ts +24 -23
- package/topic.d.ts +9 -19
- package/vite.d.ts +8 -1
package/command.d.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Alepha, AlephaError, Async, HookDescriptor, KIND, Logger, Module, OPTIONS, Static, TObject, TProperties, TSchema, TString } from "alepha";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import { glob } from "node:fs/promises";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/Runner.d.ts
|
|
6
|
+
type Task = {
|
|
7
|
+
name: string;
|
|
8
|
+
handler: () => any;
|
|
9
|
+
};
|
|
10
|
+
interface Timer {
|
|
11
|
+
name: string;
|
|
12
|
+
duration: string;
|
|
13
|
+
}
|
|
14
|
+
interface RunnerMethod {
|
|
15
|
+
(cmd: string | Array<string | Task>, fn?: () => any): Promise<string>;
|
|
16
|
+
rm: (glob: string | string[]) => Promise<string>;
|
|
17
|
+
}
|
|
18
|
+
declare class Runner {
|
|
19
|
+
protected readonly log: Logger;
|
|
20
|
+
protected readonly timers: Timer[];
|
|
21
|
+
protected readonly startTime: number;
|
|
22
|
+
readonly run: RunnerMethod;
|
|
23
|
+
constructor(log: Logger);
|
|
24
|
+
protected exec(cmd: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Executes one or more tasks.
|
|
27
|
+
*
|
|
28
|
+
* @param task - A single task or an array of tasks to run in parallel.
|
|
29
|
+
*/
|
|
30
|
+
protected execute(task: Task | Task[]): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Prints a summary of all executed tasks and their durations.
|
|
33
|
+
*/
|
|
34
|
+
summary(): void;
|
|
35
|
+
protected executeTask(task: Task): Promise<string>;
|
|
36
|
+
protected renderTable(data: string[][]): void;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/descriptors/$command.d.ts
|
|
40
|
+
declare const KEY = "COMMAND";
|
|
41
|
+
interface CommandDescriptorOptions<T extends TObject> {
|
|
42
|
+
/**
|
|
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>;
|
|
51
|
+
/**
|
|
52
|
+
* The name of the command. If omitted, the property key is used.
|
|
53
|
+
*
|
|
54
|
+
* An empty string "" denotes the root command.
|
|
55
|
+
*/
|
|
56
|
+
name?: string;
|
|
57
|
+
/**
|
|
58
|
+
* A short description of the command, shown in the help message.
|
|
59
|
+
*/
|
|
60
|
+
description?: string;
|
|
61
|
+
/**
|
|
62
|
+
* An array of alternative names for the command.
|
|
63
|
+
*/
|
|
64
|
+
aliases?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* A TypeBox object schema defining the flags for the command.
|
|
67
|
+
*/
|
|
68
|
+
flags?: T;
|
|
69
|
+
}
|
|
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
|
+
}
|
|
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
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/errors/CommandError.d.ts
|
|
90
|
+
declare class CommandError extends AlephaError {}
|
|
91
|
+
//#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
|
+
}
|
|
101
|
+
declare const envSchema: TObject<{
|
|
102
|
+
CLI_NAME: TString;
|
|
103
|
+
CLI_DESCRIPTION: TString;
|
|
104
|
+
}>;
|
|
105
|
+
declare module "alepha" {
|
|
106
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
107
|
+
}
|
|
108
|
+
declare class CommandDescriptorProvider {
|
|
109
|
+
protected readonly env: Static<typeof envSchema>;
|
|
110
|
+
protected readonly alepha: Alepha;
|
|
111
|
+
protected readonly log: Logger;
|
|
112
|
+
protected commands: Command[];
|
|
113
|
+
options: {
|
|
114
|
+
name: string;
|
|
115
|
+
description: string;
|
|
116
|
+
argv: string[];
|
|
117
|
+
};
|
|
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">;
|
|
125
|
+
private findCommand;
|
|
126
|
+
protected parseCommandFlags(argv: string[], schema: TObject): Record<string, any>;
|
|
127
|
+
protected parseFlags(argv: string[], flagDefs: {
|
|
128
|
+
key: string;
|
|
129
|
+
aliases: string[];
|
|
130
|
+
schema: TSchema;
|
|
131
|
+
}[]): Record<string, any>;
|
|
132
|
+
private printHelp;
|
|
133
|
+
private getMaxCmdLength;
|
|
134
|
+
private getMaxFlagLength;
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/index.d.ts
|
|
138
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
139
|
+
/**
|
|
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
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { $command, AlephaCommand, CommandDescriptor, CommandDescriptorOptions, CommandDescriptorProvider, CommandError, Runner, RunnerMethod, Task };
|
|
154
|
+
//# sourceMappingURL=index.d.ts.map
|
package/command.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/command'
|