@vitnode/core 1.2.0-canary.53 → 1.2.0-canary.54
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/scripts/prepare-database.d.ts +0 -1
- package/dist/scripts/prepare-database.d.ts.map +1 -1
- package/dist/scripts/scripts.js +4 -4
- package/dist/src/api/adapters/cron/node-cron.adapter.d.ts +3 -0
- package/dist/src/api/adapters/cron/node-cron.adapter.d.ts.map +1 -0
- package/dist/src/api/adapters/cron/node-cron.adapter.js +11 -0
- package/dist/src/api/config.d.ts.map +1 -1
- package/dist/src/api/config.js +21 -9
- package/dist/src/api/lib/cron.d.ts +18 -0
- package/dist/src/api/lib/cron.d.ts.map +1 -0
- package/dist/src/api/lib/cron.js +22 -0
- package/dist/src/api/lib/module.d.ts +4 -1
- package/dist/src/api/lib/module.d.ts.map +1 -1
- package/dist/src/api/lib/module.js +3 -2
- package/dist/src/api/lib/plugin.d.ts +2 -0
- package/dist/src/api/lib/plugin.d.ts.map +1 -1
- package/dist/src/api/lib/plugin.js +9 -1
- package/dist/src/api/middlewares/cron-auth.middleware.d.ts +3 -0
- package/dist/src/api/middlewares/cron-auth.middleware.d.ts.map +1 -0
- package/dist/src/api/middlewares/cron-auth.middleware.js +19 -0
- package/dist/src/api/middlewares/global.middleware.d.ts +6 -0
- package/dist/src/api/middlewares/global.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/global.middleware.js +33 -22
- package/dist/src/api/models/user/sign-up.d.ts +1 -1
- package/dist/src/api/models/user.d.ts +1 -1
- package/dist/src/api/modules/admin/admin.module.d.ts +163 -1
- package/dist/src/api/modules/admin/admin.module.d.ts.map +1 -1
- package/dist/src/api/modules/admin/admin.module.js +6 -3
- package/dist/src/api/modules/admin/advanced/advanced.admin.module.d.ts +164 -0
- package/dist/src/api/modules/admin/advanced/advanced.admin.module.d.ts.map +1 -0
- package/dist/src/api/modules/admin/advanced/advanced.admin.module.js +11 -0
- package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.d.ts +164 -0
- package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.d.ts.map +1 -0
- package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.js +12 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/get.route.d.ts +98 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/get.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/get.route.js +66 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/run.route.d.ts +70 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/run.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/run.route.js +95 -0
- package/dist/src/api/modules/admin/debug/debug.admin.module.js +1 -1
- package/dist/src/api/modules/admin/debug/routes/logs.route.js +1 -1
- package/dist/src/api/modules/admin/routes/session.route.js +1 -1
- package/dist/src/api/modules/admin/users/routes/list.route.js +1 -1
- package/dist/src/api/modules/admin/users/routes/users.route.d.ts +3 -3
- package/dist/src/api/modules/admin/users/routes/users.route.js +1 -1
- package/dist/src/api/modules/admin/users/users.admin.module.js +1 -1
- package/dist/src/api/modules/cron/cron/clean.cron.d.ts +2 -0
- package/dist/src/api/modules/cron/cron/clean.cron.d.ts.map +1 -0
- package/dist/src/api/modules/cron/cron/clean.cron.js +24 -0
- package/dist/src/api/modules/cron/cron.module.d.ts +26 -0
- package/dist/src/api/modules/cron/cron.module.d.ts.map +1 -0
- package/dist/src/api/modules/cron/cron.module.js +14 -0
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts +36 -0
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts.map +1 -0
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.js +72 -0
- package/dist/src/api/modules/cron/routes/cron.route.d.ts +27 -0
- package/dist/src/api/modules/cron/routes/cron.route.d.ts.map +1 -0
- package/dist/src/api/modules/cron/routes/cron.route.js +95 -0
- package/dist/src/api/modules/middleware/middleware.module.js +1 -1
- package/dist/src/api/modules/middleware/route.js +1 -1
- package/dist/src/api/modules/users/routes/change-password.route.js +1 -1
- package/dist/src/api/modules/users/routes/reset-passowrd.route.js +1 -1
- package/dist/src/api/modules/users/routes/session.route.js +1 -1
- package/dist/src/api/modules/users/routes/sign-in.route.js +1 -1
- package/dist/src/api/modules/users/routes/sign-out.route.js +1 -1
- package/dist/src/api/modules/users/routes/sign-up.route.js +1 -1
- package/dist/src/api/modules/users/routes/test.route.js +1 -1
- package/dist/src/api/modules/users/sso/routes/callback.route.js +1 -1
- package/dist/src/api/modules/users/sso/routes/create-url.route.js +1 -1
- package/dist/src/api/modules/users/sso/sso.module.js +1 -1
- package/dist/src/api/modules/users/users.module.js +1 -1
- package/dist/src/api/plugin.d.ts.map +1 -1
- package/dist/src/api/plugin.js +4 -2
- package/dist/src/app_admin/core/advanced/cron/page.d.ts +11 -0
- package/dist/src/app_admin/core/advanced/cron/page.d.ts.map +1 -0
- package/dist/src/app_admin/core/advanced/cron/page.js +42 -0
- package/dist/src/components/switchers/langs/{language-swietcher.d.ts → language-switcher.d.ts} +1 -1
- package/dist/src/components/switchers/langs/language-switcher.d.ts.map +1 -0
- package/dist/src/components/tiptap/extension.d.ts +4 -0
- package/dist/src/components/tiptap/extension.d.ts.map +1 -0
- package/dist/src/components/tiptap/extension.js +26 -0
- package/dist/src/components/tiptap/toolbar/actions/bold-action.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/bold-action.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/bold-action.js +39 -0
- package/dist/src/components/tiptap/toolbar/actions/headings-action.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/headings-action.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/headings-action.js +94 -0
- package/dist/src/components/tiptap/toolbar/actions/italic-action.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/italic-action.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/italic-action.js +38 -0
- package/dist/src/components/tiptap/toolbar/actions/list-action.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/list-action.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/list-action.js +60 -0
- package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.js +59 -0
- package/dist/src/components/tiptap/toolbar/actions/underline-action.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/underline-action.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/underline-action.js +38 -0
- package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.js +63 -0
- package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.d.ts +4 -0
- package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.js +11 -0
- package/dist/src/components/tiptap/toolbar/tiptap-toolbar.d.ts +5 -0
- package/dist/src/components/tiptap/toolbar/tiptap-toolbar.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/tiptap-toolbar.js +35 -0
- package/dist/src/components/tiptap/toolbar/use-toolbar-editor.d.ts +9 -0
- package/dist/src/components/tiptap/toolbar/use-toolbar-editor.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/use-toolbar-editor.js +5 -0
- package/dist/src/components/ui/button-client.d.ts.map +1 -1
- package/dist/src/components/ui/button-client.js +1 -1
- package/dist/src/components/ui/button.js +1 -1
- package/dist/src/components/ui/editor-content.d.ts +4 -0
- package/dist/src/components/ui/editor-content.d.ts.map +1 -0
- package/dist/src/components/ui/editor-content.js +10 -0
- package/dist/src/components/ui/editor.d.ts +6 -0
- package/dist/src/components/ui/editor.d.ts.map +1 -0
- package/dist/src/components/ui/editor.js +35 -0
- package/dist/src/components/ui/sidebar.js +14 -14
- package/dist/src/components/ui/table.js +1 -1
- package/dist/src/components/ui/tooltip.d.ts +4 -1
- package/dist/src/components/ui/tooltip.d.ts.map +1 -1
- package/dist/src/components/ui/tooltip.js +18 -2
- package/dist/src/database/cron.d.ts +171 -0
- package/dist/src/database/cron.d.ts.map +1 -0
- package/dist/src/database/cron.js +22 -0
- package/dist/src/database/users.d.ts +2 -2
- package/dist/src/database/users.js +1 -1
- package/dist/src/lib/api/get-next-cron-run-date.d.ts +2 -0
- package/dist/src/lib/api/get-next-cron-run-date.d.ts.map +1 -0
- package/dist/src/lib/api/get-next-cron-run-date.js +14 -0
- package/dist/src/lib/api/get-next-cron-run-date.test.d.ts +2 -0
- package/dist/src/lib/api/get-next-cron-run-date.test.d.ts.map +1 -0
- package/dist/src/lib/api/get-next-cron-run-date.test.js +55 -0
- package/dist/src/lib/api/should-cron-job-run.d.ts +2 -0
- package/dist/src/lib/api/should-cron-job-run.d.ts.map +1 -0
- package/dist/src/lib/api/should-cron-job-run.js +16 -0
- package/dist/src/lib/api/should-cron-job-run.test.d.ts +2 -0
- package/dist/src/lib/api/should-cron-job-run.test.d.ts.map +1 -0
- package/dist/src/lib/api/should-cron-job-run.test.js +213 -0
- package/dist/src/lib/config.d.ts +1 -0
- package/dist/src/lib/config.d.ts.map +1 -1
- package/dist/src/lib/config.js +7 -5
- package/dist/src/lib/ctrl-or-command-character.d.ts +2 -0
- package/dist/src/lib/ctrl-or-command-character.d.ts.map +1 -0
- package/dist/src/lib/ctrl-or-command-character.js +9 -0
- package/dist/src/lib/navigation.d.ts +1 -1
- package/dist/src/lib/navigation.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/admin-layout.js +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/item.js +0 -3
- package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/nav.js +12 -1
- package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.d.ts +5 -0
- package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.d.ts.map +1 -0
- package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.js +97 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.d.ts +4 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.d.ts.map +1 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.js +23 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.d.ts +4 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.d.ts.map +1 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.js +37 -0
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +11 -20
- package/dist/src/views/admin/views/core/test.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/test.js +116 -106
- package/dist/src/views/layouts/theme/header/header.js +1 -1
- package/dist/src/vitnode.config.d.ts +2 -0
- package/dist/src/vitnode.config.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -26
- package/src/app_admin/core/advanced/cron/page.tsx +41 -0
- package/src/locales/en.json +43 -0
- package/src/tiptap.css +20 -0
- package/dist/src/components/switchers/langs/language-swietcher.d.ts.map +0 -1
- /package/dist/src/components/switchers/langs/{language-swietcher.js → language-switcher.js} +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare const getCronsRoute: {
|
|
3
|
+
handler: (c: import("hono").Context<import("../../../../../middlewares/global.middleware").EnvVitNode, "/", {
|
|
4
|
+
in: {
|
|
5
|
+
query: {
|
|
6
|
+
cursor?: string | undefined;
|
|
7
|
+
first?: string | undefined;
|
|
8
|
+
last?: string | undefined;
|
|
9
|
+
order?: "asc" | "desc" | undefined;
|
|
10
|
+
orderBy?: "createdAt" | "lastRun" | "nextRun" | undefined;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
out: {
|
|
14
|
+
query: {
|
|
15
|
+
cursor?: string | undefined;
|
|
16
|
+
first?: string | undefined;
|
|
17
|
+
last?: string | undefined;
|
|
18
|
+
order?: "asc" | "desc" | undefined;
|
|
19
|
+
orderBy?: "createdAt" | "lastRun" | "nextRun" | undefined;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}>) => Promise<Response & import("hono").TypedResponse<{
|
|
23
|
+
edges: {
|
|
24
|
+
id: number;
|
|
25
|
+
name: string;
|
|
26
|
+
description: string | null;
|
|
27
|
+
lastRun: string | null;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
pluginId: string;
|
|
30
|
+
module: string;
|
|
31
|
+
nextRun: string | null;
|
|
32
|
+
schedule: string;
|
|
33
|
+
}[];
|
|
34
|
+
pageInfo: {
|
|
35
|
+
count: number;
|
|
36
|
+
endCursor: null | number;
|
|
37
|
+
hasNextPage: boolean;
|
|
38
|
+
hasPreviousPage: boolean;
|
|
39
|
+
startCursor: null | number;
|
|
40
|
+
totalCount: number;
|
|
41
|
+
};
|
|
42
|
+
}, 200, "json">>;
|
|
43
|
+
pluginId: "@vitnode/core";
|
|
44
|
+
route: {
|
|
45
|
+
method: "get";
|
|
46
|
+
description: string;
|
|
47
|
+
path: "/";
|
|
48
|
+
request: {
|
|
49
|
+
query: z.ZodObject<{
|
|
50
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
51
|
+
first: z.ZodOptional<z.ZodString>;
|
|
52
|
+
last: z.ZodOptional<z.ZodString>;
|
|
53
|
+
order: z.ZodOptional<z.ZodEnum<{
|
|
54
|
+
asc: "asc";
|
|
55
|
+
desc: "desc";
|
|
56
|
+
}>>;
|
|
57
|
+
orderBy: z.ZodOptional<z.ZodEnum<{
|
|
58
|
+
createdAt: "createdAt";
|
|
59
|
+
lastRun: "lastRun";
|
|
60
|
+
nextRun: "nextRun";
|
|
61
|
+
}>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
};
|
|
64
|
+
responses: {
|
|
65
|
+
200: {
|
|
66
|
+
content: {
|
|
67
|
+
"application/json": {
|
|
68
|
+
schema: z.ZodObject<{
|
|
69
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
70
|
+
id: z.ZodNumber;
|
|
71
|
+
createdAt: z.ZodDate;
|
|
72
|
+
name: z.ZodString;
|
|
73
|
+
description: z.ZodNullable<z.ZodString>;
|
|
74
|
+
pluginId: z.ZodString;
|
|
75
|
+
module: z.ZodString;
|
|
76
|
+
lastRun: z.ZodNullable<z.ZodDate>;
|
|
77
|
+
nextRun: z.ZodNullable<z.ZodDate>;
|
|
78
|
+
schedule: z.ZodString;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
pageInfo: z.ZodObject<{
|
|
81
|
+
totalCount: z.ZodNumber;
|
|
82
|
+
count: z.ZodNumber;
|
|
83
|
+
hasNextPage: z.ZodBoolean;
|
|
84
|
+
hasPreviousPage: z.ZodBoolean;
|
|
85
|
+
startCursor: z.ZodNullable<z.ZodNumber>;
|
|
86
|
+
endCursor: z.ZodNullable<z.ZodNumber>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
} & {
|
|
95
|
+
getRoutingPath: () => "/";
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=get.route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.route.d.ts","sourceRoot":"","sources":["../../../../../../../../src/api/modules/admin/advanced/cron/routes/get.route.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAUpB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DxB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { buildRoute } from "../../../../../lib/route.js";
|
|
3
|
+
import { withPagination, zodPaginationPageInfo, zodPaginationQuery } from "../../../../../lib/with-pagination.js";
|
|
4
|
+
import { CONFIG_PLUGIN } from "../../../../../../config.js";
|
|
5
|
+
import { core_cron } from "../../../../../../database/cron.js";
|
|
6
|
+
export const getCronsRoute = buildRoute({
|
|
7
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
8
|
+
route: {
|
|
9
|
+
method: "get",
|
|
10
|
+
description: "Get Admin Cron Logs",
|
|
11
|
+
path: "/",
|
|
12
|
+
request: {
|
|
13
|
+
query: zodPaginationQuery.extend({
|
|
14
|
+
order: z.enum([
|
|
15
|
+
"asc",
|
|
16
|
+
"desc"
|
|
17
|
+
]).optional(),
|
|
18
|
+
orderBy: z.enum([
|
|
19
|
+
"createdAt",
|
|
20
|
+
"lastRun",
|
|
21
|
+
"nextRun"
|
|
22
|
+
]).optional()
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
responses: {
|
|
26
|
+
200: {
|
|
27
|
+
content: {
|
|
28
|
+
"application/json": {
|
|
29
|
+
schema: z.object({
|
|
30
|
+
edges: z.array(z.object({
|
|
31
|
+
id: z.number(),
|
|
32
|
+
createdAt: z.date(),
|
|
33
|
+
name: z.string(),
|
|
34
|
+
description: z.string().nullable(),
|
|
35
|
+
pluginId: z.string(),
|
|
36
|
+
module: z.string(),
|
|
37
|
+
lastRun: z.date().nullable(),
|
|
38
|
+
nextRun: z.date().nullable(),
|
|
39
|
+
schedule: z.string()
|
|
40
|
+
})),
|
|
41
|
+
pageInfo: zodPaginationPageInfo
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
description: "List of cron jobs"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
handler: async (c)=>{
|
|
50
|
+
const query = c.req.valid("query");
|
|
51
|
+
const data = await withPagination({
|
|
52
|
+
params: {
|
|
53
|
+
query
|
|
54
|
+
},
|
|
55
|
+
c,
|
|
56
|
+
primaryCursor: core_cron.id,
|
|
57
|
+
query: async ({ limit, where, orderBy })=>await c.get("db").select().from(core_cron).where(where).orderBy(orderBy).limit(limit),
|
|
58
|
+
table: core_cron,
|
|
59
|
+
orderBy: {
|
|
60
|
+
column: query.orderBy ? core_cron[query.orderBy] : core_cron.lastRun,
|
|
61
|
+
order: query.order ?? "desc"
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return c.json(data);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const runCronRoute: {
|
|
3
|
+
handler: (c: import("hono").Context<import("../../../../../middlewares/global.middleware").EnvVitNode, "/:id", {
|
|
4
|
+
in: {
|
|
5
|
+
param: {
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
out: {
|
|
10
|
+
param: {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}>) => Promise<(Response & import("hono").TypedResponse<{
|
|
15
|
+
error: string;
|
|
16
|
+
}, 404, "json">) | (Response & import("hono").TypedResponse<{
|
|
17
|
+
message: string;
|
|
18
|
+
}, 201, "json">) | (Response & import("hono").TypedResponse<{
|
|
19
|
+
error: string;
|
|
20
|
+
}, 500, "json">)>;
|
|
21
|
+
pluginId: "@vitnode/core";
|
|
22
|
+
route: {
|
|
23
|
+
method: "post";
|
|
24
|
+
description: string;
|
|
25
|
+
path: "/{id}";
|
|
26
|
+
request: {
|
|
27
|
+
params: z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
};
|
|
31
|
+
responses: {
|
|
32
|
+
201: {
|
|
33
|
+
content: {
|
|
34
|
+
"application/json": {
|
|
35
|
+
schema: z.ZodObject<{
|
|
36
|
+
message: z.ZodOptional<z.ZodString>;
|
|
37
|
+
error: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
404: {
|
|
44
|
+
content: {
|
|
45
|
+
"application/json": {
|
|
46
|
+
schema: z.ZodObject<{
|
|
47
|
+
message: z.ZodOptional<z.ZodString>;
|
|
48
|
+
error: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
500: {
|
|
55
|
+
content: {
|
|
56
|
+
"application/json": {
|
|
57
|
+
schema: z.ZodObject<{
|
|
58
|
+
message: z.ZodOptional<z.ZodString>;
|
|
59
|
+
error: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
} & {
|
|
67
|
+
getRoutingPath: () => "/:id";
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=run.route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.route.d.ts","sourceRoot":"","sources":["../../../../../../../../src/api/modules/admin/advanced/cron/routes/run.route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwGvB,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { buildRoute } from "../../../../../lib/route.js";
|
|
4
|
+
import { CONFIG_PLUGIN } from "../../../../../../config.js";
|
|
5
|
+
import { core_cron } from "../../../../../../database/cron.js";
|
|
6
|
+
import { getNextCronRunDate } from "../../../../../../lib/api/get-next-cron-run-date.js";
|
|
7
|
+
export const runCronRoute = buildRoute({
|
|
8
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
9
|
+
route: {
|
|
10
|
+
method: "post",
|
|
11
|
+
description: "Run a specific cron job",
|
|
12
|
+
path: "/{id}",
|
|
13
|
+
request: {
|
|
14
|
+
params: z.object({
|
|
15
|
+
id: z.string()
|
|
16
|
+
})
|
|
17
|
+
},
|
|
18
|
+
responses: {
|
|
19
|
+
201: {
|
|
20
|
+
content: {
|
|
21
|
+
"application/json": {
|
|
22
|
+
schema: z.object({
|
|
23
|
+
message: z.string().optional(),
|
|
24
|
+
error: z.string().optional()
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
description: "Cron job executed successfully"
|
|
29
|
+
},
|
|
30
|
+
404: {
|
|
31
|
+
content: {
|
|
32
|
+
"application/json": {
|
|
33
|
+
schema: z.object({
|
|
34
|
+
message: z.string().optional(),
|
|
35
|
+
error: z.string().optional()
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
description: "Cron job not found"
|
|
40
|
+
},
|
|
41
|
+
500: {
|
|
42
|
+
content: {
|
|
43
|
+
"application/json": {
|
|
44
|
+
schema: z.object({
|
|
45
|
+
message: z.string().optional(),
|
|
46
|
+
error: z.string().optional()
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
description: "Internal server error"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
handler: async (c)=>{
|
|
55
|
+
const db = c.get("db");
|
|
56
|
+
const cronJobs = c.get("core").cron;
|
|
57
|
+
const param = c.req.valid("param");
|
|
58
|
+
try {
|
|
59
|
+
const cronFromDb = await db.select().from(core_cron).where(eq(core_cron.id, +param.id)).limit(1);
|
|
60
|
+
if (cronFromDb.length === 0) {
|
|
61
|
+
return c.json({
|
|
62
|
+
error: "Cron job not found"
|
|
63
|
+
}, 404);
|
|
64
|
+
}
|
|
65
|
+
const dbCron = cronFromDb[0];
|
|
66
|
+
const job = cronJobs.find((j)=>j.name === dbCron.name && j.pluginId === dbCron.pluginId && j.module === dbCron.module);
|
|
67
|
+
if (!job) {
|
|
68
|
+
return c.json({
|
|
69
|
+
error: "Cron job configuration not found"
|
|
70
|
+
}, 404);
|
|
71
|
+
}
|
|
72
|
+
const now = new Date();
|
|
73
|
+
try {
|
|
74
|
+
await job.handler(c);
|
|
75
|
+
await db.update(core_cron).set({
|
|
76
|
+
lastRun: now,
|
|
77
|
+
nextRun: getNextCronRunDate(job.schedule, now)
|
|
78
|
+
}).where(eq(core_cron.id, dbCron.id));
|
|
79
|
+
return c.json({
|
|
80
|
+
message: "Cron job executed successfully"
|
|
81
|
+
}, 201);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
await c.get("log").error(`Error executing cron job: ${error}`);
|
|
84
|
+
return c.json({
|
|
85
|
+
error: "Failed to execute cron job"
|
|
86
|
+
}, 500);
|
|
87
|
+
}
|
|
88
|
+
} catch (error) {
|
|
89
|
+
await c.get("log").error(`Error running cron job: ${error}`);
|
|
90
|
+
return c.json({
|
|
91
|
+
error: "Internal server error"
|
|
92
|
+
}, 500);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
@@ -2,7 +2,7 @@ import { CONFIG_PLUGIN } from "../../../../config.js";
|
|
|
2
2
|
import { buildModule } from "../../../lib/module.js";
|
|
3
3
|
import { logsDebugAdminRoute } from "./routes/logs.route.js";
|
|
4
4
|
export const debugAdminModule = buildModule({
|
|
5
|
-
|
|
5
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
6
6
|
name: "debug",
|
|
7
7
|
routes: [
|
|
8
8
|
logsDebugAdminRoute
|
|
@@ -6,7 +6,7 @@ import { core_users } from "../../../../../database/users.js";
|
|
|
6
6
|
import { buildRoute } from "../../../../lib/route.js";
|
|
7
7
|
import { withPagination, zodPaginationPageInfo, zodPaginationQuery } from "../../../../lib/with-pagination.js";
|
|
8
8
|
export const logsDebugAdminRoute = buildRoute({
|
|
9
|
-
|
|
9
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
10
10
|
route: {
|
|
11
11
|
method: "get",
|
|
12
12
|
description: "Get Admin Debug Logs",
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { buildRoute } from "../../../lib/route.js";
|
|
4
4
|
import { CONFIG_PLUGIN } from "../../../../config.js";
|
|
5
5
|
export const sessionAdminRoute = buildRoute({
|
|
6
|
-
|
|
6
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
7
7
|
route: {
|
|
8
8
|
method: "get",
|
|
9
9
|
description: "Verify admin session",
|
|
@@ -4,7 +4,7 @@ import { withPagination, zodPaginationPageInfo, zodPaginationQuery } from "../..
|
|
|
4
4
|
import { CONFIG_PLUGIN } from "../../../../../config.js";
|
|
5
5
|
import { core_users } from "../../../../../database/users.js";
|
|
6
6
|
export const listUsersAdminRoute = buildRoute({
|
|
7
|
-
|
|
7
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
8
8
|
route: {
|
|
9
9
|
method: "get",
|
|
10
10
|
description: "Get list of all users",
|
|
@@ -7,7 +7,7 @@ export declare const usersAdminRoute: {
|
|
|
7
7
|
first?: string | undefined;
|
|
8
8
|
last?: string | undefined;
|
|
9
9
|
order?: "asc" | "desc" | undefined;
|
|
10
|
-
orderBy?: "
|
|
10
|
+
orderBy?: "id" | "email" | "name" | "createdAt" | undefined;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
out: {
|
|
@@ -16,7 +16,7 @@ export declare const usersAdminRoute: {
|
|
|
16
16
|
first?: string | undefined;
|
|
17
17
|
last?: string | undefined;
|
|
18
18
|
order?: "asc" | "desc" | undefined;
|
|
19
|
-
orderBy?: "
|
|
19
|
+
orderBy?: "id" | "email" | "name" | "createdAt" | undefined;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
}>) => Promise<Response & import("hono").TypedResponse<{
|
|
@@ -57,8 +57,8 @@ export declare const usersAdminRoute: {
|
|
|
57
57
|
desc: "desc";
|
|
58
58
|
}>>;
|
|
59
59
|
orderBy: z.ZodOptional<z.ZodEnum<{
|
|
60
|
-
email: "email";
|
|
61
60
|
id: "id";
|
|
61
|
+
email: "email";
|
|
62
62
|
name: "name";
|
|
63
63
|
createdAt: "createdAt";
|
|
64
64
|
}>>;
|
|
@@ -4,7 +4,7 @@ import { withPagination, zodPaginationPageInfo, zodPaginationQuery } from "../..
|
|
|
4
4
|
import { CONFIG_PLUGIN } from "../../../../../config.js";
|
|
5
5
|
import { core_users } from "../../../../../database/users.js";
|
|
6
6
|
export const usersAdminRoute = buildRoute({
|
|
7
|
-
|
|
7
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
8
8
|
route: {
|
|
9
9
|
method: "get",
|
|
10
10
|
description: "Get list of all users (Admin only)",
|
|
@@ -2,7 +2,7 @@ import { buildModule } from "../../../lib/module.js";
|
|
|
2
2
|
import { CONFIG_PLUGIN } from "../../../../config.js";
|
|
3
3
|
import { listUsersAdminRoute } from "./routes/list.route.js";
|
|
4
4
|
export const usersAdminModule = buildModule({
|
|
5
|
-
|
|
5
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
6
6
|
name: "users",
|
|
7
7
|
routes: [
|
|
8
8
|
listUsersAdminRoute
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean.cron.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/cron/cron/clean.cron.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,0CA0BpB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { lt } from "drizzle-orm";
|
|
2
|
+
import { buildCron } from "../../../lib/cron.js";
|
|
3
|
+
import { core_admin_sessions } from "../../../../database/admins.js";
|
|
4
|
+
import { core_sessions } from "../../../../database/sessions.js";
|
|
5
|
+
import { core_users_forgot_password } from "../../../../database/users.js";
|
|
6
|
+
export const cleanCron = buildCron({
|
|
7
|
+
name: "clean",
|
|
8
|
+
description: "Clean up expired sessions and tokens",
|
|
9
|
+
// Run every 1 hour
|
|
10
|
+
schedule: "0 * * * *",
|
|
11
|
+
handler: async (c)=>{
|
|
12
|
+
await c.get("db").transaction(async (tx)=>{
|
|
13
|
+
// Delete expired sessions
|
|
14
|
+
await tx.delete(core_sessions).where(lt(core_sessions.expiresAt, new Date()));
|
|
15
|
+
await tx.delete(core_admin_sessions).where(lt(core_admin_sessions.expiresAt, new Date()));
|
|
16
|
+
// Delete expired forgot password tokens
|
|
17
|
+
await tx.delete(core_users_forgot_password).where(lt(core_users_forgot_password.expiresAt, new Date()));
|
|
18
|
+
// // Delete expired email confirmation tokens
|
|
19
|
+
// await tx
|
|
20
|
+
// .delete(core_users_confirm_emails)
|
|
21
|
+
// .where(lt(core_users_confirm_emails.expiresAt, new Date()));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const cronModule: import("../../../api/lib/module").BuildModuleReturn<"@vitnode/core", "cron", [{
|
|
2
|
+
handler: (c: import("hono").Context<import("../../middlewares/global.middleware").EnvVitNode, "/", {}>) => Promise<(Response & import("hono").TypedResponse<`Cron jobs processed. Executed ${number} jobs.`, 200, "text">) | (Response & import("hono").TypedResponse<"Error processing cron jobs", 500, "text">)>;
|
|
3
|
+
pluginId: "@vitnode/core";
|
|
4
|
+
route: {
|
|
5
|
+
method: "post";
|
|
6
|
+
description: string;
|
|
7
|
+
path: "/";
|
|
8
|
+
middleware: ((c: import("hono").Context, next: import("hono").Next) => Promise<void>)[];
|
|
9
|
+
responses: {
|
|
10
|
+
200: {
|
|
11
|
+
content: {
|
|
12
|
+
"text/plain": {
|
|
13
|
+
schema: import("zod").ZodString;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
403: {
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
} & {
|
|
23
|
+
getRoutingPath: () => "/";
|
|
24
|
+
};
|
|
25
|
+
}], import("../../../api/lib/module").BaseBuildModuleReturn<"@vitnode/core", string, import("../../lib/route").Route<"@vitnode/core", import("@hono/zod-openapi").RouteConfig, import("@hono/zod-openapi").RouteHandler<import("@hono/zod-openapi").RouteConfig>>[]>[]>;
|
|
26
|
+
//# sourceMappingURL=cron.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron.module.d.ts","sourceRoot":"","sources":["../../../../../src/api/modules/cron/cron.module.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;gQAKrB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { buildModule } from "../../lib/module.js";
|
|
2
|
+
import { CONFIG_PLUGIN } from "../../../config.js";
|
|
3
|
+
import { cleanCron } from "./cron/clean.cron.js";
|
|
4
|
+
import { runCronRoute } from "./routes/cron.route.js";
|
|
5
|
+
export const cronModule = buildModule({
|
|
6
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
7
|
+
name: "cron",
|
|
8
|
+
routes: [
|
|
9
|
+
runCronRoute
|
|
10
|
+
],
|
|
11
|
+
cronJobs: [
|
|
12
|
+
cleanCron
|
|
13
|
+
]
|
|
14
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { CronJobConfig } from "../../../../api/lib/cron";
|
|
3
|
+
interface CronJobFromDb {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string | null;
|
|
7
|
+
lastRun: Date | null;
|
|
8
|
+
nextRun: Date | null;
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
pluginId: string;
|
|
11
|
+
module: string;
|
|
12
|
+
schedule: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function cleanupOutdatedCronJobs(db: PostgresJsDatabase<Record<string, never>>, cronFromDb: CronJobFromDb[], currentCronJobs: CronJobConfig[]): Promise<void>;
|
|
15
|
+
export declare function processCronJobs(cronJobs: CronJobConfig[], cronFromDb: CronJobFromDb[]): {
|
|
16
|
+
newJobs: CronJobConfig[];
|
|
17
|
+
jobsToExecute: CronJobConfig[];
|
|
18
|
+
jobsToUpdate: {
|
|
19
|
+
job: CronJobConfig;
|
|
20
|
+
existingJob: CronJobFromDb;
|
|
21
|
+
changes: {
|
|
22
|
+
description?: boolean;
|
|
23
|
+
schedule?: boolean;
|
|
24
|
+
};
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
export declare function updateCronJobs(db: PostgresJsDatabase<Record<string, never>>, jobsToUpdate: {
|
|
28
|
+
job: CronJobConfig;
|
|
29
|
+
existingJob: CronJobFromDb;
|
|
30
|
+
changes: {
|
|
31
|
+
description?: boolean;
|
|
32
|
+
schedule?: boolean;
|
|
33
|
+
};
|
|
34
|
+
}[]): Promise<void>;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=process-cron-jobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-cron-jobs.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/cron/helpers/process-cron-jobs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AA4BD,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAC7C,UAAU,EAAE,aAAa,EAAE,EAC3B,eAAe,EAAE,aAAa,EAAE,iBAoBjC;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,aAAa,EAAE,EACzB,UAAU,EAAE,aAAa,EAAE;;;;aAKpB,aAAa;qBACL,aAAa;iBACjB;YAAE,WAAW,CAAC,EAAE,OAAO,CAAC;YAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;;EA6BzD;AAED,wBAAsB,cAAc,CAClC,EAAE,EAAE,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAC7C,YAAY,EAAE;IACZ,GAAG,EAAE,aAAa,CAAC;IACnB,WAAW,EAAE,aAAa,CAAC;IAC3B,OAAO,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACxD,EAAE,iBAyBJ"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { eq, inArray } from "drizzle-orm";
|
|
2
|
+
import { validate } from "node-cron";
|
|
3
|
+
import { core_cron } from "../../../../database/cron.js";
|
|
4
|
+
import { shouldCronJobRun } from "../../../../lib/api/should-cron-job-run.js";
|
|
5
|
+
function findExistingJob(job, cronFromDb) {
|
|
6
|
+
return cronFromDb.find((dbJob)=>dbJob.name === job.name && dbJob.pluginId === job.pluginId && dbJob.module === job.module);
|
|
7
|
+
}
|
|
8
|
+
function getJobChanges(job, existingJob) {
|
|
9
|
+
const changes = {};
|
|
10
|
+
if (existingJob.description !== job.description) {
|
|
11
|
+
changes.description = true;
|
|
12
|
+
}
|
|
13
|
+
if (existingJob.schedule !== job.schedule) {
|
|
14
|
+
changes.schedule = true;
|
|
15
|
+
}
|
|
16
|
+
return changes;
|
|
17
|
+
}
|
|
18
|
+
export async function cleanupOutdatedCronJobs(db, cronFromDb, currentCronJobs) {
|
|
19
|
+
if (cronFromDb.length === 0) return;
|
|
20
|
+
const currentCronIdentifiers = currentCronJobs.map((job)=>`${job.pluginId}:${job.module}:${job.name}`);
|
|
21
|
+
const cronJobsToDelete = cronFromDb.filter((dbCron)=>!currentCronIdentifiers.includes(`${dbCron.pluginId}:${dbCron.module}:${dbCron.name}`)).map((dbCron)=>dbCron.id);
|
|
22
|
+
if (cronJobsToDelete.length > 0) {
|
|
23
|
+
await db.delete(core_cron).where(inArray(core_cron.id, cronJobsToDelete));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function processCronJobs(cronJobs, cronFromDb) {
|
|
27
|
+
const newJobs = [];
|
|
28
|
+
const jobsToExecute = [];
|
|
29
|
+
const jobsToUpdate = [];
|
|
30
|
+
for (const job of cronJobs){
|
|
31
|
+
if (!validate(job.schedule)) {
|
|
32
|
+
// biome-ignore lint/suspicious/noConsole: needed for cron job monitoring
|
|
33
|
+
console.warn(`\x1b[34m[VitNode]\x1b[0m \x1b[33mInvalid cron schedule for job "${job.pluginId}:${job.module}:${job.name}"\x1b[0m: ${job.schedule}`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const existingJob = findExistingJob(job, cronFromDb);
|
|
37
|
+
if (existingJob) {
|
|
38
|
+
const changes = getJobChanges(job, existingJob);
|
|
39
|
+
if (Object.keys(changes).length > 0) {
|
|
40
|
+
jobsToUpdate.push({
|
|
41
|
+
job,
|
|
42
|
+
existingJob,
|
|
43
|
+
changes
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
newJobs.push(job);
|
|
48
|
+
}
|
|
49
|
+
if (shouldCronJobRun(job.schedule, existingJob?.lastRun || null)) {
|
|
50
|
+
jobsToExecute.push(job);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
newJobs,
|
|
55
|
+
jobsToExecute,
|
|
56
|
+
jobsToUpdate
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export async function updateCronJobs(db, jobsToUpdate) {
|
|
60
|
+
if (jobsToUpdate.length === 0) return;
|
|
61
|
+
const updatePromises = jobsToUpdate.map(({ job, existingJob, changes })=>{
|
|
62
|
+
const updateData = {};
|
|
63
|
+
if (changes.description) {
|
|
64
|
+
updateData.description = job.description || null;
|
|
65
|
+
}
|
|
66
|
+
if (changes.schedule) {
|
|
67
|
+
updateData.schedule = job.schedule;
|
|
68
|
+
}
|
|
69
|
+
return db.update(core_cron).set(updateData).where(eq(core_cron.id, existingJob.id));
|
|
70
|
+
});
|
|
71
|
+
await Promise.all(updatePromises);
|
|
72
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const runCronRoute: {
|
|
3
|
+
handler: (c: import("hono").Context<import("../../../middlewares/global.middleware").EnvVitNode, "/", {}>) => Promise<(Response & import("hono").TypedResponse<`Cron jobs processed. Executed ${number} jobs.`, 200, "text">) | (Response & import("hono").TypedResponse<"Error processing cron jobs", 500, "text">)>;
|
|
4
|
+
pluginId: "@vitnode/core";
|
|
5
|
+
route: {
|
|
6
|
+
method: "post";
|
|
7
|
+
description: string;
|
|
8
|
+
path: "/";
|
|
9
|
+
middleware: ((c: import("hono").Context, next: import("hono").Next) => Promise<void>)[];
|
|
10
|
+
responses: {
|
|
11
|
+
200: {
|
|
12
|
+
content: {
|
|
13
|
+
"text/plain": {
|
|
14
|
+
schema: z.ZodString;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
403: {
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
} & {
|
|
24
|
+
getRoutingPath: () => "/";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=cron.route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/cron/routes/cron.route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;CA4GvB,CAAC"}
|