@rebasepro/server-mongodb 0.0.1-canary.94dff14 → 0.0.1-canary.bbcb8b4
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.
|
@@ -2,6 +2,16 @@ import type { CronJobStatus, CronJobLogEntry } from "@rebasepro/types";
|
|
|
2
2
|
import type { RebaseClient } from "@rebasepro/client";
|
|
3
3
|
import type { LoadedCronJob } from "./cron-loader";
|
|
4
4
|
import type { CronStore } from "./cron-store";
|
|
5
|
+
/**
|
|
6
|
+
* Validates a standard 5-field cron expression structurally and semantically.
|
|
7
|
+
* Returns `{ valid: true }` or `{ valid: false, reason: string }`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateCronExpression(schedule: string): {
|
|
10
|
+
valid: true;
|
|
11
|
+
} | {
|
|
12
|
+
valid: false;
|
|
13
|
+
reason: string;
|
|
14
|
+
};
|
|
5
15
|
export declare class CronScheduler {
|
|
6
16
|
private jobs;
|
|
7
17
|
private started;
|
|
@@ -19,6 +29,12 @@ export declare class CronScheduler {
|
|
|
19
29
|
setStore(store: CronStore): void;
|
|
20
30
|
/**
|
|
21
31
|
* Register a batch of loaded cron jobs.
|
|
32
|
+
*
|
|
33
|
+
* If the scheduler is already started, newly registered jobs are
|
|
34
|
+
* automatically scheduled (so late-registered jobs don't sit idle).
|
|
35
|
+
*
|
|
36
|
+
* Validates the cron schedule on registration — invalid schedules
|
|
37
|
+
* are rejected with a warning and the job is NOT registered.
|
|
22
38
|
*/
|
|
23
39
|
registerJobs(loadedJobs: LoadedCronJob[]): void;
|
|
24
40
|
/**
|
|
@@ -27,6 +43,9 @@ export declare class CronScheduler {
|
|
|
27
43
|
start(): void;
|
|
28
44
|
/**
|
|
29
45
|
* Stop the scheduler and clear all timers.
|
|
46
|
+
*
|
|
47
|
+
* Currently-executing handlers run to completion (they are async),
|
|
48
|
+
* but no further scheduling occurs after stop.
|
|
30
49
|
*/
|
|
31
50
|
stop(): void;
|
|
32
51
|
/**
|
|
@@ -52,10 +71,36 @@ export declare class CronScheduler {
|
|
|
52
71
|
setJobEnabled(id: string, enabled: boolean): CronJobStatus | undefined;
|
|
53
72
|
/**
|
|
54
73
|
* Manually trigger a job execution immediately.
|
|
74
|
+
*
|
|
75
|
+
* Returns `undefined` if the job doesn't exist.
|
|
76
|
+
* If the job is currently executing, returns the log entry with
|
|
77
|
+
* a `skipped: true` result rather than running concurrently.
|
|
55
78
|
*/
|
|
56
79
|
triggerJob(id: string): Promise<CronJobLogEntry | undefined>;
|
|
80
|
+
/**
|
|
81
|
+
* Schedule the next execution for a job.
|
|
82
|
+
*
|
|
83
|
+
* Safety guarantees:
|
|
84
|
+
* 1. Clears any existing timer first (prevents leaked/duplicate timers)
|
|
85
|
+
* 2. Enforces a minimum delay to prevent tight loops from jitter
|
|
86
|
+
* 3. Unref's the timer so it doesn't prevent process exit
|
|
87
|
+
* 4. Re-checks enabled & started state before executing
|
|
88
|
+
* 5. Concurrency guard prevents overlapping handler executions
|
|
89
|
+
*/
|
|
57
90
|
private scheduleNext;
|
|
91
|
+
/**
|
|
92
|
+
* Stop a single job's timer and clear its next run state.
|
|
93
|
+
*/
|
|
58
94
|
private stopJob;
|
|
95
|
+
/**
|
|
96
|
+
* Execute a job's handler with full isolation and safety.
|
|
97
|
+
*
|
|
98
|
+
* - Sets a concurrency flag to prevent overlapping runs
|
|
99
|
+
* - Wraps handler in a timeout race
|
|
100
|
+
* - Captures all logs, errors, and results
|
|
101
|
+
* - Persists to store (non-blocking) if available
|
|
102
|
+
* - Always restores state even on catastrophic errors
|
|
103
|
+
*/
|
|
59
104
|
private executeJob;
|
|
60
105
|
private toStatus;
|
|
61
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron-scheduler.d.ts","sourceRoot":"","sources":["../../../../../server-core/src/cron/cron-scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,aAAa,EACb,eAAe,EAGlB,MAAM,kBAAkB,CAAC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AAG,SAAS;IAK7C;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE;IAOzD;;;OAGG;IACG,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAS9E;;OAEG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS;IAiBtE;;;;;;OAMG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IA2BlE;;;;;;;;;OASG;IACH,OAAO,CAAC,YAAY;IAoDpB;;OAEG;IACH,OAAO,CAAC,OAAO;IASf;;;;;;;;OAQG;YACW,UAAU;IAiGxB,OAAO,CAAC,QAAQ;CAgBnB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { loadCronJobsFromDirectory } from "./cron-loader";
|
|
2
2
|
export type { LoadedCronJob } from "./cron-loader";
|
|
3
|
-
export { CronScheduler } from "./cron-scheduler";
|
|
3
|
+
export { CronScheduler, validateCronExpression } from "./cron-scheduler";
|
|
4
4
|
export { createCronRoutes } from "./cron-routes";
|
|
5
5
|
export { createCronStore } from "./cron-store";
|
|
6
6
|
export type { CronStore } from "./cron-store";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../server-core/src/cron/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../server-core/src/cron/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/server-mongodb",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.1-canary.
|
|
4
|
+
"version": "0.0.1-canary.bbcb8b4",
|
|
5
5
|
"description": "MongoDB backend for Rebase",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"mongodb": "^6.12.0",
|
|
43
43
|
"realm-web": "^2.0.0",
|
|
44
|
-
"@rebasepro/types": "0.0.1-canary.
|
|
44
|
+
"@rebasepro/types": "0.0.1-canary.bbcb8b4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/jest": "^29.5.14",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"ts-jest": "29.4.1",
|
|
52
52
|
"typescript": "^5.0.0",
|
|
53
53
|
"vite": "^5.0.0",
|
|
54
|
-
"@rebasepro/types": "0.0.1-canary.
|
|
54
|
+
"@rebasepro/types": "0.0.1-canary.bbcb8b4"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@rebasepro/server-core": "0.0.1-canary.
|
|
57
|
+
"@rebasepro/server-core": "0.0.1-canary.bbcb8b4"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"@rebasepro/server-core": {
|