@uns-kit/cron
v2.0.23
Published
Cron-driven plugin for UnsProxyProcess that emits UNS events on a schedule.
Readme
@uns-kit/cron
@uns-kit/cron adds cron-style scheduling to the UNS runtime. It registers a createCrontabProxy method on UnsProxyProcess, emitting cronEvent notifications that can be bridged to MQTT topics or any downstream integration.
Note: Apps built with uns-kit are intended to be managed by the UNS Datahub controller.
uns-kit in context
uns-kit is a batteries-included toolkit for Unified Namespace applications. It standardizes MQTT wiring, auth, config schemas, and scaffolding so you can focus on scheduled behaviors and domain logic. The toolkit includes:
| Package | Description |
| --- | --- |
| @uns-kit/core | Base runtime utilities (UnsProxyProcess, MQTT helpers, configuration tooling, gRPC gateway support). |
| @uns-kit/api | Express plugin that exposes HTTP endpoints, handles JWT/JWKS auth, and republishes API metadata to UNS. |
| @uns-kit/cron | Cron-driven scheduler that emits UNS events on a fixed cadence. |
| @uns-kit/temporal | Temporal.io integration that wires workflows into UnsProxyProcess. |
| @uns-kit/cli | Command line tool for scaffolding new UNS applications. |
Installation
pnpm add @uns-kit/cron
# or
npm install @uns-kit/cronYou will also need @uns-kit/core in your project because the plugin augments UnsProxyProcess.
Quick Start
import UnsProxyProcess from "@uns-kit/core/uns/uns-proxy-process";
import type { UnsProxyProcessWithCron } from "@uns-kit/cron";
import "@uns-kit/cron";
async function main() {
const process = new UnsProxyProcess("mqtt-broker:1883", { processName: "cron-demo" }) as UnsProxyProcessWithCron;
const cronProxy = await process.createCrontabProxy("*/5 * * * *", { event: "heartbeat" });
cronProxy.event.on("cronEvent", ({ event, cronExpression }) => {
console.log("tick", event, cronExpression);
});
}
void main();Multiple schedules
const cronProxy = await process.createCrontabProxy([
{ cronExpression: "* * * * * *", event: "a" },
{ cronExpression: "*/10 * * * * *", event: "b" },
]);You can also pass an array of cron strings and optional default options:
const cronProxy = await process.createCrontabProxy(
["*/5 * * * *", "*/15 * * * *"],
{ timezone: "UTC" },
);Scripts
pnpm run typecheck
pnpm run buildbuild emits ESM JavaScript and type declarations into dist/.
License
MIT © Aljoša Vister
