Skip to content
3 changes: 3 additions & 0 deletions packages/cli/e2e/__tests__/deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ Update and Unchanged:
Dashboard: dashboard-1
MaintenanceWindow: maintenance-window-1
PrivateLocation: private-location-1
StatusPage: test-page-1
StatusPageService: bar-service
StatusPageService: foo-service
`)
expect(resultTwo.stdout).toContain(
`Create:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable no-new */

import { StatusPage, StatusPageService } from 'checkly/constructs'

const fooService = new StatusPageService('foo-service', {
name: 'Foo',
})

const barService = new StatusPageService('bar-service', {
name: 'Bar',
})

new StatusPage('test-page-1', {
name: 'Test Status Page 1',
url: 'checkly-internal-test-status-page-18671',
cards: [{
name: 'Card 1',
services: [
fooService,
barService,
],
}],
})
2 changes: 2 additions & 0 deletions packages/cli/src/constructs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ export * from './tcp-check'
export * from './incidentio-alert-channel'
export * from './msteams-alert-channel'
export * from './telegram-alert-channel'
export * from './status-page'
export * from './status-page-service'
7 changes: 7 additions & 0 deletions packages/cli/src/constructs/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { Runtime } from '../rest/runtimes'
import {
Check, AlertChannelSubscription, AlertChannel, CheckGroup, MaintenanceWindow, Dashboard,
PrivateLocation, HeartbeatCheck, PrivateLocationCheckAssignment, PrivateLocationGroupAssignment,
StatusPage, StatusPageService,
} from './'
import { ResourceSync } from '../rest/projects'
import { PrivateLocationApi } from '../rest/private-locations'
Expand All @@ -33,6 +34,8 @@ export interface ProjectData {
'private-location-check-assignment': Record<string, PrivateLocationCheckAssignment>,
'private-location-group-assignment': Record<string, PrivateLocationGroupAssignment>,
dashboard: Record<string, Dashboard>,
'status-page': Record<string, StatusPage>,
'status-page-service': Record<string, StatusPageService>,
}

export class Project extends Construct {
Expand All @@ -49,6 +52,8 @@ export class Project extends Construct {
'private-location-check-assignment': {},
'private-location-group-assignment': {},
dashboard: {},
'status-page': {},
'status-page-service': {},
}

static readonly __checklyType = 'project'
Expand Down Expand Up @@ -99,6 +104,8 @@ export class Project extends Construct {
...this.synthesizeRecord(this.data['private-location-check-assignment']),
...this.synthesizeRecord(this.data['private-location-group-assignment']),
...this.synthesizeRecord(this.data.dashboard),
...this.synthesizeRecord(this.data['status-page-service']),
...this.synthesizeRecord(this.data['status-page']),
],
}
}
Expand Down
39 changes: 39 additions & 0 deletions packages/cli/src/constructs/status-page-service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Construct } from './construct'
import { Session } from './project'

export interface StatusPageServiceProps {
/**
* The name of the service.
*/
name: string
}

/**
* Creates a Service for Status Pages
*/
export class StatusPageService extends Construct {
name: string

static readonly __checklyType = 'status-page-service'

/**
* Constructs the Status Page Service instance
*
* @param logicalId unique project-scoped resource name identification
* @param props status page service configuration properties
*
* {@link https://checklyhq.com/docs/cli/constructs-reference/#statuspageservice Read more in the docs}
*/
constructor (logicalId: string, props: StatusPageServiceProps) {
super(StatusPageService.__checklyType, logicalId)
this.name = props.name

Session.registerConstruct(this)
}

synthesize (): any|null {
return {
name: this.name,
}
}
}
108 changes: 108 additions & 0 deletions packages/cli/src/constructs/status-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { Construct } from './construct'
import { Session } from './project'
import { StatusPageService } from './status-page-service'
import { Ref } from './ref'

export interface StatusPageCardProps {
/**
* The name of the card.
*/
name: string
/**
* A list of services to include in the card.
*/
services?: StatusPageService[]
}

export type StatusPageTheme = 'AUTO' | 'DARK' | 'LIGHT'

export interface StatusPageProps {
/**
* The name of the status page.
*/
name: string
/**
* The URL of the status page.
*/
url: string
/**
* A list of cards to add to your status page.
*/
cards: StatusPageCardProps[]
/**
* A custom user domain, e.g. "status.example.com". See the docs on updating your DNS and SSL usage.
*/
customDomain?: string
/**
* A URL pointing to an image file that serves as the logo for the status page.
*/
logo?: string
/**
* The URL that clicking the logo should redirect the user to.
*/
redirectTo?: string
/**
* A URL pointing to an image file to be used as the favicon for the status page.
*/
favicon?: string
/**
* The default theme of the status page.
*/
defaultTheme?: StatusPageTheme
}

/**
* Creates a Status Page
*/
export class StatusPage extends Construct {
name: string
cards: StatusPageCardProps[]
url: string
customDomain?: string
logo?: string
redirectTo?: string
favicon?: string
defaultTheme?: StatusPageTheme

static readonly __checklyType = 'status-page'

/**
* Constructs the Status Page instance
*
* @param logicalId unique project-scoped resource name identification
* @param props status page configuration properties
*
* {@link https://checklyhq.com/docs/cli/constructs-reference/#statuspage Read more in the docs}
*/
constructor (logicalId: string, props: StatusPageProps) {
super(StatusPage.__checklyType, logicalId)
this.name = props.name
this.url = props.url
this.cards = props.cards
this.customDomain = props.customDomain
this.logo = props.logo
this.redirectTo = props.redirectTo
this.favicon = props.favicon
this.defaultTheme = props.defaultTheme

Session.registerConstruct(this)
}

synthesize (): any|null {
return {
name: this.name,
url: this.url,
customDomain: this.customDomain,
logo: this.logo,
redirectTo: this.redirectTo,
favicon: this.favicon,
defaultTheme: this.defaultTheme,
cards: this.cards.map(card => ({
name: card.name,
services: card
.services
?.map((service) => Ref.from(service.logicalId)),
})),
}
}
}
Loading