@avstantso/utils-names-tree 1.2.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +336 -133
- package/dist/_global/_register.d.ts +296 -38
- package/dist/index.js +152 -21
- package/dist/index.js.map +1 -1
- package/package.json +7 -10
|
@@ -1,10 +1,115 @@
|
|
|
1
1
|
declare namespace AVStantso {
|
|
2
|
+
const symbolRootAlias: unique symbol;
|
|
2
3
|
const BaseKinds: {
|
|
3
4
|
name: Kinds.Method;
|
|
5
|
+
backslash: Kinds.Method;
|
|
6
|
+
slash: Kinds.Method;
|
|
7
|
+
dot: Kinds.Method;
|
|
8
|
+
amp: Kinds.Method;
|
|
9
|
+
hash: Kinds.Method;
|
|
10
|
+
colon: Kinds.Method;
|
|
11
|
+
arrow: Kinds.Method;
|
|
12
|
+
dash: Kinds.Method;
|
|
13
|
+
underscore: Kinds.Method;
|
|
14
|
+
doubleColon: Kinds.Method;
|
|
15
|
+
comma: Kinds.Method;
|
|
16
|
+
semicolon: Kinds.Method;
|
|
17
|
+
space: Kinds.Method;
|
|
18
|
+
pipe: Kinds.Method;
|
|
4
19
|
path: Kinds.Method;
|
|
5
20
|
url: Kinds.Method;
|
|
21
|
+
query: Kinds.Method;
|
|
6
22
|
i18n: Kinds.Method;
|
|
7
23
|
domain: Kinds.Method;
|
|
24
|
+
longArg: Kinds.Method;
|
|
25
|
+
shortArg: Kinds.Method;
|
|
26
|
+
envVar: Kinds.Method;
|
|
27
|
+
cssClass: Kinds.Method;
|
|
28
|
+
cssId: Kinds.Method;
|
|
29
|
+
anchor: Kinds.Method;
|
|
30
|
+
scoped: Kinds.Method;
|
|
31
|
+
param: Kinds.Method;
|
|
32
|
+
arg: Kinds.Method;
|
|
33
|
+
params: Kinds.Method;
|
|
34
|
+
args: Kinds.Method;
|
|
35
|
+
snake: Kinds.Method;
|
|
36
|
+
namespace: Kinds.Method;
|
|
37
|
+
csv: Kinds.Method;
|
|
38
|
+
title: Kinds.Method;
|
|
39
|
+
};
|
|
40
|
+
const BaseKindsMeta: {
|
|
41
|
+
readonly name: never;
|
|
42
|
+
readonly backslash: "\\";
|
|
43
|
+
readonly slash: "/";
|
|
44
|
+
readonly dot: ".";
|
|
45
|
+
readonly amp: "&";
|
|
46
|
+
readonly hash: "#";
|
|
47
|
+
readonly colon: ":";
|
|
48
|
+
readonly arrow: "->";
|
|
49
|
+
readonly dash: "-";
|
|
50
|
+
readonly underscore: "_";
|
|
51
|
+
readonly doubleColon: "::";
|
|
52
|
+
readonly comma: ",";
|
|
53
|
+
readonly semicolon: ";";
|
|
54
|
+
readonly space: " ";
|
|
55
|
+
readonly pipe: "|";
|
|
56
|
+
readonly path: "/";
|
|
57
|
+
readonly url: {
|
|
58
|
+
readonly prefix: "/";
|
|
59
|
+
readonly separator: "/";
|
|
60
|
+
};
|
|
61
|
+
readonly query: {
|
|
62
|
+
readonly prefix: "?";
|
|
63
|
+
readonly separator: "&";
|
|
64
|
+
};
|
|
65
|
+
readonly i18n: ".";
|
|
66
|
+
readonly domain: ".";
|
|
67
|
+
readonly longArg: {
|
|
68
|
+
readonly prefix: "--";
|
|
69
|
+
readonly separator: "-";
|
|
70
|
+
};
|
|
71
|
+
readonly shortArg: {
|
|
72
|
+
readonly beforeEach: "-";
|
|
73
|
+
};
|
|
74
|
+
readonly envVar: {
|
|
75
|
+
readonly separator: "_";
|
|
76
|
+
readonly up: true;
|
|
77
|
+
};
|
|
78
|
+
readonly cssClass: {
|
|
79
|
+
readonly prefix: ".";
|
|
80
|
+
readonly separator: "-";
|
|
81
|
+
};
|
|
82
|
+
readonly cssId: {
|
|
83
|
+
readonly prefix: "#";
|
|
84
|
+
readonly separator: "-";
|
|
85
|
+
};
|
|
86
|
+
readonly anchor: {
|
|
87
|
+
readonly beforeEach: "#";
|
|
88
|
+
};
|
|
89
|
+
readonly scoped: {
|
|
90
|
+
readonly prefix: "@";
|
|
91
|
+
readonly separator: "/";
|
|
92
|
+
};
|
|
93
|
+
readonly param: {
|
|
94
|
+
readonly beforeEach: ":";
|
|
95
|
+
};
|
|
96
|
+
readonly arg: {
|
|
97
|
+
readonly beforeEach: "{";
|
|
98
|
+
readonly afterEach: "}";
|
|
99
|
+
};
|
|
100
|
+
readonly params: {
|
|
101
|
+
readonly beforeEach: ":";
|
|
102
|
+
readonly separator: "/";
|
|
103
|
+
};
|
|
104
|
+
readonly args: {
|
|
105
|
+
readonly beforeEach: "{";
|
|
106
|
+
readonly afterEach: "}";
|
|
107
|
+
readonly separator: "/";
|
|
108
|
+
};
|
|
109
|
+
readonly snake: "_";
|
|
110
|
+
readonly namespace: "::";
|
|
111
|
+
readonly csv: ",";
|
|
112
|
+
readonly title: " ";
|
|
8
113
|
};
|
|
9
114
|
export namespace NamesTree {
|
|
10
115
|
export namespace Kinds {
|
|
@@ -21,18 +126,116 @@ declare namespace AVStantso {
|
|
|
21
126
|
* @summary Allow tree kind
|
|
22
127
|
*/
|
|
23
128
|
export type Kind = Kinds.All[number];
|
|
129
|
+
export type KindMeta = {
|
|
130
|
+
prefix?: string;
|
|
131
|
+
separator?: string;
|
|
132
|
+
beforeEach?: string;
|
|
133
|
+
afterEach?: string;
|
|
134
|
+
up?: boolean;
|
|
135
|
+
};
|
|
136
|
+
type BaseKindsMeta = typeof BaseKindsMeta;
|
|
137
|
+
export interface KindsMeta extends BaseKindsMeta {
|
|
138
|
+
}
|
|
139
|
+
namespace _ResolveKind {
|
|
140
|
+
type RR<M extends KindMeta, MK extends keyof KindMeta> = M[MK] extends string ? M[MK] : '';
|
|
141
|
+
export type Step<M extends KindMeta, K extends TS.Key, F extends boolean> = TS.Array.Join<[
|
|
142
|
+
RR<M, F extends true ? 'prefix' : 'separator'>,
|
|
143
|
+
RR<M, 'beforeEach'>,
|
|
144
|
+
TS.String<K>,
|
|
145
|
+
RR<M, 'afterEach'>
|
|
146
|
+
]> extends infer S extends string ? M['up'] extends true ? Uppercase<S> : S : never;
|
|
147
|
+
export {};
|
|
148
|
+
}
|
|
149
|
+
type _ResolveKind<M extends KindMeta, P extends TS.Keys, F extends boolean, R extends string = ''> = P extends readonly [infer C extends TS.Key, ...infer Rest extends TS.Keys] ? _ResolveKind<M, Rest, false, `${R}${_ResolveKind.Step<M, C, F>}`> : R;
|
|
150
|
+
/**
|
|
151
|
+
* Resolve kind step
|
|
152
|
+
* @template KD Kind to resolve
|
|
153
|
+
* @template P Path stack. E.g. for `a/b/c` must be `['c', 'b', 'a']`
|
|
154
|
+
* @example
|
|
155
|
+
* // Stack expected
|
|
156
|
+
* type P0 = ['node0'];
|
|
157
|
+
* type P1 = ['node1', 'node0'];
|
|
158
|
+
* type P2 = ['node2', 'node1', 'node0'];
|
|
159
|
+
*
|
|
160
|
+
* type name0 = CheckType<ResolveKind<'name', P0>, 'node0'>;
|
|
161
|
+
* type name1 = CheckType<ResolveKind<'name', P1>, 'node1'>;
|
|
162
|
+
* type name2 = CheckType<ResolveKind<'name', P2>, 'node2'>;
|
|
163
|
+
*
|
|
164
|
+
* type path0 = CheckType<ResolveKind<'path', P0>, 'node0'>;
|
|
165
|
+
* type path1 = CheckType<ResolveKind<'path', P1>, 'node0/node1'>;
|
|
166
|
+
* type path2 = CheckType<ResolveKind<'path', P2>, 'node0/node1/node2'>;
|
|
167
|
+
*
|
|
168
|
+
* type url0 = CheckType<ResolveKind<'url', P0>, '/node0'>;
|
|
169
|
+
* type url1 = CheckType<ResolveKind<'url', P1>, '/node0/node1'>;
|
|
170
|
+
* type url2 = CheckType<ResolveKind<'url', P2>, '/node0/node1/node2'>;
|
|
171
|
+
*
|
|
172
|
+
* type dot0 = CheckType<ResolveKind<'dot', P0>, 'node0'>;
|
|
173
|
+
* type dot1 = CheckType<ResolveKind<'dot', P1>, 'node0.node1'>;
|
|
174
|
+
* type dot2 = CheckType<ResolveKind<'dot', P2>, 'node0.node1.node2'>;
|
|
175
|
+
*
|
|
176
|
+
* type param0 = CheckType<ResolveKind<'params', P0>, ':node0'>;
|
|
177
|
+
*
|
|
178
|
+
* type params0 = CheckType<ResolveKind<'params', P0>, ':node0'>;
|
|
179
|
+
* type params1 = CheckType<ResolveKind<'params', P1>, ':node0/:node1'>;
|
|
180
|
+
* type params2 = CheckType<ResolveKind<'params', P2>, ':node0/:node1/:node2'>;
|
|
181
|
+
*
|
|
182
|
+
* type arg0 = CheckType<ResolveKind<'arg', P0>, '{node0}'>;
|
|
183
|
+
*
|
|
184
|
+
* type args0 = CheckType<ResolveKind<'args', P0>, '{node0}'>;
|
|
185
|
+
* type args1 = CheckType<ResolveKind<'args', P1>, '{node0}/{node1}'>;
|
|
186
|
+
* type args2 = CheckType<ResolveKind<'args', P2>, '{node0}/{node1}/{node2}'>;
|
|
187
|
+
*
|
|
188
|
+
* type envVar0 = CheckType<ResolveKind<'envVar', P0>, 'NODE0'>;
|
|
189
|
+
* type envVar1 = CheckType<ResolveKind<'envVar', P1>, 'NODE0_NODE1'>;
|
|
190
|
+
* type envVar2 = CheckType<ResolveKind<'envVar', P2>, 'NODE0_NODE1_NODE2'>;
|
|
191
|
+
*
|
|
192
|
+
* type query0 = CheckType<ResolveKind<'query', ['a']>, '?a'>;
|
|
193
|
+
* type query1 = CheckType<ResolveKind<'query', ['b', 'a']>, '?a&b'>;
|
|
194
|
+
* type query2 = CheckType<ResolveKind<'query', ['c', 'b', 'a']>, '?a&b&c'>;
|
|
195
|
+
*
|
|
196
|
+
* type longArg0 = CheckType<ResolveKind<'longArg', ['dry']>, '--dry'>;
|
|
197
|
+
* type longArg1 = CheckType<ResolveKind<'longArg', ['run', 'dry']>, '--dry-run'>;
|
|
198
|
+
*
|
|
199
|
+
* type shortArg0 = CheckType<ResolveKind<'shortArg', ['v']>, '-v'>;
|
|
200
|
+
* type shortArg1 = CheckType<ResolveKind<'shortArg', ['f', 'v']>, '-v-f'>;
|
|
201
|
+
*
|
|
202
|
+
* type cssClass0 = CheckType<ResolveKind<'cssClass', ['btn']>, '.btn'>;
|
|
203
|
+
* type cssClass1 = CheckType<ResolveKind<'cssClass', ['primary', 'btn']>, '.btn-primary'>;
|
|
204
|
+
*
|
|
205
|
+
* type cssId0 = CheckType<ResolveKind<'cssId', ['main']>, '#main'>;
|
|
206
|
+
* type cssId1 = CheckType<ResolveKind<'cssId', ['content', 'main']>, '#main-content'>;
|
|
207
|
+
*
|
|
208
|
+
* type anchor0 = CheckType<ResolveKind<'anchor', ['section']>, '#section'>;
|
|
209
|
+
* type anchor1 = CheckType<ResolveKind<'anchor', ['intro', 'section']>, '#section#intro'>;
|
|
210
|
+
*
|
|
211
|
+
* type scoped0 = CheckType<ResolveKind<'scoped', ['org']>, '@org'>;
|
|
212
|
+
* type scoped1 = CheckType<ResolveKind<'scoped', ['pkg', 'org']>, '@org/pkg'>;
|
|
213
|
+
*
|
|
214
|
+
* type param0_ = CheckType<ResolveKind<'param', ['id']>, ':id'>;
|
|
215
|
+
* type param1_ = CheckType<ResolveKind<'param', ['sub', 'id']>, ':id:sub'>;
|
|
216
|
+
*
|
|
217
|
+
* type prefixed = CheckType<ResolveKind<'dash', ['id', 'user'], { prefix: '$' }>, '$user-id'>;
|
|
218
|
+
*/
|
|
219
|
+
export type ResolveKind<KD extends Kind, P extends TS.Keys, O extends Options = Options> = ([KindsMeta[KD]] extends [never] ? TS.String<P[0]> : (KindsMeta[KD] extends string ? {
|
|
220
|
+
separator: KindsMeta[KD];
|
|
221
|
+
} : KindsMeta[KD]) extends infer M extends KindMeta ? _ResolveKind<M, TS.Array.Reverse<P>, true> : string) extends infer R extends string ? O extends {
|
|
222
|
+
prefix: string;
|
|
223
|
+
} ? `${O['prefix']}${R}` : R : never;
|
|
24
224
|
/**
|
|
25
225
|
* @summary Tree node data source
|
|
26
226
|
*/
|
|
27
|
-
export type Source =
|
|
227
|
+
export type Source = TS.Type.Builtin;
|
|
28
228
|
export namespace Source {
|
|
29
229
|
/**
|
|
30
230
|
* @summary Tree root node data source
|
|
31
231
|
*/
|
|
32
232
|
type Root = object | Function;
|
|
33
233
|
}
|
|
34
|
-
type _NodeKinds<KDs extends readonly Kind[], R = unknown> = KDs extends readonly [
|
|
35
|
-
|
|
234
|
+
export type _NodeKinds<O extends Options, KDs extends readonly Kind[], P extends TS.Keys, R = unknown> = KDs extends readonly [
|
|
235
|
+
infer C extends Kind,
|
|
236
|
+
...infer Rest extends readonly Kind[]
|
|
237
|
+
] ? _NodeKinds<O, Rest, P, R & {
|
|
238
|
+
[K in `_${C}`]: ResolveKind<C, P>;
|
|
36
239
|
}> : {
|
|
37
240
|
[K in keyof R]: R[K];
|
|
38
241
|
};
|
|
@@ -41,22 +244,49 @@ declare namespace AVStantso {
|
|
|
41
244
|
*
|
|
42
245
|
* If `S = true`, allows tails nodes as string
|
|
43
246
|
*/
|
|
44
|
-
export type Node<T extends Source = Source, KDs extends readonly Kind[] = Kinds.All, S extends boolean = false> = (S extends true ? unknown : _NodeKinds<KDs>) & Node.Data<T, KDs, S>;
|
|
247
|
+
export type Node<T extends Source = Source, O extends Options = Options, KDs extends readonly Kind[] = Kinds.All, S extends boolean = false, P extends TS.Keys = []> = (S extends true ? unknown : _NodeKinds<O, KDs, P>) & Node.Data<T, O, KDs, S, P>;
|
|
45
248
|
export namespace Node {
|
|
249
|
+
type _Constraint<KDs extends readonly Kind[], R = unknown> = KDs extends readonly [
|
|
250
|
+
infer C extends Kind,
|
|
251
|
+
...infer Rest extends readonly Kind[]
|
|
252
|
+
] ? _Constraint<Rest, R & {
|
|
253
|
+
[K in `_${C}`]: string;
|
|
254
|
+
}> : R;
|
|
46
255
|
/**
|
|
47
|
-
* @summary
|
|
48
|
-
*
|
|
49
|
-
* If `S = true`, allows tails nodes as string
|
|
256
|
+
* @summary Node constraint
|
|
50
257
|
*/
|
|
51
|
-
type
|
|
52
|
-
[K in keyof
|
|
53
|
-
} :
|
|
258
|
+
export type Constraint<KDs extends readonly Kind[] = Kinds.All> = _Constraint<KDs> extends infer R ? {
|
|
259
|
+
[K in keyof R]: R[K];
|
|
260
|
+
} : never;
|
|
261
|
+
/**
|
|
262
|
+
* @summary Node data part
|
|
263
|
+
*/
|
|
264
|
+
export type Data<T extends Source = Source, O extends Options = Options, KDs extends readonly Kind[] = Kinds.All, S extends boolean = false, P extends TS.Keys = []> = T extends Source.Root ? (T extends Function ? T : unknown) & {
|
|
265
|
+
[K in keyof T]: Node<Extract<T[K], Source>, O, KDs, S, [
|
|
266
|
+
TS.String<K, '?'>,
|
|
267
|
+
...P
|
|
268
|
+
]>;
|
|
269
|
+
} : S extends true ? NamesTree.ResolveKind<KDs[0], P, O> : unknown;
|
|
270
|
+
export {};
|
|
54
271
|
}
|
|
55
272
|
/**
|
|
56
273
|
* @summary Tree options
|
|
57
274
|
*/
|
|
58
275
|
export interface Options {
|
|
276
|
+
/**
|
|
277
|
+
* @summary Additional prefix for all `Kinds` methods
|
|
278
|
+
*/
|
|
59
279
|
prefix?: string;
|
|
280
|
+
/**
|
|
281
|
+
* @summary Alias for root of tree as additional property.\
|
|
282
|
+
* E.g. `Home` for urls
|
|
283
|
+
*/
|
|
284
|
+
rootAlias?: string;
|
|
285
|
+
/**
|
|
286
|
+
* @summary If picked and represents in internal array — will be used on `ToString` for nodes.\
|
|
287
|
+
* Else will be used first kind from tree.
|
|
288
|
+
*/
|
|
289
|
+
defaultKind?: Kind;
|
|
60
290
|
}
|
|
61
291
|
/**
|
|
62
292
|
* @summary `NamesTree` kinds presets
|
|
@@ -70,18 +300,22 @@ declare namespace AVStantso {
|
|
|
70
300
|
* @summary `Names` preset kinds
|
|
71
301
|
*/
|
|
72
302
|
type Kinds = ['name'];
|
|
303
|
+
/**
|
|
304
|
+
* @summary `Names` preset node constraint
|
|
305
|
+
*/
|
|
306
|
+
type Constraint = NamesTree.Node.Constraint<Kinds>;
|
|
73
307
|
/**
|
|
74
308
|
* @summary `Names` preset tree node for source `T`
|
|
75
309
|
*
|
|
76
310
|
* If `S = true`, allows tails nodes as string
|
|
77
311
|
*/
|
|
78
|
-
type Node<T extends Source = Source, S extends boolean = false> = NamesTree.Node<T, Kinds, S>;
|
|
312
|
+
type Node<T extends Source = Source, O extends Options = Options, S extends boolean = false, P extends TS.Keys = []> = NamesTree.Node<T, O, Kinds, S, P>;
|
|
79
313
|
/**
|
|
80
314
|
* @summary `Names` preset `NamesTree` for data `T`
|
|
81
315
|
*
|
|
82
316
|
* If `S = true`, allows tails nodes as string
|
|
83
317
|
*/
|
|
84
|
-
type Tree<T extends
|
|
318
|
+
type Tree<T extends Source.Root, O extends Options, S extends boolean = false> = NamesTree<T, O, Kinds, S>;
|
|
85
319
|
}
|
|
86
320
|
/**
|
|
87
321
|
* @summary `I18ns` preset
|
|
@@ -91,18 +325,22 @@ declare namespace AVStantso {
|
|
|
91
325
|
* @summary `I18ns` preset kinds
|
|
92
326
|
*/
|
|
93
327
|
type Kinds = ['i18n', 'name'];
|
|
328
|
+
/**
|
|
329
|
+
* @summary `I18ns` preset node constraint
|
|
330
|
+
*/
|
|
331
|
+
type Constraint = NamesTree.Node.Constraint<Kinds>;
|
|
94
332
|
/**
|
|
95
333
|
* @summary `I18ns` preset tree node for source `T`
|
|
96
334
|
*
|
|
97
335
|
* If `S = true`, allows tails nodes as string
|
|
98
336
|
*/
|
|
99
|
-
type Node<T extends Source = Source, S extends boolean = false> = NamesTree.Node<T, Kinds, S>;
|
|
337
|
+
type Node<T extends Source = Source, O extends Options = Options, S extends boolean = false, P extends TS.Keys = []> = NamesTree.Node<T, O, Kinds, S, P>;
|
|
100
338
|
/**
|
|
101
339
|
* @summary `I18ns` preset `NamesTree` for data `T`
|
|
102
340
|
*
|
|
103
341
|
* If `S = true`, allows tails nodes as string
|
|
104
342
|
*/
|
|
105
|
-
type Tree<T extends
|
|
343
|
+
type Tree<T extends Source.Root, O extends Options, S extends boolean = false> = NamesTree<T, O, Kinds, S>;
|
|
106
344
|
}
|
|
107
345
|
/**
|
|
108
346
|
* @summary `Urls` preset
|
|
@@ -112,36 +350,40 @@ declare namespace AVStantso {
|
|
|
112
350
|
* @summary `Urls` preset kinds
|
|
113
351
|
*/
|
|
114
352
|
type Kinds = ['name', 'path', 'url'];
|
|
353
|
+
/**
|
|
354
|
+
* @summary `Urls` preset node constraint
|
|
355
|
+
*/
|
|
356
|
+
type Constraint = NamesTree.Node.Constraint<Kinds>;
|
|
115
357
|
/**
|
|
116
358
|
* @summary `Urls` preset tree node for source `T`
|
|
117
359
|
*
|
|
118
360
|
* If `S = true`, allows tails nodes as string
|
|
119
361
|
*/
|
|
120
|
-
type Node<T extends Source = Source, S extends boolean = false> = NamesTree.Node<T, Kinds, S>;
|
|
362
|
+
type Node<T extends Source = Source, O extends Options = Options, S extends boolean = false, P extends TS.Keys = []> = NamesTree.Node<T, O, Kinds, S, P>;
|
|
121
363
|
/**
|
|
122
364
|
* @summary `Urls` preset `NamesTree` for data `T`
|
|
123
365
|
*
|
|
124
366
|
* If `S = true`, allows tails nodes as string
|
|
125
367
|
*/
|
|
126
|
-
type Tree<T extends NamesTree.Source.Root, S extends boolean = false> =
|
|
368
|
+
type Tree<T extends NamesTree.Source.Root, O extends NamesTree.Options, S extends boolean = false> = NamesTree<T, O, Kinds, S>;
|
|
127
369
|
}
|
|
128
370
|
}
|
|
129
371
|
export {};
|
|
130
372
|
}
|
|
131
373
|
namespace _NamesTree {
|
|
132
|
-
type _Splitted<T extends NamesTree.Source.Root, KDs extends readonly NamesTree.Kind[], R extends TS.Arr = []> = KDs extends readonly [
|
|
374
|
+
type _Splitted<T extends NamesTree.Source.Root, O extends NamesTree.Options, KDs extends readonly NamesTree.Kind[], R extends TS.Arr = []> = KDs extends readonly [
|
|
133
375
|
infer C extends NamesTree.Kind,
|
|
134
376
|
...infer Rest extends readonly NamesTree.Kind[]
|
|
135
|
-
] ? _Splitted<T, Rest, [
|
|
377
|
+
] ? _Splitted<T, O, Rest, [
|
|
136
378
|
...R,
|
|
137
|
-
NamesTree<T, [C], true>
|
|
379
|
+
NamesTree<T, O, [C], true>
|
|
138
380
|
]> : R;
|
|
139
|
-
export type Splitted<T extends NamesTree.Source.Root, KDs extends readonly NamesTree.Kind[]> = _Splitted<T, KDs>;
|
|
140
|
-
export type ExtractByKinds<T extends NamesTree.Source.Root, KDs extends readonly NamesTree.Kind[], R = unknown> = KDs extends readonly [
|
|
381
|
+
export type Splitted<T extends NamesTree.Source.Root, O extends NamesTree.Options, KDs extends readonly NamesTree.Kind[]> = _Splitted<T, O, KDs>;
|
|
382
|
+
export type ExtractByKinds<T extends NamesTree.Source.Root, O extends NamesTree.Options, KDs extends readonly NamesTree.Kind[], R = unknown> = KDs extends readonly [
|
|
141
383
|
infer C extends NamesTree.Kind,
|
|
142
384
|
...infer Rest extends readonly NamesTree.Kind[]
|
|
143
|
-
] ? ExtractByKinds<T, Rest, R & {
|
|
144
|
-
[K in Capitalize<C>]: NamesTree<T, [C], true>;
|
|
385
|
+
] ? ExtractByKinds<T, O, Rest, R & {
|
|
386
|
+
[K in Capitalize<C>]: NamesTree<T, O, [C], true>;
|
|
145
387
|
}> : R;
|
|
146
388
|
export {};
|
|
147
389
|
}
|
|
@@ -150,22 +392,34 @@ declare namespace AVStantso {
|
|
|
150
392
|
*
|
|
151
393
|
* If `S = true`, allows tails nodes as string
|
|
152
394
|
*/
|
|
153
|
-
export type NamesTree<T extends NamesTree.Source.Root, KDs extends readonly NamesTree.Kind[], S extends boolean = false> = NamesTree.Node.Data<T, KDs, S> & (S extends true ?
|
|
395
|
+
export type NamesTree<T extends NamesTree.Source.Root, O extends NamesTree.Options, KDs extends readonly NamesTree.Kind[], S extends boolean = false> = NamesTree.Node.Data<T, O, KDs, S> & (S extends true ? O extends {
|
|
396
|
+
rootAlias: infer R extends TS.Key;
|
|
397
|
+
} ? {
|
|
398
|
+
[K in R]: NamesTree.ResolveKind<KDs[0], [''], O>;
|
|
399
|
+
} : unknown : {
|
|
400
|
+
/**
|
|
401
|
+
* @summary Get array of splitted trees each with unique kind
|
|
402
|
+
*/
|
|
403
|
+
$splitted: _NamesTree.Splitted<T, O, KDs>;
|
|
154
404
|
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
405
|
+
* @summary Modify existing tree by additional data
|
|
406
|
+
*/
|
|
407
|
+
$merge<M extends NamesTree.Source.Root>(data: M): NamesTree<T & M, O, KDs, S>;
|
|
158
408
|
/**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
} & _NamesTree.ExtractByKinds<T, KDs>
|
|
409
|
+
* @summary Access to `rootAlias` value
|
|
410
|
+
*/
|
|
411
|
+
[symbolRootAlias]: O['rootAlias'];
|
|
412
|
+
} & _NamesTree.ExtractByKinds<T, O, KDs> & (O extends {
|
|
413
|
+
rootAlias: infer R extends TS.Key;
|
|
414
|
+
} ? {
|
|
415
|
+
[K in R]: NamesTree._NodeKinds<O, KDs, ['']>;
|
|
416
|
+
} : unknown));
|
|
163
417
|
export namespace Code {
|
|
164
418
|
/**
|
|
165
419
|
* @summary `AVStantso.NamesTree` utility
|
|
166
420
|
*/
|
|
167
421
|
interface NamesTree {
|
|
168
|
-
<T extends AVStantso.NamesTree.Source.Root, K0 extends AVStantso.NamesTree.Kind, K1 extends Exclude<AVStantso.NamesTree.Kind, K0> = undefined, K2 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1> = undefined, K3 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2> = undefined, K4 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3> = undefined, K5 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4> = undefined, K6 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5> = undefined, K7 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6> = undefined, K8 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6 | K7> = undefined, K9 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6 | K7 | K8> = undefined>(data: T, options:
|
|
422
|
+
<T extends AVStantso.NamesTree.Source.Root, O extends AVStantso.NamesTree.Options, K0 extends AVStantso.NamesTree.Kind, K1 extends Exclude<AVStantso.NamesTree.Kind, K0> = undefined, K2 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1> = undefined, K3 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2> = undefined, K4 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3> = undefined, K5 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4> = undefined, K6 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5> = undefined, K7 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6> = undefined, K8 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6 | K7> = undefined, K9 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6 | K7 | K8> = undefined>(data: T, options: O, kind0: K0, kind1?: K1, kind2?: K2, kind3?: K3, kind4?: K4, kind5?: K5, kind6?: K6, kind7?: K7, kind8?: K8, kind9?: K9): AVStantso.NamesTree<T, O, AVStantso.TS.Array.Filter<AVStantso.TS.Array.Filter.Unique<[
|
|
169
423
|
K0,
|
|
170
424
|
K1,
|
|
171
425
|
K2,
|
|
@@ -176,8 +430,8 @@ declare namespace AVStantso {
|
|
|
176
430
|
K7,
|
|
177
431
|
K8,
|
|
178
432
|
K9
|
|
179
|
-
]
|
|
180
|
-
<T extends AVStantso.NamesTree.Source.Root, K0 extends AVStantso.NamesTree.Kind, K1 extends Exclude<AVStantso.NamesTree.Kind, K0> = undefined, K2 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1> = undefined, K3 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2> = undefined, K4 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3> = undefined, K5 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4> = undefined, K6 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5> = undefined, K7 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6> = undefined, K8 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6 | K7> = undefined, K9 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6 | K7 | K8> = undefined>(data: T, kind0: K0, kind1?: K1, kind2?: K2, kind3?: K3, kind4?: K4, kind5?: K5, kind6?: K6, kind7?: K7, kind8?: K8, kind9?: K9): AVStantso.NamesTree<T, AVStantso.TS.Array.
|
|
433
|
+
]>>>;
|
|
434
|
+
<T extends AVStantso.NamesTree.Source.Root, K0 extends AVStantso.NamesTree.Kind, K1 extends Exclude<AVStantso.NamesTree.Kind, K0> = undefined, K2 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1> = undefined, K3 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2> = undefined, K4 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3> = undefined, K5 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4> = undefined, K6 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5> = undefined, K7 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6> = undefined, K8 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6 | K7> = undefined, K9 extends Exclude<AVStantso.NamesTree.Kind, K0 | K1 | K2 | K3 | K4 | K5 | K6 | K7 | K8> = undefined>(data: T, kind0: K0, kind1?: K1, kind2?: K2, kind3?: K3, kind4?: K4, kind5?: K5, kind6?: K6, kind7?: K7, kind8?: K8, kind9?: K9): AVStantso.NamesTree<T, undefined, AVStantso.TS.Array.Filter<AVStantso.TS.Array.Filter.Unique<[
|
|
181
435
|
K0,
|
|
182
436
|
K1,
|
|
183
437
|
K2,
|
|
@@ -188,7 +442,7 @@ declare namespace AVStantso {
|
|
|
188
442
|
K7,
|
|
189
443
|
K8,
|
|
190
444
|
K9
|
|
191
|
-
]
|
|
445
|
+
]>>>;
|
|
192
446
|
/**
|
|
193
447
|
* @summary Register external `NamesTree` kinds
|
|
194
448
|
*/
|
|
@@ -196,15 +450,19 @@ declare namespace AVStantso {
|
|
|
196
450
|
/**
|
|
197
451
|
* @summary Make `Name` `NamesTree`
|
|
198
452
|
*/
|
|
199
|
-
Names<T extends AVStantso.NamesTree.Source.Root>(data: T, options?:
|
|
453
|
+
Names<T extends AVStantso.NamesTree.Source.Root, O extends AVStantso.NamesTree.Options = undefined>(data: T, options?: O): AVStantso.NamesTree.Presets.Names.Tree<T, O>;
|
|
200
454
|
/**
|
|
201
455
|
* @summary Make `i18n` `NamesTree`
|
|
202
456
|
*/
|
|
203
|
-
I18ns<T extends AVStantso.NamesTree.Source.Root>(data: T, options?:
|
|
457
|
+
I18ns<T extends AVStantso.NamesTree.Source.Root, O extends AVStantso.NamesTree.Options = undefined>(data: T, options?: O): AVStantso.NamesTree.Presets.I18ns.Tree<T, O>;
|
|
204
458
|
/**
|
|
205
459
|
* @summary Make `urls` `NamesTree`
|
|
206
460
|
*/
|
|
207
|
-
Urls<T extends AVStantso.NamesTree.Source.Root>(data: T, options?:
|
|
461
|
+
Urls<T extends AVStantso.NamesTree.Source.Root, O extends AVStantso.NamesTree.Options = undefined>(data: T, options?: O): AVStantso.NamesTree.Presets.Urls.Tree<T, O>;
|
|
462
|
+
/**
|
|
463
|
+
* @summary Symbol for access to `rootAlias` value of property
|
|
464
|
+
*/
|
|
465
|
+
symbolRootAlias: typeof symbolRootAlias;
|
|
208
466
|
}
|
|
209
467
|
}
|
|
210
468
|
export interface Code {
|