elysia 2.0.0-beta.3 → 2.0.0-beta.31
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/README.md +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +1 -0
- package/dist/adapter/bun/index.d.ts +16 -2
- package/dist/adapter/bun/index.js +458 -119
- package/dist/adapter/bun/index.mjs +459 -121
- package/dist/adapter/constants.mjs +1 -0
- package/dist/adapter/default-headers.mjs +1 -0
- package/dist/adapter/index.mjs +1 -0
- package/dist/adapter/origin.js +0 -57
- package/dist/adapter/origin.mjs +1 -57
- package/dist/adapter/response-ownership.mjs +1 -0
- package/dist/adapter/skip-clone.mjs +1 -0
- package/dist/adapter/types.d.ts +2 -21
- package/dist/adapter/types.mjs +1 -0
- package/dist/adapter/utils.d.ts +11 -3
- package/dist/adapter/utils.js +147 -112
- package/dist/adapter/utils.mjs +149 -114
- package/dist/adapter/web-standard/handler.d.ts +1 -1
- package/dist/adapter/web-standard/handler.js +39 -36
- package/dist/adapter/web-standard/handler.mjs +41 -37
- package/dist/adapter/web-standard/index.js +2 -30
- package/dist/adapter/web-standard/index.mjs +3 -30
- package/dist/adapter/web-standard/utils.js +5 -18
- package/dist/adapter/web-standard/utils.mjs +6 -18
- package/dist/base.d.ts +387 -207
- package/dist/base.js +742 -676
- package/dist/base.mjs +747 -680
- package/dist/compile/aot-capture.d.ts +2 -13
- package/dist/compile/aot-capture.js +39 -89
- package/dist/compile/aot-capture.mjs +43 -88
- package/dist/compile/aot-emit.d.ts +9 -8
- package/dist/compile/aot-emit.js +36 -38
- package/dist/compile/aot-emit.mjs +37 -38
- package/dist/compile/aot-reconstruct.js +7 -30
- package/dist/compile/aot-reconstruct.mjs +8 -30
- package/dist/compile/aot.d.ts +15 -17
- package/dist/compile/aot.js +36 -58
- package/dist/compile/aot.mjs +34 -57
- package/dist/compile/handler/descriptor.d.ts +10 -17
- package/dist/compile/handler/descriptor.js +25 -58
- package/dist/compile/handler/descriptor.mjs +29 -58
- package/dist/compile/handler/frozen-validator.d.ts +7 -12
- package/dist/compile/handler/frozen-validator.js +57 -118
- package/dist/compile/handler/frozen-validator.mjs +56 -118
- package/dist/compile/handler/index.d.ts +8 -4
- package/dist/compile/handler/index.js +322 -206
- package/dist/compile/handler/index.mjs +324 -211
- package/dist/compile/handler/jit.d.ts +28 -21
- package/dist/compile/handler/jit.js +232 -159
- package/dist/compile/handler/jit.mjs +235 -165
- package/dist/compile/handler/params.d.ts +5 -4
- package/dist/compile/handler/params.js +21 -9
- package/dist/compile/handler/params.mjs +25 -12
- package/dist/compile/handler/reconstruct.d.ts +4 -4
- package/dist/compile/handler/reconstruct.js +8 -6
- package/dist/compile/handler/reconstruct.mjs +9 -6
- 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 +8 -0
- package/dist/compile/handler/utils.d.ts +29 -11
- package/dist/compile/handler/utils.js +184 -276
- package/dist/compile/handler/utils.mjs +179 -275
- package/dist/compile/jit-probe.d.ts +2 -2
- package/dist/compile/jit-probe.js +2 -3
- package/dist/compile/jit-probe.mjs +3 -3
- package/dist/compile/lexer.d.ts +7 -4
- package/dist/compile/lexer.js +268 -6
- package/dist/compile/lexer.mjs +269 -4
- package/dist/compile/utils.d.ts +2 -1
- package/dist/compile/utils.js +14 -6
- package/dist/compile/utils.mjs +14 -6
- package/dist/compiled.d.ts +0 -1
- package/dist/compiled.js +0 -10
- package/dist/compiled.mjs +1 -10
- package/dist/constants.js +19 -4
- package/dist/constants.mjs +20 -4
- package/dist/context.d.ts +15 -5
- package/dist/context.js +17 -36
- package/dist/context.mjs +20 -38
- package/dist/cookie/config.d.ts +6 -2
- package/dist/cookie/config.js +77 -23
- package/dist/cookie/config.mjs +79 -25
- package/dist/cookie/cookie.d.ts +7 -5
- package/dist/cookie/cookie.js +12 -10
- package/dist/cookie/cookie.mjs +13 -10
- package/dist/cookie/crypto.d.ts +1 -1
- package/dist/cookie/crypto.js +19 -14
- package/dist/cookie/crypto.mjs +20 -14
- package/dist/cookie/error.d.ts +1 -2
- package/dist/cookie/error.js +6 -3
- package/dist/cookie/error.mjs +7 -3
- package/dist/cookie/lib.js +2 -1
- package/dist/cookie/lib.mjs +3 -1
- package/dist/cookie/serialize.mjs +1 -0
- package/dist/cookie/types.d.ts +1 -1
- package/dist/cookie/types.mjs +1 -0
- package/dist/cookie/utils.d.ts +5 -9
- package/dist/cookie/utils.js +109 -83
- package/dist/cookie/utils.mjs +112 -84
- package/dist/error.d.ts +127 -111
- package/dist/error.js +187 -180
- package/dist/error.mjs +185 -181
- package/dist/generation.d.ts +2 -2
- package/dist/generation.mjs +1 -0
- package/dist/handler/error.d.ts +18 -18
- package/dist/handler/error.js +77 -120
- package/dist/handler/error.mjs +80 -122
- package/dist/handler/fetch.js +165 -153
- package/dist/handler/fetch.mjs +168 -155
- package/dist/handler/utils.d.ts +25 -6
- package/dist/handler/utils.js +81 -26
- package/dist/handler/utils.mjs +76 -25
- package/dist/index.d.ts +11 -11
- package/dist/index.js +3 -1
- package/dist/index.mjs +5 -4
- package/dist/memory.js +2 -2
- package/dist/memory.mjs +3 -2
- package/dist/package.js +1 -1
- package/dist/package.mjs +2 -1
- package/dist/parse-query.js +76 -80
- package/dist/parse-query.mjs +77 -80
- package/dist/plugin/aot/bun.d.ts +8 -1
- package/dist/plugin/aot/bun.js +9 -28
- package/dist/plugin/aot/bun.mjs +11 -29
- package/dist/plugin/aot/core.d.ts +37 -66
- package/dist/plugin/aot/core.js +197 -153
- package/dist/plugin/aot/core.mjs +195 -156
- package/dist/plugin/aot/esbuild.js +8 -24
- package/dist/plugin/aot/esbuild.mjs +10 -25
- package/dist/plugin/aot/hooks.d.ts +6 -17
- package/dist/plugin/aot/hooks.js +37 -17
- package/dist/plugin/aot/hooks.mjs +38 -19
- package/dist/plugin/aot/rspack-loader.d.ts +1 -5
- package/dist/plugin/aot/rspack-loader.js +1 -26
- package/dist/plugin/aot/rspack-loader.mjs +2 -26
- package/dist/plugin/aot/rspack.js +2 -19
- package/dist/plugin/aot/rspack.mjs +4 -20
- package/dist/plugin/aot/source.d.ts +7 -43
- package/dist/plugin/aot/source.js +73 -73
- package/dist/plugin/aot/source.mjs +74 -74
- package/dist/plugin/aot/treeshake.js +2 -6
- package/dist/plugin/aot/treeshake.mjs +3 -6
- package/dist/plugin/aot/unplugin.d.ts +1 -4
- package/dist/plugin/aot/unplugin.js +4 -32
- package/dist/plugin/aot/unplugin.mjs +5 -32
- package/dist/plugin/aot/vite.d.ts +2 -6
- package/dist/plugin/aot/vite.js +0 -14
- package/dist/plugin/aot/vite.mjs +1 -14
- package/dist/plugin/aot/worker.js +2 -2
- package/dist/plugin/aot/worker.mjs +3 -2
- package/dist/plugin/auto-head.js +1 -10
- package/dist/plugin/auto-head.mjs +2 -10
- package/dist/plugin/trace.d.ts +18 -1
- package/dist/plugin/trace.js +0 -16
- package/dist/plugin/trace.mjs +1 -16
- package/dist/plugin/websocket.d.ts +21 -0
- package/dist/plugin/websocket.js +0 -21
- package/dist/plugin/websocket.mjs +1 -21
- package/dist/route-table.d.ts +3 -0
- package/dist/route-table.js +4 -1
- package/dist/route-table.mjs +5 -1
- package/dist/schema-snapshot.d.ts +0 -4
- package/dist/schema-snapshot.js +60 -56
- package/dist/schema-snapshot.mjs +61 -56
- package/dist/sucrose.d.ts +7 -56
- package/dist/sucrose.js +103 -735
- package/dist/sucrose.mjs +103 -728
- package/dist/trace.d.ts +16 -10
- package/dist/trace.js +20 -134
- package/dist/trace.mjs +22 -135
- package/dist/type/bridge-live.d.ts +5 -3
- package/dist/type/bridge-live.js +6 -3
- package/dist/type/bridge-live.mjs +6 -3
- package/dist/type/bridge.d.ts +7 -5
- package/dist/type/bridge.js +38 -28
- package/dist/type/bridge.mjs +27 -22
- package/dist/type/coerce-plan.d.ts +5 -5
- package/dist/type/coerce-plan.js +53 -43
- package/dist/type/coerce-plan.mjs +56 -44
- package/dist/type/coerce.d.ts +3 -7
- package/dist/type/coerce.js +18 -79
- package/dist/type/coerce.mjs +20 -80
- package/dist/type/compat.js +10 -19
- package/dist/type/compat.mjs +12 -20
- package/dist/type/constants.d.ts +1 -1
- package/dist/type/constants.mjs +1 -0
- package/dist/type/elysia/accelerate.mjs +1 -0
- package/dist/type/elysia/array-buffer.d.ts +6 -2
- package/dist/type/elysia/array-buffer.js +16 -15
- package/dist/type/elysia/array-buffer.mjs +17 -16
- package/dist/type/elysia/array-string.js +2 -43
- package/dist/type/elysia/array-string.mjs +3 -43
- package/dist/type/elysia/array.js +5 -9
- package/dist/type/elysia/array.mjs +6 -9
- package/dist/type/elysia/boolean-string.mjs +1 -0
- package/dist/type/elysia/boolean.js +3 -13
- package/dist/type/elysia/boolean.mjs +4 -13
- package/dist/type/elysia/cookie.d.ts +3 -4
- package/dist/type/elysia/cookie.js +3 -14
- package/dist/type/elysia/cookie.mjs +4 -14
- package/dist/type/elysia/date.d.ts +2 -1
- package/dist/type/elysia/date.js +7 -14
- package/dist/type/elysia/date.mjs +8 -14
- package/dist/type/elysia/file-type.d.ts +2 -2
- package/dist/type/elysia/file-type.js +4 -3
- package/dist/type/elysia/file-type.mjs +5 -3
- package/dist/type/elysia/file.d.ts +1 -3
- package/dist/type/elysia/file.js +3 -23
- package/dist/type/elysia/file.mjs +5 -10
- package/dist/type/elysia/files.js +1 -7
- package/dist/type/elysia/files.mjs +3 -8
- package/dist/type/elysia/form.mjs +1 -0
- package/dist/type/elysia/integer-string.d.ts +1 -1
- package/dist/type/elysia/integer-string.js +3 -28
- package/dist/type/elysia/integer-string.mjs +5 -29
- package/dist/type/elysia/integer.js +3 -13
- package/dist/type/elysia/integer.mjs +4 -13
- package/dist/type/elysia/intersect.js +0 -5
- package/dist/type/elysia/intersect.mjs +1 -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 +47 -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 +54 -0
- package/dist/type/elysia/maybe-empty.mjs +1 -0
- package/dist/type/elysia/no-validate.mjs +1 -0
- package/dist/type/elysia/nullable.mjs +1 -0
- package/dist/type/elysia/number.d.ts +2 -1
- package/dist/type/elysia/number.js +19 -12
- package/dist/type/elysia/number.mjs +19 -12
- package/dist/type/elysia/numeric-enum.d.ts +5 -3
- package/dist/type/elysia/numeric-enum.js +1 -5
- package/dist/type/elysia/numeric-enum.mjs +2 -5
- package/dist/type/elysia/numeric.d.ts +4 -2
- package/dist/type/elysia/numeric.js +17 -14
- package/dist/type/elysia/numeric.mjs +17 -14
- package/dist/type/elysia/object-string.js +2 -40
- package/dist/type/elysia/object-string.mjs +3 -40
- package/dist/type/elysia/object.js +5 -9
- package/dist/type/elysia/object.mjs +6 -9
- package/dist/type/elysia/optional.js +8 -8
- package/dist/type/elysia/optional.mjs +8 -7
- package/dist/type/elysia/problem.d.ts +20 -0
- package/dist/type/elysia/problem.js +19 -0
- package/dist/type/elysia/problem.mjs +19 -0
- package/dist/type/elysia/string.mjs +1 -0
- package/dist/type/elysia/uint8-array.d.ts +2 -1
- package/dist/type/elysia/uint8-array.js +4 -18
- package/dist/type/elysia/uint8-array.mjs +5 -18
- package/dist/type/elysia/union-enum.js +5 -6
- package/dist/type/elysia/union-enum.mjs +6 -6
- package/dist/type/elysia/union.js +0 -5
- package/dist/type/elysia/union.mjs +1 -5
- package/dist/type/elysia/utils.d.ts +4 -6
- package/dist/type/elysia/utils.js +16 -40
- package/dist/type/elysia/utils.mjs +15 -36
- package/dist/type/exports.d.ts +4 -2
- package/dist/type/exports.js +13 -1
- package/dist/type/exports.mjs +5 -2
- package/dist/type/index.d.ts +1 -1
- package/dist/type/index.js +31 -23
- package/dist/type/index.mjs +33 -24
- package/dist/type/shared.d.ts +12 -10
- package/dist/type/shared.js +75 -109
- package/dist/type/shared.mjs +72 -108
- package/dist/type/sync-require.d.ts +11 -0
- package/dist/type/sync-require.js +7 -0
- package/dist/type/sync-require.mjs +6 -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 +4 -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 +24 -0
- package/dist/type/typebox-type-live.d.ts +6 -4
- package/dist/type/typebox-type-live.js +23 -9
- package/dist/type/typebox-type-live.mjs +11 -6
- package/dist/type/typebox-type.d.ts +14 -4
- package/dist/type/typebox-type.js +85 -22
- package/dist/type/typebox-type.mjs +35 -21
- package/dist/type/typebox-value-live.d.ts +3 -1
- package/dist/type/typebox-value-live.js +5 -1
- package/dist/type/typebox-value-live.mjs +4 -1
- 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 +6 -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 +9 -4
- package/dist/type/typebox-value.js +19 -8
- package/dist/type/typebox-value.mjs +19 -9
- package/dist/type/types.d.ts +1 -1
- package/dist/type/types.mjs +1 -0
- package/dist/type/utils.js +1 -10
- package/dist/type/utils.mjs +2 -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 +17 -10
- package/dist/type/validator/custom-error.js +50 -48
- package/dist/type/validator/custom-error.mjs +51 -48
- package/dist/type/validator/default-precompute.d.ts +10 -2
- package/dist/type/validator/default-precompute.js +33 -77
- package/dist/type/validator/default-precompute.mjs +33 -77
- package/dist/type/validator/exact-mirror-live.d.ts +8 -0
- package/dist/type/validator/exact-mirror-live.js +15 -0
- package/dist/type/validator/exact-mirror-live.mjs +11 -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 +15 -7
- package/dist/type/validator/exact-mirror.mjs +17 -7
- package/dist/type/validator/frozen-check.js +7 -8
- package/dist/type/validator/frozen-check.mjs +9 -9
- package/dist/type/validator/index.d.ts +2 -1
- package/dist/type/validator/index.js +149 -168
- package/dist/type/validator/index.mjs +155 -173
- package/dist/type/validator/string-codec-aot.d.ts +3 -2
- package/dist/type/validator/string-codec-aot.js +11 -7
- package/dist/type/validator/string-codec-aot.mjs +11 -7
- package/dist/type/validator/validator-cache.d.ts +5 -4
- package/dist/type/validator/validator-cache.js +49 -37
- package/dist/type/validator/validator-cache.mjs +49 -36
- package/dist/types.d.ts +596 -187
- package/dist/types.mjs +1 -0
- package/dist/universal/constants.mjs +1 -0
- 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 +7 -19
- package/dist/universal/file.mjs +9 -19
- package/dist/universal/index.d.ts +2 -2
- package/dist/universal/index.mjs +1 -0
- package/dist/universal/is-production.d.ts +1 -2
- package/dist/universal/is-production.js +1 -3
- package/dist/universal/is-production.mjs +3 -3
- package/dist/universal/server.d.ts +0 -272
- package/dist/universal/server.mjs +1 -0
- package/dist/utils.d.ts +62 -22
- package/dist/utils.js +342 -277
- package/dist/utils.mjs +327 -273
- package/dist/validator/index.d.ts +3 -3
- package/dist/validator/index.js +20 -34
- package/dist/validator/index.mjs +23 -36
- package/dist/validator/route.d.ts +3 -10
- package/dist/validator/route.js +2 -1
- package/dist/validator/route.mjs +3 -1
- package/dist/ws/context.d.ts +4 -1
- package/dist/ws/context.js +41 -36
- package/dist/ws/context.mjs +41 -36
- package/dist/ws/index.mjs +1 -0
- package/dist/ws/parser.js +12 -22
- package/dist/ws/parser.mjs +13 -22
- package/dist/ws/route.d.ts +2 -2
- package/dist/ws/route.js +295 -221
- package/dist/ws/route.mjs +302 -227
- package/dist/ws/types.d.ts +6 -7
- package/dist/ws/types.mjs +1 -0
- package/package.json +22 -55
- 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
package/dist/base.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { TraceCapability, TraceHandler } from "./trace.js";
|
|
2
|
-
import { ListenCallback, Serve, Server } from "./universal/server.js";
|
|
3
|
-
import { ChainNode } from "./utils.js";
|
|
4
|
-
import { AddRoute, AddWSRoute, AfterHandler, AfterResponseHandler, AnyErrorConstructor, AnyLocalHook, BodyHandler, CompiledHandler, CreateEden, DefaultEphemeral, DefaultMetadata, DefaultSingleton, DefinitionBase, DocumentDecoration, ElysiaConfig, ElysiaHandlerToResponseSchemaAmbiguous, EphemeralType, ErrorDefinitionEntry, ErrorHandler, EventScope, ExcludeElysiaResponse, ExtractErrorFromHandle, GlobalHookReturn, GracefulHandler, GuardHookSingleton, GuardLocalHook, HTTPMethod, HistoryEntry, HookContextSchema, HookContextSingleton, InlineHandler, InlineHandlerNonMacro, InputSchema, InputSchemaKey, InternalRoute, IntersectIfObjectSchema, JoinPath, LocalHook, LocalHookReturn, Macro, MacroSchemaChannel, MacroToContext, MacroToProperty, MapResponse, MaybeArray, MaybePromise, MergeElysiaInstances, MergeSchema, MergeScopedSchemas, MetadataBase, NonResolvableMacroKey, ObjectMacroDefs, OptionalHandler, PluginHookReturn, PreHandler, Prettify, PublicRoute, ResolveRouteErrors, RouteBase, ScopedHookReturn, ScopedMapDeriveReturn, SingletonBase, StaticMapAliases, TransformHandler, UnionResponseStatus, UnwrapRoute, WrapFn } from "./types.js";
|
|
5
1
|
import { ElysiaStatus } from "./error.js";
|
|
2
|
+
import { ChainNode } from "./utils.js";
|
|
3
|
+
import { ListenCallback, Serve, Server } from "./universal/server.js";
|
|
6
4
|
import { Context, ErrorContext, LifecycleContext } from "./context.js";
|
|
5
|
+
import { TraceCapability, TraceHandler } from "./trace.js";
|
|
7
6
|
import { AnySchema } from "./type/types.js";
|
|
8
7
|
import { AotFingerprint, CompilerSession, ProgramId } from "./compile/aot.js";
|
|
8
|
+
import { AddRoute, AddWSRoute, AfterHandler, AfterResponseHandler, AnyErrorConstructor, AnyLocalHook, BodyHandler, CatchAllEntries, CatchAllHookReturn, CompiledHandler, CreateEden, DefaultEphemeral, DefaultMetadata, DefaultSingleton, DefinitionBase, DeriveResponse, ElysiaConfig, ElysiaHandlerToResponseSchemaAmbiguous, EphemeralType, ErrorDefinitionEntry, ErrorHandler, ErrorHookStatus, EventScope, ExcludeElysiaResponse, GlobalHookReturn, GracefulHandler, GuardHookSingleton, GuardLocalHook, HTTPMethod, HistoryEntry, HookContextSchema, HookContextSingleton, InlineHandler, InlineHandlerNonMacro, InputSchema, InputSchemaKey, InternalRoute, IntersectIfObjectSchema, JoinPath, LegacyScope, LocalHook, LocalHookReturn, Macro, MacroCatchAll, MacroOptionContext, MacroToContext, MacroToProperty, MapResponse, MaybeArray, MaybePromise, MergeElysiaInstances, MergeSchema, MergeScopedSchemas, MetadataBase, ObjectMacroDefs, OptionalHandler, ParentResponse, PluginHookReturn, PreHandler, Prettify, PublicRoute, ResolveUsedRouteErrors, RouteBase, ScopedHookReturn, ScopedMapDeriveReturn, SingletonBase, StaticMapAliases, TransformHandler, UnionResponseStatus, UnwrapRoute, WithErrorEntries, WithoutMacroCatch, WrapFn } from "./types.js";
|
|
9
|
+
import { RouteErrorHooks } from "./handler/utils.js";
|
|
9
10
|
import { WSCapability, WSHandlerResponse, WSLocalHook, WSMessageHandler, WSOptions, WSOptionsEntry } from "./ws/types.js";
|
|
10
11
|
import { RouteTable } from "./route-table.js";
|
|
11
12
|
import { Generation } from "./generation.js";
|
|
@@ -14,6 +15,32 @@ import { TRef, TSchema } from "typebox";
|
|
|
14
15
|
|
|
15
16
|
//#region src/base.d.ts
|
|
16
17
|
type AnyElysia = Elysia<any, any, any, any, any, any, any, any>;
|
|
18
|
+
/**
|
|
19
|
+
* Merge two `Metadata` whose hooks all apply. `&` would intersect what both
|
|
20
|
+
* sides respond with at a status, and their `~error`, which must union.
|
|
21
|
+
* Same as in `types.ts`, kept off its public module
|
|
22
|
+
*/
|
|
23
|
+
type MergeMetadata<A extends MetadataBase, B extends MetadataBase> = {} extends A['response'] ? A & B : {} extends B['response'] ? A & B : Omit<A & B, 'response'> & {
|
|
24
|
+
response: UnionResponseStatus<A['response'], B['response']>;
|
|
25
|
+
};
|
|
26
|
+
type IgnoresApp<Factory> = Factory extends ((...a: infer A) => any) ? A extends [] ? true : false : false;
|
|
27
|
+
type NotTheParent = {
|
|
28
|
+
'~notTheParent': true;
|
|
29
|
+
};
|
|
30
|
+
type RouteHookCapture = {
|
|
31
|
+
beforeHandle?: unknown;
|
|
32
|
+
afterHandle?: unknown;
|
|
33
|
+
error?: unknown;
|
|
34
|
+
};
|
|
35
|
+
type WSHookCapture = {
|
|
36
|
+
beforeHandle?: unknown;
|
|
37
|
+
error?: unknown;
|
|
38
|
+
};
|
|
39
|
+
type HookObjectKey = keyof InputSchema | 'detail' | 'parse' | 'transform' | 'derive' | 'beforeHandle' | 'afterHandle' | 'mapResponse' | 'afterResponse' | 'error' | 'trace' | 'tags';
|
|
40
|
+
type UnknownHookKey<Key extends PropertyKey> = [Key] extends [never] ? unknown : { [K in NoInfer<Key>]: never };
|
|
41
|
+
type HocOrigin = number | {
|
|
42
|
+
origin?: number;
|
|
43
|
+
} | undefined;
|
|
17
44
|
declare class Elysia<const in out BasePath extends string = '', const in out Scope extends EventScope = 'local', const in out Singleton extends SingletonBase = DefaultSingleton, const in out Definitions extends DefinitionBase = {
|
|
18
45
|
typebox: {};
|
|
19
46
|
error: [];
|
|
@@ -21,24 +48,35 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
21
48
|
#private;
|
|
22
49
|
'~config'?: ElysiaConfig<BasePath, Scope>;
|
|
23
50
|
'~Prefix': BasePath;
|
|
24
|
-
'~Scope': Scope;
|
|
25
51
|
'~Singleton': Singleton;
|
|
26
52
|
'~Definitions': Definitions;
|
|
27
53
|
'~Metadata': Metadata;
|
|
28
54
|
'~Ephemeral': Ephemeral;
|
|
29
55
|
'~Volatile': Volatile;
|
|
30
56
|
'~Routes': Routes;
|
|
57
|
+
private ready?;
|
|
58
|
+
private _error?;
|
|
59
|
+
private hash?;
|
|
60
|
+
private childrenHash?;
|
|
61
|
+
private scopeParent?;
|
|
62
|
+
private pluginMacros?;
|
|
63
|
+
private macroBaseline?;
|
|
64
|
+
private macroSnapshots?;
|
|
31
65
|
'~ext'?: {
|
|
32
66
|
decorator?: Singleton['decorator'];
|
|
33
67
|
store?: Singleton['store'];
|
|
34
68
|
headers?: Record<string, string>;
|
|
35
69
|
macro?: Macro;
|
|
36
70
|
models?: Record<keyof any, AnySchema>;
|
|
37
|
-
error?: Map<AnyErrorConstructor, string>;
|
|
38
71
|
parser?: Record<string, BodyHandler<any, any>>;
|
|
39
72
|
hoc?: WrapFn<any>[];
|
|
73
|
+
hocOrigin?: HocOrigin[];
|
|
40
74
|
setup?: GracefulHandler<any>[];
|
|
41
75
|
cleanup?: GracefulHandler<any>[];
|
|
76
|
+
cleanupEpoch?: (handler: GracefulHandler<any> | GracefulHandler<any>[]) => boolean;
|
|
77
|
+
stop?: (closeActiveConnections?: boolean, failure?: {
|
|
78
|
+
error: unknown;
|
|
79
|
+
}) => Promise<void>;
|
|
42
80
|
capability?: {
|
|
43
81
|
trace?: {
|
|
44
82
|
provider: TraceCapability;
|
|
@@ -51,29 +89,48 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
51
89
|
};
|
|
52
90
|
'~hookChain'?: ChainNode;
|
|
53
91
|
'~wsConfig'?: WSOptions;
|
|
92
|
+
private declaredRoutes?;
|
|
93
|
+
private routeSources?;
|
|
54
94
|
server?: Server;
|
|
95
|
+
private cachedGeneration?;
|
|
96
|
+
private cachedEpoch?;
|
|
97
|
+
private cachedRoutes?;
|
|
98
|
+
private cachedHistory?;
|
|
55
99
|
get history(): readonly HistoryEntry[];
|
|
56
100
|
get ['~routes'](): readonly InternalRoute[];
|
|
57
101
|
['~addRoute'](route: InternalRoute): this;
|
|
58
|
-
|
|
102
|
+
private compiled?;
|
|
103
|
+
private jitColdRemaining?;
|
|
104
|
+
private jitTable?;
|
|
105
|
+
private jitRoute?;
|
|
106
|
+
private jitAliases?;
|
|
107
|
+
'~router'?: Memoirist<CompiledHandler | number>;
|
|
59
108
|
'~map'?: {
|
|
60
109
|
[method: string]: {
|
|
61
|
-
[path: string]: CompiledHandler;
|
|
110
|
+
[path: string]: CompiledHandler | number;
|
|
62
111
|
} | undefined;
|
|
112
|
+
WS?: {
|
|
113
|
+
[path: string]: CompiledHandler;
|
|
114
|
+
};
|
|
63
115
|
};
|
|
64
116
|
'~routeTable'?: RouteTable;
|
|
65
117
|
'~hasWS'?: boolean;
|
|
66
118
|
'~hasDynamicWS'?: boolean;
|
|
67
119
|
'~hasTrace'?: boolean;
|
|
68
|
-
'~finalizeError'?: (context: Context, error: Error) => MaybePromise<Response>;
|
|
120
|
+
'~finalizeError'?: (context: Context, error: Error, sign?: (set: Context['set']) => unknown, wholeChain?: boolean, route?: RouteErrorHooks) => MaybePromise<Response>;
|
|
69
121
|
get ['~programId'](): ProgramId;
|
|
70
122
|
'~aotFingerprint'?: AotFingerprint;
|
|
71
123
|
'~compilerSession'?: CompilerSession;
|
|
72
124
|
'~generation'?: Generation;
|
|
73
|
-
'~introspect'?: boolean;
|
|
74
125
|
'~scopeChild'?: boolean;
|
|
75
126
|
'~scopeChildren'?: AnyElysia[];
|
|
76
127
|
constructor(config?: ElysiaConfig<BasePath, Scope>);
|
|
128
|
+
/**
|
|
129
|
+
* Every registered route with its merged hooks.
|
|
130
|
+
* Development shares a frozen cache.
|
|
131
|
+
* Production rebuilds the list on every read
|
|
132
|
+
* so its metadata can be released after startup.
|
|
133
|
+
*/
|
|
77
134
|
get routes(): PublicRoute[];
|
|
78
135
|
/**
|
|
79
136
|
* ### decorate
|
|
@@ -170,13 +227,14 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
170
227
|
derive: Singleton['derive'];
|
|
171
228
|
}, Definitions, Metadata, Routes, Ephemeral, Volatile>;
|
|
172
229
|
headers(headers: Record<string, string>): this;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
230
|
+
onRequest(fn: MaybeArray<PreHandler<{}, Singleton>>): this;
|
|
231
|
+
onParse(fn: MaybeArray<BodyHandler<MergeSchema<{}, {}, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>>): this;
|
|
232
|
+
onParse(name: string): this;
|
|
233
|
+
/** @deprecated 1.x syntax, use `.onParse('plugin', fn)`, `'scoped'` is now `'plugin'` */
|
|
234
|
+
onParse<const As extends 'local' | 'scoped' | 'global'>(options: {
|
|
235
|
+
as: As;
|
|
236
|
+
}, fn: MaybeArray<BodyHandler<MergeSchema<{}, {}, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, LegacyScope<As>>>): this;
|
|
237
|
+
onParse<const HookScope extends EventScope>(scope: HookScope, fn: MaybeArray<BodyHandler<MergeSchema<{}, {}, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, HookScope>>): this;
|
|
180
238
|
parser<const Name extends string>(name: Name, fn: BodyHandler<MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>, BasePath> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], Singleton & {
|
|
181
239
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
182
240
|
}>): Elysia<BasePath, Scope, Singleton, Definitions, {
|
|
@@ -188,57 +246,66 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
188
246
|
response: Metadata['response'];
|
|
189
247
|
}, Routes, Ephemeral, Volatile>;
|
|
190
248
|
/**
|
|
191
|
-
* ###
|
|
249
|
+
* ### onStart | Life cycle event
|
|
192
250
|
* Called after server is ready for serving
|
|
193
251
|
*
|
|
194
252
|
* ---
|
|
195
253
|
* @example
|
|
196
254
|
* ```typescript
|
|
197
255
|
* new Elysia()
|
|
198
|
-
* .
|
|
199
|
-
* console.log(
|
|
256
|
+
* .onStart(({ server }) => {
|
|
257
|
+
* console.log(`Running at ${server?.url}`)
|
|
200
258
|
* })
|
|
201
259
|
* .listen(3000)
|
|
202
260
|
* ```
|
|
203
261
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
262
|
+
onStart(handler: MaybeArray<GracefulHandler<this>>): this;
|
|
263
|
+
onTransform(fn: MaybeArray<TransformHandler<MergeSchema<{}, {}, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>>): this;
|
|
264
|
+
/** @deprecated 1.x syntax, use `.onTransform('plugin', fn)`, `'scoped'` is now `'plugin'` */
|
|
265
|
+
onTransform<const As extends 'local' | 'scoped' | 'global'>(options: {
|
|
266
|
+
as: As;
|
|
267
|
+
}, fn: MaybeArray<TransformHandler<MergeSchema<{}, {}, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, LegacyScope<As>>>): this;
|
|
268
|
+
onTransform<const HookScope extends EventScope>(scope: HookScope, fn: MaybeArray<TransformHandler<MergeSchema<{}, {}, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, HookScope>>): this;
|
|
269
|
+
onBeforeHandle<const Handler extends MaybeArray<OptionalHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>>>(fn: Handler): LocalHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler, true>>;
|
|
270
|
+
onBeforeHandle<const Handler extends MaybeArray<OptionalHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>>>(scope: 'local', fn: Handler): LocalHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler, true>>;
|
|
271
|
+
onBeforeHandle<const Handler extends MaybeArray<OptionalHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, 'plugin'>>>(scope: 'plugin', fn: Handler): PluginHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler, true>>;
|
|
272
|
+
onBeforeHandle<const Handler extends MaybeArray<OptionalHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, 'global'>>>(scope: 'global', fn: Handler): GlobalHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler, true>>;
|
|
273
|
+
/** @deprecated 1.x syntax, use `.onBeforeHandle('plugin', fn)`, `'scoped'` is now `'plugin'` */
|
|
274
|
+
onBeforeHandle<const As extends 'local' | 'scoped' | 'global', const Handler extends MaybeArray<OptionalHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, LegacyScope<As>>>>(options: {
|
|
275
|
+
as: As;
|
|
276
|
+
}, fn: Handler): ScopedHookReturn<LegacyScope<As>, BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler, true>>;
|
|
277
|
+
onBeforeHandle<const HookScope extends EventScope, const Handler extends MaybeArray<OptionalHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, HookScope>>>(scope: HookScope, fn: Handler): ScopedHookReturn<HookScope, BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler, true>>;
|
|
278
|
+
derive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(transform: (context: Context<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>) => MaybePromise<Derivative>): LocalHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, DeriveResponse<Derivative>, ExcludeElysiaResponse<Derivative>>;
|
|
279
|
+
derive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(scope: 'local', transform: (context: Context<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>) => MaybePromise<Derivative>): LocalHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, DeriveResponse<Derivative>, ExcludeElysiaResponse<Derivative>>;
|
|
280
|
+
derive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(scope: 'plugin', transform: (context: LifecycleContext<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, 'plugin'>) => MaybePromise<Derivative>): PluginHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, DeriveResponse<Derivative>, ExcludeElysiaResponse<Derivative>>;
|
|
281
|
+
derive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(scope: 'global', transform: (context: LifecycleContext<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, 'global'>) => MaybePromise<Derivative>): GlobalHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, DeriveResponse<Derivative>, ExcludeElysiaResponse<Derivative>>;
|
|
282
|
+
/** @deprecated 1.x syntax, use `.derive('plugin', fn)`, `'scoped'` is now `'plugin'` */
|
|
283
|
+
derive<const As extends 'local' | 'scoped' | 'global', const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(options: {
|
|
284
|
+
as: As;
|
|
285
|
+
}, transform: (context: LifecycleContext<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, LegacyScope<As>>) => MaybePromise<Derivative>): ScopedHookReturn<LegacyScope<As>, BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, DeriveResponse<Derivative>, ExcludeElysiaResponse<Derivative>>;
|
|
286
|
+
derive<const HookScope extends EventScope, const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(scope: HookScope, transform: (context: LifecycleContext<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, HookScope>) => MaybePromise<Derivative>): ScopedHookReturn<HookScope, BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, DeriveResponse<Derivative>, ExcludeElysiaResponse<Derivative>>;
|
|
287
|
+
mapDerive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(transform: (context: Context<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>) => MaybePromise<Derivative>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
221
288
|
derive: ExcludeElysiaResponse<Derivative>;
|
|
222
289
|
schema: Volatile['schema'];
|
|
223
290
|
schemas: Volatile['schemas'];
|
|
224
|
-
response: UnionResponseStatus<Volatile['response'],
|
|
291
|
+
response: UnionResponseStatus<Volatile['response'], DeriveResponse<Derivative>>;
|
|
225
292
|
error: Volatile['error'];
|
|
226
293
|
}>;
|
|
227
|
-
mapDerive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | void>(scope: 'local', transform: (context: Context<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>) => MaybePromise<Derivative>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
294
|
+
mapDerive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(scope: 'local', transform: (context: Context<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>) => MaybePromise<Derivative>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
228
295
|
derive: ExcludeElysiaResponse<Derivative>;
|
|
229
296
|
schema: Volatile['schema'];
|
|
230
297
|
schemas: Volatile['schemas'];
|
|
231
|
-
response: UnionResponseStatus<Volatile['response'],
|
|
298
|
+
response: UnionResponseStatus<Volatile['response'], DeriveResponse<Derivative>>;
|
|
232
299
|
error: Volatile['error'];
|
|
233
300
|
}>;
|
|
234
|
-
mapDerive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | void>(scope: 'plugin', transform: (context: LifecycleContext<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, 'plugin'>) => MaybePromise<Derivative>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, {
|
|
301
|
+
mapDerive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(scope: 'plugin', transform: (context: LifecycleContext<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, 'plugin'>) => MaybePromise<Derivative>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, {
|
|
235
302
|
derive: ExcludeElysiaResponse<Derivative>;
|
|
236
303
|
schema: Ephemeral['schema'];
|
|
237
304
|
schemas: Ephemeral['schemas'];
|
|
238
|
-
response: UnionResponseStatus<Ephemeral['response'],
|
|
305
|
+
response: UnionResponseStatus<Ephemeral['response'], DeriveResponse<Derivative>>;
|
|
239
306
|
error: Ephemeral['error'];
|
|
240
307
|
}, Volatile>;
|
|
241
|
-
mapDerive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | void>(scope: 'global', transform: (context: LifecycleContext<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, 'global'>) => MaybePromise<Derivative>): Elysia<BasePath, Scope, {
|
|
308
|
+
mapDerive<const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(scope: 'global', transform: (context: LifecycleContext<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, 'global'>) => MaybePromise<Derivative>): Elysia<BasePath, Scope, {
|
|
242
309
|
decorator: Singleton['decorator'];
|
|
243
310
|
store: Singleton['store'];
|
|
244
311
|
derive: ExcludeElysiaResponse<Derivative>;
|
|
@@ -248,36 +315,46 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
248
315
|
macro: Metadata['macro'];
|
|
249
316
|
macroFn: Metadata['macroFn'];
|
|
250
317
|
parser: Metadata['parser'];
|
|
251
|
-
response: UnionResponseStatus<Metadata['response'],
|
|
318
|
+
response: UnionResponseStatus<Metadata['response'], DeriveResponse<Derivative>>;
|
|
252
319
|
}, Routes, Ephemeral, Volatile>;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
320
|
+
/** @deprecated 1.x syntax, use `.mapDerive('plugin', fn)`, `'scoped'` is now `'plugin'` */
|
|
321
|
+
mapDerive<const As extends 'local' | 'scoped' | 'global', const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(options: {
|
|
322
|
+
as: As;
|
|
323
|
+
}, transform: (context: LifecycleContext<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, LegacyScope<As>>) => MaybePromise<Derivative>): ScopedMapDeriveReturn<LegacyScope<As>, BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, DeriveResponse<Derivative>, ExcludeElysiaResponse<Derivative>>;
|
|
324
|
+
mapDerive<const HookScope extends EventScope, const Derivative extends Record<string, unknown> | ElysiaStatus<any, any, any> | Error | void>(scope: HookScope, transform: (context: LifecycleContext<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, HookScope>) => MaybePromise<Derivative>): ScopedMapDeriveReturn<HookScope, BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, DeriveResponse<Derivative>, ExcludeElysiaResponse<Derivative>>;
|
|
325
|
+
onAfterHandle<const Handler extends MaybeArray<AfterHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>>>(fn: Handler): LocalHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler>>;
|
|
326
|
+
onAfterHandle<const Handler extends MaybeArray<AfterHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>>>(scope: 'local', fn: Handler): LocalHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler>>;
|
|
327
|
+
onAfterHandle<const Handler extends MaybeArray<AfterHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, 'plugin'>>>(scope: 'plugin', fn: Handler): PluginHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler>>;
|
|
328
|
+
onAfterHandle<const Handler extends MaybeArray<AfterHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, 'global'>>>(scope: 'global', fn: Handler): GlobalHookReturn<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler>>;
|
|
329
|
+
/** @deprecated 1.x syntax, use `.onAfterHandle('plugin', fn)`, `'scoped'` is now `'plugin'` */
|
|
330
|
+
onAfterHandle<const As extends 'local' | 'scoped' | 'global', const Handler extends MaybeArray<AfterHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, LegacyScope<As>>>>(options: {
|
|
331
|
+
as: As;
|
|
332
|
+
}, fn: Handler): ScopedHookReturn<LegacyScope<As>, BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler>>;
|
|
333
|
+
onAfterHandle<const HookScope extends EventScope, const Handler extends MaybeArray<AfterHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, HookScope>>>(scope: HookScope, fn: Handler): ScopedHookReturn<HookScope, BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, ElysiaHandlerToResponseSchemaAmbiguous<Handler>>;
|
|
259
334
|
mapResponse(fn: MaybeArray<MapResponse<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>>): this;
|
|
260
|
-
mapResponse(
|
|
261
|
-
mapResponse
|
|
262
|
-
|
|
335
|
+
/** @deprecated 1.x syntax, use `.mapResponse('plugin', fn)`, `'scoped'` is now `'plugin'` */
|
|
336
|
+
mapResponse<const As extends 'local' | 'scoped' | 'global'>(options: {
|
|
337
|
+
as: As;
|
|
338
|
+
}, fn: MaybeArray<MapResponse<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, LegacyScope<As>>>): this;
|
|
263
339
|
mapResponse<const HookScope extends EventScope>(scope: HookScope, fn: MaybeArray<MapResponse<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, HookScope>>): this;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
340
|
+
onAfterResponse(fn: AfterResponseHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>>): this;
|
|
341
|
+
/** @deprecated 1.x syntax, use `.onAfterResponse('plugin', fn)`, `'scoped'` is now `'plugin'` */
|
|
342
|
+
onAfterResponse<const As extends 'local' | 'scoped' | 'global'>(options: {
|
|
343
|
+
as: As;
|
|
344
|
+
}, fn: AfterResponseHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, LegacyScope<As>>): this;
|
|
345
|
+
onAfterResponse<const HookScope extends EventScope>(scope: HookScope, fn: AfterResponseHandler<HookContextSchema<Metadata, Ephemeral, Volatile, BasePath>, HookContextSingleton<Singleton, Ephemeral, Volatile>, undefined, HookScope>): this;
|
|
346
|
+
onError<const Handler extends MaybeArray<ErrorHandler<[...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], {}, Singleton>>>(fn: Handler): CatchAllHookReturn<'local', BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Handler>;
|
|
347
|
+
onError<const E extends AnyErrorConstructor & (abstract new (...args: any) => Error), const Fn extends (context: ErrorContext<{}, Singleton & {
|
|
271
348
|
derive: Scope extends 'local' ? Partial<Ephemeral['derive'] & Volatile['derive']> : Scope extends 'plugin' ? Ephemeral['derive'] & Partial<Volatile['derive']> : Ephemeral['derive'] & Volatile['derive'];
|
|
272
349
|
}> & {
|
|
273
350
|
error: InstanceType<E>;
|
|
274
|
-
}) => unknown>(error: E, fn: Fn): Scope extends 'local' ? Elysia<BasePath, Scope, Singleton, Definitions, Metadata,
|
|
351
|
+
}) => unknown>(error: E, fn: Fn): Scope extends 'local' ? Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
275
352
|
derive: Volatile['derive'];
|
|
276
353
|
schema: Volatile['schema'];
|
|
277
354
|
schemas: Volatile['schemas'];
|
|
278
355
|
response: Volatile['response'];
|
|
279
356
|
error: [...Volatile['error'], ErrorDefinitionEntry<E, ReturnType<Fn>>];
|
|
280
|
-
}> : Scope extends 'plugin' ? Elysia<BasePath, Scope, Singleton, Definitions, Metadata,
|
|
357
|
+
}> : Scope extends 'plugin' ? Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, {
|
|
281
358
|
derive: Ephemeral['derive'];
|
|
282
359
|
schema: Ephemeral['schema'];
|
|
283
360
|
schemas: Ephemeral['schemas'];
|
|
@@ -286,27 +363,33 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
286
363
|
}, Volatile> : Elysia<BasePath, Scope, Singleton, {
|
|
287
364
|
typebox: Definitions['typebox'];
|
|
288
365
|
error: [...Definitions['error'], ErrorDefinitionEntry<E, ReturnType<Fn>>];
|
|
289
|
-
}, Metadata,
|
|
290
|
-
|
|
366
|
+
}, Metadata, Routes, Ephemeral, Volatile>;
|
|
367
|
+
onError<const E extends AnyErrorConstructor & (abstract new (...args: any) => Error), const Value>(error: E, value: Value): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
291
368
|
derive: Volatile['derive'];
|
|
292
369
|
schema: Volatile['schema'];
|
|
293
370
|
schemas: Volatile['schemas'];
|
|
294
371
|
response: Volatile['response'];
|
|
295
372
|
error: [...Volatile['error'], ErrorDefinitionEntry<E, Value>];
|
|
296
373
|
}>;
|
|
297
|
-
|
|
374
|
+
onError<const Handler extends MaybeArray<ErrorHandler<[...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], {}, Singleton & {
|
|
298
375
|
derive: Partial<Ephemeral['derive'] & Volatile['derive']>;
|
|
299
|
-
}>>>(scope: 'local', fn: Handler):
|
|
300
|
-
|
|
376
|
+
}>>>(scope: 'local', fn: Handler): CatchAllHookReturn<'local', BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Handler>;
|
|
377
|
+
onError<const Handler extends MaybeArray<ErrorHandler<[...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], {}, Singleton & {
|
|
301
378
|
derive: Ephemeral['derive'] & Partial<Volatile['derive']>;
|
|
302
|
-
}>>>(scope: 'plugin', fn: Handler):
|
|
303
|
-
|
|
379
|
+
}>>>(scope: 'plugin', fn: Handler): CatchAllHookReturn<'plugin', BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Handler>;
|
|
380
|
+
onError<const Handler extends MaybeArray<ErrorHandler<[...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], {}, Singleton & {
|
|
304
381
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
305
|
-
}>>>(scope: 'global', fn: Handler):
|
|
306
|
-
|
|
382
|
+
}>>>(scope: 'global', fn: Handler): CatchAllHookReturn<'global', BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Handler>;
|
|
383
|
+
/** @deprecated 1.x syntax, use `.onError('plugin', fn)`, `'scoped'` is now `'plugin'` */
|
|
384
|
+
onError<const As extends 'local' | 'scoped' | 'global', const Handler extends MaybeArray<ErrorHandler<[...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], {}, Singleton & {
|
|
385
|
+
derive: Partial<Ephemeral['derive'] & Volatile['derive']>;
|
|
386
|
+
}>>>(options: {
|
|
387
|
+
as: As;
|
|
388
|
+
}, fn: Handler): CatchAllHookReturn<LegacyScope<As>, BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Handler>;
|
|
389
|
+
onError<const HookScope extends EventScope, const Handler extends MaybeArray<ErrorHandler<[...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], {}, Singleton & {
|
|
307
390
|
derive: Partial<Ephemeral['derive'] & Volatile['derive']>;
|
|
308
|
-
}>>>(scope: HookScope, fn: Handler):
|
|
309
|
-
|
|
391
|
+
}>>>(scope: HookScope, fn: Handler): CatchAllHookReturn<HookScope, BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Handler>;
|
|
392
|
+
onError<const S extends EventScope, const E extends AnyErrorConstructor & (abstract new (...args: any) => Error), const Fn extends (context: ErrorContext<{}, {
|
|
310
393
|
store: Singleton['store'];
|
|
311
394
|
decorator: Singleton['decorator'];
|
|
312
395
|
derive: {};
|
|
@@ -315,29 +398,29 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
315
398
|
}) => unknown>(scope: S, error: E, fn: Fn): S extends 'global' ? Elysia<BasePath, Scope, Singleton, {
|
|
316
399
|
typebox: Definitions['typebox'];
|
|
317
400
|
error: [...Definitions['error'], ErrorDefinitionEntry<E, ReturnType<Fn>>];
|
|
318
|
-
}, Metadata,
|
|
401
|
+
}, Metadata, Routes, Ephemeral, Volatile> : S extends 'plugin' ? Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, {
|
|
319
402
|
derive: Ephemeral['derive'];
|
|
320
403
|
schema: Ephemeral['schema'];
|
|
321
404
|
schemas: Ephemeral['schemas'];
|
|
322
405
|
response: Ephemeral['response'];
|
|
323
406
|
error: [...Ephemeral['error'], ErrorDefinitionEntry<E, ReturnType<Fn>>];
|
|
324
|
-
}, Volatile> : Elysia<BasePath, Scope, Singleton, Definitions, Metadata,
|
|
407
|
+
}, Volatile> : Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
325
408
|
derive: Volatile['derive'];
|
|
326
409
|
schema: Volatile['schema'];
|
|
327
410
|
schemas: Volatile['schemas'];
|
|
328
411
|
response: Volatile['response'];
|
|
329
412
|
error: [...Volatile['error'], ErrorDefinitionEntry<E, ReturnType<Fn>>];
|
|
330
413
|
}>;
|
|
331
|
-
|
|
414
|
+
onError<const S extends EventScope, const E extends AnyErrorConstructor & (abstract new (...args: any) => Error), const Value>(scope: S, error: E, value: Value): S extends 'global' ? Elysia<BasePath, Scope, Singleton, {
|
|
332
415
|
typebox: Definitions['typebox'];
|
|
333
416
|
error: [...Definitions['error'], ErrorDefinitionEntry<E, Value>];
|
|
334
|
-
}, Metadata,
|
|
417
|
+
}, Metadata, Routes, Ephemeral, Volatile> : S extends 'plugin' ? Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, {
|
|
335
418
|
derive: Ephemeral['derive'];
|
|
336
419
|
schema: Ephemeral['schema'];
|
|
337
420
|
schemas: Ephemeral['schemas'];
|
|
338
421
|
response: Ephemeral['response'];
|
|
339
422
|
error: [...Ephemeral['error'], ErrorDefinitionEntry<E, Value>];
|
|
340
|
-
}, Volatile> : Elysia<BasePath, Scope, Singleton, Definitions, Metadata,
|
|
423
|
+
}, Volatile> : Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
341
424
|
derive: Volatile['derive'];
|
|
342
425
|
schema: Volatile['schema'];
|
|
343
426
|
schemas: Volatile['schemas'];
|
|
@@ -345,9 +428,10 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
345
428
|
error: [...Volatile['error'], ErrorDefinitionEntry<E, Value>];
|
|
346
429
|
}>;
|
|
347
430
|
trace(fn: TraceHandler<any, any>): this;
|
|
348
|
-
trace(
|
|
349
|
-
trace
|
|
350
|
-
|
|
431
|
+
/** @deprecated 1.x syntax, use `.trace('plugin', fn)`, `'scoped'` is now `'plugin'` */
|
|
432
|
+
trace<const As extends 'local' | 'scoped' | 'global'>(options: {
|
|
433
|
+
as: As;
|
|
434
|
+
}, fn: TraceHandler<any, any>): this;
|
|
351
435
|
trace<const HookScope extends EventScope>(scope: HookScope, fn: TraceHandler<any, any>): this;
|
|
352
436
|
as(type: 'plugin'): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, {
|
|
353
437
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
@@ -382,113 +466,138 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
382
466
|
* .guard({ body: t.Object({ name: t.String() }) })
|
|
383
467
|
* .post('/', ({ body }) => body)
|
|
384
468
|
* ```
|
|
385
|
-
*
|
|
386
|
-
* @remarks
|
|
387
|
-
* Chaining a very large number of `.guard()` calls on a single instance
|
|
388
|
-
* (~120+) can exhaust the TypeScript type-instantiation budget and slow or
|
|
389
|
-
* error `tsc`, because each `.guard()` re-expands the accumulated schema
|
|
390
|
-
* metadata. For large counts, compose the guards across plugins and combine
|
|
391
|
-
* them with `.use()` instead.
|
|
392
469
|
*/
|
|
393
|
-
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
470
|
+
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>>(hook: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'merge'> & {
|
|
394
471
|
schema: 'merge';
|
|
395
|
-
}
|
|
396
|
-
derive:
|
|
472
|
+
} & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
473
|
+
derive: {};
|
|
474
|
+
}>>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
475
|
+
derive: Volatile['derive'] & MacroContext['derive'];
|
|
397
476
|
schema: Volatile['schema'];
|
|
398
477
|
schemas: Volatile['schemas'] & UnwrapRoute<Input, Definitions['typebox']> & MacroContext;
|
|
399
|
-
response: UnionResponseStatus<Volatile['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle
|
|
400
|
-
error: Volatile['error'];
|
|
478
|
+
response: UnionResponseStatus<UnionResponseStatus<Volatile['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
479
|
+
error: [...Volatile['error'], ...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>];
|
|
401
480
|
}>;
|
|
402
|
-
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
403
|
-
derive:
|
|
481
|
+
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>>(hook: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'override'> & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
482
|
+
derive: {};
|
|
483
|
+
}>>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
484
|
+
derive: Volatile['derive'] & MacroContext['derive'];
|
|
404
485
|
schema: {} extends Pick<Input, Extract<keyof Input, InputSchemaKey>> ? Volatile['schema'] : MergeSchema<UnwrapRoute<Input, Definitions['typebox']>, Volatile['schema']>;
|
|
405
486
|
schemas: Volatile['schemas'] & MacroContext;
|
|
406
|
-
response: UnionResponseStatus<Volatile['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle
|
|
407
|
-
error: Volatile['error'];
|
|
487
|
+
response: UnionResponseStatus<UnionResponseStatus<Volatile['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
488
|
+
error: [...Volatile['error'], ...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>];
|
|
408
489
|
}>;
|
|
409
|
-
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
490
|
+
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const NewElysia extends AnyElysia>(hook: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'merge'> & {
|
|
410
491
|
schema: 'merge';
|
|
411
|
-
},
|
|
492
|
+
} & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
493
|
+
derive: {};
|
|
494
|
+
}>>, run: (group: Elysia<BasePath, Scope, {
|
|
412
495
|
decorator: Singleton['decorator'];
|
|
413
496
|
store: Singleton['store'];
|
|
414
|
-
derive: Singleton['derive'] & MacroContext['
|
|
415
|
-
}, Definitions, {
|
|
497
|
+
derive: Singleton['derive'] & MacroContext['derive'];
|
|
498
|
+
}, WithErrorEntries<Definitions, [...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>]>, {
|
|
416
499
|
schema: Metadata['schema'];
|
|
417
500
|
schemas: Metadata['schemas'] & UnwrapRoute<Input, Definitions['typebox']> & MacroContext;
|
|
418
501
|
macro: Metadata['macro'];
|
|
419
502
|
macroFn: Metadata['macroFn'];
|
|
420
503
|
parser: Metadata['parser'];
|
|
421
|
-
response: Metadata['response']
|
|
504
|
+
response: UnionResponseStatus<UnionResponseStatus<Metadata['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
422
505
|
}, {}, Ephemeral, Volatile>) => NewElysia): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes & NewElysia['~Routes'], Ephemeral, Volatile>;
|
|
423
|
-
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
506
|
+
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const NewElysia extends AnyElysia>(hook: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'override'> & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
507
|
+
derive: {};
|
|
508
|
+
}>>, run: (group: Elysia<BasePath, Scope, {
|
|
424
509
|
decorator: Singleton['decorator'];
|
|
425
510
|
store: Singleton['store'];
|
|
426
|
-
derive: Singleton['derive'] & MacroContext['
|
|
427
|
-
}, Definitions, {
|
|
511
|
+
derive: Singleton['derive'] & MacroContext['derive'];
|
|
512
|
+
}, WithErrorEntries<Definitions, [...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>]>, {
|
|
428
513
|
schema: MergeSchema<UnwrapRoute<Input, Definitions['typebox']>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>>;
|
|
429
514
|
schemas: Metadata['schemas'] & MacroContext;
|
|
430
515
|
macro: Metadata['macro'];
|
|
431
516
|
macroFn: Metadata['macroFn'];
|
|
432
517
|
parser: Metadata['parser'];
|
|
433
|
-
response: Metadata['response']
|
|
434
|
-
}, {},
|
|
435
|
-
|
|
518
|
+
response: UnionResponseStatus<UnionResponseStatus<Metadata['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
519
|
+
}, {}, {
|
|
520
|
+
derive: Ephemeral['derive'];
|
|
521
|
+
schema: {};
|
|
522
|
+
schemas: Ephemeral['schemas'];
|
|
523
|
+
response: Ephemeral['response'];
|
|
524
|
+
error: Ephemeral['error'];
|
|
525
|
+
}, {
|
|
526
|
+
derive: Volatile['derive'];
|
|
527
|
+
schema: {};
|
|
528
|
+
schemas: Volatile['schemas'];
|
|
529
|
+
response: Volatile['response'];
|
|
530
|
+
error: Volatile['error'];
|
|
531
|
+
}>) => NewElysia): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes & NewElysia['~Routes'], Ephemeral, Volatile>;
|
|
532
|
+
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>>(scope: 'local', hook: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'merge'> & {
|
|
436
533
|
schema: 'merge';
|
|
437
|
-
}
|
|
438
|
-
derive:
|
|
534
|
+
} & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
535
|
+
derive: {};
|
|
536
|
+
}>>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
537
|
+
derive: Volatile['derive'] & MacroContext['derive'];
|
|
439
538
|
schema: Volatile['schema'];
|
|
440
539
|
schemas: Volatile['schemas'] & UnwrapRoute<Input, Definitions['typebox']> & MacroContext;
|
|
441
|
-
response: UnionResponseStatus<Volatile['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle
|
|
442
|
-
error: Volatile['error'];
|
|
540
|
+
response: UnionResponseStatus<UnionResponseStatus<Volatile['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
541
|
+
error: [...Volatile['error'], ...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>];
|
|
443
542
|
}>;
|
|
444
|
-
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
445
|
-
derive:
|
|
543
|
+
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>>(scope: 'local', hook: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'override'> & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
544
|
+
derive: {};
|
|
545
|
+
}>>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
|
|
546
|
+
derive: Volatile['derive'] & MacroContext['derive'];
|
|
446
547
|
schema: {} extends Pick<Input, Extract<keyof Input, InputSchemaKey>> ? Volatile['schema'] : MergeSchema<UnwrapRoute<Input, Definitions['typebox']>, Volatile['schema']>;
|
|
447
548
|
schemas: Volatile['schemas'] & MacroContext;
|
|
448
|
-
response: UnionResponseStatus<Volatile['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle
|
|
449
|
-
error: Volatile['error'];
|
|
549
|
+
response: UnionResponseStatus<UnionResponseStatus<Volatile['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
550
|
+
error: [...Volatile['error'], ...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>];
|
|
450
551
|
}>;
|
|
451
|
-
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
552
|
+
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>>(scope: 'plugin', hook: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'merge'> & {
|
|
452
553
|
schema: 'merge';
|
|
453
|
-
}
|
|
454
|
-
derive:
|
|
554
|
+
} & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
555
|
+
derive: {};
|
|
556
|
+
}>>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, {
|
|
557
|
+
derive: Ephemeral['derive'] & MacroContext['derive'];
|
|
455
558
|
schema: Ephemeral['schema'];
|
|
456
559
|
schemas: Ephemeral['schemas'] & UnwrapRoute<Input, Definitions['typebox']> & MacroContext;
|
|
457
|
-
response: UnionResponseStatus<Ephemeral['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle
|
|
458
|
-
error: Ephemeral['error'];
|
|
560
|
+
response: UnionResponseStatus<UnionResponseStatus<Ephemeral['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
561
|
+
error: [...Ephemeral['error'], ...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>];
|
|
459
562
|
}, Volatile>;
|
|
460
|
-
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
461
|
-
derive:
|
|
563
|
+
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>>(scope: 'plugin', hook: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'override'> & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
564
|
+
derive: {};
|
|
565
|
+
}>>): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, {
|
|
566
|
+
derive: Ephemeral['derive'] & MacroContext['derive'];
|
|
462
567
|
schema: {} extends Pick<Input, Extract<keyof Input, InputSchemaKey>> ? Ephemeral['schema'] : MergeSchema<UnwrapRoute<Input, Definitions['typebox']>, Ephemeral['schema']>;
|
|
463
568
|
schemas: Ephemeral['schemas'] & MacroContext;
|
|
464
|
-
response: UnionResponseStatus<Ephemeral['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle
|
|
465
|
-
error: Ephemeral['error'];
|
|
569
|
+
response: UnionResponseStatus<UnionResponseStatus<Ephemeral['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
570
|
+
error: [...Ephemeral['error'], ...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>];
|
|
466
571
|
}, Volatile>;
|
|
467
|
-
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
572
|
+
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>>(scope: 'global', hook: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'merge'> & {
|
|
468
573
|
schema: 'merge';
|
|
469
|
-
}
|
|
574
|
+
} & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
575
|
+
derive: {};
|
|
576
|
+
}>>): Elysia<BasePath, Scope, {
|
|
470
577
|
decorator: Singleton['decorator'];
|
|
471
578
|
store: Singleton['store'];
|
|
472
|
-
derive: Singleton['derive'] & MacroContext['
|
|
473
|
-
}, Definitions, {
|
|
579
|
+
derive: Singleton['derive'] & MacroContext['derive'];
|
|
580
|
+
}, WithErrorEntries<Definitions, [...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>]>, {
|
|
474
581
|
schema: Metadata['schema'];
|
|
475
582
|
schemas: Metadata['schemas'] & UnwrapRoute<Input, Definitions['typebox']> & MacroContext;
|
|
476
583
|
macro: Metadata['macro'];
|
|
477
584
|
macroFn: Metadata['macroFn'];
|
|
478
585
|
parser: Metadata['parser'];
|
|
479
|
-
response: UnionResponseStatus<Metadata['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle
|
|
586
|
+
response: UnionResponseStatus<UnionResponseStatus<Metadata['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
480
587
|
}, Routes, Ephemeral, Volatile>;
|
|
481
|
-
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
588
|
+
guard<const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], BasePath>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>>(scope: 'global', hook: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'override'> & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
589
|
+
derive: {};
|
|
590
|
+
}>>): Elysia<BasePath, Scope, {
|
|
482
591
|
decorator: Singleton['decorator'];
|
|
483
592
|
store: Singleton['store'];
|
|
484
|
-
derive: Singleton['derive'] & MacroContext['
|
|
485
|
-
}, Definitions, {
|
|
593
|
+
derive: Singleton['derive'] & MacroContext['derive'];
|
|
594
|
+
}, WithErrorEntries<Definitions, [...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>]>, {
|
|
486
595
|
schema: {} extends Pick<Input, Extract<keyof Input, InputSchemaKey>> ? Metadata['schema'] : MergeSchema<UnwrapRoute<Input, Definitions['typebox']>, Metadata['schema']>;
|
|
487
596
|
schemas: Metadata['schemas'] & MacroContext;
|
|
488
597
|
macro: Metadata['macro'];
|
|
489
598
|
macroFn: Metadata['macroFn'];
|
|
490
599
|
parser: Metadata['parser'];
|
|
491
|
-
response: UnionResponseStatus<Metadata['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle
|
|
600
|
+
response: UnionResponseStatus<UnionResponseStatus<Metadata['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
492
601
|
}, Routes, Ephemeral, Volatile>;
|
|
493
602
|
group<const Prefix extends string, const NewElysia extends AnyElysia>(prefix: Prefix, run: (group: Elysia<Prefix extends '' ? BasePath : JoinPath<BasePath, Prefix>, Scope, Singleton, Definitions, {
|
|
494
603
|
schema: MergeSchema<UnwrapRoute<{}, Definitions['typebox']>, Metadata['schema']>;
|
|
@@ -498,32 +607,48 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
498
607
|
parser: Metadata['parser'];
|
|
499
608
|
response: Metadata['response'];
|
|
500
609
|
}, {}, Ephemeral, Volatile>) => NewElysia): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes & NewElysia['~Routes'], Ephemeral, Volatile>;
|
|
501
|
-
group<const Prefix extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Prefix>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
610
|
+
group<const Prefix extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Prefix>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const NewElysia extends AnyElysia>(prefix: Prefix, schema: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'merge'> & {
|
|
502
611
|
schema: 'merge';
|
|
503
|
-
},
|
|
612
|
+
} & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
613
|
+
derive: {};
|
|
614
|
+
}>>, run: (group: Elysia<JoinPath<BasePath, Prefix>, Scope, {
|
|
504
615
|
decorator: Singleton['decorator'];
|
|
505
616
|
store: Singleton['store'];
|
|
506
|
-
derive: Singleton['derive'] & MacroContext['
|
|
507
|
-
}, Definitions, {
|
|
617
|
+
derive: Singleton['derive'] & MacroContext['derive'];
|
|
618
|
+
}, WithErrorEntries<Definitions, [...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>]>, {
|
|
508
619
|
schema: Metadata['schema'];
|
|
509
620
|
schemas: Metadata['schemas'] & UnwrapRoute<Input, Definitions['typebox']> & MacroContext;
|
|
510
621
|
macro: Metadata['macro'];
|
|
511
622
|
macroFn: Metadata['macroFn'];
|
|
512
623
|
parser: Metadata['parser'];
|
|
513
|
-
response: Metadata['response']
|
|
624
|
+
response: UnionResponseStatus<UnionResponseStatus<Metadata['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
514
625
|
}, {}, Ephemeral, Volatile>) => NewElysia): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes & NewElysia['~Routes'], Ephemeral, Volatile>;
|
|
515
|
-
group<const Prefix extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Prefix>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
626
|
+
group<const Prefix extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Prefix>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const BeforeHandle extends MaybeArray<OptionalHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const AfterHandle extends MaybeArray<AfterHandler<Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const ErrorHandle extends MaybeArray<ErrorHandler<Definitions['error'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>>>, const NewElysia extends AnyElysia>(prefix: Prefix, schema: GuardLocalHook<Input, Schema & MacroContext, GuardHookSingleton<Singleton, Ephemeral, Volatile, MacroContext>, keyof Metadata['parser'], BeforeHandle, AfterHandle, ErrorHandle, 'override'> & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
627
|
+
derive: {};
|
|
628
|
+
}>>, run: (group: Elysia<JoinPath<BasePath, Prefix>, Scope, {
|
|
516
629
|
decorator: Singleton['decorator'];
|
|
517
630
|
store: Singleton['store'];
|
|
518
|
-
derive: Singleton['derive'] & MacroContext['
|
|
519
|
-
}, Definitions, {
|
|
631
|
+
derive: Singleton['derive'] & MacroContext['derive'];
|
|
632
|
+
}, WithErrorEntries<Definitions, [...CatchAllEntries<ErrorHandle>, ...MacroCatchAll<MacroContext['return' & keyof MacroContext]>]>, {
|
|
520
633
|
schema: MergeSchema<UnwrapRoute<Input, Definitions['typebox']>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>>;
|
|
521
634
|
schemas: Metadata['schemas'] & MacroContext;
|
|
522
635
|
macro: Metadata['macro'];
|
|
523
636
|
macroFn: Metadata['macroFn'];
|
|
524
637
|
parser: Metadata['parser'];
|
|
525
|
-
response: Metadata['response']
|
|
526
|
-
}, {},
|
|
638
|
+
response: UnionResponseStatus<UnionResponseStatus<Metadata['response'], ElysiaHandlerToResponseSchemaAmbiguous<BeforeHandle, true>>, UnionResponseStatus<ElysiaHandlerToResponseSchemaAmbiguous<AfterHandle>, UnionResponseStatus<ErrorHookStatus<ErrorHandle>, WithoutMacroCatch<MacroContext['return' & keyof MacroContext]> & {}>>>;
|
|
639
|
+
}, {}, {
|
|
640
|
+
derive: Ephemeral['derive'];
|
|
641
|
+
schema: {};
|
|
642
|
+
schemas: Ephemeral['schemas'];
|
|
643
|
+
response: Ephemeral['response'];
|
|
644
|
+
error: Ephemeral['error'];
|
|
645
|
+
}, {
|
|
646
|
+
derive: Volatile['derive'];
|
|
647
|
+
schema: {};
|
|
648
|
+
schemas: Volatile['schemas'];
|
|
649
|
+
response: Volatile['response'];
|
|
650
|
+
error: Volatile['error'];
|
|
651
|
+
}>) => NewElysia): Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes & NewElysia['~Routes'], Ephemeral, Volatile>;
|
|
527
652
|
['~resolvedCapability'](kind: 'trace'): TraceCapability | undefined;
|
|
528
653
|
['~resolvedCapability'](kind: 'ws'): {
|
|
529
654
|
provider: WSCapability;
|
|
@@ -546,10 +671,10 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
546
671
|
* beforeHandle() { ... }
|
|
547
672
|
* })
|
|
548
673
|
* })
|
|
549
|
-
* .get('/',
|
|
674
|
+
* .get('/', { auth: true, role: 'admin' }, ({ user }) => user)
|
|
550
675
|
* ```
|
|
551
676
|
*/
|
|
552
|
-
macro<const
|
|
677
|
+
macro<const NewMacro, const Refs = {}>(macro: ObjectMacroDefs<NewMacro, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>, Singleton & {
|
|
553
678
|
derive: Partial<Ephemeral['derive'] & Volatile['derive']>;
|
|
554
679
|
}, Definitions, Metadata['macro'], Metadata['macroFn'], Refs>): Elysia<BasePath, Scope, Singleton, Definitions, {
|
|
555
680
|
schema: Metadata['schema'];
|
|
@@ -570,57 +695,87 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
570
695
|
}, {
|
|
571
696
|
typebox: Definitions['typebox'] & NewElysia['~Definitions']['typebox'];
|
|
572
697
|
error: [...Definitions['error'], ...NewElysia['~Definitions']['error']];
|
|
573
|
-
}, Metadata
|
|
698
|
+
}, MergeMetadata<Metadata, NewElysia['~Metadata']>, BasePath extends `` ? Routes & ResolveUsedRouteErrors<NewElysia['~Routes'], [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], ParentResponse<Metadata, Ephemeral, Volatile>> : Routes & CreateEden<BasePath, ResolveUsedRouteErrors<NewElysia['~Routes'], [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], ParentResponse<Metadata, Ephemeral, Volatile>>>, Ephemeral, {
|
|
574
699
|
derive: Volatile['derive'] & NewElysia['~Ephemeral']['derive'];
|
|
575
700
|
schema: Volatile['schema'] & NewElysia['~Ephemeral']['schema'];
|
|
576
701
|
schemas: Volatile['schemas'] & NewElysia['~Ephemeral']['schemas'];
|
|
577
|
-
response: Volatile['response']
|
|
702
|
+
response: UnionResponseStatus<Volatile['response'], NewElysia['~Ephemeral']['response']>;
|
|
578
703
|
error: [...Volatile['error'], ...NewElysia['~Ephemeral']['error']];
|
|
579
704
|
}>;
|
|
580
705
|
/**
|
|
581
|
-
* Merge multiple plugin instances
|
|
706
|
+
* Merge multiple plugin instances, or a factory returning them
|
|
707
|
+
*
|
|
708
|
+
* A factory taking no `app` has its array inferred by the instance
|
|
709
|
+
* overload above, as an array rather than a tuple, so its plugins are
|
|
710
|
+
* lost: return it `as const`
|
|
582
711
|
*/
|
|
583
|
-
use<const Instances extends AnyElysia[]>(instances: Instances): MergeElysiaInstances<Instances, BasePath, Scope, Singleton, Definitions, Metadata, Ephemeral, Volatile, Routes>;
|
|
712
|
+
use<const Instances extends AnyElysia[], const Param extends AnyElysia = this>(instances: Instances | ((app: Param) => readonly [...Instances])): MergeElysiaInstances<Instances, BasePath, Scope, Singleton, Definitions, Metadata, Ephemeral, Volatile, Routes>;
|
|
584
713
|
/**
|
|
585
714
|
* Inline functional plugin
|
|
715
|
+
*
|
|
716
|
+
* A factory that ignores `app` is assumed to return a new instance, used
|
|
717
|
+
* as a plugin the same way as `.use(instance)`. One returning the parent
|
|
718
|
+
* it captured is mistyped, types can't see instance identity. A factory
|
|
719
|
+
* declaring a parameter, even an optional one, is typed as returning `app`
|
|
586
720
|
*/
|
|
587
|
-
use<const NewElysia extends AnyElysia, const Param extends AnyElysia = this>(plugin: (app: Param) => NewElysia): Elysia<BasePath, Scope, {
|
|
721
|
+
use<const NewElysia extends AnyElysia, const Param extends AnyElysia = this, const Factory = unknown>(plugin: Factory & ((app: Param) => NewElysia)): IgnoresApp<Factory> extends true ? Elysia<BasePath, Scope, {
|
|
722
|
+
decorator: Singleton['decorator'] & NewElysia['~Singleton']['decorator'];
|
|
723
|
+
store: Prettify<Singleton['store'] & NewElysia['~Singleton']['store']>;
|
|
724
|
+
derive: Singleton['derive'] & NewElysia['~Singleton']['derive'];
|
|
725
|
+
}, {
|
|
726
|
+
typebox: Definitions['typebox'] & NewElysia['~Definitions']['typebox'];
|
|
727
|
+
error: [...Definitions['error'], ...NewElysia['~Definitions']['error']];
|
|
728
|
+
}, MergeMetadata<Metadata, NewElysia['~Metadata']>, BasePath extends `` ? Routes & ResolveUsedRouteErrors<NewElysia['~Routes'], [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], ParentResponse<Metadata, Ephemeral, Volatile>> : Routes & CreateEden<BasePath, ResolveUsedRouteErrors<NewElysia['~Routes'], [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], ParentResponse<Metadata, Ephemeral, Volatile>>>, Ephemeral, {
|
|
729
|
+
derive: Volatile['derive'] & NewElysia['~Ephemeral']['derive'];
|
|
730
|
+
schema: Volatile['schema'] & NewElysia['~Ephemeral']['schema'];
|
|
731
|
+
schemas: Volatile['schemas'] & NewElysia['~Ephemeral']['schemas'];
|
|
732
|
+
response: UnionResponseStatus<Volatile['response'], NewElysia['~Ephemeral']['response']>;
|
|
733
|
+
error: [...Volatile['error'], ...NewElysia['~Ephemeral']['error']];
|
|
734
|
+
}> : Elysia<BasePath, Scope, {
|
|
588
735
|
decorator: Singleton['decorator'] & NewElysia['~Singleton']['decorator'];
|
|
589
736
|
store: Prettify<Singleton['store'] & NewElysia['~Singleton']['store']>;
|
|
590
737
|
derive: Singleton['derive'] & NewElysia['~Singleton']['derive'];
|
|
591
738
|
}, {
|
|
592
739
|
typebox: Definitions['typebox'] & NewElysia['~Definitions']['typebox'];
|
|
593
740
|
error: [...Definitions['error'], ...NewElysia['~Definitions']['error']];
|
|
594
|
-
}, Metadata
|
|
741
|
+
}, MergeMetadata<Metadata, NewElysia['~Metadata']>, BasePath extends `` ? Routes & NewElysia['~Routes'] : Routes & CreateEden<BasePath, NewElysia['~Routes']>, {
|
|
595
742
|
derive: Ephemeral['derive'] & NewElysia['~Ephemeral']['derive'];
|
|
596
743
|
schema: Ephemeral['schema'] & NewElysia['~Ephemeral']['schema'];
|
|
597
744
|
schemas: Ephemeral['schemas'] & NewElysia['~Ephemeral']['schemas'];
|
|
598
|
-
response: Ephemeral['response']
|
|
745
|
+
response: UnionResponseStatus<Ephemeral['response'], NewElysia['~Ephemeral']['response']>;
|
|
599
746
|
error: NewElysia['~Ephemeral']['error'];
|
|
600
747
|
}, {
|
|
601
748
|
derive: Volatile['derive'] & NewElysia['~Volatile']['derive'];
|
|
602
749
|
schema: Volatile['schema'] & NewElysia['~Volatile']['schema'];
|
|
603
750
|
schemas: Volatile['schemas'] & NewElysia['~Volatile']['schemas'];
|
|
604
|
-
response: Volatile['response']
|
|
751
|
+
response: UnionResponseStatus<Volatile['response'], NewElysia['~Volatile']['response']>;
|
|
605
752
|
error: NewElysia['~Volatile']['error'];
|
|
606
753
|
}>;
|
|
607
754
|
/**
|
|
608
755
|
* async plugin instance
|
|
756
|
+
*
|
|
757
|
+
* A factory that ignores `app` is assumed to resolve to a new instance,
|
|
758
|
+
* used as a plugin the same way. One resolving to the parent it captured
|
|
759
|
+
* is mistyped, types can't see instance identity. A factory declaring a
|
|
760
|
+
* parameter, even an optional one, is typed as returning `app`, see the
|
|
761
|
+
* async functional plugin below
|
|
609
762
|
*/
|
|
610
763
|
use<const NewElysia extends AnyElysia>(instance: Promise<NewElysia | {
|
|
611
764
|
default: NewElysia;
|
|
612
|
-
}>)
|
|
765
|
+
}> | ((app?: NotTheParent) => MaybePromise<NewElysia | {
|
|
766
|
+
default: NewElysia;
|
|
767
|
+
}>)): Elysia<BasePath, Scope, {
|
|
613
768
|
decorator: Singleton['decorator'] & NewElysia['~Singleton']['decorator'];
|
|
614
769
|
store: Prettify<Singleton['store'] & NewElysia['~Singleton']['store']>;
|
|
615
770
|
derive: Singleton['derive'] & Partial<NewElysia['~Singleton']['derive']>;
|
|
616
771
|
}, {
|
|
617
772
|
typebox: Definitions['typebox'] & NewElysia['~Definitions']['typebox'];
|
|
618
773
|
error: [...Definitions['error'], ...NewElysia['~Definitions']['error']];
|
|
619
|
-
}, Metadata
|
|
774
|
+
}, MergeMetadata<Metadata, NewElysia['~Metadata']>, BasePath extends `` ? Routes & ResolveUsedRouteErrors<NewElysia['~Routes'], [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], ParentResponse<Metadata, Ephemeral, Volatile>> : Routes & CreateEden<BasePath, ResolveUsedRouteErrors<NewElysia['~Routes'], [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], ParentResponse<Metadata, Ephemeral, Volatile>>>, Ephemeral, {
|
|
620
775
|
derive: Volatile['derive'] & Partial<NewElysia['~Ephemeral']['derive']>;
|
|
621
776
|
schema: Volatile['schema'] & NewElysia['~Ephemeral']['schema'];
|
|
622
777
|
schemas: Volatile['schemas'] & NewElysia['~Ephemeral']['schemas'];
|
|
623
|
-
response: Volatile['response']
|
|
778
|
+
response: UnionResponseStatus<Volatile['response'], NewElysia['~Ephemeral']['response']>;
|
|
624
779
|
error: [...Volatile['error'], ...NewElysia['~Ephemeral']['error']];
|
|
625
780
|
}>;
|
|
626
781
|
/**
|
|
@@ -635,17 +790,17 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
635
790
|
}, {
|
|
636
791
|
typebox: Definitions['typebox'] & NewElysia['~Definitions']['typebox'];
|
|
637
792
|
error: [...Definitions['error'], ...NewElysia['~Definitions']['error']];
|
|
638
|
-
}, Metadata
|
|
793
|
+
}, MergeMetadata<Metadata, NewElysia['~Metadata']>, BasePath extends `` ? Routes & NewElysia['~Routes'] : Routes & CreateEden<BasePath, NewElysia['~Routes']>, {
|
|
639
794
|
derive: Ephemeral['derive'] & Partial<NewElysia['~Ephemeral']['derive']>;
|
|
640
795
|
schema: Ephemeral['schema'] & NewElysia['~Ephemeral']['schema'];
|
|
641
796
|
schemas: Ephemeral['schemas'] & NewElysia['~Ephemeral']['schemas'];
|
|
642
|
-
response: Ephemeral['response']
|
|
797
|
+
response: UnionResponseStatus<Ephemeral['response'], NewElysia['~Ephemeral']['response']>;
|
|
643
798
|
error: NewElysia['~Ephemeral']['error'];
|
|
644
799
|
}, {
|
|
645
800
|
derive: Volatile['derive'] & Partial<NewElysia['~Volatile']['derive']>;
|
|
646
801
|
schema: Volatile['schema'] & NewElysia['~Volatile']['schema'];
|
|
647
802
|
schemas: Volatile['schemas'] & NewElysia['~Volatile']['schemas'];
|
|
648
|
-
response: Volatile['response']
|
|
803
|
+
response: UnionResponseStatus<Volatile['response'], NewElysia['~Volatile']['response']>;
|
|
649
804
|
error: NewElysia['~Volatile']['error'];
|
|
650
805
|
}>;
|
|
651
806
|
/**
|
|
@@ -654,6 +809,7 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
654
809
|
use(app: MaybePromise<AnyElysia | AnyElysia[] | {
|
|
655
810
|
default: unknown;
|
|
656
811
|
} | ((app: any) => unknown)> | null | undefined): this;
|
|
812
|
+
has(plugin: AnyElysia): boolean;
|
|
657
813
|
get modules(): Promise<void>;
|
|
658
814
|
get pending(): boolean;
|
|
659
815
|
model<const Name extends string, const Model extends AnySchema>(name: Name, model: Model): Elysia<BasePath, Scope, Singleton, {
|
|
@@ -687,9 +843,9 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
687
843
|
* .get('/hook', { query: t.Object({ name: t.String() }) }, () => 'hi')
|
|
688
844
|
* ```
|
|
689
845
|
*/
|
|
690
|
-
get<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string
|
|
846
|
+
get<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & RouteHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
691
847
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
692
|
-
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
848
|
+
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handle extends ({} extends MacroContext ? InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>> : InlineHandler<NoInfer<Schema>, NoInfer<Decorator>, MacroContext>), UnknownKey extends PropertyKey = Exclude<keyof Input, HookObjectKey | keyof Metadata['macro']>>(path: Path, hook: LocalHook<Input, Schema & MacroContext, Decorator, Definitions['error'], keyof Metadata['parser']> & MacroOptionContext<Metadata['macroFn'], Schema, Decorator> & UnknownHookKey<UnknownKey>, fn: Handle): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'get', Path, Schema, MacroContext, Handle, Input>;
|
|
693
849
|
get<const Path extends string, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<{}, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', true>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
694
850
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
695
851
|
}, const Handle extends InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>>>(path: Path, fn: Handle & Metadata['macro']): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'get', Path, Schema, {}, Handle>;
|
|
@@ -707,9 +863,9 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
707
863
|
* .post('/hook', { query: t.Object({ name: t.String() }) }, () => 'hi')
|
|
708
864
|
* ```
|
|
709
865
|
*/
|
|
710
|
-
post<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string
|
|
866
|
+
post<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & RouteHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
711
867
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
712
|
-
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
868
|
+
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handle extends ({} extends MacroContext ? InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>> : InlineHandler<NoInfer<Schema>, NoInfer<Decorator>, MacroContext>), UnknownKey extends PropertyKey = Exclude<keyof Input, HookObjectKey | keyof Metadata['macro']>>(path: Path, hook: LocalHook<Input, Schema & MacroContext, Decorator, Definitions['error'], keyof Metadata['parser']> & MacroOptionContext<Metadata['macroFn'], Schema, Decorator> & UnknownHookKey<UnknownKey>, fn: Handle): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'post', Path, Schema, MacroContext, Handle, Input>;
|
|
713
869
|
post<const Path extends string, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<{}, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', true>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
714
870
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
715
871
|
}, const Handle extends InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>>>(path: Path, fn: Handle & Metadata['macro']): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'post', Path, Schema, {}, Handle>;
|
|
@@ -727,9 +883,9 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
727
883
|
* .put('/hook', { query: t.Object({ name: t.String() }) }, () => 'hi')
|
|
728
884
|
* ```
|
|
729
885
|
*/
|
|
730
|
-
put<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string
|
|
886
|
+
put<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & RouteHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
731
887
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
732
|
-
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
888
|
+
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handle extends ({} extends MacroContext ? InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>> : InlineHandler<NoInfer<Schema>, NoInfer<Decorator>, MacroContext>), UnknownKey extends PropertyKey = Exclude<keyof Input, HookObjectKey | keyof Metadata['macro']>>(path: Path, hook: LocalHook<Input, Schema & MacroContext, Decorator, Definitions['error'], keyof Metadata['parser']> & MacroOptionContext<Metadata['macroFn'], Schema, Decorator> & UnknownHookKey<UnknownKey>, fn: Handle): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'put', Path, Schema, MacroContext, Handle, Input>;
|
|
733
889
|
put<const Path extends string, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<{}, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', true>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
734
890
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
735
891
|
}, const Handle extends InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>>>(path: Path, fn: Handle & Metadata['macro']): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'put', Path, Schema, {}, Handle>;
|
|
@@ -747,9 +903,9 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
747
903
|
* .patch('/hook', { query: t.Object({ name: t.String() }) }, () => 'hi')
|
|
748
904
|
* ```
|
|
749
905
|
*/
|
|
750
|
-
patch<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string
|
|
906
|
+
patch<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & RouteHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
751
907
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
752
|
-
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
908
|
+
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handle extends ({} extends MacroContext ? InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>> : InlineHandler<NoInfer<Schema>, NoInfer<Decorator>, MacroContext>), UnknownKey extends PropertyKey = Exclude<keyof Input, HookObjectKey | keyof Metadata['macro']>>(path: Path, hook: LocalHook<Input, Schema & MacroContext, Decorator, Definitions['error'], keyof Metadata['parser']> & MacroOptionContext<Metadata['macroFn'], Schema, Decorator> & UnknownHookKey<UnknownKey>, fn: Handle): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'patch', Path, Schema, MacroContext, Handle, Input>;
|
|
753
909
|
patch<const Path extends string, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<{}, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', true>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
754
910
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
755
911
|
}, const Handle extends InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>>>(path: Path, fn: Handle & Metadata['macro']): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'patch', Path, Schema, {}, Handle>;
|
|
@@ -767,9 +923,9 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
767
923
|
* .delete('/hook', { query: t.Object({ name: t.String() }) }, () => 'hi')
|
|
768
924
|
* ```
|
|
769
925
|
*/
|
|
770
|
-
delete<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string
|
|
926
|
+
delete<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & RouteHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
771
927
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
772
|
-
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
928
|
+
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handle extends ({} extends MacroContext ? InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>> : InlineHandler<NoInfer<Schema>, NoInfer<Decorator>, MacroContext>), UnknownKey extends PropertyKey = Exclude<keyof Input, HookObjectKey | keyof Metadata['macro']>>(path: Path, hook: LocalHook<Input, Schema & MacroContext, Decorator, Definitions['error'], keyof Metadata['parser']> & MacroOptionContext<Metadata['macroFn'], Schema, Decorator> & UnknownHookKey<UnknownKey>, fn: Handle): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'delete', Path, Schema, MacroContext, Handle, Input>;
|
|
773
929
|
delete<const Path extends string, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<{}, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', true>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
774
930
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
775
931
|
}, const Handle extends InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>>>(path: Path, fn: Handle & Metadata['macro']): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'delete', Path, Schema, {}, Handle>;
|
|
@@ -787,12 +943,32 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
787
943
|
* .options('/hook', { query: t.Object({ name: t.String() }) }, () => 'hi')
|
|
788
944
|
* ```
|
|
789
945
|
*/
|
|
790
|
-
options<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string
|
|
946
|
+
options<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & RouteHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
791
947
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
792
|
-
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
948
|
+
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handle extends ({} extends MacroContext ? InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>> : InlineHandler<NoInfer<Schema>, NoInfer<Decorator>, MacroContext>), UnknownKey extends PropertyKey = Exclude<keyof Input, HookObjectKey | keyof Metadata['macro']>>(path: Path, hook: LocalHook<Input, Schema & MacroContext, Decorator, Definitions['error'], keyof Metadata['parser']> & MacroOptionContext<Metadata['macroFn'], Schema, Decorator> & UnknownHookKey<UnknownKey>, fn: Handle): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'options', Path, Schema, MacroContext, Handle, Input>;
|
|
793
949
|
options<const Path extends string, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<{}, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', true>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
794
950
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
795
951
|
}, const Handle extends InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>>>(path: Path, fn: Handle & Metadata['macro']): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'options', Path, Schema, {}, Handle>;
|
|
952
|
+
/**
|
|
953
|
+
* ### query
|
|
954
|
+
* Register handler for path with method [QUERY]
|
|
955
|
+
*
|
|
956
|
+
* ---
|
|
957
|
+
* @example
|
|
958
|
+
* ```typescript
|
|
959
|
+
* import { Elysia, t } from 'elysia'
|
|
960
|
+
*
|
|
961
|
+
* new Elysia()
|
|
962
|
+
* .query('/', () => 'hi')
|
|
963
|
+
* .query('/hook', { query: t.Object({ name: t.String() }) }, () => 'hi')
|
|
964
|
+
* ```
|
|
965
|
+
*/
|
|
966
|
+
query<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & RouteHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
967
|
+
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
968
|
+
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handle extends ({} extends MacroContext ? InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>> : InlineHandler<NoInfer<Schema>, NoInfer<Decorator>, MacroContext>), UnknownKey extends PropertyKey = Exclude<keyof Input, HookObjectKey | keyof Metadata['macro']>>(path: Path, hook: LocalHook<Input, Schema & MacroContext, Decorator, Definitions['error'], keyof Metadata['parser']> & MacroOptionContext<Metadata['macroFn'], Schema, Decorator> & UnknownHookKey<UnknownKey>, fn: Handle): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'query', Path, Schema, MacroContext, Handle, Input>;
|
|
969
|
+
query<const Path extends string, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<{}, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', true>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
970
|
+
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
971
|
+
}, const Handle extends InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>>>(path: Path, fn: Handle & Metadata['macro']): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'query', Path, Schema, {}, Handle>;
|
|
796
972
|
/**
|
|
797
973
|
* ### head
|
|
798
974
|
* Register handler for path with method [HEAD]
|
|
@@ -807,9 +983,9 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
807
983
|
* .head('/hook', { query: t.Object({ name: t.String() }) }, () => 'hi')
|
|
808
984
|
* ```
|
|
809
985
|
*/
|
|
810
|
-
head<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string
|
|
986
|
+
head<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & RouteHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
811
987
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
812
|
-
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
988
|
+
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handle extends ({} extends MacroContext ? InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>> : InlineHandler<NoInfer<Schema>, NoInfer<Decorator>, MacroContext>), UnknownKey extends PropertyKey = Exclude<keyof Input, HookObjectKey | keyof Metadata['macro']>>(path: Path, hook: LocalHook<Input, Schema & MacroContext, Decorator, Definitions['error'], keyof Metadata['parser']> & MacroOptionContext<Metadata['macroFn'], Schema, Decorator> & UnknownHookKey<UnknownKey>, fn: Handle): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'head', Path, Schema, MacroContext, Handle, Input>;
|
|
813
989
|
head<const Path extends string, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<{}, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', true>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
814
990
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
815
991
|
}, const Handle extends InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>>>(path: Path, fn: Handle & Metadata['macro']): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, 'head', Path, Schema, {}, Handle>;
|
|
@@ -826,47 +1002,50 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
826
1002
|
* .method('Elysia', '/', 'hi')
|
|
827
1003
|
* ```
|
|
828
1004
|
*/
|
|
829
|
-
method<const Method extends HTTPMethod, const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string
|
|
1005
|
+
method<const Method extends HTTPMethod, const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & RouteHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
830
1006
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
831
|
-
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
1007
|
+
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handle extends ({} extends MacroContext ? InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>> : InlineHandler<NoInfer<Schema>, NoInfer<Decorator>, MacroContext>), UnknownKey extends PropertyKey = Exclude<keyof Input, HookObjectKey | keyof Metadata['macro']>>(method: Method, path: Path, hook: LocalHook<Input, Schema & MacroContext, Decorator, Definitions['error'], keyof Metadata['parser']> & MacroOptionContext<Metadata['macroFn'], Schema, Decorator> & UnknownHookKey<UnknownKey>, fn: Handle): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Method, Path, Schema, MacroContext, Handle, Input>;
|
|
832
1008
|
method<const Method extends HTTPMethod, const Path extends string, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<{}, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', true>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
833
1009
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
834
1010
|
}, const Handle extends InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>>>(method: Method, path: Path, fn: Handle & Metadata['macro']): AddRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Method, Path, Schema, {}, Handle>;
|
|
835
1011
|
all<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
836
1012
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
837
|
-
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'],
|
|
1013
|
+
}, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handle extends ({} extends MacroContext ? InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>> : InlineHandler<NoInfer<Schema>, NoInfer<Decorator>, MacroContext>), UnknownKey extends PropertyKey = Exclude<keyof Input, HookObjectKey | keyof Metadata['macro']>>(path: Path, hook: LocalHook<Input, Schema & MacroContext, Decorator, Definitions['error'], keyof Metadata['parser']> & MacroOptionContext<Metadata['macroFn'], Schema, Decorator> & UnknownHookKey<UnknownKey>, fn: Handle): this;
|
|
838
1014
|
all<const Path extends string, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<{}, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', true>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const Decorator extends Singleton & {
|
|
839
1015
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
840
1016
|
}, const Handle extends InlineHandlerNonMacro<NoInfer<Schema>, NoInfer<Decorator>>>(path: Path, fn: Handle & Metadata['macro']): this;
|
|
841
1017
|
/**
|
|
842
1018
|
* ### ws
|
|
843
|
-
* Register a WebSocket route
|
|
1019
|
+
* Register a WebSocket route as `(path, options)`, `(path, handler)`, or `(path, options, handler)`.
|
|
1020
|
+
* Requires `.use(websocket())` from `elysia/websocket`.
|
|
844
1021
|
*/
|
|
845
|
-
ws<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string
|
|
846
|
-
derive: Ephemeral['derive'] & Volatile['derive'] & MacroContext['
|
|
847
|
-
}>
|
|
848
|
-
|
|
849
|
-
|
|
1022
|
+
ws<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & WSHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>)>(path: Path, options: WSLocalHook<Input, Schema & MacroContext, Singleton & {
|
|
1023
|
+
derive: Ephemeral['derive'] & Volatile['derive'] & MacroContext['derive'];
|
|
1024
|
+
}> & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
1025
|
+
derive: {};
|
|
1026
|
+
}>>): AddWSRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Path, Schema, MacroContext, void, Input['error'], Input['beforeHandle']>;
|
|
1027
|
+
ws<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string>, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handler extends WSMessageHandler<Schema & MacroContext, Singleton & {
|
|
1028
|
+
derive: Ephemeral['derive'] & Volatile['derive'] & MacroContext['derive'];
|
|
850
1029
|
}>>(path: Path, handler: Handler): AddWSRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Path, Schema, MacroContext, WSHandlerResponse<Handler>>;
|
|
851
|
-
ws<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string
|
|
852
|
-
derive: Ephemeral['derive'] & Volatile['derive'] & MacroContext['
|
|
1030
|
+
ws<const Path extends string, const Input extends Metadata['macro'] & InputSchema<keyof Definitions['typebox'] & string> & WSHookCapture, const Schema extends IntersectIfObjectSchema<MergeSchema<UnwrapRoute<Input, Definitions['typebox'], JoinPath<BasePath, Path>>, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, '', undefined extends Input['params'] ? true : false>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>>, const MacroContext extends ({} extends Metadata['macroFn'] ? {} : MacroToContext<Metadata['macroFn'], Input, Definitions['typebox']>), const Handler extends WSMessageHandler<Schema & MacroContext, Singleton & {
|
|
1031
|
+
derive: Ephemeral['derive'] & Volatile['derive'] & MacroContext['derive'];
|
|
853
1032
|
}>>(path: Path, options: WSLocalHook<Input, Schema & MacroContext, Singleton & {
|
|
854
|
-
derive: Ephemeral['derive'] & Volatile['derive'] & MacroContext['
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
mount(path: string, handle: (request: Request) => MaybePromise<Response
|
|
860
|
-
detail?: DocumentDecoration;
|
|
861
|
-
}): this;
|
|
1033
|
+
derive: Ephemeral['derive'] & Volatile['derive'] & MacroContext['derive'];
|
|
1034
|
+
}> & MacroOptionContext<Metadata['macroFn'], Schema, GuardHookSingleton<Singleton, Ephemeral, Volatile, {
|
|
1035
|
+
derive: {};
|
|
1036
|
+
}>>, handler: Handler): AddWSRoute<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, Volatile, Path, Schema, MacroContext, WSHandlerResponse<Handler>, Input['error'], Input['beforeHandle']>;
|
|
1037
|
+
mount(handle: (request: Request) => MaybePromise<Response>): this;
|
|
1038
|
+
mount(path: string, handle: (request: Request) => MaybePromise<Response>): this;
|
|
862
1039
|
/**
|
|
863
1040
|
* Force all route handlers to compile immediately (sets `precompile: true`
|
|
864
1041
|
* on the config and triggers a fresh build of the fetch handler).
|
|
865
1042
|
*/
|
|
866
1043
|
compile(): this;
|
|
867
|
-
handler(index: number, immediate?: boolean, route?: InternalRoute,
|
|
868
|
-
|
|
869
|
-
|
|
1044
|
+
handler(index: number, immediate?: boolean, route?: InternalRoute, aliases?: StaticMapAliases, table?: RouteTable): CompiledHandler;
|
|
1045
|
+
'~dispatch'(index: number, context: any): MaybePromise<Response>;
|
|
1046
|
+
private fetchFn?;
|
|
1047
|
+
get fetch(): (request: Request) => MaybePromise<Response>;
|
|
1048
|
+
private _handle?;
|
|
870
1049
|
get handle(): (url: string | Request, options?: RequestInit) => Promise<Response>;
|
|
871
1050
|
listen(options: string | number | Partial<Serve>, callback?: ListenCallback): this;
|
|
872
1051
|
/**
|
|
@@ -878,36 +1057,37 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
878
1057
|
*
|
|
879
1058
|
* new Elysia()
|
|
880
1059
|
* .wrap(
|
|
881
|
-
* (fetch) => (request) =>
|
|
882
|
-
* ctx.run({ counter: 0 }, () => fetch(request))
|
|
1060
|
+
* (fetch) => (request, ...rest) =>
|
|
1061
|
+
* ctx.run({ counter: 0 }, () => fetch(request, ...rest))
|
|
883
1062
|
* )
|
|
884
1063
|
* .get('/', () => ctx.getStore())
|
|
885
1064
|
* ```
|
|
886
1065
|
*/
|
|
887
1066
|
wrap<T extends (...params: any) => MaybePromise<Response> = (request: Request, ...rest: any[]) => MaybePromise<Response>>(callback: WrapFn<T>): this;
|
|
888
1067
|
/**
|
|
889
|
-
* ###
|
|
1068
|
+
* ### onStop | Life cycle event
|
|
890
1069
|
* Called after server stop serving request
|
|
891
1070
|
*
|
|
892
1071
|
* ---
|
|
893
1072
|
* @example
|
|
894
1073
|
* ```typescript
|
|
895
1074
|
* new Elysia()
|
|
896
|
-
* .
|
|
1075
|
+
* .onStop((app) => {
|
|
897
1076
|
* closeDatabase()
|
|
898
1077
|
* })
|
|
899
1078
|
* ```
|
|
900
1079
|
*/
|
|
901
|
-
|
|
1080
|
+
onStop(handler: MaybeArray<GracefulHandler<this>>): this;
|
|
902
1081
|
/**
|
|
903
|
-
* Stop the underlying server (if any),
|
|
904
|
-
*
|
|
1082
|
+
* Stop the underlying server (if any), then run every `onStop` handler
|
|
1083
|
+
*
|
|
1084
|
+
* Awaiting `stop()` from inside an `onStart`, `onStop` or WebSocket lifecycle
|
|
1085
|
+
* callback is only supported while that callback is still synchronous
|
|
905
1086
|
*
|
|
906
|
-
* @param closeActiveConnections Pass `true` to terminate
|
|
907
|
-
*
|
|
908
|
-
* draining gracefully.
|
|
1087
|
+
* @param closeActiveConnections Pass `true` to terminate active
|
|
1088
|
+
* transports. Omit (or pass `false`) to drain safely.
|
|
909
1089
|
*/
|
|
910
|
-
stop(closeActiveConnections?: boolean): Promise<void> |
|
|
1090
|
+
stop(closeActiveConnections?: boolean): Promise<void> | undefined;
|
|
911
1091
|
}
|
|
912
1092
|
//#endregion
|
|
913
1093
|
export { AnyElysia, Elysia };
|