elysia 2.0.0-beta.2 → 2.0.0-beta.21
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/bun/index.d.ts +18 -2
- package/dist/adapter/bun/index.js +467 -110
- package/dist/adapter/bun/index.mjs +467 -112
- package/dist/adapter/types.d.ts +2 -21
- package/dist/adapter/utils.d.ts +14 -3
- package/dist/adapter/utils.js +146 -87
- package/dist/adapter/utils.mjs +148 -90
- package/dist/adapter/web-standard/handler.d.ts +1 -1
- package/dist/adapter/web-standard/handler.js +47 -36
- package/dist/adapter/web-standard/handler.mjs +48 -37
- package/dist/adapter/web-standard/index.js +2 -30
- package/dist/adapter/web-standard/index.mjs +2 -30
- package/dist/adapter/web-standard/utils.js +5 -18
- package/dist/adapter/web-standard/utils.mjs +5 -18
- package/dist/base.d.ts +99 -67
- package/dist/base.js +678 -510
- package/dist/base.mjs +682 -514
- package/dist/compile/aot-capture.d.ts +2 -13
- package/dist/compile/aot-capture.js +26 -69
- package/dist/compile/aot-capture.mjs +28 -67
- package/dist/compile/aot-emit.d.ts +9 -7
- package/dist/compile/aot-emit.js +42 -19
- package/dist/compile/aot-emit.mjs +42 -20
- package/dist/compile/aot.d.ts +17 -19
- package/dist/compile/aot.js +41 -51
- package/dist/compile/aot.mjs +39 -49
- package/dist/compile/handler/descriptor.d.ts +9 -12
- package/dist/compile/handler/descriptor.js +19 -44
- package/dist/compile/handler/descriptor.mjs +20 -42
- package/dist/compile/handler/frozen-validator.d.ts +5 -10
- package/dist/compile/handler/frozen-validator.js +55 -105
- package/dist/compile/handler/frozen-validator.mjs +53 -105
- package/dist/compile/handler/index.d.ts +7 -5
- package/dist/compile/handler/index.js +270 -111
- package/dist/compile/handler/index.mjs +270 -113
- package/dist/compile/handler/jit.d.ts +19 -17
- package/dist/compile/handler/jit.js +222 -149
- package/dist/compile/handler/jit.mjs +224 -152
- package/dist/compile/handler/params.d.ts +1 -4
- package/dist/compile/handler/params.js +10 -5
- package/dist/compile/handler/params.mjs +14 -8
- package/dist/compile/handler/reconstruct.d.ts +2 -2
- package/dist/compile/handler/reconstruct.js +6 -4
- package/dist/compile/handler/reconstruct.mjs +6 -4
- package/dist/compile/handler/static-clone-resolver.d.ts +6 -0
- package/dist/compile/handler/static-clone-resolver.js +8 -0
- package/dist/compile/handler/static-clone-resolver.mjs +7 -0
- package/dist/compile/handler/utils.d.ts +22 -11
- package/dist/compile/handler/utils.js +159 -253
- package/dist/compile/handler/utils.mjs +155 -252
- package/dist/compile/jit-probe.d.ts +2 -2
- package/dist/compile/jit-probe.js +2 -3
- package/dist/compile/jit-probe.mjs +2 -3
- package/dist/compile/lexer.d.ts +7 -4
- package/dist/compile/lexer.js +268 -6
- package/dist/compile/lexer.mjs +268 -4
- package/dist/compile/utils.js +7 -4
- package/dist/compile/utils.mjs +7 -4
- package/dist/compiled.d.ts +0 -1
- package/dist/compiled.js +0 -1
- package/dist/compiled.mjs +0 -1
- package/dist/context.d.ts +14 -4
- package/dist/context.js +17 -32
- package/dist/context.mjs +19 -34
- package/dist/cookie/config.d.ts +7 -2
- package/dist/cookie/config.js +76 -16
- package/dist/cookie/config.mjs +77 -18
- package/dist/cookie/cookie.d.ts +1 -1
- package/dist/cookie/cookie.js +8 -10
- package/dist/cookie/cookie.mjs +8 -10
- package/dist/cookie/crypto.d.ts +8 -7
- package/dist/cookie/crypto.js +51 -40
- package/dist/cookie/crypto.mjs +51 -41
- package/dist/cookie/error.d.ts +1 -2
- package/dist/cookie/error.js +6 -4
- package/dist/cookie/error.mjs +6 -4
- package/dist/cookie/lib.js +7 -2
- package/dist/cookie/lib.mjs +7 -2
- 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.d.ts +4 -8
- package/dist/cookie/utils.js +86 -52
- package/dist/cookie/utils.mjs +89 -54
- package/dist/error.d.ts +113 -103
- package/dist/error.js +181 -117
- package/dist/error.mjs +179 -118
- package/dist/generation.d.ts +2 -2
- package/dist/handler/error.d.ts +26 -15
- package/dist/handler/error.js +77 -96
- package/dist/handler/error.mjs +74 -97
- package/dist/handler/fetch.js +87 -108
- package/dist/handler/fetch.mjs +89 -110
- package/dist/handler/utils.d.ts +12 -6
- package/dist/handler/utils.js +84 -28
- package/dist/handler/utils.mjs +80 -28
- package/dist/index.d.ts +12 -12
- package/dist/index.js +2 -9
- package/dist/index.mjs +1 -1
- package/dist/memory.js +1 -1
- package/dist/memory.mjs +1 -1
- package/dist/package.js +1 -1
- package/dist/package.mjs +1 -1
- package/dist/plugin/aot/bun.d.ts +8 -1
- package/dist/plugin/aot/bun.js +16 -9
- package/dist/plugin/aot/bun.mjs +17 -10
- package/dist/plugin/aot/core.d.ts +52 -60
- package/dist/plugin/aot/core.js +208 -109
- package/dist/plugin/aot/core.mjs +205 -111
- package/dist/plugin/aot/esbuild.js +8 -5
- package/dist/plugin/aot/esbuild.mjs +9 -6
- package/dist/plugin/aot/hooks.d.ts +6 -17
- package/dist/plugin/aot/hooks.js +36 -14
- package/dist/plugin/aot/hooks.mjs +37 -16
- package/dist/plugin/aot/rspack-loader.d.ts +1 -5
- package/dist/plugin/aot/rspack-loader.js +1 -10
- package/dist/plugin/aot/rspack-loader.mjs +1 -10
- package/dist/plugin/aot/rspack.js +2 -5
- package/dist/plugin/aot/rspack.mjs +3 -6
- package/dist/plugin/aot/source.d.ts +6 -42
- package/dist/plugin/aot/source.js +71 -71
- package/dist/plugin/aot/source.mjs +72 -72
- package/dist/plugin/aot/treeshake.js +2 -6
- package/dist/plugin/aot/treeshake.mjs +2 -6
- package/dist/plugin/aot/unplugin.d.ts +1 -4
- package/dist/plugin/aot/unplugin.js +4 -13
- package/dist/plugin/aot/unplugin.mjs +4 -13
- package/dist/plugin/aot/vite.d.ts +2 -6
- package/dist/plugin/aot/worker.js +2 -2
- package/dist/plugin/aot/worker.mjs +2 -2
- package/dist/plugin/auto-head.js +1 -10
- package/dist/plugin/auto-head.mjs +1 -10
- package/dist/plugin/trace.d.ts +2 -1
- package/dist/route-table.d.ts +3 -0
- package/dist/route-table.js +16 -11
- package/dist/route-table.mjs +16 -11
- package/dist/schema-snapshot.d.ts +0 -4
- package/dist/schema-snapshot.js +32 -49
- package/dist/schema-snapshot.mjs +32 -49
- package/dist/sucrose.d.ts +6 -55
- package/dist/sucrose.js +103 -731
- package/dist/sucrose.mjs +102 -724
- package/dist/trace.d.ts +5 -8
- package/dist/trace.js +23 -134
- package/dist/trace.mjs +24 -135
- package/dist/type/bridge-live.d.ts +4 -2
- package/dist/type/bridge-live.js +6 -3
- package/dist/type/bridge-live.mjs +4 -2
- package/dist/type/bridge.d.ts +6 -4
- package/dist/type/bridge.js +17 -9
- package/dist/type/bridge.mjs +5 -3
- package/dist/type/coerce-plan.d.ts +5 -5
- package/dist/type/coerce-plan.js +41 -39
- package/dist/type/coerce-plan.mjs +43 -39
- package/dist/type/coerce.d.ts +3 -7
- package/dist/type/coerce.js +18 -75
- package/dist/type/coerce.mjs +19 -76
- package/dist/type/compat.d.ts +3 -0
- package/dist/type/compat.js +23 -14
- package/dist/type/compat.mjs +20 -10
- package/dist/type/elysia/array-buffer.d.ts +4 -1
- package/dist/type/elysia/array-buffer.js +17 -17
- package/dist/type/elysia/array-buffer.mjs +17 -17
- package/dist/type/elysia/array-string.js +2 -40
- package/dist/type/elysia/array-string.mjs +2 -39
- package/dist/type/elysia/array.js +5 -9
- package/dist/type/elysia/array.mjs +5 -9
- package/dist/type/elysia/boolean-string.js +2 -3
- package/dist/type/elysia/boolean-string.mjs +1 -1
- package/dist/type/elysia/boolean.js +3 -12
- package/dist/type/elysia/boolean.mjs +3 -11
- package/dist/type/elysia/cookie.d.ts +3 -4
- package/dist/type/elysia/cookie.js +5 -15
- package/dist/type/elysia/cookie.mjs +5 -15
- package/dist/type/elysia/date.js +13 -20
- package/dist/type/elysia/date.mjs +10 -16
- package/dist/type/elysia/file-type.d.ts +11 -4
- package/dist/type/elysia/file-type.js +17 -2
- package/dist/type/elysia/file-type.mjs +17 -3
- package/dist/type/elysia/file.d.ts +1 -3
- package/dist/type/elysia/file.js +11 -27
- package/dist/type/elysia/file.mjs +11 -12
- package/dist/type/elysia/files.js +7 -11
- package/dist/type/elysia/files.mjs +7 -10
- package/dist/type/elysia/form.js +2 -3
- package/dist/type/elysia/form.mjs +3 -3
- package/dist/type/elysia/integer-string.d.ts +1 -1
- package/dist/type/elysia/integer-string.js +4 -30
- package/dist/type/elysia/integer-string.mjs +5 -30
- package/dist/type/elysia/integer.js +3 -12
- package/dist/type/elysia/integer.mjs +3 -11
- package/dist/type/elysia/intersect.js +0 -5
- package/dist/type/elysia/intersect.mjs +0 -5
- package/dist/type/elysia/json-string.d.ts +7 -0
- package/dist/type/elysia/json-string.js +47 -0
- package/dist/type/elysia/json-string.mjs +46 -0
- package/dist/type/elysia/keep-config.d.ts +14 -0
- package/dist/type/elysia/keep-config.js +62 -0
- package/dist/type/elysia/keep-config.mjs +53 -0
- 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.d.ts +2 -1
- package/dist/type/elysia/number.js +19 -11
- package/dist/type/elysia/number.mjs +18 -10
- package/dist/type/elysia/numeric-enum.d.ts +1 -1
- package/dist/type/elysia/numeric-enum.js +4 -5
- package/dist/type/elysia/numeric-enum.mjs +3 -3
- package/dist/type/elysia/numeric.d.ts +4 -2
- package/dist/type/elysia/numeric.js +20 -17
- package/dist/type/elysia/numeric.mjs +19 -16
- package/dist/type/elysia/object-string.js +2 -37
- package/dist/type/elysia/object-string.mjs +2 -36
- package/dist/type/elysia/object.js +5 -9
- package/dist/type/elysia/object.mjs +5 -9
- package/dist/type/elysia/optional.js +8 -8
- package/dist/type/elysia/optional.mjs +7 -7
- package/dist/type/elysia/problem.d.ts +20 -0
- package/dist/type/elysia/problem.js +25 -0
- package/dist/type/elysia/problem.mjs +24 -0
- package/dist/type/elysia/string.js +4 -3
- package/dist/type/elysia/string.mjs +4 -2
- package/dist/type/elysia/uint8-array.d.ts +1 -1
- package/dist/type/elysia/uint8-array.js +5 -20
- package/dist/type/elysia/uint8-array.mjs +5 -19
- package/dist/type/elysia/union-enum.js +7 -8
- package/dist/type/elysia/union-enum.mjs +6 -6
- package/dist/type/elysia/union.js +0 -5
- package/dist/type/elysia/union.mjs +0 -5
- package/dist/type/elysia/utils.d.ts +2 -4
- package/dist/type/elysia/utils.js +10 -21
- package/dist/type/elysia/utils.mjs +7 -15
- package/dist/type/exports.d.ts +4 -2
- package/dist/type/exports.js +23 -2
- package/dist/type/exports.mjs +11 -2
- package/dist/type/index.d.ts +10 -2
- package/dist/type/index.js +62 -15
- package/dist/type/index.mjs +65 -11
- package/dist/type/shared.d.ts +3 -9
- package/dist/type/shared.js +44 -97
- package/dist/type/shared.mjs +43 -97
- package/dist/type/sync-require.d.ts +11 -0
- package/dist/type/sync-require.js +14 -0
- package/dist/type/sync-require.mjs +12 -0
- package/dist/type/typebox-system-lite.d.ts +2 -0
- package/dist/type/typebox-system-lite.js +34 -0
- package/dist/type/typebox-system-lite.mjs +3 -0
- package/dist/type/typebox-system-require.d.ts +7 -0
- package/dist/type/typebox-system-require.js +24 -0
- package/dist/type/typebox-system-require.mjs +23 -0
- package/dist/type/typebox-type-live.d.ts +11 -0
- package/dist/type/typebox-type-live.js +45 -0
- package/dist/type/typebox-type-live.mjs +20 -0
- package/dist/type/typebox-type.d.ts +34 -0
- package/dist/type/typebox-type.js +199 -0
- package/dist/type/typebox-type.mjs +86 -0
- package/dist/type/typebox-value-live.d.ts +11 -0
- package/dist/type/typebox-value-live.js +31 -0
- package/dist/type/typebox-value-live.mjs +13 -0
- package/dist/type/typebox-value-ops.d.ts +4 -0
- package/dist/type/typebox-value-ops.js +90 -0
- package/dist/type/typebox-value-ops.mjs +5 -0
- package/dist/type/typebox-value-require.d.ts +8 -0
- package/dist/type/typebox-value-require.js +28 -0
- package/dist/type/typebox-value-require.mjs +25 -0
- package/dist/type/typebox-value.d.ts +35 -0
- package/dist/type/typebox-value.js +161 -0
- package/dist/type/typebox-value.mjs +74 -0
- package/dist/type/utils.js +1 -10
- package/dist/type/utils.mjs +1 -10
- package/dist/type/validator/clean-safe.d.ts +2 -4
- package/dist/type/validator/clean-safe.js +15 -11
- package/dist/type/validator/clean-safe.mjs +16 -10
- package/dist/type/validator/custom-error.js +12 -16
- package/dist/type/validator/custom-error.mjs +11 -14
- package/dist/type/validator/default-precompute.d.ts +9 -1
- package/dist/type/validator/default-precompute.js +40 -77
- package/dist/type/validator/default-precompute.mjs +37 -74
- package/dist/type/validator/exact-mirror-live.d.ts +8 -0
- package/dist/type/validator/exact-mirror-live.js +22 -0
- package/dist/type/validator/exact-mirror-live.mjs +17 -0
- package/dist/type/validator/exact-mirror-require.d.ts +4 -0
- package/dist/type/validator/exact-mirror-require.js +11 -0
- package/dist/type/validator/exact-mirror-require.mjs +9 -0
- package/dist/type/validator/exact-mirror.js +8 -8
- package/dist/type/validator/exact-mirror.mjs +9 -8
- package/dist/type/validator/frozen-check.js +5 -6
- package/dist/type/validator/frozen-check.mjs +6 -7
- package/dist/type/validator/index.d.ts +1 -0
- package/dist/type/validator/index.js +169 -166
- package/dist/type/validator/index.mjs +162 -158
- package/dist/type/validator/string-codec-aot.d.ts +2 -1
- package/dist/type/validator/string-codec-aot.js +8 -2
- package/dist/type/validator/string-codec-aot.mjs +7 -2
- package/dist/type/validator/validator-cache.d.ts +5 -4
- package/dist/type/validator/validator-cache.js +41 -24
- package/dist/type/validator/validator-cache.mjs +40 -22
- package/dist/types.d.ts +263 -95
- package/dist/universal/constants.d.ts +2 -1
- package/dist/universal/constants.js +3 -1
- package/dist/universal/constants.mjs +2 -1
- package/dist/universal/env.js +2 -3
- package/dist/universal/env.mjs +2 -3
- package/dist/universal/file.d.ts +6 -4
- package/dist/universal/file.js +11 -16
- package/dist/universal/file.mjs +12 -16
- package/dist/universal/index.d.ts +2 -2
- package/dist/universal/is-production.d.ts +1 -2
- package/dist/universal/is-production.js +1 -3
- package/dist/universal/is-production.mjs +2 -3
- package/dist/universal/server.d.ts +0 -272
- package/dist/utils.d.ts +43 -7
- package/dist/utils.js +181 -126
- package/dist/utils.mjs +168 -126
- package/dist/validator/index.d.ts +1 -1
- package/dist/validator/index.js +17 -30
- package/dist/validator/index.mjs +18 -31
- package/dist/validator/route.js +2 -1
- package/dist/validator/route.mjs +2 -1
- package/dist/ws/context.d.ts +8 -1
- package/dist/ws/context.js +68 -44
- package/dist/ws/context.mjs +67 -44
- package/dist/ws/parser.js +10 -20
- package/dist/ws/parser.mjs +10 -20
- package/dist/ws/route.d.ts +2 -2
- package/dist/ws/route.js +249 -141
- package/dist/ws/route.mjs +254 -146
- package/dist/ws/types.d.ts +2 -2
- package/package.json +23 -49
- package/dist/compile/analysis-cache.d.ts +0 -6
- package/dist/compile/analysis-cache.js +0 -12
- package/dist/compile/analysis-cache.mjs +0 -11
- package/dist/cookie/index.d.ts +0 -7
- package/dist/cookie/index.js +0 -13
- package/dist/cookie/index.mjs +0 -7
- package/dist/handler/index.d.ts +0 -2
- package/dist/handler/index.js +0 -5
- package/dist/handler/index.mjs +0 -3
|
@@ -1,49 +1,15 @@
|
|
|
1
1
|
import { nullObject } from "../../utils.mjs";
|
|
2
|
-
import { Check, Compile, Decode as Decode$1 } from "../bridge.mjs";
|
|
3
2
|
import { ELYSIA_TYPES } from "../constants.mjs";
|
|
4
|
-
import {
|
|
3
|
+
import { jsonString } from "./json-string.mjs";
|
|
5
4
|
import { Union } from "./union.mjs";
|
|
6
5
|
import { elyType, getMeta } from "./utils.mjs";
|
|
7
6
|
import { ObjectType } from "./object.mjs";
|
|
8
|
-
import { Decode, Refine } from "typebox/type";
|
|
9
7
|
|
|
10
8
|
//#region src/type/elysia/object-string.ts
|
|
11
|
-
const MEMO_LIMIT = 8192;
|
|
12
9
|
function ObjectString(property, _options) {
|
|
13
10
|
const [{ properties, ...constraints }, meta] = getMeta(_options ?? nullObject());
|
|
14
11
|
const object = ObjectType(property, constraints);
|
|
15
|
-
|
|
16
|
-
let raw;
|
|
17
|
-
let parsed;
|
|
18
|
-
const objectString = Decode(Refine(StringType(), (value) => {
|
|
19
|
-
if (value.charCodeAt(0) !== 123) return false;
|
|
20
|
-
if (value === raw) return true;
|
|
21
|
-
try {
|
|
22
|
-
const next = JSON.parse(value);
|
|
23
|
-
if (!check) try {
|
|
24
|
-
const compiled = Compile(object);
|
|
25
|
-
if (compiled.evaluateResult) compiled.evaluateResult.code = void 0;
|
|
26
|
-
if (compiled.buildResult) compiled.buildResult.functions = void 0;
|
|
27
|
-
check = (v) => compiled.Check(v);
|
|
28
|
-
} catch {
|
|
29
|
-
check = (v) => Check(object, v);
|
|
30
|
-
}
|
|
31
|
-
if (!check(next)) return false;
|
|
32
|
-
if (value.length <= MEMO_LIMIT) {
|
|
33
|
-
raw = value;
|
|
34
|
-
parsed = next;
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
} catch {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}, () => "must be an object"), (value) => {
|
|
41
|
-
const decoded = value === raw ? parsed : JSON.parse(value);
|
|
42
|
-
raw = void 0;
|
|
43
|
-
parsed = void 0;
|
|
44
|
-
return Decode$1(object, decoded);
|
|
45
|
-
});
|
|
46
|
-
return elyType(ELYSIA_TYPES.ObjectString, Union([object, objectString], meta));
|
|
12
|
+
return elyType(ELYSIA_TYPES.ObjectString, Union([object, jsonString(object, 123, "must be an object")], meta));
|
|
47
13
|
}
|
|
48
14
|
|
|
49
15
|
//#endregion
|
|
@@ -2,7 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_utils = require('../../utils.js');
|
|
3
3
|
|
|
4
4
|
//#region src/type/elysia/object.ts
|
|
5
|
-
|
|
5
|
+
const objectKind = {
|
|
6
|
+
value: "Object",
|
|
7
|
+
enumerable: false
|
|
8
|
+
};
|
|
6
9
|
let objectProto;
|
|
7
10
|
function ObjectType(properties, options) {
|
|
8
11
|
const keys = Object.keys(properties);
|
|
@@ -19,20 +22,13 @@ function ObjectType(properties, options) {
|
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
if (!options || require_utils.isEmpty(options)) {
|
|
22
|
-
objectProto ??= Object.defineProperty({}, "~kind",
|
|
23
|
-
value: "Object",
|
|
24
|
-
enumerable: false
|
|
25
|
-
});
|
|
25
|
+
objectProto ??= Object.defineProperty({}, "~kind", objectKind);
|
|
26
26
|
const schema = Object.create(objectProto);
|
|
27
27
|
schema.type = "object";
|
|
28
28
|
schema.properties = properties;
|
|
29
29
|
schema.required = required;
|
|
30
30
|
return schema;
|
|
31
31
|
}
|
|
32
|
-
objectKind ??= {
|
|
33
|
-
value: "Object",
|
|
34
|
-
enumerable: false
|
|
35
|
-
};
|
|
36
32
|
const schema = {
|
|
37
33
|
...options,
|
|
38
34
|
type: "object",
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { isEmpty } from "../../utils.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/type/elysia/object.ts
|
|
4
|
-
|
|
4
|
+
const objectKind = {
|
|
5
|
+
value: "Object",
|
|
6
|
+
enumerable: false
|
|
7
|
+
};
|
|
5
8
|
let objectProto;
|
|
6
9
|
function ObjectType(properties, options) {
|
|
7
10
|
const keys = Object.keys(properties);
|
|
@@ -18,20 +21,13 @@ function ObjectType(properties, options) {
|
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
if (!options || isEmpty(options)) {
|
|
21
|
-
objectProto ??= Object.defineProperty({}, "~kind",
|
|
22
|
-
value: "Object",
|
|
23
|
-
enumerable: false
|
|
24
|
-
});
|
|
24
|
+
objectProto ??= Object.defineProperty({}, "~kind", objectKind);
|
|
25
25
|
const schema = Object.create(objectProto);
|
|
26
26
|
schema.type = "object";
|
|
27
27
|
schema.properties = properties;
|
|
28
28
|
schema.required = required;
|
|
29
29
|
return schema;
|
|
30
30
|
}
|
|
31
|
-
objectKind ??= {
|
|
32
|
-
value: "Object",
|
|
33
|
-
enumerable: false
|
|
34
|
-
};
|
|
35
31
|
const schema = {
|
|
36
32
|
...options,
|
|
37
33
|
type: "object",
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_type_shared = require('../shared.js');
|
|
3
3
|
|
|
4
4
|
//#region src/type/elysia/optional.ts
|
|
5
|
-
|
|
5
|
+
const optionalTrue = {
|
|
6
|
+
value: true,
|
|
7
|
+
enumerable: false,
|
|
8
|
+
configurable: true
|
|
9
|
+
};
|
|
6
10
|
let OptionalShared;
|
|
7
11
|
function Optional(schema) {
|
|
8
12
|
if (OptionalShared?.has(schema)) return OptionalShared.get(schema);
|
|
9
13
|
const result = Object.assign(Object.create(Object.getPrototypeOf(schema)), schema);
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(result, "~optional",
|
|
12
|
-
value: true,
|
|
13
|
-
enumerable: false,
|
|
14
|
-
configurable: true
|
|
15
|
-
});
|
|
14
|
+
require_type_shared.copyNonEnumerable(schema, result);
|
|
15
|
+
Object.defineProperty(result, "~optional", optionalTrue);
|
|
16
16
|
OptionalShared ??= /* @__PURE__ */ new WeakMap();
|
|
17
17
|
OptionalShared.set(schema, result);
|
|
18
18
|
return result;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { copyNonEnumerable } from "
|
|
1
|
+
import { copyNonEnumerable } from "../shared.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/type/elysia/optional.ts
|
|
4
|
-
|
|
4
|
+
const optionalTrue = {
|
|
5
|
+
value: true,
|
|
6
|
+
enumerable: false,
|
|
7
|
+
configurable: true
|
|
8
|
+
};
|
|
5
9
|
let OptionalShared;
|
|
6
10
|
function Optional(schema) {
|
|
7
11
|
if (OptionalShared?.has(schema)) return OptionalShared.get(schema);
|
|
8
12
|
const result = Object.assign(Object.create(Object.getPrototypeOf(schema)), schema);
|
|
9
13
|
copyNonEnumerable(schema, result);
|
|
10
|
-
Object.defineProperty(result, "~optional",
|
|
11
|
-
value: true,
|
|
12
|
-
enumerable: false,
|
|
13
|
-
configurable: true
|
|
14
|
-
});
|
|
14
|
+
Object.defineProperty(result, "~optional", optionalTrue);
|
|
15
15
|
OptionalShared ??= /* @__PURE__ */ new WeakMap();
|
|
16
16
|
OptionalShared.set(schema, result);
|
|
17
17
|
return result;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TInteger, TObject, TObjectOptions, TOptional, TProperties, TString } from "typebox";
|
|
2
|
+
|
|
3
|
+
//#region src/type/elysia/problem.d.ts
|
|
4
|
+
interface TProblemBase {
|
|
5
|
+
type: TString;
|
|
6
|
+
code: TOptional<TString>;
|
|
7
|
+
title: TString;
|
|
8
|
+
status: TInteger;
|
|
9
|
+
detail: TOptional<TString>;
|
|
10
|
+
instance: TOptional<TString>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* RFC 9457 Problem Details schema. Extension members are spread last, so they
|
|
14
|
+
* may override a base member.
|
|
15
|
+
*
|
|
16
|
+
* @see https://www.rfc-editor.org/info/rfc9457
|
|
17
|
+
*/
|
|
18
|
+
declare const Problem: <T extends TProperties = {}>(extension?: T, options?: TObjectOptions) => TObject<Omit<TProblemBase, keyof T> & T>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Problem };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_type_elysia_string = require('./string.js');
|
|
3
|
+
const require_type_elysia_object = require('./object.js');
|
|
4
|
+
const require_type_elysia_integer = require('./integer.js');
|
|
5
|
+
const require_type_elysia_optional = require('./optional.js');
|
|
6
|
+
|
|
7
|
+
//#region src/type/elysia/problem.ts
|
|
8
|
+
/**
|
|
9
|
+
* RFC 9457 Problem Details schema. Extension members are spread last, so they
|
|
10
|
+
* may override a base member.
|
|
11
|
+
*
|
|
12
|
+
* @see https://www.rfc-editor.org/info/rfc9457
|
|
13
|
+
*/
|
|
14
|
+
const Problem = (extension, options) => require_type_elysia_object.ObjectType({
|
|
15
|
+
type: require_type_elysia_string.StringType(),
|
|
16
|
+
code: require_type_elysia_optional.Optional(require_type_elysia_string.StringType()),
|
|
17
|
+
title: require_type_elysia_string.StringType(),
|
|
18
|
+
status: require_type_elysia_integer.Integer(),
|
|
19
|
+
detail: require_type_elysia_optional.Optional(require_type_elysia_string.StringType()),
|
|
20
|
+
instance: require_type_elysia_optional.Optional(require_type_elysia_string.StringType()),
|
|
21
|
+
...extension
|
|
22
|
+
}, options);
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.Problem = Problem;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StringType } from "./string.mjs";
|
|
2
|
+
import { ObjectType } from "./object.mjs";
|
|
3
|
+
import { Integer } from "./integer.mjs";
|
|
4
|
+
import { Optional } from "./optional.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/type/elysia/problem.ts
|
|
7
|
+
/**
|
|
8
|
+
* RFC 9457 Problem Details schema. Extension members are spread last, so they
|
|
9
|
+
* may override a base member.
|
|
10
|
+
*
|
|
11
|
+
* @see https://www.rfc-editor.org/info/rfc9457
|
|
12
|
+
*/
|
|
13
|
+
const Problem = (extension, options) => ObjectType({
|
|
14
|
+
type: StringType(),
|
|
15
|
+
code: Optional(StringType()),
|
|
16
|
+
title: StringType(),
|
|
17
|
+
status: Integer(),
|
|
18
|
+
detail: Optional(StringType()),
|
|
19
|
+
instance: Optional(StringType()),
|
|
20
|
+
...extension
|
|
21
|
+
}, options);
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { Problem };
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import { ArrayBufferOptions } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/type/elysia/uint8-array.d.ts
|
|
4
|
-
declare
|
|
4
|
+
declare const Uint8ArrayType: (property?: ArrayBufferOptions) => any;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { Uint8ArrayType };
|
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
3
|
-
const require_utils = require('../../utils.js');
|
|
4
2
|
const require_type_constants = require('../constants.js');
|
|
5
|
-
const
|
|
6
|
-
|
|
3
|
+
const require_type_typebox_type = require('../typebox-type.js');
|
|
4
|
+
const require_type_elysia_array_buffer = require('./array-buffer.js');
|
|
7
5
|
|
|
8
6
|
//#region src/type/elysia/uint8-array.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
BaseUint8Array ??= (0, typebox_type.Codec)((0, typebox_type.Refine)((0, 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
|
-
if (!property || require_utils.isEmpty(property)) return emptyUint8Array ??= Object.freeze(require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.Uint8Array, BaseUint8Array));
|
|
14
|
-
const refines = [[(value) => value instanceof Uint8Array || value instanceof ArrayBuffer, "must be Uint8Array"]];
|
|
15
|
-
if (property.minByteLength !== void 0) refines.push([(value) => value.byteLength >= property.minByteLength, `Expect byte to be more than ${property.minByteLength}`]);
|
|
16
|
-
if (property.maxByteLength !== void 0) refines.push([(value) => value.byteLength <= property.maxByteLength, `Expect byte to be less than ${property.maxByteLength}`]);
|
|
17
|
-
let schema = require_type_elysia_utils.Refines(BaseUint8Array, refines);
|
|
18
|
-
const [, meta] = require_type_elysia_utils.getMeta(property);
|
|
19
|
-
if (meta) {
|
|
20
|
-
schema = require_type_elysia_utils.cloneSchema(schema);
|
|
21
|
-
Object.assign(schema, meta);
|
|
22
|
-
}
|
|
23
|
-
return require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.Uint8Array, schema);
|
|
24
|
-
}
|
|
7
|
+
const isUint8Array = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
|
|
8
|
+
const uint8Array = /* @__PURE__ */ require_type_elysia_array_buffer.bufferType(require_type_constants.ELYSIA_TYPES.Uint8Array, () => require_type_typebox_type.Codec(require_type_typebox_type.Refine(require_type_typebox_type.Unsafe({ "~kind": "Uint8Array" }), isUint8Array, () => "must be Uint8Array")).Decode((value) => value instanceof Uint8Array ? value : new Uint8Array(value)).Encode((value) => value));
|
|
9
|
+
const Uint8ArrayType = (property) => uint8Array(property);
|
|
25
10
|
|
|
26
11
|
//#endregion
|
|
27
12
|
exports.Uint8ArrayType = Uint8ArrayType;
|
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
import { isEmpty } from "../../utils.mjs";
|
|
2
1
|
import { ELYSIA_TYPES } from "../constants.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { Codec, Refine, Unsafe } from "../typebox-type.mjs";
|
|
3
|
+
import { bufferType } from "./array-buffer.mjs";
|
|
5
4
|
|
|
6
5
|
//#region src/type/elysia/uint8-array.ts
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
BaseUint8Array ??= Codec(Refine(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);
|
|
11
|
-
if (!property || isEmpty(property)) return emptyUint8Array ??= Object.freeze(elyType(ELYSIA_TYPES.Uint8Array, BaseUint8Array));
|
|
12
|
-
const refines = [[(value) => value instanceof Uint8Array || value instanceof ArrayBuffer, "must be Uint8Array"]];
|
|
13
|
-
if (property.minByteLength !== void 0) refines.push([(value) => value.byteLength >= property.minByteLength, `Expect byte to be more than ${property.minByteLength}`]);
|
|
14
|
-
if (property.maxByteLength !== void 0) refines.push([(value) => value.byteLength <= property.maxByteLength, `Expect byte to be less than ${property.maxByteLength}`]);
|
|
15
|
-
let schema = Refines(BaseUint8Array, refines);
|
|
16
|
-
const [, meta] = getMeta(property);
|
|
17
|
-
if (meta) {
|
|
18
|
-
schema = cloneSchema(schema);
|
|
19
|
-
Object.assign(schema, meta);
|
|
20
|
-
}
|
|
21
|
-
return elyType(ELYSIA_TYPES.Uint8Array, schema);
|
|
22
|
-
}
|
|
6
|
+
const isUint8Array = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
|
|
7
|
+
const uint8Array = /* @__PURE__ */ bufferType(ELYSIA_TYPES.Uint8Array, () => Codec(Refine(Unsafe({ "~kind": "Uint8Array" }), isUint8Array, () => "must be Uint8Array")).Decode((value) => value instanceof Uint8Array ? value : new Uint8Array(value)).Encode((value) => value));
|
|
8
|
+
const Uint8ArrayType = (property) => uint8Array(property);
|
|
23
9
|
|
|
24
10
|
//#endregion
|
|
25
11
|
export { Uint8ArrayType };
|
|
@@ -1,11 +1,13 @@
|
|
|
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
|
+
const unionEnumKind = {
|
|
8
|
+
value: "UnionEnum",
|
|
9
|
+
enumerable: false
|
|
10
|
+
};
|
|
9
11
|
function UnionEnum(values, options) {
|
|
10
12
|
let kind;
|
|
11
13
|
let mixed = false;
|
|
@@ -19,12 +21,9 @@ function UnionEnum(values, options) {
|
|
|
19
21
|
default: values[0],
|
|
20
22
|
...options,
|
|
21
23
|
enum: values
|
|
22
|
-
}, "~kind",
|
|
23
|
-
value: "UnionEnum",
|
|
24
|
-
enumerable: false
|
|
25
|
-
});
|
|
24
|
+
}, "~kind", unionEnumKind);
|
|
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,9 +1,12 @@
|
|
|
1
1
|
import { ELYSIA_TYPES } from "../constants.mjs";
|
|
2
|
+
import { Unsafe } from "../typebox-type.mjs";
|
|
2
3
|
import { elyType } from "./utils.mjs";
|
|
3
|
-
import { Unsafe } from "typebox/type";
|
|
4
4
|
|
|
5
5
|
//#region src/type/elysia/union-enum.ts
|
|
6
|
-
|
|
6
|
+
const unionEnumKind = {
|
|
7
|
+
value: "UnionEnum",
|
|
8
|
+
enumerable: false
|
|
9
|
+
};
|
|
7
10
|
function UnionEnum(values, options) {
|
|
8
11
|
let kind;
|
|
9
12
|
let mixed = false;
|
|
@@ -17,10 +20,7 @@ function UnionEnum(values, options) {
|
|
|
17
20
|
default: values[0],
|
|
18
21
|
...options,
|
|
19
22
|
enum: values
|
|
20
|
-
}, "~kind",
|
|
21
|
-
value: "UnionEnum",
|
|
22
|
-
enumerable: false
|
|
23
|
-
});
|
|
23
|
+
}, "~kind", unionEnumKind);
|
|
24
24
|
if (!mixed) schema.type = kind;
|
|
25
25
|
return elyType(ELYSIA_TYPES.UnionEnum, Unsafe(schema));
|
|
26
26
|
}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_utils = require('../../utils.js');
|
|
3
2
|
const require_type_constants = require('../constants.js');
|
|
4
3
|
|
|
5
4
|
//#region src/type/elysia/union.ts
|
|
6
5
|
function Union(schemas, options) {
|
|
7
|
-
if (!options || require_utils.isEmpty(options)) return Object.defineProperty({
|
|
8
|
-
"~kind": "Union",
|
|
9
|
-
anyOf: schemas
|
|
10
|
-
}, "~kind", require_type_constants.noEnumerable);
|
|
11
6
|
const schema = {
|
|
12
7
|
...options,
|
|
13
8
|
"~kind": "Union",
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { isEmpty } from "../../utils.mjs";
|
|
2
1
|
import { noEnumerable } from "../constants.mjs";
|
|
3
2
|
|
|
4
3
|
//#region src/type/elysia/union.ts
|
|
5
4
|
function Union(schemas, options) {
|
|
6
|
-
if (!options || isEmpty(options)) return Object.defineProperty({
|
|
7
|
-
"~kind": "Union",
|
|
8
|
-
anyOf: schemas
|
|
9
|
-
}, "~kind", noEnumerable);
|
|
10
5
|
const schema = {
|
|
11
6
|
...options,
|
|
12
7
|
"~kind": "Union",
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { ELYSIA_TYPES } from "../constants.js";
|
|
2
2
|
import { BaseSchema } from "../types.js";
|
|
3
|
-
import { clearSharedReferenceCaches } from "../shared.js";
|
|
4
3
|
import { Static, TSchema } from "typebox";
|
|
5
4
|
|
|
6
5
|
//#region src/type/elysia/utils.d.ts
|
|
7
|
-
declare function copyNonEnumerable(src: object, target: object, skipKey?: string): void;
|
|
8
6
|
declare function cloneSchema<T extends TSchema>(schema: T): T;
|
|
7
|
+
declare function withMeta<T extends TSchema>(schema: T, property: object): T;
|
|
9
8
|
declare function elyType<T extends TSchema>(name: ELYSIA_TYPES[keyof ELYSIA_TYPES], schema: T): T;
|
|
10
9
|
declare function createSharedReference<const P extends Record<keyof any, unknown>, const T extends TSchema>(createType: (property: P) => T): (property: P) => T;
|
|
11
|
-
declare const hasMeta: (property: Partial<BaseSchema> & Record<keyof any, unknown>) => boolean;
|
|
12
10
|
declare function getMeta(property: Partial<BaseSchema> & Record<keyof any, unknown>, doHaveMeta?: boolean): readonly [{
|
|
13
11
|
[x: string]: unknown;
|
|
14
12
|
[x: number]: unknown;
|
|
@@ -50,4 +48,4 @@ declare function propertyChecksum(property: Partial<BaseSchema> & Record<keyof a
|
|
|
50
48
|
type Refines<T> = [refine: (value: T) => boolean, message: string][];
|
|
51
49
|
declare function Refines<T extends TSchema>(schema: T, refines: Refines<Static<T>>): T;
|
|
52
50
|
//#endregion
|
|
53
|
-
export { Refines,
|
|
51
|
+
export { Refines, cloneSchema, createSharedReference, elyType, getMeta, propertyChecksum, withMeta };
|
|
@@ -1,30 +1,21 @@
|
|
|
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
|
-
function copyNonEnumerable(src, target, skipKey) {
|
|
9
|
-
for (const key of Object.getOwnPropertyNames(src)) {
|
|
10
|
-
const desc = Object.getOwnPropertyDescriptor(src, key);
|
|
11
|
-
if (!desc || desc.enumerable || key === skipKey) continue;
|
|
12
|
-
Object.defineProperty(target, key, {
|
|
13
|
-
value: desc.value,
|
|
14
|
-
enumerable: false,
|
|
15
|
-
writable: true,
|
|
16
|
-
configurable: true
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
7
|
function cloneSchema(schema) {
|
|
21
8
|
const target = { ...schema };
|
|
22
|
-
copyNonEnumerable(schema, target);
|
|
9
|
+
require_type_shared.copyNonEnumerable(schema, target);
|
|
23
10
|
return target;
|
|
24
11
|
}
|
|
12
|
+
function withMeta(schema, property) {
|
|
13
|
+
const [, meta] = getMeta(property);
|
|
14
|
+
return meta ? Object.assign(cloneSchema(schema), meta) : schema;
|
|
15
|
+
}
|
|
25
16
|
function elyType(name, schema) {
|
|
26
17
|
const target = Object.assign(Object.create(Object.getPrototypeOf(schema)), schema, { "~elyTyp": name });
|
|
27
|
-
copyNonEnumerable(schema, target, "~elyTyp");
|
|
18
|
+
require_type_shared.copyNonEnumerable(schema, target, "~elyTyp");
|
|
28
19
|
return target;
|
|
29
20
|
}
|
|
30
21
|
function createSharedReference(createType) {
|
|
@@ -82,17 +73,15 @@ function propertyChecksum(property) {
|
|
|
82
73
|
return [require_utils.fnv1a(JSON.stringify(entries))];
|
|
83
74
|
}
|
|
84
75
|
function Refines(schema, refines) {
|
|
85
|
-
for (const [refine, message] of refines) schema =
|
|
76
|
+
for (const [refine, message] of refines) schema = require_type_typebox_type.Refine(schema, refine, () => message);
|
|
86
77
|
return schema;
|
|
87
78
|
}
|
|
88
79
|
|
|
89
80
|
//#endregion
|
|
90
81
|
exports.Refines = Refines;
|
|
91
|
-
exports.clearSharedReferenceCaches = require_type_shared.clearSharedReferenceCaches;
|
|
92
82
|
exports.cloneSchema = cloneSchema;
|
|
93
|
-
exports.copyNonEnumerable = copyNonEnumerable;
|
|
94
83
|
exports.createSharedReference = createSharedReference;
|
|
95
84
|
exports.elyType = elyType;
|
|
96
85
|
exports.getMeta = getMeta;
|
|
97
|
-
exports.
|
|
98
|
-
exports.
|
|
86
|
+
exports.propertyChecksum = propertyChecksum;
|
|
87
|
+
exports.withMeta = withMeta;
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { evictOldestHalf, fnv1a } from "../../utils.mjs";
|
|
2
|
-
import { SHARED_REFERENCE_CACHE_LIMIT,
|
|
3
|
-
import { Refine } from "typebox
|
|
2
|
+
import { SHARED_REFERENCE_CACHE_LIMIT, copyNonEnumerable, referenceCache } from "../shared.mjs";
|
|
3
|
+
import { Refine } from "../typebox-type.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/type/elysia/utils.ts
|
|
6
|
-
function copyNonEnumerable(src, target, skipKey) {
|
|
7
|
-
for (const key of Object.getOwnPropertyNames(src)) {
|
|
8
|
-
const desc = Object.getOwnPropertyDescriptor(src, key);
|
|
9
|
-
if (!desc || desc.enumerable || key === skipKey) continue;
|
|
10
|
-
Object.defineProperty(target, key, {
|
|
11
|
-
value: desc.value,
|
|
12
|
-
enumerable: false,
|
|
13
|
-
writable: true,
|
|
14
|
-
configurable: true
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
6
|
function cloneSchema(schema) {
|
|
19
7
|
const target = { ...schema };
|
|
20
8
|
copyNonEnumerable(schema, target);
|
|
21
9
|
return target;
|
|
22
10
|
}
|
|
11
|
+
function withMeta(schema, property) {
|
|
12
|
+
const [, meta] = getMeta(property);
|
|
13
|
+
return meta ? Object.assign(cloneSchema(schema), meta) : schema;
|
|
14
|
+
}
|
|
23
15
|
function elyType(name, schema) {
|
|
24
16
|
const target = Object.assign(Object.create(Object.getPrototypeOf(schema)), schema, { "~elyTyp": name });
|
|
25
17
|
copyNonEnumerable(schema, target, "~elyTyp");
|
|
@@ -85,4 +77,4 @@ function Refines(schema, refines) {
|
|
|
85
77
|
}
|
|
86
78
|
|
|
87
79
|
//#endregion
|
|
88
|
-
export { Refines,
|
|
80
|
+
export { Refines, cloneSchema, createSharedReference, elyType, getMeta, propertyChecksum, withMeta };
|
package/dist/type/exports.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ArrayBufferType } from "./elysia/array-buffer.js";
|
|
|
4
4
|
import { ArrayString } from "./elysia/array-string.js";
|
|
5
5
|
import { BooleanType } from "./elysia/boolean.js";
|
|
6
6
|
import { BooleanString } from "./elysia/boolean-string.js";
|
|
7
|
+
import { CompositeType, EvaluateType, InterfaceType, MappedType, OmitType, PartialType, PickType, ReadonlyObjectType, RequiredType } from "./elysia/keep-config.js";
|
|
7
8
|
import { Cookie } from "./elysia/cookie.js";
|
|
8
9
|
import { DateType } from "./elysia/date.js";
|
|
9
10
|
import { File } from "./elysia/file.js";
|
|
@@ -21,6 +22,7 @@ import { NumericEnum } from "./elysia/numeric-enum.js";
|
|
|
21
22
|
import { ObjectType } from "./elysia/object.js";
|
|
22
23
|
import { ObjectString } from "./elysia/object-string.js";
|
|
23
24
|
import { Optional } from "./elysia/optional.js";
|
|
25
|
+
import { Problem } from "./elysia/problem.js";
|
|
24
26
|
import { StringType } from "./elysia/string.js";
|
|
25
27
|
import { Uint8ArrayType } from "./elysia/uint8-array.js";
|
|
26
28
|
import { Union } from "./elysia/union.js";
|
|
@@ -29,8 +31,8 @@ export * from "typebox/type";
|
|
|
29
31
|
|
|
30
32
|
//#region src/type/exports.d.ts
|
|
31
33
|
declare namespace exports_d_exports {
|
|
32
|
-
export { Accelerate, ArrayType as Array, ArrayBufferType as ArrayBuffer, ArrayString, BooleanType as Boolean, BooleanString, Cookie, DateType as Date, File, Files, Form, Integer, IntegerString, Intersect, MaybeEmpty, NoValidate, Nullable, NumberType as Number, Numeric, NumericEnum, ObjectType as Object, ObjectString, Optional, StringType as String, Uint8ArrayType as Uint8Array, Union, UnionEnum };
|
|
34
|
+
export { Accelerate, ArrayType as Array, ArrayBufferType as ArrayBuffer, ArrayString, BooleanType as Boolean, BooleanString, CompositeType as Composite, Cookie, DateType as Date, EvaluateType as Evaluate, File, Files, Form, Integer, IntegerString, InterfaceType as Interface, Intersect, MappedType as Mapped, MaybeEmpty, NoValidate, Nullable, NumberType as Number, Numeric, NumericEnum, ObjectType as Object, ObjectString, OmitType as Omit, Optional, PartialType as Partial, PickType as Pick, Problem, ReadonlyObjectType as ReadonlyObject, RequiredType as Required, StringType as String, Uint8ArrayType as Uint8Array, Union, UnionEnum };
|
|
33
35
|
}
|
|
34
36
|
import * as import_typebox_type from "typebox/type";
|
|
35
37
|
//#endregion
|
|
36
|
-
export { Accelerate, ArrayType as Array, ArrayBufferType as ArrayBuffer, ArrayString, BooleanType as Boolean, BooleanString, Cookie, DateType as Date, File, Files, Form, Integer, IntegerString, Intersect, MaybeEmpty, NoValidate, Nullable, NumberType as Number, Numeric, NumericEnum, ObjectType as Object, ObjectString, Optional, StringType as String, Uint8ArrayType as Uint8Array, Union, UnionEnum, exports_d_exports };
|
|
38
|
+
export { Accelerate, ArrayType as Array, ArrayBufferType as ArrayBuffer, ArrayString, BooleanType as Boolean, BooleanString, CompositeType as Composite, Cookie, DateType as Date, EvaluateType as Evaluate, File, Files, Form, Integer, IntegerString, InterfaceType as Interface, Intersect, MappedType as Mapped, MaybeEmpty, NoValidate, Nullable, NumberType as Number, Numeric, NumericEnum, ObjectType as Object, ObjectString, OmitType as Omit, Optional, PartialType as Partial, PickType as Pick, Problem, ReadonlyObjectType as ReadonlyObject, RequiredType as Required, StringType as String, Uint8ArrayType as Uint8Array, Union, UnionEnum, exports_d_exports };
|