inferred-types 0.16.0 → 0.18.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 (177) hide show
  1. package/.tsbuildinfo +1 -0
  2. package/devops/build.js +1 -3
  3. package/dist/{types/utility/state/KeyStorage.d.ts → index.d.ts} +9767 -8195
  4. package/dist/index.js +659 -0
  5. package/dist/index.mjs +577 -0
  6. package/on-hold/tests/api-spec.ts +9 -15
  7. package/package.json +27 -39
  8. package/pnpm-lock.yaml +2807 -3858
  9. package/src/errors/InferenceError.ts +1 -1
  10. package/src/shared/randomString.ts +1 -1
  11. package/src/types/Constructor.ts +5 -0
  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 +9 -5
  17. package/src/types/{fluent.ts → fluent/fluent.ts} +8 -9
  18. package/src/types/fluent/index.ts +42 -0
  19. package/src/types/index.ts +13 -7
  20. package/src/types/ruleset-types.ts +1 -1
  21. package/src/types/{SameKeys.ts → type-conversion/SameKeys.ts} +0 -0
  22. package/src/types/type-conversion/WrapValue.ts +15 -0
  23. package/src/types/type-conversion/index.ts +11 -4
  24. package/src/utility/dictionary/dictionaryTransform.ts +6 -7
  25. package/tests/Where.spec.ts +39 -0
  26. package/tests/constructor.spec.ts +40 -0
  27. package/tests/data/index.ts +8 -3
  28. package/tests/kv/dict-to-kv-and-back.spec.ts +2 -6
  29. package/tsconfig.json +4 -3
  30. package/dist/cjs/index.js +0 -21
  31. package/dist/es/index.js +0 -17
  32. package/dist/tsconfig.tsbuildinfo +0 -1
  33. package/dist/types/Mutation/MutationFunction.d.ts +0 -16
  34. package/dist/types/Mutation/MutationIdentity.d.ts +0 -30
  35. package/dist/types/Mutation/index.d.ts +0 -2
  36. package/dist/types/errors/InferenceError.d.ts +0 -1
  37. package/dist/types/errors/index.d.ts +0 -1
  38. package/dist/types/index.d.ts +0 -4
  39. package/dist/types/shared/index.d.ts +0 -3
  40. package/dist/types/shared/randomString.d.ts +0 -1
  41. package/dist/types/shared/uuid.d.ts +0 -1
  42. package/dist/types/shared/valueTypes.d.ts +0 -27
  43. package/dist/types/types/Api.d.ts +0 -10
  44. package/dist/types/types/EnumValues.d.ts +0 -14
  45. package/dist/types/types/ExpandRecursively.d.ts +0 -3
  46. package/dist/types/types/First.d.ts +0 -4
  47. package/dist/types/types/FunctionType.d.ts +0 -9
  48. package/dist/types/types/If.d.ts +0 -10
  49. package/dist/types/types/Include.d.ts +0 -16
  50. package/dist/types/types/Includes.d.ts +0 -5
  51. package/dist/types/types/KeyedRecord.d.ts +0 -22
  52. package/dist/types/types/Keys.d.ts +0 -17
  53. package/dist/types/types/Length.d.ts +0 -8
  54. package/dist/types/types/Mutable.d.ts +0 -6
  55. package/dist/types/types/Narrowable.d.ts +0 -5
  56. package/dist/types/types/Not.d.ts +0 -11
  57. package/dist/types/types/Numeric.d.ts +0 -14
  58. package/dist/types/types/Opaque.d.ts +0 -12
  59. package/dist/types/types/Retain.d.ts +0 -16
  60. package/dist/types/types/SameKeys.d.ts +0 -11
  61. package/dist/types/types/Transformer.d.ts +0 -11
  62. package/dist/types/types/TypeGuard.d.ts +0 -7
  63. package/dist/types/types/alphabetic/AllCaps.d.ts +0 -12
  64. package/dist/types/types/alphabetic/CamelCase.d.ts +0 -2
  65. package/dist/types/types/alphabetic/CapFirstAlpha.d.ts +0 -13
  66. package/dist/types/types/alphabetic/CapitalizeWords.d.ts +0 -4
  67. package/dist/types/types/alphabetic/DashToSnake.d.ts +0 -1
  68. package/dist/types/types/alphabetic/DashUppercase.d.ts +0 -14
  69. package/dist/types/types/alphabetic/Dasherize.d.ts +0 -15
  70. package/dist/types/types/alphabetic/HasUppercase.d.ts +0 -13
  71. package/dist/types/types/alphabetic/Intrinsic.d.ts +0 -4
  72. package/dist/types/types/alphabetic/IsCapitalized.d.ts +0 -15
  73. package/dist/types/types/alphabetic/KebabCase.d.ts +0 -12
  74. package/dist/types/types/alphabetic/LowerAllCaps.d.ts +0 -4
  75. package/dist/types/types/alphabetic/PascalCase.d.ts +0 -16
  76. package/dist/types/types/alphabetic/Pluralize.d.ts +0 -36
  77. package/dist/types/types/alphabetic/SnakeCase.d.ts +0 -14
  78. package/dist/types/types/alphabetic/alpha-characters.d.ts +0 -36
  79. package/dist/types/types/alphabetic/index.d.ts +0 -16
  80. package/dist/types/types/append-types.d.ts +0 -9
  81. package/dist/types/types/dictionary/Get.d.ts +0 -7
  82. package/dist/types/types/dictionary/index.d.ts +0 -1
  83. package/dist/types/types/fluent.d.ts +0 -51
  84. package/dist/types/types/index.d.ts +0 -34
  85. package/dist/types/types/kv/DictFromKv.d.ts +0 -6
  86. package/dist/types/types/kv/KeyValue.d.ts +0 -11
  87. package/dist/types/types/kv/KvFrom.d.ts +0 -13
  88. package/dist/types/types/kv/KvTuple.d.ts +0 -14
  89. package/dist/types/types/kv/index.d.ts +0 -4
  90. package/dist/types/types/lists/UniqueForProp.d.ts +0 -14
  91. package/dist/types/types/lists/index.d.ts +0 -1
  92. package/dist/types/types/maybe.d.ts +0 -8
  93. package/dist/types/types/props.d.ts +0 -100
  94. package/dist/types/types/ruleset-types.d.ts +0 -59
  95. package/dist/types/types/runtime.d.ts +0 -33
  96. package/dist/types/types/string-literals/Break.d.ts +0 -12
  97. package/dist/types/types/string-literals/Concat.d.ts +0 -8
  98. package/dist/types/types/string-literals/LeftWhitespace.d.ts +0 -9
  99. package/dist/types/types/string-literals/Replace.d.ts +0 -11
  100. package/dist/types/types/string-literals/RightWhitespace.d.ts +0 -9
  101. package/dist/types/types/string-literals/StringLength.d.ts +0 -10
  102. package/dist/types/types/string-literals/Trim.d.ts +0 -11
  103. package/dist/types/types/string-literals/TrimLeft.d.ts +0 -11
  104. package/dist/types/types/string-literals/TrimRight.d.ts +0 -11
  105. package/dist/types/types/string-literals/form-fields.d.ts +0 -12
  106. package/dist/types/types/string-literals/index.d.ts +0 -10
  107. package/dist/types/types/tuples/DictArray.d.ts +0 -19
  108. package/dist/types/types/tuples/FirstKey.d.ts +0 -8
  109. package/dist/types/types/tuples/FirstKeyValue.d.ts +0 -8
  110. package/dist/types/types/tuples/FirstOfEach.d.ts +0 -11
  111. package/dist/types/types/tuples/FromDictArray.d.ts +0 -10
  112. package/dist/types/types/tuples/SecondOfEach.d.ts +0 -10
  113. package/dist/types/types/tuples/index.d.ts +0 -6
  114. package/dist/types/types/type-conversion/TupleToUnion.d.ts +0 -10
  115. package/dist/types/types/type-conversion/UnionToIntersection.d.ts +0 -5
  116. package/dist/types/types/type-conversion/UnionToTuple.d.ts +0 -9
  117. package/dist/types/types/type-conversion/index.d.ts +0 -3
  118. package/dist/types/types/type-testing.d.ts +0 -13
  119. package/dist/types/utility/api/api.d.ts +0 -2
  120. package/dist/types/utility/api/index.d.ts +0 -1
  121. package/dist/types/utility/createFnWithProps.d.ts +0 -1
  122. package/dist/types/utility/dictionary/arrayToKeyLookup.d.ts +0 -9
  123. package/dist/types/utility/dictionary/dictFilter.d.ts +0 -8
  124. package/dist/types/utility/dictionary/dictionaryTransform.d.ts +0 -9
  125. package/dist/types/utility/dictionary/entries.d.ts +0 -17
  126. package/dist/types/utility/dictionary/index.d.ts +0 -8
  127. package/dist/types/utility/dictionary/kv/dictToKv.d.ts +0 -16
  128. package/dist/types/utility/dictionary/kv/filterDictArray.d.ts +0 -9
  129. package/dist/types/utility/dictionary/kv/index.d.ts +0 -4
  130. package/dist/types/utility/dictionary/kv/kv.d.ts +0 -10
  131. package/dist/types/utility/dictionary/kv/kvToDict.d.ts +0 -15
  132. package/dist/types/utility/dictionary/mapValues.d.ts +0 -13
  133. package/dist/types/utility/dictionary/strArrayToDict.d.ts +0 -6
  134. package/dist/types/utility/dictionary/valuesOfProp.d.ts +0 -1
  135. package/dist/types/utility/index.d.ts +0 -11
  136. package/dist/types/utility/keys.d.ts +0 -5
  137. package/dist/types/utility/lists/groupBy.d.ts +0 -12
  138. package/dist/types/utility/lists/index.d.ts +0 -1
  139. package/dist/types/utility/literals/ExplicitFunction.d.ts +0 -6
  140. package/dist/types/utility/literals/arrayToObject.d.ts +0 -41
  141. package/dist/types/utility/literals/defineType.d.ts +0 -8
  142. package/dist/types/utility/literals/identity.d.ts +0 -6
  143. package/dist/types/utility/literals/index.d.ts +0 -5
  144. package/dist/types/utility/literals/literal.d.ts +0 -41
  145. package/dist/types/utility/map-reduce/filter.d.ts +0 -26
  146. package/dist/types/utility/map-reduce/index.d.ts +0 -1
  147. package/dist/types/utility/modelling/IoModel.d.ts +0 -26
  148. package/dist/types/utility/modelling/Model.d.ts +0 -22
  149. package/dist/types/utility/modelling/index.d.ts +0 -1
  150. package/dist/types/utility/ruleset.d.ts +0 -18
  151. package/dist/types/utility/runtime/condition.d.ts +0 -3
  152. package/dist/types/utility/runtime/conditions/index.d.ts +0 -12
  153. package/dist/types/utility/runtime/conditions/isArray.d.ts +0 -2
  154. package/dist/types/utility/runtime/conditions/isBoolean.d.ts +0 -5
  155. package/dist/types/utility/runtime/conditions/isFalse.d.ts +0 -4
  156. package/dist/types/utility/runtime/conditions/isFunction.d.ts +0 -15
  157. package/dist/types/utility/runtime/conditions/isLiteral.d.ts +0 -2
  158. package/dist/types/utility/runtime/conditions/isNull.d.ts +0 -1
  159. package/dist/types/utility/runtime/conditions/isNumber.d.ts +0 -1
  160. package/dist/types/utility/runtime/conditions/isObject.d.ts +0 -10
  161. package/dist/types/utility/runtime/conditions/isString.d.ts +0 -2
  162. package/dist/types/utility/runtime/conditions/isSymbol.d.ts +0 -1
  163. package/dist/types/utility/runtime/conditions/isTrue.d.ts +0 -20
  164. package/dist/types/utility/runtime/conditions/isUndefined.d.ts +0 -1
  165. package/dist/types/utility/runtime/ifTypeOf.d.ts +0 -23
  166. package/dist/types/utility/runtime/index.d.ts +0 -5
  167. package/dist/types/utility/runtime/type.d.ts +0 -27
  168. package/dist/types/utility/runtime/withValue.d.ts +0 -19
  169. package/dist/types/utility/state/Configurator.d.ts +0 -36
  170. package/dist/types/utility/state/FluentConfigurator.d.ts +0 -27
  171. package/dist/types/utility/state/index.d.ts +0 -3
  172. package/src/types/alphabetic/Intrinsic.ts +0 -6
  173. package/src/utility/modelling/IoModel.ts +0 -38
  174. package/tests/FluentApi-spec.ts +0 -90
  175. package/tests/FluentConfigurator-spec.hold +0 -88
  176. package/tests/IoModel-spec.hold +0 -209
  177. package/tests/lists/groupBy.spec.ts +0 -0
