@akanjs/dictionary 0.0.39 → 0.0.40
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 +2 -0
- package/index.js +21 -1298
- package/package.json +2 -10
- package/src/index.d.ts +2 -0
- package/src/index.js +21 -0
- package/src/trans.d.ts +277 -0
- package/src/trans.js +593 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/dictionary",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -14,13 +14,5 @@
|
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@urql/core": "^5.1.0",
|
|
19
|
-
"dayjs": "^1.11.13",
|
|
20
|
-
"immer": "^10.1.1",
|
|
21
|
-
"next": "^15.3.2",
|
|
22
|
-
"pluralize": "^8.0.0",
|
|
23
|
-
"reflect-metadata": "^0.2.2",
|
|
24
|
-
"socket.io-client": "^4.8.1"
|
|
25
|
-
}
|
|
17
|
+
"dependencies": {}
|
|
26
18
|
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var src_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(src_exports);
|
|
17
|
+
__reExport(src_exports, require("./trans"), module.exports);
|
|
18
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
19
|
+
0 && (module.exports = {
|
|
20
|
+
...require("./trans")
|
|
21
|
+
});
|
package/src/trans.d.ts
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
|
|
3
|
+
type Environment = "testing" | "debug" | "develop" | "main";
|
|
4
|
+
|
|
5
|
+
declare class BaseObject {
|
|
6
|
+
id: string;
|
|
7
|
+
createdAt: Dayjs;
|
|
8
|
+
updatedAt: Dayjs;
|
|
9
|
+
removedAt: Dayjs | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
13
|
+
type OptionalKeys<T> = T extends {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
} ? {
|
|
16
|
+
[K in keyof T]-?: null extends T[K] ? K : never;
|
|
17
|
+
}[keyof T] : never;
|
|
18
|
+
type ObjectToId<O, D = Dayjs> = O extends BaseObject ? string : O extends BaseObject[] ? string[] : O extends Dayjs ? D : O extends {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
} ? DocumentModel<O> : O;
|
|
21
|
+
type SortOf<Filter> = keyof GetStateObject<Filter>;
|
|
22
|
+
type FilterType = Record<string, any>;
|
|
23
|
+
type DocumentModel<T, D = Dayjs> = T extends (infer S)[] ? DocumentModel<S>[] : T extends string ? T : T extends number ? T : T extends boolean ? T : T extends Dayjs ? T : T extends Map<infer K, infer V> ? Map<K, DocumentModel<V, D>> : Optional<{
|
|
24
|
+
[K in keyof GetStateObject<T>]: T[K] extends infer S ? S extends null ? undefined : ObjectToId<T[K], D> : never;
|
|
25
|
+
}, OptionalKeys<GetStateObject<T>>>;
|
|
26
|
+
type GetStateObject<T> = Omit<{
|
|
27
|
+
[K in keyof T as T[K] extends (...args: any) => any ? never : K]: T[K];
|
|
28
|
+
}, "prototype">;
|
|
29
|
+
type GetActionObject<T> = Omit<{
|
|
30
|
+
[K in keyof T as T[K] extends (...args: any) => any ? K : never]: T[K];
|
|
31
|
+
}, "prototype">;
|
|
32
|
+
|
|
33
|
+
type BaseFilterKey = "latest" | "oldest" | "any" | "byStatuses";
|
|
34
|
+
|
|
35
|
+
declare const Account: (option?: {
|
|
36
|
+
nullable?: boolean;
|
|
37
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
38
|
+
type Account<AddData = unknown> = {
|
|
39
|
+
__InternalArg__: "Account";
|
|
40
|
+
self?: Self;
|
|
41
|
+
me?: Me;
|
|
42
|
+
appName: string;
|
|
43
|
+
environment: Environment;
|
|
44
|
+
} & AddData;
|
|
45
|
+
declare const Self: (option?: {
|
|
46
|
+
nullable?: boolean;
|
|
47
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
48
|
+
interface Self {
|
|
49
|
+
__InternalArg__: "Self";
|
|
50
|
+
id: string;
|
|
51
|
+
nickname: string;
|
|
52
|
+
roles: string[];
|
|
53
|
+
image: {
|
|
54
|
+
url: string;
|
|
55
|
+
imageSize: [number, number];
|
|
56
|
+
} | null;
|
|
57
|
+
profileStatus: "active" | "prepare" | "applied" | "approved" | "reapplied" | "featured" | "reserved" | "rejected";
|
|
58
|
+
status: "prepare" | "active" | "restricted" | "dormant";
|
|
59
|
+
removedAt: Dayjs | null;
|
|
60
|
+
}
|
|
61
|
+
declare const Me: (option?: {
|
|
62
|
+
nullable?: boolean;
|
|
63
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
64
|
+
interface Me {
|
|
65
|
+
__InternalArg__: "Me";
|
|
66
|
+
id: string;
|
|
67
|
+
accountId: string;
|
|
68
|
+
roles: string[];
|
|
69
|
+
status: "active";
|
|
70
|
+
removedAt: Dayjs | null;
|
|
71
|
+
}
|
|
72
|
+
type DefaultSignal<T extends string, Input, Full, Light, Insight, Filter extends FilterType> = DefaultSignalWithQuerySort<T, Input, Full, Light, Insight, GetActionObject<Filter>, SortOf<Filter>>;
|
|
73
|
+
type DefaultSignalWithQuerySort<T extends string, Input, Full, Light, Insight, Query, Sort> = {
|
|
74
|
+
[K in Uncapitalize<T>]: (id: string) => Promise<Full>;
|
|
75
|
+
} & {
|
|
76
|
+
[K in `light${Capitalize<T>}`]: (id: string) => Promise<Light>;
|
|
77
|
+
} & {
|
|
78
|
+
[K in `${Uncapitalize<T>}List`]: (...args: [query: Query, skip: number | null, limit: number | null, sort: Sort | null]) => Promise<Full[]>;
|
|
79
|
+
} & {
|
|
80
|
+
[K in `${Uncapitalize<T>}Insight`]: (query: Query) => Promise<Insight>;
|
|
81
|
+
} & {
|
|
82
|
+
[K in `${Uncapitalize<T>}Exists`]: (query: Query) => Promise<boolean>;
|
|
83
|
+
} & {
|
|
84
|
+
[K in `create${Capitalize<T>}`]: (data: DocumentModel<Input>, account: Account) => Promise<Full>;
|
|
85
|
+
} & {
|
|
86
|
+
[K in `update${Capitalize<T>}`]: (id: string, data: DocumentModel<Input>, account: Account) => Promise<Full>;
|
|
87
|
+
} & {
|
|
88
|
+
[K in `remove${Capitalize<T>}`]: (id: string, account: Account) => Promise<Full>;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type TranslationSingle = readonly [string, string] | readonly [string, string, string, string];
|
|
92
|
+
type TranslationWithParam = readonly [string, string, {
|
|
93
|
+
[key: string]: string | number;
|
|
94
|
+
}];
|
|
95
|
+
type Translation = TranslationSingle | TranslationWithParam;
|
|
96
|
+
type Translate<Checker> = {
|
|
97
|
+
[K in keyof GetStateObject<Checker>]: Translation;
|
|
98
|
+
} & {
|
|
99
|
+
[key: string]: Translation;
|
|
100
|
+
} & {
|
|
101
|
+
modelName: Translation;
|
|
102
|
+
};
|
|
103
|
+
type ExtendModelDictionary<Model, Insight = unknown, Filter = unknown> = {
|
|
104
|
+
[K in keyof Omit<GetStateObject<Model & Insight & Filter>, BaseFilterKey> as K extends string ? K | `desc-${K}` : never]: Translation;
|
|
105
|
+
} & {
|
|
106
|
+
[K in keyof Omit<GetActionObject<Filter>, BaseFilterKey> as K extends string ? `qry-${K}` | `qrydesc-${K}` : never]: Translation;
|
|
107
|
+
} & {
|
|
108
|
+
[key: string]: Translation;
|
|
109
|
+
};
|
|
110
|
+
type ModelDictionary<Model, Insight = unknown, Filter = unknown> = {
|
|
111
|
+
[K in keyof GetStateObject<Model & Insight & Filter> as K extends string ? K | `desc-${K}` : never]: Translation;
|
|
112
|
+
} & {
|
|
113
|
+
[K in keyof GetActionObject<Filter> as K extends string ? `qry-${K}` | `qrydesc-${K}` : never]: Translation;
|
|
114
|
+
} & {
|
|
115
|
+
[key: string]: Translation;
|
|
116
|
+
} & {
|
|
117
|
+
modelName: Translation;
|
|
118
|
+
modelDesc: Translation;
|
|
119
|
+
};
|
|
120
|
+
type SummaryDictionary<Summary> = {
|
|
121
|
+
[K in keyof GetStateObject<Summary> as K extends string ? K | `desc-${K}` : never]: Translation;
|
|
122
|
+
};
|
|
123
|
+
type SignalDictionary<Checker, Model = unknown> = {
|
|
124
|
+
[K in keyof GetActionObject<Checker> as K extends string ? K extends keyof Model ? never : Checker[K] extends (...args: any) => Promise<{
|
|
125
|
+
__Returns__: "Done";
|
|
126
|
+
}> ? never : `apidesc-${K}` | `api-${K}` : never]: Translation;
|
|
127
|
+
} & {
|
|
128
|
+
[key: string]: Translation;
|
|
129
|
+
};
|
|
130
|
+
type GetKeys<O> = O extends infer U ? (U extends object ? keyof U : never) : never;
|
|
131
|
+
type TransMessage<Locale extends Record<string, any>> = Locale extends infer U ? U extends object ? {
|
|
132
|
+
[K in keyof U]-?: `${K & string}${U[K] extends Record<string, any> ? `.${GetKeys<U[K]>}` : never}`;
|
|
133
|
+
}[keyof U] : never : never;
|
|
134
|
+
declare const baseTrans: {
|
|
135
|
+
readonly id: readonly ["Id", "아이디"];
|
|
136
|
+
readonly "desc-id": readonly ["Unique ID value", "유니크한 아이디값"];
|
|
137
|
+
readonly createdAt: readonly ["CreatedAt", "생성일"];
|
|
138
|
+
readonly "desc-createdAt": readonly ["Data created time", "데이터 생성 시각"];
|
|
139
|
+
readonly updatedAt: readonly ["UpdatedAt", "수정일"];
|
|
140
|
+
readonly "desc-updatedAt": readonly ["Data updated time", "데이터 마지막 수정 시각"];
|
|
141
|
+
readonly removedAt: readonly ["RemovedAt", "삭제일"];
|
|
142
|
+
readonly "desc-removedAt": readonly ["Data removed time", "데이터 삭제 시각"];
|
|
143
|
+
readonly status: readonly ["Status", "상태"];
|
|
144
|
+
readonly "desc-status": readonly ["Data status", "데이터 상태"];
|
|
145
|
+
readonly count: readonly ["Count", "개수"];
|
|
146
|
+
readonly "desc-count": readonly ["Data count", "데이터 개수"];
|
|
147
|
+
readonly latest: readonly ["latest", "최신순"];
|
|
148
|
+
readonly "desc-latest": readonly ["latest", "최신순"];
|
|
149
|
+
readonly oldest: readonly ["oldest", "오래된순"];
|
|
150
|
+
readonly "desc-oldest": readonly ["oldest", "오래된순"];
|
|
151
|
+
readonly "qry-any": readonly ["All", "전체"];
|
|
152
|
+
readonly "qrydesc-any": readonly ["All", "전체"];
|
|
153
|
+
readonly "qry-byStatuses": readonly ["By Statuses", "상태별 조회"];
|
|
154
|
+
readonly "qrydesc-byStatuses": readonly ["By Statuses", "상태별 조회"];
|
|
155
|
+
readonly "qarg-byStatuses-statuses": readonly ["Statuses", "상태"];
|
|
156
|
+
readonly "qargdesc-byStatuses-statuses": readonly ["Statuses", "상태"];
|
|
157
|
+
};
|
|
158
|
+
type BaseSignalTrans<T extends string> = {
|
|
159
|
+
[K in keyof DefaultSignal<T, any, any, any, any, any> as K extends string ? `apidesc-${K}` | `api-${K}` : never]: Translation;
|
|
160
|
+
};
|
|
161
|
+
declare const getBaseSignalTrans: <T extends string>(modelName: T) => BaseSignalTrans<T>;
|
|
162
|
+
declare const checkDictCoverage: () => void;
|
|
163
|
+
type MergeDoubleDepths<T, U> = U extends undefined ? T : {
|
|
164
|
+
[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;
|
|
165
|
+
};
|
|
166
|
+
declare const rootDictionary: {
|
|
167
|
+
[key: string]: {
|
|
168
|
+
[key: string]: Translation;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
declare const makeDictionary: <RootDict extends {
|
|
172
|
+
[key: string]: {
|
|
173
|
+
[key: string]: Translation;
|
|
174
|
+
};
|
|
175
|
+
}, Dict1 extends {
|
|
176
|
+
[key: string]: {
|
|
177
|
+
[key: string]: Translation;
|
|
178
|
+
};
|
|
179
|
+
}, 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>;
|
|
180
|
+
declare const languages: readonly ["ko", "en", "zhChs", "zhCht"];
|
|
181
|
+
type Language = (typeof languages)[number];
|
|
182
|
+
declare const msg: {
|
|
183
|
+
info: (key: TransMessage<any>, option?: {
|
|
184
|
+
key?: string;
|
|
185
|
+
duration?: number;
|
|
186
|
+
data?: {
|
|
187
|
+
[key: string]: any;
|
|
188
|
+
};
|
|
189
|
+
}) => void;
|
|
190
|
+
success: (key: TransMessage<any>, option?: {
|
|
191
|
+
key?: string;
|
|
192
|
+
duration?: number;
|
|
193
|
+
data?: {
|
|
194
|
+
[key: string]: any;
|
|
195
|
+
};
|
|
196
|
+
}) => void;
|
|
197
|
+
error: (key: TransMessage<any>, option?: {
|
|
198
|
+
key?: string;
|
|
199
|
+
duration?: number;
|
|
200
|
+
data?: {
|
|
201
|
+
[key: string]: any;
|
|
202
|
+
};
|
|
203
|
+
}) => void;
|
|
204
|
+
warning: (key: TransMessage<any>, option?: {
|
|
205
|
+
key?: string;
|
|
206
|
+
duration?: number;
|
|
207
|
+
data?: {
|
|
208
|
+
[key: string]: any;
|
|
209
|
+
};
|
|
210
|
+
}) => void;
|
|
211
|
+
loading: (key: TransMessage<any>, option?: {
|
|
212
|
+
key?: string;
|
|
213
|
+
duration?: number;
|
|
214
|
+
data?: {
|
|
215
|
+
[key: string]: any;
|
|
216
|
+
};
|
|
217
|
+
}) => void;
|
|
218
|
+
};
|
|
219
|
+
declare const makeTrans: <Locale extends {
|
|
220
|
+
[key: string]: {
|
|
221
|
+
[key: string]: Translation;
|
|
222
|
+
};
|
|
223
|
+
}>(locale: Locale) => {
|
|
224
|
+
revert: (key: TransMessage<Locale>, data?: any) => never;
|
|
225
|
+
Revert: {
|
|
226
|
+
new (key: TransMessage<Locale>, data?: any): {
|
|
227
|
+
name: string;
|
|
228
|
+
message: string;
|
|
229
|
+
stack?: string;
|
|
230
|
+
};
|
|
231
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
232
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
233
|
+
stackTraceLimit: number;
|
|
234
|
+
};
|
|
235
|
+
translate: (lang: Language, key: TransMessage<Locale>, data?: any) => string | {
|
|
236
|
+
[key: string]: string | number;
|
|
237
|
+
};
|
|
238
|
+
msg: {
|
|
239
|
+
info: (key: TransMessage<Locale>, option?: {
|
|
240
|
+
key?: string;
|
|
241
|
+
duration?: number;
|
|
242
|
+
data?: {
|
|
243
|
+
[key: string]: any;
|
|
244
|
+
};
|
|
245
|
+
}) => void;
|
|
246
|
+
success: (key: TransMessage<Locale>, option?: {
|
|
247
|
+
key?: string;
|
|
248
|
+
duration?: number;
|
|
249
|
+
data?: {
|
|
250
|
+
[key: string]: any;
|
|
251
|
+
};
|
|
252
|
+
}) => void;
|
|
253
|
+
error: (key: TransMessage<Locale>, option?: {
|
|
254
|
+
key?: string;
|
|
255
|
+
duration?: number;
|
|
256
|
+
data?: {
|
|
257
|
+
[key: string]: any;
|
|
258
|
+
};
|
|
259
|
+
}) => void;
|
|
260
|
+
warning: (key: TransMessage<Locale>, option?: {
|
|
261
|
+
key?: string;
|
|
262
|
+
duration?: number;
|
|
263
|
+
data?: {
|
|
264
|
+
[key: string]: any;
|
|
265
|
+
};
|
|
266
|
+
}) => void;
|
|
267
|
+
loading: (key: TransMessage<Locale>, option?: {
|
|
268
|
+
key?: string;
|
|
269
|
+
duration?: number;
|
|
270
|
+
data?: {
|
|
271
|
+
[key: string]: any;
|
|
272
|
+
};
|
|
273
|
+
}) => void;
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export { type ExtendModelDictionary, type GetKeys, type ModelDictionary, type SignalDictionary, type SummaryDictionary, type TransMessage, type Translate, type Translation, baseTrans, checkDictCoverage, getBaseSignalTrans, makeDictionary, makeTrans, msg, rootDictionary };
|