inferred-types 0.27.0 → 0.28.0

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.
@@ -3,8 +3,12 @@
3
3
  "editor.formatOnSave": true,
4
4
  "cSpell.words": [
5
5
  "Aint",
6
+ "appr",
7
+ "barbar",
6
8
  "Dasherize",
7
9
  "dasherized",
10
+ "Decomp",
11
+ "foofoo",
8
12
  "fooy",
9
13
  "ruleset",
10
14
  "tokei",
package/dist/index.d.ts CHANGED
@@ -215,11 +215,213 @@ declare type Keys<T extends Record<string, any> | readonly string[], W extends s
215
215
  */
216
216
  declare type Length<T extends readonly any[]> = T["length"];
217
217
 
218
+ /**
219
+ * Converts a Tuple type into a _union_ of the tuple elements
220
+ * ```ts
221
+ * const arr = [1, 3, 5] as const;
222
+ * // 1 | 3 | 5
223
+ * type U = TupleToUnion<typeof arr>;
224
+ * ```
225
+ */
226
+ declare type TupleToUnion<T> = Mutable<T> extends any[] ? Mutable<T>[number] : never;
227
+
228
+ /**
229
+ * UnionToIntersection<{ foo: string } | { bar: string }> =
230
+ * { foo: string } & { bar: string }.
231
+ */
232
+ declare type UnionToIntersection<U> = (U extends unknown ? (arg: U) => 0 : never) extends (arg: infer I) => 0 ? I : never;
233
+
234
+ /**
235
+ * LastInUnion<1 | 2> = 2.
236
+ */
237
+ declare type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
238
+ /**
239
+ * UnionToTuple<1 | 2> = [1, 2].
240
+ */
241
+ declare type UnionToTuple<U, Last = LastInUnion<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, Last>>, Last];
242
+
243
+ declare type Widen<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
244
+
245
+ /**
246
+ * **IsBooleanLiteral**
247
+ *
248
+ * Type utility which returns true/false if the boolean value is a _boolean literal_ versus
249
+ * just the wider _boolean_ type.
250
+ */
251
+ declare type IsBooleanLiteral<T extends boolean> = boolean extends T ? false : true;
252
+ /**
253
+ * **IfBooleanLiteral**
254
+ *
255
+ * Branch utility which returns `IF` type when `T` is a boolean literal and `ELSE` otherwise
256
+ */
257
+ declare type IfBooleanLiteral<T extends boolean, IF, ELSE> = IsBooleanLiteral<T> extends true ? IF : ELSE;
258
+
259
+ /**
260
+ * **IsStringLiteral**
261
+ *
262
+ * Type utility which returns true/false if the string a _string literal_ versus
263
+ * just the _string_ type.
264
+ */
265
+ declare type IsStringLiteral<T extends string> = string extends T ? false : true;
266
+ /**
267
+ * **IfStringLiteral**
268
+ *
269
+ * Branch utility which returns `IF` type when `T` is a string literal and `ELSE` otherwise
270
+ */
271
+ declare type IfStringLiteral<T extends string, IF, ELSE> = IsStringLiteral<T> extends true ? IF : ELSE;
272
+
273
+ /**
274
+ * **IsNumericLiteral**
275
+ *
276
+ * Type utility which returns true/false if the numeric value a _numeric literal_ versus
277
+ * just the _number_ type.
278
+ */
279
+ declare type IsNumericLiteral<T extends number> = number extends T ? false : true;
280
+ /**
281
+ * **IfNumericLiteral**
282
+ *
283
+ * Branch utility which returns `IF` type when `T` is a numeric literal and `ELSE` otherwise
284
+ */
285
+ declare type IfNumericLiteral<T extends number, IF, ELSE> = IsNumericLiteral<T> extends true ? IF : ELSE;
286
+
287
+ /**
288
+ * **IsLiteral**
289
+ *
290
+ * Type utility which returns true/false if the value passed -- a form of a
291
+ * string, number, or boolean -- is a _literal_ value of that type (true) or
292
+ * the more generic wide type (false).
293
+ */
294
+ declare type IsLiteral<T> = [T] extends [string] ? IsStringLiteral<T> : [T] extends [boolean] ? IsBooleanLiteral<T> : [T] extends [number] ? IsNumericLiteral<T> : false;
295
+ /**
296
+ * **IsOptionalLiteral**
297
+ *
298
+ * Type utility which returns true/false if the value passed -- a form of a
299
+ * string, number, or boolean -- is a _literal_ value of that type (true) or
300
+ * the more generic wide type (false).
301
+ *
302
+ * This type also strips off _undefined_ from any possible union type to evaluate
303
+ * to `true` even when a literal value is in union with _undefined_. If you don't
304
+ * want to test for the union with _undefined_ use the `IsOptional` utility instead.
305
+ */
306
+ declare type IsOptionalLiteral<T> = [Exclude<T, undefined>] extends [string] ? IsStringLiteral<Exclude<T, undefined>> : [Exclude<T, undefined>] extends [boolean] ? IsBooleanLiteral<Exclude<T, undefined>> : [Exclude<T, undefined>] extends [number] ? IsNumericLiteral<Exclude<T, undefined>> : false;
307
+ /**
308
+ * **IfLiteral**
309
+ *
310
+ * Branch type utility with return `IF` when `T` is a _literal_ value and `ELSE` otherwise
311
+ */
312
+ declare type IfLiteral<T, IF, ELSE> = IsLiteral<T> extends true ? IF : ELSE;
313
+ /**
314
+ * **IfOptionalLiteral**
315
+ *
316
+ * Branch type utility with return `IF` when `T` is a _literal_ value (with possibly
317
+ * the inclusion of _undefined_); otherwise returns the type `ELSE`
318
+ */
319
+ declare type IfOptionalLiteral<T, IF, ELSE> = IsOptionalLiteral<T> extends true ? IF : ELSE;
320
+
321
+ /**
322
+ * **Includes<TSource, TValue>**
323
+ *
324
+ * Type utility which returns `true` or `false` based on whether `TValue` is found
325
+ * in `TSource`. Where `TSource` can be a string literal or an array of string literals.
326
+ *
327
+ * **Note:** if the source is a _wide_ type (aka, `string` or `string[]`) then there is
328
+ * no way to know at design-time whether the value includes `TValue` and so it will return
329
+ * a type of `boolean`.
330
+ */
331
+ declare type Includes<TSource extends string | string[], TValue extends string> = TSource extends string[] ? IsStringLiteral<TupleToUnion<TSource>> extends true ? IsLiteral<TValue> extends true ? TValue extends TupleToUnion<TSource> ? true : false : boolean : boolean : TSource extends string ? IsLiteral<TSource> extends true ? IsLiteral<TValue> extends true ? TSource extends `${string}${TValue}${string}` ? true : false : boolean : boolean : boolean;
332
+
333
+ declare type IsScalar<T> = [T] extends [string] ? true : [T] extends [number] ? true : [T] extends [boolean] ? true : false;
334
+ /**
335
+ * **IfScalar**
336
+ *
337
+ * Branch type utility which returns `IF` when `T` is a scalar value and `ELSE` otherwise
338
+ */
339
+ declare type IfScalar<T, IF, ELSE> = IsScalar<T> extends true ? IF : ELSE;
340
+
341
+ /**
342
+ * **Extends**
343
+ *
344
+ * Boolean type utility which returns `true` if `E` _extends_ `T`.
345
+ */
346
+ declare type Extends<E, T> = E extends T ? true : false;
347
+ /**
348
+ * **IfExtends**
349
+ *
350
+ * Branching type utility which returns type `IF` when `E` _extends_ `T`; otherwise
351
+ * it will return the type `ELSE`.
352
+ */
353
+ declare type IfExtends<E, T, IF, ELSE> = Extends<E, T> extends true ? IF : ELSE;
354
+
355
+ /**
356
+ * Often when mutating the shape of an object you will end up with the union of a number of
357
+ * `Record<string, x>` and `Record<string, y>` which is messy to look at and take away meaning.
358
+ *
359
+ * This type utility will cleanup an object and return a simple dictionary definition for it.
360
+ */
361
+ declare type SimplifyObject<T extends {}> = ExpandRecursively<UnionToIntersection<ExpandRecursively<T>>>;
362
+
363
+ /**
364
+ * **IsUndefined**
365
+ *
366
+ * Boolean type utility returns `true` if `T` is undefined; `false` otherwise
367
+ */
368
+ declare type IsUndefined<T> = T extends undefined ? true : false;
369
+ /**
370
+ * **IfUndefined**
371
+ *
372
+ * Branch utility which returns `IF` type when `T` is an _undefined_ value
373
+ * otherwise returns `ELSE` type
374
+ */
375
+ declare type IfUndefined<T, IF, ELSE> = IsUndefined<T> extends true ? IF : ELSE;
376
+
377
+ /**
378
+ * **TypeDefault**
379
+ *
380
+ * A type utility designed to help maintain strong and narrow types where
381
+ * you have a value `T` which _might_ be **undefined** and a type `D` which
382
+ * defines all the _default_ type for `T`.
383
+ *
384
+ * - In all cases we compare first whether `T` is undefined and replace it's
385
+ * type with `D` 1-for-1 if it is
386
+ * - To address a larger set of use cases, when `D` _extends_ an object we will
387
+ * compare each property of `D` against `T`
388
+ * ```ts
389
+ * type I = { foo?: "foo" | undefined; bar?: 42 | 53 | undefined };
390
+ * type D = { foo: "foo"; bar: 53 };
391
+ * type DF = TypeDefault<I,D>; // `D`
392
+ * const i = { foo: undefined, bar: 99 } as const;
393
+ * type DF2 = TypeDefault<typeof i, D>; // `{ foo: "foo"; bar: 99 }`
394
+ * ```
395
+ */
396
+ declare type TypeDefault<T, D> = IsObject<D> extends true ? IsObject<T> extends true ? SimplifyObject<{
397
+ [K in keyof D]: K extends keyof T ? TypeDefault<T[K], D[K]> : D[K];
398
+ }> : IfUndefined<T, // check if T is undefined
399
+ D, // use D as the type
400
+ Exclude<T, undefined>> : IfUndefined<T, // check whether is T is undefined
401
+ D, // assign to D if it is
402
+ IfOptionalLiteral<T, // if T is a literal
403
+ IfExtends<D, T, D, // use D since it extends the value of T
404
+ Exclude<T, undefined>>, Exclude<T, undefined>>>;
405
+
406
+ /**
407
+ * **IsObject**
408
+ *
409
+ * Boolean type utility used to check whether a type `T` is an object
410
+ */
411
+ declare type IsObject<T> = Mutable<T> extends Record<string, any> ? T extends FunctionType ? false : Mutable<T> extends any[] ? false : true : false;
412
+ /**
413
+ * **IfObject**
414
+ *
415
+ * Branch type utility with return `IF` when `T` extends an object type
416
+ * and `ELSE` otherwise
417
+ */
418
+ declare type IfObject<T, IF, ELSE> = IsObject<T> extends true ? IF : ELSE;
419
+
218
420
  /**
219
421
  * Makes a readonly structure mutable
220
422
  */
