import { messageObjectTypesQuerySchema } from "../../data/validators.js";
import { getMessageObjectTypesForMessageType } from "../../lib/message-objects-registry.js";
import {
  messageObjectTypeListResponseSchema,
  messageObjectTypesQuerySchema as messageObjectTypesQueryOpenApiSchema
} from "../openapi.js";
const metadata = {
  GET: { requireAuth: true, requireFeatures: ["messages.compose"] }
};
async function GET(req) {
  const params = Object.fromEntries(new URL(req.url).searchParams);
  const parsed = messageObjectTypesQuerySchema.safeParse(params);
  if (!parsed.success) {
    return Response.json({ error: "messageType is required" }, { status: 400 });
  }
  const input = parsed.data;
  const items = getMessageObjectTypesForMessageType(input.messageType).map((objectType) => ({
    module: objectType.module,
    entityType: objectType.entityType,
    labelKey: objectType.labelKey,
    icon: objectType.icon,
    actions: objectType.actions.map((action) => ({
      id: action.id,
      labelKey: action.labelKey,
      variant: action.variant,
      icon: action.icon,
      commandId: action.commandId,
      href: action.href,
      isTerminal: action.isTerminal,
      confirmRequired: action.confirmRequired,
      confirmMessage: action.confirmMessage
    }))
  }));
  return Response.json({ items });
}
const openApi = {
  tag: "Messages",
  methods: {
    GET: {
      summary: "List registered message object types for a message type",
      query: messageObjectTypesQueryOpenApiSchema,
      responses: [
        { status: 200, description: "Message object types", schema: messageObjectTypeListResponseSchema },
        { status: 400, description: "Invalid query" }
      ]
    }
  }
};
export {
  GET,
  metadata,
  openApi
};
//# sourceMappingURL=route.js.map
