elysia 2.0.0-exp.14 → 2.0.0-exp.16

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.
@@ -2,7 +2,6 @@ import { StatusMap } from "../constants.js";
2
2
  import { BaseCookie } from "../cookie/types.js";
3
3
  import { HTTPHeaders } from "../types.js";
4
4
  import { Context } from "../context.js";
5
-
6
5
  //#region src/adapter/utils.d.ts
7
6
  declare function handleFile(response: File | Blob, set?: Context['set'], request?: Request): Response;
8
7
  declare function parseSetCookies(headers: Headers, setCookie: string[]): Headers;
package/dist/base.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ElysiaStatus } from "./error.js";
2
2
  import { TraceHandler } from "./trace.js";
3
- import { AnySchema } from "./type/types.js";
4
3
  import { ListenCallback, Serve, Server } from "./universal/server.js";
5
- import { AddRoute, AddWSRoute, AfterHandler, AfterResponseHandler, AnyErrorConstructor, AnyLocalHook, BodyHandler, CompiledHandler, CreateEden, DefaultEphemeral, DefaultMetadata, DefaultSingleton, DefinitionBase, DocumentDecoration, ElysiaConfig, ElysiaHandlerToResponseSchemaAmbiguous, EphemeralType, ErrorDefinitionEntry, ErrorHandler, EventScope, ExcludeElysiaResponse, ExtractErrorFromHandle, GracefulHandler, GuardLocalHook, HTTPMethod, InlineHandler, InlineHandlerNonMacro, InputSchema, InputSchemaKey, InternalRoute, IntersectIfObjectSchema, JoinPath, LocalHook, Macro, MacroToContext, MacroToProperty, MapResponse, MaybeArray, MaybePromise, MergeElysiaInstances, MergeSchema, MergeScopedSchemas, MetadataBase, NonResolvableMacroKey, ObjectMacroDefs, OptionalHandler, PreHandler, Prettify, PublicRoute, ResolveRouteErrors, RouteBase, SingletonBase, TransformHandler, UnionResponseStatus, UnwrapRoute, WrapFn } from "./types.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, GracefulHandler, GuardLocalHook, HTTPMethod, InlineHandler, InlineHandlerNonMacro, InputSchema, InputSchemaKey, InternalRoute, IntersectIfObjectSchema, JoinPath, LocalHook, Macro, MacroSchemaChannel, MacroToContext, MacroToProperty, MapResponse, MaybeArray, MaybePromise, MergeElysiaInstances, MergeSchema, MergeScopedSchemas, MetadataBase, NonResolvableMacroKey, ObjectMacroDefs, OptionalHandler, PreHandler, Prettify, PublicRoute, ResolveRouteErrors, RouteBase, SingletonBase, TransformHandler, UnionResponseStatus, UnwrapRoute, WrapFn } from "./types.js";
5
+ import { AnySchema } from "./type/types.js";
6
6
  import { ChainNode } from "./utils.js";
7
7
  import { Context, ErrorContext, LifecycleContext } from "./context.js";
8
8
  import { WSHandlerResponse, WSLocalHook, WSMessageHandler } from "./ws/types.js";
@@ -685,7 +685,7 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
685
685
  * .get('/', ({ user }) => user, { auth: true, role: 'admin' })
