alepha 0.13.5 → 0.13.7

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 (136) hide show
  1. package/dist/api-audits/index.browser.js +116 -0
  2. package/dist/api-audits/index.browser.js.map +1 -0
  3. package/dist/api-audits/index.d.ts +1194 -0
  4. package/dist/api-audits/index.js +674 -0
  5. package/dist/api-audits/index.js.map +1 -0
  6. package/dist/api-notifications/index.d.ts +147 -147
  7. package/dist/api-parameters/index.browser.js +36 -5
  8. package/dist/api-parameters/index.browser.js.map +1 -1
  9. package/dist/api-parameters/index.d.ts +711 -33
  10. package/dist/api-parameters/index.js +831 -17
  11. package/dist/api-parameters/index.js.map +1 -1
  12. package/dist/api-users/index.d.ts +16 -3
  13. package/dist/api-users/index.js +699 -19
  14. package/dist/api-users/index.js.map +1 -1
  15. package/dist/api-verifications/index.js +2 -1
  16. package/dist/api-verifications/index.js.map +1 -1
  17. package/dist/bin/index.js +1 -0
  18. package/dist/bin/index.js.map +1 -1
  19. package/dist/cli/index.d.ts +85 -31
  20. package/dist/cli/index.js +205 -33
  21. package/dist/cli/index.js.map +1 -1
  22. package/dist/command/index.d.ts +67 -6
  23. package/dist/command/index.js +30 -3
  24. package/dist/command/index.js.map +1 -1
  25. package/dist/core/index.browser.js +241 -61
  26. package/dist/core/index.browser.js.map +1 -1
  27. package/dist/core/index.d.ts +170 -90
  28. package/dist/core/index.js +264 -67
  29. package/dist/core/index.js.map +1 -1
  30. package/dist/core/index.native.js +248 -65
  31. package/dist/core/index.native.js.map +1 -1
  32. package/dist/email/index.js +15 -10554
  33. package/dist/email/index.js.map +1 -1
  34. package/dist/logger/index.d.ts +4 -4
  35. package/dist/logger/index.js +77 -72
  36. package/dist/logger/index.js.map +1 -1
  37. package/dist/orm/index.d.ts +5 -1
  38. package/dist/orm/index.js +24 -7
  39. package/dist/orm/index.js.map +1 -1
  40. package/dist/queue/index.d.ts +4 -4
  41. package/dist/redis/index.d.ts +10 -10
  42. package/dist/security/index.d.ts +28 -28
  43. package/dist/server/index.d.ts +10 -1
  44. package/dist/server/index.js +20 -6
  45. package/dist/server/index.js.map +1 -1
  46. package/dist/server-auth/index.d.ts +163 -152
  47. package/dist/server-auth/index.js +40 -10
  48. package/dist/server-auth/index.js.map +1 -1
  49. package/dist/server-cookies/index.js +5 -1
  50. package/dist/server-cookies/index.js.map +1 -1
  51. package/dist/server-links/index.d.ts +33 -33
  52. package/dist/server-security/index.d.ts +9 -9
  53. package/dist/thread/index.js +2 -2
  54. package/dist/thread/index.js.map +1 -1
  55. package/dist/vite/index.d.ts +2 -2
  56. package/dist/vite/index.js +102 -45
  57. package/dist/vite/index.js.map +1 -1
  58. package/dist/websocket/index.browser.js +3 -3
  59. package/dist/websocket/index.browser.js.map +1 -1
  60. package/dist/websocket/index.d.ts +7 -7
  61. package/dist/websocket/index.js +4 -4
  62. package/dist/websocket/index.js.map +1 -1
  63. package/package.json +14 -9
  64. package/src/api-audits/controllers/AuditController.ts +186 -0
  65. package/src/api-audits/entities/audits.ts +132 -0
  66. package/src/api-audits/index.browser.ts +18 -0
  67. package/src/api-audits/index.ts +58 -0
  68. package/src/api-audits/primitives/$audit.ts +159 -0
  69. package/src/api-audits/schemas/auditQuerySchema.ts +23 -0
  70. package/src/api-audits/schemas/auditResourceSchema.ts +9 -0
  71. package/src/api-audits/schemas/createAuditSchema.ts +27 -0
  72. package/src/api-audits/services/AuditService.ts +412 -0
  73. package/src/api-parameters/controllers/ConfigController.ts +324 -0
  74. package/src/api-parameters/entities/parameters.ts +93 -10
  75. package/src/api-parameters/index.ts +43 -4
  76. package/src/api-parameters/primitives/$config.ts +291 -19
  77. package/src/api-parameters/schedulers/ConfigActivationScheduler.ts +30 -0
  78. package/src/api-parameters/services/ConfigStore.ts +491 -0
  79. package/src/api-users/atoms/realmAuthSettingsAtom.ts +19 -0
  80. package/src/api-users/controllers/UserRealmController.ts +0 -2
  81. package/src/api-users/index.ts +2 -0
  82. package/src/api-users/primitives/$userRealm.ts +18 -3
  83. package/src/api-users/providers/UserRealmProvider.ts +6 -3
  84. package/src/api-users/services/RegistrationService.ts +2 -1
  85. package/src/api-users/services/SessionService.ts +4 -0
  86. package/src/api-users/services/UserService.ts +3 -0
  87. package/src/api-verifications/index.ts +7 -1
  88. package/src/bin/index.ts +1 -0
  89. package/src/cli/assets/biomeJson.ts +1 -1
  90. package/src/cli/assets/dummySpecTs.ts +7 -0
  91. package/src/cli/assets/editorconfig.ts +13 -0
  92. package/src/cli/assets/mainTs.ts +14 -0
  93. package/src/cli/commands/BiomeCommands.ts +2 -0
  94. package/src/cli/commands/CoreCommands.ts +28 -9
  95. package/src/cli/commands/VerifyCommands.ts +2 -1
  96. package/src/cli/commands/ViteCommands.ts +8 -9
  97. package/src/cli/services/AlephaCliUtils.ts +214 -23
  98. package/src/command/helpers/Asker.ts +0 -1
  99. package/src/command/primitives/$command.ts +67 -0
  100. package/src/command/providers/CliProvider.ts +39 -8
  101. package/src/core/Alepha.ts +40 -30
  102. package/src/core/helpers/jsonSchemaToTypeBox.ts +307 -0
  103. package/src/core/index.shared.ts +1 -0
  104. package/src/core/index.ts +30 -3
  105. package/src/core/providers/EventManager.ts +1 -1
  106. package/src/core/providers/StateManager.ts +23 -12
  107. package/src/core/providers/TypeProvider.ts +26 -34
  108. package/src/logger/index.ts +8 -6
  109. package/src/logger/primitives/$logger.ts +1 -1
  110. package/src/logger/providers/{SimpleFormatterProvider.ts → PrettyFormatterProvider.ts} +10 -1
  111. package/src/orm/index.ts +6 -0
  112. package/src/orm/services/PgRelationManager.ts +2 -2
  113. package/src/orm/services/PostgresModelBuilder.ts +11 -7
  114. package/src/orm/services/Repository.ts +16 -7
  115. package/src/orm/services/SqliteModelBuilder.ts +10 -0
  116. package/src/server/index.ts +6 -0
  117. package/src/server/primitives/$action.ts +10 -1
  118. package/src/server/providers/ServerBodyParserProvider.ts +11 -5
  119. package/src/server/providers/ServerRouterProvider.ts +13 -7
  120. package/src/server-auth/primitives/$auth.ts +7 -0
  121. package/src/server-auth/providers/ServerAuthProvider.ts +51 -8
  122. package/src/server-cookies/index.ts +2 -1
  123. package/src/thread/primitives/$thread.ts +2 -2
  124. package/src/vite/index.ts +0 -2
  125. package/src/vite/tasks/buildServer.ts +3 -4
  126. package/src/vite/tasks/generateCloudflare.ts +35 -19
  127. package/src/vite/tasks/generateDocker.ts +18 -4
  128. package/src/vite/tasks/generateSitemap.ts +5 -7
  129. package/src/vite/tasks/generateVercel.ts +76 -41
  130. package/src/vite/tasks/runAlepha.ts +16 -1
  131. package/src/websocket/providers/NodeWebSocketServerProvider.ts +3 -11
  132. package/src/websocket/services/WebSocketClient.ts +3 -3
  133. package/dist/cli/dist-BlfFtOk2.js +0 -2770
  134. package/dist/cli/dist-BlfFtOk2.js.map +0 -1
  135. package/src/api-parameters/controllers/ParameterController.ts +0 -45
  136. package/src/api-parameters/services/ParameterStore.ts +0 -23
