@akanjs/dictionary 0.0.39 → 0.0.41

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/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/dictionary",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./trans";
package/src/trans.d.ts ADDED
@@ -0,0 +1,188 @@
1
+ import { type BaseFilterKey, type GetActionObject, type GetStateObject } from "@akanjs/constant";
2
+ import { DefaultSignal } from "@akanjs/signal";
3
+ type TranslationSingle = readonly [string, string] | readonly [string, string, string, string];
4
+ type TranslationWithParam = readonly [string, string, {
5
+ [key: string]: string | number;
6
+ }];
7
+ export type Translation = TranslationSingle | TranslationWithParam;
8
+ export type Translate<Checker> = {
9
+ [K in keyof GetStateObject<Checker>]: Translation;
10
+ } & {
11
+ [key: string]: Translation;
12
+ } & {
13
+ modelName: Translation;
14
+ };
15
+ export type ExtendModelDictionary<Model, Insight = unknown, Filter = unknown> = {
16
+ [K in keyof Omit<GetStateObject<Model & Insight & Filter>, BaseFilterKey> as K extends string ? K | `desc-${K}` : never]: Translation;
17
+ } & {
18
+ [K in keyof Omit<GetActionObject<Filter>, BaseFilterKey> as K extends string ? `qry-${K}` | `qrydesc-${K}` : never]: Translation;
19
+ } & {
20
+ [key: string]: Translation;
21
+ };
22
+ export type ModelDictionary<Model, Insight = unknown, Filter = unknown> = {
23
+ [K in keyof GetStateObject<Model & Insight & Filter> as K extends string ? K | `desc-${K}` : never]: Translation;
24
+ } & {
25
+ [K in keyof GetActionObject<Filter> as K extends string ? `qry-${K}` | `qrydesc-${K}` : never]: Translation;
26
+ } & {
27
+ [key: string]: Translation;
28
+ } & {
29
+ modelName: Translation;
30
+ modelDesc: Translation;
31
+ };
32
+ export type SummaryDictionary<Summary> = {
33
+ [K in keyof GetStateObject<Summary> as K extends string ? K | `desc-${K}` : never]: Translation;
34
+ };
35
+ export type SignalDictionary<Checker, Model = unknown> = {
36
+ [K in keyof GetActionObject<Checker> as K extends string ? K extends keyof Model ? never : Checker[K] extends (...args: any) => Promise<{
37
+ __Returns__: "Done";
38
+ }> ? never : `apidesc-${K}` | `api-${K}` : never]: Translation;
39
+ } & {
40
+ [key: string]: Translation;
41
+ };
42
+ export type GetKeys<O> = O extends infer U ? (U extends object ? keyof U : never) : never;
43
+ export type TransMessage<Locale extends Record<string, any>> = Locale extends infer U ? U extends object ? {
44
+ [K in keyof U]-?: `${K & string}${U[K] extends Record<string, any> ? `.${GetKeys<U[K]>}` : never}`;
45
+ }[keyof U] : never : never;
46
+ export declare const baseTrans: {
47
+ readonly id: readonly ["Id", "아이디"];
48
+ readonly "desc-id": readonly ["Unique ID value", "유니크한 아이디값"];
49
+ readonly createdAt: readonly ["CreatedAt", "생성일"];
50
+ readonly "desc-createdAt": readonly ["Data created time", "데이터 생성 시각"];
51
+ readonly updatedAt: readonly ["UpdatedAt", "수정일"];
52
+ readonly "desc-updatedAt": readonly ["Data updated time", "데이터 마지막 수정 시각"];
53
+ readonly removedAt: readonly ["RemovedAt", "삭제일"];
54
+ readonly "desc-removedAt": readonly ["Data removed time", "데이터 삭제 시각"];
55
+ readonly status: readonly ["Status", "상태"];
56
+ readonly "desc-status": readonly ["Data status", "데이터 상태"];
57
+ readonly count: readonly ["Count", "개수"];
58
+ readonly "desc-count": readonly ["Data count", "데이터 개수"];
59
+ readonly latest: readonly ["latest", "최신순"];
60
+ readonly "desc-latest": readonly ["latest", "최신순"];
61
+ readonly oldest: readonly ["oldest", "오래된순"];
62
+ readonly "desc-oldest": readonly ["oldest", "오래된순"];
63
+ readonly "qry-any": readonly ["All", "전체"];
64
+ readonly "qrydesc-any": readonly ["All", "전체"];
65
+ readonly "qry-byStatuses": readonly ["By Statuses", "상태별 조회"];
66
+ readonly "qrydesc-byStatuses": readonly ["By Statuses", "상태별 조회"];
67
+ readonly "qarg-byStatuses-statuses": readonly ["Statuses", "상태"];
68
+ readonly "qargdesc-byStatuses-statuses": readonly ["Statuses", "상태"];
69
+ };
70
+ type BaseSignalTrans<T extends string> = {
71
+ [K in keyof DefaultSignal<T, any, any, any, any, any> as K extends string ? `apidesc-${K}` | `api-${K}` : never]: Translation;
72
+ };
73
+ export declare const getBaseSignalTrans: <T extends string>(modelName: T) => BaseSignalTrans<T>;
74
+ export declare const checkDictCoverage: () => void;
75
+ type MergeDoubleDepths<T, U> = U extends undefined ? T : {
76
+ [K in keyof T | keyof U]: K extends keyof T ? K extends keyof U ? T[K] & U[K] : T[K] : K extends keyof U ? U[K] : never;
77
+ };
78
+ export declare const rootDictionary: {
79
+ [key: string]: {
80
+ [key: string]: Translation;
81
+ };
82
+ };
83
+ export declare const makeDictionary: <RootDict extends {
84
+ [key: string]: {
85
+ [key: string]: Translation;
86
+ };
87
+ }, Dict1 extends {
88
+ [key: string]: {
89
+ [key: string]: Translation;
90
+ };
91
+ }, Dict2 = unknown, Dict3 = unknown, Dict4 = unknown, Dict5 = unknown>(rootDict: RootDict, dict1: Dict1, dict2?: Dict2, dict3?: Dict3, dict4?: Dict4, dict5?: Dict5) => MergeDoubleDepths<MergeDoubleDepths<MergeDoubleDepths<MergeDoubleDepths<MergeDoubleDepths<RootDict, Dict1>, Dict2>, Dict3>, Dict4>, Dict5>;
92
+ declare const languages: readonly ["ko", "en", "zhChs", "zhCht"];
93
+ type Language = (typeof languages)[number];
94
+ export declare const msg: {
95
+ info: (key: TransMessage<any>, option?: {
96
+ key?: string;
97
+ duration?: number;
98
+ data?: {
99
+ [key: string]: any;
100
+ };
101
+ }) => void;
102
+ success: (key: TransMessage<any>, option?: {
103
+ key?: string;
104
+ duration?: number;
105
+ data?: {
106
+ [key: string]: any;
107
+ };
108
+ }) => void;
109
+ error: (key: TransMessage<any>, option?: {
110
+ key?: string;
111
+ duration?: number;
112
+ data?: {
113
+ [key: string]: any;
114
+ };
115
+ }) => void;
116
+ warning: (key: TransMessage<any>, option?: {
117
+ key?: string;
118
+ duration?: number;
119
+ data?: {
120
+ [key: string]: any;
121
+ };
122
+ }) => void;
123
+ loading: (key: TransMessage<any>, option?: {
124
+ key?: string;
125
+ duration?: number;
126
+ data?: {
127
+ [key: string]: any;
128
+ };
129
+ }) => void;
130
+ };
131
+ export declare const makeTrans: <Locale extends {
132
+ [key: string]: {
133
+ [key: string]: Translation;
134
+ };
135
+ }>(locale: Locale) => {
136
+ revert: (key: TransMessage<Locale>, data?: any) => never;
137
+ Revert: {
138
+ new (key: TransMessage<Locale>, data?: any): {
139
+ name: string;
140
+ message: string;
141
+ stack?: string;
142
+ };
143
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
144
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
145
+ stackTraceLimit: number;
146
+ };
147
+ translate: (lang: Language, key: TransMessage<Locale>, data?: any) => string | {
148
+ [key: string]: string | number;
149
+ };
150
+ msg: {
151
+ info: (key: TransMessage<Locale>, option?: {
152
+ key?: string;
153
+ duration?: number;
154
+ data?: {
155
+ [key: string]: any;
156
+ };
157
+ }) => void;
158
+ success: (key: TransMessage<Locale>, option?: {
159
+ key?: string;
160
+ duration?: number;
161
+ data?: {
162
+ [key: string]: any;
163
+ };
164
+ }) => void;
165
+ error: (key: TransMessage<Locale>, option?: {
166
+ key?: string;
167
+ duration?: number;
168
+ data?: {
169
+ [key: string]: any;
170
+ };
171
+ }) => void;
172
+ warning: (key: TransMessage<Locale>, option?: {
173
+ key?: string;
174
+ duration?: number;
175
+ data?: {
176
+ [key: string]: any;
177
+ };
178
+ }) => void;
179
+ loading: (key: TransMessage<Locale>, option?: {
180
+ key?: string;
181
+ duration?: number;
182
+ data?: {
183
+ [key: string]: any;
184
+ };
185
+ }) => void;
186
+ };
187
+ };
188
+ export {};