@strictly/define 0.0.1 → 0.0.2

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 (199) hide show
  1. package/.out/index.d.ts +17 -11
  2. package/.out/index.js +17 -11
  3. package/.out/transformers/copies/copy.d.ts +3 -3
  4. package/.out/transformers/copies/copy_to.d.ts +3 -3
  5. package/.out/transformers/copies/copy_to.js +4 -0
  6. package/.out/transformers/copies/mobx_copy.d.ts +4 -4
  7. package/.out/transformers/copies/mobx_copy.js +1 -1
  8. package/.out/transformers/copies/specs/copy_to.tests.js +8 -8
  9. package/.out/transformers/copies/specs/mobx_copy.tests.js +1 -1
  10. package/.out/transformers/flatteners/flatten_accessors_of_type.d.ts +5 -0
  11. package/.out/transformers/flatteners/flatten_accessors_of_type.js +11 -0
  12. package/.out/transformers/flatteners/flatten_json_value_to_type_paths_of.d.ts +2 -2
  13. package/.out/transformers/flatteners/flatten_json_value_to_type_paths_of.js +2 -2
  14. package/.out/transformers/flatteners/{flatten_type_def_to.d.ts → flatten_type_to.d.ts} +1 -1
  15. package/.out/transformers/flatteners/{flatten_type_def_to.js → flatten_type_to.js} +1 -1
  16. package/.out/transformers/flatteners/{flatten_type_defs_of.d.ts → flatten_types_of_type.d.ts} +1 -1
  17. package/.out/transformers/flatteners/flatten_types_of_type.js +7 -0
  18. package/.out/transformers/flatteners/flatten_validation_errors_of_type.d.ts +22 -0
  19. package/.out/transformers/flatteners/flatten_validation_errors_of_type.js +10 -0
  20. package/.out/transformers/flatteners/flatten_validators_of_validating_type.d.ts +4 -0
  21. package/.out/transformers/flatteners/flatten_validators_of_validating_type.js +17 -0
  22. package/.out/transformers/flatteners/{flatten_value_type_to.d.ts → flatten_value_to.d.ts} +4 -4
  23. package/.out/transformers/flatteners/{flatten_value_type_to.js → flatten_value_to.js} +7 -2
  24. package/.out/transformers/flatteners/flatten_values_of_type.d.ts +3 -0
  25. package/.out/transformers/flatteners/flatten_values_of_type.js +7 -0
  26. package/.out/transformers/flatteners/specs/{flatten_accessors_of.tests.js → flatten_accessors_of_type.tests.js} +5 -6
  27. package/.out/transformers/flatteners/specs/flatten_json_value_to_type_paths_of.tests.js +6 -6
  28. package/.out/transformers/flatteners/specs/{flatten_type_def_to.tests.js → flatten_type_to.tests.js} +15 -13
  29. package/.out/transformers/flatteners/specs/flatten_types_of_type.tests.js +18 -0
  30. package/.out/transformers/flatteners/specs/flatten_validation_errors_of_type.tests.js +25 -0
  31. package/.out/transformers/flatteners/specs/{flatten_value_type_to.tests.js → flatten_value_to.tests.js} +81 -58
  32. package/.out/transformers/flatteners/specs/{flatten_value_types_of.tests.js → flatten_values_of_type.tests.js} +4 -4
  33. package/.out/transformers/flatteners/specs/value_path_to_type_path.tests.js +5 -3
  34. package/.out/transformers/flatteners/value_path_to_type_path.d.ts +1 -1
  35. package/.out/tsconfig.tsbuildinfo +1 -1
  36. package/.out/types/builders.d.ts +55 -29
  37. package/.out/types/builders.js +116 -32
  38. package/.out/types/definitions.d.ts +1 -1
  39. package/.out/types/flattened_accessors_of_type.d.ts +9 -0
  40. package/.out/types/{flattened_type_defs_of.d.ts → flattened_types_of_type.d.ts} +9 -6
  41. package/.out/types/flattened_types_of_validating_type.d.ts +25 -0
  42. package/.out/types/flattened_validators_of_validating_type.d.ts +10 -0
  43. package/.out/types/flattened_values_of_type.d.ts +6 -0
  44. package/.out/types/{mobx_value_type_of.d.ts → mobx_value_of_type.d.ts} +2 -2
  45. package/.out/types/{partial_type_def_of.d.ts → partial_type_of_type.d.ts} +1 -1
  46. package/.out/types/path_of.d.ts +1 -0
  47. package/.out/types/{json_paths_of.d.ts → paths_of_type.d.ts} +5 -5
  48. package/.out/types/readonly_type_of_type.d.ts +29 -0
  49. package/.out/types/specs/builder.tests.js +73 -23
  50. package/.out/types/specs/{flattened_accessors_of.tests.js → flattened_accessors_of_type.tests.js} +1 -1
  51. package/.out/types/specs/{flattened_type_defs_of.tests.js → flattened_types_of_type.tests.js} +22 -15
  52. package/.out/types/specs/flattened_validators_of_validating_type.tests.js +24 -0
  53. package/.out/types/specs/flattened_values_of_type.tests.js +18 -0
  54. package/.out/types/specs/{partial_type_def_of.tests.js → partial_type_of_type.tests.js} +4 -4
  55. package/.out/types/specs/{json_paths_of.tests.js → paths_of_type.tests.js} +19 -19
  56. package/.out/types/specs/{readonly_type_def_of.tests.js → readonly_type_of_type.tests.js} +6 -6
  57. package/.out/types/specs/type_of_type.tests.d.ts +1 -0
  58. package/.out/types/specs/type_of_type.tests.js +27 -0
  59. package/.out/types/specs/value_of_type.tests.d.ts +1 -0
  60. package/.out/types/specs/{value_type_of.tests.js → value_of_type.tests.js} +1 -1
  61. package/.out/types/specs/value_to_type_paths_of_type.tests.d.ts +1 -0
  62. package/.out/types/specs/{value_to_type_paths_of.tests.js → value_to_type_paths_of_type.tests.js} +9 -9
  63. package/.out/types/specs/value_types_of_discriminated_union.tests.js +2 -2
  64. package/.out/types/strict_definitions.d.ts +2 -2
  65. package/.out/types/type_of_type.d.ts +49 -0
  66. package/.out/types/type_of_type.js +70 -0
  67. package/.out/types/validating_definitions.d.ts +49 -0
  68. package/.out/types/validating_definitions.js +1 -0
  69. package/.out/types/validating_type_def_with_error.d.ts +55 -0
  70. package/.out/types/validating_type_def_with_error.js +1 -0
  71. package/.out/types/value_of_type.d.ts +24 -0
  72. package/.out/types/value_of_type.js +1 -0
  73. package/.out/types/{value_to_type_paths_of.d.ts → value_to_type_paths_of_type.d.ts} +13 -13
  74. package/.out/types/value_to_type_paths_of_type.js +1 -0
  75. package/.out/types/value_types_of_discriminated_union.d.ts +5 -4
  76. package/.out/validation/errors_of_validators.d.ts +4 -0
  77. package/.out/validation/errors_of_validators.js +1 -0
  78. package/.out/validation/specs/errors_of_validators.tests.d.ts +1 -0
  79. package/.out/validation/specs/errors_of_validators.tests.js +9 -0
  80. package/.out/validation/specs/validators_of_values.tests.d.ts +1 -0
  81. package/.out/validation/specs/validators_of_values.tests.js +21 -0
  82. package/.out/validation/validator.d.ts +21 -0
  83. package/.out/validation/validator.js +26 -0
  84. package/.out/validation/validators/defined_validator.d.ts +10 -0
  85. package/.out/validation/validators/defined_validator.js +18 -0
  86. package/.out/validation/validators/minimum_string_length_validator.d.ts +16 -0
  87. package/.out/validation/validators/minimum_string_length_validator.js +23 -0
  88. package/.out/validation/validators_of_values.d.ts +4 -0
  89. package/.out/validation/validators_of_values.js +1 -0
  90. package/.turbo/turbo-build.log +9 -9
  91. package/.turbo/turbo-check-types.log +1 -1
  92. package/.turbo/turbo-release$colon$exports.log +1 -1
  93. package/README.md +16 -2
  94. package/dist/index.cjs +364 -76
  95. package/dist/index.d.cts +365 -114
  96. package/dist/index.d.ts +365 -114
  97. package/dist/index.js +355 -73
  98. package/index.ts +17 -11
  99. package/package.json +11 -3
  100. package/transformers/copies/copy.ts +4 -4
  101. package/transformers/copies/copy_to.ts +11 -7
  102. package/transformers/copies/mobx_copy.ts +6 -6
  103. package/transformers/copies/specs/copy_to.tests.ts +8 -8
  104. package/transformers/copies/specs/mobx_copy.tests.ts +3 -3
  105. package/transformers/flatteners/{flatten_accessors_of.ts → flatten_accessors_of_type.ts} +10 -10
  106. package/transformers/flatteners/flatten_json_value_to_type_paths_of.ts +5 -5
  107. package/transformers/flatteners/{flatten_type_def_to.ts → flatten_type_to.ts} +1 -1
  108. package/transformers/flatteners/{flatten_type_defs_of.ts → flatten_types_of_type.ts} +3 -3
  109. package/transformers/flatteners/flatten_validation_errors_of_type.ts +93 -0
  110. package/transformers/flatteners/flatten_validators_of_validating_type.ts +32 -0
  111. package/transformers/flatteners/{flatten_value_type_to.ts → flatten_value_to.ts} +12 -7
  112. package/transformers/flatteners/{flatten_value_types_of.ts → flatten_values_of_type.ts} +6 -6
  113. package/transformers/flatteners/specs/{flatten_accessors_of.tests.ts → flatten_accessors_of_type.tests.ts} +10 -11
  114. package/transformers/flatteners/specs/flatten_json_value_to_type_paths_of.tests.ts +6 -6
  115. package/transformers/flatteners/specs/{flatten_type_def_to.tests.ts → flatten_type_to.tests.ts} +15 -13
  116. package/transformers/flatteners/specs/flatten_types_of_type.tests.ts +27 -0
  117. package/transformers/flatteners/specs/flatten_validation_errors_of_type.tests.ts +48 -0
  118. package/transformers/flatteners/specs/{flatten_value_type_to.tests.ts → flatten_value_to.tests.ts} +124 -91
  119. package/transformers/flatteners/specs/{flatten_value_types_of.tests.ts → flatten_values_of_type.tests.ts} +4 -4
  120. package/transformers/flatteners/specs/value_path_to_type_path.tests.ts +20 -18
  121. package/transformers/flatteners/value_path_to_type_path.ts +4 -4
  122. package/types/builders.ts +239 -71
  123. package/types/definitions.ts +2 -2
  124. package/types/{flattened_accessors_of.ts → flattened_accessors_of_type.ts} +3 -3
  125. package/types/{flattened_type_defs_of.ts → flattened_types_of_type.ts} +22 -12
  126. package/types/flattened_types_of_validating_type.ts +152 -0
  127. package/types/flattened_validators_of_validating_type.ts +33 -0
  128. package/types/flattened_values_of_type.ts +11 -0
  129. package/types/{mobx_value_type_of.ts → mobx_value_of_type.ts} +2 -2
  130. package/types/{partial_type_def_of.ts → partial_type_of_type.ts} +3 -1
  131. package/types/{json_path_of.ts → path_of.ts} +1 -1
  132. package/types/{json_paths_of.ts → paths_of_type.ts} +5 -5
  133. package/types/readonly_type_of_type.ts +54 -0
  134. package/types/specs/builder.tests.ts +205 -54
  135. package/types/specs/{flattened_accessors_of.tests.ts → flattened_accessors_of_type.tests.ts} +3 -3
  136. package/types/specs/{flattened_type_defs_of.tests.ts → flattened_types_of_type.tests.ts} +82 -34
  137. package/types/specs/flattened_validators_of_validating_type.tests.ts +47 -0
  138. package/types/specs/flattened_values_of_type.tests.ts +39 -0
  139. package/types/specs/{partial_type_def_of.tests.ts → partial_type_of_type.tests.ts} +11 -11
  140. package/types/specs/{json_paths_of.tests.ts → paths_of_type.tests.ts} +47 -47
  141. package/types/specs/{readonly_type_def_of.tests.ts → readonly_type_of_type.tests.ts} +14 -14
  142. package/types/specs/type_of_type.tests.ts +60 -0
  143. package/types/specs/{value_type_of.tests.ts → value_of_type.tests.ts} +15 -15
  144. package/types/specs/{value_to_type_paths_of.tests.ts → value_to_type_paths_of_type.tests.ts} +26 -25
  145. package/types/specs/value_types_of_discriminated_union.tests.ts +6 -6
  146. package/types/strict_definitions.ts +3 -3
  147. package/types/type_of_type.ts +178 -0
  148. package/types/validating_definitions.ts +109 -0
  149. package/types/validating_type_def_with_error.ts +93 -0
  150. package/types/value_of_type.ts +84 -0
  151. package/types/{value_to_type_paths_of.ts → value_to_type_paths_of_type.ts} +30 -29
  152. package/types/value_types_of_discriminated_union.ts +4 -3
  153. package/validation/errors_of_validators.ts +10 -0
  154. package/validation/specs/errors_of_validators.tests.ts +20 -0
  155. package/validation/specs/validators_of_values.tests.ts +68 -0
  156. package/validation/validator.ts +103 -0
  157. package/validation/validators/defined_validator.ts +22 -0
  158. package/validation/validators/minimum_string_length_validator.ts +36 -0
  159. package/validation/validators_of_values.ts +17 -0
  160. package/.out/transformers/flatteners/flatten_accessors_of.d.ts +0 -5
  161. package/.out/transformers/flatteners/flatten_accessors_of.js +0 -11
  162. package/.out/transformers/flatteners/flatten_type_defs_of.js +0 -7
  163. package/.out/transformers/flatteners/flatten_value_types_of.d.ts +0 -3
  164. package/.out/transformers/flatteners/flatten_value_types_of.js +0 -7
  165. package/.out/transformers/flatteners/specs/flatten_type_defs_of.tests.js +0 -17
  166. package/.out/types/flattened_accessors_of.d.ts +0 -9
  167. package/.out/types/flattened_value_types_of.d.ts +0 -6
  168. package/.out/types/json_path_of.d.ts +0 -1
  169. package/.out/types/readonly_type_def_of.d.ts +0 -29
  170. package/.out/types/specs/flattened_value_types_of.tests.js +0 -11
  171. package/.out/types/value_type_of.d.ts +0 -24
  172. package/transformers/flatteners/specs/flatten_type_defs_of.tests.ts +0 -26
  173. package/types/flattened_value_types_of.ts +0 -11
  174. package/types/readonly_type_def_of.ts +0 -53
  175. package/types/specs/flattened_value_types_of.tests.ts +0 -21
  176. package/types/value_type_of.ts +0 -84
  177. /package/.out/transformers/flatteners/specs/{flatten_accessors_of.tests.d.ts → flatten_accessors_of_type.tests.d.ts} +0 -0
  178. /package/.out/transformers/flatteners/specs/{flatten_type_def_to.tests.d.ts → flatten_type_to.tests.d.ts} +0 -0
  179. /package/.out/transformers/flatteners/specs/{flatten_type_defs_of.tests.d.ts → flatten_types_of_type.tests.d.ts} +0 -0
  180. /package/.out/transformers/flatteners/specs/{flatten_value_type_to.tests.d.ts → flatten_validation_errors_of_type.tests.d.ts} +0 -0
  181. /package/.out/transformers/flatteners/specs/{flatten_value_types_of.tests.d.ts → flatten_value_to.tests.d.ts} +0 -0
  182. /package/.out/{types/flattened_accessors_of.js → transformers/flatteners/specs/flatten_values_of_type.tests.d.ts} +0 -0
  183. /package/.out/types/{flattened_type_defs_of.js → flattened_accessors_of_type.js} +0 -0
  184. /package/.out/types/{flattened_value_types_of.js → flattened_types_of_type.js} +0 -0
  185. /package/.out/types/{json_path_of.js → flattened_types_of_validating_type.js} +0 -0
  186. /package/.out/types/{json_paths_of.js → flattened_validators_of_validating_type.js} +0 -0
  187. /package/.out/types/{partial_type_def_of.js → flattened_values_of_type.js} +0 -0
  188. /package/.out/types/{mobx_value_type_of.js → mobx_value_of_type.js} +0 -0
  189. /package/.out/types/{readonly_type_def_of.js → partial_type_of_type.js} +0 -0
  190. /package/.out/types/{specs/flattened_accessors_of.tests.d.ts → path_of.js} +0 -0
  191. /package/.out/types/{specs/flattened_type_defs_of.tests.d.ts → paths_of_type.js} +0 -0
  192. /package/.out/types/{specs/flattened_value_types_of.tests.d.ts → readonly_type_of_type.js} +0 -0
  193. /package/.out/types/specs/{json_paths_of.tests.d.ts → flattened_accessors_of_type.tests.d.ts} +0 -0
  194. /package/.out/types/specs/{partial_type_def_of.tests.d.ts → flattened_types_of_type.tests.d.ts} +0 -0
  195. /package/.out/types/specs/{readonly_type_def_of.tests.d.ts → flattened_validators_of_validating_type.tests.d.ts} +0 -0
  196. /package/.out/types/specs/{value_to_type_paths_of.tests.d.ts → flattened_values_of_type.tests.d.ts} +0 -0
  197. /package/.out/types/specs/{value_type_of.tests.d.ts → partial_type_of_type.tests.d.ts} +0 -0
  198. /package/.out/types/{value_to_type_paths_of.js → specs/paths_of_type.tests.d.ts} +0 -0
  199. /package/.out/types/{value_type_of.js → specs/readonly_type_of_type.tests.d.ts} +0 -0
