···11/// <reference types="next" />
22/// <reference types="next/image-types/global" />
33-import "./.next/dev/types/routes.d.ts";
33+import "./.next/types/routes.d.ts";
4455// NOTE: This file should not be edited
66// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
···6767 return true;
6868 },
6969 {
7070- message: "Value must be manual when type is manual",
7070+ error: "Value must be manual when type is manual",
7171 path: ["value"],
7272 },
7373 );
···1313 .number()
1414 .max(5)
1515 .optional()
1616- .default(1)
1616+ .prefault(1)
1717 .openapi({ description: "The number of times to run the check" }),
1818 aggregated: z
1919 .boolean()
···8787 .optional()
8888 .openapi({ description: "The body of the response" }),
8989 headers: z
9090- .record(z.string())
9090+ .record(z.string(), z.string())
9191 .optional()
9292 .openapi({ description: "The headers of the response" }),
9393 timing: TimingSchema.openapi({
···131131});
132132133133export const CheckPostResponseSchema = z.object({
134134- id: z.number().int().openapi({ description: "The id of the check" }),
134134+ id: z.int().openapi({ description: "The id of the check" }),
135135 raw: z.array(TimingSchema).openapi({
136136 description: "The raw data of the check",
137137 }),
+4-1
apps/server/src/routes/v1/incidents/put.test.ts
···6060 });
61616262 const result = (await res.json()) as Record<string, unknown>;
6363- expect(result.message).toBe("invalid_date in 'acknowledgedAt': Invalid date");
6363+ // expect(result.message).toBe("invalid_date in 'acknowledgedAt': Invalid date");
6464+ expect(result.message).toBe(
6565+ "invalid_type in 'acknowledgedAt': Invalid input: expected date, received Date",
6666+ );
6467 expect(res.status).toBe(400);
6568});
6669
+1-1
apps/server/src/routes/v1/maintenances/schema.ts
···3737 monitorIds: z
3838 .array(z.number())
3939 .optional()
4040- .default([])
4040+ .prefault([])
4141 .openapi({ description: "IDs of affected monitors" }),
4242 pageId: z.number().openapi({
4343 description: "The id of the status page this maintenance belongs to",
+1-1
apps/server/src/routes/v1/monitors/run/schema.ts
···2233export const QuerySchema = z
44 .object({
55- "no-wait": z.coerce.boolean().optional().default(false).openapi({
55+ "no-wait": z.coerce.boolean().optional().prefault(false).openapi({
66 description: "Don't wait for the result",
77 }),
88 })
+52-62
apps/server/src/routes/v1/monitors/schema.ts
···2020 description: "The comparison to run",
2121 example: "eq",
2222 }),
2323- target: z
2424- .number()
2525- .int()
2626- .positive()
2727- .openapi({ description: "The target value" }),
2323+ target: z.int().positive().openapi({ description: "The target value" }),
2824 })
2925 .openapi({
3026 description: "The status assertion",
···9490 }),
9591});
96929393+const PeriodicityEnumHonoSchema = z.enum([...monitorPeriodicitySchema.options]);
9494+9795export const MonitorSchema = z
9896 .object({
9997 id: z.number().openapi({
10098 example: 123,
10199 description: "The id of the monitor",
102100 }),
103103- periodicity: monitorPeriodicitySchema.openapi({
101101+ periodicity: PeriodicityEnumHonoSchema.openapi({
104102 example: "1m",
105103 description: "How often the monitor should run",
106104 }),
···111109 regions: z
112110 .preprocess(
113111 (val) => {
114114- let regions: Array<unknown> = [];
115115- if (!val) return regions;
112112+ let parsedRegions: Array<unknown> = [];
113113+ if (!val) return parsedRegions;
116114 if (Array.isArray(val)) {
117117- regions = val;
115115+ parsedRegions = val;
118116 }
119117 if (String(val).length > 0) {
120120- regions = String(val).split(",");
118118+ parsedRegions = String(val).split(",");
121119 }
122122-123123- const deprecatedRegions = regions.filter((r) => {
124124- return !AVAILABLE_REGIONS.includes(
125125- r as (typeof AVAILABLE_REGIONS)[number],
126126- );
127127- });
128128-129129- if (deprecatedRegions.length > 0) {
130130- throw new ZodError([
131131- {
132132- code: "custom",
133133- path: ["regions"],
134134- message: `Deprecated regions are not allowed: ${deprecatedRegions.join(
135135- ", ",
136136- )}`,
137137- },
138138- ]);
139139- }
140140-141141- return regions;
120120+ return parsedRegions;
142121 },
143122 z.array(z.enum(monitorRegions)),
144123 )
145145- .default([])
124124+ .superRefine((regions, ctx) => {
125125+ const deprecatedRegions = regions.filter((r) => {
126126+ return !AVAILABLE_REGIONS.includes(
127127+ r as (typeof AVAILABLE_REGIONS)[number],
128128+ );
129129+ });
130130+ if (deprecatedRegions.length > 0) {
131131+ ctx.addIssue({
132132+ code: "custom",
133133+ path: ["regions"],
134134+ message: `Deprecated regions are not allowed: ${deprecatedRegions.join(
135135+ ", ",
136136+ )}`,
137137+ });
138138+ }
139139+ })
140140+ .prefault([])
146141 .openapi({
147142 example: ["ams"],
148143 description: "Where we should monitor it",
···166161 return String(val);
167162 }, z.string())
168163 .nullish()
169169- .default("")
164164+ .prefault("")
170165 .openapi({
171166 example: "Hello World",
172167 description: "The body",
···190185 ]);
191186 }
192187 },
193193- z.array(z.object({ key: z.string(), value: z.string() })).default([]),
188188+ z.array(z.object({ key: z.string(), value: z.string() })).prefault([]),
194189 )
195190 .nullish()
196191 .openapi({
···216211 }
217212 }, z.array(assertion))
218213 .nullish()
219219- .default([])
214214+ .prefault([])
220215 .openapi({
221216 description: "The assertions to run",
222217 }),
223218 active: z
224219 .boolean()
225225- .default(false)
220220+ .prefault(false)
226221 .openapi({ description: "If the monitor is active" }),
227222 public: z
228223 .boolean()
229229- .default(false)
224224+ .prefault(false)
230225 .openapi({ description: "If the monitor is public" }),
231226 degradedAfter: z.number().nullish().openapi({
232227 description:
233228 "The time after the monitor is considered degraded in milliseconds",
234229 }),
235235- timeout: z.number().nullish().default(45000).openapi({
230230+ timeout: z.number().nullish().prefault(45000).openapi({
236231 description: "The timeout of the request in milliseconds",
237232 }),
238238- retry: z.number().default(3).openapi({
233233+ retry: z.number().prefault(3).openapi({
239234 description: "The number of retries to attempt",
240235 }),
241241- followRedirects: z.boolean().default(true).openapi({
236236+ followRedirects: z.boolean().prefault(true).openapi({
242237 description: "If the monitor should follow redirects",
243238 }),
244244- jobType: z.enum(monitorJobTypes).optional().default("http").openapi({
239239+ jobType: z.enum(monitorJobTypes).optional().prefault("http").openapi({
245240 description: "The type of the monitor",
246241 }),
247242 openTelemetry: z
248243 .object({
249249- endpoint: z
250250- .string()
251251- .url()
244244+ endpoint: z.url().optional().prefault("http://localhost:4317").openapi({
245245+ description: "The endpoint of the OpenTelemetry collector",
246246+ }),
247247+ headers: z
248248+ .record(z.string(), z.string())
252249 .optional()
253253- .default("http://localhost:4317")
250250+ .prefault({})
254251 .openapi({
255255- description: "The endpoint of the OpenTelemetry collector",
252252+ description: "The headers to send to the OpenTelemetry collector",
256253 }),
257257- headers: z.record(z.string()).optional().default({}).openapi({
258258- description: "The headers to send to the OpenTelemetry collector",
259259- }),
260254 })
261255 .optional()
262256 .openapi({
···316310]);
317311318312export const ResultRun = z.object({
319319- latency: z.number().int(), // in ms
320320- statusCode: z.number().int().nullable().default(null),
321321- monitorId: z.string().default(""),
313313+ latency: z.int(), // in ms
314314+ statusCode: z.int().nullable().prefault(null),
315315+ monitorId: z.string().prefault(""),
322316 url: z.string().optional(),
323323- error: z.coerce.boolean().default(false),
317317+ error: z.coerce.boolean().prefault(false),
324318 region: z.enum(monitorRegions),
325325- timestamp: z.number().int().optional(),
319319+ timestamp: z.int().optional(),
326320 message: z.string().nullable().optional(),
327321 timing: z
328322 .preprocess((val) => {
···413407 },
414408 z.array(z.enum(monitorRegions)),
415409 )
416416- .default([])
410410+ .prefault([])
417411 .openapi({
418412 example: ["ams"],
419413 description: "Where we should monitor it",
···421415 openTelemetry: z
422416 .object({
423417 endpoint: z
424424- .string()
425418 .url()
426419 .optional()
427420 .openapi({
···441434442435const httpRequestSchema = z.object({
443436 method: z.enum(monitorMethods),
444444- url: z
445445- .string()
446446- .url()
447447- .openapi({
448448- description: "URL to request",
449449- examples: ["https://openstat.us", "https://www.openstatus.dev"],
450450- }),
437437+ url: z.url().openapi({
438438+ description: "URL to request",
439439+ examples: ["https://openstat.us", "https://www.openstatus.dev"],
440440+ }),
451441 headers: z
452442 .record(z.string(), z.string())
453443 .optional()
···44export { ParamsSchema };
5566export const SummarySchema = z.object({
77- ok: z.number().int().openapi({
77+ ok: z.int().openapi({
88 description:
99 "The number of ok responses (defined by the assertions - or by default status code 200)",
1010 }),
1111- count: z
1212- .number()
1313- .int()
1414- .openapi({ description: "The total number of request" }),
1111+ count: z.int().openapi({ description: "The total number of request" }),
1512 day: z.coerce
1613 .date()
1714 .openapi({ description: "The date of the daily stat in ISO8601 format" }),
···2020 description: "The id of the subscriber",
2121 example: 1,
2222 }),
2323- email: z.string().email().openapi({
2323+ email: z.email().openapi({
2424 description: "The email of the subscriber",
2525 }),
2626 pageId: z.number().openapi({
+2-3
apps/server/src/routes/v1/pages/schema.ts
···4343 example: "status.acme.com",
4444 }),
4545 icon: z
4646- .string()
4746 .url()
4847 .or(z.literal(""))
4948 .transform((val) => (val ? val : undefined))
···5251 description: "The icon of the page",
5352 example: "https://example.com/icon.png",
5453 }),
5555- passwordProtected: z.boolean().optional().default(false).openapi({
5454+ passwordProtected: z.boolean().optional().prefault(false).openapi({
5655 description:
5756 "Make the page password protected. Used with the 'passwordProtected' property.",
5857 example: true,
···6160 description: "Your password to protect the page from the public",
6261 example: "hidden-password",
6362 }),
6464- showMonitorValues: z.boolean().optional().nullish().default(true).openapi({
6363+ showMonitorValues: z.boolean().optional().nullish().prefault(true).openapi({
6564 description:
6665 "Displays the total and failed request numbers for each monitor",
6766 example: true,
···2222 status: z.enum(statusReportStatus).openapi({
2323 description: "The status of the update",
2424 }),
2525- date: z.coerce.date().default(new Date()).openapi({
2525+ date: z.coerce.date().prefault(new Date()).openapi({
2626 description: "The date of the update in ISO8601 format",
2727 }),
2828 message: z.string().openapi({
+1-1
apps/server/src/routes/v1/statusReports/post.ts
···3232 id: true,
3333 statusReportUpdateIds: true,
3434 }).extend({
3535- date: z.coerce.date().optional().default(new Date()).openapi({
3535+ date: z.coerce.date().optional().prefault(new Date()).openapi({
3636 description:
3737 "The date of the report in ISO8601 format, defaults to now",
3838 }),
+2-2
apps/server/src/routes/v1/statusReports/schema.ts
···3030 .array(z.number())
3131 .optional()
3232 .nullable()
3333- .default([])
3333+ .prefault([])
3434 .openapi({
3535 description: "The ids of the status report updates",
3636 }),
3737 monitorIds: z
3838 .array(z.number())
3939 .optional()
4040- .default([])
4040+ .prefault([])
4141 .openapi({ description: "Ids of the monitors the status report." }),
4242 pageId: z.number().openapi({
4343 description: "The id of the page this status report belongs to",
+1-1
apps/server/src/routes/v1/whoami/schema.ts
···99 .optional()
1010 .openapi({ description: "The current workspace name" }),
1111 slug: z.string().openapi({ description: "The current workspace slug" }),
1212- plan: z.enum(workspacePlans).nullable().default("free").openapi({
1212+ plan: z.enum(workspacePlans).nullable().prefault("free").openapi({
1313 description: "The current workspace plan",
1414 }),
1515 })
···11/// <reference types="next" />
22/// <reference types="next/image-types/global" />
33-import "./.next/dev/types/routes.d.ts";
33+import "./.next/types/routes.d.ts";
4455// NOTE: This file should not be edited
66// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
···2233export const preferencesSchema = z
44 .object({
55- combinedRegions: z.boolean().nullable().default(false).optional(),
55+ combinedRegions: z.boolean().nullable().prefault(false).optional(),
66 // ... other settings to store user preferences
77 // accessible via document.cookie in the client and cookies() on the server
88 })