alepha 0.12.1 → 0.13.1

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 (198) hide show
  1. package/dist/api-notifications/index.d.ts +111 -111
  2. package/dist/api-users/index.d.ts +1240 -1240
  3. package/dist/api-verifications/index.d.ts +94 -94
  4. package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
  5. package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
  6. package/dist/cli/index.d.ts +3 -11
  7. package/dist/cli/index.js +106 -74
  8. package/dist/cli/index.js.map +1 -1
  9. package/dist/email/index.js +71 -73
  10. package/dist/email/index.js.map +1 -1
  11. package/dist/orm/index.d.ts +1 -1
  12. package/dist/orm/index.js.map +1 -1
  13. package/dist/queue/index.d.ts +4 -4
  14. package/dist/redis/index.d.ts +10 -10
  15. package/dist/retry/index.d.ts +1 -1
  16. package/dist/retry/index.js +2 -2
  17. package/dist/retry/index.js.map +1 -1
  18. package/dist/scheduler/index.d.ts +6 -6
  19. package/dist/server/index.js +1 -1
  20. package/dist/server/index.js.map +1 -1
  21. package/dist/server-auth/index.d.ts +193 -193
  22. package/dist/server-health/index.d.ts +17 -17
  23. package/dist/server-links/index.d.ts +34 -34
  24. package/dist/server-metrics/index.js +170 -174
  25. package/dist/server-metrics/index.js.map +1 -1
  26. package/dist/server-security/index.d.ts +9 -9
  27. package/dist/vite/index.js +4 -5
  28. package/dist/vite/index.js.map +1 -1
  29. package/dist/websocket/index.d.ts +7 -7
  30. package/package.json +52 -103
  31. package/src/cli/apps/AlephaPackageBuilderCli.ts +7 -2
  32. package/src/cli/assets/appRouterTs.ts +9 -0
  33. package/src/cli/assets/indexHtml.ts +2 -1
  34. package/src/cli/assets/mainBrowserTs.ts +10 -0
  35. package/src/cli/commands/CoreCommands.ts +6 -5
  36. package/src/cli/commands/DrizzleCommands.ts +65 -57
  37. package/src/cli/commands/VerifyCommands.ts +1 -1
  38. package/src/cli/services/ProjectUtils.ts +44 -38
  39. package/src/orm/providers/DrizzleKitProvider.ts +1 -1
  40. package/src/retry/descriptors/$retry.ts +5 -3
  41. package/src/server/providers/NodeHttpServerProvider.ts +1 -1
  42. package/src/vite/helpers/boot.ts +3 -3
  43. package/dist/api-files/index.cjs +0 -1293
  44. package/dist/api-files/index.cjs.map +0 -1
  45. package/dist/api-files/index.d.cts +0 -829
  46. package/dist/api-jobs/index.cjs +0 -274
  47. package/dist/api-jobs/index.cjs.map +0 -1
  48. package/dist/api-jobs/index.d.cts +0 -654
  49. package/dist/api-notifications/index.cjs +0 -380
  50. package/dist/api-notifications/index.cjs.map +0 -1
  51. package/dist/api-notifications/index.d.cts +0 -289
  52. package/dist/api-parameters/index.cjs +0 -66
  53. package/dist/api-parameters/index.cjs.map +0 -1
  54. package/dist/api-parameters/index.d.cts +0 -84
  55. package/dist/api-users/index.cjs +0 -6009
  56. package/dist/api-users/index.cjs.map +0 -1
  57. package/dist/api-users/index.d.cts +0 -4740
  58. package/dist/api-verifications/index.cjs +0 -407
  59. package/dist/api-verifications/index.cjs.map +0 -1
  60. package/dist/api-verifications/index.d.cts +0 -207
  61. package/dist/batch/index.cjs +0 -408
  62. package/dist/batch/index.cjs.map +0 -1
  63. package/dist/batch/index.d.cts +0 -330
  64. package/dist/bin/index.cjs +0 -17
  65. package/dist/bin/index.cjs.map +0 -1
  66. package/dist/bin/index.d.cts +0 -1
  67. package/dist/bucket/index.cjs +0 -303
  68. package/dist/bucket/index.cjs.map +0 -1
  69. package/dist/bucket/index.d.cts +0 -355
  70. package/dist/cache/index.cjs +0 -241
  71. package/dist/cache/index.cjs.map +0 -1
  72. package/dist/cache/index.d.cts +0 -202
  73. package/dist/cache-redis/index.cjs +0 -84
  74. package/dist/cache-redis/index.cjs.map +0 -1
  75. package/dist/cache-redis/index.d.cts +0 -40
  76. package/dist/cli/chunk-DSlc6foC.cjs +0 -43
  77. package/dist/cli/dist-BBPjuQ56.js +0 -2778
  78. package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
  79. package/dist/cli/index.cjs +0 -1241
  80. package/dist/cli/index.cjs.map +0 -1
  81. package/dist/cli/index.d.cts +0 -422
  82. package/dist/command/index.cjs +0 -693
  83. package/dist/command/index.cjs.map +0 -1
  84. package/dist/command/index.d.cts +0 -340
  85. package/dist/core/index.cjs +0 -2264
  86. package/dist/core/index.cjs.map +0 -1
  87. package/dist/core/index.d.cts +0 -1927
  88. package/dist/datetime/index.cjs +0 -318
  89. package/dist/datetime/index.cjs.map +0 -1
  90. package/dist/datetime/index.d.cts +0 -145
  91. package/dist/email/index.cjs +0 -10874
  92. package/dist/email/index.cjs.map +0 -1
  93. package/dist/email/index.d.cts +0 -186
  94. package/dist/fake/index.cjs +0 -34641
  95. package/dist/fake/index.cjs.map +0 -1
  96. package/dist/fake/index.d.cts +0 -74
  97. package/dist/file/index.cjs +0 -1212
  98. package/dist/file/index.cjs.map +0 -1
  99. package/dist/file/index.d.cts +0 -698
  100. package/dist/lock/index.cjs +0 -226
  101. package/dist/lock/index.cjs.map +0 -1
  102. package/dist/lock/index.d.cts +0 -361
  103. package/dist/lock-redis/index.cjs +0 -113
  104. package/dist/lock-redis/index.cjs.map +0 -1
  105. package/dist/lock-redis/index.d.cts +0 -24
  106. package/dist/logger/index.cjs +0 -521
  107. package/dist/logger/index.cjs.map +0 -1
  108. package/dist/logger/index.d.cts +0 -281
  109. package/dist/orm/index.cjs +0 -2986
  110. package/dist/orm/index.cjs.map +0 -1
  111. package/dist/orm/index.d.cts +0 -2213
  112. package/dist/queue/index.cjs +0 -1044
  113. package/dist/queue/index.cjs.map +0 -1
  114. package/dist/queue/index.d.cts +0 -1265
  115. package/dist/queue-redis/index.cjs +0 -873
  116. package/dist/queue-redis/index.cjs.map +0 -1
  117. package/dist/queue-redis/index.d.cts +0 -82
  118. package/dist/redis/index.cjs +0 -153
  119. package/dist/redis/index.cjs.map +0 -1
  120. package/dist/redis/index.d.cts +0 -82
  121. package/dist/retry/index.cjs +0 -146
  122. package/dist/retry/index.cjs.map +0 -1
  123. package/dist/retry/index.d.cts +0 -172
  124. package/dist/router/index.cjs +0 -111
  125. package/dist/router/index.cjs.map +0 -1
  126. package/dist/router/index.d.cts +0 -46
  127. package/dist/scheduler/index.cjs +0 -576
  128. package/dist/scheduler/index.cjs.map +0 -1
  129. package/dist/scheduler/index.d.cts +0 -145
  130. package/dist/security/index.cjs +0 -2402
  131. package/dist/security/index.cjs.map +0 -1
  132. package/dist/security/index.d.cts +0 -598
  133. package/dist/server/index.cjs +0 -1680
  134. package/dist/server/index.cjs.map +0 -1
  135. package/dist/server/index.d.cts +0 -810
  136. package/dist/server-auth/index.cjs +0 -3146
  137. package/dist/server-auth/index.cjs.map +0 -1
  138. package/dist/server-auth/index.d.cts +0 -1164
  139. package/dist/server-cache/index.cjs +0 -252
  140. package/dist/server-cache/index.cjs.map +0 -1
  141. package/dist/server-cache/index.d.cts +0 -164
  142. package/dist/server-compress/index.cjs +0 -141
  143. package/dist/server-compress/index.cjs.map +0 -1
  144. package/dist/server-compress/index.d.cts +0 -38
  145. package/dist/server-cookies/index.cjs +0 -234
  146. package/dist/server-cookies/index.cjs.map +0 -1
  147. package/dist/server-cookies/index.d.cts +0 -144
  148. package/dist/server-cors/index.cjs +0 -201
  149. package/dist/server-cors/index.cjs.map +0 -1
  150. package/dist/server-cors/index.d.cts +0 -140
  151. package/dist/server-health/index.cjs +0 -62
  152. package/dist/server-health/index.cjs.map +0 -1
  153. package/dist/server-health/index.d.cts +0 -58
  154. package/dist/server-helmet/index.cjs +0 -131
  155. package/dist/server-helmet/index.cjs.map +0 -1
  156. package/dist/server-helmet/index.d.cts +0 -97
  157. package/dist/server-links/index.cjs +0 -992
  158. package/dist/server-links/index.cjs.map +0 -1
  159. package/dist/server-links/index.d.cts +0 -513
  160. package/dist/server-metrics/index.cjs +0 -4535
  161. package/dist/server-metrics/index.cjs.map +0 -1
  162. package/dist/server-metrics/index.d.cts +0 -35
  163. package/dist/server-multipart/index.cjs +0 -237
  164. package/dist/server-multipart/index.cjs.map +0 -1
  165. package/dist/server-multipart/index.d.cts +0 -50
  166. package/dist/server-proxy/index.cjs +0 -186
  167. package/dist/server-proxy/index.cjs.map +0 -1
  168. package/dist/server-proxy/index.d.cts +0 -234
  169. package/dist/server-rate-limit/index.cjs +0 -241
  170. package/dist/server-rate-limit/index.cjs.map +0 -1
  171. package/dist/server-rate-limit/index.d.cts +0 -183
  172. package/dist/server-security/index.cjs +0 -316
  173. package/dist/server-security/index.cjs.map +0 -1
  174. package/dist/server-security/index.d.cts +0 -173
  175. package/dist/server-static/index.cjs +0 -170
  176. package/dist/server-static/index.cjs.map +0 -1
  177. package/dist/server-static/index.d.cts +0 -121
  178. package/dist/server-swagger/index.cjs +0 -1021
  179. package/dist/server-swagger/index.cjs.map +0 -1
  180. package/dist/server-swagger/index.d.cts +0 -382
  181. package/dist/sms/index.cjs +0 -221
  182. package/dist/sms/index.cjs.map +0 -1
  183. package/dist/sms/index.d.cts +0 -130
  184. package/dist/thread/index.cjs +0 -350
  185. package/dist/thread/index.cjs.map +0 -1
  186. package/dist/thread/index.d.cts +0 -260
  187. package/dist/topic/index.cjs +0 -282
  188. package/dist/topic/index.cjs.map +0 -1
  189. package/dist/topic/index.d.cts +0 -523
  190. package/dist/topic-redis/index.cjs +0 -71
  191. package/dist/topic-redis/index.cjs.map +0 -1
  192. package/dist/topic-redis/index.d.cts +0 -42
  193. package/dist/vite/index.cjs +0 -1077
  194. package/dist/vite/index.cjs.map +0 -1
  195. package/dist/vite/index.d.cts +0 -542
  196. package/dist/websocket/index.cjs +0 -1117
  197. package/dist/websocket/index.cjs.map +0 -1
  198. package/dist/websocket/index.d.cts +0 -861