@@ -0,0 +1,70 @@
1
+ import { map, UnreachableError, } from '@strictly/base';
2
+ import { TypeDefType, } from 'types/definitions';
3
+ export function typeOfType({ definition }) {
4
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
5
+ return {
6
+ definition: typeDefOfTypeDef(definition),
7
+ };
8
+ }
9
+ function typeDefOfTypeDef(t) {
10
+ switch (t.type) {
11
+ case TypeDefType.Literal:
12
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
13
+ return typeDefOfLiteralTypeDef(t);
14
+ case TypeDefType.List:
15
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
16
+ return typeDefOfListTypeDef(t);
17
+ case TypeDefType.Record:
18
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
19
+ return typeDefOfRecordTypeDef(t);
20
+ case TypeDefType.Object:
21
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
22
+ return typeDefOfObjectTypeDef(t);
23
+ case TypeDefType.Union:
24
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
25
+ return typeDefOfUnionTypeDef(t);
26
+ default:
27
+ throw new UnreachableError(t);
28
+ }
29
+ }
30
+ function typeDefOfLiteralTypeDef({ type, valuePrototype, }) {
31
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
32
+ return {
33
+ type,
34
+ valuePrototype,
35
+ };
36
+ }
37
+ function typeDefOfListTypeDef({ type, elements, }) {
38
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
39
+ return {
40
+ type,
41
+ elements: typeDefOfTypeDef(elements),
42
+ };
43
+ }
44
+ function typeDefOfRecordTypeDef({ type, keyPrototype, valueTypeDef, }) {
45
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
46
+ return {
47
+ type,
48
+ keyPrototype,
49
+ valueTypeDef: typeDefOfTypeDef(valueTypeDef),
50
+ };
51
+ }
52
+ function typeDefOfObjectTypeDef({ type, fields, }) {
53
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
54
+ return {
55
+ type,
56
+ fields: map(fields, function (_k, v) {
57
+ return typeDefOfTypeDef(v);
58
+ }),
59
+ };
60
+ }
61
+ function typeDefOfUnionTypeDef({ type, discriminator, unions, }) {
62
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
63
+ return {
64
+ type,
65
+ discriminator,
66
+ unions: map(unions, function (_k, v) {
67
+ return typeDefOfTypeDef(v);
68
+ }),
69
+ };
70
+ }
@@ -0,0 +1,49 @@
1
+ import { type ObjectFieldKey, type RecordKeyType, type TypeDefType, type UnionKey } from './definitions';
2
+ export type ValidatingType<T extends ValidatingTypeDef = ValidatingTypeDef> = {
3
+ readonly definition: T;
4
+ };
5
+ export type Rule<E = any, V = any> = (v: V) => E | null;
6
+ export type ErrorOfValidatingTypeDef<T extends ValidatingTypeDef> = T extends ValidatingTypeDef<infer E> ? E : never;
7
+ export type ValidatingTypeDef<E = any> = ValidatingLiteralTypeDef<E> | ValidatingListTypeDef<E> | ValidatingRecordTypeDef<E> | ValidatingObjectTypeDef<E> | ValidatingUnionTypeDef<E>;
8
+ type AnyTypeDef = any;
9
+ export type ValidatingLiteralTypeDef<E = any, V = any> = {
10
+ readonly type: TypeDefType.Literal;
11
+ readonly valuePrototype: [V];
12
+ readonly rule: Rule<E>;
13
+ readonly required: boolean;
14
+ readonly readonly: boolean;
15
+ };
16
+ export type ValidatingListTypeDef<E = any, Ele extends ValidatingTypeDef = AnyTypeDef> = {
17
+ readonly type: TypeDefType.List;
18
+ readonly elements: Ele;
19
+ readonly rule: Rule<E>;
20
+ readonly required: boolean;
21
+ readonly readonly: boolean;
22
+ };
23
+ export type ValidatingRecordTypeDef<E = any, K extends RecordKeyType = RecordKeyType, V extends ValidatingTypeDef | undefined = AnyTypeDef> = {
24
+ readonly type: TypeDefType.Record;
25
+ readonly keyPrototype: K;
26
+ readonly valueTypeDef: V;
27
+ readonly rule: Rule<E>;
28
+ readonly required: boolean;
29
+ readonly readonly: boolean;
30
+ };
31
+ export type ValidatingObjectTypeDefFields = {
32
+ [Key: ObjectFieldKey]: AnyTypeDef;
33
+ };
34
+ export type ValidatingObjectTypeDef<E = any, Fields extends ValidatingObjectTypeDefFields = ValidatingObjectTypeDefFields> = {
35
+ readonly type: TypeDefType.Object;
36
+ readonly fields: Fields;
37
+ readonly rule: Rule<E>;
38
+ readonly required: boolean;
39
+ readonly readonly: boolean;
40
+ };
41
+ export type ValidatingUnionTypeDef<E = any, D extends string | null = string | null, U extends Readonly<Record<UnionKey, AnyTypeDef>> = Readonly<Record<UnionKey, AnyTypeDef>>> = {
42
+ readonly discriminator: D;
43
+ readonly type: TypeDefType.Union;
44
+ readonly unions: U;
45
+ readonly rule: Rule<E>;
46
+ readonly required: boolean;
47
+ readonly readonly: boolean;
48
+ };
49
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ import { type IsFieldReadonly } from '@strictly/base';
2
+ import { type TypeDefType } from 'types/definitions';
3
+ import { type Rule, type ValidatingListTypeDef, type ValidatingLiteralTypeDef, type ValidatingObjectTypeDef, type ValidatingRecordTypeDef, type ValidatingTypeDef, type ValidatingUnionTypeDef } from './validating_definitions';
4
+ export type ValidatingTypeDefWithError<T extends ValidatingTypeDef, E> = T extends ValidatingLiteralTypeDef ? ValidatingLiteralTypeDefWithError<T, E> : T extends ValidatingListTypeDef ? ValidatingListTypeDefWithError<T, E> : T extends ValidatingRecordTypeDef ? ValidatingRecordTypeDefWithError<T, E> : T extends ValidatingObjectTypeDef ? ValidatingObjectTypeDefWithError<T, E> : T extends ValidatingUnionTypeDef ? ValidatingUnionTypeDefWithError<T, E> : never;
5
+ type ValidatingLiteralTypeDefWithError<T extends ValidatingLiteralTypeDef, E2> = T extends ValidatingLiteralTypeDef<infer E1, infer V> ? {
6
+ readonly type: TypeDefType.Literal;
7
+ readonly valuePrototype: [V];
8
+ readonly rule: Rule<E1 | E2>;
9
+ readonly required: boolean;
10
+ readonly readonly: boolean;
11
+ } : never;
12
+ type ValidatingListTypeDefWithError<T extends ValidatingListTypeDef, E2> = T extends ValidatingListTypeDef<infer E1, infer E> ? IsFieldReadonly<T, 'elements'> extends true ? {
13
+ readonly type: TypeDefType.List;
14
+ readonly elements: E;
15
+ readonly rule: Rule<E1 | E2>;
16
+ readonly required: boolean;
17
+ readonly readonly: boolean;
18
+ } : {
19
+ readonly type: TypeDefType.List;
20
+ elements: E;
21
+ readonly rule: Rule<E1 | E2>;
22
+ readonly required: boolean;
23
+ readonly readonly: boolean;
24
+ } : never;
25
+ type ValidatingRecordTypeDefWithError<T extends ValidatingRecordTypeDef, E2> = T extends ValidatingRecordTypeDef<infer E1, infer K, infer V> ? IsFieldReadonly<T, 'valueTypeDef'> extends true ? {
26
+ readonly type: TypeDefType.Record;
27
+ readonly keyPrototype: K;
28
+ readonly valueTypeDef: V;
29
+ readonly rule: Rule<E1 | E2>;
30
+ readonly required: boolean;
31
+ readonly readonly: boolean;
32
+ } : {
33
+ readonly type: TypeDefType.Record;
34
+ readonly keyPrototype: K;
35
+ valueTypeDef: V;
36
+ readonly rule: Rule<E1 | E2>;
37
+ readonly required: boolean;
38
+ readonly readonly: boolean;
39
+ } : never;
40
+ type ValidatingObjectTypeDefWithError<T extends ValidatingObjectTypeDef, E2> = T extends ValidatingObjectTypeDef<infer E1, infer Fields> ? {
41
+ readonly type: TypeDefType.Object;
42
+ readonly fields: Fields;
43
+ readonly rule: Rule<E1 | E2>;
44
+ readonly required: boolean;
45
+ readonly readonly: boolean;
46
+ } : never;
47
+ type ValidatingUnionTypeDefWithError<T extends ValidatingUnionTypeDef, E2> = T extends ValidatingUnionTypeDef<infer E1, infer D, infer U> ? {
48
+ readonly type: TypeDefType.Union;
49
+ readonly discriminator: D;
50
+ readonly unions: U;
51
+ readonly rule: Rule<E1 | E2>;
52
+ readonly required: boolean;
53
+ readonly readonly: boolean;
54
+ } : never;
55
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { type IsFieldReadonly } from '@strictly/base';
2
+ import { type ListTypeDef, type LiteralTypeDef, type ObjectTypeDef, type RecordTypeDef, type Type, type TypeDef, type UnionTypeDef } from './definitions';
3
+ export type ValueOfType<T, Extra = {}> = T extends Type ? ValueOfTypeDef<T['definition'], Extra> : never;
4
+ export type ValueOfTypeDef<F extends TypeDef, Extra = {}> = F extends LiteralTypeDef ? ValueOfLiteralTypeDef<F> : F extends ListTypeDef ? ValueOfListTypeDef<F, Extra> : F extends RecordTypeDef ? ValueOfRecordTypeDef<F, Extra> : F extends ObjectTypeDef ? ValueOfObjectTypeDef<F, Extra> : F extends UnionTypeDef ? ValueOfUnionTypeDef<F, Extra> : never;
5
+ type ValueOfLiteralTypeDef<F extends LiteralTypeDef> = F['valuePrototype'][number];
6
+ type ValueOfListTypeDef<F extends ListTypeDef, Extra> = IsFieldReadonly<F, 'elements'> extends true ? readonly ValueOfTypeDef<F['elements'], Extra>[] & Extra : ValueOfTypeDef<F['elements'], Extra>[] & Extra;
7
+ type ValueOfRecordTypeDef<F extends RecordTypeDef, Extra> = undefined extends F['valueTypeDef'] ? IsFieldReadonly<F, 'valueTypeDef'> extends true ? {
8
+ readonly [k in F['keyPrototype']]?: ValueOfTypeDef<F['valueTypeDef'], Extra>;
9
+ } : {
10
+ [k in F['keyPrototype']]?: ValueOfTypeDef<F['valueTypeDef'], Extra>;
11
+ } : IsFieldReadonly<F, 'valueTypeDef'> extends true ? {
12
+ readonly [k in F['keyPrototype']]: ValueOfTypeDef<F['valueTypeDef'], Extra>;
13
+ } : {
14
+ [k in F['keyPrototype']]: ValueOfTypeDef<F['valueTypeDef'], Extra>;
15
+ };
16
+ type ValueOfObjectTypeDef<F extends ObjectTypeDef, Extra> = F extends ObjectTypeDef<infer Fields> ? {
17
+ [K in keyof Fields]: ValueOfTypeDef<Fields[K], Extra>;
18
+ } & Extra : never;
19
+ type ValueOfUnionTypeDef<F extends UnionTypeDef, Extra> = F extends UnionTypeDef<infer D, infer U> ? D extends string ? {
20
+ [K in keyof U]: ValueOfTypeDef<U[K], Extra> & Readonly<Record<D, K>>;
21
+ }[keyof U] : {
22
+ [K in keyof U]: ValueOfTypeDef<U[K], Extra>;
23
+ }[keyof U] : never;
24
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,22 +1,22 @@
1
1
  import { type SimplifyDeep, type UnionToIntersection } from 'type-fest';
