vap1 0.4.5 → 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.
Files changed (72) hide show
  1. package/basetype.d.ts +4 -0
  2. package/components/Box/Box.d.ts +2 -2
  3. package/components/Box/Box.js +1 -1
  4. package/components/{SearchBar → SearchTool/SearchBar}/ActionButtons.d.ts +2 -2
  5. package/components/{SearchBar → SearchTool/SearchBar}/ActionButtons.js +5 -5
  6. package/components/{SearchBar → SearchTool/SearchBar}/ByField.js +4 -4
  7. package/components/{SearchBar → SearchTool/SearchBar}/ByKeyword.js +3 -3
  8. package/components/{SearchBar → SearchTool/SearchBar}/SearchField.d.ts +1 -1
  9. package/components/{SearchBar → SearchTool/SearchBar}/SearchTags.js +1 -1
  10. package/components/{SearchBar → SearchTool/SearchBar}/_register.d.ts +1 -1
  11. package/components/{SearchBar → SearchTool/SearchBar}/_register.js +3 -3
  12. package/components/SearchTool/SearchBar/index.d.ts +71 -0
  13. package/components/{SearchBar → SearchTool/SearchBar}/index.js +1 -1
  14. package/components/{SearchBar → SearchTool}/index.d.ts +1 -70
  15. package/components/SearchTool/index.js +2 -0
  16. package/components/Tables/ApiTable.d.ts +1 -1
  17. package/components/Tables/ApiTableModal.d.ts +1 -1
  18. package/components/Tables/Components/ActionBar.d.ts +1 -1
  19. package/components/Tables/Components/ActionBar.js +1 -1
  20. package/components/Tables/VTable.d.ts +4 -2
  21. package/components/Tables/index.d.ts +1 -1
  22. package/components/TreeSelect/STreeSelect.js +1 -1
  23. package/components/UForm/_FieldType.d.ts +1 -1
  24. package/components/UForm/_FieldType.js +4 -0
  25. package/components/UForm/_input.d.ts +1 -1
  26. package/components/_adapt/Col.d.ts +1 -1
  27. package/components/_common/UTitle.d.ts +1 -1
  28. package/components/_common/UTitle.js +1 -1
  29. package/components/index.d.ts +2 -2
  30. package/components/index.js +1 -1
  31. package/deps/app-data/Const.d.ts +68 -3
  32. package/deps/app-data/Const.js +47 -3
  33. package/deps/app-data/TimeConst.d.ts +0 -0
  34. package/deps/app-data/TimeConst.js +58 -0
  35. package/deps/app-data/useSource.d.ts +22 -0
  36. package/deps/app-data/useSource.js +243 -162
  37. package/index.d.ts +1 -1
  38. package/index.js +1 -1
  39. package/package.json +1 -1
  40. package/utils/Ajax.js +12 -9
  41. package/utils/Format.js +5 -10
  42. package/utils/Global.d.ts +34 -2
  43. package/utils/Global.js +17 -1
  44. package/utils/Renders/ApiGetRender.js +5 -2
  45. package/utils/TreeUtil.js +2 -4
  46. package/utils/VAP.js +0 -1
  47. package/utils/_Support.d.ts +1 -1
  48. package/utils/crontab/_en.d.ts +2 -0
  49. package/utils/crontab/_en.js +178 -0
  50. package/utils/crontab/_global.d.ts +11 -0
  51. package/utils/crontab/_global.js +23 -0
  52. package/utils/crontab/_zh_CN.d.ts +2 -0
  53. package/utils/crontab/_zh_CN.js +180 -0
  54. package/utils/crontab/_zh_TW.d.ts +2 -0
  55. package/utils/crontab/_zh_TW.js +170 -0
  56. package/utils/crontab/crontabParser.d.ts +1 -0
  57. package/utils/crontab/crontabParser.js +251 -0
  58. package/utils/crontab/crontabRender.d.ts +23 -0
  59. package/utils/crontab/crontabRender.js +503 -0
  60. package/utils/crontab/index.d.ts +3 -0
  61. package/utils/crontab/index.js +9 -0
  62. package/utils/crontab/type.d.ts +79 -0
  63. package/utils/crontab/type.js +2 -0
  64. package/utils/crontab/utils.d.ts +20 -0
  65. package/utils/crontab/utils.js +122 -0
  66. package/utils/py.js +2 -0
  67. /package/components/{SearchBar → SearchTool/SearchBar}/ByField.d.ts +0 -0
  68. /package/components/{SearchBar → SearchTool/SearchBar}/ByKeyword.d.ts +0 -0
  69. /package/components/{SearchBar → SearchTool/SearchBar}/SearchField.js +0 -0
  70. /package/components/{SearchBar → SearchTool/SearchBar}/SearchTags.d.ts +0 -0
  71. /package/components/{SearchBar → SearchTool}/_FieldType.d.ts +0 -0
  72. /package/components/{SearchBar → SearchTool}/_FieldType.js +0 -0
