@nocobase/plugin-field-sequence 1.0.0-alpha.1
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/LICENSE +661 -0
- package/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/SequenceFieldProvider.d.ts +2 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js +19 -0
- package/dist/client/locale/index.d.ts +3 -0
- package/dist/client/sequence.d.ts +259 -0
- package/dist/externalVersion.js +14 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/en-US.json +24 -0
- package/dist/locale/es-ES.json +24 -0
- package/dist/locale/fr-FR.json +24 -0
- package/dist/locale/ko_KR.json +24 -0
- package/dist/locale/pt-BR.json +24 -0
- package/dist/locale/zh-CN.json +25 -0
- package/dist/node_modules/cron-parser/.eslintrc.json +15 -0
- package/dist/node_modules/cron-parser/.travis.yml +7 -0
- package/dist/node_modules/cron-parser/LICENSE +21 -0
- package/dist/node_modules/cron-parser/component.json +11 -0
- package/dist/node_modules/cron-parser/index.d.ts +1 -0
- package/dist/node_modules/cron-parser/lib/date.js +252 -0
- package/dist/node_modules/cron-parser/lib/expression.js +983 -0
- package/dist/node_modules/cron-parser/lib/field_compactor.js +70 -0
- package/dist/node_modules/cron-parser/lib/field_stringify.js +38 -0
- package/dist/node_modules/cron-parser/lib/parser.js +1 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/amd/luxon.js +8489 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/cjs-browser/luxon.js +8487 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.js +8490 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.min.js +1 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/node/luxon.js +7522 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/package.json +96 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/datetime.js +2169 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/duration.js +880 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/errors.js +61 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/conversions.js +157 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/diff.js +80 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/digits.js +76 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/english.js +233 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formats.js +191 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formatter.js +386 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/invalid.js +14 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/locale.js +482 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/regexParser.js +335 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/tokenParser.js +424 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/util.js +292 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/zoneUtil.js +36 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/info.js +193 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/interval.js +602 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/luxon.js +26 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/luxonFilled.js +13 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/settings.js +137 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zone.js +88 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/IANAZone.js +191 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/fixedOffsetZone.js +94 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/invalidZone.js +53 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/localZone.js +63 -0
- package/dist/node_modules/cron-parser/package.json +1 -0
- package/dist/node_modules/cron-parser/test/31_of_month.js +17 -0
- package/dist/node_modules/cron-parser/test/bug.js +29 -0
- package/dist/node_modules/cron-parser/test/crondate.js +16 -0
- package/dist/node_modules/cron-parser/test/crontab.example +7 -0
- package/dist/node_modules/cron-parser/test/empty_around_comma.js +22 -0
- package/dist/node_modules/cron-parser/test/expression.js +1489 -0
- package/dist/node_modules/cron-parser/test/field_compactor.js +250 -0
- package/dist/node_modules/cron-parser/test/field_stringify.js +84 -0
- package/dist/node_modules/cron-parser/test/fields.js +32 -0
- package/dist/node_modules/cron-parser/test/increment_on_first_iteration.js +22 -0
- package/dist/node_modules/cron-parser/test/index-ts3.test-d.ts +133 -0
- package/dist/node_modules/cron-parser/test/index.test-d.ts +138 -0
- package/dist/node_modules/cron-parser/test/leap_year.js +17 -0
- package/dist/node_modules/cron-parser/test/parser.js +46 -0
- package/dist/node_modules/cron-parser/test/parser_crondate_formats.js +145 -0
- package/dist/node_modules/cron-parser/test/parser_day_of_month.js +169 -0
- package/dist/node_modules/cron-parser/test/prev_date.js +32 -0
- package/dist/node_modules/cron-parser/test/stringify.js +402 -0
- package/dist/node_modules/cron-parser/test/timezone.js +422 -0
- package/dist/node_modules/cron-parser/types/common.d.ts +131 -0
- package/dist/node_modules/cron-parser/types/index.d.ts +45 -0
- package/dist/node_modules/cron-parser/types/ts3/index.d.ts +28 -0
- package/dist/server/Plugin.d.ts +8 -0
- package/dist/server/Plugin.js +124 -0
- package/dist/server/collections/sequences.d.ts +2 -0
- package/dist/server/collections/sequences.js +88 -0
- package/dist/server/fields/sequence-field.d.ts +38 -0
- package/dist/server/fields/sequence-field.js +386 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +39 -0
- package/dist/server/migrations/20221207022250-sequence-field-key.d.ts +6 -0
- package/dist/server/migrations/20221207022250-sequence-field-key.js +85 -0
- package/dist/server/migrations/20240425225438-change-locale-module.d.ts +6 -0
- package/dist/server/migrations/20240425225438-change-locale-module.js +42 -0
- package/package.json +36 -0
- package/server.d.ts +2 -0
- 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;
|