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,12 +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: 9dbff34
5
-
6
- // file exports
7
- export * from "./fluent";
8
-
9
- // #endregion auto-indexed files
10
-
11
- // see https://github.com/inocan-group/do-devops/docs/autoindex.md
12
- // for more info
@@ -1,12 +0,0 @@
1
- /**
2
- * A type utility which looks at a chain for functions and reduces the type
3
- * to the final `ReturnType` of the chain.
4
- *
5
- * ```ts
6
- * // number
7
- * type T = FinalReturn<() => (foo: string) => (bar: string) => () => number>;
8
- * ```
9
- */
10
- export type FinalReturn<T extends any> = T extends (...args: any[]) => any
11
- ? FinalReturn<ReturnType<T>>
12
- : T;
@@ -1,4 +0,0 @@
1
- /**
2
- * A function which returns a boolean value
3
- */
4
- export type LogicFunction<T extends readonly any[]> = (...args: T) => boolean;
@@ -1,13 +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: 57dfa865
5
-
6
- // file exports
7
- export * from "./FinalReturn";
8
- export * from "./LogicFunction";
9
-
10
- // #endregion auto-indexed files
11
-
12
- // see https://github.com/inocan-group/do-devops/docs/autoindex.md
13
- // for more info
@@ -1,49 +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: fbd4603a
5
-
6
- // file exports
7
- export * from "./Api";
8
- export * from "./Constructor";
9
- export * from "./EnumValues";
10
- export * from "./ExpandRecursively";
11
- export * from "./lists/First";
12
- export * from "./FunctionType";
13
- export * from "./If";
14
- export * from "./Include";
15
- export * from "./KeyedRecord";
16
- export * from "./Keys";
17
- export * from "./Length";
18
- export * from "./Mutable";
19
- export * from "./Narrowable";
20
- export * from "./Not";
21
- export * from "./Numeric";
22
- export * from "./Opaque";
23
- export * from "./Retain";
24
- export * from "./SimplifyObject";
25
- export * from "./Transformer";
26
- export * from "./TypeGuard";
27
- export * from "./Where";
28
- export * from "./append-types";
29
- export * from "./maybe";
30
- export * from "./ruleset-types";
31
- export * from "./runtime";
32
- export * from "./type-testing";
33
- // directory exports
34
- export * from "./alphabetic/index";
35
- export * from "./dictionary/index";
36
- export * from "./fluent/index";
37
- export * from "./functions/index";
38
- export * from "./kv/index";
39
- export * from "./lists/index";
40
- export * from "./literal-unions/index";
41
- export * from "./string-literals/index";
42
- export * from "./tuples/index";
43
- export * from "./type-conversion/index";
44
- export * from "./boolean-logic/index";
45
-
46
- // #endregion auto-indexed files
47
-
48
- // see https://github.com/inocan-group/do-devops/docs/autoindex.md
49
- // for more info
@@ -1,3 +0,0 @@
1
- export type DictFromKv<T extends readonly { key: string; value: unknown }[]> = {
2
- [R in T[number] as R["key"]]: R["value"];
3
- };
@@ -1,12 +0,0 @@
1
- import { ExpandRecursively } from "../ExpandRecursively";
2
-
3
- /**
4
- * Provides a strongly typed _key_ and _value_ for a dictionary `T`
5
- *
6
- * ```ts
7
- * type Obj = { foo: 1, bar: "hi" };
8
- * // ["foo", 1 ]
9
- * type Foo = KeyValue<Obj, "foo">;
10
- * ```
11
- */
12
- export type KeyValue<T extends object, K extends keyof T> = [K & keyof T, ExpandRecursively<T[K]>];
@@ -1,8 +0,0 @@
1
- /**
2
- * Type utility which takes an object type and converts to an array of KV objects:
3
- * ```ts
4
- * // [ {key: "id", value: 123 } | {key: "foo", value: "bar" } ][]
5
- * type Arr = KvFrom<{ id: 123, foo: "bar" }>;
6
- * ```
7
- */
8
- export type KvFrom<T extends object> = Array<{ [K in keyof T]: { key: K; value: T[K] } }[keyof T]>;
@@ -1,14 +0,0 @@
1
- /**
2
- * **KvTuple**
3
- *
4
- * a key/value of type `T` represented as `[key, kv]`
5
- *
6
- * ```ts
7
- * type Obj = { foo: 1, bar: "hi" };
8
- * // ["foo", { foo: 1 } ]
9
- * type Foo = KvTuple<Obj, "foo">;
10
- * ```
11
- *
12
- * **Note:** _consider use of `KeyValue<T,K>` as an alternate representation_
13
- */
14
- export type KvTuple<T, K extends keyof T> = [K, Record<K, T[K]>];
@@ -1,15 +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: 744ff3bf
5
-
6
- // file exports
7
- export * from "./DictFromKv";
8
- export * from "./KeyValue";
9
- export * from "./KvFrom";
10
- export * from "./KvTuple";
11
-
12
- // #endregion auto-indexed files
13
-
14
- // see https://github.com/inocan-group/do-devops/docs/autoindex.md
15
- // for more info
@@ -1,10 +0,0 @@
1
- /**
2
- * **AfterFirst**`<T>`
3
- *
4
- * returns the elements in an array _after_ the first element
5
- */
6
- export type AfterFirst<T extends readonly any[]> = T extends readonly [any, ...any[]]
7
- ? T extends readonly [any, ...infer Rest]
8
- ? Rest
9
- : never
10
- : T;
@@ -1,151 +0,0 @@
1
- import { TupleToUnion, UnionToTuple } from "../type-conversion";
2
- import { Narrowable } from "../Narrowable";
3
- import { First } from "./First";
4
- import { AfterFirst } from "./AfterFirst";
5
- import { Keys } from "../Keys";
6
-
7
- import { DictionaryWithoutValue } from "../dictionary/props";
8
-
9
- // [Mapped Tuple Types](https://github.com/Microsoft/TypeScript/issues/25947)
10
-
11
- /**
12
- * The basic shape of a `Converter`
13
- */
14
- export type ConverterShape<
15
- S extends Narrowable,
16
- N extends Narrowable,
17
- B extends Narrowable,
18
- O extends Narrowable
19
- > = {
20
- string: <T extends string>(v: T) => S;
21
- number: <T extends number>(v: T) => N;
22
- boolean: <T extends boolean>(v: T) => B;
23
- object: <T extends Record<string, any>>(v: T) => O;
24
- };
25
-
26
- type ConverterKeys<S, N, B, O> = UnionToTuple<
27
- Keys<
28
- DictionaryWithoutValue<
29
- {
30
- string: S;
31
- number: N;
32
- boolean: B;
33
- object: O;
34
- },
35
- undefined
36
- >
37
- >
38
- >;
39
-
40
- type ConverterInputType<T extends string> = T extends "string"
41
- ? string
42
- : T extends "number"
43
- ? number
44
- : T extends "boolean"
45
- ? boolean
46
- : T extends "object"
47
- ? Record<string, any>
48
- : unknown;
49
-
50
- type ConverterInputUnion<
51
- TConverted extends readonly any[],
52
- TRemaining extends readonly string[]
53
- > = [] extends TRemaining
54
- ? // we're done iterating
55
- TConverted
56
- : // recurse
57
- ConverterInputUnion<
58
- [...TConverted, ConverterInputType<First<TRemaining>>],
59
- AfterFirst<TRemaining>
60
- >;
61
-
62
- /**
63
- * **AvailableConverters**
64
- *
65
- * Type utility which will produce the correct union type for a "converter"
66
- */
67
- export type AvailableConverters<S, N, B, O> = ConverterKeys<S, N, B, O> extends readonly string[]
68
- ? TupleToUnion<ConverterInputUnion<[], ConverterKeys<S, N, B, O>>>
69
- : never;
70
-
71
- /**
72
- * **Converter**
73
- *
74
- * A type converter coming from the `createConverter()` utility. It receives
75
- * one or more broad types (e.g., number, string, etc.) -- what it can take
76
- * is based on what is configured -- and then converts based on the value
77
- * passed in.
78
- *
79
- * The primary goal is to preserve as many _narrow_ types as possible in this process.
80
- */
81
- export type Converter<
82
- S extends Narrowable,
83
- N extends Narrowable,
84
- B extends Narrowable,
85
- O extends Narrowable
86
- > = <T extends AvailableConverters<S, N, B, O>>(input: T) => ConverterShape<S, N, B, O>;
87
-
88
- export type Conversion<TInput extends Narrowable, TOutput extends Narrowable> = <T extends TInput>(
89
- input: T
90
- ) => TOutput;
91
-
92
- export type ConverterCoverage = "string" | "number" | "boolean" | "object";
93
-
94
- /**
95
- * Extracts the coverage provided by a `StrongMap` as a Tuple
96
- */
97
- export type MapCoverage<T extends StrongMap<ConverterCoverage>> = T extends StrongMap<
98
- infer Coverage
99
- >
100
- ? UnionToTuple<Coverage>
101
- : never;
102
-
103
- export type StrongMapTypes<K extends readonly any[]> = [] extends K
104
- ? never
105
- : TupleToUnion<
106
- [
107
- First<K> extends "string"
108
- ? TupleToUnion<[string, ...UnionToTuple<StrongMapTypes<AfterFirst<K>>>]>
109
- : First<K> extends "number"
110
- ? TupleToUnion<[number, ...UnionToTuple<StrongMapTypes<AfterFirst<K>>>]>
111
- : First<K> extends "boolean"
112
- ? TupleToUnion<[boolean, ...UnionToTuple<StrongMapTypes<AfterFirst<K>>>]>
113
- : First<K> extends "object"
114
- ? TupleToUnion<[Record<string, any>, ...UnionToTuple<StrongMapTypes<AfterFirst<K>>>]>
115
- : never,
116
- ...UnionToTuple<StrongMapTypes<AfterFirst<K>>>
117
- ]
118
- >;
119
-
120
- export type StrongMap<TDefined = ConverterCoverage> = {
121
- string: TDefined extends "string" ? <T extends string, R extends any>(v: T) => R : never;
122
- number: TDefined extends "number" ? <T extends number, R extends any>(v: T) => R : never;
123
- boolean: TDefined extends "boolean" ? <T extends boolean, R extends any>(v: T) => R : never;
124
- object: TDefined extends "object"
125
- ? <T extends Record<string, any>, R extends any>(v: T) => R
126
- : never;
127
- };
128
-
129
- export type StrongMapTransformer<M extends StrongMap> = <
130
- T extends readonly StrongMapTypes<MapCoverage<M>>[]
131
- >(
132
- tuple: T
133
- ) => {
134
- [K in keyof T]: T[K] extends string
135
- ? M["string"] extends (...args: any[]) => any
136
- ? ReturnType<M["string"]>
137
- : never
138
- : T[K] extends number
139
- ? M["number"] extends (...args: any[]) => any
140
- ? ReturnType<M["number"]>
141
- : never
142
- : T[K] extends boolean
143
- ? M["boolean"] extends (...args: any[]) => any
144
- ? ReturnType<M["boolean"]>
145
- : never
146
- : T[K] extends Record<string, any>
147
- ? M["object"] extends (...args: any[]) => any
148
- ? ReturnType<M["object"]>
149
- : never
150
- : never;
151
- }[keyof T];
@@ -1,20 +0,0 @@
1
- /**
2
- * **FilterTuple**
3
- *
4
- * Allows a known tuple `T` to be _filtered down_ by eliminating all items
5
- * in the Tuple that _extend_ type `F`
6
- * ```ts
7
- * type T = [1,"foo",3];
8
- * // [1,3]
9
- * type T2 = FilterTuple<T, string>;
10
- * ```
11
- */
12
- export type FilterTuple<
13
- TTuple extends any[] | readonly any[],
14
- TFilter,
15
- Result extends any[] = []
16
- > = TTuple extends [infer A, ...infer R]
17
- ? [A] extends [TFilter]
18
- ? FilterTuple<R, TFilter, Result>
19
- : FilterTuple<R, TFilter, [...Result, A]>
20
- : Result;
@@ -1,8 +0,0 @@
1
- /**
2
- * Returns the first values type in an array of values
3
- */
4
- export type First<T extends readonly any[]> = T[0] extends T[number] ? T[0] : never;
5
-
6
- export type FirstOrUndefined<T extends unknown> = T extends [unknown, ...[unknown]]
7
- ? First<T>
8
- : undefined;
@@ -1,4 +0,0 @@
1
- /**
2
- * returns the first `string` value from an array of values
3
- */
4
- export type FirstString<T> = T extends [infer S extends string, ...unknown[]] ? S : never;
@@ -1,21 +0,0 @@
1
- /**
2
- * **Split**`<T, SEP>`
3
- *
4
- * Splits a string literal `T` by string literal _separator_ `SEP`. The result is an array
5
- * of string literals.
6
- */
7
- export type Split<
8
- T extends string,
9
- SEP extends string,
10
- ANSWER extends string[] = []
11
- > = string extends T
12
- ? // wide string so we can only return wide string[]
13
- string[]
14
- : T extends SEP
15
- ? // the string === separator results in empty array
16
- ANSWER
17
- : // test whether can recurse
18
- T extends `${infer HEAD}${SEP}${infer TAIL}`
19
- ? // recurse to produce strong literal type
20
- Split<TAIL, SEP, [...ANSWER, HEAD]>
21
- : [...ANSWER, T];
@@ -1,18 +0,0 @@
1
- import { Get } from "../dictionary/Get";
2
- import { Narrowable } from "../Narrowable";
3
-
4
- /**
5
- * Create a union type based on a given property in an array of objects
6
- * ```ts
7
- * const data = [
8
- * { id: 123, color: "blue" },
9
- * { id: 456, color: "red" },
10
- * ] as const;
11
- * // 123 | 456
12
- * type U = UniqueForProp<typeof data, "id">;
13
- * ```
14
- */
15
- export type UniqueForProp<
16
- T extends readonly Record<string, Narrowable>[],
17
- P extends string
18
- > = Readonly<Get<T[number], P>>;
@@ -1,18 +0,0 @@
1
- // #autoindex
2
-
3
- // #region auto-indexed files
4
- // index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
5
- // hash-code: 582c0cf0
6
-
7
- // file exports
8
- export * from "./AfterFirst";
9
- export * from "./First";
10
- export * from "./FirstString";
11
- export * from "./FilterTuple";
12
- export * from "./Split";
13
- export * from "./UniqueForProp";
14
-
15
- // #endregion auto-indexed files
16
-
17
- // see https://github.com/inocan-group/do-devops/docs/autoindex.md
18
- // for more info
@@ -1,4 +0,0 @@
1
- /**
2
- * Expresses whether an option is "opt" (optional) or "req" (required)
3
- */
4
- export type OptRequired = "opt" | "req";
@@ -1 +0,0 @@
1
- export * from "./OptRequired";
@@ -1,9 +0,0 @@
1
- /**
2
- * Accepts the `true` literal or _undefined_.
3
- */
4
- export type MaybeTrue = true | undefined;
5
-
6
- /**
7
- * Accepts the `false` literal or _undefined_.
8
- */
9
- export type MaybeFalse = false | undefined;
@@ -1,76 +0,0 @@
1
- import { TypeCondition } from "src/runtime/type-checks/ifTypeOf";
2
- import { OptionalKeys } from "./dictionary/props";
3
- import { SameKeys } from "./dictionary/SameKeys";
4
-
5
- /**
6
- * **RuleDefinition**
7
- *
8
- * A rule definition is the typing for the fluent API surface that is built up
9
- * with the **ruleset** utility.
10
- */
11
- export type RuleDefinition<
12
- /** the data which will be evaluated on rule execution */
13
- T extends object,
14
- /** the optional props -- as a union type -- which must be defined per the rule */
15
- H extends string = "",
16
- /** the key/values which will be evaluated on execution (wide type) */
17
- E extends Partial<SameKeys<T>> = {},
18
- /** the key/values which will be evaluated on execution (narrow type) */
19
- N extends Partial<SameKeys<T>> = {}
20
- > = {
21
- /**
22
- * sets up a true/false check that a given property is defined; this
23
- * condition can only be applied to _optional_ properties.
24
- */
25
- has(optProp: OptionalKeys<T>): RuleDefinition<T, H & typeof optProp, E, N>;
26
-
27
- /**
28
- * Validates that a given property extends a certain value's type; comparison
29
- * is made assuming "wide types".
30
- */
31
- equals<K extends keyof T, V extends Pick<T, K>>(
32
- prop: K,
33
- value: V
34
- ): RuleDefinition<T, H, E & Record<K, V>, N>;
35
-
36
- /**
37
- * Validates that a given property extends a certain value's type; comparison
38
- * is made assuming "narrow types". This is only available for props which
39
- * expose a
40
- */
41
- narrowlyEquals<K extends keyof T, V extends Pick<T, K>>(
42
- prop: K,
43
- value: V
44
- ): RuleDefinition<T, H, E, N & Record<K, V>>;
45
- };
46
-
47
- /**
48
- * **DynamicRule**
49
- *
50
- * A dynamic rule allows type and runtime validation of a data structure
51
- * which extends a known `State`. It then returns the literal type `true`
52
- * or `false`.
53
- *
54
- * ```ts
55
- * type State = { id?: string; favorite: boolean; color: string };
56
- * // type-safe way to check whether optional prop is actually set
57
- * const rule: DynamicRule<State> = s => s
58
- * .has("id")
59
- * .equals("favorite", true)
60
- * .equals("color", "red");
61
- * ```
62
- */
63
- export type DynamicRule<TState extends any, TResult extends true | false> = (
64
- rule: TypeCondition<any, TState>
65
- ) => TResult;
66
-
67
- /**
68
- * **DynamicRuleSet**
69
- *
70
- * A function which accepts the agreed `TState` generic as input and returns a discrete
71
- * `true` or `false` value.
72
- */
73
- export type DynamicRuleSet<
74
- TState extends any,
75
- TRules extends Record<string, TypeCondition<any, TState>>
76
- > = (rules: TRules) => true | false;
@@ -1,39 +0,0 @@
1
- // runtime types relate to the types coming out of the runtime utilities
2
-
3
- import { TypeGuard } from "./TypeGuard";
4
-
5
- export type RuntimeType<T> = {
6
- __kind: "type";
7
-
8
- type: T;
9
- is: TypeGuard<T>;
10
- };
11
-
12
- export type RuntimeProp<P extends Readonly<PropertyKey>, T extends RuntimeType<any>> = {
13
- __kind: "prop";
14
- key: Readonly<P>;
15
- valueType: Readonly<T["type"]>;
16
- /**
17
- * Provides the _type_ to the type system when used with `typeof`.
18
- *
19
- * ```ts
20
- * const t = number();
21
- * // number
22
- * type T = typeof t.type;
23
- * ```
24
- *
25
- * **Note:** _the runtime system will get a string equivalent name:_
26
- * ```ts
27
- * const t = number();
28
- * // "number"
29
- * console.log(t.type);
30
- * ```
31
- */
32
- type: Record<P, T["type"]>;
33
- is: TypeGuard<Record<P, T["type"]>>;
34
- };
35
-
36
- export type TypeOptions<T extends Partial<object> = {}> = {
37
- /** each type has a default type guard but you can override if you need to be more specific */
38
- typeGuard?: TypeGuard<T>;
39
- } & T;
@@ -1,22 +0,0 @@
1
-
2
- /**
3
- * **Break<T,D>**
4
- *
5
- * Takes a string `T`, and splits it into a tuple of the form `[F, R]`.
6
- * ```ts
7
- * // ["the", " long and winding road"]
8
- * type T1 = Break<"the long and winding road", " ">;
9
- * // ["there", " I was, there I was"]
10
- * type T2 = Break<"there I was, there I was", " ">;
11
- * ```
12
- */
13
- export type Break<T extends string, D extends string> = (
14
- string extends T ? [string, string] : (
15
- T extends `${infer F}${D}${infer _R}` ? (
16
- F extends `${infer _X}${D}${infer _Y}` ? never : (
17
- T extends `${F}${infer R}` ? [F, R] : never
18
- )
19
- ) : [T, ""]
20
- )
21
- );
22
-
@@ -1,9 +0,0 @@
1
- /**
2
- * Concatenates two arrays (of literals).
3
- * ```ts
4
- * // [ "foo", "bar", "baz" ]
5
- * type T = ArrConcat<["foo"], ["bar", "baz"]>;
6
- * ```
7
- */
8
- export type ArrConcat<A extends any[], B extends any[]> = [...A, ...B];
9
-
@@ -1,13 +0,0 @@
1
- import { Replace } from "./Replace";
2
- import { TrimLeft } from "./TrimLeft";
3
-
4
- /**
5
- * Provides the _left_ whitespace of a string
6
- * ```ts
7
- * // "\n\t "
8
- * type T = LeftWhitespace<"\n\t foobar">;
9
- * ```
10
- */
11
- export type LeftWhitespace<S extends string> = string extends S
12
- ? string
13
- : Replace<S, TrimLeft<S>, "">;
@@ -1,17 +0,0 @@
1
- /**
2
- * Type utility which takes a string `S` and replaces the substring `W` with `P`.
3
- * ```ts
4
- * const fooy = "fooy";
5
- * // "Foo"
6
- * type Foo = Replace<typeof fooy, "y", "">;
7
- * ```
8
- *
9
- * Note: _the first match is replaced and all subsequent matches are ignored_
10
- */
11
- export type Replace<S extends string, W extends string, P extends string> = S extends ""
12
- ? ""
13
- : W extends ""
14
- ? S
15
- : S extends `${infer F}${W}${infer E}`
16
- ? `${F}${P}${E}`
17
- : S;
@@ -1,13 +0,0 @@
1
- import { Replace } from "./Replace";
2
- import { TrimRight } from "./TrimRight";
3
-
4
- /**
5
- * Provides the _left_ whitespace of a string
6
- * ```ts
7
- * // "\n\t "
8
- * type T = LeftWhitespace<"\n\t foobar">;
9
- * ```
10
- */
11
- export type RightWhitespace<S extends string> = string extends S
12
- ? string
13
- : Replace<S, TrimRight<S>, "">;
@@ -1,34 +0,0 @@
1
- /**
2
- * Type utility that provides the _length_ of a given string type in a way which
3
- * is _not_ limited to TS's recursive string length of roughly 48.
4
- *
5
- * ```ts
6
- * // 3
7
- * type Three = StringLength<"foo">;
8
- * ```
9
- */
10
- export type StringLength<S extends string, R extends number[] = []>
11
- = S extends `${infer _First}${infer _Second}${infer _Third}${infer _Fourth}${infer _Fifth}${infer _Sixth}${infer _Sevebnth}${infer _Eighth}${infer _Ninth}${infer _Tenth}${infer Rest}`
12
- ? StringLength<Rest, [...R, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]>
13
- : S extends `${infer _First}${infer _Second}${infer _Third}${infer _Fourth}${infer _Fifth}${infer _Sixth}${infer _Sevebnth}${infer _Eighth}${infer _Ninth}${infer Rest}`
14
- ? StringLength<Rest, [...R, 1, 1, 1, 1, 1, 1, 1, 1, 1]>
15
- : S extends `${infer _First}${infer _Second}${infer _Third}${infer _Fourth}${infer _Fifth}${infer _Sixth}${infer _Sevebnth}${infer _Eighth}${infer Rest}`
16
- ? StringLength<Rest, [...R, 1, 1, 1, 1, 1, 1, 1, 1]>
17
- : S extends `${infer _First}${infer _Second}${infer _Third}${infer _Fourth}${infer _Fifth}${infer _Sixth}${infer _Sevebnth}${infer Rest}`
18
- ? StringLength<Rest, [...R, 1, 1, 1, 1, 1, 1, 1]>
19
- : S extends `${infer _First}${infer _Second}${infer _Third}${infer _Fourth}${infer _Fifth}${infer _Sixth}${infer Rest}`
20
- ? StringLength<Rest, [...R, 1, 1, 1, 1, 1, 1]>
21
- : S extends `${infer _First}${infer _Second}${infer _Third}${infer _Fourth}${infer _Fifth}}${infer Rest}`
22
- ? StringLength<Rest, [...R, 1, 1, 1, 1, 1]>
23
- : S extends `${infer _First}${infer _Second}${infer _Third}${infer _Fourth}${infer Rest}`
24
- ? StringLength<Rest, [...R, 1, 1, 1, 1]>
25
- : S extends `${infer _First}${infer _Second}${infer _Third}${infer Rest}`
26
- ? StringLength<Rest, [...R, 1, 1, 1]>
27
- : S extends `${infer _First}${infer _Second}${infer Rest}`
28
- ? StringLength<Rest, [...R, 1, 1]>
29
- : S extends `${infer _First}${infer Rest}`
30
- ? StringLength<Rest, [...R, 1]>
31
- : [...R]["length"];
32
-
33
-
34
-