elysia 1.4.28 → 2.0.0-beta.0
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/_virtual/_rolldown/runtime.js +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +38 -0
- package/dist/adapter/bun/index.d.ts +7 -6
- package/dist/adapter/bun/index.js +219 -380
- package/dist/adapter/bun/index.mjs +217 -382
- package/dist/adapter/constants.d.ts +6 -0
- package/dist/adapter/constants.js +10 -0
- package/dist/adapter/constants.mjs +9 -0
- package/dist/adapter/default-headers.d.ts +4 -0
- package/dist/adapter/default-headers.js +7 -0
- package/dist/adapter/default-headers.mjs +5 -0
- package/dist/adapter/index.d.ts +8 -1
- package/dist/adapter/index.js +7 -14
- package/dist/adapter/index.mjs +5 -0
- package/dist/adapter/origin.d.ts +63 -0
- package/dist/adapter/origin.js +64 -0
- package/dist/adapter/origin.mjs +62 -0
- package/dist/adapter/response-ownership.d.ts +5 -0
- package/dist/adapter/response-ownership.js +13 -0
- package/dist/adapter/response-ownership.mjs +10 -0
- package/dist/adapter/skip-clone.d.ts +4 -0
- package/dist/adapter/skip-clone.js +7 -0
- package/dist/adapter/skip-clone.mjs +5 -0
- package/dist/adapter/types.d.ts +50 -125
- package/dist/adapter/types.js +1 -14
- package/dist/adapter/types.mjs +1 -0
- package/dist/adapter/utils.d.ts +47 -19
- package/dist/adapter/utils.js +561 -311
- package/dist/adapter/utils.mjs +551 -283
- package/dist/adapter/web-standard/handler.d.ts +11 -9
- package/dist/adapter/web-standard/handler.js +146 -415
- package/dist/adapter/web-standard/handler.mjs +144 -400
- package/dist/adapter/web-standard/index.d.ts +5 -2
- package/dist/adapter/web-standard/index.js +68 -161
- package/dist/adapter/web-standard/index.mjs +68 -146
- package/dist/adapter/web-standard/utils.d.ts +4 -0
- package/dist/adapter/web-standard/utils.js +153 -0
- package/dist/adapter/web-standard/utils.mjs +152 -0
- package/dist/base.d.ts +898 -0
- package/dist/base.js +1564 -0
- package/dist/base.mjs +1561 -0
- package/dist/compile/analysis-cache.d.ts +6 -0
- package/dist/compile/analysis-cache.js +12 -0
- package/dist/compile/analysis-cache.mjs +11 -0
- package/dist/compile/aot-capture.d.ts +24 -0
- package/dist/compile/aot-capture.js +376 -0
- package/dist/compile/aot-capture.mjs +365 -0
- package/dist/compile/aot-emit.d.ts +29 -0
- package/dist/compile/aot-emit.js +107 -0
- package/dist/compile/aot-emit.mjs +101 -0
- package/dist/compile/aot-reconstruct.d.ts +30 -0
- package/dist/compile/aot-reconstruct.js +156 -0
- package/dist/compile/aot-reconstruct.mjs +147 -0
- package/dist/compile/aot.d.ts +287 -0
- package/dist/compile/aot.js +220 -0
- package/dist/compile/aot.mjs +200 -0
- package/dist/compile/handler/descriptor.d.ts +77 -0
- package/dist/compile/handler/descriptor.js +199 -0
- package/dist/compile/handler/descriptor.mjs +194 -0
- package/dist/compile/handler/frozen-validator.d.ts +39 -0
- package/dist/compile/handler/frozen-validator.js +319 -0
- package/dist/compile/handler/frozen-validator.mjs +313 -0
- package/dist/compile/handler/index.d.ts +19 -0
- package/dist/compile/handler/index.js +379 -0
- package/dist/compile/handler/index.mjs +371 -0
- package/dist/compile/handler/jit.d.ts +43 -0
- package/dist/compile/handler/jit.js +536 -0
- package/dist/compile/handler/jit.mjs +532 -0
- package/dist/compile/handler/params.d.ts +28 -0
- package/dist/compile/handler/params.js +78 -0
- package/dist/compile/handler/params.mjs +76 -0
- package/dist/compile/handler/reconstruct.d.ts +12 -0
- package/dist/compile/handler/reconstruct.js +50 -0
- package/dist/compile/handler/reconstruct.mjs +49 -0
- package/dist/compile/handler/utils.d.ts +45 -0
- package/dist/compile/handler/utils.js +514 -0
- package/dist/compile/handler/utils.mjs +498 -0
- package/dist/compile/jit-probe.d.ts +15 -0
- package/dist/compile/jit-probe.js +28 -0
- package/dist/compile/jit-probe.mjs +26 -0
- package/dist/compile/lexer.d.ts +7 -0
- package/dist/compile/lexer.js +53 -0
- package/dist/compile/lexer.mjs +48 -0
- package/dist/compile/utils.d.ts +8 -0
- package/dist/compile/utils.js +23 -0
- package/dist/compile/utils.mjs +19 -0
- package/dist/compiled.d.ts +17 -0
- package/dist/compiled.js +20 -0
- package/dist/compiled.mjs +16 -0
- package/dist/constants.d.ts +137 -0
- package/dist/constants.js +96 -0
- package/dist/constants.mjs +88 -0
- package/dist/context.d.ts +86 -129
- package/dist/context.js +110 -13
- package/dist/context.mjs +108 -0
- package/dist/cookie/config.d.ts +31 -0
- package/dist/cookie/config.js +98 -0
- package/dist/cookie/config.mjs +95 -0
- package/dist/cookie/cookie.d.ts +26 -0
- package/dist/cookie/cookie.js +105 -0
- package/dist/cookie/cookie.mjs +104 -0
- package/dist/cookie/crypto.d.ts +20 -0
- package/dist/cookie/crypto.js +168 -0
- package/dist/cookie/crypto.mjs +151 -0
- package/dist/cookie/error.d.ts +17 -0
- package/dist/cookie/error.js +25 -0
- package/dist/cookie/error.mjs +24 -0
- package/dist/cookie/index.d.ts +7 -0
- package/dist/cookie/index.js +13 -0
- package/dist/cookie/index.mjs +7 -0
- package/dist/cookie/lib.d.ts +7 -0
- package/dist/cookie/lib.js +76 -0
- package/dist/cookie/lib.mjs +74 -0
- package/dist/cookie/serialize.d.ts +6 -0
- package/dist/cookie/serialize.js +32 -0
- package/dist/cookie/serialize.mjs +31 -0
- package/dist/cookie/types.d.ts +113 -0
- package/dist/cookie/types.js +1 -0
- package/dist/cookie/types.mjs +1 -0
- package/dist/cookie/utils.d.ts +25 -0
- package/dist/cookie/utils.js +182 -0
- package/dist/cookie/utils.mjs +171 -0
- package/dist/error.d.ts +226 -188
- package/dist/error.js +519 -357
- package/dist/error.mjs +503 -327
- package/dist/generation.d.ts +30 -0
- package/dist/generation.js +23 -0
- package/dist/generation.mjs +17 -0
- package/dist/handler/error.d.ts +7 -0
- package/dist/handler/error.js +105 -0
- package/dist/handler/error.mjs +104 -0
- package/dist/handler/fetch.d.ts +8 -0
- package/dist/handler/fetch.js +371 -0
- package/dist/handler/fetch.mjs +367 -0
- package/dist/handler/index.d.ts +2 -0
- package/dist/handler/index.js +5 -0
- package/dist/handler/index.mjs +3 -0
- package/dist/handler/utils.d.ts +15 -0
- package/dist/handler/utils.js +48 -0
- package/dist/handler/utils.mjs +42 -0
- package/dist/index.d.ts +23 -2198
- package/dist/index.js +62 -1948
- package/dist/index.mjs +20 -1986
- package/dist/memory.d.ts +4 -0
- package/dist/memory.js +17 -0
- package/dist/memory.mjs +16 -0
- package/dist/package.js +11 -0
- package/dist/package.mjs +5 -0
- package/dist/parse-query.d.ts +7 -9
- package/dist/parse-query.js +154 -164
- package/dist/parse-query.mjs +150 -133
- package/dist/plugin/aot/bun.d.ts +26 -0
- package/dist/plugin/aot/bun.js +35 -0
- package/dist/plugin/aot/bun.mjs +34 -0
- package/dist/plugin/aot/core.d.ts +291 -0
- package/dist/plugin/aot/core.js +505 -0
- package/dist/plugin/aot/core.mjs +481 -0
- package/dist/plugin/aot/esbuild.d.ts +28 -0
- package/dist/plugin/aot/esbuild.js +48 -0
- package/dist/plugin/aot/esbuild.mjs +46 -0
- package/dist/plugin/aot/hooks.d.ts +28 -0
- package/dist/plugin/aot/hooks.js +114 -0
- package/dist/plugin/aot/hooks.mjs +112 -0
- package/dist/plugin/aot/rspack-loader.d.ts +23 -0
- package/dist/plugin/aot/rspack-loader.js +44 -0
- package/dist/plugin/aot/rspack-loader.mjs +40 -0
- package/dist/plugin/aot/rspack.d.ts +23 -0
- package/dist/plugin/aot/rspack.js +85 -0
- package/dist/plugin/aot/rspack.mjs +82 -0
- package/dist/plugin/aot/source.d.ts +60 -0
- package/dist/plugin/aot/source.js +422 -0
- package/dist/plugin/aot/source.mjs +418 -0
- package/dist/plugin/aot/treeshake.d.ts +4 -0
- package/dist/plugin/aot/treeshake.js +95 -0
- package/dist/plugin/aot/treeshake.mjs +94 -0
- package/dist/plugin/aot/unplugin.d.ts +50 -0
- package/dist/plugin/aot/unplugin.js +64 -0
- package/dist/plugin/aot/unplugin.mjs +62 -0
- package/dist/plugin/aot/vite.d.ts +30 -0
- package/dist/plugin/aot/vite.js +34 -0
- package/dist/plugin/aot/vite.mjs +33 -0
- package/dist/plugin/aot/worker.d.ts +1 -0
- package/dist/plugin/aot/worker.js +28 -0
- package/dist/plugin/aot/worker.mjs +27 -0
- package/dist/plugin/auto-head.d.ts +6 -0
- package/dist/plugin/auto-head.js +38 -0
- package/dist/plugin/auto-head.mjs +36 -0
- package/dist/plugin/trace.d.ts +10 -0
- package/dist/plugin/trace.js +39 -0
- package/dist/plugin/trace.mjs +36 -0
- package/dist/plugin/websocket.d.ts +6 -0
- package/dist/plugin/websocket.js +61 -0
- package/dist/plugin/websocket.mjs +60 -0
- package/dist/route-table.d.ts +28 -0
- package/dist/route-table.js +64 -0
- package/dist/route-table.mjs +61 -0
- package/dist/schema-snapshot.d.ts +9 -0
- package/dist/schema-snapshot.js +271 -0
- package/dist/schema-snapshot.mjs +269 -0
- package/dist/sucrose.d.ts +28 -63
- package/dist/sucrose.js +814 -306
- package/dist/sucrose.mjs +805 -274
- package/dist/trace.d.ts +145 -130
- package/dist/trace.js +387 -135
- package/dist/trace.mjs +385 -113
- package/dist/type/bridge-live.d.ts +15 -0
- package/dist/type/bridge-live.js +39 -0
- package/dist/type/bridge-live.mjs +17 -0
- package/dist/type/bridge.d.ts +56 -0
- package/dist/type/bridge.js +180 -0
- package/dist/type/bridge.mjs +63 -0
- package/dist/type/coerce-plan.d.ts +38 -0
- package/dist/type/coerce-plan.js +107 -0
- package/dist/type/coerce-plan.mjs +98 -0
- package/dist/type/coerce.d.ts +43 -0
- package/dist/type/coerce.js +351 -0
- package/dist/type/coerce.mjs +339 -0
- package/dist/type/compat.d.ts +8 -0
- package/dist/type/compat.js +46 -0
- package/dist/type/compat.mjs +44 -0
- package/dist/type/constants.d.ts +25 -0
- package/dist/type/constants.js +36 -0
- package/dist/type/constants.mjs +32 -0
- package/dist/type/elysia/accelerate.d.ts +6 -0
- package/dist/type/elysia/accelerate.js +12 -0
- package/dist/type/elysia/accelerate.mjs +10 -0
- package/dist/type/elysia/array-buffer.d.ts +6 -0
- package/dist/type/elysia/array-buffer.js +27 -0
- package/dist/type/elysia/array-buffer.mjs +25 -0
- package/dist/type/elysia/array-string.d.ts +7 -0
- package/dist/type/elysia/array-string.js +28 -0
- package/dist/type/elysia/array-string.mjs +26 -0
- package/dist/type/elysia/array.d.ts +6 -0
- package/dist/type/elysia/array.js +32 -0
- package/dist/type/elysia/array.mjs +31 -0
- package/dist/type/elysia/boolean-string.d.ts +6 -0
- package/dist/type/elysia/boolean-string.js +24 -0
- package/dist/type/elysia/boolean-string.mjs +22 -0
- package/dist/type/elysia/boolean.d.ts +6 -0
- package/dist/type/elysia/boolean.js +20 -0
- package/dist/type/elysia/boolean.mjs +18 -0
- package/dist/type/elysia/cookie.d.ts +15 -0
- package/dist/type/elysia/cookie.js +51 -0
- package/dist/type/elysia/cookie.mjs +50 -0
- package/dist/type/elysia/date.d.ts +7 -0
- package/dist/type/elysia/date.js +98 -0
- package/dist/type/elysia/date.mjs +96 -0
- package/dist/type/elysia/file-type.d.ts +25 -0
- package/dist/type/elysia/file-type.js +81 -0
- package/dist/type/elysia/file-type.mjs +71 -0
- package/dist/type/elysia/file.d.ts +9 -0
- package/dist/type/elysia/file.js +64 -0
- package/dist/type/elysia/file.mjs +48 -0
- package/dist/type/elysia/files.d.ts +8 -0
- package/dist/type/elysia/files.js +45 -0
- package/dist/type/elysia/files.mjs +43 -0
- package/dist/type/elysia/form.d.ts +8 -0
- package/dist/type/elysia/form.js +17 -0
- package/dist/type/elysia/form.mjs +15 -0
- package/dist/type/elysia/integer-string.d.ts +7 -0
- package/dist/type/elysia/integer-string.js +40 -0
- package/dist/type/elysia/integer-string.mjs +38 -0
- package/dist/type/elysia/integer.d.ts +6 -0
- package/dist/type/elysia/integer.js +20 -0
- package/dist/type/elysia/integer.mjs +18 -0
- package/dist/type/elysia/intersect.d.ts +6 -0
- package/dist/type/elysia/intersect.js +20 -0
- package/dist/type/elysia/intersect.mjs +19 -0
- package/dist/type/elysia/maybe-empty.d.ts +7 -0
- package/dist/type/elysia/maybe-empty.js +21 -0
- package/dist/type/elysia/maybe-empty.mjs +19 -0
- package/dist/type/elysia/no-validate.d.ts +6 -0
- package/dist/type/elysia/no-validate.js +9 -0
- package/dist/type/elysia/no-validate.mjs +8 -0
- package/dist/type/elysia/nullable.d.ts +7 -0
- package/dist/type/elysia/nullable.js +15 -0
- package/dist/type/elysia/nullable.mjs +13 -0
- package/dist/type/elysia/number.d.ts +6 -0
- package/dist/type/elysia/number.js +20 -0
- package/dist/type/elysia/number.mjs +18 -0
- package/dist/type/elysia/numeric-enum.d.ts +11 -0
- package/dist/type/elysia/numeric-enum.js +26 -0
- package/dist/type/elysia/numeric-enum.mjs +24 -0
- package/dist/type/elysia/numeric.d.ts +7 -0
- package/dist/type/elysia/numeric.js +62 -0
- package/dist/type/elysia/numeric.mjs +60 -0
- package/dist/type/elysia/object-string.d.ts +7 -0
- package/dist/type/elysia/object-string.js +28 -0
- package/dist/type/elysia/object-string.mjs +26 -0
- package/dist/type/elysia/object.d.ts +6 -0
- package/dist/type/elysia/object.js +47 -0
- package/dist/type/elysia/object.mjs +46 -0
- package/dist/type/elysia/optional.d.ts +6 -0
- package/dist/type/elysia/optional.js +22 -0
- package/dist/type/elysia/optional.mjs +21 -0
- package/dist/type/elysia/string.d.ts +6 -0
- package/dist/type/elysia/string.js +43 -0
- package/dist/type/elysia/string.mjs +41 -0
- package/dist/type/elysia/uint8-array.d.ts +6 -0
- package/dist/type/elysia/uint8-array.js +27 -0
- package/dist/type/elysia/uint8-array.mjs +25 -0
- package/dist/type/elysia/union-enum.d.ts +8 -0
- package/dist/type/elysia/union-enum.js +31 -0
- package/dist/type/elysia/union-enum.mjs +29 -0
- package/dist/type/elysia/union.d.ts +6 -0
- package/dist/type/elysia/union.js +20 -0
- package/dist/type/elysia/union.mjs +19 -0
- package/dist/type/elysia/utils.d.ts +53 -0
- package/dist/type/elysia/utils.js +98 -0
- package/dist/type/elysia/utils.mjs +88 -0
- package/dist/type/exports.d.ts +36 -0
- package/dist/type/exports.js +68 -0
- package/dist/type/exports.mjs +36 -0
- package/dist/type/index.d.ts +13 -0
- package/dist/type/index.js +81 -0
- package/dist/type/index.mjs +68 -0
- package/dist/type/shared.d.ts +27 -0
- package/dist/type/shared.js +171 -0
- package/dist/type/shared.mjs +161 -0
- package/dist/type/types.d.ts +206 -0
- package/dist/type/types.js +1 -0
- package/dist/type/types.mjs +1 -0
- package/dist/type/utils.d.ts +7 -0
- package/dist/type/utils.js +43 -0
- package/dist/type/utils.mjs +41 -0
- package/dist/type/validator/clean-safe.d.ts +8 -0
- package/dist/type/validator/clean-safe.js +82 -0
- package/dist/type/validator/clean-safe.mjs +77 -0
- package/dist/type/validator/custom-error.d.ts +10 -0
- package/dist/type/validator/custom-error.js +191 -0
- package/dist/type/validator/custom-error.mjs +188 -0
- package/dist/type/validator/default-precompute.d.ts +26 -0
- package/dist/type/validator/default-precompute.js +432 -0
- package/dist/type/validator/default-precompute.mjs +421 -0
- package/dist/type/validator/exact-mirror.d.ts +7 -0
- package/dist/type/validator/exact-mirror.js +19 -0
- package/dist/type/validator/exact-mirror.mjs +15 -0
- package/dist/type/validator/frozen-check.d.ts +11 -0
- package/dist/type/validator/frozen-check.js +20 -0
- package/dist/type/validator/frozen-check.mjs +19 -0
- package/dist/type/validator/index.d.ts +32 -0
- package/dist/type/validator/index.js +657 -0
- package/dist/type/validator/index.mjs +651 -0
- package/dist/type/validator/string-codec-aot.d.ts +8 -0
- package/dist/type/validator/string-codec-aot.js +68 -0
- package/dist/type/validator/string-codec-aot.mjs +66 -0
- package/dist/type/validator/validator-cache.d.ts +26 -0
- package/dist/type/validator/validator-cache.js +247 -0
- package/dist/type/validator/validator-cache.mjs +242 -0
- package/dist/types.d.ts +938 -1235
- package/dist/types.js +1 -14
- package/dist/types.mjs +1 -0
- package/dist/universal/constants.d.ts +6 -0
- package/dist/universal/constants.js +19 -0
- package/dist/universal/constants.mjs +15 -0
- package/dist/universal/env.d.ts +5 -1
- package/dist/universal/env.js +12 -26
- package/dist/universal/env.mjs +10 -5
- package/dist/universal/file.d.ts +55 -86
- package/dist/universal/file.js +116 -157
- package/dist/universal/file.mjs +111 -132
- package/dist/universal/index.d.ts +5 -3
- package/dist/universal/index.js +8 -27
- package/dist/universal/index.mjs +4 -5
- package/dist/universal/is-production.d.ts +5 -0
- package/dist/universal/is-production.js +10 -0
- package/dist/universal/is-production.mjs +8 -0
- package/dist/universal/server.d.ts +318 -313
- package/dist/universal/server.js +1 -14
- package/dist/universal/server.mjs +1 -0
- package/dist/utils.d.ts +162 -191
- package/dist/utils.js +732 -693
- package/dist/utils.mjs +683 -631
- package/dist/validator/index.d.ts +63 -0
- package/dist/validator/index.js +299 -0
- package/dist/validator/index.mjs +296 -0
- package/dist/validator/route.d.ts +32 -0
- package/dist/validator/route.js +51 -0
- package/dist/validator/route.mjs +50 -0
- package/dist/ws/context.d.ts +49 -0
- package/dist/ws/context.js +152 -0
- package/dist/ws/context.mjs +150 -0
- package/dist/ws/index.d.ts +5 -77
- package/dist/ws/index.js +11 -180
- package/dist/ws/index.mjs +5 -157
- package/dist/ws/parser.d.ts +5 -0
- package/dist/ws/parser.js +69 -0
- package/dist/ws/parser.mjs +66 -0
- package/dist/ws/route.d.ts +16 -0
- package/dist/ws/route.js +560 -0
- package/dist/ws/route.mjs +554 -0
- package/dist/ws/types.d.ts +154 -57
- package/dist/ws/types.js +1 -14
- package/dist/ws/types.mjs +1 -0
- package/package.json +179 -120
- package/bunfig.toml +0 -2
- package/dist/adapter/bun/compose.d.ts +0 -3
- package/dist/adapter/bun/compose.js +0 -90
- package/dist/adapter/bun/compose.mjs +0 -74
- package/dist/adapter/bun/handler-native.d.ts +0 -3
- package/dist/adapter/bun/handler-native.js +0 -42
- package/dist/adapter/bun/handler-native.mjs +0 -22
- package/dist/adapter/bun/handler.d.ts +0 -7
- package/dist/adapter/bun/handler.js +0 -363
- package/dist/adapter/bun/handler.mjs +0 -346
- package/dist/adapter/cloudflare-worker/index.d.ts +0 -20
- package/dist/adapter/cloudflare-worker/index.js +0 -59
- package/dist/adapter/cloudflare-worker/index.mjs +0 -39
- package/dist/compose.d.ts +0 -30
- package/dist/compose.js +0 -1324
- package/dist/compose.mjs +0 -1336
- package/dist/cookies.d.ts +0 -158
- package/dist/cookies.js +0 -250
- package/dist/cookies.mjs +0 -221
- package/dist/dynamic-handle.d.ts +0 -15
- package/dist/dynamic-handle.js +0 -521
- package/dist/dynamic-handle.mjs +0 -509
- package/dist/formats.d.ts +0 -79
- package/dist/formats.js +0 -153
- package/dist/formats.mjs +0 -132
- package/dist/manifest.d.ts +0 -0
- package/dist/manifest.js +0 -1
- package/dist/manifest.mjs +0 -0
- package/dist/replace-schema.d.ts +0 -60
- package/dist/replace-schema.js +0 -140
- package/dist/replace-schema.mjs +0 -115
- package/dist/schema.d.ts +0 -107
- package/dist/schema.js +0 -833
- package/dist/schema.mjs +0 -814
- package/dist/type-system/format.d.ts +0 -55
- package/dist/type-system/format.js +0 -197
- package/dist/type-system/format.mjs +0 -175
- package/dist/type-system/index.d.ts +0 -45
- package/dist/type-system/index.js +0 -406
- package/dist/type-system/index.mjs +0 -394
- package/dist/type-system/types.d.ts +0 -155
- package/dist/type-system/types.js +0 -14
- package/dist/type-system/types.mjs +0 -0
- package/dist/type-system/utils.d.ts +0 -62
- package/dist/type-system/utils.js +0 -141
- package/dist/type-system/utils.mjs +0 -111
- package/dist/universal/request.d.ts +0 -29
- package/dist/universal/request.js +0 -126
- package/dist/universal/request.mjs +0 -105
- package/dist/universal/types.d.ts +0 -124
- package/dist/universal/types.js +0 -41
- package/dist/universal/types.mjs +0 -19
- package/dist/universal/utils.d.ts +0 -3
- package/dist/universal/utils.js +0 -41
- package/dist/universal/utils.mjs +0 -18
- package/dist/ws/bun.d.ts +0 -419
- package/dist/ws/bun.js +0 -14
- package/dist/ws/bun.mjs +0 -0
- package/knip.json +0 -22
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
-
mod
|
|
23
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
-
var utils_exports = {};
|
|
25
|
-
__export(utils_exports, {
|
|
26
|
-
checkFileExtension: () => checkFileExtension,
|
|
27
|
-
compile: () => compile,
|
|
28
|
-
createType: () => createType,
|
|
29
|
-
fileType: () => fileType,
|
|
30
|
-
fileTypeFromBlob: () => fileTypeFromBlob,
|
|
31
|
-
loadFileType: () => loadFileType,
|
|
32
|
-
parseFileUnit: () => parseFileUnit,
|
|
33
|
-
tryParse: () => tryParse,
|
|
34
|
-
validateFile: () => validateFile,
|
|
35
|
-
validationDetail: () => validationDetail
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(utils_exports);
|
|
38
|
-
var import_typebox = require("@sinclair/typebox"), import_value = require("@sinclair/typebox/value"), import_compiler = require("@sinclair/typebox/compiler"), import_file = require('../universal/file.js'), import_error = require('../error.js');
|
|
39
|
-
const tryParse = (v, schema) => {
|
|
40
|
-
try {
|
|
41
|
-
return JSON.parse(v);
|
|
42
|
-
} catch {
|
|
43
|
-
throw new import_error.ValidationError("property", schema, v);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
function createType(kind, func) {
|
|
47
|
-
return import_typebox.TypeRegistry.Has(kind) || import_typebox.TypeRegistry.Set(kind, func), (options = {}) => (0, import_typebox.Unsafe)({ ...options, [import_typebox.Kind]: kind });
|
|
48
|
-
}
|
|
49
|
-
const compile = (schema) => {
|
|
50
|
-
try {
|
|
51
|
-
const compiler = import_compiler.TypeCompiler.Compile(schema);
|
|
52
|
-
return compiler.Create = () => import_value.Value.Create(schema), compiler.Error = (v) => (
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
new import_error.ValidationError("property", schema, v, compiler.Errors(v))
|
|
55
|
-
), compiler;
|
|
56
|
-
} catch {
|
|
57
|
-
return {
|
|
58
|
-
Check: (v) => import_value.Value.Check(schema, v),
|
|
59
|
-
CheckThrow: (v) => {
|
|
60
|
-
if (!import_value.Value.Check(schema, v))
|
|
61
|
-
throw new import_error.ValidationError(
|
|
62
|
-
"property",
|
|
63
|
-
schema,
|
|
64
|
-
v,
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
import_value.Value.Errors(schema, v)
|
|
67
|
-
);
|
|
68
|
-
},
|
|
69
|
-
Decode: (v) => import_value.Value.Decode(schema, v),
|
|
70
|
-
Create: () => import_value.Value.Create(schema),
|
|
71
|
-
Error: (v) => new import_error.ValidationError(
|
|
72
|
-
"property",
|
|
73
|
-
schema,
|
|
74
|
-
v,
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
import_value.Value.Errors(schema, v)
|
|
77
|
-
)
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}, parseFileUnit = (size) => {
|
|
81
|
-
if (typeof size == "string")
|
|
82
|
-
switch (size.slice(-1)) {
|
|
83
|
-
case "k":
|
|
84
|
-
return +size.slice(0, size.length - 1) * 1024;
|
|
85
|
-
case "m":
|
|
86
|
-
return +size.slice(0, size.length - 1) * 1048576;
|
|
87
|
-
default:
|
|
88
|
-
return +size;
|
|
89
|
-
}
|
|
90
|
-
return size;
|
|
91
|
-
}, checkFileExtension = (type, extension) => type.startsWith(extension) ? !0 : extension.charCodeAt(extension.length - 1) === 42 && extension.charCodeAt(extension.length - 2) === 47 && type.startsWith(extension.slice(0, -1));
|
|
92
|
-
let _fileTypeFromBlobWarn = !1;
|
|
93
|
-
const warnIfFileTypeIsNotInstalled = () => {
|
|
94
|
-
_fileTypeFromBlobWarn || (console.warn(
|
|
95
|
-
"[Elysia] Attempt to validate file type without 'file-type'. This may lead to security risks. We recommend installing 'file-type' to properly validate file extension."
|
|
96
|
-
), _fileTypeFromBlobWarn = !0);
|
|
97
|
-
}, loadFileType = async () => import("file-type").then((x) => (_fileTypeFromBlob = x.fileTypeFromBlob, _fileTypeFromBlob)).catch(warnIfFileTypeIsNotInstalled);
|
|
98
|
-
let _fileTypeFromBlob;
|
|
99
|
-
const fileTypeFromBlob = (file) => _fileTypeFromBlob ? _fileTypeFromBlob(file) : loadFileType().then((mod) => {
|
|
100
|
-
if (mod) return mod(file);
|
|
101
|
-
}), fileType = async (file, extension, name = file?.name ?? "") => {
|
|
102
|
-
if (Array.isArray(file))
|
|
103
|
-
return await Promise.all(file.map((f) => fileType(f, extension, name))), !0;
|
|
104
|
-
if (!file) return !1;
|
|
105
|
-
const result = await fileTypeFromBlob(file);
|
|
106
|
-
if (!result) throw new import_error.InvalidFileType(name, extension);
|
|
107
|
-
if (typeof extension == "string" && !checkFileExtension(result.mime, extension))
|
|
108
|
-
throw new import_error.InvalidFileType(name, extension);
|
|
109
|
-
for (let i = 0; i < extension.length; i++)
|
|
110
|
-
if (checkFileExtension(result.mime, extension[i])) return !0;
|
|
111
|
-
throw new import_error.InvalidFileType(name, extension);
|
|
112
|
-
}, validateFile = (options, value) => {
|
|
113
|
-
if (value instanceof import_file.ElysiaFile) return !0;
|
|
114
|
-
if (!(value instanceof Blob) || options.minSize && value.size < parseFileUnit(options.minSize) || options.maxSize && value.size > parseFileUnit(options.maxSize))
|
|
115
|
-
return !1;
|
|
116
|
-
if (options.extension) {
|
|
117
|
-
if (typeof options.extension == "string")
|
|
118
|
-
return checkFileExtension(value.type, options.extension);
|
|
119
|
-
for (let i = 0; i < options.extension.length; i++)
|
|
120
|
-
if (checkFileExtension(value.type, options.extension[i]))
|
|
121
|
-
return !0;
|
|
122
|
-
return !1;
|
|
123
|
-
}
|
|
124
|
-
return !0;
|
|
125
|
-
}, validationDetail = (message) => (error) => ({
|
|
126
|
-
...error,
|
|
127
|
-
message
|
|
128
|
-
});
|
|
129
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
-
0 && (module.exports = {
|
|
131
|
-
checkFileExtension,
|
|
132
|
-
compile,
|
|
133
|
-
createType,
|
|
134
|
-
fileType,
|
|
135
|
-
fileTypeFromBlob,
|
|
136
|
-
loadFileType,
|
|
137
|
-
parseFileUnit,
|
|
138
|
-
tryParse,
|
|
139
|
-
validateFile,
|
|
140
|
-
validationDetail
|
|
141
|
-
});
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Kind,
|
|
3
|
-
TypeRegistry,
|
|
4
|
-
Unsafe
|
|
5
|
-
} from "@sinclair/typebox";
|
|
6
|
-
import { Value } from "@sinclair/typebox/value";
|
|
7
|
-
import { TypeCompiler } from "@sinclair/typebox/compiler";
|
|
8
|
-
import { ElysiaFile } from "../universal/file.mjs";
|
|
9
|
-
import { InvalidFileType, ValidationError } from "../error.mjs";
|
|
10
|
-
const tryParse = (v, schema) => {
|
|
11
|
-
try {
|
|
12
|
-
return JSON.parse(v);
|
|
13
|
-
} catch {
|
|
14
|
-
throw new ValidationError("property", schema, v);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
function createType(kind, func) {
|
|
18
|
-
return TypeRegistry.Has(kind) || TypeRegistry.Set(kind, func), (options = {}) => Unsafe({ ...options, [Kind]: kind });
|
|
19
|
-
}
|
|
20
|
-
const compile = (schema) => {
|
|
21
|
-
try {
|
|
22
|
-
const compiler = TypeCompiler.Compile(schema);
|
|
23
|
-
return compiler.Create = () => Value.Create(schema), compiler.Error = (v) => (
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
new ValidationError("property", schema, v, compiler.Errors(v))
|
|
26
|
-
), compiler;
|
|
27
|
-
} catch {
|
|
28
|
-
return {
|
|
29
|
-
Check: (v) => Value.Check(schema, v),
|
|
30
|
-
CheckThrow: (v) => {
|
|
31
|
-
if (!Value.Check(schema, v))
|
|
32
|
-
throw new ValidationError(
|
|
33
|
-
"property",
|
|
34
|
-
schema,
|
|
35
|
-
v,
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
Value.Errors(schema, v)
|
|
38
|
-
);
|
|
39
|
-
},
|
|
40
|
-
Decode: (v) => Value.Decode(schema, v),
|
|
41
|
-
Create: () => Value.Create(schema),
|
|
42
|
-
Error: (v) => new ValidationError(
|
|
43
|
-
"property",
|
|
44
|
-
schema,
|
|
45
|
-
v,
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
Value.Errors(schema, v)
|
|
48
|
-
)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}, parseFileUnit = (size) => {
|
|
52
|
-
if (typeof size == "string")
|
|
53
|
-
switch (size.slice(-1)) {
|
|
54
|
-
case "k":
|
|
55
|
-
return +size.slice(0, size.length - 1) * 1024;
|
|
56
|
-
case "m":
|
|
57
|
-
return +size.slice(0, size.length - 1) * 1048576;
|
|
58
|
-
default:
|
|
59
|
-
return +size;
|
|
60
|
-
}
|
|
61
|
-
return size;
|
|
62
|
-
}, checkFileExtension = (type, extension) => type.startsWith(extension) ? !0 : extension.charCodeAt(extension.length - 1) === 42 && extension.charCodeAt(extension.length - 2) === 47 && type.startsWith(extension.slice(0, -1));
|
|
63
|
-
let _fileTypeFromBlobWarn = !1;
|
|
64
|
-
const warnIfFileTypeIsNotInstalled = () => {
|
|
65
|
-
_fileTypeFromBlobWarn || (console.warn(
|
|
66
|
-
"[Elysia] Attempt to validate file type without 'file-type'. This may lead to security risks. We recommend installing 'file-type' to properly validate file extension."
|
|
67
|
-
), _fileTypeFromBlobWarn = !0);
|
|
68
|
-
}, loadFileType = async () => import("file-type").then((x) => (_fileTypeFromBlob = x.fileTypeFromBlob, _fileTypeFromBlob)).catch(warnIfFileTypeIsNotInstalled);
|
|
69
|
-
let _fileTypeFromBlob;
|
|
70
|
-
const fileTypeFromBlob = (file) => _fileTypeFromBlob ? _fileTypeFromBlob(file) : loadFileType().then((mod) => {
|
|
71
|
-
if (mod) return mod(file);
|
|
72
|
-
}), fileType = async (file, extension, name = file?.name ?? "") => {
|
|
73
|
-
if (Array.isArray(file))
|
|
74
|
-
return await Promise.all(file.map((f) => fileType(f, extension, name))), !0;
|
|
75
|
-
if (!file) return !1;
|
|
76
|
-
const result = await fileTypeFromBlob(file);
|
|
77
|
-
if (!result) throw new InvalidFileType(name, extension);
|
|
78
|
-
if (typeof extension == "string" && !checkFileExtension(result.mime, extension))
|
|
79
|
-
throw new InvalidFileType(name, extension);
|
|
80
|
-
for (let i = 0; i < extension.length; i++)
|
|
81
|
-
if (checkFileExtension(result.mime, extension[i])) return !0;
|
|
82
|
-
throw new InvalidFileType(name, extension);
|
|
83
|
-
}, validateFile = (options, value) => {
|
|
84
|
-
if (value instanceof ElysiaFile) return !0;
|
|
85
|
-
if (!(value instanceof Blob) || options.minSize && value.size < parseFileUnit(options.minSize) || options.maxSize && value.size > parseFileUnit(options.maxSize))
|
|
86
|
-
return !1;
|
|
87
|
-
if (options.extension) {
|
|
88
|
-
if (typeof options.extension == "string")
|
|
89
|
-
return checkFileExtension(value.type, options.extension);
|
|
90
|
-
for (let i = 0; i < options.extension.length; i++)
|
|
91
|
-
if (checkFileExtension(value.type, options.extension[i]))
|
|
92
|
-
return !0;
|
|
93
|
-
return !1;
|
|
94
|
-
}
|
|
95
|
-
return !0;
|
|
96
|
-
}, validationDetail = (message) => (error) => ({
|
|
97
|
-
...error,
|
|
98
|
-
message
|
|
99
|
-
});
|
|
100
|
-
export {
|
|
101
|
-
checkFileExtension,
|
|
102
|
-
compile,
|
|
103
|
-
createType,
|
|
104
|
-
fileType,
|
|
105
|
-
fileTypeFromBlob,
|
|
106
|
-
loadFileType,
|
|
107
|
-
parseFileUnit,
|
|
108
|
-
tryParse,
|
|
109
|
-
validateFile,
|
|
110
|
-
validationDetail
|
|
111
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { RequestCache, RequestCredentials, RequestDestination, RequestDuplex, RequestInfo, RequestInit, RequestMode, RequestRedirect, WebStandardRequest } from './types';
|
|
2
|
-
export declare class ElysiaRequest implements WebStandardRequest {
|
|
3
|
-
private input;
|
|
4
|
-
private init?;
|
|
5
|
-
constructor(input: RequestInfo, init?: RequestInit | undefined);
|
|
6
|
-
readonly cache: RequestCache;
|
|
7
|
-
readonly credentials: RequestCredentials;
|
|
8
|
-
readonly destination: RequestDestination;
|
|
9
|
-
readonly integrity: string;
|
|
10
|
-
readonly method: string;
|
|
11
|
-
readonly mode: RequestMode;
|
|
12
|
-
readonly redirect: RequestRedirect;
|
|
13
|
-
readonly referrerPolicy: string;
|
|
14
|
-
readonly url: string;
|
|
15
|
-
private _headers;
|
|
16
|
-
get headers(): Headers;
|
|
17
|
-
readonly keepalive: boolean;
|
|
18
|
-
private _signal;
|
|
19
|
-
get signal(): AbortSignal;
|
|
20
|
-
readonly duplex: RequestDuplex;
|
|
21
|
-
readonly bodyUsed: boolean;
|
|
22
|
-
get body(): ReadableStream | null;
|
|
23
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
24
|
-
blob(): Promise<Blob>;
|
|
25
|
-
formData(): Promise<FormData>;
|
|
26
|
-
json(): Promise<any>;
|
|
27
|
-
text(): Promise<string>;
|
|
28
|
-
clone(): ElysiaRequest;
|
|
29
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
-
var request_exports = {};
|
|
17
|
-
__export(request_exports, {
|
|
18
|
-
ElysiaRequest: () => ElysiaRequest
|
|
19
|
-
});
|
|
20
|
-
module.exports = __toCommonJS(request_exports);
|
|
21
|
-
class ElysiaRequest {
|
|
22
|
-
constructor(input, init) {
|
|
23
|
-
this.input = input;
|
|
24
|
-
this.init = init;
|
|
25
|
-
this.cache = "default";
|
|
26
|
-
this.credentials = "omit";
|
|
27
|
-
this.destination = "";
|
|
28
|
-
this.integrity = "";
|
|
29
|
-
this.method = "GET";
|
|
30
|
-
this.mode = "no-cors";
|
|
31
|
-
this.redirect = "manual";
|
|
32
|
-
this.referrerPolicy = "";
|
|
33
|
-
this.keepalive = !1;
|
|
34
|
-
this.duplex = "half";
|
|
35
|
-
this.bodyUsed = !1;
|
|
36
|
-
if (typeof input == "string") this.url = input;
|
|
37
|
-
else if (input instanceof URL) this.url = input.href;
|
|
38
|
-
else if (input instanceof Request) this.url = input.url;
|
|
39
|
-
else throw new TypeError("Invalid url");
|
|
40
|
-
init && (init.method && (this.method = init.method), init.keepalive && (this.keepalive = init.keepalive), init.redirect && (this.redirect = init.redirect), init.integrity && (this.integrity = init.integrity), init.signal && (this._signal = init.signal), init.credentials && (this.credentials = init.credentials), init.mode && (this.mode = init.mode), init.referrerPolicy && (this.referrerPolicy = init.referrerPolicy), init.duplex && (this.duplex = init.duplex));
|
|
41
|
-
}
|
|
42
|
-
get headers() {
|
|
43
|
-
if (this._headers) return this._headers;
|
|
44
|
-
if (!this.init?.headers) return this._headers = new Headers();
|
|
45
|
-
const headers = this.init.headers;
|
|
46
|
-
return Array.isArray(headers) ? this._headers = new Headers(headers) : headers instanceof Headers ? this._headers = headers : headers ? this._headers = new Headers(headers) : this._headers = new Headers();
|
|
47
|
-
}
|
|
48
|
-
get signal() {
|
|
49
|
-
return this._signal ? this._signal : this._signal = new AbortController().signal;
|
|
50
|
-
}
|
|
51
|
-
get body() {
|
|
52
|
-
if (this.method === "GET" || this.method === "HEAD" || !this.init?.body)
|
|
53
|
-
return null;
|
|
54
|
-
const body = this.init.body;
|
|
55
|
-
return body instanceof ReadableStream ? body : body instanceof ArrayBuffer ? new ReadableStream({
|
|
56
|
-
start(controller) {
|
|
57
|
-
controller.enqueue(body), controller.close();
|
|
58
|
-
}
|
|
59
|
-
}) : body instanceof Blob ? body.stream() : typeof body == "string" ? new ReadableStream({
|
|
60
|
-
start(controller) {
|
|
61
|
-
controller.enqueue(new TextEncoder().encode(body)), controller.close();
|
|
62
|
-
}
|
|
63
|
-
}) : body instanceof URLSearchParams || body instanceof FormData ? new ReadableStream({
|
|
64
|
-
start(controller) {
|
|
65
|
-
controller.enqueue(
|
|
66
|
-
new TextEncoder().encode(body.toString())
|
|
67
|
-
), controller.close();
|
|
68
|
-
}
|
|
69
|
-
}) : body instanceof DataView ? new ReadableStream({
|
|
70
|
-
start(controller) {
|
|
71
|
-
controller.enqueue(body.buffer), controller.close();
|
|
72
|
-
}
|
|
73
|
-
}) : Symbol.iterator in body ? new ReadableStream({
|
|
74
|
-
start(controller) {
|
|
75
|
-
for (const chunk of body) controller.enqueue(chunk);
|
|
76
|
-
controller.close();
|
|
77
|
-
}
|
|
78
|
-
}) : Symbol.asyncIterator in body ? new ReadableStream({
|
|
79
|
-
async start(controller) {
|
|
80
|
-
for await (const chunk of body) controller.enqueue(chunk);
|
|
81
|
-
controller.close();
|
|
82
|
-
}
|
|
83
|
-
}) : null;
|
|
84
|
-
}
|
|
85
|
-
async arrayBuffer() {
|
|
86
|
-
if (this.init?.body instanceof ArrayBuffer) return this.init.body;
|
|
87
|
-
if (!this.body) return new ArrayBuffer(0);
|
|
88
|
-
const chunks = [];
|
|
89
|
-
for await (const chunk of this.body) chunks.push(chunk);
|
|
90
|
-
return Buffer.concat(chunks);
|
|
91
|
-
}
|
|
92
|
-
async blob() {
|
|
93
|
-
if (this.init?.body instanceof Blob) return this.init.body;
|
|
94
|
-
const buffer = await this.arrayBuffer();
|
|
95
|
-
return new Blob([buffer]);
|
|
96
|
-
}
|
|
97
|
-
async formData() {
|
|
98
|
-
if (this.init?.body instanceof FormData) return this.init.body;
|
|
99
|
-
throw new Error("Unable to parse body as FormData");
|
|
100
|
-
}
|
|
101
|
-
async json() {
|
|
102
|
-
return this.init?.body instanceof ReadableStream ? JSON.parse(await readableStreamToString(this.init.body)) : typeof this.init?.body == "string" ? JSON.parse(this.init.body) : this.init?.body instanceof ArrayBuffer ? JSON.parse(Buffer.from(this.init.body).toString()) : JSON.parse(Buffer.from(await this.arrayBuffer()).toString());
|
|
103
|
-
}
|
|
104
|
-
async text() {
|
|
105
|
-
if (this.init?.body instanceof ReadableStream)
|
|
106
|
-
return readableStreamToString(this.init.body);
|
|
107
|
-
if (typeof this.init?.body == "string") return this.init.body;
|
|
108
|
-
if (this.init?.body instanceof ArrayBuffer)
|
|
109
|
-
return Buffer.from(this.init.body).toString();
|
|
110
|
-
const buffer = await this.arrayBuffer();
|
|
111
|
-
return Buffer.from(buffer).toString();
|
|
112
|
-
}
|
|
113
|
-
// @ts-ignore
|
|
114
|
-
clone() {
|
|
115
|
-
return new ElysiaRequest(this.input, this.init);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
async function readableStreamToString(stream) {
|
|
119
|
-
const chunks = [];
|
|
120
|
-
for await (const chunk of stream) chunks.push(chunk);
|
|
121
|
-
return Buffer.from(Buffer.concat(chunks)).toString();
|
|
122
|
-
}
|
|
123
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
-
0 && (module.exports = {
|
|
125
|
-
ElysiaRequest
|
|
126
|
-
});
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
class ElysiaRequest {
|
|
2
|
-
constructor(input, init) {
|
|
3
|
-
this.input = input;
|
|
4
|
-
this.init = init;
|
|
5
|
-
this.cache = "default";
|
|
6
|
-
this.credentials = "omit";
|
|
7
|
-
this.destination = "";
|
|
8
|
-
this.integrity = "";
|
|
9
|
-
this.method = "GET";
|
|
10
|
-
this.mode = "no-cors";
|
|
11
|
-
this.redirect = "manual";
|
|
12
|
-
this.referrerPolicy = "";
|
|
13
|
-
this.keepalive = !1;
|
|
14
|
-
this.duplex = "half";
|
|
15
|
-
this.bodyUsed = !1;
|
|
16
|
-
if (typeof input == "string") this.url = input;
|
|
17
|
-
else if (input instanceof URL) this.url = input.href;
|
|
18
|
-
else if (input instanceof Request) this.url = input.url;
|
|
19
|
-
else throw new TypeError("Invalid url");
|
|
20
|
-
init && (init.method && (this.method = init.method), init.keepalive && (this.keepalive = init.keepalive), init.redirect && (this.redirect = init.redirect), init.integrity && (this.integrity = init.integrity), init.signal && (this._signal = init.signal), init.credentials && (this.credentials = init.credentials), init.mode && (this.mode = init.mode), init.referrerPolicy && (this.referrerPolicy = init.referrerPolicy), init.duplex && (this.duplex = init.duplex));
|
|
21
|
-
}
|
|
22
|
-
get headers() {
|
|
23
|
-
if (this._headers) return this._headers;
|
|
24
|
-
if (!this.init?.headers) return this._headers = new Headers();
|
|
25
|
-
const headers = this.init.headers;
|
|
26
|
-
return Array.isArray(headers) ? this._headers = new Headers(headers) : headers instanceof Headers ? this._headers = headers : headers ? this._headers = new Headers(headers) : this._headers = new Headers();
|
|
27
|
-
}
|
|
28
|
-
get signal() {
|
|
29
|
-
return this._signal ? this._signal : this._signal = new AbortController().signal;
|
|
30
|
-
}
|
|
31
|
-
get body() {
|
|
32
|
-
if (this.method === "GET" || this.method === "HEAD" || !this.init?.body)
|
|
33
|
-
return null;
|
|
34
|
-
const body = this.init.body;
|
|
35
|
-
return body instanceof ReadableStream ? body : body instanceof ArrayBuffer ? new ReadableStream({
|
|
36
|
-
start(controller) {
|
|
37
|
-
controller.enqueue(body), controller.close();
|
|
38
|
-
}
|
|
39
|
-
}) : body instanceof Blob ? body.stream() : typeof body == "string" ? new ReadableStream({
|
|
40
|
-
start(controller) {
|
|
41
|
-
controller.enqueue(new TextEncoder().encode(body)), controller.close();
|
|
42
|
-
}
|
|
43
|
-
}) : body instanceof URLSearchParams || body instanceof FormData ? new ReadableStream({
|
|
44
|
-
start(controller) {
|
|
45
|
-
controller.enqueue(
|
|
46
|
-
new TextEncoder().encode(body.toString())
|
|
47
|
-
), controller.close();
|
|
48
|
-
}
|
|
49
|
-
}) : body instanceof DataView ? new ReadableStream({
|
|
50
|
-
start(controller) {
|
|
51
|
-
controller.enqueue(body.buffer), controller.close();
|
|
52
|
-
}
|
|
53
|
-
}) : Symbol.iterator in body ? new ReadableStream({
|
|
54
|
-
start(controller) {
|
|
55
|
-
for (const chunk of body) controller.enqueue(chunk);
|
|
56
|
-
controller.close();
|
|
57
|
-
}
|
|
58
|
-
}) : Symbol.asyncIterator in body ? new ReadableStream({
|
|
59
|
-
async start(controller) {
|
|
60
|
-
for await (const chunk of body) controller.enqueue(chunk);
|
|
61
|
-
controller.close();
|
|
62
|
-
}
|
|
63
|
-
}) : null;
|
|
64
|
-
}
|
|
65
|
-
async arrayBuffer() {
|
|
66
|
-
if (this.init?.body instanceof ArrayBuffer) return this.init.body;
|
|
67
|
-
if (!this.body) return new ArrayBuffer(0);
|
|
68
|
-
const chunks = [];
|
|
69
|
-
for await (const chunk of this.body) chunks.push(chunk);
|
|
70
|
-
return Buffer.concat(chunks);
|
|
71
|
-
}
|
|
72
|
-
async blob() {
|
|
73
|
-
if (this.init?.body instanceof Blob) return this.init.body;
|
|
74
|
-
const buffer = await this.arrayBuffer();
|
|
75
|
-
return new Blob([buffer]);
|
|
76
|
-
}
|
|
77
|
-
async formData() {
|
|
78
|
-
if (this.init?.body instanceof FormData) return this.init.body;
|
|
79
|
-
throw new Error("Unable to parse body as FormData");
|
|
80
|
-
}
|
|
81
|
-
async json() {
|
|
82
|
-
return this.init?.body instanceof ReadableStream ? JSON.parse(await readableStreamToString(this.init.body)) : typeof this.init?.body == "string" ? JSON.parse(this.init.body) : this.init?.body instanceof ArrayBuffer ? JSON.parse(Buffer.from(this.init.body).toString()) : JSON.parse(Buffer.from(await this.arrayBuffer()).toString());
|
|
83
|
-
}
|
|
84
|
-
async text() {
|
|
85
|
-
if (this.init?.body instanceof ReadableStream)
|
|
86
|
-
return readableStreamToString(this.init.body);
|
|
87
|
-
if (typeof this.init?.body == "string") return this.init.body;
|
|
88
|
-
if (this.init?.body instanceof ArrayBuffer)
|
|
89
|
-
return Buffer.from(this.init.body).toString();
|
|
90
|
-
const buffer = await this.arrayBuffer();
|
|
91
|
-
return Buffer.from(buffer).toString();
|
|
92
|
-
}
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
clone() {
|
|
95
|
-
return new ElysiaRequest(this.input, this.init);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
async function readableStreamToString(stream) {
|
|
99
|
-
const chunks = [];
|
|
100
|
-
for await (const chunk of stream) chunks.push(chunk);
|
|
101
|
-
return Buffer.from(Buffer.concat(chunks)).toString();
|
|
102
|
-
}
|
|
103
|
-
export {
|
|
104
|
-
ElysiaRequest
|
|
105
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
export type RequestInfo = string | URL | Request;
|
|
2
|
-
export declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
3
|
-
export type BodyInit = ArrayBuffer | AsyncIterable<Uint8Array> | Blob | FormData | Iterable<Uint8Array> | NodeJS.ArrayBufferView | URLSearchParams | null | string;
|
|
4
|
-
export interface BodyMixin {
|
|
5
|
-
readonly body: ReadableStream | null;
|
|
6
|
-
readonly bodyUsed: boolean;
|
|
7
|
-
readonly arrayBuffer: () => Promise<ArrayBuffer>;
|
|
8
|
-
readonly blob: () => Promise<Blob>;
|
|
9
|
-
readonly formData: () => Promise<FormData>;
|
|
10
|
-
readonly json: () => Promise<unknown>;
|
|
11
|
-
readonly text: () => Promise<string>;
|
|
12
|
-
}
|
|
13
|
-
export interface SpecIterator<T, TReturn = any, TNext = undefined> {
|
|
14
|
-
next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
|
|
15
|
-
}
|
|
16
|
-
export interface SpecIterableIterator<T> extends SpecIterator<T> {
|
|
17
|
-
[Symbol.iterator](): SpecIterableIterator<T>;
|
|
18
|
-
}
|
|
19
|
-
export interface SpecIterable<T> {
|
|
20
|
-
[Symbol.iterator](): SpecIterator<T>;
|
|
21
|
-
}
|
|
22
|
-
export type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers;
|
|
23
|
-
export declare class Headers implements SpecIterable<[string, string]> {
|
|
24
|
-
constructor(init?: HeadersInit);
|
|
25
|
-
readonly append: (name: string, value: string) => void;
|
|
26
|
-
readonly delete: (name: string) => void;
|
|
27
|
-
readonly get: (name: string) => string | null;
|
|
28
|
-
readonly has: (name: string) => boolean;
|
|
29
|
-
readonly set: (name: string, value: string) => void;
|
|
30
|
-
readonly getSetCookie: () => string[];
|
|
31
|
-
readonly forEach: (callbackfn: (value: string, key: string, iterable: Headers) => void, thisArg?: unknown) => void;
|
|
32
|
-
readonly keys: () => SpecIterableIterator<string>;
|
|
33
|
-
readonly values: () => SpecIterableIterator<string>;
|
|
34
|
-
readonly entries: () => SpecIterableIterator<[string, string]>;
|
|
35
|
-
readonly [Symbol.iterator]: () => SpecIterator<[string, string]>;
|
|
36
|
-
}
|
|
37
|
-
export type RequestCache = 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
|
|
38
|
-
export type RequestCredentials = 'omit' | 'include' | 'same-origin';
|
|
39
|
-
export type RequestDestination = '' | 'audio' | 'audioworklet' | 'document' | 'embed' | 'font' | 'image' | 'manifest' | 'object' | 'paintworklet' | 'report' | 'script' | 'sharedworker' | 'style' | 'track' | 'video' | 'worker' | 'xslt';
|
|
40
|
-
export interface RequestInit {
|
|
41
|
-
method?: string;
|
|
42
|
-
keepalive?: boolean;
|
|
43
|
-
headers?: HeadersInit;
|
|
44
|
-
body?: BodyInit;
|
|
45
|
-
redirect?: RequestRedirect;
|
|
46
|
-
integrity?: string;
|
|
47
|
-
signal?: AbortSignal;
|
|
48
|
-
credentials?: RequestCredentials;
|
|
49
|
-
mode?: RequestMode;
|
|
50
|
-
referrer?: string;
|
|
51
|
-
referrerPolicy?: ReferrerPolicy;
|
|
52
|
-
window?: null;
|
|
53
|
-
dispatcher?: unknown;
|
|
54
|
-
duplex?: RequestDuplex;
|
|
55
|
-
}
|
|
56
|
-
export type ReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
57
|
-
export type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin';
|
|
58
|
-
export type RequestRedirect = 'error' | 'follow' | 'manual';
|
|
59
|
-
export type RequestDuplex = 'half';
|
|
60
|
-
export declare abstract class WebStandardRequest implements BodyMixin {
|
|
61
|
-
abstract readonly cache: RequestCache;
|
|
62
|
-
abstract readonly credentials: RequestCredentials;
|
|
63
|
-
abstract readonly destination: RequestDestination;
|
|
64
|
-
abstract readonly headers: Headers;
|
|
65
|
-
abstract readonly integrity: string;
|
|
66
|
-
abstract readonly method: string;
|
|
67
|
-
abstract readonly mode: RequestMode;
|
|
68
|
-
abstract readonly redirect: RequestRedirect;
|
|
69
|
-
abstract readonly referrerPolicy: string;
|
|
70
|
-
abstract readonly url: string;
|
|
71
|
-
abstract readonly keepalive: boolean;
|
|
72
|
-
abstract readonly signal: AbortSignal;
|
|
73
|
-
abstract readonly duplex: RequestDuplex;
|
|
74
|
-
abstract readonly body: ReadableStream | null;
|
|
75
|
-
abstract readonly bodyUsed: boolean;
|
|
76
|
-
abstract readonly arrayBuffer: () => Promise<ArrayBuffer>;
|
|
77
|
-
abstract readonly blob: () => Promise<Blob>;
|
|
78
|
-
abstract readonly formData: () => Promise<FormData>;
|
|
79
|
-
abstract readonly json: () => Promise<unknown>;
|
|
80
|
-
abstract readonly text: () => Promise<string>;
|
|
81
|
-
abstract readonly clone: () => Request;
|
|
82
|
-
}
|
|
83
|
-
export interface ResponseInit {
|
|
84
|
-
readonly status?: number;
|
|
85
|
-
readonly statusText?: string;
|
|
86
|
-
readonly headers?: HeadersInit;
|
|
87
|
-
}
|
|
88
|
-
export type ResponseType = 'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect';
|
|
89
|
-
export type ResponseRedirectStatus = 301 | 302 | 303 | 307 | 308;
|
|
90
|
-
export declare abstract class WebStandardResponse implements BodyMixin {
|
|
91
|
-
constructor(body?: BodyInit, init?: ResponseInit);
|
|
92
|
-
abstract readonly headers: Headers;
|
|
93
|
-
abstract readonly ok: boolean;
|
|
94
|
-
abstract readonly status: number;
|
|
95
|
-
abstract readonly statusText: string;
|
|
96
|
-
abstract readonly type: ResponseType;
|
|
97
|
-
abstract readonly url: string;
|
|
98
|
-
abstract readonly redirected: boolean;
|
|
99
|
-
abstract readonly body: ReadableStream | null;
|
|
100
|
-
abstract readonly bodyUsed: boolean;
|
|
101
|
-
abstract readonly arrayBuffer: () => Promise<ArrayBuffer>;
|
|
102
|
-
abstract readonly blob: () => Promise<Blob>;
|
|
103
|
-
abstract readonly formData: () => Promise<FormData>;
|
|
104
|
-
abstract readonly json: () => Promise<unknown>;
|
|
105
|
-
abstract readonly text: () => Promise<string>;
|
|
106
|
-
abstract readonly clone: () => Response;
|
|
107
|
-
static error(): Response;
|
|
108
|
-
static json(data: any, init?: ResponseInit): Response;
|
|
109
|
-
static redirect(url: string, status: ResponseRedirectStatus): Response;
|
|
110
|
-
}
|
|
111
|
-
export interface BunHTMLBundlelike {
|
|
112
|
-
index: string;
|
|
113
|
-
files?: {
|
|
114
|
-
input?: string;
|
|
115
|
-
path: string;
|
|
116
|
-
loader: any;
|
|
117
|
-
isEntry: boolean;
|
|
118
|
-
headers: {
|
|
119
|
-
etag: string;
|
|
120
|
-
'content-type': string;
|
|
121
|
-
[key: string]: string;
|
|
122
|
-
};
|
|
123
|
-
}[];
|
|
124
|
-
}
|
package/dist/universal/types.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
-
var types_exports = {};
|
|
17
|
-
__export(types_exports, {
|
|
18
|
-
WebStandardRequest: () => WebStandardRequest,
|
|
19
|
-
WebStandardResponse: () => WebStandardResponse
|
|
20
|
-
});
|
|
21
|
-
module.exports = __toCommonJS(types_exports);
|
|
22
|
-
class WebStandardRequest {
|
|
23
|
-
}
|
|
24
|
-
class WebStandardResponse {
|
|
25
|
-
constructor(body, init) {
|
|
26
|
-
}
|
|
27
|
-
static error() {
|
|
28
|
-
return Response.error();
|
|
29
|
-
}
|
|
30
|
-
static json(data, init) {
|
|
31
|
-
return Response.json(data, init);
|
|
32
|
-
}
|
|
33
|
-
static redirect(url, status) {
|
|
34
|
-
return Response.redirect(url, status);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
WebStandardRequest,
|
|
40
|
-
WebStandardResponse
|
|
41
|
-
});
|