@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,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validate = exports.validator = exports.oneOfSchemas = exports.stripNullFromSchema = exports.setDefaultYupValidationOptions = void 0;
4
- const yup = require("yup");
5
- const types_1 = require("../types");
6
- let defaultOptions = {
7
- abortEarly: false,
8
- stripUnknown: false
9
- };
10
- function setDefaultYupValidationOptions(options) {
11
- defaultOptions = options;
12
- }
13
- exports.setDefaultYupValidationOptions = setDefaultYupValidationOptions;
14
- function stripNullFromSchema(schema) {
15
- return schema;
16
- }
17
- exports.stripNullFromSchema = stripNullFromSchema;
18
- function oneOfSchemas(schemas, message = 'value did not match any of the allowed schemas') {
19
- return yup.mixed().test({
20
- name: 'one-of-schemas',
21
- message,
22
- test(value) {
23
- const errors = [];
24
- for (const schema of schemas) {
25
- try {
26
- schema.validateSync(value, this.options);
27
- return true;
28
- }
29
- catch (error) {
30
- errors.push(error);
31
- }
32
- }
33
- const error = new yup.ValidationError('none of the provided schemas validated successfully', value, this.path);
34
- error.inner = errors;
35
- return error;
36
- }
37
- });
38
- }
39
- exports.oneOfSchemas = oneOfSchemas;
40
- function validator(schema, options) {
41
- return (value) => validate(schema, value, options);
42
- }
43
- exports.validator = validator;
44
- function validate(schema, value, options = defaultOptions) {
45
- try {
46
- return schema.validateSync(value, options);
47
- }
48
- catch (error) {
49
- throw convertError(error);
50
- }
51
- }
52
- exports.validate = validate;
53
- function convertError(error) {
54
- const details = {
55
- path: error.path
56
- };
57
- const inner = (error.inner.length > 0) ? error.inner.map(convertError) : undefined;
58
- return new types_1.ValidationError(error.message, { details, inner });
59
- }
60
- //# sourceMappingURL=yup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"yup.js","sourceRoot":"","sources":["../../../../source/old-api/validation/validators/yup.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AAE3B,oCAA2C;AAE3C,IAAI,cAAc,GAAwB;IACxC,UAAU,EAAE,KAAK;IACjB,YAAY,EAAE,KAAK;CACpB,CAAC;AAEF,SAAgB,8BAA8B,CAAC,OAA4B;IACzE,cAAc,GAAG,OAAO,CAAC;AAC3B,CAAC;AAFD,wEAEC;AAED,SAAgB,mBAAmB,CAAI,MAA0B;IAC/D,OAAO,MAA2C,CAAC;AACrD,CAAC;AAFD,kDAEC;AAED,SAAgB,YAAY,CAAI,OAAwB,EAAE,UAAkB,gDAAgD;IAC1H,OAAO,GAAG,CAAC,KAAK,EAAK,CAAC,IAAI,CAAC;QACzB,IAAI,EAAE,gBAAgB;QACtB,OAAO;QACP,IAAI,CAAC,KAAU;YACb,MAAM,MAAM,GAA0B,EAAE,CAAC;YAEzC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;gBAC5B,IAAI;oBACF,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;oBACzC,OAAO,IAAI,CAAC;iBACb;gBACD,OAAO,KAAc,EAAE;oBACrB,MAAM,CAAC,IAAI,CAAC,KAA4B,CAAC,CAAC;iBAC3C;aACF;YAED,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,qDAAqD,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/G,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;YAErB,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAvBD,oCAuBC;AAED,SAAgB,SAAS,CAAI,MAAqB,EAAE,OAA6B;IAC/E,OAAO,CAAC,KAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC;AAFD,8BAEC;AAED,SAAgB,QAAQ,CAAO,MAAqB,EAAE,KAAQ,EAAE,UAA+B,cAAc;IAC3G,IAAI;QACF,OAAO,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KAC5C;IACD,OAAO,KAAc,EAAE;QACrB,MAAM,YAAY,CAAC,KAA4B,CAAC,CAAC;KAClD;AACH,CAAC;AAPD,4BAOC;AAED,SAAS,YAAY,CAAC,KAA0B;IAC9C,MAAM,OAAO,GAAG;QACd,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC;IAEF,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEnF,OAAO,IAAI,uBAAe,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AAChE,CAAC"}
@@ -1,40 +0,0 @@
1
- import { JsonPath } from "../json-path";
2
- import type { PrimitiveType, PrimitiveTypeString, Type } from "../types";
3
- import { SchemaError } from './schema.error';
4
- import type { Coercible, Maskable, SchemaDefinition, SchemaInput, SchemaOutput } from './types';
5
- export declare const test: unique symbol;
6
- export declare const testAsync: unique symbol;
7
- export declare type CoercerFunction<P extends PrimitiveTypeString, T> = (value: PrimitiveType<P>, path: string | JsonPath) => ValidationTestResult<T>;
8
- export declare type CoercerMap<T> = {
9
- [P in PrimitiveTypeString]?: CoercerFunction<P, T>;
10
- };
11
- export declare type ValidationOptions = Coercible & Maskable;
12
- export declare type DefinedValidationOptions = Required<ValidationOptions>;
13
- export declare type ValidationTestResult<T> = {
14
- valid: true;
15
- value: T;
16
- error?: undefined;
17
- } | {
18
- valid: false;
19
- value?: undefined;
20
- error: SchemaError;
21
- };
22
- export declare type EnsureTypeOptions = Coercible;
23
- export declare abstract class SchemaValidator<S extends SchemaDefinition = SchemaDefinition> {
24
- readonly schema: S;
25
- /** used for type inference only */
26
- readonly inputType: SchemaInput<S>;
27
- /** used for type inference only */
28
- readonly outputType: SchemaOutput<S>;
29
- constructor(schema: S);
30
- is(value: any, options?: ValidationOptions): value is SchemaOutput<S>;
31
- isAsync(value: SchemaInput<S>, options?: ValidationOptions): Promise<boolean>;
32
- parse(value: SchemaInput<S>, options?: ValidationOptions): SchemaOutput<S>;
33
- parseAsync(value: SchemaInput<S>, options?: ValidationOptions): Promise<SchemaOutput<S>>;
34
- test(value: SchemaInput<S>, options?: ValidationOptions): ValidationTestResult<SchemaOutput<S>>;
35
- testAsync(value: SchemaInput<S>, options?: ValidationOptions): Promise<ValidationTestResult<SchemaOutput<S>>>;
36
- protected ensureType<U extends PrimitiveType>(type: PrimitiveTypeString<U>, value: unknown, path: JsonPath, options?: EnsureTypeOptions, coercers?: CoercerMap<U>): ValidationTestResult<U>;
37
- protected ensureInstance<U extends PrimitiveType>(type: Type, value: unknown, path: JsonPath, options?: EnsureTypeOptions, coercers?: CoercerMap<U>): ValidationTestResult<U>;
38
- protected [testAsync](value: SchemaInput<S>, options: DefinedValidationOptions, path: JsonPath): Promise<ValidationTestResult<SchemaOutput<S>>>;
39
- protected abstract [test](value: SchemaInput<S>, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<SchemaOutput<S>>;
40
- }
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SchemaValidator = exports.testAsync = exports.test = void 0;
4
- const json_path_1 = require("../json-path");
5
- const type_guards_1 = require("../utils/type-guards");
6
- const type_of_1 = require("../utils/type-of");
7
- const schema_error_1 = require("./schema.error");
8
- exports.test = Symbol('test');
9
- exports.testAsync = Symbol('testAsync');
10
- class SchemaValidator {
11
- constructor(schema) {
12
- this.schema = schema;
13
- }
14
- is(value, options) {
15
- const result = this.test(value, options);
16
- return result.valid;
17
- }
18
- async isAsync(value, options) {
19
- const result = await this.testAsync(value, options);
20
- return result.valid;
21
- }
22
- parse(value, options) {
23
- const result = this.test(value, options);
24
- if (result.valid) {
25
- return result.value;
26
- }
27
- throw result.error;
28
- }
29
- async parseAsync(value, options) {
30
- const result = await this.testAsync(value, options);
31
- if (result.valid) {
32
- return result.value;
33
- }
34
- throw result.error;
35
- }
36
- test(value, options) {
37
- return this[exports.test](value, convertOptions(options), new json_path_1.JsonPath());
38
- }
39
- async testAsync(value, options) {
40
- return this[exports.testAsync](value, convertOptions(options), new json_path_1.JsonPath());
41
- }
42
- ensureType(type, value, path, options, coercers) {
43
- const valueType = typeof value;
44
- if (valueType == type) {
45
- return { valid: true, value: value };
46
- }
47
- const coercer = (options?.coerce ?? false) ? coercers?.[valueType] : undefined;
48
- if ((0, type_guards_1.isUndefined)(coercer)) {
49
- return { valid: false, error: schema_error_1.SchemaError.expectedButGot(type, (0, type_of_1.typeOf)(value), path) };
50
- }
51
- return coercer(value, path);
52
- }
53
- ensureInstance(type, value, path, options, coercers) {
54
- if (value instanceof type) {
55
- return { valid: true, value: value };
56
- }
57
- const coercer = (options?.coerce ?? false) ? coercers?.[typeof value] : undefined;
58
- if ((0, type_guards_1.isUndefined)(coercer)) {
59
- return { valid: false, error: schema_error_1.SchemaError.expectedButGot(type.name, (0, type_of_1.typeOf)(value), path) };
60
- }
61
- return coercer(value, path);
62
- }
63
- // eslint-disable-next-line @typescript-eslint/adjacent-overload-signatures, @typescript-eslint/require-await
64
- async [exports.testAsync](value, options, path) {
65
- return this[exports.test](value, options, path);
66
- }
67
- }
68
- exports.SchemaValidator = SchemaValidator;
69
- function convertOptions(options) {
70
- return {
71
- coerce: options?.coerce ?? false,
72
- mask: options?.mask ?? false
73
- };
74
- }
75
- //# sourceMappingURL=schema.validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sch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,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAEzH,IAAI,IAAA,yBAAW,EAAC,OAAO,CAAC,EAAE;YACxB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAA,gBAAM,EAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;SAC5F;QAED,OAAO,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,6GAA6G;IACnG,KAAK,CAAC,CAAC,iBAAS,CAAC,CAAC,KAAqB,EAAE,OAAiC,EAAE,IAAc;QAClG,OAAO,IAAI,CAAC,YAAI,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;CAGF;AAvFD,0CAuFC;AAED,SAAS,cAAc,CAAC,OAA2B;IACjD,OAAO;QACL,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;QAChC,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,KAAK;KAC7B,CAAC;AACJ,CAAC"}
@@ -1,13 +0,0 @@
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 { SchemaDefinition, SchemaInput, SchemaOptions, SchemaOutput } from '../types';
5
- export declare type AsyncIterableSchemaDefinition<T extends SchemaDefinition> = SchemaDefinition<'asyncIterable', AsyncIterable<SchemaInput<T>>, AsyncIterable<SchemaOutput<T>>> & {
6
- schema: T;
7
- };
8
- export declare class AsyncIterableSchemaValidator<T extends SchemaDefinition> extends SchemaValidator<AsyncIterableSchemaDefinition<T>> {
9
- private readonly innerValidator;
10
- constructor(innerValidator: SchemaValidator<T>, schema: AsyncIterableSchemaDefinition<T>);
11
- [test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<SchemaOutput<AsyncIterableSchemaDefinition<T>>>;
12
- }
13
- export declare function asyncIterable<T extends SchemaDefinition>(schemaValidator: SchemaValidator<T>, options?: SchemaOptions<AsyncIterableSchemaDefinition<T>, 'schema'>): AsyncIterableSchemaValidator<T>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asyncIterable = exports.AsyncIterableSchemaValidator = void 0;
4
- const any_iterable_iterator_1 = require("../../utils/any-iterable-iterator");
5
- const map_1 = require("../../utils/async-iterable-helpers/map");
6
- const type_of_1 = require("../../utils/type-of");
7
- const schema_error_1 = require("../schema.error");
8
- const schema_validator_1 = require("../schema.validator");
9
- const types_1 = require("../types");
10
- class AsyncIterableSchemaValidator extends schema_validator_1.SchemaValidator {
11
- constructor(innerValidator, schema) {
12
- super(schema);
13
- this.innerValidator = innerValidator;
14
- }
15
- [schema_validator_1.test](value, options, path) {
16
- if (!(0, any_iterable_iterator_1.isAnyIterable)(value)) {
17
- return { valid: false, error: schema_error_1.SchemaError.expectedButGot('iterable or async-iterable', (0, type_of_1.typeOf)(value), path) };
18
- }
19
- const innerValidator = this.innerValidator;
20
- const validatedAsyncIterable = (0, map_1.mapAsync)(value, async (innerValue) => {
21
- const testResult = await innerValidator[schema_validator_1.testAsync](innerValue, options, path.add('@asyncIteration'));
22
- if (!testResult.valid) {
23
- throw testResult.error;
24
- }
25
- return testResult.value;
26
- });
27
- return { valid: true, value: validatedAsyncIterable };
28
- }
29
- }
30
- exports.AsyncIterableSchemaValidator = AsyncIterableSchemaValidator;
31
- function asyncIterable(schemaValidator, options) {
32
- const schema = (0, types_1.schemaHelper)({
33
- type: 'asyncIterable',
34
- schema: schemaValidator.schema,
35
- ...options
36
- });
37
- return new AsyncIterableSchemaValidator(schemaValidator, schema);
38
- }
39
- exports.asyncIterable = asyncIterable;
40
- //# sourceMappingURL=async-iterable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-iterable.js","sourceRoot":"","sources":["../../../source/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e,CAAC,MAAM;QAC9B,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,IAAI,4BAA4B,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AACnE,CAAC;AARD,sCAQC"}
@@ -1,13 +0,0 @@
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 { SchemaDefinition, SchemaInput, SchemaOptions, SchemaOutput } from '../types';
5
- export declare type IterableSchemaDefinition<T extends SchemaDefinition> = SchemaDefinition<'iterable', Iterable<SchemaInput<T>>, Iterable<SchemaOutput<T>>> & {
6
- schema: T;
7
- };
8
- export declare class IterableSchemaValidator<T extends SchemaDefinition> extends SchemaValidator<IterableSchemaDefinition<T>> {
9
- private readonly innerValidator;
10
- constructor(innerValidator: SchemaValidator<T>, schema: IterableSchemaDefinition<T>);
11
- [test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<SchemaOutput<IterableSchemaDefinition<T>>>;
12
- }
13
- export declare function iterable<T extends SchemaDefinition>(schemaValidator: SchemaValidator<T>, options?: SchemaOptions<IterableSchemaDefinition<T>, 'schema'>): IterableSchemaValidator<T>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.iterable = exports.IterableSchemaValidator = void 0;
4
- const is_iterable_1 = require("../../utils/iterable-helpers/is-iterable");
5
- const map_1 = require("../../utils/iterable-helpers/map");
6
- const type_of_1 = require("../../utils/type-of");
7
- const schema_error_1 = require("../schema.error");
8
- const schema_validator_1 = require("../schema.validator");
9
- const types_1 = require("../types");
10
- class IterableSchemaValidator extends schema_validator_1.SchemaValidator {
11
- constructor(innerValidator, schema) {
12
- super(schema);
13
- this.innerValidator = innerValidator;
14
- }
15
- [schema_validator_1.test](value, options, path) {
16
- if (!(0, is_iterable_1.isIterable)(value)) {
17
- return { valid: false, error: schema_error_1.SchemaError.expectedButGot('iterable', (0, type_of_1.typeOf)(value), path) };
18
- }
19
- const innerValidator = this.innerValidator;
20
- const validatedIterable = (0, map_1.map)(value, (innerValue) => {
21
- const testResult = innerValidator[schema_validator_1.test](innerValue, options, path.add('@iteration'));
22
- if (!testResult.valid) {
23
- throw testResult.error;
24
- }
25
- return testResult.value;
26
- });
27
- return { valid: true, value: validatedIterable };
28
- }
29
- }
30
- exports.IterableSchemaValidator = IterableSchemaValidator;
31
- function iterable(schemaValidator, options) {
32
- const schema = (0, types_1.schemaHelper)({
33
- type: 'iterable',
34
- schema: schemaValidator.schema,
35
- ...options
36
- });
37
- return new IterableSchemaValidator(schemaValidator, schema);
38
- }
39
- exports.iterable = iterable;
40
- //# sourceMappingURL=iterable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"iterable.js","sourceRoot":"","sources":["../../../source/schema/schemas/iterable.ts"],"names":[],"mappings":";;;AACA,0EAAkE;AAClE,0DAAmD;AACnD,iDAAyC;AACzC,kDAA8C;AAE9C,0DAA4D;AAE5D,oCAAwC;AAMxC,MAAa,uBAAoD,SAAQ,kCAA4C;IAGnH,YAAY,cAAkC,EAAE,MAAmC;QACjF,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,IAAI,CAAC,IAAA,wBAAU,EAAC,KAAK,CAAC,EAAE;YACtB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,UAAU,EAAE,IAAA,gBAAM,EAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;SAC7F;QAED,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAE3C,MAAM,iBAAiB,GAAG,IAAA,SAAG,EAAC,KAAkC,EAAE,CAAC,UAAU,EAAE,EAAE;YAC/E,MAAM,UAAU,GAAG,cAAc,CAAC,uBAAI,CAAC,CAAC,UAA4B,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;YAEvG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;gBACrB,MAAM,UAAU,CAAC,KAAK,CAAC;aACxB;YAED,OAAO,UAAU,CAAC,KAAK,CAAC;QAC1B,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IACnD,CAAC;CACF;AA5BD,0DA4BC;AAED,SAAgB,QAAQ,CAA6B,eAAmC,EAAE,OAA8D;IACtJ,MAAM,MAAM,GAAG,IAAA,oBAAY,EAA8B;QACvD,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,eAAe,CAAC,MAAM;QAC9B,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,IAAI,uBAAuB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAC9D,CAAC;AARD,4BAQC"}
@@ -1,9 +0,0 @@
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 { SchemaDefinition, SchemaOptions, SchemaOutput } from '../types';
5
- export declare type NeverSchemaDefinition = SchemaDefinition<'never', unknown, never>;
6
- export declare class NeverSchemaValidator extends SchemaValidator<NeverSchemaDefinition> {
7
- [test](value: unknown, _options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<SchemaOutput<NeverSchemaDefinition>>;
8
- }
9
- export declare function never(options?: SchemaOptions<NeverSchemaDefinition>): NeverSchemaValidator;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.never = exports.NeverSchemaValidator = void 0;
4
- const type_of_1 = require("../../utils/type-of");
5
- const schema_error_1 = require("../schema.error");
6
- const schema_validator_1 = require("../schema.validator");
7
- const types_1 = require("../types");
8
- class NeverSchemaValidator extends schema_validator_1.SchemaValidator {
9
- [schema_validator_1.test](value, _options, path) {
10
- return { valid: false, error: schema_error_1.SchemaError.expectedButGot('never', (0, type_of_1.typeOf)(value), path) };
11
- }
12
- }
13
- exports.NeverSchemaValidator = NeverSchemaValidator;
14
- function never(options) {
15
- const schema = (0, types_1.schemaHelper)({
16
- type: 'never',
17
- ...options
18
- });
19
- return new NeverSchemaValidator(schema);
20
- }
21
- exports.never = never;
22
- //# sourceMappingURL=never.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"never.js","sourceRoot":"","sources":["../../../source/schema/schemas/never.ts"],"names":[],"mappings":";;;AACA,iDAAyC;AACzC,kDAA8C;AAE9C,0DAA4D;AAE5D,oCAAwC;AAIxC,MAAa,oBAAqB,SAAQ,kCAAsC;IAC9E,CAAC,uBAAI,CAAC,CAAC,KAAc,EAAE,QAAkC,EAAE,IAAc;QACvE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,OAAO,EAAE,IAAA,gBAAM,EAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;IAC3F,CAAC;CACF;AAJD,oDAIC;AAED,SAAgB,KAAK,CAAC,OAA8C;IAClE,MAAM,MAAM,GAAG,IAAA,oBAAY,EAAwB;QACjD,IAAI,EAAE,OAAO;QACb,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC;AAPD,sBAOC"}
@@ -1,16 +0,0 @@
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 Preprocessor<S extends SchemaDefinition, Input> = (value: Input) => SchemaInput<S> | Promise<SchemaInput<S>>;
6
- export declare type PreprocessSchemaDefinition<S extends SchemaDefinition = SchemaDefinition, Input = never> = SchemaDefinition<'preprocess', Input, SchemaOutput<S>> & {
7
- outputSchema: S;
8
- preprocessor: Preprocessor<S, Input>;
9
- };
10
- export declare class PreprocessSchemaValidator<T extends SchemaDefinition, Input = never> extends SchemaValidator<PreprocessSchemaDefinition<T, Input>> {
11
- private readonly outputValidator;
12
- constructor(schema: PreprocessSchemaDefinition<T, Input>, outputValidator: SchemaValidator<T>);
13
- [test](value: Input, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<SchemaOutput<T>>;
14
- protected [testAsync](value: Input, options: DefinedValidationOptions, path: JsonPath): Promise<ValidationTestResult<SchemaOutput<T>>>;
15
- }
16
- export declare function preprocess<T extends SchemaDefinition, Input>(outputSchemaValidator: SchemaValidator<T>, preprocessor: Preprocessor<T, Input>, options?: SchemaOptions<PreprocessSchemaDefinition<T, Input>, 'outputSchema' | 'preprocessor'>): PreprocessSchemaValidator<T, Input>;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preprocess = exports.PreprocessSchemaValidator = void 0;
4
- const type_guards_1 = require("../../utils/type-guards");
5
- const schema_validator_1 = require("../schema.validator");
6
- const types_1 = require("../types");
7
- class PreprocessSchemaValidator extends schema_validator_1.SchemaValidator {
8
- constructor(schema, outputValidator) {
9
- super(schema);
10
- this.outputValidator = outputValidator;
11
- }
12
- [schema_validator_1.test](value, options, path) {
13
- const preprocessed = this.schema.preprocessor(value);
14
- if ((0, type_guards_1.isPromise)(preprocessed)) {
15
- throw new Error(`cannot handle async preprocess in sync validation. Use async instead (path: ${path.path})`);
16
- }
17
- return this.outputValidator[schema_validator_1.test](preprocessed, options, path);
18
- }
19
- async [schema_validator_1.testAsync](value, options, path) {
20
- const preprocessed = await this.schema.preprocessor(value);
21
- return this.outputValidator[schema_validator_1.testAsync](preprocessed, options, path);
22
- }
23
- }
24
- exports.PreprocessSchemaValidator = PreprocessSchemaValidator;
25
- function preprocess(outputSchemaValidator, preprocessor, options) {
26
- const schema = (0, types_1.schemaHelper)({
27
- type: 'preprocess',
28
- outputSchema: outputSchemaValidator.schema,
29
- preprocessor,
30
- ...options
31
- });
32
- return new PreprocessSchemaValidator(schema, outputSchemaValidator);
33
- }
34
- exports.preprocess = preprocess;
35
- //# sourceMappingURL=preprocess.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preprocess.js","sourceRoot":"","sources":["../../../source/schema/schemas/preprocess.ts"],"names":[],"mappings":";;;AACA,yDAAgD;AAEhD,0DAAuE;AAEvE,oCAAwC;AASxC,MAAa,yBAAqE,SAAQ,kCAAqD;IAG7I,YAAY,MAA4C,EAAE,eAAmC;QAC3F,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED,CAAC,uBAAI,CAAC,CAAC,KAAY,EAAE,OAAiC,EAAE,IAAc;QACpE,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAErD,IAAI,IAAA,uBAAS,EAAC,YAAY,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,+EAA+E,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;SAC9G;QAED,OAAO,IAAI,CAAC,eAAe,CAAC,uBAAI,CAAC,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;IAES,KAAK,CAAC,CAAC,4BAAS,CAAC,CAAC,KAAY,EAAE,OAAiC,EAAE,IAAc;QACzF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC,eAAe,CAAC,4BAAS,CAAC,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC;CACF;AAvBD,8DAuBC;AAED,SAAgB,UAAU,CAAoC,qBAAyC,EAAE,YAAoC,EAAE,OAA8F;IAC3O,MAAM,MAAM,GAAG,IAAA,oBAAY,EAAuC;QAChE,IAAI,EAAE,YAAY;QAClB,YAAY,EAAE,qBAAqB,CAAC,MAAM;QAC1C,YAAY;QACZ,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,IAAI,yBAAyB,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AACtE,CAAC;AATD,gCASC"}
@@ -1,24 +0,0 @@
1
- import type { JsonPath } from "../../json-path";
2
- import { SchemaError } from '../schema.error';
3
- import type { DefinedValidationOptions, ValidationTestResult } from '../schema.validator';
4
- import { SchemaValidator, test, testAsync } from '../schema.validator';
5
- import type { SchemaDefinition, SchemaInput, SchemaOptions, SchemaOutput } from '../types';
6
- export declare type RefineResult = {
7
- valid: true;
8
- error?: undefined;
9
- } | {
10
- valid: false;
11
- error: SchemaError | string;
12
- };
13
- export declare type Refiner<T> = (value: T, path: JsonPath) => RefineResult | Promise<RefineResult>;
14
- export declare type RefineSchemaDefinition<S extends SchemaDefinition = SchemaDefinition> = SchemaDefinition<'refine', SchemaInput<S>, SchemaOutput<S>> & {
15
- inputSchema: S;
16
- refiner: Refiner<SchemaOutput<S>>;
17
- };
18
- export declare class RefineSchemaValidator<T extends SchemaDefinition> extends SchemaValidator<RefineSchemaDefinition<T>> {
19
- private readonly inputValidator;
20
- constructor(schema: RefineSchemaDefinition<T>, inputValidator: SchemaValidator<T>);
21
- [test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<SchemaOutput<T>>;
22
- protected [testAsync](value: unknown, options: DefinedValidationOptions, path: JsonPath): Promise<ValidationTestResult<SchemaOutput<T>>>;
23
- }
24
- export declare function refine<T extends SchemaDefinition>(inputSchemaValidator: SchemaValidator<T>, refiner: Refiner<SchemaOutput<T>>, options?: SchemaOptions<RefineSchemaDefinition<T>, 'inputSchema' | 'refiner'>): RefineSchemaValidator<T>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.refine = exports.RefineSchemaValidator = void 0;
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");
7
- const types_1 = require("../types");
8
- class RefineSchemaValidator extends schema_validator_1.SchemaValidator {
9
- constructor(schema, inputValidator) {
10
- super(schema);
11
- this.inputValidator = inputValidator;
12
- }
13
- [schema_validator_1.test](value, options, path) {
14
- const inputTestResult = this.inputValidator[schema_validator_1.test](value, options, path);
15
- if (!inputTestResult.valid) {
16
- return inputTestResult;
17
- }
18
- const refineResult = this.schema.refiner(inputTestResult.value, path);
19
- if ((0, type_guards_1.isPromise)(refineResult)) {
20
- throw new Error(`cannot handle async refine in sync validation. Use async instead (path: ${path.path})`);
21
- }
22
- if (!refineResult.valid) {
23
- const error = (refineResult.error instanceof schema_error_1.SchemaError) ? refineResult.error : new schema_error_1.SchemaError(refineResult.error, { path });
24
- return { valid: false, error };
25
- }
26
- return { valid: true, value: inputTestResult.value };
27
- }
28
- async [schema_validator_1.testAsync](value, options, path) {
29
- const inputTestResult = await this.inputValidator[schema_validator_1.testAsync](value, options, path);
30
- if (!inputTestResult.valid) {
31
- return inputTestResult;
32
- }
33
- const refineResult = await this.schema.refiner(inputTestResult.value, path);
34
- if (!refineResult.valid) {
35
- const error = (refineResult.error instanceof schema_error_1.SchemaError) ? refineResult.error : new schema_error_1.SchemaError(refineResult.error, { path });
36
- return { valid: false, error };
37
- }
38
- return { valid: true, value: inputTestResult.value };
39
- }
40
- }
41
- exports.RefineSchemaValidator = RefineSchemaValidator;
42
- function refine(inputSchemaValidator, refiner, options) {
43
- const schema = (0, types_1.schemaHelper)({
44
- type: 'refine',
45
- inputSchema: inputSchemaValidator.schema,
46
- refiner,
47
- ...options
48
- });
49
- return new RefineSchemaValidator(schema, inputSchemaValidator);
50
- }
51
- exports.refine = refine;
52
- //# sourceMappingURL=refine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"refine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