2
2
  import { type ListTypeDef, type LiteralTypeDef, type ObjectTypeDef, type RecordTypeDef, type TypeDef, type UnionTypeDef } from './definitions';
3
3
  import { type Depths, type StartingDepth } from './flattened';
4
- import { type JsonPathOf } from './json_path_of';
4
+ import { type PathOf } from './path_of';
5
5
  import { type StrictType } from './strict_definitions';
6
- export type ValueToTypePathsOf<T extends StrictType, SegmentOverride extends string = '*', Path extends string = '$'> = SimplifyDeep<InternalFlattenedJsonPathsOf<T['definition'], SegmentOverride, Path, Path, StartingDepth>>;
7
- type InternalFlattenedJsonPathsOf<T extends TypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Depth extends number> = {
6
+ export type ValueToTypePathsOfType<T extends StrictType, SegmentOverride extends string = '*', Path extends string = '$'> = SimplifyDeep<InternalFlattenedTypePathsOf<T['definition'], SegmentOverride, Path, Path, StartingDepth>>;
7
+ type InternalFlattenedTypePathsOf<T extends TypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Depth extends number> = {
8
8
  readonly [K in ValuePath]: TypePath;
9
- } & InternalFlattenedJsonPathsOfChildren<T, SegmentOverride, ValuePath, TypePath, '', Depth>;
10
- type InternalFlattenedJsonPathsOfChildren<T extends TypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Qualifier extends string, Depth extends number, NextDepth extends number = Depths[Depth]> = NextDepth extends -1 ? never : T extends LiteralTypeDef ? InternalFlattenedJsonPathsOfLiteralChildren : T extends ListTypeDef ? InternalFlattenedJsonPathsOfListChildren<T, SegmentOverride, ValuePath, TypePath, NextDepth> : T extends RecordTypeDef ? InternalFlattenedJsonPathsOfRecordChildren<T, SegmentOverride, ValuePath, TypePath, NextDepth> : T extends ObjectTypeDef ? InternalFlattenedJsonPathsOfObjectChildren<T, SegmentOverride, ValuePath, TypePath, Qualifier, NextDepth> : T extends UnionTypeDef ? InternalFlattenedJsonPathsOfUnionChildren<T, SegmentOverride, ValuePath, TypePath, Qualifier, NextDepth> : never;
11
- type InternalFlattenedJsonPathsOfLiteralChildren = {};
12
- type InternalFlattenedJsonPathsOfListChildren<T extends ListTypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Depth extends number> = InternalFlattenedJsonPathsOf<T['elements'], SegmentOverride, JsonPathOf<ValuePath, number>, JsonPathOf<TypePath, number, SegmentOverride>, Depth>;
13
- type InternalFlattenedJsonPathsOfRecordChildren<T extends RecordTypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Depth extends number> = InternalFlattenedJsonPathsOf<T['valueTypeDef'], SegmentOverride, JsonPathOf<ValuePath, T['keyPrototype']>, JsonPathOf<TypePath, T['keyPrototype'], SegmentOverride>, Depth>;
14
- type InternalFlattenedJsonPathsOfObjectChildren<T extends ObjectTypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Qualifier extends string, Depth extends number> = T extends ObjectTypeDef<infer Fields> ? keyof Fields extends string ? UnionToIntersection<{
15
- readonly [K in keyof Fields]-?: InternalFlattenedJsonPathsOf<Exclude<Fields[K], undefined>, SegmentOverride, JsonPathOf<ValuePath, `${Qualifier}${K}`>, JsonPathOf<TypePath, `${Qualifier}${K}`>, Depth>;
9
+ } & InternalFlattenedTypePathsOfChildren<T, SegmentOverride, ValuePath, TypePath, '', Depth>;
10
+ type InternalFlattenedTypePathsOfChildren<T extends TypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Qualifier extends string, Depth extends number, NextDepth extends number = Depths[Depth]> = NextDepth extends -1 ? never : T extends LiteralTypeDef ? InternalFlattenedTypePathsOfLiteralChildren : T extends ListTypeDef ? InternalFlattenedTypePathsOfListChildren<T, SegmentOverride, ValuePath, TypePath, NextDepth> : T extends RecordTypeDef ? InternalFlattenedTypePathsOfRecordChildren<T, SegmentOverride, ValuePath, TypePath, NextDepth> : T extends ObjectTypeDef ? InternalFlattenedTypePathsOfObjectChildren<T, SegmentOverride, ValuePath, TypePath, Qualifier, NextDepth> : T extends UnionTypeDef ? InternalFlattenedTypePathsOfUnionChildren<T, SegmentOverride, ValuePath, TypePath, Qualifier, NextDepth> : never;
11
+ type InternalFlattenedTypePathsOfLiteralChildren = {};
12
+ type InternalFlattenedTypePathsOfListChildren<T extends ListTypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Depth extends number> = InternalFlattenedTypePathsOf<T['elements'], SegmentOverride, PathOf<ValuePath, number>, PathOf<TypePath, number, SegmentOverride>, Depth>;
13
+ type InternalFlattenedTypePathsOfRecordChildren<T extends RecordTypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Depth extends number> = InternalFlattenedTypePathsOf<T['valueTypeDef'], SegmentOverride, PathOf<ValuePath, T['keyPrototype']>, PathOf<TypePath, T['keyPrototype'], SegmentOverride>, Depth>;
14
+ type InternalFlattenedTypePathsOfObjectChildren<T extends ObjectTypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Qualifier extends string, Depth extends number> = T extends ObjectTypeDef<infer Fields> ? keyof Fields extends string ? UnionToIntersection<{
15
+ readonly [K in keyof Fields]-?: InternalFlattenedTypePathsOf<Exclude<Fields[K], undefined>, SegmentOverride, PathOf<ValuePath, `${Qualifier}${K}`>, PathOf<TypePath, `${Qualifier}${K}`>, Depth>;
16
16
  }[keyof Fields]> : never : never;
17
- type InternalFlattenedJsonPathsOfUnionChildren<T extends UnionTypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Qualifier extends string, Depth extends number> = T extends UnionTypeDef<infer D, infer Unions> ? keyof Unions extends string ? D extends null ? UnionToIntersection<{
18
- readonly [K in keyof Unions]: InternalFlattenedJsonPathsOfChildren<Unions[K], SegmentOverride, ValuePath, TypePath, '', Depth>;
17
+ type InternalFlattenedTypePathsOfUnionChildren<T extends UnionTypeDef, SegmentOverride extends string, ValuePath extends string, TypePath extends string, Qualifier extends string, Depth extends number> = T extends UnionTypeDef<infer D, infer Unions> ? keyof Unions extends string ? D extends null ? UnionToIntersection<{
18
+ readonly [K in keyof Unions]: InternalFlattenedTypePathsOfChildren<Unions[K], SegmentOverride, ValuePath, TypePath, '', Depth>;
19
19
  }[keyof Unions]> : UnionToIntersection<{
20
- readonly [K in keyof Unions]: InternalFlattenedJsonPathsOfChildren<Unions[K], SegmentOverride, ValuePath, TypePath, `${Qualifier}${K}:`, Depth>;
20
+ readonly [K in keyof Unions]: InternalFlattenedTypePathsOfChildren<Unions[K], SegmentOverride, ValuePath, TypePath, `${Qualifier}${K}:`, Depth>;
21
21
  }[keyof Unions]> : never : never;
22
22
  export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,10 @@
1
1
  import { type UnionTypeDef } from './definitions';
2
- import { type ValueTypeOf } from './value_type_of';
2
+ import { type ReadonlyTypeOfType } from './readonly_type_of_type';
3
+ import { type ValueOfType } from './value_of_type';
3
4
  export type ValueTypesOfDiscriminatedUnion<U extends UnionTypeDef> = U extends UnionTypeDef<infer D, infer Unions> ? D extends string ? {
4
- [K in keyof Unions]: ValueTypeOf<{
5
+ [K in keyof Unions]: ValueOfType<ReadonlyTypeOfType<{
5
6
  definition: Unions[K];
6
- }> & {
7
- [KD in D]: K;
7
+ }>> & {
8
+ readonly [KD in D]: K;
8
9
  };
9
10
  } : never : never;
@@ -0,0 +1,4 @@
1
+ import { type ErrorOfValidator, type Validator } from 'validation/validator';
2
+ export type ErrorsOfValidators<Validators extends Record<string, Validator>> = {
3
+ readonly [K in keyof Validators]: ErrorOfValidator<Validators[K]>;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ describe('ErrorsOfValidators', function () {
2
+ describe('simple', function () {
3
+ let t;
4
+ it('equals expected type', function () {
5
+ expectTypeOf().toEqualTypeOf(t);
6
+ });
7
+ });
8
+ });
9
+ export {};
@@ -0,0 +1,21 @@
1
+ describe('FlattenedValidatorsOfType', function () {
2
+ describe('literal', function () {
3
+ let t;
4
+ it('has the expected type', function () {
5
+ expectTypeOf().toEqualTypeOf(t);
6
+ });
7
+ });
8
+ describe('list', function () {
9
+ let t;
10
+ it('has the expected type', function () {
11
+ expectTypeOf().toEqualTypeOf(t);
12
+ });
13
+ });
14
+ describe('with defaults', function () {
15
+ let t;
16
+ it('has the expected type', function () {
17
+ expectTypeOf().toEqualTypeOf(t);
18
+ });
19
+ });
20
+ });
21
+ export {};
@@ -0,0 +1,21 @@
1
+ import { type Simplify } from 'type-fest';
2
+ export type FunctionalValidator<V = any, E = any, ValuePath extends string = any, Context = any> = (v: V, valuePath: ValuePath, context: Context) => E | null;
3
+ export type AnnotatedValidator<V = any, E = any, ValuePath extends string = any, Context = any> = {
4
+ readonly validate: (v: V, valuePath: ValuePath, context: Context) => E | null;
5
+ readonly annotations: (valuePath: ValuePath, context: Context) => {
6
+ readonly required: boolean;
7
+ readonly readonly: boolean;
8
+ };
9
+ };
10
+ export type Validator<V = any, E = any, ValuePath extends string = any, Context = any> = FunctionalValidator<V, E, ValuePath, Context> | AnnotatedValidator<V, E, ValuePath, Context>;
11
+ export type ErrorOfValidator<V extends Validator> = V extends Validator<infer _V, infer E> ? E : never;
12
+ export type ValidationError<Type extends string, Data = {}> = Simplify<{
13
+ type: Type;
14
+ } & Data>;
15
+ export declare function isFunctionalValidator(v: Validator): v is FunctionalValidator;
16
+ export declare function isAnnotatedValidator(v: Validator): v is AnnotatedValidator;
17
+ export declare function validate<V = any, E = any, ValuePath extends string = any, Context = any>(validator: Validator<V, E, ValuePath, Context>, v: V, valuePath: ValuePath, context: Context): E | null;
18
+ export declare function annotations<V = any, E = any, ValuePath extends string = any, Context = any>(validator: Validator<V, E, ValuePath, Context>, valuePath: ValuePath, context: Context): {
19
+ readonly required: boolean;
20
+ readonly readonly: boolean;
21
+ };
@@ -0,0 +1,26 @@
1
+ export function isFunctionalValidator(v) {
2
+ return typeof v === 'function';
3
+ }
4
+ export function isAnnotatedValidator(v) {
5
+ return typeof v !== 'function';
6
+ }
7
+ export function validate(validator, v, valuePath, context) {
8
+ if (isAnnotatedValidator(validator)) {
9
+ return validator.validate(v, valuePath, context);
10
+ }
11
+ else {
12
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
13
+ return validator(v, valuePath, context);
14
+ }
15
+ }
16
+ export function annotations(validator, valuePath, context) {
17
+ if (isAnnotatedValidator(validator)) {
18
+ return validator.annotations(valuePath, context);
19
+ }
20
+ else {
21
+ return {
22
+ required: false,
23
+ readonly: false,
24
+ };
25
+ }
26
+ }
@@ -0,0 +1,10 @@
1
+ import { type AnnotatedValidator } from 'validation/validator';
2
+ export declare class DefinedValidator<V, E, ValuePath extends string, Context> implements AnnotatedValidator<V | null | undefined, E, ValuePath, Context> {
3
+ private readonly error;
4
+ constructor(error: E);
5
+ validate(v: V | null | undefined): E | null;
6
+ annotations(): {
7
+ required: boolean;
8
+ readonly: boolean;
9
+ };
10
+ }
@@ -0,0 +1,18 @@
1
+ export class DefinedValidator {
2
+ error;
3
+ constructor(error) {
4
+ this.error = error;
5
+ }
6
+ validate(v) {
7
+ if (v == null) {
8
+ return this.error;
9
+ }
10
+ return null;
11
+ }
12
+ annotations() {
13
+ return {
14
+ required: true,
15
+ readonly: false,
16
+ };
17
+ }
18
+ }
@@ -0,0 +1,16 @@
1
+ import { type AnnotatedValidator } from 'validation/validator';
2
+ export declare const MinimumStringLengthValidationErrorType = "minimum_string_length";
3
+ export type MinimumStringLengthValidationError = {
4
+ type: typeof MinimumStringLengthValidationErrorType;
5
+ receivedLength: number;
6
+ minimumLength: number;
7
+ };
8
+ export declare class MinimumStringLengthValidator<ValuePath extends string, Context> implements AnnotatedValidator<string, MinimumStringLengthValidationError, ValuePath, Context> {
9
+ private readonly minimumLength;
10
+ constructor(minimumLength: number);
11
+ validate(value: string): MinimumStringLengthValidationError | null;
12
+ annotations(): {
13
+ required: boolean;
14
+ readonly: boolean;
15
+ };
16
+ }
@@ -0,0 +1,23 @@
1
+ export const MinimumStringLengthValidationErrorType = 'minimum_string_length';
2
+ export class MinimumStringLengthValidator {
3
+ minimumLength;
4
+ constructor(minimumLength) {
5
+ this.minimumLength = minimumLength;
6
+ }
7
+ validate(value) {
8
+ if (value.length < this.minimumLength) {
9
+ return {
10
+ type: MinimumStringLengthValidationErrorType,
11
+ minimumLength: this.minimumLength,
12
+ receivedLength: value.length,
13
+ };
14
+ }
15
+ return null;
16
+ }
17
+ annotations() {
18
+ return {
19
+ required: true,
20
+ readonly: false,
21
+ };
22
+ }
23
+ }
@@ -0,0 +1,4 @@
1
+ import { type Validator } from 'validation/validator';
2
+ export type ValidatorsOfValues<FlattenedValues extends Readonly<Record<string, any>>, TypePathsToValuePaths extends Readonly<Record<keyof FlattenedValues, string>> = Readonly<Record<keyof FlattenedValues, any>>, Context = any> = {
3
+ readonly [K in keyof FlattenedValues]: Validator<FlattenedValues[K], any, TypePathsToValuePaths[K], Context>;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -3,16 +3,16 @@ $ tsup
3
3
  CLI Building entry: index.ts
4
4
  CLI Using tsconfig: tsconfig.build.json
5
5
  CLI tsup v8.3.5
6
- CLI Using tsup config: /home/runner/work/de/de/packages/define/tsup.config.ts
6
+ CLI Using tsup config: /home/runner/work/strictly/strictly/packages/define/tsup.config.ts
7
7
  CLI Target: esnext
8
8
  CJS Build start
9
9
  ESM Build start
10
- CJS dist/index.cjs 20.29 KB
11
- CJS ⚡️ Build success in 60ms
12
- ESM dist/index.js 18.58 KB
13
- ESM ⚡️ Build success in 59ms
10
+ CJS dist/index.cjs 26.97 KB
11
+ CJS ⚡️ Build success in 50ms
12
+ ESM dist/index.js 24.77 KB
13
+ ESM ⚡️ Build success in 52ms
14
14
  DTS Build start
15
- DTS ⚡️ Build success in 4995ms
16
- DTS dist/index.d.cts 22.22 KB
17
- DTS dist/index.d.ts 22.22 KB
18
- Done in 5.97s.
15
+ DTS ⚡️ Build success in 5601ms
16
+ DTS dist/index.d.cts 38.05 KB
17
+ DTS dist/index.d.ts 38.05 KB
18
+ Done in 6.43s.
@@ -1,3 +1,3 @@
1
1
  yarn run v1.22.22
2
2
  $ tsc
3
- Done in 4.06s.
3
+ Done in 5.18s.
@@ -1,3 +1,3 @@
1
1
  yarn run v1.22.22
2
2
  $ json -f package.json -f package.exports.json --merge > package.release.json
3
- Done in 0.08s.
3
+ Done in 0.11s.
package/README.md CHANGED
@@ -1,12 +1,26 @@
1
- # Define
2
-
3
1
  Type definitions for specifying and modifying types
4
2
 
3
+ # Define Your Types
4
+
5
+ One of the goals of @strictly/form is to provide a type-safe mapping between your display types and your domain types. In order to achieve this we need to be able to specify those types.
6
+
5
7
  ## Defining Types
6
8
 
7
9
  ## Type Builder
8
10
 
11
+ # Transforming Types
12
+
9
13
  ## Modifying Types
10
14
 
11
15
  ## Modifying Values
12
16
 
17
+ # FAQ
18
+
19
+ ## Why not use Zod (or equivalent)?
20
+
21
+ While [Zod](https://zod.dev/) is a great tool, with many, many features and great supporting libraries, it does not produce 100% introspectable type definitions. Our definitions need to be quite minimal, while Zod's are quite fully featured. The reasons for this are
22
+ 1. The Typescript compiler is actually fairly limited in how much it processing it will do on a [Mapped Type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html) before it throws the dreaded `Type instantiation is excessively deep and possibly infinite. ts(2589)` [error](https://github.com/microsoft/TypeScript/issues/30188#issuecomment-469285102). The types we use are tuned to circumvent this restriction as much as possible.
23
+ 2. @strictly transforms the type definitions in multiple ways. The more variation allowed in the base types, the more cases the transformers need to deal with (and the more processing we need to do on those mapped types). Essentially the amount of code you have to write is quadratic (the number of supported type definitions multiplied by the number of transformations). As the number of transformations is potentially unbounded, keeping the number of distinct type definitions to a minimum is key
24
+
25
+ It's a definite possibility that someone could write an adapter from Zod to our internal type definitions, but it's not practical to use Zod in place of the internal type definitions.
26
+