@openstatus/sdk-node 0.0.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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +412 -0
  3. package/esm/gen/buf/validate/validate_pb.d.ts +4766 -0
  4. package/esm/gen/buf/validate/validate_pb.d.ts.map +1 -0
  5. package/esm/gen/buf/validate/validate_pb.js +361 -0
  6. package/esm/gen/openstatus/health/v1/health_pb.d.ts +89 -0
  7. package/esm/gen/openstatus/health/v1/health_pb.d.ts.map +1 -0
  8. package/esm/gen/openstatus/health/v1/health_pb.js +54 -0
  9. package/esm/gen/openstatus/monitor/v1/assertions_pb.d.ts +240 -0
  10. package/esm/gen/openstatus/monitor/v1/assertions_pb.d.ts.map +1 -0
  11. package/esm/gen/openstatus/monitor/v1/assertions_pb.js +157 -0
  12. package/esm/gen/openstatus/monitor/v1/dns_monitor_pb.d.ts +106 -0
  13. package/esm/gen/openstatus/monitor/v1/dns_monitor_pb.d.ts.map +1 -0
  14. package/esm/gen/openstatus/monitor/v1/dns_monitor_pb.js +22 -0
  15. package/esm/gen/openstatus/monitor/v1/http_monitor_pb.d.ts +236 -0
  16. package/esm/gen/openstatus/monitor/v1/http_monitor_pb.d.ts.map +1 -0
  17. package/esm/gen/openstatus/monitor/v1/http_monitor_pb.js +82 -0
  18. package/esm/gen/openstatus/monitor/v1/monitor_pb.d.ts +269 -0
  19. package/esm/gen/openstatus/monitor/v1/monitor_pb.d.ts.map +1 -0
  20. package/esm/gen/openstatus/monitor/v1/monitor_pb.js +274 -0
  21. package/esm/gen/openstatus/monitor/v1/service_pb.d.ts +602 -0
  22. package/esm/gen/openstatus/monitor/v1/service_pb.d.ts.map +1 -0
  23. package/esm/gen/openstatus/monitor/v1/service_pb.js +151 -0
  24. package/esm/gen/openstatus/monitor/v1/tcp_monitor_pb.d.ts +99 -0
  25. package/esm/gen/openstatus/monitor/v1/tcp_monitor_pb.d.ts.map +1 -0
  26. package/esm/gen/openstatus/monitor/v1/tcp_monitor_pb.js +20 -0
  27. package/esm/mod.d.ts +107 -0
  28. package/esm/mod.d.ts.map +1 -0
  29. package/esm/mod.js +82 -0
  30. package/esm/package.json +3 -0
  31. package/package.json +34 -0
  32. package/script/gen/buf/validate/validate_pb.d.ts +4766 -0
  33. package/script/gen/buf/validate/validate_pb.d.ts.map +1 -0
  34. package/script/gen/buf/validate/validate_pb.js +364 -0
  35. package/script/gen/openstatus/health/v1/health_pb.d.ts +89 -0
  36. package/script/gen/openstatus/health/v1/health_pb.d.ts.map +1 -0
  37. package/script/gen/openstatus/health/v1/health_pb.js +57 -0
  38. package/script/gen/openstatus/monitor/v1/assertions_pb.d.ts +240 -0
  39. package/script/gen/openstatus/monitor/v1/assertions_pb.d.ts.map +1 -0
  40. package/script/gen/openstatus/monitor/v1/assertions_pb.js +160 -0
  41. package/script/gen/openstatus/monitor/v1/dns_monitor_pb.d.ts +106 -0
  42. package/script/gen/openstatus/monitor/v1/dns_monitor_pb.d.ts.map +1 -0
  43. package/script/gen/openstatus/monitor/v1/dns_monitor_pb.js +25 -0
  44. package/script/gen/openstatus/monitor/v1/http_monitor_pb.d.ts +236 -0
  45. package/script/gen/openstatus/monitor/v1/http_monitor_pb.d.ts.map +1 -0
  46. package/script/gen/openstatus/monitor/v1/http_monitor_pb.js +85 -0
  47. package/script/gen/openstatus/monitor/v1/monitor_pb.d.ts +269 -0
  48. package/script/gen/openstatus/monitor/v1/monitor_pb.d.ts.map +1 -0
  49. package/script/gen/openstatus/monitor/v1/monitor_pb.js +277 -0
  50. package/script/gen/openstatus/monitor/v1/service_pb.d.ts +602 -0
  51. package/script/gen/openstatus/monitor/v1/service_pb.d.ts.map +1 -0
  52. package/script/gen/openstatus/monitor/v1/service_pb.js +154 -0
  53. package/script/gen/openstatus/monitor/v1/tcp_monitor_pb.d.ts +99 -0
  54. package/script/gen/openstatus/monitor/v1/tcp_monitor_pb.d.ts.map +1 -0
  55. package/script/gen/openstatus/monitor/v1/tcp_monitor_pb.js +23 -0
  56. package/script/mod.d.ts +107 -0
  57. package/script/mod.d.ts.map +1 -0
  58. package/script/mod.js +91 -0
  59. package/script/package.json +3 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Openstatus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,412 @@
