1 | import { Key } from '../Any/Key';
|
2 | import { Head } from '../List/Head';
|
3 | import { List } from '../List/List';
|
4 | import { Pop } from '../List/Pop';
|
5 | import { Tail } from '../List/Tail';
|
6 | import { Path } from '../Object/Path';
|
7 | import { UnionOf } from '../Object/UnionOf';
|
8 | import { Select } from '../Union/Select';
|
9 | import { Join } from '../String/Join';
|
10 | import { Split } from '../String/Split';
|
11 |
|
12 |
|
13 |
|
14 | declare type Index = number | string;
|
15 |
|
16 |
|
17 |
|
18 | declare type KeyToIndex<K extends Key, SP extends List<Index>> = number extends K ? Head<SP> : K & Index;
|
19 |
|
20 |
|
21 |
|
22 | declare type MetaPath<O, D extends string, SP extends List<Index> = [], P extends List<Index> = []> = {
|
23 | [K in keyof O]: MetaPath<O[K], D, Tail<SP>, [...P, KeyToIndex<K, SP>]> | Join<[...P, KeyToIndex<K, SP>], D>;
|
24 | };
|
25 |
|
26 |
|
27 |
|
28 | declare type NextPath<OP> = Select<UnionOf<Exclude<OP, string> & {}>, string>;
|
29 |
|
30 |
|
31 |
|
32 | declare type ExecPath<A, SP extends List<Index>, Delimiter extends string> = NextPath<Path<MetaPath<A, Delimiter, SP>, SP>>;
|
33 |
|
34 |
|
35 |
|
36 | declare type HintPath<A, P extends string, SP extends List<Index>, Exec extends string, D extends string> = [Exec] extends [never] ? ExecPath<A, Pop<SP>, D> : Exec | P;
|
37 |
|
38 |
|
39 |
|
40 | declare type _AutoPath<A, P extends string, D extends string, SP extends List<Index> = Split<P, D>> = HintPath<A, P, SP, ExecPath<A, SP, D>, D>;
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | export declare type AutoPath<O extends any, P extends string, D extends string = '.'> = _AutoPath<O, P, D>;
|
69 | export {};
|