@@ -1,3 +1,3 @@
1
1
  import { createError } from "brilliant-errors";
2
2
 
3
- export const InferenceError = createError("InferenceError", "inferred-types");
3
+ export const [InferenceError, isInferenceError] = createError("InferenceError", "inferred-types")()()()();
@@ -1,5 +1,5 @@
1
1
  export function randomString() {
2
- return Math.trunc((1 + Math.random()) * 0x10000)
2
+ return Math.trunc((1 + Math.random()) * 0x1_00_00)
3
3
  .toString(16)
4
4
  .slice(1);
5
5
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Define a class constructor; allowing strong typing for constructor's parameters
3
+ * and the returned class structure.
4
+ */
5
+ export type Constructor<Ctor extends any[], Klass extends any> = new (...props: Ctor) => Klass;
package/src/types/Not.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Provides a negation of a type of the type `T` _not_ `U`
2
+ * Provides a negation of a type of the type `T` _not_ `U`.
3
3
  * ```ts
4
4
  * const foo = 42;
5
5
  * // 33
@@ -7,5 +7,7 @@
7
7
  * // never
8
8
  * type NotTheMeaningOfLife = Not<42, 42>;
9
9
  * ```
10
+ *
11
+ * Note: same as `Exclude`
10
12
  */
11
13
  export type Not<T, U> = T extends U ? never : T;
@@ -1,4 +1,4 @@
1
- import { SameKeys } from "./SameKeys";
1
+ import { SameKeys } from "./type-conversion/SameKeys";
2
2
 
3
3
  /**
4
4
  * **Transformer**
@@ -13,4 +13,3 @@ export type Transformer<I extends object, O extends SameKeys<I>, K extends keyof
13
13
  input: I,
14
14
  key: K
15
15
  ) => O[K];
16
-
@@ -0,0 +1,36 @@
1
+ import { Include } from "native-dash";
2
+
3
+ /**
4
+ * Allows filtering down `T` to those which extend a given type `U`.
5
+ *
6
+ * - `T` is either a dictionary (where keys will be used to compare) or
7
+ * a readonly sting array.
8
+ * ```ts
9
+ * const arr = ["foo", "bar", "baz"];
10
+ * // "bar" | "baz"
11
+ * type BA = Where<typeof arr, `ba${string}`>;
12
+ * ```
13
+ */
14
+ export type Where<T extends Record<string, any> | readonly string[], U> = T extends readonly string[]
15
+ ? Include<T[number], U>
16
+ : {
17
+ [K in keyof T]: K extends U ? K : never;
18
+ }[keyof T];
19
+
20
+
21
+ /**
22
+ * Allows filtering down `T` to those which extend a given type `U`.
23
+ *
24
+ * - `T` is either a dictionary (where keys will be used to compare) or
25
+ * a readonly sting array.
26
+ * ```ts
27
+ * const arr = ["foo", "bar", "baz"];
28
+ * // "foo"
29
+ * type F = WhereNot<typeof arr, `ba${string}`>;
30
+ * ```
31
+ */
32
+ export type WhereNot<T extends Record<string, any> | readonly string[], U> = T extends readonly string[]
33
+ ? Exclude<T[number], U>
34
+ : {
35
+ [K in keyof T]: K extends U ? never : K;
36
+ }[keyof T];
@@ -1,5 +1,5 @@
1
1
  /* eslint @typescript-eslint/no-unused-vars: "off" */
2
- import type { Capitalize, LowerAllCaps, Trim } from "~/types";
2
+ import type { LowerAllCaps, Trim } from "~/types";
3
3
 
4
4
  type Delimiter = "_" | "-" | " ";
5
5
 
@@ -10,7 +10,7 @@ type DashDelim<T extends string> = T extends `${infer Begin}${" "}${infer Rest}`
10
10
  ? DashDelim<`${Begin}-${Rest}`>
11
11
  : T;
12
12
 
13
- /**
13
+ /**
14
14
  * Converts a string literal type to a **PascalCase** representation.
15
15
  * ```ts
16
16
  * // "FooBar"
@@ -20,7 +20,8 @@ type DashDelim<T extends string> = T extends `${infer Begin}${" "}${infer Rest}`
20
20
  * type T = PascalCase<"\n foo_bar \t">;
21
21
  * ```
22
22
  */
23
- export type PascalCase<S extends string> = string extends S ? string :
24
- Trim<DashDelim<LowerAllCaps<S>>> extends `${infer Begin}${Delimiter}${infer Rest}`
23
+ export type PascalCase<S extends string> = string extends S
24
+ ? string
25
+ : Trim<DashDelim<LowerAllCaps<S>>> extends `${infer Begin}${Delimiter}${infer Rest}`
25
26
  ? PascalCase<`${Capitalize<Begin>}${Capitalize<Rest>}`>
26
27
  : Capitalize<Trim<LowerAllCaps<S>>>;
@@ -1,9 +1,9 @@
1
1
  // #autoindex, exclude: Alpha
2
2
  // #region autoindexed files
3
3
 
4
- // index last changed at: 7th Jul, 2021, 01:59 PM ( GMT-7 )
4
+ // index last changed at: 12th Dec, 2021, 12:24 PM ( GMT-8 )
5
5
  // export: named; exclusions: Alpha, index, private.
6
- // files: AllCaps, CamelCase, CapFirstAlpha, CapitalizeWords, DashToSnake, DashUppercase, Dasherize, HasUppercase, Intrinsic, IsCapitalized, KebabCase, LowerAllCaps, PascalCase, Pluralize, SnakeCase, alpha-characters.
6
+ // files: AllCaps, CamelCase, CapFirstAlpha, CapitalizeWords, DashToSnake, DashUppercase, Dasherize, HasUppercase, IsCapitalized, KebabCase, LowerAllCaps, PascalCase, Pluralize, SnakeCase, alpha-characters.
7
7
 
8
8
  // local file exports
9
9
  export * from "./AllCaps";
@@ -14,7 +14,6 @@ export * from "./DashToSnake";
14
14
  export * from "./DashUppercase";
15
15
  export * from "./Dasherize";
16
16
  export * from "./HasUppercase";
17
- export * from "./Intrinsic";
18
17
  export * from "./IsCapitalized";
19
18
  export * from "./KebabCase";
20
19
  export * from "./LowerAllCaps";
@@ -26,7 +25,7 @@ export * from "./alpha-characters";
26
25
  // Note:
27
26
  // -----
28
27
  // This file was created by running: "dd devops autoindex"; it assumes you have
29
- // the 'do-devops' pkg installed as a dev dep.
28
+ // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
30
29
  //
31
30
  // By default it assumes that exports are named exports but this can be changed by
32
31
  // adding a modifier to the '// #autoindex' syntax:
@@ -45,7 +44,12 @@ export * from "./alpha-characters";
45
44
  //
46
45
  // - autoindex:named, exclude: foo,bar,baz
47
46
  //
48
- // Also be aware that all of your content outside the defined region in this file
47
+ // Inversely, if you state a file to be an "orphan" then autoindex files
48
+ // below this file will not reference this autoindex file:
49
+ //
50
+ // - autoindex:named, orphan
51
+ //
52
+ // Also be aware that all of your content outside the "// #region" section in this file
49
53
  // will be preserved in situations where you need to do something paricularly awesome.
50
54
  // Keep on being awesome.
51
55
 
@@ -14,8 +14,7 @@ export type ToFluent<
14
14
  X extends object = {}
15
15
  > = {
16
16
  [K in keyof T]: (...args: Parameters<T[K]>) => ToFluent<T, X> & X;
17
- } &
18
- X;
17
+ } & X;
19
18
 
