import { SchemaModel } from '@verb/src/libs/shared/base/base.model'; import { SubSchema } from '@verb/src/libs/shared/json-schema-validator/schema-types'; export class StreamRecordingModel implements SchemaModel { public startedAt: Date | null = null; public endedAt: Date | null = null; public videoId = ''; public constructor(streamRecordingSchema?: StreamRecordingSchema) { if (streamRecordingSchema) { this.fromSchema(streamRecordingSchema); } } public fromSchema(streamRecordingSchema: StreamRecordingSchema): void { this.endedAt = streamRecordingSchema.ended_at ? new Date(streamRecordingSchema.ended_at) : null; this.startedAt = streamRecordingSchema.started_at ? new Date(streamRecordingSchema.started_at) : null; this.videoId = streamRecordingSchema.video_id; } public toSchema(): StreamRecordingSchema { return { ended_at: this.endedAt ? this.endedAt.toUTCString() : null, started_at: this.startedAt ? this.startedAt.toUTCString() : null, video_id: this.videoId, }; } } export interface StreamRecordingSchema { ended_at: string | null; started_at: string | null; video_id: string; } export const streamRecordingValidationSchema: SubSchema = { additionalProperties: false, description: 'Stream Recording Schema Validation', properties: { ended_at: { description: 'Ended at', type: 'string', }, started_at: { description: 'Started at', type: 'string', }, video_id: { description: 'Video ID', minLength: 1, type: 'string', }, }, required: ['video_id'], type: 'object', };