686
686
  * ```
687
687
  */
688
- macro<const Body, const Headers, const Query, const Params, const Cookie, const NewMacro>(macro: ObjectMacroDefs<Body, Headers, Query, Params, Cookie, NewMacro, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>, Singleton & {
688
+ macro<const Body extends MacroSchemaChannel<Definitions>, const Headers extends MacroSchemaChannel<Definitions>, const Query extends MacroSchemaChannel<Definitions>, const Params extends MacroSchemaChannel<Definitions>, const Cookie extends MacroSchemaChannel<Definitions>, const NewMacro>(macro: ObjectMacroDefs<Body, Headers, Query, Params, Cookie, NewMacro, MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>>, MergeScopedSchemas<Metadata['schemas'], Ephemeral['schemas'], Volatile['schemas']>, Singleton & {
689
689
  derive: Partial<Ephemeral['derive'] & Volatile['derive']>;
690
690
  }, Definitions, Metadata['macro']>): Elysia<BasePath, Scope, Singleton, Definitions, {
691
691
  schema: Metadata['schema'];
package/dist/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import { StatusMap, StatusMapBack } from "./constants.js";
2
- import { ElysiaError, ElysiaStatus, InternalServerError, InvalidCookieSignature, NotFound, ParseError, ValidationError, status, validationDetail } from "./error.js";
2
+ import { ElysiaError, ElysiaStatus, InternalServerError, InvalidCookieSignature, NotFound, ParseError, SelectiveStatus, ValidationError, status, validationDetail } from "./error.js";
3
+ import { BaseCookie, CookieOptions } from "./cookie/types.js";
4
+ import { Cookie } from "./cookie/cookie.js";
3
5
  import { ElysiaFile, file } from "./universal/file.js";
4
- import { TraceEvent, TraceHandler, TraceListener, TraceProcess, TraceStream } from "./trace.js";
6
+ import { env } from "./universal/env.js";
7
+ import { Server } from "./universal/server.js";
8
+ import { HTTPHeaders, SSEPayload, UnwrapSchema } from "./types.js";
5
9
  import { AnySchema, BaseSchema, StandardJSONSchemaV1Like, StandardSchemaV1Like } from "./type/types.js";
6
10
  import { FileTypeDetector, fileType, setFileTypeDetector } from "./type/elysia/file-type.js";
7
11
  import { setupTypebox } from "./type/compat.js";
@@ -9,9 +13,7 @@ import { Capture, Compiled } from "./compile/aot.js";
9
13
  import { MultiValidator, StandardValidator, Validator } from "./validator/index.js";
10
14
  import { TypeBoxValidator } from "./type/validator/index.js";
11
15
  import { TypeSystem, t } from "./type/index.js";
12
- import { env } from "./universal/env.js";
13
- import { SSEPayload } from "./types.js";
14
- import { form, redirect, sse } from "./utils.js";
16
+ import { form, prefix, redirect, sse } from "./utils.js";
15
17
  import { Context, ErrorContext, createBaseContext, createContext } from "./context.js";
16
18
  import { Elysia } from "./base.js";
17
- export { type AnySchema, type BaseSchema, Compiled, type Context, Elysia, Elysia as default, ElysiaError, ElysiaFile, ElysiaStatus, type ErrorContext, type FileTypeDetector, InternalServerError, InvalidCookieSignature, Capture as Manifest, MultiValidator, NotFound, ParseError, type SSEPayload, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, StandardValidator, StatusMap, StatusMapBack, type TraceEvent, type TraceHandler, type TraceListener, type TraceProcess, type TraceStream, TypeBoxValidator, TypeSystem, ValidationError, Validator, createBaseContext, createContext, env, file, fileType, form, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
19
+ export { type AnySchema, type BaseCookie, type BaseSchema, Compiled, type Context, type Cookie, type CookieOptions, Elysia, Elysia as default, ElysiaError, ElysiaFile, ElysiaStatus, type ErrorContext, type FileTypeDetector, type HTTPHeaders, InternalServerError, InvalidCookieSignature, Capture as Manifest, MultiValidator, NotFound, ParseError, type SSEPayload, type SelectiveStatus, type Server, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, StandardValidator, StatusMap, StatusMapBack, TypeBoxValidator, TypeSystem, type UnwrapSchema, ValidationError, Validator, createBaseContext, createContext, env, file, fileType, form, prefix, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ exports.env = require_universal_env.env;
49
49
  exports.file = require_universal_file.file;
50
50
  exports.fileType = require_type_elysia_file_type.fileType;
51
51
  exports.form = require_utils.form;
52
+ exports.prefix = require_utils.prefix;
52
53
  exports.redirect = require_utils.redirect;
53
54
  exports.setFileTypeDetector = require_type_elysia_file_type.setFileTypeDetector;
54
55
  exports.setupTypebox = require_type_compat.setupTypebox;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { StatusMap, StatusMapBack } from "./constants.mjs";
2
2
  import { ElysiaFile, file } from "./universal/file.mjs";
3
- import { form, redirect, sse } from "./utils.mjs";
3
+ import { form, prefix, redirect, sse } from "./utils.mjs";
4
4
  import { env } from "./universal/env.mjs";
5
5
  import { ElysiaError, ElysiaStatus, InternalServerError, InvalidCookieSignature, NotFound, ParseError, ValidationError, status, validationDetail } from "./error.mjs";
6
6
  import { createBaseContext, createContext } from "./context.mjs";
@@ -16,4 +16,4 @@ import { TypeSystem, t } from "./type/index.mjs";
16
16
  var src_default = Elysia;
17
17
 
18
18
  //#endregion
19
- export { Compiled, Elysia, ElysiaError, ElysiaFile, ElysiaStatus, InternalServerError, InvalidCookieSignature, Capture as Manifest, MultiValidator, NotFound, ParseError, StandardValidator, StatusMap, StatusMapBack, TypeBoxValidator, TypeSystem, ValidationError, Validator, createBaseContext, createContext, src_default as default, env, file, fileType, form, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
19
+ export { Compiled, Elysia, ElysiaError, ElysiaFile, ElysiaStatus, InternalServerError, InvalidCookieSignature, Capture as Manifest, MultiValidator, NotFound, ParseError, StandardValidator, StatusMap, StatusMapBack, TypeBoxValidator, TypeSystem, ValidationError, Validator, createBaseContext, createContext, src_default as default, env, file, fileType, form, prefix, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
@@ -17,7 +17,17 @@ import { BunPlugin } from "bun";
17
17
  * outdir: 'dist',
18
18
  * plugins: [aot('src/index.ts')]
19
19
  * })
20
+ *
21
+ * process.exit(0)
20
22
  * ```
