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.
Files changed (149) hide show
  1. package/README.md +3 -3
  2. package/dist/api/audits/index.d.ts +80 -1
  3. package/dist/api/audits/index.d.ts.map +1 -1
  4. package/dist/api/audits/index.js.map +1 -1
  5. package/dist/api/files/index.d.ts +80 -1
  6. package/dist/api/files/index.d.ts.map +1 -1
  7. package/dist/api/files/index.js.map +1 -1
  8. package/dist/api/jobs/index.d.ts +236 -157
  9. package/dist/api/jobs/index.d.ts.map +1 -1
  10. package/dist/api/jobs/index.js.map +1 -1
  11. package/dist/api/notifications/index.d.ts +21 -1
  12. package/dist/api/notifications/index.d.ts.map +1 -1
  13. package/dist/api/parameters/index.d.ts +451 -4
  14. package/dist/api/parameters/index.d.ts.map +1 -1
  15. package/dist/api/parameters/index.js.map +1 -1
  16. package/dist/api/users/index.d.ts +252 -249
  17. package/dist/api/users/index.d.ts.map +1 -1
  18. package/dist/api/users/index.js +4 -0
  19. package/dist/api/users/index.js.map +1 -1
  20. package/dist/api/verifications/index.d.ts +128 -128
  21. package/dist/api/verifications/index.d.ts.map +1 -1
  22. package/dist/batch/index.js.map +1 -1
  23. package/dist/cache/core/index.js.map +1 -1
  24. package/dist/cli/index.d.ts +304 -115
  25. package/dist/cli/index.d.ts.map +1 -1
  26. package/dist/cli/index.js +650 -531
  27. package/dist/cli/index.js.map +1 -1
  28. package/dist/command/index.d.ts +210 -13
  29. package/dist/command/index.d.ts.map +1 -1
  30. package/dist/command/index.js +306 -69
  31. package/dist/command/index.js.map +1 -1
  32. package/dist/core/index.browser.js.map +1 -1
  33. package/dist/core/index.d.ts +1 -1
  34. package/dist/core/index.d.ts.map +1 -1
  35. package/dist/core/index.js +7 -6
  36. package/dist/core/index.js.map +1 -1
  37. package/dist/core/index.native.js +7 -6
  38. package/dist/core/index.native.js.map +1 -1
  39. package/dist/datetime/index.js.map +1 -1
  40. package/dist/fake/index.js.map +1 -1
  41. package/dist/file/index.d.ts.map +1 -1
  42. package/dist/file/index.js.map +1 -1
  43. package/dist/lock/redis/index.js.map +1 -1
  44. package/dist/logger/index.js.map +1 -1
  45. package/dist/mcp/index.js.map +1 -1
  46. package/dist/orm/index.browser.js +26 -5
  47. package/dist/orm/index.browser.js.map +1 -1
  48. package/dist/orm/index.d.ts +294 -215
  49. package/dist/orm/index.d.ts.map +1 -1
  50. package/dist/orm/index.js +522 -523
  51. package/dist/orm/index.js.map +1 -1
  52. package/dist/queue/redis/index.js +2 -4
  53. package/dist/queue/redis/index.js.map +1 -1
  54. package/dist/redis/index.d.ts +400 -29
  55. package/dist/redis/index.d.ts.map +1 -1
  56. package/dist/redis/index.js +412 -21
  57. package/dist/redis/index.js.map +1 -1
  58. package/dist/retry/index.js.map +1 -1
  59. package/dist/router/index.js.map +1 -1
  60. package/dist/scheduler/index.js.map +1 -1
  61. package/dist/security/index.d.ts.map +1 -1
  62. package/dist/security/index.js.map +1 -1
  63. package/dist/server/auth/index.d.ts +155 -155
  64. package/dist/server/auth/index.js.map +1 -1
  65. package/dist/server/cache/index.js.map +1 -1
  66. package/dist/server/cookies/index.browser.js.map +1 -1
  67. package/dist/server/cookies/index.js.map +1 -1
  68. package/dist/server/core/index.browser.js.map +1 -1
  69. package/dist/server/core/index.d.ts +0 -1
  70. package/dist/server/core/index.d.ts.map +1 -1
  71. package/dist/server/core/index.js.map +1 -1
  72. package/dist/server/helmet/index.d.ts +4 -1
  73. package/dist/server/helmet/index.d.ts.map +1 -1
  74. package/dist/server/helmet/index.js.map +1 -1
  75. package/dist/server/links/index.browser.js.map +1 -1
  76. package/dist/server/links/index.js.map +1 -1
  77. package/dist/server/multipart/index.d.ts.map +1 -1
  78. package/dist/server/multipart/index.js.map +1 -1
  79. package/dist/server/proxy/index.js.map +1 -1
  80. package/dist/server/rate-limit/index.js.map +1 -1
  81. package/dist/server/security/index.d.ts +9 -9
  82. package/dist/server/security/index.js.map +1 -1
  83. package/dist/server/swagger/index.js.map +1 -1
  84. package/dist/thread/index.js.map +1 -1
  85. package/dist/topic/core/index.js.map +1 -1
  86. package/dist/topic/redis/index.js +3 -3
  87. package/dist/topic/redis/index.js.map +1 -1
  88. package/dist/vite/index.js +9 -6
  89. package/dist/vite/index.js.map +1 -1
  90. package/dist/websocket/index.browser.js.map +1 -1
  91. package/dist/websocket/index.d.ts +7 -7
  92. package/dist/websocket/index.js.map +1 -1
  93. package/package.json +3 -3
  94. package/src/api/users/index.ts +4 -0
  95. package/src/cli/apps/AlephaCli.ts +36 -14
  96. package/src/cli/apps/AlephaPackageBuilderCli.ts +5 -1
  97. package/src/cli/assets/appRouterTs.ts +1 -1
  98. package/src/cli/atoms/changelogOptions.ts +45 -0
  99. package/src/cli/commands/{ViteCommands.ts → build.ts} +4 -93
  100. package/src/cli/commands/changelog.ts +244 -0
  101. package/src/cli/commands/clean.ts +14 -0
  102. package/src/cli/commands/{DrizzleCommands.ts → db.ts} +37 -124
  103. package/src/cli/commands/deploy.ts +118 -0
  104. package/src/cli/commands/dev.ts +57 -0
  105. package/src/cli/commands/format.ts +17 -0
  106. package/src/cli/commands/{CoreCommands.ts → init.ts} +2 -40
  107. package/src/cli/commands/lint.ts +17 -0
  108. package/src/cli/commands/root.ts +32 -0
  109. package/src/cli/commands/run.ts +24 -0
  110. package/src/cli/commands/test.ts +42 -0
  111. package/src/cli/commands/typecheck.ts +19 -0
  112. package/src/cli/commands/{VerifyCommands.ts → verify.ts} +1 -13
  113. package/src/cli/defineConfig.ts +24 -0
  114. package/src/cli/index.ts +17 -5
  115. package/src/cli/services/AlephaCliUtils.ts +4 -21
  116. package/src/cli/services/GitMessageParser.ts +77 -0
  117. package/src/command/helpers/EnvUtils.ts +37 -0
  118. package/src/command/index.ts +3 -1
  119. package/src/command/primitives/$command.ts +172 -6
  120. package/src/command/providers/CliProvider.ts +424 -91
  121. package/src/core/Alepha.ts +8 -5
  122. package/src/file/providers/NodeFileSystemProvider.ts +3 -1
  123. package/src/orm/index.browser.ts +1 -1
  124. package/src/orm/index.ts +18 -10
  125. package/src/orm/interfaces/PgQueryWhere.ts +1 -26
  126. package/src/orm/providers/{PostgresTypeProvider.ts → DatabaseTypeProvider.ts} +25 -3
  127. package/src/orm/providers/drivers/BunPostgresProvider.ts +225 -0
  128. package/src/orm/providers/drivers/BunSqliteProvider.ts +180 -0
  129. package/src/orm/providers/drivers/DatabaseProvider.ts +25 -0
  130. package/src/orm/providers/drivers/NodePostgresProvider.ts +0 -25
  131. package/src/orm/services/QueryManager.ts +10 -125
  132. package/src/queue/redis/providers/RedisQueueProvider.ts +2 -7
  133. package/src/redis/index.ts +65 -3
  134. package/src/redis/providers/BunRedisProvider.ts +304 -0
  135. package/src/redis/providers/BunRedisSubscriberProvider.ts +94 -0
  136. package/src/redis/providers/NodeRedisProvider.ts +280 -0
  137. package/src/redis/providers/NodeRedisSubscriberProvider.ts +94 -0
  138. package/src/redis/providers/RedisProvider.ts +134 -140
  139. package/src/redis/providers/RedisSubscriberProvider.ts +58 -49
  140. package/src/server/core/providers/BunHttpServerProvider.ts +0 -3
  141. package/src/server/core/providers/ServerBodyParserProvider.ts +3 -1
  142. package/src/server/core/providers/ServerProvider.ts +7 -4
  143. package/src/server/multipart/providers/ServerMultipartProvider.ts +3 -1
  144. package/src/server/proxy/providers/ServerProxyProvider.ts +1 -1
  145. package/src/topic/redis/providers/RedisTopicProvider.ts +3 -3
  146. package/src/vite/tasks/buildServer.ts +1 -0
  147. package/src/cli/commands/BiomeCommands.ts +0 -29
  148. package/src/cli/commands/ChangelogCommands.ts +0 -389
  149. 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 = <T extends TObject, A extends TSchema>(
23
- options: CommandPrimitiveOptions<T, A>,
24
- ) => createPrimitive(CommandPrimitive<T, A>, options);
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<T extends TObject, A extends TSchema> {
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
- > extends Primitive<CommandPrimitiveOptions<T, A>> {
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
  }