@@ -2,11 +2,10 @@ import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import cluster from "node:cluster";
3
3
  import { cpus } from "node:os";
4
4
  import { Compile } from "typebox/compile";
5
- import * as TypeBox from "typebox";
6
5
  import { Type } from "typebox";
7
- import TypeBoxFormat from "typebox/format";
6
+ import Format from "typebox/format";
8
7
  import { Locale } from "typebox/system";
9
- import * as TypeBoxValue from "typebox/value";
8
+ import * as Value from "typebox/value";
10
9
 
11
10
  //#region ../../src/core/constants/KIND.ts
12
11
  /**
@@ -700,7 +699,7 @@ var StateManager = class {
700
699
  const key = atom.key;
701
700
  if (!this.atoms.has(key)) {
702
701
  this.atoms.set(key, atom);
703
- if (!(key in this.store)) this.set(key, atom.options.default);
702
+ if (!(key in this.store)) this.set(key, atom.options.default, { skipContext: true });
704
703
  }
705
704
  return this;
706
705
  }
@@ -710,15 +709,15 @@ var StateManager = class {
710
709
  const store = this.store;
711
710
  return this.als?.exists() ? this.als.get(key) ?? store[key] : store[key];
712
711
  }
713
- set(target, value) {
712
+ set(target, value, options) {
714
713
  if (target instanceof Atom) this.register(target);
715
714
  const key = target instanceof Atom ? target.key : target;
716
715
  const store = this.store;
717
716
  const prevValue = this.get(key);
718
717
  if (prevValue === value) return this;
719
- if (this.als?.exists()) this.als.set(key, value);
718
+ if (options?.skipContext !== true && this.als?.exists()) this.als.set(key, value);
720
719
  else store[key] = value;
721
- this.events?.emit("state:mutate", {
720
+ if (options?.skipEvents !== true) this.events?.emit("state:mutate", {
722
721
  key,
723
722
  value,
724
723
  prevValue
@@ -744,9 +743,9 @@ var StateManager = class {
744
743
  /**
745
744
  * Push a value to an array in the state
746
745
  */
