elysia 2.0.0-beta.2 → 2.0.0-beta.21

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.
Files changed (339) hide show
  1. package/dist/adapter/bun/index.d.ts +18 -2
  2. package/dist/adapter/bun/index.js +467 -110
  3. package/dist/adapter/bun/index.mjs +467 -112
  4. package/dist/adapter/types.d.ts +2 -21
  5. package/dist/adapter/utils.d.ts +14 -3
  6. package/dist/adapter/utils.js +146 -87
  7. package/dist/adapter/utils.mjs +148 -90
  8. package/dist/adapter/web-standard/handler.d.ts +1 -1
  9. package/dist/adapter/web-standard/handler.js +47 -36
  10. package/dist/adapter/web-standard/handler.mjs +48 -37
  11. package/dist/adapter/web-standard/index.js +2 -30
  12. package/dist/adapter/web-standard/index.mjs +2 -30
  13. package/dist/adapter/web-standard/utils.js +5 -18
  14. package/dist/adapter/web-standard/utils.mjs +5 -18
  15. package/dist/base.d.ts +99 -67
  16. package/dist/base.js +678 -510
  17. package/dist/base.mjs +682 -514
  18. package/dist/compile/aot-capture.d.ts +2 -13
  19. package/dist/compile/aot-capture.js +26 -69
  20. package/dist/compile/aot-capture.mjs +28 -67
  21. package/dist/compile/aot-emit.d.ts +9 -7
  22. package/dist/compile/aot-emit.js +42 -19
  23. package/dist/compile/aot-emit.mjs +42 -20
  24. package/dist/compile/aot.d.ts +17 -19
  25. package/dist/compile/aot.js +41 -51
  26. package/dist/compile/aot.mjs +39 -49
  27. package/dist/compile/handler/descriptor.d.ts +9 -12
  28. package/dist/compile/handler/descriptor.js +19 -44
  29. package/dist/compile/handler/descriptor.mjs +20 -42
  30. package/dist/compile/handler/frozen-validator.d.ts +5 -10
  31. package/dist/compile/handler/frozen-validator.js +55 -105
  32. package/dist/compile/handler/frozen-validator.mjs +53 -105
  33. package/dist/compile/handler/index.d.ts +7 -5
  34. package/dist/compile/handler/index.js +270 -111
  35. package/dist/compile/handler/index.mjs +270 -113
  36. package/dist/compile/handler/jit.d.ts +19 -17
  37. package/dist/compile/handler/jit.js +222 -149
  38. package/dist/compile/handler/jit.mjs +224 -152
  39. package/dist/compile/handler/params.d.ts +1 -4
  40. package/dist/compile/handler/params.js +10 -5
  41. package/dist/compile/handler/params.mjs +14 -8
  42. package/dist/compile/handler/reconstruct.d.ts +2 -2
  43. package/dist/compile/handler/reconstruct.js +6 -4
  44. package/dist/compile/handler/reconstruct.mjs +6 -4
  45. package/dist/compile/handler/static-clone-resolver.d.ts +6 -0
  46. package/dist/compile/handler/static-clone-resolver.js +8 -0
  47. package/dist/compile/handler/static-clone-resolver.mjs +7 -0
  48. package/dist/compile/handler/utils.d.ts +22 -11
  49. package/dist/compile/handler/utils.js +159 -253
  50. package/dist/compile/handler/utils.mjs +155 -252
  51. package/dist/compile/jit-probe.d.ts +2 -2
  52. package/dist/compile/jit-probe.js +2 -3
  53. package/dist/compile/jit-probe.mjs +2 -3
  54. package/dist/compile/lexer.d.ts +7 -4
  55. package/dist/compile/lexer.js +268 -6
  56. package/dist/compile/lexer.mjs +268 -4
  57. package/dist/compile/utils.js +7 -4
  58. package/dist/compile/utils.mjs +7 -4
  59. package/dist/compiled.d.ts +0 -1
  60. package/dist/compiled.js +0 -1
  61. package/dist/compiled.mjs +0 -1
  62. package/dist/context.d.ts +14 -4
  63. package/dist/context.js +17 -32
  64. package/dist/context.mjs +19 -34
  65. package/dist/cookie/config.d.ts +7 -2
  66. package/dist/cookie/config.js +76 -16
  67. package/dist/cookie/config.mjs +77 -18
  68. package/dist/cookie/cookie.d.ts +1 -1
  69. package/dist/cookie/cookie.js +8 -10
  70. package/dist/cookie/cookie.mjs +8 -10
  71. package/dist/cookie/crypto.d.ts +8 -7
  72. package/dist/cookie/crypto.js +51 -40
  73. package/dist/cookie/crypto.mjs +51 -41
  74. package/dist/cookie/error.d.ts +1 -2
  75. package/dist/cookie/error.js +6 -4
  76. package/dist/cookie/error.mjs +6 -4
  77. package/dist/cookie/lib.js +7 -2
  78. package/dist/cookie/lib.mjs +7 -2
  79. package/dist/cookie/serialize.js +1 -1
  80. package/dist/cookie/serialize.mjs +1 -1
  81. package/dist/cookie/types.d.ts +10 -0
  82. package/dist/cookie/utils.d.ts +4 -8
  83. package/dist/cookie/utils.js +86 -52
  84. package/dist/cookie/utils.mjs +89 -54
  85. package/dist/error.d.ts +113 -103
  86. package/dist/error.js +181 -117
  87. package/dist/error.mjs +179 -118
  88. package/dist/generation.d.ts +2 -2
  89. package/dist/handler/error.d.ts +26 -15
  90. package/dist/handler/error.js +77 -96
  91. package/dist/handler/error.mjs +74 -97
  92. package/dist/handler/fetch.js +87 -108
  93. package/dist/handler/fetch.mjs +89 -110
  94. package/dist/handler/utils.d.ts +12 -6
  95. package/dist/handler/utils.js +84 -28
  96. package/dist/handler/utils.mjs +80 -28
  97. package/dist/index.d.ts +12 -12
  98. package/dist/index.js +2 -9
  99. package/dist/index.mjs +1 -1
  100. package/dist/memory.js +1 -1
  101. package/dist/memory.mjs +1 -1
  102. package/dist/package.js +1 -1
  103. package/dist/package.mjs +1 -1
  104. package/dist/plugin/aot/bun.d.ts +8 -1
  105. package/dist/plugin/aot/bun.js +16 -9
  106. package/dist/plugin/aot/bun.mjs +17 -10
  107. package/dist/plugin/aot/core.d.ts +52 -60
  108. package/dist/plugin/aot/core.js +208 -109
  109. package/dist/plugin/aot/core.mjs +205 -111
  110. package/dist/plugin/aot/esbuild.js +8 -5
  111. package/dist/plugin/aot/esbuild.mjs +9 -6
  112. package/dist/plugin/aot/hooks.d.ts +6 -17
  113. package/dist/plugin/aot/hooks.js +36 -14
  114. package/dist/plugin/aot/hooks.mjs +37 -16
  115. package/dist/plugin/aot/rspack-loader.d.ts +1 -5
  116. package/dist/plugin/aot/rspack-loader.js +1 -10
  117. package/dist/plugin/aot/rspack-loader.mjs +1 -10
  118. package/dist/plugin/aot/rspack.js +2 -5
  119. package/dist/plugin/aot/rspack.mjs +3 -6
  120. package/dist/plugin/aot/source.d.ts +6 -42
  121. package/dist/plugin/aot/source.js +71 -71
  122. package/dist/plugin/aot/source.mjs +72 -72
  123. package/dist/plugin/aot/treeshake.js +2 -6
  124. package/dist/plugin/aot/treeshake.mjs +2 -6
  125. package/dist/plugin/aot/unplugin.d.ts +1 -4
  126. package/dist/plugin/aot/unplugin.js +4 -13
  127. package/dist/plugin/aot/unplugin.mjs +4 -13
  128. package/dist/plugin/aot/vite.d.ts +2 -6
  129. package/dist/plugin/aot/worker.js +2 -2
  130. package/dist/plugin/aot/worker.mjs +2 -2
  131. package/dist/plugin/auto-head.js +1 -10
  132. package/dist/plugin/auto-head.mjs +1 -10
  133. package/dist/plugin/trace.d.ts +2 -1
  134. package/dist/route-table.d.ts +3 -0
  135. package/dist/route-table.js +16 -11
  136. package/dist/route-table.mjs +16 -11
  137. package/dist/schema-snapshot.d.ts +0 -4
  138. package/dist/schema-snapshot.js +32 -49
  139. package/dist/schema-snapshot.mjs +32 -49
  140. package/dist/sucrose.d.ts +6 -55
  141. package/dist/sucrose.js +103 -731
  142. package/dist/sucrose.mjs +102 -724
  143. package/dist/trace.d.ts +5 -8
  144. package/dist/trace.js +23 -134
  145. package/dist/trace.mjs +24 -135
  146. package/dist/type/bridge-live.d.ts +4 -2
  147. package/dist/type/bridge-live.js +6 -3
  148. package/dist/type/bridge-live.mjs +4 -2
  149. package/dist/type/bridge.d.ts +6 -4
  150. package/dist/type/bridge.js +17 -9
  151. package/dist/type/bridge.mjs +5 -3
  152. package/dist/type/coerce-plan.d.ts +5 -5
  153. package/dist/type/coerce-plan.js +41 -39
  154. package/dist/type/coerce-plan.mjs +43 -39
  155. package/dist/type/coerce.d.ts +3 -7
  156. package/dist/type/coerce.js +18 -75
  157. package/dist/type/coerce.mjs +19 -76
  158. package/dist/type/compat.d.ts +3 -0
  159. package/dist/type/compat.js +23 -14
  160. package/dist/type/compat.mjs +20 -10
  161. package/dist/type/elysia/array-buffer.d.ts +4 -1
  162. package/dist/type/elysia/array-buffer.js +17 -17
  163. package/dist/type/elysia/array-buffer.mjs +17 -17
  164. package/dist/type/elysia/array-string.js +2 -40
  165. package/dist/type/elysia/array-string.mjs +2 -39
  166. package/dist/type/elysia/array.js +5 -9
  167. package/dist/type/elysia/array.mjs +5 -9
  168. package/dist/type/elysia/boolean-string.js +2 -3
  169. package/dist/type/elysia/boolean-string.mjs +1 -1
  170. package/dist/type/elysia/boolean.js +3 -12
  171. package/dist/type/elysia/boolean.mjs +3 -11
  172. package/dist/type/elysia/cookie.d.ts +3 -4
  173. package/dist/type/elysia/cookie.js +5 -15
  174. package/dist/type/elysia/cookie.mjs +5 -15
  175. package/dist/type/elysia/date.js +13 -20
  176. package/dist/type/elysia/date.mjs +10 -16
  177. package/dist/type/elysia/file-type.d.ts +11 -4
  178. package/dist/type/elysia/file-type.js +17 -2
  179. package/dist/type/elysia/file-type.mjs +17 -3
  180. package/dist/type/elysia/file.d.ts +1 -3
  181. package/dist/type/elysia/file.js +11 -27
  182. package/dist/type/elysia/file.mjs +11 -12
  183. package/dist/type/elysia/files.js +7 -11
  184. package/dist/type/elysia/files.mjs +7 -10
  185. package/dist/type/elysia/form.js +2 -3
  186. package/dist/type/elysia/form.mjs +3 -3
  187. package/dist/type/elysia/integer-string.d.ts +1 -1
  188. package/dist/type/elysia/integer-string.js +4 -30
  189. package/dist/type/elysia/integer-string.mjs +5 -30
  190. package/dist/type/elysia/integer.js +3 -12
  191. package/dist/type/elysia/integer.mjs +3 -11
  192. package/dist/type/elysia/intersect.js +0 -5
  193. package/dist/type/elysia/intersect.mjs +0 -5
  194. package/dist/type/elysia/json-string.d.ts +7 -0
  195. package/dist/type/elysia/json-string.js +47 -0
  196. package/dist/type/elysia/json-string.mjs +46 -0
  197. package/dist/type/elysia/keep-config.d.ts +14 -0
  198. package/dist/type/elysia/keep-config.js +62 -0
  199. package/dist/type/elysia/keep-config.mjs +53 -0
  200. package/dist/type/elysia/maybe-empty.js +3 -4
  201. package/dist/type/elysia/maybe-empty.mjs +1 -1
  202. package/dist/type/elysia/nullable.js +2 -3
  203. package/dist/type/elysia/nullable.mjs +1 -1
  204. package/dist/type/elysia/number.d.ts +2 -1
  205. package/dist/type/elysia/number.js +19 -11
  206. package/dist/type/elysia/number.mjs +18 -10
  207. package/dist/type/elysia/numeric-enum.d.ts +1 -1
  208. package/dist/type/elysia/numeric-enum.js +4 -5
  209. package/dist/type/elysia/numeric-enum.mjs +3 -3
  210. package/dist/type/elysia/numeric.d.ts +4 -2
  211. package/dist/type/elysia/numeric.js +20 -17
  212. package/dist/type/elysia/numeric.mjs +19 -16
  213. package/dist/type/elysia/object-string.js +2 -37
  214. package/dist/type/elysia/object-string.mjs +2 -36
  215. package/dist/type/elysia/object.js +5 -9
  216. package/dist/type/elysia/object.mjs +5 -9
  217. package/dist/type/elysia/optional.js +8 -8
  218. package/dist/type/elysia/optional.mjs +7 -7
  219. package/dist/type/elysia/problem.d.ts +20 -0
  220. package/dist/type/elysia/problem.js +25 -0
  221. package/dist/type/elysia/problem.mjs +24 -0
  222. package/dist/type/elysia/string.js +4 -3
  223. package/dist/type/elysia/string.mjs +4 -2
  224. package/dist/type/elysia/uint8-array.d.ts +1 -1
  225. package/dist/type/elysia/uint8-array.js +5 -20
  226. package/dist/type/elysia/uint8-array.mjs +5 -19
  227. package/dist/type/elysia/union-enum.js +7 -8
  228. package/dist/type/elysia/union-enum.mjs +6 -6
  229. package/dist/type/elysia/union.js +0 -5
  230. package/dist/type/elysia/union.mjs +0 -5
  231. package/dist/type/elysia/utils.d.ts +2 -4
  232. package/dist/type/elysia/utils.js +10 -21
  233. package/dist/type/elysia/utils.mjs +7 -15
  234. package/dist/type/exports.d.ts +4 -2
  235. package/dist/type/exports.js +23 -2
  236. package/dist/type/exports.mjs +11 -2
  237. package/dist/type/index.d.ts +10 -2
  238. package/dist/type/index.js +62 -15
  239. package/dist/type/index.mjs +65 -11
  240. package/dist/type/shared.d.ts +3 -9
  241. package/dist/type/shared.js +44 -97
  242. package/dist/type/shared.mjs +43 -97
  243. package/dist/type/sync-require.d.ts +11 -0
  244. package/dist/type/sync-require.js +14 -0
  245. package/dist/type/sync-require.mjs +12 -0
  246. package/dist/type/typebox-system-lite.d.ts +2 -0
  247. package/dist/type/typebox-system-lite.js +34 -0
  248. package/dist/type/typebox-system-lite.mjs +3 -0
  249. package/dist/type/typebox-system-require.d.ts +7 -0
  250. package/dist/type/typebox-system-require.js +24 -0
  251. package/dist/type/typebox-system-require.mjs +23 -0
  252. package/dist/type/typebox-type-live.d.ts +11 -0
  253. package/dist/type/typebox-type-live.js +45 -0
  254. package/dist/type/typebox-type-live.mjs +20 -0
  255. package/dist/type/typebox-type.d.ts +34 -0
  256. package/dist/type/typebox-type.js +199 -0
  257. package/dist/type/typebox-type.mjs +86 -0
  258. package/dist/type/typebox-value-live.d.ts +11 -0
  259. package/dist/type/typebox-value-live.js +31 -0
  260. package/dist/type/typebox-value-live.mjs +13 -0
  261. package/dist/type/typebox-value-ops.d.ts +4 -0
  262. package/dist/type/typebox-value-ops.js +90 -0
  263. package/dist/type/typebox-value-ops.mjs +5 -0
  264. package/dist/type/typebox-value-require.d.ts +8 -0
  265. package/dist/type/typebox-value-require.js +28 -0
  266. package/dist/type/typebox-value-require.mjs +25 -0
  267. package/dist/type/typebox-value.d.ts +35 -0
  268. package/dist/type/typebox-value.js +161 -0
  269. package/dist/type/typebox-value.mjs +74 -0
  270. package/dist/type/utils.js +1 -10
  271. package/dist/type/utils.mjs +1 -10
  272. package/dist/type/validator/clean-safe.d.ts +2 -4
  273. package/dist/type/validator/clean-safe.js +15 -11
  274. package/dist/type/validator/clean-safe.mjs +16 -10
  275. package/dist/type/validator/custom-error.js +12 -16
  276. package/dist/type/validator/custom-error.mjs +11 -14
  277. package/dist/type/validator/default-precompute.d.ts +9 -1
  278. package/dist/type/validator/default-precompute.js +40 -77
  279. package/dist/type/validator/default-precompute.mjs +37 -74
  280. package/dist/type/validator/exact-mirror-live.d.ts +8 -0
  281. package/dist/type/validator/exact-mirror-live.js +22 -0
  282. package/dist/type/validator/exact-mirror-live.mjs +17 -0
  283. package/dist/type/validator/exact-mirror-require.d.ts +4 -0
  284. package/dist/type/validator/exact-mirror-require.js +11 -0
  285. package/dist/type/validator/exact-mirror-require.mjs +9 -0
  286. package/dist/type/validator/exact-mirror.js +8 -8
  287. package/dist/type/validator/exact-mirror.mjs +9 -8
  288. package/dist/type/validator/frozen-check.js +5 -6
  289. package/dist/type/validator/frozen-check.mjs +6 -7
  290. package/dist/type/validator/index.d.ts +1 -0
  291. package/dist/type/validator/index.js +169 -166
  292. package/dist/type/validator/index.mjs +162 -158
  293. package/dist/type/validator/string-codec-aot.d.ts +2 -1
  294. package/dist/type/validator/string-codec-aot.js +8 -2
  295. package/dist/type/validator/string-codec-aot.mjs +7 -2
  296. package/dist/type/validator/validator-cache.d.ts +5 -4
  297. package/dist/type/validator/validator-cache.js +41 -24
  298. package/dist/type/validator/validator-cache.mjs +40 -22
  299. package/dist/types.d.ts +263 -95
  300. package/dist/universal/constants.d.ts +2 -1
  301. package/dist/universal/constants.js +3 -1
  302. package/dist/universal/constants.mjs +2 -1
  303. package/dist/universal/env.js +2 -3
  304. package/dist/universal/env.mjs +2 -3
  305. package/dist/universal/file.d.ts +6 -4
  306. package/dist/universal/file.js +11 -16
  307. package/dist/universal/file.mjs +12 -16
  308. package/dist/universal/index.d.ts +2 -2
  309. package/dist/universal/is-production.d.ts +1 -2
  310. package/dist/universal/is-production.js +1 -3
  311. package/dist/universal/is-production.mjs +2 -3
  312. package/dist/universal/server.d.ts +0 -272
  313. package/dist/utils.d.ts +43 -7
  314. package/dist/utils.js +181 -126
  315. package/dist/utils.mjs +168 -126
  316. package/dist/validator/index.d.ts +1 -1
  317. package/dist/validator/index.js +17 -30
  318. package/dist/validator/index.mjs +18 -31
  319. package/dist/validator/route.js +2 -1
  320. package/dist/validator/route.mjs +2 -1
  321. package/dist/ws/context.d.ts +8 -1
  322. package/dist/ws/context.js +68 -44
  323. package/dist/ws/context.mjs +67 -44
  324. package/dist/ws/parser.js +10 -20
  325. package/dist/ws/parser.mjs +10 -20
  326. package/dist/ws/route.d.ts +2 -2
  327. package/dist/ws/route.js +249 -141
  328. package/dist/ws/route.mjs +254 -146
  329. package/dist/ws/types.d.ts +2 -2
  330. package/package.json +23 -49
  331. package/dist/compile/analysis-cache.d.ts +0 -6
  332. package/dist/compile/analysis-cache.js +0 -12
  333. package/dist/compile/analysis-cache.mjs +0 -11
  334. package/dist/cookie/index.d.ts +0 -7
  335. package/dist/cookie/index.js +0 -13
  336. package/dist/cookie/index.mjs +0 -7
  337. package/dist/handler/index.d.ts +0 -2
  338. package/dist/handler/index.js +0 -5
  339. package/dist/handler/index.mjs +0 -3
