alepha 0.14.0 → 0.14.2
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/README.md +3 -3
- package/dist/api/audits/index.d.ts +80 -1
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts +80 -1
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +236 -157
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/notifications/index.d.ts +21 -1
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/parameters/index.d.ts +451 -4
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/users/index.d.ts +252 -249
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +4 -0
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +128 -128
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/batch/index.js.map +1 -1
- package/dist/cache/core/index.js.map +1 -1
- package/dist/cli/index.d.ts +304 -115
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +650 -531
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +210 -13
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +306 -69
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +7 -6
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +7 -6
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.js.map +1 -1
- package/dist/fake/index.js.map +1 -1
- package/dist/file/index.d.ts.map +1 -1
- package/dist/file/index.js.map +1 -1
- package/dist/lock/redis/index.js.map +1 -1
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/index.browser.js +26 -5
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.d.ts +294 -215
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +522 -523
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/redis/index.js +2 -4
- package/dist/queue/redis/index.js.map +1 -1
- package/dist/redis/index.d.ts +400 -29
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +412 -21
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.js.map +1 -1
- package/dist/router/index.js.map +1 -1
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +155 -155
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.js.map +1 -1
- package/dist/server/cookies/index.browser.js.map +1 -1
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.browser.js.map +1 -1
- package/dist/server/core/index.d.ts +0 -1
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/helmet/index.d.ts +4 -1
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/helmet/index.js.map +1 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/multipart/index.js.map +1 -1
- package/dist/server/proxy/index.js.map +1 -1
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/security/index.d.ts +9 -9
- package/dist/server/security/index.js.map +1 -1
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/core/index.js.map +1 -1
- package/dist/topic/redis/index.js +3 -3
- package/dist/topic/redis/index.js.map +1 -1
- package/dist/vite/index.js +9 -6
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +7 -7
- package/dist/websocket/index.js.map +1 -1
- package/package.json +3 -3
- package/src/api/users/index.ts +4 -0
- package/src/cli/apps/AlephaCli.ts +36 -14
- package/src/cli/apps/AlephaPackageBuilderCli.ts +5 -1
- package/src/cli/assets/appRouterTs.ts +1 -1
- package/src/cli/atoms/changelogOptions.ts +45 -0
- package/src/cli/commands/{ViteCommands.ts → build.ts} +4 -93
- package/src/cli/commands/changelog.ts +244 -0
- package/src/cli/commands/clean.ts +14 -0
- package/src/cli/commands/{DrizzleCommands.ts → db.ts} +37 -124
- package/src/cli/commands/deploy.ts +118 -0
- package/src/cli/commands/dev.ts +57 -0
- package/src/cli/commands/format.ts +17 -0
- package/src/cli/commands/{CoreCommands.ts → init.ts} +2 -40
- package/src/cli/commands/lint.ts +17 -0
- package/src/cli/commands/root.ts +32 -0
- package/src/cli/commands/run.ts +24 -0
- package/src/cli/commands/test.ts +42 -0
- package/src/cli/commands/typecheck.ts +19 -0
- package/src/cli/commands/{VerifyCommands.ts → verify.ts} +1 -13
- package/src/cli/defineConfig.ts +24 -0
- package/src/cli/index.ts +17 -5
- package/src/cli/services/AlephaCliUtils.ts +4 -21
- package/src/cli/services/GitMessageParser.ts +77 -0
- package/src/command/helpers/EnvUtils.ts +37 -0
- package/src/command/index.ts +3 -1
- package/src/command/primitives/$command.ts +172 -6
- package/src/command/providers/CliProvider.ts +424 -91
- package/src/core/Alepha.ts +8 -5
- package/src/file/providers/NodeFileSystemProvider.ts +3 -1
- package/src/orm/index.browser.ts +1 -1
- package/src/orm/index.ts +18 -10
- package/src/orm/interfaces/PgQueryWhere.ts +1 -26
- package/src/orm/providers/{PostgresTypeProvider.ts → DatabaseTypeProvider.ts} +25 -3
- package/src/orm/providers/drivers/BunPostgresProvider.ts +225 -0
- package/src/orm/providers/drivers/BunSqliteProvider.ts +180 -0
- package/src/orm/providers/drivers/DatabaseProvider.ts +25 -0
- package/src/orm/providers/drivers/NodePostgresProvider.ts +0 -25
- package/src/orm/services/QueryManager.ts +10 -125
- package/src/queue/redis/providers/RedisQueueProvider.ts +2 -7
- package/src/redis/index.ts +65 -3
- package/src/redis/providers/BunRedisProvider.ts +304 -0
- package/src/redis/providers/BunRedisSubscriberProvider.ts +94 -0
- package/src/redis/providers/NodeRedisProvider.ts +280 -0
- package/src/redis/providers/NodeRedisSubscriberProvider.ts +94 -0
- package/src/redis/providers/RedisProvider.ts +134 -140
- package/src/redis/providers/RedisSubscriberProvider.ts +58 -49
- package/src/server/core/providers/BunHttpServerProvider.ts +0 -3
- package/src/server/core/providers/ServerBodyParserProvider.ts +3 -1
- package/src/server/core/providers/ServerProvider.ts +7 -4
- package/src/server/multipart/providers/ServerMultipartProvider.ts +3 -1
- package/src/server/proxy/providers/ServerProxyProvider.ts +1 -1
- package/src/topic/redis/providers/RedisTopicProvider.ts +3 -3
- package/src/vite/tasks/buildServer.ts +1 -0
- package/src/cli/commands/BiomeCommands.ts +0 -29
- package/src/cli/commands/ChangelogCommands.ts +0 -389
- package/src/orm/services/PgJsonQueryManager.ts +0 -511
|
@@ -19,17 +19,29 @@ import type { RunnerMethod } from "../helpers/Runner.ts";
|
|
|
19
19
|
* This primitive allows you to define a command, its flags, and its handler
|
|
20
20
|
* within your Alepha application structure.
|
|
21
21
|
*/
|
|
22
|
-
export const $command = <
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export const $command = <
|
|
23
|
+
T extends TObject,
|
|
24
|
+
A extends TSchema,
|
|
25
|
+
E extends TObject,
|
|
26
|
+
>(
|
|
27
|
+
options: CommandPrimitiveOptions<T, A, E>,
|
|
28
|
+
) => createPrimitive(CommandPrimitive<T, A, E>, options);
|
|
25
29
|
|
|
26
30
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
27
31
|
|
|
28
|
-
export interface CommandPrimitiveOptions<
|
|
32
|
+
export interface CommandPrimitiveOptions<
|
|
33
|
+
T extends TObject,
|
|
34
|
+
A extends TSchema,
|
|
35
|
+
E extends TObject = TObject,
|
|
36
|
+
> {
|
|
29
37
|
/**
|
|
30
38
|
* The handler function to execute when the command is matched.
|
|
39
|
+
*
|
|
40
|
+
* For parent commands with children, the handler is called when:
|
|
41
|
+
* - The parent command is invoked without a subcommand
|
|
42
|
+
* - The parent command is invoked with --help (to show available subcommands)
|
|
31
43
|
*/
|
|
32
|
-
handler: (args: CommandHandlerArgs<T, A>) => Async<void>;
|
|
44
|
+
handler: (args: CommandHandlerArgs<T, A, E>) => Async<void>;
|
|
33
45
|
|
|
34
46
|
/**
|
|
35
47
|
* The name of the command. If omitted, the property key is used.
|
|
@@ -53,6 +65,28 @@ export interface CommandPrimitiveOptions<T extends TObject, A extends TSchema> {
|
|
|
53
65
|
*/
|
|
54
66
|
flags?: T;
|
|
55
67
|
|
|
68
|
+
/**
|
|
69
|
+
* A TypeBox object schema defining required environment variables.
|
|
70
|
+
*
|
|
71
|
+
* Environment variables are validated before the handler runs (fail fast).
|
|
72
|
+
* They are displayed in the help output under "Env:" section.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* $command({
|
|
77
|
+
* env: t.object({
|
|
78
|
+
* VERCEL_TOKEN: t.text({ description: "Vercel API token" }),
|
|
79
|
+
* VERCEL_ORG_ID: t.optional(t.text({ description: "Organization ID" })),
|
|
80
|
+
* }),
|
|
81
|
+
* handler: async ({ env }) => {
|
|
82
|
+
* // env.VERCEL_TOKEN is typed & guaranteed to exist
|
|
83
|
+
* console.log(env.VERCEL_TOKEN);
|
|
84
|
+
* }
|
|
85
|
+
* })
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
env?: E;
|
|
89
|
+
|
|
56
90
|
/**
|
|
57
91
|
* An optional TypeBox schema defining the arguments for the command.
|
|
58
92
|
*
|
|
@@ -137,6 +171,86 @@ export interface CommandPrimitiveOptions<T extends TObject, A extends TSchema> {
|
|
|
137
171
|
* If true, this command will be hidden from the help output.
|
|
138
172
|
*/
|
|
139
173
|
hide?: boolean;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Adds a `--mode, -m` flag to load environment files.
|
|
177
|
+
*
|
|
178
|
+
* When enabled:
|
|
179
|
+
* - Loads `.env` and `.env.local` by default
|
|
180
|
+
* - With `--mode production`, also loads `.env.production` and `.env.production.local`
|
|
181
|
+
* - The mode value is exposed in the handler as `mode: string | undefined`
|
|
182
|
+
*
|
|
183
|
+
* Set to `true` to enable with no default, or a string to set a default mode.
|
|
184
|
+
*
|
|
185
|
+
* This follows Vite's environment loading convention.
|
|
186
|
+
* @see https://vite.dev/guide/env-and-mode
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* // No default mode
|
|
191
|
+
* build = $command({
|
|
192
|
+
* mode: true,
|
|
193
|
+
* handler: async ({ mode }) => {
|
|
194
|
+
* console.log(`Building for ${mode ?? 'development'}...`);
|
|
195
|
+
* }
|
|
196
|
+
* });
|
|
197
|
+
*
|
|
198
|
+
* // Default mode "production"
|
|
199
|
+
* deploy = $command({
|
|
200
|
+
* mode: "production",
|
|
201
|
+
* handler: async ({ mode }) => {
|
|
202
|
+
* console.log(`Deploying for ${mode}...`); // always defined
|
|
203
|
+
* }
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* Usage:
|
|
208
|
+
* - `cli build` - loads .env (mode = undefined)
|
|
209
|
+
* - `cli build --mode production` - loads .env and .env.production
|
|
210
|
+
* - `cli deploy` - loads .env and .env.production (default mode)
|
|
211
|
+
* - `cli deploy --mode staging` - loads .env and .env.staging
|
|
212
|
+
*/
|
|
213
|
+
mode?: boolean | string;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Child commands (subcommands) for this command.
|
|
217
|
+
*
|
|
218
|
+
* When children are defined, the command becomes a parent command that
|
|
219
|
+
* can be invoked with space-separated subcommands:
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* class DeployCommands {
|
|
224
|
+
* // Subcommands
|
|
225
|
+
* vercel = $command({
|
|
226
|
+
* description: "Deploy to Vercel",
|
|
227
|
+
* handler: async () => { ... }
|
|
228
|
+
* });
|
|
229
|
+
*
|
|
230
|
+
* cloudflare = $command({
|
|
231
|
+
* description: "Deploy to Cloudflare",
|
|
232
|
+
* handler: async () => { ... }
|
|
233
|
+
* });
|
|
234
|
+
*
|
|
235
|
+
* // Parent command with children
|
|
236
|
+
* deploy = $command({
|
|
237
|
+
* description: "Deploy the application",
|
|
238
|
+
* children: [this.vercel, this.cloudflare],
|
|
239
|
+
* handler: async () => {
|
|
240
|
+
* // Called when "deploy" is invoked without subcommand
|
|
241
|
+
* console.log("Available: deploy vercel, deploy cloudflare");
|
|
242
|
+
* }
|
|
243
|
+
* });
|
|
244
|
+
* }
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
247
|
+
* This allows CLI usage like:
|
|
248
|
+
* - `cli deploy vercel` - runs the vercel subcommand
|
|
249
|
+
* - `cli deploy cloudflare` - runs the cloudflare subcommand
|
|
250
|
+
* - `cli deploy` - runs the parent handler (shows available subcommands)
|
|
251
|
+
* - `cli deploy --help` - shows help with all available subcommands
|
|
252
|
+
*/
|
|
253
|
+
children?: CommandPrimitive<any, any>[];
|
|
140
254
|
}
|
|
141
255
|
|
|
142
256
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
@@ -144,8 +258,10 @@ export interface CommandPrimitiveOptions<T extends TObject, A extends TSchema> {
|
|
|
144
258
|
export class CommandPrimitive<
|
|
145
259
|
T extends TObject = TObject,
|
|
146
260
|
A extends TSchema = TSchema,
|
|
147
|
-
|
|
261
|
+
E extends TObject = TObject,
|
|
262
|
+
> extends Primitive<CommandPrimitiveOptions<T, A, E>> {
|
|
148
263
|
public readonly flags = this.options.flags ?? t.object({});
|
|
264
|
+
public readonly env = this.options.env ?? t.object({});
|
|
149
265
|
public readonly aliases = this.options.aliases ?? [];
|
|
150
266
|
|
|
151
267
|
protected onInit() {
|
|
@@ -166,6 +282,29 @@ export class CommandPrimitive<
|
|
|
166
282
|
}
|
|
167
283
|
return this.options.name ?? `${this.config.propertyKey}`;
|
|
168
284
|
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Get the child commands (subcommands) for this command.
|
|
288
|
+
*/
|
|
289
|
+
public get children(): CommandPrimitive<any, any>[] {
|
|
290
|
+
return this.options.children ?? [];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Check if this command has child commands (is a parent command).
|
|
295
|
+
*/
|
|
296
|
+
public get hasChildren(): boolean {
|
|
297
|
+
return this.children.length > 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Find a child command by name or alias.
|
|
302
|
+
*/
|
|
303
|
+
public findChild(name: string): CommandPrimitive<any, any> | undefined {
|
|
304
|
+
return this.children.find(
|
|
305
|
+
(child) => child.name === name || child.aliases.includes(name),
|
|
306
|
+
);
|
|
307
|
+
}
|
|
169
308
|
}
|
|
170
309
|
|
|
171
310
|
$command[KIND] = CommandPrimitive;
|
|
@@ -175,9 +314,11 @@ $command[KIND] = CommandPrimitive;
|
|
|
175
314
|
export interface CommandHandlerArgs<
|
|
176
315
|
T extends TObject,
|
|
177
316
|
A extends TSchema = TSchema,
|
|
317
|
+
E extends TObject = TObject,
|
|
178
318
|
> {
|
|
179
319
|
flags: Static<T>;
|
|
180
320
|
args: A extends TSchema ? Static<A> : Array<string>;
|
|
321
|
+
env: Static<E>;
|
|
181
322
|
run: RunnerMethod;
|
|
182
323
|
ask: AskMethod;
|
|
183
324
|
glob: typeof glob;
|
|
@@ -187,4 +328,29 @@ export interface CommandHandlerArgs<
|
|
|
187
328
|
* The root directory where the command is executed.
|
|
188
329
|
*/
|
|
189
330
|
root: string;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Display help for the current command.
|
|
334
|
+
*
|
|
335
|
+
* Useful for parent commands with children to show available subcommands
|
|
336
|
+
* when invoked without a specific subcommand.
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* deploy = $command({
|
|
341
|
+
* children: [this.vercel, this.cloudflare],
|
|
342
|
+
* handler: async ({ help }) => {
|
|
343
|
+
* help(); // Shows available subcommands
|
|
344
|
+
* }
|
|
345
|
+
* });
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
help: () => void;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* The current execution mode (e.g., "development", "production", "staging").
|
|
352
|
+
*
|
|
353
|
+
* Use --mode flag to set this value when running the command.
|
|
354
|
+
*/
|
|
355
|
+
mode?: string;
|
|
190
356
|
}
|