Skip to content

Commit c00aa42

Browse files
Status page (#6)
* fix gh action * add status page
1 parent 15bb1d9 commit c00aa42

6 files changed

Lines changed: 2438 additions & 10 deletions

File tree

README.md

Lines changed: 345 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@
44
[![npm](https://img.shields.io/npm/v/@openstatus/sdk-node)](https://www.npmjs.com/package/@openstatus/sdk-node)
55
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
66

7-
Official Node.js SDK for [OpenStatus](https://openstatus.dev) - The open-source status page with uptime monitoring.
7+
Official Node.js SDK for [OpenStatus](https://openstatus.dev) - The open-source
8+
status page with uptime monitoring.
89

910
## Features
1011

1112
### Status Page
12-
- **Status Reports** - Manage incident and maintenance reports with update timelines
13+
14+
- **Status Pages** - Create and manage public status pages with custom domains
15+
- **Page Components** - Add monitor-based or static components with grouping
16+
- **Subscribers** - Manage email subscriptions for status updates
17+
- **Status Reports** - Manage incident and maintenance reports with update
18+
timelines
1319

1420
### Monitoring
21+
1522
- **HTTP Monitoring** - Monitor websites and APIs with customizable assertions
1623
- **TCP Monitoring** - Check database connections and other TCP services
1724
- **DNS Monitoring** - Verify DNS records and resolution
@@ -380,7 +387,10 @@ const { statusReports, totalSize } = await openstatus.statusReport.v1
380387
{
381388
limit: 10,
382389
offset: 0,
383-
statuses: [StatusReportStatus.INVESTIGATING, StatusReportStatus.IDENTIFIED],
390+
statuses: [
391+
StatusReportStatus.INVESTIGATING,
392+
StatusReportStatus.IDENTIFIED,
393+
],
384394
},
385395
{ headers },
386396
);
@@ -428,7 +438,8 @@ const { statusReport } = await openstatus.statusReport.v1.StatusReportService
428438
{
429439
statusReportId: "sr_123",
430440
status: StatusReportStatus.IDENTIFIED,
431-
message: "The issue has been identified as a database connection problem.",
441+
message:
442+
"The issue has been identified as a database connection problem.",
432443
date: "2024-01-15T11:00:00", // optional, defaults to current time
433444
notify: true,
434445
},
@@ -438,13 +449,337 @@ const { statusReport } = await openstatus.statusReport.v1.StatusReportService
438449

439450
### Status Report Status
440451

441-
| Enum Value | Description |
442-
| --------------- | ------------------------------- |
443-
| `UNSPECIFIED` | Default/unspecified status |
452+
| Enum Value | Description |
453+
| --------------- | -------------------------------- |
454+
| `UNSPECIFIED` | Default/unspecified status |
444455
| `INVESTIGATING` | Actively investigating the issue |
445-
| `IDENTIFIED` | Root cause has been identified |
446-
| `MONITORING` | Fix deployed, monitoring |
447-
| `RESOLVED` | Issue fully resolved |
456+
| `IDENTIFIED` | Root cause has been identified |
457+
| `MONITORING` | Fix deployed, monitoring |
458+
| `RESOLVED` | Issue fully resolved |
459+
460+
### Status Page Service
461+
462+
Manage status pages, components, and subscribers.
463+
464+
#### `createStatusPage(request, options)`
465+
466+
Create a new status page.
467+
468+
```typescript
469+
const { statusPage } = await openstatus.statusPage.v1.StatusPageService
470+
.createStatusPage(
471+
{
472+
title: "My Service Status",
473+
slug: "my-service",
474+
description: "Status page for My Service",
475+
homepageUrl: "https://example.com",
476+
contactUrl: "https://example.com/contact",
477+
},
478+
{ headers },
479+
);
480+
481+
console.log(`Status page created: ${statusPage?.id}`);
482+
```
483+
484+
#### `getStatusPage(request, options)`
485+
486+
Get a status page by ID.
487+
488+
```typescript
489+
const { statusPage } = await openstatus.statusPage.v1.StatusPageService
490+
.getStatusPage(
491+
{ id: "page_123" },
492+
{ headers },
493+
);
494+
```
495+
496+
#### `listStatusPages(request, options)`
497+
498+
List all status pages with pagination.
499+
500+
```typescript
501+
const { statusPages, totalSize } = await openstatus.statusPage.v1
502+
.StatusPageService.listStatusPages(
503+
{ limit: 10, offset: 0 },
504+
{ headers },
505+
);
506+
507+
console.log(`Found ${totalSize} status pages`);
508+
```
509+
510+
#### `updateStatusPage(request, options)`
511+
512+
Update a status page.
513+
514+
```typescript
515+
const { statusPage } = await openstatus.statusPage.v1.StatusPageService
516+
.updateStatusPage(
517+
{
518+
id: "page_123",
519+
title: "Updated Title",
520+
description: "Updated description",
521+
},
522+
{ headers },
523+
);
524+
```
525+
526+
#### `deleteStatusPage(request, options)`
527+
528+
Delete a status page.
529+
530+
```typescript
531+
const { success } = await openstatus.statusPage.v1.StatusPageService
532+
.deleteStatusPage(
533+
{ id: "page_123" },
534+
{ headers },
535+
);
536+
```
537+
538+
#### `addMonitorComponent(request, options)`
539+
540+
Add a monitor-based component to a status page.
541+
542+
```typescript
543+
const { component } = await openstatus.statusPage.v1.StatusPageService
544+
.addMonitorComponent(
545+
{
546+
pageId: "page_123",
547+
monitorId: "mon_456",
548+
name: "API Server",
549+
description: "Main API endpoint",
550+
order: 1,
551+
},
552+
{ headers },
553+
);
554+
```
555+
556+
#### `addStaticComponent(request, options)`
557+
558+
Add a static component (not linked to a monitor).
559+
560+
```typescript
561+
const { component } = await openstatus.statusPage.v1.StatusPageService
562+
.addStaticComponent(
563+
{
564+
pageId: "page_123",
565+
name: "Third-party Service",
566+
description: "External dependency",
567+
order: 2,
568+
},
569+
{ headers },
570+
);
571+
```
572+
573+
#### `updateComponent(request, options)`
574+
575+
Update a component.
576+
577+
```typescript
578+
const { component } = await openstatus.statusPage.v1.StatusPageService
579+
.updateComponent(
580+
{
581+
id: "comp_123",
582+
name: "Updated Component Name",
583+
order: 3,
584+
},
585+
{ headers },
586+
);
587+
```
588+
589+
#### `removeComponent(request, options)`
590+
591+
Remove a component from a status page.
592+
593+
```typescript
594+
const { success } = await openstatus.statusPage.v1.StatusPageService
595+
.removeComponent(
596+
{ id: "comp_123" },
597+
{ headers },
598+
);
599+
```
600+
601+
#### `createComponentGroup(request, options)`
602+
603+
Create a component group.
604+
605+
```typescript
606+
const { group } = await openstatus.statusPage.v1.StatusPageService
607+
.createComponentGroup(
608+
{
609+
pageId: "page_123",
610+
name: "Core Services",
611+
},
612+
{ headers },
613+
);
614+
```
615+
616+
#### `updateComponentGroup(request, options)`
617+
618+
Update a component group.
619+
620+
```typescript
621+
const { group } = await openstatus.statusPage.v1.StatusPageService
622+
.updateComponentGroup(
623+
{
624+
id: "group_123",
625+
name: "Updated Group Name",
626+
},
627+
{ headers },
628+
);
629+
```
630+
631+
#### `deleteComponentGroup(request, options)`
632+
633+
Delete a component group.
634+
635+
```typescript
636+
const { success } = await openstatus.statusPage.v1.StatusPageService
637+
.deleteComponentGroup(
638+
{ id: "group_123" },
639+
{ headers },
640+
);
641+
```
642+
643+
#### `subscribeToPage(request, options)`
644+
645+
Subscribe an email to status page updates.
646+
647+
```typescript
648+
const { subscriber } = await openstatus.statusPage.v1.StatusPageService
649+
.subscribeToPage(
650+
{
651+
pageId: "page_123",
652+
email: "user@example.com",
653+
},
654+
{ headers },
655+
);
656+
```
657+
658+
#### `unsubscribeFromPage(request, options)`
659+
660+
Unsubscribe from a status page.
661+
662+
```typescript
663+
// By email
664+
const { success } = await openstatus.statusPage.v1.StatusPageService
665+
.unsubscribeFromPage(
666+
{
667+
pageId: "page_123",
668+
identifier: { case: "email", value: "user@example.com" },
669+
},
670+
{ headers },
671+
);
672+
673+
// Or by subscriber ID
674+
const { success: success2 } = await openstatus.statusPage.v1.StatusPageService
675+
.unsubscribeFromPage(
676+
{
677+
pageId: "page_123",
678+
identifier: { case: "id", value: "sub_456" },
679+
},
680+
{ headers },
681+
);
682+
```
683+
684+
#### `listSubscribers(request, options)`
685+
686+
List all subscribers for a status page.
687+
688+
```typescript
689+
const { subscribers, totalSize } = await openstatus.statusPage.v1
690+
.StatusPageService.listSubscribers(
691+
{
692+
pageId: "page_123",
693+
limit: 50,
694+
offset: 0,
695+
includeUnsubscribed: false,
696+
},
697+
{ headers },
698+
);
699+
```
700+
701+
#### `getStatusPageContent(request, options)`
702+
703+
Get full status page content including components, groups, and active reports.
704+
705+
```typescript
706+
const content = await openstatus.statusPage.v1.StatusPageService
707+
.getStatusPageContent(
708+
{ identifier: { case: "slug", value: "my-service" } },
709+
{ headers },
710+
);
711+
712+
console.log(`Page: ${content.statusPage?.title}`);
713+
console.log(`Components: ${content.components.length}`);
714+
console.log(`Active reports: ${content.statusReports.length}`);
715+
```
716+
717+
#### `getOverallStatus(request, options)`
718+
719+
Get the aggregated status of a status page.
720+
721+
```typescript
722+
import { OverallStatus } from "@openstatus/sdk-node";
723+
724+
const { overallStatus, componentStatuses } = await openstatus.statusPage.v1
725+
.StatusPageService.getOverallStatus(
726+
{ identifier: { case: "id", value: "page_123" } },
727+
{ headers },
728+
);
729+
730+
console.log(`Overall: ${OverallStatus[overallStatus]}`);
731+
for (const { componentId, status } of componentStatuses) {
732+
console.log(` ${componentId}: ${OverallStatus[status]}`);
733+
}
734+
```
735+
736+
### Status Page Options
737+
738+
| Option | Type | Required | Description |
739+
| ------------- | ------ | -------- | ---------------------------------------- |
740+
| `title` | string | Yes | Title of the status page (max 256 chars) |
741+
| `slug` | string | Yes | URL-friendly slug (lowercase, hyphens) |
742+
| `description` | string | No | Description (max 2048 chars) |
743+
| `homepageUrl` | string | No | Link to your homepage |
744+
| `contactUrl` | string | No | Link to your contact page |
745+
746+
### Page Access Type
747+
748+
| Enum Value | Description |
749+
| -------------------- | ----------------------- |
750+
| `UNSPECIFIED` | Default/unspecified |
751+
| `PUBLIC` | Publicly accessible |
752+
| `PASSWORD_PROTECTED` | Requires password |
753+
| `AUTHENTICATED` | Requires authentication |
754+
755+
### Page Theme
756+
757+
| Enum Value | Description |
758+
| ------------- | ------------------- |
759+
| `UNSPECIFIED` | Default/unspecified |
760+
| `SYSTEM` | Follow system theme |
761+
| `LIGHT` | Light theme |
762+
| `DARK` | Dark theme |
763+
764+
### Overall Status
765+
766+
| Enum Value | Description |
767+
| ---------------- | --------------------------- |
768+
| `UNSPECIFIED` | Default/unspecified |
769+
| `OPERATIONAL` | All systems operational |
770+
| `DEGRADED` | Performance is degraded |
771+
| `PARTIAL_OUTAGE` | Some systems are down |
772+
| `MAJOR_OUTAGE` | Major systems are down |
773+
| `MAINTENANCE` | Scheduled maintenance |
774+
| `UNKNOWN` | Status cannot be determined |
775+
776+
### Page Component Type
777+
778+
| Enum Value | Description |
779+
| ------------- | ------------------------- |
780+
| `UNSPECIFIED` | Default/unspecified |
781+
| `MONITOR` | Linked to a monitor |
782+
| `STATIC` | Static component (manual) |
448783

449784
## Monitor Options
450785

0 commit comments

Comments
 (0)