Skip to content

Commit 2c456b2

Browse files
committed
fix: import stuff
1 parent 8fc5d2d commit 2c456b2

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

packages/importers/src/providers/instatus/api-types.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export const InstatusComponentSchema = z.object({
2828
"MAJOROUTAGE",
2929
]),
3030
order: z.number(),
31-
group: z.string().nullable(),
32-
showUptime: z.boolean(),
33-
grouped: z.boolean(),
31+
group: z.string().nullable().optional(),
32+
showUptime: z.boolean().optional(),
33+
grouped: z.boolean().optional(),
3434
});
3535

3636
export type InstatusComponent = z.infer<typeof InstatusComponentSchema>;
@@ -49,14 +49,19 @@ export type InstatusIncidentUpdate = z.infer<
4949
typeof InstatusIncidentUpdateSchema
5050
>;
5151

52+
const InstatusIncidentComponentRefSchema = z.object({
53+
id: z.string(),
54+
name: z.string().optional(),
55+
});
56+
5257
export const InstatusIncidentSchema = z.object({
5358
id: z.string(),
5459
name: z.string(),
5560
status: z.enum(["INVESTIGATING", "IDENTIFIED", "MONITORING", "RESOLVED"]),
5661
started: z.string(),
5762
resolved: z.string().nullable(),
5863
updates: z.array(InstatusIncidentUpdateSchema).optional(),
59-
components: z.array(z.string()).optional(),
64+
components: z.array(InstatusIncidentComponentRefSchema).optional(),
6065
});
6166

6267
export type InstatusIncident = z.infer<typeof InstatusIncidentSchema>;
@@ -81,7 +86,7 @@ export const InstatusMaintenanceSchema = z.object({
8186
start: z.string(),
8287
duration: z.number().nullable(),
8388
updates: z.array(InstatusMaintenanceUpdateSchema).optional(),
84-
components: z.array(z.string()).optional(),
89+
components: z.array(InstatusIncidentComponentRefSchema).optional(),
8590
});
8691

8792
export type InstatusMaintenance = z.infer<typeof InstatusMaintenanceSchema>;

packages/importers/src/providers/instatus/fixtures.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const MOCK_INCIDENTS: InstatusIncident[] = [
127127
createdAt: "2024-06-10T16:45:00.000Z",
128128
},
129129
],
130-
components: ["in_comp_001"],
130+
components: [{ id: "in_comp_001", name: "API Gateway" }],
131131
},
132132
{
133133
id: "in_incident_002",
@@ -159,7 +159,7 @@ export const MOCK_INCIDENTS: InstatusIncident[] = [
159159
createdAt: "2024-06-11T09:45:00.000Z",
160160
},
161161
],
162-
components: ["in_comp_003"],
162+
components: [{ id: "in_comp_003", name: "Dashboard" }],
163163
},
164164
];
165165

@@ -182,7 +182,10 @@ export const MOCK_MAINTENANCES: InstatusMaintenance[] = [
182182
started: "2024-06-12T10:00:00.000Z",
183183
},
184184
],
185-
components: ["in_comp_001", "in_comp_002"],
185+
components: [
186+
{ id: "in_comp_001", name: "API Gateway" },
187+
{ id: "in_comp_002", name: "Authentication Service" },
188+
],
186189
},
187190
{
188191
id: "in_maint_002",
@@ -208,7 +211,7 @@ export const MOCK_MAINTENANCES: InstatusMaintenance[] = [
208211
started: "2024-06-15T03:25:00.000Z",
209212
},
210213
],
211-
components: ["in_comp_004"],
214+
components: [{ id: "in_comp_004", name: "CDN" }],
212215
},
213216
];
214217

packages/importers/src/providers/instatus/mapper.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ export function mapIncidentToStatusReport(
110110
? mapIncidentStatus(lastUpdate.status)
111111
: "investigating";
112112

113-
const sourceComponentIds: string[] = incident.components ?? [];
113+
const sourceComponentIds: string[] = (incident.components ?? []).map(
114+
(c) => c.id,
115+
);
114116

115117
return {
116118
report: {

packages/importers/src/providers/instatus/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export function createInstatusProvider(): ImportProvider<InstatusImportConfig> {
126126
status: "created" as const,
127127
data: {
128128
...mapMaintenanceToMaintenance(m, config.workspaceId, pageId),
129-
sourceComponentIds: m.components ?? [],
129+
sourceComponentIds: (m.components ?? []).map((c) => c.id),
130130
},
131131
}),
132132
);

0 commit comments

Comments
 (0)