@tstdl/base 0.71.88 → 0.78.0-beta2

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 (349) hide show
  1. package/.eslintrc.js +2 -4
  2. package/api/client/client.js +2 -12
  3. package/api/client/client.js.map +1 -1
  4. package/api/default-error-handlers.d.ts +0 -4
  5. package/api/default-error-handlers.js +1 -6
  6. package/api/default-error-handlers.js.map +1 -1
  7. package/api/server/gateway.js +12 -18
  8. package/api/server/gateway.js.map +1 -1
  9. package/api/server/module.d.ts +0 -4
  10. package/api/server/module.js +1 -12
  11. package/api/server/module.js.map +1 -1
  12. package/api/types.d.ts +8 -32
  13. package/api/types.js.map +1 -1
  14. package/container/container.js +2 -2
  15. package/container/container.js.map +1 -1
  16. package/data-structures/index.d.ts +1 -0
  17. package/data-structures/index.js +1 -0
  18. package/data-structures/index.js.map +1 -1
  19. package/data-structures/iterable-weak-map.d.ts +29 -0
  20. package/data-structures/iterable-weak-map.js +128 -0
  21. package/data-structures/iterable-weak-map.js.map +1 -0
  22. package/data-structures/multi-key-map.d.ts +12 -1
  23. package/data-structures/multi-key-map.js +22 -11
  24. package/data-structures/multi-key-map.js.map +1 -1
  25. package/error/custom.error.d.ts +3 -1
  26. package/error/custom.error.js +16 -7
  27. package/error/custom.error.js.map +1 -1
  28. package/examples/api/basic-overview.js +16 -8
  29. package/examples/api/basic-overview.js.map +1 -1
  30. package/image-service/image-service.d.ts +32 -65
  31. package/image-service/image-service.js +73 -15
  32. package/image-service/image-service.js.map +1 -1
  33. package/json-path/json-path.d.ts +8 -3
  34. package/json-path/json-path.js +24 -7
  35. package/json-path/json-path.js.map +1 -1
  36. package/module/modules/index.d.ts +0 -1
  37. package/module/modules/index.js +0 -1
  38. package/module/modules/index.js.map +1 -1
  39. package/openid-connect/oidc-configuration.service.js +7 -7
  40. package/openid-connect/oidc-configuration.service.js.map +1 -1
  41. package/openid-connect/oidc.service.js +7 -7
  42. package/openid-connect/oidc.service.js.map +1 -1
  43. package/package.json +3 -4
  44. package/process-shutdown.js +3 -2
  45. package/process-shutdown.js.map +1 -1
  46. package/reflection/decorators.js +1 -0
  47. package/reflection/decorators.js.map +1 -1
  48. package/reflection/reflection-data-map.d.ts +10 -0
  49. package/reflection/reflection-data-map.js +40 -0
  50. package/reflection/reflection-data-map.js.map +1 -0
  51. package/reflection/registry.d.ts +7 -7
  52. package/reflection/registry.js +7 -6
  53. package/reflection/registry.js.map +1 -1
  54. package/reflection/types.d.ts +1 -0
  55. package/reflection/utils.d.ts +6 -3
  56. package/reflection/utils.js +9 -35
  57. package/reflection/utils.js.map +1 -1
  58. package/schema/array-constraints/index.d.ts +2 -0
  59. package/{old-api/validation/validators → schema/array-constraints}/index.js +2 -1
  60. package/schema/array-constraints/index.js.map +1 -0
  61. package/schema/array-constraints/maximum-length.d.ts +11 -0
  62. package/schema/array-constraints/maximum-length.js +26 -0
  63. package/schema/array-constraints/maximum-length.js.map +1 -0
  64. package/schema/array-constraints/minimum-length.d.ts +11 -0
  65. package/schema/array-constraints/minimum-length.js +26 -0
  66. package/schema/array-constraints/minimum-length.js.map +1 -0
  67. package/schema/coercers/boolean.coercer.d.ts +9 -0
  68. package/schema/coercers/boolean.coercer.js +35 -0
  69. package/schema/coercers/boolean.coercer.js.map +1 -0
  70. package/schema/coercers/date.coercer.d.ts +9 -0
  71. package/schema/coercers/date.coercer.js +24 -0
  72. package/schema/coercers/date.coercer.js.map +1 -0
  73. package/schema/coercers/default-value.coercer.d.ts +9 -0
  74. package/schema/coercers/default-value.coercer.js +16 -0
  75. package/schema/coercers/default-value.coercer.js.map +1 -0
  76. package/schema/coercers/index.d.ts +7 -0
  77. package/schema/coercers/index.js +24 -0
  78. package/schema/coercers/index.js.map +1 -0
  79. package/schema/coercers/number.coercer.d.ts +9 -0
  80. package/schema/coercers/number.coercer.js +22 -0
  81. package/schema/coercers/number.coercer.js.map +1 -0
  82. package/schema/coercers/regexp.coercer.d.ts +11 -0
  83. package/schema/coercers/regexp.coercer.js +24 -0
  84. package/schema/coercers/regexp.coercer.js.map +1 -0
  85. package/schema/coercers/string.coercer.d.ts +9 -0
  86. package/schema/coercers/string.coercer.js +22 -0
  87. package/schema/coercers/string.coercer.js.map +1 -0
  88. package/schema/coercers/uint8-array.coercer.d.ts +9 -0
  89. package/schema/coercers/uint8-array.coercer.js +31 -0
  90. package/schema/coercers/uint8-array.coercer.js.map +1 -0
  91. package/schema/constraints/enumeration.d.ts +13 -0
  92. package/schema/constraints/enumeration.js +29 -0
  93. package/schema/constraints/enumeration.js.map +1 -0
  94. package/schema/constraints/generic.d.ts +22 -0
  95. package/schema/constraints/generic.js +32 -0
  96. package/schema/constraints/generic.js.map +1 -0
  97. package/schema/constraints/index.d.ts +12 -0
  98. package/schema/constraints/index.js +29 -0
  99. package/schema/constraints/index.js.map +1 -0
  100. package/schema/constraints/integer.d.ts +12 -0
  101. package/schema/constraints/integer.js +27 -0
  102. package/schema/constraints/integer.js.map +1 -0
  103. package/schema/constraints/length.d.ts +6 -0
  104. package/schema/constraints/length.js +20 -0
  105. package/schema/constraints/length.js.map +1 -0
  106. package/schema/constraints/literal.d.ts +10 -0
  107. package/schema/constraints/literal.js +26 -0
  108. package/schema/constraints/literal.js.map +1 -0
  109. package/schema/constraints/maximum-date.d.ts +12 -0
  110. package/schema/constraints/maximum-date.js +29 -0
  111. package/schema/constraints/maximum-date.js.map +1 -0
  112. package/schema/constraints/maximum-length.d.ts +12 -0
  113. package/schema/constraints/maximum-length.js +29 -0
  114. package/schema/constraints/maximum-length.js.map +1 -0
  115. package/schema/constraints/maximum.d.ts +12 -0
  116. package/schema/constraints/maximum.js +27 -0
  117. package/schema/constraints/maximum.js.map +1 -0
  118. package/schema/constraints/minimum-date.d.ts +12 -0
  119. package/schema/constraints/minimum-date.js +29 -0
  120. package/schema/constraints/minimum-date.js.map +1 -0
  121. package/schema/constraints/minimum-length.d.ts +12 -0
  122. package/schema/constraints/minimum-length.js +29 -0
  123. package/schema/constraints/minimum-length.js.map +1 -0
  124. package/schema/constraints/minimum.d.ts +12 -0
  125. package/schema/constraints/minimum.js +27 -0
  126. package/schema/constraints/minimum.js.map +1 -0
  127. package/schema/constraints/pattern.d.ts +13 -0
  128. package/schema/constraints/pattern.js +28 -0
  129. package/schema/constraints/pattern.js.map +1 -0
  130. package/schema/decorators/array.d.ts +4 -0
  131. package/schema/decorators/array.js +11 -0
  132. package/schema/decorators/array.js.map +1 -0
  133. package/schema/decorators/coerce.d.ts +2 -0
  134. package/schema/decorators/coerce.js +10 -0
  135. package/schema/decorators/coerce.js.map +1 -0
  136. package/schema/decorators/defaulted.d.ts +3 -0
  137. package/schema/decorators/defaulted.js +11 -0
  138. package/schema/decorators/defaulted.js.map +1 -0
  139. package/schema/decorators/index.d.ts +8 -0
  140. package/{old-api → schema/decorators}/index.js +8 -3
  141. package/schema/decorators/index.js.map +1 -0
  142. package/schema/decorators/nullable.d.ts +2 -0
  143. package/schema/decorators/nullable.js +10 -0
  144. package/schema/decorators/nullable.js.map +1 -0
  145. package/schema/decorators/optional.d.ts +2 -0
  146. package/schema/decorators/optional.js +10 -0
  147. package/schema/decorators/optional.js.map +1 -0
  148. package/schema/decorators/property.d.ts +6 -0
  149. package/schema/decorators/property.js +19 -0
  150. package/schema/decorators/property.js.map +1 -0
  151. package/schema/decorators/type.d.ts +3 -0
  152. package/schema/decorators/type.js +10 -0
  153. package/schema/decorators/type.js.map +1 -0
  154. package/schema/decorators/types.d.ts +18 -0
  155. package/schema/decorators/types.js +3 -0
  156. package/schema/decorators/types.js.map +1 -0
  157. package/schema/decorators/utils.d.ts +10 -0
  158. package/schema/decorators/utils.js +59 -0
  159. package/schema/decorators/utils.js.map +1 -0
  160. package/schema/index.d.ts +7 -1
  161. package/schema/index.js +7 -1
  162. package/schema/index.js.map +1 -1
  163. package/schema/schema.d.ts +19 -0
  164. package/schema/schema.error.d.ts +13 -7
  165. package/schema/schema.error.js +45 -13
  166. package/schema/schema.error.js.map +1 -1
  167. package/schema/schema.js +286 -0
  168. package/schema/schema.js.map +1 -0
  169. package/schema/schemas/any.d.ts +4 -8
  170. package/schema/schemas/any.js +9 -14
  171. package/schema/schemas/any.js.map +1 -1
  172. package/schema/schemas/array.d.ts +7 -13
  173. package/schema/schemas/array.js +14 -43
  174. package/schema/schemas/array.js.map +1 -1
  175. package/schema/schemas/assign.d.ts +8 -0
  176. package/schema/schemas/assign.js +28 -0
  177. package/schema/schemas/assign.js.map +1 -0
  178. package/schema/schemas/boolean.d.ts +5 -9
  179. package/schema/schemas/boolean.js +11 -38
  180. package/schema/schemas/boolean.js.map +1 -1
  181. package/schema/schemas/constraint.d.ts +4 -0
  182. package/schema/schemas/constraint.js +14 -0
  183. package/schema/schemas/constraint.js.map +1 -0
  184. package/schema/schemas/date.d.ts +7 -11
  185. package/schema/schemas/date.js +18 -53
  186. package/schema/schemas/date.js.map +1 -1
  187. package/schema/schemas/defaulted.d.ts +2 -15
  188. package/schema/schemas/defaulted.js +7 -23
  189. package/schema/schemas/defaulted.js.map +1 -1
  190. package/schema/schemas/enumeration.d.ts +6 -18
  191. package/schema/schemas/enumeration.js +13 -50
  192. package/schema/schemas/enumeration.js.map +1 -1
  193. package/schema/schemas/exclude.d.ts +4 -0
  194. package/schema/schemas/exclude.js +17 -0
  195. package/schema/schemas/exclude.js.map +1 -0
  196. package/schema/schemas/index.d.ts +5 -6
  197. package/schema/schemas/index.js +5 -6
  198. package/schema/schemas/index.js.map +1 -1
  199. package/schema/schemas/instance.d.ts +2 -12
  200. package/schema/schemas/instance.js +4 -20
  201. package/schema/schemas/instance.js.map +1 -1
  202. package/schema/schemas/literal.d.ts +4 -11
  203. package/schema/schemas/literal.js +13 -18
  204. package/schema/schemas/literal.js.map +1 -1
  205. package/schema/schemas/nullable.d.ts +3 -13
  206. package/schema/schemas/nullable.js +3 -26
  207. package/schema/schemas/nullable.js.map +1 -1
  208. package/schema/schemas/number.d.ts +7 -14
  209. package/schema/schemas/number.js +23 -44
  210. package/schema/schemas/number.js.map +1 -1
  211. package/schema/schemas/object.d.ts +6 -34
  212. package/schema/schemas/object.js +8 -112
  213. package/schema/schemas/object.js.map +1 -1
  214. package/schema/schemas/optional.d.ts +3 -13
  215. package/schema/schemas/optional.js +3 -26
  216. package/schema/schemas/optional.js.map +1 -1
  217. package/schema/schemas/pick.d.ts +4 -0
  218. package/schema/schemas/pick.js +17 -0
  219. package/schema/schemas/pick.js.map +1 -0
  220. package/schema/schemas/readable-stream.d.ts +4 -9
  221. package/schema/schemas/readable-stream.js +9 -15
  222. package/schema/schemas/readable-stream.js.map +1 -1
  223. package/schema/schemas/record.d.ts +4 -0
  224. package/schema/schemas/record.js +14 -0
  225. package/schema/schemas/record.js.map +1 -0
  226. package/schema/schemas/regexp.d.ts +6 -9
  227. package/schema/schemas/regexp.js +10 -27
  228. package/schema/schemas/regexp.js.map +1 -1
  229. package/schema/schemas/string.d.ts +9 -13
  230. package/schema/schemas/string.js +34 -46
  231. package/schema/schemas/string.js.map +1 -1
  232. package/schema/schemas/transform.d.ts +4 -16
  233. package/schema/schemas/transform.js +7 -36
  234. package/schema/schemas/transform.js.map +1 -1
  235. package/schema/schemas/uint8-array.d.ts +8 -11
  236. package/schema/schemas/uint8-array.js +20 -32
  237. package/schema/schemas/uint8-array.js.map +1 -1
  238. package/schema/schemas/union.d.ts +5 -17
  239. package/schema/schemas/union.js +9 -35
  240. package/schema/schemas/union.js.map +1 -1
  241. package/schema/schemas/unknown.d.ts +4 -8
  242. package/schema/schemas/unknown.js +9 -14
  243. package/schema/schemas/unknown.js.map +1 -1
  244. package/schema/transformers/generic.d.ts +13 -0
  245. package/schema/transformers/generic.js +28 -0
  246. package/schema/transformers/generic.js.map +1 -0
  247. package/schema/transformers/index.d.ts +3 -0
  248. package/{old-api/endpoints → schema/transformers}/index.js +3 -1
  249. package/schema/transformers/index.js.map +1 -0
  250. package/schema/transformers/lowercase.d.ts +9 -0
  251. package/schema/transformers/lowercase.js +22 -0
  252. package/schema/transformers/lowercase.js.map +1 -0
  253. package/schema/transformers/trim.d.ts +9 -0
  254. package/schema/transformers/trim.js +22 -0
  255. package/schema/transformers/trim.js.map +1 -0
  256. package/schema/transformers/uppercase.d.ts +9 -0
  257. package/schema/transformers/uppercase.js +22 -0
  258. package/schema/transformers/uppercase.js.map +1 -0
  259. package/schema/types.d.ts +135 -15
  260. package/schema/types.js +39 -3
  261. package/schema/types.js.map +1 -1
  262. package/schema/utils/index.d.ts +2 -0
  263. package/{old-api/validation → schema/utils}/index.js +2 -1
  264. package/schema/utils/index.js.map +1 -0
  265. package/schema/utils/schema.d.ts +12 -0
  266. package/schema/utils/schema.js +78 -0
  267. package/schema/utils/schema.js.map +1 -0
  268. package/schema/utils/value-type.d.ts +4 -0
  269. package/schema/utils/value-type.js +35 -0
  270. package/schema/utils/value-type.js.map +1 -0
  271. package/templates/providers/file-template.provider.base.d.ts +1 -1
  272. package/templates/providers/file-template.provider.base.js +3 -2
  273. package/templates/providers/file-template.provider.base.js.map +1 -1
  274. package/types.d.ts +6 -3
  275. package/utils/enum.d.ts +1 -1
  276. package/utils/function/memoize.d.ts +6 -2
  277. package/utils/function/memoize.js +28 -20
  278. package/utils/function/memoize.js.map +1 -1
  279. package/utils/index.d.ts +1 -0
  280. package/utils/index.js +1 -0
  281. package/utils/index.js.map +1 -1
  282. package/utils/merge.d.ts +5 -0
  283. package/utils/merge.js +32 -0
  284. package/utils/merge.js.map +1 -0
  285. package/utils/object/dereference.js.map +1 -1
  286. package/utils/object/object.d.ts +4 -0
  287. package/utils/object/object.js +9 -2
  288. package/utils/object/object.js.map +1 -1
  289. package/utils/patterns.d.ts +1 -1
  290. package/utils/patterns.js +3 -3
  291. package/utils/patterns.js.map +1 -1
  292. package/utils/timing.d.ts +0 -8
  293. package/utils/timing.js.map +1 -1
  294. package/utils/type-guards.d.ts +6 -0
  295. package/utils/type-guards.js +16 -4
  296. package/utils/type-guards.js.map +1 -1
  297. package/instance-provider.d.ts +0 -17
  298. package/instance-provider.js +0 -55
  299. package/instance-provider.js.map +0 -1
  300. package/module/modules/old-web-server.module.d.ts +0 -22
  301. package/module/modules/old-web-server.module.js +0 -37
  302. package/module/modules/old-web-server.module.js.map +0 -1
  303. package/old-api/endpoint.d.ts +0 -5
  304. package/old-api/endpoint.js +0 -20
  305. package/old-api/endpoint.js.map +0 -1
  306. package/old-api/endpoints/echo.endpoint.d.ts +0 -2
  307. package/old-api/endpoints/echo.endpoint.js +0 -6
  308. package/old-api/endpoints/echo.endpoint.js.map +0 -1
  309. package/old-api/endpoints/index.d.ts +0 -1
  310. package/old-api/endpoints/index.js.map +0 -1
  311. package/old-api/http-api.d.ts +0 -63
  312. package/old-api/http-api.js +0 -269
  313. package/old-api/http-api.js.map +0 -1
  314. package/old-api/index.d.ts +0 -3
  315. package/old-api/index.js.map +0 -1
  316. package/old-api/validation/index.d.ts +0 -1
  317. package/old-api/validation/index.js.map +0 -1
  318. package/old-api/validation/types.d.ts +0 -6
  319. package/old-api/validation/types.js +0 -6
  320. package/old-api/validation/types.js.map +0 -1
  321. package/old-api/validation/validators/index.d.ts +0 -1
  322. package/old-api/validation/validators/index.js.map +0 -1
  323. package/old-api/validation/validators/noop.d.ts +0 -2
  324. package/old-api/validation/validators/noop.js +0 -8
  325. package/old-api/validation/validators/noop.js.map +0 -1
  326. package/old-api/validation/validators/superstruct.d.ts +0 -14
  327. package/old-api/validation/validators/superstruct.js +0 -66
  328. package/old-api/validation/validators/superstruct.js.map +0 -1
  329. package/old-api/validation/validators/yup.d.ts +0 -7
  330. package/old-api/validation/validators/yup.js +0 -60
  331. package/old-api/validation/validators/yup.js.map +0 -1
  332. package/schema/schema.validator.d.ts +0 -40
  333. package/schema/schema.validator.js +0 -75
  334. package/schema/schema.validator.js.map +0 -1
  335. package/schema/schemas/async-iterable.d.ts +0 -13
  336. package/schema/schemas/async-iterable.js +0 -40
  337. package/schema/schemas/async-iterable.js.map +0 -1
  338. package/schema/schemas/iterable.d.ts +0 -13
  339. package/schema/schemas/iterable.js +0 -40
  340. package/schema/schemas/iterable.js.map +0 -1
  341. package/schema/schemas/never.d.ts +0 -9
  342. package/schema/schemas/never.js +0 -22
  343. package/schema/schemas/never.js.map +0 -1
  344. package/schema/schemas/preprocess.d.ts +0 -16
  345. package/schema/schemas/preprocess.js +0 -35
  346. package/schema/schemas/preprocess.js.map +0 -1
  347. package/schema/schemas/refine.d.ts +0 -24
  348. package/schema/schemas/refine.js +0 -52
  349. package/schema/schemas/refine.js.map +0 -1
