@positronic/cloudflare 0.0.74 → 0.0.75
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/dist/src/api/brains.js
CHANGED
|
@@ -1081,7 +1081,7 @@ brains.post('/schedules', function(context) {
|
|
|
1081
1081
|
}
|
|
1082
1082
|
return [
|
|
1083
1083
|
4,
|
|
1084
|
-
scheduleStub.createSchedule(brainTitle, cronExpression, timezone, runAsUserName)
|
|
1084
|
+
scheduleStub.createSchedule(brainTitle, cronExpression, timezone, runAsUserName, body.options)
|
|
1085
1085
|
];
|
|
1086
1086
|
case 4:
|
|
1087
1087
|
schedule = _state.sent();
|
package/dist/src/schedule-do.js
CHANGED
|
@@ -260,13 +260,19 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
260
260
|
} catch (e) {
|
|
261
261
|
// Column already exists
|
|
262
262
|
}
|
|
263
|
+
// Migration: add options column for existing DOs
|
|
264
|
+
try {
|
|
265
|
+
_this.storage.exec("ALTER TABLE schedules ADD COLUMN options TEXT");
|
|
266
|
+
} catch (e) {
|
|
267
|
+
// Column already exists
|
|
268
|
+
}
|
|
263
269
|
return _this;
|
|
264
270
|
}
|
|
265
271
|
_create_class(ScheduleDO, [
|
|
266
272
|
{
|
|
267
273
|
key: "createSchedule",
|
|
268
274
|
value: function createSchedule(brainTitle, cronExpression) {
|
|
269
|
-
var timezone = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 'UTC', runAsUserName = arguments.length > 3 ? arguments[3] : void 0;
|
|
275
|
+
var timezone = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 'UTC', runAsUserName = arguments.length > 3 ? arguments[3] : void 0, options = arguments.length > 4 ? arguments[4] : void 0;
|
|
270
276
|
return _async_to_generator(function() {
|
|
271
277
|
var id, createdAt, alarm, nextRunAt;
|
|
272
278
|
return _ts_generator(this, function(_state) {
|
|
@@ -299,7 +305,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
299
305
|
// Note: Cron expression is validated at the API level before calling this method
|
|
300
306
|
// Calculate next run time
|
|
301
307
|
nextRunAt = this.calculateNextRunTime(cronExpression, createdAt, timezone);
|
|
302
|
-
this.storage.exec("INSERT INTO schedules (id, brain_title, cron_expression, timezone, enabled, created_at, next_run_at, run_as_user_name)\n VALUES (?, ?, ?, ?, 1, ?, ?, ?)", id, brainTitle, cronExpression, timezone, createdAt, nextRunAt, runAsUserName);
|
|
308
|
+
this.storage.exec("INSERT INTO schedules (id, brain_title, cron_expression, timezone, enabled, created_at, next_run_at, run_as_user_name, options)\n VALUES (?, ?, ?, ?, 1, ?, ?, ?, ?)", id, brainTitle, cronExpression, timezone, createdAt, nextRunAt, runAsUserName, options ? JSON.stringify(options) : null);
|
|
303
309
|
return [
|
|
304
310
|
2,
|
|
305
311
|
{
|
|
@@ -310,7 +316,8 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
310
316
|
enabled: true,
|
|
311
317
|
createdAt: createdAt,
|
|
312
318
|
nextRunAt: nextRunAt,
|
|
313
|
-
runAsUserName: runAsUserName
|
|
319
|
+
runAsUserName: runAsUserName,
|
|
320
|
+
options: options
|
|
314
321
|
}
|
|
315
322
|
];
|
|
316
323
|
}
|
|
@@ -324,7 +331,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
324
331
|
return _async_to_generator(function() {
|
|
325
332
|
var results, result;
|
|
326
333
|
return _ts_generator(this, function(_state) {
|
|
327
|
-
results = this.storage.exec("SELECT id, brain_title, cron_expression, timezone, enabled, created_at, next_run_at, run_as_user_name\n FROM schedules WHERE id = ?", scheduleId).toArray();
|
|
334
|
+
results = this.storage.exec("SELECT id, brain_title, cron_expression, timezone, enabled, created_at, next_run_at, run_as_user_name, options\n FROM schedules WHERE id = ?", scheduleId).toArray();
|
|
328
335
|
if (results.length === 0) {
|
|
329
336
|
return [
|
|
330
337
|
2,
|
|
@@ -342,7 +349,8 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
342
349
|
enabled: result.enabled === 1,
|
|
343
350
|
createdAt: result.created_at,
|
|
344
351
|
nextRunAt: result.next_run_at,
|
|
345
|
-
runAsUserName: result.run_as_user_name
|
|
352
|
+
runAsUserName: result.run_as_user_name,
|
|
353
|
+
options: result.options ? JSON.parse(result.options) : undefined
|
|
346
354
|
}
|
|
347
355
|
];
|
|
348
356
|
});
|
|
@@ -421,7 +429,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
421
429
|
_state.sent();
|
|
422
430
|
_state.label = 4;
|
|
423
431
|
case 4:
|
|
424
|
-
schedules = this.storage.exec("SELECT id, brain_title, cron_expression, timezone, enabled, created_at, next_run_at, run_as_user_name\n FROM schedules\n WHERE (? IS NULL OR run_as_user_name = ?)\n ORDER BY created_at DESC", userName, userName).toArray().map(function(row) {
|
|
432
|
+
schedules = this.storage.exec("SELECT id, brain_title, cron_expression, timezone, enabled, created_at, next_run_at, run_as_user_name, options\n FROM schedules\n WHERE (? IS NULL OR run_as_user_name = ?)\n ORDER BY created_at DESC", userName, userName).toArray().map(function(row) {
|
|
425
433
|
return {
|
|
426
434
|
id: row.id,
|
|
427
435
|
brainTitle: row.brain_title,
|
|
@@ -430,7 +438,8 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
430
438
|
enabled: row.enabled === 1,
|
|
431
439
|
createdAt: row.created_at,
|
|
432
440
|
nextRunAt: row.next_run_at,
|
|
433
|
-
runAsUserName: row.run_as_user_name
|
|
441
|
+
runAsUserName: row.run_as_user_name,
|
|
442
|
+
options: row.options ? JSON.parse(row.options) : undefined
|
|
434
443
|
};
|
|
435
444
|
});
|
|
436
445
|
return [
|
|
@@ -507,7 +516,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
507
516
|
value: // Handle the alarm trigger - runs every minute in a perpetual cycle
|
|
508
517
|
function alarm() {
|
|
509
518
|
return _async_to_generator(function() {
|
|
510
|
-
var now, dueSchedules, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, schedule, scheduleId, brainTitle, cronExpression, runAsUserName, brainRunId, error, errorMessage, timezone, nextRunAt, err;
|
|
519
|
+
var now, dueSchedules, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, schedule, scheduleId, brainTitle, cronExpression, runAsUserName, options, brainRunId, error, errorMessage, timezone, nextRunAt, err;
|
|
511
520
|
return _ts_generator(this, function(_state) {
|
|
512
521
|
switch(_state.label){
|
|
513
522
|
case 0:
|
|
@@ -522,7 +531,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
522
531
|
// checking every minute ensures we never miss a scheduled run.
|
|
523
532
|
// Get all enabled schedules that are due
|
|
524
533
|
now = Date.now();
|
|
525
|
-
dueSchedules = this.storage.exec("SELECT id, brain_title, cron_expression, timezone, run_as_user_name\n FROM schedules\n WHERE enabled = 1 AND next_run_at <= ?", now).toArray();
|
|
534
|
+
dueSchedules = this.storage.exec("SELECT id, brain_title, cron_expression, timezone, run_as_user_name, options\n FROM schedules\n WHERE enabled = 1 AND next_run_at <= ?", now).toArray();
|
|
526
535
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
527
536
|
_state.label = 1;
|
|
528
537
|
case 1:
|
|
@@ -544,6 +553,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
544
553
|
brainTitle = schedule.brain_title;
|
|
545
554
|
cronExpression = schedule.cron_expression;
|
|
546
555
|
runAsUserName = schedule.run_as_user_name;
|
|
556
|
+
options = schedule.options ? JSON.parse(schedule.options) : undefined;
|
|
547
557
|
_state.label = 3;
|
|
548
558
|
case 3:
|
|
549
559
|
_state.trys.push([
|
|
@@ -554,7 +564,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
554
564
|
]);
|
|
555
565
|
return [
|
|
556
566
|
4,
|
|
557
|
-
this.triggerBrainRun(brainTitle, runAsUserName)
|
|
567
|
+
this.triggerBrainRun(brainTitle, runAsUserName, options)
|
|
558
568
|
];
|
|
559
569
|
case 4:
|
|
560
570
|
brainRunId = _state.sent();
|
|
@@ -644,7 +654,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
644
654
|
},
|
|
645
655
|
{
|
|
646
656
|
key: "triggerBrainRun",
|
|
647
|
-
value: function triggerBrainRun(brainTitle, runAsUserName) {
|
|
657
|
+
value: function triggerBrainRun(brainTitle, runAsUserName, options) {
|
|
648
658
|
return _async_to_generator(function() {
|
|
649
659
|
var brainRunId, namespace, doId, stub;
|
|
650
660
|
return _ts_generator(this, function(_state) {
|
|
@@ -659,7 +669,9 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
659
669
|
4,
|
|
660
670
|
stub.start(brainTitle, brainRunId, {
|
|
661
671
|
name: runAsUserName
|
|
662
|
-
}
|
|
672
|
+
}, options ? {
|
|
673
|
+
options: options
|
|
674
|
+
} : undefined)
|
|
663
675
|
];
|
|
664
676
|
case 1:
|
|
665
677
|
_state.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brains.d.ts","sourceRoot":"","sources":["../../../src/api/brains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAM1C,OAAO,KAAK,EAAE,QAAQ,EAAiD,MAAM,YAAY,CAAC;AAE1F,QAAA,MAAM,MAAM;cAAwB,QAAQ;yCAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"brains.d.ts","sourceRoot":"","sources":["../../../src/api/brains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAM1C,OAAO,KAAK,EAAE,QAAQ,EAAiD,MAAM,YAAY,CAAC;AAE1F,QAAA,MAAM,MAAM;cAAwB,QAAQ;yCAAK,CAAC;AAqoBlD,eAAe,MAAM,CAAC"}
|
|
@@ -15,6 +15,7 @@ interface Schedule {
|
|
|
15
15
|
createdAt: number;
|
|
16
16
|
nextRunAt?: number;
|
|
17
17
|
runAsUserName: string;
|
|
18
|
+
options?: Record<string, string>;
|
|
18
19
|
}
|
|
19
20
|
interface ScheduledRun {
|
|
20
21
|
id: number;
|
|
@@ -28,7 +29,7 @@ interface ScheduledRun {
|
|
|
28
29
|
export declare class ScheduleDO extends DurableObject<Env> {
|
|
29
30
|
private readonly storage;
|
|
30
31
|
constructor(state: DurableObjectState, env: Env);
|
|
31
|
-
createSchedule(brainTitle: string, cronExpression: string, timezone: string | undefined, runAsUserName: string): Promise<Schedule>;
|
|
32
|
+
createSchedule(brainTitle: string, cronExpression: string, timezone: string | undefined, runAsUserName: string, options?: Record<string, string>): Promise<Schedule>;
|
|
32
33
|
getSchedule(scheduleId: string): Promise<Schedule | null>;
|
|
33
34
|
deleteSchedule(scheduleId: string): Promise<boolean>;
|
|
34
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule-do.d.ts","sourceRoot":"","sources":["../../src/schedule-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,GAAG;IAClB,eAAe,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SA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|
|
6
6
|
},
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"clean": "rm -rf tsconfig.tsbuildinfo dist"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@positronic/core": "^0.0.
|
|
35
|
-
"@positronic/spec": "^0.0.
|
|
36
|
-
"@positronic/template-new-project": "^0.0.
|
|
34
|
+
"@positronic/core": "^0.0.75",
|
|
35
|
+
"@positronic/spec": "^0.0.75",
|
|
36
|
+
"@positronic/template-new-project": "^0.0.75",
|
|
37
37
|
"aws4fetch": "^1.0.18",
|
|
38
38
|
"caz": "^2.0.0",
|
|
39
39
|
"croner": "^10.0.1",
|