diff --git a/packages/importers/src/providers/statuspage/api-types.ts b/packages/importers/src/providers/statuspage/api-types.ts index eb512034..d760fe46 100644 --- a/packages/importers/src/providers/statuspage/api-types.ts +++ b/packages/importers/src/providers/statuspage/api-types.ts @@ -110,7 +110,7 @@ export type StatuspageIncident = z.infer; export const StatuspageSubscriberSchema = z.object({ id: z.string(), - page_id: z.string(), + page_id: z.string().nullish(), mode: lenientEnum([ "email", "sms", diff --git a/packages/importers/src/providers/statuspage/client.test.ts b/packages/importers/src/providers/statuspage/client.test.ts index b86af6dc..a75fcd5c 100644 --- a/packages/importers/src/providers/statuspage/client.test.ts +++ b/packages/importers/src/providers/statuspage/client.test.ts @@ -162,6 +162,24 @@ describe("StatuspageClient", () => { expect(subscribers[0].workspace_name).toBeUndefined(); }); + test("getSubscribers accepts the real API shape without page_id", async () => { + mockFetchPaginated([ + { + id: "ht9cy29jdb3r", + mode: "email", + email: "user@example.com", + created_at: "03-14-22 12:19 CET", + confirmed_at: "03-14-22 12:19 CET", + skip_confirmation_notification: false, + quarantined_at: null, + purge_at: null, + }, + ]); + const subscribers = await client.getSubscribers("sp_page_001"); + expect(subscribers[0].email).toBe("user@example.com"); + expect(subscribers[0].page_id).toBeUndefined(); + }); + test("getIncidents accepts incidents with omitted optional fields", async () => { const [incident] = MOCK_INCIDENTS; const { metadata, postmortem_body, shortlink, ...rest } = incident; @@ -171,7 +189,9 @@ describe("StatuspageClient", () => { mockFetchPaginated([{ ...rest, incident_updates: updates }]); const incidents = await client.getIncidents("sp_page_001"); expect(incidents[0].postmortem_body).toBeUndefined(); - expect(incidents[0].incident_updates?.[0].affected_components).toBeUndefined(); + expect( + incidents[0].incident_updates?.[0].affected_components, + ).toBeUndefined(); }); test("getSubscribers returns parsed subscribers", async () => {