elysia 1.0.21 → 1.0.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/utils.mjs CHANGED
@@ -337,7 +337,7 @@ var validateFile = (options, value) => {
337
337
  }
338
338
  return true;
339
339
  };
340
- var File = TypeRegistry.Get("Files") ?? TypeSystem.Type("File", validateFile);
340
+ var File2 = TypeRegistry.Get("Files") ?? TypeSystem.Type("File", validateFile);
341
341
  var Files = TypeRegistry.Get("Files") ?? TypeSystem.Type(
342
342
  "Files",
343
343
  (options, value) => {
@@ -483,7 +483,7 @@ var ElysiaType = {
483
483
  return JSON.stringify(value);
484
484
  });
485
485
  },
486
- File,
486
+ File: File2,
487
487
  Files: (options = {}) => t.Transform(Files(options)).Decode((value) => {
488
488
  if (Array.isArray(value))
489
489
  return value;
@@ -682,7 +682,7 @@ var getSchemaValidator = (s, {
682
682
  models = {},
683
683
  dynamic = false,
684
684
  normalize = false,
685
- additionalProperties = normalize
685
+ additionalProperties = false
686
686
  } = {}) => {
687
687
  if (!s)
688
688
  return void 0;
@@ -703,7 +703,7 @@ var getSchemaValidator = (s, {
703
703
  Errors: (value) => Value4.Errors(schema, value),
704
704
  Code: () => ""
705
705
  };
706
- if (normalize && schema.additionalProperties === true)
706
+ if (normalize && schema.additionalProperties === false)
707
707
  validator.Clean = cleaner;
708
708
  if (schema.config) {
709
709
  validator.config = schema.config;
@@ -725,7 +725,7 @@ var getResponseSchemaValidator = (s, {
725
725
  models = {},
726
726
  dynamic = false,
727
727
  normalize = false,
728
- additionalProperties = normalize
728
+ additionalProperties = false
729
729
  }) => {
730
730
  if (!s)
731
731
  return;
@@ -746,7 +746,7 @@ var getResponseSchemaValidator = (s, {
746
746
  Code: () => ""
747
747
  };
748
748
  const compiledValidator = TypeCompiler2.Compile(schema, references);
749
- if (normalize && schema.additionalProperties === true)
749
+ if (normalize && schema.additionalProperties === false)
750
750
  compiledValidator.Clean = cleaner;
751
751
  return compiledValidator;
752
752
  };
@@ -1233,13 +1233,27 @@ var cloneInference = (inference) => ({
1233
1233
  set: inference.trace.set
1234
1234
  }
1235
1235
  });
1236
- var redirect = (url, status = 301) => new Response(null, {
1237
- status,
1238
- headers: {
1239
- Location: url
1236
+ var redirect = (url, status = 301) => Response.redirect(url, status);
1237
+ var ELYSIA_FORM_DATA = Symbol("ElysiaFormData");
1238
+ var form = (items) => {
1239
+ const formData = new FormData();
1240
+ for (const [key, value] of Object.entries(items)) {
1241
+ if (Array.isArray(value)) {
1242
+ for (const v of value) {
1243
+ if (value instanceof File)
1244
+ formData.append(key, value, value.name);
1245
+ formData.append(key, v);
1246
+ }
1247
+ continue;
1248
+ }
1249
+ if (value instanceof File)
1250
+ formData.append(key, value, value.name);
1251
+ formData.append(key, value);
1240
1252
  }
1241
- });
1253
+ return formData;
1254
+ };
1242
1255
  export {
1256
+ ELYSIA_FORM_DATA,
1243
1257
  InvertedStatusMap,
1244
1258
  PromiseGroup,
1245
1259
  StatusMap,
@@ -1249,6 +1263,7 @@ export {
1249
1263
  createMacroManager,
1250
1264
  filterGlobalHook,
1251
1265
  fnToContainer,
1266
+ form,
1252
1267
  getCookieValidator,
1253
1268
  getResponseSchemaValidator,
1254
1269
  getSchemaValidator,
package/dist/ws/index.mjs CHANGED
@@ -242,7 +242,7 @@ var validateFile = (options, value) => {
242
242
  }
243
243
  return true;
244
244
  };
245
- var File = TypeRegistry.Get("Files") ?? TypeSystem.Type("File", validateFile);
245
+ var File2 = TypeRegistry.Get("Files") ?? TypeSystem.Type("File", validateFile);
246
246
  var Files = TypeRegistry.Get("Files") ?? TypeSystem.Type(
247
247
  "Files",
248
248
  (options, value) => {
@@ -388,7 +388,7 @@ var ElysiaType = {
388
388
  return JSON.stringify(value);
389
389
  });
390
390
  },
391
- File,
391
+ File: File2,
392
392
  Files: (options = {}) => t.Transform(Files(options)).Decode((value) => {
393
393
  if (Array.isArray(value))
394
394
  return value;
@@ -550,6 +550,7 @@ var InvertedStatusMap = Object.fromEntries(
550
550
  Object.entries(StatusMap).map(([k, v]) => [v, k])
551
551
  );
552
552
  var encoder = new TextEncoder();
553
+ var ELYSIA_FORM_DATA = Symbol("ElysiaFormData");
553
554
 
554
555
  // src/error.ts
555
556
  var env = typeof Bun !== "undefined" ? Bun.env : typeof process !== "undefined" ? process?.env : void 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elysia",
3
3
  "description": "Ergonomic Framework for Human",
4
- "version": "1.0.21",
4
+ "version": "1.0.23",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",
@@ -11,6 +11,7 @@
11
11
  "module": "./dist/index.mjs",
12
12
  "types": "./dist/index.d.ts",
13
13
  "exports": {
14
+ "./package.json": "./package.json",
14
15
  ".": {
15
16
  "types": "./dist/index.d.ts",
16
17
  "import": "./dist/index.mjs",