From ba2e87b87aab0bc23e6e55c5282d7041f0122e96 Mon Sep 17 00:00:00 2001 From: caballeto Date: Tue, 5 May 2026 22:07:23 +0200 Subject: [PATCH] fix(types): mark monitor.currentStatus nullable + doc post-create timing `Monitor.currentStatus` is computed by the probe pipeline and isn't populated on a freshly-created monitor, so a fresh dev who logs it straight after `client.monitors.create()` sees `undefined`. Wrap the generated `MonitorDto` so the field is surfaced as `string | null` with a doc comment that explains the timing, and update the README quickstart with a one-line note + `?? 'PENDING'` display pattern so the example doesn't read as broken. Round-2 DevEx friction P2 #14. Co-authored-by: Cursor --- README.md | 1 + src/types.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f4fd198..8b71aca 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ const monitor = await client.monitors.create({ // re-deploy, or `TERRAFORM` if it lives in `.tf` you re-apply. managedBy: 'DASHBOARD', }) +// Note: `monitor.currentStatus` is null until the first probe runs (~1 minute); display `monitor.currentStatus ?? 'PENDING'`. // Get a single monitor const fetched = await client.monitors.get(monitor.id) diff --git a/src/types.ts b/src/types.ts index e2946a6..cbec11a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -6,7 +6,24 @@ export type Schemas = components['schemas'] // ── Response DTOs ────────────────────────────────────────────────────── -export type MonitorDto = z.infer +type MonitorDtoBase = z.infer + +/** + * Full monitor representation returned by GET, POST, and PUT endpoints. + * + * `currentStatus` is the derived health of the monitor (e.g. `"up"`, + * `"degraded"`, `"down"`). It is populated after the first probe runs — + * typically ~1 minute after create — so on a freshly-created monitor it + * may be `null` or `undefined`. Always provide a fallback when displaying + * it, e.g. `monitor.currentStatus ?? 'PENDING'`. + */ +export type MonitorDto = MonitorDtoBase & { + /** + * Populated after the first probe (~1 minute after create). May be + * null or undefined immediately after create. + */ + currentStatus?: string | null +} export type IncidentDto = z.infer export type IncidentDetailDto = z.infer export type AlertChannelDto = z.infer