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
|
/**
|
|
@@ -938,12 +937,6 @@ var Alepha = class Alepha {
|
|
|
938
937
|
*/
|
|
939
938
|
starting;
|
|
940
939
|
/**
|
|
941
|
-
* Initial state of the container.
|
|
942
|
-
*
|
|
943
|
-
* > Used to initialize the StateManager.
|
|
944
|
-
*/
|
|
945
|
-
init;
|
|
946
|
-
/**
|
|
947
940
|
* During the instantiation process, we keep a list of pending instantiations.
|
|
948
941
|
* > It allows us to detect circular dependencies.
|
|
949
942
|
*/
|
|
@@ -980,30 +973,21 @@ var Alepha = class Alepha {
|
|
|
980
973
|
*
|
|
981
974
|
* Mocked for browser environments.
|
|
982
975
|
*/
|
|
983
|
-
|
|
984
|
-
return this.inject(AlsProvider);
|
|
985
|
-
}
|
|
976
|
+
context;
|
|
986
977
|
/**
|
|
987
978
|
* Event manager to handle lifecycle events and custom events.
|
|
988
979
|
*/
|
|
989
|
-
|
|
990
|
-
return this.inject(EventManager, { args: [() => this.log] });
|
|
991
|
-
}
|
|
980
|
+
events;
|
|
992
981
|
/**
|
|
993
982
|
* State manager to store arbitrary values.
|
|
994
983
|
*/
|
|
995
|
-
|
|
996
|
-
this.events;
|
|
997
|
-
return this.inject(StateManager, { args: [this.init] });
|
|
998
|
-
}
|
|
984
|
+
store;
|
|
999
985
|
/**
|
|
1000
986
|
* Codec manager for encoding and decoding data with different formats.
|
|
1001
987
|
*
|
|
1002
988
|
* Supports multiple codec formats (JSON, Protobuf, etc.) with a unified interface.
|
|
1003
989
|
*/
|
|
1004
|
-
|
|
1005
|
-
return this.inject(CodecManager);
|
|
1006
|
-
}
|
|
990
|
+
codec;
|
|
1007
991
|
/**
|
|
1008
992
|
* Get logger instance.
|
|
1009
993
|
*/
|
|
@@ -1016,8 +1000,12 @@ var Alepha = class Alepha {
|
|
|
1016
1000
|
get env() {
|
|
1017
1001
|
return this.store.get("env") ?? {};
|
|
1018
1002
|
}
|
|
1019
|
-
constructor(
|
|
1020
|
-
this.
|
|
1003
|
+
constructor(state = {}) {
|
|
1004
|
+
this.store = this.inject(StateManager, { args: [state] });
|
|
1005
|
+
this.events = this.inject(EventManager);
|
|
1006
|
+
this.events.logFn = () => this.log;
|
|
1007
|
+
this.context = this.inject(AlsProvider);
|
|
1008
|
+
this.codec = this.inject(CodecManager);
|
|
1021
1009
|
}
|
|
1022
1010
|
set(target, value) {
|
|
1023
1011
|
this.store.set(target, value);
|
|
@@ -1084,7 +1072,7 @@ var Alepha = class Alepha {
|
|
|
1084
1072
|
isServerless() {
|
|
1085
1073
|
if (this.isBrowser()) return false;
|
|
1086
1074
|
if (this.env.VERCEL_REGION) return true;
|
|
1087
|
-
if (
|
|
1075
|
+
if (typeof global === "object" && typeof global.Cloudflare === "object") return true;
|
|
1088
1076
|
return false;
|
|
1089
1077
|
}
|
|
1090
1078
|
/**
|
|
@@ -1122,7 +1110,6 @@ var Alepha = class Alepha {
|
|
|
1122
1110
|
this.log?.warn("App is already starting, waiting for it to finish...");
|
|
1123
1111
|
return this.starting.promise;
|
|
1124
1112
|
}
|
|
1125
|
-
this.codec;
|
|
1126
1113
|
this.starting = Promise.withResolvers();
|
|
1127
1114
|
const now = Date.now();
|
|
1128
1115
|
this.log?.info("Starting App...");
|
|
@@ -1302,6 +1289,19 @@ var Alepha = class Alepha {
|
|
|
1302
1289
|
return config;
|
|
1303
1290
|
}
|
|
1304
1291
|
/**
|
|
1292
|
+
* Get all environment variable schemas and their parsed values.
|
|
1293
|
+
*
|
|
1294
|
+
* This is useful for DevTools to display all expected environment variables.
|
|
1295
|
+
*/
|
|
1296
|
+
getEnvSchemas() {
|
|
1297
|
+
const result = [];
|
|
1298
|
+
for (const [schema, values] of this.cacheEnv.entries()) result.push({
|
|
1299
|
+
schema,
|
|
1300
|
+
values
|
|
1301
|
+
});
|
|
1302
|
+
return result;
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
1305
|
* Dump the current dependency graph of the App.
|
|
1306
1306
|
*
|
|
1307
1307
|
* This method returns a record where the keys are the names of the services.
|
|
@@ -1456,33 +1456,27 @@ const isFileLike = (value) => {
|
|
|
1456
1456
|
|
|
1457
1457
|
//#endregion
|
|
1458
1458
|
//#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;
|
|
1459
|
+
const isUUID = Format.IsUuid;
|
|
1466
1460
|
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 =
|
|
1461
|
+
isBigInt = (value) => Type.IsString(value) && "format" in value && value.format === "bigint";
|
|
1462
|
+
isUUID = (value) => Type.IsString(value) && "format" in value && value.format === "uuid";
|
|
1463
|
+
isObject = Type.IsObject;
|
|
1464
|
+
isNumber = Type.IsNumber;
|
|
1465
|
+
isString = Type.IsString;
|
|
1466
|
+
isBoolean = Type.IsBoolean;
|
|
1467
|
+
isAny = Type.IsAny;
|
|
1468
|
+
isArray = Type.IsArray;
|
|
1469
|
+
isOptional = Type.IsOptional;
|
|
1470
|
+
isUnion = Type.IsUnion;
|
|
1471
|
+
isInteger = Type.IsInteger;
|
|
1472
|
+
isNull = Type.IsNull;
|
|
1473
|
+
isUndefined = Type.IsUndefined;
|
|
1474
|
+
isUnsafe = Type.IsUnsafe;
|
|
1475
|
+
isRecord = Type.IsRecord;
|
|
1476
|
+
isTuple = Type.IsTuple;
|
|
1477
|
+
isVoid = Type.IsVoid;
|
|
1478
|
+
isLiteral = Type.IsLiteral;
|
|
1479
|
+
isSchema = Type.IsSchema;
|
|
1486
1480
|
isFile = isTypeFile;
|
|
1487
1481
|
isDateTime = (schema) => {
|
|
1488
1482
|
return t.schema.isString(schema) && schema.format === "date-time";
|
|
@@ -1498,9 +1492,9 @@ var TypeGuard = class {
|
|
|
1498
1492
|
};
|
|
1499
1493
|
};
|
|
1500
1494
|
var TypeProvider = class TypeProvider {
|
|
1501
|
-
static format =
|
|
1495
|
+
static format = Format;
|
|
1502
1496
|
static {
|
|
1503
|
-
|
|
1497
|
+
Format.Set("bigint", (value) => TypeProvider.isValidBigInt(value));
|
|
1504
1498
|
}
|
|
1505
1499
|
static translateError(error, locale) {
|
|
1506
1500
|
if (!locale) return error.cause.message;
|
|
@@ -1899,6 +1893,192 @@ var TypeProvider = class TypeProvider {
|
|
|
1899
1893
|
};
|
|
1900
1894
|
const t = new TypeProvider();
|
|
1901
1895
|
|
|
1896
|
+
//#endregion
|
|
1897
|
+
//#region ../../src/core/helpers/jsonSchemaToTypeBox.ts
|
|
1898
|
+
/**
|
|
1899
|
+
* Converts a JSON Schema object to a TypeBox schema using Alepha's type system.
|
|
1900
|
+
*
|
|
1901
|
+
* This is useful when receiving JSON Schema from an API (e.g., configuration schemas)
|
|
1902
|
+
* and needing to use them with TypeBox-based form rendering or validation.
|
|
1903
|
+
*
|
|
1904
|
+
* **Supports:**
|
|
1905
|
+
* - Basic types: string, number, integer, boolean, null, object, array
|
|
1906
|
+
* - String formats: email, uuid, date-time, date, time, url/uri, binary, bigint, duration, color
|
|
1907
|
+
* - Enums (string enums)
|
|
1908
|
+
* - Nested objects with required/optional properties
|
|
1909
|
+
* - Arrays with item schemas
|
|
1910
|
+
* - Common validation options: minLength, maxLength, minimum, maximum, pattern
|
|
1911
|
+
*
|
|
1912
|
+
* **Not supported:**
|
|
1913
|
+
* - oneOf, anyOf, allOf, not (composition schemas)
|
|
1914
|
+
* - $ref (references)
|
|
1915
|
+
* - additionalProperties, patternProperties
|
|
1916
|
+
*
|
|
1917
|
+
* @param schema - JSON Schema object to convert
|
|
1918
|
+
* @returns TypeBox TSchema
|
|
1919
|
+
*
|
|
1920
|
+
* @example
|
|
1921
|
+
* ```ts
|
|
1922
|
+
* const jsonSchema = {
|
|
1923
|
+
* type: "object",
|
|
1924
|
+
* properties: {
|
|
1925
|
+
* email: { type: "string", format: "email" },
|
|
1926
|
+
* age: { type: "integer", minimum: 0 },
|
|
1927
|
+
* active: { type: "boolean" },
|
|
1928
|
+
* },
|
|
1929
|
+
* required: ["email"]
|
|
1930
|
+
* };
|
|
1931
|
+
*
|
|
1932
|
+
* const typeBoxSchema = jsonSchemaToTypeBox(jsonSchema);
|
|
1933
|
+
* // Equivalent to:
|
|
1934
|
+
* // t.object({
|
|
1935
|
+
* // email: t.email(),
|
|
1936
|
+
* // age: t.optional(t.integer({ minimum: 0 })),
|
|
1937
|
+
* // active: t.optional(t.boolean()),
|
|
1938
|
+
* // })
|
|
1939
|
+
* ```
|
|
1940
|
+
*/
|
|
1941
|
+
function jsonSchemaToTypeBox(schema) {
|
|
1942
|
+
if (schema["~kind"]) return schema;
|
|
1943
|
+
if (schema.const !== void 0) return t.const(schema.const);
|
|
1944
|
+
if (schema.enum && Array.isArray(schema.enum)) {
|
|
1945
|
+
if (schema.enum.every((v) => typeof v === "string")) return t.enum(schema.enum, filterUndefined({
|
|
1946
|
+
title: schema.title,
|
|
1947
|
+
description: schema.description,
|
|
1948
|
+
default: schema.default
|
|
1949
|
+
}));
|
|
1950
|
+
return t.union(schema.enum.map((v) => t.const(v)));
|
|
1951
|
+
}
|
|
1952
|
+
switch (Array.isArray(schema.type) ? schema.type[0] : schema.type) {
|
|
1953
|
+
case "string": return convertString(schema);
|
|
1954
|
+
case "number": return convertNumber(schema);
|
|
1955
|
+
case "integer": return convertInteger(schema);
|
|
1956
|
+
case "boolean": return convertBoolean(schema);
|
|
1957
|
+
case "null": return t.null();
|
|
1958
|
+
case "object": return convertObject(schema);
|
|
1959
|
+
case "array": return convertArray(schema);
|
|
1960
|
+
default:
|
|
1961
|
+
if (schema.properties) return convertObject(schema);
|
|
1962
|
+
return t.any();
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* Remove undefined values from an object.
|
|
1967
|
+
*/
|
|
1968
|
+
function filterUndefined(obj) {
|
|
1969
|
+
return Object.fromEntries(Object.entries(obj).filter(([_, v]) => v !== void 0));
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Convert JSON Schema string type to TypeBox.
|
|
1973
|
+
*/
|
|
1974
|
+
function convertString(schema) {
|
|
1975
|
+
const options = filterUndefined({
|
|
1976
|
+
title: schema.title,
|
|
1977
|
+
description: schema.description,
|
|
1978
|
+
default: schema.default,
|
|
1979
|
+
minLength: schema.minLength,
|
|
1980
|
+
maxLength: schema.maxLength,
|
|
1981
|
+
pattern: schema.pattern
|
|
1982
|
+
});
|
|
1983
|
+
switch (schema.format) {
|
|
1984
|
+
case "email": return t.email(options);
|
|
1985
|
+
case "uuid": return t.uuid(options);
|
|
1986
|
+
case "date-time": return t.datetime(options);
|
|
1987
|
+
case "date": return t.date(options);
|
|
1988
|
+
case "time": return t.time(options);
|
|
1989
|
+
case "url":
|
|
1990
|
+
case "uri": return t.url(options);
|
|
1991
|
+
case "binary": return t.binary(options);
|
|
1992
|
+
case "bigint": return t.bigint(options);
|
|
1993
|
+
case "duration": return t.duration(options);
|
|
1994
|
+
case "color": return t.text({
|
|
1995
|
+
...options,
|
|
1996
|
+
format: "color"
|
|
1997
|
+
});
|
|
1998
|
+
case "e164": return t.e164(options);
|
|
1999
|
+
case "bcp47": return t.bcp47(options);
|
|
2000
|
+
default:
|
|
2001
|
+
if (schema.format) return t.text({
|
|
2002
|
+
...options,
|
|
2003
|
+
format: schema.format
|
|
2004
|
+
});
|
|
2005
|
+
return t.text(options);
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
/**
|
|
2009
|
+
* Convert JSON Schema number type to TypeBox.
|
|
2010
|
+
*/
|
|
2011
|
+
function convertNumber(schema) {
|
|
2012
|
+
return t.number(filterUndefined({
|
|
2013
|
+
title: schema.title,
|
|
2014
|
+
description: schema.description,
|
|
2015
|
+
default: schema.default,
|
|
2016
|
+
minimum: schema.minimum,
|
|
2017
|
+
maximum: schema.maximum,
|
|
2018
|
+
exclusiveMinimum: schema.exclusiveMinimum,
|
|
2019
|
+
exclusiveMaximum: schema.exclusiveMaximum,
|
|
2020
|
+
multipleOf: schema.multipleOf
|
|
2021
|
+
}));
|
|
2022
|
+
}
|
|
2023
|
+
/**
|
|
2024
|
+
* Convert JSON Schema integer type to TypeBox.
|
|
2025
|
+
*/
|
|
2026
|
+
function convertInteger(schema) {
|
|
2027
|
+
return t.integer(filterUndefined({
|
|
2028
|
+
title: schema.title,
|
|
2029
|
+
description: schema.description,
|
|
2030
|
+
default: schema.default,
|
|
2031
|
+
minimum: schema.minimum,
|
|
2032
|
+
maximum: schema.maximum,
|
|
2033
|
+
exclusiveMinimum: schema.exclusiveMinimum,
|
|
2034
|
+
exclusiveMaximum: schema.exclusiveMaximum,
|
|
2035
|
+
multipleOf: schema.multipleOf
|
|
2036
|
+
}));
|
|
2037
|
+
}
|
|
2038
|
+
/**
|
|
2039
|
+
* Convert JSON Schema boolean type to TypeBox.
|
|
2040
|
+
*/
|
|
2041
|
+
function convertBoolean(schema) {
|
|
2042
|
+
return t.boolean(filterUndefined({
|
|
2043
|
+
title: schema.title,
|
|
2044
|
+
description: schema.description,
|
|
2045
|
+
default: schema.default
|
|
2046
|
+
}));
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Convert JSON Schema object type to TypeBox.
|
|
2050
|
+
*/
|
|
2051
|
+
function convertObject(schema) {
|
|
2052
|
+
if (!schema.properties) return t.json(filterUndefined({
|
|
2053
|
+
title: schema.title,
|
|
2054
|
+
description: schema.description
|
|
2055
|
+
}));
|
|
2056
|
+
const required = new Set(schema.required ?? []);
|
|
2057
|
+
const properties = {};
|
|
2058
|
+
for (const [key, propSchema] of Object.entries(schema.properties)) {
|
|
2059
|
+
let converted = jsonSchemaToTypeBox(propSchema);
|
|
2060
|
+
if (!required.has(key)) converted = t.optional(converted);
|
|
2061
|
+
properties[key] = converted;
|
|
2062
|
+
}
|
|
2063
|
+
return t.object(properties, filterUndefined({
|
|
2064
|
+
title: schema.title,
|
|
2065
|
+
description: schema.description
|
|
2066
|
+
}));
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Convert JSON Schema array type to TypeBox.
|
|
2070
|
+
*/
|
|
2071
|
+
function convertArray(schema) {
|
|
2072
|
+
const itemSchema = schema.items ? jsonSchemaToTypeBox(schema.items) : t.any();
|
|
2073
|
+
return t.array(itemSchema, filterUndefined({
|
|
2074
|
+
title: schema.title,
|
|
2075
|
+
description: schema.description,
|
|
2076
|
+
minItems: schema.minItems,
|
|
2077
|
+
maxItems: schema.maxItems,
|
|
2078
|
+
uniqueItems: schema.uniqueItems
|
|
2079
|
+
}));
|
|
2080
|
+
}
|
|
2081
|
+
|
|
1902
2082
|
//#endregion
|
|
1903
2083
|
//#region ../../src/core/primitives/$env.ts
|
|
1904
2084
|
/**
|
|
@@ -2114,5 +2294,5 @@ const run = (entry, opts) => {
|
|
|
2114
2294
|
};
|
|
2115
2295
|
|
|
2116
2296
|
//#endregion
|
|
2117
|
-
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,
|
|
2297
|
+
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 };
|
|
2118
2298
|
//# sourceMappingURL=index.browser.js.map
|