221
423
  declare type Mutable<T> = {
222
- -readonly [K in keyof T]: T[K];
424
+ -readonly [K in keyof T]: IsObject<T[K]> extends true ? Mutable<T[K]> : T[K];
223
425
  };
224
426
 
225
427
  /**
@@ -279,20 +481,6 @@ declare type Opaque<Type, Token = unknown> = Type & {
279
481
  */
280
482
  declare type Retain<T, K extends keyof T> = Pick<T, Include<keyof T, K>>;
281
483
 
282
- /**
283
- * UnionToIntersection<{ foo: string } | { bar: string }> =
284
- * { foo: string } & { bar: string }.
285
- */
286
- declare type UnionToIntersection<U> = (U extends unknown ? (arg: U) => 0 : never) extends (arg: infer I) => 0 ? I : never;
287
-
288
- /**
289
- * Often when mutating the shape of an object you will end up with the union of a number of
290
- * `Record<string, x>` and `Record<string, y>` which is messy to look at and take away meaning.
291
- *
292
- * This type utility will cleanup an object and return a simple dictionary definition for it.
293
- */
294
- declare type SimplifyObject<T extends {}> = ExpandRecursively<UnionToIntersection<ExpandRecursively<T>>>;
295
-
296
484
  /**
297
485
  * **SameKeys**
298
486
  *
@@ -429,7 +617,6 @@ declare function isNull<T>(i: T): T extends null ? true : false;
429
617
 
430
618
  declare function isNumber<T>(i: T): T extends number ? true : false;
431
619
 
432
- declare type IsObject<T> = Mutable<T> extends Record<string, any> ? T extends FunctionType ? false : Mutable<T> extends any[] ? false : true : false;
433
620
  declare type ObjectType = Not<Record<string, Narrowable>, FunctionType>;
434
621
  /**
435
622
  * Detects whether the passed in `v` is of type "object" where an object
@@ -583,10 +770,49 @@ declare type Get<T, K> = K extends `${infer FK}.${infer L}` ? FK extends keyof T
583
770
  */
