watchfor 0.15.0 → 0.16.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 +9 -0
- package/dist/cli.js +18 -0
- package/dist/client.d.ts +16 -0
- package/dist/client.js +10 -0
- package/dist/index.d.ts +1 -1
- package/dist/schema.d.ts +80 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -138,12 +138,20 @@ belongs to; choose one with `organization` — the SDK sends it as the
|
|
|
138
138
|
`X-WatchFor-Organization` header on every request:
|
|
139
139
|
|
|
140
140
|
```ts
|
|
141
|
+
const wf = new WatchFor({ apiKey: oauthAccessToken });
|
|
142
|
+
const { data } = await wf.organizations.list();
|
|
143
|
+
// [{ id, name, slug, role: "owner", plan: "Pro", is_default: true, is_current: true }, …]
|
|
144
|
+
|
|
141
145
|
const acme = new WatchFor({ apiKey: oauthAccessToken, organization: "<organization-id>" });
|
|
142
146
|
await acme.me(); // { organization: { id, name, slug }, scope }
|
|
143
147
|
const other = acme.withOrganization("<another-organization-id>"); // new client, same token
|
|
144
148
|
await other.monitors.list();
|
|
145
149
|
```
|
|
146
150
|
|
|
151
|
+
- `organizations.list()` returns the ids to use: every organization of the
|
|
152
|
+
token's user with their `role`, `is_default` (used without `organization`)
|
|
153
|
+
and `is_current` (what this client acts on). With an API key it returns just
|
|
154
|
+
the key's own organization (`role: null`).
|
|
147
155
|
- Without `organization`, an OAuth token acts on the user's oldest owned
|
|
148
156
|
organization (else their oldest membership).
|
|
149
157
|
- The user must be a member of that organization (otherwise `403
|
|
@@ -174,6 +182,7 @@ npx watchfor monitors example.com
|
|
|
174
182
|
npx watchfor checks <monitor-id> --failed # add --cursor <next_cursor> for older pages
|
|
175
183
|
npx watchfor report --period 30d
|
|
176
184
|
npx watchfor me # which organization + scope
|
|
185
|
+
npx watchfor organizations # ids for --organization
|
|
177
186
|
|
|
178
187
|
# OAuth token: pick the organization per call or via the environment
|
|
179
188
|
export WATCHFOR_API_KEY=<oauth-access-token>
|
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,7 @@ import { WatchFor, WatchForError } from "./client.js";
|
|
|
8
8
|
* watchfor incidents --status firing
|
|
9
9
|
* watchfor monitors [search]
|
|
10
10
|
* watchfor checks <monitor-id> --failed
|
|
11
|
+
* watchfor organizations (ids for --organization)
|
|
11
12
|
* watchfor --organization <org-id> monitors (OAuth tokens)
|
|
12
13
|
*/
|
|
13
14
|
const HELP = `watchfor — WatchFor monitoring CLI (https://watchfor.io)
|
|
@@ -17,6 +18,7 @@ Usage:
|
|
|
17
18
|
|
|
18
19
|
Commands:
|
|
19
20
|
watchfor me Which organization and scope the credential acts with
|
|
21
|
+
watchfor organizations Organizations the credential can act on (ids for --organization)
|
|
20
22
|
watchfor summary Org snapshot: what's up/down right now
|
|
21
23
|
watchfor incidents [--status s] List incidents (firing|acknowledged|resolved)
|
|
22
24
|
watchfor monitors [query] List monitors (optional name/target search)
|
|
@@ -93,6 +95,22 @@ async function main() {
|
|
|
93
95
|
console.log(`organization: ${org ? `${org.name} (${org.id})` : "none"} · scope ${me.scope ?? "?"}`);
|
|
94
96
|
return 0;
|
|
95
97
|
}
|
|
98
|
+
case "organizations":
|
|
99
|
+
case "orgs": {
|
|
100
|
+
const res = await wf.organizations.list();
|
|
101
|
+
for (const o of res.data) {
|
|
102
|
+
const marks = [
|
|
103
|
+
o.is_current ? "current" : "",
|
|
104
|
+
o.is_default ? "default" : "",
|
|
105
|
+
]
|
|
106
|
+
.filter(Boolean)
|
|
107
|
+
.join(", ");
|
|
108
|
+
console.log(`${o.id} ${String(o.role ?? "api key").padEnd(7)} ${String(o.plan).padEnd(10)} ${o.name}${marks ? ` (${marks})` : ""}`);
|
|
109
|
+
}
|
|
110
|
+
if (res.data.length === 0)
|
|
111
|
+
console.log("(no organizations)");
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
96
114
|
case "summary": {
|
|
97
115
|
const s = await wf.summary();
|
|
98
116
|
const m = s.monitors;
|
package/dist/client.d.ts
CHANGED
|
@@ -77,6 +77,13 @@ export type Plan = components["schemas"]["Plan"];
|
|
|
77
77
|
export type Summary = components["schemas"]["Summary"];
|
|
78
78
|
/** The credential's identity: scope + the organization it acts on. */
|
|
79
79
|
export type Me = components["schemas"]["Me"];
|
|
80
|
+
/**
|
|
81
|
+
* An organization the credential can act on (`organizations.list()`):
|
|
82
|
+
* `role` is the token user's membership role (null for an API key),
|
|
83
|
+
* `is_default` marks the one used without `organization`, `is_current` the one
|
|
84
|
+
* the request acted on.
|
|
85
|
+
*/
|
|
86
|
+
export type Organization = components["schemas"]["Organization"];
|
|
80
87
|
/** `batch()` results, in request order: `{ status, body }` per operation. */
|
|
81
88
|
export type BatchResult = components["schemas"]["BatchResult"];
|
|
82
89
|
/** One operation of a `batch()` call — a relative /api/v1 path. */
|
|
@@ -229,6 +236,15 @@ export declare class WatchFor {
|
|
|
229
236
|
locations(): Promise<List<Record<string, unknown>>>;
|
|
230
237
|
/** Every monitor type with its exact alert metrics + config fields. */
|
|
231
238
|
monitorTypes(): Promise<List<Record<string, unknown>>>;
|
|
239
|
+
readonly organizations: {
|
|
240
|
+
/**
|
|
241
|
+
* The organizations this credential can act on — the ids
|
|
242
|
+
* `organization` / `withOrganization()` accept. An OAuth token lists
|
|
243
|
+
* every organization of its user; an API key only its own. Works
|
|
244
|
+
* whatever `organization` is set to (a foreign id is still 403).
|
|
245
|
+
*/
|
|
246
|
+
list: () => Promise<List<Organization>>;
|
|
247
|
+
};
|
|
232
248
|
readonly monitors: {
|
|
233
249
|
list: (q?: {
|
|
234
250
|
q?: string;
|
package/dist/client.js
CHANGED
|
@@ -180,6 +180,16 @@ export class WatchFor {
|
|
|
180
180
|
monitorTypes() {
|
|
181
181
|
return this.request("GET", "/meta/monitor-types");
|
|
182
182
|
}
|
|
183
|
+
// ── Organizations ─────────────────────────────────────────────
|
|
184
|
+
organizations = {
|
|
185
|
+
/**
|
|
186
|
+
* The organizations this credential can act on — the ids
|
|
187
|
+
* `organization` / `withOrganization()` accept. An OAuth token lists
|
|
188
|
+
* every organization of its user; an API key only its own. Works
|
|
189
|
+
* whatever `organization` is set to (a foreign id is still 403).
|
|
190
|
+
*/
|
|
191
|
+
list: () => this.request("GET", "/organizations"),
|
|
192
|
+
};
|
|
183
193
|
// ── Monitors ──────────────────────────────────────────────────
|
|
184
194
|
monitors = {
|
|
185
195
|
list: (q) => this.request("GET", "/monitors", { query: q }),
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type ActivityEvent, type AlertingState, type AlertRule, type Announcement, type AnnouncementCreate, type AnnouncementUpdate, type ApiErrorBody, type BatchOperation, type BatchResult, type BulkResult, type Check, type CheckList, type CheckNowAck, type Contact, type ContactGroup, type Deleted, type DiagnosticCatalog, type DiagnosticCatalogEntry, type DiagnosticReport, type DiagnosticRun, type DiagnosticSlug, type Incident, type IncidentStats, type IntegrityBaseline, type IntegrityBaselineAccept, type IntegrityBaselineAcceptPending, type List, type MaintenanceMarking, type MaintenanceWindow, type Me, type Monitor, type MonitorDetail, type MonitorReset, type Notification, ORGANIZATION_HEADER, type Plan, type PlaywrightRun, type PlaywrightRunSummary, type PlaywrightTestRun, type PlaywrightTestRunAccepted, type PlaywrightTestRunRequest, type ReportFilters, type ResponseTimeBucket, type ScriptVersion, type ScriptVersionSummary, type StatusPage, type StatusPageComponentCreate, type StatusPageCreate, type StatusPageUpdate, type Summary, type Uptime, type Variable, type VariableDeleted, WatchFor, WatchForError, type WatchForGrade, type WatchForOptions, } from "./client.js";
|
|
1
|
+
export { type ActivityEvent, type AlertingState, type AlertRule, type Announcement, type AnnouncementCreate, type AnnouncementUpdate, type ApiErrorBody, type BatchOperation, type BatchResult, type BulkResult, type Check, type CheckList, type CheckNowAck, type Contact, type ContactGroup, type Deleted, type DiagnosticCatalog, type DiagnosticCatalogEntry, type DiagnosticReport, type DiagnosticRun, type DiagnosticSlug, type Incident, type IncidentStats, type IntegrityBaseline, type IntegrityBaselineAccept, type IntegrityBaselineAcceptPending, type List, type MaintenanceMarking, type MaintenanceWindow, type Me, type Monitor, type MonitorDetail, type MonitorReset, type Notification, ORGANIZATION_HEADER, type Organization, type Plan, type PlaywrightRun, type PlaywrightRunSummary, type PlaywrightTestRun, type PlaywrightTestRunAccepted, type PlaywrightTestRunRequest, type ReportFilters, type ResponseTimeBucket, type ScriptVersion, type ScriptVersionSummary, type StatusPage, type StatusPageComponentCreate, type StatusPageCreate, type StatusPageUpdate, type Summary, type Uptime, type Variable, type VariableDeleted, WatchFor, WatchForError, type WatchForGrade, type WatchForOptions, } from "./client.js";
|
package/dist/schema.d.ts
CHANGED
|
@@ -227,6 +227,26 @@ export interface paths {
|
|
|
227
227
|
patch?: never;
|
|
228
228
|
trace?: never;
|
|
229
229
|
};
|
|
230
|
+
"/organizations": {
|
|
231
|
+
parameters: {
|
|
232
|
+
query?: never;
|
|
233
|
+
header?: never;
|
|
234
|
+
path?: never;
|
|
235
|
+
cookie?: never;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* List the organizations this credential can act on
|
|
239
|
+
* @description OAuth token: every organization the token's user belongs to (oldest membership first, up to 500), with their role in each — send an id as X-WatchFor-Organization to act on it. `is_default` marks the organization used without the header, `is_current` the one this request acted on. API key: exactly its own organization (role null). AI Agent token: only the organization it was issued for. Works without the header and is not plan-gated, so a client can always discover the ids; a header naming an organization the user doesn't belong to is still 403. Not paginated (has_more is always false).
|
|
240
|
+
*/
|
|
241
|
+
get: operations["listOrganizations"];
|
|
242
|
+
put?: never;
|
|
243
|
+
post?: never;
|
|
244
|
+
delete?: never;
|
|
245
|
+
options?: never;
|
|
246
|
+
head?: never;
|
|
247
|
+
patch?: never;
|
|
248
|
+
trace?: never;
|
|
249
|
+
};
|
|
230
250
|
"/openapi.json": {
|
|
231
251
|
parameters: {
|
|
232
252
|
query?: never;
|
|
@@ -2842,6 +2862,31 @@ export interface components {
|
|
|
2842
2862
|
/** @enum {string} */
|
|
2843
2863
|
scope?: "read" | "write";
|
|
2844
2864
|
};
|
|
2865
|
+
/** @description An organization the credential can act on. Send its id as X-WatchFor-Organization to act on it with an OAuth token. */
|
|
2866
|
+
Organization: {
|
|
2867
|
+
/** Format: uuid */
|
|
2868
|
+
id: string;
|
|
2869
|
+
/** @constant */
|
|
2870
|
+
object: "organization";
|
|
2871
|
+
name: string;
|
|
2872
|
+
slug: string | null;
|
|
2873
|
+
/**
|
|
2874
|
+
* Format: uri
|
|
2875
|
+
* @description Absolute URL of the organization's logo, or null.
|
|
2876
|
+
*/
|
|
2877
|
+
logo: string | null;
|
|
2878
|
+
/**
|
|
2879
|
+
* @description The token user's membership role there (decides what they may change, as in the dashboard). null for an API key, which acts for its organization without being a member.
|
|
2880
|
+
* @enum {string|null}
|
|
2881
|
+
*/
|
|
2882
|
+
role: "owner" | "admin" | "member" | null;
|
|
2883
|
+
/** @description Name of the organization's current plan. */
|
|
2884
|
+
plan: string;
|
|
2885
|
+
/** @description The organization requests act on when X-WatchFor-Organization is omitted (OAuth: the user's oldest owned organization, else their oldest membership). Always true for an API key's own organization. */
|
|
2886
|
+
is_default: boolean;
|
|
2887
|
+
/** @description The organization THIS request acted on — the one X-WatchFor-Organization named, else the default. */
|
|
2888
|
+
is_current: boolean;
|
|
2889
|
+
};
|
|
2845
2890
|
MonitorType: {
|
|
2846
2891
|
/** @constant */
|
|
2847
2892
|
object?: "monitor_type";
|
|
@@ -3128,6 +3173,12 @@ export interface components {
|
|
|
3128
3173
|
/** @description Names checks read that no variable defines */
|
|
3129
3174
|
undefined_refs?: string[];
|
|
3130
3175
|
};
|
|
3176
|
+
OrganizationList: {
|
|
3177
|
+
/** @constant */
|
|
3178
|
+
object: "list";
|
|
3179
|
+
data: components["schemas"]["Organization"][];
|
|
3180
|
+
has_more: boolean;
|
|
3181
|
+
};
|
|
3131
3182
|
MonitorTypeList: {
|
|
3132
3183
|
/** @constant */
|
|
3133
3184
|
object: "list";
|
|
@@ -3894,6 +3945,35 @@ export interface operations {
|
|
|
3894
3945
|
};
|
|
3895
3946
|
};
|
|
3896
3947
|
};
|
|
3948
|
+
listOrganizations: {
|
|
3949
|
+
parameters: {
|
|
3950
|
+
query?: never;
|
|
3951
|
+
header?: never;
|
|
3952
|
+
path?: never;
|
|
3953
|
+
cookie?: never;
|
|
3954
|
+
};
|
|
3955
|
+
requestBody?: never;
|
|
3956
|
+
responses: {
|
|
3957
|
+
/** @description OK */
|
|
3958
|
+
200: {
|
|
3959
|
+
headers: {
|
|
3960
|
+
[name: string]: unknown;
|
|
3961
|
+
};
|
|
3962
|
+
content: {
|
|
3963
|
+
"application/json": components["schemas"]["OrganizationList"];
|
|
3964
|
+
};
|
|
3965
|
+
};
|
|
3966
|
+
/** @description Error */
|
|
3967
|
+
default: {
|
|
3968
|
+
headers: {
|
|
3969
|
+
[name: string]: unknown;
|
|
3970
|
+
};
|
|
3971
|
+
content: {
|
|
3972
|
+
"application/json": components["schemas"]["Error"];
|
|
3973
|
+
};
|
|
3974
|
+
};
|
|
3975
|
+
};
|
|
3976
|
+
};
|
|
3897
3977
|
getOpenApiSpec: {
|
|
3898
3978
|
parameters: {
|
|
3899
3979
|
query?: never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "watchfor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Official TypeScript SDK + CLI for WatchFor — uptime & infrastructure monitoring (monitors, alert rules, incidents, maintenance windows) over the REST API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"watchfor",
|