@@ -179,15 +179,6 @@ declare class ProjectUtils {
179
179
  alepha: Alepha;
180
180
  entry: string;
181
181
  }>;
182
- /**
183
- * Get DrizzleKitProvider from an Alepha instance.
184
- *
185
- * Searches the Alepha registry for the DrizzleKitProvider instance.
186
- *
187
- * @param alepha - The Alepha instance to search
188
- * @returns The DrizzleKitProvider instance
189
- */
190
- getKitFromAlepha(alepha: Alepha): any;
191
182
  /**
192
183
  * Generate JavaScript code for Drizzle entities export.
193
184
  *
@@ -241,6 +232,7 @@ declare class ProjectUtils {
241
232
  }
242
233
  interface DependencyModes {
243
234
  react?: boolean;
235
+ admin?: boolean;
244
236
  }
245
237
  //#endregion
246
238
  //#region src/cli/commands/BiomeCommands.d.ts
@@ -273,9 +265,9 @@ declare class CoreCommands {
273
265
  */
274
266
  readonly init: alepha_command0.CommandDescriptor<alepha0.TObject<{
275
267
  yarn: alepha0.TOptional<alepha0.TBoolean>;
276
- api: alepha0.TOptional<alepha0.TBoolean>;
268
+ pnpm: alepha0.TOptional<alepha0.TBoolean>;
277
269
  react: alepha0.TOptional<alepha0.TBoolean>;
278
- orm: alepha0.TOptional<alepha0.TBoolean>;
270
+ admin: alepha0.TOptional<alepha0.TBoolean>;
279
271
  }>, alepha0.TSchema>;