23
+ *
24
+ * The plugin imports your entry to capture the compiled app, running its
25
+ * top-level code. `.listen()` is auto-skipped during build (gated on
26
+ * `ELYSIA_AOT_BUILD`), but any other import-time handle — a DB pool,
27
+ * `setInterval`, a queue consumer — keeps the process alive after the bundle
28
+ * is written. End the build script with `process.exit(0)` (the bundle is
29
+ * already on disk), or gate the side effect with
30
+ * `if (!process.env.ELYSIA_AOT_BUILD)`.
21
31
  */
22
32
  declare const aot: (entry: string, options?: ElysiaAotOptions) => BunPlugin;
23
33
  //#endregion
@@ -28,7 +28,17 @@ const realPath = (path) => {
28
28
  * outdir: 'dist',
29
29
  * plugins: [aot('src/index.ts')]
30
30
  * })
31
+ *
32
+ * process.exit(0)
31
33
  * ```
34
+ *
35
+ * The plugin imports your entry to capture the compiled app, running its
36
+ * top-level code. `.listen()` is auto-skipped during build (gated on
37
+ * `ELYSIA_AOT_BUILD`), but any other import-time handle — a DB pool,
38
+ * `setInterval`, a queue consumer — keeps the process alive after the bundle
39
+ * is written. End the build script with `process.exit(0)` (the bundle is
40
+ * already on disk), or gate the side effect with
41
+ * `if (!process.env.ELYSIA_AOT_BUILD)`.
32
42
  */
33
43
  const aot = (entry, options) => ({
34
44
  name: "elysia-aot",
@@ -26,7 +26,17 @@ const realPath = (path) => {
26
26
  * outdir: 'dist',
27
27
  * plugins: [aot('src/index.ts')]
28
28
  * })
29
+ *
30
+ * process.exit(0)
29
31
  * ```
32
+ *
33
+ * The plugin imports your entry to capture the compiled app, running its
34
+ * top-level code. `.listen()` is auto-skipped during build (gated on
35
+ * `ELYSIA_AOT_BUILD`), but any other import-time handle — a DB pool,
36
+ * `setInterval`, a queue consumer — keeps the process alive after the bundle
37
+ * is written. End the build script with `process.exit(0)` (the bundle is
38
+ * already on disk), or gate the side effect with
39
+ * `if (!process.env.ELYSIA_AOT_BUILD)`.
30
40
  */
31
41
  const aot = (entry, options) => ({
32
42
  name: "elysia-aot",
@@ -16,7 +16,17 @@ import { ElysiaAotOptions } from "./core.js";
16
16
  * outfile: 'dist/index.js',
17
17
  * plugins: [elysiaAot('src/index.ts')]
18
18
  * })
19
+ *
20
+ * process.exit(0)
19
21
  * ```
22
+ *
23
+ * The plugin imports your entry to capture the compiled app, running its
24
+ * top-level code. `.listen()` is auto-skipped during build (gated on
25
+ * `ELYSIA_AOT_BUILD`), but any other import-time handle — a DB pool,
26
+ * `setInterval`, a queue consumer — keeps the process alive after the bundle
27
+ * is written. End the build script with `process.exit(0)` (the bundle is
28
+ * already on disk), or gate the side effect with
29
+ * `if (!process.env.ELYSIA_AOT_BUILD)`.
20
30
  */
21
31
  declare const aot: (entry: string, options?: ElysiaAotOptions) => {
22
32
  name: string;
@@ -30,7 +30,17 @@ const realPath = (path) => {
30
30
  * outfile: 'dist/index.js',
31
31
  * plugins: [elysiaAot('src/index.ts')]
32
32
  * })
33
+ *
34
+ * process.exit(0)
33
35
  * ```
36
+ *
37
+ * The plugin imports your entry to capture the compiled app, running its
38
+ * top-level code. `.listen()` is auto-skipped during build (gated on
39
+ * `ELYSIA_AOT_BUILD`), but any other import-time handle — a DB pool,
40
+ * `setInterval`, a queue consumer — keeps the process alive after the bundle
41
+ * is written. End the build script with `process.exit(0)` (the bundle is
42
+ * already on disk), or gate the side effect with
43
+ * `if (!process.env.ELYSIA_AOT_BUILD)`.
34
44
  */
