inferred-types 0.26.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.
- package/.vscode/settings.json +5 -0
- package/dist/index.d.ts +441 -126
- package/dist/index.js +80 -6
- package/dist/index.mjs +74 -6
- package/package.json +1 -1
- package/src/types/Mutable.ts +3 -1
- package/src/types/TypeInfo/Extends.ts +14 -0
- package/src/types/TypeInfo/IsBooleanLiteral.ts +9 -0
- package/src/types/TypeInfo/IsLiteral.ts +36 -2
- package/src/types/TypeInfo/IsNumericLiteral.ts +9 -0
- package/src/types/TypeInfo/IsObject.ts +27 -0
- package/src/types/TypeInfo/IsScalar.ts +14 -0
- package/src/types/TypeInfo/IsStringLiteral.ts +9 -0
- package/src/types/TypeInfo/IsUndefined.ts +14 -0
- package/src/types/TypeInfo/TypeDefault.ts +58 -0
- package/src/types/TypeInfo/index.ts +4 -0
- package/src/types/alphabetic/Cardinality.ts +80 -0
- package/src/types/alphabetic/index.ts +1 -0
- package/src/types/dictionary/MapTo.ts +332 -13
- package/src/types/dictionary/props.ts +11 -0
- package/src/types/index.ts +1 -0
- package/src/types/kv/DictFromKv.ts +1 -1
- package/src/types/literal-unions/OptRequired.ts +4 -0
- package/src/types/literal-unions/index.ts +1 -0
- package/src/types/string-literals/Replace.ts +8 -4
- package/src/types/type-testing.ts +2 -5
- package/src/utility/dictionary/kv/kvToDict.ts +1 -2
- package/src/utility/dictionary/mapTo.ts +160 -28
- package/src/utility/dictionary/merge.ts +36 -0
- package/src/utility/runtime/conditions/isObject.ts +2 -16
- package/tests/TypeInfo/IsLiteral.spec.ts +17 -1
- package/tests/createFnWithProps.spec.ts +1 -0
- package/tests/dictionary/IntersectingKeys.test.ts +42 -0
- package/tests/dictionary/TypeDefault.test.ts +76 -0
- package/tests/dictionary/mapTo.test.ts +327 -94
- package/tests/dictionary/merge.test.ts +41 -0
- package/tests/withValue.spec.ts +0 -1
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
|
|
@@ -579,26 +766,192 @@ O extends (...args: any[]) => any = (...args: any[]) => any> = SimplifyObject<{
|
|
|
579
766
|
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;
|
|
580
767
|
|
|
581
768
|
/**
|
|
582
|
-
*
|
|
769
|
+
* Expresses whether an option is "opt" (optional) or "req" (required)
|
|
770
|
+
*/
|
|
771
|
+
declare type OptRequired = "opt" | "req";
|
|
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_
|
|
583
798
|
*
|
|
584
|
-
*
|
|
799
|
+
* This utility creates a strongly typed data mapper which maps from one
|
|
800
|
+
* known source `I` to another `O`.
|
|
585
801
|
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
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
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Expresses relationship between inputs/outputs:
|
|
589
814
|
*/
|
|
590
|
-
declare
|
|
815
|
+
declare enum MapCardinality {
|
|
816
|
+
/** every input results in 0:M outputs */
|
|
817
|
+
OneToMany = "I -> O[]",
|
|
818
|
+
/** every input results in 0:1 outputs */
|
|
819
|
+
OneToOne = "I -> O",
|
|
820
|
+
/** every input is an array of type I and reduced to a single O */
|
|
821
|
+
ManyToOne = "I[] -> O"
|
|
822
|
+
}
|
|
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;
|
|
591
927
|
/**
|
|
592
|
-
* **
|
|
928
|
+
* **MapTo<I, O>**
|
|
929
|
+
*
|
|
930
|
+
* A mapping function between an input type `I` and output type `O`.
|
|
593
931
|
*
|
|
594
|
-
*
|
|
932
|
+
* **Note:** this type is designed to guide the userland mapping; refer
|
|
933
|
+
* to `MapFn` if you want the type output by the `mapFn()` utility.
|
|
934
|
+
*/
|
|
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;
|
|
938
|
+
/**
|
|
939
|
+
* The mapping function provided by the `mapFn()` utility. This _fn_
|
|
940
|
+
* is intended to be used in two ways:
|
|
595
941
|
*
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
*
|
|
942
|
+
* 1. Iterative:
|
|
943
|
+
* ```ts
|
|
944
|
+
* const m = mapTo<I,O>(i => [ ... ]);
|
|
945
|
+
* // maps inputs to outputs
|
|
946
|
+
* const out = inputs.map(m);
|
|
947
|
+
* ```
|
|
948
|
+
* 2. Block:
|
|
949
|
+
* ```ts
|
|
950
|
+
* // maps inputs to outputs (filtering or splitting where appr.)
|
|
951
|
+
* const out2 = m(inputs);
|
|
952
|
+
* ```
|
|
600
953
|
*/
|
|
601
|
-
declare type
|
|
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>>;
|
|
602
955
|
|
|
603
956
|
/**
|
|
604
957
|
* Given a dictionary of type `<T>`, this utility function will
|
|
@@ -672,6 +1025,12 @@ declare type RequiredKeys<T extends object, V extends any = any> = {
|
|
|
672
1025
|
[P in K]: T[K];
|
|
673
1026
|
} ? never : T[K] extends V ? K : never;
|
|
674
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];
|
|
675
1034
|
/**
|
|
676
1035
|
* Extracts the _optional_ keys in the object's type. You also may
|
|
677
1036
|
* optionally filter by the _value_ of the key.
|
|
@@ -881,7 +1240,6 @@ declare type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? true : fa
|
|
|
881
1240
|
* Validates that a given type extends another and returns `any` or `never` as a type
|
|
882
1241
|
*/
|
|
883
1242
|
declare type AssertExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? any : never;
|
|
884
|
-
declare type IfExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? VALUE : never;
|
|
885
1243
|
/**
|
|
886
1244
|
* Give a type `TValue` and a comparison type `TExtends`
|
|
887
1245
|
*/
|
|
@@ -1061,6 +1419,56 @@ declare type _DU<T extends string> = T extends Lowercase<T> ? T : `-${Lowercase<
|
|
|
1061
1419
|
*/
|
|
1062
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>}` : "";
|
|
1063
1421
|
|
|
1422
|
+
declare type OneToOne = `1:1`;
|
|
1423
|
+
declare type OneToMany = `1:M`;
|
|
1424
|
+
declare type OneToZero = `1:0`;
|
|
1425
|
+
declare type ZeroToOne = `0:1`;
|
|
1426
|
+
declare type ZeroToMany = `0:M`;
|
|
1427
|
+
declare type ZeroToZero = `0:0`;
|
|
1428
|
+
declare type ManyToMany = "M:M";
|
|
1429
|
+
declare type ManyToOne = "M:1";
|
|
1430
|
+
declare type ManyToZero = "M:0";
|
|
1431
|
+
declare type CardinalityNode = "0" | "1" | "M";
|
|
1432
|
+
/**
|
|
1433
|
+
* Cardinality which expects a singular input and requires
|
|
1434
|
+
* 1 or many outputs.
|
|
1435
|
+
*
|
|
1436
|
+
* Note: choose `CardinalityFilter1` if you want to allow output
|
|
1437
|
+
* to have no outputs.
|
|
1438
|
+
*/
|
|
1439
|
+
declare type Cardinality1 = OneToOne | OneToMany;
|
|
1440
|
+
/**
|
|
1441
|
+
* Cardinality which expects a singular input and maps to 0,
|
|
1442
|
+
* 1, or many outputs.
|
|
1443
|
+
*/
|
|
1444
|
+
declare type CardinalityFilter1 = OneToOne | OneToMany | OneToZero;
|
|
1445
|
+
/**
|
|
1446
|
+
* Cardinality which expects a singular input which is allowed to be
|
|
1447
|
+
* _undefined_ or the expected type.
|
|
1448
|
+
*/
|
|
1449
|
+
declare type Cardinality0 = ZeroToOne | ZeroToMany | OneToOne | OneToMany;
|
|
1450
|
+
/**
|
|
1451
|
+
* Cardinality which expects a singular input -- which is allowed to be
|
|
1452
|
+
* _undefined_ -- and maps to 0,
|
|
1453
|
+
* 1, or many outputs.
|
|
1454
|
+
*/
|
|
1455
|
+
declare type CardinalityFilter0 = ZeroToOne | ZeroToMany | OneToOne | OneToMany | OneToZero | ZeroToZero;
|
|
1456
|
+
declare type CardinalityExplicit = `${number}:${number}`;
|
|
1457
|
+
/**
|
|
1458
|
+
* Cardinality of any sort between two types
|
|
1459
|
+
*/
|
|
1460
|
+
declare type Cardinality = CardinalityFilter0 | CardinalityFilter1 | ManyToMany | ManyToOne | ManyToZero | CardinalityExplicit;
|
|
1461
|
+
declare type CardinalityTuple<T extends Cardinality> = UnionToTuple<T>;
|
|
1462
|
+
/**
|
|
1463
|
+
* The first or _input_ part of the Cardinality relationship
|
|
1464
|
+
*/
|
|
1465
|
+
declare type CardinalityIn<T extends Cardinality> = T extends `${infer IN}:${string}` ? IN : never;
|
|
1466
|
+
/**
|
|
1467
|
+
* The second or _output_ part of the Cardinality relationship
|
|
1468
|
+
*/
|
|
1469
|
+
declare type CardinalityOut<T extends Cardinality> = T extends `${string}:${infer OUT}` ? OUT : never;
|
|
1470
|
+
declare type CardinalityInput<T, C extends Cardinality> = CardinalityTuple<C>[0] extends 0 ? T | undefined : CardinalityTuple<C>[0] extends 1 ? T : T[];
|
|
1471
|
+
|
|
1064
1472
|
/**
|
|
1065
1473
|
* Converts a string literal into a _dasherized_ format while ignoring _exterior_ whitespace.
|
|
1066
1474
|
*
|
|
@@ -1197,10 +1605,10 @@ declare type FinalReturn<T extends any> = T extends (...args: any[]) => any ? Fi
|
|
|
1197
1605
|
*/
|
|
1198
1606
|
declare type LogicFunction<T extends any[]> = (...args: T) => boolean;
|
|
1199
1607
|
|
|
1200
|
-
declare type DictFromKv<T extends readonly
|
|
1608
|
+
declare type DictFromKv<T extends readonly {
|
|
1201
1609
|
key: string;
|
|
1202
1610
|
value: unknown;
|
|
1203
|
-
}
|
|
1611
|
+
}[]> = {
|
|
1204
1612
|
[R in T[number] as R["key"]]: R["value"];
|
|
1205
1613
|
};
|
|
1206
1614
|
|
|
@@ -1277,15 +1685,6 @@ declare type DictArray<T> = Array<{
|
|
|
1277
1685
|
[K in keyof T]: DictArrayKv<K, T>;
|
|
1278
1686
|
}[keyof T]>;
|
|
1279
1687
|
|
|
1280
|
-
/**
|
|
1281
|
-
* LastInUnion<1 | 2> = 2.
|
|
1282
|
-
*/
|
|
1283
|
-
declare type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
|
|
1284
|
-
/**
|
|
1285
|
-
* UnionToTuple<1 | 2> = [1, 2].
|
|
1286
|
-
*/
|
|
1287
|
-
declare type UnionToTuple<U, Last = LastInUnion<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, Last>>, Last];
|
|
1288
|
-
|
|
1289
1688
|
/**
|
|
1290
1689
|
* Returns the _first_ key in an object.
|
|
1291
1690
|
*
|
|
@@ -1314,18 +1713,6 @@ declare type FirstKeyValue<T extends object> = FirstKey<T> extends keyof T ? T[F
|
|
|
1314
1713
|
*/
|
|
1315
1714
|
declare type FirstOfEach<T extends readonly any[][]> = T[number][0] extends T[number][number] ? T[number][0] : never;
|
|
1316
1715
|
|
|
1317
|
-
/**
|
|
1318
|
-
* Converts a Tuple type into a _union_ of the tuple elements
|
|
1319
|
-
* ```ts
|
|
1320
|
-
* const arr = [1, 3, 5] as const;
|
|
1321
|
-
* // 1 | 3 | 5
|
|
1322
|
-
* type U = TupleToUnion<typeof arr>;
|
|
1323
|
-
* ```
|
|
1324
|
-
*/
|
|
1325
|
-
declare type TupleToUnion<T> = Mutable<T> extends any[] ? Mutable<T>[number] : never;
|
|
1326
|
-
|
|
1327
|
-
declare type Widen<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
|
|
1328
|
-
|
|
1329
1716
|
/**
|
|
1330
1717
|
* Typescript utility which receives `T` as shape which resembles `DictArray<D>`
|
|
1331
1718
|
* and if the type `D` can be inferred it is returned.
|
|
@@ -1347,51 +1734,6 @@ declare type FromDictArray<T extends [string, Record<string, unknown>][]> = Expa
|
|
|
1347
1734
|
*/
|
|
1348
1735
|
declare type SecondOfEach<T extends any[][]> = T[number][1] extends T[number][number] ? T[number][1] : never;
|
|
1349
1736
|
|
|
1350
|
-
/**
|
|
1351
|
-
* **IsBooleanLiteral**
|
|
1352
|
-
*
|
|
1353
|
-
* Type utility which returns true/false if the boolean value is a _boolean literal_ versus
|
|
1354
|
-
* just the wider _boolean_ type.
|
|
1355
|
-
*/
|
|
1356
|
-
declare type IsBooleanLiteral<T extends boolean> = boolean extends T ? false : true;
|
|
1357
|
-
|
|
1358
|
-
/**
|
|
1359
|
-
* **IsStringLiteral**
|
|
1360
|
-
*
|
|
1361
|
-
* Type utility which returns true/false if the string a _string literal_ versus
|
|
1362
|
-
* just the _string_ type.
|
|
1363
|
-
*/
|
|
1364
|
-
declare type IsStringLiteral<T extends string> = string extends T ? false : true;
|
|
1365
|
-
|
|
1366
|
-
/**
|
|
1367
|
-
* **IsNumericLiteral**
|
|
1368
|
-
*
|
|
1369
|
-
* Type utility which returns true/false if the numeric value a _numeric literal_ versus
|
|
1370
|
-
* just the _number_ type.
|
|
1371
|
-
*/
|
|
1372
|
-
declare type IsNumericLiteral<T extends number> = number extends T ? false : true;
|
|
1373
|
-
|
|
1374
|
-
/**
|
|
1375
|
-
* **IsLiteral**
|
|
1376
|
-
*
|
|
1377
|
-
* Type utility which returns true/false if the value passed -- a form of a
|
|
1378
|
-
* string, number, or boolean -- is a _literal_ value of that type (true) or
|
|
1379
|
-
* the more generic wide type (false).
|
|
1380
|
-
*/
|
|
1381
|
-
declare type IsLiteral<T extends string | number | boolean> = [T] extends [string] ? IsStringLiteral<T> : [T] extends [boolean] ? IsBooleanLiteral<T> : [T] extends [number] ? IsNumericLiteral<T> : never;
|
|
1382
|
-
|
|
1383
|
-
/**
|
|
1384
|
-
* **Includes<TSource, TValue>**
|
|
1385
|
-
*
|
|
1386
|
-
* Type utility which returns `true` or `false` based on whether `TValue` is found
|
|
1387
|
-
* in `TSource`. Where `TSource` can be a string literal or an array of string literals.
|
|
1388
|
-
*
|
|
1389
|
-
* **Note:** if the source is a _wide_ type (aka, `string` or `string[]`) then there is
|
|
1390
|
-
* no way to know at design-time whether the value includes `TValue` and so it will return
|
|
1391
|
-
* a type of `boolean`.
|
|
1392
|
-
*/
|
|
1393
|
-
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;
|
|
1394
|
-
|
|
1395
1737
|
declare function createFnWithProps<F extends Function, P extends {}>(fn: F, props: P): F & P;
|
|
1396
1738
|
/**
|
|
1397
1739
|
* Adds a dictionary of key/value pairs to a function.
|
|
@@ -1624,33 +1966,6 @@ declare function entries<N extends Narrowable, T extends Record<string, N>, I ex
|
|
|
1624
1966
|
*/
|
|
1625
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; };
|
|
1626
1968
|
|
|
1627
|
-
/**
|
|
1628
|
-
* **mapTo**
|
|
1629
|
-
*
|
|
1630
|
-
* A utility function which maps one dictionary structure `I` to another `O`; which allows
|
|
1631
|
-
* the transform to:
|
|
1632
|
-
*
|
|
1633
|
-
* - _split_ inputs into multiple outputs
|
|
1634
|
-
* - _map_ 1:1 between input and output
|
|
1635
|
-
* - _filter_ inputs which don't meet certain criteria (by returning `null`)
|
|
1636
|
-
*
|
|
1637
|
-
* This higher order function first asks for the mapping criteria:
|
|
1638
|
-
* ```ts
|
|
1639
|
-
* const mapper = mapTo<I,O>(i => i.name
|
|
1640
|
-
* ? [
|
|
1641
|
-
* { name: i.name, a: "static text", b: i.products.length }
|
|
1642
|
-
* ]
|
|
1643
|
-
* : null
|
|
1644
|
-
* );
|
|
1645
|
-
* ```
|
|
1646
|
-
*
|
|
1647
|
-
* and now you'll have a _mapper_ variable will be assigned as a mapping fn:
|
|
1648
|
-
* ```ts
|
|
1649
|
-
* function (source: I | I[]): O[]
|
|
1650
|
-
* ```
|
|
1651
|
-
*/
|
|
1652
|
-
declare const mapTo: <I extends {}, O extends {}>(cb: MapToWithFiltering<I, O>) => (source: I | I[]) => O[];
|
|
1653
|
-
|
|
1654
1969
|
/**
|
|
1655
1970
|
* converts an array of strings `["a", "b", "c"]` into a more type friendly
|
|
1656
1971
|
* dictionary of the type `{ a: true, b: true, c: true }`
|
|
@@ -1927,4 +2242,4 @@ interface IFluentConfigurator<C> {
|
|
|
1927
2242
|
*/
|
|
1928
2243
|
declare function FluentConfigurator<I>(initial?: I): IFluentConfigurator<{}>;
|
|
1929
2244
|
|
|
1930
|
-
export { AllCaps, Alpha, AlphaNumeric, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AsArray, AssertExtends, Bracket, Break, CamelCase, CapitalizeWords, 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, MapTo,
|
|
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 };
|