@akanjs/dictionary 0.0.40 → 0.0.42
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 +1 -2
- package/index.js +1298 -21
- package/package.json +10 -2
- package/src/index.d.ts +1 -2
- package/src/trans.d.ts +18 -107
- package/src/index.js +0 -21
- package/src/trans.js +0 -593
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/dictionary",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -14,5 +14,13 @@
|
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
17
|
-
"dependencies": {
|
|
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
|
+
}
|
|
18
26
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
import 'dayjs';
|
|
1
|
+
export * from "./trans";
|
package/src/trans.d.ts
CHANGED
|
@@ -1,113 +1,25 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
1
|
+
import { type BaseFilterKey, type GetActionObject, type GetStateObject } from "@akanjs/constant";
|
|
2
|
+
import { DefaultSignal } from "@akanjs/signal";
|
|
91
3
|
type TranslationSingle = readonly [string, string] | readonly [string, string, string, string];
|
|
92
4
|
type TranslationWithParam = readonly [string, string, {
|
|
93
5
|
[key: string]: string | number;
|
|
94
6
|
}];
|
|
95
|
-
type Translation = TranslationSingle | TranslationWithParam;
|
|
96
|
-
type Translate<Checker> = {
|
|
7
|
+
export type Translation = TranslationSingle | TranslationWithParam;
|
|
8
|
+
export type Translate<Checker> = {
|
|
97
9
|
[K in keyof GetStateObject<Checker>]: Translation;
|
|
98
10
|
} & {
|
|
99
11
|
[key: string]: Translation;
|
|
100
12
|
} & {
|
|
101
13
|
modelName: Translation;
|
|
102
14
|
};
|
|
103
|
-
type ExtendModelDictionary<Model, Insight = unknown, Filter = unknown> = {
|
|
15
|
+
export type ExtendModelDictionary<Model, Insight = unknown, Filter = unknown> = {
|
|
104
16
|
[K in keyof Omit<GetStateObject<Model & Insight & Filter>, BaseFilterKey> as K extends string ? K | `desc-${K}` : never]: Translation;
|
|
105
17
|
} & {
|
|
106
18
|
[K in keyof Omit<GetActionObject<Filter>, BaseFilterKey> as K extends string ? `qry-${K}` | `qrydesc-${K}` : never]: Translation;
|
|
107
19
|
} & {
|
|
108
20
|
[key: string]: Translation;
|
|
109
21
|
};
|
|
110
|
-
type ModelDictionary<Model, Insight = unknown, Filter = unknown> = {
|
|
22
|
+
export type ModelDictionary<Model, Insight = unknown, Filter = unknown> = {
|
|
111
23
|
[K in keyof GetStateObject<Model & Insight & Filter> as K extends string ? K | `desc-${K}` : never]: Translation;
|
|
112
24
|
} & {
|
|
113
25
|
[K in keyof GetActionObject<Filter> as K extends string ? `qry-${K}` | `qrydesc-${K}` : never]: Translation;
|
|
@@ -117,21 +29,21 @@ type ModelDictionary<Model, Insight = unknown, Filter = unknown> = {
|
|
|
117
29
|
modelName: Translation;
|
|
118
30
|
modelDesc: Translation;
|
|
119
31
|
};
|
|
120
|
-
type SummaryDictionary<Summary> = {
|
|
32
|
+
export type SummaryDictionary<Summary> = {
|
|
121
33
|
[K in keyof GetStateObject<Summary> as K extends string ? K | `desc-${K}` : never]: Translation;
|
|
122
34
|
};
|
|
123
|
-
type SignalDictionary<Checker, Model = unknown> = {
|
|
35
|
+
export type SignalDictionary<Checker, Model = unknown> = {
|
|
124
36
|
[K in keyof GetActionObject<Checker> as K extends string ? K extends keyof Model ? never : Checker[K] extends (...args: any) => Promise<{
|
|
125
37
|
__Returns__: "Done";
|
|
126
38
|
}> ? never : `apidesc-${K}` | `api-${K}` : never]: Translation;
|
|
127
39
|
} & {
|
|
128
40
|
[key: string]: Translation;
|
|
129
41
|
};
|
|
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 ? {
|
|
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 ? {
|
|
132
44
|
[K in keyof U]-?: `${K & string}${U[K] extends Record<string, any> ? `.${GetKeys<U[K]>}` : never}`;
|
|
133
45
|
}[keyof U] : never : never;
|
|
134
|
-
declare const baseTrans: {
|
|
46
|
+
export declare const baseTrans: {
|
|
135
47
|
readonly id: readonly ["Id", "아이디"];
|
|
136
48
|
readonly "desc-id": readonly ["Unique ID value", "유니크한 아이디값"];
|
|
137
49
|
readonly createdAt: readonly ["CreatedAt", "생성일"];
|
|
@@ -158,17 +70,17 @@ declare const baseTrans: {
|
|
|
158
70
|
type BaseSignalTrans<T extends string> = {
|
|
159
71
|
[K in keyof DefaultSignal<T, any, any, any, any, any> as K extends string ? `apidesc-${K}` | `api-${K}` : never]: Translation;
|
|
160
72
|
};
|
|
161
|
-
declare const getBaseSignalTrans: <T extends string>(modelName: T) => BaseSignalTrans<T>;
|
|
162
|
-
declare const checkDictCoverage: () => void;
|
|
73
|
+
export declare const getBaseSignalTrans: <T extends string>(modelName: T) => BaseSignalTrans<T>;
|
|
74
|
+
export declare const checkDictCoverage: () => void;
|
|
163
75
|
type MergeDoubleDepths<T, U> = U extends undefined ? T : {
|
|
164
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;
|
|
165
77
|
};
|
|
166
|
-
declare const rootDictionary: {
|
|
78
|
+
export declare const rootDictionary: {
|
|
167
79
|
[key: string]: {
|
|
168
80
|
[key: string]: Translation;
|
|
169
81
|
};
|
|
170
82
|
};
|
|
171
|
-
declare const makeDictionary: <RootDict extends {
|
|
83
|
+
export declare const makeDictionary: <RootDict extends {
|
|
172
84
|
[key: string]: {
|
|
173
85
|
[key: string]: Translation;
|
|
174
86
|
};
|
|
@@ -179,7 +91,7 @@ declare const makeDictionary: <RootDict extends {
|
|
|
179
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>;
|
|
180
92
|
declare const languages: readonly ["ko", "en", "zhChs", "zhCht"];
|
|
181
93
|
type Language = (typeof languages)[number];
|
|
182
|
-
declare const msg: {
|
|
94
|
+
export declare const msg: {
|
|
183
95
|
info: (key: TransMessage<any>, option?: {
|
|
184
96
|
key?: string;
|
|
185
97
|
duration?: number;
|
|
@@ -216,7 +128,7 @@ declare const msg: {
|
|
|
216
128
|
};
|
|
217
129
|
}) => void;
|
|
218
130
|
};
|
|
219
|
-
declare const makeTrans: <Locale extends {
|
|
131
|
+
export declare const makeTrans: <Locale extends {
|
|
220
132
|
[key: string]: {
|
|
221
133
|
[key: string]: Translation;
|
|
222
134
|
};
|
|
@@ -273,5 +185,4 @@ declare const makeTrans: <Locale extends {
|
|
|
273
185
|
}) => void;
|
|
274
186
|
};
|
|
275
187
|
};
|
|
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 };
|
|
188
|
+
export {};
|
package/src/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
});
|