abler-api 1.0.1 → 1.0.3
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/dist/cjs/pp-util.js +22 -26
- package/package.json +6 -6
package/dist/cjs/pp-util.js
CHANGED
|
@@ -35,10 +35,10 @@ const {
|
|
|
35
35
|
dbUtil: dbUtil$1,
|
|
36
36
|
ppRedis,
|
|
37
37
|
kvStorage: kvStorage$1,
|
|
38
|
-
redisSimulator
|
|
38
|
+
redisSimulator,
|
|
39
|
+
DbVersionManager
|
|
39
40
|
} = require$$4__default["default"];
|
|
40
41
|
let conf$3, err$1;
|
|
41
|
-
// const dbCheck = require('../dbupdate/dd-version');
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* API服务启动时前置条件检查
|
|
@@ -54,11 +54,11 @@ class preconditions$2 {
|
|
|
54
54
|
static appName;
|
|
55
55
|
static checkFunctions = [];
|
|
56
56
|
static checkPromises = [];
|
|
57
|
-
static
|
|
57
|
+
static config(appName) {
|
|
58
58
|
ppUtil$4.configNeeded();
|
|
59
59
|
conf$3 = ppUtil$4.appConfig;
|
|
60
60
|
err$1 = ppUtil$4.appErrCfg;
|
|
61
|
-
preconditions$2.appName =
|
|
61
|
+
preconditions$2.appName = appName || conf$3.thisApp;
|
|
62
62
|
return preconditions$2;
|
|
63
63
|
}
|
|
64
64
|
static addCheckPromise(p) {
|
|
@@ -150,13 +150,11 @@ class preconditions$2 {
|
|
|
150
150
|
static async initKvStorage(dbSql) {
|
|
151
151
|
return await initKvStorage(dbSql);
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// return await checkDatabase();
|
|
159
|
-
// }
|
|
153
|
+
static async checkAppDbVersion() {
|
|
154
|
+
const dbVersionManager = new DbVersionManager();
|
|
155
|
+
const updateInfo = await dbVersionManager.checkAppDbVersion();
|
|
156
|
+
return updateInfo.updateMessage;
|
|
157
|
+
}
|
|
160
158
|
}
|
|
161
159
|
async function createEnvSettingFile(fileName, lastEnvSettingEx) {
|
|
162
160
|
try {
|
|
@@ -272,7 +270,7 @@ const {
|
|
|
272
270
|
netUtil: netUtil$1
|
|
273
271
|
} = require$$6__default["default"];
|
|
274
272
|
const preconditions$1 = ppPrecond;
|
|
275
|
-
let conf$2, appSetting, errCfg
|
|
273
|
+
let conf$2, appSetting, errCfg;
|
|
276
274
|
const pnToken = "access_token",
|
|
277
275
|
hnToken = pnToken,
|
|
278
276
|
pnApiKey = "apiKey",
|
|
@@ -294,17 +292,15 @@ class apiUtil$2 {
|
|
|
294
292
|
|
|
295
293
|
// static apiCallRecSaver;
|
|
296
294
|
|
|
297
|
-
static config(
|
|
298
|
-
conf$2 = appConfig;
|
|
295
|
+
static config() {
|
|
296
|
+
conf$2 = ppUtil$3.appConfig;
|
|
299
297
|
appSetting = conf$2?.appSetting;
|
|
300
|
-
errCfg = appErrCfg;
|
|
301
|
-
|
|
302
|
-
ppUtil$3.config(appConfig, appErrCfg);
|
|
303
|
-
kvStorage.config(appConfig, appErrCfg);
|
|
298
|
+
errCfg = ppUtil$3.appErrCfg;
|
|
299
|
+
kvStorage.config(conf$2, errCfg);
|
|
304
300
|
apiUtil$2.debugFlag = appSetting?.debugFlag || apiUtil$2.debugFlag;
|
|
305
301
|
apiUtil$2.testFlag = appSetting?.testFlag || apiUtil$2.testFlag;
|
|
306
302
|
// apiUtil.apiCallRecSaver = apiCallRecSaver;
|
|
307
|
-
preconditions$1.
|
|
303
|
+
preconditions$1.config();
|
|
308
304
|
apiUtil$2.appAsPrefix = conf$2.thisApp.toLowerCase();
|
|
309
305
|
}
|
|
310
306
|
|
|
@@ -885,7 +881,7 @@ class apiUtil$2 {
|
|
|
885
881
|
static createApiCallRec(tokenData, req) {
|
|
886
882
|
if (!req.apiCallRec) {
|
|
887
883
|
if (req.apiCallRecId) {
|
|
888
|
-
return dbUtil.dbQueryOne(dbSql.loadApiUsage, {
|
|
884
|
+
return dbUtil.dbQueryOne(conf$2.dbSql.loadApiUsage, {
|
|
889
885
|
replacements: {
|
|
890
886
|
id: req.apiCallRecId
|
|
891
887
|
}
|
|
@@ -951,7 +947,7 @@ class apiUtil$2 {
|
|
|
951
947
|
* @returns {Promise<null|*>}
|
|
952
948
|
*/
|
|
953
949
|
static async queryCompanyInfo(companyId, nullable) {
|
|
954
|
-
return await dbUtil.dbQueryOne(dbSql.queryCompanyInfo, {
|
|
950
|
+
return await dbUtil.dbQueryOne(conf$2.dbSql.queryCompanyInfo, {
|
|
955
951
|
companyId
|
|
956
952
|
}, nullable);
|
|
957
953
|
}
|
|
@@ -969,7 +965,7 @@ class apiUtil$2 {
|
|
|
969
965
|
certSpare: null,
|
|
970
966
|
certSpareId: ''
|
|
971
967
|
};
|
|
972
|
-
return await dbUtil.dbQueryOne(dbSql.queryCertDataByOwner, {
|
|
968
|
+
return await dbUtil.dbQueryOne(conf$2.dbSql.queryCertDataByOwner, {
|
|
973
969
|
ownerId: companyId,
|
|
974
970
|
applyId: "company"
|
|
975
971
|
}, false).then(certRec => {
|
|
@@ -980,7 +976,7 @@ class apiUtil$2 {
|
|
|
980
976
|
// 公司正式证书
|
|
981
977
|
certInfo.certLiving = pubKeyData;
|
|
982
978
|
certInfo.certLivingId = certRec.id;
|
|
983
|
-
return dbUtil.dbQueryOne(dbSql.queryCertDataByOwner, {
|
|
979
|
+
return dbUtil.dbQueryOne(conf$2.dbSql.queryCertDataByOwner, {
|
|
984
980
|
ownerId: companyId,
|
|
985
981
|
applyId: "company_spare"
|
|
986
982
|
}, false).then(certRec1 => {
|
|
@@ -1085,13 +1081,13 @@ class apiUtil$2 {
|
|
|
1085
1081
|
// 备用证书验证成功了,则将备用证书替换为正式证书
|
|
1086
1082
|
console.log(t_f$2("公司(%s)备用证书验签成功,正式启用...", tokenData.apiKey));
|
|
1087
1083
|
return dbUtil.dbTrans(trans => {
|
|
1088
|
-
let p1 = dbUtil.dbExec(dbSql.deleteCertRecById, {
|
|
1084
|
+
let p1 = dbUtil.dbExec(conf$2.dbSql.deleteCertRecById, {
|
|
1089
1085
|
replacements: {
|
|
1090
1086
|
id: tokenData.certLivingId
|
|
1091
1087
|
},
|
|
1092
1088
|
transaction: trans
|
|
1093
1089
|
});
|
|
1094
|
-
let p2 = dbUtil.dbExec(dbSql.spareCertToLiving, {
|
|
1090
|
+
let p2 = dbUtil.dbExec(conf$2.dbSql.spareCertToLiving, {
|
|
1095
1091
|
replacements: {
|
|
1096
1092
|
id: tokenData.certSpareId
|
|
1097
1093
|
},
|
|
@@ -1445,7 +1441,7 @@ class apiUtil$2 {
|
|
|
1445
1441
|
static async restoreAppInfo(apiKey, req) {
|
|
1446
1442
|
let appInfo = await apiUtil$2.restoreObj(`${this.appAsPrefix}App_${apiKey}`, appSetting.tokenExpireTime);
|
|
1447
1443
|
if (!appInfo) {
|
|
1448
|
-
appInfo = await dbUtil.dbQueryOneAndUnstringify(dbSql.APP_QUERY, {
|
|
1444
|
+
appInfo = await dbUtil.dbQueryOneAndUnstringify(conf$2.dbSql.APP_QUERY, {
|
|
1449
1445
|
apiKey
|
|
1450
1446
|
}, "exData");
|
|
1451
1447
|
if (appInfo) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abler-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "API服务相关工具",
|
|
5
5
|
"main": "./dist/cjs/pp-util.js",
|
|
6
6
|
"-module": "./dist/es/pp-util.js",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"author": "peng_peng",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"abler-db": "^1.0.
|
|
18
|
+
"abler-db": "^1.0.3",
|
|
19
19
|
"abler-i18n": "^1.0.1",
|
|
20
|
-
"abler-messenger": "^1.0.
|
|
21
|
-
"abler-net": "^1.0.
|
|
22
|
-
"abler-util": "^1.0.
|
|
20
|
+
"abler-messenger": "^1.0.3",
|
|
21
|
+
"abler-net": "^1.0.3",
|
|
22
|
+
"abler-util": "^1.0.3",
|
|
23
23
|
"basic-auth": "^2.0.1",
|
|
24
24
|
"node-cron": "^3.0.1",
|
|
25
25
|
"q": "^1.5.1"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"rollup-plugin-json": "^4.0.0",
|
|
43
43
|
"rollup-plugin-terser": "^7.0.2"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "ef71a9b05cf37ec9837a09b1d4dce9ca354de627"
|
|
46
46
|
}
|