2023-11-29 16:43:55 +00:00
|
|
|
import * as z from "zod"
|
2023-12-13 10:21:04 +00:00
|
|
|
import * as imports from "./schemas"
|
2023-11-29 16:43:55 +00:00
|
|
|
import { CompleteTelemetrySession, RelatedTelemetrySessionModelSchema } from "./index"
|
|
|
|
|
|
|
|
// 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 TelemetryEventModelSchema = z.object({
|
|
|
|
id: z.string(),
|
|
|
|
sessionId: z.string(),
|
|
|
|
workspaceId: z.string(),
|
|
|
|
eventName: z.string().nullish(),
|
|
|
|
urlOrigin: z.string(),
|
|
|
|
urlPath: z.string(),
|
|
|
|
/**
|
|
|
|
* [CommonPayload]
|
|
|
|
*/
|
|
|
|
payload: jsonSchema,
|
|
|
|
createdAt: z.date(),
|
|
|
|
})
|
|
|
|
|
|
|
|
export interface CompleteTelemetryEvent extends z.infer<typeof TelemetryEventModelSchema> {
|
|
|
|
session: CompleteTelemetrySession
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RelatedTelemetryEventModelSchema contains all relations on your model in addition to the scalars
|
|
|
|
*
|
|
|
|
* NOTE: Lazy required in case of potential circular dependencies within schema
|
|
|
|
*/
|
|
|
|
export const RelatedTelemetryEventModelSchema: z.ZodSchema<CompleteTelemetryEvent> = z.lazy(() => TelemetryEventModelSchema.extend({
|
|
|
|
session: RelatedTelemetrySessionModelSchema,
|
|
|
|
}))
|