Openstatus www.openstatus.dev

fix: text body (#960)

* fix: text body

* ci: apply automated fixes

* fix: more

* ci: apply automated fixes

* fix: document cookie expires date

* fix: missing body

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

authored by

Maximilian Kaske
autofix-ci[bot]
and committed by
GitHub
b7070851 0bc9389c

+41 -12
+15 -4
apps/web/src/components/forms/monitor/form.tsx
··· 91 91 statusAssertions: _assertions.filter((a) => a.type === "status") as any, // TS considers a.type === "header" 92 92 // biome-ignore lint/suspicious/noExplicitAny: <explanation> 93 93 headerAssertions: _assertions.filter((a) => a.type === "header") as any, // TS considers a.type === "status" 94 - 94 + textBodyAssertions: _assertions.filter( 95 + (a) => a.type === "textBody", 96 + // biome-ignore lint/suspicious/noExplicitAny: <explanation> 97 + ) as any, // TS considers a.type === "textBody" 95 98 degradedAfter: defaultValues?.degradedAfter, 96 99 timeout: defaultValues?.timeout || 45000, 97 100 }, ··· 165 168 166 169 const pingEndpoint = async (region?: MonitorFlyRegion) => { 167 170 try { 168 - const { url, body, method, headers, statusAssertions, headerAssertions } = 169 - form.getValues(); 171 + const { 172 + url, 173 + body, 174 + method, 175 + headers, 176 + statusAssertions, 177 + headerAssertions, 178 + textBodyAssertions, 179 + } = form.getValues(); 170 180 171 181 if (body && body !== "") { 172 182 const validJSON = validateJSON(body); ··· 194 204 JSON.stringify([ 195 205 ...(statusAssertions || []), 196 206 ...(headerAssertions || []), 207 + ...(textBodyAssertions || []), 197 208 ]), 198 209 ); 199 210 ··· 206 217 if (as.length > 0) { 207 218 for (const a of as) { 208 219 const { success, message } = a.assert({ 209 - body: "", // data.body ?? "", 220 + body: data.body ?? "", 210 221 header: data.headers ?? {}, 211 222 status: data.status, 212 223 });
+1 -1
apps/web/src/components/forms/monitor/section-assertions.tsx
··· 249 249 <div className="col-span-3" /> 250 250 <FormField 251 251 control={form.control} 252 - name={`statusAssertions.${i}.compare`} 252 + name={`textBodyAssertions.${i}.compare`} 253 253 render={({ field }) => ( 254 254 <FormItem className="col-span-3 w-full"> 255 255 <Select
+1
apps/web/src/components/ping-response-analysis/utils.ts
··· 100 100 headers: z.record(z.string()), 101 101 time: z.number(), 102 102 timing: timingSchema, 103 + body: z.string().optional().nullable(), 103 104 }); 104 105 105 106 export const cachedCheckerSchema = z.object({
+9 -1
packages/api/src/router/monitor.ts
··· 5 5 type Assertion, 6 6 HeaderAssertion, 7 7 StatusAssertion, 8 + TextBodyAssertion, 8 9 serialize, 9 10 } from "@openstatus/assertions"; 10 11 import { and, eq, inArray, isNull, sql } from "@openstatus/db"; ··· 24 25 selectNotificationSchema, 25 26 selectPublicMonitorSchema, 26 27 } from "@openstatus/db/src/schema"; 27 - import { allPlans } from "@openstatus/db/src/schema/plan/config"; 28 28 29 29 import { trackNewMonitor } from "../analytics"; 30 30 import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc"; ··· 90 90 tags, 91 91 statusAssertions, 92 92 headerAssertions, 93 + textBodyAssertions, 93 94 ...data 94 95 } = opts.input; 95 96 ··· 99 100 } 100 101 for (const a of headerAssertions ?? []) { 101 102 assertions.push(new HeaderAssertion(a)); 103 + } 104 + for (const a of textBodyAssertions ?? []) { 105 + assertions.push(new TextBodyAssertion(a)); 102 106 } 103 107 104 108 const newMonitor = await opts.ctx.db ··· 288 292 tags, 289 293 statusAssertions, 290 294 headerAssertions, 295 + textBodyAssertions, 291 296 ...data 292 297 } = opts.input; 293 298 ··· 297 302 } 298 303 for (const a of headerAssertions ?? []) { 299 304 assertions.push(new HeaderAssertion(a)); 305 + } 306 + for (const a of textBodyAssertions ?? []) { 307 + assertions.push(new TextBodyAssertion(a)); 300 308 } 301 309 302 310 const currentMonitor = await opts.ctx.db