karin-plugin-mys-core 1.0.7 → 1.0.9
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/lib/apps/MiHoYoLogin.js +25 -27
- package/lib/apps/MysDevice.js +18 -18
- package/lib/apps/UIDManage.js +20 -20
- package/lib/{chunk-BWFWWHCT.js → chunk-2BVJS5VE.js} +7 -4
- package/lib/{chunk-Y3J3J5B2.js → chunk-3JN5WYUN.js} +31 -20
- package/lib/{chunk-DJTJKSNN.js → chunk-4BTKE3LO.js} +26 -19
- package/lib/chunk-5DXIT7UB.js +88 -0
- package/lib/{chunk-G547WVGV.js → chunk-DMJ5OQR6.js} +1 -1
- package/lib/{chunk-7ZQQ76WC.js → chunk-EDNBKOMS.js} +4 -4
- package/lib/{chunk-EAVXU4Q2.js → chunk-G7TMVDGP.js} +17 -6
- package/lib/{chunk-HTH25YE2.js → chunk-HJ6HX5HB.js} +4 -4
- package/lib/{chunk-BH4S574A.js → chunk-KQVWWGRH.js} +1 -1
- package/lib/{chunk-LLYBEHPW.js → chunk-LBLGKL3W.js} +3 -3
- package/lib/{chunk-EMAUATE3.js → chunk-MPZP23EX.js} +5 -3
- package/lib/{chunk-P2PBUTB7.js → chunk-MQ52BX7O.js} +10 -15
- package/lib/{chunk-6PIXUPZ6.js → chunk-PMFOX5HA.js} +14 -16
- package/lib/chunk-TTN7NFCA.js +109 -0
- package/lib/{chunk-BNSHDFFN.js → chunk-ZTOR2DXG.js} +7 -7
- package/lib/common-BlI5Gsw_.d.ts +35 -0
- package/lib/exports/config/array.d.ts +1 -1
- package/lib/exports/config/array.js +1 -1
- package/lib/exports/config/config.d.ts +56 -1
- package/lib/exports/config/config.js +6 -2
- package/lib/exports/config/index.d.ts +1 -2
- package/lib/exports/config/index.js +7 -5
- package/lib/exports/database/database.js +7 -3
- package/lib/exports/database/dbs/base.d.ts +5 -3
- package/lib/exports/database/dbs/base.js +5 -1
- package/lib/exports/database/dbs/index.d.ts +1 -1
- package/lib/exports/database/dbs/index.js +12 -6
- package/lib/exports/database/dbs/sqlite3.d.ts +7 -3
- package/lib/exports/database/dbs/sqlite3.js +6 -2
- package/lib/exports/database/dbs/table.d.ts +12 -8
- package/lib/exports/database/dbs/table.js +12 -6
- package/lib/exports/database/index.d.ts +2 -2
- package/lib/exports/database/index.js +18 -14
- package/lib/exports/database/tables/index.js +14 -12
- package/lib/exports/database/tables/mysAccountInfo.d.ts +1 -1
- package/lib/exports/database/tables/mysAccountInfo.js +9 -5
- package/lib/exports/database/tables/mysDeviceInfo.d.ts +1 -1
- package/lib/exports/database/tables/mysDeviceInfo.js +9 -7
- package/lib/exports/database/tables/mysUserInfo.d.ts +1 -1
- package/lib/exports/database/tables/mysUserInfo.js +9 -5
- package/lib/exports/database/types/dbs/base.d.ts +17 -6
- package/lib/exports/database/types/index.d.ts +1 -1
- package/lib/exports/database/types/tables/index.d.ts +1 -1
- package/lib/exports/database/types/tables/mysUserInfo.d.ts +6 -5
- package/lib/exports/mys/api/apis.js +18 -18
- package/lib/exports/mys/api/app.js +11 -9
- package/lib/exports/mys/api/define.js +18 -18
- package/lib/exports/mys/api/index.js +21 -21
- package/lib/exports/mys/index.js +24 -24
- package/lib/exports/mys/user/deviceInfo.js +12 -10
- package/lib/exports/mys/user/game.d.ts +12 -5
- package/lib/exports/mys/user/game.js +1 -1
- package/lib/exports/mys/user/index.d.ts +3 -3
- package/lib/exports/mys/user/index.js +21 -21
- package/lib/exports/mys/user/userInfo.js +18 -18
- package/lib/exports/render/index.js +5 -3
- package/lib/exports/render/render.js +5 -3
- package/lib/exports/utils/common.d.ts +1 -33
- package/lib/exports/utils/common.js +3 -1
- package/lib/exports/utils/index.d.ts +2 -1
- package/lib/exports/utils/index.js +4 -2
- package/lib/exports/{config/types/config.d.ts → utils/types/common.d.ts} +3 -4
- package/lib/exports/utils/types/common.js +1 -0
- package/lib/exports/utils/types/index.d.ts +1 -0
- package/lib/exports/utils/types/index.js +2 -0
- package/package.json +1 -1
- package/lib/array-CCexQ14j.d.ts +0 -62
- package/lib/chunk-BXA3VAQC.js +0 -131
- package/lib/chunk-LG34FPBI.js +0 -50
- package/lib/exports/config/types/config.js +0 -1
- package/lib/exports/config/types/index.d.ts +0 -1
- package/lib/exports/config/types/index.js +0 -2
- /package/lib/{chunk-2DHTKQ34.js → chunk-3ERB3ILC.js} +0 -0
- /package/lib/{chunk-7SZX3RBZ.js → chunk-ARLTXJFJ.js} +0 -0
- /package/lib/{chunk-UC6INRYV.js → chunk-PYTECG57.js} +0 -0
- /package/lib/{chunk-XQWTJIT4.js → chunk-T7W4DXRM.js} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
common_exports
|
|
3
|
-
} from "./chunk-LG34FPBI.js";
|
|
4
1
|
import {
|
|
5
2
|
dir
|
|
6
3
|
} from "./chunk-SHLPPEAY.js";
|
|
4
|
+
import {
|
|
5
|
+
common_exports
|
|
6
|
+
} from "./chunk-5DXIT7UB.js";
|
|
7
7
|
|
|
8
8
|
// src/exports/render/render.ts
|
|
9
9
|
import karin, { config, existToMkdirSync, karinPathBase } from "node-karin";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DbBase
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3JN5WYUN.js";
|
|
4
4
|
import {
|
|
5
5
|
DatabaseArray
|
|
6
6
|
} from "./chunk-JVJQKRJ4.js";
|
|
@@ -30,8 +30,8 @@ var Sqlite3 = class extends DbBase {
|
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
async init(DataDir, modelName, modelSchema, type) {
|
|
34
|
-
this.initBase(DataDir, modelName, modelSchema, type);
|
|
33
|
+
async init(DataDir, modelName, modelSchema, modelSchemaDefine, type, primaryKey) {
|
|
34
|
+
this.initBase(DataDir, modelName, modelSchema, modelSchemaDefine, type, primaryKey);
|
|
35
35
|
if (this.databaseType === "db" /* Db */) {
|
|
36
36
|
this.model = sequelize.define(this.modelName, this.modelSchema, {
|
|
37
37
|
timestamps: false,
|
|
@@ -179,6 +179,7 @@ var Sqlite3Static = new class Sqlite3Static2 {
|
|
|
179
179
|
}
|
|
180
180
|
ArrayColumn(key, fn) {
|
|
181
181
|
return {
|
|
182
|
+
ArrayColumn: true,
|
|
182
183
|
type: DataTypes.STRING,
|
|
183
184
|
defaultValue: [].join(","),
|
|
184
185
|
get() {
|
|
@@ -193,6 +194,7 @@ var Sqlite3Static = new class Sqlite3Static2 {
|
|
|
193
194
|
}
|
|
194
195
|
JsonColumn(key, def) {
|
|
195
196
|
return {
|
|
197
|
+
JsonColumn: true,
|
|
196
198
|
type: DataTypes.STRING,
|
|
197
199
|
defaultValue: JSON.stringify(def),
|
|
198
200
|
get() {
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
DefaultLayoutComponent
|
|
2
|
+
DefaultLayoutComponent,
|
|
3
|
+
React
|
|
3
4
|
} from "./chunk-JT3SU5UU.js";
|
|
4
5
|
import {
|
|
5
6
|
ReactRender
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LBLGKL3W.js";
|
|
7
8
|
import {
|
|
8
9
|
UserInfo
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4BTKE3LO.js";
|
|
10
11
|
import {
|
|
11
12
|
MysGame
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-2BVJS5VE.js";
|
|
13
14
|
import {
|
|
14
15
|
dir
|
|
15
16
|
} from "./chunk-SHLPPEAY.js";
|
|
16
17
|
|
|
17
|
-
// src/template/ShowBindAccount
|
|
18
|
-
import React from "react";
|
|
19
|
-
|
|
20
|
-
// src/template/render.ts
|
|
21
|
-
var Render = new ReactRender(dir, {});
|
|
22
|
-
|
|
23
|
-
// src/template/ShowBindAccount/ShowBindAccount.tsx
|
|
18
|
+
// src/template/ShowBindAccount.tsx
|
|
24
19
|
var ShowBindAccountComponent = ({
|
|
25
20
|
User,
|
|
26
21
|
AccountList
|
|
@@ -65,8 +60,8 @@ var ShowBindAccountComponent = ({
|
|
|
65
60
|
)) : /* @__PURE__ */ React.createElement("div", { className: "my-3 px-5 py-5 text-center font-semibold text-[#6b6b6b]" }, "\u6682\u672A\u7ED1\u5B9A\u8D26\u53F7")));
|
|
66
61
|
};
|
|
67
62
|
|
|
68
|
-
// src/template/
|
|
69
|
-
|
|
63
|
+
// src/template/index.ts
|
|
64
|
+
var Render = new ReactRender(dir, {});
|
|
70
65
|
|
|
71
66
|
// src/apps/UIDManage.ts
|
|
72
67
|
import karin, { handler, segment } from "node-karin";
|
|
@@ -83,7 +78,7 @@ var BindUID = karin.command(
|
|
|
83
78
|
}
|
|
84
79
|
const userInfo = await Game.UserInfo.create(e.userId);
|
|
85
80
|
const bindUids = userInfo.bind_uids;
|
|
86
|
-
if (!
|
|
81
|
+
if (!bindUids[uid]) {
|
|
87
82
|
bindUids[uid] = { perm: 0 /* BIND */, ltuid: "" };
|
|
88
83
|
}
|
|
89
84
|
await userInfo.saveUserInfo({
|
|
@@ -123,7 +118,7 @@ var UnbindUID = karin.command(
|
|
|
123
118
|
}
|
|
124
119
|
delUid = filterUids[idx - 1][0];
|
|
125
120
|
}
|
|
126
|
-
if (delUid
|
|
121
|
+
if (bindUids[delUid]) {
|
|
127
122
|
if (bindUids[delUid].perm === 0 /* BIND */) {
|
|
128
123
|
delete bindUids[delUid];
|
|
129
124
|
} else {
|
|
@@ -47,30 +47,28 @@ var EnhancedArray = class _EnhancedArray extends Array {
|
|
|
47
47
|
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
48
48
|
return this;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
lodash.pullAt(this, predicate);
|
|
57
|
-
} else if (lodash.isFunction(predicate)) {
|
|
58
|
-
lodash.remove(this, predicate);
|
|
59
|
-
} else {
|
|
60
|
-
lodash.pull(this, predicate);
|
|
50
|
+
/** @description 删除指定索引 */
|
|
51
|
+
pullAt(idx, save) {
|
|
52
|
+
if (idx < 0 || idx >= this.length) {
|
|
53
|
+
logger.error(`\u7D22\u5F15 ${idx} \u8D85\u51FA\u8303\u56F4 [0, ${this.length - 1}]`);
|
|
54
|
+
return this;
|
|
61
55
|
}
|
|
56
|
+
lodash.pullAt(this, idx);
|
|
62
57
|
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
63
58
|
return this;
|
|
64
59
|
}
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
* @param save - 是否立即保存
|
|
68
|
-
*/
|
|
69
|
-
removeSome(elements, save) {
|
|
60
|
+
/** @description 删除指定元素 */
|
|
61
|
+
pullAll(elements, save) {
|
|
70
62
|
lodash.pullAll(this, elements);
|
|
71
63
|
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
72
64
|
return this;
|
|
73
65
|
}
|
|
66
|
+
/** @description 使用条件函数删除元素 */
|
|
67
|
+
remove(predicate, save) {
|
|
68
|
+
lodash.remove(this, predicate);
|
|
69
|
+
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
74
72
|
clear() {
|
|
75
73
|
this.length = 0;
|
|
76
74
|
return this;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
common_exports
|
|
3
|
+
} from "./chunk-5DXIT7UB.js";
|
|
4
|
+
import {
|
|
5
|
+
EnhancedArray
|
|
6
|
+
} from "./chunk-PMFOX5HA.js";
|
|
7
|
+
|
|
8
|
+
// src/exports/config/config.ts
|
|
9
|
+
import { existsSync, existToMkdirSync, logger, requireFileSync, watch, writeJsonSync } from "node-karin";
|
|
10
|
+
import lodash from "node-karin/lodash";
|
|
11
|
+
import path from "path";
|
|
12
|
+
var Config = class {
|
|
13
|
+
#cfgName;
|
|
14
|
+
/**
|
|
15
|
+
* @description 配置缓存
|
|
16
|
+
*/
|
|
17
|
+
#ConfigCache = null;
|
|
18
|
+
/**
|
|
19
|
+
* @description 默认配置
|
|
20
|
+
*/
|
|
21
|
+
#DefaultConfig;
|
|
22
|
+
#DefineConfig;
|
|
23
|
+
/**
|
|
24
|
+
* @description 配置保存路径
|
|
25
|
+
*/
|
|
26
|
+
#ConfigPath;
|
|
27
|
+
/**
|
|
28
|
+
* @param name 插件名称:配置名称
|
|
29
|
+
*/
|
|
30
|
+
constructor(name, ConfigDir, DefaultConfig, DefineConfig) {
|
|
31
|
+
this.#cfgName = name;
|
|
32
|
+
const splitName = name.split(":");
|
|
33
|
+
if (!splitName[1]) {
|
|
34
|
+
throw new Error("\u914D\u7F6E\u540D\u79F0\u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A \u63D2\u4EF6\u540D\u79F0:\u914D\u7F6E\u540D\u79F0");
|
|
35
|
+
}
|
|
36
|
+
this.#ConfigPath = path.join(ConfigDir, `${splitName[1]}.json`);
|
|
37
|
+
this.#DefaultConfig = DefaultConfig;
|
|
38
|
+
this.#DefineConfig = DefineConfig;
|
|
39
|
+
existToMkdirSync(ConfigDir);
|
|
40
|
+
!existsSync(this.#ConfigPath) && writeJsonSync(this.#ConfigPath, DefaultConfig, true);
|
|
41
|
+
this.loadConfig();
|
|
42
|
+
}
|
|
43
|
+
loadConfig() {
|
|
44
|
+
const config = requireFileSync(this.#ConfigPath);
|
|
45
|
+
const mergedConfig = this.mergeWithDefaults(config, this.#DefaultConfig, this.#DefineConfig);
|
|
46
|
+
this.#ConfigCache = mergedConfig;
|
|
47
|
+
return mergedConfig;
|
|
48
|
+
}
|
|
49
|
+
mergeWithDefaults(userConfig, defaultConfig, DefineConfig) {
|
|
50
|
+
const filteredUserConfig = common_exports.filterData(userConfig, defaultConfig, DefineConfig);
|
|
51
|
+
const result = lodash.merge({}, defaultConfig, filteredUserConfig);
|
|
52
|
+
if (!lodash.isEqual(result, userConfig)) {
|
|
53
|
+
try {
|
|
54
|
+
writeJsonSync(this.#ConfigPath, result);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
logger.error(err);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @description 获取配置路径对应的默认配置
|
|
63
|
+
*/
|
|
64
|
+
getDef(path2) {
|
|
65
|
+
const defConfig = JSON.parse(JSON.stringify(this.#DefaultConfig));
|
|
66
|
+
return lodash.get(defConfig, path2);
|
|
67
|
+
}
|
|
68
|
+
get(path2, isArray = false, def) {
|
|
69
|
+
const conf = JSON.parse(JSON.stringify(this.#ConfigCache));
|
|
70
|
+
const result = path2 ? lodash.get(conf, path2, def) : conf;
|
|
71
|
+
if (isArray) {
|
|
72
|
+
if (!Array.isArray(result)) {
|
|
73
|
+
logger.error(`\u914D\u7F6E\u8DEF\u5F84 ${path2} \u4E0D\u662F\u6570\u7EC4\u7C7B\u578B`);
|
|
74
|
+
return new EnhancedArray(this, [], path2);
|
|
75
|
+
}
|
|
76
|
+
return new EnhancedArray(this, result, path2);
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @param save 是否立即保存
|
|
82
|
+
*/
|
|
83
|
+
set(path2, value, save) {
|
|
84
|
+
lodash.set(this.#ConfigCache, path2, value);
|
|
85
|
+
save && this.save();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @description 立即保存配置
|
|
89
|
+
*/
|
|
90
|
+
save() {
|
|
91
|
+
try {
|
|
92
|
+
logger.debug(`[${this.#cfgName}] \u4FDD\u5B58\u914D\u7F6E`, this.#ConfigCache);
|
|
93
|
+
writeJsonSync(this.#ConfigPath, this.#ConfigCache);
|
|
94
|
+
} catch (err) {
|
|
95
|
+
logger.error(err);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
watch(fnc) {
|
|
99
|
+
watch(this.#ConfigPath, async (oldData, newData) => {
|
|
100
|
+
fnc && await fnc(this, oldData, newData);
|
|
101
|
+
this.loadConfig();
|
|
102
|
+
});
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
Config
|
|
109
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createTable
|
|
3
|
+
} from "./chunk-G7TMVDGP.js";
|
|
4
4
|
import {
|
|
5
5
|
Database
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
common_exports
|
|
9
|
-
} from "./chunk-LG34FPBI.js";
|
|
6
|
+
} from "./chunk-DMJ5OQR6.js";
|
|
10
7
|
import {
|
|
11
8
|
dir
|
|
12
9
|
} from "./chunk-SHLPPEAY.js";
|
|
10
|
+
import {
|
|
11
|
+
common_exports
|
|
12
|
+
} from "./chunk-5DXIT7UB.js";
|
|
13
13
|
|
|
14
14
|
// src/exports/database/tables/mysDeviceInfo.ts
|
|
15
|
-
var MysDeviceInfoTable =
|
|
15
|
+
var MysDeviceInfoTable = createTable(
|
|
16
16
|
dir.DataDir,
|
|
17
17
|
"mys_device_info_data",
|
|
18
18
|
"db" /* Db */
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 生成随机字符串
|
|
3
|
+
* @param length - 字符串长度
|
|
4
|
+
*/
|
|
5
|
+
declare const randomString: (length: number, type: "Lower" | "Upper" | "All") => string;
|
|
6
|
+
/**
|
|
7
|
+
* @description 生成设备guid
|
|
8
|
+
*/
|
|
9
|
+
declare const getDeviceGuid: () => string;
|
|
10
|
+
/**
|
|
11
|
+
* @description 将字符串解析为key-value键值对
|
|
12
|
+
* @param Str - 字符串
|
|
13
|
+
* @param sep - 分隔符
|
|
14
|
+
*/
|
|
15
|
+
declare const StrToObj: <D extends {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
}>(Str: string, sep: string | RegExp) => Partial<D>;
|
|
18
|
+
/**
|
|
19
|
+
* @description 将key-value键值对解析为字符串
|
|
20
|
+
* @param obj - key-value键值对
|
|
21
|
+
* @param sep - 分隔符
|
|
22
|
+
*/
|
|
23
|
+
declare const ObjToStr: (obj: Record<string, string | number>, sep: string) => string;
|
|
24
|
+
declare function filterData(user: any, defaults: any, Define: any): any;
|
|
25
|
+
|
|
26
|
+
declare const common_ObjToStr: typeof ObjToStr;
|
|
27
|
+
declare const common_StrToObj: typeof StrToObj;
|
|
28
|
+
declare const common_filterData: typeof filterData;
|
|
29
|
+
declare const common_getDeviceGuid: typeof getDeviceGuid;
|
|
30
|
+
declare const common_randomString: typeof randomString;
|
|
31
|
+
declare namespace common {
|
|
32
|
+
export { common_ObjToStr as ObjToStr, common_StrToObj as StrToObj, common_filterData as filterData, common_getDeviceGuid as getDeviceGuid, common_randomString as randomString };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { ObjToStr as O, StrToObj as S, common as c, filterData as f, getDeviceGuid as g, randomString as r };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { E as EnhancedArray } from '
|
|
1
|
+
export { E as EnhancedArray } from './config.js';
|
|
@@ -1 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
declare class Config<C extends Record<string, any>> {
|
|
2
|
+
#private;
|
|
3
|
+
/**
|
|
4
|
+
* @param name 插件名称:配置名称
|
|
5
|
+
*/
|
|
6
|
+
constructor(name: `${string}:${string}`, ConfigDir: string, DefaultConfig: C, DefineConfig: Record<string, any>);
|
|
7
|
+
loadConfig(): C;
|
|
8
|
+
mergeWithDefaults(userConfig: C, defaultConfig: C, DefineConfig: Record<string, any>): C;
|
|
9
|
+
/**
|
|
10
|
+
* @description 获取配置路径对应的默认配置
|
|
11
|
+
*/
|
|
12
|
+
getDef<T>(path: string): T;
|
|
13
|
+
/**
|
|
14
|
+
* @description 获取配置路径对应的配置
|
|
15
|
+
*/
|
|
16
|
+
get<T>(path: string, isArray?: false, def?: T): T;
|
|
17
|
+
get<T>(path: string, isArray: true, def?: T[]): EnhancedArray<T>;
|
|
18
|
+
/**
|
|
19
|
+
* @param save 是否立即保存
|
|
20
|
+
*/
|
|
21
|
+
set<T>(path: string, value: T, save: boolean): void;
|
|
22
|
+
/**
|
|
23
|
+
* @description 立即保存配置
|
|
24
|
+
*/
|
|
25
|
+
save(): void;
|
|
26
|
+
watch(fnc?: (self: Config<C>, oldData: C, newData: C) => Promise<void> | void): this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare class EnhancedArray<T> extends Array<T> {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(cfg: Config<any>, items: T[], path: string);
|
|
32
|
+
/**
|
|
33
|
+
* @param element - string | number
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
has(element: T & (string | number)): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* @param isEqual 是否不添加重复元素
|
|
39
|
+
* @param save 是否立即保存
|
|
40
|
+
*/
|
|
41
|
+
add(element: T, isEqual: boolean, save: boolean): this;
|
|
42
|
+
/**
|
|
43
|
+
* @param isEqual 是否不添加重复元素
|
|
44
|
+
* @param save 是否立即保存
|
|
45
|
+
*/
|
|
46
|
+
addSome(elements: T[], isEqual: boolean, save: boolean): this;
|
|
47
|
+
/** @description 删除指定索引 */
|
|
48
|
+
pullAt(idx: number, save: boolean): this;
|
|
49
|
+
/** @description 删除指定元素 */
|
|
50
|
+
pullAll(elements: T[], save: boolean): this;
|
|
51
|
+
/** @description 使用条件函数删除元素 */
|
|
52
|
+
remove(predicate: (item: T) => boolean, save: boolean): this;
|
|
53
|
+
clear(): this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { Config, EnhancedArray as E };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Config
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-TTN7NFCA.js";
|
|
4
|
+
import "../../chunk-ARLTXJFJ.js";
|
|
5
|
+
import "../../chunk-PYTECG57.js";
|
|
6
|
+
import "../../chunk-T7W4DXRM.js";
|
|
7
|
+
import "../../chunk-5DXIT7UB.js";
|
|
8
|
+
import "../../chunk-PMFOX5HA.js";
|
|
5
9
|
import "../../chunk-MLKGABMK.js";
|
|
6
10
|
export {
|
|
7
11
|
Config
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { ConfigDefine, ConfigDefineArray } from './types/config.js';
|
|
1
|
+
export { Config, E as EnhancedArray } from './config.js';
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import "../../chunk-
|
|
2
|
-
import "../../chunk-7SZX3RBZ.js";
|
|
3
|
-
import "../../chunk-2DHTKQ34.js";
|
|
1
|
+
import "../../chunk-3ERB3ILC.js";
|
|
4
2
|
import {
|
|
5
3
|
Config
|
|
6
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-TTN7NFCA.js";
|
|
5
|
+
import "../../chunk-ARLTXJFJ.js";
|
|
6
|
+
import "../../chunk-PYTECG57.js";
|
|
7
|
+
import "../../chunk-T7W4DXRM.js";
|
|
8
|
+
import "../../chunk-5DXIT7UB.js";
|
|
7
9
|
import {
|
|
8
10
|
EnhancedArray
|
|
9
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-PMFOX5HA.js";
|
|
10
12
|
import "../../chunk-MLKGABMK.js";
|
|
11
13
|
export {
|
|
12
14
|
Config,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Database
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-DMJ5OQR6.js";
|
|
4
|
+
import "../../chunk-MPZP23EX.js";
|
|
5
|
+
import "../../chunk-3JN5WYUN.js";
|
|
6
6
|
import "../../chunk-7KEG6SDX.js";
|
|
7
7
|
import "../../chunk-FBWSEBAW.js";
|
|
8
8
|
import "../../chunk-JVJQKRJ4.js";
|
|
@@ -12,6 +12,10 @@ import "../../chunk-K5U2O3HH.js";
|
|
|
12
12
|
import "../../chunk-I7XZONDN.js";
|
|
13
13
|
import "../../chunk-JRH4JC43.js";
|
|
14
14
|
import "../../chunk-SHLPPEAY.js";
|
|
15
|
+
import "../../chunk-ARLTXJFJ.js";
|
|
16
|
+
import "../../chunk-PYTECG57.js";
|
|
17
|
+
import "../../chunk-T7W4DXRM.js";
|
|
18
|
+
import "../../chunk-5DXIT7UB.js";
|
|
15
19
|
import "../../chunk-MLKGABMK.js";
|
|
16
20
|
export {
|
|
17
21
|
Database
|
|
@@ -2,12 +2,14 @@ import { ModelStatic, Model } from 'sequelize';
|
|
|
2
2
|
import { DatabaseType, ModelAttributes, DatabaseReturn } from '../types/dbs/base.js';
|
|
3
3
|
|
|
4
4
|
declare class DbBase<T extends Record<string, any>, D extends DatabaseType> {
|
|
5
|
-
|
|
5
|
+
primaryKey: keyof T | undefined;
|
|
6
|
+
model: ModelStatic<Model> | undefined;
|
|
6
7
|
databasePath: string;
|
|
7
8
|
databaseType: D;
|
|
8
9
|
modelName: string;
|
|
9
|
-
modelSchema: ModelAttributes<Model>;
|
|
10
|
-
|
|
10
|
+
modelSchema: ModelAttributes<Model, T>;
|
|
11
|
+
modelSchemaDefine: Partial<Record<keyof T, any>>;
|
|
12
|
+
initBase(DataDir: string, modelName: string, modelSchema: ModelAttributes<Model, T>, modelSchemaDefine: Partial<Record<keyof T, any>>, type: D, primaryKey?: keyof T): void;
|
|
11
13
|
schemaToJSON(pk: string): T;
|
|
12
14
|
userPath(pk: string): string;
|
|
13
15
|
readSync(path: string, pk: string): DatabaseReturn<T>[DatabaseType.File];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DbBase
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-3JN5WYUN.js";
|
|
4
4
|
import "../../../chunk-7KEG6SDX.js";
|
|
5
5
|
import "../../../chunk-FBWSEBAW.js";
|
|
6
6
|
import "../../../chunk-JVJQKRJ4.js";
|
|
@@ -9,6 +9,10 @@ import "../../../chunk-SHW6FHIB.js";
|
|
|
9
9
|
import "../../../chunk-K5U2O3HH.js";
|
|
10
10
|
import "../../../chunk-I7XZONDN.js";
|
|
11
11
|
import "../../../chunk-JRH4JC43.js";
|
|
12
|
+
import "../../../chunk-ARLTXJFJ.js";
|
|
13
|
+
import "../../../chunk-PYTECG57.js";
|
|
14
|
+
import "../../../chunk-T7W4DXRM.js";
|
|
15
|
+
import "../../../chunk-5DXIT7UB.js";
|
|
12
16
|
import "../../../chunk-MLKGABMK.js";
|
|
13
17
|
export {
|
|
14
18
|
DbBase
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import "../../../chunk-SEWEEPJN.js";
|
|
2
2
|
import {
|
|
3
|
-
Table
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import "../../../chunk-
|
|
3
|
+
Table,
|
|
4
|
+
createTable
|
|
5
|
+
} from "../../../chunk-G7TMVDGP.js";
|
|
6
|
+
import "../../../chunk-DMJ5OQR6.js";
|
|
7
|
+
import "../../../chunk-MPZP23EX.js";
|
|
7
8
|
import {
|
|
8
9
|
DbBase
|
|
9
|
-
} from "../../../chunk-
|
|
10
|
+
} from "../../../chunk-3JN5WYUN.js";
|
|
10
11
|
import "../../../chunk-7KEG6SDX.js";
|
|
11
12
|
import "../../../chunk-FBWSEBAW.js";
|
|
12
13
|
import "../../../chunk-JVJQKRJ4.js";
|
|
@@ -16,8 +17,13 @@ import "../../../chunk-K5U2O3HH.js";
|
|
|
16
17
|
import "../../../chunk-I7XZONDN.js";
|
|
17
18
|
import "../../../chunk-JRH4JC43.js";
|
|
18
19
|
import "../../../chunk-SHLPPEAY.js";
|
|
20
|
+
import "../../../chunk-ARLTXJFJ.js";
|
|
21
|
+
import "../../../chunk-PYTECG57.js";
|
|
22
|
+
import "../../../chunk-T7W4DXRM.js";
|
|
23
|
+
import "../../../chunk-5DXIT7UB.js";
|
|
19
24
|
import "../../../chunk-MLKGABMK.js";
|
|
20
25
|
export {
|
|
21
26
|
DbBase,
|
|
22
|
-
Table
|
|
27
|
+
Table,
|
|
28
|
+
createTable
|
|
23
29
|
};
|
|
@@ -5,7 +5,7 @@ import { DbBase } from './base.js';
|
|
|
5
5
|
declare class Sqlite3<T extends Record<string, any>, D extends DatabaseType> extends DbBase<T, D> implements DatabaseClassInstance<T, D> {
|
|
6
6
|
dialect: Dialect;
|
|
7
7
|
check(): Promise<boolean>;
|
|
8
|
-
init(DataDir: string, modelName: string, modelSchema: ModelAttributes<Model>, type: D): Promise<DatabaseClassInstance<T, D>>;
|
|
8
|
+
init(DataDir: string, modelName: string, modelSchema: ModelAttributes<Model, T>, modelSchemaDefine: Partial<Record<keyof T, any>>, type: D, primaryKey?: keyof T): Promise<DatabaseClassInstance<T, D>>;
|
|
9
9
|
findByPk(pk: string, create: true): Promise<DatabaseReturn<T>[D]>;
|
|
10
10
|
findByPk(pk: string, create?: false): Promise<DatabaseReturn<T>[D] | undefined>;
|
|
11
11
|
findAllByPks(pks: string[]): Promise<DatabaseReturn<T>[D][]>;
|
|
@@ -16,8 +16,12 @@ declare const Sqlite3Static: {
|
|
|
16
16
|
dialect: Dialect;
|
|
17
17
|
description: string;
|
|
18
18
|
Column<T>(type: keyof typeof DataTypes, def: T, option?: Partial<ModelAttributeColumnOptions<Model>>): ModelAttributeColumnOptions<Model>;
|
|
19
|
-
ArrayColumn<T>(key: string, fn?: (data: DatabaseArray<T>) => T[]): ModelAttributeColumnOptions<Model
|
|
20
|
-
|
|
19
|
+
ArrayColumn<T>(key: string, fn?: (data: DatabaseArray<T>) => T[]): ModelAttributeColumnOptions<Model> & {
|
|
20
|
+
ArrayColumn: true;
|
|
21
|
+
};
|
|
22
|
+
JsonColumn<T>(key: string, def: T): ModelAttributeColumnOptions<Model> & {
|
|
23
|
+
JsonColumn: true;
|
|
24
|
+
};
|
|
21
25
|
};
|
|
22
26
|
|
|
23
27
|
export { Sqlite3, Sqlite3Static };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Sqlite3,
|
|
3
3
|
Sqlite3Static
|
|
4
|
-
} from "../../../chunk-
|
|
5
|
-
import "../../../chunk-
|
|
4
|
+
} from "../../../chunk-MPZP23EX.js";
|
|
5
|
+
import "../../../chunk-3JN5WYUN.js";
|
|
6
6
|
import "../../../chunk-7KEG6SDX.js";
|
|
7
7
|
import "../../../chunk-FBWSEBAW.js";
|
|
8
8
|
import "../../../chunk-JVJQKRJ4.js";
|
|
@@ -12,6 +12,10 @@ import "../../../chunk-K5U2O3HH.js";
|
|
|
12
12
|
import "../../../chunk-I7XZONDN.js";
|
|
13
13
|
import "../../../chunk-JRH4JC43.js";
|
|
14
14
|
import "../../../chunk-SHLPPEAY.js";
|
|
15
|
+
import "../../../chunk-ARLTXJFJ.js";
|
|
16
|
+
import "../../../chunk-PYTECG57.js";
|
|
17
|
+
import "../../../chunk-T7W4DXRM.js";
|
|
18
|
+
import "../../../chunk-5DXIT7UB.js";
|
|
15
19
|
import "../../../chunk-MLKGABMK.js";
|
|
16
20
|
export {
|
|
17
21
|
Sqlite3,
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DatabaseType, DatabaseClassInstance } from '../types/dbs/base.js';
|
|
1
|
+
import { Model } from 'sequelize';
|
|
2
|
+
import { DatabaseType, DatabaseClassInstance, ModelAttributes } from '../types/dbs/base.js';
|
|
3
3
|
|
|
4
|
-
declare class Table<TableType extends Record<string, any>,
|
|
4
|
+
declare class Table<TableType extends Record<string, any>, ExtraTableType extends Record<string, any> = {}, DBType extends DatabaseType = DatabaseType> {
|
|
5
5
|
#private;
|
|
6
6
|
initCache: DatabaseClassInstance<TableType, DBType>;
|
|
7
|
-
modelSchema:
|
|
7
|
+
modelSchema: ModelAttributes<Model, TableType>;
|
|
8
|
+
modelSchemaDefine: Partial<Record<keyof TableType, any>>;
|
|
8
9
|
/**
|
|
9
10
|
* @param type Db: 直接保存在sqlite数据中、 File: 保存在单个json文件中、 Dir: 保存在多个json文件的目录中、Schema中除pk外每一个键值对应一个文件 e.g tableName/user/key.json
|
|
10
11
|
*/
|
|
11
|
-
constructor(DataDir: string, tableName: string, type: DBType);
|
|
12
|
-
init(Schema: Record<keyof TableType,
|
|
13
|
-
addSchem<newTableType extends ExtraTableType>(newSchema: Record<keyof newTableType,
|
|
12
|
+
constructor(DataDir: string, tableName: string, type: DBType, primaryKey?: keyof TableType);
|
|
13
|
+
init(Schema: ModelAttributes<Model, TableType>, SchemaDefine?: Partial<Record<keyof TableType, any>>): Promise<() => Promise<DatabaseClassInstance<TableType, DBType>>>;
|
|
14
|
+
addSchem<newTableType extends ExtraTableType>(newSchema: ModelAttributes<Model, newTableType>, SchemaDefine?: Partial<Record<keyof newTableType, any>>): Promise<() => Promise<DatabaseClassInstance<TableType & newTableType, DBType>>>;
|
|
14
15
|
}
|
|
16
|
+
declare function createTable<TableType extends Record<string, any>, ExtraTableType extends Record<string, any> = {}>(DataDir: string, tableName: string, type: DatabaseType.File, primaryKey: keyof TableType): Table<TableType, ExtraTableType, DatabaseType.File>;
|
|
17
|
+
declare function createTable<TableType extends Record<string, any>, ExtraTableType extends Record<string, any> = {}>(DataDir: string, tableName: string, type: DatabaseType.Dir, primaryKey: keyof TableType): Table<TableType, ExtraTableType, DatabaseType.Dir>;
|
|
18
|
+
declare function createTable<TableType extends Record<string, any>, ExtraTableType extends Record<string, any> = {}>(DataDir: string, tableName: string, type: DatabaseType.Db, primaryKey?: keyof TableType): Table<TableType, ExtraTableType, DatabaseType.Db>;
|
|
15
19
|
|
|
16
|
-
export { Table };
|
|
20
|
+
export { Table, createTable };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Table
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import "../../../chunk-
|
|
6
|
-
import "../../../chunk-
|
|
2
|
+
Table,
|
|
3
|
+
createTable
|
|
4
|
+
} from "../../../chunk-G7TMVDGP.js";
|
|
5
|
+
import "../../../chunk-DMJ5OQR6.js";
|
|
6
|
+
import "../../../chunk-MPZP23EX.js";
|
|
7
|
+
import "../../../chunk-3JN5WYUN.js";
|
|
7
8
|
import "../../../chunk-7KEG6SDX.js";
|
|
8
9
|
import "../../../chunk-FBWSEBAW.js";
|
|
9
10
|
import "../../../chunk-JVJQKRJ4.js";
|
|
@@ -13,7 +14,12 @@ import "../../../chunk-K5U2O3HH.js";
|
|
|
13
14
|
import "../../../chunk-I7XZONDN.js";
|
|
14
15
|
import "../../../chunk-JRH4JC43.js";
|
|
15
16
|
import "../../../chunk-SHLPPEAY.js";
|
|
17
|
+
import "../../../chunk-ARLTXJFJ.js";
|
|
18
|
+
import "../../../chunk-PYTECG57.js";
|
|
19
|
+
import "../../../chunk-T7W4DXRM.js";
|
|
20
|
+
import "../../../chunk-5DXIT7UB.js";
|
|
16
21
|
import "../../../chunk-MLKGABMK.js";
|
|
17
22
|
export {
|
|
18
|
-
Table
|
|
23
|
+
Table,
|
|
24
|
+
createTable
|
|
19
25
|
};
|