584
771
  declare type OptRequired = "opt" | "req";
585
772
 
773
+ declare const DEFAULT_ONE_TO_MANY_MAPPING: FinalizedMapConfig<"req", "I -> O[]", "opt">;
774
+ declare const DEFAULT_ONE_TO_ONE_MAPPING: FinalizedMapConfig<"req", "I -> O", "req">;
775
+ declare const DEFAULT_MANY_TO_ONE_MAPPING: FinalizedMapConfig<"req", "I[] -> O", "req">;
776
+ declare type DefaultOneToManyMapping = typeof DEFAULT_ONE_TO_MANY_MAPPING;
777
+ declare type DefaultOneToOneMapping = typeof DEFAULT_ONE_TO_ONE_MAPPING;
778
+ declare type DefaultManyToOneMapping = typeof DEFAULT_MANY_TO_ONE_MAPPING;
779
+ /**
780
+ * **mapTo** _utility_
781
+ *
782
+ * This utility -- by default -- creates a strongly typed 1:M data mapper which maps from one
783
+ * known source `I` to any array of another `O[]`:
784
+ * ```ts
785
+ * const mapper = mapTo<I, O>(i => [{
786
+ * foo: i.bar
787
+ * }]);
788
+ * ```
789
+ */
790
+ declare const mapToFn: ConfiguredMap<DefaultOneToManyMapping>["map"];
791
+ /**
792
+ * Provides a `config` method which allows the relationships between _inputs_
793
+ * and _outputs_ to be configured.
794
+ */
795
+ declare const mapToDict: MapperApi;
796
+ /**
797
+ * **mapTo** _utility_
798
+ *
799
+ * This utility creates a strongly typed data mapper which maps from one
800
+ * known source `I` to another `O`.
801
+ *
802
+ * Signatures:
803
+ * ```ts
804
+ * const defMap = mapTo<I,O>( ... );
805
+ * const configured = mapTo.config({ output: "req" }).map<I,O>( ... );
806
+ * const one2one = mapTo.oneToOne().map<I,O>( ... );
807
+ * const many2one = mapTo.manyToOne().map<I,O>( ... );
808
+ * ```
809
+ */
810
+ declare const mapTo: (<I, O>(map: (source: I) => O[]) => <S extends I | I[]>(source: S) => S extends I[] ? O[] : O[] | null) & MapperApi;
811
+
586
812
  /**
587
813
  * Expresses relationship between inputs/outputs:
588
814
  */
