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
|
@@ -20,9 +20,6 @@ interface HandlerParamContext {
|
|
|
20
20
|
cookieConfig: unknown;
|
|
21
21
|
tracers: unknown;
|
|
22
22
|
}
|
|
23
|
-
type Resolver = (c: HandlerParamContext) => unknown;
|
|
24
|
-
/** @internal exported for test/aot/param-descriptor.test.ts */
|
|
25
|
-
declare const handlerParams: () => Record<string, Resolver>;
|
|
26
23
|
declare function resolveHandlerParams(names: string[], c: HandlerParamContext): unknown[];
|
|
27
24
|
//#endregion
|
|
28
|
-
export {
|
|
25
|
+
export { resolveHandlerParams };
|
|
@@ -7,10 +7,10 @@ const require_cookie_utils = require('../../cookie/utils.js');
|
|
|
7
7
|
const require_handler_utils = require('../../handler/utils.js');
|
|
8
8
|
const require_handler_error = require('../../handler/error.js');
|
|
9
9
|
const require_compile_handler_utils = require('./utils.js');
|
|
10
|
+
const require_compile_handler_static_clone_resolver = require('./static-clone-resolver.js');
|
|
10
11
|
|
|
11
12
|
//#region src/compile/handler/params.ts
|
|
12
13
|
let _handlerParams;
|
|
13
|
-
/** @internal exported for test/aot/param-descriptor.test.ts */
|
|
14
14
|
const handlerParams = () => _handlerParams ??= {
|
|
15
15
|
pf: (c) => c.parse.formData,
|
|
16
16
|
pj: (c) => c.parse.json,
|
|
@@ -23,18 +23,22 @@ const handlerParams = () => _handlerParams ??= {
|
|
|
23
23
|
qa: (c) => require_compile_handler_utils.getQueryParseChannels(c.vali?.query?.schema)?.array,
|
|
24
24
|
qo: (c) => require_compile_handler_utils.getQueryParseChannels(c.vali?.query?.schema)?.object,
|
|
25
25
|
rm: (c) => c.res.map,
|
|
26
|
-
rc: (c) => c.res.compact
|
|
26
|
+
rc: (c) => c.res.compact,
|
|
27
27
|
rid: () => require_utils.requestId,
|
|
28
28
|
pq: () => require_parse_query.parseQueryFromURL,
|
|
29
29
|
pe: () => require_error.ParseError,
|
|
30
30
|
es: () => require_error.ElysiaStatus,
|
|
31
31
|
rdc: () => require_compile_handler_utils.replaceDeriveContext,
|
|
32
|
+
dsp: () => require_handler_utils.registerDeriveDisposable,
|
|
33
|
+
dds: () => require_handler_utils.drainDisposables,
|
|
32
34
|
emp: () => require_handler_utils.emptyResponse,
|
|
33
35
|
ea: () => require_compile_handler_utils.armEntryAbort,
|
|
34
36
|
verr: () => require_error.ValidationError,
|
|
35
37
|
tee: () => require_adapter_utils.tee,
|
|
38
|
+
obs: () => require_adapter_utils.observeStream,
|
|
36
39
|
msh: () => require_adapter_utils.materializeSetHeaders,
|
|
37
40
|
cr: () => require_compile_handler_utils.cloneResponse,
|
|
41
|
+
scl: require_compile_handler_static_clone_resolver.staticCloneResolver,
|
|
38
42
|
pcr: () => require_cookie_utils.parseCookieRaw,
|
|
39
43
|
pcrs: () => require_cookie_utils.parseCookieRawSync,
|
|
40
44
|
pcrsg: () => require_cookie_utils.parseCookieRawSigned,
|
|
@@ -44,6 +48,10 @@ const handlerParams = () => _handlerParams ??= {
|
|
|
44
48
|
scv: () => require_cookie_utils.signCookieValues,
|
|
45
49
|
va: (c) => c.vali,
|
|
46
50
|
fe: () => require_handler_utils.forwardError,
|
|
51
|
+
ie: (c) => {
|
|
52
|
+
const classes = require_handler_utils.returnedErrorClasses(c.hook, c.root);
|
|
53
|
+
return classes ? require_handler_utils.forwardErrorOf(classes) : require_handler_utils.forwardError;
|
|
54
|
+
},
|
|
47
55
|
fre: () => require_handler_utils.finalizeRouteError,
|
|
48
56
|
fbr: () => require_handler_error.fallbackResponse,
|
|
49
57
|
aet: () => require_handler_error.adoptErrorType,
|
|
@@ -51,8 +59,6 @@ const handlerParams = () => _handlerParams ??= {
|
|
|
51
59
|
ho: (c) => c.hook,
|
|
52
60
|
tf: (c) => c.hook.transform,
|
|
53
61
|
bf: (c) => c.hook.beforeHandle,
|
|
54
|
-
bp: (c) => c.hook["~beforeHandlePrefix"],
|
|
55
|
-
rbp: () => require_compile_handler_utils.runBeforeHandlePrefix,
|
|
56
62
|
af: (c) => c.hook.afterHandle,
|
|
57
63
|
mr: (c) => c.hook.mapResponse,
|
|
58
64
|
er: (c) => c.hook.error,
|
|
@@ -74,5 +80,4 @@ function resolveHandlerParams(names, c) {
|
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
//#endregion
|
|
77
|
-
exports.handlerParams = handlerParams;
|
|
78
83
|
exports.resolveHandlerParams = resolveHandlerParams;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { requestId } from "../../utils.mjs";
|
|
2
2
|
import { ElysiaStatus, ParseError, ValidationError } from "../../error.mjs";
|
|
3
|
-
import { materializeSetHeaders, normalizeContentType, tee } from "../../adapter/utils.mjs";
|
|
3
|
+
import { materializeSetHeaders, normalizeContentType, observeStream, tee } from "../../adapter/utils.mjs";
|
|
4
4
|
import { parseQueryFromURL } from "../../parse-query.mjs";
|
|
5
5
|
import { buildCookieJar, parseCookieRaw, parseCookieRawDeferred, parseCookieRawLazy, parseCookieRawSigned, parseCookieRawSync, signCookieValues } from "../../cookie/utils.mjs";
|
|
6
|
-
import { emptyResponse, finalizeRouteError, forwardError } from "../../handler/utils.mjs";
|
|
6
|
+
import { drainDisposables, emptyResponse, finalizeRouteError, forwardError, forwardErrorOf, registerDeriveDisposable, returnedErrorClasses } from "../../handler/utils.mjs";
|
|
7
7
|
import { adoptErrorType, fallbackResponse } from "../../handler/error.mjs";
|
|
8
|
-
import { armEntryAbort, cloneResponse, getQueryParseChannels, hasRequestBody, replaceDeriveContext
|
|
8
|
+
import { armEntryAbort, cloneResponse, getQueryParseChannels, hasRequestBody, replaceDeriveContext } from "./utils.mjs";
|
|
9
|
+
import { staticCloneResolver } from "./static-clone-resolver.mjs";
|
|
9
10
|
|
|
10
11
|
//#region src/compile/handler/params.ts
|
|
11
12
|
let _handlerParams;
|
|
12
|
-
/** @internal exported for test/aot/param-descriptor.test.ts */
|
|
13
13
|
const handlerParams = () => _handlerParams ??= {
|
|
14
14
|
pf: (c) => c.parse.formData,
|
|
15
15
|
pj: (c) => c.parse.json,
|
|
@@ -22,18 +22,22 @@ const handlerParams = () => _handlerParams ??= {
|
|
|
22
22
|
qa: (c) => getQueryParseChannels(c.vali?.query?.schema)?.array,
|
|
23
23
|
qo: (c) => getQueryParseChannels(c.vali?.query?.schema)?.object,
|
|
24
24
|
rm: (c) => c.res.map,
|
|
25
|
-
rc: (c) => c.res.compact
|
|
25
|
+
rc: (c) => c.res.compact,
|
|
26
26
|
rid: () => requestId,
|
|
27
27
|
pq: () => parseQueryFromURL,
|
|
28
28
|
pe: () => ParseError,
|
|
29
29
|
es: () => ElysiaStatus,
|
|
30
30
|
rdc: () => replaceDeriveContext,
|
|
31
|
+
dsp: () => registerDeriveDisposable,
|
|
32
|
+
dds: () => drainDisposables,
|
|
31
33
|
emp: () => emptyResponse,
|
|
32
34
|
ea: () => armEntryAbort,
|
|
33
35
|
verr: () => ValidationError,
|
|
34
36
|
tee: () => tee,
|
|
37
|
+
obs: () => observeStream,
|
|
35
38
|
msh: () => materializeSetHeaders,
|
|
36
39
|
cr: () => cloneResponse,
|
|
40
|
+
scl: staticCloneResolver,
|
|
37
41
|
pcr: () => parseCookieRaw,
|
|
38
42
|
pcrs: () => parseCookieRawSync,
|
|
39
43
|
pcrsg: () => parseCookieRawSigned,
|
|
@@ -43,6 +47,10 @@ const handlerParams = () => _handlerParams ??= {
|
|
|
43
47
|
scv: () => signCookieValues,
|
|
44
48
|
va: (c) => c.vali,
|
|
45
49
|
fe: () => forwardError,
|
|
50
|
+
ie: (c) => {
|
|
51
|
+
const classes = returnedErrorClasses(c.hook, c.root);
|
|
52
|
+
return classes ? forwardErrorOf(classes) : forwardError;
|
|
53
|
+
},
|
|
46
54
|
fre: () => finalizeRouteError,
|
|
47
55
|
fbr: () => fallbackResponse,
|
|
48
56
|
aet: () => adoptErrorType,
|
|
@@ -50,8 +58,6 @@ const handlerParams = () => _handlerParams ??= {
|
|
|
50
58
|
ho: (c) => c.hook,
|
|
51
59
|
tf: (c) => c.hook.transform,
|
|
52
60
|
bf: (c) => c.hook.beforeHandle,
|
|
53
|
-
bp: (c) => c.hook["~beforeHandlePrefix"],
|
|
54
|
-
rbp: () => runBeforeHandlePrefix,
|
|
55
61
|
af: (c) => c.hook.afterHandle,
|
|
56
62
|
mr: (c) => c.hook.mapResponse,
|
|
57
63
|
er: (c) => c.hook.error,
|
|
@@ -73,4 +79,4 @@ function resolveHandlerParams(names, c) {
|
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
//#endregion
|
|
76
|
-
export {
|
|
82
|
+
export { resolveHandlerParams };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AnyLocalHook, HTTPMethod } from "../../types.js";
|
|
2
|
-
import { CompiledCookieConfig } from "../../cookie/config.js";
|
|
3
2
|
import { AnyElysia } from "../../base.js";
|
|
3
|
+
import { CompiledCookieConfig } from "../../cookie/config.js";
|
|
4
4
|
|
|
5
5
|
//#region src/compile/handler/reconstruct.d.ts
|
|
6
6
|
declare abstract class Reconstrct {
|
|
7
|
-
static validator(hook: AnyLocalHook, root: AnyElysia, method: HTTPMethod, path: string): any;
|
|
7
|
+
static validator(hook: AnyLocalHook, root: AnyElysia, method: HTTPMethod, path: string, liveOnly?: boolean): any;
|
|
8
8
|
static cookie(hook: AnyLocalHook, root: AnyElysia): CompiledCookieConfig;
|
|
9
9
|
static trace(hook: AnyLocalHook, root: AnyElysia): any;
|
|
10
10
|
}
|
|
@@ -7,9 +7,9 @@ const require_compile_handler_frozen_validator = require('./frozen-validator.js'
|
|
|
7
7
|
|
|
8
8
|
//#region src/compile/handler/reconstruct.ts
|
|
9
9
|
var Reconstrct = class {
|
|
10
|
-
static validator(hook, root, method, path) {
|
|
10
|
+
static validator(hook, root, method, path, liveOnly = false) {
|
|
11
11
|
const frozenRoot = require_generation.frozenRootOf(root);
|
|
12
|
-
if (!require_type_bridge.isBridgeLive()) {
|
|
12
|
+
if (!liveOnly && !require_type_bridge.isBridgeLive()) {
|
|
13
13
|
const frozen = require_compile_handler_frozen_validator.buildFrozenRouteValidator(hook, root, method, path);
|
|
14
14
|
if (frozen) return frozen;
|
|
15
15
|
}
|
|
@@ -20,7 +20,7 @@ var Reconstrct = class {
|
|
|
20
20
|
normalize: frozenRoot["~config"]?.normalize,
|
|
21
21
|
sanitize: frozenRoot["~config"]?.sanitize,
|
|
22
22
|
schemas: hook?.schemas,
|
|
23
|
-
aot: {
|
|
23
|
+
aot: liveOnly ? void 0 : {
|
|
24
24
|
method,
|
|
25
25
|
path
|
|
26
26
|
},
|
|
@@ -28,13 +28,15 @@ var Reconstrct = class {
|
|
|
28
28
|
});
|
|
29
29
|
} catch (error) {
|
|
30
30
|
if (!require_compile_handler_frozen_validator.isBridgeNotInitialized(error)) throw error;
|
|
31
|
+
if (liveOnly) throw new Error("Route requires live compilation but the TypeBox bridge is not initialized", { cause: error });
|
|
31
32
|
const frozen = require_compile_handler_frozen_validator.buildFrozenRouteValidator(hook, root, method, path);
|
|
32
33
|
if (frozen) return frozen;
|
|
33
34
|
throw error;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
static cookie(hook, root) {
|
|
37
|
-
|
|
38
|
+
const frozenRoot = require_generation.frozenRootOf(root);
|
|
39
|
+
return require_cookie_config.compileCookieConfig(hook?.cookie, frozenRoot["~config"]?.cookie, frozenRoot["~ext"]?.models, hook?.schemas);
|
|
38
40
|
}
|
|
39
41
|
static trace(hook, root) {
|
|
40
42
|
const traceHandlers = hook?.trace;
|
|
@@ -6,9 +6,9 @@ import { buildFrozenRouteValidator, isBridgeNotInitialized } from "./frozen-vali
|
|
|
6
6
|
|
|
7
7
|
//#region src/compile/handler/reconstruct.ts
|
|
8
8
|
var Reconstrct = class {
|
|
9
|
-
static validator(hook, root, method, path) {
|
|
9
|
+
static validator(hook, root, method, path, liveOnly = false) {
|
|
10
10
|
const frozenRoot = frozenRootOf(root);
|
|
11
|
-
if (!isBridgeLive()) {
|
|
11
|
+
if (!liveOnly && !isBridgeLive()) {
|
|
12
12
|
const frozen = buildFrozenRouteValidator(hook, root, method, path);
|
|
13
13
|
if (frozen) return frozen;
|
|
14
14
|
}
|
|
@@ -19,7 +19,7 @@ var Reconstrct = class {
|
|
|
19
19
|
normalize: frozenRoot["~config"]?.normalize,
|
|
20
20
|
sanitize: frozenRoot["~config"]?.sanitize,
|
|
21
21
|
schemas: hook?.schemas,
|
|
22
|
-
aot: {
|
|
22
|
+
aot: liveOnly ? void 0 : {
|
|
23
23
|
method,
|
|
24
24
|
path
|
|
25
25
|
},
|
|
@@ -27,13 +27,15 @@ var Reconstrct = class {
|
|
|
27
27
|
});
|
|
28
28
|
} catch (error) {
|
|
29
29
|
if (!isBridgeNotInitialized(error)) throw error;
|
|
30
|
+
if (liveOnly) throw new Error("Route requires live compilation but the TypeBox bridge is not initialized", { cause: error });
|
|
30
31
|
const frozen = buildFrozenRouteValidator(hook, root, method, path);
|
|
31
32
|
if (frozen) return frozen;
|
|
32
33
|
throw error;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
static cookie(hook, root) {
|
|
36
|
-
|
|
37
|
+
const frozenRoot = frozenRootOf(root);
|
|
38
|
+
return compileCookieConfig(hook?.cookie, frozenRoot["~config"]?.cookie, frozenRoot["~ext"]?.models, hook?.schemas);
|
|
37
39
|
}
|
|
38
40
|
static trace(hook, root) {
|
|
39
41
|
const traceHandlers = hook?.trace;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_compile_handler_utils = require('./utils.js');
|
|
3
|
+
|
|
4
|
+
//#region src/compile/handler/static-clone-resolver.ts
|
|
5
|
+
const staticCloneResolver = () => require_compile_handler_utils.cloneStaticValue;
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
exports.staticCloneResolver = staticCloneResolver;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { CompactBeforeHandlePrefix, DeriveEntry } from "../../utils.js";
|
|
2
|
-
import { AfterResponseHandler, AppHook, ErrorHandler, MaybeArray, TransformHandler } from "../../types.js";
|
|
3
2
|
import { Context } from "../../context.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { AfterResponseHandler, AppHook, ErrorHandler, MaybeArray, TransformHandler } from "../../types.js";
|
|
6
4
|
//#region src/compile/handler/utils.d.ts
|
|
7
5
|
type Link = (v: unknown, key: string) => void;
|
|
8
6
|
interface TraceReporter {
|
|
@@ -12,6 +10,7 @@ interface TraceReporter {
|
|
|
12
10
|
};
|
|
13
11
|
}
|
|
14
12
|
declare function cloneResponse(r: unknown): unknown;
|
|
13
|
+
declare function cloneStaticValue(value: unknown): unknown;
|
|
15
14
|
declare function hasRequestBody(request: Request): boolean;
|
|
16
15
|
/**
|
|
17
16
|
* Route-entry abort probe. Mirrors `createFetchHandler`'s `armEager`, but is
|
|
@@ -21,25 +20,37 @@ declare function hasRequestBody(request: Request): boolean;
|
|
|
21
20
|
* @see `../../adapter/origin` for the provenance channel
|
|
22
21
|
*/
|
|
23
22
|
declare function armEntryAbort(context: any): any;
|
|
24
|
-
declare const mapTransform: (event: MaybeArray<TransformHandler<any, any, undefined, "local">>, rest?: [isAsync:
|
|
25
|
-
declare function extractDeriveKeys(fn: Function): string[] | null;
|
|
23
|
+
declare const mapTransform: (event: MaybeArray<TransformHandler<any, any, undefined, "local">>, rest?: [isAsync: AsyncMode, report?: TraceReporter | undefined, arm?: string | undefined] | undefined, abortGuard?: string, tail?: TailMode) => string;
|
|
26
24
|
declare function replaceDeriveContext(context: any, derivative: any): any;
|
|
27
25
|
declare function deriveModes(hooks: Function[], entries?: readonly DeriveEntry[]): (boolean | undefined)[] | undefined;
|
|
28
|
-
declare function mapBeforeHandle(_hooks: AppHook['beforeHandle'] | AppHook['beforeHandle'][0], derive: readonly DeriveEntry[] | undefined, link: Link, isAsync:
|
|
26
|
+
declare function mapBeforeHandle(_hooks: AppHook['beforeHandle'] | AppHook['beforeHandle'][0], derive: readonly DeriveEntry[] | undefined, link: Link, isAsync: AsyncMode, report?: TraceReporter, abortGuard?: string, arm?: string): string;
|
|
29
27
|
type BeforeHandleContext = {
|
|
30
28
|
request: Request;
|
|
31
29
|
'~sig'?: AbortSignal;
|
|
32
30
|
};
|
|
33
31
|
declare function runBeforeHandlePrefix(prefix: CompactBeforeHandlePrefix, context: BeforeHandleContext, abort?: 1): any;
|
|
34
32
|
declare function runBeforeHandlePrefixAsync(prefix: CompactBeforeHandlePrefix, context: BeforeHandleContext, abort?: 1): Promise<any>;
|
|
35
|
-
declare
|
|
36
|
-
declare const
|
|
37
|
-
declare const
|
|
38
|
-
declare const mapError: (event: MaybeArray<ErrorHandler<any, any, any>>, rest?: [map: string, link: Link, mapResponse: (response: unknown, set: Context["set"], ...params: unknown[]) => unknown, schedule: string, sign: string, isAsync: boolean] | undefined, abortGuard?: string) => string;
|
|
33
|
+
declare function mapChainHook(_hooks: Function | Function[], prefix: string, isAsync: AsyncMode, report?: TraceReporter, abortGuard?: string, arm?: string): string;
|
|
34
|
+
declare const mapAfterResponse: (event: MaybeArray<AfterResponseHandler<any, any, undefined, "local">>, rest?: [report?: TraceReporter | undefined] | undefined, abortGuard?: string, tail?: TailMode) => string;
|
|
35
|
+
declare const mapError: (event: MaybeArray<ErrorHandler<any, any, any>>, rest?: [map: string, link: Link, mapResponse: (response: unknown, set: Context["set"], ...params: unknown[]) => unknown, schedule: string, sign: string, isAsync: AsyncMode, arm?: string | undefined] | undefined, abortGuard?: string, tail?: TailMode) => string;
|
|
39
36
|
interface QueryWalkState {
|
|
40
37
|
array: Record<string, 1> | undefined;
|
|
41
38
|
object: Record<string, 1> | undefined;
|
|
42
39
|
}
|
|
43
40
|
declare function getQueryParseChannels(querySchema: any): QueryWalkState | undefined;
|
|
41
|
+
type AsyncMode = boolean | TailMode;
|
|
42
|
+
interface TailMode {
|
|
43
|
+
async: boolean;
|
|
44
|
+
n: number;
|
|
45
|
+
r?: boolean;
|
|
46
|
+
e?: boolean;
|
|
47
|
+
live: string;
|
|
48
|
+
sites: string[];
|
|
49
|
+
}
|
|
50
|
+
declare const asyncTail: (mode: AsyncMode) => TailMode | undefined;
|
|
51
|
+
declare function awaitSite(call: string, fn: Function, isAsync: AsyncMode, target: string, arm?: string): string;
|
|
52
|
+
declare const tailStage: (mode: TailMode, guard?: string) => string;
|
|
53
|
+
declare const tailPlain: (mode: AsyncMode, code: string) => string;
|
|
54
|
+
declare function awaitGuard(fn: Function, isAsync: AsyncMode, target: string, arm?: string): string;
|
|
44
55
|
//#endregion
|
|
45
|
-
export { Link, TraceReporter, armEntryAbort,
|
|
56
|
+
export { AsyncMode, Link, TailMode, TraceReporter, armEntryAbort, asyncTail, awaitGuard, awaitSite, cloneResponse, cloneStaticValue, deriveModes, getQueryParseChannels, hasRequestBody, mapAfterResponse, mapBeforeHandle, mapChainHook, mapError, mapTransform, replaceDeriveContext, runBeforeHandlePrefix, runBeforeHandlePrefixAsync, tailPlain, tailStage };
|