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