akanjs 2.3.8-rc.1 → 2.3.8-rc.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/dictionary/dictInfo.ts +48 -19
- package/dictionary/locale.ts +46 -25
- package/package.json +1 -1
- package/types/dictionary/dictInfo.d.ts +14 -14
- package/types/dictionary/locale.d.ts +9 -9
package/dictionary/dictInfo.ts
CHANGED
|
@@ -2,19 +2,39 @@ import type { GetStateObject } from "akanjs/base";
|
|
|
2
2
|
import { capitalize } from "akanjs/common";
|
|
3
3
|
import type { BaseInsight, BaseObject } from "akanjs/constant";
|
|
4
4
|
import type { BaseFilterQueryKey, BaseFilterSortKey, FilterCls, FilterInfo, FilterInstance } from "akanjs/document";
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
EndpInfoArgNames,
|
|
7
|
+
EndpointCls,
|
|
8
|
+
EndpointInfo,
|
|
9
|
+
SliceCls,
|
|
10
|
+
SliceInfo,
|
|
11
|
+
SliceInfoArgNames,
|
|
12
|
+
} from "akanjs/signal";
|
|
6
13
|
import type { DictionaryNode, RootDictionary } from "./trans";
|
|
7
14
|
|
|
8
15
|
type MutableDictionaryNode = DictionaryNode & { t?: string; desc?: DictionaryNode };
|
|
9
16
|
type EnumValueKey = string | number;
|
|
10
17
|
type AnyFilterShape = FilterInstance<Record<string, FilterInfo>, Record<string, unknown>>;
|
|
11
|
-
type DictFilterShape<Filter> =
|
|
12
|
-
|
|
13
|
-
: Filter extends FilterCls<infer FilterShape>
|
|
18
|
+
type DictFilterShape<Filter> =
|
|
19
|
+
Filter extends FilterCls<infer FilterShape>
|
|
14
20
|
? FilterShape
|
|
15
|
-
: Filter extends
|
|
21
|
+
: Filter extends FilterInstance
|
|
16
22
|
? Filter
|
|
17
|
-
:
|
|
23
|
+
: Filter extends { query: Record<string, FilterInfo>; sort: Record<string, unknown> }
|
|
24
|
+
? Filter
|
|
25
|
+
: AnyFilterShape;
|
|
26
|
+
type DictSliceShape<Slice> =
|
|
27
|
+
Slice extends SliceCls<infer _SrvModule, infer SliceInfoObj>
|
|
28
|
+
? SliceInfoObj
|
|
29
|
+
: Slice extends Record<string, SliceInfo>
|
|
30
|
+
? Slice
|
|
31
|
+
: Record<never, never>;
|
|
32
|
+
type DictEndpointShape<Endpoint> =
|
|
33
|
+
Endpoint extends EndpointCls<infer _SrvModule, infer EndpointInfoObj>
|
|
34
|
+
? EndpointInfoObj
|
|
35
|
+
: Endpoint extends Record<string, EndpointInfo>
|
|
36
|
+
? Endpoint
|
|
37
|
+
: Record<never, never>;
|
|
18
38
|
type DictFilterQuery<Filter> = DictFilterShape<Filter>["query"];
|
|
19
39
|
type DictFilterSort<Filter> = DictFilterShape<Filter>["sort"];
|
|
20
40
|
|
|
@@ -96,7 +116,7 @@ export class ModelDictInfo<
|
|
|
96
116
|
SortKey extends string = BaseFilterSortKey,
|
|
97
117
|
EnumKey extends string = never,
|
|
98
118
|
BaseSignalKey extends string = never,
|
|
99
|
-
SliceKey extends string =
|
|
119
|
+
SliceKey extends string = "",
|
|
100
120
|
EndpointKey extends string = never,
|
|
101
121
|
ErrorKey extends string = never,
|
|
102
122
|
EtcKey extends string = never,
|
|
@@ -162,7 +182,7 @@ export class ModelDictInfo<
|
|
|
162
182
|
static baseSliceDictionary: {
|
|
163
183
|
[key in ""]: FunctionTranslation<[string, string], "query">;
|
|
164
184
|
} = {
|
|
165
|
-
|
|
185
|
+
"": fn(["Universal", "유니버설"])
|
|
166
186
|
.desc(["Universal Slice", "유니버설 슬라이스"])
|
|
167
187
|
.arg((t) => ({
|
|
168
188
|
query: t(["Query", "쿼리"]).desc(["Query Description", "쿼리 설명"]),
|
|
@@ -264,7 +284,8 @@ export class ModelDictInfo<
|
|
|
264
284
|
translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
265
285
|
[K in Exclude<keyof DictFilterQuery<Filter>, QueryKey>]: DictFilterQuery<Filter>[K] extends FilterInfo<
|
|
266
286
|
infer ArgNames,
|
|
267
|
-
|
|
287
|
+
infer _Args,
|
|
288
|
+
infer _Model
|
|
268
289
|
>
|
|
269
290
|
? FunctionTranslation<Languages, ArgNames[number]>
|
|
270
291
|
: never;
|
|
@@ -273,7 +294,9 @@ export class ModelDictInfo<
|
|
|
273
294
|
Object.assign(this.queryDictionary, translate(fn), ModelDictInfo.baseQueryDictionary) as unknown as {
|
|
274
295
|
[K in keyof DictFilterQuery<Filter>]: FunctionTranslation<
|
|
275
296
|
Languages,
|
|
276
|
-
DictFilterQuery<Filter>[K] extends FilterInfo<infer ArgNames,
|
|
297
|
+
DictFilterQuery<Filter>[K] extends FilterInfo<infer ArgNames, infer _Args, infer _Model>
|
|
298
|
+
? ArgNames[number]
|
|
299
|
+
: never
|
|
277
300
|
>;
|
|
278
301
|
};
|
|
279
302
|
return this as unknown as ModelDictInfo<
|
|
@@ -340,13 +363,14 @@ export class ModelDictInfo<
|
|
|
340
363
|
}
|
|
341
364
|
slice<Slice>(
|
|
342
365
|
translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
343
|
-
[K in Exclude<keyof Slice
|
|
366
|
+
[K in Exclude<keyof DictSliceShape<Slice>, SliceKey>]: DictSliceShape<Slice>[K] extends infer Info extends
|
|
367
|
+
SliceInfo
|
|
344
368
|
? FunctionTranslation<Languages, SliceInfoArgNames<Info>[number]>
|
|
345
369
|
: never;
|
|
346
370
|
},
|
|
347
371
|
) {
|
|
348
372
|
Object.assign(this.sliceDictionary, translate(fn), ModelDictInfo.baseSliceDictionary) as unknown as {
|
|
349
|
-
[K in keyof Slice]: FunctionTranslation<Languages>;
|
|
373
|
+
[K in keyof DictSliceShape<Slice>]: FunctionTranslation<Languages>;
|
|
350
374
|
};
|
|
351
375
|
return this as unknown as ModelDictInfo<
|
|
352
376
|
Languages,
|
|
@@ -356,7 +380,7 @@ export class ModelDictInfo<
|
|
|
356
380
|
SortKey,
|
|
357
381
|
EnumKey,
|
|
358
382
|
BaseSignalKey,
|
|
359
|
-
keyof Slice & string,
|
|
383
|
+
keyof DictSliceShape<Slice> & string,
|
|
360
384
|
EndpointKey,
|
|
361
385
|
ErrorKey,
|
|
362
386
|
EtcKey
|
|
@@ -364,7 +388,10 @@ export class ModelDictInfo<
|
|
|
364
388
|
}
|
|
365
389
|
endpoint<Endpoint>(
|
|
366
390
|
translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
367
|
-
[K in Exclude<
|
|
391
|
+
[K in Exclude<
|
|
392
|
+
keyof DictEndpointShape<Endpoint>,
|
|
393
|
+
EndpointKey
|
|
394
|
+
>]: DictEndpointShape<Endpoint>[K] extends infer Info extends EndpointInfo
|
|
368
395
|
? FunctionTranslation<Languages, EndpInfoArgNames<Info>[number]>
|
|
369
396
|
: never;
|
|
370
397
|
},
|
|
@@ -381,7 +408,7 @@ export class ModelDictInfo<
|
|
|
381
408
|
EnumKey,
|
|
382
409
|
BaseSignalKey,
|
|
383
410
|
SliceKey,
|
|
384
|
-
keyof Endpoint & string,
|
|
411
|
+
keyof DictEndpointShape<Endpoint> & string,
|
|
385
412
|
ErrorKey,
|
|
386
413
|
EtcKey
|
|
387
414
|
>;
|
|
@@ -777,7 +804,7 @@ type MergeTwoModelDicts<ModelDict1, ModelDict2> =
|
|
|
777
804
|
infer EtcKey1
|
|
778
805
|
>
|
|
779
806
|
? ModelDict2 extends ModelDictInfo<
|
|
780
|
-
|
|
807
|
+
infer _Languages2,
|
|
781
808
|
infer ModelKey2,
|
|
782
809
|
infer InsightKey2,
|
|
783
810
|
infer QueryKey2,
|
|
@@ -980,15 +1007,17 @@ export class ServiceDictInfo<
|
|
|
980
1007
|
constructor(languages: Languages) {
|
|
981
1008
|
this.languages = languages;
|
|
982
1009
|
}
|
|
983
|
-
endpoint<Endpoint
|
|
1010
|
+
endpoint<Endpoint>(
|
|
984
1011
|
translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
985
|
-
[K in keyof Endpoint]:
|
|
1012
|
+
[K in keyof DictEndpointShape<Endpoint>]: DictEndpointShape<Endpoint>[K] extends infer Info extends EndpointInfo
|
|
1013
|
+
? FunctionTranslation<Languages, EndpInfoArgNames<Info>[number]>
|
|
1014
|
+
: never;
|
|
986
1015
|
},
|
|
987
1016
|
) {
|
|
988
1017
|
Object.assign(this.endpointDictionary, translate(fn)) as unknown as {
|
|
989
1018
|
[K in EndpointKey]: FunctionTranslation<Languages>;
|
|
990
1019
|
};
|
|
991
|
-
return this as unknown as ServiceDictInfo<Languages, keyof Endpoint & string, ErrorKey, EtcKey>;
|
|
1020
|
+
return this as unknown as ServiceDictInfo<Languages, keyof DictEndpointShape<Endpoint> & string, ErrorKey, EtcKey>;
|
|
992
1021
|
}
|
|
993
1022
|
error<ErrorDict extends { [key: string]: Languages }>(errorDictionary: ErrorDict) {
|
|
994
1023
|
Object.assign(this.errorDictionary, errorDictionary);
|
package/dictionary/locale.ts
CHANGED
|
@@ -17,20 +17,21 @@ interface FnTrans<ArgKey extends string> {
|
|
|
17
17
|
arg?: { [key in ArgKey]: FieldTrans };
|
|
18
18
|
}
|
|
19
19
|
type AnyFilterShape = FilterInstance<Record<string, FilterInfo>, Record<string, unknown>>;
|
|
20
|
-
type DictFilterShape<Filter> =
|
|
21
|
-
|
|
22
|
-
: Filter extends FilterCls<infer FilterShape>
|
|
20
|
+
type DictFilterShape<Filter> =
|
|
21
|
+
Filter extends FilterCls<infer FilterShape>
|
|
23
22
|
? FilterShape
|
|
24
|
-
: Filter extends
|
|
23
|
+
: Filter extends FilterInstance
|
|
25
24
|
? Filter
|
|
26
|
-
:
|
|
25
|
+
: Filter extends { query: Record<string, FilterInfo>; sort: Record<string, unknown> }
|
|
26
|
+
? Filter
|
|
27
|
+
: AnyFilterShape;
|
|
27
28
|
type DictFilterQuery<Filter> = DictFilterShape<Filter>["query"];
|
|
28
29
|
type DictFilterSort<Filter> = DictFilterShape<Filter>["sort"];
|
|
29
30
|
type FilterTranslatorKey<Filter> = {
|
|
30
31
|
[Key in keyof DictFilterQuery<Filter> & string]:
|
|
31
32
|
| `${Key}`
|
|
32
33
|
| `${Key}.desc`
|
|
33
|
-
| (DictFilterQuery<Filter>[Key] extends FilterInfo<infer ArgNames,
|
|
34
|
+
| (DictFilterQuery<Filter>[Key] extends FilterInfo<infer ArgNames, infer _Args>
|
|
34
35
|
? ArgNames[number] extends string
|
|
35
36
|
? `${Key}.arg.${ArgNames[number]}` | `${Key}.arg.${ArgNames[number]}.desc`
|
|
36
37
|
: never
|
|
@@ -94,7 +95,7 @@ export type ModelTrans<
|
|
|
94
95
|
model: { [K in keyof GetStateObject<Model>]: FieldTrans };
|
|
95
96
|
insight: { [K in keyof GetStateObject<Insight>]: FieldTrans };
|
|
96
97
|
query: {
|
|
97
|
-
[K in keyof DictFilterQuery<Filter>]: DictFilterQuery<Filter>[K] extends FilterInfo<infer ArgNames,
|
|
98
|
+
[K in keyof DictFilterQuery<Filter>]: DictFilterQuery<Filter>[K] extends FilterInfo<infer ArgNames, infer _Args>
|
|
98
99
|
? FnTrans<ArgNames[number]>
|
|
99
100
|
: never;
|
|
100
101
|
};
|
|
@@ -125,7 +126,7 @@ export type ModelTranslatorKey<
|
|
|
125
126
|
| `${T}.signal.${EndpointTranslatorKey<Endpoint> | SliceTranslatorKey<Slice>}`
|
|
126
127
|
| `${T}.${EtcKey}`;
|
|
127
128
|
|
|
128
|
-
export type ScalarTrans<
|
|
129
|
+
export type ScalarTrans<_T extends string, Model, ErrorKey extends string, EtcKey extends string> = {
|
|
129
130
|
name: Trans;
|
|
130
131
|
desc: Trans;
|
|
131
132
|
model: { [K in keyof GetStateObject<Model>]: FieldTrans };
|
|
@@ -138,7 +139,7 @@ export type ScalarTranslatorKey<T extends string, Model, EtcKey extends string>
|
|
|
138
139
|
| `${T}.${EtcKey}`;
|
|
139
140
|
|
|
140
141
|
export type ServiceTrans<
|
|
141
|
-
|
|
142
|
+
_T extends string,
|
|
142
143
|
Endpoint extends { [key: string]: EndpointInfo },
|
|
143
144
|
ErrorKey extends string,
|
|
144
145
|
EtcKey extends string,
|
|
@@ -162,7 +163,10 @@ export type EnumTranslatorKey<EnumKey extends string> = `${EnumKey}.${string}${"
|
|
|
162
163
|
export interface DictModule<DictKey extends string, ErrorKey extends string> {
|
|
163
164
|
__Dict_Key__: DictKey;
|
|
164
165
|
__Error_Key__: ErrorKey;
|
|
165
|
-
dict:
|
|
166
|
+
dict:
|
|
167
|
+
| ModelDictInfo<[string, ...string[]]>
|
|
168
|
+
| ScalarDictInfo<[string, ...string[]]>
|
|
169
|
+
| ServiceDictInfo<[string, ...string[]]>;
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
export const registerModelTrans = <
|
|
@@ -172,25 +176,37 @@ export const registerModelTrans = <
|
|
|
172
176
|
Filter,
|
|
173
177
|
Slice extends { [key: string]: SliceInfo },
|
|
174
178
|
Endpoint extends { [key: string]: EndpointInfo },
|
|
175
|
-
ModelDict
|
|
179
|
+
ModelDict,
|
|
176
180
|
>(
|
|
177
181
|
modelDict: ModelDict,
|
|
178
|
-
): ModelDict extends ModelDictInfo<
|
|
182
|
+
): ModelDict extends ModelDictInfo<
|
|
183
|
+
infer _Languages,
|
|
184
|
+
infer _ModelKey,
|
|
185
|
+
infer _InsightKey,
|
|
186
|
+
infer _QueryKey,
|
|
187
|
+
infer _SortKey,
|
|
188
|
+
infer EnumKey,
|
|
189
|
+
infer _BaseSignalKey,
|
|
190
|
+
infer _SliceKey,
|
|
191
|
+
infer _EndpointKey,
|
|
192
|
+
infer ErrorKey,
|
|
193
|
+
infer EtcKey
|
|
194
|
+
>
|
|
179
195
|
? DictModule<
|
|
180
196
|
ModelTranslatorKey<RefName, Model, Insight, Filter, Slice, Endpoint, EtcKey> | EnumTranslatorKey<EnumKey>,
|
|
181
197
|
`${RefName}.error.${ErrorKey}`
|
|
182
198
|
>
|
|
183
199
|
: never => {
|
|
184
200
|
return { dict: modelDict } as unknown as ModelDict extends ModelDictInfo<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
201
|
+
infer _Languages,
|
|
202
|
+
infer _ModelKey,
|
|
203
|
+
infer _InsightKey,
|
|
204
|
+
infer _QueryKey,
|
|
205
|
+
infer _SortKey,
|
|
190
206
|
infer EnumKey,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
207
|
+
infer _BaseSignalKey,
|
|
208
|
+
infer _SliceKey,
|
|
209
|
+
infer _EndpointKey,
|
|
194
210
|
infer ErrorKey,
|
|
195
211
|
infer EtcKey
|
|
196
212
|
>
|
|
@@ -203,12 +219,12 @@ export const registerModelTrans = <
|
|
|
203
219
|
|
|
204
220
|
export const registerScalarTrans = <T extends string, Model, ScalarDict>(
|
|
205
221
|
scalarDict: ScalarDict,
|
|
206
|
-
): ScalarDict extends ScalarDictInfo<
|
|
222
|
+
): ScalarDict extends ScalarDictInfo<infer _Languages, infer _ModelKey, infer EnumKey, infer ErrorKey, infer EtcKey>
|
|
207
223
|
? DictModule<ScalarTranslatorKey<T, Model, EtcKey> | EnumTranslatorKey<EnumKey>, `${T}.error.${ErrorKey}`>
|
|
208
224
|
: never => {
|
|
209
225
|
return { dict: scalarDict } as unknown as ScalarDict extends ScalarDictInfo<
|
|
210
|
-
|
|
211
|
-
|
|
226
|
+
infer _Languages,
|
|
227
|
+
infer _ModelKey,
|
|
212
228
|
infer EnumKey,
|
|
213
229
|
infer ErrorKey,
|
|
214
230
|
infer EtcKey
|
|
@@ -219,10 +235,15 @@ export const registerScalarTrans = <T extends string, Model, ScalarDict>(
|
|
|
219
235
|
|
|
220
236
|
export const registerServiceTrans = <T extends string, Endpoint extends { [key: string]: EndpointInfo }, ServiceDict>(
|
|
221
237
|
serviceDict: ServiceDict,
|
|
222
|
-
): ServiceDict extends ServiceDictInfo<
|
|
238
|
+
): ServiceDict extends ServiceDictInfo<infer _Languages, infer _EndpointKey, infer ErrorKey, infer EtcKey>
|
|
223
239
|
? DictModule<ServiceTranslatorKey<T, Endpoint, EtcKey>, `${T}.error.${ErrorKey}`>
|
|
224
240
|
: never => {
|
|
225
|
-
return { dict: serviceDict } as unknown as ServiceDict extends ServiceDictInfo<
|
|
241
|
+
return { dict: serviceDict } as unknown as ServiceDict extends ServiceDictInfo<
|
|
242
|
+
infer _Languages,
|
|
243
|
+
infer _EndpointKey,
|
|
244
|
+
infer ErrorKey,
|
|
245
|
+
infer EtcKey
|
|
246
|
+
>
|
|
226
247
|
? DictModule<ServiceTranslatorKey<T, Endpoint, EtcKey>, `${T}.error.${ErrorKey}`>
|
|
227
248
|
: never;
|
|
228
249
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { GetStateObject } from "akanjs/base";
|
|
2
2
|
import type { BaseInsight, BaseObject } from "akanjs/constant";
|
|
3
3
|
import type { BaseFilterQueryKey, BaseFilterSortKey, FilterCls, FilterInfo, FilterInstance } from "akanjs/document";
|
|
4
|
-
import type { EndpInfoArgNames, EndpointInfo, SliceInfo, SliceInfoArgNames } from "akanjs/signal";
|
|
4
|
+
import type { EndpInfoArgNames, EndpointCls, EndpointInfo, SliceCls, SliceInfo, SliceInfoArgNames } from "akanjs/signal";
|
|
5
5
|
import type { RootDictionary } from "./trans.d.ts";
|
|
6
6
|
type EnumValueKey = string | number;
|
|
7
7
|
type AnyFilterShape = FilterInstance<Record<string, FilterInfo>, Record<string, unknown>>;
|
|
8
|
-
type DictFilterShape<Filter> = Filter extends
|
|
8
|
+
type DictFilterShape<Filter> = Filter extends FilterCls<infer FilterShape> ? FilterShape : Filter extends FilterInstance ? Filter : Filter extends {
|
|
9
9
|
query: Record<string, FilterInfo>;
|
|
10
10
|
sort: Record<string, unknown>;
|
|
11
11
|
} ? Filter : AnyFilterShape;
|
|
12
|
+
type DictSliceShape<Slice> = Slice extends SliceCls<infer _SrvModule, infer SliceInfoObj> ? SliceInfoObj : Slice extends Record<string, SliceInfo> ? Slice : Record<never, never>;
|
|
13
|
+
type DictEndpointShape<Endpoint> = Endpoint extends EndpointCls<infer _SrvModule, infer EndpointInfoObj> ? EndpointInfoObj : Endpoint extends Record<string, EndpointInfo> ? Endpoint : Record<never, never>;
|
|
12
14
|
type DictFilterQuery<Filter> = DictFilterShape<Filter>["query"];
|
|
13
15
|
type DictFilterSort<Filter> = DictFilterShape<Filter>["sort"];
|
|
14
16
|
declare class FieldTranslation<Languages extends [string, ...string[]]> {
|
|
@@ -42,7 +44,7 @@ type BaseModelCrudGetSignalTranslation<T extends string, Languages extends [stri
|
|
|
42
44
|
[K in `remove${_CapitalizedRefName}`]: FunctionTranslation<Languages, `${T}Id`>;
|
|
43
45
|
};
|
|
44
46
|
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 =
|
|
47
|
+
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
48
|
#private;
|
|
47
49
|
static baseModelDictionary: {
|
|
48
50
|
[key in keyof BaseObject]: FieldTranslation<[string, string]>;
|
|
@@ -103,7 +105,7 @@ export declare class ModelDictInfo<Languages extends [string, ...string[]] = [st
|
|
|
103
105
|
[K in Exclude<keyof GetStateObject<Insight>, InsightKey>]: FieldTranslation<Languages>;
|
|
104
106
|
}): ModelDictInfo<Languages, ModelKey, keyof GetStateObject<Insight> & string, QueryKey, SortKey, EnumKey, BaseSignalKey, SliceKey, EndpointKey, ErrorKey, EtcKey>;
|
|
105
107
|
query<Filter>(translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
106
|
-
[K in Exclude<keyof DictFilterQuery<Filter>, QueryKey>]: DictFilterQuery<Filter>[K] extends FilterInfo<infer ArgNames,
|
|
108
|
+
[K in Exclude<keyof DictFilterQuery<Filter>, QueryKey>]: DictFilterQuery<Filter>[K] extends FilterInfo<infer ArgNames, infer _Args, infer _Model> ? FunctionTranslation<Languages, ArgNames[number]> : never;
|
|
107
109
|
}): ModelDictInfo<Languages, ModelKey, InsightKey, keyof DictFilterQuery<Filter> & string, SortKey, EnumKey, BaseSignalKey, SliceKey, EndpointKey, ErrorKey, EtcKey>;
|
|
108
110
|
sort<Filter>(translate: (t: (trans: Languages) => FieldTranslation<Languages>) => {
|
|
109
111
|
[K in Exclude<keyof DictFilterSort<Filter>, SortKey>]: FieldTranslation<Languages>;
|
|
@@ -115,11 +117,11 @@ export declare class ModelDictInfo<Languages extends [string, ...string[]] = [st
|
|
|
115
117
|
[K in Enum["value"]]: FieldTranslation<Languages>;
|
|
116
118
|
}): ModelDictInfo<Languages, ModelKey, InsightKey, QueryKey, SortKey, EnumKey | Enum["refName"], BaseSignalKey, SliceKey, EndpointKey, ErrorKey, EtcKey>;
|
|
117
119
|
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>;
|
|
120
|
+
[K in Exclude<keyof DictSliceShape<Slice>, SliceKey>]: DictSliceShape<Slice>[K] extends infer Info extends SliceInfo ? FunctionTranslation<Languages, SliceInfoArgNames<Info>[number]> : never;
|
|
121
|
+
}): ModelDictInfo<Languages, ModelKey, InsightKey, QueryKey, SortKey, EnumKey, BaseSignalKey, keyof DictSliceShape<Slice> & string, EndpointKey, ErrorKey, EtcKey>;
|
|
120
122
|
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>;
|
|
123
|
+
[K in Exclude<keyof DictEndpointShape<Endpoint>, EndpointKey>]: DictEndpointShape<Endpoint>[K] extends infer Info extends EndpointInfo ? FunctionTranslation<Languages, EndpInfoArgNames<Info>[number]> : never;
|
|
124
|
+
}): ModelDictInfo<Languages, ModelKey, InsightKey, QueryKey, SortKey, EnumKey, BaseSignalKey, SliceKey, keyof DictEndpointShape<Endpoint> & string, ErrorKey, EtcKey>;
|
|
123
125
|
error<ErrorDict extends {
|
|
124
126
|
[key: string]: Languages;
|
|
125
127
|
}>(errorDictionary: ErrorDict): ModelDictInfo<Languages, ModelKey, InsightKey, QueryKey, SortKey, EnumKey, BaseSignalKey, SliceKey, EndpointKey, ErrorKey | (keyof ErrorDict & string), EtcKey>;
|
|
@@ -136,7 +138,7 @@ export declare class ModelDictInfo<Languages extends [string, ...string[]] = [st
|
|
|
136
138
|
};
|
|
137
139
|
}
|
|
138
140
|
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<
|
|
141
|
+
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
142
|
type MergeModelDicts<ModelDicts extends AnyModelDictInfo[]> = ModelDicts extends [
|
|
141
143
|
infer First extends AnyModelDictInfo,
|
|
142
144
|
...infer Rest extends AnyModelDictInfo[]
|
|
@@ -193,11 +195,9 @@ export declare class ServiceDictInfo<Languages extends [string, ...string[]] = [
|
|
|
193
195
|
[K in EtcKey]: Languages;
|
|
194
196
|
};
|
|
195
197
|
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>;
|
|
198
|
+
endpoint<Endpoint>(translate: (fn: (trans: Languages) => FunctionTranslation<Languages>) => {
|
|
199
|
+
[K in keyof DictEndpointShape<Endpoint>]: DictEndpointShape<Endpoint>[K] extends infer Info extends EndpointInfo ? FunctionTranslation<Languages, EndpInfoArgNames<Info>[number]> : never;
|
|
200
|
+
}): ServiceDictInfo<Languages, keyof DictEndpointShape<Endpoint> & string, ErrorKey, EtcKey>;
|
|
201
201
|
error<ErrorDict extends {
|
|
202
202
|
[key: string]: Languages;
|
|
203
203
|
}>(errorDictionary: ErrorDict): ServiceDictInfo<Languages, EndpointKey, keyof ErrorDict & string, EtcKey>;
|
|
@@ -18,14 +18,14 @@ interface FnTrans<ArgKey extends string> {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
type AnyFilterShape = FilterInstance<Record<string, FilterInfo>, Record<string, unknown>>;
|
|
21
|
-
type DictFilterShape<Filter> = Filter extends
|
|
21
|
+
type DictFilterShape<Filter> = Filter extends FilterCls<infer FilterShape> ? FilterShape : Filter extends FilterInstance ? Filter : Filter extends {
|
|
22
22
|
query: Record<string, FilterInfo>;
|
|
23
23
|
sort: Record<string, unknown>;
|
|
24
24
|
} ? Filter : AnyFilterShape;
|
|
25
25
|
type DictFilterQuery<Filter> = DictFilterShape<Filter>["query"];
|
|
26
26
|
type DictFilterSort<Filter> = DictFilterShape<Filter>["sort"];
|
|
27
27
|
type FilterTranslatorKey<Filter> = {
|
|
28
|
-
[Key in keyof DictFilterQuery<Filter> & string]: `${Key}` | `${Key}.desc` | (DictFilterQuery<Filter>[Key] extends FilterInfo<infer ArgNames,
|
|
28
|
+
[Key in keyof DictFilterQuery<Filter> & string]: `${Key}` | `${Key}.desc` | (DictFilterQuery<Filter>[Key] extends FilterInfo<infer ArgNames, infer _Args> ? ArgNames[number] extends string ? `${Key}.arg.${ArgNames[number]}` | `${Key}.arg.${ArgNames[number]}.desc` : never : never);
|
|
29
29
|
}[keyof DictFilterQuery<Filter> & string];
|
|
30
30
|
type EndpointTranslatorKey<Endpoint extends {
|
|
31
31
|
[key: string]: EndpointInfo;
|
|
@@ -65,7 +65,7 @@ export type ModelTrans<T extends string, Model extends BaseObject, Insight exten
|
|
|
65
65
|
[K in keyof GetStateObject<Insight>]: FieldTrans;
|
|
66
66
|
};
|
|
67
67
|
query: {
|
|
68
|
-
[K in keyof DictFilterQuery<Filter>]: DictFilterQuery<Filter>[K] extends FilterInfo<infer ArgNames,
|
|
68
|
+
[K in keyof DictFilterQuery<Filter>]: DictFilterQuery<Filter>[K] extends FilterInfo<infer ArgNames, infer _Args> ? FnTrans<ArgNames[number]> : never;
|
|
69
69
|
};
|
|
70
70
|
sort: {
|
|
71
71
|
[K in keyof DictFilterSort<Filter>]: FieldTrans;
|
|
@@ -86,7 +86,7 @@ export type ModelTranslatorKey<T extends string, Model, Insight, Filter, Slice e
|
|
|
86
86
|
}, Endpoint extends {
|
|
87
87
|
[key: string]: EndpointInfo;
|
|
88
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<
|
|
89
|
+
export type ScalarTrans<_T extends string, Model, ErrorKey extends string, EtcKey extends string> = {
|
|
90
90
|
name: Trans;
|
|
91
91
|
desc: Trans;
|
|
92
92
|
model: {
|
|
@@ -99,7 +99,7 @@ export type ScalarTrans<T extends string, Model, ErrorKey extends string, EtcKey
|
|
|
99
99
|
[K in EtcKey]: Trans;
|
|
100
100
|
};
|
|
101
101
|
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<
|
|
102
|
+
export type ServiceTrans<_T extends string, Endpoint extends {
|
|
103
103
|
[key: string]: EndpointInfo;
|
|
104
104
|
}, ErrorKey extends string, EtcKey extends string> = {
|
|
105
105
|
api: {
|
|
@@ -121,15 +121,15 @@ export type EnumTranslatorKey<EnumKey extends string> = `${EnumKey}.${string}${"
|
|
|
121
121
|
export interface DictModule<DictKey extends string, ErrorKey extends string> {
|
|
122
122
|
__Dict_Key__: DictKey;
|
|
123
123
|
__Error_Key__: ErrorKey;
|
|
124
|
-
dict: ModelDictInfo<
|
|
124
|
+
dict: ModelDictInfo<[string, ...string[]]> | ScalarDictInfo<[string, ...string[]]> | ServiceDictInfo<[string, ...string[]]>;
|
|
125
125
|
}
|
|
126
126
|
export declare const registerModelTrans: <RefName extends string, Model extends BaseObject, Insight extends BaseInsight, Filter, Slice extends {
|
|
127
127
|
[key: string]: SliceInfo;
|
|
128
128
|
}, Endpoint extends {
|
|
129
129
|
[key: string]: EndpointInfo;
|
|
130
|
-
}, ModelDict
|
|
131
|
-
export declare const registerScalarTrans: <T extends string, Model, ScalarDict>(scalarDict: ScalarDict) => ScalarDict extends ScalarDictInfo<
|
|
130
|
+
}, 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;
|
|
131
|
+
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;
|
|
132
132
|
export declare const registerServiceTrans: <T extends string, Endpoint extends {
|
|
133
133
|
[key: string]: EndpointInfo;
|
|
134
|
-
}, ServiceDict>(serviceDict: ServiceDict) => ServiceDict extends ServiceDictInfo<
|
|
134
|
+
}, ServiceDict>(serviceDict: ServiceDict) => ServiceDict extends ServiceDictInfo<infer _Languages, infer _EndpointKey, infer ErrorKey, infer EtcKey> ? DictModule<ServiceTranslatorKey<T, Endpoint, EtcKey>, `${T}.error.${ErrorKey}`> : never;
|
|
135
135
|
export {};
|