abler-api 1.0.2 → 1.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.
Files changed (2) hide show
  1. package/dist/cjs/pp-util.js +15 -17
  2. package/package.json +6 -6
@@ -54,11 +54,11 @@ class preconditions$2 {
54
54
  static appName;
55
55
  static checkFunctions = [];
56
56
  static checkPromises = [];
57
- static setAppName(aName) {
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 = aName || conf$3.thisApp;
61
+ preconditions$2.appName = appName || conf$3.thisApp;
62
62
  return preconditions$2;
63
63
  }
64
64
  static addCheckPromise(p) {
@@ -270,7 +270,7 @@ const {
270
270
  netUtil: netUtil$1
271
271
  } = require$$6__default["default"];
272
272
  const preconditions$1 = ppPrecond;
273
- let conf$2, appSetting, errCfg, dbSql;
273
+ let conf$2, appSetting, errCfg;
274
274
  const pnToken = "access_token",
275
275
  hnToken = pnToken,
276
276
  pnApiKey = "apiKey",
@@ -292,17 +292,15 @@ class apiUtil$2 {
292
292
 
293
293
  // static apiCallRecSaver;
294
294
 
295
- static config(appConfig, appErrCfg, appDbSql) {
296
- conf$2 = appConfig;
295
+ static config() {
296
+ conf$2 = ppUtil$3.appConfig;
297
297
  appSetting = conf$2?.appSetting;
298
- errCfg = appErrCfg;
299
- dbSql = appDbSql;
300
- ppUtil$3.config(appConfig, appErrCfg);
301
- kvStorage.config(appConfig, appErrCfg);
298
+ errCfg = ppUtil$3.appErrCfg;
299
+ kvStorage.config(conf$2, errCfg);
302
300
  apiUtil$2.debugFlag = appSetting?.debugFlag || apiUtil$2.debugFlag;
303
301
  apiUtil$2.testFlag = appSetting?.testFlag || apiUtil$2.testFlag;
304
302
  // apiUtil.apiCallRecSaver = apiCallRecSaver;
305
- preconditions$1.setAppName();
303
+ preconditions$1.config();
306
304
  apiUtil$2.appAsPrefix = conf$2.thisApp.toLowerCase();
307
305
  }
308
306
 
@@ -883,7 +881,7 @@ class apiUtil$2 {
883
881
  static createApiCallRec(tokenData, req) {
884
882
  if (!req.apiCallRec) {
885
883
  if (req.apiCallRecId) {
886
- return dbUtil.dbQueryOne(dbSql.loadApiUsage, {
884
+ return dbUtil.dbQueryOne(conf$2.dbSql.loadApiUsage, {
887
885
  replacements: {
888
886
  id: req.apiCallRecId
889
887
  }
@@ -949,7 +947,7 @@ class apiUtil$2 {
949
947
  * @returns {Promise<null|*>}
950
948
  */
951
949
  static async queryCompanyInfo(companyId, nullable) {
952
- return await dbUtil.dbQueryOne(dbSql.queryCompanyInfo, {
950
+ return await dbUtil.dbQueryOne(conf$2.dbSql.queryCompanyInfo, {
953
951
  companyId
954
952
  }, nullable);
955
953
  }
@@ -967,7 +965,7 @@ class apiUtil$2 {
967
965
  certSpare: null,
968
966
  certSpareId: ''
969
967
  };
970
- return await dbUtil.dbQueryOne(dbSql.queryCertDataByOwner, {
968
+ return await dbUtil.dbQueryOne(conf$2.dbSql.queryCertDataByOwner, {
971
969
  ownerId: companyId,
972
970
  applyId: "company"
973
971
  }, false).then(certRec => {
@@ -978,7 +976,7 @@ class apiUtil$2 {
978
976
  // 公司正式证书
979
977
  certInfo.certLiving = pubKeyData;
980
978
  certInfo.certLivingId = certRec.id;
981
- return dbUtil.dbQueryOne(dbSql.queryCertDataByOwner, {
979
+ return dbUtil.dbQueryOne(conf$2.dbSql.queryCertDataByOwner, {
982
980
  ownerId: companyId,
983
981
  applyId: "company_spare"
984
982
  }, false).then(certRec1 => {
@@ -1083,13 +1081,13 @@ class apiUtil$2 {
1083
1081
  // 备用证书验证成功了,则将备用证书替换为正式证书
1084
1082
  console.log(t_f$2("公司(%s)备用证书验签成功,正式启用...", tokenData.apiKey));
1085
1083
  return dbUtil.dbTrans(trans => {
1086
- let p1 = dbUtil.dbExec(dbSql.deleteCertRecById, {
1084
+ let p1 = dbUtil.dbExec(conf$2.dbSql.deleteCertRecById, {
1087
1085
  replacements: {
1088
1086
  id: tokenData.certLivingId
1089
1087
  },
1090
1088
  transaction: trans
1091
1089
  });
1092
- let p2 = dbUtil.dbExec(dbSql.spareCertToLiving, {
1090
+ let p2 = dbUtil.dbExec(conf$2.dbSql.spareCertToLiving, {
1093
1091
  replacements: {
1094
1092
  id: tokenData.certSpareId
1095
1093
  },
@@ -1443,7 +1441,7 @@ class apiUtil$2 {
1443
1441
  static async restoreAppInfo(apiKey, req) {
1444
1442
  let appInfo = await apiUtil$2.restoreObj(`${this.appAsPrefix}App_${apiKey}`, appSetting.tokenExpireTime);
1445
1443
  if (!appInfo) {
1446
- appInfo = await dbUtil.dbQueryOneAndUnstringify(dbSql.APP_QUERY, {
1444
+ appInfo = await dbUtil.dbQueryOneAndUnstringify(conf$2.dbSql.APP_QUERY, {
1447
1445
  apiKey
1448
1446
  }, "exData");
1449
1447
  if (appInfo) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abler-api",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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.2",
18
+ "abler-db": "^1.0.4",
19
19
  "abler-i18n": "^1.0.1",
20
- "abler-messenger": "^1.0.2",
21
- "abler-net": "^1.0.2",
22
- "abler-util": "^1.0.2",
20
+ "abler-messenger": "^1.0.4",
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": "985e0ce8a13250f5ebe2ccbb61ab819f4ee7d455"
45
+ "gitHead": "bc6f804856bb253537e9e7120f4bbb7f942e466e"
46
46
  }