@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.
Files changed (98) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +9 -0
  3. package/README.zh-CN.md +9 -0
  4. package/client.d.ts +2 -0
  5. package/client.js +1 -0
  6. package/dist/client/SequenceFieldProvider.d.ts +2 -0
  7. package/dist/client/index.d.ts +5 -0
  8. package/dist/client/index.js +19 -0
  9. package/dist/client/locale/index.d.ts +3 -0
  10. package/dist/client/sequence.d.ts +259 -0
  11. package/dist/externalVersion.js +14 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +39 -0
  14. package/dist/locale/en-US.json +24 -0
  15. package/dist/locale/es-ES.json +24 -0
  16. package/dist/locale/fr-FR.json +24 -0
  17. package/dist/locale/ko_KR.json +24 -0
  18. package/dist/locale/pt-BR.json +24 -0
  19. package/dist/locale/zh-CN.json +25 -0
  20. package/dist/node_modules/cron-parser/.eslintrc.json +15 -0
  21. package/dist/node_modules/cron-parser/.travis.yml +7 -0
  22. package/dist/node_modules/cron-parser/LICENSE +21 -0
  23. package/dist/node_modules/cron-parser/component.json +11 -0
  24. package/dist/node_modules/cron-parser/index.d.ts +1 -0
  25. package/dist/node_modules/cron-parser/lib/date.js +252 -0
  26. package/dist/node_modules/cron-parser/lib/expression.js +983 -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 +38 -0
  29. package/dist/node_modules/cron-parser/lib/parser.js +1 -0
  30. package/dist/node_modules/cron-parser/node_modules/luxon/build/amd/luxon.js +8489 -0
  31. package/dist/node_modules/cron-parser/node_modules/luxon/build/cjs-browser/luxon.js +8487 -0
  32. package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.js +8490 -0
  33. package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.min.js +1 -0
  34. package/dist/node_modules/cron-parser/node_modules/luxon/build/node/luxon.js +7522 -0
  35. package/dist/node_modules/cron-parser/node_modules/luxon/package.json +96 -0
  36. package/dist/node_modules/cron-parser/node_modules/luxon/src/datetime.js +2169 -0
  37. package/dist/node_modules/cron-parser/node_modules/luxon/src/duration.js +880 -0
  38. package/dist/node_modules/cron-parser/node_modules/luxon/src/errors.js +61 -0
  39. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/conversions.js +157 -0
  40. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/diff.js +80 -0
  41. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/digits.js +76 -0
  42. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/english.js +233 -0
  43. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formats.js +191 -0
  44. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formatter.js +386 -0
  45. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/invalid.js +14 -0
  46. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/locale.js +482 -0
  47. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/regexParser.js +335 -0
  48. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/tokenParser.js +424 -0
  49. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/util.js +292 -0
  50. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/zoneUtil.js +36 -0
  51. package/dist/node_modules/cron-parser/node_modules/luxon/src/info.js +193 -0
  52. package/dist/node_modules/cron-parser/node_modules/luxon/src/interval.js +602 -0
  53. package/dist/node_modules/cron-parser/node_modules/luxon/src/luxon.js +26 -0
  54. package/dist/node_modules/cron-parser/node_modules/luxon/src/luxonFilled.js +13 -0
  55. package/dist/node_modules/cron-parser/node_modules/luxon/src/settings.js +137 -0
  56. package/dist/node_modules/cron-parser/node_modules/luxon/src/zone.js +88 -0
  57. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/IANAZone.js +191 -0
  58. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/fixedOffsetZone.js +94 -0
  59. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/invalidZone.js +53 -0
  60. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/localZone.js +63 -0
  61. package/dist/node_modules/cron-parser/package.json +1 -0
  62. package/dist/node_modules/cron-parser/test/31_of_month.js +17 -0
  63. package/dist/node_modules/cron-parser/test/bug.js +29 -0
  64. package/dist/node_modules/cron-parser/test/crondate.js +16 -0
  65. package/dist/node_modules/cron-parser/test/crontab.example +7 -0
  66. package/dist/node_modules/cron-parser/test/empty_around_comma.js +22 -0
  67. package/dist/node_modules/cron-parser/test/expression.js +1489 -0
  68. package/dist/node_modules/cron-parser/test/field_compactor.js +250 -0
  69. package/dist/node_modules/cron-parser/test/field_stringify.js +84 -0
  70. package/dist/node_modules/cron-parser/test/fields.js +32 -0
  71. package/dist/node_modules/cron-parser/test/increment_on_first_iteration.js +22 -0
  72. package/dist/node_modules/cron-parser/test/index-ts3.test-d.ts +133 -0
  73. package/dist/node_modules/cron-parser/test/index.test-d.ts +138 -0
  74. package/dist/node_modules/cron-parser/test/leap_year.js +17 -0
  75. package/dist/node_modules/cron-parser/test/parser.js +46 -0
  76. package/dist/node_modules/cron-parser/test/parser_crondate_formats.js +145 -0
  77. package/dist/node_modules/cron-parser/test/parser_day_of_month.js +169 -0
  78. package/dist/node_modules/cron-parser/test/prev_date.js +32 -0
  79. package/dist/node_modules/cron-parser/test/stringify.js +402 -0
  80. package/dist/node_modules/cron-parser/test/timezone.js +422 -0
  81. package/dist/node_modules/cron-parser/types/common.d.ts +131 -0
  82. package/dist/node_modules/cron-parser/types/index.d.ts +45 -0
  83. package/dist/node_modules/cron-parser/types/ts3/index.d.ts +28 -0
  84. package/dist/server/Plugin.d.ts +8 -0
  85. package/dist/server/Plugin.js +124 -0
  86. package/dist/server/collections/sequences.d.ts +2 -0
  87. package/dist/server/collections/sequences.js +88 -0
  88. package/dist/server/fields/sequence-field.d.ts +38 -0
  89. package/dist/server/fields/sequence-field.js +386 -0
  90. package/dist/server/index.d.ts +2 -0
  91. package/dist/server/index.js +39 -0
  92. package/dist/server/migrations/20221207022250-sequence-field-key.d.ts +6 -0
  93. package/dist/server/migrations/20221207022250-sequence-field-key.js +85 -0
  94. package/dist/server/migrations/20240425225438-change-locale-module.d.ts +6 -0
  95. package/dist/server/migrations/20240425225438-change-locale-module.js +42 -0
  96. package/package.json +36 -0
  97. package/server.d.ts +2 -0
  98. 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;