@convex-dev/crons 0.1.9 → 0.2.1
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/{commonjs/component → component}/convex.config.d.ts +1 -1
- 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 +2 -2
- package/dist/component/public.d.ts.map +1 -0
- package/dist/{commonjs/component → component}/public.js +9 -8
- package/dist/component/public.js.map +1 -0
- package/dist/{commonjs/component → component}/schema.d.ts +2 -2
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/{commonjs/component → component}/schema.js +3 -3
- package/dist/component/schema.js.map +1 -0
- package/package.json +60 -41
- 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} +1 -5
- package/src/component/_generated/server.ts +156 -0
- package/src/component/public.ts +26 -19
- package/src/component/schema.ts +1 -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 -12
- 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 -12
- 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 -119
- package/dist/esm/component/public.d.ts.map +0 -1
- package/dist/esm/component/public.js +0 -226
- package/dist/esm/component/public.js.map +0 -1
- package/dist/esm/component/schema.d.ts +0 -49
- package/dist/esm/component/schema.d.ts.map +0 -1
- package/dist/esm/component/schema.js +0 -21
- 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.js +0 -0
|
@@ -70,7 +70,7 @@ function validateSchedule(schedule) {
|
|
|
70
70
|
async function scheduleNextRun(ctx, id, lastScheduled, schedule) {
|
|
71
71
|
const nextRun = calculateNextRun(lastScheduled, schedule);
|
|
72
72
|
const schedulerJobId = await ctx.scheduler.runAt(nextRun, internal.public.rescheduler, { id });
|
|
73
|
-
await ctx.db.patch(id, { schedulerJobId });
|
|
73
|
+
await ctx.db.patch("crons", id, { schedulerJobId });
|
|
74
74
|
}
|
|
75
75
|
function calculateNextRun(lastScheduled, schedule) {
|
|
76
76
|
if (schedule.kind === "interval") {
|
|
@@ -116,7 +116,7 @@ export const get = query({
|
|
|
116
116
|
returns: v.union(cronInfoValidator, v.null()),
|
|
117
117
|
handler: async (ctx, { identifier }) => {
|
|
118
118
|
const cron = "id" in identifier
|
|
119
|
-
? await ctx.db.get(identifier.id)
|
|
119
|
+
? await ctx.db.get("crons", identifier.id)
|
|
120
120
|
: await ctx.db
|
|
121
121
|
.query("crons")
|
|
122
122
|
.withIndex("name", (q) => q.eq("name", identifier.name))
|
|
@@ -145,7 +145,7 @@ export const del = mutation({
|
|
|
145
145
|
handler: async (ctx, { identifier }) => {
|
|
146
146
|
let cron;
|
|
147
147
|
if ("id" in identifier) {
|
|
148
|
-
cron = await ctx.db.get(identifier.id);
|
|
148
|
+
cron = await ctx.db.get("crons", identifier.id);
|
|
149
149
|
if (!cron) {
|
|
150
150
|
throw new Error(`Cron ${identifier.id} not found`);
|
|
151
151
|
}
|
|
@@ -169,7 +169,7 @@ export const del = mutation({
|
|
|
169
169
|
await ctx.scheduler.cancel(cron.executionJobId);
|
|
170
170
|
}
|
|
171
171
|
console.log(`Deleting cron ${cron._id}`);
|
|
172
|
-
await ctx.db.delete(cron._id);
|
|
172
|
+
await ctx.db.delete("crons", cron._id);
|
|
173
173
|
},
|
|
174
174
|
});
|
|
175
175
|
// Continue rescheduling a cron job.
|
|
@@ -186,7 +186,7 @@ export const rescheduler = internalMutation({
|
|
|
186
186
|
returns: v.null(),
|
|
187
187
|
handler: async (ctx, { id }) => {
|
|
188
188
|
// Cron job is the logical concept we're rescheduling repeatedly.
|
|
189
|
-
const cronJob = await ctx.db.get(id);
|
|
189
|
+
const cronJob = await ctx.db.get("crons", id);
|
|
190
190
|
if (!cronJob) {
|
|
191
191
|
throw Error(`Cron ${id} not found`);
|
|
192
192
|
}
|
|
@@ -195,7 +195,7 @@ export const rescheduler = internalMutation({
|
|
|
195
195
|
}
|
|
196
196
|
// Scheduler job is the job that's running right now, that we use to trigger
|
|
197
197
|
// repeated executions.
|
|
198
|
-
const schedulerJob = await ctx.db.system.get(cronJob.schedulerJobId);
|
|
198
|
+
const schedulerJob = await ctx.db.system.get("_scheduled_functions", cronJob.schedulerJobId);
|
|
199
199
|
if (!schedulerJob) {
|
|
200
200
|
throw Error(`Scheduler job ${cronJob.schedulerJobId} not found`);
|
|
201
201
|
}
|
|
@@ -206,7 +206,7 @@ export const rescheduler = internalMutation({
|
|
|
206
206
|
// Execution job is the previous job used to actually do the work of the cron.
|
|
207
207
|
let stillRunning = false;
|
|
208
208
|
if (cronJob.executionJobId) {
|
|
209
|
-
const executionJob = await ctx.db.system.get(cronJob.executionJobId);
|
|
209
|
+
const executionJob = await ctx.db.system.get("_scheduled_functions", cronJob.executionJobId);
|
|
210
210
|
if (executionJob &&
|
|
211
211
|
(executionJob.state.kind === "pending" ||
|
|
212
212
|
executionJob.state.kind === "inProgress")) {
|
|
@@ -218,7 +218,8 @@ export const rescheduler = internalMutation({
|
|
|
218
218
|
}
|
|
219
219
|
else {
|
|
220
220
|
console.log(`Running cron ${cronJob._id}.`);
|
|
221
|
-
await ctx.scheduler.runAfter(0, cronJob.functionHandle, cronJob.args);
|
|
221
|
+
const executionJobId = await ctx.scheduler.runAfter(0, cronJob.functionHandle, cronJob.args);
|
|
222
|
+
await ctx.db.patch("crons", id, { executionJobId });
|
|
222
223
|
}
|
|
223
224
|
await scheduleNextRun(ctx, id, new Date(schedulerJob.scheduledTime), cronJob.schedule);
|
|
224
225
|
},
|
|
@@ -0,0 +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;AA8BjC,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,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC5B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,IAAI,EAAE,C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|
|
|
3
3
|
name?: string | undefined;
|
|
4
4
|
schedulerJobId?: import("convex/values").GenericId<"_scheduled_functions"> | undefined;
|
|
5
5
|
executionJobId?: import("convex/values").GenericId<"_scheduled_functions"> | undefined;
|
|
6
|
-
functionHandle: string;
|
|
7
6
|
args: Record<string, any>;
|
|
7
|
+
functionHandle: string;
|
|
8
8
|
schedule: {
|
|
9
9
|
kind: "interval";
|
|
10
10
|
ms: number;
|
|
@@ -41,7 +41,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
|
|
|
41
41
|
}, "required", "kind" | "cronspec" | "tz">], "required", "kind" | "ms" | "cronspec" | "tz">;
|
|
42
42
|
schedulerJobId: import("convex/values").VId<import("convex/values").GenericId<"_scheduled_functions"> | undefined, "optional">;
|
|
43
43
|
executionJobId: import("convex/values").VId<import("convex/values").GenericId<"_scheduled_functions"> | undefined, "optional">;
|
|
44
|
-
}, "required", "
|
|
44
|
+
}, "required", "args" | "functionHandle" | "name" | "schedule" | "schedulerJobId" | "executionJobId" | `args.${string}` | "schedule.kind" | "schedule.ms" | "schedule.cronspec" | "schedule.tz">, {
|
|
45
45
|
name: ["name", "_creationTime"];
|
|
46
46
|
}, {}, {}>;
|
|
47
47
|
}, true>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wBAoBG"}
|
|
@@ -3,7 +3,7 @@ import { v } from "convex/values";
|
|
|
3
3
|
export default defineSchema({
|
|
4
4
|
// User space crons.
|
|
5
5
|
crons: defineTable({
|
|
6
|
-
name: v.optional(v.string()),
|
|
6
|
+
name: v.optional(v.string()), // optional
|
|
7
7
|
functionHandle: v.string(),
|
|
8
8
|
args: v.record(v.string(), v.any()),
|
|
9
9
|
schedule: v.union(v.object({
|
|
@@ -11,10 +11,10 @@ export default defineSchema({
|
|
|
11
11
|
ms: v.float64(), // milliseconds
|
|
12
12
|
}), v.object({
|
|
13
13
|
kind: v.literal("cron"),
|
|
14
|
-
cronspec: v.string(),
|
|
14
|
+
cronspec: v.string(), // "* * * * *"
|
|
15
15
|
tz: v.optional(v.string()), // optional timezone, e.g. "America/New_York"
|
|
16
16
|
})),
|
|
17
|
-
schedulerJobId: v.optional(v.id("_scheduled_functions")),
|
|
17
|
+
schedulerJobId: v.optional(v.id("_scheduled_functions")), // job to wait for the next execution
|
|
18
18
|
executionJobId: v.optional(v.id("_scheduled_functions")), // async job to run the function
|
|
19
19
|
}).index("name", ["name"]),
|
|
20
20
|
});
|
|
@@ -0,0 +1 @@
|
|
|
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,EAAE,WAAW;QACzC,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;YACpC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,6CAA6C;SAC1E,CAAC,CACH;QACD,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,EAAE,qCAAqC;QAC/F,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@convex-dev/crons",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Convex component for scheduling periodic jobs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"convex",
|
|
@@ -17,56 +17,75 @@
|
|
|
17
17
|
"repository": "github:get-convex/crons",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"type": "module",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"src"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"dev": "convex dev --start 'npm run dev:build'",
|
|
26
|
+
"dev:frontend": "cd example && vite --clearScreen false",
|
|
27
|
+
"dev:build": "chokidar 'tsconfig*.json' 'src/**/*.ts' -i '**/*.test.ts' -c 'npm run build:codegen' --initial",
|
|
28
|
+
"predev": "convex init && npm run build:codegen",
|
|
29
|
+
"build": "tsc --project ./tsconfig.build.json",
|
|
30
|
+
"build:codegen": "npx convex codegen --component-dir ./src/component && npm run build",
|
|
31
|
+
"build:clean": "rm -rf dist *.tsbuildinfo && npm run build:codegen",
|
|
32
|
+
"typecheck": "tsc --noEmit && tsc -p example/convex",
|
|
33
|
+
"lint": "eslint .",
|
|
34
|
+
"test": "vitest run --typecheck",
|
|
35
|
+
"test:watch": "vitest --typecheck --clearScreen false",
|
|
36
|
+
"test:debug": "vitest --inspect-brk --no-file-parallelism",
|
|
37
|
+
"test:coverage": "vitest run --coverage --coverage.reporter=text",
|
|
38
|
+
"preversion": "npm ci && npm run build:clean && npm run test && npm run lint && npm run typecheck",
|
|
39
|
+
"alpha": "npm version prerelease --preid alpha && npm publish --tag alpha && git push --follow-tags",
|
|
40
|
+
"release": "npm version patch && npm publish && git push --follow-tags",
|
|
41
|
+
"version": "(npm whoami || npm login) && vim -c 'normal o' -c 'normal o## '$npm_package_version CHANGELOG.md && prettier -w CHANGELOG.md && git add CHANGELOG.md"
|
|
42
|
+
},
|
|
20
43
|
"exports": {
|
|
21
44
|
"./package.json": "./package.json",
|
|
22
45
|
".": {
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"@convex-dev/component-source": "./src/client/index.ts",
|
|
30
|
-
"types": "./dist/commonjs/client/index.d.ts",
|
|
31
|
-
"default": "./dist/commonjs/client/index.js"
|
|
32
|
-
}
|
|
46
|
+
"types": "./dist/client/index.d.ts",
|
|
47
|
+
"default": "./dist/client/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./test": "./src/test.ts",
|
|
50
|
+
"./_generated/component.js": {
|
|
51
|
+
"types": "./dist/component/_generated/component.d.ts"
|
|
33
52
|
},
|
|
34
53
|
"./convex.config": {
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
55
|
+
"default": "./dist/component/convex.config.js"
|
|
56
|
+
},
|
|
57
|
+
"./convex.config.js": {
|
|
58
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
59
|
+
"default": "./dist/component/convex.config.js"
|
|
40
60
|
}
|
|
41
61
|
},
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"types": "./dist/commonjs/client/index.d.ts",
|
|
45
|
-
"files": [
|
|
46
|
-
"dist",
|
|
47
|
-
"src"
|
|
48
|
-
],
|
|
49
|
-
"scripts": {
|
|
50
|
-
"build": "npm run build:esm && npm run build:cjs",
|
|
51
|
-
"build:cjs": "tsc --project ./commonjs.json && echo '{\\n \"type\": \"commonjs\"\\n}' > dist/commonjs/package.json",
|
|
52
|
-
"build:esm": "tsc --project ./esm.json && echo '{\\n \"type\": \"module\"\\n}' > dist/esm/package.json",
|
|
53
|
-
"lint": "eslint --ext .ts src",
|
|
54
|
-
"prepare": "npm run build",
|
|
55
|
-
"typecheck": "tsc --noEmit"
|
|
56
|
-
},
|
|
62
|
+
"module": "./dist/client/index.js",
|
|
63
|
+
"types": "./dist/client/index.d.ts",
|
|
57
64
|
"dependencies": {
|
|
58
65
|
"cron-parser": "^4.9.0"
|
|
59
66
|
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"@eslint/js": "^9.28.0",
|
|
62
|
-
"@types/node": "^18.17.0",
|
|
63
|
-
"eslint": "^9.28.0",
|
|
64
|
-
"globals": "^16.2.0",
|
|
65
|
-
"prettier": "3.2.5",
|
|
66
|
-
"typescript": "~5.0.3",
|
|
67
|
-
"typescript-eslint": "^8.33.1"
|
|
68
|
-
},
|
|
69
67
|
"peerDependencies": {
|
|
70
|
-
"convex": "
|
|
68
|
+
"convex": "^1.24.8"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@arethetypeswrong/cli": "0.18.3",
|
|
72
|
+
"@convex-dev/eslint-plugin": "2.0.0",
|
|
73
|
+
"@edge-runtime/vm": "5.0.0",
|
|
74
|
+
"@eslint/eslintrc": "3.3.5",
|
|
75
|
+
"@eslint/js": "10.0.1",
|
|
76
|
+
"@types/node": "24.12.4",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "8.60.0",
|
|
78
|
+
"@typescript-eslint/parser": "8.60.0",
|
|
79
|
+
"chokidar-cli": "3.0.0",
|
|
80
|
+
"convex": "1.39.1",
|
|
81
|
+
"convex-test": "0.0.53",
|
|
82
|
+
"eslint": "10.4.1",
|
|
83
|
+
"eslint-plugin-react-hooks": "7.1.1",
|
|
84
|
+
"eslint-plugin-react-refresh": "0.5.2",
|
|
85
|
+
"globals": "17.6.0",
|
|
86
|
+
"prettier": "3.8.3",
|
|
87
|
+
"typescript": "6.0.3",
|
|
88
|
+
"typescript-eslint": "8.60.0",
|
|
89
|
+
"vitest": "4.1.7"
|
|
71
90
|
}
|
|
72
91
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
createFunctionHandle,
|
|
5
|
-
FunctionArgs,
|
|
6
|
-
FunctionHandle,
|
|
7
|
-
SchedulableFunctionReference,
|
|
5
|
+
type FunctionArgs,
|
|
6
|
+
type FunctionHandle,
|
|
7
|
+
type SchedulableFunctionReference,
|
|
8
8
|
} from "convex/server";
|
|
9
|
-
import {
|
|
10
|
-
import { CronInfo, Schedule } from "../component/public.js";
|
|
11
|
-
import { RunMutationCtx, RunQueryCtx
|
|
9
|
+
import type { ComponentApi } from "../component/_generated/component.js";
|
|
10
|
+
import type { CronInfo, Schedule } from "../component/public.js";
|
|
11
|
+
import type { RunMutationCtx, RunQueryCtx } from "./utils.js";
|
|
12
12
|
|
|
13
13
|
export type { CronInfo };
|
|
14
14
|
|
|
@@ -52,7 +52,7 @@ export class Crons {
|
|
|
52
52
|
* }
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
|
-
constructor(private component:
|
|
55
|
+
constructor(private component: ComponentApi) {}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Schedule a mutation or action to run on a cron schedule or interval.
|
|
@@ -71,7 +71,7 @@ export class Crons {
|
|
|
71
71
|
schedule: Schedule,
|
|
72
72
|
func: F,
|
|
73
73
|
args: FunctionArgs<F>,
|
|
74
|
-
name?: string
|
|
74
|
+
name?: string,
|
|
75
75
|
): Promise<string> {
|
|
76
76
|
return ctx.runMutation(this.component.public.register, {
|
|
77
77
|
name,
|
|
@@ -104,7 +104,7 @@ export class Crons {
|
|
|
104
104
|
*/
|
|
105
105
|
async get(
|
|
106
106
|
ctx: RunQueryCtx,
|
|
107
|
-
identifier: { id: string } | { name: string }
|
|
107
|
+
identifier: { id: string } | { name: string },
|
|
108
108
|
): Promise<CronInfo | null> {
|
|
109
109
|
const cron = await ctx.runQuery(this.component.public.get, { identifier });
|
|
110
110
|
if (cron === null) {
|
|
@@ -125,7 +125,7 @@ export class Crons {
|
|
|
125
125
|
*/
|
|
126
126
|
async delete(
|
|
127
127
|
ctx: RunMutationCtx,
|
|
128
|
-
identifier: { id: string } | { name: string }
|
|
128
|
+
identifier: { id: string } | { name: string },
|
|
129
129
|
): Promise<null> {
|
|
130
130
|
return ctx.runMutation(this.component.public.del, { identifier });
|
|
131
131
|
}
|
package/src/client/utils.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
// Type utilities for component clients.
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
|
-
Expand,
|
|
5
|
-
FunctionReference,
|
|
6
2
|
GenericDataModel,
|
|
7
3
|
GenericMutationCtx,
|
|
8
4
|
GenericQueryCtx,
|
|
9
5
|
} from "convex/server";
|
|
10
|
-
import type { GenericId } from "convex/values";
|
|
11
6
|
|
|
12
7
|
export type RunQueryCtx = {
|
|
13
8
|
runQuery: GenericQueryCtx<GenericDataModel>["runQuery"];
|
|
@@ -15,30 +10,3 @@ export type RunQueryCtx = {
|
|
|
15
10
|
export type RunMutationCtx = {
|
|
16
11
|
runMutation: GenericMutationCtx<GenericDataModel>["runMutation"];
|
|
17
12
|
};
|
|
18
|
-
|
|
19
|
-
export type OpaqueIds<T> =
|
|
20
|
-
T extends GenericId<infer _T>
|
|
21
|
-
? string
|
|
22
|
-
: T extends (infer U)[]
|
|
23
|
-
? OpaqueIds<U>[]
|
|
24
|
-
: T extends object
|
|
25
|
-
? { [K in keyof T]: OpaqueIds<T[K]> }
|
|
26
|
-
: T;
|
|
27
|
-
|
|
28
|
-
export type UseApi<API> = Expand<{
|
|
29
|
-
[mod in keyof API]: API[mod] extends FunctionReference<
|
|
30
|
-
infer FType,
|
|
31
|
-
"public",
|
|
32
|
-
infer FArgs,
|
|
33
|
-
infer FReturnType,
|
|
34
|
-
infer FComponentPath
|
|
35
|
-
>
|
|
36
|
-
? FunctionReference<
|
|
37
|
-
FType,
|
|
38
|
-
"internal",
|
|
39
|
-
OpaqueIds<FArgs>,
|
|
40
|
-
OpaqueIds<FReturnType>,
|
|
41
|
-
FComponentPath
|
|
42
|
-
>
|
|
43
|
-
: UseApi<API[mod]>;
|
|
44
|
-
}>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type * as public_ from "../public.js";
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
ApiFromModules,
|
|
15
|
+
FilterApi,
|
|
16
|
+
FunctionReference,
|
|
17
|
+
} from "convex/server";
|
|
18
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
19
|
+
|
|
20
|
+
const fullApi: ApiFromModules<{
|
|
21
|
+
public: typeof public_;
|
|
22
|
+
}> = anyApi as any;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
26
|
+
*
|
|
27
|
+
* Usage:
|
|
28
|
+
* ```js
|
|
29
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const api: FilterApi<
|
|
33
|
+
typeof fullApi,
|
|
34
|
+
FunctionReference<any, "public">
|
|
35
|
+
> = anyApi as any;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
39
|
+
*
|
|
40
|
+
* Usage:
|
|
41
|
+
* ```js
|
|
42
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export const internal: FilterApi<
|
|
46
|
+
typeof fullApi,
|
|
47
|
+
FunctionReference<any, "internal">
|
|
48
|
+
> = anyApi as any;
|
|
49
|
+
|
|
50
|
+
export const components = componentsGeneric() as unknown as {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `ComponentApi` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { FunctionReference } from "convex/server";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A utility for referencing a Convex component's exposed API.
|
|
15
|
+
*
|
|
16
|
+
* Useful when expecting a parameter like `components.myComponent`.
|
|
17
|
+
* Usage:
|
|
18
|
+
* ```ts
|
|
19
|
+
* async function myFunction(ctx: QueryCtx, component: ComponentApi) {
|
|
20
|
+
* return ctx.runQuery(component.someFile.someQuery, { ...args });
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
25
|
+
{
|
|
26
|
+
public: {
|
|
27
|
+
del: FunctionReference<
|
|
28
|
+
"mutation",
|
|
29
|
+
"internal",
|
|
30
|
+
{ identifier: { id: string } | { name: string } },
|
|
31
|
+
null,
|
|
32
|
+
Name
|
|
33
|
+
>;
|
|
34
|
+
get: FunctionReference<
|
|
35
|
+
"query",
|
|
36
|
+
"internal",
|
|
37
|
+
{ identifier: { id: string } | { name: string } },
|
|
38
|
+
{
|
|
39
|
+
args: Record<string, any>;
|
|
40
|
+
functionHandle: string;
|
|
41
|
+
id: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
schedule:
|
|
44
|
+
| { kind: "interval"; ms: number }
|
|
45
|
+
| { cronspec: string; kind: "cron"; tz?: string };
|
|
46
|
+
} | null,
|
|
47
|
+
Name
|
|
48
|
+
>;
|
|
49
|
+
list: FunctionReference<
|
|
50
|
+
"query",
|
|
51
|
+
"internal",
|
|
52
|
+
{},
|
|
53
|
+
Array<{
|
|
54
|
+
args: Record<string, any>;
|
|
55
|
+
functionHandle: string;
|
|
56
|
+
id: string;
|
|
57
|
+
name?: string;
|
|
58
|
+
schedule:
|
|
59
|
+
| { kind: "interval"; ms: number }
|
|
60
|
+
| { cronspec: string; kind: "cron"; tz?: string };
|
|
61
|
+
}>,
|
|
62
|
+
Name
|
|
63
|
+
>;
|
|
64
|
+
register: FunctionReference<
|
|
65
|
+
"mutation",
|
|
66
|
+
"internal",
|
|
67
|
+
{
|
|
68
|
+
args: Record<string, any>;
|
|
69
|
+
functionHandle: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
schedule:
|
|
72
|
+
| { kind: "interval"; ms: number }
|
|
73
|
+
| { cronspec: string; kind: "cron"; tz?: string };
|
|
74
|
+
},
|
|
75
|
+
string,
|
|
76
|
+
Name
|
|
77
|
+
>;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* prettier-ignore-start */
|
|
2
|
-
|
|
3
1
|
/* eslint-disable */
|
|
4
2
|
/**
|
|
5
3
|
* Generated data model types.
|
|
@@ -40,7 +38,7 @@ export type Doc<TableName extends TableNames> = DocumentByName<
|
|
|
40
38
|
* Convex documents are uniquely identified by their `Id`, which is accessible
|
|
41
39
|
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
|
|
42
40
|
*
|
|
43
|
-
* Documents can be loaded using `db.get(id)` in query and mutation functions.
|
|
41
|
+
* Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
|
|
44
42
|
*
|
|
45
43
|
* IDs are just strings at runtime, but this type can be used to distinguish them from other
|
|
46
44
|
* strings when type checking.
|
|
@@ -60,5 +58,3 @@ export type Id<TableName extends TableNames | SystemTableNames> =
|
|
|
60
58
|
* `mutationGeneric` to make them type-safe.
|
|
61
59
|
*/
|
|
62
60
|
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
|
|
63
|
-
|
|
64
|
-
/* prettier-ignore-end */
|