35
45
  const aot = (entry, options) => ({
36
46
  name: "elysia-aot",
@@ -28,7 +28,17 @@ const realPath = (path) => {
28
28
  * outfile: 'dist/index.js',
29
29
  * plugins: [elysiaAot('src/index.ts')]
30
30
  * })
31
+ *
32
+ * process.exit(0)
31
33
  * ```
34
+ *
35
+ * The plugin imports your entry to capture the compiled app, running its
36
+ * top-level code. `.listen()` is auto-skipped during build (gated on
37
+ * `ELYSIA_AOT_BUILD`), but any other import-time handle — a DB pool,
38
+ * `setInterval`, a queue consumer — keeps the process alive after the bundle
39
+ * is written. End the build script with `process.exit(0)` (the bundle is
40
+ * already on disk), or gate the side effect with
41
+ * `if (!process.env.ELYSIA_AOT_BUILD)`.
32
42
  */
33
43
  const aot = (entry, options) => ({
34
44
  name: "elysia-aot",
@@ -23,6 +23,13 @@ interface ElysiaAotVitePlugin {
23
23
  * plugins: [aot('src/index.ts')]
24
24
  * })
25
25
  * ```
26
+ *
27
+ * The plugin imports your entry to capture the compiled app, running its
28
+ * top-level code. `.listen()` is auto-skipped during build (gated on
29
+ * `ELYSIA_AOT_BUILD`), but any other import-time handle — a DB pool,
30
+ * `setInterval`, a queue consumer — can keep the build process alive after
31
+ * the bundle is written. Gate the side effect with
32
+ * `if (!process.env.ELYSIA_AOT_BUILD)`.
26
33
  */
27
34
  declare const aot: (entry: string, options?: ElysiaAotOptions) => ElysiaAotVitePlugin;
28
35
  //#endregion
@@ -18,6 +18,13 @@ const VIRTUAL = "\0elysia/compiled";
18
18
  * plugins: [aot('src/index.ts')]
19
19
  * })
20
20
  * ```
21
+ *
22
+ * The plugin imports your entry to capture the compiled app, running its
23
+ * top-level code. `.listen()` is auto-skipped during build (gated on
24
+ * `ELYSIA_AOT_BUILD`), but any other import-time handle — a DB pool,
25
+ * `setInterval`, a queue consumer — can keep the build process alive after
26
+ * the bundle is written. Gate the side effect with
27
+ * `if (!process.env.ELYSIA_AOT_BUILD)`.
21
28
  */
22
29
  const aot = (entry, options) => {
23
30
  const entryPath = require_plugin_core.resolveEntry(entry);
@@ -17,6 +17,13 @@ const VIRTUAL = "\0elysia/compiled";
17
17
  * plugins: [aot('src/index.ts')]
18
18
  * })
19
19
  * ```
20
+ *
21
+ * The plugin imports your entry to capture the compiled app, running its
22
+ * top-level code. `.listen()` is auto-skipped during build (gated on
23
+ * `ELYSIA_AOT_BUILD`), but any other import-time handle — a DB pool,
24
+ * `setInterval`, a queue consumer — can keep the build process alive after
25
+ * the bundle is written. Gate the side effect with
26
+ * `if (!process.env.ELYSIA_AOT_BUILD)`.
20
27
  */
