@sapiom/tools 0.9.0 → 0.10.1

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.
@@ -0,0 +1,40 @@
1
+ # schedules
2
+
3
+ Create and manage schedules for a deployed orchestration: a recurring **cron** schedule, or a **one-off** delayed run. A schedule is attached to an orchestration by its **slug**, and each time it fires it starts a run of that orchestration with the input you set.
4
+
5
+ ```ts
6
+ import { schedules } from "@sapiom/tools";
7
+
8
+ // Recurring: run "enrich-lead" at 9am New York time, Monday–Friday.
9
+ const daily = await schedules.create({
10
+ definition: "enrich-lead",
11
+ kind: "schedule_cron",
12
+ cron: "0 9 * * 1-5",
13
+ timezone: "America/New_York",
14
+ input: { source: "crm" },
15
+ });
16
+
17
+ // One-off: run once, two hours from now.
18
+ await schedules.create({
19
+ definition: "send-receipt",
20
+ kind: "schedule_once",
21
+ at: new Date(Date.now() + 2 * 60 * 60_000).toISOString(),
22
+ input: { orderId },
23
+ });
24
+ ```
25
+
26
+ ```ts
27
+ // List an orchestration's schedules, inspect one, or cancel it.
28
+ const all = await schedules.list("enrich-lead");
29
+ const one = await schedules.get(all[0].id); // includes nextFireAt + recent fires
30
+ await schedules.cancel(one.id);
31
+ ```
32
+
33
+ ## Things to know
34
+
35
+ - **Two kinds.** `schedule_cron` takes a `cron` expression (+ optional `timezone`); `schedule_once` takes an `at` time (ISO 8601). A cron schedule fires on every matching tick until cancelled; a one-off fires exactly once.
36
+ - **Timezone-aware cron.** `timezone` is an IANA name (e.g. `"America/New_York"`); the cron is evaluated in that zone, so daylight-saving shifts are handled for you. Defaults to UTC.
37
+ - **Best-effort timing.** A schedule fires at or shortly after its scheduled time — fine for "around 9am", not for hard real-time deadlines.
38
+ - **`get` shows health.** `get(id)` returns the next scheduled fire (`nextFireAt`) and a recent fire history — each with the `executionId` of the run it started — so you can confirm a schedule is firing or debug one that isn't.
39
+ - **Cancel is final.** A cancelled schedule stops firing (a recurring one won't re-arm); recreate to reschedule.
40
+ - **Optional bounds (cron).** `startAt` / `endAt` confine when a cron schedule is active.