stonyx 0.2.3-alpha.8 → 0.2.3-alpha.9
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/docs/conventions/cron-conventions.md +100 -13
- package/package.json +1 -1
|
@@ -139,24 +139,115 @@ await service.add({
|
|
|
139
139
|
|
|
140
140
|
## ORM Data Model
|
|
141
141
|
|
|
142
|
-
When persisting cron data with `@stonyx/orm`, use the following model structure.
|
|
142
|
+
When persisting cron data with `@stonyx/orm`, use the following model structure.
|
|
143
143
|
|
|
144
144
|
### Models
|
|
145
145
|
|
|
146
146
|
```
|
|
147
147
|
models/
|
|
148
|
-
cron-job.js
|
|
148
|
+
cron-job.js
|
|
149
149
|
cron-job/
|
|
150
|
-
schedule.js
|
|
151
|
-
payload.js
|
|
152
|
-
state.js
|
|
153
|
-
delivery.js
|
|
154
|
-
cron-run.js
|
|
150
|
+
schedule.js
|
|
151
|
+
payload.js
|
|
152
|
+
state.js
|
|
153
|
+
delivery.js
|
|
154
|
+
cron-run.js
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
**`cron-job.js`** — parent model with `belongsTo` for schedule, payload, state, and delivery sub-models (property flattening rule — no passthrough objects):
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
```js
|
|
160
|
+
import { Model, attr, belongsTo } from '@stonyx/orm';
|
|
161
|
+
|
|
162
|
+
export default class CronJobModel extends Model {
|
|
163
|
+
name = attr('string');
|
|
164
|
+
description = attr('string');
|
|
165
|
+
enabled = attr('boolean');
|
|
166
|
+
deleteAfterRun = attr('boolean');
|
|
167
|
+
sessionTarget = attr('string');
|
|
168
|
+
wakeMode = attr('string');
|
|
169
|
+
createdAtMs = attr('number');
|
|
170
|
+
updatedAtMs = attr('number');
|
|
171
|
+
|
|
172
|
+
schedule = belongsTo('cron-job/schedule');
|
|
173
|
+
payload = belongsTo('cron-job/payload');
|
|
174
|
+
state = belongsTo('cron-job/state');
|
|
175
|
+
delivery = belongsTo('cron-job/delivery');
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**`cron-job/schedule.js`**
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
import { Model, attr } from '@stonyx/orm';
|
|
183
|
+
|
|
184
|
+
export default class CronJobScheduleModel extends Model {
|
|
185
|
+
kind = attr('string');
|
|
186
|
+
at = attr('string');
|
|
187
|
+
everyMs = attr('number');
|
|
188
|
+
anchorMs = attr('number');
|
|
189
|
+
expr = attr('string');
|
|
190
|
+
tz = attr('string');
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**`cron-job/payload.js`**
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
import { Model, attr } from '@stonyx/orm';
|
|
198
|
+
|
|
199
|
+
export default class CronJobPayloadModel extends Model {
|
|
200
|
+
kind = attr('string');
|
|
201
|
+
message = attr('string');
|
|
202
|
+
text = attr('string');
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**`cron-job/state.js`**
|
|
207
|
+
|
|
208
|
+
```js
|
|
209
|
+
import { Model, attr } from '@stonyx/orm';
|
|
210
|
+
|
|
211
|
+
export default class CronJobStateModel extends Model {
|
|
212
|
+
nextRunAtMs = attr('number');
|
|
213
|
+
runningAtMs = attr('number');
|
|
214
|
+
lastRunAtMs = attr('number');
|
|
215
|
+
lastStatus = attr('string');
|
|
216
|
+
lastError = attr('string');
|
|
217
|
+
lastDurationMs = attr('number');
|
|
218
|
+
consecutiveErrors = attr('number');
|
|
219
|
+
scheduleErrorCount = attr('number');
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**`cron-job/delivery.js`**
|
|
224
|
+
|
|
225
|
+
```js
|
|
226
|
+
import { Model, attr } from '@stonyx/orm';
|
|
227
|
+
|
|
228
|
+
export default class CronJobDeliveryModel extends Model {
|
|
229
|
+
mode = attr('string');
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**`cron-run.js`**
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
import { Model, attr } from '@stonyx/orm';
|
|
237
|
+
|
|
238
|
+
export default class CronRunModel extends Model {
|
|
239
|
+
jobId = attr('string');
|
|
240
|
+
status = attr('string');
|
|
241
|
+
error = attr('string');
|
|
242
|
+
summary = attr('string');
|
|
243
|
+
runAtMs = attr('number');
|
|
244
|
+
durationMs = attr('number');
|
|
245
|
+
nextRunAtMs = attr('number');
|
|
246
|
+
ts = attr('number');
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**Property ordering:** `attr()` → `belongsTo()` (on parent model).
|
|
160
251
|
|
|
161
252
|
### DB Schema
|
|
162
253
|
|
|
@@ -173,10 +264,6 @@ export default class DBModel extends Model {
|
|
|
173
264
|
}
|
|
174
265
|
```
|
|
175
266
|
|
|
176
|
-
### Serializers
|
|
177
|
-
|
|
178
|
-
Identity maps for all cron models — field names match the model attributes directly.
|
|
179
|
-
|
|
180
267
|
## Configuration
|
|
181
268
|
|
|
182
269
|
```js
|