20
19
  /**
21
20
  * A _pure_ Fluent API which promotes an API surface where _every_ API endpoint must be a function
@@ -53,10 +52,10 @@ export type PureFluentApi<
53
52
  * pass out the interior state which has been configured by the fluent parts of the API
54
53
  * - `TExclude` represents part of the API which -- due to the internal state -- should be hidden
55
54
  */
56
- export type FluentApi<
57
- TFluent extends {
58
- [K in keyof TFluent]: (...args: Parameters<TFluent[K]>) => FluentApi<TFluent, TEscape>;
59
- },
60
- TEscape extends object = {},
61
- TExclude extends string = ""
62
- > = Omit<TFluent & TEscape, TExclude>;
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>;
@@ -0,0 +1,42 @@
1
+ // #autoindex
2
+ // #region autoindexed files
3
+
4
+ // index last changed at: 12th Dec, 2021, 12:28 PM ( GMT-8 )
5
+ // export: named; exclusions: index, private.
6
+ // files: fluent.
7
+
8
+ // local file exports
9
+ export * from "./fluent";
10
+
11
+ // Note:
12
+ // -----
13
+ // This file was created by running: "dd devops autoindex"; it assumes you have
14
+ // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
15
+ //
16
+ // By default it assumes that exports are named exports but this can be changed by
17
+ // adding a modifier to the '// #autoindex' syntax:
18
+ //
19
+ // - autoindex:named same as default, exports "named symbols"
20
+ // - autoindex:default assumes each file is exporting a default export
21
+ // and converts the default export to the name of the
22
+ // file
23
+ // - autoindex:offset assumes files export "named symbols" but that each
24
+ // file's symbols should be offset by the file's name
25
+ // (useful for files which might symbols which collide
26
+ // or where the namespacing helps consumers)
27
+ //
28
+ // You may also exclude certain files or directories by adding it to the
29
+ // autoindex command. As an example:
30
+ //
31
+ // - autoindex:named, exclude: foo,bar,baz
32
+ //
33
+ // Inversely, if you state a file to be an "orphan" then autoindex files
34
+ // below this file will not reference this autoindex file:
35
+ //
36
+ // - autoindex:named, orphan
37
+ //
38
+ // Also be aware that all of your content outside the "// #region" section in this file
39
+ // will be preserved in situations where you need to do something paricularly awesome.
40
+ // Keep on being awesome.
41
+
42
+ // #endregion
@@ -1,13 +1,14 @@
1
1
  // #autoindex