1
+ # OpenStatus Node.js SDK
2
+
3
+ [![JSR](https://jsr.io/badges/@openstatus/node-sdk)](https://jsr.io/@openstatus/node-sdk)
4
+ [![npm](https://img.shields.io/npm/v/@openstatus/node-sdk)](https://www.npmjs.com/package/@openstatus/node-sdk)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ Official Node.js SDK for [OpenStatus](https://openstatus.dev) - the open-source
8
+ monitoring platform.
9
+
10
+ ## Features
11
+
12
+ - **HTTP Monitoring** - Monitor websites and APIs with customizable assertions
13
+ - **TCP Monitoring** - Check database connections and other TCP services
14
+ - **DNS Monitoring** - Verify DNS records and resolution
15
+ - **Global Regions** - Monitor from 28 locations worldwide
16
+ - **Type-safe** - Full TypeScript support with generated types
17
+
18
+ ## Installation
19
+
20
+ ### JSR
21
+
22
+ ```bash
23
+ npx jsr add @openstatus/node-sdk
24
+ ```
25
+
26
+ ### npm
27
+
28
+ ```bash
29
+ npm install @openstatus/node-sdk
30
+ ```
31
+
32
+ ### Deno
33
+
34
+ ```typescript
35
+ import { openstatus } from "jsr:@openstatus/node-sdk";
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ```typescript
41
+ import { openstatus } from "@openstatus/node-sdk";
42
+
43
+ const headers = {
44
+ "x-openstatus-key": `Bearer ${process.env.OPENSTATUS_API_KEY}`,
45
+ };
46
+
47
+ // Create a monitor
48
+ const monitor = await openstatus.monitor.v1.MonitorService.createHTTPMonitor(
49
+ {
50
+ name: "My API",
51
+ url: "https://api.example.com/health",
52
+ periodicity: "1m",
53
+ method: "GET",
54
+ regions: ["ams", "iad", "syd"],
55
+ active: true,
56
+ statusCodeAssertions: [{ comparator: "EQUAL", target: 200 }],
57
+ },
58
+ { headers },
59
+ );
60
+
61
+ console.log(`Monitor created: ${monitor.monitor?.id}`);
62
+
63
+ // List all monitors
64
+ const { httpMonitors, tcpMonitors, dnsMonitors, totalSize } =
65
+ await openstatus.monitor.v1.MonitorService.listMonitors({}, { headers });
66
+
67
+ console.log(`Found ${totalSize} monitors`);
68
+ ```
69
+
70
+ ## Authentication
71
+
72
+ All API requests require an API key. Get yours from the
73
+ [OpenStatus dashboard](https://www.openstatus.dev/app).
74
+
75
+ ```typescript
76
+ const headers = {
77
+ "x-openstatus-key": `Bearer ${process.env.OPENSTATUS_API_KEY}`,
78
+ };
79
+
80
+ // Pass headers to any service method
81
+ await openstatus.monitor.v1.MonitorService.listMonitors({}, { headers });
82
+ ```
83
+
84
+ ## Environment Variables
85
+
86
+ | Variable | Description | Default |
87
+ | -------------------- | ----------------------- | -------------------------------- |
88
+ | `OPENSTATUS_API_KEY` | Your OpenStatus API key | - |
89
+ | `OPENSTATUS_API_URL` | Custom API endpoint | `https://api.openstatus.dev/rpc` |
90
+
91
+ ## API Reference
92
+
93
+ ### Monitor Service
94
+
95
+ #### `createHTTPMonitor(request, options)`
96
+
97
+ Create an HTTP/HTTPS monitor.
98
+
99
+ ```typescript
100
+ const { monitor } = await openstatus.monitor.v1.MonitorService
101
+ .createHTTPMonitor(
102
+ {
103
+ name: "My Website",
104
+ url: "https://example.com",
105
+ periodicity: "1m",
106
+ method: "GET",
107
+ regions: ["ams", "iad", "syd"],
108
+ active: true,
109
+ },
110
+ { headers },
111
+ );
112
+ ```
113
+
114
+ #### `createTCPMonitor(request, options)`
115
+
116
+ Create a TCP connection monitor.
117
+
118
+ ```typescript
119
+ const { monitor } = await openstatus.monitor.v1.MonitorService.createTCPMonitor(
120
+ {
121
+ name: "Database",
122
+ uri: "db.example.com:5432",
123
+ periodicity: "5m",
124
+ regions: ["ams", "iad"],
125
+ active: true,
126
+ },
127
+ { headers },
128
+ );
129
+ ```
130
+
131
+ #### `createDNSMonitor(request, options)`
132
+
133
+ Create a DNS resolution monitor.
134
+
135
+ ```typescript
136
+ const { monitor } = await openstatus.monitor.v1.MonitorService.createDNSMonitor(
137
+ {
138
+ name: "DNS Check",
139
+ uri: "example.com",
140
+ periodicity: "10m",
141
+ regions: ["ams"],
142
+ active: true,
143
+ recordAssertions: [{
144
+ recordType: "A",
145
+ comparator: "EQUAL",
146
+ target: "93.184.216.34",
147
+ }],
148
+ },
149
+ { headers },
150
+ );
151
+ ```
152
+
153
+ #### `listMonitors(request, options)`
154
+
155
+ List all monitors with pagination. Returns monitors grouped by type.
156
+
157
+ ```typescript
158
+ const { httpMonitors, tcpMonitors, dnsMonitors, nextPageToken, totalSize } =
159
+ await openstatus.monitor.v1.MonitorService.listMonitors(
160
+ { pageSize: 10, pageToken: "" },
161
+ { headers },
162
+ );
163
+ ```
164
+
165
+ #### `triggerMonitor(request, options)`
166
+
167
+ Trigger an immediate check.
168
+
169
+ ```typescript
170
+ await openstatus.monitor.v1.MonitorService.triggerMonitor(
171
+ { id: "mon_123" },
172
+ { headers },
173
+ );
174
+ ```
175
+
176
+ #### `deleteMonitor(request, options)`
177
+
178
+ Delete a monitor.
179
+
180
+ ```typescript
181
+ await openstatus.monitor.v1.MonitorService.deleteMonitor(
182
+ { id: "mon_123" },
183
+ { headers },
184
+ );
185
+ ```
186
+
187
+ #### `getMonitorStatus(request, options)`
188
+
189
+ Get the current status of a monitor across all configured regions.
190
+
191
+ ```typescript
192
+ const { id, regions } =
193
+ await openstatus.monitor.v1.MonitorService.getMonitorStatus(
194
+ { id: "mon_123" },
195
+ { headers },
196
+ );
197
+
198
+ // regions is an array of { region, status }
199
+ // status: ACTIVE, DEGRADED, or ERROR
200
+ for (const { region, status } of regions) {
201
+ console.log(`${region}: ${status}`);
202
+ }
203
+ ```
204
+
205
+ #### `getMonitorSummary(request, options)`
206
+
207
+ Get aggregated metrics and latency percentiles for a monitor.
208
+
209
+ ```typescript
210
+ import { TimeRange } from "@openstatus/node-sdk";
211
+
212
+ const summary = await openstatus.monitor.v1.MonitorService.getMonitorSummary(
213
+ {
214
+ id: "mon_123",
215
+ timeRange: TimeRange.TIME_RANGE_7D, // 1D, 7D, or 14D
216
+ regions: [], // optional: filter by specific regions
217
+ },
218
+ { headers },
219
+ );
220
+
221
+ console.log(`Last ping: ${summary.lastPingAt}`);
222
+ console.log(`Success: ${summary.totalSuccessful}`);
223
+ console.log(`Degraded: ${summary.totalDegraded}`);
224
+ console.log(`Failed: ${summary.totalFailed}`);
225
+ console.log(`P50 latency: ${summary.p50}ms`);
226
+ console.log(`P95 latency: ${summary.p95}ms`);
227
+ console.log(`P99 latency: ${summary.p99}ms`);
228
+ ```
229
+
230
+ ### Health Service
231
+
232
+ Check API health status (no authentication required).
233
+
234
+ ```typescript
235
+ const { status } = await openstatus.health.v1.HealthService.check({});
236
+ console.log(status); // "SERVING"
237
+ ```
238
+
239
+ ## Monitor Options
240
+
241
+ ### HTTP Monitor
242
+
243
+ | Option | Type | Required | Description |
244
+ | ---------------------- | -------- | -------- | ------------------------------------------------- |
245
+ | `name` | string | Yes | Monitor name (max 256 chars) |
246
+ | `url` | string | Yes | URL to monitor |
247
+ | `periodicity` | string | No | `30s`, `1m`, `5m`, `10m`, `30m`, `1h` |
248
+ | `method` | string | No | `GET`, `POST`, `HEAD`, `PUT`, `PATCH`, `DELETE` |
249
+ | `body` | string | No | Request body |
250
+ | `headers` | object | No | Custom headers |
251
+ | `timeout` | number | No | Timeout in ms (default: 45000, max: 120000) |
252
+ | `retry` | number | No | Retry attempts (default: 3, max: 10) |
253
+ | `followRedirects` | boolean | No | Follow redirects (default: true) |
254
+ | `regions` | string[] | No | [Regions](#regions) for checks |
255
+ | `active` | boolean | No | Enable monitoring (default: false) |
256
+ | `public` | boolean | No | Public visibility (default: false) |
257
+ | `degradedAt` | number | No | Latency threshold (ms) for degraded status |
258
+ | `statusCodeAssertions` | array | No | [Status code assertions](#status-code-assertions) |
259
+ | `bodyAssertions` | array | No | [Body assertions](#body-assertions) |
260
+ | `headerAssertions` | array | No | [Header assertions](#header-assertions) |
261
+
262
+ ### TCP Monitor
263
+
264
+ | Option | Type | Required | Description |
265
+ | ------------- | -------- | -------- | ------------------------------ |
266
+ | `name` | string | Yes | Monitor name |
267
+ | `uri` | string | Yes | `host:port` to monitor |
268
+ | `periodicity` | string | No | Check interval |
269
+ | `timeout` | number | No | Timeout in ms (default: 45000) |
270
+ | `retry` | number | No | Retry attempts (default: 3) |
271
+ | `regions` | string[] | No | [Regions](#regions) for checks |
272
+ | `active` | boolean | No | Enable monitoring |
273
+
274
+ ### DNS Monitor
275
+
276
+ | Option | Type | Required | Description |
277
+ | ------------------ | -------- | -------- | ----------------------------------------------- |
278
+ | `name` | string | Yes | Monitor name |
279
+ | `uri` | string | Yes | Domain to resolve |
280
+ | `periodicity` | string | No | Check interval |
281
+ | `timeout` | number | No | Timeout in ms (default: 45000) |
282
+ | `retry` | number | No | Retry attempts (default: 3) |
283
+ | `regions` | string[] | No | [Regions](#regions) for checks |
284
+ | `recordAssertions` | array | No | [DNS record assertions](#dns-record-assertions) |
285
+
286
+ ## Assertions
287
+
288
+ ### Status Code Assertions
289
+
290
+ Validate HTTP response status codes.
291
+
292
+ ```typescript
293
+ {
294
+ statusCodeAssertions: [
295
+ { comparator: "EQUAL", target: 200 },
296
+ { comparator: "LESS_THAN", target: 400 },
297
+ ];
298
+ }
299
+ ```
300
+
301
+ **Comparators:** `EQUAL`, `NOT_EQUAL`, `GREATER_THAN`, `GREATER_THAN_OR_EQUAL`,
302
+ `LESS_THAN`, `LESS_THAN_OR_EQUAL`
303
+
304
+ ### Body Assertions
305
+
306
+ Validate response body content.
307
+
308
+ ```typescript
309
+ {
310
+ bodyAssertions: [
311
+ { comparator: "CONTAINS", target: '"status":"ok"' },
312
+ { comparator: "NOT_EMPTY" },
313
+ ];
314
+ }
315
+ ```
316
+
317
+ **Comparators:** `CONTAINS`, `NOT_CONTAINS`, `EQUAL`, `NOT_EQUAL`, `EMPTY`,
318
+ `NOT_EMPTY`
319
+
320
+ ### Header Assertions
321
+
322
+ Validate response headers.
323
+
324
+ ```typescript
325
+ {
326
+ headerAssertions: [
327
+ { key: "content-type", comparator: "CONTAINS", target: "application/json" },
328
+ ];
329
+ }
330
+ ```
331
+
332
+ ### DNS Record Assertions
333
+
334
+ Validate DNS records.
335
+
336
+ ```typescript
337
+ {
338
+ recordAssertions: [
339
+ { recordType: "A", comparator: "EQUAL", target: "93.184.216.34" },
340
+ { recordType: "CNAME", comparator: "CONTAINS", target: "cdn" },
341
+ ];
342
+ }
343
+ ```
344
+
345
+ **Record types:** `A`, `AAAA`, `CNAME`, `MX`, `TXT`
346
+
347
+ ## Regions
348
+
349
+ Monitor from 28 global locations across multiple providers:
350
+
351
+ ### Fly.io Regions
352
+
353
+ | Code | Location | Code | Location |
354
+ | ----- | --------------- | ----- | ------------ |
355
+ | `ams` | Amsterdam | `lax` | Los Angeles |
356
+ | `arn` | Stockholm | `lhr` | London |
357
+ | `bom` | Mumbai | `nrt` | Tokyo |
358
+ | `cdg` | Paris | `ord` | Chicago |
359
+ | `dfw` | Dallas | `sjc` | San Jose |
360
+ | `ewr` | Newark | `sin` | Singapore |
361
+ | `fra` | Frankfurt | `syd` | Sydney |
362
+ | `gru` | São Paulo | `yyz` | Toronto |
363
+ | `iad` | Washington D.C. | `jnb` | Johannesburg |
364
+
365
+ ### Koyeb Regions
366
+
367
+ | Code | Location |
368
+ | ----------- | ------------- |
369
+ | `koyeb_fra` | Frankfurt |
370
+ | `koyeb_par` | Paris |
371
+ | `koyeb_sfo` | San Francisco |
372
+ | `koyeb_sin` | Singapore |
373
+ | `koyeb_tyo` | Tokyo |
374
+ | `koyeb_was` | Washington |
375
+
376
+ ### Railway Regions
377
+
378
+ | Code | Location |
379
+ | ----------------------- | -------------- |
380
+ | `railway_us_west2` | US West |
381
+ | `railway_us_east4` | US East |
382
+ | `railway_europe_west4` | Europe West |
383
+ | `railway_asia_southeast1` | Asia Southeast |
384
+
385
+ ## Error Handling
386
+
387
+ The SDK uses Connect RPC. Errors include a `code` and `message`:
388
+
389
+ ```typescript
390
+ import { ConnectError } from "@connectrpc/connect";
391
+
392
+ try {
393
+ await openstatus.monitor.v1.MonitorService.deleteMonitor(
394
+ { id: "invalid" },
395
+ { headers },
396
+ );
397
+ } catch (error) {
398
+ if (error instanceof ConnectError) {
399
+ console.error(`Error ${error.code}: ${error.message}`);
400
+ }
401
+ }
402
+ ```
403
+
404
+ ## Related
405
+
406
+ - [OpenStatus](https://openstatus.dev) - Open-source monitoring platform
407
+ - [Documentation](https://docs.openstatus.dev) - Full API documentation
408
+ - [Status Page](https://status.openstatus.dev) - OpenStatus service status
409
+
410
+ ## License
411
+
412
+ MIT