// src/models/workspace.ts
// Copyright (C) 2026 Rob Colbert <rob.colbert@openplatform.us>
// Licensed under the Apache License, Version 2.0

import { model, Schema } from "mongoose";
import { IWorkspace, WorkspaceStatus } from "@gadget/api";

export const WorkspaceSchema = new Schema<IWorkspace>({
  _id: { type: String, required: true },
  createdAt: { type: Date, required: true, default: Date.now, index: -1 },
  user: { type: String, required: true, index: 1, ref: "User" },
  status: {
    type: String,
    enum: WorkspaceStatus,
    default: WorkspaceStatus.Inactive,
    required: true,
  },
  hostname: { type: String, required: true },
  rootDir: { type: String, required: true },
  lockedDrone: { type: String, ref: "DroneRegistration" },
});

export const Workspace = model<IWorkspace>("Workspace", WorkspaceSchema);
export default Workspace;
