import { createDbPlugin } from '@btst/db';

const aiChatSchema = createDbPlugin("aiChat", {
  conversation: {
    modelName: "conversation",
    fields: {
      id: {
        type: "string",
        required: true,
        unique: true
      },
      userId: {
        type: "string",
        required: false
      },
      title: {
        type: "string",
        required: true
      },
      createdAt: {
        type: "date",
        defaultValue: () => /* @__PURE__ */ new Date()
      },
      updatedAt: {
        type: "date",
        defaultValue: () => /* @__PURE__ */ new Date()
      }
    }
  },
  message: {
    modelName: "message",
    fields: {
      id: {
        type: "string",
        required: true,
        unique: true
      },
      conversationId: {
        type: "string",
        required: true,
        references: {
          model: "conversation",
          field: "id",
          onDelete: "cascade"
        }
      },
      role: {
        type: "string",
        required: true
      },
      content: {
        type: "string",
        required: true
      },
      createdAt: {
        type: "date",
        defaultValue: () => /* @__PURE__ */ new Date()
      }
    }
  }
});

export { aiChatSchema };
