vap1 0.4.4 → 0.4.7
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/basetype.d.ts +4 -0
- package/components/Box/Box.d.ts +2 -2
- package/components/Box/Box.js +1 -1
- package/components/Box/index.d.ts +1 -1
- package/components/Lists/SList.d.ts +1 -1
- package/components/Lists/SList.js +3 -2
- package/components/{SearchBar → SearchTool/SearchBar}/ActionButtons.d.ts +2 -2
- package/components/{SearchBar → SearchTool/SearchBar}/ActionButtons.js +5 -5
- package/components/{SearchBar → SearchTool/SearchBar}/ByField.js +4 -4
- package/components/{SearchBar → SearchTool/SearchBar}/ByKeyword.js +3 -3
- package/components/{SearchBar → SearchTool/SearchBar}/SearchField.d.ts +1 -1
- package/components/{SearchBar → SearchTool/SearchBar}/SearchTags.js +1 -1
- package/components/{SearchBar → SearchTool/SearchBar}/_register.d.ts +1 -1
- package/components/{SearchBar → SearchTool/SearchBar}/_register.js +3 -3
- package/components/SearchTool/SearchBar/index.d.ts +71 -0
- package/components/{SearchBar → SearchTool/SearchBar}/index.js +1 -1
- package/components/{SearchBar → SearchTool}/index.d.ts +1 -70
- package/components/SearchTool/index.js +2 -0
- package/components/Tables/ApiTable.d.ts +1 -1
- package/components/Tables/ApiTableModal.d.ts +1 -1
- package/components/Tables/Components/ActionBar.d.ts +1 -1
- package/components/Tables/Components/ActionBar.js +1 -1
- package/components/Tables/STable.d.ts +1 -1
- package/components/Tables/TopTable.js +0 -1
- package/components/Tables/VTable.d.ts +4 -2
- package/components/Tables/index.d.ts +1 -1
- package/components/TreeSelect/STreeSelect.js +1 -1
- package/components/Trees/ActionTree.d.ts +4 -1
- package/components/Trees/BaseTree.d.ts +1 -0
- package/components/Trees/BaseTree.js +11 -2
- package/components/Trees/DTree.d.ts +1 -0
- package/components/Trees/FTree.d.ts +1 -0
- package/components/Trees/index.d.ts +4 -0
- package/components/UForm/_FieldType.d.ts +1 -1
- package/components/UForm/_FieldType.js +4 -0
- package/components/UForm/_input.d.ts +1 -1
- package/components/UForm/_register.d.ts +1 -1
- package/components/_adapt/Col.d.ts +1 -1
- package/components/_common/HighLight.js +1 -1
- package/components/_common/UTitle.d.ts +1 -1
- package/components/_common/UTitle.js +1 -1
- package/components/index.d.ts +2 -2
- package/components/index.js +1 -1
- package/deps/app-data/Const.d.ts +68 -3
- package/deps/app-data/Const.js +47 -3
- package/deps/app-data/TimeConst.d.ts +0 -0
- package/deps/app-data/TimeConst.js +58 -0
- package/deps/app-data/useSource.d.ts +22 -0
- package/deps/app-data/useSource.js +243 -162
- package/hooks/useApiGlobal.js +1 -1
- package/hooks/useEffectFunction.d.ts +4 -2
- package/hooks/useGetSet.d.ts +1 -1
- package/hooks/useGlobal.d.ts +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/screen/Page.js +3 -3
- package/utils/Ajax.js +12 -9
- package/utils/CustomApp.d.ts +2 -2
- package/utils/Format.js +5 -10
- package/utils/Global.d.ts +39 -2
- package/utils/Global.js +18 -1
- package/utils/Renders/ApiGetRender.js +5 -2
- package/utils/Renders/DictRender.d.ts +2 -5
- package/utils/Renders/DictRender.js +14 -8
- package/utils/StringUtil.d.ts +4 -2
- package/utils/StringUtil.js +12 -3
- package/utils/TreeUtil.js +7 -8
- package/utils/VAP.js +0 -1
- package/utils/_Support.d.ts +1 -7
- package/utils/_Support.js +1 -67
- package/utils/crontab/_en.d.ts +2 -0
- package/utils/crontab/_en.js +178 -0
- package/utils/crontab/_global.d.ts +11 -0
- package/utils/crontab/_global.js +23 -0
- package/utils/crontab/_zh_CN.d.ts +2 -0
- package/utils/crontab/_zh_CN.js +180 -0
- package/utils/crontab/_zh_TW.d.ts +2 -0
- package/utils/crontab/_zh_TW.js +170 -0
- package/utils/crontab/crontabParser.d.ts +1 -0
- package/utils/crontab/crontabParser.js +251 -0
- package/utils/crontab/crontabRender.d.ts +23 -0
- package/utils/crontab/crontabRender.js +503 -0
- package/utils/crontab/index.d.ts +3 -0
- package/utils/crontab/index.js +9 -0
- package/utils/crontab/type.d.ts +79 -0
- package/utils/crontab/type.js +2 -0
- package/utils/crontab/utils.d.ts +20 -0
- package/utils/crontab/utils.js +122 -0
- package/utils/py.d.ts +19 -0
- package/utils/py.js +176 -0
- /package/components/{SearchBar → SearchTool/SearchBar}/ByField.d.ts +0 -0
- /package/components/{SearchBar → SearchTool/SearchBar}/ByKeyword.d.ts +0 -0
- /package/components/{SearchBar → SearchTool/SearchBar}/SearchField.js +0 -0
- /package/components/{SearchBar → SearchTool/SearchBar}/SearchTags.d.ts +0 -0
- /package/components/{SearchBar → SearchTool}/_FieldType.d.ts +0 -0
- /package/components/{SearchBar → SearchTool}/_FieldType.js +0 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.crontabParser = void 0;
|
|
4
|
+
var utils_1 = require("./utils");
|
|
5
|
+
var _global_1 = require("./_global");
|
|
6
|
+
var parseSpecial = function (expression) {
|
|
7
|
+
var specialExpressions = {
|
|
8
|
+
'@yearly': '0 0 1 1 *',
|
|
9
|
+
'@annually': '0 0 1 1 *',
|
|
10
|
+
'@monthly': '0 0 1 * *',
|
|
11
|
+
'@weekly': '0 0 * * 0',
|
|
12
|
+
'@daily': '0 0 * * *',
|
|
13
|
+
'@midnight': '0 0 * * *',
|
|
14
|
+
'@hourly': '0 * * * *'
|
|
15
|
+
};
|
|
16
|
+
var special = specialExpressions[expression];
|
|
17
|
+
if (!special) {
|
|
18
|
+
throw new Error('未知的特殊表达式');
|
|
19
|
+
}
|
|
20
|
+
return special;
|
|
21
|
+
};
|
|
22
|
+
var extractParts = function (expression) {
|
|
23
|
+
// if (!this.expression) {
|
|
24
|
+
// throw new Error("cron expression is empty");
|
|
25
|
+
// }
|
|
26
|
+
// split on one or more spaces
|
|
27
|
+
var parsed = expression.trim().split(/[ ]+/);
|
|
28
|
+
// sort elements with array of numbers
|
|
29
|
+
for (var i = 0; i < parsed.length; i++) {
|
|
30
|
+
if (parsed[i].includes(",")) {
|
|
31
|
+
var arrayElement = parsed[i]
|
|
32
|
+
.split(",")
|
|
33
|
+
.map(function (item) { return item.trim(); })
|
|
34
|
+
.filter(function (item) { return item !== ""; })
|
|
35
|
+
.map(function (item) { return (!isNaN(Number(item)) ? Number(item) : item); })
|
|
36
|
+
.filter(function (item) { return item !== null && item !== ""; });
|
|
37
|
+
if (arrayElement.length === 0) {
|
|
38
|
+
arrayElement.push("*");
|
|
39
|
+
}
|
|
40
|
+
arrayElement.sort(function (a, b) { return (a !== null && b !== null ? a - b : 0); });
|
|
41
|
+
parsed[i] = arrayElement.map(function (item) { return (item !== null ? item.toString() : ""); }).join(",");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (parsed.length < 5) {
|
|
45
|
+
throw new Error("\u8868\u8FBE\u5F0F\u81F3\u5C11\u9700\u8981\u75315\u4E2A\u90E8\u5206\u7EC4\u6210");
|
|
46
|
+
}
|
|
47
|
+
else if (parsed.length == 5) {
|
|
48
|
+
// 5 part cron so shift array past seconds element
|
|
49
|
+
parsed.unshift("");
|
|
50
|
+
parsed.push("");
|
|
51
|
+
}
|
|
52
|
+
else if (parsed.length == 6) {
|
|
53
|
+
/* We will detect if this 6 part expression has a year specified and if so we will shift the parts and treat the
|
|
54
|
+
first part as a minute part rather than a second part.
|
|
55
|
+
|
|
56
|
+
Ways we detect:
|
|
57
|
+
1. Last part is a literal year (i.e. 2020)
|
|
58
|
+
2. 3rd or 5th part is specified as "?" (DOM or DOW)
|
|
59
|
+
*/
|
|
60
|
+
var isYearWithNoSecondsPart = /\d{4}$/.test(parsed[5]) || parsed[4] == "?" || parsed[2] == "?";
|
|
61
|
+
if (isYearWithNoSecondsPart) {
|
|
62
|
+
// year provided; shift parts over by one
|
|
63
|
+
parsed.unshift("");
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// seconds provided
|
|
67
|
+
parsed.push("");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (parsed.length > 7) {
|
|
71
|
+
throw new Error("\u8868\u8FBE\u5F0F\u6700\u591A\u53EA\u80FD\u75317\u4E2A\u90E8\u5206\u7EC4\u6210");
|
|
72
|
+
}
|
|
73
|
+
return parsed;
|
|
74
|
+
};
|
|
75
|
+
var normalize = function (expressionParts) {
|
|
76
|
+
// Convert ? to * for DOM and DOW
|
|
77
|
+
expressionParts[3] = expressionParts[3].replace("?", "*");
|
|
78
|
+
expressionParts[5] = expressionParts[5].replace("?", "*");
|
|
79
|
+
// Convert ? to * for Hour. ? isn't valid for hour position but we can work around it.
|
|
80
|
+
expressionParts[2] = expressionParts[2].replace("?", "*");
|
|
81
|
+
// Convert 0/, 1/ to */
|
|
82
|
+
if (expressionParts[0].indexOf("0/") == 0) {
|
|
83
|
+
// Seconds
|
|
84
|
+
expressionParts[0] = expressionParts[0].replace("0/", "*/");
|
|
85
|
+
}
|
|
86
|
+
if (expressionParts[1].indexOf("0/") == 0) {
|
|
87
|
+
// Minutes
|
|
88
|
+
expressionParts[1] = expressionParts[1].replace("0/", "*/");
|
|
89
|
+
}
|
|
90
|
+
if (expressionParts[2].indexOf("0/") == 0) {
|
|
91
|
+
// Hours
|
|
92
|
+
expressionParts[2] = expressionParts[2].replace("0/", "*/");
|
|
93
|
+
}
|
|
94
|
+
if (expressionParts[3].indexOf("1/") == 0) {
|
|
95
|
+
// DOM
|
|
96
|
+
expressionParts[3] = expressionParts[3].replace("1/", "*/");
|
|
97
|
+
}
|
|
98
|
+
if (expressionParts[4].indexOf("1/") == 0) {
|
|
99
|
+
// Month
|
|
100
|
+
expressionParts[4] = expressionParts[4].replace("1/", "*/");
|
|
101
|
+
}
|
|
102
|
+
if (expressionParts[6].indexOf("1/") == 0) {
|
|
103
|
+
// Years
|
|
104
|
+
expressionParts[6] = expressionParts[6].replace("1/", "*/");
|
|
105
|
+
}
|
|
106
|
+
// Adjust DOW based on dayOfWeekStartIndexZero option
|
|
107
|
+
// Normalized DOW: 0=Sunday/6=Saturday
|
|
108
|
+
expressionParts[5] = expressionParts[5].replace(/(^\d)|([^#/\s]\d)/g, function (t) {
|
|
109
|
+
// skip anything preceeded by # or /
|
|
110
|
+
var dowDigits = t.replace(/\D/, ""); // extract digit part (i.e. if "-2" or ",2", just take 2)
|
|
111
|
+
var dowDigitsAdjusted = dowDigits;
|
|
112
|
+
if (_global_1.dayOfWeekStartIndexZero) {
|
|
113
|
+
// "7" also means Sunday so we will convert to "0" to normalize it
|
|
114
|
+
if (dowDigits == "7") {
|
|
115
|
+
dowDigitsAdjusted = "0";
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
// If dayOfWeekStartIndexZero==false, Sunday is specified as 1 and Saturday is specified as 7.
|
|
120
|
+
// To normalize, we will shift the DOW number down so that 1 becomes 0, 2 becomes 1, and so on.
|
|
121
|
+
dowDigitsAdjusted = (parseInt(dowDigits) - 1).toString();
|
|
122
|
+
}
|
|
123
|
+
return t.replace(dowDigits, dowDigitsAdjusted);
|
|
124
|
+
});
|
|
125
|
+
// Convert DOW 'L' to '6' (Saturday)
|
|
126
|
+
if (expressionParts[5] == "L") {
|
|
127
|
+
expressionParts[5] = "6";
|
|
128
|
+
}
|
|
129
|
+
// Convert DOM '?' to '*'
|
|
130
|
+
if (expressionParts[3] == "?") {
|
|
131
|
+
expressionParts[3] = "*";
|
|
132
|
+
}
|
|
133
|
+
if (expressionParts[3].indexOf("W") > -1 &&
|
|
134
|
+
(expressionParts[3].indexOf(",") > -1 || expressionParts[3].indexOf("-") > -1)) {
|
|
135
|
+
throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");
|
|
136
|
+
}
|
|
137
|
+
// Convert DOW SUN-SAT format to 0-6 format
|
|
138
|
+
var days = {
|
|
139
|
+
SUN: 0,
|
|
140
|
+
MON: 1,
|
|
141
|
+
TUE: 2,
|
|
142
|
+
WED: 3,
|
|
143
|
+
THU: 4,
|
|
144
|
+
FRI: 5,
|
|
145
|
+
SAT: 6,
|
|
146
|
+
};
|
|
147
|
+
for (var day in days) {
|
|
148
|
+
expressionParts[5] = expressionParts[5].replace(new RegExp(day, "gi"), days[day].toString());
|
|
149
|
+
}
|
|
150
|
+
// Adjust month based on monthStartIndexZero option
|
|
151
|
+
// Normalized Month: 1=JAN/12=DEC
|
|
152
|
+
expressionParts[4] = expressionParts[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g, function (t) {
|
|
153
|
+
// skip anything preceeded by # or /
|
|
154
|
+
var dowDigits = t.replace(/\D/, ""); // extract digit part (i.e. if "-2" or ",2", just take 2)
|
|
155
|
+
var dowDigitsAdjusted = dowDigits;
|
|
156
|
+
if (_global_1.monthStartIndexZero) {
|
|
157
|
+
// if monthStartIndexZero==true, we will shift month number up so that JAN=1 and DEC=12
|
|
158
|
+
dowDigitsAdjusted = (parseInt(dowDigits) + 1).toString();
|
|
159
|
+
}
|
|
160
|
+
return t.replace(dowDigits, dowDigitsAdjusted);
|
|
161
|
+
});
|
|
162
|
+
// Convert JAN-DEC format to 1-12 format
|
|
163
|
+
var months = {
|
|
164
|
+
JAN: 1,
|
|
165
|
+
FEB: 2,
|
|
166
|
+
MAR: 3,
|
|
167
|
+
APR: 4,
|
|
168
|
+
MAY: 5,
|
|
169
|
+
JUN: 6,
|
|
170
|
+
JUL: 7,
|
|
171
|
+
AUG: 8,
|
|
172
|
+
SEP: 9,
|
|
173
|
+
OCT: 10,
|
|
174
|
+
NOV: 11,
|
|
175
|
+
DEC: 12,
|
|
176
|
+
};
|
|
177
|
+
for (var month in months) {
|
|
178
|
+
expressionParts[4] = expressionParts[4].replace(new RegExp(month, "gi"), months[month].toString());
|
|
179
|
+
}
|
|
180
|
+
// Convert 0 second to (empty)
|
|
181
|
+
if (expressionParts[0] == "0") {
|
|
182
|
+
expressionParts[0] = "";
|
|
183
|
+
}
|
|
184
|
+
// If time increment or * (every) is specified for seconds or minutes and hours part is single item, make it a "self-range" so
|
|
185
|
+
// the expression can be interpreted as an increment / range. This will allow us to easily interpret an hour part as 'between' a second or minute duration.
|
|
186
|
+
// For example:
|
|
187
|
+
// 0-20/3 9 * * * => 0-20/3 9-9 * * * (9 => 9-9) => Every 3 minutes, minutes 0 through 20 past the hour, between 09:00 AM and 09:59 AM
|
|
188
|
+
// */5 3 * * * => */5 3-3 * * * (3 => 3-3) => Every 5 minutes, between 03:00 AM and 03:59 AM
|
|
189
|
+
if (!/\*|\-|\,|\//.test(expressionParts[2]) &&
|
|
190
|
+
(/\*|\//.test(expressionParts[1]) || /\*|\//.test(expressionParts[0]))) {
|
|
191
|
+
expressionParts[2] += "-".concat(expressionParts[2]);
|
|
192
|
+
}
|
|
193
|
+
// Loop through all parts and apply global normalization
|
|
194
|
+
for (var i = 0; i < expressionParts.length; i++) {
|
|
195
|
+
// ignore empty characters around comma
|
|
196
|
+
// if nothing left, set it to *
|
|
197
|
+
if (expressionParts[i].indexOf(",") != -1) {
|
|
198
|
+
expressionParts[i] =
|
|
199
|
+
expressionParts[i]
|
|
200
|
+
.split(",")
|
|
201
|
+
.filter(function (str) { return str !== ""; })
|
|
202
|
+
.join(",") || "*";
|
|
203
|
+
}
|
|
204
|
+
// convert all '*/1' to '*'
|
|
205
|
+
if (expressionParts[i] == "*/1") {
|
|
206
|
+
expressionParts[i] = "*";
|
|
207
|
+
}
|
|
208
|
+
/* Convert Month,DOW,Year step values with a starting value (i.e. not '*') to range expressions.
|
|
209
|
+
This allows us to reuse the range expression handling for step values.
|
|
210
|
+
|
|
211
|
+
For example:
|
|
212
|
+
- month part '3/2' will be converted to '3-12/2' (every 2 months between March and December)
|
|
213
|
+
- DOW part '3/2' will be converted to '3-6/2' (every 2 days between Tuesday and Saturday)
|
|
214
|
+
*/
|
|
215
|
+
if (expressionParts[i].indexOf("/") > -1 && !/^\*|\-|\,/.test(expressionParts[i])) {
|
|
216
|
+
var stepRangeThrough = null;
|
|
217
|
+
switch (i) {
|
|
218
|
+
case 4:
|
|
219
|
+
stepRangeThrough = "12";
|
|
220
|
+
break;
|
|
221
|
+
case 5:
|
|
222
|
+
stepRangeThrough = "6";
|
|
223
|
+
break;
|
|
224
|
+
case 6:
|
|
225
|
+
stepRangeThrough = "9999";
|
|
226
|
+
break;
|
|
227
|
+
default:
|
|
228
|
+
stepRangeThrough = null;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
if (stepRangeThrough !== null) {
|
|
232
|
+
var parts = expressionParts[i].split("/");
|
|
233
|
+
expressionParts[i] = "".concat(parts[0], "-").concat(stepRangeThrough, "/").concat(parts[1]);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
var crontabParser = function (expression) {
|
|
239
|
+
var parsed;
|
|
240
|
+
if (expression.startsWith('@')) {
|
|
241
|
+
var special = parseSpecial(expression);
|
|
242
|
+
parsed = extractParts(special);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
parsed = extractParts(expression);
|
|
246
|
+
}
|
|
247
|
+
normalize(parsed);
|
|
248
|
+
(0, utils_1.validate)(parsed);
|
|
249
|
+
return parsed;
|
|
250
|
+
};
|
|
251
|
+
exports.crontabParser = crontabParser;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Options } from "./type";
|
|
2
|
+
export declare const crontabRender: (expression: string, options?: Options) => string;
|
|
3
|
+
export declare class ExpressionDescriptor {
|
|
4
|
+
specialCharacters: string[];
|
|
5
|
+
expression: string;
|
|
6
|
+
expressionParts: string[];
|
|
7
|
+
options: Options;
|
|
8
|
+
constructor(expression: string, options: Options);
|
|
9
|
+
getFullDescription(): string;
|
|
10
|
+
protected getTimeOfDayDescription(): string;
|
|
11
|
+
protected getSecondsDescription(): string;
|
|
12
|
+
protected getMinutesDescription(): string;
|
|
13
|
+
protected getHoursDescription(): string;
|
|
14
|
+
protected getDayOfWeekDescription(): string;
|
|
15
|
+
protected getMonthDescription(): string;
|
|
16
|
+
protected getDayOfMonthDescription(): string | null;
|
|
17
|
+
protected getYearDescription(): string;
|
|
18
|
+
protected getSegmentDescription(expression: string, allDescription: string, getSingleItemDescription: (t: string, form?: number) => string, getIncrementDescriptionFormat: (t: string) => string, getRangeDescriptionFormat: (t: string) => string, getDescriptionFormat: (t: string) => string): string | null;
|
|
19
|
+
protected generateRangeSegmentDescription(rangeExpression: string, getRangeDescriptionFormat: (t: string) => string, getSingleItemDescription: (t: string, form?: number) => string): string;
|
|
20
|
+
protected formatTime(hourExpression: string, minuteExpression: string, secondExpression: string): string;
|
|
21
|
+
protected transformVerbosity(description: string, useVerboseFormat: boolean): string;
|
|
22
|
+
private getPeriod;
|
|
23
|
+
}
|