Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

1.3 KB
Raw Blame
import mongoose, { Schema } from 'mongoose';
import type { IAction } from '~/types';

// Define the Auth sub-schema with type-safety.
const AuthSchema = new Schema(
  {
    authorization_type: { type: String },
    custom_auth_header: { type: String },
    type: { type: String, enum: ['service_http', 'oauth', 'none'] },
    authorization_content_type: { type: String },
    authorization_url: { type: String },
    client_url: { type: String },
    scope: { type: String },
    token_exchange_method: { type: String, enum: ['default_post', 'basic_auth_header', null] },
  },
  { _id: false },
);

const Action: mongoose.Schema<IAction> = new Schema<IAction>({
  user: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User',
    index: true,
    required: true,
  },
  action_id: {
    type: String,
    index: true,
    required: true,
  },
  type: {
    type: String,
    default: 'action_prototype',
  },
  settings: Schema.Types.Mixed,
  agent_id: {
    type: String,
    index: true,
  },
  assistant_id: {
    type: String,
    index: true,
  },
  metadata: {
    api_key: String,
    auth: AuthSchema,
    domain: {
      type: String,
      required: true,
    },
    privacy_policy_url: String,
    raw_spec: String,
    oauth_client_id: String,
    oauth_client_secret: String,
  },
  tenantId: {
    type: String,
    index: true,
  },
});

export default Action;