@akanjs/dictionary 0.0.4

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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # akan
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build akan` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test akan` to execute the unit tests via [Jest](https://jestjs.io).
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src";
package/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 dictionary_exports = {};
16
+ module.exports = __toCommonJS(dictionary_exports);
17
+ __reExport(dictionary_exports, require("./src"), module.exports);
18
+ // Annotate the CommonJS export names for ESM import in node:
19
+ 0 && (module.exports = {
20
+ ...require("./src")
21
+ });
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@akanjs/dictionary",
3
+ "version": "0.0.4",
4
+ "type": "commonjs",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/akan-team/akanjs.git",
11
+ "directory": "pkgs/@akanjs/dictionary"
12
+ },
13
+ "dependencies": {
14
+ "@urql/core": "5.1.0",
15
+ "bull": "4.16.5",
16
+ "dayjs": "1.11.13",
17
+ "express": "4.21.2",
18
+ "immer": "10.1.1",
19
+ "mongoose": "8.9.3",
20
+ "next": "15.1.3",
21
+ "pluralize": "8.0.0",
22
+ "react": "18.2.0",
23
+ "react-dom": "18.2.0",
24
+ "reflect-metadata": "0.2.2",
25
+ "socket.io": "4.8.1",
26
+ "socket.io-client": "4.8.1",
27
+ "tunnel-ssh": "5.2.0"
28
+ },
29
+ "main": "./index.js"
30
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./trans";
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,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 {};
package/src/trans.js ADDED
@@ -0,0 +1,377 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var trans_exports = {};
19
+ __export(trans_exports, {
20
+ baseTrans: () => baseTrans,
21
+ checkDictCoverage: () => checkDictCoverage,
22
+ getBaseSignalTrans: () => getBaseSignalTrans,
23
+ makeDictionary: () => makeDictionary,
24
+ makeTrans: () => makeTrans,
25
+ msg: () => msg,
26
+ rootDictionary: () => rootDictionary
27
+ });
28
+ module.exports = __toCommonJS(trans_exports);
29
+ var import_common = require("@akanjs/common");
30
+ var import_constant = require("@akanjs/constant");
31
+ var import_signal = require("@akanjs/signal");
32
+ const baseTrans = {
33
+ id: ["Id", "\uC544\uC774\uB514"],
34
+ "desc-id": ["Unique ID value", "\uC720\uB2C8\uD06C\uD55C \uC544\uC774\uB514\uAC12"],
35
+ createdAt: ["CreatedAt", "\uC0DD\uC131\uC77C"],
36
+ "desc-createdAt": ["Data created time", "\uB370\uC774\uD130 \uC0DD\uC131 \uC2DC\uAC01"],
37
+ updatedAt: ["UpdatedAt", "\uC218\uC815\uC77C"],
38
+ "desc-updatedAt": ["Data updated time", "\uB370\uC774\uD130 \uB9C8\uC9C0\uB9C9 \uC218\uC815 \uC2DC\uAC01"],
39
+ removedAt: ["RemovedAt", "\uC0AD\uC81C\uC77C"],
40
+ "desc-removedAt": ["Data removed time", "\uB370\uC774\uD130 \uC0AD\uC81C \uC2DC\uAC01"],
41
+ status: ["Status", "\uC0C1\uD0DC"],
42
+ "desc-status": ["Data status", "\uB370\uC774\uD130 \uC0C1\uD0DC"],
43
+ count: ["Count", "\uAC1C\uC218"],
44
+ "desc-count": ["Data count", "\uB370\uC774\uD130 \uAC1C\uC218"],
45
+ latest: ["latest", "\uCD5C\uC2E0\uC21C"],
46
+ "desc-latest": ["latest", "\uCD5C\uC2E0\uC21C"],
47
+ oldest: ["oldest", "\uC624\uB798\uB41C\uC21C"],
48
+ "desc-oldest": ["oldest", "\uC624\uB798\uB41C\uC21C"],
49
+ "qry-any": ["All", "\uC804\uCCB4"],
50
+ "qrydesc-any": ["All", "\uC804\uCCB4"],
51
+ "qry-byStatuses": ["By Statuses", "\uC0C1\uD0DC\uBCC4 \uC870\uD68C"],
52
+ "qrydesc-byStatuses": ["By Statuses", "\uC0C1\uD0DC\uBCC4 \uC870\uD68C"],
53
+ "qarg-byStatuses-statuses": ["Statuses", "\uC0C1\uD0DC"],
54
+ "qargdesc-byStatuses-statuses": ["Statuses", "\uC0C1\uD0DC"]
55
+ };
56
+ const getBaseSignalTrans = (modelName) => {
57
+ const className = (0, import_common.capitalize)(modelName);
58
+ return {
59
+ // * ==================== Endpoint ==================== * //
60
+ [`api-light${className}`]: [`Get light version of ${modelName}`, `${modelName} \uACBD\uB7C9\uD654 \uBC84\uC804 \uC870\uD68C`],
61
+ [`apidesc-light${className}`]: [`Get light version of ${modelName}`, `${modelName} \uACBD\uB7C9\uD654 \uBC84\uC804 \uC870\uD68C`],
62
+ [`arg-light${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
63
+ [`argdesc-light${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
64
+ [`api-${modelName}`]: [`Get ${modelName}`, `${modelName} \uC870\uD68C`],
65
+ [`apidesc-${modelName}`]: [`Get ${modelName}`, `${modelName} \uC870\uD68C`],
66
+ [`arg-${modelName}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
67
+ [`argdesc-${modelName}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
68
+ [`api-${modelName}List`]: [`Get ${modelName} list`, `${modelName} \uB9AC\uC2A4\uD2B8 \uC870\uD68C`],
69
+ [`apidesc-${modelName}List`]: [`Get ${modelName} list`, `${modelName} \uB9AC\uC2A4\uD2B8 \uC870\uD68C`],
70
+ [`arg-${modelName}List-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
71
+ [`argdesc-${modelName}List-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
72
+ [`arg-${modelName}List-skip`]: [`Skip of ${modelName}`, `${modelName} \uC2A4\uD0B5`],
73
+ [`argdesc-${modelName}List-skip`]: [`Skip of ${modelName}`, `${modelName} \uC2A4\uD0B5`],
74
+ [`arg-${modelName}List-limit`]: [`Limit of ${modelName}`, `${modelName} \uC81C\uD55C`],
75
+ [`argdesc-${modelName}List-limit`]: [`Limit of ${modelName}`, `${modelName} \uC81C\uD55C`],
76
+ [`arg-${modelName}List-sort`]: [`Sort of ${modelName}`, `${modelName} \uC815\uB82C`],
77
+ [`argdesc-${modelName}List-sort`]: [`Sort of ${modelName}`, `${modelName} \uC815\uB82C`],
78
+ [`api-${modelName}Insight`]: [`Get ${modelName} insight`, `${modelName} \uC778\uC0AC\uC774\uD2B8 \uC870\uD68C`],
79
+ [`apidesc-${modelName}Insight`]: [`Get ${modelName} insight`, `${modelName} \uC778\uC0AC\uC774\uD2B8 \uC870\uD68C`],
80
+ [`arg-${modelName}Insight-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
81
+ [`argdesc-${modelName}Insight-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
82
+ [`api-${modelName}Exists`]: [`Check ${modelName} exists`, `${modelName} \uC874\uC7AC \uC5EC\uBD80 \uD655\uC778`],
83
+ [`apidesc-${modelName}Exists`]: [`Check ${modelName} exists`, `${modelName} \uC874\uC7AC \uC5EC\uBD80 \uD655\uC778`],
84
+ [`arg-${modelName}Exists-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
85
+ [`argdesc-${modelName}Exists-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
86
+ [`api-create${className}`]: [`Create ${modelName}`, `${modelName} \uC0DD\uC131`],
87
+ [`apidesc-create${className}`]: [`Create ${modelName}`, `${modelName} \uC0DD\uC131`],
88
+ [`arg-create${className}-data`]: [`Data of ${modelName}`, `${modelName} \uB370\uC774\uD130`],
89
+ [`argdesc-create${className}-data`]: [`Data of ${modelName}`, `${modelName} \uB370\uC774\uD130`],
90
+ [`api-update${className}`]: [`Update ${modelName}`, `${modelName} \uC218\uC815`],
91
+ [`apidesc-update${className}`]: [`Update ${modelName}`, `${modelName} \uC218\uC815`],
92
+ [`arg-update${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
93
+ [`argdesc-update${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
94
+ [`arg-update${className}-data`]: [`Data of ${modelName}`, `${modelName} \uB370\uC774\uD130`],
95
+ [`argdesc-update${className}-data`]: [`Data of ${modelName}`, `${modelName} \uB370\uC774\uD130`],
96
+ [`api-remove${className}`]: [`Remove ${modelName}`, `${modelName} \uC0AD\uC81C`],
97
+ [`apidesc-remove${className}`]: [`Remove ${modelName}`, `${modelName} \uC0AD\uC81C`],
98
+ [`arg-remove${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
99
+ [`argdesc-remove${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`]
100
+ // * ==================== Endpoint ==================== * //
101
+ };
102
+ };
103
+ const checkModelDictCoverages = (modelName, dictionary, modelRefs, filterRefs) => {
104
+ const enumKeyMap = /* @__PURE__ */ new Map();
105
+ modelRefs.forEach((modelRef) => {
106
+ const fieldMetaMap = (0, import_constant.getFieldMetaMap)(modelRef);
107
+ [...fieldMetaMap.values()].forEach((fieldMeta) => {
108
+ if (!fieldMeta.enum)
109
+ return;
110
+ enumKeyMap.set(fieldMeta.key, new Set(fieldMeta.enum.map((value) => value.toString())));
111
+ fieldMeta.enum.forEach((value) => {
112
+ const enumDict = dictionary[`enum-${fieldMeta.key}-${value}`];
113
+ const modelDict = rootDictionary[modelName];
114
+ const rootEnumDict = modelDict?.[`enum-${fieldMeta.key}-${value}`];
115
+ if (!enumDict && !rootEnumDict) {
116
+ import_common.Logger.warn(`\u2620\uFE0F Missing enum translation: ${modelName}.enum-${fieldMeta.key}-${value}`);
117
+ }
118
+ const enumDescDict = dictionary[`enumdesc-${fieldMeta.key}-${value}`];
119
+ const rootEnumDescDict = modelDict?.[`enumdesc-${fieldMeta.key}-${value}`];
120
+ if (!enumDescDict && !rootEnumDescDict) {
121
+ import_common.Logger.warn(`\u2620\uFE0F Missing enum description: ${modelName}.enumdesc-${fieldMeta.key}-${value}`);
122
+ }
123
+ });
124
+ });
125
+ });
126
+ Object.keys(dictionary).filter((key) => key.startsWith("enum-")).forEach((key) => {
127
+ const [, fieldKey, ...values] = key.split("-");
128
+ const value = values.join("-");
129
+ if (!enumKeyMap.get(fieldKey)?.has(value)) {
130
+ import_common.Logger.error(
131
+ `\u{1F47B} Unused enum translation, need to delete: ${modelName}.enum-${fieldKey}-${value} & ${modelName}.enumdesc-${fieldKey}-${value}`
132
+ );
133
+ }
134
+ });
135
+ const fieldKeySet = /* @__PURE__ */ new Set([
136
+ ...modelRefs.map((modelRef) => [...(0, import_constant.getFieldMetaMap)(modelRef).keys()]).flat(),
137
+ ...filterRefs.map((filterRef) => Object.keys((0, import_constant.getFilterSortMap)(filterRef))).flat()
138
+ ]);
139
+ Object.keys(dictionary).filter((key) => key.startsWith("desc-")).forEach((key) => {
140
+ const [, fieldKey] = key.split("-");
141
+ if (!fieldKeySet.has(fieldKey))
142
+ import_common.Logger.error(
143
+ `\u{1F47B} Unused description translation, need to delete: ${modelName}.${fieldKey} & ${modelName}.desc-${fieldKey}`
144
+ );
145
+ });
146
+ };
147
+ const checkSignalDictCoverages = (modelName, sigRefs, dictionary) => {
148
+ const argKeyMap = /* @__PURE__ */ new Map();
149
+ sigRefs.forEach((sigRef) => {
150
+ const gqlMetas = (0, import_signal.getGqlMetas)(sigRef);
151
+ gqlMetas.filter((gqlMeta) => gqlMeta.type !== "Process").forEach((gqlMeta) => {
152
+ const [argMetas] = (0, import_signal.getArgMetas)(sigRef, gqlMeta.key);
153
+ argKeyMap.set(gqlMeta.key, new Set(argMetas.map((argMeta) => argMeta.name)));
154
+ argMetas.forEach((argMeta) => {
155
+ const argDict = dictionary[`arg-${gqlMeta.key}-${argMeta.name}`];
156
+ if (!argDict) {
157
+ import_common.Logger.warn(`\u2620\uFE0F Missing arg translation: ${modelName}.arg-${gqlMeta.key}-${argMeta.name}`);
158
+ }
159
+ const argDescDict = dictionary[`argdesc-${gqlMeta.key}-${argMeta.name}`];
160
+ if (!argDescDict) {
161
+ import_common.Logger.warn(`\u2620\uFE0F Missing arg description: ${modelName}.argdesc-${gqlMeta.key}-${argMeta.name}`);
162
+ }
163
+ });
164
+ });
165
+ });
166
+ Object.keys(dictionary).filter((key) => key.startsWith("arg-")).forEach((key) => {
167
+ const [, gqlKey, argKey] = key.split("-");
168
+ if (!argKeyMap.get(gqlKey)?.has(argKey))
169
+ import_common.Logger.error(
170
+ `\u{1F47B} Unused arg translation, need to delete: ${modelName}.arg-${gqlKey}-${argKey} & ${modelName}.argdesc-${gqlKey}-${argKey}`
171
+ );
172
+ });
173
+ };
174
+ const checkFilterDictCoverages = (modelName, filterRefs, dictionary) => {
175
+ const qargKeyMap = /* @__PURE__ */ new Map();
176
+ filterRefs.forEach((filterRef) => {
177
+ const filterMetaMap = (0, import_constant.getFilterQueryMap)(filterRef);
178
+ filterMetaMap.forEach((filterMeta) => {
179
+ const filterArgMetas = (0, import_constant.getFilterArgMetas)(filterRef, filterMeta.key);
180
+ qargKeyMap.set(filterMeta.key, new Set(filterArgMetas.map((filterArgMeta) => filterArgMeta.name)));
181
+ filterArgMetas.forEach((filterArgMeta) => {
182
+ const qargDict = dictionary[`qarg-${filterMeta.key}-${filterArgMeta.name}`];
183
+ if (!qargDict)
184
+ import_common.Logger.warn(`\u2620\uFE0F Missing qarg translation: ${modelName}.qarg-${filterMeta.key}-${filterArgMeta.name}`);
185
+ const qargDescDict = dictionary[`qargdesc-${filterMeta.key}-${filterArgMeta.name}`];
186
+ if (!qargDescDict)
187
+ import_common.Logger.warn(`\u2620\uFE0F Missing qarg description: ${modelName}.qargdesc-${filterMeta.key}-${filterArgMeta.name}`);
188
+ });
189
+ });
190
+ });
191
+ Object.keys(dictionary).filter((key) => key.startsWith("qarg-")).forEach((key) => {
192
+ const [, filterKey, filterArgKey] = key.split("-");
193
+ if (!qargKeyMap.get(filterKey)?.has(filterArgKey))
194
+ import_common.Logger.error(
195
+ `\u{1F47B} Unused qarg translation, need to delete: ${modelName}.qarg-${filterKey}-${filterArgKey} & ${modelName}.qargdesc-${filterKey}-${filterArgKey}`
196
+ );
197
+ });
198
+ };
199
+ const checkDictCoverage = () => {
200
+ const fullModelRefEntries = (0, import_constant.getAllFullModelRefs)().filter((modelRef) => {
201
+ const classMeta = (0, import_constant.getClassMeta)(modelRef);
202
+ return classMeta.type === "full" && classMeta.modelType === "data";
203
+ }).map((modelRef) => {
204
+ const classMeta = (0, import_constant.getClassMeta)(modelRef);
205
+ const modelName = (0, import_common.lowerlize)(classMeta.refName);
206
+ return { modelName, modelRef };
207
+ });
208
+ const scalarModelRefs = (0, import_constant.getAllScalarModelRefs)();
209
+ const insightModelRefEntries = scalarModelRefs.filter((ref) => (0, import_constant.getClassMeta)(ref).modelType === "insight").map((modelRef) => {
210
+ const classMeta = (0, import_constant.getClassMeta)(modelRef);
211
+ if (!classMeta.refName.endsWith("Insight"))
212
+ throw new Error(`Invalid insight model name: ${classMeta.refName}`);
213
+ const modelName = (0, import_common.lowerlize)(classMeta.refName.slice(0, -7));
214
+ return { modelName, modelRef };
215
+ });
216
+ const pureScalarModelRefEntries = scalarModelRefs.filter((ref) => (0, import_constant.getClassMeta)(ref).modelType === "data").map((modelRef) => {
217
+ const classMeta = (0, import_constant.getClassMeta)(modelRef);
218
+ const modelName = (0, import_common.lowerlize)(classMeta.refName);
219
+ return { modelName, modelRef };
220
+ });
221
+ const filterModelRefEntries = (0, import_constant.getAllFilterModelRefs)().map((filterModelRef) => {
222
+ const filterMeta = (0, import_constant.getFilterMeta)(filterModelRef);
223
+ if (!filterMeta.refName.endsWith("Filter"))
224
+ throw new Error(`Invalid filter model name: ${filterMeta.refName}`);
225
+ const modelName = (0, import_common.lowerlize)(filterMeta.refName.slice(0, -6));
226
+ return { modelName, filterModelRef };
227
+ });
228
+ const signalRefs = (0, import_signal.getAllSignalRefs)();
229
+ const fullModelSignalRefEntries = signalRefs.filter((ref) => {
230
+ const sigMeta = (0, import_signal.getSigMeta)(ref);
231
+ if (!sigMeta.returns)
232
+ return false;
233
+ const modelRef = sigMeta.returns();
234
+ const classMeta = (0, import_constant.getClassMeta)(modelRef);
235
+ return classMeta.type === "full";
236
+ }).map((sigRef) => {
237
+ const sigMeta = (0, import_signal.getSigMeta)(sigRef);
238
+ const modelName = (0, import_common.lowerlize)(sigMeta.refName);
239
+ return { modelName, sigRef };
240
+ });
241
+ const scalarModelSignalRefEntries = signalRefs.filter((ref) => {
242
+ const sigMeta = (0, import_signal.getSigMeta)(ref);
243
+ if (!sigMeta.returns)
244
+ return false;
245
+ const modelRef = sigMeta.returns();
246
+ const classMeta = (0, import_constant.getClassMeta)(modelRef);
247
+ return classMeta.type === "scalar";
248
+ }).map((sigRef) => {
249
+ const sigMeta = (0, import_signal.getSigMeta)(sigRef);
250
+ const modelName = (0, import_common.lowerlize)(sigMeta.refName);
251
+ return { modelName, sigRef };
252
+ });
253
+ const pureSignalRefEntries = signalRefs.filter((ref) => !(0, import_signal.getSigMeta)(ref).returns).map((sigRef) => {
254
+ const sigMeta = (0, import_signal.getSigMeta)(sigRef);
255
+ const modelName = (0, import_common.lowerlize)(sigMeta.refName);
256
+ return { modelName, sigRef };
257
+ });
258
+ const modelDictExamMap = /* @__PURE__ */ new Map();
259
+ const scalarDictExamMap = /* @__PURE__ */ new Map();
260
+ const signalDictExamMap = /* @__PURE__ */ new Map();
261
+ const getDefaultModelDict = () => ({ modelRefs: [], insightRefs: [], sigRefs: [], filterRefs: [] });
262
+ fullModelRefEntries.forEach(({ modelName, modelRef }) => {
263
+ const modelDictExam = modelDictExamMap.get(modelName) ?? getDefaultModelDict();
264
+ modelDictExam.modelRefs.push(modelRef);
265
+ modelDictExamMap.set(modelName, modelDictExam);
266
+ });
267
+ insightModelRefEntries.forEach(({ modelName, modelRef }) => {
268
+ const modelDictExam = modelDictExamMap.get(modelName) ?? getDefaultModelDict();
269
+ modelDictExam.insightRefs.push(modelRef);
270
+ modelDictExamMap.set(modelName, modelDictExam);
271
+ });
272
+ fullModelSignalRefEntries.forEach(({ modelName, sigRef }) => {
273
+ const modelDictExam = modelDictExamMap.get(modelName) ?? getDefaultModelDict();
274
+ modelDictExam.sigRefs.push(sigRef);
275
+ modelDictExamMap.set(modelName, modelDictExam);
276
+ });
277
+ filterModelRefEntries.forEach(({ modelName, filterModelRef }) => {
278
+ const modelDictExam = modelDictExamMap.get(modelName) ?? getDefaultModelDict();
279
+ modelDictExam.filterRefs.push(filterModelRef);
280
+ modelDictExamMap.set(modelName, modelDictExam);
281
+ });
282
+ const getDefaultScalarDict = () => ({ modelRefs: [], sigRefs: [] });
283
+ pureScalarModelRefEntries.forEach(({ modelName, modelRef }) => {
284
+ const scalarDictExam = scalarDictExamMap.get(modelName) ?? getDefaultScalarDict();
285
+ scalarDictExam.modelRefs.push(modelRef);
286
+ scalarDictExamMap.set(modelName, scalarDictExam);
287
+ });
288
+ scalarModelSignalRefEntries.forEach(({ modelName, sigRef }) => {
289
+ const scalarDictExam = scalarDictExamMap.get(modelName) ?? getDefaultScalarDict();
290
+ scalarDictExam.sigRefs.push(sigRef);
291
+ scalarDictExamMap.set(modelName, scalarDictExam);
292
+ });
293
+ const getDefaultSignalDict = () => ({ sigRefs: [] });
294
+ pureSignalRefEntries.forEach(({ modelName, sigRef }) => {
295
+ const signalDictExam = signalDictExamMap.get(modelName) ?? getDefaultSignalDict();
296
+ signalDictExam.sigRefs.push(sigRef);
297
+ signalDictExamMap.set(modelName, signalDictExam);
298
+ });
299
+ modelDictExamMap.forEach(({ modelRefs, insightRefs, sigRefs, filterRefs }, modelName) => {
300
+ const dictionary = rootDictionary[modelName];
301
+ if (!dictionary)
302
+ return;
303
+ checkModelDictCoverages(modelName, dictionary, [...modelRefs, ...insightRefs], filterRefs);
304
+ checkSignalDictCoverages(modelName, sigRefs, dictionary);
305
+ checkFilterDictCoverages(modelName, filterRefs, dictionary);
306
+ });
307
+ scalarDictExamMap.forEach(({ modelRefs, sigRefs }, modelName) => {
308
+ const dictionary = rootDictionary[modelName];
309
+ if (!dictionary)
310
+ return;
311
+ checkModelDictCoverages(modelName, dictionary, modelRefs, []);
312
+ checkSignalDictCoverages(modelName, sigRefs, dictionary);
313
+ });
314
+ signalDictExamMap.forEach(({ sigRefs }, modelName) => {
315
+ const dictionary = rootDictionary[modelName];
316
+ if (!dictionary)
317
+ return;
318
+ checkSignalDictCoverages(modelName, sigRefs, dictionary);
319
+ });
320
+ };
321
+ const rootDictionary = {};
322
+ const makeDictionary = (rootDict, dict1, dict2, dict3, dict4, dict5) => {
323
+ const dicts = [dict1, dict2, dict3, dict4, dict5].filter((d) => !!d);
324
+ dicts.forEach((dict) => {
325
+ Object.entries(dict).forEach(([key, value]) => {
326
+ const rootValue = rootDict[key];
327
+ if (!rootValue)
328
+ Object.assign(rootDict, { [key]: value });
329
+ else
330
+ Object.assign(rootDict[key], value);
331
+ });
332
+ });
333
+ return rootDict;
334
+ };
335
+ const languages = ["ko", "en", "zhChs", "zhCht"];
336
+ const msg = {
337
+ info: () => null,
338
+ success: () => null,
339
+ error: () => null,
340
+ warning: () => null,
341
+ loading: () => null
342
+ };
343
+ const makeTrans = (locale) => {
344
+ const revert = (key, data) => {
345
+ throw new Error(key);
346
+ };
347
+ class Revert extends Error {
348
+ constructor(key, data) {
349
+ super(key);
350
+ }
351
+ }
352
+ const translate = (lang, key, data) => {
353
+ const langIdx = languages.indexOf(lang);
354
+ const [modelName, msgKey] = key.split(".");
355
+ const model = locale[modelName];
356
+ const message = model[msgKey][langIdx];
357
+ if (!message)
358
+ throw new Error("Invalid message");
359
+ return message;
360
+ };
361
+ return {
362
+ revert,
363
+ Revert,
364
+ translate,
365
+ msg
366
+ };
367
+ };
368
+ // Annotate the CommonJS export names for ESM import in node:
369
+ 0 && (module.exports = {
370
+ baseTrans,
371
+ checkDictCoverage,
372
+ getBaseSignalTrans,
373
+ makeDictionary,
374
+ makeTrans,
375
+ msg,
376
+ rootDictionary
377
+ });