alepha 0.13.6 → 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.
- package/dist/api-audits/index.browser.js +116 -0
- package/dist/api-audits/index.browser.js.map +1 -0
- package/dist/api-audits/index.d.ts +1194 -0
- package/dist/api-audits/index.js +674 -0
- package/dist/api-audits/index.js.map +1 -0
- package/dist/api-notifications/index.d.ts +147 -147
- package/dist/api-parameters/index.browser.js +36 -5
- package/dist/api-parameters/index.browser.js.map +1 -1
- package/dist/api-parameters/index.d.ts +711 -33
- package/dist/api-parameters/index.js +831 -17
- package/dist/api-parameters/index.js.map +1 -1
- package/dist/api-users/index.d.ts +793 -780
- package/dist/api-users/index.js +699 -19
- package/dist/api-users/index.js.map +1 -1
- package/dist/api-verifications/index.js +2 -1
- package/dist/api-verifications/index.js.map +1 -1
- package/dist/bin/index.js +1 -0
- package/dist/bin/index.js.map +1 -1
- package/dist/cli/index.d.ts +85 -31
- package/dist/cli/index.js +205 -33
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +67 -6
- package/dist/command/index.js +30 -3
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +241 -61
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +170 -90
- package/dist/core/index.js +264 -67
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +248 -65
- package/dist/core/index.native.js.map +1 -1
- package/dist/email/index.js +15 -10554
- package/dist/email/index.js.map +1 -1
- package/dist/logger/index.d.ts +4 -4
- package/dist/logger/index.js +77 -72
- package/dist/logger/index.js.map +1 -1
- package/dist/orm/index.d.ts +5 -1
- package/dist/orm/index.js +24 -7
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/index.d.ts +4 -4
- package/dist/scheduler/index.d.ts +6 -6
- package/dist/server/index.d.ts +10 -1
- package/dist/server/index.js +20 -6
- package/dist/server/index.js.map +1 -1
- package/dist/server-auth/index.d.ts +163 -152
- package/dist/server-auth/index.js +40 -10
- package/dist/server-auth/index.js.map +1 -1
- package/dist/server-cookies/index.js +5 -1
- package/dist/server-cookies/index.js.map +1 -1
- package/dist/server-links/index.d.ts +33 -33
- package/dist/server-security/index.d.ts +9 -9
- package/dist/thread/index.js +2 -2
- package/dist/thread/index.js.map +1 -1
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +102 -45
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +3 -3
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.js +4 -4
- package/dist/websocket/index.js.map +1 -1
- package/package.json +14 -9
- package/src/api-audits/controllers/AuditController.ts +186 -0
- package/src/api-audits/entities/audits.ts +132 -0
- package/src/api-audits/index.browser.ts +18 -0
- package/src/api-audits/index.ts +58 -0
- package/src/api-audits/primitives/$audit.ts +159 -0
- package/src/api-audits/schemas/auditQuerySchema.ts +23 -0
- package/src/api-audits/schemas/auditResourceSchema.ts +9 -0
- package/src/api-audits/schemas/createAuditSchema.ts +27 -0
- package/src/api-audits/services/AuditService.ts +412 -0
- package/src/api-parameters/controllers/ConfigController.ts +324 -0
- package/src/api-parameters/entities/parameters.ts +93 -10
- package/src/api-parameters/index.ts +43 -4
- package/src/api-parameters/primitives/$config.ts +291 -19
- package/src/api-parameters/schedulers/ConfigActivationScheduler.ts +30 -0
- package/src/api-parameters/services/ConfigStore.ts +491 -0
- package/src/api-users/atoms/realmAuthSettingsAtom.ts +19 -0
- package/src/api-users/controllers/UserRealmController.ts +0 -2
- package/src/api-users/index.ts +2 -0
- package/src/api-users/primitives/$userRealm.ts +18 -3
- package/src/api-users/providers/UserRealmProvider.ts +6 -3
- package/src/api-users/services/RegistrationService.ts +2 -1
- package/src/api-users/services/SessionService.ts +4 -0
- package/src/api-users/services/UserService.ts +3 -0
- package/src/api-verifications/index.ts +7 -1
- package/src/bin/index.ts +1 -0
- package/src/cli/assets/biomeJson.ts +1 -1
- package/src/cli/assets/dummySpecTs.ts +7 -0
- package/src/cli/assets/editorconfig.ts +13 -0
- package/src/cli/assets/mainTs.ts +14 -0
- package/src/cli/commands/BiomeCommands.ts +2 -0
- package/src/cli/commands/CoreCommands.ts +28 -9
- package/src/cli/commands/VerifyCommands.ts +2 -1
- package/src/cli/commands/ViteCommands.ts +8 -9
- package/src/cli/services/AlephaCliUtils.ts +214 -23
- package/src/command/helpers/Asker.ts +0 -1
- package/src/command/primitives/$command.ts +67 -0
- package/src/command/providers/CliProvider.ts +39 -8
- package/src/core/Alepha.ts +40 -30
- package/src/core/helpers/jsonSchemaToTypeBox.ts +307 -0
- package/src/core/index.shared.ts +1 -0
- package/src/core/index.ts +30 -3
- package/src/core/providers/EventManager.ts +1 -1
- package/src/core/providers/StateManager.ts +23 -12
- package/src/core/providers/TypeProvider.ts +26 -34
- package/src/logger/index.ts +8 -6
- package/src/logger/primitives/$logger.ts +1 -1
- package/src/logger/providers/{SimpleFormatterProvider.ts → PrettyFormatterProvider.ts} +10 -1
- package/src/orm/index.ts +6 -0
- package/src/orm/services/PgRelationManager.ts +2 -2
- package/src/orm/services/PostgresModelBuilder.ts +11 -7
- package/src/orm/services/Repository.ts +16 -7
- package/src/orm/services/SqliteModelBuilder.ts +10 -0
- package/src/server/index.ts +6 -0
- package/src/server/primitives/$action.ts +10 -1
- package/src/server/providers/ServerBodyParserProvider.ts +11 -5
- package/src/server/providers/ServerRouterProvider.ts +13 -7
- package/src/server-auth/primitives/$auth.ts +7 -0
- package/src/server-auth/providers/ServerAuthProvider.ts +51 -8
- package/src/server-cookies/index.ts +2 -1
- package/src/thread/primitives/$thread.ts +2 -2
- package/src/vite/index.ts +0 -2
- package/src/vite/tasks/buildServer.ts +3 -4
- package/src/vite/tasks/generateCloudflare.ts +35 -19
- package/src/vite/tasks/generateDocker.ts +18 -4
- package/src/vite/tasks/generateSitemap.ts +5 -7
- package/src/vite/tasks/generateVercel.ts +76 -41
- package/src/vite/tasks/runAlepha.ts +16 -1
- package/src/websocket/providers/NodeWebSocketServerProvider.ts +3 -11
- package/src/websocket/services/WebSocketClient.ts +3 -3
- package/dist/cli/dist-BlfFtOk2.js +0 -2770
- package/dist/cli/dist-BlfFtOk2.js.map +0 -1
- package/src/api-parameters/controllers/ParameterController.ts +0 -45
- package/src/api-parameters/services/ParameterStore.ts +0 -23
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Compile } from "typebox/compile";
|
|
2
|
-
import * as TypeBox from "typebox";
|
|
3
2
|
import { Type } from "typebox";
|
|
4
|
-
import
|
|
3
|
+
import Format from "typebox/format";
|
|
5
4
|
import { Locale } from "typebox/system";
|
|
6
|
-
import * as
|
|
5
|
+
import * as Value from "typebox/value";
|
|
7
6
|
|
|
8
7
|
//#region ../../src/core/constants/KIND.ts
|
|
9
8
|
/**
|
|
@@ -697,7 +696,7 @@ var StateManager = class {
|
|
|
697
696
|
const key = atom.key;
|
|
698
697
|
if (!this.atoms.has(key)) {
|
|
699
698
|
this.atoms.set(key, atom);
|
|
700
|
-
if (!(key in this.store)) this.set(key, atom.options.default);
|
|
699
|
+
if (!(key in this.store)) this.set(key, atom.options.default, { skipContext: true });
|
|
701
700
|
}
|
|
702
701
|
return this;
|
|
703
702
|
}
|
|
@@ -707,15 +706,15 @@ var StateManager = class {
|
|
|
707
706
|
const store = this.store;
|
|
708
707
|
return this.als?.exists() ? this.als.get(key) ?? store[key] : store[key];
|
|
709
708
|
}
|
|
710
|
-
set(target, value) {
|
|
709
|
+
set(target, value, options) {
|
|
711
710
|
if (target instanceof Atom) this.register(target);
|
|
712
711
|
const key = target instanceof Atom ? target.key : target;
|
|
713
712
|
const store = this.store;
|
|
714
713
|
const prevValue = this.get(key);
|
|
715
714
|
if (prevValue === value) return this;
|
|
716
|
-
if (this.als?.exists()) this.als.set(key, value);
|
|
715
|
+
if (options?.skipContext !== true && this.als?.exists()) this.als.set(key, value);
|
|
717
716
|
else store[key] = value;
|
|
718
|
-
this.events?.emit("state:mutate", {
|
|
717
|
+
if (options?.skipEvents !== true) this.events?.emit("state:mutate", {
|
|
719
718
|
key,
|
|
720
719
|
value,
|
|
721
720
|
prevValue
|
|
@@ -741,9 +740,9 @@ var StateManager = class {
|
|
|
741
740
|
/**
|
|
742
741
|
* Push a value to an array in the state
|
|
743
742
|
*/
|
|
744
|
-
push(key, value) {
|
|
743
|
+
push(key, ...value) {
|
|
745
744
|
const current = this.get(key) ?? [];
|
|
746
|
-
if (Array.isArray(current)) this.set(key, [...current, value]);
|
|
745
|
+
if (Array.isArray(current)) this.set(key, [...current, ...value]);
|
|
747
746
|
return this;
|
|
748
747
|
}
|
|
749
748
|
/**
|
|
@@ -896,10 +895,13 @@ var Alepha = class Alepha {
|
|
|
896
895
|
* If you are not interested about these helpers, you can use the constructor directly.
|
|
897
896
|
*/
|
|
898
897
|
static create(state = {}) {
|
|
899
|
-
if (typeof process === "object" && typeof process.env === "object")
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
898
|
+
if (typeof process === "object" && typeof process.env === "object") {
|
|
899
|
+
state.env = {
|
|
900
|
+
...state.env,
|
|
901
|
+
...process.env
|
|
902
|
+
};
|
|
903
|
+
if (process.env.NODE_ENV === "production") state.env.NODE_ENV ??= "production";
|
|
904
|
+
}
|
|
903
905
|
const alepha = new Alepha(state);
|
|
904
906
|
if (alepha.isTest()) {
|
|
905
907
|
const g = globalThis;
|
|
@@ -938,12 +940,6 @@ var Alepha = class Alepha {
|
|
|
938
940
|
*/
|
|
939
941
|
starting;
|
|
940
942
|
/**
|
|
941
|
-
* Initial state of the container.
|
|
942
|
-
*
|
|
943
|
-
* > Used to initialize the StateManager.
|
|
944
|
-
*/
|
|
945
|
-
init;
|
|
946
|
-
/**
|
|
947
943
|
* During the instantiation process, we keep a list of pending instantiations.
|
|
948
944
|
* > It allows us to detect circular dependencies.
|
|
949
945
|
*/
|
|
@@ -980,30 +976,21 @@ var Alepha = class Alepha {
|
|
|
980
976
|
*
|
|
981
977
|
* Mocked for browser environments.
|
|
982
978
|
*/
|
|
983
|
-
|
|
984
|
-
return this.inject(AlsProvider);
|
|
985
|
-
}
|
|
979
|
+
context;
|
|
986
980
|
/**
|
|
987
981
|
* Event manager to handle lifecycle events and custom events.
|
|
988
982
|
*/
|
|
989
|
-
|
|
990
|
-
return this.inject(EventManager, { args: [() => this.log] });
|
|
991
|
-
}
|
|
983
|
+
events;
|
|
992
984
|
/**
|
|
993
985
|
* State manager to store arbitrary values.
|
|
994
986
|
*/
|
|
995
|
-
|
|
996
|
-
this.events;
|
|
997
|
-
return this.inject(StateManager, { args: [this.init] });
|
|
998
|
-
}
|
|
987
|
+
store;
|
|
999
988
|
/**
|
|
1000
989
|
* Codec manager for encoding and decoding data with different formats.
|
|
1001
990
|
*
|
|
1002
991
|
* Supports multiple codec formats (JSON, Protobuf, etc.) with a unified interface.
|
|
1003
992
|
*/
|
|
1004
|
-
|
|
1005
|
-
return this.inject(CodecManager);
|
|
1006
|
-
}
|
|
993
|
+
codec;
|
|
1007
994
|
/**
|
|
1008
995
|
* Get logger instance.
|
|
1009
996
|
*/
|
|
@@ -1016,8 +1003,12 @@ var Alepha = class Alepha {
|
|
|
1016
1003
|
get env() {
|
|
1017
1004
|
return this.store.get("env") ?? {};
|
|
1018
1005
|
}
|
|
1019
|
-
constructor(
|
|
1020
|
-
this.
|
|
1006
|
+
constructor(state = {}) {
|
|
1007
|
+
this.store = this.inject(StateManager, { args: [state] });
|
|
1008
|
+
this.events = this.inject(EventManager);
|
|
1009
|
+
this.events.logFn = () => this.log;
|
|
1010
|
+
this.context = this.inject(AlsProvider);
|
|
1011
|
+
this.codec = this.inject(CodecManager);
|
|
1021
1012
|
}
|
|
1022
1013
|
set(target, value) {
|
|
1023
1014
|
this.store.set(target, value);
|
|
@@ -1084,7 +1075,7 @@ var Alepha = class Alepha {
|
|
|
1084
1075
|
isServerless() {
|
|
1085
1076
|
if (this.isBrowser()) return false;
|
|
1086
1077
|
if (this.env.VERCEL_REGION) return true;
|
|
1087
|
-
if (
|
|
1078
|
+
if (typeof global === "object" && typeof global.Cloudflare === "object") return true;
|
|
1088
1079
|
return false;
|
|
1089
1080
|
}
|
|
1090
1081
|
/**
|
|
@@ -1122,7 +1113,6 @@ var Alepha = class Alepha {
|
|
|
1122
1113
|
this.log?.warn("App is already starting, waiting for it to finish...");
|
|
1123
1114
|
return this.starting.promise;
|
|
1124
1115
|
}
|
|
1125
|
-
this.codec;
|
|
1126
1116
|
this.starting = Promise.withResolvers();
|
|
1127
1117
|
const now = Date.now();
|
|
1128
1118
|
this.log?.info("Starting App...");
|
|
@@ -1302,6 +1292,19 @@ var Alepha = class Alepha {
|
|
|
1302
1292
|
return config;
|
|
1303
1293
|
}
|
|
1304
1294
|
/**
|
|
1295
|
+
* Get all environment variable schemas and their parsed values.
|
|
1296
|
+
*
|
|
1297
|
+
* This is useful for DevTools to display all expected environment variables.
|
|
1298
|
+
*/
|
|
1299
|
+
getEnvSchemas() {
|
|
1300
|
+
const result = [];
|
|
1301
|
+
for (const [schema, values] of this.cacheEnv.entries()) result.push({
|
|
1302
|
+
schema,
|
|
1303
|
+
values
|
|
1304
|
+
});
|
|
1305
|
+
return result;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1305
1308
|
* Dump the current dependency graph of the App.
|
|
1306
1309
|
*
|
|
1307
1310
|
* This method returns a record where the keys are the names of the services.
|
|
@@ -1456,33 +1459,27 @@ const isFileLike = (value) => {
|
|
|
1456
1459
|
|
|
1457
1460
|
//#endregion
|
|
1458
1461
|
//#region ../../src/core/providers/TypeProvider.ts
|
|
1459
|
-
const isUUID =
|
|
1460
|
-
const isEmail = TypeBoxFormat.IsEmail;
|
|
1461
|
-
const isURL = TypeBoxFormat.IsUrl;
|
|
1462
|
-
const isDateTime = TypeBoxFormat.IsDateTime;
|
|
1463
|
-
const isDate = TypeBoxFormat.IsDate;
|
|
1464
|
-
const isTime = TypeBoxFormat.IsTime;
|
|
1465
|
-
const isDuration = TypeBoxFormat.IsDuration;
|
|
1462
|
+
const isUUID = Format.IsUuid;
|
|
1466
1463
|
var TypeGuard = class {
|
|
1467
|
-
isBigInt = (value) =>
|
|
1468
|
-
isUUID = (value) =>
|
|
1469
|
-
isObject =
|
|
1470
|
-
isNumber =
|
|
1471
|
-
isString =
|
|
1472
|
-
isBoolean =
|
|
1473
|
-
isAny =
|
|
1474
|
-
isArray =
|
|
1475
|
-
isOptional =
|
|
1476
|
-
isUnion =
|
|
1477
|
-
isInteger =
|
|
1478
|
-
isNull =
|
|
1479
|
-
isUndefined =
|
|
1480
|
-
isUnsafe =
|
|
1481
|
-
isRecord =
|
|
1482
|
-
isTuple =
|
|
1483
|
-
isVoid =
|
|
1484
|
-
isLiteral =
|
|
1485
|
-
isSchema =
|
|
1464
|
+
isBigInt = (value) => Type.IsString(value) && "format" in value && value.format === "bigint";
|
|
1465
|
+
isUUID = (value) => Type.IsString(value) && "format" in value && value.format === "uuid";
|
|
1466
|
+
isObject = Type.IsObject;
|
|
1467
|
+
isNumber = Type.IsNumber;
|
|
1468
|
+
isString = Type.IsString;
|
|
1469
|
+
isBoolean = Type.IsBoolean;
|
|
1470
|
+
isAny = Type.IsAny;
|
|
1471
|
+
isArray = Type.IsArray;
|
|
1472
|
+
isOptional = Type.IsOptional;
|
|
1473
|
+
isUnion = Type.IsUnion;
|
|
1474
|
+
isInteger = Type.IsInteger;
|
|
1475
|
+
isNull = Type.IsNull;
|
|
1476
|
+
isUndefined = Type.IsUndefined;
|
|
1477
|
+
isUnsafe = Type.IsUnsafe;
|
|
1478
|
+
isRecord = Type.IsRecord;
|
|
1479
|
+
isTuple = Type.IsTuple;
|
|
1480
|
+
isVoid = Type.IsVoid;
|
|
1481
|
+
isLiteral = Type.IsLiteral;
|
|
1482
|
+
isSchema = Type.IsSchema;
|
|
1486
1483
|
isFile = isTypeFile;
|
|
1487
1484
|
isDateTime = (schema) => {
|
|
1488
1485
|
return t.schema.isString(schema) && schema.format === "date-time";
|
|
@@ -1498,9 +1495,9 @@ var TypeGuard = class {
|
|
|
1498
1495
|
};
|
|
1499
1496
|
};
|
|
1500
1497
|
var TypeProvider = class TypeProvider {
|
|
1501
|
-
static format =
|
|
1498
|
+
static format = Format;
|
|
1502
1499
|
static {
|
|
1503
|
-
|
|
1500
|
+
Format.Set("bigint", (value) => TypeProvider.isValidBigInt(value));
|
|
1504
1501
|
}
|
|
1505
1502
|
static translateError(error, locale) {
|
|
1506
1503
|
if (!locale) return error.cause.message;
|
|
@@ -1899,6 +1896,192 @@ var TypeProvider = class TypeProvider {
|
|
|
1899
1896
|
};
|
|
1900
1897
|
const t = new TypeProvider();
|
|
1901
1898
|
|
|
1899
|
+
//#endregion
|
|
1900
|
+
//#region ../../src/core/helpers/jsonSchemaToTypeBox.ts
|
|
1901
|
+
/**
|
|
1902
|
+
* Converts a JSON Schema object to a TypeBox schema using Alepha's type system.
|
|
1903
|
+
*
|
|
1904
|
+
* This is useful when receiving JSON Schema from an API (e.g., configuration schemas)
|
|
1905
|
+
* and needing to use them with TypeBox-based form rendering or validation.
|
|
1906
|
+
*
|
|
1907
|
+
* **Supports:**
|
|
1908
|
+
* - Basic types: string, number, integer, boolean, null, object, array
|
|
1909
|
+
* - String formats: email, uuid, date-time, date, time, url/uri, binary, bigint, duration, color
|
|
1910
|
+
* - Enums (string enums)
|
|
1911
|
+
* - Nested objects with required/optional properties
|
|
1912
|
+
* - Arrays with item schemas
|
|
1913
|
+
* - Common validation options: minLength, maxLength, minimum, maximum, pattern
|
|
1914
|
+
*
|
|
1915
|
+
* **Not supported:**
|
|
1916
|
+
* - oneOf, anyOf, allOf, not (composition schemas)
|
|
1917
|
+
* - $ref (references)
|
|
1918
|
+
* - additionalProperties, patternProperties
|
|
1919
|
+
*
|
|
1920
|
+
* @param schema - JSON Schema object to convert
|
|
1921
|
+
* @returns TypeBox TSchema
|
|
1922
|
+
*
|
|
1923
|
+
* @example
|
|
1924
|
+
* ```ts
|
|
1925
|
+
* const jsonSchema = {
|
|
1926
|
+
* type: "object",
|
|
1927
|
+
* properties: {
|
|
1928
|
+
* email: { type: "string", format: "email" },
|
|
1929
|
+
* age: { type: "integer", minimum: 0 },
|
|
1930
|
+
* active: { type: "boolean" },
|
|
1931
|
+
* },
|
|
1932
|
+
* required: ["email"]
|
|
1933
|
+
* };
|
|
1934
|
+
*
|
|
1935
|
+
* const typeBoxSchema = jsonSchemaToTypeBox(jsonSchema);
|
|
1936
|
+
* // Equivalent to:
|
|
1937
|
+
* // t.object({
|
|
1938
|
+
* // email: t.email(),
|
|
1939
|
+
* // age: t.optional(t.integer({ minimum: 0 })),
|
|
1940
|
+
* // active: t.optional(t.boolean()),
|
|
1941
|
+
* // })
|
|
1942
|
+
* ```
|
|
1943
|
+
*/
|
|
1944
|
+
function jsonSchemaToTypeBox(schema) {
|
|
1945
|
+
if (schema["~kind"]) return schema;
|
|
1946
|
+
if (schema.const !== void 0) return t.const(schema.const);
|
|
1947
|
+
if (schema.enum && Array.isArray(schema.enum)) {
|
|
1948
|
+
if (schema.enum.every((v) => typeof v === "string")) return t.enum(schema.enum, filterUndefined({
|
|
1949
|
+
title: schema.title,
|
|
1950
|
+
description: schema.description,
|
|
1951
|
+
default: schema.default
|
|
1952
|
+
}));
|
|
1953
|
+
return t.union(schema.enum.map((v) => t.const(v)));
|
|
1954
|
+
}
|
|
1955
|
+
switch (Array.isArray(schema.type) ? schema.type[0] : schema.type) {
|
|
1956
|
+
case "string": return convertString(schema);
|
|
1957
|
+
case "number": return convertNumber(schema);
|
|
1958
|
+
case "integer": return convertInteger(schema);
|
|
1959
|
+
case "boolean": return convertBoolean(schema);
|
|
1960
|
+
case "null": return t.null();
|
|
1961
|
+
case "object": return convertObject(schema);
|
|
1962
|
+
case "array": return convertArray(schema);
|
|
1963
|
+
default:
|
|
1964
|
+
if (schema.properties) return convertObject(schema);
|
|
1965
|
+
return t.any();
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* Remove undefined values from an object.
|
|
1970
|
+
*/
|
|
1971
|
+
function filterUndefined(obj) {
|
|
1972
|
+
return Object.fromEntries(Object.entries(obj).filter(([_, v]) => v !== void 0));
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Convert JSON Schema string type to TypeBox.
|
|
1976
|
+
*/
|
|
1977
|
+
function convertString(schema) {
|
|
1978
|
+
const options = filterUndefined({
|
|
1979
|
+
title: schema.title,
|
|
1980
|
+
description: schema.description,
|
|
1981
|
+
default: schema.default,
|
|
1982
|
+
minLength: schema.minLength,
|
|
1983
|
+
maxLength: schema.maxLength,
|
|
1984
|
+
pattern: schema.pattern
|
|
1985
|
+
});
|
|
1986
|
+
switch (schema.format) {
|
|
1987
|
+
case "email": return t.email(options);
|
|
1988
|
+
case "uuid": return t.uuid(options);
|
|
1989
|
+
case "date-time": return t.datetime(options);
|
|
1990
|
+
case "date": return t.date(options);
|
|
1991
|
+
case "time": return t.time(options);
|
|
1992
|
+
case "url":
|
|
1993
|
+
case "uri": return t.url(options);
|
|
1994
|
+
case "binary": return t.binary(options);
|
|
1995
|
+
case "bigint": return t.bigint(options);
|
|
1996
|
+
case "duration": return t.duration(options);
|
|
1997
|
+
case "color": return t.text({
|
|
1998
|
+
...options,
|
|
1999
|
+
format: "color"
|
|
2000
|
+
});
|
|
2001
|
+
case "e164": return t.e164(options);
|
|
2002
|
+
case "bcp47": return t.bcp47(options);
|
|
2003
|
+
default:
|
|
2004
|
+
if (schema.format) return t.text({
|
|
2005
|
+
...options,
|
|
2006
|
+
format: schema.format
|
|
2007
|
+
});
|
|
2008
|
+
return t.text(options);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Convert JSON Schema number type to TypeBox.
|
|
2013
|
+
*/
|
|
2014
|
+
function convertNumber(schema) {
|
|
2015
|
+
return t.number(filterUndefined({
|
|
2016
|
+
title: schema.title,
|
|
2017
|
+
description: schema.description,
|
|
2018
|
+
default: schema.default,
|
|
2019
|
+
minimum: schema.minimum,
|
|
2020
|
+
maximum: schema.maximum,
|
|
2021
|
+
exclusiveMinimum: schema.exclusiveMinimum,
|
|
2022
|
+
exclusiveMaximum: schema.exclusiveMaximum,
|
|
2023
|
+
multipleOf: schema.multipleOf
|
|
2024
|
+
}));
|
|
2025
|
+
}
|
|
2026
|
+
/**
|
|
2027
|
+
* Convert JSON Schema integer type to TypeBox.
|
|
2028
|
+
*/
|
|
2029
|
+
function convertInteger(schema) {
|
|
2030
|
+
return t.integer(filterUndefined({
|
|
2031
|
+
title: schema.title,
|
|
2032
|
+
description: schema.description,
|
|
2033
|
+
default: schema.default,
|
|
2034
|
+
minimum: schema.minimum,
|
|
2035
|
+
maximum: schema.maximum,
|
|
2036
|
+
exclusiveMinimum: schema.exclusiveMinimum,
|
|
2037
|
+
exclusiveMaximum: schema.exclusiveMaximum,
|
|
2038
|
+
multipleOf: schema.multipleOf
|
|
2039
|
+
}));
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Convert JSON Schema boolean type to TypeBox.
|
|
2043
|
+
*/
|
|
2044
|
+
function convertBoolean(schema) {
|
|
2045
|
+
return t.boolean(filterUndefined({
|
|
2046
|
+
title: schema.title,
|
|
2047
|
+
description: schema.description,
|
|
2048
|
+
default: schema.default
|
|
2049
|
+
}));
|
|
2050
|
+
}
|
|
2051
|
+
/**
|
|
2052
|
+
* Convert JSON Schema object type to TypeBox.
|
|
2053
|
+
*/
|
|
2054
|
+
function convertObject(schema) {
|
|
2055
|
+
if (!schema.properties) return t.json(filterUndefined({
|
|
2056
|
+
title: schema.title,
|
|
2057
|
+
description: schema.description
|
|
2058
|
+
}));
|
|
2059
|
+
const required = new Set(schema.required ?? []);
|
|
2060
|
+
const properties = {};
|
|
2061
|
+
for (const [key, propSchema] of Object.entries(schema.properties)) {
|
|
2062
|
+
let converted = jsonSchemaToTypeBox(propSchema);
|
|
2063
|
+
if (!required.has(key)) converted = t.optional(converted);
|
|
2064
|
+
properties[key] = converted;
|
|
2065
|
+
}
|
|
2066
|
+
return t.object(properties, filterUndefined({
|
|
2067
|
+
title: schema.title,
|
|
2068
|
+
description: schema.description
|
|
2069
|
+
}));
|
|
2070
|
+
}
|
|
2071
|
+
/**
|
|
2072
|
+
* Convert JSON Schema array type to TypeBox.
|
|
2073
|
+
*/
|
|
2074
|
+
function convertArray(schema) {
|
|
2075
|
+
const itemSchema = schema.items ? jsonSchemaToTypeBox(schema.items) : t.any();
|
|
2076
|
+
return t.array(itemSchema, filterUndefined({
|
|
2077
|
+
title: schema.title,
|
|
2078
|
+
description: schema.description,
|
|
2079
|
+
minItems: schema.minItems,
|
|
2080
|
+
maxItems: schema.maxItems,
|
|
2081
|
+
uniqueItems: schema.uniqueItems
|
|
2082
|
+
}));
|
|
2083
|
+
}
|
|
2084
|
+
|
|
1902
2085
|
//#endregion
|
|
1903
2086
|
//#region ../../src/core/primitives/$env.ts
|
|
1904
2087
|
/**
|
|
@@ -2113,5 +2296,5 @@ const run = (entry, opts) => {
|
|
|
2113
2296
|
};
|
|
2114
2297
|
|
|
2115
2298
|
//#endregion
|
|
2116
|
-
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,
|
|
2299
|
+
export { $atom, $context, $env, $hook, $inject, $module, $use, Alepha, 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 };
|
|
2117
2300
|
//# sourceMappingURL=index.native.js.map
|