inferred-types 0.36.4 → 0.37.1

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 (280) hide show
  1. package/README.md +1 -1
  2. package/dist/{index.mjs → index.js} +0 -0
  3. package/package.json +15 -21
  4. package/.eslintrc +0 -77
  5. package/.github/workflows/main.yml +0 -34
  6. package/.github/workflows/other.yml +0 -15
  7. package/.nvmrc +0 -1
  8. package/.prettierrc.js +0 -3
  9. package/.vscode/launch.json +0 -27
  10. package/.vscode/settings.json +0 -19
  11. package/devops/build.js +0 -243
  12. package/docs/builder-overview.md +0 -45
  13. package/docs/builder.md +0 -94
  14. package/src/errors/ReadOnlyViolation.ts +0 -3
  15. package/src/errors/index.ts +0 -12
  16. package/src/index.ts +0 -14
  17. package/src/runtime/README.md +0 -3
  18. package/src/runtime/api/api.ts +0 -10
  19. package/src/runtime/api/index.ts +0 -12
  20. package/src/runtime/builders/Model.ts +0 -25
  21. package/src/runtime/builders/url.ts +0 -15
  22. package/src/runtime/combinators/and.ts +0 -15
  23. package/src/runtime/combinators/filter.ts +0 -267
  24. package/src/runtime/combinators/index.ts +0 -4
  25. package/src/runtime/combinators/not.ts +0 -15
  26. package/src/runtime/combinators/or.ts +0 -5
  27. package/src/runtime/createFnWithProps.ts +0 -37
  28. package/src/runtime/dictionary/arrayToKeyLookup.ts +0 -19
  29. package/src/runtime/dictionary/defineProperties.ts +0 -35
  30. package/src/runtime/dictionary/dictArr.ts +0 -69
  31. package/src/runtime/dictionary/dictionaryTransform.ts +0 -22
  32. package/src/runtime/dictionary/entries.ts +0 -33
  33. package/src/runtime/dictionary/index.ts +0 -21
  34. package/src/runtime/dictionary/kv/dictToKv.ts +0 -21
  35. package/src/runtime/dictionary/kv/filterDictArray.ts +0 -31
  36. package/src/runtime/dictionary/kv/index.ts +0 -15
  37. package/src/runtime/dictionary/kv/kv.ts +0 -18
  38. package/src/runtime/dictionary/kv/kvToDict.ts +0 -24
  39. package/src/runtime/dictionary/mapTo.ts +0 -206
  40. package/src/runtime/dictionary/mapValues.ts +0 -23
  41. package/src/runtime/dictionary/merge.ts +0 -36
  42. package/src/runtime/dictionary/strArrayToDict.ts +0 -12
  43. package/src/runtime/index.ts +0 -23
  44. package/src/runtime/keys.ts +0 -16
  45. package/src/runtime/lists/asArray.ts +0 -38
  46. package/src/runtime/lists/createConverter.ts +0 -62
  47. package/src/runtime/lists/groupBy.ts +0 -15
  48. package/src/runtime/lists/index.ts +0 -15
  49. package/src/runtime/literals/ExplicitFunction.ts +0 -10
  50. package/src/runtime/literals/Suggest.ts +0 -19
  51. package/src/runtime/literals/arrayToObject.ts +0 -78
  52. package/src/runtime/literals/box.ts +0 -98
  53. package/src/runtime/literals/defineType.ts +0 -20
  54. package/src/runtime/literals/ensureLeading.ts +0 -17
  55. package/src/runtime/literals/ensureTrailing.ts +0 -17
  56. package/src/runtime/literals/identity.ts +0 -12
  57. package/src/runtime/literals/index.ts +0 -23
  58. package/src/runtime/literals/literal.ts +0 -48
  59. package/src/runtime/literals/pathJoin.ts +0 -33
  60. package/src/runtime/literals/stripLeading.ts +0 -15
  61. package/src/runtime/literals/stripTrailing.ts +0 -15
  62. package/src/runtime/literals/wide.ts +0 -13
  63. package/src/runtime/ruleset.ts +0 -42
  64. package/src/runtime/runtime/README.md +0 -3
  65. package/src/runtime/runtime/condition.ts +0 -13
  66. package/src/runtime/runtime/index.ts +0 -16
  67. package/src/runtime/runtime/type.ts +0 -127
  68. package/src/runtime/runtime/withValue.ts +0 -39
  69. package/src/runtime/state/Configurator.ts +0 -76
  70. package/src/runtime/state/FluentConfigurator.ts +0 -49
  71. package/src/runtime/state/index.ts +0 -13
  72. package/src/runtime/type-checks/ifSameType.ts +0 -20
  73. package/src/runtime/type-checks/ifTypeOf.ts +0 -124
  74. package/src/runtime/type-checks/index.ts +0 -24
  75. package/src/runtime/type-checks/isArray.ts +0 -34
  76. package/src/runtime/type-checks/isBoolean.ts +0 -24
  77. package/src/runtime/type-checks/isFalse.ts +0 -29
  78. package/src/runtime/type-checks/isFunction.ts +0 -26
  79. package/src/runtime/type-checks/isNull.ts +0 -26
  80. package/src/runtime/type-checks/isNumber.ts +0 -20
  81. package/src/runtime/type-checks/isObject.ts +0 -22
  82. package/src/runtime/type-checks/isString.ts +0 -34
  83. package/src/runtime/type-checks/isSymbol.ts +0 -3
  84. package/src/runtime/type-checks/isTrue.ts +0 -31
  85. package/src/runtime/type-checks/isUndefined.ts +0 -33
  86. package/src/runtime/type-checks/startsWith.ts +0 -107
  87. package/src/runtime/valueTypes.ts +0 -48
  88. package/src/types/Api.ts +0 -16
  89. package/src/types/Constructor.ts +0 -5
  90. package/src/types/EnumValues.ts +0 -14
  91. package/src/types/ExpandRecursively.ts +0 -12
  92. package/src/types/FunctionType.ts +0 -19
  93. package/src/types/If.ts +0 -10
  94. package/src/types/Include.ts +0 -18
  95. package/src/types/KeyedRecord.ts +0 -21
  96. package/src/types/Keys.ts +0 -26
  97. package/src/types/Length.ts +0 -8
  98. package/src/types/Mutable.ts +0 -8
  99. package/src/types/Narrowable.ts +0 -5
  100. package/src/types/Not.ts +0 -13
  101. package/src/types/Numeric.ts +0 -20
  102. package/src/types/Opaque.ts +0 -11
  103. package/src/types/README.md +0 -3
  104. package/src/types/Retain.ts +0 -16
  105. package/src/types/SimplifyObject.ts +0 -12
  106. package/src/types/Transformer.ts +0 -15
  107. package/src/types/TypeGuard.ts +0 -7
  108. package/src/types/Where.ts +0 -40
  109. package/src/types/alphabetic/AllCaps.ts +0 -15
  110. package/src/types/alphabetic/CamelCase.ts +0 -3
  111. package/src/types/alphabetic/CapFirstAlpha.ts +0 -23
  112. package/src/types/alphabetic/CapitalizeWords.ts +0 -9
  113. package/src/types/alphabetic/Cardinality.ts +0 -80
  114. package/src/types/alphabetic/DashToSnake.ts +0 -3
  115. package/src/types/alphabetic/DashUppercase.ts +0 -19
  116. package/src/types/alphabetic/Dasherize.ts +0 -23
  117. package/src/types/alphabetic/EnsureLeading.ts +0 -24
  118. package/src/types/alphabetic/EnsureTrailing.ts +0 -24
  119. package/src/types/alphabetic/HasUppercase.ts +0 -16
  120. package/src/types/alphabetic/IsCapitalized.ts +0 -18
  121. package/src/types/alphabetic/KebabCase.ts +0 -13
  122. package/src/types/alphabetic/LowerAllCaps.ts +0 -5
  123. package/src/types/alphabetic/PascalCase.ts +0 -29
  124. package/src/types/alphabetic/PathJoin.ts +0 -54
  125. package/src/types/alphabetic/Pluralize.ts +0 -112
  126. package/src/types/alphabetic/SnakeCase.ts +0 -27
  127. package/src/types/alphabetic/StripLeading.ts +0 -23
  128. package/src/types/alphabetic/StripTrailing.ts +0 -23
  129. package/src/types/alphabetic/Url.ts +0 -29
  130. package/src/types/alphabetic/alpha-characters.ts +0 -81
  131. package/src/types/alphabetic/index.ts +0 -32
  132. package/src/types/append-types.ts +0 -10
  133. package/src/types/boolean-logic/EndsWith.ts +0 -40
  134. package/src/types/boolean-logic/Extends.ts +0 -22
  135. package/src/types/boolean-logic/HasParameters.ts +0 -21
  136. package/src/types/boolean-logic/Includes.ts +0 -33
  137. package/src/types/boolean-logic/IsLiteral.ts +0 -101
  138. package/src/types/boolean-logic/IsScalar.ts +0 -20
  139. package/src/types/boolean-logic/IsUndefined.ts +0 -20
  140. package/src/types/boolean-logic/Or.ts +0 -12
  141. package/src/types/boolean-logic/StartsWith.ts +0 -42
  142. package/src/types/boolean-logic/TypeDefault.ts +0 -58
  143. package/src/types/boolean-logic/array.ts +0 -57
  144. package/src/types/boolean-logic/boolean.ts +0 -84
  145. package/src/types/boolean-logic/equivalency.ts +0 -15
  146. package/src/types/boolean-logic/index.ts +0 -14
  147. package/src/types/boolean-logic/object.ts +0 -30
  148. package/src/types/boolean-logic/string.ts +0 -21
  149. package/src/types/dictionary/DictChangeValue.ts +0 -34
  150. package/src/types/dictionary/DictPartialApplication.ts +0 -30
  151. package/src/types/dictionary/DictPrependWithFn.ts +0 -23
  152. package/src/types/dictionary/DictReturnValues.ts +0 -27
  153. package/src/types/dictionary/Get.ts +0 -14
  154. package/src/types/dictionary/MapTo.ts +0 -428
  155. package/src/types/dictionary/MutableProps.ts +0 -19
  156. package/src/types/dictionary/RequireProps.ts +0 -15
  157. package/src/types/dictionary/SameKeys.ts +0 -11
  158. package/src/types/dictionary/index.ts +0 -21
  159. package/src/types/dictionary/props.ts +0 -145
  160. package/src/types/fluent/fluent.ts +0 -61
  161. package/src/types/fluent/index.ts +0 -12
  162. package/src/types/functions/FinalReturn.ts +0 -12
  163. package/src/types/functions/LogicFunction.ts +0 -4
  164. package/src/types/functions/index.ts +0 -13
  165. package/src/types/index.ts +0 -49
  166. package/src/types/kv/DictFromKv.ts +0 -3
  167. package/src/types/kv/KeyValue.ts +0 -12
  168. package/src/types/kv/KvFrom.ts +0 -8
  169. package/src/types/kv/KvTuple.ts +0 -14
  170. package/src/types/kv/index.ts +0 -15
  171. package/src/types/lists/AfterFirst.ts +0 -10
  172. package/src/types/lists/ConvertAndMap.ts +0 -151
  173. package/src/types/lists/FilterTuple.ts +0 -20
  174. package/src/types/lists/First.ts +0 -8
  175. package/src/types/lists/FirstString.ts +0 -4
  176. package/src/types/lists/Split.ts +0 -21
  177. package/src/types/lists/UniqueForProp.ts +0 -18
  178. package/src/types/lists/index.ts +0 -18
  179. package/src/types/literal-unions/OptRequired.ts +0 -4
  180. package/src/types/literal-unions/index.ts +0 -1
  181. package/src/types/maybe.ts +0 -9
  182. package/src/types/ruleset-types.ts +0 -76
  183. package/src/types/runtime.ts +0 -39
  184. package/src/types/string-literals/Break.ts +0 -22
  185. package/src/types/string-literals/Concat.ts +0 -9
  186. package/src/types/string-literals/LeftWhitespace.ts +0 -13
  187. package/src/types/string-literals/Replace.ts +0 -17
  188. package/src/types/string-literals/RightWhitespace.ts +0 -13
  189. package/src/types/string-literals/StringLength.ts +0 -34
  190. package/src/types/string-literals/Trim.ts +0 -15
  191. package/src/types/string-literals/TrimLeft.ts +0 -14
  192. package/src/types/string-literals/TrimRight.ts +0 -14
  193. package/src/types/string-literals/form-fields.ts +0 -15
  194. package/src/types/string-literals/index.ts +0 -21
  195. package/src/types/tuples/DictArray.ts +0 -21
  196. package/src/types/tuples/FirstKey.ts +0 -10
  197. package/src/types/tuples/FirstKeyValue.ts +0 -9
  198. package/src/types/tuples/FirstOfEach.ts +0 -13
  199. package/src/types/tuples/FromDictArray.ts +0 -14
  200. package/src/types/tuples/SecondOfEach.ts +0 -13
  201. package/src/types/tuples/index.ts +0 -17
  202. package/src/types/type-conversion/TupleToUnion.ts +0 -9
  203. package/src/types/type-conversion/UnionToIntersection.ts +0 -9
  204. package/src/types/type-conversion/UnionToTuple.ts +0 -20
  205. package/src/types/type-conversion/Widen.ts +0 -22
  206. package/src/types/type-conversion/index.ts +0 -16
  207. package/src/types/type-testing.ts +0 -14
  208. package/tests/CamelCase-spec.ts +0 -20
  209. package/tests/Configurator-spec.hold +0 -106
  210. package/tests/ExplicitFunction-spec.ts +0 -50
  211. package/tests/IncludeAndRetain-spec.ts +0 -67
  212. package/tests/Includes-spec.ts +0 -36
  213. package/tests/KebabCase-spec.ts +0 -21
  214. package/tests/PascalCase-spec.ts +0 -22
  215. package/tests/Pluralize-spec.ts +0 -23
  216. package/tests/SnakeCase-spec.ts +0 -21
  217. package/tests/Where.spec.ts +0 -38
  218. package/tests/arrayToKeyLookup-spec.ts +0 -17
  219. package/tests/arrayToObject-spec.ts +0 -115
  220. package/tests/boolean-logic/Contains.test.ts +0 -55
  221. package/tests/boolean-logic/HasParameters.ts +0 -29
  222. package/tests/boolean-logic/IsLiteral.spec.ts +0 -65
  223. package/tests/boolean-logic/boolean.spec.ts +0 -21
  224. package/tests/boolean-logic/filter.spec.ts +0 -52
  225. package/tests/constructor.spec.ts +0 -42
  226. package/tests/createFnWithProps.spec.ts +0 -14
  227. package/tests/data/SimpleTable.hold +0 -21
  228. package/tests/data/index.ts +0 -12
  229. package/tests/data/playlist.hold +0 -25
  230. package/tests/data/song.hold +0 -23
  231. package/tests/defineType-spec.ts +0 -57
  232. package/tests/dictionary/DictChangeValue.test.ts +0 -30
  233. package/tests/dictionary/DictPartialApplication.test.ts +0 -43
  234. package/tests/dictionary/DictReturnValues.test.ts +0 -36
  235. package/tests/dictionary/Get.spec.ts +0 -28
  236. package/tests/dictionary/IntersectingKeys.test.ts +0 -42
  237. package/tests/dictionary/MutableProps.test.ts +0 -30
  238. package/tests/dictionary/OptionalKeys.test.ts +0 -24
  239. package/tests/dictionary/PrependValuesWithFunction.test.ts +0 -34
  240. package/tests/dictionary/RequireProps.test.ts +0 -21
  241. package/tests/dictionary/RequiredKeys.test.ts +0 -53
  242. package/tests/dictionary/TypeDefault.test.ts +0 -76
  243. package/tests/dictionary/mapTo.test.ts +0 -388
  244. package/tests/dictionary/merge.test.ts +0 -41
  245. package/tests/dictionaryTransform-spec.ts +0 -280
  246. package/tests/ifTypeOf-spec.ts +0 -191
  247. package/tests/kv/KeyValue-spec.ts +0 -22
  248. package/tests/kv/SameKeys-spec.ts +0 -35
  249. package/tests/kv/dict-to-kv-and-back.spec.ts +0 -169
  250. package/tests/kv/entries-spec.ts +0 -65
  251. package/tests/kv/keys.spec.ts +0 -66
  252. package/tests/kv/kv-spec.ts +0 -20
  253. package/tests/lists/First.test.ts +0 -43
  254. package/tests/lists/Length.test.ts +0 -19
  255. package/tests/lists/Split.test.ts +0 -29
  256. package/tests/lists/UniqueForProp.spec.ts +0 -59
  257. package/tests/lists/asArray.test.ts +0 -109
  258. package/tests/lists/dictArr.test.ts +0 -110
  259. package/tests/literal-spec.ts +0 -82
  260. package/tests/literals/AllCaps.spec.ts +0 -33
  261. package/tests/literals/CamelCase.spec.ts +0 -109
  262. package/tests/literals/Dasherize.spec.ts +0 -107
  263. package/tests/literals/EnsureStripLeadingTrailing.test.ts +0 -79
  264. package/tests/literals/HasUppercase.spec.ts +0 -33
  265. package/tests/literals/PascalCase.spec.ts +0 -109
  266. package/tests/literals/PathJoin.test.ts +0 -111
  267. package/tests/literals/SnakeCase.spec.ts +0 -109
  268. package/tests/literals/box.test.ts +0 -85
  269. package/tests/literals/whitespace-capture.spec.ts +0 -60
  270. package/tests/mapValues-spec.ts +0 -50
  271. package/tests/props-spec.ts +0 -234
  272. package/tests/runtime/condition.spec.ts +0 -19
  273. package/tests/runtime/if-is.spec.ts +0 -390
  274. package/tests/runtime/map-and-convert.test.ts +0 -31
  275. package/tests/runtime/type.spec.ts +0 -190
  276. package/tests/strArrayToDict-spec.ts +0 -40
  277. package/tests/tuples/TupleToUnion.spec.ts +0 -20
  278. package/tests/withValue.spec.ts +0 -173
  279. package/tsconfig.json +0 -36
  280. package/vitest.config.ts +0 -17
