@convex-dev/crons 0.1.4 → 0.1.6-alpha.0
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/README.md +18 -2
- package/dist/commonjs/client/index.d.ts +39 -0
- package/dist/commonjs/client/index.d.ts.map +1 -1
- package/dist/commonjs/client/index.js +39 -34
- package/dist/commonjs/client/index.js.map +1 -1
- package/dist/commonjs/component/public.d.ts +17 -0
- package/dist/commonjs/component/public.d.ts.map +1 -1
- package/dist/commonjs/component/public.js.map +1 -1
- package/dist/esm/client/index.d.ts +39 -0
- package/dist/esm/client/index.d.ts.map +1 -1
- package/dist/esm/client/index.js +39 -34
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/component/public.d.ts +17 -0
- package/dist/esm/component/public.d.ts.map +1 -1
- package/dist/esm/component/public.js.map +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +39 -35
- package/src/component/public.ts +26 -2
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/@convex-dev%2Fcrons)
|
|
4
4
|
|
|
5
|
-
**Note: Convex Components are currently in beta.**
|
|
6
|
-
|
|
7
5
|
<!-- START: Include on https://convex.dev/components -->
|
|
8
6
|
|
|
9
7
|
This Convex component provides functionality for registering and managing cron
|
|
@@ -11,6 +9,24 @@ jobs at runtime. Convex comes with built-in support for cron jobs but they must
|
|
|
11
9
|
be statically defined at deployment time. This library allows for dynamic
|
|
12
10
|
registration of cron jobs at runtime.
|
|
13
11
|
|
|
12
|
+
```ts
|
|
13
|
+
// Register a cron to run once per day.
|
|
14
|
+
const daily = await crons.register(
|
|
15
|
+
ctx,
|
|
16
|
+
{ kind: "cron", cronspec: "0 0 * * *" },
|
|
17
|
+
internal.example.logStuff,
|
|
18
|
+
{ message: "daily cron" }
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// Register a cron to run every hour.
|
|
22
|
+
const hourly = await crons.register(
|
|
23
|
+
ctx,
|
|
24
|
+
{ kind: "interval", ms: 3600000 },
|
|
25
|
+
internal.example.logStuff,
|
|
26
|
+
{ message: "hourly cron" }
|
|
27
|
+
);
|
|
28
|
+
```
|
|
29
|
+
|
|
14
30
|
It supports intervals in milliseconds as well as cron schedules with the same
|
|
15
31
|
format as the unix `cron` command:
|
|
16
32
|
|
|
@@ -5,6 +5,45 @@ import { RunMutationCtx, RunQueryCtx, UseApi } from "./utils.js";
|
|
|
5
5
|
export type { CronInfo };
|
|
6
6
|
export declare class Crons {
|
|
7
7
|
private component;
|
|
8
|
+
/**
|
|
9
|
+
* Implementation of crons in user space.
|
|
10
|
+
*
|
|
11
|
+
* Supports intervals in ms as well as cron schedules with the same format as
|
|
12
|
+
* the unix `cron` command:
|
|
13
|
+
*
|
|
14
|
+
* ```
|
|
15
|
+
* * * * * * *
|
|
16
|
+
* ┬ ┬ ┬ ┬ ┬ ┬
|
|
17
|
+
* │ │ │ │ │ |
|
|
18
|
+
* │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
19
|
+
* │ │ │ │ └───── month (1 - 12)
|
|
20
|
+
* │ │ │ └──────── day of month (1 - 31, L)
|
|
21
|
+
* │ │ └─────────── hour (0 - 23)
|
|
22
|
+
* │ └────────────── minute (0 - 59)
|
|
23
|
+
* └───────────────── second (0 - 59, optional)
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Crons can be registered at runtime via the `register` function.
|
|
27
|
+
*
|
|
28
|
+
* If you'd like to statically define cronjobs like in the built-in `crons.ts`
|
|
29
|
+
* Convex feature you can do so via an init script that idempotently registers a
|
|
30
|
+
* cron with a given name. e.g., in an `init.ts` file that gets run on every
|
|
31
|
+
* deploy via `convex dev --run init`:
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const crons = new Crons(components.crons);
|
|
35
|
+
* ...
|
|
36
|
+
* if ((await crons.get(ctx, { name: "daily" })) === null) {
|
|
37
|
+
* await crons.register(
|
|
38
|
+
* ctx,
|
|
39
|
+
* { kind: "cron", cronspec: "0 0 * * *" },
|
|
40
|
+
* internal.example.logStuff,
|
|
41
|
+
* { message: "daily cron" },
|
|
42
|
+
* "daily"
|
|
43
|
+
* );
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
8
47
|
constructor(component: UseApi<typeof api>);
|
|
9
48
|
/**
|
|
10
49
|
* Schedule a mutation or action to run on a cron schedule or interval.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAEZ,4BAA4B,EAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEjE,YAAY,EAAE,QAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAEZ,4BAA4B,EAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEjE,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB,qBAAa,KAAK;IAwCJ,OAAO,CAAC,SAAS;IAvC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;gBACiB,SAAS,EAAE,MAAM,CAAC,OAAO,GAAG,CAAC;IAEjD;;;;;;;;;;;OAWG;IACG,QAAQ,CAAC,CAAC,SAAS,4BAA4B,EACnD,GAAG,EAAE,cAAc,EACnB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC;IASlB;;;;OAIG;IACG,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAUjD;;;;;OAKG;IACG,GAAG,CACP,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAC5C,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAa3B;;;;OAIG;IACG,MAAM,CACV,GAAG,EAAE,cAAc,EACnB,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAC5C,OAAO,CAAC,IAAI,CAAC;CAGjB"}
|
|
@@ -1,41 +1,46 @@
|
|
|
1
1
|
// Client side implementation of the Crons component.
|
|
2
2
|
import { createFunctionHandle, } from "convex/server";
|
|
3
|
-
// TODO (james): should we add helpers for minutely, hourly, etc schedules?
|
|
4
|
-
// Implementation of crons in user space.
|
|
5
|
-
//
|
|
6
|
-
// Supports intervals in ms as well as cron schedules with the same format as
|
|
7
|
-
// the unix `cron` command:
|
|
8
|
-
//
|
|
9
|
-
// * * * * * *
|
|
10
|
-
// ┬ ┬ ┬ ┬ ┬ ┬
|
|
11
|
-
// │ │ │ │ │ |
|
|
12
|
-
// │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
13
|
-
// │ │ │ │ └───── month (1 - 12)
|
|
14
|
-
// │ │ │ └──────── day of month (1 - 31, L)
|
|
15
|
-
// │ │ └─────────── hour (0 - 23)
|
|
16
|
-
// │ └────────────── minute (0 - 59)
|
|
17
|
-
// └───────────────── second (0 - 59, optional)
|
|
18
|
-
//
|
|
19
|
-
// Crons can be registered at runtime via the `register` function.
|
|
20
|
-
//
|
|
21
|
-
// If you'd like to statically define cronjobs like in the built-in `crons.ts`
|
|
22
|
-
// Convex feature you can do so via an init script that idempotently registers a
|
|
23
|
-
// cron with a given name. e.g., in an `init.ts` file that gets run on every
|
|
24
|
-
// deploy via `convex dev --run init`:
|
|
25
|
-
//
|
|
26
|
-
// const crons = new Crons(components.crons);
|
|
27
|
-
// ...
|
|
28
|
-
// if ((await crons.get(ctx, { name: "daily" })) === null) {
|
|
29
|
-
// await crons.register(
|
|
30
|
-
// ctx,
|
|
31
|
-
// { kind: "cron", cronspec: "0 0 * * *" },
|
|
32
|
-
// internal.example.logStuff,
|
|
33
|
-
// { message: "daily cron" },
|
|
34
|
-
// "daily"
|
|
35
|
-
// );
|
|
36
|
-
// }
|
|
37
3
|
export class Crons {
|
|
38
4
|
component;
|
|
5
|
+
/**
|
|
6
|
+
* Implementation of crons in user space.
|
|
7
|
+
*
|
|
8
|
+
* Supports intervals in ms as well as cron schedules with the same format as
|
|
9
|
+
* the unix `cron` command:
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* * * * * * *
|
|
13
|
+
* ┬ ┬ ┬ ┬ ┬ ┬
|
|
14
|
+
* │ │ │ │ │ |
|
|
15
|
+
* │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
16
|
+
* │ │ │ │ └───── month (1 - 12)
|
|
17
|
+
* │ │ │ └──────── day of month (1 - 31, L)
|
|
18
|
+
* │ │ └─────────── hour (0 - 23)
|
|
19
|
+
* │ └────────────── minute (0 - 59)
|
|
20
|
+
* └───────────────── second (0 - 59, optional)
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Crons can be registered at runtime via the `register` function.
|
|
24
|
+
*
|
|
25
|
+
* If you'd like to statically define cronjobs like in the built-in `crons.ts`
|
|
26
|
+
* Convex feature you can do so via an init script that idempotently registers a
|
|
27
|
+
* cron with a given name. e.g., in an `init.ts` file that gets run on every
|
|
28
|
+
* deploy via `convex dev --run init`:
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* const crons = new Crons(components.crons);
|
|
32
|
+
* ...
|
|
33
|
+
* if ((await crons.get(ctx, { name: "daily" })) === null) {
|
|
34
|
+
* await crons.register(
|
|
35
|
+
* ctx,
|
|
36
|
+
* { kind: "cron", cronspec: "0 0 * * *" },
|
|
37
|
+
* internal.example.logStuff,
|
|
38
|
+
* { message: "daily cron" },
|
|
39
|
+
* "daily"
|
|
40
|
+
* );
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
39
44
|
constructor(component) {
|
|
40
45
|
this.component = component;
|
|
41
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,EACL,oBAAoB,GAIrB,MAAM,eAAe,CAAC;AAOvB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,EACL,oBAAoB,GAIrB,MAAM,eAAe,CAAC;AAOvB,MAAM,OAAO,KAAK;IAwCI;IAvCpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,YAAoB,SAA6B;QAA7B,cAAS,GAAT,SAAS,CAAoB;IAAG,CAAC;IAErD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CACZ,GAAmB,EACnB,QAAkB,EAClB,IAAO,EACP,IAAqB,EACrB,IAAa;QAEb,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE;YACrD,IAAI;YACJ,QAAQ;YACR,cAAc,EAAE,MAAM,oBAAoB,CAAC,IAAI,CAAC;YAChD,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,GAAgB;QACzB,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACjE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC1B,GAAG,IAAI;YACP,cAAc,EAAE,IAAI,CAAC,cAEpB;SACF,CAAC,CAAC,CAAC;IACN,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CACP,GAAgB,EAChB,UAA6C;QAE7C,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QAC3E,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,OAAO,IAAI,CAAC;SACb;QACD,OAAO;YACL,GAAG,IAAI;YACP,cAAc,EAAE,IAAI,CAAC,cAEpB;SACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CACV,GAAmB,EACnB,UAA6C;QAE7C,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IACpE,CAAC;CACF"}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import { FunctionHandle } from "convex/server";
|
|
2
2
|
export type Schedule = {
|
|
3
|
+
/** A schedule using a cron specification string. */
|
|
3
4
|
kind: "cron";
|
|
5
|
+
/**
|
|
6
|
+
* A cron specification string.
|
|
7
|
+
* ```
|
|
8
|
+
* * * * * * *
|
|
9
|
+
* ┬ ┬ ┬ ┬ ┬ ┬
|
|
10
|
+
* │ │ │ │ │ |
|
|
11
|
+
* │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
12
|
+
* │ │ │ │ └───── month (1 - 12)
|
|
13
|
+
* │ │ │ └──────── day of month (1 - 31, L)
|
|
14
|
+
* │ │ └─────────── hour (0 - 23)
|
|
15
|
+
* │ └────────────── minute (0 - 59)
|
|
16
|
+
* └───────────────── second (0 - 59, optional)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
4
19
|
cronspec: string;
|
|
5
20
|
} | {
|
|
21
|
+
/** A schedule using an interval in milliseconds. */
|
|
6
22
|
kind: "interval";
|
|
23
|
+
/** The interval in milliseconds. */
|
|
7
24
|
ms: number;
|
|
8
25
|
};
|
|
9
26
|
export type CronInfo = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/component/public.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/component/public.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAc/C,MAAM,MAAM,QAAQ,GAChB;IACE,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;;;OAaG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IACE,oDAAoD;IACpD,IAAI,EAAE,UAAU,CAAC;IACjB,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAGN,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,cAAc,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;IACtD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AASF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;uDAiCnB,CAAC;AAyCH;;;;GAIG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;KAaf,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;UAyBd,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,GAAG;;;;;;iBAoCd,CAAC;AASH,eAAO,MAAM,WAAW;;iBA4DtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/component/public.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,6CAA6C;AAG7C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAEL,QAAQ,EACR,KAAK,EACL,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,MAAM,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/component/public.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,6CAA6C;AAG7C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAEL,QAAQ,EACR,KAAK,EACL,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,MAAM,MAAM,aAAa,CAAC;AA6BjC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC;AASxE,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC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8E;QAC9E,IAAI,YAAY,GAAG,KAAK,CAAC;QACzB,IAAI,OAAO,CAAC,cAAc,EAAE;YAC1B,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YACrE,IACE,YAAY;gBACZ,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS;oBACpC,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,EAC3C;gBACA,YAAY,GAAG,IAAI,CAAC;aACrB;SACF;QACD,IAAI,YAAY,EAAE;YAChB,OAAO,CAAC,GAAG,CAAC,QAAQ,OAAO,CAAC,GAAG,oCAAoC,CAAC,CAAC;SACtE;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;YAC5C,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,CAC1B,CAAC,EACD,OAAO,CAAC,cAAuD,EAC/D,OAAO,CAAC,IAAI,CACb,CAAC;SACH;QAED,MAAM,eAAe,CACnB,GAAG,EACH,EAAE,EACF,IAAI,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,EACpC,OAAO,CAAC,QAAQ,CACjB,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -5,6 +5,45 @@ import { RunMutationCtx, RunQueryCtx, UseApi } from "./utils.js";
|
|
|
5
5
|
export type { CronInfo };
|
|
6
6
|
export declare class Crons {
|
|
7
7
|
private component;
|
|
8
|
+
/**
|
|
9
|
+
* Implementation of crons in user space.
|
|
10
|
+
*
|
|
11
|
+
* Supports intervals in ms as well as cron schedules with the same format as
|
|
12
|
+
* the unix `cron` command:
|
|
13
|
+
*
|
|
14
|
+
* ```
|
|
15
|
+
* * * * * * *
|
|
16
|
+
* ┬ ┬ ┬ ┬ ┬ ┬
|
|
17
|
+
* │ │ │ │ │ |
|
|
18
|
+
* │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
19
|
+
* │ │ │ │ └───── month (1 - 12)
|
|
20
|
+
* │ │ │ └──────── day of month (1 - 31, L)
|
|
21
|
+
* │ │ └─────────── hour (0 - 23)
|
|
22
|
+
* │ └────────────── minute (0 - 59)
|
|
23
|
+
* └───────────────── second (0 - 59, optional)
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Crons can be registered at runtime via the `register` function.
|
|
27
|
+
*
|
|
28
|
+
* If you'd like to statically define cronjobs like in the built-in `crons.ts`
|
|
29
|
+
* Convex feature you can do so via an init script that idempotently registers a
|
|
30
|
+
* cron with a given name. e.g., in an `init.ts` file that gets run on every
|
|
31
|
+
* deploy via `convex dev --run init`:
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const crons = new Crons(components.crons);
|
|
35
|
+
* ...
|
|
36
|
+
* if ((await crons.get(ctx, { name: "daily" })) === null) {
|
|
37
|
+
* await crons.register(
|
|
38
|
+
* ctx,
|
|
39
|
+
* { kind: "cron", cronspec: "0 0 * * *" },
|
|
40
|
+
* internal.example.logStuff,
|
|
41
|
+
* { message: "daily cron" },
|
|
42
|
+
* "daily"
|
|
43
|
+
* );
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
8
47
|
constructor(component: UseApi<typeof api>);
|
|
9
48
|
/**
|
|
10
49
|
* Schedule a mutation or action to run on a cron schedule or interval.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAEZ,4BAA4B,EAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EA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AE,MAAM,CAAA;KAAE,GAC5C,OAAO,CAAC,IAAI,CAAC;CAGjB"}
|
package/dist/esm/client/index.js
CHANGED
|
@@ -1,41 +1,46 @@
|
|
|
1
1
|
// Client side implementation of the Crons component.
|
|
2
2
|
import { createFunctionHandle, } from "convex/server";
|
|
3
|
-
// TODO (james): should we add helpers for minutely, hourly, etc schedules?
|
|
4
|
-
// Implementation of crons in user space.
|
|
5
|
-
//
|
|
6
|
-
// Supports intervals in ms as well as cron schedules with the same format as
|
|
7
|
-
// the unix `cron` command:
|
|
8
|
-
//
|
|
9
|
-
// * * * * * *
|
|
10
|
-
// ┬ ┬ ┬ ┬ ┬ ┬
|
|
11
|
-
// │ │ │ │ │ |
|
|
12
|
-
// │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
13
|
-
// │ │ │ │ └───── month (1 - 12)
|
|
14
|
-
// │ │ │ └──────── day of month (1 - 31, L)
|
|
15
|
-
// │ │ └─────────── hour (0 - 23)
|
|
16
|
-
// │ └────────────── minute (0 - 59)
|
|
17
|
-
// └───────────────── second (0 - 59, optional)
|
|
18
|
-
//
|
|
19
|
-
// Crons can be registered at runtime via the `register` function.
|
|
20
|
-
//
|
|
21
|
-
// If you'd like to statically define cronjobs like in the built-in `crons.ts`
|
|
22
|
-
// Convex feature you can do so via an init script that idempotently registers a
|
|
23
|
-
// cron with a given name. e.g., in an `init.ts` file that gets run on every
|
|
24
|
-
// deploy via `convex dev --run init`:
|
|
25
|
-
//
|
|
26
|
-
// const crons = new Crons(components.crons);
|
|
27
|
-
// ...
|
|
28
|
-
// if ((await crons.get(ctx, { name: "daily" })) === null) {
|
|
29
|
-
// await crons.register(
|
|
30
|
-
// ctx,
|
|
31
|
-
// { kind: "cron", cronspec: "0 0 * * *" },
|
|
32
|
-
// internal.example.logStuff,
|
|
33
|
-
// { message: "daily cron" },
|
|
34
|
-
// "daily"
|
|
35
|
-
// );
|
|
36
|
-
// }
|
|
37
3
|
export class Crons {
|
|
38
4
|
component;
|
|
5
|
+
/**
|
|
6
|
+
* Implementation of crons in user space.
|
|
7
|
+
*
|
|
8
|
+
* Supports intervals in ms as well as cron schedules with the same format as
|
|
9
|
+
* the unix `cron` command:
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* * * * * * *
|
|
13
|
+
* ┬ ┬ ┬ ┬ ┬ ┬
|
|
14
|
+
* │ │ │ │ │ |
|
|
15
|
+
* │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
16
|
+
* │ │ │ │ └───── month (1 - 12)
|
|
17
|
+
* │ │ │ └──────── day of month (1 - 31, L)
|
|
18
|
+
* │ │ └─────────── hour (0 - 23)
|
|
19
|
+
* │ └────────────── minute (0 - 59)
|
|
20
|
+
* └───────────────── second (0 - 59, optional)
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Crons can be registered at runtime via the `register` function.
|
|
24
|
+
*
|
|
25
|
+
* If you'd like to statically define cronjobs like in the built-in `crons.ts`
|
|
26
|
+
* Convex feature you can do so via an init script that idempotently registers a
|
|
27
|
+
* cron with a given name. e.g., in an `init.ts` file that gets run on every
|
|
28
|
+
* deploy via `convex dev --run init`:
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* const crons = new Crons(components.crons);
|
|
32
|
+
* ...
|
|
33
|
+
* if ((await crons.get(ctx, { name: "daily" })) === null) {
|
|
34
|
+
* await crons.register(
|
|
35
|
+
* ctx,
|
|
36
|
+
* { kind: "cron", cronspec: "0 0 * * *" },
|
|
37
|
+
* internal.example.logStuff,
|
|
38
|
+
* { message: "daily cron" },
|
|
39
|
+
* "daily"
|
|
40
|
+
* );
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
39
44
|
constructor(component) {
|
|
40
45
|
this.component = component;
|
|
41
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client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QAC3E,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,OAAO,IAAI,CAAC;SACb;QACD,OAAO;YACL,GAAG,IAAI;YACP,cAAc,EAAE,IAAI,CAAC,cAEpB;SACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CACV,GAAmB,EACnB,UAA6C;QAE7C,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IACpE,CAAC;CACF"}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import { FunctionHandle } from "convex/server";
|
|
2
2
|
export type Schedule = {
|
|
3
|
+
/** A schedule using a cron specification string. */
|
|
3
4
|
kind: "cron";
|
|
5
|
+
/**
|
|
6
|
+
* A cron specification string.
|
|
7
|
+
* ```
|
|
8
|
+
* * * * * * *
|
|
9
|
+
* ┬ ┬ ┬ ┬ ┬ ┬
|
|
10
|
+
* │ │ │ │ │ |
|
|
11
|
+
* │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
12
|
+
* │ │ │ │ └───── month (1 - 12)
|
|
13
|
+
* │ │ │ └──────── day of month (1 - 31, L)
|
|
14
|
+
* │ │ └─────────── hour (0 - 23)
|
|
15
|
+
* │ └────────────── minute (0 - 59)
|
|
16
|
+
* └───────────────── second (0 - 59, optional)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
4
19
|
cronspec: string;
|
|
5
20
|
} | {
|
|
21
|
+
/** A schedule using an interval in milliseconds. */
|
|
6
22
|
kind: "interval";
|
|
23
|
+
/** The interval in milliseconds. */
|
|
7
24
|
ms: number;
|
|
8
25
|
};
|
|
9
26
|
export type CronInfo = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/component/public.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/component/public.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAc/C,MAAM,MAAM,QAAQ,GAChB;IACE,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;;;OAaG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IACE,oDAAoD;IACpD,IAAI,EAAE,UAAU,CAAC;IACjB,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAGN,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,cAAc,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;IACtD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AASF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;uDAiCnB,CAAC;AAyCH;;;;GAIG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;KAaf,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;UAyBd,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,GAAG;;;;;;iBAoCd,CAAC;AASH,eAAO,MAAM,WAAW;;iBA4DtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/component/public.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,6CAA6C;AAG7C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAEL,QAAQ,EACR,KAAK,EACL,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,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OAAO,CAAC,cAAuD,EAC/D,OAAO,CAAC,IAAI,CACb,CAAC;SACH;QAED,MAAM,eAAe,CACnB,GAAG,EACH,EAAE,EACF,IAAI,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,EACpC,OAAO,CAAC,QAAQ,CACjB,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/client/index.ts
CHANGED
|
@@ -12,42 +12,46 @@ import { RunMutationCtx, RunQueryCtx, UseApi } from "./utils.js";
|
|
|
12
12
|
|
|
13
13
|
export type { CronInfo };
|
|
14
14
|
|
|
15
|
-
// TODO (james): should we add helpers for minutely, hourly, etc schedules?
|
|
16
|
-
|
|
17
|
-
// Implementation of crons in user space.
|
|
18
|
-
//
|
|
19
|
-
// Supports intervals in ms as well as cron schedules with the same format as
|
|
20
|
-
// the unix `cron` command:
|
|
21
|
-
//
|
|
22
|
-
// * * * * * *
|
|
23
|
-
// ┬ ┬ ┬ ┬ ┬ ┬
|
|
24
|
-
// │ │ │ │ │ |
|
|
25
|
-
// │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
26
|
-
// │ │ │ │ └───── month (1 - 12)
|
|
27
|
-
// │ │ │ └──────── day of month (1 - 31, L)
|
|
28
|
-
// │ │ └─────────── hour (0 - 23)
|
|
29
|
-
// │ └────────────── minute (0 - 59)
|
|
30
|
-
// └───────────────── second (0 - 59, optional)
|
|
31
|
-
//
|
|
32
|
-
// Crons can be registered at runtime via the `register` function.
|
|
33
|
-
//
|
|
34
|
-
// If you'd like to statically define cronjobs like in the built-in `crons.ts`
|
|
35
|
-
// Convex feature you can do so via an init script that idempotently registers a
|
|
36
|
-
// cron with a given name. e.g., in an `init.ts` file that gets run on every
|
|
37
|
-
// deploy via `convex dev --run init`:
|
|
38
|
-
//
|
|
39
|
-
// const crons = new Crons(components.crons);
|
|
40
|
-
// ...
|
|
41
|
-
// if ((await crons.get(ctx, { name: "daily" })) === null) {
|
|
42
|
-
// await crons.register(
|
|
43
|
-
// ctx,
|
|
44
|
-
// { kind: "cron", cronspec: "0 0 * * *" },
|
|
45
|
-
// internal.example.logStuff,
|
|
46
|
-
// { message: "daily cron" },
|
|
47
|
-
// "daily"
|
|
48
|
-
// );
|
|
49
|
-
// }
|
|
50
15
|
export class Crons {
|
|
16
|
+
/**
|
|
17
|
+
* Implementation of crons in user space.
|
|
18
|
+
*
|
|
19
|
+
* Supports intervals in ms as well as cron schedules with the same format as
|
|
20
|
+
* the unix `cron` command:
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
* * * * * * *
|
|
24
|
+
* ┬ ┬ ┬ ┬ ┬ ┬
|
|
25
|
+
* │ │ │ │ │ |
|
|
26
|
+
* │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
27
|
+
* │ │ │ │ └───── month (1 - 12)
|
|
28
|
+
* │ │ │ └──────── day of month (1 - 31, L)
|
|
29
|
+
* │ │ └─────────── hour (0 - 23)
|
|
30
|
+
* │ └────────────── minute (0 - 59)
|
|
31
|
+
* └───────────────── second (0 - 59, optional)
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Crons can be registered at runtime via the `register` function.
|
|
35
|
+
*
|
|
36
|
+
* If you'd like to statically define cronjobs like in the built-in `crons.ts`
|
|
37
|
+
* Convex feature you can do so via an init script that idempotently registers a
|
|
38
|
+
* cron with a given name. e.g., in an `init.ts` file that gets run on every
|
|
39
|
+
* deploy via `convex dev --run init`:
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* const crons = new Crons(components.crons);
|
|
43
|
+
* ...
|
|
44
|
+
* if ((await crons.get(ctx, { name: "daily" })) === null) {
|
|
45
|
+
* await crons.register(
|
|
46
|
+
* ctx,
|
|
47
|
+
* { kind: "cron", cronspec: "0 0 * * *" },
|
|
48
|
+
* internal.example.logStuff,
|
|
49
|
+
* { message: "daily cron" },
|
|
50
|
+
* "daily"
|
|
51
|
+
* );
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
51
55
|
constructor(private component: UseApi<typeof api>) {}
|
|
52
56
|
|
|
53
57
|
/**
|
package/src/component/public.ts
CHANGED
|
@@ -15,9 +15,33 @@ import { Doc, Id } from "./_generated/dataModel.js";
|
|
|
15
15
|
import parser from "cron-parser";
|
|
16
16
|
import schema from "./schema.js";
|
|
17
17
|
|
|
18
|
+
// TODO (james): should we add helpers for minutely, hourly, etc schedules?
|
|
18
19
|
export type Schedule =
|
|
19
|
-
| {
|
|
20
|
-
|
|
20
|
+
| {
|
|
21
|
+
/** A schedule using a cron specification string. */
|
|
22
|
+
kind: "cron";
|
|
23
|
+
/**
|
|
24
|
+
* A cron specification string.
|
|
25
|
+
* ```
|
|
26
|
+
* * * * * * *
|
|
27
|
+
* ┬ ┬ ┬ ┬ ┬ ┬
|
|
28
|
+
* │ │ │ │ │ |
|
|
29
|
+
* │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun)
|
|
30
|
+
* │ │ │ │ └───── month (1 - 12)
|
|
31
|
+
* │ │ │ └──────── day of month (1 - 31, L)
|
|
32
|
+
* │ │ └─────────── hour (0 - 23)
|
|
33
|
+
* │ └────────────── minute (0 - 59)
|
|
34
|
+
* └───────────────── second (0 - 59, optional)
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
cronspec: string;
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
/** A schedule using an interval in milliseconds. */
|
|
41
|
+
kind: "interval";
|
|
42
|
+
/** The interval in milliseconds. */
|
|
43
|
+
ms: number;
|
|
44
|
+
};
|
|
21
45
|
const scheduleValidator = schema.tables.crons.validator.fields.schedule;
|
|
22
46
|
|
|
23
47
|
export type CronInfo = {
|