elysia 2.0.0-exp.14 → 2.0.0-exp.15

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.
@@ -12,7 +12,7 @@ declare function responseToSetHeaders(response: Response, set?: Context['set']):
12
12
  cookie?: Record<string, BaseCookie>;
13
13
  } | {
14
14
  headers: any;
15
- status: number | "Bad Request" | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required";
15
+ status: number | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required";
16
16
  };
17
17
  interface CreateHandlerParameter {
18
18
  mapResponse(response: unknown, set: Context['set'], request?: Request): Response;
package/dist/base.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ElysiaStatus } from "./error.js";
2
2
  import { TraceHandler } from "./trace.js";
3
3
  import { AnySchema } from "./type/types.js";
4
4
  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";
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, 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";
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/error.d.ts CHANGED
@@ -85,7 +85,7 @@ declare class ElysiaStatus<const in out Code extends number | keyof StatusMap, T
85
85
  constructor(code: Code, res: T);
86
86
  get status(): number;
87
87
  }
88
- declare const status: <const Code extends number | keyof StatusMap, const T = (Code extends keyof StatusMapBack ? StatusMapBack[Code] : Code)>(code: Code, response?: T) => ElysiaStatus<Code, T, Code extends "Bad Request" | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? {
88
+ declare const status: <const Code extends number | keyof StatusMap, const T = (Code extends keyof StatusMapBack ? StatusMapBack[Code] : Code)>(code: Code, response?: T) => ElysiaStatus<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? {
89
89
  readonly Continue: 100;
90
90
  readonly 'Switching Protocols': 101;
91
91
  readonly Processing: 102;
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import { TypeBoxValidator } from "./type/validator/index.js";
11
11
  import { TypeSystem, t } from "./type/index.js";
12
12
  import { env } from "./universal/env.js";
13
13
  import { SSEPayload } from "./types.js";
14
- import { form, redirect, sse } from "./utils.js";
14
+ import { form, prefix, redirect, sse } from "./utils.js";
15
15
  import { Context, ErrorContext, createBaseContext, createContext } from "./context.js";
16
16
  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 };
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, 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 };
@@ -1,16 +1,16 @@
1
- import { Intersect as Intersect$1 } from "./elysia/intersect.js";
1
+ import { Intersect as Intersect$2 } from "./elysia/intersect.js";
2
2
  import { applyCoercions as applyCoercions$1, coerceBody as coerceBody$1, coerceFormData as coerceFormData$1, coerceQuery as coerceQuery$1, coerceRoot as coerceRoot$1, coerceStringToStructure as coerceStringToStructure$1 } from "./coerce.js";
3
3
  import { hasTypes as hasTypes$1 } from "./utils.js";
4
4
  import { TypeBoxValidatorCache as TypeBoxValidatorCache$1 } from "./validator/validator-cache.js";
5
5
  import { TypeBoxValidator as TypeBoxValidator$1 } from "./validator/index.js";
6
- import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
7
6
  import { Compile as Compile$1 } from "typebox/compile";
8
- import { Decode as Decode$1, Default as Default$1, HasCodec as HasCodec$1 } from "typebox/value";
7
+ import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
8
+ import { Decode as Decode$2, Default as Default$1, HasCodec as HasCodec$1 } from "typebox/value";
9
9
 
10
10
  //#region src/type/bridge.d.ts
11
11
  interface TypeboxModule {
12
12
  Compile: typeof Compile$1;
13
- Decode: typeof Decode$1;
13
+ Decode: typeof Decode$2;
14
14
  applyCoercions: typeof applyCoercions$1;
15
15
  TypeBoxValidator: TypeBoxValidator$1;
16
16
  TypeBoxValidatorCache: TypeBoxValidatorCache$1;
@@ -21,12 +21,12 @@ interface TypeboxModule {
21
21
  coerceBody: typeof coerceBody$1;
22
22
  hasTypes: typeof hasTypes$1;
23
23
  HasCodec: typeof HasCodec$1;
24
- Intersect: typeof Intersect$1;
24
+ Intersect: typeof Intersect$2;
25
25
  Default: typeof Default$1;
26
26
  Ref: typeof Ref$1;
27
27
  }
28
28
  declare let Compile: typeof Compile$1;
29
- declare let Decode: typeof Decode$1;
29
+ declare let Decode: typeof Decode$2;
30
30
  declare let applyCoercions: typeof applyCoercions$1;
31
31
  declare let TypeBoxValidator: TypeBoxValidator$1;
32
32
  type TypeBoxValidator<T extends TSchema = TAny> = TypeBoxValidator$1<T>;
@@ -39,7 +39,7 @@ declare let coerceStringToStructure: typeof coerceStringToStructure$1;
39
39
  declare let coerceBody: typeof coerceBody$1;
40
40
  declare let hasTypes: typeof hasTypes$1;
41
41
  declare let HasCodec: typeof HasCodec$1;
42
- declare let Intersect: typeof Intersect$1;
42
+ declare let Intersect: typeof Intersect$2;
43
43
  declare let Default: typeof Default$1;
44
44
  declare let Ref: typeof Ref$1;
45
45
  declare function useTypebox(mod: TypeboxModule): void;
@@ -1,9 +1,9 @@
1
1
  import { ELYSIA_TYPES } from "./constants.js";
2
2
  import { CookieOptions } from "../cookie/types.js";
3
3
  import { MaybeArray } from "../types.js";
4
+ import { Validator } from "typebox/schema";
4
5
  import { TObjectOptions, TSchemaOptions } from "typebox";
5
6
  import { TLocalizedValidationError } from "typebox/error";
6
- import { Validator } from "typebox/schema";
7
7
 
8
8
  //#region src/type/types.d.ts
9
9
  type FileUnit = number | `${number}${'k' | 'm'}`;
@@ -2,8 +2,8 @@ import { Validator as Validator$1, ValidatorOptions } from "../../validator/inde
2
2
  import { TypeBoxValidatorCache } from "./validator-cache.js";
3
3
  import { MaybePromise } from "../../types.js";
4
4
  import { Static, StaticDecode, StaticEncode, TAny, TSchema } from "typebox/type";
5
- import { TLocalizedValidationError } from "typebox/error";
6
5
  import { Validator } from "typebox/schema";
6
+ import { TLocalizedValidationError } from "typebox/error";
7
7
 
8
8
  //#region src/type/validator/index.d.ts
9
9
  declare function shallowMergeObjects(members: any[]): TSchema | null;
package/dist/types.d.ts CHANGED
@@ -10,8 +10,8 @@ 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
@@ -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 };
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.15",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",