abler-api 0.1.73 → 0.1.74
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 +78 -58
- package/package.json +5 -2
package/dist/cjs/pp-util.js
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
var require$$0 = require('fs');
|
|
4
4
|
var require$$1$1 = require('crypto');
|
|
5
5
|
var require$$2$1 = require('basic-auth');
|
|
6
|
-
var require$$2 = require('abler-
|
|
7
|
-
var require$$3 = require('abler-
|
|
8
|
-
var require$$
|
|
6
|
+
var require$$2 = require('abler-lang');
|
|
7
|
+
var require$$3 = require('abler-util');
|
|
8
|
+
var require$$4 = require('abler-db');
|
|
9
|
+
var require$$6 = require('abler-net');
|
|
9
10
|
var require$$1 = require('path');
|
|
10
|
-
var require$$
|
|
11
|
+
var require$$2$2 = require('abler-messenger');
|
|
11
12
|
var require$$0$1 = require('node-cron');
|
|
12
13
|
|
|
13
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -17,20 +18,24 @@ var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
|
|
|
17
18
|
var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
|
|
18
19
|
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
19
20
|
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
|
|
20
|
-
var require$$
|
|
21
|
+
var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
|
|
22
|
+
var require$$6__default = /*#__PURE__*/_interopDefaultLegacy(require$$6);
|
|
21
23
|
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
22
|
-
var require$$
|
|
24
|
+
var require$$2__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$2$2);
|
|
23
25
|
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
24
26
|
|
|
25
27
|
const fs$1 = require$$0__default["default"];
|
|
26
28
|
const path = require$$1__default["default"];
|
|
27
|
-
const
|
|
29
|
+
const {
|
|
30
|
+
t_f: t_f$3
|
|
31
|
+
} = require$$2__default["default"];
|
|
32
|
+
const ppUtil$4 = require$$3__default["default"].ppUtil;
|
|
28
33
|
const {
|
|
29
34
|
dbUtil: dbUtil$1,
|
|
30
35
|
ppRedis,
|
|
31
36
|
kvStorage: kvStorage$1,
|
|
32
37
|
redisSimulator
|
|
33
|
-
} = require$$
|
|
38
|
+
} = require$$4__default["default"];
|
|
34
39
|
let conf$3, err$2;
|
|
35
40
|
// const dbCheck = require('../dbupdate/dd-version');
|
|
36
41
|
|
|
@@ -102,7 +107,7 @@ class preconditions$2 {
|
|
|
102
107
|
}
|
|
103
108
|
let text = "";
|
|
104
109
|
if (preconditions$2.messages) {
|
|
105
|
-
text =
|
|
110
|
+
text = t_f$3("*** 由于以下原因,%s 尚不能正常提供服务:\n\n", preconditions$2.appName) + preconditions$2.messages.join("\n\n") + "\n\n*** 请检查以上各项条件,修复后重新启动服务";
|
|
106
111
|
console.log("\n" + text);
|
|
107
112
|
// for (let i = 0; i < preconditions.messages.length; i++) {
|
|
108
113
|
// console.log(preconditions.messages[i]);
|
|
@@ -156,12 +161,12 @@ async function createEnvSettingFile(fileName, lastEnvSettingEx) {
|
|
|
156
161
|
try {
|
|
157
162
|
const cfgText = await ppUtil$4.doCreateEnvSettingFile(fileName, lastEnvSettingEx);
|
|
158
163
|
if (cfgText.indexOf(`cfgVersion: "${conf$3._envSetting.cfgVersion}"`) > 0) {
|
|
159
|
-
console.log(
|
|
164
|
+
console.log(t_f$3("\n*** 已創建新的本機環境配置文件\n%s\n请檢查各項內容是否正确(此项更新服务可正常运行)\n\n", fileName));
|
|
160
165
|
return "";
|
|
161
166
|
}
|
|
162
|
-
return
|
|
167
|
+
return t_f$3("已創建新的本機環境配置文件\n%s\n请檢查並正確設置各項內容,然後將配置版本號修改為%s", fileName, conf$3._envSettings.default.cfgVersion);
|
|
163
168
|
} catch (e) {
|
|
164
|
-
return
|
|
169
|
+
return t_f$3("創建本機環境配置文件失敗\n《%s》\n%s", fileName, err$2.ERROR(e).message);
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
async function checkExEnvSetting(loadjs) {
|
|
@@ -188,7 +193,7 @@ async function checkExEnvSetting(loadjs) {
|
|
|
188
193
|
}
|
|
189
194
|
ppUtil$4.importExEnvSetting(conf$3._envSetting, fileName, loadjs);
|
|
190
195
|
} catch (e) {
|
|
191
|
-
return
|
|
196
|
+
return t_f$3("导入本机环境配置失败\n%s", e.stack);
|
|
192
197
|
}
|
|
193
198
|
}
|
|
194
199
|
|
|
@@ -208,8 +213,8 @@ async function checkRedis() {
|
|
|
208
213
|
redis.error = e;
|
|
209
214
|
});
|
|
210
215
|
if (redis.error) {
|
|
211
|
-
console.log(
|
|
212
|
-
return
|
|
216
|
+
console.log(t_f$3("未能成功連接 redis: %s,請檢查相關設置", redis.error));
|
|
217
|
+
return t_f$3("未能成功連接 redis: %s,請檢查相關設置", redis.error);
|
|
213
218
|
}
|
|
214
219
|
// console.log(`checkRedis done:`);
|
|
215
220
|
// console.log(redis);
|
|
@@ -219,12 +224,12 @@ async function initDb() {
|
|
|
219
224
|
dbUtil$1.config(conf$3, err$2);
|
|
220
225
|
} catch (e) {
|
|
221
226
|
if (e.reason === 'bad decrypt') {
|
|
222
|
-
e = new Error(
|
|
227
|
+
e = new Error(t_f$3("解密数据库密码(%s)失败", conf$3.dbconn.dbpwd));
|
|
223
228
|
}
|
|
224
229
|
// if (e.reason === 'bad decrypt') {
|
|
225
230
|
// e = new Error(`解密Redis密码(${conf.redis.password})失败`);
|
|
226
231
|
// }
|
|
227
|
-
return
|
|
232
|
+
return t_f$3("初始化数据库连接失败(%s)", e.message);
|
|
228
233
|
}
|
|
229
234
|
}
|
|
230
235
|
async function initKvStorage(dbSql) {
|
|
@@ -239,7 +244,7 @@ async function initKvStorage(dbSql) {
|
|
|
239
244
|
// if (e.reason === 'bad decrypt') {
|
|
240
245
|
// e = new Error(`解密Redis密码(${conf.redis.password})失败`);
|
|
241
246
|
// }
|
|
242
|
-
return
|
|
247
|
+
return t_f$3("初始化键值对存储器失败(%s)", e.message);
|
|
243
248
|
}
|
|
244
249
|
}
|
|
245
250
|
var ppPrecond = preconditions$2;
|
|
@@ -247,14 +252,18 @@ var ppPrecond = preconditions$2;
|
|
|
247
252
|
const fs = require$$0__default["default"];
|
|
248
253
|
const crypto = require$$1__default$1["default"];
|
|
249
254
|
const getBasicAuthorization = require$$2__default$1["default"];
|
|
250
|
-
const
|
|
255
|
+
const {
|
|
256
|
+
t_f: t_f$2,
|
|
257
|
+
t
|
|
258
|
+
} = require$$2__default["default"];
|
|
259
|
+
const ppUtil$3 = require$$3__default["default"].ppUtil;
|
|
251
260
|
const {
|
|
252
261
|
dbUtil,
|
|
253
262
|
kvStorage
|
|
254
|
-
} = require$$
|
|
263
|
+
} = require$$4__default["default"];
|
|
255
264
|
const {
|
|
256
265
|
netUtil: netUtil$1
|
|
257
|
-
} = require$$
|
|
266
|
+
} = require$$6__default["default"];
|
|
258
267
|
const preconditions$1 = ppPrecond;
|
|
259
268
|
let conf$2, appSetting, err$1, dbSql;
|
|
260
269
|
const pnToken = "access_token",
|
|
@@ -394,7 +403,7 @@ class apiUtil$2 {
|
|
|
394
403
|
if (this[name] === undefined) return defaultValue;
|
|
395
404
|
let result = +this[name];
|
|
396
405
|
if (typeof result !== "number" || result < minValue || result > maxValue) {
|
|
397
|
-
throw [err$1.INVALID_PARAM,
|
|
406
|
+
throw [err$1.INVALID_PARAM, t_f$2("参数 %s 必须是 %s ~ %s 之间的数字", name, minValue, maxValue)];
|
|
398
407
|
}
|
|
399
408
|
return result;
|
|
400
409
|
});
|
|
@@ -506,7 +515,7 @@ class apiUtil$2 {
|
|
|
506
515
|
try {
|
|
507
516
|
response.send(data);
|
|
508
517
|
} catch (e) {
|
|
509
|
-
console.log(
|
|
518
|
+
console.log(t_f$2("response.send 出错了,req.url: %s, response:", response.req.url), response);
|
|
510
519
|
console.log("异常信息", e);
|
|
511
520
|
}
|
|
512
521
|
}
|
|
@@ -553,7 +562,7 @@ class apiUtil$2 {
|
|
|
553
562
|
|
|
554
563
|
/**
|
|
555
564
|
* 从请求参数中获取查询参数
|
|
556
|
-
|
|
565
|
+
* @param req
|
|
557
566
|
* @param res
|
|
558
567
|
* @returns {*}
|
|
559
568
|
*/
|
|
@@ -983,7 +992,7 @@ class apiUtil$2 {
|
|
|
983
992
|
return certInfo;
|
|
984
993
|
}).catch(e => {
|
|
985
994
|
console.log('获取企业证书失败:\n', e);
|
|
986
|
-
throw [err$1.ACCESS_REFUSED,
|
|
995
|
+
throw [err$1.ACCESS_REFUSED, t_f$2("获取企业证书失败:%s", err$1.ERROR(e).message)];
|
|
987
996
|
});
|
|
988
997
|
}
|
|
989
998
|
|
|
@@ -996,17 +1005,17 @@ class apiUtil$2 {
|
|
|
996
1005
|
static async verifyApiSignature(tokenData, req) {
|
|
997
1006
|
try {
|
|
998
1007
|
if (!req.headers.timestamp) {
|
|
999
|
-
throw [err$1.ACCESS_REFUSED,
|
|
1008
|
+
throw [err$1.ACCESS_REFUSED, t_f$2("必须在请求头中设置时戳")];
|
|
1000
1009
|
}
|
|
1001
1010
|
let timestamp = parseInt(req.headers.timestamp);
|
|
1002
1011
|
let currentTime = new Date().valueOf();
|
|
1003
1012
|
let maxTimeDiff = apiUtil$2.isDebugMode(req) ? 7 * 24 * 3600 : apiUtil$2.isTestMode(req) ? 4 * 3600 : 100; // 100
|
|
1004
1013
|
if (timestamp.toString() == "NaN" || currentTime < timestamp - 5000 || currentTime - timestamp > maxTimeDiff * 1000) {
|
|
1005
|
-
throw [err$1.ACCESS_REFUSED,
|
|
1014
|
+
throw [err$1.ACCESS_REFUSED, t_f$2("时戳(%s)无效,当前时戳:%s,时差 %s秒", timestamp, currentTime, (currentTime - timestamp) / 1000)];
|
|
1006
1015
|
}
|
|
1007
1016
|
let signature = req.headers.signature;
|
|
1008
1017
|
if (!signature) {
|
|
1009
|
-
throw [err$1.ACCESS_REFUSED,
|
|
1018
|
+
throw [err$1.ACCESS_REFUSED, t_f$2("必须在请求头中提供签名")];
|
|
1010
1019
|
}
|
|
1011
1020
|
let signData = apiUtil$2.extractToken(req, null, true) || tokenData.apiKey;
|
|
1012
1021
|
signData += timestamp;
|
|
@@ -1053,7 +1062,7 @@ class apiUtil$2 {
|
|
|
1053
1062
|
if (!tokenData.certPublicKeySpare) {
|
|
1054
1063
|
throw {
|
|
1055
1064
|
eo: err$1.ACCESS_REFUSED,
|
|
1056
|
-
msgArgv: "签名验证异常",
|
|
1065
|
+
msgArgv: t("签名验证异常"),
|
|
1057
1066
|
data: e
|
|
1058
1067
|
};
|
|
1059
1068
|
}
|
|
@@ -1067,7 +1076,7 @@ class apiUtil$2 {
|
|
|
1067
1076
|
verifyOK = verifySpare.verify(tokenData.certPublicKeySpare, signature, 'base64');
|
|
1068
1077
|
if (verifyOK) {
|
|
1069
1078
|
// 备用证书验证成功了,则将备用证书替换为正式证书
|
|
1070
|
-
console.log(
|
|
1079
|
+
console.log(t_f$2("公司(%s)备用证书验签成功,正式启用...", tokenData.apiKey));
|
|
1071
1080
|
return dbUtil.dbTrans(trans => {
|
|
1072
1081
|
let p1 = dbUtil.dbExec(dbSql.deleteCertRecById, {
|
|
1073
1082
|
replacements: {
|
|
@@ -1091,21 +1100,21 @@ class apiUtil$2 {
|
|
|
1091
1100
|
if (token) {
|
|
1092
1101
|
apiUtil$2.storeToken(apiUtil$2.apiTokenStoreKey(token), tokenData, tokenData.apiKey, req);
|
|
1093
1102
|
}
|
|
1094
|
-
console.log(
|
|
1103
|
+
console.log(t_f$2("公司(%s)备用证书成功转换为正式证书", tokenData.apiKey));
|
|
1095
1104
|
});
|
|
1096
1105
|
}
|
|
1097
1106
|
} catch (e) {
|
|
1098
1107
|
console.log("SPO服务签名验证异常(备用证书), ", e);
|
|
1099
1108
|
throw {
|
|
1100
1109
|
eo: err$1.ACCESS_REFUSED,
|
|
1101
|
-
msgArgv: "签名验证异常(spare)",
|
|
1110
|
+
msgArgv: t("签名验证异常(spare)"),
|
|
1102
1111
|
data: e
|
|
1103
1112
|
};
|
|
1104
1113
|
}
|
|
1105
1114
|
}
|
|
1106
1115
|
if (!verifyOK) {
|
|
1107
1116
|
console.log("SPO服务签名验证失败, tokenData: ", tokenData);
|
|
1108
|
-
throw [err$1.ACCESS_REFUSED, "签名验证未通过"];
|
|
1117
|
+
throw [err$1.ACCESS_REFUSED, t("签名验证未通过")];
|
|
1109
1118
|
}
|
|
1110
1119
|
return verifyOK;
|
|
1111
1120
|
}
|
|
@@ -1121,7 +1130,7 @@ class apiUtil$2 {
|
|
|
1121
1130
|
if (!tokenData.companyInfo) {
|
|
1122
1131
|
tokenData.companyInfo = await apiUtil$2.queryCompanyInfo(tokenData.apiKey, true).catch(e => {
|
|
1123
1132
|
console.log("执行企业信息查询发生异常", e);
|
|
1124
|
-
throw [err$1.API_KEY_INVALID, "执行企业信息查询发生异常:" + e.message || ""];
|
|
1133
|
+
throw [err$1.API_KEY_INVALID, t("执行企业信息查询发生异常:") + e.message || ""];
|
|
1125
1134
|
});
|
|
1126
1135
|
}
|
|
1127
1136
|
const companyInfo = tokenData.companyInfo;
|
|
@@ -1179,7 +1188,7 @@ class apiUtil$2 {
|
|
|
1179
1188
|
break;
|
|
1180
1189
|
}
|
|
1181
1190
|
}
|
|
1182
|
-
paramName =
|
|
1191
|
+
paramName = t_f$2("%s 之一", paramName);
|
|
1183
1192
|
} else {
|
|
1184
1193
|
paramExists = typeof params[paramName] != 'undefined' || typeof params[paramName + paramSufix] != 'undefined';
|
|
1185
1194
|
}
|
|
@@ -1249,7 +1258,7 @@ class apiUtil$2 {
|
|
|
1249
1258
|
const myEnvHosts = apiUtil$2.getEnvHosts(params);
|
|
1250
1259
|
const myIp = ppUtil$3.getMyIp();
|
|
1251
1260
|
const host = params.host || myIp;
|
|
1252
|
-
if (!myEnvHosts.hosts.contains(host)) throw [err$1.ACCESS_REFUSED,
|
|
1261
|
+
if (!myEnvHosts.hosts.contains(host)) throw [err$1.ACCESS_REFUSED, t_f$2("环境%s貌似无此主机:%s", conf$2.envId, params.host)];
|
|
1253
1262
|
if (!apiUtil$2.hostIsMySelf(host, options._res.req)) {
|
|
1254
1263
|
let result = await apiUtil$2.forwardsTo(host, myEnvHosts.port, params, options._res.req, myIp);
|
|
1255
1264
|
options._res.send(result);
|
|
@@ -1279,7 +1288,7 @@ class apiUtil$2 {
|
|
|
1279
1288
|
};
|
|
1280
1289
|
let result = await netUtil$1.apiRequest(reqOptions);
|
|
1281
1290
|
if (result.status !== 200) {
|
|
1282
|
-
console.log(
|
|
1291
|
+
console.log(t_f$2("访问 %s 出错", reqOptions.url), result.status, result.res.statusMessage);
|
|
1283
1292
|
throw [err$1.EXCEPTION, `[${result.status}] - ${result.res.statusMessage}`];
|
|
1284
1293
|
}
|
|
1285
1294
|
return result.data;
|
|
@@ -1302,7 +1311,7 @@ class apiUtil$2 {
|
|
|
1302
1311
|
key = keys[i];
|
|
1303
1312
|
value = parent[key];
|
|
1304
1313
|
if (value === undefined) {
|
|
1305
|
-
throw [err$1.INVALID_PARAM,
|
|
1314
|
+
throw [err$1.INVALID_PARAM, t_f$2("无此配置项: %s", key)];
|
|
1306
1315
|
}
|
|
1307
1316
|
}
|
|
1308
1317
|
return {
|
|
@@ -1361,6 +1370,7 @@ class apiUtil$2 {
|
|
|
1361
1370
|
await apiUtil$2.restoreTokenData(apiUtil$2.userTokenStoreKey(req.accessToken), apiUtil$2.tokenExpireTime(req)).then(function (data) {
|
|
1362
1371
|
req.userInfo = apiUtil$2.setUserIdNo(data, data._idNo);
|
|
1363
1372
|
}, function (e) {
|
|
1373
|
+
|
|
1364
1374
|
//no token
|
|
1365
1375
|
});
|
|
1366
1376
|
}
|
|
@@ -1572,7 +1582,7 @@ class apiUtil$2 {
|
|
|
1572
1582
|
await apiUtil$2.parametersOK(params, "value");
|
|
1573
1583
|
let c = apiUtil$2.parseCfgPath(cfgItem);
|
|
1574
1584
|
if (typeof c.value === "object") {
|
|
1575
|
-
throw [err$1.ACCESS_REFUSED,
|
|
1585
|
+
throw [err$1.ACCESS_REFUSED, t_f$2("暂不支持修改复杂配置")];
|
|
1576
1586
|
}
|
|
1577
1587
|
// c.oldValue = c.value;
|
|
1578
1588
|
c.newValue = params.value;
|
|
@@ -1634,18 +1644,24 @@ function configNeeded() {
|
|
|
1634
1644
|
}
|
|
1635
1645
|
var ppUtilApi = apiUtil$2;
|
|
1636
1646
|
|
|
1637
|
-
// 普通消息系统
|
|
1638
|
-
// 若 redis 可用,则使用基于 redis 的消息订阅发布系统
|
|
1639
|
-
// 若 redis 不可用,则将消息转发到其它主机
|
|
1640
|
-
|
|
1641
1647
|
const {
|
|
1642
|
-
|
|
1648
|
+
t_f: t_f$1
|
|
1643
1649
|
} = require$$2__default["default"];
|
|
1644
|
-
const
|
|
1650
|
+
const {
|
|
1651
|
+
ppUtil: ppUtil$2
|
|
1652
|
+
} = require$$3__default["default"];
|
|
1653
|
+
const RedisMessenger = require$$2__default$2["default"];
|
|
1645
1654
|
const {
|
|
1646
1655
|
netUtil
|
|
1647
|
-
} = require$$
|
|
1656
|
+
} = require$$6__default["default"];
|
|
1648
1657
|
let conf$1;
|
|
1658
|
+
|
|
1659
|
+
/**
|
|
1660
|
+
* 普通消息系统
|
|
1661
|
+
* =
|
|
1662
|
+
* 若 redis 可用,则使用基于 redis 的消息订阅发布系统
|
|
1663
|
+
* 若 redis 不可用,则将消息转发到其它主机
|
|
1664
|
+
*/
|
|
1649
1665
|
class commonMessenger$2 {
|
|
1650
1666
|
static myMsgAddr = "";
|
|
1651
1667
|
static redisMessenger = null;
|
|
@@ -1712,26 +1728,30 @@ async function forwardMessage(message) {
|
|
|
1712
1728
|
data: message
|
|
1713
1729
|
};
|
|
1714
1730
|
let res = await netUtil.apiRequest(reqOptions).catch(e => {
|
|
1715
|
-
console.log(
|
|
1731
|
+
console.log(t_f$1("转发消息失败, url: %s", reqOptions.url), e);
|
|
1716
1732
|
throw e;
|
|
1717
1733
|
});
|
|
1718
1734
|
return res.data;
|
|
1719
1735
|
}
|
|
1720
1736
|
var ppMessengerEx = commonMessenger$2;
|
|
1721
1737
|
|
|
1722
|
-
/**
|
|
1723
|
-
* CSCA 自动任务
|
|
1724
|
-
* ==============
|
|
1725
|
-
*/
|
|
1726
1738
|
const CRON = require$$0__default$1["default"];
|
|
1727
1739
|
const {
|
|
1728
|
-
|
|
1740
|
+
t_f
|
|
1729
1741
|
} = require$$2__default["default"];
|
|
1742
|
+
const {
|
|
1743
|
+
ppUtil: ppUtil$1
|
|
1744
|
+
} = require$$3__default["default"];
|
|
1730
1745
|
const apiUtil$1 = ppUtilApi;
|
|
1731
1746
|
const commonMessenger$1 = ppMessengerEx;
|
|
1732
1747
|
const MT_SCHEDULE_STATE = 'schedule-state',
|
|
1733
1748
|
MT_SCHEDULE_STATE_REPLY = 'schedule-state-reply';
|
|
1734
1749
|
let conf, err;
|
|
1750
|
+
|
|
1751
|
+
/**
|
|
1752
|
+
* CSCA 自动任务
|
|
1753
|
+
* ==============
|
|
1754
|
+
*/
|
|
1735
1755
|
class schedule$1 {
|
|
1736
1756
|
static tasks = {};
|
|
1737
1757
|
|
|
@@ -1763,9 +1783,9 @@ class schedule$1 {
|
|
|
1763
1783
|
doScheduleTask: async function () {
|
|
1764
1784
|
let self = this;
|
|
1765
1785
|
if (this._pp_task) self = this._pp_task;
|
|
1766
|
-
console.log(new Date().format('[yyyy/MM/dd hh:mm:ss:S]'),
|
|
1786
|
+
console.log(new Date().format('[yyyy/MM/dd hh:mm:ss:S]'), t_f("开始执行%s任务 ...", self.caption));
|
|
1767
1787
|
await self.taskFunc();
|
|
1768
|
-
console.log(new Date().format('[yyyy/MM/dd hh:mm:ss:S]'),
|
|
1788
|
+
console.log(new Date().format('[yyyy/MM/dd hh:mm:ss:S]'), t_f("%s任务执行结束", self.caption));
|
|
1769
1789
|
}
|
|
1770
1790
|
};
|
|
1771
1791
|
this.tasks[taskName] = task;
|
|
@@ -1799,7 +1819,7 @@ class schedule$1 {
|
|
|
1799
1819
|
if (typeof task === "string") {
|
|
1800
1820
|
task = this.findTask(taskOrName);
|
|
1801
1821
|
}
|
|
1802
|
-
if (!task) throw [err.INVALID_PARAM,
|
|
1822
|
+
if (!task) throw [err.INVALID_PARAM, t_f("任务%s不存在", taskOrName)];
|
|
1803
1823
|
cronExp = cronExp || task.cronExp;
|
|
1804
1824
|
if (task.cronExp !== cronExp) {
|
|
1805
1825
|
this.stop(task);
|
|
@@ -1824,7 +1844,7 @@ class schedule$1 {
|
|
|
1824
1844
|
if (typeof task === "string") {
|
|
1825
1845
|
task = this.findTask(taskOrName);
|
|
1826
1846
|
}
|
|
1827
|
-
if (!task) throw [err.INVALID_PARAM,
|
|
1847
|
+
if (!task) throw [err.INVALID_PARAM, t_f("任务%s不存在", taskOrName)];
|
|
1828
1848
|
if (task.schedule) {
|
|
1829
1849
|
task.schedule.stop();
|
|
1830
1850
|
task.schedule = null;
|
|
@@ -1901,7 +1921,7 @@ class schedule$1 {
|
|
|
1901
1921
|
let task;
|
|
1902
1922
|
if (params.taskName) {
|
|
1903
1923
|
task = this.findTask(params.taskName);
|
|
1904
|
-
if (!task) throw [err.INVALID_PARAM,
|
|
1924
|
+
if (!task) throw [err.INVALID_PARAM, t_f("任务%s不存在", params.taskName)];
|
|
1905
1925
|
}
|
|
1906
1926
|
if (params.state) {
|
|
1907
1927
|
if ("started" === params.state) {
|
|
@@ -1909,7 +1929,7 @@ class schedule$1 {
|
|
|
1909
1929
|
} else if ("stopped" === params.state) {
|
|
1910
1930
|
apiResult = await this.stop(task);
|
|
1911
1931
|
} else {
|
|
1912
|
-
throw [err.INVALID_PARAM,
|
|
1932
|
+
throw [err.INVALID_PARAM, t_f("(%s), 只能是 started/stopped", params.state)];
|
|
1913
1933
|
}
|
|
1914
1934
|
if (params.runOnce) {
|
|
1915
1935
|
task = this.findTask(params.taskName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abler-api",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.74",
|
|
4
4
|
"description": "API服务相关工具",
|
|
5
5
|
"main": "./dist/cjs/pp-util.js",
|
|
6
6
|
"-module": "./dist/es/pp-util.js",
|
|
@@ -17,8 +17,11 @@
|
|
|
17
17
|
"q": "^1.5.1",
|
|
18
18
|
"abler-util": ">=0.1.1",
|
|
19
19
|
"abler-db": ">=0.1.1",
|
|
20
|
+
"abler-lang": "^0.1.20",
|
|
20
21
|
"abler-messenger": ">=0.1.1",
|
|
21
|
-
"abler-net": ">=0.1.1"
|
|
22
|
+
"abler-net": ">=0.1.1",
|
|
23
|
+
"basic-auth": "^2.0.1",
|
|
24
|
+
"node-cron": "^3.0.1"
|
|
22
25
|
},
|
|
23
26
|
"devDependencies": {
|
|
24
27
|
"@babel/core": "^7.18.5",
|