akanjs 2.3.8-rc.1 → 2.3.8-rc.3
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/base/symbols.ts +3 -0
- package/dictionary/dictInfo.ts +78 -36
- package/dictionary/locale.ts +136 -70
- package/document/filterMeta.ts +18 -2
- package/package.json +1 -1
- package/signal/endpoint.ts +14 -6
- package/signal/slice.ts +11 -3
- package/types/base/symbols.d.ts +3 -0
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictInfo.d.ts +30 -17
- package/types/dictionary/locale.d.ts +42 -43
- package/types/document/filterMeta.d.ts +25 -3
- package/types/signal/endpoint.d.ts +16 -6
- package/types/signal/signalRegistry.d.ts +2 -14
- package/types/signal/slice.d.ts +13 -3
package/base/symbols.ts
CHANGED
|
@@ -4,6 +4,9 @@ export const FILTER_META = Symbol.for("akan.filter");
|
|
|
4
4
|
export const LOADER_META = Symbol.for("akan.loader");
|
|
5
5
|
export const INJECT_META = Symbol.for("akan.inject");
|
|
6
6
|
export const ENDPOINT_META = Symbol.for("akan.endpoint");
|
|
7
|
+
export const ENDPOINT_DICT_SHAPE: unique symbol = Symbol.for("akan.endpoint.dictShape") as never;
|
|
8
|
+
export const SLICE_DICT_SHAPE: unique symbol = Symbol.for("akan.slice.dictShape") as never;
|
|
9
|
+
export const FILTER_DICT_SHAPE: unique symbol = Symbol.for("akan.filter.dictShape") as never;
|
|
7
10
|
export const INTERNAL_META = Symbol.for("akan.internal");
|
|
8
11
|
export const STATE_META = Symbol.for("akan.state");
|
|
9
12
|
export const STATE_INIT_META = Symbol.for("akan.state.init");
|
package/dictionary/dictInfo.ts
CHANGED
|
@@ -1,20 +1,62 @@
|
|
|
1
|
-
import type { GetStateObject } from "akanjs/base";
|
|
1
|
+
import type { ENDPOINT_DICT_SHAPE, FILTER_DICT_SHAPE, GetStateObject, SLICE_DICT_SHAPE } from "akanjs/base";
|
|
2
2
|
import { capitalize } from "akanjs/common";
|
|
3
3
|
import type { BaseInsight, BaseObject } from "akanjs/constant";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
4
|
+
import type {
|
|
5
|
+
BaseFilterQueryKey,
|
|
6
|
+
BaseFilterSortKey,
|
|
7
|
+
FilterCls,
|
|
8
|
+
FilterDictShape as FilterCompactShape,
|
|
9
|
+
FilterDictArgShape,
|
|
10
|
+
FilterInfo,
|
|
11
|
+
FilterInstance,
|
|
12
|
+
} from "akanjs/document";
|
|
13
|
+
import type {
|
|
14
|
+
EndpointCls,
|
|
15
|
+
EndpointDictShape as EndpointCompactShape,
|
|
16
|
+
EndpointInfo,
|
|
17
|
+
SliceCls,
|
|
18
|
+
SliceDictShape as SliceCompactShape,
|
|
19
|
+
SliceInfo,
|
|
20
|
+
} from "akanjs/signal";
|
|
6
21
|
import type { DictionaryNode, RootDictionary } from "./trans";
|
|
7
22
|
|
|
8
23
|
type MutableDictionaryNode = DictionaryNode & { t?: string; desc?: DictionaryNode };
|
|
9
24
|
type EnumValueKey = string | number;
|
|
10
|
-
type
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
? FilterShape
|
|
15
|
-
: Filter extends {
|
|
16
|
-
?
|
|
17
|
-
:
|
|
25
|
+
type DictArgShape = { [key: string]: readonly string[] };
|
|
26
|
+
type AnyFilterShape = FilterCompactShape<FilterInstance<Record<string, FilterInfo>, Record<string, unknown>>>;
|
|
27
|
+
type DictFilterShape<Filter> =
|
|
28
|
+
Filter extends FilterCls<infer FilterShape>
|
|
29
|
+
? FilterCompactShape<FilterShape>
|
|
30
|
+
: Filter extends { readonly [FILTER_DICT_SHAPE]: infer CompactShape extends FilterDictArgShape }
|
|
31
|
+
? CompactShape
|
|
32
|
+
: Filter extends FilterInstance
|
|
33
|
+
? FilterCompactShape<Filter>
|
|
34
|
+
: Filter extends { query: Record<string, FilterInfo>; sort: Record<string, unknown> }
|
|
35
|
+
? FilterCompactShape<Filter>
|
|
36
|
+
: Filter extends { query: DictArgShape; sort: Record<string, true> }
|
|
37
|
+
? Filter
|
|
38
|
+
: AnyFilterShape;
|
|
39
|
+
type DictSliceShape<Slice> =
|
|
40
|
+
Slice extends SliceCls<infer _SrvModule, infer SliceInfoObj>
|
|
41
|
+
? SliceCompactShape<SliceInfoObj>
|
|
42
|
+
: Slice extends { readonly [SLICE_DICT_SHAPE]: infer CompactShape extends DictArgShape }
|
|
43
|
+
? CompactShape
|
|
44
|
+
: Slice extends DictArgShape
|
|
45
|
+
? Slice
|
|
46
|
+
: Slice extends Record<string, SliceInfo>
|
|
47
|
+
? SliceCompactShape<Slice>
|
|
48
|
+
: Record<never, never>;
|
|
49
|
+
type DictEndpointShape<Endpoint> =
|
|
50
|
+
Endpoint extends EndpointCls<infer _SrvModule, infer EndpointInfoObj>
|
|
51
|
+
? EndpointCompactShape<EndpointInfoObj>
|
|
52
|
+
: Endpoint extends { readonly [ENDPOINT_DICT_SHAPE]: infer CompactShape extends DictArgShape }
|
|
53
|
+
? CompactShape
|
|
54
|
+
: Endpoint extends DictArgShape
|
|
55
|
+
? Endpoint
|
|
56
|
+
: Endpoint extends Record<string, EndpointInfo>
|
|
57
|
+
? EndpointCompactShape<Endpoint>
|
|
58
|
+
: Record<never, never>;
|
|
59
|
+
type DictArgNames<ArgNames> = ArgNames extends readonly string[] ? ArgNames[number] : never;
|
|
18
60
|
type DictFilterQuery<Filter> = DictFilterShape<Filter>["query"];
|
|
19
61
|
type DictFilterSort<Filter> = DictFilterShape<Filter>["sort"];
|
|
20
62
|
|
|
@@ -96,7 +138,7 @@ export class ModelDictInfo<
|
|
|
96
138
|
SortKey extends string = BaseFilterSortKey,
|
|
97
139
|
EnumKey extends string = never,
|
|
98
140
|
BaseSignalKey extends string = never,
|
|
99
|
-
SliceKey extends string =
|
|
141
|
+
SliceKey extends string = "",
|
|
100
142
|
EndpointKey extends string = never,
|
|
101
143
|
ErrorKey extends string = never,
|
|
102
144
|
EtcKey extends string = never,
|
|
@@ -162,7 +204,7 @@ export class ModelDictInfo<
|
|
|
162
204
|
static baseSliceDictionary: {
|
|
163
205
|
[key in ""]: FunctionTranslation<[string, string], "query">;
|
|
164
206
|
} = {
|
|
165
|
-
|
|
207
|
+
"": fn(["Universal", "유니버설"])
|
|
166
208
|
.desc(["Universal Slice", "유니버설 슬라이스"])
|
|
167
209
|
.arg((t) => ({
|
|
168
210
|
query: t(["Query", "쿼리"]).desc(["Query Description", "쿼리 설명"]),
|
|
@@ -262,19 +304,14 @@ export class ModelDictInfo<
|
|
|
262
304
|
}
|
|
263
305
|
query<Filter>(
|
|
264
306
|
translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
265
|
-
[K in Exclude<keyof DictFilterQuery<Filter>, QueryKey>]:
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
? FunctionTranslation<Languages, ArgNames[number]>
|
|
270
|
-
: never;
|
|
307
|
+
[K in Exclude<keyof DictFilterQuery<Filter>, QueryKey>]: FunctionTranslation<
|
|
308
|
+
Languages,
|
|
309
|
+
DictArgNames<DictFilterQuery<Filter>[K]>
|
|
310
|
+
>;
|
|
271
311
|
},
|
|
272
312
|
) {
|
|
273
313
|
Object.assign(this.queryDictionary, translate(fn), ModelDictInfo.baseQueryDictionary) as unknown as {
|
|
274
|
-
[K in keyof DictFilterQuery<Filter>]: FunctionTranslation<
|
|
275
|
-
Languages,
|
|
276
|
-
DictFilterQuery<Filter>[K] extends FilterInfo<infer ArgNames, any> ? ArgNames[number] : never
|
|
277
|
-
>;
|
|
314
|
+
[K in keyof DictFilterQuery<Filter>]: FunctionTranslation<Languages, DictArgNames<DictFilterQuery<Filter>[K]>>;
|
|
278
315
|
};
|
|
279
316
|
return this as unknown as ModelDictInfo<
|
|
280
317
|
Languages,
|
|
@@ -340,13 +377,14 @@ export class ModelDictInfo<
|
|
|
340
377
|
}
|
|
341
378
|
slice<Slice>(
|
|
342
379
|
translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
343
|
-
[K in Exclude<keyof Slice
|
|
344
|
-
|
|
345
|
-
|
|
380
|
+
[K in Exclude<keyof DictSliceShape<Slice>, SliceKey>]: FunctionTranslation<
|
|
381
|
+
Languages,
|
|
382
|
+
DictArgNames<DictSliceShape<Slice>[K]>
|
|
383
|
+
>;
|
|
346
384
|
},
|
|
347
385
|
) {
|
|
348
386
|
Object.assign(this.sliceDictionary, translate(fn), ModelDictInfo.baseSliceDictionary) as unknown as {
|
|
349
|
-
[K in keyof Slice]: FunctionTranslation<Languages>;
|
|
387
|
+
[K in keyof DictSliceShape<Slice>]: FunctionTranslation<Languages>;
|
|
350
388
|
};
|
|
351
389
|
return this as unknown as ModelDictInfo<
|
|
352
390
|
Languages,
|
|
@@ -356,7 +394,7 @@ export class ModelDictInfo<
|
|
|
356
394
|
SortKey,
|
|
357
395
|
EnumKey,
|
|
358
396
|
BaseSignalKey,
|
|
359
|
-
keyof Slice & string,
|
|
397
|
+
keyof DictSliceShape<Slice> & string,
|
|
360
398
|
EndpointKey,
|
|
361
399
|
ErrorKey,
|
|
362
400
|
EtcKey
|
|
@@ -364,9 +402,10 @@ export class ModelDictInfo<
|
|
|
364
402
|
}
|
|
365
403
|
endpoint<Endpoint>(
|
|
366
404
|
translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
367
|
-
[K in Exclude<keyof Endpoint
|
|
368
|
-
|
|
369
|
-
|
|
405
|
+
[K in Exclude<keyof DictEndpointShape<Endpoint>, EndpointKey>]: FunctionTranslation<
|
|
406
|
+
Languages,
|
|
407
|
+
DictArgNames<DictEndpointShape<Endpoint>[K]>
|
|
408
|
+
>;
|
|
370
409
|
},
|
|
371
410
|
) {
|
|
372
411
|
Object.assign(this.endpointDictionary, translate(fn)) as unknown as {
|
|
@@ -381,7 +420,7 @@ export class ModelDictInfo<
|
|
|
381
420
|
EnumKey,
|
|
382
421
|
BaseSignalKey,
|
|
383
422
|
SliceKey,
|
|
384
|
-
keyof Endpoint & string,
|
|
423
|
+
keyof DictEndpointShape<Endpoint> & string,
|
|
385
424
|
ErrorKey,
|
|
386
425
|
EtcKey
|
|
387
426
|
>;
|
|
@@ -777,7 +816,7 @@ type MergeTwoModelDicts<ModelDict1, ModelDict2> =
|
|
|
777
816
|
infer EtcKey1
|
|
778
817
|
>
|
|
779
818
|
? ModelDict2 extends ModelDictInfo<
|
|
780
|
-
|
|
819
|
+
infer _Languages2,
|
|
781
820
|
infer ModelKey2,
|
|
782
821
|
infer InsightKey2,
|
|
783
822
|
infer QueryKey2,
|
|
@@ -980,15 +1019,18 @@ export class ServiceDictInfo<
|
|
|
980
1019
|
constructor(languages: Languages) {
|
|
981
1020
|
this.languages = languages;
|
|
982
1021
|
}
|
|
983
|
-
endpoint<Endpoint
|
|
1022
|
+
endpoint<Endpoint>(
|
|
984
1023
|
translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
985
|
-
[K in keyof Endpoint]: FunctionTranslation<
|
|
1024
|
+
[K in keyof DictEndpointShape<Endpoint>]: FunctionTranslation<
|
|
1025
|
+
Languages,
|
|
1026
|
+
DictArgNames<DictEndpointShape<Endpoint>[K]>
|
|
1027
|
+
>;
|
|
986
1028
|
},
|
|
987
1029
|
) {
|
|
988
1030
|
Object.assign(this.endpointDictionary, translate(fn)) as unknown as {
|
|
989
1031
|
[K in EndpointKey]: FunctionTranslation<Languages>;
|
|
990
1032
|
};
|
|
991
|
-
return this as unknown as ServiceDictInfo<Languages, keyof Endpoint & string, ErrorKey, EtcKey>;
|
|
1033
|
+
return this as unknown as ServiceDictInfo<Languages, keyof DictEndpointShape<Endpoint> & string, ErrorKey, EtcKey>;
|
|
992
1034
|
}
|
|
993
1035
|
error<ErrorDict extends { [key: string]: Languages }>(errorDictionary: ErrorDict) {
|
|
994
1036
|
Object.assign(this.errorDictionary, errorDictionary);
|
package/dictionary/locale.ts
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ENDPOINT_DICT_SHAPE,
|
|
3
|
+
FILTER_DICT_SHAPE,
|
|
4
|
+
GetStateObject,
|
|
5
|
+
MergedValues,
|
|
6
|
+
SLICE_DICT_SHAPE,
|
|
7
|
+
} from "akanjs/base";
|
|
2
8
|
import type { BaseInsight, BaseObject } from "akanjs/constant";
|
|
3
|
-
import type {
|
|
4
|
-
|
|
9
|
+
import type {
|
|
10
|
+
FilterCls,
|
|
11
|
+
FilterDictShape as FilterCompactShape,
|
|
12
|
+
FilterDictArgShape,
|
|
13
|
+
FilterInfo,
|
|
14
|
+
FilterInstance,
|
|
15
|
+
} from "akanjs/document";
|
|
16
|
+
import type {
|
|
17
|
+
EndpointCls,
|
|
18
|
+
EndpointDictShape as EndpointCompactShape,
|
|
19
|
+
EndpointInfo,
|
|
20
|
+
SliceCls,
|
|
21
|
+
SliceDictShape as SliceCompactShape,
|
|
22
|
+
SliceInfo,
|
|
23
|
+
SliceInfoArgNames,
|
|
24
|
+
SliceInfoRefName,
|
|
25
|
+
} from "akanjs/signal";
|
|
5
26
|
import type { ModelDictInfo, ScalarDictInfo, ServiceDictInfo } from ".";
|
|
6
27
|
|
|
7
28
|
interface Trans {
|
|
@@ -16,34 +37,61 @@ interface FnTrans<ArgKey extends string> {
|
|
|
16
37
|
desc?: string;
|
|
17
38
|
arg?: { [key in ArgKey]: FieldTrans };
|
|
18
39
|
}
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
? FilterShape
|
|
24
|
-
: Filter extends {
|
|
25
|
-
?
|
|
26
|
-
:
|
|
40
|
+
type DictArgShape = { [key: string]: readonly string[] };
|
|
41
|
+
type AnyFilterShape = FilterCompactShape<FilterInstance<Record<string, FilterInfo>, Record<string, unknown>>>;
|
|
42
|
+
type DictFilterShape<Filter> =
|
|
43
|
+
Filter extends FilterCls<infer FilterShape>
|
|
44
|
+
? FilterCompactShape<FilterShape>
|
|
45
|
+
: Filter extends { readonly [FILTER_DICT_SHAPE]: infer CompactShape extends FilterDictArgShape }
|
|
46
|
+
? CompactShape
|
|
47
|
+
: Filter extends FilterInstance
|
|
48
|
+
? FilterCompactShape<Filter>
|
|
49
|
+
: Filter extends { query: Record<string, FilterInfo>; sort: Record<string, unknown> }
|
|
50
|
+
? FilterCompactShape<Filter>
|
|
51
|
+
: Filter extends { query: DictArgShape; sort: Record<string, true> }
|
|
52
|
+
? Filter
|
|
53
|
+
: AnyFilterShape;
|
|
27
54
|
type DictFilterQuery<Filter> = DictFilterShape<Filter>["query"];
|
|
28
55
|
type DictFilterSort<Filter> = DictFilterShape<Filter>["sort"];
|
|
56
|
+
type DictArgNames<ArgNames> = ArgNames extends readonly string[] ? ArgNames[number] : never;
|
|
57
|
+
type DictEndpointShape<Endpoint> =
|
|
58
|
+
Endpoint extends EndpointCls<infer _SrvModule, infer EndpointInfoObj>
|
|
59
|
+
? EndpointCompactShape<EndpointInfoObj>
|
|
60
|
+
: Endpoint extends { readonly [ENDPOINT_DICT_SHAPE]: infer CompactShape extends DictArgShape }
|
|
61
|
+
? CompactShape
|
|
62
|
+
: Endpoint extends DictArgShape
|
|
63
|
+
? Endpoint
|
|
64
|
+
: Endpoint extends Record<string, EndpointInfo>
|
|
65
|
+
? EndpointCompactShape<Endpoint>
|
|
66
|
+
: Record<never, never>;
|
|
67
|
+
type DictSliceShape<Slice> =
|
|
68
|
+
Slice extends SliceCls<infer _SrvModule, infer SliceInfoObj>
|
|
69
|
+
? SliceCompactShape<SliceInfoObj>
|
|
70
|
+
: Slice extends { readonly [SLICE_DICT_SHAPE]: infer CompactShape extends DictArgShape }
|
|
71
|
+
? CompactShape
|
|
72
|
+
: Slice extends DictArgShape
|
|
73
|
+
? Slice
|
|
74
|
+
: Slice extends Record<string, SliceInfo>
|
|
75
|
+
? SliceCompactShape<Slice>
|
|
76
|
+
: Record<never, never>;
|
|
29
77
|
type FilterTranslatorKey<Filter> = {
|
|
30
78
|
[Key in keyof DictFilterQuery<Filter> & string]:
|
|
31
79
|
| `${Key}`
|
|
32
80
|
| `${Key}.desc`
|
|
33
|
-
| (DictFilterQuery<Filter>[Key] extends
|
|
34
|
-
?
|
|
35
|
-
|
|
36
|
-
|
|
81
|
+
| (DictArgNames<DictFilterQuery<Filter>[Key]> extends string
|
|
82
|
+
?
|
|
83
|
+
| `${Key}.arg.${DictArgNames<DictFilterQuery<Filter>[Key]>}`
|
|
84
|
+
| `${Key}.arg.${DictArgNames<DictFilterQuery<Filter>[Key]>}.desc`
|
|
37
85
|
: never);
|
|
38
86
|
}[keyof DictFilterQuery<Filter> & string];
|
|
39
|
-
type EndpointTranslatorKey<Endpoint
|
|
40
|
-
[Key in keyof Endpoint & string]:
|
|
87
|
+
type EndpointTranslatorKey<Endpoint> = {
|
|
88
|
+
[Key in keyof DictEndpointShape<Endpoint> & string]:
|
|
41
89
|
| `${Key}`
|
|
42
90
|
| `${Key}.desc`
|
|
43
|
-
| `${Key}.arg.${
|
|
44
|
-
| `${Key}.arg.${
|
|
45
|
-
}[keyof Endpoint & string];
|
|
46
|
-
type
|
|
91
|
+
| `${Key}.arg.${DictArgNames<DictEndpointShape<Endpoint>[Key]>}`
|
|
92
|
+
| `${Key}.arg.${DictArgNames<DictEndpointShape<Endpoint>[Key]>}.desc`;
|
|
93
|
+
}[keyof DictEndpointShape<Endpoint> & string];
|
|
94
|
+
type FullSliceTranslatorKey<Slice> = {
|
|
47
95
|
[Key in keyof Slice & string]: Slice[Key] extends infer Info extends SliceInfo
|
|
48
96
|
?
|
|
49
97
|
| `${SliceInfoRefName<Info>}List${Capitalize<Key>}`
|
|
@@ -56,6 +104,21 @@ type SliceTranslatorKey<Slice> = {
|
|
|
56
104
|
| `${SliceInfoRefName<Info>}Insight${Capitalize<Key>}.arg.${SliceInfoArgNames<Info>[number]}.desc`
|
|
57
105
|
: never;
|
|
58
106
|
}[keyof Slice & string];
|
|
107
|
+
type CompactSliceTranslatorKey<T extends string, Slice> = {
|
|
108
|
+
[Key in keyof DictSliceShape<Slice> & string]: Key extends ""
|
|
109
|
+
? never
|
|
110
|
+
:
|
|
111
|
+
| `${T}List${Capitalize<Key>}`
|
|
112
|
+
| `${T}List${Capitalize<Key>}.desc`
|
|
113
|
+
| `${T}List${Capitalize<Key>}.arg.${DictArgNames<DictSliceShape<Slice>[Key]> | "skip" | "limit" | "sort"}`
|
|
114
|
+
| `${T}List${Capitalize<Key>}.arg.${DictArgNames<DictSliceShape<Slice>[Key]> | "skip" | "limit" | "sort"}.desc`
|
|
115
|
+
| `${T}Insight${Capitalize<Key>}`
|
|
116
|
+
| `${T}Insight${Capitalize<Key>}.desc`
|
|
117
|
+
| `${T}Insight${Capitalize<Key>}.arg.${DictArgNames<DictSliceShape<Slice>[Key]>}`
|
|
118
|
+
| `${T}Insight${Capitalize<Key>}.arg.${DictArgNames<DictSliceShape<Slice>[Key]>}.desc`;
|
|
119
|
+
}[keyof DictSliceShape<Slice> & string];
|
|
120
|
+
type SliceTranslatorKey<T extends string, Slice> =
|
|
121
|
+
Slice extends Record<string, SliceInfo> ? FullSliceTranslatorKey<Slice> : CompactSliceTranslatorKey<T, Slice>;
|
|
59
122
|
|
|
60
123
|
type SliceApiTrans<
|
|
61
124
|
T extends string,
|
|
@@ -84,8 +147,8 @@ export type ModelTrans<
|
|
|
84
147
|
Model extends BaseObject,
|
|
85
148
|
Insight extends BaseInsight,
|
|
86
149
|
Filter,
|
|
87
|
-
Slice
|
|
88
|
-
Endpoint
|
|
150
|
+
Slice,
|
|
151
|
+
Endpoint,
|
|
89
152
|
ErrorKey extends string,
|
|
90
153
|
EtcKey extends string,
|
|
91
154
|
> = {
|
|
@@ -94,38 +157,28 @@ export type ModelTrans<
|
|
|
94
157
|
model: { [K in keyof GetStateObject<Model>]: FieldTrans };
|
|
95
158
|
insight: { [K in keyof GetStateObject<Insight>]: FieldTrans };
|
|
96
159
|
query: {
|
|
97
|
-
[K in keyof DictFilterQuery<Filter>]: DictFilterQuery<Filter>[K]
|
|
98
|
-
? FnTrans<ArgNames[number]>
|
|
99
|
-
: never;
|
|
160
|
+
[K in keyof DictFilterQuery<Filter>]: FnTrans<DictArgNames<DictFilterQuery<Filter>[K]>>;
|
|
100
161
|
};
|
|
101
162
|
sort: { [K in keyof DictFilterSort<Filter>]: FieldTrans };
|
|
102
163
|
api: {
|
|
103
|
-
[K in keyof Endpoint]: FnTrans<
|
|
164
|
+
[K in keyof DictEndpointShape<Endpoint>]: FnTrans<DictArgNames<DictEndpointShape<Endpoint>[K]>>;
|
|
104
165
|
} & BaseModelCrudGetApiTrans<T> &
|
|
105
166
|
MergedValues<{
|
|
106
|
-
[K in keyof Slice]: SliceApiTrans<
|
|
167
|
+
[K in keyof DictSliceShape<Slice>]: SliceApiTrans<T, K & string, DictArgNames<DictSliceShape<Slice>[K]>>;
|
|
107
168
|
}>;
|
|
108
169
|
error: { [K in ErrorKey]: Trans };
|
|
109
170
|
} & { [K in EtcKey]: Trans };
|
|
110
|
-
export type ModelTranslatorKey<
|
|
111
|
-
T extends string,
|
|
112
|
-
Model,
|
|
113
|
-
Insight,
|
|
114
|
-
Filter,
|
|
115
|
-
Slice extends { [key: string]: SliceInfo },
|
|
116
|
-
Endpoint extends { [key: string]: EndpointInfo },
|
|
117
|
-
EtcKey extends string,
|
|
118
|
-
> =
|
|
171
|
+
export type ModelTranslatorKey<T extends string, Model, Insight, Filter, Slice, Endpoint, EtcKey extends string> =
|
|
119
172
|
| `${T}.modelName`
|
|
120
173
|
| `${T}.modelDesc`
|
|
121
174
|
| `${T}.${keyof GetStateObject<Model> & string}${"" | ".desc"}`
|
|
122
175
|
| `${T}.insight.${keyof GetStateObject<Insight> & string}${"" | ".desc"}`
|
|
123
176
|
| `${T}.query.${FilterTranslatorKey<Filter>}`
|
|
124
177
|
| `${T}.sort.${keyof DictFilterSort<Filter> & string}${"" | ".desc"}`
|
|
125
|
-
| `${T}.signal.${EndpointTranslatorKey<Endpoint> | SliceTranslatorKey<Slice>}`
|
|
178
|
+
| `${T}.signal.${EndpointTranslatorKey<Endpoint> | SliceTranslatorKey<T, Slice>}`
|
|
126
179
|
| `${T}.${EtcKey}`;
|
|
127
180
|
|
|
128
|
-
export type ScalarTrans<
|
|
181
|
+
export type ScalarTrans<_T extends string, Model, ErrorKey extends string, EtcKey extends string> = {
|
|
129
182
|
name: Trans;
|
|
130
183
|
desc: Trans;
|
|
131
184
|
model: { [K in keyof GetStateObject<Model>]: FieldTrans };
|
|
@@ -137,22 +190,15 @@ export type ScalarTranslatorKey<T extends string, Model, EtcKey extends string>
|
|
|
137
190
|
| `${T}.${keyof GetStateObject<Model> & string}${"" | ".desc"}`
|
|
138
191
|
| `${T}.${EtcKey}`;
|
|
139
192
|
|
|
140
|
-
export type ServiceTrans<
|
|
141
|
-
T extends string,
|
|
142
|
-
Endpoint extends { [key: string]: EndpointInfo },
|
|
143
|
-
ErrorKey extends string,
|
|
144
|
-
EtcKey extends string,
|
|
145
|
-
> = {
|
|
193
|
+
export type ServiceTrans<_T extends string, Endpoint, ErrorKey extends string, EtcKey extends string> = {
|
|
146
194
|
api: {
|
|
147
|
-
[K in keyof Endpoint]: FnTrans<
|
|
195
|
+
[K in keyof DictEndpointShape<Endpoint>]: FnTrans<DictArgNames<DictEndpointShape<Endpoint>[K]>>;
|
|
148
196
|
};
|
|
149
197
|
error: { [K in ErrorKey]: Trans };
|
|
150
198
|
} & { [K in EtcKey]: Trans };
|
|
151
|
-
export type ServiceTranslatorKey<
|
|
152
|
-
T
|
|
153
|
-
|
|
154
|
-
EtcKey extends string,
|
|
155
|
-
> = `${T}.signal.${EndpointTranslatorKey<Endpoint>}` | `${T}.${EtcKey}`;
|
|
199
|
+
export type ServiceTranslatorKey<T extends string, Endpoint, EtcKey extends string> =
|
|
200
|
+
| `${T}.signal.${EndpointTranslatorKey<Endpoint>}`
|
|
201
|
+
| `${T}.${EtcKey}`;
|
|
156
202
|
|
|
157
203
|
export type EnumTrans<EnumValue extends string | number> = {
|
|
158
204
|
[key in EnumValue]: Trans;
|
|
@@ -162,7 +208,10 @@ export type EnumTranslatorKey<EnumKey extends string> = `${EnumKey}.${string}${"
|
|
|
162
208
|
export interface DictModule<DictKey extends string, ErrorKey extends string> {
|
|
163
209
|
__Dict_Key__: DictKey;
|
|
164
210
|
__Error_Key__: ErrorKey;
|
|
165
|
-
dict:
|
|
211
|
+
dict:
|
|
212
|
+
| ModelDictInfo<[string, ...string[]]>
|
|
213
|
+
| ScalarDictInfo<[string, ...string[]]>
|
|
214
|
+
| ServiceDictInfo<[string, ...string[]]>;
|
|
166
215
|
}
|
|
167
216
|
|
|
168
217
|
export const registerModelTrans = <
|
|
@@ -170,27 +219,39 @@ export const registerModelTrans = <
|
|
|
170
219
|
Model extends BaseObject,
|
|
171
220
|
Insight extends BaseInsight,
|
|
172
221
|
Filter,
|
|
173
|
-
Slice
|
|
174
|
-
Endpoint
|
|
175
|
-
ModelDict
|
|
222
|
+
Slice,
|
|
223
|
+
Endpoint,
|
|
224
|
+
ModelDict,
|
|
176
225
|
>(
|
|
177
226
|
modelDict: ModelDict,
|
|
178
|
-
): ModelDict extends ModelDictInfo<
|
|
227
|
+
): ModelDict extends ModelDictInfo<
|
|
228
|
+
infer _Languages,
|
|
229
|
+
infer _ModelKey,
|
|
230
|
+
infer _InsightKey,
|
|
231
|
+
infer _QueryKey,
|
|
232
|
+
infer _SortKey,
|
|
233
|
+
infer EnumKey,
|
|
234
|
+
infer _BaseSignalKey,
|
|
235
|
+
infer _SliceKey,
|
|
236
|
+
infer _EndpointKey,
|
|
237
|
+
infer ErrorKey,
|
|
238
|
+
infer EtcKey
|
|
239
|
+
>
|
|
179
240
|
? DictModule<
|
|
180
241
|
ModelTranslatorKey<RefName, Model, Insight, Filter, Slice, Endpoint, EtcKey> | EnumTranslatorKey<EnumKey>,
|
|
181
242
|
`${RefName}.error.${ErrorKey}`
|
|
182
243
|
>
|
|
183
244
|
: never => {
|
|
184
245
|
return { dict: modelDict } as unknown as ModelDict extends ModelDictInfo<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
246
|
+
infer _Languages,
|
|
247
|
+
infer _ModelKey,
|
|
248
|
+
infer _InsightKey,
|
|
249
|
+
infer _QueryKey,
|
|
250
|
+
infer _SortKey,
|
|
190
251
|
infer EnumKey,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
252
|
+
infer _BaseSignalKey,
|
|
253
|
+
infer _SliceKey,
|
|
254
|
+
infer _EndpointKey,
|
|
194
255
|
infer ErrorKey,
|
|
195
256
|
infer EtcKey
|
|
196
257
|
>
|
|
@@ -203,12 +264,12 @@ export const registerModelTrans = <
|
|
|
203
264
|
|
|
204
265
|
export const registerScalarTrans = <T extends string, Model, ScalarDict>(
|
|
205
266
|
scalarDict: ScalarDict,
|
|
206
|
-
): ScalarDict extends ScalarDictInfo<
|
|
267
|
+
): ScalarDict extends ScalarDictInfo<infer _Languages, infer _ModelKey, infer EnumKey, infer ErrorKey, infer EtcKey>
|
|
207
268
|
? DictModule<ScalarTranslatorKey<T, Model, EtcKey> | EnumTranslatorKey<EnumKey>, `${T}.error.${ErrorKey}`>
|
|
208
269
|
: never => {
|
|
209
270
|
return { dict: scalarDict } as unknown as ScalarDict extends ScalarDictInfo<
|
|
210
|
-
|
|
211
|
-
|
|
271
|
+
infer _Languages,
|
|
272
|
+
infer _ModelKey,
|
|
212
273
|
infer EnumKey,
|
|
213
274
|
infer ErrorKey,
|
|
214
275
|
infer EtcKey
|
|
@@ -217,12 +278,17 @@ export const registerScalarTrans = <T extends string, Model, ScalarDict>(
|
|
|
217
278
|
: never;
|
|
218
279
|
};
|
|
219
280
|
|
|
220
|
-
export const registerServiceTrans = <T extends string, Endpoint
|
|
281
|
+
export const registerServiceTrans = <T extends string, Endpoint, ServiceDict>(
|
|
221
282
|
serviceDict: ServiceDict,
|
|
222
|
-
): ServiceDict extends ServiceDictInfo<
|
|
283
|
+
): ServiceDict extends ServiceDictInfo<infer _Languages, infer _EndpointKey, infer ErrorKey, infer EtcKey>
|
|
223
284
|
? DictModule<ServiceTranslatorKey<T, Endpoint, EtcKey>, `${T}.error.${ErrorKey}`>
|
|
224
285
|
: never => {
|
|
225
|
-
return { dict: serviceDict } as unknown as ServiceDict extends ServiceDictInfo<
|
|
286
|
+
return { dict: serviceDict } as unknown as ServiceDict extends ServiceDictInfo<
|
|
287
|
+
infer _Languages,
|
|
288
|
+
infer _EndpointKey,
|
|
289
|
+
infer ErrorKey,
|
|
290
|
+
infer EtcKey
|
|
291
|
+
>
|
|
226
292
|
? DictModule<ServiceTranslatorKey<T, Endpoint, EtcKey>, `${T}.error.${ErrorKey}`>
|
|
227
293
|
: never;
|
|
228
294
|
};
|
package/document/filterMeta.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Cls, MergeAllDoubleKeyOfObjects, MergeAllKeyOfTypes } from "akanjs/base";
|
|
2
|
-
import { FILTER_META } from "akanjs/base";
|
|
2
|
+
import { FILTER_DICT_SHAPE, FILTER_META } from "akanjs/base";
|
|
3
3
|
import type {
|
|
4
4
|
BaseObject,
|
|
5
5
|
ConstantFieldTypeInput,
|
|
@@ -109,6 +109,21 @@ export type FilterInstance<
|
|
|
109
109
|
query: Query;
|
|
110
110
|
sort: Sort;
|
|
111
111
|
};
|
|
112
|
+
export type FilterDictArgShape = {
|
|
113
|
+
query: { [key: string]: readonly string[] };
|
|
114
|
+
sort: { [key: string]: true };
|
|
115
|
+
};
|
|
116
|
+
export type FilterDictShape<Filter extends FilterInstance> = {
|
|
117
|
+
query: {
|
|
118
|
+
[K in keyof Filter["query"]]: Filter["query"][K] extends FilterInfo<infer ArgNames, infer _Args, infer _Model>
|
|
119
|
+
? ArgNames
|
|
120
|
+
: never;
|
|
121
|
+
};
|
|
122
|
+
sort: { [K in keyof Filter["sort"]]: true };
|
|
123
|
+
};
|
|
124
|
+
export interface FilterDictShapeCarrier<DictShape extends FilterDictArgShape = FilterDictArgShape> {
|
|
125
|
+
readonly [FILTER_DICT_SHAPE]: DictShape;
|
|
126
|
+
}
|
|
112
127
|
interface BaseQuery<Model> {
|
|
113
128
|
any: FilterInfo<[], [], Model>;
|
|
114
129
|
}
|
|
@@ -140,8 +155,9 @@ export type ExtractQuery<Filter extends FilterInstance> = {
|
|
|
140
155
|
};
|
|
141
156
|
export type ExtractSort<Filter extends FilterInstance> = keyof Filter["sort"];
|
|
142
157
|
export interface FilterCls<Filter extends FilterInstance = any, Query = unknown, Sort = unknown>
|
|
143
|
-
extends Cls<{ [key: string]:
|
|
158
|
+
extends Cls<FilterDictShapeCarrier<FilterDictShape<Filter>> & { [key: string]: unknown }> {
|
|
144
159
|
[FILTER_META]: Filter;
|
|
160
|
+
prototype: FilterDictShapeCarrier<FilterDictShape<Filter>> & { [key: string]: unknown };
|
|
145
161
|
sortField: Set<string>;
|
|
146
162
|
_Query: Query;
|
|
147
163
|
_Sort: Sort;
|
package/package.json
CHANGED
package/signal/endpoint.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import type { Assign } from "akanjs/base";
|
|
2
|
-
import { ENDPOINT_META } from "akanjs/base";
|
|
2
|
+
import { ENDPOINT_DICT_SHAPE, ENDPOINT_META } from "akanjs/base";
|
|
3
3
|
import { applyMixins } from "akanjs/common";
|
|
4
4
|
import { type Adaptor, type AdaptorCls, dangerouslyAdapt, type ServiceModel } from "akanjs/service";
|
|
5
|
-
import { buildEndpoint, type EndpointBuilder, type EndpointInfo } from "./endpointInfo";
|
|
5
|
+
import { buildEndpoint, type EndpInfoArgNames, type EndpointBuilder, type EndpointInfo } from "./endpointInfo";
|
|
6
6
|
import type { SrvRefName } from "./types";
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export type EndpointDictArgShape = { [key: string]: readonly string[] };
|
|
9
|
+
export type EndpointDictShape<EndpointInfoObj extends { [key: string]: EndpointInfo }> = {
|
|
10
|
+
[K in keyof EndpointInfoObj]: EndpInfoArgNames<EndpointInfoObj[K]>;
|
|
11
|
+
};
|
|
9
12
|
|
|
10
|
-
export interface
|
|
13
|
+
export interface Endpoint<DictShape extends EndpointDictArgShape = Record<never, never>> extends Adaptor {
|
|
14
|
+
readonly [ENDPOINT_DICT_SHAPE]: DictShape;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type EndpointCls<
|
|
11
18
|
SrvModule extends ServiceModel = ServiceModel,
|
|
12
19
|
EndpointInfoObj extends { [key: string]: EndpointInfo } = { [key: string]: EndpointInfo },
|
|
13
|
-
>
|
|
20
|
+
> = AdaptorCls<Endpoint<EndpointDictShape<EndpointInfoObj>>> & {
|
|
14
21
|
baseName: SrvRefName<SrvModule>;
|
|
15
22
|
srv: SrvModule;
|
|
23
|
+
prototype: Endpoint<EndpointDictShape<EndpointInfoObj>>;
|
|
16
24
|
[ENDPOINT_META]: EndpointInfoObj;
|
|
17
|
-
}
|
|
25
|
+
};
|
|
18
26
|
|
|
19
27
|
type EndpointMetaOf<EndpCls> = EndpCls extends EndpointCls<any, infer EndpointInfoObj> ? EndpointInfoObj : never;
|
|
20
28
|
|
package/signal/slice.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Any, type Assign, type Cls, type MergeAllKeyOfObjects, SLICE_META } from "akanjs/base";
|
|
1
|
+
import { Any, type Assign, type Cls, type MergeAllKeyOfObjects, SLICE_DICT_SHAPE, SLICE_META } from "akanjs/base";
|
|
2
2
|
import { applyMixins } from "akanjs/common";
|
|
3
3
|
import type { DocumentModel, QueryOf } from "akanjs/constant";
|
|
4
4
|
import type { FilterInstance } from "akanjs/document";
|
|
@@ -16,14 +16,22 @@ import {
|
|
|
16
16
|
} from "./sliceInfo";
|
|
17
17
|
import type { CnstFull, CnstInput, CnstInsight, CnstLight, DbFilter, SrvMap, SrvRefName } from "./types";
|
|
18
18
|
|
|
19
|
-
export
|
|
19
|
+
export type SliceDictArgShape = { [key: string]: readonly string[] };
|
|
20
|
+
export type SliceDictShape<SliceInfoObj extends { [key: string]: SliceInfo }> = {
|
|
21
|
+
[K in keyof SliceInfoObj]: SliceInfoArgNames<SliceInfoObj[K]>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export interface Slice<DictShape extends SliceDictArgShape = Record<never, never>> extends Adaptor {
|
|
25
|
+
readonly [SLICE_DICT_SHAPE]: DictShape;
|
|
26
|
+
}
|
|
20
27
|
|
|
21
28
|
export type SliceCls<
|
|
22
29
|
SrvModule extends ServiceModel = ServiceModel,
|
|
23
30
|
SliceInfoObj extends { [key: string]: SliceInfo } = { [key: string]: SliceInfo },
|
|
24
|
-
> = AdaptorCls & {
|
|
31
|
+
> = AdaptorCls<Slice<SliceDictShape<SliceInfoObj>>> & {
|
|
25
32
|
baseName: SrvRefName<SrvModule>;
|
|
26
33
|
srv: SrvModule;
|
|
34
|
+
prototype: Slice<SliceDictShape<SliceInfoObj>>;
|
|
27
35
|
[SLICE_META]: SliceInfoObj;
|
|
28
36
|
getGuards: GuardCls[];
|
|
29
37
|
cruGuards: GuardCls[];
|
package/types/base/symbols.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ export declare const FILTER_META: unique symbol;
|
|
|
4
4
|
export declare const LOADER_META: unique symbol;
|
|
5
5
|
export declare const INJECT_META: unique symbol;
|
|
6
6
|
export declare const ENDPOINT_META: unique symbol;
|
|
7
|
+
export declare const ENDPOINT_DICT_SHAPE: unique symbol;
|
|
8
|
+
export declare const SLICE_DICT_SHAPE: unique symbol;
|
|
9
|
+
export declare const FILTER_DICT_SHAPE: unique symbol;
|
|
7
10
|
export declare const INTERNAL_META: unique symbol;
|
|
8
11
|
export declare const STATE_META: unique symbol;
|
|
9
12
|
export declare const STATE_INIT_META: unique symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const baseDictionary: import("./dictInfo.d.ts").ServiceDictInfo<[string, string],
|
|
1
|
+
export declare const baseDictionary: import("./dictInfo.d.ts").ServiceDictInfo<[string, string], "ping" | "pingBody" | "pingParam" | "pingQuery" | "wsPing" | "pubsubPing", never, "error" | "save" | "password" | "remove" | "ok" | "connecting" | "failed" | "cancel" | "success" | "edit" | "view" | "somethingWrong" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "unauthorized" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "actions" | "new">;
|
|
@@ -1,14 +1,29 @@
|
|
|
1
|
-
import type { GetStateObject } from "akanjs/base";
|
|
1
|
+
import type { ENDPOINT_DICT_SHAPE, FILTER_DICT_SHAPE, GetStateObject, SLICE_DICT_SHAPE } from "akanjs/base";
|
|
2
2
|
import type { BaseInsight, BaseObject } from "akanjs/constant";
|
|
3
|
-
import type { BaseFilterQueryKey, BaseFilterSortKey, FilterCls, FilterInfo, FilterInstance } from "akanjs/document";
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseFilterQueryKey, BaseFilterSortKey, FilterCls, FilterDictShape as FilterCompactShape, FilterDictArgShape, FilterInfo, FilterInstance } from "akanjs/document";
|
|
4
|
+
import type { EndpointCls, EndpointDictShape as EndpointCompactShape, EndpointInfo, SliceCls, SliceDictShape as SliceCompactShape, SliceInfo } from "akanjs/signal";
|
|
5
5
|
import type { RootDictionary } from "./trans.d.ts";
|
|
6
6
|
type EnumValueKey = string | number;
|
|
7
|
-
type
|
|
8
|
-
|
|
7
|
+
type DictArgShape = {
|
|
8
|
+
[key: string]: readonly string[];
|
|
9
|
+
};
|
|
10
|
+
type AnyFilterShape = FilterCompactShape<FilterInstance<Record<string, FilterInfo>, Record<string, unknown>>>;
|
|
11
|
+
type DictFilterShape<Filter> = Filter extends FilterCls<infer FilterShape> ? FilterCompactShape<FilterShape> : Filter extends {
|
|
12
|
+
readonly [FILTER_DICT_SHAPE]: infer CompactShape extends FilterDictArgShape;
|
|
13
|
+
} ? CompactShape : Filter extends FilterInstance ? FilterCompactShape<Filter> : Filter extends {
|
|
9
14
|
query: Record<string, FilterInfo>;
|
|
10
15
|
sort: Record<string, unknown>;
|
|
16
|
+
} ? FilterCompactShape<Filter> : Filter extends {
|
|
17
|
+
query: DictArgShape;
|
|
18
|
+
sort: Record<string, true>;
|
|
11
19
|
} ? Filter : AnyFilterShape;
|
|
20
|
+
type DictSliceShape<Slice> = Slice extends SliceCls<infer _SrvModule, infer SliceInfoObj> ? SliceCompactShape<SliceInfoObj> : Slice extends {
|
|
21
|
+
readonly [SLICE_DICT_SHAPE]: infer CompactShape extends DictArgShape;
|
|
22
|
+
} ? CompactShape : Slice extends DictArgShape ? Slice : Slice extends Record<string, SliceInfo> ? SliceCompactShape<Slice> : Record<never, never>;
|
|
23
|
+
type DictEndpointShape<Endpoint> = Endpoint extends EndpointCls<infer _SrvModule, infer EndpointInfoObj> ? EndpointCompactShape<EndpointInfoObj> : Endpoint extends {
|
|
24
|
+
readonly [ENDPOINT_DICT_SHAPE]: infer CompactShape extends DictArgShape;
|
|
25
|
+
} ? CompactShape : Endpoint extends DictArgShape ? Endpoint : Endpoint extends Record<string, EndpointInfo> ? EndpointCompactShape<Endpoint> : Record<never, never>;
|
|
26
|
+
type DictArgNames<ArgNames> = ArgNames extends readonly string[] ? ArgNames[number] : never;
|
|
12
27
|
type DictFilterQuery<Filter> = DictFilterShape<Filter>["query"];
|
|
13
28
|
type DictFilterSort<Filter> = DictFilterShape<Filter>["sort"];
|
|
14
29
|
declare class FieldTranslation<Languages extends [string, ...string[]]> {
|
|
@@ -42,7 +57,7 @@ type BaseModelCrudGetSignalTranslation<T extends string, Languages extends [stri
|
|
|
42
57
|
[K in `remove${_CapitalizedRefName}`]: FunctionTranslation<Languages, `${T}Id`>;
|
|
43
58
|
};
|
|
44
59
|
type GetBaseSignalKey<T extends string> = keyof BaseModelCrudGetSignalTranslation<T>;
|
|
45
|
-
export declare class ModelDictInfo<Languages extends [string, ...string[]] = [string], ModelKey extends string = keyof BaseObject, InsightKey extends string = keyof BaseInsight, QueryKey extends string = BaseFilterQueryKey, SortKey extends string = BaseFilterSortKey, EnumKey extends string = never, BaseSignalKey extends string = never, SliceKey extends string =
|
|
60
|
+
export declare class ModelDictInfo<Languages extends [string, ...string[]] = [string], ModelKey extends string = keyof BaseObject, InsightKey extends string = keyof BaseInsight, QueryKey extends string = BaseFilterQueryKey, SortKey extends string = BaseFilterSortKey, EnumKey extends string = never, BaseSignalKey extends string = never, SliceKey extends string = "", EndpointKey extends string = never, ErrorKey extends string = never, EtcKey extends string = never> {
|
|
46
61
|
#private;
|
|
47
62
|
static baseModelDictionary: {
|
|
48
63
|
[key in keyof BaseObject]: FieldTranslation<[string, string]>;
|
|
@@ -103,7 +118,7 @@ export declare class ModelDictInfo<Languages extends [string, ...string[]] = [st
|
|
|
103
118
|
[K in Exclude<keyof GetStateObject<Insight>, InsightKey>]: FieldTranslation<Languages>;
|
|
104
119
|
}): ModelDictInfo<Languages, ModelKey, keyof GetStateObject<Insight> & string, QueryKey, SortKey, EnumKey, BaseSignalKey, SliceKey, EndpointKey, ErrorKey, EtcKey>;
|
|
105
120
|
query<Filter>(translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
106
|
-
[K in Exclude<keyof DictFilterQuery<Filter>, QueryKey>]: DictFilterQuery<Filter>[K]
|
|
121
|
+
[K in Exclude<keyof DictFilterQuery<Filter>, QueryKey>]: FunctionTranslation<Languages, DictArgNames<DictFilterQuery<Filter>[K]>>;
|
|
107
122
|
}): ModelDictInfo<Languages, ModelKey, InsightKey, keyof DictFilterQuery<Filter> & string, SortKey, EnumKey, BaseSignalKey, SliceKey, EndpointKey, ErrorKey, EtcKey>;
|
|
108
123
|
sort<Filter>(translate: (t: (trans: Languages) => FieldTranslation<Languages>) => {
|
|
109
124
|
[K in Exclude<keyof DictFilterSort<Filter>, SortKey>]: FieldTranslation<Languages>;
|
|
@@ -115,11 +130,11 @@ export declare class ModelDictInfo<Languages extends [string, ...string[]] = [st
|
|
|
115
130
|
[K in Enum["value"]]: FieldTranslation<Languages>;
|
|
116
131
|
}): ModelDictInfo<Languages, ModelKey, InsightKey, QueryKey, SortKey, EnumKey | Enum["refName"], BaseSignalKey, SliceKey, EndpointKey, ErrorKey, EtcKey>;
|
|
117
132
|
slice<Slice>(translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
118
|
-
[K in Exclude<keyof Slice
|
|
119
|
-
}): ModelDictInfo<Languages, ModelKey, InsightKey, QueryKey, SortKey, EnumKey, BaseSignalKey, keyof Slice & string, EndpointKey, ErrorKey, EtcKey>;
|
|
133
|
+
[K in Exclude<keyof DictSliceShape<Slice>, SliceKey>]: FunctionTranslation<Languages, DictArgNames<DictSliceShape<Slice>[K]>>;
|
|
134
|
+
}): ModelDictInfo<Languages, ModelKey, InsightKey, QueryKey, SortKey, EnumKey, BaseSignalKey, keyof DictSliceShape<Slice> & string, EndpointKey, ErrorKey, EtcKey>;
|
|
120
135
|
endpoint<Endpoint>(translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
121
|
-
[K in Exclude<keyof Endpoint
|
|
122
|
-
}): ModelDictInfo<Languages, ModelKey, InsightKey, QueryKey, SortKey, EnumKey, BaseSignalKey, SliceKey, keyof Endpoint & string, ErrorKey, EtcKey>;
|
|
136
|
+
[K in Exclude<keyof DictEndpointShape<Endpoint>, EndpointKey>]: FunctionTranslation<Languages, DictArgNames<DictEndpointShape<Endpoint>[K]>>;
|
|
137
|
+
}): ModelDictInfo<Languages, ModelKey, InsightKey, QueryKey, SortKey, EnumKey, BaseSignalKey, SliceKey, keyof DictEndpointShape<Endpoint> & string, ErrorKey, EtcKey>;
|
|
123
138
|
error<ErrorDict extends {
|
|
124
139
|
[key: string]: Languages;
|
|
125
140
|
}>(errorDictionary: ErrorDict): ModelDictInfo<Languages, ModelKey, InsightKey, QueryKey, SortKey, EnumKey, BaseSignalKey, SliceKey, EndpointKey, ErrorKey | (keyof ErrorDict & string), EtcKey>;
|
|
@@ -136,7 +151,7 @@ export declare class ModelDictInfo<Languages extends [string, ...string[]] = [st
|
|
|
136
151
|
};
|
|
137
152
|
}
|
|
138
153
|
type AnyModelDictInfo = ModelDictInfo<any, any, any, any, any, any, any, any, any, any, any>;
|
|
139
|
-
type MergeTwoModelDicts<ModelDict1, ModelDict2> = ModelDict1 extends ModelDictInfo<infer Languages1, infer ModelKey1, infer InsightKey1, infer QueryKey1, infer SortKey1, infer EnumKey1, infer BaseSignalKey1, infer SliceKey1, infer EndpointKey1, infer ErrorKey1, infer EtcKey1> ? ModelDict2 extends ModelDictInfo<
|
|
154
|
+
type MergeTwoModelDicts<ModelDict1, ModelDict2> = ModelDict1 extends ModelDictInfo<infer Languages1, infer ModelKey1, infer InsightKey1, infer QueryKey1, infer SortKey1, infer EnumKey1, infer BaseSignalKey1, infer SliceKey1, infer EndpointKey1, infer ErrorKey1, infer EtcKey1> ? ModelDict2 extends ModelDictInfo<infer _Languages2, infer ModelKey2, infer InsightKey2, infer QueryKey2, infer SortKey2, infer EnumKey2, infer BaseSignalKey2, infer SliceKey2, infer EndpointKey2, infer ErrorKey2, infer EtcKey2> ? ModelDictInfo<Languages1, ModelKey1 | ModelKey2, InsightKey1 | InsightKey2, QueryKey1 | QueryKey2, SortKey1 | SortKey2, EnumKey1 | EnumKey2, BaseSignalKey1 | BaseSignalKey2, SliceKey1 | SliceKey2, EndpointKey1 | EndpointKey2, ErrorKey1 | ErrorKey2, EtcKey1 | EtcKey2> : ModelDict1 : never;
|
|
140
155
|
type MergeModelDicts<ModelDicts extends AnyModelDictInfo[]> = ModelDicts extends [
|
|
141
156
|
infer First extends AnyModelDictInfo,
|
|
142
157
|
...infer Rest extends AnyModelDictInfo[]
|
|
@@ -193,11 +208,9 @@ export declare class ServiceDictInfo<Languages extends [string, ...string[]] = [
|
|
|
193
208
|
[K in EtcKey]: Languages;
|
|
194
209
|
};
|
|
195
210
|
constructor(languages: Languages);
|
|
196
|
-
endpoint<Endpoint
|
|
197
|
-
[
|
|
198
|
-
}
|
|
199
|
-
[K in keyof Endpoint]: FunctionTranslation<Languages, EndpInfoArgNames<Endpoint[K]>[number]>;
|
|
200
|
-
}): ServiceDictInfo<Languages, keyof Endpoint & string, ErrorKey, EtcKey>;
|
|
211
|
+
endpoint<Endpoint>(translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
212
|
+
[K in keyof DictEndpointShape<Endpoint>]: FunctionTranslation<Languages, DictArgNames<DictEndpointShape<Endpoint>[K]>>;
|
|
213
|
+
}): ServiceDictInfo<Languages, keyof DictEndpointShape<Endpoint> & string, ErrorKey, EtcKey>;
|
|
201
214
|
error<ErrorDict extends {
|
|
202
215
|
[key: string]: Languages;
|
|
203
216
|
}>(errorDictionary: ErrorDict): ServiceDictInfo<Languages, EndpointKey, keyof ErrorDict & string, EtcKey>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { GetStateObject, MergedValues } from "akanjs/base";
|
|
1
|
+
import type { ENDPOINT_DICT_SHAPE, FILTER_DICT_SHAPE, GetStateObject, MergedValues, SLICE_DICT_SHAPE } from "akanjs/base";
|
|
2
2
|
import type { BaseInsight, BaseObject } from "akanjs/constant";
|
|
3
|
-
import type { FilterCls, FilterInfo, FilterInstance } from "akanjs/document";
|
|
4
|
-
import type {
|
|
3
|
+
import type { FilterCls, FilterDictShape as FilterCompactShape, FilterDictArgShape, FilterInfo, FilterInstance } from "akanjs/document";
|
|
4
|
+
import type { EndpointCls, EndpointDictShape as EndpointCompactShape, EndpointInfo, SliceCls, SliceDictShape as SliceCompactShape, SliceInfo, SliceInfoArgNames, SliceInfoRefName } from "akanjs/signal";
|
|
5
5
|
import type { ModelDictInfo, ScalarDictInfo, ServiceDictInfo } from ".";
|
|
6
6
|
interface Trans {
|
|
7
7
|
t: string;
|
|
@@ -17,24 +17,41 @@ interface FnTrans<ArgKey extends string> {
|
|
|
17
17
|
[key in ArgKey]: FieldTrans;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
type
|
|
21
|
-
|
|
20
|
+
type DictArgShape = {
|
|
21
|
+
[key: string]: readonly string[];
|
|
22
|
+
};
|
|
23
|
+
type AnyFilterShape = FilterCompactShape<FilterInstance<Record<string, FilterInfo>, Record<string, unknown>>>;
|
|
24
|
+
type DictFilterShape<Filter> = Filter extends FilterCls<infer FilterShape> ? FilterCompactShape<FilterShape> : Filter extends {
|
|
25
|
+
readonly [FILTER_DICT_SHAPE]: infer CompactShape extends FilterDictArgShape;
|
|
26
|
+
} ? CompactShape : Filter extends FilterInstance ? FilterCompactShape<Filter> : Filter extends {
|
|
22
27
|
query: Record<string, FilterInfo>;
|
|
23
28
|
sort: Record<string, unknown>;
|
|
29
|
+
} ? FilterCompactShape<Filter> : Filter extends {
|
|
30
|
+
query: DictArgShape;
|
|
31
|
+
sort: Record<string, true>;
|
|
24
32
|
} ? Filter : AnyFilterShape;
|
|
25
33
|
type DictFilterQuery<Filter> = DictFilterShape<Filter>["query"];
|
|
26
34
|
type DictFilterSort<Filter> = DictFilterShape<Filter>["sort"];
|
|
35
|
+
type DictArgNames<ArgNames> = ArgNames extends readonly string[] ? ArgNames[number] : never;
|
|
36
|
+
type DictEndpointShape<Endpoint> = Endpoint extends EndpointCls<infer _SrvModule, infer EndpointInfoObj> ? EndpointCompactShape<EndpointInfoObj> : Endpoint extends {
|
|
37
|
+
readonly [ENDPOINT_DICT_SHAPE]: infer CompactShape extends DictArgShape;
|
|
38
|
+
} ? CompactShape : Endpoint extends DictArgShape ? Endpoint : Endpoint extends Record<string, EndpointInfo> ? EndpointCompactShape<Endpoint> : Record<never, never>;
|
|
39
|
+
type DictSliceShape<Slice> = Slice extends SliceCls<infer _SrvModule, infer SliceInfoObj> ? SliceCompactShape<SliceInfoObj> : Slice extends {
|
|
40
|
+
readonly [SLICE_DICT_SHAPE]: infer CompactShape extends DictArgShape;
|
|
41
|
+
} ? CompactShape : Slice extends DictArgShape ? Slice : Slice extends Record<string, SliceInfo> ? SliceCompactShape<Slice> : Record<never, never>;
|
|
27
42
|
type FilterTranslatorKey<Filter> = {
|
|
28
|
-
[Key in keyof DictFilterQuery<Filter> & string]: `${Key}` | `${Key}.desc` | (DictFilterQuery<Filter>[Key]
|
|
43
|
+
[Key in keyof DictFilterQuery<Filter> & string]: `${Key}` | `${Key}.desc` | (DictArgNames<DictFilterQuery<Filter>[Key]> extends string ? `${Key}.arg.${DictArgNames<DictFilterQuery<Filter>[Key]>}` | `${Key}.arg.${DictArgNames<DictFilterQuery<Filter>[Key]>}.desc` : never);
|
|
29
44
|
}[keyof DictFilterQuery<Filter> & string];
|
|
30
|
-
type EndpointTranslatorKey<Endpoint
|
|
31
|
-
[
|
|
32
|
-
}>
|
|
33
|
-
|
|
34
|
-
}[keyof Endpoint & string];
|
|
35
|
-
type SliceTranslatorKey<Slice> = {
|
|
45
|
+
type EndpointTranslatorKey<Endpoint> = {
|
|
46
|
+
[Key in keyof DictEndpointShape<Endpoint> & string]: `${Key}` | `${Key}.desc` | `${Key}.arg.${DictArgNames<DictEndpointShape<Endpoint>[Key]>}` | `${Key}.arg.${DictArgNames<DictEndpointShape<Endpoint>[Key]>}.desc`;
|
|
47
|
+
}[keyof DictEndpointShape<Endpoint> & string];
|
|
48
|
+
type FullSliceTranslatorKey<Slice> = {
|
|
36
49
|
[Key in keyof Slice & string]: Slice[Key] extends infer Info extends SliceInfo ? `${SliceInfoRefName<Info>}List${Capitalize<Key>}` | `${SliceInfoRefName<Info>}List${Capitalize<Key>}.desc` | `${SliceInfoRefName<Info>}List${Capitalize<Key>}.arg.${SliceInfoArgNames<Info>[number] | "skip" | "limit" | "sort"}` | `${SliceInfoRefName<Info>}List${Capitalize<Key>}.arg.${SliceInfoArgNames<Info>[number] | "skip" | "limit" | "sort"}.desc` | `${SliceInfoRefName<Info>}Insight${Capitalize<Key>}` | `${SliceInfoRefName<Info>}Insight${Capitalize<Key>}.desc` | `${SliceInfoRefName<Info>}Insight${Capitalize<Key>}.arg.${SliceInfoArgNames<Info>[number]}` | `${SliceInfoRefName<Info>}Insight${Capitalize<Key>}.arg.${SliceInfoArgNames<Info>[number]}.desc` : never;
|
|
37
50
|
}[keyof Slice & string];
|
|
51
|
+
type CompactSliceTranslatorKey<T extends string, Slice> = {
|
|
52
|
+
[Key in keyof DictSliceShape<Slice> & string]: Key extends "" ? never : `${T}List${Capitalize<Key>}` | `${T}List${Capitalize<Key>}.desc` | `${T}List${Capitalize<Key>}.arg.${DictArgNames<DictSliceShape<Slice>[Key]> | "skip" | "limit" | "sort"}` | `${T}List${Capitalize<Key>}.arg.${DictArgNames<DictSliceShape<Slice>[Key]> | "skip" | "limit" | "sort"}.desc` | `${T}Insight${Capitalize<Key>}` | `${T}Insight${Capitalize<Key>}.desc` | `${T}Insight${Capitalize<Key>}.arg.${DictArgNames<DictSliceShape<Slice>[Key]>}` | `${T}Insight${Capitalize<Key>}.arg.${DictArgNames<DictSliceShape<Slice>[Key]>}.desc`;
|
|
53
|
+
}[keyof DictSliceShape<Slice> & string];
|
|
54
|
+
type SliceTranslatorKey<T extends string, Slice> = Slice extends Record<string, SliceInfo> ? FullSliceTranslatorKey<Slice> : CompactSliceTranslatorKey<T, Slice>;
|
|
38
55
|
type SliceApiTrans<T extends string, Suffix extends string, ArgName extends string, _CapitalizedSuffix extends string = Capitalize<Suffix>> = {
|
|
39
56
|
[K in `${T}List${_CapitalizedSuffix}`]: FnTrans<ArgName | "skip" | "limit" | "sort">;
|
|
40
57
|
} & {
|
|
@@ -51,11 +68,7 @@ type BaseModelCrudGetApiTrans<T extends string> = {
|
|
|
51
68
|
} & {
|
|
52
69
|
[K in `remove${T}`]: FnTrans<`${T}Id`>;
|
|
53
70
|
};
|
|
54
|
-
export type ModelTrans<T extends string, Model extends BaseObject, Insight extends BaseInsight, Filter, Slice extends {
|
|
55
|
-
[key: string]: SliceInfo;
|
|
56
|
-
}, Endpoint extends {
|
|
57
|
-
[key: string]: EndpointInfo;
|
|
58
|
-
}, ErrorKey extends string, EtcKey extends string> = {
|
|
71
|
+
export type ModelTrans<T extends string, Model extends BaseObject, Insight extends BaseInsight, Filter, Slice, Endpoint, ErrorKey extends string, EtcKey extends string> = {
|
|
59
72
|
modelName: Trans;
|
|
60
73
|
modelDesc: Trans;
|
|
61
74
|
model: {
|
|
@@ -65,15 +78,15 @@ export type ModelTrans<T extends string, Model extends BaseObject, Insight exten
|
|
|
65
78
|
[K in keyof GetStateObject<Insight>]: FieldTrans;
|
|
66
79
|
};
|
|
67
80
|
query: {
|
|
68
|
-
[K in keyof DictFilterQuery<Filter>]: DictFilterQuery<Filter>[K]
|
|
81
|
+
[K in keyof DictFilterQuery<Filter>]: FnTrans<DictArgNames<DictFilterQuery<Filter>[K]>>;
|
|
69
82
|
};
|
|
70
83
|
sort: {
|
|
71
84
|
[K in keyof DictFilterSort<Filter>]: FieldTrans;
|
|
72
85
|
};
|
|
73
86
|
api: {
|
|
74
|
-
[K in keyof Endpoint]: FnTrans<
|
|
87
|
+
[K in keyof DictEndpointShape<Endpoint>]: FnTrans<DictArgNames<DictEndpointShape<Endpoint>[K]>>;
|
|
75
88
|
} & BaseModelCrudGetApiTrans<T> & MergedValues<{
|
|
76
|
-
[K in keyof Slice]: SliceApiTrans<
|
|
89
|
+
[K in keyof DictSliceShape<Slice>]: SliceApiTrans<T, K & string, DictArgNames<DictSliceShape<Slice>[K]>>;
|
|
77
90
|
}>;
|
|
78
91
|
error: {
|
|
79
92
|
[K in ErrorKey]: Trans;
|
|
@@ -81,12 +94,8 @@ export type ModelTrans<T extends string, Model extends BaseObject, Insight exten
|
|
|
81
94
|
} & {
|
|
82
95
|
[K in EtcKey]: Trans;
|
|
83
96
|
};
|
|
84
|
-
export type ModelTranslatorKey<T extends string, Model, Insight, Filter, Slice extends {
|
|
85
|
-
|
|
86
|
-
}, Endpoint extends {
|
|
87
|
-
[key: string]: EndpointInfo;
|
|
88
|
-
}, EtcKey extends string> = `${T}.modelName` | `${T}.modelDesc` | `${T}.${keyof GetStateObject<Model> & string}${"" | ".desc"}` | `${T}.insight.${keyof GetStateObject<Insight> & string}${"" | ".desc"}` | `${T}.query.${FilterTranslatorKey<Filter>}` | `${T}.sort.${keyof DictFilterSort<Filter> & string}${"" | ".desc"}` | `${T}.signal.${EndpointTranslatorKey<Endpoint> | SliceTranslatorKey<Slice>}` | `${T}.${EtcKey}`;
|
|
89
|
-
export type ScalarTrans<T extends string, Model, ErrorKey extends string, EtcKey extends string> = {
|
|
97
|
+
export type ModelTranslatorKey<T extends string, Model, Insight, Filter, Slice, Endpoint, EtcKey extends string> = `${T}.modelName` | `${T}.modelDesc` | `${T}.${keyof GetStateObject<Model> & string}${"" | ".desc"}` | `${T}.insight.${keyof GetStateObject<Insight> & string}${"" | ".desc"}` | `${T}.query.${FilterTranslatorKey<Filter>}` | `${T}.sort.${keyof DictFilterSort<Filter> & string}${"" | ".desc"}` | `${T}.signal.${EndpointTranslatorKey<Endpoint> | SliceTranslatorKey<T, Slice>}` | `${T}.${EtcKey}`;
|
|
98
|
+
export type ScalarTrans<_T extends string, Model, ErrorKey extends string, EtcKey extends string> = {
|
|
90
99
|
name: Trans;
|
|
91
100
|
desc: Trans;
|
|
92
101
|
model: {
|
|
@@ -99,11 +108,9 @@ export type ScalarTrans<T extends string, Model, ErrorKey extends string, EtcKey
|
|
|
99
108
|
[K in EtcKey]: Trans;
|
|
100
109
|
};
|
|
101
110
|
export type ScalarTranslatorKey<T extends string, Model, EtcKey extends string> = `${T}.modelName` | `${T}.modelDesc` | `${T}.${keyof GetStateObject<Model> & string}${"" | ".desc"}` | `${T}.${EtcKey}`;
|
|
102
|
-
export type ServiceTrans<
|
|
103
|
-
[key: string]: EndpointInfo;
|
|
104
|
-
}, ErrorKey extends string, EtcKey extends string> = {
|
|
111
|
+
export type ServiceTrans<_T extends string, Endpoint, ErrorKey extends string, EtcKey extends string> = {
|
|
105
112
|
api: {
|
|
106
|
-
[K in keyof Endpoint]: FnTrans<
|
|
113
|
+
[K in keyof DictEndpointShape<Endpoint>]: FnTrans<DictArgNames<DictEndpointShape<Endpoint>[K]>>;
|
|
107
114
|
};
|
|
108
115
|
error: {
|
|
109
116
|
[K in ErrorKey]: Trans;
|
|
@@ -111,9 +118,7 @@ export type ServiceTrans<T extends string, Endpoint extends {
|
|
|
111
118
|
} & {
|
|
112
119
|
[K in EtcKey]: Trans;
|
|
113
120
|
};
|
|
114
|
-
export type ServiceTranslatorKey<T extends string, Endpoint extends {
|
|
115
|
-
[key: string]: EndpointInfo;
|
|
116
|
-
}, EtcKey extends string> = `${T}.signal.${EndpointTranslatorKey<Endpoint>}` | `${T}.${EtcKey}`;
|
|
121
|
+
export type ServiceTranslatorKey<T extends string, Endpoint, EtcKey extends string> = `${T}.signal.${EndpointTranslatorKey<Endpoint>}` | `${T}.${EtcKey}`;
|
|
117
122
|
export type EnumTrans<EnumValue extends string | number> = {
|
|
118
123
|
[key in EnumValue]: Trans;
|
|
119
124
|
};
|
|
@@ -121,15 +126,9 @@ export type EnumTranslatorKey<EnumKey extends string> = `${EnumKey}.${string}${"
|
|
|
121
126
|
export interface DictModule<DictKey extends string, ErrorKey extends string> {
|
|
122
127
|
__Dict_Key__: DictKey;
|
|
123
128
|
__Error_Key__: ErrorKey;
|
|
124
|
-
dict: ModelDictInfo<
|
|
129
|
+
dict: ModelDictInfo<[string, ...string[]]> | ScalarDictInfo<[string, ...string[]]> | ServiceDictInfo<[string, ...string[]]>;
|
|
125
130
|
}
|
|
126
|
-
export declare const registerModelTrans: <RefName extends string, Model extends BaseObject, Insight extends BaseInsight, Filter, Slice extends {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
[key: string]: EndpointInfo;
|
|
130
|
-
}, ModelDict extends ModelDictInfo<any>>(modelDict: ModelDict) => ModelDict extends ModelDictInfo<any, any, any, any, any, infer EnumKey, any, any, any, infer ErrorKey, infer EtcKey> ? DictModule<ModelTranslatorKey<RefName, Model, Insight, Filter, Slice, Endpoint, EtcKey> | EnumTranslatorKey<EnumKey>, `${RefName}.error.${ErrorKey}`> : never;
|
|
131
|
-
export declare const registerScalarTrans: <T extends string, Model, ScalarDict>(scalarDict: ScalarDict) => ScalarDict extends ScalarDictInfo<any, any, infer EnumKey, infer ErrorKey, infer EtcKey> ? DictModule<ScalarTranslatorKey<T, Model, EtcKey> | EnumTranslatorKey<EnumKey>, `${T}.error.${ErrorKey}`> : never;
|
|
132
|
-
export declare const registerServiceTrans: <T extends string, Endpoint extends {
|
|
133
|
-
[key: string]: EndpointInfo;
|
|
134
|
-
}, ServiceDict>(serviceDict: ServiceDict) => ServiceDict extends ServiceDictInfo<any, any, infer ErrorKey, infer EtcKey> ? DictModule<ServiceTranslatorKey<T, Endpoint, EtcKey>, `${T}.error.${ErrorKey}`> : never;
|
|
131
|
+
export declare const registerModelTrans: <RefName extends string, Model extends BaseObject, Insight extends BaseInsight, Filter, Slice, Endpoint, ModelDict>(modelDict: ModelDict) => ModelDict extends ModelDictInfo<infer _Languages, infer _ModelKey, infer _InsightKey, infer _QueryKey, infer _SortKey, infer EnumKey, infer _BaseSignalKey, infer _SliceKey, infer _EndpointKey, infer ErrorKey, infer EtcKey> ? DictModule<ModelTranslatorKey<RefName, Model, Insight, Filter, Slice, Endpoint, EtcKey> | EnumTranslatorKey<EnumKey>, `${RefName}.error.${ErrorKey}`> : never;
|
|
132
|
+
export declare const registerScalarTrans: <T extends string, Model, ScalarDict>(scalarDict: ScalarDict) => ScalarDict extends ScalarDictInfo<infer _Languages, infer _ModelKey, infer EnumKey, infer ErrorKey, infer EtcKey> ? DictModule<ScalarTranslatorKey<T, Model, EtcKey> | EnumTranslatorKey<EnumKey>, `${T}.error.${ErrorKey}`> : never;
|
|
133
|
+
export declare const registerServiceTrans: <T extends string, Endpoint, ServiceDict>(serviceDict: ServiceDict) => ServiceDict extends ServiceDictInfo<infer _Languages, infer _EndpointKey, infer ErrorKey, infer EtcKey> ? DictModule<ServiceTranslatorKey<T, Endpoint, EtcKey>, `${T}.error.${ErrorKey}`> : never;
|
|
135
134
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Cls, MergeAllDoubleKeyOfObjects, MergeAllKeyOfTypes } from "akanjs/base";
|
|
2
|
-
import { FILTER_META } from "akanjs/base";
|
|
2
|
+
import { FILTER_DICT_SHAPE, FILTER_META } from "akanjs/base";
|
|
3
3
|
import type { BaseObject, ConstantFieldTypeInput, DocumentModel, FieldToValue, PlainTypeToFieldType, QueryOf, Serialized } from "akanjs/constant";
|
|
4
4
|
import type { DocumentQuery, DocumentQueryHelper } from "./documentQuery.d.ts";
|
|
5
5
|
import type { ConstantFilterMeta } from "./types.d.ts";
|
|
@@ -30,6 +30,25 @@ export type FilterInstance<Query extends {
|
|
|
30
30
|
query: Query;
|
|
31
31
|
sort: Sort;
|
|
32
32
|
};
|
|
33
|
+
export type FilterDictArgShape = {
|
|
34
|
+
query: {
|
|
35
|
+
[key: string]: readonly string[];
|
|
36
|
+
};
|
|
37
|
+
sort: {
|
|
38
|
+
[key: string]: true;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type FilterDictShape<Filter extends FilterInstance> = {
|
|
42
|
+
query: {
|
|
43
|
+
[K in keyof Filter["query"]]: Filter["query"][K] extends FilterInfo<infer ArgNames, infer _Args, infer _Model> ? ArgNames : never;
|
|
44
|
+
};
|
|
45
|
+
sort: {
|
|
46
|
+
[K in keyof Filter["sort"]]: true;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export interface FilterDictShapeCarrier<DictShape extends FilterDictArgShape = FilterDictArgShape> {
|
|
50
|
+
readonly [FILTER_DICT_SHAPE]: DictShape;
|
|
51
|
+
}
|
|
33
52
|
interface BaseQuery<Model> {
|
|
34
53
|
any: FilterInfo<[], [], Model>;
|
|
35
54
|
}
|
|
@@ -53,10 +72,13 @@ export type ExtractQuery<Filter extends FilterInstance> = {
|
|
|
53
72
|
[K in keyof Filter["query"]]: Filter["query"][K] extends FilterInfo<any, infer Args> ? (...args: Args) => QueryOf<any> : never;
|
|
54
73
|
};
|
|
55
74
|
export type ExtractSort<Filter extends FilterInstance> = keyof Filter["sort"];
|
|
56
|
-
export interface FilterCls<Filter extends FilterInstance = any, Query = unknown, Sort = unknown> extends Cls<{
|
|
57
|
-
[key: string]:
|
|
75
|
+
export interface FilterCls<Filter extends FilterInstance = any, Query = unknown, Sort = unknown> extends Cls<FilterDictShapeCarrier<FilterDictShape<Filter>> & {
|
|
76
|
+
[key: string]: unknown;
|
|
58
77
|
}> {
|
|
59
78
|
[FILTER_META]: Filter;
|
|
79
|
+
prototype: FilterDictShapeCarrier<FilterDictShape<Filter>> & {
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
};
|
|
60
82
|
sortField: Set<string>;
|
|
61
83
|
_Query: Query;
|
|
62
84
|
_Sort: Sort;
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import type { Assign } from "akanjs/base";
|
|
2
|
-
import { ENDPOINT_META } from "akanjs/base";
|
|
2
|
+
import { ENDPOINT_DICT_SHAPE, ENDPOINT_META } from "akanjs/base";
|
|
3
3
|
import { type Adaptor, type AdaptorCls, type ServiceModel } from "akanjs/service";
|
|
4
|
-
import { type EndpointBuilder, type EndpointInfo } from "./endpointInfo.d.ts";
|
|
4
|
+
import { type EndpInfoArgNames, type EndpointBuilder, type EndpointInfo } from "./endpointInfo.d.ts";
|
|
5
5
|
import type { SrvRefName } from "./types.d.ts";
|
|
6
|
-
export
|
|
6
|
+
export type EndpointDictArgShape = {
|
|
7
|
+
[key: string]: readonly string[];
|
|
8
|
+
};
|
|
9
|
+
export type EndpointDictShape<EndpointInfoObj extends {
|
|
10
|
+
[key: string]: EndpointInfo;
|
|
11
|
+
}> = {
|
|
12
|
+
[K in keyof EndpointInfoObj]: EndpInfoArgNames<EndpointInfoObj[K]>;
|
|
13
|
+
};
|
|
14
|
+
export interface Endpoint<DictShape extends EndpointDictArgShape = Record<never, never>> extends Adaptor {
|
|
15
|
+
readonly [ENDPOINT_DICT_SHAPE]: DictShape;
|
|
7
16
|
}
|
|
8
|
-
export
|
|
17
|
+
export type EndpointCls<SrvModule extends ServiceModel = ServiceModel, EndpointInfoObj extends {
|
|
9
18
|
[key: string]: EndpointInfo;
|
|
10
19
|
} = {
|
|
11
20
|
[key: string]: EndpointInfo;
|
|
12
|
-
}>
|
|
21
|
+
}> = AdaptorCls<Endpoint<EndpointDictShape<EndpointInfoObj>>> & {
|
|
13
22
|
baseName: SrvRefName<SrvModule>;
|
|
14
23
|
srv: SrvModule;
|
|
24
|
+
prototype: Endpoint<EndpointDictShape<EndpointInfoObj>>;
|
|
15
25
|
[ENDPOINT_META]: EndpointInfoObj;
|
|
16
|
-
}
|
|
26
|
+
};
|
|
17
27
|
type EndpointMetaOf<EndpCls> = EndpCls extends EndpointCls<any, infer EndpointInfoObj> ? EndpointInfoObj : never;
|
|
18
28
|
type MergeEndpointMetas<EndpClses extends readonly EndpointCls[], Acc = unknown> = EndpClses extends readonly [
|
|
19
29
|
infer First extends EndpointCls,
|
|
@@ -30,20 +30,8 @@ export declare class ServiceSignal<IntlCls extends InternalCls = InternalCls, En
|
|
|
30
30
|
export declare class SignalRegistry {
|
|
31
31
|
#private;
|
|
32
32
|
static registerDatabase<RefName extends string, IntlCls extends InternalCls, EndpCls extends EndpointCls, SlceCls extends SliceCls, SrvrCls extends ServerSignalCls>(refName: RefName, internal: SignalWithBase<RefName, IntlCls>, endpoint: SignalWithBase<RefName, EndpCls>, slice: SignalWithBase<RefName, SlceCls>, server: SrvrCls): DatabaseSignal<IntlCls, EndpCls, SlceCls, SrvrCls>;
|
|
33
|
-
static getDatabase(refName: string): DatabaseSignal<InternalCls, EndpointCls
|
|
34
|
-
[x: `${Uncapitalize<string>}Service`]: import("../service.d.ts").ExtractInjectInfoObject<{}> & import("../service.d.ts").Service;
|
|
35
|
-
}>, {
|
|
36
|
-
[key: string]: import("./endpointInfo.d.ts").EndpointInfo<import("./endpointInfo.d.ts").EndpointType, {
|
|
37
|
-
[key: string]: any;
|
|
38
|
-
}, any, any, any, any, import("../constant.d.ts").ConstantFieldTypeInput, never, never, boolean>;
|
|
39
|
-
}>, SliceCls, ServerSignalCls> | undefined;
|
|
33
|
+
static getDatabase(refName: string): DatabaseSignal<InternalCls, EndpointCls, SliceCls, ServerSignalCls> | undefined;
|
|
40
34
|
static registerService<RefName extends string, IntlCls extends InternalCls, EndpCls extends EndpointCls, SrvrCls extends ServerSignalCls>(refName: RefName, internal: SignalWithBase<RefName, IntlCls>, endpoint: SignalWithBase<RefName, EndpCls>, server: SrvrCls): ServiceSignal<IntlCls, EndpCls, SrvrCls>;
|
|
41
|
-
static getService(refName: string): ServiceSignal<InternalCls, EndpointCls
|
|
42
|
-
[x: `${Uncapitalize<string>}Service`]: import("../service.d.ts").ExtractInjectInfoObject<{}> & import("../service.d.ts").Service;
|
|
43
|
-
}>, {
|
|
44
|
-
[key: string]: import("./endpointInfo.d.ts").EndpointInfo<import("./endpointInfo.d.ts").EndpointType, {
|
|
45
|
-
[key: string]: any;
|
|
46
|
-
}, any, any, any, any, import("../constant.d.ts").ConstantFieldTypeInput, never, never, boolean>;
|
|
47
|
-
}>, ServerSignalCls> | undefined;
|
|
35
|
+
static getService(refName: string): ServiceSignal<InternalCls, EndpointCls, ServerSignalCls> | undefined;
|
|
48
36
|
}
|
|
49
37
|
export {};
|
package/types/signal/slice.d.ts
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
import { type Assign, type Cls, type MergeAllKeyOfObjects, SLICE_META } from "akanjs/base";
|
|
1
|
+
import { type Assign, type Cls, type MergeAllKeyOfObjects, SLICE_DICT_SHAPE, SLICE_META } from "akanjs/base";
|
|
2
2
|
import type { DocumentModel, QueryOf } from "akanjs/constant";
|
|
3
3
|
import type { FilterInstance } from "akanjs/document";
|
|
4
4
|
import { type Adaptor, type AdaptorCls, type ServiceModel } from "akanjs/service";
|
|
5
5
|
import type { Guard, GuardCls } from "./guard.d.ts";
|
|
6
6
|
import { type SliceBuilder, type SliceInfo, type SliceInfoArgNames, type SliceInfoArgs, type SliceInfoInternalArgs, type SliceInfoServerArgs, type SliceInfoSrvs } from "./sliceInfo.d.ts";
|
|
7
7
|
import type { CnstFull, CnstInput, CnstInsight, CnstLight, DbFilter, SrvMap, SrvRefName } from "./types.d.ts";
|
|
8
|
-
export
|
|
8
|
+
export type SliceDictArgShape = {
|
|
9
|
+
[key: string]: readonly string[];
|
|
10
|
+
};
|
|
11
|
+
export type SliceDictShape<SliceInfoObj extends {
|
|
12
|
+
[key: string]: SliceInfo;
|
|
13
|
+
}> = {
|
|
14
|
+
[K in keyof SliceInfoObj]: SliceInfoArgNames<SliceInfoObj[K]>;
|
|
15
|
+
};
|
|
16
|
+
export interface Slice<DictShape extends SliceDictArgShape = Record<never, never>> extends Adaptor {
|
|
17
|
+
readonly [SLICE_DICT_SHAPE]: DictShape;
|
|
9
18
|
}
|
|
10
19
|
export type SliceCls<SrvModule extends ServiceModel = ServiceModel, SliceInfoObj extends {
|
|
11
20
|
[key: string]: SliceInfo;
|
|
12
21
|
} = {
|
|
13
22
|
[key: string]: SliceInfo;
|
|
14
|
-
}> = AdaptorCls & {
|
|
23
|
+
}> = AdaptorCls<Slice<SliceDictShape<SliceInfoObj>>> & {
|
|
15
24
|
baseName: SrvRefName<SrvModule>;
|
|
16
25
|
srv: SrvModule;
|
|
26
|
+
prototype: Slice<SliceDictShape<SliceInfoObj>>;
|
|
17
27
|
[SLICE_META]: SliceInfoObj;
|
|
18
28
|
getGuards: GuardCls[];
|
|
19
29
|
cruGuards: GuardCls[];
|