21
28
  const aot = (entry, options) => {
22
29
  const entryPath = resolveEntry(entry);
@@ -1,5 +1,5 @@
1
- import { FileType, FileUnit } from "../types.js";
2
1
  import { MaybeArray, MaybePromise } from "../../types.js";
2
+ import { FileType, FileUnit } from "../types.js";
3
3
 
4
4
  //#region src/type/elysia/file-type.d.ts
5
5
  type FileTypeDetector = (file: File) => MaybePromise<string | {
@@ -1,6 +1,6 @@
1
+ import { MaybePromise } from "../../types.js";
1
2
  import { Validator as Validator$1, ValidatorOptions } from "../../validator/index.js";
2
3
  import { TypeBoxValidatorCache } from "./validator-cache.js";
3
- import { MaybePromise } from "../../types.js";
4
4
  import { Static, StaticDecode, StaticEncode, TAny, TSchema } from "typebox/type";
5
5
  import { TLocalizedValidationError } from "typebox/error";
6
6
  import { Validator } from "typebox/schema";
package/dist/types.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import { MethodMap, StatusMapBack } from "./constants.js";
2
2
  import { ElysiaError, ElysiaStatus } from "./error.js";
3
+ import { CookieOptions } from "./cookie/types.js";
3
4
  import { ElysiaFile } from "./universal/file.js";
4
5
  import { TraceEvent, TraceListener } from "./trace.js";
5
- import { CookieOptions } from "./cookie/types.js";
6
- import { AnySchema, StandardSchemaV1Like, TypeBoxSchema } from "./type/types.js";
7
6
  import { Serve } from "./universal/server.js";
8
7
  import { ElysiaAdapter } from "./adapter/index.js";
8
+ import { AnySchema, StandardSchemaV1Like, TypeBoxSchema } from "./type/types.js";
9
9
  import { ChainNode } from "./utils.js";
10
10
  import { Context, ErrorContext, LifecycleContext, PreContext } from "./context.js";
11
11
  import { WebSocketHandler } from "./ws/types.js";
12
12
  import { AnyElysia, Elysia } from "./base.js";
13
- import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from "typebox";
14
13
  import { Instruction } from "exact-mirror";
14
+ import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from "typebox";
15
15
  import { OpenAPIV3 } from "openapi-types";
16
16
 
17
17
  //#region src/types.d.ts
@@ -742,6 +742,18 @@ type MacroDefSchema<K, MBody, MHeaders, MQuery, MParams, MCookie> = {
742
742
  cookie: AsMacroSchemaField<K extends keyof MCookie ? MCookie[K] : undefined>;
743
743
  response: undefined;
744
744
  };
745
+ /**
746
+ * Upper bound for a macro definition's schema channel (`body`/`headers`/…):
747
+ * a registered model name or an inline schema.
748
+ *
749
+ * Used as the `const Body extends …` constraint on `.macro()`. It does not
750
+ * restrict (valid inputs already satisfy it) — it stops `Body[K]` from being a
751
+ * bare `unknown`, which is what lets the `| Name` in the field surface model
752
+ * names to autocomplete (a `unknown | Name` union collapses to `unknown`).
753
+ * `const` still narrows `Body[K]` to the typed literal for `UnwrapRoute`.
754
+ */
755
+ type MacroSchemaChannel<Definitions extends DefinitionBase> = Record<keyof any, AnySchema | (keyof Definitions['typebox'] & string)>;
756
+ type MacroChannel<Channel, Key extends keyof InputSchema, Definitions extends DefinitionBase> = { [K in keyof Channel]: MaybeValueOrVoidFunction<{ [F in Key]?: Channel[K] | (keyof Definitions['typebox'] & string) } & Record<string, unknown>> };
745
757
  /**
746
758
  * Parameter type of the object-form `.macro({ name: definition })`
747
759
  *
@@ -754,17 +766,7 @@ type MacroDefSchema<K, MBody, MHeaders, MQuery, MParams, MCookie> = {
754
766
  * still flow into `N` (the verbatim definitions, stored in
755
767
  * `Metadata['macroFn']` for the consuming route)
756
768
  */
757
- type ObjectMacroDefs<Body, Headers, Query, Params, Cookie, N, AmbientSchema extends RouteSchema, ScopedSchemas extends RouteSchema, Singleton extends SingletonBase, Definitions extends DefinitionBase, MacroNames extends BaseMacro> = { [K in keyof Body]: MaybeValueOrVoidFunction<{
758
- body?: Body[K];
759
- }> } & { [K in keyof Headers]: MaybeValueOrVoidFunction<{
760
- headers?: Headers[K];
761
- }> } & { [K in keyof Query]: MaybeValueOrVoidFunction<{
762
- query?: Query[K];
763
- }> } & { [K in keyof Params]: MaybeValueOrVoidFunction<{
764
- params?: Params[K];
765
- }> } & { [K in keyof Cookie]: MaybeValueOrVoidFunction<{
766
- cookie?: Cookie[K];
767
- }> } & { [K in keyof N]: MaybeValueOrVoidFunction<MacroProperty<MacroNames & InputSchema<keyof Definitions['typebox'] & string>, IntersectIfObjectSchema<MergeSchema<UnwrapMacroSchema<MacroDefSchema<K, Body, Headers, Query, Params, Cookie>, Definitions['typebox']>, AmbientSchema>, ScopedSchemas>, Singleton, Definitions['error']>> } & { [K in keyof N]: N[K] extends ((...a: any[]) => any) ? unknown : string extends keyof N[K] ? unknown : { [P in Exclude<keyof N[K], MacroPropertyKey | InputSchemaKey | keyof MacroNames | keyof N>]: `Unknown macro property '${P & string}'` } } & N;
769
+ type ObjectMacroDefs<Body, Headers, Query, Params, Cookie, N, AmbientSchema extends RouteSchema, ScopedSchemas extends RouteSchema, Singleton extends SingletonBase, Definitions extends DefinitionBase, MacroNames extends BaseMacro> = MacroChannel<Body, 'body', Definitions> & MacroChannel<Headers, 'headers', Definitions> & MacroChannel<Query, 'query', Definitions> & MacroChannel<Params, 'params', Definitions> & MacroChannel<Cookie, 'cookie', Definitions> & { [K in keyof N]: MaybeValueOrVoidFunction<MacroProperty<MacroNames & InputSchema<keyof Definitions['typebox'] & string>, IntersectIfObjectSchema<MergeSchema<UnwrapMacroSchema<MacroDefSchema<K, Body, Headers, Query, Params, Cookie>, Definitions['typebox']>, AmbientSchema>, ScopedSchemas>, Singleton, Definitions['error']>> } & { [K in keyof N]: N[K] extends ((...a: any[]) => any) ? unknown : string extends keyof N[K] ? unknown : { [P in Exclude<keyof N[K], MacroPropertyKey | InputSchemaKey | keyof MacroNames | keyof N>]: `Unknown macro property '${P & string}'` } } & N;
768
770
  type CreateEden<Path extends string, Property extends Record<string, unknown> = {}> = Path extends `/${infer Rest}` ? _CreateEden<Rest, Property> : Path extends '' | '/' ? Property : _CreateEden<Path, Property>;
769
771
  type _CreateEden<Path extends string, Property extends Record<string, unknown> = {}> = Path extends `${infer Start}/${infer Rest}` ? { [x in Start]: _CreateEden<Rest, Property> } : Path extends '' ? Property : { [x in Path]: Property };
770
772
  type CreateEdenResponse<Path extends string, Schema extends RouteSchema, MacroContext extends RouteSchema, Res extends PossibleResponse, Err extends Error = never> = RouteSchema extends MacroContext ? {
@@ -883,4 +885,4 @@ type AddWSRoute<BasePath extends string, Scope extends EventScope, Singleton ext
883
885
  subscribe: CreateWSEdenResponse<Path, Schema, MacroContext, ComposeElysiaResponse<Schema & MacroContext & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], Response, UnionResponseStatus<Metadata['response'], UnionResponseStatus<Ephemeral['response'], UnionResponseStatus<Volatile['response'], MacroContext['return'] & {}>>>, [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']]>>;
884
886
  }>, Ephemeral, Volatile>;
885
887
  //#endregion
886
- export { AddRoute, AddWSRoute, AfterHandler, AfterResponseHandler, AnyErrorConstructor, AnyLocalHook, type AnySchema, AnyWSLocalHook, AppEvent, AppHook, BaseMacro, BodyHandler, BunHTMLBundlelike, CompiledHandler, ComposeElysiaResponse, ContentType, ContextAppendType, CreateEden, CreateEdenResponse, CreateWSEdenResponse, DefaultEphemeral, DefaultMetadata, DefaultSingleton, DefinitionBase, DocumentDecoration, ElysiaConfig, ElysiaFormData, ElysiaHandlerToResponseSchema, ElysiaHandlerToResponseSchemaAmbiguous, ElysiaHandlerToResponseSchemas, EmptyInputSchema, EphemeralType, Equal, ErrorDefinition, ErrorDefinitionEntry, ErrorHandler, ErrorHandlerResponseSchema, EventFn, EventScope, ExcludeElysiaResponse, ExtractErrorFromHandle, ExtractReturnedError, GetPathParameter, GracefulHandler, GuardLocalHook, GuardSchemaType, HTTPHeaders, HTTPMethod, Handler, InlineHandler, InlineHandlerNonMacro, InlineHandlerResponse, InlineResponse, InlineSchemaResponse, InputSchema, InputSchemaKey, InternalRoute, IntersectIfObject, IntersectIfObjectSchema, IsAny, IsNever, IsTuple, IsUnknown, JoinPath, LocalHook, Macro, MacroProperty, MacroPropertyKey, MacroToContext, MacroToProperty, MapResponse, MaybeArray, MaybePromise, MaybeValueOrVoidFunction, MergeElysiaInstances, MergeSchema, MergeScopedSchemas, MetadataBase, NonResolvableMacroKey, ObjectMacroDefs, OptionalHandler, PossibleResponse, PreHandler, Prettify, PublicRoute, Replace, ResolveHandler, ResolvePath, ResolveRouteErrors, RouteBase, RouteSchema, SSEPayload, SingletonBase, type StandardSchemaV1Like, TraceHandler, TransformHandler, type TypeBoxSchema, UnhandledReturnedError, UnhandledReturnedErrorOf, UnionResponseStatus, UnionToIntersect, UnwrapArray, UnwrapBodySchema, UnwrapMacroSchema, UnwrapRoute, UnwrapSchema, ValueOrFunctionToResponseSchema, ValueToResponseSchema, VoidHandler, WrapFn };
888
+ export { AddRoute, AddWSRoute, AfterHandler, AfterResponseHandler, AnyErrorConstructor, AnyLocalHook, type AnySchema, AnyWSLocalHook, AppEvent, AppHook, BaseMacro, BodyHandler, BunHTMLBundlelike, CompiledHandler, ComposeElysiaResponse, ContentType, ContextAppendType, CreateEden, CreateEdenResponse, CreateWSEdenResponse, DefaultEphemeral, DefaultMetadata, DefaultSingleton, DefinitionBase, DocumentDecoration, ElysiaConfig, ElysiaFormData, ElysiaHandlerToResponseSchema, ElysiaHandlerToResponseSchemaAmbiguous, ElysiaHandlerToResponseSchemas, EmptyInputSchema, EphemeralType, Equal, ErrorDefinition, ErrorDefinitionEntry, ErrorHandler, ErrorHandlerResponseSchema, EventFn, EventScope, ExcludeElysiaResponse, ExtractErrorFromHandle, ExtractReturnedError, GetPathParameter, GracefulHandler, GuardLocalHook, GuardSchemaType, HTTPHeaders, HTTPMethod, Handler, InlineHandler, InlineHandlerNonMacro, InlineHandlerResponse, InlineResponse, InlineSchemaResponse, InputSchema, InputSchemaKey, InternalRoute, IntersectIfObject, IntersectIfObjectSchema, IsAny, IsNever, IsTuple, IsUnknown, JoinPath, LocalHook, Macro, MacroProperty, MacroPropertyKey, MacroSchemaChannel, MacroToContext, MacroToProperty, MapResponse, MaybeArray, MaybePromise, MaybeValueOrVoidFunction, MergeElysiaInstances, MergeSchema, MergeScopedSchemas, MetadataBase, NonResolvableMacroKey, ObjectMacroDefs, OptionalHandler, PossibleResponse, PreHandler, Prettify, PublicRoute, Replace, ResolveHandler, ResolvePath, ResolveRouteErrors, RouteBase, RouteSchema, SSEPayload, SingletonBase, type StandardSchemaV1Like, TraceHandler, TransformHandler, type TypeBoxSchema, UnhandledReturnedError, UnhandledReturnedErrorOf, UnionResponseStatus, UnionToIntersect, UnwrapArray, UnwrapBodySchema, UnwrapMacroSchema, UnwrapRoute, UnwrapSchema, ValueOrFunctionToResponseSchema, ValueToResponseSchema, VoidHandler, WrapFn };
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MethodMap } from "./constants.js";
2
- import { AnySchema, StandardSchemaV1Like } from "./type/types.js";
3
2
  import { AnyLocalHook, AppHook, ElysiaFormData, EventFn, EventScope, GuardSchemaType, InputSchema, Macro, MaybeArray, Prettify, SSEPayload } from "./types.js";
3
+ import { AnySchema, StandardSchemaV1Like } from "./type/types.js";
4
4
  import { Context } from "./context.js";
5
5
 
6
6
  //#region src/utils.d.ts
@@ -137,5 +137,9 @@ declare function pushField<K extends keyof any>(target: Record<K, unknown>, key:
137
137
  declare const requestId: any;
138
138
  declare function replaceUrlPath(url: string, path: string): string;
139
139
  declare function clonePlainDecorators<T extends Record<string, unknown>>(source: T, seen?: WeakMap<object, any>): T;
140
+ declare function prefix<T extends string, Models extends Record<string, AnySchema>>(prefix: T, models: Models): { [k in keyof Models as `${T}.${k & string}`]: Models[k] };
141
+ declare namespace prefix {
142
+ var capitalize: <T extends string, Models extends Record<string, AnySchema>>(prefix: T, models: Models) => { [k in keyof Models as `${T}.${Capitalize<k & string>}`]: Models[k] };
143
+ }
140
144
  //#endregion
141
- export { ChainNode, cloneHook, clonePlainDecorators, coalesceStandaloneSchemas, constantTimeEqual, createErrorEventHandler, dedupedMergeArray, eventProperties, flattenChain, flattenChainMemo, fnOrigin, fnv1a, form, formToFormData, getLoosePath, hookToGuard, isBlob, isDownwardScope, isEmpty, isLocalScope, isNotEmpty, isRecordNumber, joinPath, mapMethodBack, mergeArray, mergeDeep, mergeHook, mergeResponse, nullObject, pushField, redirect, replaceUrlPath, requestId, schemaProperties, sse };
145
+ export { ChainNode, cloneHook, clonePlainDecorators, coalesceStandaloneSchemas, constantTimeEqual, createErrorEventHandler, dedupedMergeArray, eventProperties, flattenChain, flattenChainMemo, fnOrigin, fnv1a, form, formToFormData, getLoosePath, hookToGuard, isBlob, isDownwardScope, isEmpty, isLocalScope, isNotEmpty, isRecordNumber, joinPath, mapMethodBack, mergeArray, mergeDeep, mergeHook, mergeResponse, nullObject, prefix, pushField, redirect, replaceUrlPath, requestId, schemaProperties, sse };
package/dist/utils.js CHANGED
@@ -445,6 +445,17 @@ function clonePlainDecorators(source, seen = /* @__PURE__ */ new WeakMap()) {
445
445
  }
446
446
  return out;
447
447
  }
448
+ const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
449
+ function prefix(prefix, models) {
450
+ const prefixed = nullObject();
451
+ for (const key in models) prefixed[`${prefix}.${key}`] = models[key];
452
+ return prefixed;
453
+ }
454
+ prefix.capitalize = function prefixModelsCapitalize(prefix, models) {
455
+ const prefixed = nullObject();
456
+ for (const key in models) prefixed[`${prefix}.${capitalize(key)}`] = models[key];
457
+ return prefixed;
458
+ };
448
459
 
449
460
  //#endregion
450
461
  exports.cloneHook = cloneHook;
@@ -475,6 +486,7 @@ exports.mergeDeep = mergeDeep;
475
486
  exports.mergeHook = mergeHook;
476
487
  exports.mergeResponse = mergeResponse;
477
488
  exports.nullObject = nullObject;
489
+ exports.prefix = prefix;
478
490
  exports.pushField = pushField;
479
491
  exports.redirect = redirect;
480
492
  exports.replaceUrlPath = replaceUrlPath;
package/dist/utils.mjs CHANGED
@@ -444,6 +444,17 @@ function clonePlainDecorators(source, seen = /* @__PURE__ */ new WeakMap()) {
444
444
  }
445
445
  return out;
446
446
  }
