feat: add status page incident model
This commit is contained in:
parent
6a1f413a38
commit
d1820416f4
@ -0,0 +1,10 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "StatusPageIncident" (
|
||||||
|
"id" VARCHAR(30) NOT NULL,
|
||||||
|
"createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMPTZ(6) NOT NULL,
|
||||||
|
"name" VARCHAR(100) NOT NULL,
|
||||||
|
"payload" JSON NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "StatusPageIncident_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
@ -436,6 +436,17 @@ model MonitorStatusPage {
|
|||||||
@@index([slug])
|
@@index([slug])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model StatusPageIncident {
|
||||||
|
id String @id @default(cuid()) @db.VarChar(30)
|
||||||
|
createdAt DateTime @default(now()) @db.Timestamptz(6)
|
||||||
|
updatedAt DateTime @updatedAt @db.Timestamptz(6)
|
||||||
|
name String @db.VarChar(100)
|
||||||
|
|
||||||
|
/// [StatusPageIncidentPayload]
|
||||||
|
/// @zod.custom(imports.StatusPageIncidentPayloadSchema)
|
||||||
|
payload Json @db.Json
|
||||||
|
}
|
||||||
|
|
||||||
model WorkspaceDailyUsage {
|
model WorkspaceDailyUsage {
|
||||||
id String @id @unique @default(cuid()) @db.VarChar(30)
|
id String @id @unique @default(cuid()) @db.VarChar(30)
|
||||||
workspaceId String @db.VarChar(30)
|
workspaceId String @db.VarChar(30)
|
||||||
|
@ -19,6 +19,7 @@ export * from "./monitorevent.js"
|
|||||||
export * from "./monitordata.js"
|
export * from "./monitordata.js"
|
||||||
export * from "./monitorstatus.js"
|
export * from "./monitorstatus.js"
|
||||||
export * from "./monitorstatuspage.js"
|
export * from "./monitorstatuspage.js"
|
||||||
|
export * from "./statuspageincident.js"
|
||||||
export * from "./workspacedailyusage.js"
|
export * from "./workspacedailyusage.js"
|
||||||
export * from "./workspaceauditlog.js"
|
export * from "./workspaceauditlog.js"
|
||||||
export * from "./survey.js"
|
export * from "./survey.js"
|
||||||
|
@ -19,3 +19,26 @@ export const SurveyPayloadSchema = z.object({
|
|||||||
})
|
})
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const StatusPageIncidentPayloadSchema = z.object({
|
||||||
|
history: z.array(
|
||||||
|
z.object({
|
||||||
|
message: z.string(),
|
||||||
|
timestamp: z.number(),
|
||||||
|
status: z.enum(['investigating', 'identified', 'monitoring', 'resolved']),
|
||||||
|
components: z.array(
|
||||||
|
z.object({
|
||||||
|
id: z.string(),
|
||||||
|
type: z.enum(['website', 'monitor']),
|
||||||
|
status: z.enum([
|
||||||
|
'operational',
|
||||||
|
'degradedPerformance',
|
||||||
|
'partialOutage',
|
||||||
|
'majorOutage',
|
||||||
|
'underMaintenance',
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
});
|
||||||
|
19
src/server/prisma/zod/statuspageincident.ts
Normal file
19
src/server/prisma/zod/statuspageincident.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import * as z from "zod"
|
||||||
|
import * as imports from "./schemas/index.js"
|
||||||
|
|
||||||
|
// Helper schema for JSON fields
|
||||||
|
type Literal = boolean | number | string
|
||||||
|
type Json = Literal | { [key: string]: Json } | Json[]
|
||||||
|
const literalSchema = z.union([z.string(), z.number(), z.boolean()])
|
||||||
|
const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))
|
||||||
|
|
||||||
|
export const StatusPageIncidentModelSchema = z.object({
|
||||||
|
id: z.string(),
|
||||||
|
createdAt: z.date(),
|
||||||
|
updatedAt: z.date(),
|
||||||
|
name: z.string(),
|
||||||
|
/**
|
||||||
|
* [StatusPageIncidentPayload]
|
||||||
|
*/
|
||||||
|
payload: imports.StatusPageIncidentPayloadSchema,
|
||||||
|
})
|
4
src/server/types/global.d.ts
vendored
4
src/server/types/global.d.ts
vendored
@ -2,6 +2,7 @@ import type { JWTPayload } from '../middleware/auth.ts';
|
|||||||
import type {
|
import type {
|
||||||
MonitorStatusPageListSchema,
|
MonitorStatusPageListSchema,
|
||||||
SurveyPayloadSchema,
|
SurveyPayloadSchema,
|
||||||
|
StatusPageIncidentPayloadSchema,
|
||||||
} from '../prisma/zod/schemas/index.ts';
|
} from '../prisma/zod/schemas/index.ts';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@ -17,5 +18,8 @@ declare global {
|
|||||||
} | null;
|
} | null;
|
||||||
type MonitorStatusPageList = z.infer<typeof MonitorStatusPageListSchema>;
|
type MonitorStatusPageList = z.infer<typeof MonitorStatusPageListSchema>;
|
||||||
type SurveyPayload = z.infer<typeof SurveyPayloadSchema>;
|
type SurveyPayload = z.infer<typeof SurveyPayloadSchema>;
|
||||||
|
type StatusPageIncidentPayload = z.infer<
|
||||||
|
typeof StatusPageIncidentPayloadSchema
|
||||||
|
>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user