280
272
  }
281
273
  //#endregion
package/dist/cli/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import { createRequire } from "node:module";
2
1
  import { $env, $inject, $module, Alepha, AlephaError, OPTIONS, t } from "alepha";
3
2
  import { $command, CliProvider } from "alepha/command";
4
3
  import { $logger } from "alepha/logger";
@@ -78,6 +77,18 @@ var ProcessRunner = class {
78
77
  }
79
78
  };
80
79
 
80
+ //#endregion
81
+ //#region src/cli/assets/appRouterTs.ts
82
+ const appRouterTs = () => `
83
+ import { $page } from "@alepha/react";
84
+
85
+ export class AppRouter {
86
+ home = $page({
87
+ component: () => "Hello World",
88
+ });
89
+ }
90
+ `.trim();
91
+
81
92
  //#endregion
82
93
  //#region src/cli/assets/biomeJson.ts
83
94
  const biomeJson = `
@@ -116,7 +127,7 @@ const biomeJson = `
116
127
 
117
128
  //#endregion
118
129
  //#region src/cli/assets/indexHtml.ts
119
- const indexHtml = (browserEntry = "/src/main.tsx") => `
130
+ const indexHtml = (browserEntry) => `
120
131
  <!DOCTYPE html>
121
132
  <html lang="en">
