import { CronJob, CronJobParams } from 'cron'; import { type Static } from '@sinclair/typebox'; import type { Logger, LoggerOptions } from 'pino'; export type KLog = Logger; export type KLogOptions = LoggerOptions & { stream?: { write: (msg: string) => void; }; }; export type CronContext = C extends null ? KBaseJob : NonNullable; export type CronCallback = (this: CronContext, onComplete: WithOnCompleteBool extends true ? CronOnCompleteCallback : never) => void | Promise; export type CronOnCompleteCallback = () => void | Promise; export type CronCommand = CronCallback; export type CronOnCompleteCommand = CronOnCompleteCallback; export type WithOnComplete = OC extends null ? false : true; export type KBaseParams = CronJobParams; export type KBaseJob = CronJob & { log?: KLog; }; export type KNamedParams = KBaseParams & { name: string; log?: KLog; onTick: CronCommand>; }; export type KParams = KNamedParams & { log?: KLog; }; export type KNamedJob = KBaseJob & Required>; export type KJob = KNamedJob; /** * Configuration options for the Cron Job manager class. * * @property dir - Optional directory configuration. * @property dir.base - The base directory path. * @property dir.writeable - Whether the directory is writeable. Optional. * @property log - Optional logging configuration of type `CJLog`. * @property name - Optional name for the configuration. */ export type KConfig = { cronTabPath?: string; jobsDir?: { base: string; writeable?: boolean; }; name?: string; logger?: boolean | KLogOptions; loggerInstance?: KLog; httpServer?: boolean | { port?: number; host?: string; path?: string; }; terminal?: boolean; }; /** * Schema and type definition for a cron job configuration object. * * @property schedule - The schedule for the cron job, which can be either a string (e.g., cron expression) or a Date object. * @property timezone - (Optional) The timezone in which the cron job should run, specified as a string. * @property start - (Optional) Indicates whether the cron job should start automatically. Defaults to true. */ export declare const KCronConfigSchema: import("@sinclair/typebox").TRecord; schedule: import("@sinclair/typebox").TOptional>; timezone: import("@sinclair/typebox").TOptional; start: import("@sinclair/typebox").TOptional; waitForCompletion: import("@sinclair/typebox").TOptional; }>>; type ValueOf = T[keyof T]; export type KCronConfig = ValueOf>; export type KCronJobConfig = (() => KCronConfig) | (() => Promise) | KCronConfig; /** * Represents the structure of a cron job module. * * @property default - An asynchronous function that executes the main logic of the cron job. * @property config - (Optional) An asynchronous function that returns the configuration for the cron job. * @property name - (Optional) The name of the cron job module. */ export type KCronJob = { default: () => Promise; config?: KCronJobConfig; name?: string; }; export {};