@@ -1,428 +0,0 @@
1
- /* eslint-disable no-use-before-define */
2
- import { OptRequired } from "src/types/literal-unions";
3
- import {
4
- DefaultManyToOneMapping,
5
- DefaultOneToManyMapping,
6
- DefaultOneToOneMapping,
7
- } from "src/runtime/dictionary/mapTo";
8
- import { EnumValues } from "../EnumValues";
9
- import { TypeDefault } from "../boolean-logic/TypeDefault";
10
-
11
- /**
12
- * Expresses relationship between inputs/outputs:
13
- */
14
- export enum MapCardinality {
15
- /** every input results in 0:M outputs */
16
- OneToMany = "I -> O[]",
17
- /** every input results in 0:1 outputs */
18
- OneToOne = "I -> O",
19
- /** every input is an array of type I and reduced to a single O */
20
- ManyToOne = "I[] -> O",
21
- }
22
-
23
- export type MapCardinalityIllustrated = EnumValues<MapCardinality>;
24
-
25
- /**
26
- * The _user_ configuration of a **mapTo** mapper function
27
- * which will be finalized by merging it with the appropriate
28
- * default mapping type.
29
- */
30
- export interface MapConfig<
31
- IR extends OptRequired | undefined = undefined,
32
- D extends MapCardinalityIllustrated | undefined = undefined,
33
- OR extends OptRequired | undefined = undefined
34
- > {
35
- input?: IR;
36
- output?: OR;
37
- cardinality?: D;
38
- /**
39
- * Whether calls to the final `MapFn` will be logged to stderr
40
- * for debugging purposes. Defaults to false; if you specify
41
- * a _string_ for a value that will be sent to stderr along
42
- * with other debugging info.
43
- */
44
- debug?: boolean | string;
45
- }
46
-
47
- /**
48
- * A finalized configuration of a **mapTo** mapper functions cardinality
49
- * relationships between _inputs_ and _outputs_.
50
- *
51
- * Note: _this configuration does _not_ yet include the actual mapping
52
- * configuration between the input and output._
53
- */
54
- export type FinalizedMapConfig<
55
- IR extends OptRequired = MapIR<DefaultOneToManyMapping>,
56
- D extends MapCardinalityIllustrated = MapCard<DefaultOneToManyMapping>,
57
- OR extends OptRequired = MapOR<DefaultOneToManyMapping>
58
- > = Required<Omit<MapConfig<IR, D, OR>, "debug">> & { finalized: true; debug: boolean | string };
59
-
60
- /**
61
- * User configuration exposed by a config function which specifies the
62
- * cardinality already (e.g., `oneToMany()`, `manyToOne()`)
63
- */
64
- type MapCardinalityConfig<
65
- IR extends OptRequired | undefined,
66
- OR extends OptRequired | undefined
67
- > = {
68
- /** whether we the input can _optionally_ be an `undefined` value or not */
69
- input?: IR;
70
- /** whether we the output can _optionally_ be an `undefined` value or not */
71
- output?: OR;
72
- /**
73
- * Whether calls to the final `MapFn` will be logged to stderr
74
- * for debugging purposes. Defaults to false; if you set to a string
75
- * value than this will be echoed out with stderr.
76
- */
77
- debug?: boolean | string;
78
- };
79
-
80
- /**
81
- * **ConfiguredMap**
82
- *
83
- * A partial application of the mapTo() utility which has expressed the
84
- * configuration of the _inputs_ and _outputs_ and provides a `.map()`
85
- * method which allows the user configure the specifics of the mapping.
86
- */
87
- export type ConfiguredMap<
88
- C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
89
- > = {
90
- map: <I, O>(map: MapTo<I, O, C>) => Mapper<I, O, C>;
91
- input: MapIR<C>;
92
- cardinality: MapCard<C>;
93
- output: MapOR<C>;
94
- debug: boolean | string;
95
- };
96
-
97
- /**
98
- * Extracts the IR, Cardinality, and OR generics from a FinalizedMapConfig
99
- */
100
- export type DecomposeMapConfig<
101
- M extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
102
- > = M extends MapConfig<infer IR, infer D, infer OR>
103
- ? IR extends OptRequired | undefined
104
- ? D extends MapCardinalityIllustrated | undefined
105
- ? OR extends OptRequired | undefined
106
- ? [IR, D, OR]
107
- : never
108
- : never
109
- : never
110
- : M extends FinalizedMapConfig<infer IR, infer D, infer OR>
111
- ? IR extends OptRequired
112
- ? D extends MapCardinalityIllustrated
113
- ? OR extends OptRequired
114
- ? [IR, D, OR]
115
- : never
116
- : never
117
- : never
118
- : never;
119
-
120
- /** extracts IR from a `FinalizedMapConfig` */
121
- export type MapIR<
122
- T extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
123
- > = DecomposeMapConfig<T>[0];
124
-
125
- /**
126
- * extracts the MapCardinality from a `FinalizedMapConfig`
127
- */
128
- export type MapCard<
129
- T extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
130
- > = DecomposeMapConfig<T>[1];
131
-
132
- /** extracts OR from a `FinalizedMapConfig` */
133
- export type MapOR<
134
- T extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
135
- > = DecomposeMapConfig<T>[2];
136
-
137
- /**
138
- * Merges the types of a userland configuration with a default configuration
139
- */
140
- export type AsFinalizedConfig<
141
- U extends MapConfig<
142
- OptRequired | undefined,
143
- MapCardinalityIllustrated | undefined,
144
- OptRequired | undefined
145
- >,
146
- D extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
147
- > = TypeDefault<U, D> extends FinalizedMapConfig<infer IR, infer C, infer OR>
148
- ? FinalizedMapConfig<IR, C, OR>
149
- : never;
150
-
151
- export type MapperApi = {
152
- /**
153
- * Provides opportunity to configure _input_, _output_, and _cardinality_
154
- * prior to providing a mapping function.
155
- *
156
- * Note: _the defaults for configuration are defined by the_ `DEFAULT_ONE_TO_MANY_MAPPING`
157
- * _constant made available as a symbol from this library._
158
- */
159
- config: <
160
- C extends MapConfig<
161
- OptRequired, //
162
- MapCardinalityIllustrated,
163
- OptRequired
164
- >
165
- >(
166
- config: C
167
- ) => ConfiguredMap<
168
- AsFinalizedConfig<
169
- C, //
170
- DefaultOneToManyMapping
171
- >
172
- >;
173
-
174
- /**
175
- * Provides a nice 1:1 ratio between the input and output.
176
- *
177
- * By default the input and output are considered to be _required_
178
- * properties but this can be changed with the options hash provided.
179
- * ```ts
180
- * const mapper = mapTo.oneToOne().map(...);
181
- * // add in ability to filter out some inputs
182
- * const mapAndFilter = mapTo.oneToOne({ output: "opt" })
183
- * ```
184
- */
185
- oneToOne: <C extends MapCardinalityConfig<OptRequired, OptRequired>>(
186
- config?: C
187
- ) => ConfiguredMap<
188
- AsFinalizedConfig<
189
- C, //
190
- DefaultOneToOneMapping
191
- >
192
- >;
193
-
194
- /**
195
- * **manyToOne** _mapping_
196
- *
197
- * Provides a configuration where multiple inputs `I[]` will be mapped to a
198
- * single output `O`.
199
- *
200
- * Choosing this configuration will, by default, set both input and output
201
- * to be "required" but you can change this default if you so choose.
202
- */
203
- manyToOne: <
204
- C extends MapCardinalityConfig<
205
- OptRequired | undefined, //
206
- OptRequired | undefined
207
- >
208
- >(
209
- config?: C
210
- ) => ConfiguredMap<
211
- AsFinalizedConfig<
212
- C, //
213
- DefaultManyToOneMapping
214
- >
215
- >;
216
-
217
- oneToMany: <
218
- C extends MapCardinalityConfig<
219
- OptRequired | undefined, //
220
- OptRequired | undefined
221
- >
222
- >(
223
- config?: C
224
- ) => ConfiguredMap<
225
- AsFinalizedConfig<
226
- C, //
227
- DefaultOneToManyMapping
228
- >
229
- >;
230
- };
231
-
232
- export type MapInput<
233
- I, //
234
- IR extends OptRequired,
235
- C extends MapCardinalityIllustrated
236
- > = C extends MapCardinality.OneToMany | "I -> O[]"
237
- ? IR extends "opt"
238
- ? I | undefined
239
- : I
240
- : C extends MapCardinality.OneToOne | "I -> O"
241
- ? IR extends "opt"
242
- ? I | undefined
243
- : I
244
- : C extends MapCardinality.ManyToOne | "I[] -> O"
245
- ? IR extends "opt"
246
- ? I[] | undefined
247
- : I[]
248
- : never;
249
-
250
- export type MapOutput<
251
- O, //
252
- OR extends OptRequired,
253
- C extends MapCardinalityIllustrated
254
- > = C extends MapCardinality.OneToMany | "I -> O[]"
255
- ? OR extends "opt"
256
- ? O[]
257
- : [O, ...O[]]
258
- : C extends MapCardinality.OneToOne | "I -> O"
259
- ? OR extends "opt"
260
- ? O | null
261
- : O
262
- : C extends MapCardinality.ManyToOne | "I[] -> O"
263
- ? OR extends "opt"
264
- ? O | null
265
- : O
266
- : never;
267
-
268
- /**
269
- * **MapTo<I, O>**
270
- *
271
- * A mapping function between an input type `I` and output type `O`. Defaults to using
272
- * the _default_ OneToMany mapping config.
273
- *
274
- * **Note:** this type is designed to guide the userland mapping; refer
275
- * to `MapFn` if you want the type output by the `mapFn()` utility.
276
- */
277
- export type MapTo<
278
- I,
279
- O,
280
- C extends FinalizedMapConfig<
281
- OptRequired,
282
- MapCardinalityIllustrated,
283
- OptRequired
284
- > = DefaultOneToManyMapping
285
- > = MapIR<C> extends "opt"
286
- ? (source?: MapInput<I, MapIR<C>, MapCard<C>>) => MapOutput<O, MapOR<C>, MapCard<C>>
287
- : (source: MapInput<I, MapIR<C>, MapCard<C>>) => MapOutput<O, MapOR<C>, MapCard<C>>;
288
-
289
- export type MapFnOutput<
290
- I,
291
- O,
292
- S,
293
- OR extends OptRequired,
294
- C extends MapCardinalityIllustrated
295
- > = C extends "I -> O[]" | MapCardinality.OneToMany
296
- ? S extends I[]
297
- ? OR extends "opt"
298
- ? O[]
299
- : [O, ...O[]]
300
- : OR extends "opt"
301
- ? O[] | null
302
- : O[]
303
- : C extends MapCardinality.OneToOne | "I -> O"
304
- ? S extends I[]
305
- ? OR extends "opt"
306
- ? O[]
307
- : [O, ...O[]]
308
- : OR extends "opt"
309
- ? O | null
310
- : O
311
- : C extends MapCardinality.ManyToOne | "I[] -> O"
312
- ? S extends I[][]
313
- ? OR extends "opt"
314
- ? O[]
315
- : [O, ...O[]]
316
- : OR extends "opt"
317
- ? O | null
318
- : O
319
- : never;
320
-
321
- export type MapFnInput<I, IR extends OptRequired, D extends MapCardinalityIllustrated> = D extends
322
- | "I -> O[]"
323
- | MapCardinality.OneToMany
324
- ? IR extends "opt"
325
- ? I | I[] | undefined
326
- : I | I[]
327
- : D extends MapCardinality.OneToOne | "I -> O"
328
- ? IR extends "opt"
329
- ? I | I[] | undefined
330
- : I | I[]
331
- : D extends MapCardinality.ManyToOne | "I[] -> O"
332
- ? IR extends "opt"
333
- ? I[] | I[][] | undefined
334
- : I[] | I[][]
335
- : never;
336
-
337
- /**
338
- * The mapping function provided by the `mapFn()` utility. This _fn_
339
- * is intended to be used in two ways:
340
- *
341
- * 1. Iterative:
342
- * ```ts
343
- * const m = mapTo<I,O>(i => [ ... ]);
344
- * // maps inputs to outputs
345
- * const out = inputs.map(m);
346
- * ```
347
- * 2. Block:
348
- * ```ts
349
- * // maps inputs to outputs (filtering or splitting where appr.)
350
- * const out2 = m(inputs);
351
- * ```
352
- */
353
- export type MapFn<
354
- I,
355
- O,
356
- C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
357
- > = MapIR<C> extends "opt"
358
- ? <S extends MapFnInput<I, MapIR<C>, MapCard<C>>>(
359
- source?: S
360
- ) => MapFnOutput<I, O, S, MapOR<C>, MapCard<C>>
361
- : <S extends MapFnInput<I, MapIR<C>, MapCard<C>>>(
362
- source: S
363
- ) => MapFnOutput<I, O, S, MapOR<C>, MapCard<C>>;
364
-
365
- /**
366
- * **Mapper**
367
- *
368
- * A fully configured _mapper_ stemming from the **mapTo()** utility. It is both a mapping
369
- * function and a dictionary which describes the mapper's properties.
370
- * ```ts
371
- * const m = mapTo.oneToOne().map( ... );
372
- * const mapped = m(inputs);
373
- * const mappedOver = inputs.map(m);
374
- * ```
375
- *
376
- * Note: the root of a `Mapper` is the mapper function but
377
- * this is combined with a dictionary of settings and types
378
- * which you can use. For instance, look at the `fnSignature`
379
- * property to get the _type_ signature of the map function.
380
- */
381
- export type Mapper<
382
- I = unknown,
383
- O = unknown,
384
- C extends FinalizedMapConfig<
385
- OptRequired,
386
- MapCardinalityIllustrated,
387
- OptRequired
388
- > = FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
389
- > = {
390
- input: MapIR<C>;
391
- output: MapOR<C>;
392
- cardinality: MapCard<C>;
393
- debug: boolean | string;
394
- inputType: I;
395
- outputType: O;
396
- /**
397
- * Provides the _type_ information for mapper function.
398
- *
399
- * Note: _this is just a **type**_ not the actual function which positioned
400
- * at the root of the Mapper type
401
- */
402
- fnSignature: MapFn<I, O, C>;
403
- } & MapFn<I, O, C>;
404
-
405
- /**
406
- * **MapInputFrom**
407
- *
408
- * Type utility which extracts the `I` type from a fully configured `Mapper`
409
- */
410
- export type MapInputFrom<T extends Mapper> = T extends Mapper<infer I> ? I : never;
411
-
412
- /**
413
- * **MapOutputFrom**
414
- *
415
- * Type utility which extracts the output [`O`] type from a fully configured `Mapper`
416
- */
417
- export type MapOutputFrom<T extends Mapper> = T extends Mapper<any, infer O> ? O : never;
418
-
419
- /**
420
- * **MapCardinalityFrom**
421
- *
422
- * Type utility which extracts _cardinality_ of a `Mapper`'s inputs to outputs
423
- */
424
- export type MapCardinalityFrom<T extends Mapper> = T extends Mapper<any, any, infer C>
425
- ? C extends FinalizedMapConfig<OptRequired, infer Cardinality, OptRequired>
426
- ? Cardinality
427
- : never
428
- : never;
@@ -1,19 +0,0 @@
1
- import { ExpandRecursively } from "../ExpandRecursively";
2
- import { Keys } from "../Keys";
3
- import { Mutable } from "../Mutable";
4
-
5
- /**
6
- * Given a dictionary of type `<T>`, this utility function will
7
- * make the `<M>` generic property _mutable_ and all other _read-only_.
8
- *
9
- * ```ts
10
- * // { foo: string, bar?: Readonly<number> }
11
- * type Example = MutableProps<{
12
- * foo: Readonly<string>,
13
- * bar?: number
14
- * }, "foo">;
15
- * ```
16
- */
17
- export type MutableProps<T extends {}, M extends keyof T & string> = ExpandRecursively<
18
- Mutable<Pick<T, M>> & Readonly<Pick<T, Keys<T, M>>>
19
- >;
@@ -1,15 +0,0 @@
1
- import { ExpandRecursively } from "../ExpandRecursively";
2
-
3
- /**
4
- * Given a dictionary of type `<T>`, this utility function will
5
- * make the `<R>` generic property _required_ (use a union to make
6
- * more than one prop required).
7
- *
8
- * ```ts
9
- * // { foo: string, bar?: number }
10
- * type Example = RequireProps<{foo?: string, bar?: number}, "foo">;
11
- * ```
12
- */
13
- export type RequireProps<T extends {}, R extends keyof T> = ExpandRecursively<
14
- Required<Pick<T, R>> & T
15
- >;
@@ -1,11 +0,0 @@
1
- /**
2
- * **SameKeys**
3
- *
4
- * Creates a _type_ with the same _keys_ as `T` but sets all values of these keys to `A` (which is
5
- * **any** by default).
6
- *
7
- * Note: meant to be used as part of an _extends_ clause in most cases.
8
- */
9
- export type SameKeys<T extends object, A extends any = any> = {
10
- [P in keyof T]: A;
11
- };
@@ -1,21 +0,0 @@
1
- // #autoindex
2
- // #region auto-indexed files
3
- // index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
4
- // hash-code: 55881f7d
5
-
6
- // file exports
7
- export * from "./DictPartialApplication";
8
- export * from "./DictChangeValue";
9
- export * from "./DictPrependWithFn";
10
- export * from "./DictReturnValues";
11
- export * from "./Get";
12
- export * from "./MapTo";
13
- export * from "./MutableProps";
14
- export * from "./RequireProps";
15
- export * from "./SameKeys";
16
- export * from "./props";
17
-
18
- // #endregion auto-indexed files
19
-
20
- // see https://github.com/inocan-group/do-devops/docs/autoindex.md
21
- // for more info
@@ -1,145 +0,0 @@
1
- import { Alpha } from "../alphabetic/alpha-characters";
2
- import { Keys } from "../Keys";
3
-
4
- /**
5
- * Extracts the _required_ keys in the object's type. You also may
6
- * optionally filter by the _value_ of the key.
7
- */
8
- export type RequiredKeys<T extends object, V extends any = any> = {
9
- [K in keyof T]-?: {} extends { [P in K]: T[K] }
10
- ? never //
11
- : T[K] extends V
12
- ? K
13
- : never;
14
- }[keyof T];
15
-
16
- /**
17
- * Extracts the intersecting/common keys to two objects
18
- */
19
- export type IntersectingKeys<
20
- T extends Record<string, any> | readonly string[],
21
- U extends Record<string, any> | readonly string[]
22
- > = {
23
- [K in keyof T]: K extends Keys<U> ? K : never;
24
- }[keyof T];
25
-
26
- /**
27
- * Extracts the _optional_ keys in the object's type. You also may
28
- * optionally filter by the _value_ of the key.
29
- */
30
- export type OptionalKeys<T extends object, V extends any = any> = {
31
- [K in keyof T]-?: {} extends { [P in K]: T[K] }
32
- ? V extends T[K]
33
- ? K
34
- : never //
35
- : never;
36
- }[keyof T];
37
-
38
- /**
39
- * The _keys_ on a given object `T` which have a literal value of `W`.
40
- *
41
- * Optionally, you may provide a generic `E` to exclude certain keys in
42
- * result set.
43
- * ```ts
44
- * // "foo"
45
- * type Str = KeysWithValue<{ foo: "hi"; bar: 5 }>;
46
- * ```
47
- */
48
- export type KeysWithValue<W extends any, T extends object> = {
49
- [K in keyof T]: T[K] extends W ? Readonly<K> : never;
50
- }[keyof T];
51
-
52
- /**
53
- * A `PrivateKey` must start with a `_` character and then follow with
54
- * an alphabetic character
55
- */
56
- export type PrivateKey = `_${Alpha}${string}`;
57
-
58
- /**
59
- * Keys on an object which have a `_` character as first part of the
60
- * name are considered private and this utility will create a union
61
- * of all the keys in this category.
62
- */
63
- export type PrivateKeys<T extends object> = {
64
- [K in keyof T]: K extends `_${string}` ? K : never;
65
- }[keyof T];
66
-
67
- /**
68
- * **PublicKeys**
69
- *
70
- * Builds a union type of all keys which are "public" where a public
71
- * key is any key which _does not_ start with the `_` character.
72
- */
73
- export type PublicKeys<T extends object> = {
74
- [K in keyof T]: K extends `_${string}` ? never : K;
75
- }[keyof T];
76
-
77
- export type StringKeys<T extends object> = {
78
- [K in keyof T]: K extends string ? Readonly<K> : never;
79
- }[keyof T];
80
-
81
- /**
82
- * The keys of an object which _are not_ a string type
83
- */
84
- export type NonStringKeys<T extends object> = {
85
- [K in keyof T]: K extends string ? never : Readonly<K>;
86
- }[keyof T];
87
-
88
- export type NumericKeys<T extends object> = {
89
- [K in keyof T]: K extends number ? Readonly<K> : never;
90
- }[keyof T];
91
-
92
- export type NonNumericKeys<T extends object> = {
93
- [K in keyof T]: K extends number ? never : Readonly<K>;
94
- }[keyof T];
95
-
96
- /**
97
- * **RequiredProps**
98
- *
99
- * Reduces an object type to only key/value pairs where the key is required
100
- */
101
- export type RequiredProps<T extends object> = Pick<T, RequiredKeys<T>>;
102
-
103
- /**
104
- * **OptionalProps**
105
- *
106
- * Reduces an object to only key/value pairs where the key is optional
107
- */
108
- export type OptionalProps<T extends object> = Pick<T, OptionalKeys<T>>;
109
-
110
- /**
111
- * **WithValue**
112
- *
113
- * Reduces an object's type down to only those key/value pairs where the
114
- * value is of type `W`.
115
- * ```ts
116
- * const foo = { a: 1, b: "hi", c: () => "hello" }
117
- * // { c: () => "hello" }
118
- * type W = WithValue<Function, typeof foo>
119
- * ```
120
- */
121
- export type WithValue<
122
- W extends any,
123
- T extends object,
124
- E extends any = undefined
125
- > = undefined extends E
126
- ? // no exclusion provided
127
- Pick<T, KeysWithValue<W, T>>
128
- : // Exclude using E
129
- Omit<Pick<T, KeysWithValue<W, T>>, KeysWithValue<E, T>>;
130
-
131
- export type DictionaryWithoutValue<TDict extends object, TWithoutValue> = Omit<
132
- TDict,
133
- KeysWithValue<TWithoutValue, TDict>
134
- >;
135
-
136
- /**
137
- * Reduces an object to only the key/value pairs where the key is a
138
- * string.
139
- */
140
- export type WithStringKeys<T extends object> = Omit<T, NonStringKeys<T>>;
141
-
142
- /**
143
- * Reduces an object to only the key/value pairs where the key is numeric.
144
- */
145
- export type WithNumericKeys<T extends object> = Omit<T, NonNumericKeys<T>>;
@@ -1,61 +0,0 @@
1
- /* eslint-disable no-use-before-define */
2
-
3
- /**
4
- * **ToFluent**
5
- *
6
- * Converts the typing of a dictionary of functions into the same
7
- * function signatures but changes the return type to be the Fluent API.
8
- *
9
- * **Note:** this utility also allows a non-fluent API surface `X` to be included as
10
- * part of the API surface if this is desired.
11
- */
12
- export type ToFluent<
13
- T extends { [key: string]: (...args: any[]) => any },
14
- X extends object = {}
15
- > = {
16
- [K in keyof T]: (...args: Parameters<T[K]>) => ToFluent<T, X> & X;
17
- } & X;
18
-
19
- /**
20
- * A _pure_ Fluent API which promotes an API surface where _every_ API endpoint must be a function
21
- * which returns the same API surface.
22
- *
23
- * To provide value, this style of Fluent API will need to perform useful _side effects_ when functions
24
- * on the API surface are called as this structure does not provide any means to maintain an internal state
25
- * which can be returned later.
26
- *
27
- * **Note:** _if you prefer a Fluent API with means to _escape_ with an internally managed state then
28
- * you should prefer the use of the `FluentApi` type._
29
- */
30
- export type PureFluentApi<
31
- TApi extends Record<string, (...args: any[]) => PureFluentApi<TApi, any>>,
32
- TExclude extends string = ""
33
- > = { [P in keyof TApi]: (...args: Parameters<TApi[P]>) => PureFluentApi<Omit<TApi, TExclude>> };
34
-
35
- /**
36
- * Represents a **Fluent API** which exposes a API as a dictionary of functions. These functions will:
37
- *
38
- * 1. mutate an internal state or cause useful side-effects
39
- * 2. return the same API surface
40
- *
41
- * While in the case where the Fluent API is used to cause useful side effects, you might only
42
- * need the Fluent API surface to achieve your objectives but if instead it is used to
43
- * build up a useful _internal state_, then we must allow for
44
- * If this were 100% pure, however, the internal state would be unreachable and this pattern would
45
- * not be very valuable. Therefore, a secondary API, is expressed which allows for non-fluent
46
- *
47
- * At some point the internal state will be configured "enough" and the API will be extended to allow
48
- * the extraction of this state. This functional goal is expressed with the following generics:
49
- *
50
- * - `TFluent` is the fluent API which exposes a dictionary of functions
51
- * - `TEscape` is a non-fluent API used to do whatever you like but often is the means to
52
- * pass out the interior state which has been configured by the fluent parts of the API
53
- * - `TExclude` represents part of the API which -- due to the internal state -- should be hidden
54
- */
55
- // export type FluentApi<
56
- // TFluent extends {
57
- // [K in keyof TFluent]: (...args: Parameters<TFluent[K]>) => FluentApi<TFluent, TEscape>;
58
- // },
59
- // TEscape extends object = {},
60
- // TExclude extends string = ""
61
- // > = Omit<TFluent & TEscape, TExclude>;