@tachybase/module-cron 0.23.8

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 (50) hide show
  1. package/.turbo/turbo-build.log +14 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/components/EndsByField.d.ts +5 -0
  6. package/dist/client/components/FieldsSelect.d.ts +2 -0
  7. package/dist/client/components/OnField.d.ts +5 -0
  8. package/dist/client/components/RepeatField.d.ts +5 -0
  9. package/dist/client/components/locale/Cron.zh-CN.d.ts +34 -0
  10. package/dist/client/cron-jobs-table/CronJobsTable.d.ts +7 -0
  11. package/dist/client/cron-jobs-table/CronJobsTable.schema.d.ts +1241 -0
  12. package/dist/client/index.d.ts +7 -0
  13. package/dist/client/index.js +36 -0
  14. package/dist/client/locale.d.ts +3 -0
  15. package/dist/collections/cronJobs.d.ts +3 -0
  16. package/dist/collections/cronJobs.js +200 -0
  17. package/dist/constants.d.ts +6 -0
  18. package/dist/constants.js +37 -0
  19. package/dist/externalVersion.js +11 -0
  20. package/dist/index.d.ts +2 -0
  21. package/dist/index.js +39 -0
  22. package/dist/locale/en-US.json +36 -0
  23. package/dist/locale/zh-CN.json +36 -0
  24. package/dist/node_modules/cron-parser/LICENSE +21 -0
  25. package/dist/node_modules/cron-parser/lib/date.js +252 -0
  26. package/dist/node_modules/cron-parser/lib/expression.js +1002 -0
  27. package/dist/node_modules/cron-parser/lib/field_compactor.js +70 -0
  28. package/dist/node_modules/cron-parser/lib/field_stringify.js +58 -0
  29. package/dist/node_modules/cron-parser/lib/parser.js +1 -0
  30. package/dist/node_modules/cron-parser/package.json +1 -0
  31. package/dist/node_modules/cron-parser/types/common.d.ts +131 -0
  32. package/dist/node_modules/cron-parser/types/index.d.ts +45 -0
  33. package/dist/node_modules/cron-parser/types/ts3/index.d.ts +28 -0
  34. package/dist/server/actions/cron-jobs-controller.d.ts +4 -0
  35. package/dist/server/actions/cron-jobs-controller.js +94 -0
  36. package/dist/server/collections/cronJobs.d.ts +1 -0
  37. package/dist/server/collections/cronJobs.js +33 -0
  38. package/dist/server/index.d.ts +1 -0
  39. package/dist/server/index.js +33 -0
  40. package/dist/server/model/CronJobModel.d.ts +19 -0
  41. package/dist/server/model/CronJobModel.js +29 -0
  42. package/dist/server/plugin.d.ts +11 -0
  43. package/dist/server/plugin.js +104 -0
  44. package/dist/server/service/StaticScheduleTrigger.d.ts +15 -0
  45. package/dist/server/service/StaticScheduleTrigger.js +298 -0
  46. package/dist/server/utils/index.d.ts +1 -0
  47. package/dist/server/utils/index.js +29 -0
  48. package/package.json +23 -0
  49. package/server.d.ts +2 -0
  50. package/server.js +1 -0
