inferred-types 0.16.1 → 0.18.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 (191) hide show
  1. package/.tsbuildinfo +1 -0
  2. package/dist/{types/utility/state/KeyStorage.d.ts → index.d.ts} +9780 -8195
  3. package/dist/index.js +687 -0
  4. package/dist/index.mjs +603 -0
  5. package/on-hold/Builder/index.ts +15 -21
  6. package/on-hold/types/index.ts +15 -20
  7. package/package.json +25 -36
  8. package/pnpm-lock.yaml +1680 -3233
  9. package/src/Mutation/index.ts +16 -18
  10. package/src/index.ts +15 -19
  11. package/src/shared/index.ts +16 -18
  12. package/src/types/Not.ts +3 -1
  13. package/src/types/Transformer.ts +1 -2
  14. package/src/types/Where.ts +36 -0
  15. package/src/types/alphabetic/PascalCase.ts +5 -4
  16. package/src/types/alphabetic/index.ts +16 -20
  17. package/src/types/dictionary/index.ts +16 -18
  18. package/src/types/{fluent.ts → fluent/fluent.ts} +8 -9
  19. package/src/types/fluent/index.ts +35 -0
  20. package/src/types/index.ts +18 -22
  21. package/src/types/kv/index.ts +16 -18
  22. package/src/types/lists/index.ts +16 -18
  23. package/src/types/ruleset-types.ts +1 -1
  24. package/src/types/string-literals/index.ts +16 -18
  25. package/src/types/tuples/index.ts +16 -18
  26. package/src/types/{SameKeys.ts → type-conversion/SameKeys.ts} +0 -0
  27. package/src/types/type-conversion/WrapValue.ts +15 -0
  28. package/src/types/type-conversion/index.ts +18 -18
  29. package/src/utility/api/index.ts +16 -18
  30. package/src/utility/dictionary/index.ts +16 -20
  31. package/src/utility/dictionary/kv/index.ts +16 -18
  32. package/src/utility/index.ts +16 -20
  33. package/src/utility/lists/index.ts +16 -18
  34. package/src/utility/literals/index.ts +16 -18
  35. package/src/utility/map-reduce/index.ts +16 -18
  36. package/src/utility/modelling/index.ts +16 -18
  37. package/src/utility/runtime/conditions/index.ts +16 -18
  38. package/src/utility/runtime/ifTypeOf.ts +1 -5
  39. package/src/utility/runtime/index.ts +16 -20
  40. package/src/utility/state/index.ts +16 -18
  41. package/tests/Where.spec.ts +39 -0
  42. package/tests/data/index.ts +9 -14
  43. package/tests/kv/dict-to-kv-and-back.spec.ts +6 -2
  44. package/tsconfig.json +4 -3
  45. package/dist/cjs/index.js +0 -1
  46. package/dist/es/index.js +0 -1
  47. package/dist/tsconfig.tsbuildinfo +0 -1
  48. package/dist/types/Mutation/MutationFunction.d.ts +0 -16
  49. package/dist/types/Mutation/MutationIdentity.d.ts +0 -30
  50. package/dist/types/Mutation/index.d.ts +0 -2
  51. package/dist/types/errors/InferenceError.d.ts +0 -1
  52. package/dist/types/errors/index.d.ts +0 -1
  53. package/dist/types/index.d.ts +0 -4
  54. package/dist/types/shared/index.d.ts +0 -3
  55. package/dist/types/shared/randomString.d.ts +0 -1
  56. package/dist/types/shared/uuid.d.ts +0 -1
  57. package/dist/types/shared/valueTypes.d.ts +0 -27
  58. package/dist/types/types/Api.d.ts +0 -10
  59. package/dist/types/types/Constructor.d.ts +0 -5
  60. package/dist/types/types/EnumValues.d.ts +0 -14
  61. package/dist/types/types/ExpandRecursively.d.ts +0 -3
  62. package/dist/types/types/First.d.ts +0 -4
  63. package/dist/types/types/FunctionType.d.ts +0 -9
  64. package/dist/types/types/If.d.ts +0 -10
  65. package/dist/types/types/Include.d.ts +0 -16
  66. package/dist/types/types/Includes.d.ts +0 -5
  67. package/dist/types/types/KeyedRecord.d.ts +0 -22
  68. package/dist/types/types/Keys.d.ts +0 -17
  69. package/dist/types/types/Length.d.ts +0 -8
  70. package/dist/types/types/Mutable.d.ts +0 -6
  71. package/dist/types/types/Narrowable.d.ts +0 -5
  72. package/dist/types/types/Not.d.ts +0 -11
  73. package/dist/types/types/Numeric.d.ts +0 -14
  74. package/dist/types/types/Opaque.d.ts +0 -12
  75. package/dist/types/types/Retain.d.ts +0 -16
  76. package/dist/types/types/SameKeys.d.ts +0 -11
  77. package/dist/types/types/Transformer.d.ts +0 -11
  78. package/dist/types/types/TypeGuard.d.ts +0 -7
  79. package/dist/types/types/alphabetic/AllCaps.d.ts +0 -12
  80. package/dist/types/types/alphabetic/CamelCase.d.ts +0 -2
  81. package/dist/types/types/alphabetic/CapFirstAlpha.d.ts +0 -13
  82. package/dist/types/types/alphabetic/CapitalizeWords.d.ts +0 -4
  83. package/dist/types/types/alphabetic/DashToSnake.d.ts +0 -1
  84. package/dist/types/types/alphabetic/DashUppercase.d.ts +0 -14
  85. package/dist/types/types/alphabetic/Dasherize.d.ts +0 -15
  86. package/dist/types/types/alphabetic/HasUppercase.d.ts +0 -13
  87. package/dist/types/types/alphabetic/Intrinsic.d.ts +0 -4
  88. package/dist/types/types/alphabetic/IsCapitalized.d.ts +0 -15
  89. package/dist/types/types/alphabetic/KebabCase.d.ts +0 -12
  90. package/dist/types/types/alphabetic/LowerAllCaps.d.ts +0 -4
  91. package/dist/types/types/alphabetic/PascalCase.d.ts +0 -16
  92. package/dist/types/types/alphabetic/Pluralize.d.ts +0 -36
  93. package/dist/types/types/alphabetic/SnakeCase.d.ts +0 -14
  94. package/dist/types/types/alphabetic/alpha-characters.d.ts +0 -36
  95. package/dist/types/types/alphabetic/index.d.ts +0 -16
  96. package/dist/types/types/append-types.d.ts +0 -9
  97. package/dist/types/types/dictionary/Get.d.ts +0 -7
  98. package/dist/types/types/dictionary/index.d.ts +0 -1
  99. package/dist/types/types/fluent.d.ts +0 -51
  100. package/dist/types/types/index.d.ts +0 -35
  101. package/dist/types/types/kv/DictFromKv.d.ts +0 -6
  102. package/dist/types/types/kv/KeyValue.d.ts +0 -11
  103. package/dist/types/types/kv/KvFrom.d.ts +0 -13
  104. package/dist/types/types/kv/KvTuple.d.ts +0 -14
  105. package/dist/types/types/kv/index.d.ts +0 -4
  106. package/dist/types/types/lists/UniqueForProp.d.ts +0 -14
  107. package/dist/types/types/lists/index.d.ts +0 -1
  108. package/dist/types/types/maybe.d.ts +0 -8
  109. package/dist/types/types/props.d.ts +0 -100
  110. package/dist/types/types/ruleset-types.d.ts +0 -59
  111. package/dist/types/types/runtime.d.ts +0 -33
  112. package/dist/types/types/string-literals/Break.d.ts +0 -12
  113. package/dist/types/types/string-literals/Concat.d.ts +0 -8
  114. package/dist/types/types/string-literals/LeftWhitespace.d.ts +0 -9
  115. package/dist/types/types/string-literals/Replace.d.ts +0 -11
  116. package/dist/types/types/string-literals/RightWhitespace.d.ts +0 -9
  117. package/dist/types/types/string-literals/StringLength.d.ts +0 -10
  118. package/dist/types/types/string-literals/Trim.d.ts +0 -11
  119. package/dist/types/types/string-literals/TrimLeft.d.ts +0 -11
  120. package/dist/types/types/string-literals/TrimRight.d.ts +0 -11
  121. package/dist/types/types/string-literals/form-fields.d.ts +0 -12
  122. package/dist/types/types/string-literals/index.d.ts +0 -10
  123. package/dist/types/types/tuples/DictArray.d.ts +0 -19
  124. package/dist/types/types/tuples/FirstKey.d.ts +0 -8
  125. package/dist/types/types/tuples/FirstKeyValue.d.ts +0 -8
  126. package/dist/types/types/tuples/FirstOfEach.d.ts +0 -11
  127. package/dist/types/types/tuples/FromDictArray.d.ts +0 -10
  128. package/dist/types/types/tuples/SecondOfEach.d.ts +0 -10
  129. package/dist/types/types/tuples/index.d.ts +0 -6
  130. package/dist/types/types/type-conversion/TupleToUnion.d.ts +0 -10
  131. package/dist/types/types/type-conversion/UnionToIntersection.d.ts +0 -5
  132. package/dist/types/types/type-conversion/UnionToTuple.d.ts +0 -9
  133. package/dist/types/types/type-conversion/index.d.ts +0 -3
  134. package/dist/types/types/type-testing.d.ts +0 -13
  135. package/dist/types/utility/api/api.d.ts +0 -2
  136. package/dist/types/utility/api/index.d.ts +0 -1
  137. package/dist/types/utility/createFnWithProps.d.ts +0 -1
  138. package/dist/types/utility/dictionary/arrayToKeyLookup.d.ts +0 -9
  139. package/dist/types/utility/dictionary/dictFilter.d.ts +0 -8
  140. package/dist/types/utility/dictionary/dictionaryTransform.d.ts +0 -9
  141. package/dist/types/utility/dictionary/entries.d.ts +0 -17
  142. package/dist/types/utility/dictionary/index.d.ts +0 -8
  143. package/dist/types/utility/dictionary/kv/dictToKv.d.ts +0 -16
  144. package/dist/types/utility/dictionary/kv/filterDictArray.d.ts +0 -9
  145. package/dist/types/utility/dictionary/kv/index.d.ts +0 -4
  146. package/dist/types/utility/dictionary/kv/kv.d.ts +0 -10
  147. package/dist/types/utility/dictionary/kv/kvToDict.d.ts +0 -15
  148. package/dist/types/utility/dictionary/mapValues.d.ts +0 -13
  149. package/dist/types/utility/dictionary/strArrayToDict.d.ts +0 -6
  150. package/dist/types/utility/dictionary/valuesOfProp.d.ts +0 -1
  151. package/dist/types/utility/index.d.ts +0 -11
  152. package/dist/types/utility/keys.d.ts +0 -5
  153. package/dist/types/utility/lists/groupBy.d.ts +0 -12
  154. package/dist/types/utility/lists/index.d.ts +0 -1
  155. package/dist/types/utility/literals/ExplicitFunction.d.ts +0 -6
  156. package/dist/types/utility/literals/arrayToObject.d.ts +0 -41
  157. package/dist/types/utility/literals/defineType.d.ts +0 -8
  158. package/dist/types/utility/literals/identity.d.ts +0 -6
  159. package/dist/types/utility/literals/index.d.ts +0 -5
  160. package/dist/types/utility/literals/literal.d.ts +0 -41
  161. package/dist/types/utility/map-reduce/filter.d.ts +0 -26
  162. package/dist/types/utility/map-reduce/index.d.ts +0 -1
  163. package/dist/types/utility/modelling/Model.d.ts +0 -22
  164. package/dist/types/utility/modelling/index.d.ts +0 -1
  165. package/dist/types/utility/ruleset.d.ts +0 -18
  166. package/dist/types/utility/runtime/condition.d.ts +0 -3
  167. package/dist/types/utility/runtime/conditions/index.d.ts +0 -12
  168. package/dist/types/utility/runtime/conditions/isArray.d.ts +0 -2
  169. package/dist/types/utility/runtime/conditions/isBoolean.d.ts +0 -5
  170. package/dist/types/utility/runtime/conditions/isFalse.d.ts +0 -4
  171. package/dist/types/utility/runtime/conditions/isFunction.d.ts +0 -15
  172. package/dist/types/utility/runtime/conditions/isLiteral.d.ts +0 -2
  173. package/dist/types/utility/runtime/conditions/isNull.d.ts +0 -1
  174. package/dist/types/utility/runtime/conditions/isNumber.d.ts +0 -1
  175. package/dist/types/utility/runtime/conditions/isObject.d.ts +0 -10
  176. package/dist/types/utility/runtime/conditions/isString.d.ts +0 -2
  177. package/dist/types/utility/runtime/conditions/isSymbol.d.ts +0 -1
  178. package/dist/types/utility/runtime/conditions/isTrue.d.ts +0 -20
  179. package/dist/types/utility/runtime/conditions/isUndefined.d.ts +0 -1
  180. package/dist/types/utility/runtime/ifTypeOf.d.ts +0 -23
  181. package/dist/types/utility/runtime/index.d.ts +0 -5
  182. package/dist/types/utility/runtime/type.d.ts +0 -27
  183. package/dist/types/utility/runtime/withValue.d.ts +0 -19
  184. package/dist/types/utility/state/Configurator.d.ts +0 -36
  185. package/dist/types/utility/state/FluentConfigurator.d.ts +0 -27
  186. package/dist/types/utility/state/index.d.ts +0 -3
  187. package/src/errors/InferenceError.ts +0 -3
  188. package/src/errors/index.ts +0 -37
  189. package/src/types/alphabetic/Intrinsic.ts +0 -6
  190. package/tests/FluentApi-spec.ts +0 -90
  191. package/tests/FluentConfigurator-spec.hold +0 -88