2
2
  // #region autoindexed files
3
3
 
4
- // index last changed at: 8th Aug, 2021, 05:44 PM ( GMT-7 )
4
+ // index last changed at: 10th Oct, 2021, 08:32 PM ( GMT-7 )
5
5
  // export: named; exclusions: index, private.
6
- // files: Api, EnumValues, ExpandRecursively, First, FunctionType, If, Include, Includes, KeyedRecord, Keys, Length, Mutable, Narrowable, Not, Numeric, Opaque, Retain, SameKeys, Transformer, TypeGuard, append-types, fluent, maybe, props, ruleset-types, runtime, type-testing.
7
- // directories: alphabetic, dictionary, kv, lists, string-literals, tuples, type-conversion.
6
+ // files: Api, Constructor, EnumValues, ExpandRecursively, First, FunctionType, If, Include, Includes, KeyedRecord, Keys, Length, Mutable, Narrowable, Not, Numeric, Opaque, Retain, Transformer, TypeGuard, Where, append-types, maybe, props, ruleset-types, runtime, type-testing.
7
+ // directories: alphabetic, dictionary, fluent, kv, lists, string-literals, tuples, type-conversion.
8
8
 
9
9
  // local file exports
10
10
  export * from "./Api";
11
+ export * from "./Constructor";
11
12
  export * from "./EnumValues";
12
13
  export * from "./ExpandRecursively";
13
14
  export * from "./First";
@@ -24,11 +25,10 @@ export * from "./Not";
24
25
  export * from "./Numeric";
25
26
  export * from "./Opaque";
26
27
  export * from "./Retain";
27
- export * from "./SameKeys";
28
28
  export * from "./Transformer";
29
29
  export * from "./TypeGuard";
30
+ export * from "./Where";
30
31
  export * from "./append-types";
31
- export * from "./fluent";
32
32
  export * from "./maybe";
33
33
  export * from "./props";
34
34
  export * from "./ruleset-types";
@@ -38,6 +38,7 @@ export * from "./type-testing";
38
38
  // directory exports
39
39
  export * from "./alphabetic/index";
40
40
  export * from "./dictionary/index";
41
+ export * from "./fluent/index";
41
42
  export * from "./kv/index";
42
43
  export * from "./lists/index";
43
44
  export * from "./string-literals/index";
@@ -47,7 +48,7 @@ export * from "./type-conversion/index";
47
48
  // Note:
48
49
  // -----
49
50
  // This file was created by running: "dd devops autoindex"; it assumes you have
50
- // the 'do-devops' pkg installed as a dev dep.
51
+ // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
51
52
  //
52
53
  // By default it assumes that exports are named exports but this can be changed by
53
54
  // adding a modifier to the '// #autoindex' syntax:
@@ -66,7 +67,12 @@ export * from "./type-conversion/index";
66
67
  //
67
68
  // - autoindex:named, exclude: foo,bar,baz
68
69
  //
69
- // Also be aware that all of your content outside the defined region in this file
70
+ // Inversely, if you state a file to be an "orphan" then autoindex files
71
+ // below this file will not reference this autoindex file:
72
+ //
73
+ // - autoindex:named, orphan
74
+ //
75
+ // Also be aware that all of your content outside the "// #region" section in this file
70
76
  // will be preserved in situations where you need to do something paricularly awesome.
71
77
  // Keep on being awesome.
72
78
 
@@ -1,6 +1,6 @@
1
1
  import type { TypeCondition } from "~/utility/runtime/ifTypeOf";
2
2
  import { OptionalKeys } from "./props";
3
- import { SameKeys } from "./SameKeys";
3
+ import { SameKeys } from "./type-conversion/SameKeys";
4
4
 
5
5
  /**
6
6
  * **RuleDefinition**
@@ -0,0 +1,15 @@
1
+ type ValueFunction<T extends any> = <R extends any>(v: T) => R;
2
+
3
+ /**
4
+ * **SameKeys**
5
+ *
6
+ * Given a dictionary `T` and a type-strong wrapper function `F`, returns a dictionary with the
7
+ * same keys but
8
+ *
9
+ * Note: meant to be used as part of an _extends_ clause in most cases.
10
+ */
11
+ export type WrapValue<T extends {}, F extends ValueFunction<T>> = {
12
+ [P in keyof T]: ReturnType<F>;
13
+ };
14
+
15
+
@@ -2,19 +2,21 @@
2
2
 
3
3
  // #region autoindexed files
4
4
 
5
- // index last changed at: 8th Aug, 2021, 04:13 PM ( GMT-7 )
5
+ // index last changed at: 10th Oct, 2021, 08:32 PM ( GMT-7 )
6
6
  // export: named; exclusions: index, private.
7
- // files: TupleToUnion, UnionToIntersection, UnionToTuple.
7
+ // files: SameKeys, TupleToUnion, UnionToIntersection, UnionToTuple, WrapValue.
8
8
 
9
9
  // local file exports
10
+ export * from "./SameKeys";
10
11
  export * from "./TupleToUnion";
11
12
  export * from "./UnionToIntersection";
12
13
  export * from "./UnionToTuple";
14
+ export * from "./WrapValue";
13
15
 
