import "../../../../../../../dialect-helpers-DRI5pyY3.mjs";
import "../../../../../../../after-B1IIdH3Y.mjs";
import "../../../../../../../object-cache-Bok5j2ae.mjs";
import "../../../../../../../content-DhgEth4k.mjs";
import "../../../../../../../base64-CmWvODNW.mjs";
import "../../../../../../../types-CuW0zWDA.mjs";
import "../../../../../../../media-BrXIaMFN.mjs";
import "../../../../../../../user-BjAOvU3Z.mjs";
import "../../../../../../../taxonomy-BxGxZZdu.mjs";
import "../../../../../../../comment-CzeatwBV.mjs";
import "../../../../../../../options-DTTML-Tx.mjs";
import "../../../../../../../menus-Cfivc2Ad.mjs";
import "../../../../../../../redirect-IyfNirgS.mjs";
import "../../../../../../../request-cache-KCNHp_RJ.mjs";
import "../../../../../../../byline-registry-BOjqDOim.mjs";
import "../../../../../../../field-defs-cache-WUI88LX5.mjs";
import "../../../../../../../byline-Bm8ZgUP9.mjs";
import "../../../../../../../seo-DXu2UQnC.mjs";
import { A as handleSchemaFieldCreate, N as handleSchemaFieldList } from "../../../../../../../api-BFURZn1i.mjs";
import "../../../../../../../dashboard-EvEKF5en.mjs";
import "../../../../../../../content-refresh-CA4uKwzH.mjs";
import "../../../../../../../fts-manager-BbFaF_V8.mjs";
import "../../../../../../../registry-B65mUtPa.mjs";
import "../../../../../../../loader-CB6YHeul.mjs";
import "../../../../../../../schema-Blhoxp3P.mjs";
import "../../../../../../../zod-generator-CacrR-i8.mjs";
import "../../../../../../../seo-89-53DDs.mjs";
import "../../../../../../../sections-CpF5SaGr.mjs";
import "../../../../../../../settings-zhmdKyJQ.mjs";
import "../../../../../../../settings-rZyHEcNT.mjs";
import "../../../../../../../resolve-DR3wqMTy.mjs";
import "../../../../../../../taxonomies-Cnb4F-Pb.mjs";
import "../../../../../../../taxonomies-BGBd16Eu.mjs";
import "../../../../../../../manifest-schema-BHlgZM1W.mjs";
import "../../../../../../../types-DROWRxYV.mjs";
import "../../../../../../../ssrf-1g7usGBg.mjs";
import { a as unwrapResult, i as requireDb } from "../../../../../../../error-CkAseSqZ.mjs";
import { n as parseBody, t as isParseError } from "../../../../../../../parse-GmjecGct.mjs";
import { kt as createFieldBody } from "../../../../../../../redirects-DXEXBAII.mjs";
import "../../../../../../../byline-fields-2Lp5Hbgf.mjs";
import "../../../../../../../status-CqJQX1QN.mjs";
import "../../../../../../../api/schemas/index.mjs";
import { n as requirePerm } from "../../../../../../../authorize-Dz88F_Fw.mjs";

//#region src/astro/routes/api/schema/collections/[slug]/fields/index.ts
const prerender = false;
const GET = async ({ params, locals }) => {
	const { emdash, user } = locals;
	const collectionSlug = params.slug;
	const dbErr = requireDb(emdash?.db);
	if (dbErr) return dbErr;
	const denied = requirePerm(user, "schema:read");
	if (denied) return denied;
	return unwrapResult(await handleSchemaFieldList(emdash.db, collectionSlug));
};
const POST = async ({ params, request, locals }) => {
	const { emdash, user } = locals;
	const collectionSlug = params.slug;
	const dbErr = requireDb(emdash?.db);
	if (dbErr) return dbErr;
	const denied = requirePerm(user, "schema:manage");
	if (denied) return denied;
	const body = await parseBody(request, createFieldBody);
	if (isParseError(body)) return body;
	return unwrapResult(await handleSchemaFieldCreate(emdash.db, collectionSlug, body), 201);
};

//#endregion
export { GET, POST, prerender };
//# sourceMappingURL=index.mjs.map