{"version":3,"file":"_slug_.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/schema/orphans/[slug].ts"],"sourcesContent":["/**\n * Register orphaned table endpoint\n *\n * POST /_emdash/api/schema/orphans/:slug - Register an orphaned table as a collection\n */\n\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm } from \"#api/authorize.js\";\nimport { apiError, requireDb, unwrapResult } from \"#api/error.js\";\nimport { handleOrphanedTableRegister } from \"#api/index.js\";\nimport { parseOptionalBody, isParseError } from \"#api/parse.js\";\nimport { orphanRegisterBody } from \"#api/schemas.js\";\n\nexport const prerender = false;\n\nexport const POST: APIRoute = async ({ params, request, locals }) => {\n\tconst { emdash, user } = locals;\n\n\tconst dbErr = requireDb(emdash?.db);\n\tif (dbErr) return dbErr;\n\n\tconst denied = requirePerm(user, \"schema:manage\");\n\tif (denied) return denied;\n\n\tconst slug = params.slug;\n\tif (!slug) {\n\t\treturn apiError(\"VALIDATION_ERROR\", \"Slug is required\", 400);\n\t}\n\n\tconst options = await parseOptionalBody(request, orphanRegisterBody, {});\n\tif (isParseError(options)) return options;\n\n\tconst result = await handleOrphanedTableRegister(emdash.db, slug, options);\n\treturn unwrapResult(result, 201);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAa,YAAY;AAEzB,MAAa,OAAiB,OAAO,EAAE,QAAQ,SAAS,aAAa;CACpE,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,QAAQ,UAAU,QAAQ,GAAG;AACnC,KAAI,MAAO,QAAO;CAElB,MAAM,SAAS,YAAY,MAAM,gBAAgB;AACjD,KAAI,OAAQ,QAAO;CAEnB,MAAM,OAAO,OAAO;AACpB,KAAI,CAAC,KACJ,QAAO,SAAS,oBAAoB,oBAAoB,IAAI;CAG7D,MAAM,UAAU,MAAM,kBAAkB,SAAS,oBAAoB,EAAE,CAAC;AACxE,KAAI,aAAa,QAAQ,CAAE,QAAO;AAGlC,QAAO,aADQ,MAAM,4BAA4B,OAAO,IAAI,MAAM,QAAQ,EAC9C,IAAI"}