alepha 0.13.0 → 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 (195) hide show
  1. package/dist/api-jobs/index.d.ts +26 -26
  2. package/dist/api-users/index.d.ts +1 -1
  3. package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
  4. package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
  5. package/dist/cli/index.d.ts +3 -11
  6. package/dist/cli/index.js +106 -74
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/email/index.js +71 -73
  9. package/dist/email/index.js.map +1 -1
  10. package/dist/orm/index.d.ts +1 -1
  11. package/dist/orm/index.js.map +1 -1
  12. package/dist/queue/index.d.ts +4 -4
  13. package/dist/retry/index.d.ts +1 -1
  14. package/dist/retry/index.js +2 -2
  15. package/dist/retry/index.js.map +1 -1
  16. package/dist/scheduler/index.d.ts +6 -6
  17. package/dist/security/index.d.ts +28 -28
  18. package/dist/server/index.js +1 -1
  19. package/dist/server/index.js.map +1 -1
  20. package/dist/server-health/index.d.ts +17 -17
  21. package/dist/server-metrics/index.js +170 -174
  22. package/dist/server-metrics/index.js.map +1 -1
  23. package/dist/server-security/index.d.ts +9 -9
  24. package/dist/vite/index.js +4 -5
  25. package/dist/vite/index.js.map +1 -1
  26. package/dist/websocket/index.d.ts +7 -7
  27. package/package.json +52 -103
  28. package/src/cli/apps/AlephaPackageBuilderCli.ts +7 -2
  29. package/src/cli/assets/appRouterTs.ts +9 -0
  30. package/src/cli/assets/indexHtml.ts +2 -1
  31. package/src/cli/assets/mainBrowserTs.ts +10 -0
  32. package/src/cli/commands/CoreCommands.ts +6 -5
  33. package/src/cli/commands/DrizzleCommands.ts +65 -57
  34. package/src/cli/commands/VerifyCommands.ts +1 -1
  35. package/src/cli/services/ProjectUtils.ts +44 -38
  36. package/src/orm/providers/DrizzleKitProvider.ts +1 -1
  37. package/src/retry/descriptors/$retry.ts +5 -3
  38. package/src/server/providers/NodeHttpServerProvider.ts +1 -1
  39. package/src/vite/helpers/boot.ts +3 -3
  40. package/dist/api-files/index.cjs +0 -1293
  41. package/dist/api-files/index.cjs.map +0 -1
  42. package/dist/api-files/index.d.cts +0 -829
  43. package/dist/api-jobs/index.cjs +0 -274
  44. package/dist/api-jobs/index.cjs.map +0 -1
  45. package/dist/api-jobs/index.d.cts +0 -654
  46. package/dist/api-notifications/index.cjs +0 -380
  47. package/dist/api-notifications/index.cjs.map +0 -1
  48. package/dist/api-notifications/index.d.cts +0 -289
  49. package/dist/api-parameters/index.cjs +0 -66
  50. package/dist/api-parameters/index.cjs.map +0 -1
  51. package/dist/api-parameters/index.d.cts +0 -84
  52. package/dist/api-users/index.cjs +0 -6009
  53. package/dist/api-users/index.cjs.map +0 -1
  54. package/dist/api-users/index.d.cts +0 -4740
  55. package/dist/api-verifications/index.cjs +0 -407
  56. package/dist/api-verifications/index.cjs.map +0 -1
  57. package/dist/api-verifications/index.d.cts +0 -207
  58. package/dist/batch/index.cjs +0 -408
  59. package/dist/batch/index.cjs.map +0 -1
  60. package/dist/batch/index.d.cts +0 -330
  61. package/dist/bin/index.cjs +0 -17
  62. package/dist/bin/index.cjs.map +0 -1
  63. package/dist/bin/index.d.cts +0 -1
  64. package/dist/bucket/index.cjs +0 -303
  65. package/dist/bucket/index.cjs.map +0 -1
  66. package/dist/bucket/index.d.cts +0 -355
  67. package/dist/cache/index.cjs +0 -241
  68. package/dist/cache/index.cjs.map +0 -1
  69. package/dist/cache/index.d.cts +0 -202
  70. package/dist/cache-redis/index.cjs +0 -84
  71. package/dist/cache-redis/index.cjs.map +0 -1
  72. package/dist/cache-redis/index.d.cts +0 -40
  73. package/dist/cli/chunk-DSlc6foC.cjs +0 -43
  74. package/dist/cli/dist-BBPjuQ56.js +0 -2778
  75. package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
  76. package/dist/cli/index.cjs +0 -1241
  77. package/dist/cli/index.cjs.map +0 -1
  78. package/dist/cli/index.d.cts +0 -422
  79. package/dist/command/index.cjs +0 -693
  80. package/dist/command/index.cjs.map +0 -1
  81. package/dist/command/index.d.cts +0 -340
  82. package/dist/core/index.cjs +0 -2264
  83. package/dist/core/index.cjs.map +0 -1
  84. package/dist/core/index.d.cts +0 -1927
  85. package/dist/datetime/index.cjs +0 -318
  86. package/dist/datetime/index.cjs.map +0 -1
  87. package/dist/datetime/index.d.cts +0 -145
  88. package/dist/email/index.cjs +0 -10874
  89. package/dist/email/index.cjs.map +0 -1
  90. package/dist/email/index.d.cts +0 -186
  91. package/dist/fake/index.cjs +0 -34641
  92. package/dist/fake/index.cjs.map +0 -1
  93. package/dist/fake/index.d.cts +0 -74
  94. package/dist/file/index.cjs +0 -1212
  95. package/dist/file/index.cjs.map +0 -1
  96. package/dist/file/index.d.cts +0 -698
  97. package/dist/lock/index.cjs +0 -226
  98. package/dist/lock/index.cjs.map +0 -1
  99. package/dist/lock/index.d.cts +0 -361
  100. package/dist/lock-redis/index.cjs +0 -113
  101. package/dist/lock-redis/index.cjs.map +0 -1
  102. package/dist/lock-redis/index.d.cts +0 -24
  103. package/dist/logger/index.cjs +0 -521
  104. package/dist/logger/index.cjs.map +0 -1
  105. package/dist/logger/index.d.cts +0 -281
  106. package/dist/orm/index.cjs +0 -2986
  107. package/dist/orm/index.cjs.map +0 -1
  108. package/dist/orm/index.d.cts +0 -2213
  109. package/dist/queue/index.cjs +0 -1044
  110. package/dist/queue/index.cjs.map +0 -1
  111. package/dist/queue/index.d.cts +0 -1265
  112. package/dist/queue-redis/index.cjs +0 -873
  113. package/dist/queue-redis/index.cjs.map +0 -1
  114. package/dist/queue-redis/index.d.cts +0 -82
  115. package/dist/redis/index.cjs +0 -153
  116. package/dist/redis/index.cjs.map +0 -1
  117. package/dist/redis/index.d.cts +0 -82
  118. package/dist/retry/index.cjs +0 -146
  119. package/dist/retry/index.cjs.map +0 -1
  120. package/dist/retry/index.d.cts +0 -172
  121. package/dist/router/index.cjs +0 -111
  122. package/dist/router/index.cjs.map +0 -1
  123. package/dist/router/index.d.cts +0 -46
  124. package/dist/scheduler/index.cjs +0 -576
  125. package/dist/scheduler/index.cjs.map +0 -1
  126. package/dist/scheduler/index.d.cts +0 -145
  127. package/dist/security/index.cjs +0 -2402
  128. package/dist/security/index.cjs.map +0 -1
  129. package/dist/security/index.d.cts +0 -598
  130. package/dist/server/index.cjs +0 -1680
  131. package/dist/server/index.cjs.map +0 -1
  132. package/dist/server/index.d.cts +0 -810
  133. package/dist/server-auth/index.cjs +0 -3146
  134. package/dist/server-auth/index.cjs.map +0 -1
  135. package/dist/server-auth/index.d.cts +0 -1164
  136. package/dist/server-cache/index.cjs +0 -252
  137. package/dist/server-cache/index.cjs.map +0 -1
  138. package/dist/server-cache/index.d.cts +0 -164
  139. package/dist/server-compress/index.cjs +0 -141
  140. package/dist/server-compress/index.cjs.map +0 -1
  141. package/dist/server-compress/index.d.cts +0 -38
  142. package/dist/server-cookies/index.cjs +0 -234
  143. package/dist/server-cookies/index.cjs.map +0 -1
  144. package/dist/server-cookies/index.d.cts +0 -144
  145. package/dist/server-cors/index.cjs +0 -201
  146. package/dist/server-cors/index.cjs.map +0 -1
  147. package/dist/server-cors/index.d.cts +0 -140
  148. package/dist/server-health/index.cjs +0 -62
  149. package/dist/server-health/index.cjs.map +0 -1
  150. package/dist/server-health/index.d.cts +0 -58
  151. package/dist/server-helmet/index.cjs +0 -131
  152. package/dist/server-helmet/index.cjs.map +0 -1
  153. package/dist/server-helmet/index.d.cts +0 -97
  154. package/dist/server-links/index.cjs +0 -992
  155. package/dist/server-links/index.cjs.map +0 -1
  156. package/dist/server-links/index.d.cts +0 -513
  157. package/dist/server-metrics/index.cjs +0 -4535
  158. package/dist/server-metrics/index.cjs.map +0 -1
  159. package/dist/server-metrics/index.d.cts +0 -35
  160. package/dist/server-multipart/index.cjs +0 -237
  161. package/dist/server-multipart/index.cjs.map +0 -1
  162. package/dist/server-multipart/index.d.cts +0 -50
  163. package/dist/server-proxy/index.cjs +0 -186
  164. package/dist/server-proxy/index.cjs.map +0 -1
  165. package/dist/server-proxy/index.d.cts +0 -234
  166. package/dist/server-rate-limit/index.cjs +0 -241
  167. package/dist/server-rate-limit/index.cjs.map +0 -1
  168. package/dist/server-rate-limit/index.d.cts +0 -183
  169. package/dist/server-security/index.cjs +0 -316
  170. package/dist/server-security/index.cjs.map +0 -1
  171. package/dist/server-security/index.d.cts +0 -173
  172. package/dist/server-static/index.cjs +0 -170
  173. package/dist/server-static/index.cjs.map +0 -1
  174. package/dist/server-static/index.d.cts +0 -121
  175. package/dist/server-swagger/index.cjs +0 -1021
  176. package/dist/server-swagger/index.cjs.map +0 -1
  177. package/dist/server-swagger/index.d.cts +0 -382
  178. package/dist/sms/index.cjs +0 -221
  179. package/dist/sms/index.cjs.map +0 -1
  180. package/dist/sms/index.d.cts +0 -130
  181. package/dist/thread/index.cjs +0 -350
  182. package/dist/thread/index.cjs.map +0 -1
  183. package/dist/thread/index.d.cts +0 -260
  184. package/dist/topic/index.cjs +0 -282
  185. package/dist/topic/index.cjs.map +0 -1
  186. package/dist/topic/index.d.cts +0 -523
  187. package/dist/topic-redis/index.cjs +0 -71
  188. package/dist/topic-redis/index.cjs.map +0 -1
  189. package/dist/topic-redis/index.d.cts +0 -42
  190. package/dist/vite/index.cjs +0 -1077
  191. package/dist/vite/index.cjs.map +0 -1
  192. package/dist/vite/index.d.cts +0 -542
  193. package/dist/websocket/index.cjs +0 -1117
  194. package/dist/websocket/index.cjs.map +0 -1
  195. package/dist/websocket/index.d.cts +0 -861