@@ -0,0 +1,252 @@
1
+ 'use strict';
2
+
3
+ var luxon = require('luxon');
4
+
5
+ CronDate.prototype.addYear = function() {
6
+ this._date = this._date.plus({ years: 1 });
7
+ };
8
+
9
+ CronDate.prototype.addMonth = function() {
10
+ this._date = this._date.plus({ months: 1 }).startOf('month');
11
+ };
12
+
13
+ CronDate.prototype.addDay = function() {
14
+ this._date = this._date.plus({ days: 1 }).startOf('day');
15
+ };
16
+
17
+ CronDate.prototype.addHour = function() {
18
+ var prev = this._date;
19
+ this._date = this._date.plus({ hours: 1 }).startOf('hour');
20
+ if (this._date <= prev) {
21
+ this._date = this._date.plus({ hours: 1 });
22
+ }
23
+ };
24
+
25
+ CronDate.prototype.addMinute = function() {
26
+ var prev = this._date;
27
+ this._date = this._date.plus({ minutes: 1 }).startOf('minute');
28
+ if (this._date < prev) {
29
+ this._date = this._date.plus({ hours: 1 });
30
+ }
31
+ };
32
+
33
+ CronDate.prototype.addSecond = function() {
34
+ var prev = this._date;
35
+ this._date = this._date.plus({ seconds: 1 }).startOf('second');
36
+ if (this._date < prev) {
37
+ this._date = this._date.plus({ hours: 1 });
38
+ }
39
+ };
40
+
41
+ CronDate.prototype.subtractYear = function() {
42
+ this._date = this._date.minus({ years: 1 });
43
+ };
44
+
45
+ CronDate.prototype.subtractMonth = function() {
46
+ this._date = this._date
47
+ .minus({ months: 1 })
48
+ .endOf('month')
49
+ .startOf('second');
50
+ };
51
+
52
+ CronDate.prototype.subtractDay = function() {
53
+ this._date = this._date
54
+ .minus({ days: 1 })
55
+ .endOf('day')
56
+ .startOf('second');
57
+ };
58
+
59
+ CronDate.prototype.subtractHour = function() {
60
+ var prev = this._date;
61
+ this._date = this._date
62
+ .minus({ hours: 1 })
63
+ .endOf('hour')
64
+ .startOf('second');
65
+ if (this._date >= prev) {
66
+ this._date = this._date.minus({ hours: 1 });
67
+ }
68
+ };
69
+
70
+ CronDate.prototype.subtractMinute = function() {
71
+ var prev = this._date;
72
+ this._date = this._date.minus({ minutes: 1 })
73
+ .endOf('minute')
74
+ .startOf('second');
75
+ if (this._date > prev) {
76
+ this._date = this._date.minus({ hours: 1 });
77
+ }
78
+ };
79
+
80
+ CronDate.prototype.subtractSecond = function() {
81
+ var prev = this._date;
82
+ this._date = this._date
83
+ .minus({ seconds: 1 })
84
+ .startOf('second');
85
+ if (this._date > prev) {
86
+ this._date = this._date.minus({ hours: 1 });
87
+ }
88
+ };
89
+
90
+ CronDate.prototype.getDate = function() {
91
+ return this._date.day;
92
+ };
93
+
94
+ CronDate.prototype.getFullYear = function() {
95
+ return this._date.year;
96
+ };
97
+
98
+ CronDate.prototype.getDay = function() {
99
+ var weekday = this._date.weekday;
100
+ return weekday == 7 ? 0 : weekday;
101
+ };
102
+
103
+ CronDate.prototype.getMonth = function() {
104
+ return this._date.month - 1;
105
+ };
106
+
107
+ CronDate.prototype.getHours = function() {
108
+ return this._date.hour;
109
+ };
110
+
111
+ CronDate.prototype.getMinutes = function() {
112
+ return this._date.minute;
113
+ };
114
+
115
+ CronDate.prototype.getSeconds = function() {
116
+ return this._date.second;
117
+ };
118
+
119
+ CronDate.prototype.getMilliseconds = function() {
120
+ return this._date.millisecond;
121
+ };
122
+
123
+ CronDate.prototype.getTime = function() {
124
+ return this._date.valueOf();
125
+ };
126
+
127
+ CronDate.prototype.getUTCDate = function() {
128
+ return this._getUTC().day;
129
+ };
130
+
131
+ CronDate.prototype.getUTCFullYear = function() {
132
+ return this._getUTC().year;
133
+ };
134
+
135
+ CronDate.prototype.getUTCDay = function() {
136
+ var weekday = this._getUTC().weekday;
137
+ return weekday == 7 ? 0 : weekday;
138
+ };
139
+
140
+ CronDate.prototype.getUTCMonth = function() {
141
+ return this._getUTC().month - 1;
142
+ };
143
+
144
+ CronDate.prototype.getUTCHours = function() {
145
+ return this._getUTC().hour;
146
+ };
147
+
148
+ CronDate.prototype.getUTCMinutes = function() {
149
+ return this._getUTC().minute;
150
+ };
151
+
152
+ CronDate.prototype.getUTCSeconds = function() {
153
+ return this._getUTC().second;
154
+ };
155
+
156
+ CronDate.prototype.toISOString = function() {
157
+ return this._date.toUTC().toISO();
158
+ };
159
+
160
+ CronDate.prototype.toJSON = function() {
161
+ return this._date.toJSON();
162
+ };
163
+
164
+ CronDate.prototype.setDate = function(d) {
165
+ this._date = this._date.set({ day: d });
166
+ };
167
+
168
+ CronDate.prototype.setFullYear = function(y) {
169
+ this._date = this._date.set({ year: y });
170
+ };
171
+
172
+ CronDate.prototype.setDay = function(d) {
173
+ this._date = this._date.set({ weekday: d });
174
+ };
175
+
176
+ CronDate.prototype.setMonth = function(m) {
177
+ this._date = this._date.set({ month: m + 1 });
178
+ };
179
+
180
+ CronDate.prototype.setHours = function(h) {
181
+ this._date = this._date.set({ hour: h });
182
+ };
183
+
184
+ CronDate.prototype.setMinutes = function(m) {
185
+ this._date = this._date.set({ minute: m });
186
+ };
187
+
188
+ CronDate.prototype.setSeconds = function(s) {
189
+ this._date = this._date.set({ second: s });
190
+ };
191
+
192
+ CronDate.prototype.setMilliseconds = function(s) {
193
+ this._date = this._date.set({ millisecond: s });
194
+ };
195
+
196
+ CronDate.prototype._getUTC = function() {
197
+ return this._date.toUTC();
198
+ };
199
+
200
+ CronDate.prototype.toString = function() {
201
+ return this.toDate().toString();
202
+ };
203
+
204
+ CronDate.prototype.toDate = function() {
205
+ return this._date.toJSDate();
206
+ };
207
+
208
+ CronDate.prototype.isLastDayOfMonth = function() {
209
+ //next day
210
+ var newDate = this._date.plus({ days: 1 }).startOf('day');
211
+ return this._date.month !== newDate.month;
212
+ };
213
+
214
+ /**
215
+ * Returns true when the current weekday is the last occurrence of this weekday
216
+ * for the present month.
217
+ */
218
+ CronDate.prototype.isLastWeekdayOfMonth = function() {
219
+ // Check this by adding 7 days to the current date and seeing if it's
220
+ // a different month
221
+ var newDate = this._date.plus({ days: 7 }).startOf('day');
222
+ return this._date.month !== newDate.month;
223
+ };
224
+
225
+ function CronDate (timestamp, tz) {
226
+ var dateOpts = { zone: tz };
227
+ if (!timestamp) {
228
+ this._date = luxon.DateTime.local();
229
+ } else if (timestamp instanceof CronDate) {
230
+ this._date = timestamp._date;
231
+ } else if (timestamp instanceof Date) {
232
+ this._date = luxon.DateTime.fromJSDate(timestamp, dateOpts);
233
+ } else if (typeof timestamp === 'number') {
234
+ this._date = luxon.DateTime.fromMillis(timestamp, dateOpts);
235
+ } else if (typeof timestamp === 'string') {
236
+ this._date = luxon.DateTime.fromISO(timestamp, dateOpts);
237
+ this._date.isValid || (this._date = luxon.DateTime.fromRFC2822(timestamp, dateOpts));
238
+ this._date.isValid || (this._date = luxon.DateTime.fromSQL(timestamp, dateOpts));
239
+ // RFC2822-like format without the required timezone offset (used in tests)
240
+ this._date.isValid || (this._date = luxon.DateTime.fromFormat(timestamp, 'EEE, d MMM yyyy HH:mm:ss', dateOpts));
241
+ }
242
+
243
+ if (!this._date || !this._date.isValid) {
244
+ throw new Error('CronDate: unhandled timestamp: ' + JSON.stringify(timestamp));
245
+ }
246
+
247
+ if (tz && tz !== this._date.zoneName) {
248
+ this._date = this._date.setZone(tz);
249
+ }
250
+ }
251
+
252
+ module.exports = CronDate;