elysia 2.0.0-beta.2 → 2.0.0-beta.3
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/adapter/utils.js +3 -3
- package/dist/adapter/utils.mjs +4 -4
- package/dist/adapter/web-standard/handler.js +5 -2
- package/dist/adapter/web-standard/handler.mjs +5 -2
- package/dist/base.d.ts +2 -2
- package/dist/base.js +42 -27
- package/dist/base.mjs +43 -28
- package/dist/compile/aot.d.ts +4 -4
- package/dist/compile/aot.js +14 -9
- package/dist/compile/aot.mjs +15 -9
- package/dist/compile/handler/descriptor.js +1 -1
- package/dist/compile/handler/descriptor.mjs +1 -1
- package/dist/compile/handler/index.d.ts +2 -2
- package/dist/compile/handler/index.js +6 -4
- package/dist/compile/handler/index.mjs +6 -4
- package/dist/compile/handler/utils.js +2 -2
- package/dist/compile/handler/utils.mjs +3 -3
- package/dist/context.js +3 -4
- package/dist/context.mjs +3 -4
- package/dist/cookie/config.d.ts +1 -0
- package/dist/cookie/config.js +3 -2
- package/dist/cookie/config.mjs +3 -2
- package/dist/cookie/cookie.d.ts +1 -0
- package/dist/cookie/cookie.js +6 -5
- package/dist/cookie/cookie.mjs +6 -5
- package/dist/cookie/crypto.d.ts +8 -7
- package/dist/cookie/crypto.js +38 -31
- package/dist/cookie/crypto.mjs +38 -32
- package/dist/cookie/error.js +1 -2
- package/dist/cookie/error.mjs +1 -2
- package/dist/cookie/lib.js +5 -1
- package/dist/cookie/lib.mjs +5 -1
- package/dist/cookie/serialize.js +1 -1
- package/dist/cookie/serialize.mjs +1 -1
- package/dist/cookie/types.d.ts +10 -0
- package/dist/cookie/utils.js +28 -14
- package/dist/cookie/utils.mjs +29 -15
- package/dist/handler/error.d.ts +23 -12
- package/dist/handler/error.js +24 -21
- package/dist/handler/error.mjs +20 -21
- package/dist/handler/fetch.js +6 -7
- package/dist/handler/fetch.mjs +7 -8
- package/dist/handler/utils.js +4 -2
- package/dist/handler/utils.mjs +5 -3
- package/dist/index.js +1 -8
- package/dist/package.js +1 -1
- package/dist/package.mjs +1 -1
- package/dist/plugin/aot/core.d.ts +22 -1
- package/dist/plugin/aot/core.js +35 -3
- package/dist/plugin/aot/core.mjs +35 -3
- package/dist/route-table.js +12 -10
- package/dist/route-table.mjs +12 -10
- package/dist/type/bridge-live.d.ts +1 -1
- package/dist/type/bridge-live.js +1 -1
- package/dist/type/bridge-live.mjs +1 -1
- package/dist/type/bridge.d.ts +1 -1
- package/dist/type/coerce-plan.js +3 -4
- package/dist/type/coerce-plan.mjs +1 -1
- package/dist/type/compat.d.ts +3 -0
- package/dist/type/compat.js +32 -14
- package/dist/type/compat.mjs +27 -8
- package/dist/type/elysia/array-buffer.js +2 -3
- package/dist/type/elysia/array-buffer.mjs +1 -1
- package/dist/type/elysia/array-string.js +7 -4
- package/dist/type/elysia/array-string.mjs +9 -5
- package/dist/type/elysia/boolean-string.js +2 -3
- package/dist/type/elysia/boolean-string.mjs +1 -1
- package/dist/type/elysia/boolean.js +4 -3
- package/dist/type/elysia/boolean.mjs +4 -2
- package/dist/type/elysia/cookie.js +2 -1
- package/dist/type/elysia/cookie.mjs +2 -1
- package/dist/type/elysia/date.js +7 -7
- package/dist/type/elysia/date.mjs +3 -2
- package/dist/type/elysia/file-type.d.ts +9 -2
- package/dist/type/elysia/file-type.js +16 -1
- package/dist/type/elysia/file-type.mjs +16 -2
- package/dist/type/elysia/file.js +8 -4
- package/dist/type/elysia/file.mjs +8 -3
- package/dist/type/elysia/files.js +6 -4
- package/dist/type/elysia/files.mjs +5 -2
- package/dist/type/elysia/form.js +2 -3
- package/dist/type/elysia/form.mjs +3 -3
- package/dist/type/elysia/integer-string.js +4 -5
- package/dist/type/elysia/integer-string.mjs +3 -3
- package/dist/type/elysia/integer.js +4 -3
- package/dist/type/elysia/integer.mjs +4 -2
- package/dist/type/elysia/maybe-empty.js +3 -4
- package/dist/type/elysia/maybe-empty.mjs +1 -1
- package/dist/type/elysia/nullable.js +2 -3
- package/dist/type/elysia/nullable.mjs +1 -1
- package/dist/type/elysia/number.js +4 -3
- package/dist/type/elysia/number.mjs +4 -2
- package/dist/type/elysia/numeric-enum.js +2 -3
- package/dist/type/elysia/numeric-enum.mjs +1 -1
- package/dist/type/elysia/numeric.js +5 -5
- package/dist/type/elysia/numeric.mjs +3 -2
- package/dist/type/elysia/object-string.js +7 -4
- package/dist/type/elysia/object-string.mjs +9 -5
- package/dist/type/elysia/string.js +4 -3
- package/dist/type/elysia/string.mjs +4 -2
- package/dist/type/elysia/uint8-array.js +2 -3
- package/dist/type/elysia/uint8-array.mjs +1 -1
- package/dist/type/elysia/union-enum.js +2 -3
- package/dist/type/elysia/union-enum.mjs +1 -1
- package/dist/type/elysia/utils.js +2 -3
- package/dist/type/elysia/utils.mjs +1 -1
- package/dist/type/exports.js +10 -1
- package/dist/type/exports.mjs +7 -0
- package/dist/type/index.d.ts +9 -1
- package/dist/type/index.js +41 -13
- package/dist/type/index.mjs +44 -9
- package/dist/type/typebox-type-live.d.ts +9 -0
- package/dist/type/typebox-type-live.js +31 -0
- package/dist/type/typebox-type-live.mjs +16 -0
- package/dist/type/typebox-type.d.ts +24 -0
- package/dist/type/typebox-type.js +130 -0
- package/dist/type/typebox-type.mjs +66 -0
- package/dist/type/typebox-value-live.d.ts +9 -0
- package/dist/type/typebox-value-live.js +27 -0
- package/dist/type/typebox-value-live.mjs +11 -0
- package/dist/type/typebox-value.d.ts +30 -0
- package/dist/type/typebox-value.js +147 -0
- package/dist/type/typebox-value.mjs +62 -0
- package/dist/type/validator/custom-error.js +4 -5
- package/dist/type/validator/custom-error.mjs +3 -3
- package/dist/type/validator/default-precompute.js +4 -5
- package/dist/type/validator/default-precompute.mjs +1 -1
- package/dist/type/validator/index.js +41 -35
- package/dist/type/validator/index.mjs +23 -16
- package/dist/type/validator/validator-cache.js +10 -5
- package/dist/type/validator/validator-cache.mjs +10 -4
- package/dist/universal/constants.d.ts +2 -1
- package/dist/universal/constants.js +3 -1
- package/dist/universal/constants.mjs +2 -1
- package/dist/utils.d.ts +10 -1
- package/dist/utils.js +18 -3
- package/dist/utils.mjs +14 -3
- package/dist/validator/index.js +2 -1
- package/dist/validator/index.mjs +2 -1
- package/dist/ws/context.d.ts +4 -0
- package/dist/ws/context.js +44 -26
- package/dist/ws/context.mjs +44 -26
- package/dist/ws/route.js +126 -23
- package/dist/ws/route.mjs +128 -25
- package/package.json +4 -2
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { isEmpty } from "../../utils.mjs";
|
|
2
2
|
import { noEnumerable } from "../constants.mjs";
|
|
3
|
-
import { Number } from "typebox/type";
|
|
4
3
|
|
|
5
4
|
//#region src/type/elysia/number.ts
|
|
6
|
-
const emptyNumber = Object.freeze(
|
|
5
|
+
const emptyNumber = Object.freeze(Object.defineProperty({
|
|
6
|
+
type: "number",
|
|
7
|
+
"~kind": "Number"
|
|
8
|
+
}, "~kind", noEnumerable));
|
|
7
9
|
function NumberType(options) {
|
|
8
10
|
if (!options || isEmpty(options)) return emptyNumber;
|
|
9
11
|
const schema = {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
3
2
|
const require_type_constants = require('../constants.js');
|
|
3
|
+
const require_type_typebox_type = require('../typebox-type.js');
|
|
4
4
|
const require_type_elysia_string = require('./string.js');
|
|
5
5
|
const require_type_elysia_union = require('./union.js');
|
|
6
6
|
const require_type_elysia_utils = require('./utils.js');
|
|
7
7
|
const require_type_elysia_number = require('./number.js');
|
|
8
|
-
let typebox_type = require("typebox/type");
|
|
9
8
|
|
|
10
9
|
//#region src/type/elysia/numeric-enum.ts
|
|
11
10
|
/**
|
|
@@ -14,7 +13,7 @@ let typebox_type = require("typebox/type");
|
|
|
14
13
|
*/
|
|
15
14
|
function NumericEnum(item, property) {
|
|
16
15
|
const allowed = new Set(Object.values(item).filter((v) => typeof v === "number").map((v) => v));
|
|
17
|
-
const decoder =
|
|
16
|
+
const decoder = require_type_typebox_type.Decode(require_type_typebox_type.Refine(require_type_elysia_union.Union([require_type_elysia_string.StringType({ format: "numeric" }), require_type_elysia_number.NumberType()], property), (value) => {
|
|
18
17
|
if (typeof value === "string" && value.trim() === "") return false;
|
|
19
18
|
const n = +value;
|
|
20
19
|
return !isNaN(n) && allowed.has(n);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ELYSIA_TYPES } from "../constants.mjs";
|
|
2
|
+
import { Decode, Refine } from "../typebox-type.mjs";
|
|
2
3
|
import { StringType } from "./string.mjs";
|
|
3
4
|
import { Union } from "./union.mjs";
|
|
4
5
|
import { elyType } from "./utils.mjs";
|
|
5
6
|
import { NumberType } from "./number.mjs";
|
|
6
|
-
import { Decode, Refine } from "typebox/type";
|
|
7
7
|
|
|
8
8
|
//#region src/type/elysia/numeric-enum.ts
|
|
9
9
|
/**
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
3
2
|
const require_utils = require('../../utils.js');
|
|
4
3
|
const require_type_constants = require('../constants.js');
|
|
5
4
|
const require_type_shared = require('../shared.js');
|
|
5
|
+
const require_type_typebox_type = require('../typebox-type.js');
|
|
6
6
|
const require_type_elysia_string = require('./string.js');
|
|
7
7
|
const require_type_elysia_union = require('./union.js');
|
|
8
8
|
const require_type_elysia_utils = require('./utils.js');
|
|
9
9
|
const require_type_elysia_number = require('./number.js');
|
|
10
|
-
let typebox_type = require("typebox/type");
|
|
11
10
|
|
|
12
11
|
//#region src/type/elysia/numeric.ts
|
|
13
12
|
function isDecimalString(value) {
|
|
@@ -33,7 +32,8 @@ function isDecimalString(value) {
|
|
|
33
32
|
}
|
|
34
33
|
if (!digits && !fractions) return false;
|
|
35
34
|
} else if (!digits) return false;
|
|
36
|
-
|
|
35
|
+
if (index !== length) return false;
|
|
36
|
+
return digits < 309 || Number.isFinite(+value);
|
|
37
37
|
}
|
|
38
38
|
let StringifiedNumber;
|
|
39
39
|
let emptyNumeric;
|
|
@@ -46,11 +46,11 @@ function passesConstraints(n, c) {
|
|
|
46
46
|
return true;
|
|
47
47
|
}
|
|
48
48
|
function Numeric(property) {
|
|
49
|
-
StringifiedNumber ??= require_type_shared.pureRefine(
|
|
49
|
+
StringifiedNumber ??= require_type_shared.pureRefine(require_type_typebox_type.Decode(require_type_typebox_type.Refine(require_type_elysia_string.StringType(), isDecimalString, () => "must be number"), (value) => +value));
|
|
50
50
|
if (!property || require_utils.isEmpty(property)) return emptyNumeric ??= Object.freeze(require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.Numeric, require_type_elysia_union.Union([require_type_elysia_number.NumberType(), StringifiedNumber])));
|
|
51
51
|
const [constraints, meta] = require_type_elysia_utils.getMeta(property);
|
|
52
52
|
const number = require_type_elysia_number.NumberType(constraints);
|
|
53
|
-
const stringified =
|
|
53
|
+
const stringified = require_type_typebox_type.Decode(require_type_typebox_type.Refine(require_type_elysia_string.StringType(), (value) => {
|
|
54
54
|
if (!isDecimalString(value)) return false;
|
|
55
55
|
return passesConstraints(+value, constraints);
|
|
56
56
|
}, () => "must be number"), (value) => +value);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isEmpty } from "../../utils.mjs";
|
|
2
2
|
import { ELYSIA_TYPES } from "../constants.mjs";
|
|
3
3
|
import { pureRefine } from "../shared.mjs";
|
|
4
|
+
import { Decode, Refine } from "../typebox-type.mjs";
|
|
4
5
|
import { StringType } from "./string.mjs";
|
|
5
6
|
import { Union } from "./union.mjs";
|
|
6
7
|
import { elyType, getMeta } from "./utils.mjs";
|
|
7
8
|
import { NumberType } from "./number.mjs";
|
|
8
|
-
import { Decode, Refine } from "typebox/type";
|
|
9
9
|
|
|
10
10
|
//#region src/type/elysia/numeric.ts
|
|
11
11
|
function isDecimalString(value) {
|
|
@@ -31,7 +31,8 @@ function isDecimalString(value) {
|
|
|
31
31
|
}
|
|
32
32
|
if (!digits && !fractions) return false;
|
|
33
33
|
} else if (!digits) return false;
|
|
34
|
-
|
|
34
|
+
if (index !== length) return false;
|
|
35
|
+
return digits < 309 || Number.isFinite(+value);
|
|
35
36
|
}
|
|
36
37
|
let StringifiedNumber;
|
|
37
38
|
let emptyNumeric;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
3
2
|
const require_utils = require('../../utils.js');
|
|
4
3
|
const require_type_bridge = require('../bridge.js');
|
|
5
4
|
const require_type_constants = require('../constants.js');
|
|
5
|
+
const require_type_typebox_type = require('../typebox-type.js');
|
|
6
6
|
const require_type_elysia_string = require('./string.js');
|
|
7
7
|
const require_type_elysia_union = require('./union.js');
|
|
8
8
|
const require_type_elysia_utils = require('./utils.js');
|
|
9
9
|
const require_type_elysia_object = require('./object.js');
|
|
10
|
-
let typebox_type = require("typebox/type");
|
|
11
10
|
|
|
12
11
|
//#region src/type/elysia/object-string.ts
|
|
13
12
|
const MEMO_LIMIT = 8192;
|
|
@@ -17,7 +16,7 @@ function ObjectString(property, _options) {
|
|
|
17
16
|
let check;
|
|
18
17
|
let raw;
|
|
19
18
|
let parsed;
|
|
20
|
-
const objectString =
|
|
19
|
+
const objectString = require_type_typebox_type.Decode(require_type_typebox_type.Refine(require_type_elysia_string.StringType(), (value) => {
|
|
21
20
|
if (value.charCodeAt(0) !== 123) return false;
|
|
22
21
|
if (value === raw) return true;
|
|
23
22
|
try {
|
|
@@ -30,13 +29,17 @@ function ObjectString(property, _options) {
|
|
|
30
29
|
} catch {
|
|
31
30
|
check = (v) => require_type_bridge.Check(object, v);
|
|
32
31
|
}
|
|
33
|
-
if (!check(next))
|
|
32
|
+
if (!check(next)) {
|
|
33
|
+
raw = parsed = void 0;
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
34
36
|
if (value.length <= MEMO_LIMIT) {
|
|
35
37
|
raw = value;
|
|
36
38
|
parsed = next;
|
|
37
39
|
}
|
|
38
40
|
return true;
|
|
39
41
|
} catch {
|
|
42
|
+
raw = parsed = void 0;
|
|
40
43
|
return false;
|
|
41
44
|
}
|
|
42
45
|
}, () => "must be an object"), (value) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { nullObject } from "../../utils.mjs";
|
|
2
|
-
import { Check, Compile, Decode
|
|
2
|
+
import { Check, Compile, Decode } from "../bridge.mjs";
|
|
3
3
|
import { ELYSIA_TYPES } from "../constants.mjs";
|
|
4
|
+
import { Decode as Decode$1, Refine } from "../typebox-type.mjs";
|
|
4
5
|
import { StringType } from "./string.mjs";
|
|
5
6
|
import { Union } from "./union.mjs";
|
|
6
7
|
import { elyType, getMeta } from "./utils.mjs";
|
|
7
8
|
import { ObjectType } from "./object.mjs";
|
|
8
|
-
import { Decode, Refine } from "typebox/type";
|
|
9
9
|
|
|
10
10
|
//#region src/type/elysia/object-string.ts
|
|
11
11
|
const MEMO_LIMIT = 8192;
|
|
@@ -15,7 +15,7 @@ function ObjectString(property, _options) {
|
|
|
15
15
|
let check;
|
|
16
16
|
let raw;
|
|
17
17
|
let parsed;
|
|
18
|
-
const objectString = Decode(Refine(StringType(), (value) => {
|
|
18
|
+
const objectString = Decode$1(Refine(StringType(), (value) => {
|
|
19
19
|
if (value.charCodeAt(0) !== 123) return false;
|
|
20
20
|
if (value === raw) return true;
|
|
21
21
|
try {
|
|
@@ -28,20 +28,24 @@ function ObjectString(property, _options) {
|
|
|
28
28
|
} catch {
|
|
29
29
|
check = (v) => Check(object, v);
|
|
30
30
|
}
|
|
31
|
-
if (!check(next))
|
|
31
|
+
if (!check(next)) {
|
|
32
|
+
raw = parsed = void 0;
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
32
35
|
if (value.length <= MEMO_LIMIT) {
|
|
33
36
|
raw = value;
|
|
34
37
|
parsed = next;
|
|
35
38
|
}
|
|
36
39
|
return true;
|
|
37
40
|
} catch {
|
|
41
|
+
raw = parsed = void 0;
|
|
38
42
|
return false;
|
|
39
43
|
}
|
|
40
44
|
}, () => "must be an object"), (value) => {
|
|
41
45
|
const decoded = value === raw ? parsed : JSON.parse(value);
|
|
42
46
|
raw = void 0;
|
|
43
47
|
parsed = void 0;
|
|
44
|
-
return Decode
|
|
48
|
+
return Decode(object, decoded);
|
|
45
49
|
});
|
|
46
50
|
return elyType(ELYSIA_TYPES.ObjectString, Union([object, objectString], meta));
|
|
47
51
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
3
2
|
const require_utils = require('../../utils.js');
|
|
4
3
|
const require_type_constants = require('../constants.js');
|
|
5
4
|
const require_type_shared = require('../shared.js');
|
|
6
|
-
let typebox_type = require("typebox/type");
|
|
7
5
|
|
|
8
6
|
//#region src/type/elysia/string.ts
|
|
9
|
-
const emptyString = Object.freeze(
|
|
7
|
+
const emptyString = Object.freeze(Object.defineProperty({
|
|
8
|
+
type: "string",
|
|
9
|
+
"~kind": "String"
|
|
10
|
+
}, "~kind", require_type_constants.noEnumerable));
|
|
10
11
|
const stringFormatCache = /* @__PURE__ */ new Map();
|
|
11
12
|
require_type_shared.referenceCache(stringFormatCache);
|
|
12
13
|
function StringType(options) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { evictOldestHalf } from "../../utils.mjs";
|
|
2
2
|
import { noEnumerable } from "../constants.mjs";
|
|
3
3
|
import { SHARED_REFERENCE_CACHE_LIMIT, referenceCache } from "../shared.mjs";
|
|
4
|
-
import { String } from "typebox/type";
|
|
5
4
|
|
|
6
5
|
//#region src/type/elysia/string.ts
|
|
7
|
-
const emptyString = Object.freeze(
|
|
6
|
+
const emptyString = Object.freeze(Object.defineProperty({
|
|
7
|
+
type: "string",
|
|
8
|
+
"~kind": "String"
|
|
9
|
+
}, "~kind", noEnumerable));
|
|
8
10
|
const stringFormatCache = /* @__PURE__ */ new Map();
|
|
9
11
|
referenceCache(stringFormatCache);
|
|
10
12
|
function StringType(options) {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
3
2
|
const require_utils = require('../../utils.js');
|
|
4
3
|
const require_type_constants = require('../constants.js');
|
|
4
|
+
const require_type_typebox_type = require('../typebox-type.js');
|
|
5
5
|
const require_type_elysia_utils = require('./utils.js');
|
|
6
|
-
let typebox_type = require("typebox/type");
|
|
7
6
|
|
|
8
7
|
//#region src/type/elysia/uint8-array.ts
|
|
9
8
|
let BaseUint8Array;
|
|
10
9
|
let emptyUint8Array;
|
|
11
10
|
function Uint8ArrayType(property) {
|
|
12
|
-
BaseUint8Array ??=
|
|
11
|
+
BaseUint8Array ??= require_type_typebox_type.Codec(require_type_typebox_type.Refine(require_type_typebox_type.Unsafe({ "~kind": "Uint8Array" }), (value) => value instanceof Uint8Array || value instanceof ArrayBuffer, () => "must be Uint8Array")).Decode((value) => value instanceof Uint8Array ? value : new Uint8Array(value)).Encode((value) => value);
|
|
13
12
|
if (!property || require_utils.isEmpty(property)) return emptyUint8Array ??= Object.freeze(require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.Uint8Array, BaseUint8Array));
|
|
14
13
|
const refines = [[(value) => value instanceof Uint8Array || value instanceof ArrayBuffer, "must be Uint8Array"]];
|
|
15
14
|
if (property.minByteLength !== void 0) refines.push([(value) => value.byteLength >= property.minByteLength, `Expect byte to be more than ${property.minByteLength}`]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isEmpty } from "../../utils.mjs";
|
|
2
2
|
import { ELYSIA_TYPES } from "../constants.mjs";
|
|
3
|
+
import { Codec, Refine, Unsafe } from "../typebox-type.mjs";
|
|
3
4
|
import { Refines, cloneSchema, elyType, getMeta } from "./utils.mjs";
|
|
4
|
-
import { Codec, Refine, Unsafe } from "typebox/type";
|
|
5
5
|
|
|
6
6
|
//#region src/type/elysia/uint8-array.ts
|
|
7
7
|
let BaseUint8Array;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
3
2
|
const require_type_constants = require('../constants.js');
|
|
3
|
+
const require_type_typebox_type = require('../typebox-type.js');
|
|
4
4
|
const require_type_elysia_utils = require('./utils.js');
|
|
5
|
-
let typebox_type = require("typebox/type");
|
|
6
5
|
|
|
7
6
|
//#region src/type/elysia/union-enum.ts
|
|
8
7
|
let unionEnumNoEnumerable;
|
|
@@ -24,7 +23,7 @@ function UnionEnum(values, options) {
|
|
|
24
23
|
enumerable: false
|
|
25
24
|
});
|
|
26
25
|
if (!mixed) schema.type = kind;
|
|
27
|
-
return require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.UnionEnum,
|
|
26
|
+
return require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.UnionEnum, require_type_typebox_type.Unsafe(schema));
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
//#endregion
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
3
2
|
const require_utils = require('../../utils.js');
|
|
4
3
|
const require_type_shared = require('../shared.js');
|
|
5
|
-
|
|
4
|
+
const require_type_typebox_type = require('../typebox-type.js');
|
|
6
5
|
|
|
7
6
|
//#region src/type/elysia/utils.ts
|
|
8
7
|
function copyNonEnumerable(src, target, skipKey) {
|
|
@@ -82,7 +81,7 @@ function propertyChecksum(property) {
|
|
|
82
81
|
return [require_utils.fnv1a(JSON.stringify(entries))];
|
|
83
82
|
}
|
|
84
83
|
function Refines(schema, refines) {
|
|
85
|
-
for (const [refine, message] of refines) schema =
|
|
84
|
+
for (const [refine, message] of refines) schema = require_type_typebox_type.Refine(schema, refine, () => message);
|
|
86
85
|
return schema;
|
|
87
86
|
}
|
|
88
87
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { evictOldestHalf, fnv1a } from "../../utils.mjs";
|
|
2
2
|
import { SHARED_REFERENCE_CACHE_LIMIT, clearSharedReferenceCaches, referenceCache } from "../shared.mjs";
|
|
3
|
-
import { Refine } from "typebox
|
|
3
|
+
import { Refine } from "../typebox-type.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/type/elysia/utils.ts
|
|
6
6
|
function copyNonEnumerable(src, target, skipKey) {
|
package/dist/type/exports.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.js');
|
|
3
|
+
const require_type_typebox_type = require('./typebox-type.js');
|
|
2
4
|
const require_type_elysia_array = require('./elysia/array.js');
|
|
3
5
|
const require_type_elysia_string = require('./elysia/string.js');
|
|
4
6
|
const require_type_elysia_union = require('./elysia/union.js');
|
|
@@ -27,8 +29,16 @@ const require_type_elysia_numeric_enum = require('./elysia/numeric-enum.js');
|
|
|
27
29
|
const require_type_elysia_optional = require('./elysia/optional.js');
|
|
28
30
|
const require_type_elysia_uint8_array = require('./elysia/uint8-array.js');
|
|
29
31
|
const require_type_elysia_union_enum = require('./elysia/union-enum.js');
|
|
32
|
+
let typebox_type = require("typebox/type");
|
|
33
|
+
typebox_type = require_runtime.__toESM(typebox_type);
|
|
34
|
+
let typebox_system = require("typebox/system");
|
|
35
|
+
typebox_system = require_runtime.__toESM(typebox_system);
|
|
30
36
|
|
|
31
37
|
//#region src/type/exports.ts
|
|
38
|
+
require_type_typebox_type.injectTypeboxType({
|
|
39
|
+
type: typebox_type,
|
|
40
|
+
system: typebox_system
|
|
41
|
+
});
|
|
32
42
|
require_type_compat.setupTypebox();
|
|
33
43
|
|
|
34
44
|
//#endregion
|
|
@@ -59,7 +69,6 @@ exports.String = require_type_elysia_string.StringType;
|
|
|
59
69
|
exports.Uint8Array = require_type_elysia_uint8_array.Uint8ArrayType;
|
|
60
70
|
exports.Union = require_type_elysia_union.Union;
|
|
61
71
|
exports.UnionEnum = require_type_elysia_union_enum.UnionEnum;
|
|
62
|
-
var typebox_type = require("typebox/type");
|
|
63
72
|
Object.keys(typebox_type).forEach(function (k) {
|
|
64
73
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
65
74
|
enumerable: true,
|
package/dist/type/exports.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { injectTypeboxType } from "./typebox-type.mjs";
|
|
1
2
|
import { ArrayType } from "./elysia/array.mjs";
|
|
2
3
|
import { StringType } from "./elysia/string.mjs";
|
|
3
4
|
import { Union } from "./elysia/union.mjs";
|
|
@@ -26,10 +27,16 @@ import { NumericEnum } from "./elysia/numeric-enum.mjs";
|
|
|
26
27
|
import { Optional } from "./elysia/optional.mjs";
|
|
27
28
|
import { Uint8ArrayType } from "./elysia/uint8-array.mjs";
|
|
28
29
|
import { UnionEnum } from "./elysia/union-enum.mjs";
|
|
30
|
+
import * as type from "typebox/type";
|
|
31
|
+
import * as system from "typebox/system";
|
|
29
32
|
|
|
30
33
|
export * from "typebox/type"
|
|
31
34
|
|
|
32
35
|
//#region src/type/exports.ts
|
|
36
|
+
injectTypeboxType({
|
|
37
|
+
type,
|
|
38
|
+
system
|
|
39
|
+
});
|
|
33
40
|
setupTypebox();
|
|
34
41
|
|
|
35
42
|
//#endregion
|
package/dist/type/index.d.ts
CHANGED
|
@@ -4,10 +4,18 @@ import { exports_d_exports } from "./exports.js";
|
|
|
4
4
|
import { setupTypebox } from "./compat.js";
|
|
5
5
|
import { TypeBoxValidator } from "./validator/index.js";
|
|
6
6
|
import * as TypeBoxType from "typebox/type";
|
|
7
|
-
import { System
|
|
7
|
+
import { System } from "typebox/system";
|
|
8
8
|
|
|
9
9
|
//#region src/type/index.d.ts
|
|
10
10
|
type TypeBuilder = Omit<typeof TypeBoxType, keyof typeof exports_d_exports> & typeof exports_d_exports;
|
|
11
11
|
declare const t: TypeBuilder;
|
|
12
|
+
/**
|
|
13
|
+
* `typebox/system` is a subgraph of `typebox/type`, so a static re-export here
|
|
14
|
+
* would pin ~231 KB of the deferral back into the eager graph. The proxy also
|
|
15
|
+
* guarantees Elysia's own `Settings` default lands BEFORE the namespace is
|
|
16
|
+
* handed out, keeping a user's explicit `TypeSystem.Settings.Set(...)` last —
|
|
17
|
+
* the ordering the eager `setupTypebox()` used to provide
|
|
18
|
+
*/
|
|
19
|
+
declare const TypeSystem: typeof System;
|
|
12
20
|
//#endregion
|
|
13
21
|
export { type AnySchema, type BaseSchema, type FileTypeDetector, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, type TypeBoxSchema, TypeBoxValidator, TypeSystem, fileType, setFileTypeDetector, setupTypebox, t };
|
package/dist/type/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.js');
|
|
3
2
|
const require_type_elysia_file_type = require('./elysia/file-type.js');
|
|
3
|
+
const require_type_typebox_type = require('./typebox-type.js');
|
|
4
4
|
const require_type_elysia_array = require('./elysia/array.js');
|
|
5
5
|
const require_type_elysia_string = require('./elysia/string.js');
|
|
6
6
|
const require_type_elysia_union = require('./elysia/union.js');
|
|
@@ -30,14 +30,39 @@ const require_type_elysia_numeric_enum = require('./elysia/numeric-enum.js');
|
|
|
30
30
|
const require_type_elysia_optional = require('./elysia/optional.js');
|
|
31
31
|
const require_type_elysia_uint8_array = require('./elysia/uint8-array.js');
|
|
32
32
|
const require_type_elysia_union_enum = require('./elysia/union-enum.js');
|
|
33
|
-
let typebox_type = require("typebox/type");
|
|
34
|
-
typebox_type = require_runtime.__toESM(typebox_type);
|
|
35
|
-
let typebox_system = require("typebox/system");
|
|
36
33
|
|
|
37
34
|
//#region src/type/index.ts
|
|
38
35
|
require_type_compat.setupTypebox();
|
|
39
|
-
const
|
|
40
|
-
|
|
36
|
+
const hasOwn = (target, key) => Object.prototype.hasOwnProperty.call(target, key);
|
|
37
|
+
/**
|
|
38
|
+
* A namespace object that materializes `typebox/type` only when a key it does
|
|
39
|
+
* not own is actually read
|
|
40
|
+
*/
|
|
41
|
+
const lazyNamespace = (resolve, overrides) => new Proxy(overrides, {
|
|
42
|
+
get: (target, key, receiver) => key in target ? Reflect.get(target, key, receiver) : resolve()[key],
|
|
43
|
+
has: (target, key) => key in target || key in resolve(),
|
|
44
|
+
ownKeys(target) {
|
|
45
|
+
const keys = Object.keys(resolve());
|
|
46
|
+
for (const key of Object.getOwnPropertyNames(target)) if (!keys.includes(key)) keys.push(key);
|
|
47
|
+
return keys;
|
|
48
|
+
},
|
|
49
|
+
getOwnPropertyDescriptor(target, key) {
|
|
50
|
+
if (hasOwn(target, key)) return Reflect.getOwnPropertyDescriptor(target, key);
|
|
51
|
+
const ns = resolve();
|
|
52
|
+
if (!hasOwn(ns, key)) return;
|
|
53
|
+
return {
|
|
54
|
+
value: ns[key],
|
|
55
|
+
enumerable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
configurable: true
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
preventExtensions: () => false,
|
|
61
|
+
set: (target, key, value) => Reflect.set(target, key, value),
|
|
62
|
+
defineProperty: (target, key, descriptor) => Reflect.defineProperty(target, key, descriptor),
|
|
63
|
+
deleteProperty: (target, key) => Reflect.deleteProperty(target, key)
|
|
64
|
+
});
|
|
65
|
+
const t = lazyNamespace(() => require_type_typebox_type.loadTypeNamespace().type, {
|
|
41
66
|
Accelerate: require_type_elysia_accelerate.Accelerate,
|
|
42
67
|
Array: require_type_elysia_array.ArrayType,
|
|
43
68
|
ArrayBuffer: require_type_elysia_array_buffer.ArrayBufferType,
|
|
@@ -65,16 +90,19 @@ const t = {
|
|
|
65
90
|
Uint8Array: require_type_elysia_uint8_array.Uint8ArrayType,
|
|
66
91
|
Union: require_type_elysia_union.Union,
|
|
67
92
|
UnionEnum: require_type_elysia_union_enum.UnionEnum
|
|
68
|
-
};
|
|
93
|
+
});
|
|
94
|
+
/**
|
|
95
|
+
* `typebox/system` is a subgraph of `typebox/type`, so a static re-export here
|
|
96
|
+
* would pin ~231 KB of the deferral back into the eager graph. The proxy also
|
|
97
|
+
* guarantees Elysia's own `Settings` default lands BEFORE the namespace is
|
|
98
|
+
* handed out, keeping a user's explicit `TypeSystem.Settings.Set(...)` last —
|
|
99
|
+
* the ordering the eager `setupTypebox()` used to provide
|
|
100
|
+
*/
|
|
101
|
+
const TypeSystem = lazyNamespace(() => require_type_typebox_type.loadTypeNamespace().system.System, Object.create(null));
|
|
69
102
|
|
|
70
103
|
//#endregion
|
|
71
104
|
exports.TypeBoxValidator = require_type_validator_index.TypeBoxValidator;
|
|
72
|
-
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function () {
|
|
75
|
-
return typebox_system.System;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
105
|
+
exports.TypeSystem = TypeSystem;
|
|
78
106
|
exports.fileType = require_type_elysia_file_type.fileType;
|
|
79
107
|
exports.setFileTypeDetector = require_type_elysia_file_type.setFileTypeDetector;
|
|
80
108
|
exports.setupTypebox = require_type_compat.setupTypebox;
|
package/dist/type/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fileType, setFileTypeDetector } from "./elysia/file-type.mjs";
|
|
2
|
+
import { loadTypeNamespace } from "./typebox-type.mjs";
|
|
2
3
|
import { ArrayType } from "./elysia/array.mjs";
|
|
3
4
|
import { StringType } from "./elysia/string.mjs";
|
|
4
5
|
import { Union } from "./elysia/union.mjs";
|
|
@@ -9,11 +10,11 @@ import { NumberType } from "./elysia/number.mjs";
|
|
|
9
10
|
import { Numeric } from "./elysia/numeric.mjs";
|
|
10
11
|
import { BooleanType } from "./elysia/boolean.mjs";
|
|
11
12
|
import { BooleanString } from "./elysia/boolean-string.mjs";
|
|
12
|
-
import { Integer
|
|
13
|
+
import { Integer } from "./elysia/integer.mjs";
|
|
13
14
|
import { IntegerString } from "./elysia/integer-string.mjs";
|
|
14
15
|
import { File } from "./elysia/file.mjs";
|
|
15
16
|
import { TypeBoxValidator } from "./validator/index.mjs";
|
|
16
|
-
import { Intersect
|
|
17
|
+
import { Intersect } from "./elysia/intersect.mjs";
|
|
17
18
|
import { setupTypebox } from "./compat.mjs";
|
|
18
19
|
import { Accelerate } from "./elysia/accelerate.mjs";
|
|
19
20
|
import { ArrayBufferType } from "./elysia/array-buffer.mjs";
|
|
@@ -28,13 +29,39 @@ import { NumericEnum } from "./elysia/numeric-enum.mjs";
|
|
|
28
29
|
import { Optional } from "./elysia/optional.mjs";
|
|
29
30
|
import { Uint8ArrayType } from "./elysia/uint8-array.mjs";
|
|
30
31
|
import { UnionEnum } from "./elysia/union-enum.mjs";
|
|
31
|
-
import * as TypeBox from "typebox/type";
|
|
32
|
-
import { System as TypeSystem } from "typebox/system";
|
|
33
32
|
|
|
34
33
|
//#region src/type/index.ts
|
|
35
34
|
setupTypebox();
|
|
36
|
-
const
|
|
37
|
-
|
|
35
|
+
const hasOwn = (target, key) => Object.prototype.hasOwnProperty.call(target, key);
|
|
36
|
+
/**
|
|
37
|
+
* A namespace object that materializes `typebox/type` only when a key it does
|
|
38
|
+
* not own is actually read
|
|
39
|
+
*/
|
|
40
|
+
const lazyNamespace = (resolve, overrides) => new Proxy(overrides, {
|
|
41
|
+
get: (target, key, receiver) => key in target ? Reflect.get(target, key, receiver) : resolve()[key],
|
|
42
|
+
has: (target, key) => key in target || key in resolve(),
|
|
43
|
+
ownKeys(target) {
|
|
44
|
+
const keys = Object.keys(resolve());
|
|
45
|
+
for (const key of Object.getOwnPropertyNames(target)) if (!keys.includes(key)) keys.push(key);
|
|
46
|
+
return keys;
|
|
47
|
+
},
|
|
48
|
+
getOwnPropertyDescriptor(target, key) {
|
|
49
|
+
if (hasOwn(target, key)) return Reflect.getOwnPropertyDescriptor(target, key);
|
|
50
|
+
const ns = resolve();
|
|
51
|
+
if (!hasOwn(ns, key)) return;
|
|
52
|
+
return {
|
|
53
|
+
value: ns[key],
|
|
54
|
+
enumerable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
configurable: true
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
preventExtensions: () => false,
|
|
60
|
+
set: (target, key, value) => Reflect.set(target, key, value),
|
|
61
|
+
defineProperty: (target, key, descriptor) => Reflect.defineProperty(target, key, descriptor),
|
|
62
|
+
deleteProperty: (target, key) => Reflect.deleteProperty(target, key)
|
|
63
|
+
});
|
|
64
|
+
const t = lazyNamespace(() => loadTypeNamespace().type, {
|
|
38
65
|
Accelerate,
|
|
39
66
|
Array: ArrayType,
|
|
40
67
|
ArrayBuffer: ArrayBufferType,
|
|
@@ -46,8 +73,8 @@ const t = {
|
|
|
46
73
|
File,
|
|
47
74
|
Files,
|
|
48
75
|
Form,
|
|
49
|
-
Integer
|
|
50
|
-
Intersect
|
|
76
|
+
Integer,
|
|
77
|
+
Intersect,
|
|
51
78
|
IntegerString,
|
|
52
79
|
MaybeEmpty,
|
|
53
80
|
NoValidate,
|
|
@@ -62,7 +89,15 @@ const t = {
|
|
|
62
89
|
Uint8Array: Uint8ArrayType,
|
|
63
90
|
Union,
|
|
64
91
|
UnionEnum
|
|
65
|
-
};
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* `typebox/system` is a subgraph of `typebox/type`, so a static re-export here
|
|
95
|
+
* would pin ~231 KB of the deferral back into the eager graph. The proxy also
|
|
96
|
+
* guarantees Elysia's own `Settings` default lands BEFORE the namespace is
|
|
97
|
+
* handed out, keeping a user's explicit `TypeSystem.Settings.Set(...)` last —
|
|
98
|
+
* the ordering the eager `setupTypebox()` used to provide
|
|
99
|
+
*/
|
|
100
|
+
const TypeSystem = lazyNamespace(() => loadTypeNamespace().system.System, Object.create(null));
|
|
66
101
|
|
|
67
102
|
//#endregion
|
|
68
103
|
export { TypeBoxValidator, TypeSystem, fileType, setFileTypeDetector, setupTypebox, t };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TypeboxTypeNamespaces } from "./typebox-type.js";
|
|
2
|
+
import { Codec, Decode, Evaluate, Intersect, Module, Null, Ref, Refine, Undefined, Unsafe } from "typebox/type";
|
|
3
|
+
|
|
4
|
+
//#region src/type/typebox-type-live.d.ts
|
|
5
|
+
declare function injectTypeboxType(_typebox?: TypeboxTypeNamespaces): void;
|
|
6
|
+
declare function ensureTypeSettings(): void;
|
|
7
|
+
declare const loadTypeNamespace: () => TypeboxTypeNamespaces;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { Codec, Decode, Evaluate, Intersect, Module, Null, Ref, Refine, type TypeboxTypeNamespaces, Undefined, Unsafe, ensureTypeSettings, injectTypeboxType, loadTypeNamespace };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.js');
|
|
3
|
+
let typebox_type = require("typebox/type");
|
|
4
|
+
typebox_type = require_runtime.__toESM(typebox_type);
|
|
5
|
+
let typebox_system = require("typebox/system");
|
|
6
|
+
typebox_system = require_runtime.__toESM(typebox_system);
|
|
7
|
+
|
|
8
|
+
//#region src/type/typebox-type-live.ts
|
|
9
|
+
typebox_system.Settings.Set({ unionPrioritySort: false });
|
|
10
|
+
const namespaces = {
|
|
11
|
+
type: typebox_type,
|
|
12
|
+
system: typebox_system
|
|
13
|
+
};
|
|
14
|
+
function injectTypeboxType(_typebox) {}
|
|
15
|
+
function ensureTypeSettings() {}
|
|
16
|
+
const loadTypeNamespace = () => namespaces;
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.Codec = typebox_type.Codec;
|
|
20
|
+
exports.Decode = typebox_type.Decode;
|
|
21
|
+
exports.Evaluate = typebox_type.Evaluate;
|
|
22
|
+
exports.Intersect = typebox_type.Intersect;
|
|
23
|
+
exports.Module = typebox_type.Module;
|
|
24
|
+
exports.Null = typebox_type.Null;
|
|
25
|
+
exports.Ref = typebox_type.Ref;
|
|
26
|
+
exports.Refine = typebox_type.Refine;
|
|
27
|
+
exports.Undefined = typebox_type.Undefined;
|
|
28
|
+
exports.Unsafe = typebox_type.Unsafe;
|
|
29
|
+
exports.ensureTypeSettings = ensureTypeSettings;
|
|
30
|
+
exports.injectTypeboxType = injectTypeboxType;
|
|
31
|
+
exports.loadTypeNamespace = loadTypeNamespace;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as type from "typebox/type";
|
|
2
|
+
import { Codec, Decode, Evaluate, Intersect, Module, Null, Ref, Refine, Undefined, Unsafe } from "typebox/type";
|
|
3
|
+
import * as system from "typebox/system";
|
|
4
|
+
|
|
5
|
+
//#region src/type/typebox-type-live.ts
|
|
6
|
+
system.Settings.Set({ unionPrioritySort: false });
|
|
7
|
+
const namespaces = {
|
|
8
|
+
type,
|
|
9
|
+
system
|
|
10
|
+
};
|
|
11
|
+
function injectTypeboxType(_typebox) {}
|
|
12
|
+
function ensureTypeSettings() {}
|
|
13
|
+
const loadTypeNamespace = () => namespaces;
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Codec, Decode, Evaluate, Intersect, Module, Null, Ref, Refine, Undefined, Unsafe, ensureTypeSettings, injectTypeboxType, loadTypeNamespace };
|