Skip to content

Commit

Permalink
Better types.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pickysaurus committed Feb 3, 2025
1 parent d96a863 commit 51cbceb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/interactions/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function action(client: ClientExt, baseInteraction: CommandInteraction): P
## Planned Maintainece
${statusPage.scheduled_maintenances.length ? statusPage.scheduled_maintenances.map(c => `${c.name}\n${c.incident_updates[0].body}`).join('\n'): 'None'}
`);
return interaction.editReply({ embeds: [embed], content: `\`\`\`json\n${JSON.stringify(statusPage, null, 2)}\`\`\`` });
return interaction.editReply({ embeds: [embed] });
}
catch(err) {
throw err;
Expand Down
37 changes: 24 additions & 13 deletions src/types/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,14 @@ export interface IStatusPageFullResponse extends IStatusPageQuickResponse {
scheduled_maintenances: IStatusPageIncident[];
}

type StatusPageComponentStatus = 'operational' | 'partial_outage' | string;
type StatusPageIncidentStatus = 'identified' | 'investigating' | 'scheduled' | 'in_progress' | string;
type StatusPageImpact = 'major' | 'critical' | 'minor' | 'none' | string;

interface IStatusPageComponent {
id: string;
name: string;
status: 'operational' | string;
status: StatusPageComponentStatus;
created_at: string;
updated_at: string;
position: number;
Expand All @@ -232,25 +236,32 @@ interface IStatusPageComponent {
}

interface IStatusPageIncident {
created_at: string;
id: string;
impact: 'critical' | 'minor' | 'none' | string;
incident_updates: IStatusPageIncidentUpdate[];
monitoring_at: string | null;
name: string;
page_id: string;
resolved_at: string | null;
shortlink: string;
status: 'identified' | string;
status: StatusPageIncidentStatus;
created_at: string;
updated_at: string;
monitoring_at: string | null;
resolved_at: string | null;
impact: StatusPageImpact;
shortlink: string;
started_at: string;
page_id: string;
incident_updates: IStatusPageIncidentUpdate[];
}

interface IStatusPageIncidentUpdate {
body: string;
created_at: string;
display_at: string;
id: string;
status: StatusPageIncidentStatus;
body: string;
incident_id: string;
status: 'identified' | 'scheduled' | 'in_progress' | string;
created_at: string;
updated_at: string;
display_at: string;
affected_components: {
code: string;
name: string;
old_status: string;
new_status: string;
}[]
}

0 comments on commit 51cbceb

Please sign in to comment.