mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:10:43 +00:00
refactor: share cron list page types
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { CronListPageOptions, CronListPageResult } from "./service/list-page-types.js";
|
||||
import type {
|
||||
CronAddInput,
|
||||
CronAddResult,
|
||||
@@ -12,28 +13,7 @@ import type {
|
||||
} from "./service/state.js";
|
||||
import type { CronJob } from "./types.js";
|
||||
|
||||
type CronJobsEnabledFilter = "all" | "enabled" | "disabled";
|
||||
type CronJobsSortBy = "nextRunAtMs" | "updatedAtMs" | "name";
|
||||
type CronSortDir = "asc" | "desc";
|
||||
|
||||
export type CronListPageOptions = {
|
||||
includeDisabled?: boolean;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
query?: string;
|
||||
enabled?: CronJobsEnabledFilter;
|
||||
sortBy?: CronJobsSortBy;
|
||||
sortDir?: CronSortDir;
|
||||
};
|
||||
|
||||
export type CronListPageResult = {
|
||||
jobs: CronJob[];
|
||||
total: number;
|
||||
offset: number;
|
||||
limit: number;
|
||||
hasMore: boolean;
|
||||
nextOffset: number | null;
|
||||
};
|
||||
export type { CronListPageOptions, CronListPageResult } from "./service/list-page-types.js";
|
||||
|
||||
export type CronWakeResult = { ok: true } | { ok: false };
|
||||
|
||||
|
||||
24
src/cron/service/list-page-types.ts
Normal file
24
src/cron/service/list-page-types.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { CronJob } from "../types.js";
|
||||
|
||||
export type CronJobsEnabledFilter = "all" | "enabled" | "disabled";
|
||||
export type CronJobsSortBy = "nextRunAtMs" | "updatedAtMs" | "name";
|
||||
export type CronSortDir = "asc" | "desc";
|
||||
|
||||
export type CronListPageOptions = {
|
||||
includeDisabled?: boolean;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
query?: string;
|
||||
enabled?: CronJobsEnabledFilter;
|
||||
sortBy?: CronJobsSortBy;
|
||||
sortDir?: CronSortDir;
|
||||
};
|
||||
|
||||
export type CronListPageResult<TJobs extends readonly CronJob[] = CronJob[]> = {
|
||||
jobs: TJobs;
|
||||
total: number;
|
||||
offset: number;
|
||||
limit: number;
|
||||
hasMore: boolean;
|
||||
nextOffset: number | null;
|
||||
};
|
||||
@@ -21,6 +21,13 @@ import {
|
||||
recomputeNextRuns,
|
||||
recomputeNextRunsForMaintenance,
|
||||
} from "./jobs.js";
|
||||
import type {
|
||||
CronJobsEnabledFilter,
|
||||
CronJobsSortBy,
|
||||
CronListPageOptions,
|
||||
CronListPageResult,
|
||||
CronSortDir,
|
||||
} from "./list-page-types.js";
|
||||
import { locked } from "./locked.js";
|
||||
import type { CronServiceState } from "./state.js";
|
||||
import { ensureLoaded, persist, warnIfDisabled } from "./store.js";
|
||||
@@ -35,28 +42,6 @@ import {
|
||||
wake,
|
||||
} from "./timer.js";
|
||||
|
||||
type CronJobsEnabledFilter = "all" | "enabled" | "disabled";
|
||||
type CronJobsSortBy = "nextRunAtMs" | "updatedAtMs" | "name";
|
||||
type CronSortDir = "asc" | "desc";
|
||||
|
||||
export type CronListPageOptions = {
|
||||
includeDisabled?: boolean;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
query?: string;
|
||||
enabled?: CronJobsEnabledFilter;
|
||||
sortBy?: CronJobsSortBy;
|
||||
sortDir?: CronSortDir;
|
||||
};
|
||||
|
||||
export type CronListPageResult = {
|
||||
jobs: ReturnType<typeof sortJobs>;
|
||||
total: number;
|
||||
offset: number;
|
||||
limit: number;
|
||||
hasMore: boolean;
|
||||
nextOffset: number | null;
|
||||
};
|
||||
function mergeManualRunSnapshotAfterReload(params: {
|
||||
state: CronServiceState;
|
||||
jobId: string;
|
||||
|
||||
Reference in New Issue
Block a user