@@ -0,0 +1,47 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_type_bridge = require('../bridge.js');
3
+ const require_type_shared = require('../shared.js');
4
+ const require_type_typebox_type = require('../typebox-type.js');
5
+ const require_type_elysia_string = require('./string.js');
6
+
7
+ //#region src/type/elysia/json-string.ts
8
+ const MEMO_LIMIT = 8192;
9
+ function jsonString(inner, open, message) {
10
+ let check;
11
+ let raw;
12
+ let parsed;
13
+ return require_type_typebox_type.Decode(require_type_typebox_type.Refine(require_type_elysia_string.StringType(), (value) => {
14
+ if (value.charCodeAt(0) !== open) return false;
15
+ if (value === raw) return true;
16
+ try {
17
+ const next = JSON.parse(value);
18
+ if (!check) try {
19
+ const compiled = require_type_bridge.Compile(inner);
20
+ require_type_shared.dropCompiledSource(compiled);
21
+ check = (v) => compiled.Check(v);
22
+ } catch {
23
+ check = (v) => require_type_bridge.Check(inner, v);
24
+ }
25
+ if (!check(next)) {
26
+ raw = parsed = void 0;
27
+ return false;
28
+ }
29
+ if (value.length <= MEMO_LIMIT) {
30
+ raw = value;
31
+ parsed = next;
32
+ }
33
+ return true;
34
+ } catch {
35
+ raw = parsed = void 0;
36
+ return false;
37
+ }
38
+ }, () => message), (value) => {
39
+ const decoded = value === raw ? parsed : JSON.parse(value);
40
+ raw = void 0;
41
+ parsed = void 0;
42
+ return require_type_bridge.Decode(inner, decoded);
43
+ });
44
+ }
45
+
46
+ //#endregion
47
+ exports.jsonString = jsonString;
@@ -0,0 +1,46 @@
1
+ import { Check, Compile, Decode } from "../bridge.mjs";
2
+ import { dropCompiledSource } from "../shared.mjs";
3
+ import { Decode as Decode$1, Refine } from "../typebox-type.mjs";
4
+ import { StringType } from "./string.mjs";
5
+
6
+ //#region src/type/elysia/json-string.ts
7
+ const MEMO_LIMIT = 8192;
8
+ function jsonString(inner, open, message) {
9
+ let check;
10
+ let raw;
11
+ let parsed;
12
+ return Decode$1(Refine(StringType(), (value) => {
13
+ if (value.charCodeAt(0) !== open) return false;
14
+ if (value === raw) return true;
15
+ try {
16
+ const next = JSON.parse(value);
17
+ if (!check) try {
18
+ const compiled = Compile(inner);
19
+ dropCompiledSource(compiled);
20
+ check = (v) => compiled.Check(v);
21
+ } catch {
22
+ check = (v) => Check(inner, v);
23
+ }
24
+ if (!check(next)) {
25
+ raw = parsed = void 0;
26
+ return false;
27
+ }
28
+ if (value.length <= MEMO_LIMIT) {
29
+ raw = value;
30
+ parsed = next;
31
+ }
32
+ return true;
33
+ } catch {
34
+ raw = parsed = void 0;
35
+ return false;
36
+ }
37
+ }, () => message), (value) => {
38
+ const decoded = value === raw ? parsed : JSON.parse(value);
39
+ raw = void 0;
40
+ parsed = void 0;
41
+ return Decode(inner, decoded);
42
+ });
43
+ }
44
+
45
+ //#endregion
46
+ export { jsonString };
@@ -0,0 +1,14 @@
1
+ import { Composite, Evaluate, Interface, Mapped, Omit, Partial, Pick, ReadonlyObject, Required } from "../typebox-type.js";
2
+
3
+ //#region src/type/elysia/keep-config.d.ts
4
+ declare const CompositeType: typeof Composite;
5
+ declare const EvaluateType: typeof Evaluate;
6
+ declare const InterfaceType: typeof Interface;
7
+ declare const MappedType: typeof Mapped;
8
+ declare const OmitType: typeof Omit;
9
+ declare const PartialType: typeof Partial;
10
+ declare const PickType: typeof Pick;
11
+ declare const ReadonlyObjectType: typeof ReadonlyObject;
12
+ declare const RequiredType: typeof Required;
13
+ //#endregion
14
+ export { CompositeType, EvaluateType, InterfaceType, MappedType, OmitType, PartialType, PickType, ReadonlyObjectType, RequiredType };
@@ -0,0 +1,62 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_utils = require('../../utils.js');
3
+ const require_type_typebox_type = require('../typebox-type.js');
4
+
5
+ //#region src/type/elysia/keep-config.ts
6
+ const carries = (schema, field = false, seen = /* @__PURE__ */ new Set()) => {
7
+ if (!schema || typeof schema !== "object" || seen.has(schema)) return false;
8
+ seen.add(schema);
9
+ if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || require_utils.compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) => carries(member, field, seen)))) return true;
10
+ if (!field) {
11
+ for (const name in schema.properties) if (carries(schema.properties[name], true)) return true;
12
+ }
13
+ return false;
14
+ };
15
+ const from = (schema, sources) => Object.defineProperty(Object.create(Object.getPrototypeOf(schema), Object.getOwnPropertyDescriptors(schema)), "~cookieFrom", {
16
+ value: sources,
17
+ writable: true,
18
+ configurable: true
19
+ });
20
+ const keep = (build, sourcesOf) => ((...args) => {
21
+ const sources = sourcesOf(...args);
22
+ const result = build(...args);
23
+ if (!sources.some((source) => carries(source))) return result;
24
+ const built = from(result, sources);
25
+ const ref = built.$ref;
26
+ const replaced = sources[0]?.$defs?.[ref];
27
+ if (replaced && built.$defs?.[ref] && built.$defs[ref] !== replaced) built.$defs = {
28
+ ...built.$defs,
29
+ [ref]: from(built.$defs[ref], [replaced])
30
+ };
31
+ return built;
32
+ });
33
+ const operand = (type, options) => [type, options];
34
+ const indexed = (type, _, options) => [type, options];
35
+ const CompositeType = /* @__PURE__ */ keep(require_type_typebox_type.Composite, (left, right) => [left, right]);
36
+ const EvaluateType = /* @__PURE__ */ keep(require_type_typebox_type.Evaluate, operand);
37
+ const InterfaceType = /* @__PURE__ */ keep(require_type_typebox_type.Interface, (heritage, properties, options) => [
38
+ ...heritage,
39
+ { properties },
40
+ options
41
+ ]);
42
+ const MappedType = /* @__PURE__ */ keep(require_type_typebox_type.Mapped, (_, type, __, property, options) => [
43
+ type,
44
+ property,
45
+ options
46
+ ]);
47
+ const OmitType = /* @__PURE__ */ keep(require_type_typebox_type.Omit, indexed);
48
+ const PartialType = /* @__PURE__ */ keep(require_type_typebox_type.Partial, operand);
49
+ const PickType = /* @__PURE__ */ keep(require_type_typebox_type.Pick, indexed);
50
+ const ReadonlyObjectType = /* @__PURE__ */ keep(require_type_typebox_type.ReadonlyObject, operand);
51
+ const RequiredType = /* @__PURE__ */ keep(require_type_typebox_type.Required, operand);
52
+
53
+ //#endregion
54
+ exports.CompositeType = CompositeType;
55
+ exports.EvaluateType = EvaluateType;
56
+ exports.InterfaceType = InterfaceType;
57
+ exports.MappedType = MappedType;
58
+ exports.OmitType = OmitType;
59
+ exports.PartialType = PartialType;
60
+ exports.PickType = PickType;
61
+ exports.ReadonlyObjectType = ReadonlyObjectType;
62
+ exports.RequiredType = RequiredType;
@@ -0,0 +1,53 @@
1
+ import { compositionKeys } from "../../utils.mjs";
2
+ import { Composite, Evaluate, Interface, Mapped, Omit, Partial, Pick, ReadonlyObject, Required } from "../typebox-type.mjs";
3
+
4
+ //#region src/type/elysia/keep-config.ts
5
+ const carries = (schema, field = false, seen = /* @__PURE__ */ new Set()) => {
6
+ if (!schema || typeof schema !== "object" || seen.has(schema)) return false;
7
+ seen.add(schema);
8
+ if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) => carries(member, field, seen)))) return true;
9
+ if (!field) {
10
+ for (const name in schema.properties) if (carries(schema.properties[name], true)) return true;
11
+ }
12
+ return false;
13
+ };
14
+ const from = (schema, sources) => Object.defineProperty(Object.create(Object.getPrototypeOf(schema), Object.getOwnPropertyDescriptors(schema)), "~cookieFrom", {
15
+ value: sources,
16
+ writable: true,
17
+ configurable: true
18
+ });
19
+ const keep = (build, sourcesOf) => ((...args) => {
20
+ const sources = sourcesOf(...args);
21
+ const result = build(...args);
22
+ if (!sources.some((source) => carries(source))) return result;
23
+ const built = from(result, sources);
24
+ const ref = built.$ref;
25
+ const replaced = sources[0]?.$defs?.[ref];
26
+ if (replaced && built.$defs?.[ref] && built.$defs[ref] !== replaced) built.$defs = {
27
+ ...built.$defs,
28
+ [ref]: from(built.$defs[ref], [replaced])
29
+ };
30
+ return built;
31
+ });
32
+ const operand = (type, options) => [type, options];
33
+ const indexed = (type, _, options) => [type, options];
34
+ const CompositeType = /* @__PURE__ */ keep(Composite, (left, right) => [left, right]);
35
+ const EvaluateType = /* @__PURE__ */ keep(Evaluate, operand);
36
+ const InterfaceType = /* @__PURE__ */ keep(Interface, (heritage, properties, options) => [
37
+ ...heritage,
38
+ { properties },
39
+ options
40
+ ]);
41
+ const MappedType = /* @__PURE__ */ keep(Mapped, (_, type, __, property, options) => [
42
+ type,
43
+ property,
44
+ options
45
+ ]);
46
+ const OmitType = /* @__PURE__ */ keep(Omit, indexed);
47
+ const PartialType = /* @__PURE__ */ keep(Partial, operand);
48
+ const PickType = /* @__PURE__ */ keep(Pick, indexed);
49
+ const ReadonlyObjectType = /* @__PURE__ */ keep(ReadonlyObject, operand);
50
+ const RequiredType = /* @__PURE__ */ keep(Required, operand);
51
+
52
+ //#endregion
53
+ export { CompositeType, EvaluateType, InterfaceType, MappedType, OmitType, PartialType, PickType, ReadonlyObjectType, RequiredType };
@@ -1,16 +1,15 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
2
  const require_type_constants = require('../constants.js');