447
+ const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
448
+ function prefix(prefix, models) {
449
+ const prefixed = nullObject();
450
+ for (const key in models) prefixed[`${prefix}.${key}`] = models[key];
451
+ return prefixed;
452
+ }
453
+ prefix.capitalize = function prefixModelsCapitalize(prefix, models) {
454
+ const prefixed = nullObject();
455
+ for (const key in models) prefixed[`${prefix}.${capitalize(key)}`] = models[key];
456
+ return prefixed;
457
+ };
447
458
 
448
459
  //#endregion
449
- export { cloneHook, clonePlainDecorators, coalesceStandaloneSchemas, constantTimeEqual, createErrorEventHandler, dedupedMergeArray, eventProperties, flattenChain, flattenChainMemo, fnOrigin, fnv1a, form, formToFormData, getLoosePath, hookToGuard, isBlob, isDownwardScope, isEmpty, isLocalScope, isNotEmpty, isRecordNumber, joinPath, mapMethodBack, mergeArray, mergeDeep, mergeHook, mergeResponse, nullObject, pushField, redirect, replaceUrlPath, requestId, schemaProperties, sse };
460
+ export { cloneHook, clonePlainDecorators, coalesceStandaloneSchemas, constantTimeEqual, createErrorEventHandler, dedupedMergeArray, eventProperties, flattenChain, flattenChainMemo, fnOrigin, fnv1a, form, formToFormData, getLoosePath, hookToGuard, isBlob, isDownwardScope, isEmpty, isLocalScope, isNotEmpty, isRecordNumber, joinPath, mapMethodBack, mergeArray, mergeDeep, mergeHook, mergeResponse, nullObject, prefix, pushField, redirect, replaceUrlPath, requestId, schemaProperties, sse };
@@ -1,8 +1,8 @@
1
+ import { ElysiaConfig, MaybePromise } from "../types.js";
1
2
  import { AnySchema, StandardSchemaV1Like } from "../type/types.js";
2
3
  import { CoerceOption } from "../type/coerce.js";
3
4
  import { ValidatorSlot } from "../compile/aot.js";
4
5
  import { TypeBoxValidator } from "../type/bridge.js";
5
- import { ElysiaConfig, MaybePromise } from "../types.js";
6
6
  import { TSchema } from "typebox/type";
7
7
  import { TLocalizedValidationError } from "typebox/error";
8
8
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elysia",
3
3
  "description": "Ergonomic Framework for Human",
4
- "version": "2.0.0-exp.14",
4
+ "version": "2.0.0-exp.16",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",