@@ -1,22 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readableStream = exports.ReadableStreamSchemaValidator = void 0;
4
- const schema_validator_1 = require("../schema.validator");
3
+ exports.ReadableStream = exports.readableStream = void 0;
4
+ const decorators_1 = require("../decorators");
5
5
  const types_1 = require("../types");
6
- const instance_1 = require("./instance");
7
- const readableStreamInstanceSchema = (typeof ReadableStream != 'function' ? undefined : (0, instance_1.instance)(ReadableStream));
8
- class ReadableStreamSchemaValidator extends schema_validator_1.SchemaValidator {
9
- [schema_validator_1.test](value, options, path) {
10
- return readableStreamInstanceSchema[schema_validator_1.test](value, options, path);
11
- }
12
- }
13
- exports.ReadableStreamSchemaValidator = ReadableStreamSchemaValidator;
14
- function readableStream(options) {
15
- const schema = (0, types_1.schemaHelper)({
16
- type: 'readableStream',
17
- ...options
6
+ function readableStream() {
7
+ return (0, types_1.valueSchema)({
8
+ type: globalThis.ReadableStream
18
9
  });
19
- return new ReadableStreamSchemaValidator(schema);
20
10
  }
21
11
  exports.readableStream = readableStream;
12
+ function ReadableStream() {
13
+ return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(readableStream());
14
+ }
15
+ exports.ReadableStream = ReadableStream;
22
16
  //# sourceMappingURL=readable-stream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"readable-stream.js","sourceRoot":"","sources":["../../../source/schema/schemas/readable-stream.ts"],"names":[],"mappings":";;;AAEA,0DAA4D;AAE5D,oCAAwC;AACxC,yCAAsC;AAItC,MAAM,4BAA4B,GAAG,CAAC,OAAO,cAAc,IAAI,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,mBAAQ,EAAC,cAAc,CAAC,CAAE,CAAC;AAEnH,MAAa,6BAA8B,SAAQ,kCAA+C;IAChG,CAAC,uBAAI,CAAC,CAAC,KAAc,EAAE,OAAiC,EAAE,IAAc;QACtE,OAAO,4BAA4B,CAAC,uBAAI,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;CACF;AAJD,sEAIC;AAED,SAAgB,cAAc,CAAC,OAAuD;IACpF,MAAM,MAAM,GAAG,IAAA,oBAAY,EAAiC;QAC1D,IAAI,EAAE,gBAAgB;QACtB,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,IAAI,6BAA6B,CAAC,MAAM,CAAC,CAAC;AACnD,CAAC;AAPD,wCAOC"}
1
+ {"version":3,"file":"readable-stream.js","sourceRoot":"","sources":["../../../source/schema/schemas/readable-stream.ts"],"names":[],"mappings":";;;AACA,8CAA2E;AAE3E,oCAAuC;AAEvC,SAAgB,cAAc;IAC5B,OAAO,IAAA,mBAAW,EAAC;QACjB,IAAI,EAAE,UAAU,CAAC,cAAc;KAChC,CAAC,CAAC;AACL,CAAC;AAJD,wCAIC;AAED,SAAgB,cAAc;IAC5B,OAAO,IAAA,uDAA0C,EAAC,cAAc,EAAE,CAAC,CAAC;AACtE,CAAC;AAFD,wCAEC"}
@@ -0,0 +1,4 @@
1
+ import type { Record, TypedOmit } from "../../types";
2
+ import type { MaybeDeferredValueTypes, ObjectSchema } from '../types';
3
+ export declare type RecordOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties' | 'allowUnknownProperties'>;
4
+ export declare function record<T extends MaybeDeferredValueTypes>(schemas: T, options?: RecordOptions): ObjectSchema<Record<any, T extends MaybeDeferredValueTypes<infer U> ? U : never>>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/naming-convention */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.record = void 0;
5
+ const types_1 = require("../types");
6
+ function record(schemas, options) {
7
+ return (0, types_1.objectSchema)({
8
+ properties: {},
9
+ allowUnknownProperties: schemas,
10
+ ...options
11
+ });
12
+ }
13
+ exports.record = record;
14
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["../../../source/schema/schemas/record.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,oCAAwC;AAIxC,SAAgB,MAAM,CAAoC,OAAU,EAAE,OAAuB;IAC3F,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU,EAAE,EAAE;QACd,sBAAsB,EAAE,OAAO;QAC/B,GAAG,OAAO;KACX,CAAiB,CAAC;AACrB,CAAC;AAND,wBAMC"}
@@ -1,9 +1,6 @@
1
- import type { JsonPath } from "../../json-path";
2
- import type { DefinedValidationOptions, ValidationTestResult } from '../schema.validator';
3
- import { SchemaValidator, test } from '../schema.validator';
4
- import type { Coercible, SchemaDefinition, SchemaOptions } from '../types';
5
- export declare type RegExpSchemaDefinition = SchemaDefinition<'regexp', unknown, RegExp> & Coercible;
6
- export declare class RegExpSchemaValidator extends SchemaValidator<RegExpSchemaDefinition> {
7
- [test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<RegExp>;
8
- }
9
- export declare function regexp(options?: SchemaOptions<RegExpSchemaDefinition>): RegExpSchemaValidator;
1
+ import type { Decorator } from "../../reflection";
2
+ import type { Schema } from '../schema';
3
+ import type { Coercible } from '../types';
4
+ export declare type RegExpSchemaOptions = Coercible;
5
+ export declare function regexp(options?: RegExpSchemaOptions): Schema<globalThis.RegExp>;
6
+ export declare function RegExp(options?: RegExpSchemaOptions): Decorator<'property' | 'accessor'>;
@@ -1,34 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.regexp = exports.RegExpSchemaValidator = void 0;
4
- const type_guards_1 = require("../../utils/type-guards");
5
- const type_of_1 = require("../../utils/type-of");
6
- const schema_error_1 = require("../schema.error");
7
- const schema_validator_1 = require("../schema.validator");
3
+ exports.RegExp = exports.regexp = void 0;
4
+ const decorators_1 = require("../decorators");
8
5
  const types_1 = require("../types");
9
- class RegExpSchemaValidator extends schema_validator_1.SchemaValidator {
10
- [schema_validator_1.test](value, options, path) {
11
- if (!(0, type_guards_1.isRegExp)(value)) {
12
- if ((this.schema.coerce ?? options.coerce) && (0, type_guards_1.isString)(value)) {
13
- try {
14
- return { valid: true, value: RegExp(value, 'u') };
15
- }
16
- catch (error) {
17
- return { valid: false, error: (0, schema_error_1.schemaError)(`could not coerce provided string to regular expression: ${error.message}`, path) };
18
- }
19
- }
20
- return { valid: false, error: schema_error_1.SchemaError.expectedButGot('RegExp', (0, type_of_1.typeOf)(value), path) };
21
- }
22
- return { valid: true, value };
23
- }
24
- }
25
- exports.RegExpSchemaValidator = RegExpSchemaValidator;
26
- function regexp(options) {
27
- const schema = (0, types_1.schemaHelper)({
28
- type: 'regexp',
29
- ...options
6
+ function regexp(options = {}) {
7
+ return (0, types_1.valueSchema)({
8
+ type: globalThis.RegExp,
9
+ coerce: options.coerce
30
10
  });
31
- return new RegExpSchemaValidator(schema);
32
11
  }
33
12
  exports.regexp = regexp;
13
+ function RegExp(options) {
14
+ return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(regexp(options));
15
+ }
16
+ exports.RegExp = RegExp;
34
17
  //# sourceMappingURL=regexp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../../source/schema/schemas/regexp.ts"],"names":[],"mappings":";;;AACA,yDAAyD;AACzD,iDAAyC;AACzC,kDAA2D;AAE3D,0DAA4D;AAE5D,oCAAwC;AAIxC,MAAa,qBAAsB,SAAQ,kCAAuC;IAChF,CAAC,uBAAI,CAAC,CAAC,KAAc,EAAE,OAAi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CAAC;AALD,wBAKC;AAED,SAAgB,MAAM,CAAC,OAA6B;IAClD,OAAO,IAAA,uDAA0C,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACrE,CAAC;AAFD,wBAEC"}
@@ -1,8 +1,6 @@
1
- import type { JsonPath } from "../../json-path";
2
- import type { DefinedValidationOptions, ValidationTestResult } from '../schema.validator';
3
- import { SchemaValidator, test } from '../schema.validator';
4
- import type { Coercible, SchemaDefinition, SchemaOptions } from '../types';
5
- export declare type StringSchemaDefinition = SchemaDefinition<'string', unknown, string> & Coercible & {
1
+ import type { Decorator } from "../../reflection";
2
+ import type { Coercible, ValueSchema } from '../types';
3
+ export declare type StringOptions = Coercible & {
6
4
  /** trim */
7
5
  trim?: boolean;
8
6
  /** lowercase */
@@ -10,17 +8,15 @@ export declare type StringSchemaDefinition = SchemaDefinition<'string', unknown,
10
8
  /** uppercase */
11
9
  uppercase?: boolean;
12
10
  /** minimum length */
13
- min?: number;
11
+ minimumLength?: number;
14
12
  /** maximum length */
15
- max?: number;
13
+ maximumLength?: number;
16
14
  /** regular expression */
17
15
  pattern?: string | RegExp;
18
16
  /** regular expression flags */
19
17
  patternFlags?: string;
18
+ /** name for errors */
19
+ patternName?: string;
20
20
  };
21
- export declare class StringSchemaValidator extends SchemaValidator<StringSchemaDefinition> {
22
- private readonly regexp;
23
- constructor(schema: StringSchemaDefinition);
24
- [test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<string>;
25
- }
26
- export declare function string(options?: SchemaOptions<StringSchemaDefinition>): StringSchemaValidator;
21
+ export declare function string(options?: StringOptions): ValueSchema<string>;
22
+ export declare function String(options?: StringOptions): Decorator<'property' | 'accessor'>;
@@ -1,56 +1,44 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/naming-convention */
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.string = exports.StringSchemaValidator = void 0;
4
+ exports.String = exports.string = void 0;
4
5
  const type_guards_1 = require("../../utils/type-guards");
5
- const schema_error_1 = require("../schema.error");
6
- const schema_validator_1 = require("../schema.validator");
6
+ const constraints_1 = require("../constraints");
7
+ const decorators_1 = require("../decorators");
8
+ const transformers_1 = require("../transformers");
7
9
  const types_1 = require("../types");
8
- const coercerMap = {
9
- number: (number) => ({ valid: true, value: number.toString() }),
10
- boolean: (boolean) => ({ valid: true, value: boolean.toString() }),
11
- bigint: (bigint) => ({ valid: true, value: bigint.toString() })
12
- };
13
- class StringSchemaValidator extends schema_validator_1.SchemaValidator {
14
- constructor(schema) {
15
- const pattern = (0, type_guards_1.isRegExp)(schema.pattern) ? schema.pattern.source : schema.pattern;
16
- const patternFlags = (0, type_guards_1.isRegExp)(schema.pattern) ? (schema.patternFlags ?? schema.pattern.flags) : schema.patternFlags;
17
- super({ ...schema, pattern, patternFlags });
18
- this.regexp = (0, type_guards_1.isDefined)(pattern) ? RegExp(pattern, patternFlags) : undefined;
10
+ function string(options = {}) {
11
+ const constraints = [];
12
+ const transformers = [];
13
+ if ((0, type_guards_1.isDefined)(options.minimumLength)) {
14
+ constraints.push(new constraints_1.MinimumLengthConstraint(options.minimumLength));
19
15
  }
20
- [schema_validator_1.test](value, options, path) {
21
- const result = super.ensureType('string', value, path, { coerce: this.schema.coerce ?? options.coerce }, coercerMap);
22
- if (!result.valid) {
23
- return result;
24
- }
25
- let resultValue = result.value;
26
- if (this.schema.trim == true) {
27
- resultValue = resultValue.trim();
28
- }
29
- if (this.schema.lowercase == true) {
30
- resultValue = resultValue.toLowerCase();
31
- }
32
- if (this.schema.uppercase == true) {
33
- resultValue = resultValue.toUpperCase();
34
- }
35
- if ((0, type_guards_1.isDefined)(this.schema.min) && (resultValue.length < this.schema.min)) {
36
- return { valid: false, error: (0, schema_error_1.schemaError)(`minimum length is ${this.schema.min} but value has ${resultValue.length}`, path) };
37
- }
38
- if ((0, type_guards_1.isDefined)(this.schema.max) && (resultValue.length > this.schema.max)) {
39
- return { valid: false, error: (0, schema_error_1.schemaError)(`maximum length is ${this.schema.max} but value has ${resultValue.length}`, path) };
40
- }
41
- if ((0, type_guards_1.isDefined)(this.regexp) && !this.regexp.test(resultValue)) {
42
- return { valid: false, error: (0, schema_error_1.schemaError)('pattern did not match', path) };
43
- }
44
- return { valid: true, value: resultValue };
16
+ if ((0, type_guards_1.isDefined)(options.maximumLength)) {
17
+ constraints.push(new constraints_1.MaximumLengthConstraint(options.maximumLength));
45
18
  }
46
- }
47
- exports.StringSchemaValidator = StringSchemaValidator;
48
- function string(options) {
49
- const schema = (0, types_1.schemaHelper)({
50
- type: 'string',
51
- ...options
19
+ if ((0, type_guards_1.isDefined)(options.pattern)) {
20
+ const pattern = RegExp(options.pattern, options.patternFlags);
21
+ constraints.push(new constraints_1.PatternConstraint(pattern, options.patternName));
22
+ }
23
+ if ((0, type_guards_1.isDefined)(options.trim)) {
24
+ transformers.push(new transformers_1.TrimTransformer());
25
+ }
26
+ if ((0, type_guards_1.isDefined)(options.lowercase)) {
27
+ transformers.push(new transformers_1.LowercaseTransformer());
28
+ }
29
+ if ((0, type_guards_1.isDefined)(options.uppercase)) {
30
+ transformers.push(new transformers_1.UppercaseTransformer());
31
+ }
32
+ return (0, types_1.valueSchema)({
33
+ type: globalThis.String,
34
+ coerce: options.coerce,
35
+ valueConstraints: constraints,
36
+ transformers
52
37
  });
53
- return new StringSchemaValidator(schema);
54
38
  }
55
39
  exports.string = string;
40
+ function String(options) {
41
+ return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(string(options));
42
+ }
43
+ exports.String = String;
56
44
  //# sourceMappingURL=string.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../source/schema/schemas/string.ts"],"names":[],"mappings":";;;AACA,yDAA0D;AAC1D,kDAA8C;AAE9C,0DAA4D;AAE5D,oCAAwC;AAExC,MAAM,UAAU,GAAuB;IACrC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAA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AAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;KACvE;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC3B,YAAY,CAAC,IAAI,CAAC,IAAI,8BAAe,EAAE,CAAC,CAAC;KAC1C;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAChC,YAAY,CAAC,IAAI,CAAC,IAAI,mCAAoB,EAAE,CAAC,CAAC;KAC/C;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAChC,YAAY,CAAC,IAAI,CAAC,IAAI,mCAAoB,EAAE,CAAC,CAAC;KAC/C;IAED,OAAO,IAAA,mBAAW,EAAC;QACjB,IAAI,EAAE,UAAU,CAAC,MAAM;QACvB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,gBAAgB,EAAE,WAAW;QAC7B,YAAY;KACb,CAAC,CAAC;AACL,CAAC;AAnCD,wBAmCC;AAED,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,IAAA,uDAA0C,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACrE,CAAC;AAFD,wBAEC"}
@@ -1,16 +1,4 @@
1
- import type { JsonPath } from "../../json-path";
2
- import type { DefinedValidationOptions, ValidationTestResult } from '../schema.validator';
3
- import { SchemaValidator, test, testAsync } from '../schema.validator';
4
- import type { SchemaDefinition, SchemaInput, SchemaOptions, SchemaOutput } from '../types';
5
- export declare type Transformer<T extends SchemaDefinition, Output> = (value: SchemaOutput<T>) => Output | Promise<Output>;
6
- export declare type TransformSchemaDefinition<T extends SchemaDefinition = SchemaDefinition, Output = unknown> = SchemaDefinition<'transform', SchemaInput<T>, Output> & {
7
- inputSchema: T;
8
- transformer: Transformer<T, Output>;
9
- };
10
- export declare class TransformSchemaValidator<T extends SchemaDefinition, Output> extends SchemaValidator<TransformSchemaDefinition<T, Output>> {
11
- private readonly inputValidator;
12
- constructor(schema: TransformSchemaDefinition<T, Output>, inputValidator: SchemaValidator<T>);
13
- [test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<Output>;
14
- protected [testAsync](value: unknown, options: DefinedValidationOptions, path: JsonPath): Promise<ValidationTestResult<Output>>;
15
- }
16
- export declare function transform<T extends SchemaDefinition, Output>(inputSchemaValidator: SchemaValidator<T>, transformer: Transformer<T, Output>, options?: SchemaOptions<TransformSchemaDefinition<T, Output>, 'inputSchema' | 'transformer'>): TransformSchemaValidator<T, Output>;
1
+ import type { OneOrMany } from "../../types";
2
+ import type { GenericTransformFunction } from '../transformers/generic';
3
+ import type { MaybeDeferredValueTypes, ValueSchema, ValueType } from '../types';
4
+ export declare function transform<T>(schema: MaybeDeferredValueTypes<T>, sourceType: OneOrMany<ValueType>, targetType: ValueType, transformFunction: GenericTransformFunction<T>): ValueSchema<T>;
@@ -1,43 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transform = exports.TransformSchemaValidator = void 0;
4
- const type_guards_1 = require("../../utils/type-guards");
5
- const schema_validator_1 = require("../schema.validator");
3
+ exports.transform = void 0;
4
+ const generic_1 = require("../transformers/generic");
6
5
  const types_1 = require("../types");
7
- class TransformSchemaValidator extends schema_validator_1.SchemaValidator {
8
- constructor(schema, inputValidator) {
9
- super(schema);
10
- this.inputValidator = inputValidator;
11
- }
12
- [schema_validator_1.test](value, options, path) {
13
- const inputTestResult = this.inputValidator[schema_validator_1.test](value, options, path);
14
- if (!inputTestResult.valid) {
15
- return inputTestResult;
16
- }
17
- const transformed = this.schema.transformer(inputTestResult.value);
18
- if ((0, type_guards_1.isPromise)(transformed)) {
19
- throw new Error(`cannot handle async transform in sync validation. Use async instead (path: ${path.path})`);
20
- }
21
- return { valid: true, value: transformed };
22
- }
23
- async [schema_validator_1.testAsync](value, options, path) {
24
- const inputTestResult = await this.inputValidator[schema_validator_1.testAsync](value, options, path);
25
- if (!inputTestResult.valid) {
26
- return inputTestResult;
27
- }
28
- const transformed = await this.schema.transformer(inputTestResult.value);
29
- return { valid: true, value: transformed };
30
- }
31
- }
32
- exports.TransformSchemaValidator = TransformSchemaValidator;
33
- function transform(inputSchemaValidator, transformer, options) {
34
- const schema = (0, types_1.schemaHelper)({
35
- type: 'transform',
36
- inputSchema: inputSchemaValidator.schema,
37
- transformer,
38
- ...options
6
+ function transform(schema, sourceType, targetType, transformFunction) {
7
+ return (0, types_1.valueSchema)({
8
+ type: schema,
9
+ transformers: new generic_1.GenericTransformer(sourceType, targetType, transformFunction)
39
10
  });
40
- return new TransformSchemaValidator(schema, inputSchemaValidator);
41
11
  }
42
12
  exports.transform = transform;
13
+ /* decorator is in file of GenericTransformer */
43
14
  //# sourceMappingURL=transform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../source/schema/schemas/transform.ts"],"names":[],"mappings":";;;AACA,yDAAgD;AAEhD,0DAAuE;AAEvE,oCAAwC;AASxC,MAAa,wBAA6D,SAAQ,kCAAqD;IAGrI,YAAY,MAA4C,EAAE,cAAkC;QAC1F,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED,CAAC,uBAAI,CAAC,CAAC,KAAc,EAAE,OAAiC,EAAE,IAAc;QACtE,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,uBAAI,CAAC,CAAC,KAAuB,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAE1F,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE;YAC1B,OAAO,eAAe,CAAC;SACxB;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAEnE,IAAI,IAAA,uBAAS,EAAC,WAAW,CAAC,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,8EAA8E,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC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@@ -1,12 +1,9 @@
1
- import type { JsonPath } from "../../json-path";
2
- import type { DefinedValidationOptions, ValidationTestResult } from '../schema.validator';
3
- import { SchemaValidator, test } from '../schema.validator';
4
- import type { Coercible, SchemaDefinition, SchemaOptions, SchemaOutput } from '../types';
5
- export declare type Uint8ArraySchemaDefinition = SchemaDefinition<'uint8-array', unknown, Uint8Array> & Coercible & {
6
- min?: number;
7
- max?: number;
1
+ import type { Decorator } from "../../reflection";
2
+ import type { Schema } from '../schema';
3
+ import type { Coercible } from '../types';
4
+ export declare type Uint8ArraySchemaOptions = Coercible & {
5
+ minimumLength?: number;
6
+ maximumLength?: number;
8
7
  };
9
- export declare class Uint8ArraySchemaValidator extends SchemaValidator<Uint8ArraySchemaDefinition> {
10
- [test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<SchemaOutput<Uint8ArraySchemaDefinition>>;
11
- }
12
- export declare function uint8Array(options?: SchemaOptions<Uint8ArraySchemaDefinition>): Uint8ArraySchemaValidator;
8
+ export declare function uint8Array(options?: Uint8ArraySchemaOptions): Schema<Uint8Array>;
9
+ export declare function Uint8Array(options?: Uint8ArraySchemaOptions): Decorator<'property' | 'accessor'>;
@@ -1,41 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uint8Array = exports.Uint8ArraySchemaValidator = void 0;
3
+ exports.Uint8Array = exports.uint8Array = void 0;
4
4
  const type_guards_1 = require("../../utils/type-guards");
5
- const schema_error_1 = require("../schema.error");
6
- const schema_validator_1 = require("../schema.validator");
5
+ const uint8_array_coercer_1 = require("../coercers/uint8-array.coercer");
6
+ const maximum_length_1 = require("../constraints/maximum-length");
7
+ const minimum_length_1 = require("../constraints/minimum-length");
8
+ const decorators_1 = require("../decorators");
7
9
  const types_1 = require("../types");
8
- const instance_1 = require("./instance");
9
- const uint8ArrayInstanceSchema = (0, instance_1.instance)(Uint8Array);
10
- class Uint8ArraySchemaValidator extends schema_validator_1.SchemaValidator {
11
- [schema_validator_1.test](value, options, path) {
12
- const instanceTestResult = uint8ArrayInstanceSchema[schema_validator_1.test](value, options, path);
13
- let array;
14
- if (instanceTestResult.valid) {
15
- array = instanceTestResult.value;
16
- }
17
- else if ((this.schema.coerce ?? options.coerce) && (0, type_guards_1.isArray)(value) && value.every((v) => (0, type_guards_1.isNumber)(v) && Number.isInteger(v) && (v >= 0) && (v <= 255))) {
18
- array = Uint8Array.from(value);
19
- }
20
- else {
21
- return instanceTestResult;
22
- }
23
- if ((0, type_guards_1.isDefined)(this.schema.min) && (array.byteLength < this.schema.min)) {
24
- return { valid: false, error: (0, schema_error_1.schemaError)(`minimum buffer length is ${this.schema.min}`, path) };
25
- }
26
- if ((0, type_guards_1.isDefined)(this.schema.max) && (array.byteLength > this.schema.max)) {
27
- return { valid: false, error: (0, schema_error_1.schemaError)(`maximum buffer length is ${this.schema.max}`, path) };
28
- }
29
- return { valid: true, value: array };
10
+ function uint8Array(options = {}) {
11
+ const constraints = [];
12
+ if ((0, type_guards_1.isDefined)(options.minimumLength)) {
13
+ constraints.push(new minimum_length_1.MinimumLengthConstraint(options.minimumLength));
30
14
  }
31
- }
32
- exports.Uint8ArraySchemaValidator = Uint8ArraySchemaValidator;
33
- function uint8Array(options) {
34
- const schema = (0, types_1.schemaHelper)({
35
- type: 'uint8-array',
36
- ...options
15
+ if ((0, type_guards_1.isDefined)(options.maximumLength)) {
16
+ constraints.push(new maximum_length_1.MaximumLengthConstraint(options.maximumLength));
17
+ }
18
+ return (0, types_1.valueSchema)({
19
+ type: globalThis.Uint8Array,
20
+ coercers: (options.coerce == true) ? uint8_array_coercer_1.uint8ArrayCoercer : undefined,
21
+ valueConstraints: constraints
37
22
  });
38
- return new Uint8ArraySchemaValidator(schema);
39
23
  }
40
24
  exports.uint8Array = uint8Array;
25
+ function Uint8Array(options) {
26
+ return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(uint8Array(options));
27
+ }
28
+ exports.Uint8Array = Uint8Array;
41
29
  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AAa,CAAC,CAAC,CAAC;KACtE;IAED,OAAO,IAAA,mBAAW,EAAC;QACjB,IAAI,EAAE,UAAU,CAAC,UAAU;QAC3B,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,uCAAiB,CAAC,CAAC,CAAC,SAAS;QAClE,gBAAgB,EAAE,WAAW;KAC9B,CAAC,CAAC;AACL,CAAC;AAhBD,gCAgBC;AAED,SAAgB,UAAU,CAAC,OAAiC;IAC1D,OAAO,IAAA,uDAA0C,EAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC;AAFD,gCAEC"}
@@ -1,17 +1,5 @@
1
- import type { JsonPath } from "../../json-path";
2
- import type { DefinedValidationOptions, ValidationTestResult } from '../schema.validator';
3
- import { SchemaValidator, test, testAsync } from '../schema.validator';
4
- import type { SchemaDefinition, SchemaInput, SchemaOptions, SchemaOutput } from '../types';
5
- export declare type UnionSchemaInput<A extends SchemaDefinition, B extends SchemaDefinition[]> = SchemaInput<A> | SchemaInput<B[number]>;
6
- export declare type UnionSchemaOutput<A extends SchemaDefinition, B extends SchemaDefinition[]> = SchemaOutput<A> | SchemaOutput<B[number]>;
7
- export declare type UnionSchemaDefinition<A extends SchemaDefinition, B extends SchemaDefinition[]> = SchemaDefinition<'union', UnionSchemaInput<A, B>, UnionSchemaOutput<A, B>> & {
8
- schemas: [A, ...B];
9
- };
10
- export declare class UnionSchemaValidator<A extends SchemaDefinition, B extends SchemaDefinition[]> extends SchemaValidator<UnionSchemaDefinition<A, B>> {
11
- private readonly innerSchemaTypesString;
12
- readonly innerSchemas: [SchemaValidator<A>, ...SchemaValidator<B[number]>[]];
13
- constructor(innerSchemas: [SchemaValidator<A>, ...SchemaValidator<B[number]>[]], schema: UnionSchemaDefinition<A, B>);
14
- [test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<UnionSchemaOutput<A, B>>;
15
- protected [testAsync](value: unknown, options: DefinedValidationOptions, path: JsonPath): Promise<ValidationTestResult<UnionSchemaOutput<A, B>>>;
16
- }
17
- export declare function union<A extends SchemaValidator, B extends SchemaValidator[]>(schemas: [A, ...B], options?: SchemaOptions<UnionSchemaDefinition<A['schema'], B[number]['schema'][]>, 'schemas'>): UnionSchemaValidator<A['schema'], B[number]['schema'][]>;
1
+ import type { Decorator } from "../../reflection";
2
+ import type { MaybeDeferredValueTypes, ValueSchema } from '../types';
3
+ export declare type UnionTypeHelper<T extends MaybeDeferredValueTypes> = T extends MaybeDeferredValueTypes<infer U> ? U : never;
4
+ export declare function union<T extends [MaybeDeferredValueTypes, ...MaybeDeferredValueTypes[]]>(...schemas: T): ValueSchema<UnionTypeHelper<T[number]>>;
5
+ export declare function Union(...schemas: [MaybeDeferredValueTypes, ...MaybeDeferredValueTypes[]]): Decorator<'property' | 'accessor'>;
@@ -1,42 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.union = exports.UnionSchemaValidator = void 0;
4
- const schema_error_1 = require("../schema.error");
5
- const schema_validator_1 = require("../schema.validator");
3
+ exports.Union = exports.union = void 0;
4
+ const decorators_1 = require("../decorators");
6
5
  const types_1 = require("../types");
7
- class UnionSchemaValidator extends schema_validator_1.SchemaValidator {
8
- constructor(innerSchemas, schema) {
9
- super(schema);
10
- this.innerSchemas = innerSchemas;
11
- this.innerSchemaTypesString = this.innerSchemas.map((innerSchema) => innerSchema.schema.type).join(', ');
12
- }
13
- [schema_validator_1.test](value, options, path) {
14
- for (const schema of this.innerSchemas) {
15
- const result = schema.test(value, options);
16
- if (result.valid) {
17
- return result;
18
- }
19
- }
20
- return { valid: false, error: new schema_error_1.SchemaError(`Value did not match any of the allowed schemas (${this.innerSchemaTypesString}).`, { path }) };
21
- }
22
- async [schema_validator_1.testAsync](value, options, path) {
23
- for (const schema of this.innerSchemas) {
24
- const result = await schema.testAsync(value, options);
25
- if (result.valid) {
26
- return result;
27
- }
28
- }
29
- return { valid: false, error: new schema_error_1.SchemaError(`Value did not match any of the allowed schemas (${this.innerSchemaTypesString}).`, { path }) };
30
- }
31
- }
32
- exports.UnionSchemaValidator = UnionSchemaValidator;
33
- function union(schemas, options) {
34
- const schema = (0, types_1.schemaHelper)({
35
- type: 'union',
36
- schemas: schemas.map((innerSchema) => innerSchema.schema),
37
- ...options
6
+ function union(...schemas) {
7
+ return (0, types_1.valueSchema)({
8
+ type: schemas
38
9
  });
39
- return new UnionSchemaValidator(schemas, schema);
40
10
  }
41
11
  exports.union = union;
12
+ function Union(...schemas) {
13
+ return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(union(...schemas));
14
+ }
15
+ exports.Union = Union;
42
16
  //# sourceMappingURL=union.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAE9C,0DAAuE;AAEvE,oCAAwC;AASxC,MAAa,oBAA+E,SAAQ,kCAA4C;IAK9I,YAAY,YAAmE,EAAE,MAAmC;QAClH,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3G,CAAC;IAED,CAAC,uBAAI,CAAC,CAAC,KAAc,EAAE,OAAiC,EAAE,IAAc;QACtE,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE;YACtC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAA0B,EAAE,OAAO,CAAC,CAAC;YAEhE,IAAI,MAAM,CAAC,KAAK,EAAE;gBAChB,OAAO,MAAM,CAAC;aACf;SACF;QAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE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CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AACvE,CAAC;AAFD,sBAEC"}
@@ -1,8 +1,4 @@
1
- import type { ValidationTestResult } from '../schema.validator';
2
- import { SchemaValidator, test } from '../schema.validator';
3
- import type { SchemaDefinition, SchemaOptions } from '../types';
4
- export declare type UnknownSchemaDefinition = SchemaDefinition<'unknown'>;
5
- export declare class UnknownSchemaValidator extends SchemaValidator<UnknownSchemaDefinition> {
6
- [test](value: unknown): ValidationTestResult<unknown>;
7
- }
8
- export declare function unknown(options?: SchemaOptions<UnknownSchemaDefinition>): UnknownSchemaValidator;
1
+ import type { Decorator } from "../../reflection";
2
+ import type { ValueSchema } from '../types';
3
+ export declare function unknown(): ValueSchema<unknown>;
4
+ export declare function Unknwon(): Decorator<'property' | 'accessor'>;
@@ -1,20 +1,15 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/naming-convention */
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unknown = exports.UnknownSchemaValidator = void 0;
4
- const schema_validator_1 = require("../schema.validator");
4
+ exports.Unknwon = exports.unknown = void 0;
5
+ const decorators_1 = require("../decorators");
5
6
  const types_1 = require("../types");
6
- class UnknownSchemaValidator extends schema_validator_1.SchemaValidator {
7
- [schema_validator_1.test](value) {
8
- return { valid: true, value };
9
- }
10
- }
11
- exports.UnknownSchemaValidator = UnknownSchemaValidator;
12
- function unknown(options) {
13
- const schema = (0, types_1.schemaHelper)({
14
- type: 'unknown',
15
- ...options
16
- });
17
- return new UnknownSchemaValidator(schema);
7
+ function unknown() {
8
+ return (0, types_1.valueSchema)({ type: 'any' });
18
9
  }
19
10
  exports.unknown = unknown;
11
+ function Unknwon() {
12
+ return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(unknown());
13
+ }
14
+ exports.Unknwon = Unknwon;
20
15
  //# sourceMappingURL=unknown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../source/schema/schemas/unknown.ts"],"names":[],"mappings":";;;AACA,0DAA4D;AAE5D,oCAAwC;AAIxC,MAAa,sBAAuB,SAAQ,kCAAwC;IAClF,CAAC,uBAAI,CAAC,CAAC,KAAc;QACnB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAChC,CAAC;CACF;AAJD,wDAIC;AAED,SAAgB,OAAO,CAAC,OAAgD;IACtE,MAAM,MAAM,GAAG,IAAA,oBAAY,EAA0B;QACnD,IAAI,EAAE,SAAS;QACf,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC;AAPD,0BAOC"}
1
+ {"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../source/schema/schemas/unknown.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAA2E;AAE3E,oCAAuC;AAEvC,SAAgB,OAAO;IACrB,OAAO,IAAA,mBAAW,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACtC,CAAC;AAFD,0BAEC;AAED,SAAgB,OAAO;IACrB,OAAO,IAAA,uDAA0C,EAAC,OAAO,EAAE,CAAC,CAAC;AAC/D,CAAC;AAFD,0BAEC"}