UNPKG

@boundless-oss/atlas

Version:

Atlas - MCP Server for comprehensive startup project management

63 lines 1.51 kB
import cron from 'node-cron'; export class NodeCronAdapter { validate(expression) { return cron.validate(expression); } schedule(expression, callback, options) { return cron.schedule(expression, callback, options); } } export class MockCronAdapter { mockTasks = new Map(); shouldValidate = true; setShouldValidate(value) { this.shouldValidate = value; } validate(expression) { return this.shouldValidate; } schedule(expression, callback, options) { const task = new MockCronTask(callback, options?.scheduled !== false); this.mockTasks.set(expression, task); return task; } getTasks() { return this.mockTasks; } clear() { this.mockTasks.clear(); } } class MockCronTask { isRunning; callback; destroyed = false; constructor(callback, autoStart = true) { this.callback = callback; this.isRunning = autoStart; } start() { if (!this.destroyed) { this.isRunning = true; } } stop() { this.isRunning = false; } destroy() { this.isRunning = false; this.destroyed = true; } isActive() { return this.isRunning && !this.destroyed; } isDestroyed() { return this.destroyed; } async trigger() { if (this.isRunning && !this.destroyed) { await this.callback(); } } } //# sourceMappingURL=cron-adapter.js.map