@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 120 kB
JavaScript
import{constants_default as e,logger_default as t,lucid_api_error_default as n,lucid_error_default as r,permission_groups_default as i,translations_default as a}from"./errors-RyYO6qM6.js";import{build_response_default as o,defaultErrorResponse as s,hono_swagger_paramaters_default as c,hono_swagger_request_body_default as l,hono_swagger_response_default as u}from"./swagger-B1fvTrVq.js";import{service_wrapper_default as d}from"./service-wrapper-Duby87GY.js";import{formatters_default as ee}from"./formatters-CNwZ581Q.js";import"./build-table-name-yLR81YJn.js";import{documentVersionResponseSchema as te,passthrough_processor_default as ne,services_default as f}from"./services-CB4SBOvq.js";import{controllerSchemas as p,package_default as re,stringTranslations as m}from"./helpers-V6u-T5es.js";import{authenticate_default as h,client_authenticate_default as g,content_locale_default as ie,log_route_default as ae,permissionCheck as _,permissions_default as v,validate_csrf_default as y,validate_default as b}from"./log-route-DYL_LxgN.js";import{sharp_processor_default as oe}from"./sharp-processor-BCi9CFoT.js";import se,{z as ce,default as x}from"zod/v4";import{Hono as S}from"hono";import{cors as le}from"hono/cors";import{secureHeaders as ue}from"hono/secure-headers";import{describeRoute as C,openAPISpecs as de}from"hono-openapi";import{createFactory as w}from"hono/factory";import{Kysely as fe,Migrator as pe,sql as me}from"kysely";import{Readable as he}from"node:stream";import{stream as ge}from"hono/streaming";import{Scalar as _e}from"@scalar/hono-api-reference";const T={getCSRF:{body:void 0,query:{string:void 0,formatted:void 0},params:void 0,response:x.object({_csrf:x.string().meta({description:`Store this value and use it for the _csrf header on required endpoints.`,example:`55b26b90b9715d0e9cc425e8f1ba565cad5157e3d56ae8380d8c832a5fb3fcb7`})})},login:{body:x.object({usernameOrEmail:x.string().meta({description:`Username or email address`,example:`admin`}),password:x.string().meta({description:`User password`,example:`password`})}).meta({description:`User credentials for login`}),query:{string:void 0,formatted:void 0},params:void 0,response:void 0},token:{body:void 0,query:{string:void 0,formatted:void 0},params:void 0,response:void 0},logout:{body:void 0,query:{string:void 0,formatted:void 0},params:void 0,response:void 0},setupRequired:{body:void 0,query:{string:void 0,formatted:void 0},params:void 0,response:x.object({setupRequired:x.boolean().meta({description:`Whether initial user setup is required`,example:!0})})},setup:{body:x.object({email:x.email().meta({description:`Admin user email address`,example:`admin@example.com`}),username:x.string().meta({description:`Admin username`,example:`admin`}),firstName:x.string().meta({description:`Admin first name`,example:`John`}).optional(),lastName:x.string().meta({description:`Admin last name`,example:`Doe`}).optional(),password:x.string().meta({description:`Admin password`,example:`securepassword123`})}).meta({description:`Initial admin user setup data`}),query:{string:void 0,formatted:void 0},params:void 0,response:void 0}},ve=w(),ye=ve.createHandlers(C({description:`Authenticates a user and sets a refresh and access token as httpOnly cookies.`,tags:[`auth`],summary:`Login`,responses:u(),parameters:c({headers:{csrf:!0}}),requestBody:l(T.login.body),validateResponse:!0}),y,b(`json`,T.login.body),async e=>{let{usernameOrEmail:t,password:r}=e.req.valid(`json`),i=await d(f.auth.login,{transaction:!1,defaultError:{type:`basic`,code:`login`,name:a(`route_login_error_name`),message:a(`route_login_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{usernameOrEmail:t,password:r});if(i.error)throw new n(i.error);let[o,s]=await Promise.all([f.auth.refreshToken.generateToken(e,i.data.id),f.auth.accessToken.generateToken(e,i.data.id)]);if(o.error)throw new n(o.error);if(s.error)throw new n(s.error);return e.status(204),e.body(null)});var be=ye;const xe=w(),Se=xe.createHandlers(C({description:`This endpoint returns a CSRF token in the response body as well as setting a _csrf httpOnly cookie. Some endpoints require this value to be passed via a _csrf header.`,tags:[`auth`],summary:`CSRF Token`,responses:u({schema:ce.toJSONSchema(T.getCSRF.response)}),validateResponse:!0}),async e=>{let t=await f.auth.csrf.generateToken(e);if(t.error)throw new n(t.error);return e.status(201),e.json(o(e,{data:{_csrf:t.data}}))});var Ce=Se;const we=w(),Te=we.createHandlers(C({description:`Logs out a user by clearing the refresh token and access token, it also clears the CSRF token.`,tags:[`auth`],summary:`Logout`,responses:u(),parameters:c({headers:{csrf:!0}}),validateResponse:!0}),y,h,async e=>{let[t,r,i]=await Promise.all([f.auth.refreshToken.clearToken(e),f.auth.accessToken.clearToken(e),f.auth.csrf.clearToken(e)]);if(t.error)throw new n(t.error);if(r.error)throw new n(r.error);if(i.error)throw new n(i.error);return e.status(204),e.body(null)});var Ee=Te;const De=w(),Oe=De.createHandlers(C({description:`Verifies the refresh token and issues a new access and refresh token.`,tags:[`auth`],summary:`Refresh Token`,responses:u(),parameters:c({headers:{csrf:!0}}),validateResponse:!0}),y,async e=>{let t=await f.auth.refreshToken.verifyToken(e);if(t.error)throw new n(t.error);let[r,i]=await Promise.all([f.auth.refreshToken.generateToken(e,t.data.user_id),f.auth.accessToken.generateToken(e,t.data.user_id)]);if(r.error)throw new n(r.error);if(i.error)throw new n(i.error);return e.status(204),e.body(null)});var ke=Oe;const Ae=w(),je=Ae.createHandlers(C({description:`Checks if initial user setup is required. Returns true if no users exist in the system.`,tags:[`auth`],summary:`Check Setup Required`,responses:u({schema:ce.toJSONSchema(T.setupRequired.response)}),validateResponse:!0}),async e=>{let t=await d(f.auth.setupRequired,{transaction:!1,defaultError:{type:`basic`,name:a(`route_setup_required_error_name`),message:a(`route_setup_required_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f});if(t.error)throw new n(t.error);return e.status(200),e.json(o(e,{data:t.data}))});var Me=je;const Ne=w(),Pe=Ne.createHandlers(C({description:`Creates the initial admin user. This endpoint can only be used when no users exist in the system.`,tags:[`auth`],summary:`Initial Admin Setup`,responses:u(),parameters:c({headers:{csrf:!0}}),requestBody:l(T.setup.body),validateResponse:!0}),y,b(`json`,T.setup.body),async e=>{let{email:t,username:r,firstName:i,lastName:o,password:s}=e.req.valid(`json`),c=await d(f.user.createInitialAdmin,{transaction:!0,defaultError:{type:`basic`,name:a(`route_user_create_error_name`),message:a(`route_user_create_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{email:t,username:r,firstName:i,lastName:o,password:s});if(c.error)throw new n(c.error);return e.status(204),e.body(null)});var Fe=Pe;const Ie=new S().get(`/csrf`,...Ce).get(`/setup-required`,...Me).post(`/setup`,...Fe).post(`/login`,...be).post(`/logout`,...Ee).post(`/token`,...ke);var Le=Ie;const Re=x.enum([`=`,`%`,`like`,`ilike`,`in`,`not in`,`<>`,`is not`,`is`,`!=`]).optional(),E={schema:{filter:(e=!1,t,n)=>x.string().meta({description:e?n||`Accepts multiple values separated by commas.`:n||`Accepts a single value only.`,example:t}).optional(),sort:e=>x.string().meta({description:`Orders results using comma-separated field names. Prefix with - for descending order.`,example:e}).optional(),include:e=>x.string().meta({description:`Specifies related resources to include in response as comma-separated values`,example:e}).optional(),exclude:e=>x.string().meta({description:`Defines fields to exclude from response as comma-separated values`,example:e}).optional(),page:x.string().regex(/^[1-9][0-9]*$/).describe(`Specifies the page number for pagination (must be a positive integer)`).optional(),perPage:x.string().regex(/^([1-9][0-9]*|-1)$/).describe(`Sets the number of items per page (use positive integer or -1 for all items)`).optional()},meta:{patternProperties:{"^filter\\[([^\\]:]+):?([^\\]]*)\\]$":{type:[`string`,`null`],description:`Dynamic filter parameter in format filter[fieldName:operator]. Supported operators include: '=', '%', 'like', 'ilike', 'in', 'not in', '<>', 'is not', 'is' and '!='.`}},additionalProperties:!1}},D={schema:{filters:{single:x.object({value:x.union([x.string(),x.number()]),operator:Re}),union:x.object({value:x.union([x.string(),x.array(x.string()),x.number(),x.array(x.number())]),operator:Re})},page:x.number(),perPage:x.number()}},ze=x.string().meta({description:`A permission identifier`,example:`create_user`}),Be=x.object({id:x.number().meta({description:`The role ID`,example:1}),name:x.string().meta({description:`The role name`,example:`Admin`})}),O=x.object({id:x.number().meta({description:`The user's ID`,example:1}),superAdmin:x.boolean().meta({description:`Whether the user is a superadmin.`,example:!0}),email:x.email().meta({description:`The user's email address`,example:`admin@lucidcms.io`}),username:x.string().meta({description:`The user's username`,example:`admin`}),firstName:x.string().nullable().meta({description:`The user's first name`,example:`John`}),lastName:x.string().nullable().meta({description:`The user's last name`,example:`Smith`}),triggerPasswordReset:x.boolean().nullable().meta({description:`Should the UI force a password reset?`,example:!1}),roles:x.array(Be).meta({description:`The user's roles`}),permissions:x.array(ze),createdAt:x.string().nullable().meta({description:`The date the user was added`,example:`2021-06-10T20:00:00.000Z`}),updatedAt:x.string().nullable().meta({description:`The date the user row was last updated`,example:`2021-06-10T20:00:00.000Z`})}),k={createSingle:{body:x.object({email:x.email().meta({description:`The user's email address`,example:`admin@lucidcms.io`}),username:x.string().meta({description:`The user's username`,example:`Admin`}),roleIds:x.array(x.number()).meta({description:`A list of role IDs to attach to the user`,example:[1,2]}),firstName:x.string().meta({description:`The user's first name`,example:`John`}).optional(),lastName:x.string().meta({description:`The user's last name`,example:`Smith`}).optional(),superAdmin:x.boolean().meta({description:`Whether the user is a super admin or not`,example:!0}).optional()}),query:{string:void 0,formatted:void 0},params:void 0,response:O},updateSingle:{body:x.object({roleIds:x.array(x.number()).meta({description:`A list of role IDs to attach to the user`,example:[1,2]}).optional(),superAdmin:x.boolean().meta({description:`Whether the user is a super admin or not`,example:!0}).optional(),triggerPasswordReset:x.boolean().meta({description:`Whether the user should be forced to update their password in the UI`,example:!0}).optional(),isDeleted:x.literal(!1).meta({description:`Restore a deleted user`,example:!1}).optional()}),query:{string:void 0,formatted:void 0},params:x.object({id:x.string().meta({description:`The user's ID`,example:1})}),response:void 0},getSingle:{body:void 0,query:{string:void 0,formatted:void 0},params:x.object({id:x.string().meta({description:`The user's ID`,example:1})}),response:O},getMultiple:{query:{string:x.object({"filter[firstName]":E.schema.filter(!1,`John`),"filter[lastName]":E.schema.filter(!1,`Smith`),"filter[email]":E.schema.filter(!1,`admin@lucidcms.io`),"filter[username]":E.schema.filter(!1,`admin`),"filter[roleIds]":E.schema.filter(!0,`1,2,3`),"filter[id]":E.schema.filter(!0,`1,2`),sort:E.schema.sort(`createdAt,updatedAt,firstName,lastName,email,username`),include:E.schema.include(`permissions`),page:E.schema.page,perPage:E.schema.perPage}).meta(E.meta),formatted:x.object({filter:x.object({firstName:D.schema.filters.single.optional(),lastName:D.schema.filters.single.optional(),email:D.schema.filters.single.optional(),username:D.schema.filters.single.optional(),roleIds:D.schema.filters.union.optional(),id:D.schema.filters.union.optional()}).optional(),sort:x.array(x.object({key:x.enum([`createdAt`,`updatedAt`,`firstName`,`lastName`,`email`,`username`]),value:x.enum([`asc`,`desc`])})).optional(),include:x.array(x.enum([`permissions`])).optional(),page:D.schema.page,perPage:D.schema.perPage})},params:void 0,body:void 0,response:x.array(O)},deleteSingle:{body:void 0,query:{string:void 0,formatted:void 0},params:x.object({id:x.string().meta({description:`The user's ID`,example:1})}),response:void 0}},A={getMe:{body:void 0,query:{string:void 0,formatted:void 0},params:void 0,response:O},resetPassword:{body:x.object({password:x.string().min(8).max(128).meta({description:`Your new password`,example:`password123`}),passwordConfirmation:x.string().min(8).max(128).meta({description:`A repeat of your new password`,example:`password123`})}).refine(e=>e.password===e.passwordConfirmation,{message:a(`please_ensure_passwords_match`),path:[`passwordConfirmation`]}),query:{string:void 0,formatted:void 0},params:x.object({token:x.string().meta({description:`A unique token granted to you when you request a password reset`,example:`838ece1033bf7c7468e873e79ba2a3ec`})}),response:void 0},sendResetPassword:{body:x.object({email:x.email().meta({description:`Your email address`,example:`admin@lucidcms.io`})}),query:{string:void 0,formatted:void 0},params:void 0,response:x.object({message:x.string().meta({description:`A status message`,example:a(`if_account_exists_with_email_not_found`)})})},verifyResetPassword:{body:void 0,query:{string:void 0,formatted:void 0},params:x.object({token:x.string().meta({description:`A unique token granted to you when you request a password reset`,example:`838ece1033bf7c7468e873e79ba2a3ec`})}),response:void 0},updateMe:{body:x.object({firstName:x.string().meta({description:`Your new first name`,example:`John`}).optional(),lastName:x.string().meta({description:`Your new last name`,example:`Smith`}).optional(),username:x.string().min(3).meta({description:`Your new username`,example:`admin`}).optional(),email:x.email().meta({description:`your new email address`,example:`admin@lucidcms.io`}).optional(),currentPassword:x.string().meta({description:`Your current password`,example:`password`}).optional(),newPassword:x.string().min(8).max(128).meta({description:`Your new password`,example:`password123`}).optional(),passwordConfirmation:x.string().min(8).max(128).meta({description:`A repeat of your new password`,example:`password123`}).optional()}),query:{string:void 0,formatted:void 0},params:void 0,response:void 0}},Ve=w(),He=Ve.createHandlers(C({description:`Returns the authenticated user based on the access token.`,tags:[`account`],summary:`Get Authenticated User`,responses:u({schema:x.toJSONSchema(A.getMe.response)}),validateResponse:!0}),h,async e=>{let t=await d(f.user.getSingle,{transaction:!1,defaultError:{type:`basic`,name:a(`route_user_fetch_error_name`),message:a(`route_user_fetch_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{userId:e.get(`auth`).id});if(t.error)throw new n(t.error);return e.status(200),e.json(o(e,{data:t.data}))});var Ue=He;const We=w(),Ge=We.createHandlers(C({description:`Resets the password for the authenticated user.`,tags:[`account`],summary:`Reset Password`,responses:u(),parameters:c({headers:{csrf:!0},params:A.resetPassword.params}),requestBody:l(A.resetPassword.body),validateResponse:!0}),y,b(`param`,A.resetPassword.params),b(`json`,A.resetPassword.body),async e=>{let{token:t}=e.req.valid(`param`),{password:r}=e.req.valid(`json`),i=await d(f.account.resetPassword,{transaction:!0,defaultError:{type:`basic`,name:a(`route_reset_password_error_name`),message:a(`route_reset_password_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{token:t,password:r});if(i.error)throw new n(i.error);return e.status(204),e.body(null)});var Ke=Ge;const qe=w(),Je=qe.createHandlers(C({description:`Sends an email to the given email address informing them to reset their password.`,tags:[`account`],summary:`Send Password Reset`,responses:u({schema:x.toJSONSchema(A.sendResetPassword.response)}),parameters:c({headers:{csrf:!0}}),requestBody:l(A.sendResetPassword.body),validateResponse:!0}),y,b(`json`,A.sendResetPassword.body),async e=>{let{email:t}=e.req.valid(`json`),r=await d(f.account.sendResetPassword,{transaction:!0,defaultError:{type:`basic`,name:a(`route_send_password_reset_error_name`),message:a(`route_send_password_reset_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{email:t});if(r.error)throw new n(r.error);return e.status(200),e.json(o(e,{data:r.data}))});var Ye=Je;const Xe=w(),Ze=Xe.createHandlers(C({description:`Update the authenticated user's information.`,tags:[`account`],summary:`Update Authenticated User`,responses:u(),parameters:c({headers:{csrf:!0}}),requestBody:l(A.updateMe.body),validateResponse:!0}),y,h,b(`json`,A.updateMe.body),async e=>{let{firstName:t,lastName:r,username:i,email:o,currentPassword:s,newPassword:c,passwordConfirmation:l}=e.req.valid(`json`),u=await d(f.account.updateMe,{transaction:!0,defaultError:{type:`basic`,name:a(`route_user_me_update_error_name`),message:a(`route_user_me_update_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{auth:e.get(`auth`),firstName:t,lastName:r,username:i,email:o,currentPassword:s,newPassword:c,passwordConfirmation:l});if(u.error)throw new n(u.error);return e.status(204),e.body(null)});var Qe=Ze;const $e=w(),et=$e.createHandlers(C({description:`Verifies the password reset token is valid.`,tags:[`account`],summary:`Verify Reset Token`,responses:u(),parameters:c({params:A.verifyResetPassword.params}),validateResponse:!0}),b(`param`,A.verifyResetPassword.params),async e=>{let{token:t}=e.req.valid(`param`),r=await d(f.user.token.getSingle,{transaction:!1,defaultError:{type:`basic`,name:a(`route_verify_password_reset_error_name`),message:a(`route_verify_password_reset_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{tokenType:`password_reset`,token:t});if(r.error)throw new n(r.error);return e.status(204),e.body(null)});var tt=et;const nt=new S().get(`/`,...Ue).patch(`/`,...Qe).patch(`/reset-password/:token`,...Ke).post(`/reset-password`,...Ye).get(`/reset-password/:token`,...tt);var rt=nt;const j=x.object({id:x.number().meta({description:`The client integration ID`,example:`26`}),key:x.string().meta({description:`A short unique key used to authenticate client query requests`,example:`bd61bb`}),name:x.string().min(2).meta({description:`The name of the client`,example:`Marketing Website`}),description:x.string().nullable().meta({description:`A description of the client`,example:`The Astro marketing site at example.com`}),enabled:x.boolean().meta({description:`Whether or not the client is active. If inactive you wont be able to use it to query data`,example:!0}),createdAt:x.string().nullable().meta({description:`The time the client integration was created`,example:`2022-01-01T00:00:00Z`}),updatedAt:x.string().nullable().meta({description:`The time the client integration was last updated`,example:`2022-01-01T00:00:00Z`})}),M={createSingle:{body:x.object({name:x.string().min(2).meta({description:`The name of the client`,example:`Marketing Website`}),description:x.string().meta({description:`A description of the client`,example:`The Astro marketing site at example.com`}).optional(),enabled:x.boolean().meta({description:`Whether or not the client is active. If inactive you wont be able to use it to query data`,example:!0}).optional()}),query:{string:void 0,formatted:void 0},params:void 0,response:x.object({apiKey:x.string().meta({description:`A unique token used to authenticate client endpoint requests. You'll only ever see this value once so keep it safe`,example:`3084d4531c41ca6db79f422a4426361176461667280556c333ffcff530486a1e`})})},deleteSingle:{body:void 0,query:{string:void 0,formatted:void 0},params:x.object({id:x.string().meta({description:`The client integration ID you want to delete`,example:`1`})}),response:void 0},getAll:{body:void 0,query:{string:void 0,formatted:void 0},params:void 0,response:x.array(j)},getSingle:{body:void 0,query:{string:void 0,formatted:void 0},params:x.object({id:x.string().meta({description:`The client integration ID`,example:`1`})}),response:j},regenerateKeys:{body:void 0,query:{string:void 0,formatted:void 0},params:x.object({id:x.string().meta({description:`The client integration ID`,example:`1`})}),response:x.object({apiKey:x.string().meta({description:`A unique token used to authenticate client endpoint requests. You'll only ever see this value once so keep it safe`,example:`3084d4531c41ca6db79f422a4426361176461667280556c333ffcff530486a1e`})})},updateSingle:{body:x.object({name:x.string().min(2).meta({description:`The name of the client`,example:`Marketing Website`}).optional(),description:x.string().meta({description:`A description of the client`,example:`The Astro marketing site at example.com`}).optional(),enabled:x.boolean().meta({description:`Whether or not the client is active. If inactive you wont be able to use it to query data`,example:!0}).optional()}),query:{string:void 0,formatted:void 0},params:x.object({id:x.string().meta({description:`The client integration ID`,example:`1`})}),response:void 0}},it=w(),at=it.createHandlers(C({description:`Creates a new client integration that can be used to authenticate client endpoints.`,tags:[`client-integrations`],summary:`Create Client Integration`,responses:u({schema:x.toJSONSchema(M.createSingle.response)}),parameters:c({headers:{csrf:!0}}),requestBody:l(M.createSingle.body),validateResponse:!0}),y,h,b(`json`,M.createSingle.body),async e=>{let{name:t,description:r,enabled:i}=e.req.valid(`json`),s=await d(f.clientIntegrations.createSingle,{transaction:!0,defaultError:{type:`basic`,name:a(`route_client_integrations_create_error_name`),message:a(`route_client_integrations_create_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{name:t,description:r,enabled:i});if(s.error)throw new n(s.error);return e.status(200),e.json(o(e,{data:s.data}))});var ot=at;const st=w(),ct=st.createHandlers(C({description:`Returns all client integrations.`,tags:[`client-integrations`],summary:`Get All Client Integrations`,responses:u({schema:x.toJSONSchema(M.getAll.response)}),validateResponse:!0}),h,async e=>{let t=await d(f.clientIntegrations.getAll,{transaction:!1,defaultError:{type:`basic`,name:a(`route_client_integrations_fetch_error_name`),message:a(`route_client_integrations_fetch_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f});if(t.error)throw new n(t.error);return e.status(200),e.json(o(e,{data:t.data}))});var lt=ct;const ut=w(),dt=ut.createHandlers(C({description:`Get a single client integration by ID.`,tags:[`client-integrations`],summary:`Get Client Integration`,responses:u({schema:x.toJSONSchema(M.getSingle.response)}),parameters:c({params:M.getSingle.params}),validateResponse:!0}),h,b(`param`,M.getSingle.params),async e=>{let{id:t}=e.req.valid(`param`),r=await d(f.clientIntegrations.getSingle,{transaction:!1,defaultError:{type:`basic`,name:a(`route_client_integrations_fetch_error_name`),message:a(`route_client_integrations_fetch_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{id:Number.parseInt(t)});if(r.error)throw new n(r.error);return e.status(200),e.json(o(e,{data:r.data}))});var ft=dt;const pt=w(),mt=pt.createHandlers(C({description:`Delete a single client integration by ID.`,tags:[`client-integrations`],summary:`Delete Client Integration`,responses:u({noProperties:!0}),parameters:c({headers:{csrf:!0},params:M.deleteSingle.params}),validateResponse:!0}),y,h,b(`param`,M.deleteSingle.params),async e=>{let{id:t}=e.req.valid(`param`),r=await d(f.clientIntegrations.deleteSingle,{transaction:!0,defaultError:{type:`basic`,name:a(`route_client_integrations_delete_error_name`),message:a(`route_client_integrations_delete_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{id:Number.parseInt(t)});if(r.error)throw new n(r.error);return e.status(204),e.body(null)});var ht=mt;const gt=w(),_t=gt.createHandlers(C({description:`Update a single client integration.`,tags:[`client-integrations`],summary:`Update Client Integration`,responses:u({noProperties:!0}),requestBody:l(M.updateSingle.body),parameters:c({headers:{csrf:!0},params:M.updateSingle.params}),validateResponse:!0}),y,h,b(`json`,M.updateSingle.body),b(`param`,M.updateSingle.params),async e=>{let{name:t,description:r,enabled:i}=e.req.valid(`json`),{id:o}=e.req.valid(`param`),s=await d(f.clientIntegrations.updateSingle,{transaction:!0,defaultError:{type:`basic`,name:a(`route_client_integrations_update_error_name`),message:a(`route_client_integrations_update_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{id:Number.parseInt(o),name:t,description:r,enabled:i});if(s.error)throw new n(s.error);return e.status(204),e.body(null)});var vt=_t;const yt=w(),bt=yt.createHandlers(C({description:`Regenerates the API key for the given client integration.`,tags:[`client-integrations`],summary:`Regenerate Client Integration API Key`,responses:u({schema:x.toJSONSchema(M.regenerateKeys.response)}),parameters:c({headers:{csrf:!0},params:M.regenerateKeys.params}),validateResponse:!0}),y,h,b(`param`,M.regenerateKeys.params),async e=>{let{id:t}=e.req.valid(`param`),r=await d(f.clientIntegrations.regenerateKeys,{transaction:!0,defaultError:{type:`basic`,name:a(`route_client_integrations_update_error_name`),message:a(`route_client_integrations_update_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{id:Number.parseInt(t)});if(r.error)throw new n(r.error);return e.status(200),e.json(o(e,{data:r.data}))});var xt=bt;const St=new S().post(`/`,...ot).get(`/`,...lt).get(`/:id`,...ft).delete(`/:id`,...ht).patch(`/:id`,...vt).post(`/:id/regenerate-keys`,...xt);var Ct=St;const N=x.object({key:x.string(),type:x.union([x.literal(`text`),x.literal(`wysiwyg`),x.literal(`media`),x.literal(`number`),x.literal(`checkbox`),x.literal(`select`),x.literal(`textarea`),x.literal(`json`),x.literal(`colour`),x.literal(`datetime`),x.literal(`link`),x.literal(`repeater`),x.literal(`user`),x.literal(`document`)]),translations:x.record(x.string(),x.any()).optional(),value:x.any().optional(),get groups(){return x.array(x.object({ref:x.string(),order:x.number().optional(),open:x.boolean().optional(),get fields(){return x.array(N)}})).optional()}}),P=x.object({key:x.string().meta({description:`Unique identifier for the field`,example:`pageTitle`}),type:x.string().meta({description:`Type of the field (text, checkbox, media, etc.)`,example:`text`}),collection:x.string().nullable().meta({description:`Collection key for document reference fields`,example:`page`}).optional(),details:x.object({label:m.meta({description:`Display label for the field`,example:{en:`Page title`}}).optional(),summary:m.meta({description:`Description text for the field`,example:`The title of the page.`}).optional(),placeholder:m.meta({description:`Placeholder text for input fields`,example:`Enter page title...`}).optional(),true:m.meta({description:`Label for true value in boolean fields`,example:`Yes`}).optional(),false:m.meta({description:`Label for false value in boolean fields`,example:`No`}).optional()}),config:x.object({useTranslations:x.boolean().meta({description:`Whether the field supports translations`,example:!0}).nullable().optional(),isHidden:x.boolean().meta({description:`Whether the field is hidden in the UI`,example:!1}).nullable().optional(),isDisabled:x.boolean().meta({description:`Whether the field is disabled for editing`,example:!1}).nullable().optional(),default:x.any().meta({description:`Default value for the field`,example:`Welcome to our website`}).nullable().optional()}).optional(),validation:x.object({required:x.boolean().nullable().meta({description:`Whether the field is required`,example:!0}).optional(),zod:x.any().nullable().meta({description:`Custom Zod validation schema for the field`,example:`z.string().min(2).max(128)`}).optional(),type:x.string().nullable().meta({description:`Media type constraint for media fields`,example:`image`}).optional(),maxGroups:x.number().nullable().meta({description:`Maximum groups allowed in a repeater`,example:3}).optional(),minGroups:x.number().nullable().meta({description:`Minimum groups required in a repeater`,example:1}).optional(),extensions:x.array(x.string()).nullable().meta({description:`Allowed file extensions for media fields`,example:[`jpg`,`png`,`webp`]}).optional(),width:x.object({min:x.number().nullable().meta({description:`Minimum width for media`,example:800}),max:x.number().nullable().meta({description:`Maximum width for media`,example:1920})}).optional().nullable(),height:x.object({min:x.number().nullable().meta({description:`Minimum height for media`,example:600}),max:x.number().nullable().meta({description:`Maximum height for media`,example:1080})}).optional().nullable()}).optional(),fields:x.any().meta({description:`Nested fields for repeater or tab field types`,example:[]}).optional(),options:x.array(x.object({label:m.meta({description:`Display label for the option`,example:{en:`Option A`}}),value:x.string().meta({description:`Value of the option when selected`,example:`option_a`})})).nullable().meta({description:`Options for select field types`,example:[{label:{en:`Option A`},value:`option_a`}]}).optional(),presets:x.array(x.string()).nullable().meta({description:`Preset values for colour fields`,example:[`#ff0000`,`#00ff00`,`#0000ff`]}).optional()}),F=x.object({ref:x.string().meta({description:`Unique reference for this field group`,example:`3243243`}),order:x.number().meta({description:`The order/position of this group in its parent`,example:0}),open:x.boolean().meta({description:`Whether this group is expanded in the UI`,example:!0})}),wt=F.extend({get fields(){return x.array(x.any())}}),Tt=F.extend({get fields(){return x.record(x.any(),x.any())}}),I=x.object({key:x.string().meta({description:`The fields key`,example:`pageTitle`}),type:x.string().meta({description:`The type of field (e.g., text, number, media)`,example:`text`}),groupRef:x.string().meta({description:`Reference to the group this field belongs to, if applicable`,example:`3243243`}).optional(),translations:x.record(x.any(),x.any()).meta({description:`Translations of the field value for different locales`,example:{en:`Welcome to our website`,fr:`Bienvenue sur notre site web`}}).optional(),value:x.any().meta({description:`The value of the field`,example:`Welcome to our website`}).optional(),meta:x.union([x.record(x.any(),x.any()),x.any()]).optional()}),L=I.extend({get groups(){return x.array(wt)}}),R=I.extend({get groups(){return x.array(Tt)}}),z=x.object({id:x.number().nullable().optional(),ref:x.string(),key:x.string(),order:x.number(),type:x.union([x.literal(`builder`),x.literal(`fixed`)]),open:x.boolean().optional(),fields:x.array(N).optional()}),B=x.object({key:x.string().min(1).meta({description:`Unique identifier for the brick`,example:`banner`}),details:x.object({name:m.meta({description:`Display name for the brick`,example:{en:`Banner`}}),summary:m.nullable().meta({description:`Description text for the brick`,example:`A banner with a title and intro text`}).optional()}),preview:x.object({image:x.string().nullable().meta({description:`Preview image URL for the brick`,example:`https://example.com/banner-brick.png`}).optional()}),get fields(){return x.array(P)}}),V=x.object({id:x.number().meta({description:`The ID of the brick row`,example:1}),key:x.string().meta({description:`The key that identifies the brick`,example:`hero`}),ref:x.string().meta({description:`The unique reference identifier for this brick`,example:`7645654`}),order:x.number().meta({description:`The position order of this brick in the document`,example:0}),open:x.boolean().meta({description:`Whether this brick is expanded in the UI`,example:!0}),type:x.enum([`builder`,`fixed`]).meta({description:`The type of brick`,example:`builder`})}).meta({additionalProperties:!0}),Et=V.extend({get fields(){return x.array(L)}}),Dt=V.extend({get fields(){return x.record(x.any(),x.array(R))}}),Ot=x.object({requiresMigration:x.boolean().meta({description:`Whether the collection requires a database migration`,example:!1}),missingColumns:x.record(x.string(),x.array(x.string())).meta({description:`Columns that are missing from the database`,example:{"document-fields":[`title`]}}),hiddenFields:x.record(x.string(),x.array(x.string())).meta({description:`Fields that are hidden from the collection`,example:{banner:[`heading`]}})}),H=x.object({key:x.string().meta({description:`The collection key`,example:`page`}),mode:x.enum([`single`,`multiple`]).meta({description:`Whether the collection has one document or multiple documents`,example:`multiple`}),documentId:x.number().nullable().meta({description:`The document ID if the collection is mode "single" and had one created`,example:1}).optional(),details:x.object({name:x.any().meta({description:`Display name for the collection`,example:`Pages`}),singularName:x.any().meta({description:`Singular display name for items in the collection`,example:{en:`Page`}}),summary:x.any().nullable().meta({description:`Description text for the collection`,example:`Manage the pages and content on your website.`})}),config:x.object({useTranslations:x.boolean().meta({description:`Whether the collection supports translations`,example:!0}),useDrafts:x.boolean().meta({description:`Whether the collection supports draft documents`,example:!0}),useRevisions:x.boolean().meta({description:`Whether the collection supports document revisions`,example:!0}),isLocked:x.boolean().meta({description:`Whether the collection structure is locked from editing`,example:!1}),displayInListing:x.array(x.string()).meta({description:`Field keys to display in the document listing columns`,example:[`pageTitle`,`author`,`fullSlug`,`slug`]})}),migrationStatus:Ot.nullable(),get fixedBricks(){return x.array(B).meta({description:`Fixed (non-movable) bricks for all documents in the collection`,example:[]}).optional()},get builderBricks(){return x.array(B).meta({description:`Builder bricks that can be added to documents in the collection`,example:[]}).optional()},get fields(){return x.array(P).meta({description:`Fields that make up documents in the collection`,example:[]})}}),U={getSingle:{body:void 0,query:{string:void 0,formatted:void 0},params:x.object({key:x.string().meta({description:`The collection key`,example:`page`})}),response:H},getAll:{body:void 0,query:{string:void 0,formatted:void 0},params:void 0,response:x.array(H)}},kt=w(),At=kt.createHandlers(C({description:`Get a single collection instance.`,tags:[`collections`],summary:`Get Collection`,responses:u({schema:x.toJSONSchema(U.getSingle.response)}),parameters:c({params:U.getSingle.params}),validateResponse:!0}),h,b(`param`,U.getSingle.params),async e=>{let{key:t}=e.req.valid(`param`),r=await d(f.collection.getSingle,{transaction:!1,defaultError:{type:`basic`,name:a(`route_collection_fetch_error_name`),message:a(`route_collection_fetch_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{key:t});if(r.error)throw new n(r.error);return e.status(200),e.json(o(e,{data:r.data}))});var jt=At;const Mt=w(),Nt=Mt.createHandlers(C({description:`Returns all the config for all collection instances.`,tags:[`collections`],summary:`Get All Collections`,responses:u({schema:x.toJSONSchema(U.getAll.response)}),validateResponse:!0}),h,async e=>{let t=await d(f.collection.getAll,{transaction:!1,defaultError:{type:`basic`,name:a(`route_collection_fetch_error_name`),message:a(`route_collection_fetch_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{includeDocumentId:!0});if(t.error)throw new n(t.error);return e.status(200),e.json(o(e,{data:t.data}))});var Pt=Nt;const Ft=new S().get(`/`,...Pt).get(`/:key`,...jt);var It=Ft;const W=x.object({id:x.number().meta({description:`The user ID`,example:42}),email:x.email().nullable().meta({description:`The email address of the user`,example:`admin@lucidcms.io`}),firstName:x.string().nullable().meta({description:`The first name of the user`,example:`John`}),lastName:x.string().nullable().meta({description:`The last name of the user`,example:`Smith`}),username:x.string().nullable().meta({description:`The username of the user`,example:`admin`})}),G=x.object({id:x.number().nullable().meta({description:`The document version ID`,example:5}),promotedFrom:x.number().nullable().meta({description:`The ID of the version this was promoted from, if applicable`,example:3}),createdAt:x.string().nullable().meta({description:`The timestamp when this version was created`,example:`2025-04-10T14:30:00Z`}),createdBy:x.number().nullable().meta({description:`The ID of the user who created this version`,example:42})}),K=x.object({id:x.number().meta({description:`The document ID`,example:123}),collectionKey:x.string().meta({description:`The key of the collection this document belongs to`,example:`page`}),status:x.enum([`draft`,`published`,`revision`]).nullable().meta({description:`The current status of the document`,example:`published`}),versionId:x.number().nullable().meta({description:`The current version ID`,example:1}),version:x.object({draft:G.nullable(),published:G.nullable()}),createdBy:W.nullable(),updatedBy:W.nullable(),createdAt:x.string().nullable().meta({description:`The timestamp when this document was created`,example:`2025-04-08T09:00:00Z`}),updatedAt:x.string().nullable().meta({description:`The timestamp when this document was last updated`,example:`2025-04-10T15:45:00Z`})}),Lt=K.extend({bricks:x.array(Et).nullable().optional(),fields:x.array(L).nullable().optional()}),Rt=K.extend({bricks:x.array(Dt).nullable().optional(),fields:x.record(x.string(),x.array(R)).nullable().optional()}),q={createSingle:{body:x.object({publish:x.boolean().meta({description:`Whether it should be published or be a draft.`,example:!1}),bricks:x.array(z).meta({description:`An array of bricks to be added to the document`}).optional(),fields:x.array(N).meta({description:`Collection field values`}).optional()}),query:{string:void 0,formatted:void 0},params:x.object({collectionKey:x.string().meta({description:`The collection key`,example:`page`})}),response:x.object({id:x.number().meta({description:`The new document's ID`,example:1})})},createVersion:{body:x.object({publish:x.boolean().meta({description:`Whether it should be published or be a draft.`,example:!1}),bricks:x.array(z).meta({description:`An array of bricks to be added to the document`}).optional(),fields:x.array(N).meta({description:`Collection field values`}).optional()}),query:{string:void 0,formatted:void 0},params:x.object({id:x.string().meta({description:`The document's ID`,example:1}),collectionKey:x.string().meta({description:`The collection key`,example:`page`})}),response:x.object({id:x.number().meta({description:`The document's ID`,example:1})})},updateVersion:{body:x.object({bricks:x.array(z).meta({description:`An array of bricks to be added to the document`}).optional(),fields:x.array(N).meta({description:`Collection field values`}).optional()}),query:{string:void 0,formatted:void 0},params:x.object({id:x.string().meta({description:`The document's ID`,example:1}),collectionKey:x.string().meta({description:`The collection key`,example:`page`}),versionId:x.string().meta({description:`The version ID`,example:1})}),response:x.object({id:x.number().meta({description:`The document's ID`,example:1})})},deleteMultiple:{body:x.object({ids:x.array(x.number()).meta({description:`An array of document IDs you wish to delete`,example:[1,2,3]})}),query:{string:void 0,formatted:void 0},params:x.object({collectionKey:x.string().meta({description:`The collection key`,example:`page`})}),response:void 0},deleteSingle:{body:void 0,query:{string:void 0,formatted:void 0},params:x.object({collectionKey:x.string().meta({description:`The collection key`,example:`page`}),id:x.string().meta({description:`The document ID`,example:1})}),response:void 0},getMultipleRevisions:{body:void 0,query:{string:x.object({"filter[createdBy]":E.schema.filter(!0,`1`),sort:E.schema.sort(`createdAt`),page:E.schema.page,perPage:E.schema.perPage}).meta(E.meta),formatted:x.object({filter:x.object({createdBy:x.union([D.schema.filters.single,D.schema.filters.union]).optional()}).optional(),sort:x.array(x.object({key:x.enum([`createdAt`]),value:x.enum([`asc`,`desc`])})).optional(),page:D.schema.page,perPage:D.schema.perPage})},params:x.object({collectionKey:x.string().meta({description:`The collection key`,example:`page`}),id:x.string().meta({description:`The document ID`,example:1})}),response:x.array(te)},getMultiple:{query:{string:x.object({"filter[id]":E.schema.filter(!0,`1`),"filter[createdBy]":E.schema.filter(!0,`1`),"filter[updatedBy]":E.schema.filter(!0,`1`),"filter[createdAt]":E.schema.filter(!1,`2025-03-15T09:22:10Z`),"filter[updatedAt]":E.schema.filter(!1,`2025-03-15T09:22:10Z`),"filter[_customFieldKey]":E.schema.filter(!0,void 0,`Prefix custom field keys with an underscore to filter by them`),"filter[brickKey._customFieldKey]":E.schema.filter(!0,void 0,`Add a brick key before the custom field key to filter against the brick`),"filter[brickKey.repeaterKey._customFieldKey]":E.schema.filter(!0,void 0,`Target a repeater field by adding a repeater key after the brick key`),sort:E.schema.sort(`createdAt,updatedAt`),page:E.schema.page,perPage:E.schema.perPage}).meta(E.meta),formatted:x.object({filter:x.union([x.record(x.string(),x.union([D.schema.filters.single,D.schema.filters.union])),x.object({id:x.union([D.schema.filters.single,D.schema.filters.union]).optional(),createdBy:x.union([D.schema.filters.single,D.schema.filters.union]).optional(),updatedBy:x.union([D.schema.filters.single,D.schema.filters.union]).optional(),createdAt:D.schema.filters.single.optional(),updatedAt:D.schema.filters.single.optional()})]).optional(),sort:x.array(x.object({key:x.enum([`createdAt`,`updatedAt`]),value:x.enum([`asc`,`desc`])})).optional(),page:D.schema.page,perPage:D.schema.perPage})},params:x.object({collectionKey:x.string().meta({description:`The collection key`,example:`page`}),status:x.enum([`published`,`draft`]).meta({description:`The status version type`,example:`draft`})}),body:void 0,response:x.array(Lt)},getSingle:{query:{string:x.object({include:E.schema.include(`bricks`)}),formatted:x.object({include:x.array(x.enum([`bricks`])).optional()})},params:x.object({id:x.string().meta({description:`The document ID`,example:1}),statusOrId:x.union([x.literal(`published`),x.literal(`draft`),x.string()]).meta({description:`The status (version type), or a version ID`,example:`draft`}),collectionKey:x.string().meta({description:`The collection key`,example:`page`})}),body:void 0,response:Lt},promoteVersion:{body:x.object({versionType:x.enum([`draft`,`published`]).meta({description:`The version type you want to promote it to`,example:`published`})}),query:{string:void 0,formatted:void 0},params:x.object({collectionKey:x.string().meta({description:`The collection key`,example:`page`}),id:x.string().meta({description:`The document ID`,example:1}),versionId:x.string().meta({description:`The version ID you want to promote`,example:2})}),response:void 0},restoreRevision:{body:void 0,query:{string:void 0,formatted:void 0},params:x.object({collectionKey:x.string().meta({description:`The collection key`,example:`page`}),id:x.string().meta({description:`The document ID`,example:1}),versionId:x.string().meta({description:`The version ID you want to promote`,example:2})}),response:void 0},client:{getSingle:{query:{string:x.object({"filter[id]":E.schema.filter(!0,`1`),"filter[createdBy]":E.schema.filter(!0,`1`),"filter[updatedBy]":E.schema.filter(!0,`1`),"filter[createdAt]":E.schema.filter(!1,`2025-03-15T09:22:10Z`),"filter[updatedAt]":E.schema.filter(!1,`2025-03-15T09:22:10Z`),"filter[_customFieldKey]":E.schema.filter(!0,void 0,`Prefix custom field keys with an underscore to filter by them`),"filter[brickKey._customFieldKey]":E.schema.filter(!0,void 0,`Add a brick key before the custom field key to filter against the brick`),"filter[brickKey.repeaterKey._customFieldKey]":E.schema.filter(!0,void 0,`Target a repeater field by adding a repeater key after the brick key`),include:E.schema.include(`bricks`),page:E.schema.page,perPage:E.schema.perPage}).meta(E.meta),formatted:x.object({filter:x.union([x.record(x.string(),x.union([D.schema.filters.single,D.schema.filters.union])),x.object({id:D.schema.filters.single.optional(),createdBy:D.schema.filters.single.optional(),updatedBy:D.schema.filters.single.optional(),createdAt:D.schema.filters.single.optional(),updatedAt:D.schema.filters.single.optional()})]).optional(),include:x.array(x.enum([`bricks`])).optional()})},params:x.object({collectionKey:x.string().meta({description:`The collection key`,example:`page`}),status:x.enum([`published`,`draft`]).meta({description:`The status version type`,example:`draft`})}),body:void 0,response:Rt},getMultiple:{query:{string:x.object({"filter[id]":E.schema.filter(!0,`1`),"filter[createdBy]":E.schema.filter(!0,`1`),"filter[updatedBy]":E.schema.filter(!0,`1`),"filter[createdAt]":E.schema.filter(!1,`2025-03-15T09:22:10Z`),"filter[updatedAt]":E.schema.filter(!1,`2025-03-15T09:22:10Z`),"filter[_customFieldKey]":E.schema.filter(!0,void 0,`Prefix custom field keys with an underscore to filter by them`),"filter[brickKey._customFieldKey]":E.schema.filter(!0,void 0,`Add a brick key before the custom field key to filter against the brick`),"filter[brickKey.repeaterKey._customFieldKey]":E.schema.filter(!0,void 0,`Target a repeater field by adding a repeater key after the brick key`),sort:E.schema.sort(`createdAt,updatedAt`),page:E.schema.page,perPage:E.schema.perPage}).meta(E.meta),formatted:x.object({filter:x.union([x.record(x.string(),x.union([D.schema.filters.single,D.schema.filters.union])),x.object({id:x.union([D.schema.filters.single,D.schema.filters.union]).optional(),createdBy:x.union([D.schema.filters.single,D.schema.filters.union]).optional(),updatedBy:x.union([D.schema.filters.single,D.schema.filters.union]).optional(),createdAt:D.schema.filters.single.optional(),updatedAt:D.schema.filters.single.optional()})]).optional(),sort:x.array(x.object({key:x.enum([`createdAt`,`updatedAt`]),value:x.enum([`asc`,`desc`])})).optional(),page:D.schema.page,perPage:D.schema.perPage})},params:x.object({collectionKey:x.string().meta({description:`The collection key`,example:`page`}),status:x.enum([`published`,`draft`]).meta({description:`The status version type`,example:`draft`})}),body:void 0,response:x.array(Rt)}}},zt=w(),Bt=zt.createHandlers(C({description:`Create a single document for a given collection.`,tags:[`documents`],summary:`Create Document`,responses:u({schema:x.toJSONSchema(q.createSingle.response)}),requestBody:l(q.createSingle.body),parameters:c({params:q.createSingle.params,headers:{csrf:!0}}),validateResponse:!0}),y,h,b(`json`,q.createSingle.body),b(`param`,q.createSingle.params),async e=>{let{publish:t,bricks:r,fields:i}=e.req.valid(`json`),{collectionKey:s}=e.req.valid(`param`);_(e,t?[`publish_content`]:[`create_content`]);let c=await d(f.collection.documents.upsertSingle,{transaction:!0,defaultError:{type:`basic`,name:a(`route_document_create_error_name`),message:a(`route_document_create_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{collectionKey:s,publish:t,userId:e.get(`auth`).id,bricks:r,fields:i});if(c.error)throw new n(c.error);return e.status(200),e.json(o(e,{data:{id:c.data}}))});var Vt=Bt;const Ht=w(),Ut=Ht.createHandlers(C({description:`Create a new version for a single document for a given collection key and document ID.`,tags:[`documents`],summary:`Create Document Version`,responses:u({schema:x.toJSONSchema(q.createVersion.response)}),requestBody:l(q.createVersion.body),parameters:c({params:q.createVersion.params,headers:{csrf:!0}}),validateResponse:!0}),y,h,b(`json`,q.createVersion.body),b(`param`,q.createVersion.params),async e=>{let{publish:t,bricks:r,fields:i}=e.req.valid(`json`),{collectionKey:s,id:c}=e.req.valid(`param`);_(e,t?[`publish_content`]:[`create_content`]);let l=await d(f.collection.documents.upsertSingle,{transaction:!0,defaultError:{type:`basic`,name:a(`route_document_create_error_name`),message:a(`route_document_create_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{collectionKey:s,publish:t,userId:e.get(`auth`).id,documentId:Number.parseInt(c),bricks:r,fields:i});if(l.error)throw new n(l.error);return e.status(200),e.json(o(e,{data:{id:l.data}}))});var Wt=Ut;const Gt=w(),Kt=Gt.createHandlers(C({description:`Delete a multiple documents for a given collection.`,tags:[`documents`],summary:`Delete Multiple Documents`,responses:u({noProperties:!0}),requestBody:l(q.deleteMultiple.body),parameters:c({params:q.deleteMultiple.params,headers:{csrf:!0}}),validateResponse:!0}),y,h,v([`delete_content`]),b(`json`,q.deleteMultiple.body),b(`param`,q.deleteMultiple.params),async e=>{let{ids:t}=e.req.valid(`json`),{collectionKey:r}=e.req.valid(`param`),i=await d(f.collection.documents.deleteMultiple,{transaction:!0,defaultError:{type:`basic`,name:a(`route_document_delete_error_name`),message:a(`route_document_delete_error_message`)}})({db:e.get(`config`).db.client,config:e.get(`config`),services:f},{ids:t,collectionKey:r,userId:e.get(`auth`).id});if(i.error)throw new n(i.error);return e.status(204),e.body(null)});var qt=Kt;const Jt=w(),Yt=Jt.createHandlers(C({description:`Delete a single document for a given collection and ID.`,tags:[`documents`],summary:`Delete Document`,responses:u({noProperties:!0}),parameters:c({params:q.deleteSingle.params,head