589
- declare enum MapDirection {
815
+ declare enum MapCardinality {
590
816
  /** every input results in 0:M outputs */
591
817
  OneToMany = "I -> O[]",
592
818
  /** every input results in 0:1 outputs */
@@ -594,9 +820,110 @@ declare enum MapDirection {
594
820
  /** every input is an array of type I and reduced to a single O */
595
821
  ManyToOne = "I[] -> O"
596
822
  }
597
- declare type MapDirectionVal = EnumValues<MapDirection>;
598
- declare type MapInput<I, IR, D extends MapDirectionVal> = D extends MapDirection.OneToMany | "I -> O[]" ? IR extends "opt" ? I | undefined : I : D extends MapDirection.OneToOne | "I -> O" ? IR extends "opt" ? I | undefined : I : D extends MapDirection.ManyToOne | "I[] -> O" ? IR extends "opt" ? I[] | undefined : I[] : never;
599
- declare type MapOutput<O, OR, D extends MapDirectionVal> = D extends MapDirection.OneToMany | "I -> O[]" ? OR extends "opt" ? O[] : [O, ...O[]] : D extends MapDirection.OneToOne | "I -> O" ? OR extends "opt" ? O | null : O : D extends MapDirection.ManyToOne | "I[] -> O" ? OR extends "opt" ? O | null : O : never;
823
+ declare type MapCardinalityIllustrated = EnumValues<MapCardinality>;
824
+ /**
825
+ * The _user_ configuration of a **mapTo** mapper function
826
+ * which will be finalized by merging it with the appropriate
827
+ * default mapping type.
828
+ */
829
+ interface MapConfig<IR extends OptRequired | undefined = undefined, D extends MapCardinalityIllustrated | undefined = undefined, OR extends OptRequired | undefined = undefined> {
830
+ input?: IR;
831
+ output?: OR;
832
+ cardinality?: D;
833
+ }
834
+ /**
835
+ * A finalized configuration of a **mapTo** mapper functions cardinality
836
+ * relationships between _inputs_ and _outputs_.
837
+ *
838
+ * Note: _this configuration does _not_ yet include the actual mapping
839
+ * configuration between the input and output._
840
+ */
841
+ declare type FinalizedMapConfig<IR extends OptRequired, D extends MapCardinalityIllustrated, OR extends OptRequired> = Required<MapConfig<IR, D, OR>> & {
842
+ finalized: true;
843
+ };
844
+ /**
845
+ * User configuration exposed by a config function which specifies the
846
+ * cardinality already (e.g., `oneToMany()`, `manyToOne()`)
847
+ */
848
+ declare type MapCardinalityConfig<IR extends OptRequired | undefined, OR extends OptRequired | undefined> = {
849
+ input?: IR;
850
+ output?: OR;
851
+ };
852
+ /**
853
+ * **ConfiguredMap**
854
+ *
855
+ * A partial application of the mapTo() utility which has expressed the
856
+ * configuration of the _inputs_ and _outputs_ and provides a `.map()`
857
+ * method which allows the user configure the specifics of the mapping.
858
+ */
859
+ declare type ConfiguredMap<C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = {
860
+ map: <I, O>(map: MapTo<I, O, C>) => MapFn<I, O, C>;
861
+ input: MapIR<C>;
862
+ cardinality: MapCard<C>;
863
+ output: MapOR<C>;
864
+ };
865
+ /**
866
+ * Extracts the IR, Cardinality, and OR generics from a FinalizedMapConfig
867
+ */
868
+ declare type DecomposeMapConfig<M extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = M extends MapConfig<infer IR, infer D, infer OR> ? IR extends OptRequired | undefined ? D extends MapCardinalityIllustrated | undefined ? OR extends OptRequired | undefined ? [IR, D, OR] : never : never : never : M extends FinalizedMapConfig<infer IR, infer D, infer OR> ? IR extends OptRequired ? D extends MapCardinalityIllustrated ? OR extends OptRequired ? [IR, D, OR] : never : never : never : never;
869
+ /** extracts IR from a `FinalizedMapConfig` */
870
+ declare type MapIR<T extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = DecomposeMapConfig<T>[0];
871
+ /**
872
+ * extracts the MapCardinality from a `FinalizedMapConfig`
873
+ */
874
+ declare type MapCard<T extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = DecomposeMapConfig<T>[1];
875
+ /** extracts OR from a `FinalizedMapConfig` */
876
+ declare type MapOR<T extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = DecomposeMapConfig<T>[2];
877
+ /**
878
+ * Merges the types of a userland configuration with a default configuration
879
+ */
880
+ declare type AsFinalizedConfig<U extends MapConfig<OptRequired | undefined, MapCardinalityIllustrated | undefined, OptRequired | undefined>, D extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = TypeDefault<U, D> extends FinalizedMapConfig<infer IR, infer C, infer OR> ? FinalizedMapConfig<IR, C, OR> : never;
881
+ declare type MapperApi = {
882
+ /**
883
+ * Provides opportunity to configure _input_, _output_, and _cardinality_
884
+ * prior to providing a mapping function.
885
+ *
886
+ * Note: _the defaults for configuration are defined by the_ `DEFAULT_ONE_TO_MANY_MAPPING`
887
+ * _constant made available as a symbol from this library._
888
+ */
889
+ config: <C extends MapConfig<OptRequired, //
890
+ MapCardinalityIllustrated, OptRequired>>(config: C) => ConfiguredMap<AsFinalizedConfig<C, //
891
+ DefaultOneToManyMapping>>;
892
+ /**
893
+ * Provides a nice 1:1 ratio between the input and output.
894
+ *
895
+ * By default the input and output are considered to be _required_
896
+ * properties but this can be changed with the options hash provided.
897
+ * ```ts
898
+ * const mapper = mapTo.oneToOne().map(...);
899
+ * // add in ability to filter out some inputs
900
+ * const mapAndFilter = mapTo.oneToOne({ output: "opt" })
901
+ * ```
902
+ */
903
+ oneToOne: <C extends MapCardinalityConfig<OptRequired, OptRequired>>(config?: C) => ConfiguredMap<AsFinalizedConfig<C, //
904
+ DefaultOneToOneMapping>>;
905
+ /**
906
+ * **manyToOne** _mapping_
907
+ *
908
+ * Provides a configuration where multiple inputs `I[]` will be mapped to a
909
+ * single output `O`.
910
+ *
911
+ * Choosing this configuration will, by default, set both input and output
912
+ * to be "required" but you can change this default if you so choose.
913
+ */
914
+ manyToOne: <C extends MapCardinalityConfig<OptRequired | undefined, //
915
+ //
916
+ OptRequired | undefined>>(config?: C) => ConfiguredMap<AsFinalizedConfig<C, //
917
+ DefaultManyToOneMapping>>;
918
+ oneToMany: <C extends MapCardinalityConfig<OptRequired | undefined, //
919
+ //
920
+ OptRequired | undefined>>(config?: C) => ConfiguredMap<AsFinalizedConfig<C, //
921
+ DefaultOneToManyMapping>>;
922
+ };
923
+ declare type MapInput<I, //
924
+ IR extends OptRequired, C extends MapCardinalityIllustrated> = C extends MapCardinality.OneToMany | "I -> O[]" ? IR extends "opt" ? I | undefined : I : C extends MapCardinality.OneToOne | "I -> O" ? IR extends "opt" ? I | undefined : I : C extends MapCardinality.ManyToOne | "I[] -> O" ? IR extends "opt" ? I[] | undefined : I[] : never;
925
+ declare type MapOutput<O, //
926
+ OR extends OptRequired, C extends MapCardinalityIllustrated> = C extends MapCardinality.OneToMany | "I -> O[]" ? OR extends "opt" ? O[] : [O, ...O[]] : C extends MapCardinality.OneToOne | "I -> O" ? OR extends "opt" ? O | null : O : C extends MapCardinality.ManyToOne | "I[] -> O" ? OR extends "opt" ? O | null : O : never;
600
927
  /**
601
928
  * **MapTo<I, O>**
602
929
  *
@@ -605,9 +932,9 @@ declare type MapOutput<O, OR, D extends MapDirectionVal> = D extends MapDirectio
605
932
  * **Note:** this type is designed to guide the userland mapping; refer
606
933
  * to `MapFn` if you want the type output by the `mapFn()` utility.
607
934
  */
608
- declare type MapTo<I, O, IR extends OptRequired = "req", D extends MapDirectionVal = MapDirection.OneToMany, OR extends OptRequired = "opt"> = IR extends "opt" ? (source?: MapInput<I, IR, D>) => MapOutput<O, OR, D> : (source: MapInput<I, IR, D>) => MapOutput<O, OR, D>;
609
- declare type MapFnOutput<I, O, S, OR extends OptRequired, D extends MapDirectionVal> = D extends "I -> O[]" | MapDirection.OneToMany ? S extends I[] ? OR extends "opt" ? O[] : [O, ...O[]] : OR extends "opt" ? O[] | null : O[] : D extends MapDirection.OneToOne | "I -> O" ? S extends I[] ? OR extends "opt" ? O[] : [O, ...O[]] : OR extends "opt" ? O | null : O : D extends MapDirection.ManyToOne | "I[] -> O" ? S extends I[][] ? OR extends "opt" ? O[] : [O, ...O[]] : OR extends "opt" ? O | null : O : never;
610
- declare type MapFnInput<I, IR extends OptRequired, D extends MapDirectionVal> = D extends "I -> O[]" | MapDirection.OneToMany ? IR extends "opt" ? I | I[] | undefined : I | I[] : D extends MapDirection.OneToOne | "I -> O" ? IR extends "opt" ? I | I[] | undefined : I | I[] : D extends MapDirection.ManyToOne | "I[] -> O" ? IR extends "opt" ? I[] | I[][] | undefined : I[] | I[][] : never;
935
+ declare type MapTo<I, O, C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = MapIR<C> extends "opt" ? (source?: MapInput<I, MapIR<C>, MapCard<C>>) => MapOutput<O, MapOR<C>, MapCard<C>> : (source: MapInput<I, MapIR<C>, MapCard<C>>) => MapOutput<O, MapOR<C>, MapCard<C>>;
936
+ declare type MapFnOutput<I, O, S, OR extends OptRequired, C extends MapCardinalityIllustrated> = C extends "I -> O[]" | MapCardinality.OneToMany ? S extends I[] ? OR extends "opt" ? O[] : [O, ...O[]] : OR extends "opt" ? O[] | null : O[] : C extends MapCardinality.OneToOne | "I -> O" ? S extends I[] ? OR extends "opt" ? O[] : [O, ...O[]] : OR extends "opt" ? O | null : O : C extends MapCardinality.ManyToOne | "I[] -> O" ? S extends I[][] ? OR extends "opt" ? O[] : [O, ...O[]] : OR extends "opt" ? O | null : O : never;
937
+ declare type MapFnInput<I, IR extends OptRequired, D extends MapCardinalityIllustrated> = D extends "I -> O[]" | MapCardinality.OneToMany ? IR extends "opt" ? I | I[] | undefined : I | I[] : D extends MapCardinality.OneToOne | "I -> O" ? IR extends "opt" ? I | I[] | undefined : I | I[] : D extends MapCardinality.ManyToOne | "I[] -> O" ? IR extends "opt" ? I[] | I[][] | undefined : I[] | I[][] : never;
611
938
  /**
612
939
  * The mapping function provided by the `mapFn()` utility. This _fn_
613
940
  * is intended to be used in two ways:
@@ -620,11 +947,11 @@ declare type MapFnInput<I, IR extends OptRequired, D extends MapDirectionVal> =
620
947
  * ```
621
948
  * 2. Block:
622
949
  * ```ts
623
- * // maps inputs to outputs (filtering or splitting where approp)
950
+ * // maps inputs to outputs (filtering or splitting where appr.)
624
951
  * const out2 = m(inputs);
625
952
  * ```
626
953
  */
627
- declare type MapFn<I, O, IR extends OptRequired = "req", D extends MapDirectionVal = MapDirection.OneToMany, OR extends OptRequired = "opt"> = IR extends "opt" ? <S extends MapFnInput<I, IR, D>>(source?: S) => MapFnOutput<I, O, S, OR, D> : <S extends MapFnInput<I, IR, D>>(source: S) => MapFnOutput<I, O, S, OR, D>;
954
+ declare type MapFn<I, O, C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = MapIR<C> extends "opt" ? <S extends MapFnInput<I, MapIR<C>, MapCard<C>>>(source?: S) => MapFnOutput<I, O, S, MapOR<C>, MapCard<C>> : <S extends MapFnInput<I, MapIR<C>, MapCard<C>>>(source: S) => MapFnOutput<I, O, S, MapOR<C>, MapCard<C>>;
628
955
 
629
956
  /**
630
957
  * Given a dictionary of type `<T>`, this utility function will
@@ -698,6 +1025,12 @@ declare type RequiredKeys<T extends object, V extends any = any> = {
698
1025
  [P in K]: T[K];
699
1026
  } ? never : T[K] extends V ? K : never;
700
1027
  }[keyof T];
1028
+ /**
1029
+ * Extracts the intersecting/common keys to two objects
1030
+ */
1031
+ declare type IntersectingKeys<T extends Record<string, any> | readonly string[], U extends Record<string, any> | readonly string[]> = {
1032
+ [K in keyof T]: K extends Keys<U> ? K : never;
1033
+ }[keyof T];
701
1034
  /**
702
1035
  * Extracts the _optional_ keys in the object's type. You also may
703
1036
  * optionally filter by the _value_ of the key.
@@ -907,7 +1240,6 @@ declare type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? true : fa
907
1240
  * Validates that a given type extends another and returns `any` or `never` as a type
908
1241
  */
909
1242
  declare type AssertExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? any : never;
910
- declare type IfExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? VALUE : never;
911
1243
  /**
912
1244
  * Give a type `TValue` and a comparison type `TExtends`
913
1245
  */
@@ -1087,27 +1419,6 @@ declare type _DU<T extends string> = T extends Lowercase<T> ? T : `-${Lowercase<
1087
1419
  */
1088
1420
  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>}` : "";
1089
1421
 
1090
- /**
1091
- * Converts a Tuple type into a _union_ of the tuple elements
1092
- * ```ts
1093
- * const arr = [1, 3, 5] as const;
1094
- * // 1 | 3 | 5
1095
- * type U = TupleToUnion<typeof arr>;
1096
- * ```
1097
- */
1098
- declare type TupleToUnion<T> = Mutable<T> extends any[] ? Mutable<T>[number] : never;
1099
-
1100
- /**
1101
- * LastInUnion<1 | 2> = 2.
1102
- */
1103
- declare type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
1104
- /**
1105
- * UnionToTuple<1 | 2> = [1, 2].
1106
- */
1107
- declare type UnionToTuple<U, Last = LastInUnion<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, Last>>, Last];
1108
-
1109
- declare type Widen<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
1110
-
1111
1422
  declare type OneToOne = `1:1`;
1112
1423
  declare type OneToMany = `1:M`;
1113
1424
  declare type OneToZero = `1:0`;
@@ -1294,10 +1605,10 @@ declare type FinalReturn<T extends any> = T extends (...args: any[]) => any ? Fi
1294
1605
  */
1295
1606
  declare type LogicFunction<T extends any[]> = (...args: T) => boolean;
1296
1607
 
1297
- declare type DictFromKv<T extends readonly Readonly<{
1608
+ declare type DictFromKv<T extends readonly {
1298
1609
  key: string;
1299
1610
  value: unknown;
1300
- }>[]> = {
1611
+ }[]> = {
1301
1612
  [R in T[number] as R["key"]]: R["value"];
1302
1613
  };
1303
1614
 
@@ -1423,51 +1734,6 @@ declare type FromDictArray<T extends [string, Record<string, unknown>][]> = Expa
1423
1734
  */
1424
1735
  declare type SecondOfEach<T extends any[][]> = T[number][1] extends T[number][number] ? T[number][1] : never;
1425
1736
 
1426
- /**
1427
- * **IsBooleanLiteral**
1428
- *
1429
- * Type utility which returns true/false if the boolean value is a _boolean literal_ versus
1430
- * just the wider _boolean_ type.
1431
- */
1432
- declare type IsBooleanLiteral<T extends boolean> = boolean extends T ? false : true;
1433
-
1434
- /**
1435
- * **IsStringLiteral**
1436
- *
1437
- * Type utility which returns true/false if the string a _string literal_ versus
1438
- * just the _string_ type.
1439
- */
1440
- declare type IsStringLiteral<T extends string> = string extends T ? false : true;
1441
-
1442
- /**
1443
- * **IsNumericLiteral**
1444
- *
1445
- * Type utility which returns true/false if the numeric value a _numeric literal_ versus
1446
- * just the _number_ type.
1447
- */
1448
- declare type IsNumericLiteral<T extends number> = number extends T ? false : true;
1449
-
1450
- /**
1451
- * **IsLiteral**
1452
- *
1453
- * Type utility which returns true/false if the value passed -- a form of a
1454
- * string, number, or boolean -- is a _literal_ value of that type (true) or
1455
- * the more generic wide type (false).
1456
- */
1457
- declare type IsLiteral<T extends string | number | boolean> = [T] extends [string] ? IsStringLiteral<T> : [T] extends [boolean] ? IsBooleanLiteral<T> : [T] extends [number] ? IsNumericLiteral<T> : never;
1458
-
1459
- /**
1460
- * **Includes<TSource, TValue>**
1461
- *
1462
- * Type utility which returns `true` or `false` based on whether `TValue` is found
1463
- * in `TSource`. Where `TSource` can be a string literal or an array of string literals.
1464
- *
1465
- * **Note:** if the source is a _wide_ type (aka, `string` or `string[]`) then there is
1466
- * no way to know at design-time whether the value includes `TValue` and so it will return
1467
- * a type of `boolean`.
1468
- */
1469
- declare type Includes<TSource extends string | string[], TValue extends string> = TSource extends string[] ? IsStringLiteral<TupleToUnion<TSource>> extends true ? IsLiteral<TValue> extends true ? TValue extends TupleToUnion<TSource> ? true : false : boolean : boolean : TSource extends string ? IsLiteral<TSource> extends true ? IsLiteral<TValue> extends true ? TSource extends `${string}${TValue}${string}` ? true : false : boolean : boolean : boolean;
1470
-
1471
1737
  declare function createFnWithProps<F extends Function, P extends {}>(fn: F, props: P): F & P;
1472
1738
  /**
1473
1739
  * Adds a dictionary of key/value pairs to a function.
@@ -1700,75 +1966,6 @@ declare function entries<N extends Narrowable, T extends Record<string, N>, I ex
1700
1966
  */
1701
1967
  declare function mapValues<N extends Narrowable, T extends Record<string, N>, V>(obj: T, valueMapper: (k: T[keyof T]) => V): { [K in keyof T]: V; };
1702
1968
 
1703
- interface MapConfig<IR extends OptRequired = "req", D extends MapDirectionVal = "I -> O[]", OR extends OptRequired = "opt"> {
1704
- input?: IR;
1705
- output?: OR;
1706
- direction?: D;
1707
- }
1708
- /**
1709
- * Provides a mapper function using the default configuration
1710
- */
1711
- declare type MapperApiDefault = <I, O>(map: MapTo<I, O>) => MapFn<I, O>;
1712
- /**
1713
- * Provides opportunity to configure _input_ and _output_ relationships
1714
- * prior to providing a mapping function.
1715
- */
1716
- declare type MapperApiConfigured = <IR extends OptRequired = "req", D extends MapDirectionVal = "I -> O[]", OR extends OptRequired = "opt">(config: MapConfig<IR, D, OR>) => <I, O>(map: MapTo<I, O, IR, D, OR>) => MapFn<I, O, IR, D, OR>;
1717
- /**
1718
- * **mapTo** _utility_
1719
- *
1720
- * This utility creates a strongly typed data mapper which maps from one
1721
- * known source `I` to another `O`:
1722
- * ```ts
1723
- * const mapper = mapTo<I, O>(i => [{
1724
- * foo: i.bar
1725
- * }]);
1726
- * ```
1727
- */
1728
- declare const mapToFn: <I, O>(map: (source: I) => O[]) => <S extends I | I[]>(source: S) => S extends I[] ? O[] : O[] | null;
1729
- /**
1730
- * Provides a `config` method which allows the relationships between _inputs_
1731
- * and _outputs_ to be configured.
1732
- */
1733
- declare const mapToDict: {
1734
- /** configure the relationship between the _inputs_ and _outputs_ */
1735
- config: <IR extends OptRequired = "req", D extends "I -> O[]" | "I -> O" | "I[] -> O" = "I -> O[]", OR extends OptRequired = "opt">(c?: MapConfig<IR, D, OR>) => {
1736
- /**
1737
- * create your mapping with your recently setup configuration:
1738
- * ```ts
1739
- * const mapper = mapTo
1740
- * .config({ ... })
1741
- * .map<I, O>(i => [{
1742
- * foo: i.bar
1743
- * }]);
1744
- * ```
1745
- */
1746
- map<I, O>(map: MapTo<I, O, IR, D, OR>): MapFn<I, O, IR, D, OR>;
1747
- };
1748
- };
1749
- /**
1750
- * **mapTo** _utility_
1751
- *
1752
- * This utility creates a strongly typed data mapper which maps from one
1753
- * known source `I` to another `O`.
1754
- */
1755
- declare const mapTo: (<I, O>(map: (source: I) => O[]) => <S extends I | I[]>(source: S) => S extends I[] ? O[] : O[] | null) & {
1756
- /** configure the relationship between the _inputs_ and _outputs_ */
1757
- config: <IR extends OptRequired = "req", D extends "I -> O[]" | "I -> O" | "I[] -> O" = "I -> O[]", OR extends OptRequired = "opt">(c?: MapConfig<IR, D, OR>) => {
1758
- /**
1759
- * create your mapping with your recently setup configuration:
1760
- * ```ts
1761
- * const mapper = mapTo
1762
- * .config({ ... })
1763
- * .map<I, O>(i => [{
1764
- * foo: i.bar
1765
- * }]);
1766
- * ```
1767
- */
1768
- map<I, O>(map: MapTo<I, O, IR, D, OR>): MapFn<I, O, IR, D, OR>;
1769
- };
1770
- };
1771
-
1772
1969
  /**
1773
1970
  * converts an array of strings `["a", "b", "c"]` into a more type friendly
1774
1971
  * dictionary of the type `{ a: true, b: true, c: true }`
@@ -2045,4 +2242,4 @@ interface IFluentConfigurator<C> {
2045
2242
  */
2046
2243
  declare function FluentConfigurator<I>(initial?: I): IFluentConfigurator<{}>;
2047
2244
 
2048
- export { AllCaps, Alpha, AlphaNumeric, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AsArray, AssertExtends, Bracket, Break, CamelCase, CapitalizeWords, Cardinality, Cardinality0, Cardinality1, CardinalityExplicit, CardinalityFilter0, CardinalityFilter1, CardinalityIn, CardinalityInput, CardinalityNode, CardinalityOut, CardinalityTuple, ClosingBracket, Condition, ConditionFilter, Configurator, Constructor, DashToSnake, DashUppercase, Dasherize, DefinePropertiesApi, DictArrApi, DictArray, DictArrayFilterCallback, DictArrayKv, DictChangeValue, DictFromKv, DictKvTuple, DictPartialApplication, DictPrependWithFn, DictReturnValues, DynamicRule, DynamicRuleSet, Email, EnumValues, ExpandRecursively, ExpectExtends, ExplicitFunction, ExtendsClause, ExtendsNarrowlyClause, FilterContains, FilterDefn, FilterEnds, FilterEquals, FilterFn, FilterGreaterThan, FilterIs, FilterLessThan, FilterNotEqual, FilterStarts, FinalReturn, First, FirstKey, FirstKeyValue, FirstOfEach, FluentConfigurator, FluentFunction, FromDictArray, FunctionType, GeneralDictionary, Get, HasUppercase, IConfigurator, IFluentConfigurator, If, IfExtends, IfExtendsThen, Include, Includes, IsArray, IsBoolean, IsBooleanLiteral, IsCapitalized, IsFalse, IsFunction, IsLiteral, IsNumericLiteral, IsObject, IsString, IsStringLiteral, IsTrue, KebabCase, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LogicFunction, LogicalCombinator, LowerAllCaps, LowerAlpha, ManyToMany, ManyToOne, ManyToZero, MapConfig, MapDirection, MapDirectionVal, MapFn, MapFnInput, MapFnOutput, MapInput, MapOutput, MapTo, MapperApiConfigured, MapperApiDefault, MaybeFalse, MaybeTrue, Model, Mutable, MutableProps, MutationFunction, MutationIdentity, Narrowable, NonAlpha, NonNumericKeys, NonStringKeys, Not, NotFilter, Numeric, NumericFilter, NumericKeys, NumericString, ObjectType, OneToMany, OneToOne, OneToZero, Opaque, OpeningBracket, OptRequired, OptionalKeys, OptionalProps, Parenthesis, PascalCase, Pluralize, PrivateKey, PrivateKeys, PublicKeys, Punctuation, PureFluentApi, Replace, RequireProps, RequiredKeys, RequiredProps, Retain, RightWhitespace, RuleDefinition, RuntimeProp, RuntimeType, SameKeys, SecondOfEach, SimplifyObject, SnakeCase, SpecialCharacters, StringDelimiter, StringFilter, StringKeys, StringLength, ToFluent, Transformer, Trim, TrimLeft, TrimRight, TupleToUnion, Type, TypeApi, TypeCondition, TypeDefinition, TypeGuard, TypeOptions, UndefinedArrayIsUnknown, UndefinedTreatment, UndefinedValue, UnionToIntersection, UnionToTuple, UniqueDictionary, UniqueForProp, Uniqueness, UnwrapNot, UpperAlpha, ValueTuple, ValueTypeFunc, ValueTypes, Where, WhereNot, Whitespace, Widen, WithNumericKeys, WithStringKeys, WithValue, ZeroToMany, ZeroToOne, ZeroToZero, ZipCode, and, api, arrayToKeyLookup, arrayToObject, asArray, condition, createFnWithProps, createMutationFunction, defineProperties, defineType, dictArr, dictToKv, dictionaryTransform, entries, filter, filterDictArray, fnWithProps, groupBy, idLiteral, idTypeGuard, identity, ifTypeOf, isArray, isBoolean, isFalse, isFunction, isNotFilter, isNull, isNumber, isNumericFilter, isObject, isString, isSymbol, isTrue, isType, isUndefined, keys, kindLiteral, kv, kvToDict, literal, mapTo, mapToDict, mapToFn, mapValues, nameLiteral, not, or, randomString, readonlyFnWithProps, ruleSet, strArrayToDict, type, typeApi, uuid, valueTypes, withValue };
2245
+ export { AllCaps, Alpha, AlphaNumeric, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AsArray, AsFinalizedConfig, AssertExtends, Bracket, Break, CamelCase, CapitalizeWords, Cardinality, Cardinality0, Cardinality1, CardinalityExplicit, CardinalityFilter0, CardinalityFilter1, CardinalityIn, CardinalityInput, CardinalityNode, CardinalityOut, CardinalityTuple, ClosingBracket, Condition, ConditionFilter, Configurator, ConfiguredMap, Constructor, DEFAULT_MANY_TO_ONE_MAPPING, DEFAULT_ONE_TO_MANY_MAPPING, DEFAULT_ONE_TO_ONE_MAPPING, DashToSnake, DashUppercase, Dasherize, DecomposeMapConfig, DefaultManyToOneMapping, DefaultOneToManyMapping, DefaultOneToOneMapping, DefinePropertiesApi, DictArrApi, DictArray, DictArrayFilterCallback, DictArrayKv, DictChangeValue, DictFromKv, DictKvTuple, DictPartialApplication, DictPrependWithFn, DictReturnValues, DynamicRule, DynamicRuleSet, Email, EnumValues, ExpandRecursively, ExpectExtends, ExplicitFunction, Extends, ExtendsClause, ExtendsNarrowlyClause, FilterContains, FilterDefn, FilterEnds, FilterEquals, FilterFn, FilterGreaterThan, FilterIs, FilterLessThan, FilterNotEqual, FilterStarts, FinalReturn, FinalizedMapConfig, First, FirstKey, FirstKeyValue, FirstOfEach, FluentConfigurator, FluentFunction, FromDictArray, FunctionType, GeneralDictionary, Get, HasUppercase, IConfigurator, IFluentConfigurator, If, IfBooleanLiteral, IfExtends, IfExtendsThen, IfLiteral, IfNumericLiteral, IfObject, IfOptionalLiteral, IfScalar, IfStringLiteral, Include, Includes, IntersectingKeys, IsArray, IsBoolean, IsBooleanLiteral, IsCapitalized, IsFalse, IsFunction, IsLiteral, IsNumericLiteral, IsObject, IsOptionalLiteral, IsScalar, IsString, IsStringLiteral, IsTrue, KebabCase, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LogicFunction, LogicalCombinator, LowerAllCaps, LowerAlpha, ManyToMany, ManyToOne, ManyToZero, MapCard, MapCardinality, MapCardinalityIllustrated, MapConfig, MapFn, MapFnInput, MapFnOutput, MapIR, MapInput, MapOR, MapOutput, MapTo, MapperApi, MaybeFalse, MaybeTrue, Model, Mutable, MutableProps, MutationFunction, MutationIdentity, Narrowable, NonAlpha, NonNumericKeys, NonStringKeys, Not, NotFilter, Numeric, NumericFilter, NumericKeys, NumericString, ObjectType, OneToMany, OneToOne, OneToZero, Opaque, OpeningBracket, OptRequired, OptionalKeys, OptionalProps, Parenthesis, PascalCase, Pluralize, PrivateKey, PrivateKeys, PublicKeys, Punctuation, PureFluentApi, Replace, RequireProps, RequiredKeys, RequiredProps, Retain, RightWhitespace, RuleDefinition, RuntimeProp, RuntimeType, SameKeys, SecondOfEach, SimplifyObject, SnakeCase, SpecialCharacters, StringDelimiter, StringFilter, StringKeys, StringLength, ToFluent, Transformer, Trim, TrimLeft, TrimRight, TupleToUnion, Type, TypeApi, TypeCondition, TypeDefault, TypeDefinition, TypeGuard, TypeOptions, UndefinedArrayIsUnknown, UndefinedTreatment, UndefinedValue, UnionToIntersection, UnionToTuple, UniqueDictionary, UniqueForProp, Uniqueness, UnwrapNot, UpperAlpha, ValueTuple, ValueTypeFunc, ValueTypes, Where, WhereNot, Whitespace, Widen, WithNumericKeys, WithStringKeys, WithValue, ZeroToMany, ZeroToOne, ZeroToZero, ZipCode, and, api, arrayToKeyLookup, arrayToObject, asArray, condition, createFnWithProps, createMutationFunction, defineProperties, defineType, dictArr, dictToKv, dictionaryTransform, entries, filter, filterDictArray, fnWithProps, groupBy, idLiteral, idTypeGuard, identity, ifTypeOf, isArray, isBoolean, isFalse, isFunction, isNotFilter, isNull, isNumber, isNumericFilter, isObject, isString, isSymbol, isTrue, isType, isUndefined, keys, kindLiteral, kv, kvToDict, literal, mapTo, mapToDict, mapToFn, mapValues, nameLiteral, not, or, randomString, readonlyFnWithProps, ruleSet, strArrayToDict, type, typeApi, uuid, valueTypes, withValue };