14
16
  // Note:
15
17
  // -----
16
18
  // This file was created by running: "dd devops autoindex"; it assumes you have
17
- // the 'do-devops' pkg installed as a dev dep.
19
+ // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
18
20
  //
19
21
  // By default it assumes that exports are named exports but this can be changed by
20
22
  // adding a modifier to the '// #autoindex' syntax:
@@ -33,7 +35,12 @@ export * from "./UnionToTuple";
33
35
  //
34
36
  // - autoindex:named, exclude: foo,bar,baz
35
37
  //
36
- // Also be aware that all of your content outside the defined region in this file
38
+ // Inversely, if you state a file to be an "orphan" then autoindex files
39
+ // below this file will not reference this autoindex file:
40
+ //
41
+ // - autoindex:named, orphan
42
+ //
43
+ // Also be aware that all of your content outside the "// #region" section in this file
37
44
  // will be preserved in situations where you need to do something paricularly awesome.
38
45
  // Keep on being awesome.
39
46
 
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-use-before-define */
2
+ import { keys } from "~/utility/keys";
2
3
  import { SameKeys, Transformer } from "~/types";
3
- import { kv } from "native-dash";
4
4
 
5
5
  /**
6
6
  * Takes a dictionary of type `I` and converts it to a dictionary of type `O` where
@@ -10,13 +10,12 @@ import { kv } from "native-dash";
10
10
  * and key, and then return expected value of `O` for the given key.
11
11
  */
12
12
  export function dictionaryTransform<I extends object, O extends SameKeys<I>>(
13
- i: I,
13
+ input: I,
14
14
  transform: Transformer<I, O>
15
15
  ) {
16
- const result = {} as any;
17
- for (const pair of kv(i)) {
18
- result[pair.key] = transform(i, pair.key);
19
- }
20
16
 
21
- return result as O;
17
+ return keys(input).reduce((acc, i) => {
18
+ const key = i as string & keyof I;
19
+ return {...acc, [key]: transform(input, key)};
20
+ }, {} as O);
22
21
  }
@@ -0,0 +1,39 @@
1
+ import { Expect, Equal } from "@type-challenges/utils";
2
+ import { Where, WhereNot } from "../src/types/Where";
3
+
4
+ describe("Where<T,U> and WhereNot<T,U> type utility", () => {
5
+
6
+ it("readonly string array works correctly", () => {
7
+ const arr = ["foo", "bar", "baz"] as const;
8
+ type A = typeof arr;
9
+ type B = Where<A, `ba${string}`>;
10
+ type F = WhereNot<A, `ba${string}`>;
11
+
12
+ type cases = [
13
+ //
14
+ Expect<Equal<B, "bar"| "baz">>,
15
+ Expect<Equal<F, "foo">>
16
+ ];
17
+
18
+ const c: cases = [ true, true ];
19
+ expect(c).toBe(c);
20
+ });
21
+
22
+ it("object with literal keys works", () => {
23
+ const arr = {foo: true, bar: true, baz: true} as const;
24
+ type A = typeof arr;
25
+ type B = Where<A, `ba${string}`>;
26
+ type F = WhereNot<A, `ba${string}`>;
27
+
28
+ type cases = [
29
+ //
30
+ Expect<Equal<B, "bar"| "baz">>,
31
+ Expect<Equal<F, "foo">>
32
+ ];
33
+
34
+ const c: cases = [ true, true ];
35
+ expect(c).toBe(c);
36
+ });
37
+
38
+
39
+ });
@@ -0,0 +1,40 @@
1
+ import { Expect, Equal } from "@type-challenges/utils";
2
+ import { Constructor } from "../src/types/Constructor";
3
+
4
+ class TestClass {
5
+ public foo: number;
6
+ public bar: string;
7
+
8
+ constructor(foo: number, bar: string) {
9
+ this.foo = foo;
10
+ this.bar = bar;
11
+ }
12
+ }
13
+
14
+ describe("Constructor<Ctor, Klass>", () => {
15
+ it("simple test", () => {
16
+ type KlassParams = ConstructorParameters<typeof TestClass>;
17
+ type KlassInstance = InstanceType<typeof TestClass>;
18
+ type Synthetic = Constructor<[foo: number, bar: string], TestClass>;
19
+ type SynReturn = InstanceType<Synthetic>;
20
+ const s: Synthetic = TestClass;
21
+
22
+ const myS = new s(1, "bar");
23
+
24
+ const inst = new TestClass(1, "bar");
25
+ type Instance = typeof inst;
26
+
27
+ type cases = [
28
+ // prep
29
+ Expect<Equal<Instance, { foo: number; bar: string }>>,
30
+ Expect<Equal<Instance, KlassInstance>>,
31
+ Expect<Equal<KlassParams, [foo: number, bar: string]>>,
32
+ //
33
+ Expect<Equal<SynReturn, TestClass>>
34
+ ];
35
+
36
+ const c: cases = [true, true, true, true];
37
+ expect(c).toBe(c);
38
+ expect(myS).toBeInstanceOf(TestClass);
39
+ });
40
+ });
@@ -2,14 +2,14 @@
2
2
 
3
3
  // #region autoindexed files
4
4
 
5
- // index last changed at: 9th Sep, 2021, 03:09 PM ( GMT-7 )
5
+ // index last changed at: 12th Dec, 2021, 12:35 PM ( GMT-8 )
6
6
  // export: named; exclusions: index, private.
7
7
 
8
8
 
9
9
  // Note:
10
10
  // -----
11
11
  // This file was created by running: "dd devops autoindex"; it assumes you have
12
- // the 'do-devops' pkg installed as a dev dep.
12
+ // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
13
13
  //
14
14
  // By default it assumes that exports are named exports but this can be changed by
15
15
  // adding a modifier to the '// #autoindex' syntax:
@@ -28,7 +28,12 @@
28
28
  //
29
29
  // - autoindex:named, exclude: foo,bar,baz
30
30
  //
31
- // Also be aware that all of your content outside the defined region in this file
31
+ // Inversely, if you state a file to be an "orphan" then autoindex files
32
+ // below this file will not reference this autoindex file:
33
+ //
34
+ // - autoindex:named, orphan
35
+ //
36
+ // Also be aware that all of your content outside the "// #region" section in this file
32
37
  // will be preserved in situations where you need to do something paricularly awesome.
33
38
  // Keep on being awesome.
34
39
 