@@ -1,16 +0,0 @@
1
- import { Include } from "./Include";
2
- /**
3
- * **Retain<T, K>**
4
- *
5
- * Reduces the type system to just the key/values which are represented in `K`.
6
- * The `L` generic can largely be ignored unless you need _literal_ equality.
7
- *
8
- * ```ts
9
- * type Obj = { foo: 1, bar: number, baz: string };
10
- * // { foo: 1, bar: number }
11
- * type Retained = Retain<Obj, "foo" | "bar">;
12
- * ```
13
- *
14
- * **Note:** in essence this is the _opposite_ of `Exclude<T,K>`
15
- */
16
- export declare type Retain<T, K extends keyof T> = Pick<T, Include<keyof T, K>>;
@@ -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 declare type SameKeys<T extends object, A extends any = any> = {
10
- [P in keyof T]: A;
11
- };
@@ -1,11 +0,0 @@
1
- import { SameKeys } from "./SameKeys";
2
- /**
3
- * **Transformer**
4
- *
5
- * A function responsible for transforming the _values_ of
6
- * dictionary `I` into different _values_ for dictionary `O`.
7
- *
8
- * This type utility assumes that _keys_ of both dictionaries
9
- * are the same.
10
- */
11
- export declare type Transformer<I extends object, O extends SameKeys<I>, K extends keyof I = keyof I> = (input: I, key: K) => O[K];
@@ -1,7 +0,0 @@
1
- /**
2
- * **TypeGuard**
3
- *
4
- * a typing for a **TS** type-guard which evaluates an _unknown_ input
5
- * and determines if it is of type `T`.
6
- */
7
- export declare type TypeGuard<T> = (thing: unknown) => thing is T;
@@ -1,12 +0,0 @@
1
- /**
2
- * Indicates whether `T` has _all_ uppercase characters in it.
3
- * ```ts
4
- * // true
5
- * type T = AllCaps<"FOOBAR">;
6
- * // false
7
- * type T = AllCaps<"FooBar">;
8
- * // "unknown"
9
- * type T = AllCaps<string>;
10
- * ```
11
- */
12
- export declare type AllCaps<T extends string> = string extends T ? "unknown" : T extends Uppercase<T> ? true : false;
@@ -1,2 +0,0 @@
1
- import { PascalCase } from "./";
2
- export declare type CamelCase<S extends string> = Uncapitalize<PascalCase<S>>;
@@ -1,13 +0,0 @@
1
- import type { NonAlpha, Replace } from "..";
2
- /**
3
- * Strips the non-alpha characters that lead a string
4
- */
5
- export declare type StripLeftNonAlpha<S extends string> = S extends `${infer First}${infer Rest}` ? First extends NonAlpha ? StripLeftNonAlpha<Rest> : S : never;
6
- /**
7
- * identifies the leading characters which are _not_ alphabetical
8
- */
9
- export declare type LeadingNonAlpha<S extends string> = Replace<S, StripLeftNonAlpha<S>, "">;
10
- /**
11
- * Capitalize the first alphabetical character in the string
12
- */
13
- export declare type CapFirstAlpha<T extends string> = LeadingNonAlpha<T> extends string ? `${LeadingNonAlpha<T>}${Capitalize<Replace<T, LeadingNonAlpha<T>, "">>}` : Capitalize<T>;
@@ -1,4 +0,0 @@
1
- /**
2
- * Capitalize all words in a string
3
- */
4
- export declare type CapitalizeWords<S extends string> = S extends `${infer L} ${infer R}` ? `${CapitalizeWords<L>} ${CapitalizeWords<R>}` : S extends `${infer L},${infer R}` ? `${CapitalizeWords<L>},${CapitalizeWords<R>}` : S extends `${infer L}.${infer R}` ? `${CapitalizeWords<L>}.${CapitalizeWords<R>}` : Capitalize<S>;
@@ -1 +0,0 @@
1
- export declare type DashToSnake<T extends string> = T extends `${infer HEAD}-${infer TAIL}` ? DashToSnake<`${HEAD}_${TAIL}`> : T;
@@ -1,14 +0,0 @@
1
- import { HasUppercase } from "./HasUppercase";
2
- declare type _DU<T extends string> = T extends Lowercase<T> ? T : `-${Lowercase<T>}`;
3
- /**
4
- * Converts uppercase characters to a dash and then the lowercase equivalent
5
- * ```ts
6
- * // "one-two-three"
7
- * type T = DashUppercase<"oneTwoThree">;
8
- * ```
9
- *
10
- * _Intended to be used as a lower level utility; prefer `Dasherize<T>` for more full-fledged
11
- * dash solution_.
12
- */
13
- export declare type DashUppercase<T extends string> = HasUppercase<T> extends false ? T : T extends `${infer C0}${infer C1}${infer R}` ? `${_DU<C0>}${_DU<C1>}${DashUppercase<R>}` : T extends `${infer C0}${infer R}` ? `${_DU<C0>}${DashUppercase<R>}` : "";
14
- export {};
@@ -1,15 +0,0 @@
1
- import { DashUppercase, LowerAllCaps } from "..";
2
- import { Trim } from "../string-literals";
3
- /**
4
- * Converts a string literal into a _dasherized_ format while ignoring _exterior_ whitepace.
5
- *
6
- * ```ts
7
- * // "foo-bar"
8
- * type Dash = Dasherize<"foo_bar">;
9
- * type Dash = Dasherize<"fooBar">;
10
- * type Dash = Dasherize<"FooBar">;
11
- * // "\n foo-bar \t"
12
- * type Dash = Dasherize<"\n foo bar \t">;
13
- * ```
14
- */
15
- export declare type Dasherize<S extends string> = string extends S ? string : DashUppercase<Trim<LowerAllCaps<S>>> extends `${infer Begin}${"_" | " "}${infer Rest}` ? Dasherize<`${Lowercase<Begin>}-${Rest}`> : Lowercase<DashUppercase<Uncapitalize<Trim<LowerAllCaps<S>>>>>;
@@ -1,13 +0,0 @@
1
- import { UpperAlpha } from "./alpha-characters";
2
- /**
3
- * Indicates whether `T` has uppercase characters in it.
4
- * ```ts
5
- * // true
6
- * type T = HasUppercase<"Foobar">;
7
- * // false
8
- * type T = HasUppercase<"foobar">;
9
- * // "unknown"
10
- * type T = HasUppercase<string>;
11
- * ```
12
- */
13
- export declare type HasUppercase<T extends string> = string extends T ? "unknown" : T extends `${string}${UpperAlpha}${string}` ? true : false;
@@ -1,4 +0,0 @@
1
- export declare type Capitalize<T> = intrinsic;
2
- export declare type Uncapitalize<T> = intrinsic;
3
- export declare type Uppercase<T> = intrinsic;
4
- export declare type Lowercase<T> = intrinsic;
@@ -1,15 +0,0 @@
1
- /**
2
- * Returns true or false value based on whether the string literal is capitalized.
3
- * ```ts
4
- * // true
5
- * type T2 = IsCapitalized<"One">;
6
- * // false
7
- * type T1 = IsCapitalized<"one">;
8
- * // "unknown"
9
- * const a: string = "Hi";
10
- * type T3 = IsCapitalized<typeof a>;
11
- * ```
12
- *
13
- * Note: _if the value passed in is a "string" then the result will be "unknown"_
14
- */
15
- export declare type IsCapitalized<T extends string> = string extends T ? "unknown" : T extends Capitalize<T> ? true : false;
@@ -1,12 +0,0 @@
1
- import type { Dasherize } from "./";
2
- /**
3
- * **KebabCase<T>** is an _alias_ for **Dasherize<T>**.
4
- * ```ts
5
- * // "foo-bar"
6
- * type Kebab = KebabCase<"foo_bar">;
7
- * type Kebab = KebabCase<"fooBar">;
8
- * type Kebab = KebabCase<"FooBar">;
9
- * // "\n foo-bar \t"
10
- * type Kebab = KebabCase<"\n foo bar \t">;
11
- * ``` */
12
- export declare type KebabCase<T extends string> = Dasherize<T>;
@@ -1,4 +0,0 @@
1
- import { AllCaps } from "./AllCaps";
2
- /**
3
- * If **ALL CAPS** it converts to all lowercase; if not then it does nothing */
4
- export declare type LowerAllCaps<T extends string> = AllCaps<T> extends true ? Lowercase<T> : T;
@@ -1,16 +0,0 @@
1
- import type { Capitalize, LowerAllCaps, Trim } from "..";
2
- declare type Delimiter = "_" | "-" | " ";
3
- /** convert all delimiters to dashes */
4
- declare type DashDelim<T extends string> = T extends `${infer Begin}${" "}${infer Rest}` ? DashDelim<`${Begin}-${Rest}`> : T extends `${infer Begin}${"_"}${infer Rest}` ? DashDelim<`${Begin}-${Rest}`> : T;
5
- /**
6
- * Converts a string literal type to a **PascalCase** representation.
7
- * ```ts
8
- * // "FooBar"
9
- * type T = PascalCase<"fooBar">;
10
- * type T = PascalCase<"foo-bar">;
11
- * type T = PascalCase<"foo_bar">;
12
- * type T = PascalCase<"\n foo_bar \t">;
13
- * ```
14
- */
15
- export declare type PascalCase<S extends string> = string extends S ? string : Trim<DashDelim<LowerAllCaps<S>>> extends `${infer Begin}${Delimiter}${infer Rest}` ? PascalCase<`${Capitalize<Begin>}${Capitalize<Rest>}`> : Capitalize<Trim<LowerAllCaps<S>>>;
16
- export {};
@@ -1,36 +0,0 @@
1
- declare type Consonant = "b" | "c" | "d" | "f" | "g" | "h" | "j" | "k" | "l" | "m" | "n" | "p" | "q" | "r" | "s" | "t" | "v" | "w" | "x" | "z" | "y";
2
- declare type Exceptions = "photo => photos" | "piano => pianos" | "halo => halos" | "foot => feet" | "man => men" | "woman => women" | "person => people" | "mouse => mice" | "series => series" | "sheep => sheep" | "money => monies" | "deer => deer";
3
- declare type SingularException<T = Exceptions> = T extends `${infer SINGULAR} => ${infer PLURAL}` ? SINGULAR : never;
4
- declare type PluralException<T extends SingularException, E extends Exceptions = Exceptions> = E extends `${T} => ${infer PLURAL}` ? PLURAL : never;
5
- declare type SingularNoun = "s" | "sh" | "ch" | "x" | "z" | "o";
6
- declare type F = "f" | "fe";
7
- declare type Y = `${Consonant}y`;
8
- declare type RemoveTrailingY<T> = T extends `${infer HEAD}y` ? HEAD : T;
9
- /** validates that a word ends with a pluralization exception */
10
- declare type isException<T extends string> = T extends SingularException ? T : never;
11
- /** validates that a string literal ends in "is" */
12
- declare type EndsIn_IS<T extends string> = T extends `${infer HEAD}is` ? T : never;
13
- /** validates that a string literal is a singular noun */
14
- declare type EndsInSingularNoun<T extends string> = T extends `${infer HEAD}${SingularNoun}` ? T : never;
15
- /** validates that a string literal ends in "f" or "fe" */
16
- declare type EndsIn_F<T extends string> = T extends `${infer HEAD}${F}` ? T : never;
17
- /** validates that a string literal ends a consonant followed by "y" */
18
- declare type EndsIn_Y<T extends string> = T extends `${infer HEAD}${Y}` ? T : never;
19
- /**
20
- * strings which end in the letters "is" should have an "es" added to the end
21
- */
22
- declare type PluralizeEndingIn_IS<T extends string> = T extends `${infer HEAD}is` ? `${HEAD}ises` : T;
23
- /**
24
- * singular nouns should have "es" added to the end
25
- */
26
- declare type PluralizeEndingSingularNoun<T extends string> = T extends `${infer HEAD}${SingularNoun}` ? `${T}es` : T;
27
- /**
28
- * strings which end in the letters "f" or "fe" should have "ves" replace the ending
29
- */
30
- declare type PluralizeEnding_F<T extends string> = T extends `${infer HEAD}${F}` ? `${HEAD}ves` : T;
31
- /**
32
- * singular nouns should have "es" added to the end
33
- */
34
- declare type PluralizeEndingIn_Y<T extends string> = T extends `${infer HEAD}${Y}` ? `${RemoveTrailingY<T>}ies` : T;
35
- export declare type Pluralize<T extends string> = T extends isException<T> ? PluralException<T> : T extends EndsIn_IS<T> ? PluralizeEndingIn_IS<T> : T extends EndsInSingularNoun<T> ? PluralizeEndingSingularNoun<T> : T extends EndsIn_F<T> ? PluralizeEnding_F<T> : T extends EndsIn_Y<T> ? PluralizeEndingIn_Y<T> : `${T}s`;
36
- export {};
@@ -1,14 +0,0 @@
1
- import type { DashUppercase, LowerAllCaps, Trim } from "..";
2
- /** convert space to dash */
3
- declare type SpaceToDash<T extends string> = T extends `${infer Begin}${" "}${infer Rest}` ? SpaceToDash<`${Begin}-${Rest}`> : T;
4
- /**
5
- * Converts a string literal type to _snake_case_.
6
- * ```ts
7
- * // "foo_bar"
8
- * type T = SnakeCase<"fooBar">;
9
- * type T = SnakeCase<"FooBar">;
10
- * type T = SnakeCase<"foo-bar">;
11
- * type T = SnakeCase<"\n foo bar \t">;
12
- * ``` */
13
- export declare type SnakeCase<S extends string> = string extends S ? string : DashUppercase<Uncapitalize<SpaceToDash<Trim<LowerAllCaps<S>>>>> extends `${infer Begin}${"-"}${infer Rest}` ? SnakeCase<`${Lowercase<Begin>}_${Rest}`> : Lowercase<DashUppercase<Uncapitalize<Trim<LowerAllCaps<S>>>>>;
14
- export {};
@@ -1,36 +0,0 @@
1
- export declare type LowerAlpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
2
- /** Uppercase alphabetic character */
3
- export declare type UpperAlpha = Uppercase<LowerAlpha>;
4
- /**
5
- * Alphabetical characters (upper and lower)
6
- */
7
- export declare type Alpha = UpperAlpha | LowerAlpha;
8
- export declare type Whitespace = " " | "\n" | "\t";
9
- export declare type Punctuation = "." | "," | ";" | "!" | "?";
10
- /**
11
- * Characters which typically are used to separate words (but not including a space)
12
- */
13
- export declare type StringDelimiter = "_" | "-" | "/" | "\\";
14
- export declare type OpenningBracket = "(" | "[" | "{";
15
- export declare type ClosingBracket = ")" | "]" | "}";
16
- /**
17
- * Openning and closing parenthesis
18
- */
19
- export declare type Parenthesis = "(" | ")";
20
- /**
21
- * Openning and closing brackets
22
- */
23
- export declare type Bracket = OpenningBracket | ClosingBracket;
24
- /**
25
- * Numeric string characters
26
- */
27
- export declare type NumericString = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
28
- /**
29
- * Any alphabetic or numeric string character
30
- */
31
- export declare type AlphaNumeric = Alpha | NumericString;
32
- export declare type SpecialCharacters = "@" | "~" | "^" | "#" | "&" | "*";
33
- /**
34
- * Non-alphabetic characters including whitespace, string numerals, and
35
- */
36
- export declare type NonAlpha = Whitespace | Punctuation | NumericString | Bracket | SpecialCharacters;
@@ -1,16 +0,0 @@
1
- export * from "./AllCaps";
2
- export * from "./CamelCase";
3
- export * from "./CapFirstAlpha";
4
- export * from "./CapitalizeWords";
5
- export * from "./DashToSnake";
6
- export * from "./DashUppercase";
7
- export * from "./Dasherize";
8
- export * from "./HasUppercase";
9
- export * from "./Intrinsic";
10
- export * from "./IsCapitalized";
11
- export * from "./KebabCase";
12
- export * from "./LowerAllCaps";
13
- export * from "./PascalCase";
14
- export * from "./Pluralize";
15
- export * from "./SnakeCase";
16
- export * from "./alpha-characters";
@@ -1,9 +0,0 @@
1
- export declare type AppendToObject<T, U extends keyof any, V> = {
2
- [K in keyof T | U]: K extends keyof T ? T[K] : V;
3
- };
4
- /**
5
- * Appends a new Key/Value to an existing dictionary <T>
6
- */
7
- export declare type AppendToDictionary<TDict, TKey extends string, TValue> = {
8
- [K in keyof TDict | TKey]: K extends keyof TDict ? TDict[K] : TValue;
9
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * Get the type of a property of an object:
3
- * ```ts
4
- * const car = { make: "Chevy", model: "Malibu", }
5
- * ```
6
- */
7
- export declare type Get<T, K> = K extends `${infer FK}.${infer L}` ? FK extends keyof T ? Get<T[FK], L> : never : K extends keyof T ? T[K] : never;
@@ -1 +0,0 @@
1
- export * from "./Get";
@@ -1,51 +0,0 @@
1
- /**
2
- * **ToFluent**
3
- *
4
- * Converts the typing of a dictionary of functions into the same
5
- * function signatures but changes the return type to be the Fluent API.
6
- *
7
- * **Note:** this utility also allows a non-fluent API surface `X` to be included as
8
- * part of the API surface if this is desired.
9
- */
10
- export declare type ToFluent<T extends {
11
- [key: string]: (...args: any[]) => any;
12
- }, X extends object = {}> = {
13
- [K in keyof T]: (...args: Parameters<T[K]>) => ToFluent<T, X> & X;
14
- } & X;
15
- /**
16
- * A _pure_ Fluent API which promotes an API surface where _every_ API endpoint must be a function
17
- * which returns the same API surface.
18
- *
19
- * To provide value, this style of Fluent API will need to perform useful _side effects_ when functions
20
- * on the API surface are called as this structure does not provide any means to maintain an internal state
21
- * which can be returned later.
22
- *
23
- * **Note:** _if you prefer a Fluent API with means to _escape_ with an internally managed state then
24
- * you should prefer the use of the `FluentApi` type._
25
- */
26
- export declare type PureFluentApi<TApi extends Record<string, (...args: any[]) => PureFluentApi<TApi, any>>, TExclude extends string = ""> = {
27
- [P in keyof TApi]: (...args: Parameters<TApi[P]>) => PureFluentApi<Omit<TApi, TExclude>>;
28
- };
29
- /**
30
- * Represents a **Fluent API** which exposes a API as a dictionary of functions. These functions will:
31
- *
32
- * 1. mutate an internal state or cause useful side-effects
33
- * 2. return the same API surface
34
- *
35
- * While in the case where the Fluent API is used to cause useful side effects, you might only
36
- * need the Fluent API surface to achieve your objectives but if instead it is used to
37
- * build up a useful _internal state_, then we must allow for
38
- * If this were 100% pure, however, the internal state would be unreachable and this pattern would
39
- * not be very valuable. Therefore, a secondary API, is expressed which allows for non-fluent
40
- *
41
- * At some point the internal state will be configured "enough" and the API will be extended to allow
42
- * the extraction of this state. This functional goal is expressed with the following generics:
43
- *
44
- * - `TFluent` is the fluent API which exposes a dictionary of functions
45
- * - `TEscape` is a non-fluent API used to do whatever you like but often is the means to
46
- * pass out the interior state which has been configured by the fluent parts of the API
47
- * - `TExclude` represents part of the API which -- due to the internal state -- should be hidden
48
- */
49
- export declare type FluentApi<TFluent extends {
50
- [K in keyof TFluent]: (...args: Parameters<TFluent[K]>) => FluentApi<TFluent, TEscape>;
51
- }, TEscape extends object = {}, TExclude extends string = ""> = Omit<TFluent & TEscape, TExclude>;
@@ -1,35 +0,0 @@
1
- export * from "./Api";
2
- export * from "./Constructor";
3
- export * from "./EnumValues";
4
- export * from "./ExpandRecursively";
5
- export * from "./First";
6
- export * from "./FunctionType";
7
- export * from "./If";
8
- export * from "./Include";
9
- export * from "./Includes";
10
- export * from "./KeyedRecord";
11
- export * from "./Keys";
12
- export * from "./Length";
13
- export * from "./Mutable";
14
- export * from "./Narrowable";
15
- export * from "./Not";
16
- export * from "./Numeric";
17
- export * from "./Opaque";
18
- export * from "./Retain";
19
- export * from "./SameKeys";
20
- export * from "./Transformer";
21
- export * from "./TypeGuard";
22
- export * from "./append-types";
23
- export * from "./fluent";
24
- export * from "./maybe";
25
- export * from "./props";
26
- export * from "./ruleset-types";
27
- export * from "./runtime";
28
- export * from "./type-testing";
29
- export * from "./alphabetic/index";
30
- export * from "./dictionary/index";
31
- export * from "./kv/index";
32
- export * from "./lists/index";
33
- export * from "./string-literals/index";
34
- export * from "./tuples/index";
35
- export * from "./type-conversion/index";
@@ -1,6 +0,0 @@
1
- export declare type DictFromKv<T extends readonly Readonly<{
2
- key: string;
3
- value: unknown;
4
- }>[]> = {
5
- [R in T[number] as R["key"]]: R["value"];
6
- };
@@ -1,11 +0,0 @@
1
- import { ExpandRecursively } from "../ExpandRecursively";
2
- /**
3
- * Provides a strongly typed _key_ and _value_ for a dictionary `T`
4
- *
5
- * ```ts
6
- * type Obj = { foo: 1, bar: "hi" };
7
- * // ["foo", 1 ]
8
- * type Foo = KeyValue<Obj, "foo">;
9
- * ```
10
- */
11
- export declare type KeyValue<T extends object, K extends keyof T> = [K & keyof T, ExpandRecursively<T[K]>];
@@ -1,13 +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 declare type KvFrom<T extends object> = Array<{
9
- [K in keyof T]: {
10
- key: K;
11
- value: T[K];
12
- };
13
- }[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 declare type KvTuple<T, K extends keyof T> = [K, Record<K, T[K]>];
@@ -1,4 +0,0 @@
1
- export * from "./DictFromKv";
2
- export * from "./KeyValue";
3
- export * from "./KvFrom";
4
- export * from "./KvTuple";
@@ -1,14 +0,0 @@
1
- import { Get } from "../dictionary/Get";
2
- import { Narrowable } from "../Narrowable";
3
- /**
4
- * Create a union type based on a given property in an array of objects
5
- * ```ts
6
- * const data = [
7
- * { id: 123, color: "blue" },
8
- * { id: 456, color: "red" },
9
- * ] as const;
10
- * // 123 | 456
11
- * type U = UniqueForProp<typeof data, "id">;
12
- * ```
13
- */
14
- export declare type UniqueForProp<T extends readonly Record<string, Narrowable>[], P extends string> = Readonly<Get<T[number], P>>;
@@ -1 +0,0 @@
1
- export * from "./UniqueForProp";
@@ -1,8 +0,0 @@
1
- /**
2
- * Accepts the `true` literal or _undefined_.
3
- */
4
- export declare type MaybeTrue = true | undefined;
5
- /**
6
- * Accepts the `false` literal or _undefined_.
7
- */
8
- export declare type MaybeFalse = false | undefined;
@@ -1,100 +0,0 @@
1
- import { Alpha } from "common-types";
2
- /**
3
- * Extracts the _required_ keys in the object's type
4
- */
5
- export declare type RequiredKeys<T extends object> = {
6
- [K in keyof T]-?: {} extends {
7
- [P in K]: T[K];
8
- } ? never : K;
9
- }[keyof T];
10
- /**
11
- * Extracts the _optional_ keys in the object's type
12
- */
13
- export declare type OptionalKeys<T extends object> = {
14
- [K in keyof T]-?: {} extends {
15
- [P in K]: T[K];
16
- } ? K : never;
17
- }[keyof T];
18
- /**
19
- * The _keys_ on a given object `T` which have a literal value of `W`.
20
- *
21
- * Optionally, you may provide a generic `E` to exclude certain keys in
22
- * resultset.
23
- * ```ts
24
- * // "foo"
25
- * type Str = KeysWithValue<{ foo: "hi"; bar: 5 }>;
26
- * ```
27
- */
28
- export declare type KeysWithValue<W extends any, T extends object> = {
29
- [K in keyof T]: T[K] extends W ? Readonly<K> : never;
30
- }[keyof T];
31
- /**
32
- * A `PrivateKey` must start with a `_` character and then follow with
33
- * an alphabetic character
34
- */
35
- export declare type PrivateKey = `_${Alpha}${string}`;
36
- /**
37
- * Keys on an object which have a `_` character as first part of the
38
- * name are considered private and this utility will create a union
39
- * of all the keys in this category.
40
- */
41
- export declare type PrivateKeys<T extends object> = {
42
- [K in keyof T]: K extends `_${string}` ? K : never;
43
- }[keyof T];
44
- /**
45
- * **PublicKeys**
46
- *
47
- * Builds a union type of all keys which are "public" where a public
48
- * key is any key which _does not_ start with the `_` character.
49
- */
50
- export declare type PublicKeys<T extends object> = {
51
- [K in keyof T]: K extends `_${string}` ? never : K;
52
- }[keyof T];
53
- export declare type StringKeys<T extends object> = {
54
- [K in keyof T]: K extends string ? Readonly<K> : never;
55
- }[keyof T];
56
- /**
57
- * The keys of an object which _are not_ a string type
58
- */
59
- export declare type NonStringKeys<T extends object> = {
60
- [K in keyof T]: K extends string ? never : Readonly<K>;
61
- }[keyof T];
62
- export declare type NumericKeys<T extends object> = {
63
- [K in keyof T]: K extends number ? Readonly<K> : never;
64
- }[keyof T];
65
- export declare type NonNumericKeys<T extends object> = {
66
- [K in keyof T]: K extends number ? never : Readonly<K>;
67
- }[keyof T];
68
- /**
69
- * **RequiredProps**
70
- *
71
- * Reduces an object type to only key/value pairs where the key is required
72
- */
73
- export declare type RequiredProps<T extends object> = Pick<T, RequiredKeys<T>>;
74
- /**
75
- * **OptionalProps**
76
- *
77
- * Reduces an object to only key/value pairs where the key is optional
78
- */
79
- export declare type OptionalProps<T extends object> = Pick<T, RequiredKeys<T>>;
80
- /**
81
- * **WithValue**
82
- *
83
- * Reduces an object's type down to only those key/value pairs where the
84
- * value is of type `W`.
85
- * ```ts
86
- * const foo = { a: 1, b: "hi", c: () => "hello" }
87
- * // { c: () => "hello" }
88
- * type W = WithValue<Function, typeof foo>
89
- * ```
90
- */
91
- export declare type WithValue<W extends any, T extends object, E extends any = undefined> = undefined extends E ? Pick<T, KeysWithValue<W, T>> : Omit<Pick<T, KeysWithValue<W, T>>, KeysWithValue<E, T>>;
92
- /**
93
- * Reduces an object to only the key/value pairs where the key is a
94
- * string.
95
- */
96
- export declare type WithStringKeys<T extends object> = Omit<T, NonStringKeys<T>>;
97
- /**
98
- * Reduces an object to only the key/value pairs where the key is numeric.
99
- */
100
- export declare type WithNumericKeys<T extends object> = Omit<T, NonNumericKeys<T>>;