@convex-dev/crons 0.1.8 → 0.2.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 -16
- package/dist/{commonjs/client → client}/index.d.ts +5 -5
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/utils.d.ts +8 -0
- package/dist/client/utils.d.ts.map +1 -0
- package/dist/client/utils.js +2 -0
- package/dist/{commonjs/client → client}/utils.js.map +1 -1
- package/dist/component/_generated/api.d.ts +34 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/{src → dist}/component/_generated/api.js +11 -7
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +79 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/{src → dist}/component/_generated/server.d.ts +10 -42
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/{commonjs/component → component}/_generated/server.js +9 -7
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/{commonjs/component → component}/public.d.ts +6 -2
- package/dist/component/public.d.ts.map +1 -0
- package/dist/{commonjs/component → component}/public.js +2 -1
- package/dist/component/public.js.map +1 -0
- package/dist/{commonjs/component → component}/schema.d.ts +7 -3
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/{commonjs/component → component}/schema.js +3 -2
- package/dist/component/schema.js.map +1 -0
- package/package.json +63 -43
- package/src/client/index.ts +10 -10
- package/src/client/utils.ts +0 -32
- package/src/component/_generated/api.ts +50 -0
- package/src/component/_generated/component.ts +79 -0
- package/src/component/_generated/{dataModel.d.ts → dataModel.ts} +0 -4
- package/src/component/_generated/server.ts +161 -0
- package/src/component/public.ts +14 -12
- package/src/component/schema.ts +2 -1
- package/src/test.ts +18 -0
- package/dist/commonjs/client/index.d.ts.map +0 -1
- package/dist/commonjs/client/index.js.map +0 -1
- package/dist/commonjs/client/utils.d.ts +0 -15
- package/dist/commonjs/client/utils.d.ts.map +0 -1
- package/dist/commonjs/client/utils.js +0 -3
- package/dist/commonjs/component/_generated/api.d.ts +0 -14
- package/dist/commonjs/component/_generated/api.d.ts.map +0 -1
- package/dist/commonjs/component/_generated/api.js +0 -24
- package/dist/commonjs/component/_generated/api.js.map +0 -1
- package/dist/commonjs/component/_generated/server.d.ts +0 -64
- package/dist/commonjs/component/_generated/server.d.ts.map +0 -1
- package/dist/commonjs/component/_generated/server.js.map +0 -1
- package/dist/commonjs/component/convex.config.d.ts.map +0 -1
- package/dist/commonjs/component/convex.config.js.map +0 -1
- package/dist/commonjs/component/public.d.ts.map +0 -1
- package/dist/commonjs/component/public.js.map +0 -1
- package/dist/commonjs/component/schema.d.ts.map +0 -1
- package/dist/commonjs/component/schema.js.map +0 -1
- package/dist/commonjs/package.json +0 -3
- package/dist/esm/client/index.d.ts +0 -89
- package/dist/esm/client/index.d.ts.map +0 -1
- package/dist/esm/client/index.js +0 -104
- package/dist/esm/client/index.js.map +0 -1
- package/dist/esm/client/utils.d.ts +0 -15
- package/dist/esm/client/utils.d.ts.map +0 -1
- package/dist/esm/client/utils.js +0 -3
- package/dist/esm/client/utils.js.map +0 -1
- package/dist/esm/component/_generated/api.d.ts +0 -14
- package/dist/esm/component/_generated/api.d.ts.map +0 -1
- package/dist/esm/component/_generated/api.js +0 -24
- package/dist/esm/component/_generated/api.js.map +0 -1
- package/dist/esm/component/_generated/server.d.ts +0 -64
- package/dist/esm/component/_generated/server.d.ts.map +0 -1
- package/dist/esm/component/_generated/server.js +0 -76
- package/dist/esm/component/_generated/server.js.map +0 -1
- package/dist/esm/component/convex.config.d.ts +0 -3
- package/dist/esm/component/convex.config.d.ts.map +0 -1
- package/dist/esm/component/convex.config.js +0 -3
- package/dist/esm/component/convex.config.js.map +0 -1
- package/dist/esm/component/public.d.ts +0 -115
- package/dist/esm/component/public.d.ts.map +0 -1
- package/dist/esm/component/public.js +0 -225
- package/dist/esm/component/public.js.map +0 -1
- package/dist/esm/component/schema.d.ts +0 -45
- package/dist/esm/component/schema.d.ts.map +0 -1
- package/dist/esm/component/schema.js +0 -20
- package/dist/esm/component/schema.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/src/component/_generated/api.d.ts +0 -98
- package/src/component/_generated/server.js +0 -94
- /package/dist/{commonjs/client → client}/index.js +0 -0
- /package/dist/{commonjs/component → component}/convex.config.d.ts +0 -0
- /package/dist/{commonjs/component → component}/convex.config.js +0 -0
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Define a query in this Convex app's public API.
|
|
3
|
-
*
|
|
4
|
-
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
5
|
-
*
|
|
6
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
7
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
8
|
-
*/
|
|
9
|
-
export const query: import("convex/server").QueryBuilder<any, "public">;
|
|
10
|
-
/**
|
|
11
|
-
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
12
|
-
*
|
|
13
|
-
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
14
|
-
*
|
|
15
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
16
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
17
|
-
*/
|
|
18
|
-
export const internalQuery: import("convex/server").QueryBuilder<any, "internal">;
|
|
19
|
-
/**
|
|
20
|
-
* Define a mutation in this Convex app's public API.
|
|
21
|
-
*
|
|
22
|
-
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
23
|
-
*
|
|
24
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
25
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
26
|
-
*/
|
|
27
|
-
export const mutation: import("convex/server").MutationBuilder<any, "public">;
|
|
28
|
-
/**
|
|
29
|
-
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
30
|
-
*
|
|
31
|
-
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
32
|
-
*
|
|
33
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
34
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
35
|
-
*/
|
|
36
|
-
export const internalMutation: import("convex/server").MutationBuilder<any, "internal">;
|
|
37
|
-
/**
|
|
38
|
-
* Define an action in this Convex app's public API.
|
|
39
|
-
*
|
|
40
|
-
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
41
|
-
* code and code with side-effects, like calling third-party services.
|
|
42
|
-
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
43
|
-
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
44
|
-
*
|
|
45
|
-
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
46
|
-
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
47
|
-
*/
|
|
48
|
-
export const action: import("convex/server").ActionBuilder<any, "public">;
|
|
49
|
-
/**
|
|
50
|
-
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
51
|
-
*
|
|
52
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
53
|
-
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
54
|
-
*/
|
|
55
|
-
export const internalAction: import("convex/server").ActionBuilder<any, "internal">;
|
|
56
|
-
/**
|
|
57
|
-
* Define a Convex HTTP action.
|
|
58
|
-
*
|
|
59
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object
|
|
60
|
-
* as its second.
|
|
61
|
-
* @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`.
|
|
62
|
-
*/
|
|
63
|
-
export const httpAction: (func: (ctx: import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, request: Request) => Promise<Response>) => import("convex/server").PublicHttpAction;
|
|
64
|
-
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/component/_generated/server.js"],"names":[],"mappings":"AAuBA;;;;;;;GAOG;AACH,wEAAkC;AAElC;;;;;;;GAOG;AACH,kFAAkD;AAElD;;;;;;;GAOG;AACH,8EAAwC;AAExC;;;;;;;GAOG;AACH,wFAAwD;AAExD;;;;;;;;;;GAUG;AACH,0EAAoC;AAEpC;;;;;GAKG;AACH,oFAAoD;AAEpD;;;;;;GAMG;AACH,8MAA4C"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/* prettier-ignore-start */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
5
|
-
*
|
|
6
|
-
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
7
|
-
*
|
|
8
|
-
* To regenerate, run `npx convex dev`.
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
import { actionGeneric, httpActionGeneric, queryGeneric, mutationGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, componentsGeneric, } from "convex/server";
|
|
12
|
-
/**
|
|
13
|
-
* Define a query in this Convex app's public API.
|
|
14
|
-
*
|
|
15
|
-
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
16
|
-
*
|
|
17
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
18
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
19
|
-
*/
|
|
20
|
-
export const query = queryGeneric;
|
|
21
|
-
/**
|
|
22
|
-
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
23
|
-
*
|
|
24
|
-
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
25
|
-
*
|
|
26
|
-
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
27
|
-
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
28
|
-
*/
|
|
29
|
-
export const internalQuery = internalQueryGeneric;
|
|
30
|
-
/**
|
|
31
|
-
* Define a mutation in this Convex app's public API.
|
|
32
|
-
*
|
|
33
|
-
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
34
|
-
*
|
|
35
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
36
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
37
|
-
*/
|
|
38
|
-
export const mutation = mutationGeneric;
|
|
39
|
-
/**
|
|
40
|
-
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
41
|
-
*
|
|
42
|
-
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
43
|
-
*
|
|
44
|
-
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
45
|
-
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
46
|
-
*/
|
|
47
|
-
export const internalMutation = internalMutationGeneric;
|
|
48
|
-
/**
|
|
49
|
-
* Define an action in this Convex app's public API.
|
|
50
|
-
*
|
|
51
|
-
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
52
|
-
* code and code with side-effects, like calling third-party services.
|
|
53
|
-
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
54
|
-
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
55
|
-
*
|
|
56
|
-
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
57
|
-
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
58
|
-
*/
|
|
59
|
-
export const action = actionGeneric;
|
|
60
|
-
/**
|
|
61
|
-
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
62
|
-
*
|
|
63
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
64
|
-
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
65
|
-
*/
|
|
66
|
-
export const internalAction = internalActionGeneric;
|
|
67
|
-
/**
|
|
68
|
-
* Define a Convex HTTP action.
|
|
69
|
-
*
|
|
70
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object
|
|
71
|
-
* as its second.
|
|
72
|
-
* @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`.
|
|
73
|
-
*/
|
|
74
|
-
export const httpAction = httpActionGeneric;
|
|
75
|
-
/* prettier-ignore-end */
|
|
76
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../src/component/_generated/server.js"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,oBAAoB;AACpB;;;;;;;GAOG;AAEH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,YAAY,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAExD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAE5C,yBAAyB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../../src/component/convex.config.ts"],"names":[],"mappings":";AAEA,wBAAwC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAe,eAAe,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { FunctionHandle } from "convex/server";
|
|
2
|
-
export type Schedule = {
|
|
3
|
-
/** A schedule using a cron specification string. */
|
|
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
|
-
*/
|
|
19
|
-
cronspec: string;
|
|
20
|
-
} | {
|
|
21
|
-
/** A schedule using an interval in milliseconds. */
|
|
22
|
-
kind: "interval";
|
|
23
|
-
/** The interval in milliseconds. */
|
|
24
|
-
ms: number;
|
|
25
|
-
};
|
|
26
|
-
export type CronInfo = {
|
|
27
|
-
id: string;
|
|
28
|
-
name?: string;
|
|
29
|
-
functionHandle: FunctionHandle<"mutation" | "action">;
|
|
30
|
-
args: Record<string, unknown>;
|
|
31
|
-
schedule: Schedule;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Schedule a mutation or action to run on a cron schedule or interval.
|
|
35
|
-
*
|
|
36
|
-
* @param name - Optional unique name for the job. Will throw if a name is
|
|
37
|
-
* provided and a job with the same name already exists.
|
|
38
|
-
* @param schedule - Either a cron specification string or an interval in
|
|
39
|
-
* milliseconds. For intervals, ms must be >= 1000.
|
|
40
|
-
* @param functionHandle - A {@link FunctionHandle} string for the function to
|
|
41
|
-
* schedule.
|
|
42
|
-
* @param args - The arguments to the function.
|
|
43
|
-
* @returns The ID of the scheduled job.
|
|
44
|
-
*/
|
|
45
|
-
export declare const register: import("convex/server").RegisteredMutation<"public", {
|
|
46
|
-
name?: string | undefined;
|
|
47
|
-
functionHandle: string;
|
|
48
|
-
args: Record<string, any>;
|
|
49
|
-
schedule: {
|
|
50
|
-
kind: "interval";
|
|
51
|
-
ms: number;
|
|
52
|
-
} | {
|
|
53
|
-
kind: "cron";
|
|
54
|
-
cronspec: string;
|
|
55
|
-
};
|
|
56
|
-
}, Promise<import("convex/values").GenericId<"crons">>>;
|
|
57
|
-
/**
|
|
58
|
-
* List all user space cron jobs.
|
|
59
|
-
*
|
|
60
|
-
* @returns List of `cron` table rows.
|
|
61
|
-
*/
|
|
62
|
-
export declare const list: import("convex/server").RegisteredQuery<"public", {}, Promise<{
|
|
63
|
-
functionHandle: string;
|
|
64
|
-
args: Record<string, any>;
|
|
65
|
-
schedule: {
|
|
66
|
-
kind: "interval";
|
|
67
|
-
ms: number;
|
|
68
|
-
} | {
|
|
69
|
-
kind: "cron";
|
|
70
|
-
cronspec: string;
|
|
71
|
-
};
|
|
72
|
-
name?: string | undefined;
|
|
73
|
-
id: import("convex/values").GenericId<"crons">;
|
|
74
|
-
}[]>>;
|
|
75
|
-
/**
|
|
76
|
-
* Get an existing cron job by id or name.
|
|
77
|
-
*
|
|
78
|
-
* @param identifier - Either the ID or name of the cron job.
|
|
79
|
-
* @returns Cron job document or null if not found.
|
|
80
|
-
*/
|
|
81
|
-
export declare const get: import("convex/server").RegisteredQuery<"public", {
|
|
82
|
-
identifier: {
|
|
83
|
-
id: import("convex/values").GenericId<"crons">;
|
|
84
|
-
} | {
|
|
85
|
-
name: string;
|
|
86
|
-
};
|
|
87
|
-
}, Promise<{
|
|
88
|
-
functionHandle: string;
|
|
89
|
-
args: Record<string, any>;
|
|
90
|
-
schedule: {
|
|
91
|
-
kind: "interval";
|
|
92
|
-
ms: number;
|
|
93
|
-
} | {
|
|
94
|
-
kind: "cron";
|
|
95
|
-
cronspec: string;
|
|
96
|
-
};
|
|
97
|
-
name?: string | undefined;
|
|
98
|
-
id: import("convex/values").GenericId<"crons">;
|
|
99
|
-
} | null>>;
|
|
100
|
-
/**
|
|
101
|
-
* Delete and deschedule a cron job by id or name.
|
|
102
|
-
*
|
|
103
|
-
* @param identifier - Either the ID or name of the cron job.
|
|
104
|
-
*/
|
|
105
|
-
export declare const del: import("convex/server").RegisteredMutation<"public", {
|
|
106
|
-
identifier: {
|
|
107
|
-
id: import("convex/values").GenericId<"crons">;
|
|
108
|
-
} | {
|
|
109
|
-
name: string;
|
|
110
|
-
};
|
|
111
|
-
}, Promise<void>>;
|
|
112
|
-
export declare const rescheduler: import("convex/server").RegisteredMutation<"internal", {
|
|
113
|
-
id: import("convex/values").GenericId<"crons">;
|
|
114
|
-
}, Promise<void>>;
|
|
115
|
-
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,225 +0,0 @@
|
|
|
1
|
-
// Implementation of crons in user space.
|
|
2
|
-
//
|
|
3
|
-
// See ../client/index.ts for the public API.
|
|
4
|
-
import { v } from "convex/values";
|
|
5
|
-
import { mutation, query, internalMutation, } from "./_generated/server.js";
|
|
6
|
-
import { internal } from "./_generated/api.js";
|
|
7
|
-
import parser from "cron-parser";
|
|
8
|
-
import schema from "./schema.js";
|
|
9
|
-
const scheduleValidator = schema.tables.crons.validator.fields.schedule;
|
|
10
|
-
const cronInfoValidator = v.object({
|
|
11
|
-
id: v.id("crons"),
|
|
12
|
-
name: v.optional(v.string()),
|
|
13
|
-
functionHandle: v.string(),
|
|
14
|
-
args: v.record(v.string(), v.any()),
|
|
15
|
-
schedule: scheduleValidator,
|
|
16
|
-
});
|
|
17
|
-
/**
|
|
18
|
-
* Schedule a mutation or action to run on a cron schedule or interval.
|
|
19
|
-
*
|
|
20
|
-
* @param name - Optional unique name for the job. Will throw if a name is
|
|
21
|
-
* provided and a job with the same name already exists.
|
|
22
|
-
* @param schedule - Either a cron specification string or an interval in
|
|
23
|
-
* milliseconds. For intervals, ms must be >= 1000.
|
|
24
|
-
* @param functionHandle - A {@link FunctionHandle} string for the function to
|
|
25
|
-
* schedule.
|
|
26
|
-
* @param args - The arguments to the function.
|
|
27
|
-
* @returns The ID of the scheduled job.
|
|
28
|
-
*/
|
|
29
|
-
export const register = mutation({
|
|
30
|
-
args: {
|
|
31
|
-
name: v.optional(v.string()),
|
|
32
|
-
schedule: scheduleValidator,
|
|
33
|
-
functionHandle: v.string(),
|
|
34
|
-
args: v.record(v.string(), v.any()),
|
|
35
|
-
},
|
|
36
|
-
returns: v.id("crons"),
|
|
37
|
-
handler: async (ctx, { name, schedule, functionHandle, args }) => {
|
|
38
|
-
if (name &&
|
|
39
|
-
(await ctx.db
|
|
40
|
-
.query("crons")
|
|
41
|
-
.withIndex("name", (q) => q.eq("name", name))
|
|
42
|
-
.unique())) {
|
|
43
|
-
throw new Error(`Cron with name "${name}" already exists`);
|
|
44
|
-
}
|
|
45
|
-
validateSchedule(schedule);
|
|
46
|
-
const id = await ctx.db.insert("crons", {
|
|
47
|
-
functionHandle,
|
|
48
|
-
args,
|
|
49
|
-
name,
|
|
50
|
-
schedule,
|
|
51
|
-
});
|
|
52
|
-
console.log(`Scheduling cron "${name}" (${id}) on schedule ${JSON.stringify(schedule)}`);
|
|
53
|
-
await scheduleNextRun(ctx, id, new Date(), schedule);
|
|
54
|
-
return id;
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
function validateSchedule(schedule) {
|
|
58
|
-
if (schedule.kind === "interval" && schedule.ms < 1000) {
|
|
59
|
-
throw new Error("Interval must be >= 1000ms");
|
|
60
|
-
}
|
|
61
|
-
if (schedule.kind === "cron") {
|
|
62
|
-
try {
|
|
63
|
-
parser.parseExpression(schedule.cronspec);
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
throw new Error(`Invalid cronspec: "${schedule.cronspec}"`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async function scheduleNextRun(ctx, id, lastScheduled, schedule) {
|
|
71
|
-
const nextRun = calculateNextRun(lastScheduled, schedule);
|
|
72
|
-
const schedulerJobId = await ctx.scheduler.runAt(nextRun, internal.public.rescheduler, { id });
|
|
73
|
-
await ctx.db.patch(id, { schedulerJobId });
|
|
74
|
-
}
|
|
75
|
-
function calculateNextRun(lastScheduled, schedule) {
|
|
76
|
-
if (schedule.kind === "interval") {
|
|
77
|
-
return new Date(lastScheduled.getTime() + schedule.ms);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
const cron = parser.parseExpression(schedule.cronspec, {
|
|
81
|
-
currentDate: lastScheduled,
|
|
82
|
-
});
|
|
83
|
-
return cron.next().toDate();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* List all user space cron jobs.
|
|
88
|
-
*
|
|
89
|
-
* @returns List of `cron` table rows.
|
|
90
|
-
*/
|
|
91
|
-
export const list = query({
|
|
92
|
-
args: {},
|
|
93
|
-
returns: v.array(cronInfoValidator),
|
|
94
|
-
handler: async (ctx) => {
|
|
95
|
-
const crons = await ctx.db.query("crons").collect();
|
|
96
|
-
return crons.map((cron) => ({
|
|
97
|
-
id: cron._id,
|
|
98
|
-
...(cron.name && { name: cron.name }),
|
|
99
|
-
functionHandle: cron.functionHandle,
|
|
100
|
-
args: cron.args,
|
|
101
|
-
schedule: cron.schedule,
|
|
102
|
-
}));
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
/**
|
|
106
|
-
* Get an existing cron job by id or name.
|
|
107
|
-
*
|
|
108
|
-
* @param identifier - Either the ID or name of the cron job.
|
|
109
|
-
* @returns Cron job document or null if not found.
|
|
110
|
-
*/
|
|
111
|
-
export const get = query({
|
|
112
|
-
args: {
|
|
113
|
-
identifier: v.union(v.object({ id: v.id("crons") }), v.object({ name: v.string() })),
|
|
114
|
-
},
|
|
115
|
-
returns: v.union(cronInfoValidator, v.null()),
|
|
116
|
-
handler: async (ctx, { identifier }) => {
|
|
117
|
-
const cron = "id" in identifier
|
|
118
|
-
? await ctx.db.get(identifier.id)
|
|
119
|
-
: await ctx.db
|
|
120
|
-
.query("crons")
|
|
121
|
-
.withIndex("name", (q) => q.eq("name", identifier.name))
|
|
122
|
-
.unique();
|
|
123
|
-
if (!cron)
|
|
124
|
-
return null;
|
|
125
|
-
return {
|
|
126
|
-
id: cron._id,
|
|
127
|
-
...(cron.name && { name: cron.name }),
|
|
128
|
-
functionHandle: cron.functionHandle,
|
|
129
|
-
args: cron.args,
|
|
130
|
-
schedule: cron.schedule,
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
/**
|
|
135
|
-
* Delete and deschedule a cron job by id or name.
|
|
136
|
-
*
|
|
137
|
-
* @param identifier - Either the ID or name of the cron job.
|
|
138
|
-
*/
|
|
139
|
-
export const del = mutation({
|
|
140
|
-
args: {
|
|
141
|
-
identifier: v.union(v.object({ id: v.id("crons") }), v.object({ name: v.string() })),
|
|
142
|
-
},
|
|
143
|
-
returns: v.null(),
|
|
144
|
-
handler: async (ctx, { identifier }) => {
|
|
145
|
-
let cron;
|
|
146
|
-
if ("id" in identifier) {
|
|
147
|
-
cron = await ctx.db.get(identifier.id);
|
|
148
|
-
if (!cron) {
|
|
149
|
-
throw new Error(`Cron ${identifier.id} not found`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
cron = await ctx.db
|
|
154
|
-
.query("crons")
|
|
155
|
-
.withIndex("name", (q) => q.eq("name", identifier.name))
|
|
156
|
-
.unique();
|
|
157
|
-
if (!cron) {
|
|
158
|
-
throw new Error(`Cron "${identifier.name}" not found`);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (!cron.schedulerJobId) {
|
|
162
|
-
throw new Error(`Cron ${cron._id} not scheduled`);
|
|
163
|
-
}
|
|
164
|
-
console.log(`Canceling scheduler job ${cron.schedulerJobId}`);
|
|
165
|
-
await ctx.scheduler.cancel(cron.schedulerJobId);
|
|
166
|
-
if (cron.executionJobId) {
|
|
167
|
-
console.log(`Canceling execution job ${cron.executionJobId}`);
|
|
168
|
-
await ctx.scheduler.cancel(cron.executionJobId);
|
|
169
|
-
}
|
|
170
|
-
console.log(`Deleting cron ${cron._id}`);
|
|
171
|
-
await ctx.db.delete(cron._id);
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
// Continue rescheduling a cron job.
|
|
175
|
-
//
|
|
176
|
-
// This is the main worker function that does the scheduling but also schedules
|
|
177
|
-
// the target function so that it runs in a different context. As a result this
|
|
178
|
-
// function probably *shouldn't* fail since it isn't doing much, but under heavy
|
|
179
|
-
// OCC contention it's possible it may eventually fail. In this case the cron
|
|
180
|
-
// will be lost and we'll need a janitor job to recover it.
|
|
181
|
-
export const rescheduler = internalMutation({
|
|
182
|
-
args: {
|
|
183
|
-
id: v.id("crons"),
|
|
184
|
-
},
|
|
185
|
-
returns: v.null(),
|
|
186
|
-
handler: async (ctx, { id }) => {
|
|
187
|
-
// Cron job is the logical concept we're rescheduling repeatedly.
|
|
188
|
-
const cronJob = await ctx.db.get(id);
|
|
189
|
-
if (!cronJob) {
|
|
190
|
-
throw Error(`Cron ${id} not found`);
|
|
191
|
-
}
|
|
192
|
-
if (!cronJob.schedulerJobId) {
|
|
193
|
-
throw Error(`Cron ${id} not scheduled`);
|
|
194
|
-
}
|
|
195
|
-
// Scheduler job is the job that's running right now, that we use to trigger
|
|
196
|
-
// repeated executions.
|
|
197
|
-
const schedulerJob = await ctx.db.system.get(cronJob.schedulerJobId);
|
|
198
|
-
if (!schedulerJob) {
|
|
199
|
-
throw Error(`Scheduler job ${cronJob.schedulerJobId} not found`);
|
|
200
|
-
}
|
|
201
|
-
if (schedulerJob.state.kind !== "pending" &&
|
|
202
|
-
schedulerJob.state.kind !== "inProgress") {
|
|
203
|
-
throw Error(`We are running in job ${schedulerJob._id} but state is ${schedulerJob.state.kind}`);
|
|
204
|
-
}
|
|
205
|
-
// Execution job is the previous job used to actually do the work of the cron.
|
|
206
|
-
let stillRunning = false;
|
|
207
|
-
if (cronJob.executionJobId) {
|
|
208
|
-
const executionJob = await ctx.db.system.get(cronJob.executionJobId);
|
|
209
|
-
if (executionJob &&
|
|
210
|
-
(executionJob.state.kind === "pending" ||
|
|
211
|
-
executionJob.state.kind === "inProgress")) {
|
|
212
|
-
stillRunning = true;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
if (stillRunning) {
|
|
216
|
-
console.log(`Cron ${cronJob._id} still running, skipping this run.`);
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
console.log(`Running cron ${cronJob._id}.`);
|
|
220
|
-
await ctx.scheduler.runAfter(0, cronJob.functionHandle, cronJob.args);
|
|
221
|
-
}
|
|
222
|
-
await scheduleNextRun(ctx, id, new Date(schedulerJob.scheduledTime), cronJob.schedule);
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
//# sourceMappingURL=public.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;IACjC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,CA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,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"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
declare const _default: import("convex/server").SchemaDefinition<{
|
|
2
|
-
crons: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3
|
-
name?: string | undefined;
|
|
4
|
-
schedulerJobId?: import("convex/values").GenericId<"_scheduled_functions"> | undefined;
|
|
5
|
-
executionJobId?: import("convex/values").GenericId<"_scheduled_functions"> | undefined;
|
|
6
|
-
functionHandle: string;
|
|
7
|
-
args: Record<string, any>;
|
|
8
|
-
schedule: {
|
|
9
|
-
kind: "interval";
|
|
10
|
-
ms: number;
|
|
11
|
-
} | {
|
|
12
|
-
kind: "cron";
|
|
13
|
-
cronspec: string;
|
|
14
|
-
};
|
|
15
|
-
}, {
|
|
16
|
-
name: import("convex/values").VString<string | undefined, "optional">;
|
|
17
|
-
functionHandle: import("convex/values").VString<string, "required">;
|
|
18
|
-
args: import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>;
|
|
19
|
-
schedule: import("convex/values").VUnion<{
|
|
20
|
-
kind: "interval";
|
|
21
|
-
ms: number;
|
|
22
|
-
} | {
|
|
23
|
-
kind: "cron";
|
|
24
|
-
cronspec: string;
|
|
25
|
-
}, [import("convex/values").VObject<{
|
|
26
|
-
kind: "interval";
|
|
27
|
-
ms: number;
|
|
28
|
-
}, {
|
|
29
|
-
kind: import("convex/values").VLiteral<"interval", "required">;
|
|
30
|
-
ms: import("convex/values").VFloat64<number, "required">;
|
|
31
|
-
}, "required", "kind" | "ms">, import("convex/values").VObject<{
|
|
32
|
-
kind: "cron";
|
|
33
|
-
cronspec: string;
|
|
34
|
-
}, {
|
|
35
|
-
kind: import("convex/values").VLiteral<"cron", "required">;
|
|
36
|
-
cronspec: import("convex/values").VString<string, "required">;
|
|
37
|
-
}, "required", "kind" | "cronspec">], "required", "kind" | "ms" | "cronspec">;
|
|
38
|
-
schedulerJobId: import("convex/values").VId<import("convex/values").GenericId<"_scheduled_functions"> | undefined, "optional">;
|
|
39
|
-
executionJobId: import("convex/values").VId<import("convex/values").GenericId<"_scheduled_functions"> | undefined, "optional">;
|
|
40
|
-
}, "required", "name" | "functionHandle" | "args" | "schedule" | "schedulerJobId" | "executionJobId" | `args.${string}` | "schedule.kind" | "schedule.ms" | "schedule.cronspec">, {
|
|
41
|
-
name: ["name", "_creationTime"];
|
|
42
|
-
}, {}, {}>;
|
|
43
|
-
}, true>;
|
|
44
|
-
export default _default;
|
|
45
|
-
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wBAmBG"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { defineSchema, defineTable } from "convex/server";
|
|
2
|
-
import { v } from "convex/values";
|
|
3
|
-
export default defineSchema({
|
|
4
|
-
// User space crons.
|
|
5
|
-
crons: defineTable({
|
|
6
|
-
name: v.optional(v.string()),
|
|
7
|
-
functionHandle: v.string(),
|
|
8
|
-
args: v.record(v.string(), v.any()),
|
|
9
|
-
schedule: v.union(v.object({
|
|
10
|
-
kind: v.literal("interval"),
|
|
11
|
-
ms: v.float64(), // milliseconds
|
|
12
|
-
}), v.object({
|
|
13
|
-
kind: v.literal("cron"),
|
|
14
|
-
cronspec: v.string(), // "* * * * *"
|
|
15
|
-
})),
|
|
16
|
-
schedulerJobId: v.optional(v.id("_scheduled_functions")),
|
|
17
|
-
executionJobId: v.optional(v.id("_scheduled_functions")), // async job to run the function
|
|
18
|
-
}).index("name", ["name"]),
|
|
19
|
-
});
|
|
20
|
-
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,eAAe,YAAY,CAAC;IAC1B,oBAAoB;IACpB,KAAK,EAAE,WAAW,CAAC;QACjB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;QAC1B,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;QACnC,QAAQ,EAAE,CAAC,CAAC,KAAK,CACf,CAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;YAC3B,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,eAAe;SACjC,CAAC,EACF,CAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;YACvB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,cAAc;SACrC,CAAC,CACH;QACD,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC;QACxD,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,EAAE,gCAAgC;KAC3F,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;CAC3B,CAAC,CAAC"}
|
package/dist/esm/package.json
DELETED