@@ -0,0 +1,503 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ExpressionDescriptor = exports.crontabRender = void 0;
7
+ var utils_1 = require("./utils");
8
+ var lodash_1 = __importDefault(require("lodash"));
9
+ var crontabParser_1 = require("./crontabParser");
10
+ var _global_1 = require("./_global");
11
+ var crontabRender = function (expression, options) {
12
+ var option = lodash_1.default.assign({}, _global_1.DEFAULT_OPTION, options);
13
+ var descripter = new ExpressionDescriptor(expression, option);
14
+ // console.log(option)
15
+ return descripter.getFullDescription();
16
+ };
17
+ exports.crontabRender = crontabRender;
18
+ var ExpressionDescriptor = /** @class */ (function () {
19
+ function ExpressionDescriptor(expression, options) {
20
+ this.expression = expression;
21
+ this.options = options;
22
+ this.expressionParts = new Array(5);
23
+ if (options.use24HourTimeFormat === undefined) {
24
+ // if use24HourTimeFormat not specified, set based on locale default
25
+ options.use24HourTimeFormat = _global_1.i18n.use24HourTimeFormatByDefault();
26
+ }
27
+ }
28
+ ExpressionDescriptor.prototype.getFullDescription = function () {
29
+ var description = "";
30
+ try {
31
+ this.expressionParts = (0, crontabParser_1.crontabParser)(this.expression);
32
+ var timeSegment = this.getTimeOfDayDescription();
33
+ var dayOfMonthDesc = this.getDayOfMonthDescription();
34
+ var monthDesc = this.getMonthDescription();
35
+ var dayOfWeekDesc = this.getDayOfWeekDescription();
36
+ var yearDesc = this.getYearDescription();
37
+ description += timeSegment + dayOfMonthDesc + dayOfWeekDesc + monthDesc + yearDesc;
38
+ description = this.transformVerbosity(description, !!this.options.verbose);
39
+ // uppercase first character
40
+ description = description.charAt(0).toLocaleUpperCase() + description.substr(1);
41
+ }
42
+ catch (ex) {
43
+ if (!this.options.throwExceptionOnParseError) {
44
+ description = _global_1.i18n.anErrorOccuredWhenGeneratingTheExpressionD();
45
+ }
46
+ else {
47
+ throw "".concat(ex);
48
+ }
49
+ }
50
+ return description;
51
+ };
52
+ ExpressionDescriptor.prototype.getTimeOfDayDescription = function () {
53
+ var secondsExpression = this.expressionParts[0];
54
+ var minuteExpression = this.expressionParts[1];
55
+ var hourExpression = this.expressionParts[2];
56
+ var description = "";
57
+ if (!(0, utils_1.containsAny)(minuteExpression, _global_1.specialCharacters) &&
58
+ !(0, utils_1.containsAny)(hourExpression, _global_1.specialCharacters) &&
59
+ !(0, utils_1.containsAny)(secondsExpression, _global_1.specialCharacters)) {
60
+ // specific time of day (i.e. 10 14)
61
+ description += _global_1.i18n.atSpace() + this.formatTime(hourExpression, minuteExpression, secondsExpression);
62
+ }
63
+ else if (!secondsExpression &&
64
+ minuteExpression.indexOf("-") > -1 &&
65
+ !(minuteExpression.indexOf(",") > -1) &&
66
+ !(minuteExpression.indexOf("/") > -1) &&
67
+ !(0, utils_1.containsAny)(hourExpression, _global_1.specialCharacters)) {
68
+ // minute range in single hour (i.e. 0-10 11)
69
+ var minuteParts = minuteExpression.split("-");
70
+ description += (0, utils_1.format)(_global_1.i18n.everyMinuteBetweenX0AndX1(), this.formatTime(hourExpression, minuteParts[0], ""), this.formatTime(hourExpression, minuteParts[1], ""));
71
+ }
72
+ else if (!secondsExpression &&
73
+ hourExpression.indexOf(",") > -1 &&
74
+ hourExpression.indexOf("-") == -1 &&
75
+ hourExpression.indexOf("/") == -1 &&
76
+ !(0, utils_1.containsAny)(minuteExpression, _global_1.specialCharacters)) {
77
+ // hours list with single minute (i.e. 30 6,14,16)
78
+ var hourParts = hourExpression.split(",");
79
+ description += _global_1.i18n.at();
80
+ for (var i = 0; i < hourParts.length; i++) {
81
+ description += " ";
82
+ description += this.formatTime(hourParts[i], minuteExpression, "");
83
+ if (i < hourParts.length - 2) {
84
+ description += ",";
85
+ }
86
+ if (i == hourParts.length - 2) {
87
+ description += _global_1.i18n.spaceAnd();
88
+ }
89
+ }
90
+ }
91
+ else {
92
+ // default time description
93
+ var secondsDescription = this.getSecondsDescription();
94
+ var minutesDescription = this.getMinutesDescription();
95
+ var hoursDescription = this.getHoursDescription();
96
+ description += secondsDescription;
97
+ if (description && minutesDescription) {
98
+ description += ", ";
99
+ }
100
+ description += minutesDescription;
101
+ if (minutesDescription === hoursDescription) {
102
+ return description;
103
+ }
104
+ if (description && hoursDescription) {
105
+ description += ", ";
106
+ }
107
+ description += hoursDescription;
108
+ }
109
+ return description;
110
+ };
111
+ ExpressionDescriptor.prototype.getSecondsDescription = function () {
112
+ var description = this.getSegmentDescription(this.expressionParts[0], _global_1.i18n.everySecond(), function (s) {
113
+ return s;
114
+ }, function (s) {
115
+ return (0, utils_1.format)(_global_1.i18n.everyX0Seconds(s), s);
116
+ }, function (s) {
117
+ return _global_1.i18n.secondsX0ThroughX1PastTheMinute();
118
+ }, function (s) {
119
+ return s == "0"
120
+ ? ""
121
+ : parseInt(s) < 20
122
+ ? _global_1.i18n.atX0SecondsPastTheMinute(s)
123
+ : _global_1.i18n.atX0SecondsPastTheMinuteGt20() || _global_1.i18n.atX0SecondsPastTheMinute(s);
124
+ });
125
+ return description;
126
+ };
127
+ ExpressionDescriptor.prototype.getMinutesDescription = function () {
128
+ var secondsExpression = this.expressionParts[0];
129
+ var hourExpression = this.expressionParts[2];
130
+ var description = this.getSegmentDescription(this.expressionParts[1], _global_1.i18n.everyMinute(), function (s) {
131
+ return s;
132
+ }, function (s) {
133
+ return (0, utils_1.format)(_global_1.i18n.everyX0Minutes(s), s);
134
+ }, function (s) {
135
+ return _global_1.i18n.minutesX0ThroughX1PastTheHour();
136
+ }, function (s) {
137
+ try {
138
+ return s == "0" && hourExpression.indexOf("/") == -1 && secondsExpression == ""
139
+ ? _global_1.i18n.everyHour()
140
+ : parseInt(s) < 20
141
+ ? _global_1.i18n.atX0MinutesPastTheHour(s)
142
+ : _global_1.i18n.atX0MinutesPastTheHourGt20() || _global_1.i18n.atX0MinutesPastTheHour(s);
143
+ }
144
+ catch (e) {
145
+ return _global_1.i18n.atX0MinutesPastTheHour(s);
146
+ }
147
+ });
148
+ return description;
149
+ };
150
+ ExpressionDescriptor.prototype.getHoursDescription = function () {
151
+ var _this = this;
152
+ var expression = this.expressionParts[2];
153
+ var description = this.getSegmentDescription(expression, _global_1.i18n.everyHour(), function (s) {
154
+ return _this.formatTime(s, "0", "");
155
+ }, function (s) {
156
+ return (0, utils_1.format)(_global_1.i18n.everyX0Hours(s), s);
157
+ }, function (s) {
158
+ return _global_1.i18n.betweenX0AndX1();
159
+ }, function (s) {
160
+ return _global_1.i18n.atX0();
161
+ });
162
+ // If this is an hour range and minute segment is not "on the hour" (0), we'll change the second hour part from :00 to :59
163
+ if (description && expression.includes("-") && this.expressionParts[1] != "0") {
164
+ var atTheHourMatches = Array.from(description.matchAll(/:00/g));
165
+ if (atTheHourMatches.length > 1) {
166
+ var lastAtTheHourMatchIndex = atTheHourMatches[atTheHourMatches.length - 1].index;
167
+ description =
168
+ description.substring(0, lastAtTheHourMatchIndex) +
169
+ ":59" +
170
+ description.substring(lastAtTheHourMatchIndex + 3);
171
+ }
172
+ }
173
+ return description;
174
+ };
175
+ ExpressionDescriptor.prototype.getDayOfWeekDescription = function () {
176
+ var _this = this;
177
+ var daysOfWeekNames = _global_1.i18n.daysOfTheWeek();
178
+ var description = null;
179
+ if (this.expressionParts[5] == "*") {
180
+ // DOW is specified as * so we will not generate a description and defer to DOM part.
181
+ // Otherwise, we could get a contradiction like "on day 1 of the month, every day"
182
+ // or a dupe description like "every day, every day".
183
+ description = "";
184
+ }
185
+ else {
186
+ description = this.getSegmentDescription(this.expressionParts[5], _global_1.i18n.commaEveryDay(), function (s, form) {
187
+ var exp = s;
188
+ if (s.indexOf("#") > -1) {
189
+ exp = s.substring(0, s.indexOf("#"));
190
+ }
191
+ else if (s.indexOf("L") > -1) {
192
+ exp = exp.replace("L", "");
193
+ }
194
+ var parsedExp = parseInt(exp);
195
+ if (_this.options.tzOffset) {
196
+ var hourExpression = _this.expressionParts[2];
197
+ var hour = parseInt(hourExpression) + (_this.options.tzOffset ? _this.options.tzOffset : 0);
198
+ if (hour >= 24) {
199
+ parsedExp++;
200
+ }
201
+ else if (hour < 0) {
202
+ parsedExp--;
203
+ }
204
+ if (parsedExp > 6) {
205
+ parsedExp = 0;
206
+ }
207
+ else if (parsedExp < 0) {
208
+ parsedExp = 6;
209
+ }
210
+ }
211
+ var description = _global_1.i18n.daysOfTheWeekInCase
212
+ ? _global_1.i18n.daysOfTheWeekInCase(form)[parsedExp]
213
+ : daysOfWeekNames[parsedExp];
214
+ if (s.indexOf("#") > -1) {
215
+ var dayOfWeekOfMonthDescription = null;
216
+ var dayOfWeekOfMonthNumber = s.substring(s.indexOf("#") + 1);
217
+ var dayOfWeekNumber = s.substring(0, s.indexOf("#"));
218
+ switch (dayOfWeekOfMonthNumber) {
219
+ case "1":
220
+ dayOfWeekOfMonthDescription = _global_1.i18n.first(dayOfWeekNumber);
221
+ break;
222
+ case "2":
223
+ dayOfWeekOfMonthDescription = _global_1.i18n.second(dayOfWeekNumber);
224
+ break;
225
+ case "3":
226
+ dayOfWeekOfMonthDescription = _global_1.i18n.third(dayOfWeekNumber);
227
+ break;
228
+ case "4":
229
+ dayOfWeekOfMonthDescription = _global_1.i18n.fourth(dayOfWeekNumber);
230
+ break;
231
+ case "5":
232
+ dayOfWeekOfMonthDescription = _global_1.i18n.fifth(dayOfWeekNumber);
233
+ break;
234
+ }
235
+ description = dayOfWeekOfMonthDescription + " " + description;
236
+ }
237
+ return description;
238
+ }, function (s) {
239
+ if (parseInt(s) == 1) {
240
+ // rather than "every 1 days" just return empty string
241
+ return "";
242
+ }
243
+ else {
244
+ return (0, utils_1.format)(_global_1.i18n.commaEveryX0DaysOfTheWeek(s), s);
245
+ }
246
+ }, function (s) {
247
+ // If both DOM and DOW are specified, the cron will execute at either time.
248
+ var beginFrom = s.substring(0, s.indexOf("-"));
249
+ var domSpecified = _this.expressionParts[3] != "*";
250
+ return domSpecified ? _global_1.i18n.commaAndX0ThroughX1(beginFrom) : _global_1.i18n.commaX0ThroughX1(beginFrom);
251
+ }, function (s) {
252
+ var format = null;
253
+ if (s.indexOf("#") > -1) {
254
+ var dayOfWeekOfMonthNumber = s.substring(s.indexOf("#") + 1);
255
+ format = _global_1.i18n.commaOnThe(dayOfWeekOfMonthNumber).trim() + _global_1.i18n.spaceX0OfTheMonth();
256
+ }
257
+ else if (s.indexOf("L") > -1) {
258
+ format = _global_1.i18n.commaOnTheLastX0OfTheMonth(s.replace("L", ""));
259
+ }
260
+ else {
261
+ // If both DOM and DOW are specified, the cron will execute at either time.
262
+ var domSpecified = _this.expressionParts[3] != "*";
263
+ format = domSpecified ? _global_1.i18n.commaAndOnX0() : _global_1.i18n.commaOnlyOnX0(s);
264
+ }
265
+ return format;
266
+ });
267
+ }
268
+ return description;
269
+ };
270
+ ExpressionDescriptor.prototype.getMonthDescription = function () {
271
+ var monthNames = _global_1.i18n.monthsOfTheYear();
272
+ var description = this.getSegmentDescription(this.expressionParts[4], "", function (s, form) {
273
+ return form && _global_1.i18n.monthsOfTheYearInCase
274
+ ? _global_1.i18n.monthsOfTheYearInCase(form)[parseInt(s) - 1]
275
+ : monthNames[parseInt(s) - 1];
276
+ }, function (s) {
277
+ //
278
+ if (parseInt(s) == 1) {
279
+ // rather than "every 1 months" just return empty string
280
+ return "";
281
+ }
282
+ else {
283
+ return (0, utils_1.format)(_global_1.i18n.commaEveryX0Months(s), s);
284
+ }
285
+ }, function (s) {
286
+ return _global_1.i18n.commaMonthX0ThroughMonthX1() || _global_1.i18n.commaX0ThroughX1();
287
+ }, function (s) {
288
+ return _global_1.i18n.commaOnlyInMonthX0 ? _global_1.i18n.commaOnlyInMonthX0() : _global_1.i18n.commaOnlyInX0();
289
+ });
290
+ return description;
291
+ };
292
+ ExpressionDescriptor.prototype.getDayOfMonthDescription = function () {
293
+ var description = null;
294
+ var expression = this.expressionParts[3];
295
+ switch (expression) {
296
+ case "L":
297
+ description = _global_1.i18n.commaOnTheLastDayOfTheMonth();
298
+ break;
299
+ case "WL":
300
+ case "LW":
301
+ description = _global_1.i18n.commaOnTheLastWeekdayOfTheMonth();
302
+ break;
303
+ default: // i.e. 3W or W2
304
+ var weekDayNumberMatches = expression.match(/(\d{1,2}W)|(W\d{1,2})/);
305
+ if (weekDayNumberMatches) {
306
+ var dayNumber = parseInt(weekDayNumberMatches[0].replace("W", ""));
307
+ var dayString = dayNumber == 1
308
+ ? _global_1.i18n.firstWeekday()
309
+ : (0, utils_1.format)(_global_1.i18n.weekdayNearestDayX0(), dayNumber.toString());
310
+ description = (0, utils_1.format)(_global_1.i18n.commaOnTheX0OfTheMonth(), dayString);
311
+ break;
312
+ }
313
+ else {
314
+ // Handle "last day offset" (i.e. L-5: "5 days before the last day of the month")
315
+ var lastDayOffSetMatches = expression.match(/L-(\d{1,2})/);
316
+ if (lastDayOffSetMatches) {
317
+ var offSetDays = lastDayOffSetMatches[1];
318
+ description = (0, utils_1.format)(_global_1.i18n.commaDaysBeforeTheLastDayOfTheMonth(offSetDays), offSetDays);
319
+ break;
320
+ }
321
+ else if (expression == "*" && this.expressionParts[5] != "*") {
322
+ // * dayOfMonth and dayOfWeek specified so use dayOfWeek verbiage instead
323
+ return "";
324
+ }
325
+ else {
326
+ description = this.getSegmentDescription(expression, _global_1.i18n.commaEveryDay(), function (s) {
327
+ return s == "L"
328
+ ? _global_1.i18n.lastDay()
329
+ : _global_1.i18n.dayX0
330
+ ? (0, utils_1.format)(_global_1.i18n.dayX0(), s)
331
+ : s;
332
+ }, function (s) {
333
+ return s == "1" ? _global_1.i18n.commaEveryDay() : _global_1.i18n.commaEveryX0Days(s);
334
+ }, function (s) {
335
+ return _global_1.i18n.commaBetweenDayX0AndX1OfTheMonth(s);
336
+ }, function (s) {
337
+ return _global_1.i18n.commaOnDayX0OfTheMonth(s);
338
+ });
339
+ }
340
+ break;
341
+ }
342
+ }
343
+ return description;
344
+ };
345
+ ExpressionDescriptor.prototype.getYearDescription = function () {
346
+ var description = this.getSegmentDescription(this.expressionParts[6], "", function (s) {
347
+ return /^\d+$/.test(s) ? new Date(parseInt(s), 1).getFullYear().toString() : s;
348
+ }, function (s) {
349
+ return (0, utils_1.format)(_global_1.i18n.commaEveryX0Years(s), s);
350
+ }, function (s) {
351
+ return _global_1.i18n.commaYearX0ThroughYearX1() || _global_1.i18n.commaX0ThroughX1();
352
+ }, function (s) {
353
+ return _global_1.i18n.commaOnlyInYearX0 ? _global_1.i18n.commaOnlyInYearX0() : _global_1.i18n.commaOnlyInX0();
354
+ });
355
+ return description;
356
+ };
357
+ ExpressionDescriptor.prototype.getSegmentDescription = function (expression, allDescription, getSingleItemDescription, getIncrementDescriptionFormat, getRangeDescriptionFormat, getDescriptionFormat) {
358
+ var description = null;
359
+ var doesExpressionContainIncrement = expression.indexOf("/") > -1;
360
+ var doesExpressionContainRange = expression.indexOf("-") > -1;
361
+ var doesExpressionContainMultipleValues = expression.indexOf(",") > -1;
362
+ if (!expression) {
363
+ // Empty
364
+ description = "";
365
+ }
366
+ else if (expression === "*") {
367
+ // * (All)
368
+ description = allDescription;
369
+ }
370
+ else if (!doesExpressionContainIncrement && !doesExpressionContainRange && !doesExpressionContainMultipleValues) {
371
+ // Simple
372
+ description = (0, utils_1.format)(getDescriptionFormat(expression), getSingleItemDescription(expression));
373
+ }
374
+ else if (doesExpressionContainMultipleValues) {
375
+ // Multiple Values
376
+ var segments = expression.split(",");
377
+ var descriptionContent = "";
378
+ for (var i = 0; i < segments.length; i++) {
379
+ if (i > 0 && segments.length > 2) {
380
+ descriptionContent += ",";
381
+ if (i < segments.length - 1) {
382
+ descriptionContent += " ";
383
+ }
384
+ }
385
+ if (i > 0 && segments.length > 1 && (i == segments.length - 1 || segments.length == 2)) {
386
+ descriptionContent += "".concat(_global_1.i18n.spaceAnd(), " ");
387
+ }
388
+ if (segments[i].indexOf("/") > -1 || segments[i].indexOf("-") > -1) {
389
+ // Multiple Values with Increment or Range
390
+ var isSegmentRangeWithoutIncrement = segments[i].indexOf("-") > -1 && segments[i].indexOf("/") == -1;
391
+ var currentDescriptionContent = this.getSegmentDescription(segments[i], allDescription, getSingleItemDescription, getIncrementDescriptionFormat, isSegmentRangeWithoutIncrement ? _global_1.i18n.commaX0ThroughX1 : getRangeDescriptionFormat, getDescriptionFormat);
392
+ if (isSegmentRangeWithoutIncrement) {
393
+ currentDescriptionContent = currentDescriptionContent.replace(", ", "");
394
+ }
395
+ descriptionContent += currentDescriptionContent;
396
+ }
397
+ else if (!doesExpressionContainIncrement) {
398
+ descriptionContent += getSingleItemDescription(segments[i]);
399
+ }
400
+ else {
401
+ descriptionContent += this.getSegmentDescription(segments[i], allDescription, getSingleItemDescription, getIncrementDescriptionFormat, getRangeDescriptionFormat, getDescriptionFormat);
402
+ }
403
+ }
404
+ if (!doesExpressionContainIncrement) {
405
+ description = (0, utils_1.format)(getDescriptionFormat(expression), descriptionContent);
406
+ }
407
+ else {
408
+ description = descriptionContent;
409
+ }
410
+ }
411
+ else if (doesExpressionContainIncrement) {
412
+ // Increment
413
+ var segments = expression.split("/");
414
+ description = (0, utils_1.format)(getIncrementDescriptionFormat(segments[1]), segments[1]);
415
+ if (segments[0].indexOf("-") > -1) {
416
+ // Range with Increment (ex: 2-59/3 )
417
+ var rangeSegmentDescription = this.generateRangeSegmentDescription(segments[0], getRangeDescriptionFormat, getSingleItemDescription);
418
+ if (rangeSegmentDescription.indexOf(", ") != 0) {
419
+ description += ", ";
420
+ }
421
+ description += rangeSegmentDescription;
422
+ }
423
+ else if (segments[0].indexOf("*") == -1) {
424
+ var rangeItemDescription = (0, utils_1.format)(getDescriptionFormat(segments[0]), getSingleItemDescription(segments[0]));
425
+ // remove any leading comma
426
+ rangeItemDescription = rangeItemDescription.replace(", ", "");
427
+ description += (0, utils_1.format)(_global_1.i18n.commaStartingX0(), rangeItemDescription);
428
+ }
429
+ }
430
+ else if (doesExpressionContainRange) {
431
+ // Range
432
+ description = this.generateRangeSegmentDescription(expression, getRangeDescriptionFormat, getSingleItemDescription);
433
+ }
434
+ return description;
435
+ };
436
+ ExpressionDescriptor.prototype.generateRangeSegmentDescription = function (rangeExpression, getRangeDescriptionFormat, getSingleItemDescription) {
437
+ var description = "";
438
+ var rangeSegments = rangeExpression.split("-");
439
+ var rangeSegment1Description = getSingleItemDescription(rangeSegments[0], 1);
440
+ var rangeSegment2Description = getSingleItemDescription(rangeSegments[1], 2);
441
+ var rangeDescriptionFormat = getRangeDescriptionFormat(rangeExpression);
442
+ description += (0, utils_1.format)(rangeDescriptionFormat, rangeSegment1Description, rangeSegment2Description);
443
+ return description;
444
+ };
445
+ ExpressionDescriptor.prototype.formatTime = function (hourExpression, minuteExpression, secondExpression) {
446
+ var hourOffset = 0;
447
+ var minuteOffset = 0;
448
+ if (this.options.tzOffset) {
449
+ hourOffset = this.options.tzOffset > 0 ? Math.floor(this.options.tzOffset) : Math.ceil(this.options.tzOffset);
450
+ minuteOffset = (parseFloat((this.options.tzOffset % 1).toFixed(2)));
451
+ if (minuteOffset != 0) {
452
+ minuteOffset *= 60;
453
+ }
454
+ }
455
+ var hour = parseInt(hourExpression) + (hourOffset);
456
+ var minute = parseInt(minuteExpression) + (minuteOffset);
457
+ if (minute >= 60) {
458
+ minute -= 60;
459
+ hour += 1;
460
+ }
461
+ else if (minute < 0) {
462
+ minute += 60;
463
+ hour -= 1;
464
+ }
465
+ if (hour >= 24) {
466
+ hour = hour - 24;
467
+ }
468
+ else if (hour < 0) {
469
+ hour = 24 + hour;
470
+ }
471
+ var period = "";
472
+ var setPeriodBeforeTime = false;
473
+ if (!this.options.use24HourTimeFormat) {
474
+ setPeriodBeforeTime = !!(_global_1.i18n.setPeriodBeforeTime && _global_1.i18n.setPeriodBeforeTime());
475
+ period = setPeriodBeforeTime ? "".concat(this.getPeriod(hour), " ") : " ".concat(this.getPeriod(hour));
476
+ if (hour > 12) {
477
+ hour -= 12;
478
+ }
479
+ if (hour === 0) {
480
+ hour = 12;
481
+ }
482
+ }
483
+ var second = "";
484
+ if (secondExpression) {
485
+ second = ":".concat(("00" + secondExpression).substring(secondExpression.length));
486
+ }
487
+ return "".concat(setPeriodBeforeTime ? period : "").concat(("00" + hour.toString()).substring(hour.toString().length), ":").concat(("00" + minute.toString()).substring(minute.toString().length)).concat(second).concat(!setPeriodBeforeTime ? period : "");
488
+ };
489
+ ExpressionDescriptor.prototype.transformVerbosity = function (description, useVerboseFormat) {
490
+ if (!useVerboseFormat) {
491
+ description = description.replace(new RegExp(", ".concat(_global_1.i18n.everyMinute()), "g"), "");
492
+ description = description.replace(new RegExp(", ".concat(_global_1.i18n.everyHour()), "g"), "");
493
+ description = description.replace(new RegExp(_global_1.i18n.commaEveryDay(), "g"), "");
494
+ description = description.replace(/\, ?$/, "");
495
+ }
496
+ return description;
497
+ };
498
+ ExpressionDescriptor.prototype.getPeriod = function (hour) {
499
+ return hour >= 12 ? (_global_1.i18n.pm && _global_1.i18n.pm()) || "PM" : (_global_1.i18n.am && _global_1.i18n.am()) || "AM";
500
+ };
501
+ return ExpressionDescriptor;
502
+ }());
503
+ exports.ExpressionDescriptor = ExpressionDescriptor;
@@ -0,0 +1,3 @@
1
+ export { crontabParser } from './crontabParser';
2
+ export { crontabRender } from './crontabRender';
3
+ export { setLocal } from './_global';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setLocal = exports.crontabRender = exports.crontabParser = void 0;
4
+ var crontabParser_1 = require("./crontabParser");
5
+ Object.defineProperty(exports, "crontabParser", { enumerable: true, get: function () { return crontabParser_1.crontabParser; } });
6
+ var crontabRender_1 = require("./crontabRender");
7
+ Object.defineProperty(exports, "crontabRender", { enumerable: true, get: function () { return crontabRender_1.crontabRender; } });
8
+ var _global_1 = require("./_global");
9
+ Object.defineProperty(exports, "setLocal", { enumerable: true, get: function () { return _global_1.setLocal; } });
@@ -0,0 +1,79 @@
1
+ export interface Locale {
2
+ setPeriodBeforeTime?(): boolean;
3
+ pm?(): string;
4
+ am?(): string;
5
+ use24HourTimeFormatByDefault(): boolean;
6
+ anErrorOccuredWhenGeneratingTheExpressionD(): string;
7
+ everyMinute(): string;
8
+ everyHour(): string;
9
+ atSpace(): string;
10
+ everyMinuteBetweenX0AndX1(): string;
11
+ at(): string;
12
+ spaceAnd(): string;
13
+ everySecond(): string;
14
+ everyX0Seconds(s?: string): string;
15
+ secondsX0ThroughX1PastTheMinute(): string;
16
+ atX0SecondsPastTheMinute(s?: string): string;
17
+ atX0SecondsPastTheMinuteGt20(): string | null;
18
+ everyX0Minutes(s?: string): string;
19
+ minutesX0ThroughX1PastTheHour(): string;
20
+ atX0MinutesPastTheHour(s?: string): string;
21
+ atX0MinutesPastTheHourGt20(): string | null;
22
+ everyX0Hours(s?: string): string;
23
+ betweenX0AndX1(): string;
24
+ atX0(): string;
25
+ commaEveryDay(): string;
26
+ commaEveryX0DaysOfTheWeek(s?: string): string;
27
+ commaX0ThroughX1(s?: string): string;
28
+ commaAndX0ThroughX1(s?: string): string;
29
+ commaMonthX0ThroughMonthX1(): string | null;
30
+ commaYearX0ThroughYearX1(): string | null;
31
+ first(s?: string): string;
32
+ second(s?: string): string;
33
+ third(s?: string): string;
34
+ fourth(s?: string): string;
35
+ fifth(s?: string): string;
36
+ commaOnThe(s?: string): string;
37
+ spaceX0OfTheMonth(): string;
38
+ lastDay(): string;
39
+ commaOnTheLastX0OfTheMonth(s?: string): string;
40
+ commaOnlyOnX0(s?: string): string;
41
+ commaAndOnX0(): string;
42
+ commaEveryX0Months(s?: string): string;
43
+ commaOnlyInX0(): string;
44
+ commaOnlyInMonthX0?(): string;
45
+ commaOnlyInYearX0?(): string;
46
+ commaOnTheLastDayOfTheMonth(): string;
47
+ commaOnTheLastWeekdayOfTheMonth(): string;
48
+ commaDaysBeforeTheLastDayOfTheMonth(s?: string): string;
49
+ firstWeekday(): string;
50
+ weekdayNearestDayX0(): string;
51
+ commaOnTheX0OfTheMonth(): string;
52
+ commaEveryX0Days(s?: string): string;
53
+ commaBetweenDayX0AndX1OfTheMonth(s?: string): string;
54
+ commaOnDayX0OfTheMonth(s?: string): string;
55
+ commaEveryX0Years(s?: string): string;
56
+ commaStartingX0(): string;
57
+ dayX0?(): string;
58
+ daysOfTheWeek(): string[];
59
+ /** If multiple forms are needed in "%s through %s"
60
+ * @param f 1 for "from", 2 for "through"
61
+ * @return {string[]} days of week
62
+ */
63
+ daysOfTheWeekInCase?(f?: number): string[];
64
+ monthsOfTheYear(): string[];
65
+ /** If multiple forms are needed in "%s through %s"
66
+ * @param f 1 for "from", 2 for "through"
67
+ * @return {string[]} months of year
68
+ */
69
+ monthsOfTheYearInCase?(f?: number): string[];
70
+ }
71
+ export interface Options {
72
+ throwExceptionOnParseError?: boolean;
73
+ verbose?: boolean;
74
+ dayOfWeekStartIndexZero?: boolean;
75
+ monthStartIndexZero?: boolean;
76
+ use24HourTimeFormat?: boolean;
77
+ locale?: string | null;
78
+ tzOffset?: number;
79
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,20 @@
1
+ export declare const validate: (parsed: string[]) => void;
2
+ /**
3
+ * Takes a string with '%s' placeholders and replaces them with provided values.
4
+ * Works like sprintf in C or string.Format in C#.
5
+ * @static
6
+ * @param {string} template - The string template with enclosed %s replacements
7
+ * @param {...string[]} values - The ordered replacement text
8
+ * @returns {string}
9
+ */
10
+ export declare const format: (template: string, ...values: string[]) => string;
11
+ /**
12
+ *
13
+ * Given a string and an array of search strings, determines if the string
14
+ * contains any value from the array.
15
+ * @static
16
+ * @param {string} text - The string to search
17
+ * @param {string[]} searchStrings - The array of values to search for
18
+ * @returns {boolean}
19
+ */
20
+ export declare const containsAny: (text: string, searchStrings: string[]) => boolean;