@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,22 @@
|
|
|
1
|
+
import { pgTable } from "drizzle-orm/pg-core";
|
|
2
|
+
export const core_cron = pgTable("core_cron", (t)=>({
|
|
3
|
+
id: t.serial().primaryKey(),
|
|
4
|
+
name: t.varchar({
|
|
5
|
+
length: 255
|
|
6
|
+
}).notNull(),
|
|
7
|
+
description: t.varchar({
|
|
8
|
+
length: 255
|
|
9
|
+
}),
|
|
10
|
+
lastRun: t.timestamp(),
|
|
11
|
+
createdAt: t.timestamp().notNull().defaultNow(),
|
|
12
|
+
pluginId: t.varchar({
|
|
13
|
+
length: 100
|
|
14
|
+
}).notNull(),
|
|
15
|
+
module: t.varchar({
|
|
16
|
+
length: 100
|
|
17
|
+
}).notNull(),
|
|
18
|
+
nextRun: t.timestamp(),
|
|
19
|
+
schedule: t.varchar({
|
|
20
|
+
length: 100
|
|
21
|
+
}).notNull()
|
|
22
|
+
})).enableRLS();
|
|
@@ -420,8 +420,8 @@ export declare const core_users_confirm_emails: Omit<import("drizzle-orm/pg-core
|
|
|
420
420
|
identity: undefined;
|
|
421
421
|
generated: undefined;
|
|
422
422
|
}, {}, {}>;
|
|
423
|
-
|
|
424
|
-
name: "
|
|
423
|
+
expiresAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
424
|
+
name: "expiresAt";
|
|
425
425
|
tableName: "core_users_confirm_emails";
|
|
426
426
|
dataType: "date";
|
|
427
427
|
columnType: "PgTimestamp";
|
|
@@ -104,7 +104,7 @@ export const core_users_confirm_emails = pgTable("core_users_confirm_emails", (t
|
|
|
104
104
|
length: 100
|
|
105
105
|
}).notNull().unique(),
|
|
106
106
|
createdAt: t.timestamp().notNull().defaultNow(),
|
|
107
|
-
|
|
107
|
+
expiresAt: t.timestamp().notNull(),
|
|
108
108
|
ipAddress: t.varchar({
|
|
109
109
|
length: 40
|
|
110
110
|
}).notNull()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-next-cron-run-date.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/get-next-cron-run-date.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,SAAS,IAAI,GAAG,IAAI,KACnB,IAAI,GAAG,IAgBT,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import cronParser from "cron-parser";
|
|
2
|
+
export const getNextCronRunDate = (schedule, lastRun)=>{
|
|
3
|
+
try {
|
|
4
|
+
const options = {
|
|
5
|
+
currentDate: lastRun || new Date(0)
|
|
6
|
+
};
|
|
7
|
+
const interval = cronParser.parse(schedule, options);
|
|
8
|
+
return interval.next().toDate();
|
|
9
|
+
} catch (err) {
|
|
10
|
+
// biome-ignore lint/suspicious/noConsole: needed for cron job monitoring
|
|
11
|
+
console.error(`\x1b[34m[VitNode]\x1b[0m \x1b[38;5;208mError parsing schedule for nextRun\x1b[0m: ${schedule}`, err);
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-next-cron-run-date.test.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/get-next-cron-run-date.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { getNextCronRunDate } from "./get-next-cron-run-date.js";
|
|
3
|
+
describe("getNextCronRunDate", ()=>{
|
|
4
|
+
it("should return the next run date for a valid cron schedule with lastRun null", ()=>{
|
|
5
|
+
const schedule = "0 0 * * *"; // Daily at midnight
|
|
6
|
+
const lastRun = null;
|
|
7
|
+
const result = getNextCronRunDate(schedule, lastRun);
|
|
8
|
+
expect(result).toBeInstanceOf(Date);
|
|
9
|
+
if (result) {
|
|
10
|
+
expect(result.getHours()).toBe(0);
|
|
11
|
+
expect(result.getMinutes()).toBe(0);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
it("should return the next run date for a valid cron schedule with lastRun provided", ()=>{
|
|
15
|
+
const schedule = "0 0 * * *"; // Daily at midnight
|
|
16
|
+
const lastRun = new Date("2023-01-01T12:00:00Z");
|
|
17
|
+
const result = getNextCronRunDate(schedule, lastRun);
|
|
18
|
+
expect(result).toBeInstanceOf(Date);
|
|
19
|
+
if (result) {
|
|
20
|
+
expect(result.getHours()).toBe(0);
|
|
21
|
+
expect(result.getMinutes()).toBe(0);
|
|
22
|
+
expect(result.getTime()).toBeGreaterThan(lastRun.getTime());
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
it("should return null for an invalid cron schedule", ()=>{
|
|
26
|
+
const schedule = "invalid cron";
|
|
27
|
+
const lastRun = null;
|
|
28
|
+
const consoleSpy = vi.spyOn(console, "error").mockImplementation(()=>{});
|
|
29
|
+
const result = getNextCronRunDate(schedule, lastRun);
|
|
30
|
+
expect(result).toBeNull();
|
|
31
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("[VitNode]"), expect.any(Error));
|
|
32
|
+
consoleSpy.mockRestore();
|
|
33
|
+
});
|
|
34
|
+
it("should handle cron schedules with specific times", ()=>{
|
|
35
|
+
const schedule = "30 14 * * 1"; // Every Monday at 14:30
|
|
36
|
+
const lastRun = new Date("2023-01-01T10:00:00Z"); // Sunday
|
|
37
|
+
const result = getNextCronRunDate(schedule, lastRun);
|
|
38
|
+
expect(result).toBeInstanceOf(Date);
|
|
39
|
+
if (result) {
|
|
40
|
+
expect(result.getDay()).toBe(1); // Monday
|
|
41
|
+
expect(result.getHours()).toBe(14);
|
|
42
|
+
expect(result.getMinutes()).toBe(30);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
it("should return null when cron parsing throws an error", ()=>{
|
|
46
|
+
// This test assumes cron-parser can throw for certain invalid inputs
|
|
47
|
+
const schedule = "99 99 99 99 99"; // Invalid cron with out-of-range values
|
|
48
|
+
const lastRun = null;
|
|
49
|
+
const consoleSpy = vi.spyOn(console, "error").mockImplementation(()=>{});
|
|
50
|
+
const result = getNextCronRunDate(schedule, lastRun);
|
|
51
|
+
expect(result).toBeNull();
|
|
52
|
+
expect(consoleSpy).toHaveBeenCalled();
|
|
53
|
+
consoleSpy.mockRestore();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-cron-job-run.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/should-cron-job-run.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,SAAS,IAAI,GAAG,IAAI,KACnB,OAmBF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import cronParser from "cron-parser";
|
|
2
|
+
export const shouldCronJobRun = (schedule, lastRun)=>{
|
|
3
|
+
try {
|
|
4
|
+
const now = new Date();
|
|
5
|
+
const options = {
|
|
6
|
+
currentDate: lastRun || new Date(0)
|
|
7
|
+
};
|
|
8
|
+
const interval = cronParser.parse(schedule, options);
|
|
9
|
+
const nextScheduledRun = interval.next().toDate();
|
|
10
|
+
return nextScheduledRun <= now;
|
|
11
|
+
} catch (err) {
|
|
12
|
+
// biome-ignore lint/suspicious/noConsole: needed for cron job monitoring
|
|
13
|
+
console.error(`\x1b[34m[VitNode]\x1b[0m \x1b[38;5;208mError parsing schedule\x1b[0m: ${schedule}`, err);
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-cron-job-run.test.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/should-cron-job-run.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { shouldCronJobRun } from "./should-cron-job-run.js";
|
|
3
|
+
describe("shouldCronJobRun", ()=>{
|
|
4
|
+
beforeEach(()=>{
|
|
5
|
+
// Reset any mocked console methods
|
|
6
|
+
vi.clearAllMocks();
|
|
7
|
+
});
|
|
8
|
+
describe("valid cron schedules", ()=>{
|
|
9
|
+
it("should return true when job has never run (lastRun is null)", ()=>{
|
|
10
|
+
const schedule = "0 * * * *"; // Every hour
|
|
11
|
+
const lastRun = null;
|
|
12
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
13
|
+
expect(result).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
it("should return true when enough time has passed since last run", ()=>{
|
|
16
|
+
const schedule = "0 * * * *"; // Every hour
|
|
17
|
+
const lastRun = new Date("2024-01-01T10:00:00Z");
|
|
18
|
+
// Mock current time to be 2 hours later
|
|
19
|
+
vi.useFakeTimers();
|
|
20
|
+
vi.setSystemTime(new Date("2024-01-01T12:00:00Z"));
|
|
21
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
22
|
+
expect(result).toBe(true);
|
|
23
|
+
vi.useRealTimers();
|
|
24
|
+
});
|
|
25
|
+
it("should return false when not enough time has passed since last run", ()=>{
|
|
26
|
+
const schedule = "0 * * * *"; // Every hour
|
|
27
|
+
const lastRun = new Date("2024-01-01T11:30:00Z");
|
|
28
|
+
// Mock current time to be 15 minutes later (not enough for hourly job)
|
|
29
|
+
vi.useFakeTimers();
|
|
30
|
+
vi.setSystemTime(new Date("2024-01-01T11:45:00Z"));
|
|
31
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
32
|
+
expect(result).toBe(false);
|
|
33
|
+
vi.useRealTimers();
|
|
34
|
+
});
|
|
35
|
+
it("should handle daily job correctly", ()=>{
|
|
36
|
+
const schedule = "0 9 * * *"; // Every day at 9 AM
|
|
37
|
+
const lastRun = new Date("2024-01-01T09:00:00Z");
|
|
38
|
+
// Mock current time to be next day at 10 AM
|
|
39
|
+
vi.useFakeTimers();
|
|
40
|
+
vi.setSystemTime(new Date("2024-01-02T10:00:00Z"));
|
|
41
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
42
|
+
expect(result).toBe(true);
|
|
43
|
+
vi.useRealTimers();
|
|
44
|
+
});
|
|
45
|
+
it("should handle weekly job correctly", ()=>{
|
|
46
|
+
const schedule = "0 9 * * 1"; // Every Monday at 9 AM
|
|
47
|
+
const lastRun = new Date("2024-01-01T09:00:00Z"); // Monday
|
|
48
|
+
// Mock current time to be next Monday
|
|
49
|
+
vi.useFakeTimers();
|
|
50
|
+
vi.setSystemTime(new Date("2024-01-08T10:00:00Z")); // Next Monday
|
|
51
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
52
|
+
expect(result).toBe(true);
|
|
53
|
+
vi.useRealTimers();
|
|
54
|
+
});
|
|
55
|
+
it("should handle monthly job correctly", ()=>{
|
|
56
|
+
const schedule = "0 9 1 * *"; // First day of every month at 9 AM
|
|
57
|
+
const lastRun = new Date("2024-01-01T09:00:00Z");
|
|
58
|
+
// Mock current time to be next month
|
|
59
|
+
vi.useFakeTimers();
|
|
60
|
+
vi.setSystemTime(new Date("2024-02-01T10:00:00Z"));
|
|
61
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
62
|
+
expect(result).toBe(true);
|
|
63
|
+
vi.useRealTimers();
|
|
64
|
+
});
|
|
65
|
+
it("should handle every minute job correctly", ()=>{
|
|
66
|
+
const schedule = "* * * * *"; // Every minute
|
|
67
|
+
const lastRun = new Date("2024-01-01T10:00:00Z");
|
|
68
|
+
// Mock current time to be 1 minute later
|
|
69
|
+
vi.useFakeTimers();
|
|
70
|
+
vi.setSystemTime(new Date("2024-01-01T10:01:00Z"));
|
|
71
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
72
|
+
expect(result).toBe(true);
|
|
73
|
+
vi.useRealTimers();
|
|
74
|
+
});
|
|
75
|
+
it("should handle every 5 minutes job correctly", ()=>{
|
|
76
|
+
const schedule = "*/5 * * * *"; // Every 5 minutes
|
|
77
|
+
const lastRun = new Date("2024-01-01T10:00:00Z");
|
|
78
|
+
// Mock current time to be 3 minutes later (not enough)
|
|
79
|
+
vi.useFakeTimers();
|
|
80
|
+
vi.setSystemTime(new Date("2024-01-01T10:03:00Z"));
|
|
81
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
82
|
+
expect(result).toBe(false);
|
|
83
|
+
// Mock current time to be 5 minutes later (enough)
|
|
84
|
+
vi.setSystemTime(new Date("2024-01-01T10:05:00Z"));
|
|
85
|
+
const result2 = shouldCronJobRun(schedule, lastRun);
|
|
86
|
+
expect(result2).toBe(true);
|
|
87
|
+
vi.useRealTimers();
|
|
88
|
+
});
|
|
89
|
+
it("should handle complex cron expressions", ()=>{
|
|
90
|
+
const schedule = "0 9-17 * * 1-5"; // 9 AM to 5 PM on weekdays
|
|
91
|
+
const lastRun = new Date("2024-01-01T09:00:00Z"); // Monday 9 AM
|
|
92
|
+
// Mock current time to be same day at 10 AM
|
|
93
|
+
vi.useFakeTimers();
|
|
94
|
+
vi.setSystemTime(new Date("2024-01-01T10:00:00Z"));
|
|
95
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
96
|
+
expect(result).toBe(true);
|
|
97
|
+
vi.useRealTimers();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
describe("invalid cron schedules", ()=>{
|
|
101
|
+
it("should return false and log error for invalid cron schedule", ()=>{
|
|
102
|
+
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(()=>{});
|
|
103
|
+
const schedule = "invalid cron"; // Invalid schedule
|
|
104
|
+
const lastRun = null;
|
|
105
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
106
|
+
expect(result).toBe(false);
|
|
107
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining("[VitNode]") && expect.stringContaining("Error parsing schedule") && expect.stringContaining("invalid cron"), expect.any(Error));
|
|
108
|
+
consoleErrorSpy.mockRestore();
|
|
109
|
+
});
|
|
110
|
+
it("should return false for malformed cron expression", ()=>{
|
|
111
|
+
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(()=>{});
|
|
112
|
+
const schedule = "60 * * * *"; // Invalid minute (should be 0-59)
|
|
113
|
+
const lastRun = null;
|
|
114
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
115
|
+
expect(result).toBe(false);
|
|
116
|
+
expect(consoleErrorSpy).toHaveBeenCalled();
|
|
117
|
+
consoleErrorSpy.mockRestore();
|
|
118
|
+
});
|
|
119
|
+
it("should return true for empty cron schedule (parsed as valid)", ()=>{
|
|
120
|
+
// Note: cron-parser actually parses empty string as a valid cron expression
|
|
121
|
+
const schedule = ""; // Empty schedule
|
|
122
|
+
const lastRun = null;
|
|
123
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
124
|
+
expect(result).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
describe("edge cases", ()=>{
|
|
128
|
+
it("should handle lastRun being exactly at the next scheduled time", ()=>{
|
|
129
|
+
const schedule = "0 * * * *"; // Every hour
|
|
130
|
+
const lastRun = new Date("2024-01-01T10:00:00Z");
|
|
131
|
+
// Mock current time to be exactly at the next scheduled time
|
|
132
|
+
vi.useFakeTimers();
|
|
133
|
+
vi.setSystemTime(new Date("2024-01-01T11:00:00Z"));
|
|
134
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
135
|
+
expect(result).toBe(true);
|
|
136
|
+
vi.useRealTimers();
|
|
137
|
+
});
|
|
138
|
+
it("should handle lastRun being in the future (clock skew)", ()=>{
|
|
139
|
+
const schedule = "0 * * * *"; // Every hour
|
|
140
|
+
const lastRun = new Date("2024-01-01T12:00:00Z"); // Future time
|
|
141
|
+
// Mock current time to be earlier
|
|
142
|
+
vi.useFakeTimers();
|
|
143
|
+
vi.setSystemTime(new Date("2024-01-01T11:00:00Z"));
|
|
144
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
145
|
+
expect(result).toBe(false);
|
|
146
|
+
vi.useRealTimers();
|
|
147
|
+
});
|
|
148
|
+
it("should handle lastRun being epoch (new Date(0))", ()=>{
|
|
149
|
+
const schedule = "0 * * * *"; // Every hour
|
|
150
|
+
const lastRun = new Date(0); // Epoch time
|
|
151
|
+
// Mock current time to be much later
|
|
152
|
+
vi.useFakeTimers();
|
|
153
|
+
vi.setSystemTime(new Date("2024-01-01T10:00:00Z"));
|
|
154
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
155
|
+
expect(result).toBe(true);
|
|
156
|
+
vi.useRealTimers();
|
|
157
|
+
});
|
|
158
|
+
it("should handle yearly cron job", ()=>{
|
|
159
|
+
const schedule = "0 0 1 1 *"; // January 1st at midnight
|
|
160
|
+
const lastRun = new Date("2023-01-01T00:00:00Z");
|
|
161
|
+
// Mock current time to be next year
|
|
162
|
+
vi.useFakeTimers();
|
|
163
|
+
vi.setSystemTime(new Date("2024-01-01T01:00:00Z"));
|
|
164
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
165
|
+
expect(result).toBe(true);
|
|
166
|
+
vi.useRealTimers();
|
|
167
|
+
});
|
|
168
|
+
it("should handle specific day of month with month", ()=>{
|
|
169
|
+
const schedule = "0 12 15 6 *"; // June 15th at noon
|
|
170
|
+
const lastRun = new Date("2023-06-15T12:00:00Z");
|
|
171
|
+
// Mock current time to be next year same date
|
|
172
|
+
vi.useFakeTimers();
|
|
173
|
+
vi.setSystemTime(new Date("2024-06-15T13:00:00Z"));
|
|
174
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
175
|
+
expect(result).toBe(true);
|
|
176
|
+
vi.useRealTimers();
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
describe("timezone handling", ()=>{
|
|
180
|
+
it("should work with different timezone dates", ()=>{
|
|
181
|
+
const schedule = "0 9 * * *"; // Every day at 9 AM
|
|
182
|
+
const lastRun = new Date("2024-01-01T09:00:00+05:00"); // 9 AM in +5 timezone
|
|
183
|
+
// Mock current time to be next day in UTC
|
|
184
|
+
vi.useFakeTimers();
|
|
185
|
+
vi.setSystemTime(new Date("2024-01-02T04:00:00Z")); // 9 AM in +5 timezone
|
|
186
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
187
|
+
expect(result).toBe(true);
|
|
188
|
+
vi.useRealTimers();
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
describe("performance and boundary conditions", ()=>{
|
|
192
|
+
it("should handle very old lastRun dates", ()=>{
|
|
193
|
+
const schedule = "0 * * * *"; // Every hour
|
|
194
|
+
const lastRun = new Date("1970-01-01T00:00:00Z"); // Very old date
|
|
195
|
+
// Current time
|
|
196
|
+
vi.useFakeTimers();
|
|
197
|
+
vi.setSystemTime(new Date("2024-01-01T10:00:00Z"));
|
|
198
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
199
|
+
expect(result).toBe(true);
|
|
200
|
+
vi.useRealTimers();
|
|
201
|
+
});
|
|
202
|
+
it("should handle leap year considerations", ()=>{
|
|
203
|
+
const schedule = "0 0 29 2 *"; // February 29th (leap day)
|
|
204
|
+
const lastRun = new Date("2020-02-29T00:00:00Z"); // Last leap year
|
|
205
|
+
// Mock current time to be next leap year
|
|
206
|
+
vi.useFakeTimers();
|
|
207
|
+
vi.setSystemTime(new Date("2024-02-29T01:00:00Z"));
|
|
208
|
+
const result = shouldCronJobRun(schedule, lastRun);
|
|
209
|
+
expect(result).toBe(true);
|
|
210
|
+
vi.useRealTimers();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
});
|
package/dist/src/lib/config.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,MAAM;;;;;CAIlB,CAAC"}
|
package/dist/src/lib/config.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
const ENVS = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
apiUrl: process.env.NEXT_PUBLIC_API_URL,
|
|
3
|
+
webUrl: process.env.NEXT_PUBLIC_WEB_URL,
|
|
4
|
+
cronConfig: process.env.CRON_SECRET || "default-cron-secret-change-in-production"
|
|
4
5
|
};
|
|
5
6
|
const urls = {
|
|
6
|
-
api: new URL(ENVS.
|
|
7
|
-
web: new URL(ENVS.
|
|
7
|
+
api: new URL(ENVS.apiUrl ?? "http://localhost:3000"),
|
|
8
|
+
web: new URL(ENVS.webUrl ?? "http://localhost:3000")
|
|
8
9
|
};
|
|
9
10
|
export const CONFIG = {
|
|
10
11
|
node_development: process.env.NODE_ENV === "development",
|
|
11
|
-
...urls
|
|
12
|
+
...urls,
|
|
13
|
+
cronJobSecret: ENVS.cronConfig
|
|
12
14
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ctrl-or-command-character.d.ts","sourceRoot":"","sources":["../../../src/lib/ctrl-or-command-character.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,cAUlC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const CtrlOrCommandCharacter = ()=>{
|
|
3
|
+
const [key, setKey] = React.useState("⌘");
|
|
4
|
+
React.useEffect(()=>{
|
|
5
|
+
const isWindows = window.navigator.userAgent.includes("Windows");
|
|
6
|
+
if (isWindows) setKey("Ctrl");
|
|
7
|
+
}, []);
|
|
8
|
+
return key;
|
|
9
|
+
};
|
|
@@ -15,7 +15,7 @@ declare const Link: import("react").ForwardRefExoticComponent<Omit<{
|
|
|
15
15
|
scroll?: boolean | undefined;
|
|
16
16
|
shallow?: boolean | undefined;
|
|
17
17
|
passHref?: boolean | undefined;
|
|
18
|
-
prefetch?: boolean | null | undefined;
|
|
18
|
+
prefetch?: boolean | "auto" | null | "unstable_forceStale" | undefined;
|
|
19
19
|
legacyBehavior?: boolean | undefined;
|
|
20
20
|
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
21
21
|
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/lib/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKxD,QAAA,MACE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAEJ,WAAW,gBACX,SAAS;;;;;
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/lib/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKxD,QAAA,MACE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAEJ,WAAW,gBACX,SAAS;;;;;cAmBimyB,CAAC;;;;;;cAAuxC,CAAC;;;;;;cAAwxC,CAAC;;;;;GAlB5p3B,WAAW;;;;;;;YACS,CAAC;AAEvB,QAAA,MAAM,QAAQ,GACZ,MACI,MAAM,GACN;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,EACL,OAAO,YAAY,kBAKpB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { ThemeSwitcher } from "../../../components/switchers/themes/theme-switch
|
|
|
5
5
|
import { SidebarInset, SidebarProvider, SidebarTrigger } from "../../../components/ui/sidebar.js";
|
|
6
6
|
import { getSessionAdminApi } from "../../../lib/api/get-session-admin-api.js";
|
|
7
7
|
import { I18nProvider } from "../../../components/i18n-provider.js";
|
|
8
|
-
import { LanguageSwitcher } from "../../../components/switchers/langs/language-
|
|
8
|
+
import { LanguageSwitcher } from "../../../components/switchers/langs/language-switcher.js";
|
|
9
9
|
import { SidebarAdmin } from "./sidebar/sidebar.js";
|
|
10
10
|
import { UserBarAdmin } from "./user-bar/user-bar.js";
|
|
11
11
|
export const AdminLayout = async ({ children, vitNodeConfig })=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/layouts/sidebar/nav/item.tsx"],"names":[],"mappings":"AAqBA,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,YAAY,GAAI,+CAM1B,iBAAiB,GAAG;IACrB,KAAK,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,EAAE,CAAC;CAC3C,
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/layouts/sidebar/nav/item.tsx"],"names":[],"mappings":"AAqBA,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,YAAY,GAAI,+CAM1B,iBAAiB,GAAG;IACrB,KAAK,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,EAAE,CAAC;CAC3C,4CAsGA,CAAC"}
|
|
@@ -35,7 +35,6 @@ export const ItemNavAdmin = ({ href, title, icon, items = [], isOpenInNewTab })=
|
|
|
35
35
|
isActive: isActive,
|
|
36
36
|
tooltip: title,
|
|
37
37
|
children: /*#__PURE__*/ _jsx(Link, {
|
|
38
|
-
className: cn("relative", isActive && "before:bg-primary before:absolute before:bottom-1 before:left-0 before:top-1 before:h-auto before:w-1 before:rounded-r-sm"),
|
|
39
38
|
href: href,
|
|
40
39
|
onClick: ()=>{
|
|
41
40
|
if (isMobile) {
|
|
@@ -58,7 +57,6 @@ export const ItemNavAdmin = ({ href, title, icon, items = [], isOpenInNewTab })=
|
|
|
58
57
|
/*#__PURE__*/ _jsx(CollapsibleTrigger, {
|
|
59
58
|
asChild: true,
|
|
60
59
|
children: /*#__PURE__*/ _jsxs(SidebarMenuButton, {
|
|
61
|
-
className: cn("relative", (isActive || hasActiveChild) && "before:bg-primary before:absolute before:bottom-1 before:left-0 before:top-1 before:h-auto before:w-1 before:rounded-r-sm"),
|
|
62
60
|
isActive: isActive || hasActiveChild,
|
|
63
61
|
tooltip: title,
|
|
64
62
|
children: [
|
|
@@ -79,7 +77,6 @@ export const ItemNavAdmin = ({ href, title, icon, items = [], isOpenInNewTab })=
|
|
|
79
77
|
asChild: true,
|
|
80
78
|
isActive: isChildActive,
|
|
81
79
|
children: /*#__PURE__*/ _jsx(Link, {
|
|
82
|
-
className: cn("relative", isChildActive && "before:bg-primary before:absolute before:bottom-1 before:left-0 before:top-1 before:h-auto before:w-1 before:rounded-r-sm"),
|
|
83
80
|
href: item.href,
|
|
84
81
|
onClick: ()=>{
|
|
85
82
|
if (isMobile) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nav.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/layouts/sidebar/nav/nav.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,YAAY,CAAC,EAAE,CAAC;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,eAAe,GAAU,gBAEnC;IACD,SAAS,EAAE,cAAc,EAAE,CAAC;CAC7B,
|
|
1
|
+
{"version":3,"file":"nav.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/layouts/sidebar/nav/nav.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,YAAY,CAAC,EAAE,CAAC;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,eAAe,GAAU,gBAEnC;IACD,SAAS,EAAE,cAAc,EAAE,CAAC;CAC7B,uDAqDA,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { LayoutDashboardIcon, UsersRoundIcon } from "lucide-react";
|
|
2
|
+
import { LayoutDashboardIcon, UsersRoundIcon, WrenchIcon } from "lucide-react";
|
|
3
3
|
import { getTranslations } from "next-intl/server";
|
|
4
4
|
import { SidebarGroup, SidebarGroupLabel, SidebarMenu } from "../../../../../components/ui/sidebar.js";
|
|
5
5
|
import { ItemNavAdmin } from "./item.js";
|
|
@@ -29,6 +29,17 @@ export const NavSidebarAdmin = async ({ pluginNav })=>{
|
|
|
29
29
|
href: "/admin/core/test"
|
|
30
30
|
}
|
|
31
31
|
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
href: "/admin/core/advanced",
|
|
35
|
+
title: t("advanced.title"),
|
|
36
|
+
icon: /*#__PURE__*/ _jsx(WrenchIcon, {}),
|
|
37
|
+
items: [
|
|
38
|
+
{
|
|
39
|
+
title: t("advanced.cron"),
|
|
40
|
+
href: "/admin/core/advanced/cron"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
32
43
|
}
|
|
33
44
|
]
|
|
34
45
|
},
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type SearchParamsDataTable } from "../../../../../../components/table/data-table";
|
|
2
|
+
export declare const CronTableView: ({ searchParams, }: {
|
|
3
|
+
searchParams: Promise<SearchParamsDataTable>;
|
|
4
|
+
}) => Promise<import("react/jsx-runtime").JSX.Element>;
|
|
5
|
+
//# sourceMappingURL=cron-table-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron-table-view.d.ts","sourceRoot":"","sources":["../../../../../../../../src/views/admin/views/core/advanced/cron/cron-table-view.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,+BAA+B,CAAC;AAIvC,eAAO,MAAM,aAAa,GAAU,mBAEjC;IACD,YAAY,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC9C,qDA8EA,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getTranslations } from "next-intl/server";
|
|
3
|
+
import { cronAdminModule } from "../../../../../../api/modules/admin/advanced/cron/cron.admin.module.js";
|
|
4
|
+
import { DateFormat } from "../../../../../../components/date-format.js";
|
|
5
|
+
import { DataTable } from "../../../../../../components/table/data-table.js";
|
|
6
|
+
import { fetcher } from "../../../../../../lib/fetcher.js";
|
|
7
|
+
import { RunActionCronTable } from "./run-action/run-action.js";
|
|
8
|
+
export const CronTableView = async ({ searchParams })=>{
|
|
9
|
+
const query = await searchParams;
|
|
10
|
+
const res = await fetcher(cronAdminModule, {
|
|
11
|
+
path: "/",
|
|
12
|
+
method: "get",
|
|
13
|
+
module: "cron",
|
|
14
|
+
prefixPath: "/admin/advanced",
|
|
15
|
+
args: {
|
|
16
|
+
query
|
|
17
|
+
},
|
|
18
|
+
withPagination: true
|
|
19
|
+
});
|
|
20
|
+
const [data, t] = await Promise.all([
|
|
21
|
+
res.json(),
|
|
22
|
+
getTranslations("admin.advanced.cron")
|
|
23
|
+
]);
|
|
24
|
+
return /*#__PURE__*/ _jsx(DataTable, {
|
|
25
|
+
columns: [
|
|
26
|
+
{
|
|
27
|
+
id: "name",
|
|
28
|
+
label: t("list.name"),
|
|
29
|
+
cell: ({ row })=>/*#__PURE__*/ _jsxs("div", {
|
|
30
|
+
className: "flex flex-col max-w-sm",
|
|
31
|
+
children: [
|
|
32
|
+
/*#__PURE__*/ _jsx("span", {
|
|
33
|
+
children: row.name
|
|
34
|
+
}),
|
|
35
|
+
/*#__PURE__*/ _jsx("p", {
|
|
36
|
+
className: "text-sm text-muted-foreground",
|
|
37
|
+
children: row.description
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "pluginId",
|
|
44
|
+
label: t("list.pluginId")
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: "module",
|
|
48
|
+
label: t("list.module")
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "schedule",
|
|
52
|
+
label: t("list.schedule")
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "lastRun",
|
|
56
|
+
label: t("list.lastRun.title"),
|
|
57
|
+
cell: ({ row })=>row.lastRun ? /*#__PURE__*/ _jsx(DateFormat, {
|
|
58
|
+
date: row.lastRun
|
|
59
|
+
}) : /*#__PURE__*/ _jsx("span", {
|
|
60
|
+
className: "italic text-muted-foreground",
|
|
61
|
+
children: t("list.lastRun.never")
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "nextRun",
|
|
66
|
+
label: t("list.nextRun.title"),
|
|
67
|
+
cell: ({ row })=>row.nextRun ? /*#__PURE__*/ _jsx(DateFormat, {
|
|
68
|
+
date: row.nextRun,
|
|
69
|
+
showFullDate: true
|
|
70
|
+
}) : /*#__PURE__*/ _jsx("span", {
|
|
71
|
+
className: "italic text-muted-foreground",
|
|
72
|
+
children: t("list.nextRun.never")
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "actions",
|
|
77
|
+
label: "",
|
|
78
|
+
cell: ({ row })=>/*#__PURE__*/ _jsx(RunActionCronTable, {
|
|
79
|
+
id: row.id
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
edges: data.edges,
|
|
84
|
+
order: {
|
|
85
|
+
columns: [
|
|
86
|
+
"lastRun",
|
|
87
|
+
"createdAt",
|
|
88
|
+
"nextRun"
|
|
89
|
+
],
|
|
90
|
+
defaultOrder: {
|
|
91
|
+
column: "lastRun",
|
|
92
|
+
order: "desc"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
pageInfo: data.pageInfo
|
|
96
|
+
});
|
|
97
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-api.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/views/admin/views/core/advanced/cron/run-action/mutation-api.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,GAAU,IAAI,MAAM;;cAkB3C,CAAC"}
|