watchfor 0.1.0
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.
- package/README.md +55 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +117 -0
- package/dist/client.d.ts +157 -0
- package/dist/client.js +150 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/schema.d.ts +3012 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# watchfor
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK + CLI for [WatchFor](https://watchfor.io) —
|
|
4
|
+
uptime & infrastructure monitoring (25 check types, confirmed alerting,
|
|
5
|
+
status pages, on-call).
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install watchfor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## SDK
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { WatchFor } from "watchfor";
|
|
15
|
+
|
|
16
|
+
const wf = new WatchFor({ apiKey: process.env.WATCHFOR_API_KEY! });
|
|
17
|
+
|
|
18
|
+
const summary = await wf.summary(); // what's up/down right now
|
|
19
|
+
const firing = await wf.incidents.list({ status: "firing" });
|
|
20
|
+
const monitor = await wf.monitors.create({
|
|
21
|
+
name: "My site",
|
|
22
|
+
type: "http",
|
|
23
|
+
target: "https://example.com",
|
|
24
|
+
interval: 60,
|
|
25
|
+
locations: ["<location-id from wf.locations()>"],
|
|
26
|
+
});
|
|
27
|
+
await wf.alertRules.create(monitor.id!, {
|
|
28
|
+
name: "Slow response",
|
|
29
|
+
metric: "response_time",
|
|
30
|
+
operator: ">",
|
|
31
|
+
value: "2000",
|
|
32
|
+
severity: "warning",
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- Fully typed from the [OpenAPI spec](https://watchfor.io/openapi.json)
|
|
37
|
+
- Zero runtime dependencies (uses global `fetch`, Node ≥ 18)
|
|
38
|
+
- `WatchForError` carries `status`, `code` and `retryAfterSeconds`
|
|
39
|
+
- Pass an `idempotencyKey` to any create call for safe retries
|
|
40
|
+
|
|
41
|
+
## CLI
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
export WATCHFOR_API_KEY=wf_live_...
|
|
45
|
+
npx watchfor summary
|
|
46
|
+
npx watchfor incidents --status firing
|
|
47
|
+
npx watchfor monitors example.com
|
|
48
|
+
npx watchfor checks <monitor-id> --failed
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Links
|
|
52
|
+
|
|
53
|
+
- API docs: https://watchfor.io/docs/api
|
|
54
|
+
- MCP server for AI agents (37 tools): https://watchfor.io/docs/api/mcp
|
|
55
|
+
- Create an API key: dashboard → Settings → API keys (`read` or `read+write` scope)
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { WatchFor, WatchForError } from "./client.js";
|
|
3
|
+
/**
|
|
4
|
+
* `watchfor` CLI — quick terminal access to the monitoring API.
|
|
5
|
+
*
|
|
6
|
+
* export WATCHFOR_API_KEY=wf_live_...
|
|
7
|
+
* watchfor summary
|
|
8
|
+
* watchfor incidents --status firing
|
|
9
|
+
* watchfor monitors [search]
|
|
10
|
+
* watchfor checks <monitor-id> --failed
|
|
11
|
+
*/
|
|
12
|
+
const HELP = `watchfor — WatchFor monitoring CLI (https://watchfor.io)
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
watchfor summary Org snapshot: what's up/down right now
|
|
16
|
+
watchfor incidents [--status s] List incidents (firing|acknowledged|resolved)
|
|
17
|
+
watchfor monitors [query] List monitors (optional name/target search)
|
|
18
|
+
watchfor checks <monitor-id> [--failed]
|
|
19
|
+
Recent probe results for one monitor
|
|
20
|
+
watchfor help
|
|
21
|
+
|
|
22
|
+
Environment:
|
|
23
|
+
WATCHFOR_API_KEY API key (dashboard → Settings → API keys)
|
|
24
|
+
WATCHFOR_BASE_URL Override (default https://watchfor.io)
|
|
25
|
+
`;
|
|
26
|
+
function flag(args, name) {
|
|
27
|
+
const i = args.indexOf(`--${name}`);
|
|
28
|
+
if (i === -1)
|
|
29
|
+
return undefined;
|
|
30
|
+
return args[i + 1] && !args[i + 1].startsWith("--") ? args[i + 1] : "true";
|
|
31
|
+
}
|
|
32
|
+
async function main() {
|
|
33
|
+
const [cmd, ...args] = process.argv.slice(2);
|
|
34
|
+
if (!cmd || cmd === "help" || cmd === "--help" || cmd === "-h") {
|
|
35
|
+
process.stdout.write(HELP);
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
const apiKey = process.env.WATCHFOR_API_KEY;
|
|
39
|
+
if (!apiKey) {
|
|
40
|
+
console.error("WATCHFOR_API_KEY is not set. Create a key in the dashboard (Settings → API keys).");
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
const wf = new WatchFor({
|
|
44
|
+
apiKey,
|
|
45
|
+
baseUrl: process.env.WATCHFOR_BASE_URL,
|
|
46
|
+
});
|
|
47
|
+
switch (cmd) {
|
|
48
|
+
case "summary": {
|
|
49
|
+
const s = await wf.summary();
|
|
50
|
+
const m = s.monitors;
|
|
51
|
+
const i = s.incidents;
|
|
52
|
+
console.log(`monitors: ${m.total} total · ${m.up} up · ${m.down} down · ${m.paused} paused · health ${m.health_score}%`);
|
|
53
|
+
console.log(`incidents: ${i.firing} firing (${i.firing_critical} critical) · ${i.acknowledged} acknowledged · ${i.started_24h} started in 24h`);
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
case "incidents": {
|
|
57
|
+
const status = flag(args, "status");
|
|
58
|
+
const res = await wf.incidents.list({ status, limit: 25 });
|
|
59
|
+
for (const inc of res.data) {
|
|
60
|
+
const r = inc;
|
|
61
|
+
const mon = r.monitor?.name ?? "?";
|
|
62
|
+
console.log(`#${r.id} ${String(r.status).padEnd(12)} ${String(r.severity).padEnd(8)} ${mon} ${r.message ?? ""}`);
|
|
63
|
+
}
|
|
64
|
+
if (res.data.length === 0)
|
|
65
|
+
console.log("(no incidents)");
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
case "monitors": {
|
|
69
|
+
const q = args.find((a) => !a.startsWith("--"));
|
|
70
|
+
const res = await wf.monitors.list({ q, limit: 50 });
|
|
71
|
+
for (const m of res.data) {
|
|
72
|
+
const r = m;
|
|
73
|
+
console.log(`${String(r.status).padEnd(8)} ${String(r.type).padEnd(10)} ${r.name} ${r.target}`);
|
|
74
|
+
}
|
|
75
|
+
if (res.data.length === 0)
|
|
76
|
+
console.log("(no monitors)");
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
case "checks": {
|
|
80
|
+
const id = args.find((a) => !a.startsWith("--"));
|
|
81
|
+
if (!id) {
|
|
82
|
+
console.error("Usage: watchfor checks <monitor-id> [--failed]");
|
|
83
|
+
return 1;
|
|
84
|
+
}
|
|
85
|
+
const failed = flag(args, "failed") === "true";
|
|
86
|
+
const res = await wf.monitors.checks(id, {
|
|
87
|
+
success: failed ? false : undefined,
|
|
88
|
+
limit: 25,
|
|
89
|
+
});
|
|
90
|
+
for (const c of res.data) {
|
|
91
|
+
const r = c;
|
|
92
|
+
console.log(`${r.timestamp} ${r.success ? "ok " : "FAIL"} ${String(r.duration_ms).padStart(6)}ms ${r.location ?? ""} ${r.error ?? ""}`);
|
|
93
|
+
}
|
|
94
|
+
if (res.data.length === 0)
|
|
95
|
+
console.log("(no checks in window)");
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
default:
|
|
99
|
+
console.error(`Unknown command: ${cmd}\n`);
|
|
100
|
+
process.stdout.write(HELP);
|
|
101
|
+
return 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
main()
|
|
105
|
+
.then((code) => process.exit(code))
|
|
106
|
+
.catch((err) => {
|
|
107
|
+
if (err instanceof WatchForError) {
|
|
108
|
+
console.error(`Error ${err.status} (${err.code}): ${err.message}`);
|
|
109
|
+
if (err.retryAfterSeconds) {
|
|
110
|
+
console.error(`Retry after ${err.retryAfterSeconds}s`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
115
|
+
}
|
|
116
|
+
process.exit(1);
|
|
117
|
+
});
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { components } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* WatchFor API client — a thin, zero-dependency typed wrapper over
|
|
4
|
+
* https://watchfor.io/api/v1 (spec: https://watchfor.io/openapi.json).
|
|
5
|
+
*
|
|
6
|
+
* const wf = new WatchFor({ apiKey: process.env.WATCHFOR_API_KEY! });
|
|
7
|
+
* const summary = await wf.summary();
|
|
8
|
+
*/
|
|
9
|
+
export type Monitor = components["schemas"]["Monitor"];
|
|
10
|
+
export type Incident = components["schemas"]["Incident"];
|
|
11
|
+
export type AlertRule = components["schemas"]["AlertRule"];
|
|
12
|
+
export type Contact = components["schemas"]["Contact"];
|
|
13
|
+
export type ContactGroup = components["schemas"]["ContactGroup"];
|
|
14
|
+
export type MaintenanceWindow = components["schemas"]["MaintenanceWindow"];
|
|
15
|
+
export type StatusPage = components["schemas"]["StatusPage"];
|
|
16
|
+
export type Uptime = components["schemas"]["Uptime"];
|
|
17
|
+
export type Check = components["schemas"]["Check"];
|
|
18
|
+
export type Plan = components["schemas"]["Plan"];
|
|
19
|
+
export type Summary = components["schemas"]["Summary"];
|
|
20
|
+
export type IncidentStats = components["schemas"]["IncidentStats"];
|
|
21
|
+
export type ActivityEvent = components["schemas"]["ActivityEvent"];
|
|
22
|
+
export type Notification = components["schemas"]["Notification"];
|
|
23
|
+
export type ApiErrorBody = components["schemas"]["Error"];
|
|
24
|
+
export interface List<T> {
|
|
25
|
+
object: "list";
|
|
26
|
+
data: T[];
|
|
27
|
+
has_more: boolean;
|
|
28
|
+
next_cursor?: string | null;
|
|
29
|
+
total?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare class WatchForError extends Error {
|
|
32
|
+
readonly status: number;
|
|
33
|
+
readonly code: string;
|
|
34
|
+
readonly retryAfterSeconds?: number;
|
|
35
|
+
constructor(status: number, code: string, message: string, retryAfterSeconds?: number);
|
|
36
|
+
}
|
|
37
|
+
export interface WatchForOptions {
|
|
38
|
+
/** API key (wf_live_…) — dashboard Settings → API keys. */
|
|
39
|
+
apiKey: string;
|
|
40
|
+
/** Override for self-hosted / testing. Default https://watchfor.io */
|
|
41
|
+
baseUrl?: string;
|
|
42
|
+
fetch?: typeof fetch;
|
|
43
|
+
}
|
|
44
|
+
export declare class WatchFor {
|
|
45
|
+
private readonly apiKey;
|
|
46
|
+
private readonly base;
|
|
47
|
+
private readonly fetchImpl;
|
|
48
|
+
constructor(opts: WatchForOptions);
|
|
49
|
+
private request;
|
|
50
|
+
/** Current API key + organization. */
|
|
51
|
+
me(): Promise<unknown>;
|
|
52
|
+
/** One-call org snapshot: monitor status counts + active incidents. */
|
|
53
|
+
summary(): Promise<Summary>;
|
|
54
|
+
/** Plan limits and live usage. */
|
|
55
|
+
plan(): Promise<Plan>;
|
|
56
|
+
/** Aggregate incident stats: MTTR, MTBF, most unstable monitors. */
|
|
57
|
+
incidentStats(period?: "24h" | "7d" | "30d" | "90d"): Promise<IncidentStats>;
|
|
58
|
+
/** Probe locations for monitor creation. */
|
|
59
|
+
locations(): Promise<List<Record<string, unknown>>>;
|
|
60
|
+
/** All 25 monitor types with exact alert metrics + config fields. */
|
|
61
|
+
monitorTypes(): Promise<List<Record<string, unknown>>>;
|
|
62
|
+
readonly monitors: {
|
|
63
|
+
list: (q?: {
|
|
64
|
+
q?: string;
|
|
65
|
+
type?: string;
|
|
66
|
+
status?: "up" | "down" | "paused" | "unknown";
|
|
67
|
+
tag?: string;
|
|
68
|
+
limit?: number;
|
|
69
|
+
cursor?: string;
|
|
70
|
+
}) => Promise<List<Monitor>>;
|
|
71
|
+
get: (id: string) => Promise<Monitor>;
|
|
72
|
+
create: (body: Record<string, unknown>, idempotencyKey?: string) => Promise<Monitor>;
|
|
73
|
+
update: (id: string, body: Record<string, unknown>) => Promise<Monitor>;
|
|
74
|
+
delete: (id: string) => Promise<void>;
|
|
75
|
+
pause: (id: string) => Promise<Monitor>;
|
|
76
|
+
resume: (id: string) => Promise<Monitor>;
|
|
77
|
+
checkNow: (id: string) => Promise<unknown>;
|
|
78
|
+
uptime: (id: string, period?: "1h" | "24h" | "7d" | "30d" | "90d") => Promise<Uptime>;
|
|
79
|
+
checks: (id: string, q?: {
|
|
80
|
+
hours?: number;
|
|
81
|
+
success?: boolean;
|
|
82
|
+
limit?: number;
|
|
83
|
+
}) => Promise<List<Check>>;
|
|
84
|
+
};
|
|
85
|
+
readonly alertRules: {
|
|
86
|
+
list: (monitorId: string) => Promise<List<AlertRule>>;
|
|
87
|
+
get: (monitorId: string, ruleId: string) => Promise<AlertRule>;
|
|
88
|
+
create: (monitorId: string, body: Record<string, unknown>, idempotencyKey?: string) => Promise<AlertRule>;
|
|
89
|
+
update: (monitorId: string, ruleId: string, body: Record<string, unknown>) => Promise<AlertRule>;
|
|
90
|
+
delete: (monitorId: string, ruleId: string) => Promise<void>;
|
|
91
|
+
};
|
|
92
|
+
readonly incidents: {
|
|
93
|
+
list: (q?: {
|
|
94
|
+
status?: "firing" | "acknowledged" | "resolved";
|
|
95
|
+
severity?: "critical" | "warning";
|
|
96
|
+
monitor_id?: string;
|
|
97
|
+
since?: string;
|
|
98
|
+
until?: string;
|
|
99
|
+
limit?: number;
|
|
100
|
+
cursor?: string;
|
|
101
|
+
}) => Promise<List<Incident>>;
|
|
102
|
+
get: (id: number) => Promise<Incident>;
|
|
103
|
+
acknowledge: (id: number) => Promise<Incident>;
|
|
104
|
+
resolve: (id: number) => Promise<Incident>;
|
|
105
|
+
};
|
|
106
|
+
readonly maintenanceWindows: {
|
|
107
|
+
list: (q?: {
|
|
108
|
+
limit?: number;
|
|
109
|
+
cursor?: string;
|
|
110
|
+
}) => Promise<List<MaintenanceWindow>>;
|
|
111
|
+
get: (id: string) => Promise<MaintenanceWindow>;
|
|
112
|
+
create: (body: Record<string, unknown>, idempotencyKey?: string) => Promise<MaintenanceWindow>;
|
|
113
|
+
update: (id: string, body: Record<string, unknown>) => Promise<MaintenanceWindow>;
|
|
114
|
+
delete: (id: string) => Promise<void>;
|
|
115
|
+
};
|
|
116
|
+
readonly contacts: {
|
|
117
|
+
list: (q?: {
|
|
118
|
+
limit?: number;
|
|
119
|
+
cursor?: string;
|
|
120
|
+
}) => Promise<List<Contact>>;
|
|
121
|
+
get: (id: string) => Promise<Contact>;
|
|
122
|
+
create: (body: Record<string, unknown>, idempotencyKey?: string) => Promise<Contact>;
|
|
123
|
+
update: (id: string, body: Record<string, unknown>) => Promise<Contact>;
|
|
124
|
+
delete: (id: string) => Promise<void>;
|
|
125
|
+
};
|
|
126
|
+
readonly contactGroups: {
|
|
127
|
+
list: (q?: {
|
|
128
|
+
limit?: number;
|
|
129
|
+
cursor?: string;
|
|
130
|
+
}) => Promise<List<ContactGroup>>;
|
|
131
|
+
get: (id: string) => Promise<ContactGroup>;
|
|
132
|
+
create: (body: Record<string, unknown>, idempotencyKey?: string) => Promise<ContactGroup>;
|
|
133
|
+
update: (id: string, body: Record<string, unknown>) => Promise<ContactGroup>;
|
|
134
|
+
delete: (id: string) => Promise<void>;
|
|
135
|
+
};
|
|
136
|
+
/** Alerting delivery history — did the Slack/Telegram message go out? */
|
|
137
|
+
notifications(q?: {
|
|
138
|
+
status?: "sent" | "failed" | "silenced";
|
|
139
|
+
channel_type?: string;
|
|
140
|
+
monitor_id?: string;
|
|
141
|
+
incident_id?: number;
|
|
142
|
+
since?: string;
|
|
143
|
+
until?: string;
|
|
144
|
+
limit?: number;
|
|
145
|
+
cursor?: string;
|
|
146
|
+
}): Promise<List<Notification>>;
|
|
147
|
+
/** Org audit trail — who changed what, when. */
|
|
148
|
+
activity(q?: {
|
|
149
|
+
q?: string;
|
|
150
|
+
entity_type?: string;
|
|
151
|
+
entity_id?: string;
|
|
152
|
+
since?: string;
|
|
153
|
+
until?: string;
|
|
154
|
+
limit?: number;
|
|
155
|
+
cursor?: string;
|
|
156
|
+
}): Promise<List<ActivityEvent>>;
|
|
157
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export class WatchForError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
code;
|
|
4
|
+
retryAfterSeconds;
|
|
5
|
+
constructor(status, code, message, retryAfterSeconds) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "WatchForError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class WatchFor {
|
|
14
|
+
apiKey;
|
|
15
|
+
base;
|
|
16
|
+
fetchImpl;
|
|
17
|
+
constructor(opts) {
|
|
18
|
+
if (!opts.apiKey)
|
|
19
|
+
throw new Error("WatchFor: apiKey is required");
|
|
20
|
+
this.apiKey = opts.apiKey;
|
|
21
|
+
this.base = (opts.baseUrl ?? "https://watchfor.io").replace(/\/$/, "");
|
|
22
|
+
this.fetchImpl = opts.fetch ?? fetch;
|
|
23
|
+
}
|
|
24
|
+
async request(method, path, opts = {}) {
|
|
25
|
+
const url = new URL(`${this.base}/api/v1${path}`);
|
|
26
|
+
for (const [k, v] of Object.entries(opts.query ?? {})) {
|
|
27
|
+
if (v !== undefined)
|
|
28
|
+
url.searchParams.set(k, String(v));
|
|
29
|
+
}
|
|
30
|
+
const headers = {
|
|
31
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
32
|
+
Accept: "application/json",
|
|
33
|
+
};
|
|
34
|
+
if (opts.body !== undefined)
|
|
35
|
+
headers["Content-Type"] = "application/json";
|
|
36
|
+
if (opts.idempotencyKey)
|
|
37
|
+
headers["Idempotency-Key"] = opts.idempotencyKey;
|
|
38
|
+
const res = await this.fetchImpl(url, {
|
|
39
|
+
method,
|
|
40
|
+
headers,
|
|
41
|
+
body: opts.body !== undefined ? JSON.stringify(opts.body) : undefined,
|
|
42
|
+
});
|
|
43
|
+
if (res.status === 204)
|
|
44
|
+
return undefined;
|
|
45
|
+
let json = null;
|
|
46
|
+
try {
|
|
47
|
+
json = await res.json();
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
/* non-JSON body */
|
|
51
|
+
}
|
|
52
|
+
if (!res.ok) {
|
|
53
|
+
const err = json
|
|
54
|
+
?.error;
|
|
55
|
+
const retry = res.headers.get("Retry-After");
|
|
56
|
+
throw new WatchForError(res.status, err?.code ?? "http_error", err?.message ?? `HTTP ${res.status}`, retry ? Number(retry) : undefined);
|
|
57
|
+
}
|
|
58
|
+
return json;
|
|
59
|
+
}
|
|
60
|
+
// ── Org overview ──────────────────────────────────────────────
|
|
61
|
+
/** Current API key + organization. */
|
|
62
|
+
me() {
|
|
63
|
+
return this.request("GET", "/me");
|
|
64
|
+
}
|
|
65
|
+
/** One-call org snapshot: monitor status counts + active incidents. */
|
|
66
|
+
summary() {
|
|
67
|
+
return this.request("GET", "/summary");
|
|
68
|
+
}
|
|
69
|
+
/** Plan limits and live usage. */
|
|
70
|
+
plan() {
|
|
71
|
+
return this.request("GET", "/plan");
|
|
72
|
+
}
|
|
73
|
+
/** Aggregate incident stats: MTTR, MTBF, most unstable monitors. */
|
|
74
|
+
incidentStats(period) {
|
|
75
|
+
return this.request("GET", "/incidents/stats", { query: { period } });
|
|
76
|
+
}
|
|
77
|
+
/** Probe locations for monitor creation. */
|
|
78
|
+
locations() {
|
|
79
|
+
return this.request("GET", "/locations");
|
|
80
|
+
}
|
|
81
|
+
/** All 25 monitor types with exact alert metrics + config fields. */
|
|
82
|
+
monitorTypes() {
|
|
83
|
+
return this.request("GET", "/meta/monitor-types");
|
|
84
|
+
}
|
|
85
|
+
// ── Monitors ──────────────────────────────────────────────────
|
|
86
|
+
monitors = {
|
|
87
|
+
list: (q) => this.request("GET", "/monitors", { query: q }),
|
|
88
|
+
get: (id) => this.request("GET", `/monitors/${id}`),
|
|
89
|
+
create: (body, idempotencyKey) => this.request("POST", "/monitors", { body, idempotencyKey }),
|
|
90
|
+
update: (id, body) => this.request("PATCH", `/monitors/${id}`, { body }),
|
|
91
|
+
delete: (id) => this.request("DELETE", `/monitors/${id}`),
|
|
92
|
+
pause: (id) => this.request("POST", `/monitors/${id}/pause`),
|
|
93
|
+
resume: (id) => this.request("POST", `/monitors/${id}/resume`),
|
|
94
|
+
checkNow: (id) => this.request("POST", `/monitors/${id}/check-now`),
|
|
95
|
+
uptime: (id, period) => this.request("GET", `/monitors/${id}/uptime`, { query: { period } }),
|
|
96
|
+
checks: (id, q) => this.request("GET", `/monitors/${id}/checks`, { query: q }),
|
|
97
|
+
};
|
|
98
|
+
// ── Alert rules ───────────────────────────────────────────────
|
|
99
|
+
alertRules = {
|
|
100
|
+
list: (monitorId) => this.request("GET", `/monitors/${monitorId}/alert-rules`),
|
|
101
|
+
get: (monitorId, ruleId) => this.request("GET", `/monitors/${monitorId}/alert-rules/${ruleId}`),
|
|
102
|
+
create: (monitorId, body, idempotencyKey) => this.request("POST", `/monitors/${monitorId}/alert-rules`, {
|
|
103
|
+
body,
|
|
104
|
+
idempotencyKey,
|
|
105
|
+
}),
|
|
106
|
+
update: (monitorId, ruleId, body) => this.request("PATCH", `/monitors/${monitorId}/alert-rules/${ruleId}`, {
|
|
107
|
+
body,
|
|
108
|
+
}),
|
|
109
|
+
delete: (monitorId, ruleId) => this.request("DELETE", `/monitors/${monitorId}/alert-rules/${ruleId}`),
|
|
110
|
+
};
|
|
111
|
+
// ── Incidents ─────────────────────────────────────────────────
|
|
112
|
+
incidents = {
|
|
113
|
+
list: (q) => this.request("GET", "/incidents", { query: q }),
|
|
114
|
+
get: (id) => this.request("GET", `/incidents/${id}`),
|
|
115
|
+
acknowledge: (id) => this.request("POST", `/incidents/${id}/acknowledge`),
|
|
116
|
+
resolve: (id) => this.request("POST", `/incidents/${id}/resolve`),
|
|
117
|
+
};
|
|
118
|
+
// ── Maintenance windows ───────────────────────────────────────
|
|
119
|
+
maintenanceWindows = {
|
|
120
|
+
list: (q) => this.request("GET", "/maintenance-windows", { query: q }),
|
|
121
|
+
get: (id) => this.request("GET", `/maintenance-windows/${id}`),
|
|
122
|
+
create: (body, idempotencyKey) => this.request("POST", "/maintenance-windows", { body, idempotencyKey }),
|
|
123
|
+
update: (id, body) => this.request("PATCH", `/maintenance-windows/${id}`, { body }),
|
|
124
|
+
delete: (id) => this.request("DELETE", `/maintenance-windows/${id}`),
|
|
125
|
+
};
|
|
126
|
+
// ── Contacts & groups ─────────────────────────────────────────
|
|
127
|
+
contacts = {
|
|
128
|
+
list: (q) => this.request("GET", "/contacts", { query: q }),
|
|
129
|
+
get: (id) => this.request("GET", `/contacts/${id}`),
|
|
130
|
+
create: (body, idempotencyKey) => this.request("POST", "/contacts", { body, idempotencyKey }),
|
|
131
|
+
update: (id, body) => this.request("PATCH", `/contacts/${id}`, { body }),
|
|
132
|
+
delete: (id) => this.request("DELETE", `/contacts/${id}`),
|
|
133
|
+
};
|
|
134
|
+
contactGroups = {
|
|
135
|
+
list: (q) => this.request("GET", "/contact-groups", { query: q }),
|
|
136
|
+
get: (id) => this.request("GET", `/contact-groups/${id}`),
|
|
137
|
+
create: (body, idempotencyKey) => this.request("POST", "/contact-groups", { body, idempotencyKey }),
|
|
138
|
+
update: (id, body) => this.request("PATCH", `/contact-groups/${id}`, { body }),
|
|
139
|
+
delete: (id) => this.request("DELETE", `/contact-groups/${id}`),
|
|
140
|
+
};
|
|
141
|
+
// ── Observability ─────────────────────────────────────────────
|
|
142
|
+
/** Alerting delivery history — did the Slack/Telegram message go out? */
|
|
143
|
+
notifications(q) {
|
|
144
|
+
return this.request("GET", "/notifications", { query: q });
|
|
145
|
+
}
|
|
146
|
+
/** Org audit trail — who changed what, when. */
|
|
147
|
+
activity(q) {
|
|
148
|
+
return this.request("GET", "/activity", { query: q });
|
|
149
|
+
}
|
|
150
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type ActivityEvent, type AlertRule, type ApiErrorBody, type Check, type Contact, type ContactGroup, type Incident, type IncidentStats, type List, type MaintenanceWindow, type Monitor, type Notification, type Plan, type StatusPage, type Summary, type Uptime, WatchFor, WatchForError, type WatchForOptions, } from "./client.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WatchFor, WatchForError, } from "./client.js";
|