747
- push(key, value) {
746
+ push(key, ...value) {
748
747
  const current = this.get(key) ?? [];
749
- if (Array.isArray(current)) this.set(key, [...current, value]);
748
+ if (Array.isArray(current)) this.set(key, [...current, ...value]);
750
749
  return this;
751
750
  }
752
751
  /**
@@ -899,10 +898,13 @@ var Alepha = class Alepha {
899
898
  * If you are not interested about these helpers, you can use the constructor directly.
900
899
  */
901
900
  static create(state = {}) {
902
- if (typeof process === "object" && typeof process.env === "object") state.env = {
903
- ...state.env,
904
- ...process.env
905
- };
901
+ if (typeof process === "object" && typeof process.env === "object") {
902
+ state.env = {
903
+ ...state.env,
904
+ ...process.env
905
+ };
906
+ if (process.env.NODE_ENV === "production") state.env.NODE_ENV ??= "production";
907
+ }
906
908
  const alepha = new Alepha(state);
907
909
  if (alepha.isTest()) {
908
910
  const g = globalThis;
@@ -941,12 +943,6 @@ var Alepha = class Alepha {
941
943
  */
942
944
  starting;
943
945
  /**
944
- * Initial state of the container.
945
- *
946
- * > Used to initialize the StateManager.
947
- */
948
- init;
949
- /**
950
946
  * During the instantiation process, we keep a list of pending instantiations.
951
947
  * > It allows us to detect circular dependencies.
952
948
  */
@@ -983,30 +979,21 @@ var Alepha = class Alepha {
983
979
  *
984
980
  * Mocked for browser environments.
985
981
  */
986
- get context() {
987
- return this.inject(AlsProvider);
988
- }
982
+ context;
989
983
  /**
990
984
  * Event manager to handle lifecycle events and custom events.
991
985
  */
992
- get events() {
993
- return this.inject(EventManager, { args: [() => this.log] });
994
- }
986
+ events;
995
987
  /**
996
988
  * State manager to store arbitrary values.
997
989
  */
998
- get store() {
999
- this.events;
1000
- return this.inject(StateManager, { args: [this.init] });
1001
- }
990
+ store;
1002
991
  /**
1003
992
  * Codec manager for encoding and decoding data with different formats.
1004
993
  *
1005
994
  * Supports multiple codec formats (JSON, Protobuf, etc.) with a unified interface.
1006
995
  */
1007
- get codec() {
1008
- return this.inject(CodecManager);
1009
- }
996
+ codec;
1010
997
  /**
1011
998
  * Get logger instance.
1012
999
  */
@@ -1019,8 +1006,12 @@ var Alepha = class Alepha {
1019
1006
  get env() {
1020
1007
  return this.store.get("env") ?? {};
1021
1008
  }
1022
- constructor(init = {}) {
1023
- this.init = init;
1009
+ constructor(state = {}) {
1010
+ this.store = this.inject(StateManager, { args: [state] });
1011
+ this.events = this.inject(EventManager);
1012
+ this.events.logFn = () => this.log;
1013
+ this.context = this.inject(AlsProvider);
1014
+ this.codec = this.inject(CodecManager);
1024
1015
  }
1025
1016
  set(target, value) {
1026
1017
  this.store.set(target, value);
@@ -1087,7 +1078,7 @@ var Alepha = class Alepha {
1087
1078
  isServerless() {
1088
1079
  if (this.isBrowser()) return false;
1089
1080
  if (this.env.VERCEL_REGION) return true;
1090
- if (this.env.ALEPHA_SERVERLESS) return true;
1081
+ if (typeof global === "object" && typeof global.Cloudflare === "object") return true;
1091
1082
  return false;
1092
1083
  }
1093
1084
  /**
@@ -1125,7 +1116,6 @@ var Alepha = class Alepha {
1125
1116
  this.log?.warn("App is already starting, waiting for it to finish...");
1126
1117
  return this.starting.promise;
1127
1118
  }
1128
- this.codec;
1129
1119
  this.starting = Promise.withResolvers();
1130
1120
  const now = Date.now();
1131
1121
  this.log?.info("Starting App...");
@@ -1305,6 +1295,19 @@ var Alepha = class Alepha {
1305
1295
  return config;
1306
1296
  }
1307
1297
  /**
1298
+ * Get all environment variable schemas and their parsed values.
1299
+ *
1300
+ * This is useful for DevTools to display all expected environment variables.
1301
+ */
1302
+ getEnvSchemas() {
1303
+ const result = [];
1304
+ for (const [schema, values] of this.cacheEnv.entries()) result.push({
1305
+ schema,
1306
+ values
1307
+ });
1308
+ return result;
1309
+ }
1310
+ /**
1308
1311
  * Dump the current dependency graph of the App.
1309
1312
  *
1310
1313
  * This method returns a record where the keys are the names of the services.
@@ -1459,33 +1462,27 @@ const isFileLike = (value) => {
1459
1462
 
1460
1463
  //#endregion
1461
1464
  //#region ../../src/core/providers/TypeProvider.ts
1462
- const isUUID = TypeBoxFormat.IsUuid;
1463
- const isEmail = TypeBoxFormat.IsEmail;
1464
- const isURL = TypeBoxFormat.IsUrl;
1465
- const isDateTime = TypeBoxFormat.IsDateTime;
1466
- const isDate = TypeBoxFormat.IsDate;
1467
- const isTime = TypeBoxFormat.IsTime;
1468
- const isDuration = TypeBoxFormat.IsDuration;
1465
+ const isUUID = Format.IsUuid;
1469
1466
  var TypeGuard = class {
1470
- isBigInt = (value) => TypeBox.IsString(value) && "format" in value && value.format === "bigint";
1471
- isUUID = (value) => TypeBox.IsString(value) && "format" in value && value.format === "uuid";
1472
- isObject = TypeBox.IsObject;
1473
- isNumber = TypeBox.IsNumber;
1474
- isString = TypeBox.IsString;
1475
- isBoolean = TypeBox.IsBoolean;
1476
- isAny = TypeBox.IsAny;
1477
- isArray = TypeBox.IsArray;
1478
- isOptional = TypeBox.IsOptional;
1479
- isUnion = TypeBox.IsUnion;
1480
- isInteger = TypeBox.IsInteger;
1481
- isNull = TypeBox.IsNull;
1482
- isUndefined = TypeBox.IsUndefined;
1483
- isUnsafe = TypeBox.IsUnsafe;
1484
- isRecord = TypeBox.IsRecord;
1485
- isTuple = TypeBox.IsTuple;
1486
- isVoid = TypeBox.IsVoid;
1487
- isLiteral = TypeBox.IsLiteral;
1488
- isSchema = TypeBox.IsSchema;
1467
+ isBigInt = (value) => Type.IsString(value) && "format" in value && value.format === "bigint";
1468
+ isUUID = (value) => Type.IsString(value) && "format" in value && value.format === "uuid";
1469
+ isObject = Type.IsObject;
1470
+ isNumber = Type.IsNumber;
1471
+ isString = Type.IsString;
1472
+ isBoolean = Type.IsBoolean;
1473
+ isAny = Type.IsAny;
1474
+ isArray = Type.IsArray;
1475
+ isOptional = Type.IsOptional;
1476
+ isUnion = Type.IsUnion;
1477
+ isInteger = Type.IsInteger;
1478
+ isNull = Type.IsNull;
1479
+ isUndefined = Type.IsUndefined;
1480
+ isUnsafe = Type.IsUnsafe;
1481
+ isRecord = Type.IsRecord;
1482
+ isTuple = Type.IsTuple;
1483
+ isVoid = Type.IsVoid;
1484
+ isLiteral = Type.IsLiteral;
1485
+ isSchema = Type.IsSchema;
1489
1486
  isFile = isTypeFile;
1490
1487
  isDateTime = (schema) => {
1491
1488
  return t.schema.isString(schema) && schema.format === "date-time";
@@ -1501,9 +1498,9 @@ var TypeGuard = class {
1501
1498
  };
1502
1499
  };
1503
1500
  var TypeProvider = class TypeProvider {
1504
- static format = TypeBoxFormat;
1501
+ static format = Format;
1505
1502
  static {
1506
- TypeBoxFormat.Set("bigint", (value) => TypeProvider.isValidBigInt(value));
1503
+ Format.Set("bigint", (value) => TypeProvider.isValidBigInt(value));
1507
1504
  }
1508
1505
  static translateError(error, locale) {
1509
1506
  if (!locale) return error.cause.message;
@@ -1902,6 +1899,192 @@ var TypeProvider = class TypeProvider {
1902
1899
  };
1903
1900
  const t = new TypeProvider();
1904
1901
 
1902
+ //#endregion
1903
+ //#region ../../src/core/helpers/jsonSchemaToTypeBox.ts
1904
+ /**
1905
+ * Converts a JSON Schema object to a TypeBox schema using Alepha's type system.
1906
+ *
1907
+ * This is useful when receiving JSON Schema from an API (e.g., configuration schemas)
1908
+ * and needing to use them with TypeBox-based form rendering or validation.
1909
+ *
1910
+ * **Supports:**
1911
+ * - Basic types: string, number, integer, boolean, null, object, array
1912
+ * - String formats: email, uuid, date-time, date, time, url/uri, binary, bigint, duration, color
1913
+ * - Enums (string enums)
1914
+ * - Nested objects with required/optional properties
1915
+ * - Arrays with item schemas
1916
+ * - Common validation options: minLength, maxLength, minimum, maximum, pattern
1917
+ *
1918
+ * **Not supported:**
1919
+ * - oneOf, anyOf, allOf, not (composition schemas)
1920
+ * - $ref (references)
1921
+ * - additionalProperties, patternProperties
1922
+ *
1923
+ * @param schema - JSON Schema object to convert
1924
+ * @returns TypeBox TSchema
1925
+ *
1926
+ * @example
1927
+ * ```ts
1928
+ * const jsonSchema = {
1929
+ * type: "object",
1930
+ * properties: {
1931
+ * email: { type: "string", format: "email" },
1932
+ * age: { type: "integer", minimum: 0 },
1933
+ * active: { type: "boolean" },
1934
+ * },
1935
+ * required: ["email"]
1936
+ * };
1937
+ *
1938
+ * const typeBoxSchema = jsonSchemaToTypeBox(jsonSchema);
1939
+ * // Equivalent to:
1940
+ * // t.object({
1941
+ * // email: t.email(),
1942
+ * // age: t.optional(t.integer({ minimum: 0 })),
1943
+ * // active: t.optional(t.boolean()),
1944
+ * // })
1945
+ * ```
1946
+ */
1947
+ function jsonSchemaToTypeBox(schema) {
1948
+ if (schema["~kind"]) return schema;
1949
+ if (schema.const !== void 0) return t.const(schema.const);
1950
+ if (schema.enum && Array.isArray(schema.enum)) {
1951
+ if (schema.enum.every((v) => typeof v === "string")) return t.enum(schema.enum, filterUndefined({
1952
+ title: schema.title,
1953
+ description: schema.description,
1954
+ default: schema.default
1955
+ }));
1956
+ return t.union(schema.enum.map((v) => t.const(v)));
1957
+ }
1958
+ switch (Array.isArray(schema.type) ? schema.type[0] : schema.type) {
1959
+ case "string": return convertString(schema);
1960
+ case "number": return convertNumber(schema);
1961
+ case "integer": return convertInteger(schema);
1962
+ case "boolean": return convertBoolean(schema);
1963
+ case "null": return t.null();
1964
+ case "object": return convertObject(schema);
1965
+ case "array": return convertArray(schema);
1966
+ default:
1967
+ if (schema.properties) return convertObject(schema);
1968
+ return t.any();
1969
+ }
1970
+ }
1971
+ /**
1972
+ * Remove undefined values from an object.
1973
+ */
1974
+ function filterUndefined(obj) {
1975
+ return Object.fromEntries(Object.entries(obj).filter(([_, v]) => v !== void 0));
1976
+ }
1977
+ /**
1978
+ * Convert JSON Schema string type to TypeBox.
1979
+ */
1980
+ function convertString(schema) {
1981
+ const options = filterUndefined({
1982
+ title: schema.title,
1983
+ description: schema.description,
1984
+ default: schema.default,
1985
+ minLength: schema.minLength,
1986
+ maxLength: schema.maxLength,
1987
+ pattern: schema.pattern
1988
+ });
1989
+ switch (schema.format) {
1990
+ case "email": return t.email(options);
1991
+ case "uuid": return t.uuid(options);
1992
+ case "date-time": return t.datetime(options);
1993
+ case "date": return t.date(options);
1994
+ case "time": return t.time(options);
1995
+ case "url":
1996
+ case "uri": return t.url(options);
1997
+ case "binary": return t.binary(options);
1998
+ case "bigint": return t.bigint(options);
1999
+ case "duration": return t.duration(options);
2000
+ case "color": return t.text({
2001
+ ...options,
2002
+ format: "color"
2003
+ });
2004
+ case "e164": return t.e164(options);
2005
+ case "bcp47": return t.bcp47(options);
2006
+ default:
2007
+ if (schema.format) return t.text({
2008
+ ...options,
2009
+ format: schema.format
2010
+ });
2011
+ return t.text(options);
2012
+ }
2013
+ }
2014
+ /**
2015
+ * Convert JSON Schema number type to TypeBox.
2016
+ */
2017
+ function convertNumber(schema) {
2018
+ return t.number(filterUndefined({
2019
+ title: schema.title,
2020
+ description: schema.description,
2021
+ default: schema.default,
2022
+ minimum: schema.minimum,
2023
+ maximum: schema.maximum,
2024
+ exclusiveMinimum: schema.exclusiveMinimum,
2025
+ exclusiveMaximum: schema.exclusiveMaximum,
2026
+ multipleOf: schema.multipleOf
2027
+ }));
2028
+ }
2029
+ /**
2030
+ * Convert JSON Schema integer type to TypeBox.
2031
+ */
2032
+ function convertInteger(schema) {
2033
+ return t.integer(filterUndefined({
2034
+ title: schema.title,
2035
+ description: schema.description,
2036
+ default: schema.default,
2037
+ minimum: schema.minimum,
2038
+ maximum: schema.maximum,
2039
+ exclusiveMinimum: schema.exclusiveMinimum,
2040
+ exclusiveMaximum: schema.exclusiveMaximum,
2041
+ multipleOf: schema.multipleOf
2042
+ }));
2043
+ }
2044
+ /**
2045
+ * Convert JSON Schema boolean type to TypeBox.
2046
+ */
2047
+ function convertBoolean(schema) {
2048
+ return t.boolean(filterUndefined({
2049
+ title: schema.title,
2050
+ description: schema.description,
2051
+ default: schema.default
2052
+ }));
2053
+ }
2054
+ /**
2055
+ * Convert JSON Schema object type to TypeBox.
2056
+ */
2057
+ function convertObject(schema) {
2058
+ if (!schema.properties) return t.json(filterUndefined({
2059
+ title: schema.title,
2060
+ description: schema.description
2061
+ }));
2062
+ const required = new Set(schema.required ?? []);
2063
+ const properties = {};
2064
+ for (const [key, propSchema] of Object.entries(schema.properties)) {
2065
+ let converted = jsonSchemaToTypeBox(propSchema);
2066
+ if (!required.has(key)) converted = t.optional(converted);
2067
+ properties[key] = converted;
2068
+ }
2069
+ return t.object(properties, filterUndefined({
2070
+ title: schema.title,
2071
+ description: schema.description
2072
+ }));
2073
+ }
2074
+ /**
2075
+ * Convert JSON Schema array type to TypeBox.
2076
+ */
2077
+ function convertArray(schema) {
2078
+ const itemSchema = schema.items ? jsonSchemaToTypeBox(schema.items) : t.any();
2079
+ return t.array(itemSchema, filterUndefined({
2080
+ title: schema.title,
2081
+ description: schema.description,
2082
+ minItems: schema.minItems,
2083
+ maxItems: schema.maxItems,
2084
+ uniqueItems: schema.uniqueItems
2085
+ }));
2086
+ }
2087
+
1905
2088
  //#endregion
1906
2089
  //#region ../../src/core/primitives/$env.ts
1907
2090
  /**
@@ -2094,6 +2277,20 @@ TypeProvider.prototype.page = (itemSchema) => pageSchema(itemSchema);
2094
2277
 
2095
2278
  //#endregion
2096
2279
  //#region ../../src/core/index.ts
2280
+ const AlephaCore = $module({
2281
+ name: "alepha.core",
2282
+ services: [
2283
+ StateManager,
2284
+ CodecManager,
2285
+ EventManager,
2286
+ AlsProvider,
2287
+ Json,
2288
+ JsonSchemaCodec,
2289
+ SchemaCodec,
2290
+ SchemaValidator
2291
+ ],
2292
+ register: () => {}
2293
+ });
2097
2294
  /**
2098
2295
  * Run Alepha application, trigger start lifecycle.
2099
2296
  *
@@ -2125,7 +2322,7 @@ const run = (entry, opts) => {
2125
2322
  withCluster(entry, opts);
2126
2323
  return alepha;
2127
2324
  }
2128
- (async () => {
2325
+ setTimeout(async () => {
2129
2326
  try {
2130
2327
  await opts?.configure?.(alepha);
2131
2328
  await alepha.start();
@@ -2155,7 +2352,7 @@ const run = (entry, opts) => {
2155
2352
  alepha.log?.error("Alepha failed to start", error);
2156
2353
  if (typeof process === "object") process.exit(1);
2157
2354
  }
2158
- })();
2355
+ });
2159
2356
  return alepha;
2160
2357
  };
2161
2358
  AlsProvider.create = () => new AsyncLocalStorage();
@@ -2176,5 +2373,5 @@ const withCluster = (entry, opts) => {
2176
2373
  };
2177
2374
 
2178
2375
  //#endregion
2179
- export { $atom, $context, $env, $hook, $inject, $module, $use, Alepha, AlephaError, AlsProvider, AppNotStartedError, Atom, CircularDependencyError, CodecManager, ContainerLockedError, EventManager, HookPrimitive, InjectPrimitive, JsonSchemaCodec, KIND, Module, OPTIONS, Primitive, SchemaCodec, StateManager, TooLateSubstitutionError, TypeBox, TypeBoxError, TypeBoxFormat, TypeBoxValue, TypeGuard, TypeProvider, createPagination, createPrimitive, isClass, isDate, isDateTime, isDuration, isEmail, isFileLike, isTime, isTypeFile, isURL, isUUID, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
2376
+ export { $atom, $context, $env, $hook, $inject, $module, $use, Alepha, AlephaCore, AlephaError, AlsProvider, AppNotStartedError, Atom, CircularDependencyError, CodecManager, ContainerLockedError, EventManager, Format, HookPrimitive, InjectPrimitive, JsonSchemaCodec, KIND, Module, OPTIONS, Primitive, SchemaCodec, StateManager, TooLateSubstitutionError, Type, TypeBoxError, TypeGuard, TypeProvider, Value, createPagination, createPrimitive, isClass, isFileLike, isTypeFile, isUUID, jsonSchemaToTypeBox, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
2180
2377
  //# sourceMappingURL=index.js.map