@@ -23,10 +23,7 @@ describe("dictToKv()", () => {
23
23
  }
24
24
 
25
25
  type cases = [
26
- Expect<
27
- Equal<
28
- Val,
29
- [
26
+ Expect<Equal<Val, [
30
27
  {
31
28
  key: "id";
32
29
  value: 123;
@@ -35,8 +32,7 @@ describe("dictToKv()", () => {
35
32
  key: "foo";
36
33
  value: "bar";
37
34
  }
38
- ]
39
- >
35
+ ]>
40
36
  >
41
37
  ];
42
38
 
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "module": "commonjs",
4
- "target": "ES2018",
3
+ "module": "ESNEXT",
4
+ "target": "ESNEXT",
5
5
  "moduleResolution": "node",
6
6
 
7
7
  "sourceMap": true,
@@ -16,11 +16,12 @@
16
16
  "noImplicitReturns": true,
17
17
  "allowSyntheticDefaultImports": true,
18
18
 
19
- "lib": ["ES2019"],
19
+ "lib": ["ES2020"],
20
20
 
21
21
  "baseUrl": ".",
22
22
  "declaration": true,
23
23
  "outDir": "dist",
24
+ "tsBuildInfoFile": ".tsbuildinfo",
24
25
 
25
26
  "paths": {
26
27
  "~/*": ["src/*"],
package/dist/cjs/index.js DELETED
@@ -1,21 +0,0 @@
1
- 'use strict';Object.defineProperty(exports,"__esModule",{value:!0});function createMutationFunction(a){return b=>b(a)}function MutationIdentity(){return function(a){return a}}class d extends Error{constructor(){super(...arguments);this.kind="BrilliantError"}}var f={exports:{}};let g=()=>{let a=Error.prepareStackTrace;Error.prepareStackTrace=(a,b)=>b;let b=Error().stack.slice(1);Error.prepareStackTrace=a;return b};f.exports=g;f.exports.default=g;var k=f.exports;
2
- function l(a){return a.map(a=>{let b=(a.getFileName()||"[file unknown]").split("/").slice(-2).join("/"),e=a.getFunctionName()||a.getMethodName()||"unknown";a=a.getLineNumber();return`\t- ${b}, ${e}()${a?`, at line ${a}`:""}`}).join("\n")}
3
- function createError(a,b){class c extends d{constructor(c,m,h={}){super(c);this.kind="BrilliantError";this.name=a;this.origin=b;this.classification=m;this.structuredStack=k().slice(1)||[];this.filename=(this.structuredStack[0].getFileName()||"").split("/").slice(-2).join("/");this.line=this.structuredStack[0].getLineNumber();this.fn=this.structuredStack[0].getMethodName()||this.structuredStack[0].getFunctionName();this.message=`${c} [ ${this.classification} ]\n\n${l(this.structuredStack)}`;h.httpStatusCode&&
4
- (this.httpStatus=h.httpStatusCode)}toJSON(){return{name:this.name,message:this.message,classification:this.classification,origin:this.origin,fn:this.fn,line:this.line,stack:this.structuredStack}}}return c}let InferenceError=createError("InferenceError","inferred-types");function keys$1(a,...b){return 0<b.length?Object.keys(a).filter(a=>!b.includes(a)):Object.keys(a)}function createFnWithProps(a,b){for(let c of keys$1(b))a[c]=b[c];return a}function ruleSet(a){return a}
5
- let api=a=>b=>{const c=()=>b;c.prototype.priv=()=>a;return c};function arrayToKeyLookup(...a){let b={};for(let c of a)b[c]=!0;return b}var DataType;
6
- (function(a){a["null"]="null";a.string="string";a.number="number";a.bigint="bigint";a.symbol="symbol";a["boolean"]="boolean";a["function"]="function";a.undefined="undefined";a.dictionary="dictionary";a.object="object";a.array="array";a.stringArray="string[]";a.numberArray="number[]";a.booleanArray="boolean[]";a.symbolArray="symbol[]";a.functionArray="function[]";a.undefinedArray="undefined[]";a.nullArray="null[]";a.objectArray="object[]";a.dictionaryArray="dictionary[]"})(DataType||(DataType={}));
7
- function keys(a){if(null===a)throw Error("Can not run keys() on a null value!");return Object.keys(a)}function kv$1(a){if("object"!==typeof a||null===a)throw Error("Value passed into kv() must be an object");return keys(a).reduce((b,c)=>{let e=a[c];return[...b,{key:c,value:e}]},[])}function omit(a,...b){return Object.fromEntries(Object.entries(a).filter(([a])=>!b.includes(a)))}var Rule;(function(a){a[a.regex=0]="regex";a[a.fn=1]="fn";a[a.exceptions=2]="exceptions"})(Rule||(Rule={}));var ExplicitRule;
8
- (function(a){a[a.singular=0]="singular";a[a.plural=1]="plural"})(ExplicitRule||(ExplicitRule={}));function dictFilter(a,b){keys$1(a).filter(c=>!b(c,a));return omit(a,...keys$1(a).filter(c=>!b(c,a)))}function dictionaryTransform(a,b){let c={};for(let e of kv$1(a))c[e.key]=b(a,e.key);return c}function entries(a){return{*[Symbol.iterator](){for(const b of keys$1(a))yield[b,a[b]]}}}function mapValues(a,b){return Object.fromEntries([...entries(a)].map(([a,e])=>[a,b(e)]))}
9
- function strArrayToDict(...a){return a.reduce((a,c)=>a={...a,[c]:!0},{})}function valuesOfProp(){}function dictToKv(a,b){return keys$1(a).map(b=>({key:b,value:a[b]}))}function Configurator(){let a=()=>({});return(()=>({set(b,c){b={[b]:c};const e={...a(),...b};a=()=>e;return e},remove(b){const c=a(),e=omit(c,b);a=()=>e;return e},done(){return a()}}))()}
10
- function FluentConfigurator(a={}){let b=a=>({set(c,m){return b({[c]:m,...a})},done(){return a}});if(a&&"object"!==typeof a)throw Error("The FluentConfigurator was passed a non-object based value as the initial value. This is not allowed.");return a?b(a):b({})}function KeyStorage(){let a=b=>({add:(...c)=>a([...b,...c]),remove:c=>a(b.filter(a=>a!==c)),done:()=>b});return a([])}function filterDictArray(a,b){let c=Configurator();return a.filter(a=>{const [e,h]=a;(a=b(e,h))||c.set(e,!0);return a})}
11
- function kv(a,b){return{[a]:b}}function kvToDict(a){let b={};for(let c of a)b[c.key]=c.value;return b}function groupBy(a){throw Error("not implemented");}function ExplicitFunction(a){return a}function arrayToObject(a,b){return c=>!1!==b?c.reduce((b,c)=>({...b,[c[a]]:c}),{}):c.reduce((b,c)=>({...b,[c[a]]:[...b[c[a]]||[],c]}),{})}function defineType(a={}){return(b={})=>a?{...b,...a}:b}let identity=a=>a;function idLiteral(a){return{...a,id:a.id}}function nameLiteral(a){return a}
12
- function kindLiteral(a){return a}function idTypeGuard(a){return!0}function literal(a){return a}let equals=(a,b)=>({kind:"Equals",field:a,val:b}),greater=(a,b)=>({kind:"Greater",field:a,val:b}),less=(a,b)=>({kind:"Less",field:a,val:b}),and=(a,b)=>({kind:"And",a,b}),or=(a,b)=>({kind:"Or",a,b});function Model(a){return{required(b){return Model(a)},optional(b){return Model(a)},done(){return{__model__:a,__kind__:"model"}}}}let condition=(a,b)=>a(b);
13
- function runtimeExtendsCheck(a,b,c=!1){if(typeof a!==typeof b)return!1;switch(typeof a){case "boolean":case "string":case "number":case "symbol":case "bigint":return c?a===b:!0;case "undefined":return!0;case "function":if(c)throw new InferenceError("Use of narrowlyExtends with a function is not possible!","ifTypeOf/not-allowed");return!0;case "object":return null===a&&null===b?!0:keys$1(b).every(e=>runtimeExtendsCheck(a[e],b[e],c))}}
14
- let ifTypeOf=a=>({extends:b=>runtimeExtendsCheck(a,b,!1)?!0:!1,narrowlyExtends:b=>runtimeExtendsCheck(a,b,!0)?!0:!1});function isArray(a){return!0===Array.isArray(a)}function isBoolean(a){return"boolean"===typeof a}function isFalse(a){return"boolean"===typeof a&&!a}function isFunction(a){return"function"===typeof a}function isLiteral(...a){return b=>!a.every(a=>b!==a)}function isNull(a){return null===a}function isNumber(a){return"number"===typeof a}
15
- function isObject(a){return"object"===typeof a&&null!==a&&!1===Array.isArray(a)}function isString(a){return"string"===typeof a}function isSymbol(a){return"symbol"===typeof a}function isTrue(a){return"boolean"===typeof a&&a}function isUndefined(a){return"undefined"===typeof a}
16
- let typeApi=()=>({string:{name:"string",type:"",typeGuard:a=>isString(a),is:isString},boolean:{name:"boolean",type:!0,typeGuard:a=>isBoolean(a),is:isBoolean},number:{name:"number",type:1,typeGuard:a=>isNumber(a),is:isNumber},function:{name:"function",type:Function,typeGuard:a=>isFunction(a),is:isFunction},null:{name:"null",type:null,typeGuard:a=>isNull(a),is:isNull},symbol:{name:"symbol",type:Symbol(),typeGuard:a=>isSymbol(a),is:isSymbol},undefined:{name:"undefined",type:void 0,typeGuard:a=>isUndefined(a),
17
- is:isUndefined},true:{name:"true",type:!0,typeGuard:a=>isTrue(a),is:isTrue},false:{name:"false",type:!1,typeGuard:a=>isFalse(a),is:isFalse},object:{name:"object",type:{},typeGuard:a=>isObject(a),is:isObject},array:{name:"array",type:{},typeGuard:a=>isArray(a),is:isObject}});function isType(a){return"object"===typeof a&&["name","type","is"].every(b=>Object.keys(a).includes(b))}
18
- function type(a){a=a(typeApi());if(!isType(a))throw Error(`When using type(), the callback passed in returned an invalid type! Value returned was: ${a}`);return a}function withValue(a){return b=>{let c=type(a);return Object.fromEntries([...entries(b)].filter(([,a])=>c.typeGuard(a)))}}exports.Configurator=Configurator;exports.ExplicitFunction=ExplicitFunction;exports.FluentConfigurator=FluentConfigurator;exports.InferenceError=InferenceError;exports.KeyStorage=KeyStorage;exports.Model=Model;
19
- exports.MutationIdentity=MutationIdentity;exports.and=and;exports.api=api;exports.arrayToKeyLookup=arrayToKeyLookup;exports.arrayToObject=arrayToObject;exports.condition=condition;exports.createFnWithProps=createFnWithProps;exports.createMutationFunction=createMutationFunction;exports.defineType=defineType;exports.dictFilter=dictFilter;exports.dictToKv=dictToKv;exports.dictionaryTransform=dictionaryTransform;exports.entries=entries;exports.equals=equals;exports.filterDictArray=filterDictArray;
20
- exports.greater=greater;exports.groupBy=groupBy;exports.idLiteral=idLiteral;exports.idTypeGuard=idTypeGuard;exports.identity=identity;exports.ifTypeOf=ifTypeOf;exports.isArray=isArray;exports.isBoolean=isBoolean;exports.isFalse=isFalse;exports.isFunction=isFunction;exports.isLiteral=isLiteral;exports.isNull=isNull;exports.isNumber=isNumber;exports.isObject=isObject;exports.isString=isString;exports.isSymbol=isSymbol;exports.isTrue=isTrue;exports.isType=isType;exports.isUndefined=isUndefined;
21
- exports.keys=keys$1;exports.kindLiteral=kindLiteral;exports.kv=kv;exports.kvToDict=kvToDict;exports.less=less;exports.literal=literal;exports.mapValues=mapValues;exports.nameLiteral=nameLiteral;exports.or=or;exports.ruleSet=ruleSet;exports.strArrayToDict=strArrayToDict;exports.type=type;exports.typeApi=typeApi;exports.valuesOfProp=valuesOfProp;exports.withValue=withValue
package/dist/es/index.js DELETED
@@ -1,17 +0,0 @@
1
- class e extends Error{constructor(){super(...arguments);this.kind="BrilliantError"}}var f={exports:{}};let g=()=>{let a=Error.prepareStackTrace;Error.prepareStackTrace=(a,b)=>b;let b=Error().stack.slice(1);Error.prepareStackTrace=a;return b};f.exports=g;f.exports.default=g;var k=f.exports;
2
- function l(a){return a.map(a=>{let b=(a.getFileName()||"[file unknown]").split("/").slice(-2).join("/"),d=a.getFunctionName()||a.getMethodName()||"unknown";a=a.getLineNumber();return`\t- ${b}, ${d}()${a?`, at line ${a}`:""}`}).join("\n")}
3
- let m=function(a,b){class c extends e{constructor(c,n,h={}){super(c);this.kind="BrilliantError";this.name=a;this.origin=b;this.classification=n;this.structuredStack=k().slice(1)||[];this.filename=(this.structuredStack[0].getFileName()||"").split("/").slice(-2).join("/");this.line=this.structuredStack[0].getLineNumber();this.fn=this.structuredStack[0].getMethodName()||this.structuredStack[0].getFunctionName();this.message=`${c} [ ${this.classification} ]\n\n${l(this.structuredStack)}`;h.httpStatusCode&&
4
- (this.httpStatus=h.httpStatusCode)}toJSON(){return{name:this.name,message:this.message,classification:this.classification,origin:this.origin,fn:this.fn,line:this.line,stack:this.structuredStack}}}return c}("InferenceError","inferred-types");function p(a,...b){return 0<b.length?Object.keys(a).filter(a=>!b.includes(a)):Object.keys(a)}var q,r=q||(q={});r["null"]="null";r.string="string";r.number="number";r.bigint="bigint";r.symbol="symbol";r["boolean"]="boolean";r["function"]="function";
5
- r.undefined="undefined";r.dictionary="dictionary";r.object="object";r.array="array";r.stringArray="string[]";r.numberArray="number[]";r.booleanArray="boolean[]";r.symbolArray="symbol[]";r.functionArray="function[]";r.undefinedArray="undefined[]";r.nullArray="null[]";r.objectArray="object[]";r.dictionaryArray="dictionary[]";
6
- function t(a){if("object"!==typeof a||null===a)throw Error("Value passed into kv() must be an object");if(null===a)throw Error("Can not run keys() on a null value!");return Object.keys(a).reduce((b,c)=>{let d=a[c];return[...b,{key:c,value:d}]},[])}function u(a,...b){return Object.fromEntries(Object.entries(a).filter(([a])=>!b.includes(a)))}var v,w=v||(v={});w[w.regex=0]="regex";w[w.fn=1]="fn";w[w.exceptions=2]="exceptions";var x,y=x||(x={});y[y.singular=0]="singular";y[y.plural=1]="plural";
7
- function z(a){return{*[Symbol.iterator](){for(const b of p(a))yield[b,a[b]]}}}function A(){let a=()=>({});return(()=>({set(b,c){b={[b]:c};const d={...a(),...b};a=()=>d;return d},remove(b){const c=a(),d=u(c,b);a=()=>d;return d},done(){return a()}}))()}function B(a){return{required(){return B(a)},optional(){return B(a)},done(){return{__model__:a,__kind__:"model"}}}}
8
- function C(a,b,c=!1){if(typeof a!==typeof b)return!1;switch(typeof a){case "boolean":case "string":case "number":case "symbol":case "bigint":return c?a===b:!0;case "undefined":return!0;case "function":if(c)throw new m("Use of narrowlyExtends with a function is not possible!","ifTypeOf/not-allowed");return!0;case "object":return null===a&&null===b?!0:p(b).every(d=>C(a[d],b[d],c))}}function D(a){return!0===Array.isArray(a)}function E(a){return"boolean"===typeof a}
9
- function F(a){return"boolean"===typeof a&&!a}function G(a){return"function"===typeof a}function H(a){return null===a}function I(a){return"number"===typeof a}function J(a){return"object"===typeof a&&null!==a&&!1===Array.isArray(a)}function K(a){return"string"===typeof a}function L(a){return"symbol"===typeof a}function M(a){return"boolean"===typeof a&&a}function N(a){return"undefined"===typeof a}
10
- let O=()=>({string:{name:"string",type:"",typeGuard:a=>K(a),is:K},boolean:{name:"boolean",type:!0,typeGuard:a=>E(a),is:E},number:{name:"number",type:1,typeGuard:a=>I(a),is:I},function:{name:"function",type:Function,typeGuard:a=>G(a),is:G},null:{name:"null",type:null,typeGuard:a=>null===a,is:H},symbol:{name:"symbol",type:Symbol(),typeGuard:a=>L(a),is:L},undefined:{name:"undefined",type:void 0,typeGuard:a=>N(a),is:N},true:{name:"true",type:!0,typeGuard:a=>M(a),is:M},false:{name:"false",type:!1,typeGuard:a=>
11
- F(a),is:F},object:{name:"object",type:{},typeGuard:a=>J(a),is:J},array:{name:"array",type:{},typeGuard:a=>D(a),is:J}});function P(a){return"object"===typeof a&&["name","type","is"].every(b=>Object.keys(a).includes(b))}function Q(a){a=a(O());if(!P(a))throw Error(`When using type(), the callback passed in returned an invalid type! Value returned was: ${a}`);return a}function ExplicitFunction(a){return a};
12
- function FluentConfigurator(a={}){let b=a=>({set(c,n){return b({[c]:n,...a})},done(){return a}});if(a&&"object"!==typeof a)throw Error("The FluentConfigurator was passed a non-object based value as the initial value. This is not allowed.");return a?b(a):b({})};function KeyStorage(){let a=b=>({add:(...c)=>a([...b,...c]),remove:c=>a(b.filter(a=>a!==c)),done:()=>b});return a([])};function MutationIdentity(){return function(a){return a}};
13
- var and=(a,b)=>({kind:"And",a,b});var api=a=>b=>{const c=()=>b;c.prototype.priv=()=>a;return c};function arrayToKeyLookup(...a){let b={};for(let c of a)b[c]=!0;return b};function arrayToObject(a,b){return c=>!1!==b?c.reduce((b,c)=>({...b,[c[a]]:c}),{}):c.reduce((b,c)=>({...b,[c[a]]:[...b[c[a]]||[],c]}),{})};var condition=(a,b)=>a(b);function createFnWithProps(a,b){for(let c of p(b))a[c]=b[c];return a};function createMutationFunction(a){return b=>b(a)};
14
- function defineType(a={}){return(b={})=>a?{...b,...a}:b};function dictFilter(a,b){p(a).filter(c=>!b(c,a));return u(a,...p(a).filter(c=>!b(c,a)))};function dictToKv(a){return p(a).map(b=>({key:b,value:a[b]}))};function dictionaryTransform(a,b){let c={};for(let d of t(a))c[d.key]=b(a,d.key);return c};var equals=(a,b)=>({kind:"Equals",field:a,val:b});
15
- function filterDictArray(a,b){let c=A();return a.filter(a=>{const [d,h]=a;(a=b(d,h))||c.set(d,!0);return a})};var greater=(a,b)=>({kind:"Greater",field:a,val:b});function groupBy(){throw Error("not implemented");};function idLiteral(a){return{...a,id:a.id}};function idTypeGuard(){return!0};var identity=a=>a;var ifTypeOf=a=>({extends:b=>C(a,b,!1)?!0:!1,narrowlyExtends:b=>C(a,b,!0)?!0:!1});
16
- function isLiteral(...a){return b=>!a.every(a=>b!==a)};function kindLiteral(a){return a};function kv(a,b){return{[a]:b}};function kvToDict(a){let b={};for(let c of a)b[c.key]=c.value;return b};var less=(a,b)=>({kind:"Less",field:a,val:b});function literal(a){return a};
17
- function mapValues(a,b){return Object.fromEntries([...z(a)].map(([a,d])=>[a,b(d)]))};function nameLiteral(a){return a};var or=(a,b)=>({kind:"Or",a,b});function ruleSet(a){return a};function strArrayToDict(...a){return a.reduce((a,c)=>a={...a,[c]:!0},{})};function valuesOfProp(){};function withValue(a){return b=>{let c=Q(a);return Object.fromEntries([...z(b)].filter(([,a])=>c.typeGuard(a)))}};export{A as Configurator,ExplicitFunction,FluentConfigurator,m as InferenceError,KeyStorage,B as Model,MutationIdentity,and,api,arrayToKeyLookup,arrayToObject,condition,createFnWithProps,createMutationFunction,defineType,dictFilter,dictToKv,dictionaryTransform,z as entries,equals,filterDictArray,greater,groupBy,idLiteral,idTypeGuard,identity,ifTypeOf,D as isArray,E as isBoolean,F as isFalse,G as isFunction,isLiteral,H as isNull,I as isNumber,J as isObject,K as isString,L as isSymbol,M as isTrue,P as isType,N as isUndefined,p as keys,kindLiteral,kv,kvToDict,less,literal,mapValues,nameLiteral,or,ruleSet,strArrayToDict,Q as type,O as typeApi,valuesOfProp,withValue}