122
133
  <head>
@@ -124,11 +135,25 @@ const indexHtml = (browserEntry = "/src/main.tsx") => `
124
135
  <title>App</title>
125
136
  </head>
126
137
  <body>
138
+ <div id="root"></div>
127
139
  <script type="module" src="${browserEntry}"><\/script>
128
140
  </body>
129
141
  </html>
130
142
  `.trim();
131
143
 
144
+ //#endregion
145
+ //#region src/cli/assets/mainBrowserTs.ts
146
+ const mainBrowserTs = () => `
147
+ import { Alepha, run } from "alepha";
148
+ import { AppRouter } from "./AppRouter.ts";
149
+
150
+ const alepha = Alepha.create();
151
+
152
+ alepha.with(AppRouter);
153
+
154
+ run(alepha);
155
+ `.trim();
156
+
132
157
  //#endregion
133
158
  //#region src/cli/assets/tsconfigJson.ts
134
159
  const tsconfigJson = `
@@ -181,16 +206,9 @@ var ProjectUtils = class {
181
206
  * @param root - The root directory of the project
182
207
  */
183
208
  async ensureYarn(root) {
184
- const yarnrcPath = join(root, ".yarnrc.yml");
185
- try {
186
- await access(yarnrcPath);
187
- } catch {
188
- await writeFile(yarnrcPath, "nodeLinker: node-modules");
189
- }
190
- const npmLockPath = join(root, "package-lock.json");
191
- const pnpmLockPath = join(root, "pnpm-lock.yaml");
192
- await this.fs.rm(npmLockPath, { force: true });
193
- await this.fs.rm(pnpmLockPath, { force: true });
209
+ await this.ensureFileExists(root, ".yarnrc.yml", "nodeLinker: node-modules", false);
210
+ await this.fs.rm(join(root, "package-lock.json"), { force: true });
211
+ await this.fs.rm(join(root, "pnpm-lock.yaml"), { force: true });
194
212
  }
195
213
  /**
196
214
  * Generate package.json content with Alepha dependencies.
@@ -203,16 +221,19 @@ var ProjectUtils = class {
203
221
  const devDependencies = {};
204
222
  if (modes.react) {
205
223
  dependencies["@alepha/react"] = `^${version}`;
206
- dependencies.react = "19.1.0";
207
- devDependencies["@types/react"] = "19.1.0";
224
+ dependencies.react = "^19.2.0";
225
+ dependencies["react-dom"] = "^19.2.0";
226
+ devDependencies["@types/react"] = "^19.2.0";
208
227
  }
228
+ if (modes.admin) dependencies["@alepha/ui"] = `^${version}`;
209
229
  return {
210
230
  type: "module",
211
231
  dependencies,
212
232
  devDependencies,
213
233
  scripts: {
214
234
  dev: "alepha dev",
215
- build: "alepha build"
235
+ build: "alepha build",
236
+ verify: "alepha verify"
216
237
  }
217
238
  };
218
239
  }
@@ -378,17 +399,6 @@ var ProjectUtils = class {
378
399
  throw new AlephaError(`Could not find Alepha instance in entry file: ${entry}`);
379
400
  }
380
401
  /**
381
- * Get DrizzleKitProvider from an Alepha instance.
382
- *
383
- * Searches the Alepha registry for the DrizzleKitProvider instance.
384
- *
385
- * @param alepha - The Alepha instance to search
386
- * @returns The DrizzleKitProvider instance
387
- */
388
- getKitFromAlepha(alepha) {
389
- return alepha["registry"].values().find((it) => it.instance.constructor.name === "DrizzleKitProvider")?.instance;
390
- }
391
- /**
392
402
  * Generate JavaScript code for Drizzle entities export.
393
403
  *
394
404
  * Creates a temporary entities.js file that imports from the entry file
@@ -447,7 +457,7 @@ ${models.map((it) => `export const ${it} = models["${it}"];`).join("\n")}
447
457
  const rootDir = options.root;
448
458
  this.log.debug(`Using project root: ${rootDir}`);
449
459
  const { alepha, entry } = await this.loadAlephaFromServerEntryFile(rootDir, options.args);
450
- const kit = this.getKitFromAlepha(alepha);
460
+ const drizzleKitProvider = alepha.inject("DrizzleKitProvider");
451
461
  const repositoryProvider = alepha.inject("RepositoryProvider");
452
462
  const accepted = /* @__PURE__ */ new Set([]);
453
463
  for (const descriptor of repositoryProvider.getRepositories()) {
@@ -463,7 +473,7 @@ ${models.map((it) => `export const ${it} = models["${it}"];`).join("\n")}
463
473
  this.log.info("");
464
474
  this.log.info(options.logMessage(providerName, dialect));
465
475
  const drizzleConfigJsPath = await this.prepareDrizzleConfig({
466
- kit,
476
+ kit: drizzleKitProvider,
467
477
  provider,
468
478
  providerName,
469
479
  providerUrl: provider.url,
@@ -482,8 +492,16 @@ ${models.map((it) => `export const ${it} = models["${it}"];`).join("\n")}
482
492
  }
483
493
  async ensureIndexHtml(root) {
484
494
  if (await this.fs.exists(join(root, "index.html"))) return;
485
- const entry = await boot.getServerEntry(root).catch(() => null);
486
- await this.fs.writeFile(join(root, "index.html"), indexHtml(entry ? entry.replace(root, "") : void 0));
495
+ const serverEntry = "src/main.server.ts";
496
+ const browserEntry = "src/main.browser.ts";
497
+ const appRouter = "src/AppRouter.ts";
498
+ await this.fs.writeFile(join(root, "index.html"), indexHtml(browserEntry));
499
+ try {
500
+ await this.fs.mkdir(join(root, "src"), { recursive: true });
501
+ } catch {}
502
+ if (!await this.fs.exists(join(root, browserEntry))) await this.fs.writeFile(join(root, browserEntry), mainBrowserTs());
503
+ if (!await this.fs.exists(join(root, serverEntry))) await this.fs.writeFile(join(root, serverEntry), mainBrowserTs());
504
+ if (!await this.fs.exists(join(root, appRouter))) await this.fs.writeFile(join(root, appRouter), appRouterTs());
487
505
  }
488
506
  async hasDir(root, dirName) {
489
507
  return this.fs.exists(join(root, dirName));
@@ -560,9 +578,9 @@ var CoreCommands = class {
560
578
  description: "Add missing Alepha configuration files to the project",
561
579
  flags: t.object({
562
580
  yarn: t.optional(t.boolean({ description: "Use Yarn package manager" })),
563
- api: t.optional(t.boolean({ description: "Include Alepha Server dependencies" })),
581
+ pnpm: t.optional(t.boolean({ description: "Use pnpm package manager" })),
564
582
  react: t.optional(t.boolean({ description: "Include Alepha React dependencies" })),
565
- orm: t.optional(t.boolean({ description: "Include Alepha ORM dependencies" }))
583
+ admin: t.optional(t.boolean({ description: "Include Alepha admin panel dependencies" }))
566
584
  }),
567
585
  handler: async ({ run, flags, root }) => {
568
586
  await run({
@@ -571,6 +589,8 @@ var CoreCommands = class {
571
589
  await this.utils.ensureConfig(root, {
572
590
  tsconfigJson: true,
573
591
  packageJson: flags,
592
+ biomeJson: true,
593
+ viteConfigTs: true,
574
594
  indexHtml: !!flags.react
575
595
  });
576
596
  }
@@ -578,6 +598,7 @@ var CoreCommands = class {
578
598
  const guessedPm = await this.utils.getPackageManager(root);
579
599
  if (flags.yarn || guessedPm === "yarn") {
580
600
  await this.utils.ensureYarn(root);
601
+ await run("yarn set version stable");
581
602
  await run("yarn install", { alias: "Installing dependencies with Yarn" });
582
603
  } else await run("npm install", { alias: "Installing dependencies with npm" });
583
604
  }
@@ -595,54 +616,61 @@ var DrizzleCommands = class {
595
616
  * Check if database migrations are up to date.
596
617
  */
597
618
  check = $command({
598
- name: "db:migrate:check",
619
+ name: "db:check-migrations",
599
620
  description: "Check if database migration files are up to date",
600
621
  args: t.optional(t.text({
601
622
  title: "path",
602
623
  description: "Path to the Alepha server entry file"
603
624
  })),
604
625
  flags: drizzleCommandFlags,
605
- handler: async ({ args, flags, root }) => {
626
+ handler: async ({ args, root }) => {
606
627
  const rootDir = root;
607
628
  this.log.debug(`Using project root: ${rootDir}`);
608
629
  const { alepha } = await this.utils.loadAlephaFromServerEntryFile(rootDir, args);
609
- const models = [];
610
- const repositories = alepha.descriptors("repository");
611
- const kit = createRequire(import.meta.url)("drizzle-kit/api");
612
- const migrationDir = join(rootDir, "migrations");
613
- const journalFile = await readFile(`${migrationDir}/meta/_journal.json`, "utf-8").catch(() => null);
614
- if (!journalFile) {
615
- this.log.info(`No migration journal found.`);
616
- return;
617
- }
618
- const journal = JSON.parse(journalFile);
619
- const lastMigration = journal.entries[journal.entries.length - 1];
620
- const lastSnapshot = JSON.parse(await readFile(`${migrationDir}/meta/${String(lastMigration.idx).padStart(4, "0")}_snapshot.json`, "utf-8"));
621
- for (const repository of repositories) if (!models.includes(repository.table)) models.push(repository.table);
622
- const now = kit.generateDrizzleJson(models, lastSnapshot.id);
623
- const migrationStatements = await new Promise((resolve) => {
624
- (async () => {
625
- const timer = setTimeout(() => {
626
- resolve([{ message: "Migration generation timed out." }]);
627
- }, 5e3);
628
- const statements = await kit.generateMigration(lastSnapshot, now);
629
- clearTimeout(timer);
630
- resolve(statements);
631
- })();
632
- });
633
- if (migrationStatements.length === 0) {
634
- this.log.info("No changes detected.");
635
- return;
630
+ const repositoryProvider = alepha.inject("RepositoryProvider");
631
+ const drizzleKitProvider = alepha.inject("DrizzleKitProvider");
632
+ const accepted = /* @__PURE__ */ new Set([]);
633
+ for (const descriptor of repositoryProvider.getRepositories()) {
634
+ const provider = descriptor.provider;
635
+ const providerName = provider.name;
636
+ if (accepted.has(providerName)) continue;
637
+ accepted.add(providerName);
638
+ const migrationDir = join(rootDir, "migrations", providerName);
639
+ const journalFile = await readFile(`${migrationDir}/meta/_journal.json`, "utf-8").catch(() => null);
640
+ if (!journalFile) {
641
+ this.log.info(`No migration journal found.`);
642
+ return;
643
+ }
644
+ const journal = JSON.parse(journalFile);
645
+ const lastMigration = journal.entries[journal.entries.length - 1];
646
+ const lastSnapshot = JSON.parse(await readFile(`${migrationDir}/meta/${String(lastMigration.idx).padStart(4, "0")}_snapshot.json`, "utf-8"));
647
+ const models = drizzleKitProvider.getModels(provider);
648
+ const kit = drizzleKitProvider.importDrizzleKit();
649
+ const now = kit.generateDrizzleJson(models, lastSnapshot.id);
650
+ const migrationStatements = await new Promise((resolve) => {
651
+ (async () => {
652
+ const timer = setTimeout(() => {
653
+ resolve([{ message: "Migration generation timed out." }]);
654
+ }, 5e3);
655
+ const statements = await kit.generateMigration(lastSnapshot, now);
656
+ clearTimeout(timer);
657
+ resolve(statements);
658
+ })();
659
+ });
660
+ if (migrationStatements.length === 0) {
661
+ this.log.info("No changes detected.");
662
+ return;
663
+ }
664
+ this.log.info("");
665
+ this.log.info("Detected migration statements:");
666
+ this.log.info("");
667
+ for (const stmt of migrationStatements) this.log.info(stmt);
668
+ this.log.info("");
669
+ this.log.info(`At least ${migrationStatements.length} change(s) detected.`);
670
+ this.log.info("Please, run 'alepha db:generate' to update the migration files.");
671
+ this.log.info("");
672
+ throw new AlephaError("Database migrations are not up to date.");
636
673
  }
637
- this.log.info("");
638
- this.log.info("Detected migration statements:");
639
- this.log.info("");
640
- for (const stmt of migrationStatements) this.log.info(stmt);
641
- this.log.info("");
642
- this.log.info(`At least ${migrationStatements.length} change(s) detected.`);
643
- this.log.info("Please, run 'alepha db:generate' to update the migration files.");
644
- this.log.info("");
645
- throw new AlephaError("Database migrations are not up to date.");
646
674
  }
647
675
  });
648
676
  /**
@@ -842,7 +870,7 @@ var VerifyCommands = class {
842
870
  await run("alepha lint");
843
871
  await run("alepha typecheck");
844
872
  if ((await this.utils.readPackageJson(root)).devDependencies?.vitest) await run("alepha test");
845
- if (await this.utils.hasDir(root, "migrations")) await run("alepha db:migrate:check");
873
+ if (await this.utils.hasDir(root, "migrations")) await run("alepha db:check-migrations");
846
874
  await run("alepha build");
847
875
  await run("alepha clean");
848
876
  }
@@ -1036,7 +1064,7 @@ var ViteCommands = class {
1036
1064
  viteConfigTs: true
1037
1065
  });
1038
1066
  try {
1039
- await import("./dist-BBPjuQ56.js");
1067
+ await import("./dist-Dl9Vl7Ur.js");
1040
1068
  } catch {
1041
1069
  this.log.error("Vitest is not installed. Please install it with `npm install -D vitest` or `yarn add -D vitest`.");
1042
1070
  process.exit(1);
@@ -1094,7 +1122,11 @@ var AlephaPackageBuilderCli = class {
1094
1122
  const tmpDir = join(root, "node_modules/.alepha");
1095
1123
  await this.fs.mkdir(tmpDir, { recursive: true }).catch(() => {});
1096
1124
  await this.fs.writeFile(join(tmpDir, "module-dependencies.json"), JSON.stringify(modules, null, 2));
1097
- const external = ["alepha", ...modules.map((item) => `alepha/${item.name}`)];
1125
+ const external = [
1126
+ "alepha",
1127
+ packageName,
1128
+ ...modules.map((item) => `${packageName}/${item.name}`)
1129
+ ];
1098
1130
  await run.rm(this.dist);
1099
1131
  const build = async (item) => {
1100
1132
  const entries = [];
@@ -1103,7 +1135,7 @@ var AlephaPackageBuilderCli = class {
1103
1135
  entries.push({
1104
1136
  entry: join(src, "index.ts"),
1105
1137
  outDir: dest,
1106
- format: ["esm", "cjs"],
1138
+ format: ["esm"],
1107
1139
  sourcemap: true,
1108
1140
  fixedExtension: false,
1109
1141
  platform: "node",