import { Schema } from 'mongoose'; import type { VisualisierungSettingsDto } from '../../visualisierung/visualisierung.dto'; export interface VisualisierungSettings extends VisualisierungSettingsDto { anlageId: string; revision?: number; editorHistory?: unknown[] } export const VisualisierungSettingsSchema = new Schema({ anlageId: { type: String, required: true, unique: true }, revision: { type: Number, default: 0 }, editorHistory: { type: [Schema.Types.Mixed], default: undefined }, workspaceWidth: { type: Number, required: true }, workspaceHeight: { type: Number, required: true }, grid: { type: Boolean, required: true }, gridStep: { type: Number, required: true }, snapToGrid: { type: Boolean, required: true }, showHidden: { type: Boolean, required: true }, selectedSpsAntriebId: { type: Number, default: null }, editor: { type: new Schema({ layers: [new Schema({ id: String, name: String, visible: Boolean, locked: Boolean }, { _id: false, strict: 'throw' })], assignments: [new Schema({ key: String, layerId: String, locked: Boolean }, { _id: false, strict: 'throw' })], }, { _id: false, strict: 'throw' }), default: undefined }, viewport: { type: new Schema({ x: Number, y: Number, width: Number, height: Number }, { _id: false }), required: true }, }, { collection: 'visualisierung_settings', timestamps: true, strict: 'throw' });