@convex-dev/crons 0.2.1 → 0.2.2
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/client/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type FunctionArgs, type SchedulableFunctionReference } from "convex/server";
|
|
2
2
|
import type { ComponentApi } from "../component/_generated/component.js";
|
|
3
3
|
import type { CronInfo, Schedule } from "../component/public.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ActionCtx, MutationCtx, QueryCtx } from "./utils.js";
|
|
5
5
|
export type { CronInfo };
|
|
6
6
|
export declare class Crons {
|
|
7
7
|
private component;
|
|
@@ -57,20 +57,20 @@ export declare class Crons {
|
|
|
57
57
|
* provided and a cron with the same name already exists.
|
|
58
58
|
* @returns A string identifier for the cron job.
|
|
59
59
|
*/
|
|
60
|
-
register<F extends SchedulableFunctionReference>(ctx:
|
|
60
|
+
register<F extends SchedulableFunctionReference>(ctx: MutationCtx | ActionCtx, schedule: Schedule, func: F, args: FunctionArgs<F>, name?: string): Promise<string>;
|
|
61
61
|
/**
|
|
62
62
|
* List all user space cron jobs.
|
|
63
63
|
*
|
|
64
64
|
* @returns List of `cron` table rows.
|
|
65
65
|
*/
|
|
66
|
-
list(ctx:
|
|
66
|
+
list(ctx: QueryCtx | MutationCtx | ActionCtx): Promise<CronInfo[]>;
|
|
67
67
|
/**
|
|
68
68
|
* Get an existing cron job by id or name.
|
|
69
69
|
*
|
|
70
70
|
* @param identifier - Either the ID or name of the cron job.
|
|
71
71
|
* @returns Cron job document.
|
|
72
72
|
*/
|
|
73
|
-
get(ctx:
|
|
73
|
+
get(ctx: QueryCtx | MutationCtx | ActionCtx, identifier: {
|
|
74
74
|
id: string;
|
|
75
75
|
} | {
|
|
76
76
|
name: string;
|
|
@@ -80,7 +80,7 @@ export declare class Crons {
|
|
|
80
80
|
*
|
|
81
81
|
* @param identifier - Either the ID or name of the cron job.
|
|
82
82
|
*/
|
|
83
|
-
delete(ctx:
|
|
83
|
+
delete(ctx: MutationCtx | ActionCtx, identifier: {
|
|
84
84
|
id: string;
|
|
85
85
|
} | {
|
|
86
86
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,4BAA4B,EAClC,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,4BAA4B,EAClC,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnE,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB,qBAAa,KAAK;IAwCJ,OAAO,CAAC,SAAS;IAvC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;gBACiB,SAAS,EAAE,YAAY;IAE3C;;;;;;;;;;;OAWG;IACG,QAAQ,CAAC,CAAC,SAAS,4BAA4B,EACnD,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,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,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAUxE;;;;;OAKG;IACG,GAAG,CACP,GAAG,EAAE,QAAQ,GAAG,WAAW,GAAG,SAAS,EACvC,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,WAAW,GAAG,SAAS,EAC5B,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAC5C,OAAO,CAAC,IAAI,CAAC;CAGjB"}
|
package/dist/client/index.js.map
CHANGED
|
@@ -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,MAAM,OAAO,KAAK;IAwCI;IAvCpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,YAAoB,SAAuB;QAAvB,cAAS,GAAT,SAAS,CAAc;IAAG,CAAC;IAE/C;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CACZ,
|
|
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,SAAuB;QAAvB,cAAS,GAAT,SAAS,CAAc;IAAG,CAAC;IAE/C;;;;;;;;;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1,5 @@
|
|
|
1
|
-
import type { GenericDataModel, GenericMutationCtx, GenericQueryCtx } from "convex/server";
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type RunMutationCtx = {
|
|
6
|
-
runMutation: GenericMutationCtx<GenericDataModel>["runMutation"];
|
|
7
|
-
};
|
|
1
|
+
import type { GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx } from "convex/server";
|
|
2
|
+
export type QueryCtx = Pick<GenericQueryCtx<GenericDataModel>, "runQuery">;
|
|
3
|
+
export type MutationCtx = Pick<GenericMutationCtx<GenericDataModel>, "runQuery" | "runMutation">;
|
|
4
|
+
export type ActionCtx = Pick<GenericActionCtx<GenericDataModel>, "runQuery" | "runMutation" | "runAction">;
|
|
8
5
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/client/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAChB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/client/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAChB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,CAAC;AAC3E,MAAM,MAAM,WAAW,GAAG,IAAI,CAC5B,kBAAkB,CAAC,gBAAgB,CAAC,EACpC,UAAU,GAAG,aAAa,CAC3B,CAAC;AACF,MAAM,MAAM,SAAS,GAAG,IAAI,CAC1B,gBAAgB,CAAC,gBAAgB,CAAC,EAClC,UAAU,GAAG,aAAa,GAAG,WAAW,CACzC,CAAC"}
|
package/package.json
CHANGED
package/src/client/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "convex/server";
|
|
9
9
|
import type { ComponentApi } from "../component/_generated/component.js";
|
|
10
10
|
import type { CronInfo, Schedule } from "../component/public.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type { ActionCtx, MutationCtx, QueryCtx } from "./utils.js";
|
|
12
12
|
|
|
13
13
|
export type { CronInfo };
|
|
14
14
|
|
|
@@ -67,7 +67,7 @@ export class Crons {
|
|
|
67
67
|
* @returns A string identifier for the cron job.
|
|
68
68
|
*/
|
|
69
69
|
async register<F extends SchedulableFunctionReference>(
|
|
70
|
-
ctx:
|
|
70
|
+
ctx: MutationCtx | ActionCtx,
|
|
71
71
|
schedule: Schedule,
|
|
72
72
|
func: F,
|
|
73
73
|
args: FunctionArgs<F>,
|
|
@@ -86,7 +86,7 @@ export class Crons {
|
|
|
86
86
|
*
|
|
87
87
|
* @returns List of `cron` table rows.
|
|
88
88
|
*/
|
|
89
|
-
async list(ctx:
|
|
89
|
+
async list(ctx: QueryCtx | MutationCtx | ActionCtx): Promise<CronInfo[]> {
|
|
90
90
|
const crons = await ctx.runQuery(this.component.public.list, {});
|
|
91
91
|
return crons.map((cron) => ({
|
|
92
92
|
...cron,
|
|
@@ -103,7 +103,7 @@ export class Crons {
|
|
|
103
103
|
* @returns Cron job document.
|
|
104
104
|
*/
|
|
105
105
|
async get(
|
|
106
|
-
ctx:
|
|
106
|
+
ctx: QueryCtx | MutationCtx | ActionCtx,
|
|
107
107
|
identifier: { id: string } | { name: string },
|
|
108
108
|
): Promise<CronInfo | null> {
|
|
109
109
|
const cron = await ctx.runQuery(this.component.public.get, { identifier });
|
|
@@ -124,7 +124,7 @@ export class Crons {
|
|
|
124
124
|
* @param identifier - Either the ID or name of the cron job.
|
|
125
125
|
*/
|
|
126
126
|
async delete(
|
|
127
|
-
ctx:
|
|
127
|
+
ctx: MutationCtx | ActionCtx,
|
|
128
128
|
identifier: { id: string } | { name: string },
|
|
129
129
|
): Promise<null> {
|
|
130
130
|
return ctx.runMutation(this.component.public.del, { identifier });
|
package/src/client/utils.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
GenericActionCtx,
|
|
2
3
|
GenericDataModel,
|
|
3
4
|
GenericMutationCtx,
|
|
4
5
|
GenericQueryCtx,
|
|
5
6
|
} from "convex/server";
|
|
6
7
|
|
|
7
|
-
export type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export type QueryCtx = Pick<GenericQueryCtx<GenericDataModel>, "runQuery">;
|
|
9
|
+
export type MutationCtx = Pick<
|
|
10
|
+
GenericMutationCtx<GenericDataModel>,
|
|
11
|
+
"runQuery" | "runMutation"
|
|
12
|
+
>;
|
|
13
|
+
export type ActionCtx = Pick<
|
|
14
|
+
GenericActionCtx<GenericDataModel>,
|
|
15
|
+
"runQuery" | "runMutation" | "runAction"
|
|
16
|
+
>;
|