elysia 2.0.0-exp.22 → 2.0.0-exp.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.js +1 -5
- package/dist/base.mjs +1 -5
- package/dist/type/bridge.d.ts +7 -7
- package/dist/type/coerce.d.ts +1 -1
- package/dist/type/coerce.js +1 -5
- package/dist/type/coerce.mjs +1 -5
- package/dist/type/constants.d.ts +1 -1
- package/dist/type/types.d.ts +1 -1
- package/dist/type/validator/index.d.ts +1 -1
- package/dist/type/validator/index.js +7 -2
- package/dist/type/validator/index.mjs +7 -2
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/base.js
CHANGED
|
@@ -1029,11 +1029,7 @@ var Elysia = class Elysia {
|
|
|
1029
1029
|
return this.#handle ??= async (requestOrUrl, options) => this.fetch(typeof requestOrUrl === "string" ? new Request(requestOrUrl.startsWith("/") ? `http://e.ly${requestOrUrl}` : requestOrUrl, options) : requestOrUrl);
|
|
1030
1030
|
}
|
|
1031
1031
|
listen(options, callback) {
|
|
1032
|
-
|
|
1033
|
-
this["~config"] ??= require_utils.nullObject();
|
|
1034
|
-
this["~config"].adapter = require_adapter_bun_index.BunAdapter;
|
|
1035
|
-
}
|
|
1036
|
-
const listen = this["~config"]?.adapter?.listen;
|
|
1032
|
+
const listen = (this["~config"]?.adapter ?? require_universal_constants.isBun ? require_adapter_bun_index.BunAdapter : void 0)?.listen;
|
|
1037
1033
|
if (!listen) throw new Error("No adapter provided for listen()");
|
|
1038
1034
|
if (!require_universal_env.env.ELYSIA_AOT_BUILD) listen(this, options, callback);
|
|
1039
1035
|
return this;
|
package/dist/base.mjs
CHANGED
|
@@ -1026,11 +1026,7 @@ var Elysia = class Elysia {
|
|
|
1026
1026
|
return this.#handle ??= async (requestOrUrl, options) => this.fetch(typeof requestOrUrl === "string" ? new Request(requestOrUrl.startsWith("/") ? `http://e.ly${requestOrUrl}` : requestOrUrl, options) : requestOrUrl);
|
|
1027
1027
|
}
|
|
1028
1028
|
listen(options, callback) {
|
|
1029
|
-
|
|
1030
|
-
this["~config"] ??= nullObject();
|
|
1031
|
-
this["~config"].adapter = BunAdapter;
|
|
1032
|
-
}
|
|
1033
|
-
const listen = this["~config"]?.adapter?.listen;
|
|
1029
|
+
const listen = (this["~config"]?.adapter ?? isBun ? BunAdapter : void 0)?.listen;
|
|
1034
1030
|
if (!listen) throw new Error("No adapter provided for listen()");
|
|
1035
1031
|
if (!env.ELYSIA_AOT_BUILD) listen(this, options, callback);
|
|
1036
1032
|
return this;
|
package/dist/type/bridge.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Intersect as Intersect$
|
|
1
|
+
import { Intersect as Intersect$1 } 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 { Compile as Compile$1 } from "typebox/compile";
|
|
7
6
|
import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
|
|
8
|
-
import {
|
|
7
|
+
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";
|
|
9
9
|
|
|
10
10
|
//#region src/type/bridge.d.ts
|
|
11
11
|
interface TypeboxModule {
|
|
12
12
|
Compile: typeof Compile$1;
|
|
13
|
-
Decode: typeof Decode$
|
|
13
|
+
Decode: typeof Decode$1;
|
|
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$
|
|
24
|
+
Intersect: typeof Intersect$1;
|
|
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$
|
|
29
|
+
declare let Decode: typeof Decode$1;
|
|
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$
|
|
42
|
+
declare let Intersect: typeof Intersect$1;
|
|
43
43
|
declare let Default: typeof Default$1;
|
|
44
44
|
declare let Ref: typeof Ref$1;
|
|
45
45
|
declare function useTypebox(mod: TypeboxModule): void;
|
package/dist/type/coerce.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ declare const coerceQuery: () => CoerceOption[];
|
|
|
36
36
|
declare const coerceBody: () => CoerceOption[];
|
|
37
37
|
declare const coerceFormData: () => CoerceOption[];
|
|
38
38
|
declare const coerceStringToStructure: () => CoerceOption[];
|
|
39
|
-
declare function applyCoercions(schema: BaseSchema | TSchema, coerces: CoerceOption[] | undefined):
|
|
39
|
+
declare function applyCoercions(schema: BaseSchema | TSchema, coerces: CoerceOption[] | undefined): TSchema | BaseSchema;
|
|
40
40
|
interface CoerceLeaf {
|
|
41
41
|
e: number;
|
|
42
42
|
c?: Record<string, unknown>;
|
package/dist/type/coerce.js
CHANGED
|
@@ -249,16 +249,12 @@ function captureCoercePlan(original, coerced) {
|
|
|
249
249
|
const walk = (o, c) => {
|
|
250
250
|
if (o === c || !c || typeof c !== "object") return null;
|
|
251
251
|
const ely = c["~elyTyp"];
|
|
252
|
-
if (ely === require_type_constants.ELYSIA_TYPES.ObjectString && (!o || o["~elyTyp"] !== ely)) {
|
|
252
|
+
if ((ely === require_type_constants.ELYSIA_TYPES.ObjectString || ely === require_type_constants.ELYSIA_TYPES.ArrayString) && (!o || o["~elyTyp"] !== ely)) {
|
|
253
253
|
any = true;
|
|
254
254
|
const site = { os: ely };
|
|
255
255
|
if (o && "~optional" in o) site.o = o["~optional"];
|
|
256
256
|
return site;
|
|
257
257
|
}
|
|
258
|
-
if (ely === require_type_constants.ELYSIA_TYPES.ArrayString) {
|
|
259
|
-
bakeable = false;
|
|
260
|
-
return null;
|
|
261
|
-
}
|
|
262
258
|
if (ely && COERCE_LEAF_CTOR[ely] && (!o || o["~elyTyp"] !== ely)) {
|
|
263
259
|
any = true;
|
|
264
260
|
const leaf = { e: ely };
|
package/dist/type/coerce.mjs
CHANGED
|
@@ -248,16 +248,12 @@ function captureCoercePlan(original, coerced) {
|
|
|
248
248
|
const walk = (o, c) => {
|
|
249
249
|
if (o === c || !c || typeof c !== "object") return null;
|
|
250
250
|
const ely = c["~elyTyp"];
|
|
251
|
-
if (ely === ELYSIA_TYPES.ObjectString && (!o || o["~elyTyp"] !== ely)) {
|
|
251
|
+
if ((ely === ELYSIA_TYPES.ObjectString || ely === ELYSIA_TYPES.ArrayString) && (!o || o["~elyTyp"] !== ely)) {
|
|
252
252
|
any = true;
|
|
253
253
|
const site = { os: ely };
|
|
254
254
|
if (o && "~optional" in o) site.o = o["~optional"];
|
|
255
255
|
return site;
|
|
256
256
|
}
|
|
257
|
-
if (ely === ELYSIA_TYPES.ArrayString) {
|
|
258
|
-
bakeable = false;
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
257
|
if (ely && COERCE_LEAF_CTOR[ely] && (!o || o["~elyTyp"] !== ely)) {
|
|
262
258
|
any = true;
|
|
263
259
|
const leaf = { e: ely };
|
package/dist/type/constants.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare const ELYSIA_TYPES: {
|
|
|
17
17
|
readonly NoValidate: 15;
|
|
18
18
|
};
|
|
19
19
|
type ELYSIA_TYPES = typeof ELYSIA_TYPES;
|
|
20
|
-
declare const primitiveElysiaTypes: Set<
|
|
20
|
+
declare const primitiveElysiaTypes: Set<2 | 1 | 3 | 6 | 10 | 11 | 13 | 14>;
|
|
21
21
|
declare const noEnumerable: {
|
|
22
22
|
readonly enumerable: false;
|
|
23
23
|
};
|
package/dist/type/types.d.ts
CHANGED
|
@@ -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";
|
|
5
4
|
import { TObjectOptions, TSchemaOptions } from "typebox";
|
|
6
5
|
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 { Validator } from "typebox/schema";
|
|
6
5
|
import { TLocalizedValidationError } from "typebox/error";
|
|
6
|
+
import { Validator } from "typebox/schema";
|
|
7
7
|
|
|
8
8
|
//#region src/type/validator/index.d.ts
|
|
9
9
|
declare function shallowMergeObjects(members: any[]): TSchema | null;
|
|
@@ -148,8 +148,13 @@ var TypeBoxValidator = class extends require_validator_index.Validator {
|
|
|
148
148
|
const originalElyTyp = schema?.["~elyTyp"];
|
|
149
149
|
const frozen = options?.aot && options.slot ? require_compile_aot.Compiled.getValidator(options.aot.method, options.aot.path, options.slot) : void 0;
|
|
150
150
|
let schemaHasRef = false;
|
|
151
|
-
if (name && options?.models)
|
|
152
|
-
|
|
151
|
+
if (name && options?.models) {
|
|
152
|
+
schema = moduleCache.getOrInsertComputed(options.models, () => (0, typebox_type.Module)(options.models))[name];
|
|
153
|
+
if (isIntersectable) {
|
|
154
|
+
const members = [schema, ...options.schemas];
|
|
155
|
+
schema = shallowMergeObjects(members) ?? (0, typebox_type.Evaluate)((0, typebox_type.Intersect)(members));
|
|
156
|
+
}
|
|
157
|
+
} else if (options?.models && typeof name !== "string") {
|
|
153
158
|
schemaHasRef = frozen ? frozen.r === 1 : schemaContainsRef(schema);
|
|
154
159
|
if (schemaHasRef) {
|
|
155
160
|
const id = `inline@${++inlineRefId}`;
|
|
@@ -145,8 +145,13 @@ var TypeBoxValidator = class extends Validator$1 {
|
|
|
145
145
|
const originalElyTyp = schema?.["~elyTyp"];
|
|
146
146
|
const frozen = options?.aot && options.slot ? Compiled.getValidator(options.aot.method, options.aot.path, options.slot) : void 0;
|
|
147
147
|
let schemaHasRef = false;
|
|
148
|
-
if (name && options?.models)
|
|
149
|
-
|
|
148
|
+
if (name && options?.models) {
|
|
149
|
+
schema = moduleCache.getOrInsertComputed(options.models, () => Module(options.models))[name];
|
|
150
|
+
if (isIntersectable) {
|
|
151
|
+
const members = [schema, ...options.schemas];
|
|
152
|
+
schema = shallowMergeObjects(members) ?? Evaluate(Intersect(members));
|
|
153
|
+
}
|
|
154
|
+
} else if (options?.models && typeof name !== "string") {
|
|
150
155
|
schemaHasRef = frozen ? frozen.r === 1 : schemaContainsRef(schema);
|
|
151
156
|
if (schemaHasRef) {
|
|
152
157
|
const id = `inline@${++inlineRefId}`;
|
package/dist/types.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import { Context, ErrorContext, LifecycleContext, PreContext } from "./context.j
|
|
|
10
10
|
import { WebSocketHandler } from "./ws/types.js";
|
|
11
11
|
import { AnyElysia, Elysia } from "./base.js";
|
|
12
12
|
import { ElysiaAdapter } from "./adapter/index.js";
|
|
13
|
-
import { Instruction } from "exact-mirror";
|
|
14
13
|
import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from "typebox";
|
|
14
|
+
import { Instruction } from "exact-mirror";
|
|
15
15
|
import { OpenAPIV3 } from "openapi-types";
|
|
16
16
|
|
|
17
17
|
//#region src/types.d.ts
|