@@ -3,11 +3,13 @@ import { join } from "node:path";
3
3
  import { $inject, Alepha, AlephaError } from "alepha";
4
4
  import { FileSystemProvider } from "alepha/file";
5
5
  import { $logger } from "alepha/logger";
6
- import type { RepositoryProvider } from "alepha/orm";
6
+ import type { DrizzleKitProvider, RepositoryProvider } from "alepha/orm";
7
7
  import { boot } from "alepha/vite";
8
8
  import { tsImport } from "tsx/esm/api";
9
+ import { appRouterTs } from "../assets/appRouterTs.ts";
9
10
  import { biomeJson } from "../assets/biomeJson.ts";
10
11
  import { indexHtml } from "../assets/indexHtml.ts";
12
+ import { mainBrowserTs } from "../assets/mainBrowserTs.ts";
11
13
  import { tsconfigJson } from "../assets/tsconfigJson.ts";
12
14
  import { viteConfigTs } from "../assets/viteConfigTs.ts";
13
15
  import { version } from "../version.ts";
@@ -40,18 +42,16 @@ export class ProjectUtils {
40
42
  * @param root - The root directory of the project
41
43
  */
42
44
  public async ensureYarn(root: string): Promise<void> {
43
- const yarnrcPath = join(root, ".yarnrc.yml");
44
- try {
45
- await access(yarnrcPath);
46
- } catch {
47
- await writeFile(yarnrcPath, "nodeLinker: node-modules");
48
- }
45
+ await this.ensureFileExists(
46
+ root,
47
+ ".yarnrc.yml",
48
+ "nodeLinker: node-modules",
49
+ false,
50
+ );
49
51
 
50
52
  // remove lock files from other package managers
51
- const npmLockPath = join(root, "package-lock.json");
52
- const pnpmLockPath = join(root, "pnpm-lock.yaml");
53
- await this.fs.rm(npmLockPath, { force: true });
54
- await this.fs.rm(pnpmLockPath, { force: true });
53
+ await this.fs.rm(join(root, "package-lock.json"), { force: true });
54
+ await this.fs.rm(join(root, "pnpm-lock.yaml"), { force: true });
55
55
  }
56
56
 
57
57
  /**
@@ -74,8 +74,13 @@ export class ProjectUtils {
74
74
 
75
75
  if (modes.react) {
76
76
  dependencies["@alepha/react"] = `^${version}`;
77
- dependencies.react = "19.1.0";
78
- devDependencies["@types/react"] = "19.1.0";
77
+ dependencies.react = "^19.2.0";
78
+ dependencies["react-dom"] = "^19.2.0";
79
+ devDependencies["@types/react"] = "^19.2.0";
80
+ }
81
+
82
+ if (modes.admin) {
83
+ dependencies["@alepha/ui"] = `^${version}`;
79
84
  }
80
85
 
81
86
  return {
@@ -85,6 +90,7 @@ export class ProjectUtils {
85
90
  scripts: {
86
91
  dev: "alepha dev",
87
92
  build: "alepha build",
93
+ verify: "alepha verify",
88
94
  },
89
95
  };
90
96
  }
@@ -353,22 +359,6 @@ export class ProjectUtils {
353
359
  );
354
360
  }
355
361
 
356
- /**
357
- * Get DrizzleKitProvider from an Alepha instance.
358
- *
359
- * Searches the Alepha registry for the DrizzleKitProvider instance.
360
- *
361
- * @param alepha - The Alepha instance to search
362
- * @returns The DrizzleKitProvider instance
363
- */
364
- public getKitFromAlepha(alepha: Alepha): any {
365
- // biome-ignore lint/complexity/useLiteralKeys: private key
366
- return alepha["registry"]
367
- .values()
368
- .find((it: any) => it.instance.constructor.name === "DrizzleKitProvider")
369
- ?.instance;
370
- }
371
-
372
362
  /**
373
363
  * Generate JavaScript code for Drizzle entities export.
374
364
  *
@@ -476,7 +466,8 @@ ${models.map((it: string) => `export const ${it} = models["${it}"];`).join("\n")
476
466
  options.args,
477
467
  );
478
468
 
479
- const kit = this.getKitFromAlepha(alepha);
469
+ const drizzleKitProvider =
470
+ alepha.inject<DrizzleKitProvider>("DrizzleKitProvider");
480
471
  const repositoryProvider =
481
472
  alepha.inject<RepositoryProvider>("RepositoryProvider");
482
473
  const accepted = new Set<string>([]);
@@ -503,7 +494,7 @@ ${models.map((it: string) => `export const ${it} = models["${it}"];`).join("\n")
503
494
  this.log.info(options.logMessage(providerName, dialect));
504
495
 
505
496
  const drizzleConfigJsPath = await this.prepareDrizzleConfig({
506
- kit,
497
+ kit: drizzleKitProvider,
507
498
  provider,
508
499
  providerName,
509
500
  providerUrl: provider.url,
@@ -536,11 +527,27 @@ ${models.map((it: string) => `export const ${it} = models["${it}"];`).join("\n")
536
527
  return;
537
528
  }
538
529
 
539
- const entry = await boot.getServerEntry(root).catch(() => null);
540
- await this.fs.writeFile(
541
- join(root, "index.html"),
542
- indexHtml(entry ? entry.replace(root, "") : undefined),
543
- );
530
+ const serverEntry = "src/main.server.ts";
531
+ const browserEntry = "src/main.browser.ts";
532
+ const appRouter = "src/AppRouter.ts";
533
+
534
+ await this.fs.writeFile(join(root, "index.html"), indexHtml(browserEntry));
535
+
536
+ try {
537
+ await this.fs.mkdir(join(root, "src"), { recursive: true });
538
+ } catch {}
539
+
540
+ if (!(await this.fs.exists(join(root, browserEntry)))) {
541
+ await this.fs.writeFile(join(root, browserEntry), mainBrowserTs());
542
+ }
543
+
544
+ if (!(await this.fs.exists(join(root, serverEntry)))) {
545
+ await this.fs.writeFile(join(root, serverEntry), mainBrowserTs());
546
+ }
547
+
548
+ if (!(await this.fs.exists(join(root, appRouter)))) {
549
+ await this.fs.writeFile(join(root, appRouter), appRouterTs());
550
+ }
544
551
  }
545
552
 
546
553
  public async hasDir(root: string, dirName: string): Promise<boolean> {
@@ -559,6 +566,5 @@ ${models.map((it: string) => `export const ${it} = models["${it}"];`).join("\n")
559
566
 
560
567
  export interface DependencyModes {
561
568
  react?: boolean;
562
- // testing?: boolean;
563
- // ui?: boolean;
569
+ admin?: boolean;
564
570
  }
@@ -297,7 +297,7 @@ export class DrizzleKitProvider {
297
297
  * Try to load the official Drizzle Kit API.
298
298
  * If not available, fallback to the local kit import.
299
299
  */
300
- protected importDrizzleKit(): typeof DrizzleKit {
300
+ public importDrizzleKit(): typeof DrizzleKit {
301
301
  try {
302
302
  return createRequire(import.meta.url)("drizzle-kit/api");
303
303
  } catch (_) {
@@ -76,18 +76,20 @@ export class RetryDescriptor<
76
76
  T extends (...args: any[]) => any,
77
77
  > extends Descriptor<RetryDescriptorOptions<T>> {
78
78
  protected readonly retryProvider = $inject(RetryProvider);
79
- protected appAbortController: AbortController;
79
+ protected appAbortController?: AbortController;
80
80
 
81
81
  constructor(args: DescriptorArgs<RetryDescriptorOptions<T>>) {
82
82
  super(args);
83
83
 
84
- this.appAbortController = new AbortController();
85
84
  this.alepha.events.on("stop", () => {
86
- this.appAbortController.abort();
85
+ this.appAbortController?.abort();
87
86
  });
88
87
  }
89
88
 
90
89
  async run(...args: Parameters<T>): Promise<ReturnType<T>> {
90
+ // Nov 25: Cloudflare does not like 'new AbortController' outside main handler, we can't pre-create it in the constructor.
91
+ this.appAbortController ??= new AbortController();
92
+
91
93
  return this.retryProvider.retry(
92
94
  {
93
95
  ...this.options,
@@ -67,7 +67,7 @@ export class NodeHttpServerProvider extends ServerProvider {
67
67
  return createServer(
68
68
  {
69
69
  // nov 25 - keep connections alive for better performance, cuz we http/1.1 by default
70
- keepAlive: true,
70
+ keepAlive: this.alepha.isProduction(),
71
71
  },
72
72
  func,
73
73
  );
@@ -43,10 +43,8 @@ const getServerEntry = async (
43
43
  }
44
44
 
45
45
  const maybeEntry = [
46
- "src/index.server.ts",
47
46
  "src/main.server.ts",
48
47
  "src/server-entry.ts",
49
- "src/index.server.tsx",
50
48
  "src/main.server.tsx",
51
49
  "src/server-entry.tsx",
52
50
  "src/main.ts",
@@ -68,7 +66,9 @@ const getServerEntry = async (
68
66
  return clientEntry;
69
67
  }
70
68
 
71
- throw new AlephaError(`Could not find a server entry file.`);
69
+ throw new AlephaError(
70
+ `Could not find a server entry file. List of supported entry file: ${maybeEntry.join(", ")}`,
71
+ );
72
72
  };
73
73
 
74
74
  /**