3
+ const require_type_typebox_type = require('../typebox-type.js');
4
4
  const require_type_elysia_union = require('./union.js');
5
5
  const require_type_elysia_utils = require('./utils.js');
6
- let typebox_type = require("typebox/type");
7
6
 
8
7
  //#region src/type/elysia/maybe-empty.ts
9
8
  function MaybeEmpty(schema, options) {
10
9
  return require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.MaybeEmpty, require_type_elysia_union.Union([
11
10
  schema,
12
- (0, typebox_type.Null)(),
13
- (0, typebox_type.Undefined)()
11
+ require_type_typebox_type.Null(),
12
+ require_type_typebox_type.Undefined()
14
13
  ], {
15
14
  ...options,
16
15
  nullable: true
@@ -1,7 +1,7 @@
1
1
  import { ELYSIA_TYPES } from "../constants.mjs";
2
+ import { Null, Undefined } from "../typebox-type.mjs";
2
3
  import { Union } from "./union.mjs";
3
4
  import { elyType } from "./utils.mjs";
4
- import { Null, Undefined } from "typebox/type";
5
5
 
6
6
  //#region src/type/elysia/maybe-empty.ts
7
7
  function MaybeEmpty(schema, options) {
@@ -1,12 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
2
  const require_type_constants = require('../constants.js');
3
+ const require_type_typebox_type = require('../typebox-type.js');
4
4
  const require_type_elysia_union = require('./union.js');
5
5
  const require_type_elysia_utils = require('./utils.js');
6
- let typebox_type = require("typebox/type");
7
6
 
8
7
  //#region src/type/elysia/nullable.ts
9
- const Nullable = (schema, options) => require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.Nullable, require_type_elysia_union.Union([schema, (0, typebox_type.Null)()], {
8
+ const Nullable = (schema, options) => require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.Nullable, require_type_elysia_union.Union([schema, require_type_typebox_type.Null()], {
10
9
  ...options,
11
10
  nullable: true
12
11
  }));
@@ -1,7 +1,7 @@
1
1
  import { ELYSIA_TYPES } from "../constants.mjs";
2
+ import { Null } from "../typebox-type.mjs";
2
3
  import { Union } from "./union.mjs";
3
4
  import { elyType } from "./utils.mjs";
4
- import { Null } from "typebox/type";
5
5
 
6
6
  //#region src/type/elysia/nullable.ts
7
7
  const Nullable = (schema, options) => elyType(ELYSIA_TYPES.Nullable, Union([schema, Null()], {
@@ -1,6 +1,7 @@
1
1
  import { TNumber, TNumberOptions } from "typebox";
2
2
 
3
3
  //#region src/type/elysia/number.d.ts
4
+ declare function primitive(type: string, kind: string): (options?: object) => any;
4
5
  declare function NumberType(options?: TNumberOptions): TNumber;
5
6
  //#endregion
6
- export { NumberType };
7
+ export { NumberType, primitive };
@@ -1,20 +1,28 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
2
  const require_utils = require('../../utils.js');
4
3
  const require_type_constants = require('../constants.js');
5
- let typebox_type = require("typebox/type");
6
4
 
7
5
  //#region src/type/elysia/number.ts
8
- const emptyNumber = Object.freeze((0, typebox_type.Number)());
9
- function NumberType(options) {
10
- if (!options || require_utils.isEmpty(options)) return emptyNumber;
11
- const schema = {
12
- ...options,
13
- type: "number",
14
- "~kind": "Number"
6
+ function primitive(type, kind) {
7
+ const empty = Object.freeze(Object.defineProperty({
8
+ type,
9
+ "~kind": kind
10
+ }, "~kind", require_type_constants.noEnumerable));
11
+ return (options) => {
12
+ if (!options || require_utils.isEmpty(options)) return empty;
13
+ const schema = {
14
+ ...options,
15
+ type,
16
+ "~kind": kind
17
+ };
18
+ return Object.defineProperty(schema, "~kind", require_type_constants.noEnumerable);
15
19
  };
16
- return Object.defineProperty(schema, "~kind", require_type_constants.noEnumerable);
20
+ }
21
+ const number = /* @__PURE__ */ primitive("number", "Number");
22
+ function NumberType(options) {
23
+ return number(options);
17
24
  }
18
25
 
19
26
  //#endregion
20
- exports.NumberType = NumberType;
27
+ exports.NumberType = NumberType;
28
+ exports.primitive = primitive;
@@ -1,18 +1,26 @@
1
1
  import { isEmpty } from "../../utils.mjs";
2
2
  import { noEnumerable } from "../constants.mjs";
3
- import { Number } from "typebox/type";
4
3
 
5
4
  //#region src/type/elysia/number.ts
6
- const emptyNumber = Object.freeze(Number());
7
- function NumberType(options) {
8
- if (!options || isEmpty(options)) return emptyNumber;
9
- const schema = {
10
- ...options,
11
- type: "number",
12
- "~kind": "Number"
5
+ function primitive(type, kind) {
6
+ const empty = Object.freeze(Object.defineProperty({
7
+ type,
8
+ "~kind": kind
9
+ }, "~kind", noEnumerable));
10
+ return (options) => {
11
+ if (!options || isEmpty(options)) return empty;
12
+ const schema = {
13
+ ...options,
14
+ type,
15
+ "~kind": kind
16
+ };
17
+ return Object.defineProperty(schema, "~kind", noEnumerable);
13
18
  };
14
- return Object.defineProperty(schema, "~kind", noEnumerable);
19
+ }
20
+ const number = /* @__PURE__ */ primitive("number", "Number");
21
+ function NumberType(options) {
22
+ return number(options);
15
23
  }
16
24
 
17
25
  //#endregion
18
- export { NumberType };
26
+ export { NumberType, primitive };
@@ -4,7 +4,7 @@ import { TSchemaOptions } from "typebox";
4
4
  type AssertNumericEnum<T extends Record<string, string | number>> = { [K in keyof T]: K extends number ? string : K extends `${number}` ? string : K extends string ? number : never };
5
5
  /**
6
6
  * Numeric enum: accepts a numeric string or a number, decodes to the
7
- * matching enum value. Mirrors src-old `t.NumericEnum`.
7
+ * matching enum value.
8
8
  */
9
9
  declare function NumericEnum<T extends AssertNumericEnum<T>>(item: T, property?: TSchemaOptions): any;
10
10
  //#endregion
@@ -1,20 +1,19 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
2
  const require_type_constants = require('../constants.js');
3
+ const require_type_typebox_type = require('../typebox-type.js');
4
4
  const require_type_elysia_string = require('./string.js');
5
5
  const require_type_elysia_union = require('./union.js');
6
6
  const require_type_elysia_utils = require('./utils.js');
7
7
  const require_type_elysia_number = require('./number.js');
8
- let typebox_type = require("typebox/type");
9
8
 
10
9
  //#region src/type/elysia/numeric-enum.ts
11
10
  /**
12
11
  * Numeric enum: accepts a numeric string or a number, decodes to the
13
- * matching enum value. Mirrors src-old `t.NumericEnum`.
12
+ * matching enum value.
14
13
  */
15
14
  function NumericEnum(item, property) {
16
- const allowed = new Set(Object.values(item).filter((v) => typeof v === "number").map((v) => v));
17
- const decoder = (0, typebox_type.Decode)((0, typebox_type.Refine)(require_type_elysia_union.Union([require_type_elysia_string.StringType({ format: "numeric" }), require_type_elysia_number.NumberType()], property), (value) => {
15
+ const allowed = new Set(Object.values(item).filter((v) => typeof v === "number"));
16
+ const decoder = require_type_typebox_type.Decode(require_type_typebox_type.Refine(require_type_elysia_union.Union([require_type_elysia_string.StringType({ format: "numeric" }), require_type_elysia_number.NumberType()], property), (value) => {
18
17
  if (typeof value === "string" && value.trim() === "") return false;
19
18
  const n = +value;
20
19
  return !isNaN(n) && allowed.has(n);
@@ -1,17 +1,17 @@
1
1
  import { ELYSIA_TYPES } from "../constants.mjs";
2
+ import { Decode, Refine } from "../typebox-type.mjs";
2
3
  import { StringType } from "./string.mjs";
3
4
  import { Union } from "./union.mjs";
4
5
  import { elyType } from "./utils.mjs";
5
6
  import { NumberType } from "./number.mjs";
6
- import { Decode, Refine } from "typebox/type";
7
7
 
8
8
  //#region src/type/elysia/numeric-enum.ts
9
9
  /**
10
10
  * Numeric enum: accepts a numeric string or a number, decodes to the
11
- * matching enum value. Mirrors src-old `t.NumericEnum`.
11
+ * matching enum value.
12
12
  */
13
13
  function NumericEnum(item, property) {
14
- const allowed = new Set(Object.values(item).filter((v) => typeof v === "number").map((v) => v));
14
+ const allowed = new Set(Object.values(item).filter((v) => typeof v === "number"));
15
15
  const decoder = Decode(Refine(Union([StringType({ format: "numeric" }), NumberType()], property), (value) => {
16
16
  if (typeof value === "string" && value.trim() === "") return false;
17
17
  const n = +value;
@@ -1,7 +1,9 @@
1
- import { TNumberOptions, Type } from "typebox";
1
+ import { ELYSIA_TYPES } from "../constants.js";
2
+ import { TNumberOptions, TSchema, Type } from "typebox";
2
3
 
3
4
  //#region src/type/elysia/numeric.d.ts
5
+ declare function numericString(tag: ELYSIA_TYPES[keyof ELYSIA_TYPES], message: string, grammar: (value: string) => boolean, base: (constraints: TNumberOptions) => TSchema, emptyBase: () => TSchema): (property?: TNumberOptions) => Type.TSchema;
4
6
  type NumericSchema = Type.TUnion<[Type.TNumber, Type.TCodec<Type.TRefine<Type.TString>, number>]>;
5
7
  declare function Numeric(property?: TNumberOptions): Readonly<NumericSchema>;
6
8
  //#endregion
7
- export { Numeric };
9
+ export { Numeric, numericString };
@@ -1,13 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
2
  const require_utils = require('../../utils.js');
4
3
  const require_type_constants = require('../constants.js');
5
4
  const require_type_shared = require('../shared.js');
5
+ const require_type_typebox_type = require('../typebox-type.js');
6
6
  const require_type_elysia_string = require('./string.js');
7
7
  const require_type_elysia_union = require('./union.js');
8
8
  const require_type_elysia_utils = require('./utils.js');
9
9
  const require_type_elysia_number = require('./number.js');
10
- let typebox_type = require("typebox/type");
11
10
 
12
11
  //#region src/type/elysia/numeric.ts
13
12
  function isDecimalString(value) {
@@ -33,11 +32,10 @@ function isDecimalString(value) {
33
32
  }
34
33
  if (!digits && !fractions) return false;
35
34
  } else if (!digits) return false;
36
- return index === length;
35
+ if (index !== length) return false;
36
+ return digits < 309 || Number.isFinite(+value);
37
37
  }
38
- let StringifiedNumber;
39
- let emptyNumeric;
40
- function passesConstraints(n, c) {
38
+ function inRange(n, c) {
41
39
  if (typeof c.minimum === "number" && n < c.minimum) return false;
42
40
  if (typeof c.maximum === "number" && n > c.maximum) return false;
43
41
  if (typeof c.exclusiveMinimum === "number" && n <= c.exclusiveMinimum) return false;
@@ -45,18 +43,23 @@ function passesConstraints(n, c) {
45
43
  if (typeof c.multipleOf === "number" && n % c.multipleOf !== 0) return false;
46
44
  return true;
47
45
  }
46
+ function numericString(tag, message, grammar, base, emptyBase) {
47
+ let empty;
48
+ return (property) => {
49
+ if (!property || require_utils.isEmpty(property)) return empty ??= Object.freeze(require_type_elysia_utils.elyType(tag, require_type_elysia_union.Union([emptyBase(), require_type_shared.pureRefine(require_type_typebox_type.Decode(require_type_typebox_type.Refine(require_type_elysia_string.StringType(), grammar, () => message), (value) => +value))])));
50
+ const [constraints, meta] = require_type_elysia_utils.getMeta(property);
51
+ const c = constraints;
52
+ const number = base(constraints);
53
+ const stringified = require_type_typebox_type.Decode(require_type_typebox_type.Refine(require_type_elysia_string.StringType(), (value) => grammar(value) && inRange(+value, c), () => message), (value) => +value);
54
+ require_type_shared.pureRefine(stringified);
55
+ return require_type_elysia_utils.elyType(tag, require_type_elysia_union.Union([number, stringified], meta));
56
+ };
57
+ }
58
+ const numeric = /* @__PURE__ */ numericString(require_type_constants.ELYSIA_TYPES.Numeric, "must be number", isDecimalString, require_type_elysia_number.NumberType, require_type_elysia_number.NumberType);
48
59
  function Numeric(property) {
49
- StringifiedNumber ??= require_type_shared.pureRefine((0, typebox_type.Decode)((0, typebox_type.Refine)(require_type_elysia_string.StringType(), isDecimalString, () => "must be number"), (value) => +value));
50
- if (!property || require_utils.isEmpty(property)) return emptyNumeric ??= Object.freeze(require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.Numeric, require_type_elysia_union.Union([require_type_elysia_number.NumberType(), StringifiedNumber])));
51
- const [constraints, meta] = require_type_elysia_utils.getMeta(property);
52
- const number = require_type_elysia_number.NumberType(constraints);
53
- const stringified = (0, typebox_type.Decode)((0, typebox_type.Refine)(require_type_elysia_string.StringType(), (value) => {
54
- if (!isDecimalString(value)) return false;
55
- return passesConstraints(+value, constraints);
56
- }, () => "must be number"), (value) => +value);
57
- require_type_shared.pureRefine(stringified);
58
- return require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.Numeric, require_type_elysia_union.Union([number, stringified], meta));
60
+ return numeric(property);
59
61
  }
60
62
 
61
63
  //#endregion
62
- exports.Numeric = Numeric;
64
+ exports.Numeric = Numeric;
65
+ exports.numericString = numericString;
@@ -1,11 +1,11 @@
1
1
  import { isEmpty } from "../../utils.mjs";
2
2
  import { ELYSIA_TYPES } from "../constants.mjs";
3
3
  import { pureRefine } from "../shared.mjs";
4
+ import { Decode, Refine } from "../typebox-type.mjs";
4
5
  import { StringType } from "./string.mjs";
5
6
  import { Union } from "./union.mjs";
6
7
  import { elyType, getMeta } from "./utils.mjs";
7
8
  import { NumberType } from "./number.mjs";
8
- import { Decode, Refine } from "typebox/type";
9
9
 
10
10
  //#region src/type/elysia/numeric.ts
11
11
  function isDecimalString(value) {
@@ -31,11 +31,10 @@ function isDecimalString(value) {
31
31
  }
32
32
  if (!digits && !fractions) return false;
33
33
  } else if (!digits) return false;
34
- return index === length;
34
+ if (index !== length) return false;
35
+ return digits < 309 || Number.isFinite(+value);
35
36
  }
36
- let StringifiedNumber;
37
- let emptyNumeric;
38
- function passesConstraints(n, c) {
37
+ function inRange(n, c) {
39
38
  if (typeof c.minimum === "number" && n < c.minimum) return false;
40
39
  if (typeof c.maximum === "number" && n > c.maximum) return false;
41
40
  if (typeof c.exclusiveMinimum === "number" && n <= c.exclusiveMinimum) return false;
@@ -43,18 +42,22 @@ function passesConstraints(n, c) {
43
42
  if (typeof c.multipleOf === "number" && n % c.multipleOf !== 0) return false;
44
43
  return true;
45
44
  }
45
+ function numericString(tag, message, grammar, base, emptyBase) {
46
+ let empty;
47
+ return (property) => {
48
+ if (!property || isEmpty(property)) return empty ??= Object.freeze(elyType(tag, Union([emptyBase(), pureRefine(Decode(Refine(StringType(), grammar, () => message), (value) => +value))])));
49
+ const [constraints, meta] = getMeta(property);
50
+ const c = constraints;
51
+ const number = base(constraints);
52
+ const stringified = Decode(Refine(StringType(), (value) => grammar(value) && inRange(+value, c), () => message), (value) => +value);
53
+ pureRefine(stringified);
54
+ return elyType(tag, Union([number, stringified], meta));
55
+ };
56
+ }
57
+ const numeric = /* @__PURE__ */ numericString(ELYSIA_TYPES.Numeric, "must be number", isDecimalString, NumberType, NumberType);
46
58
  function Numeric(property) {
47
- StringifiedNumber ??= pureRefine(Decode(Refine(StringType(), isDecimalString, () => "must be number"), (value) => +value));
48
- if (!property || isEmpty(property)) return emptyNumeric ??= Object.freeze(elyType(ELYSIA_TYPES.Numeric, Union([NumberType(), StringifiedNumber])));
49
- const [constraints, meta] = getMeta(property);
50
- const number = NumberType(constraints);
51
- const stringified = Decode(Refine(StringType(), (value) => {
52
- if (!isDecimalString(value)) return false;
53
- return passesConstraints(+value, constraints);
54
- }, () => "must be number"), (value) => +value);
55
- pureRefine(stringified);
56
- return elyType(ELYSIA_TYPES.Numeric, Union([number, stringified], meta));
59
+ return numeric(property);
57
60
  }
58
61
 
59
62
  //#endregion
60
- export { Numeric };
63
+ export { Numeric, numericString };
@@ -1,51 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
2
  const require_utils = require('../../utils.js');
4
- const require_type_bridge = require('../bridge.js');
5
3
  const require_type_constants = require('../constants.js');
6
- const require_type_elysia_string = require('./string.js');
4
+ const require_type_elysia_json_string = require('./json-string.js');
7
5
  const require_type_elysia_union = require('./union.js');
8
6
  const require_type_elysia_utils = require('./utils.js');
9
7
  const require_type_elysia_object = require('./object.js');
10
- let typebox_type = require("typebox/type");
11
8
 
12
9
  //#region src/type/elysia/object-string.ts
13
- const MEMO_LIMIT = 8192;
14
10
  function ObjectString(property, _options) {
15
11
  const [{ properties, ...constraints }, meta] = require_type_elysia_utils.getMeta(_options ?? require_utils.nullObject());
16
12
  const object = require_type_elysia_object.ObjectType(property, constraints);
17
- let check;
18
- let raw;
19
- let parsed;
20
- const objectString = (0, typebox_type.Decode)((0, typebox_type.Refine)(require_type_elysia_string.StringType(), (value) => {
21
- if (value.charCodeAt(0) !== 123) return false;
22
- if (value === raw) return true;
23
- try {
24
- const next = JSON.parse(value);
25
- if (!check) try {
26
- const compiled = require_type_bridge.Compile(object);
27
- if (compiled.evaluateResult) compiled.evaluateResult.code = void 0;
28
- if (compiled.buildResult) compiled.buildResult.functions = void 0;
29
- check = (v) => compiled.Check(v);
30
- } catch {
31
- check = (v) => require_type_bridge.Check(object, v);
32
- }
33
- if (!check(next)) return false;
34
- if (value.length <= MEMO_LIMIT) {
35
- raw = value;
36
- parsed = next;
37
- }
38
- return true;
39
- } catch {
40
- return false;
41
- }
42
- }, () => "must be an object"), (value) => {
43
- const decoded = value === raw ? parsed : JSON.parse(value);
44
- raw = void 0;
45
- parsed = void 0;
46
- return require_type_bridge.Decode(object, decoded);
47
- });
48
- return require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.ObjectString, require_type_elysia_union.Union([object, objectString], meta));
13
+ return require_type_elysia_utils.elyType(require_type_constants.ELYSIA_TYPES.ObjectString, require_type_elysia_union.Union([object, require_type_elysia_json_string.jsonString(object, 123, "must be an object")], meta));
49
14
  }
50
15
 
51
16
  //#endregion