UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 19.1 kB
import{documentVersionResponseSchema as e,versionTypesSchema as t}from"./document-versions.mjs";import{queryFormatted as n,queryString as r}from"./helpers/querystring.mjs";import{profilePictureResponseSchema as i}from"./media.mjs";import{fieldInputSchema as a,fieldResponseSchema as o}from"./collection-fields.mjs";import{brickInputSchema as s,brickResponseSchema as c}from"./collection-bricks.mjs";import l from"zod";const u=l.string().meta({description:`An opaque preview token`}),d=l.string().trim().min(1).refine(e=>e!==`revision`&&e!==`snapshot`,{message:`Revisions and snapshots can only be accessed through a preview.`}).meta({description:`Latest or a configured collection environment`,example:`production`}),f=l.object({id:l.number().meta({description:`The user ID`,example:42}),email:l.email().nullable().meta({description:`The email address of the user`,example:`admin@lucidcms.io`}),firstName:l.string().nullable().meta({description:`The first name of the user`,example:`John`}),lastName:l.string().nullable().meta({description:`The last name of the user`,example:`Smith`}),username:l.string().nullable().meta({description:`The username of the user`,example:`admin`}),profilePicture:i.nullable()}),p=l.object({id:l.number().nullable().meta({description:`The document version ID`,example:5}),promotedFrom:l.number().nullable().meta({description:`The ID of the version this was promoted from, if applicable`,example:3}),contentId:l.string().nullable().meta({description:`The content ID of the version`,example:`123e4567-e89b-12d3-a456-426614174000`}),createdAt:l.string().nullable().meta({description:`The timestamp when this version was created`,example:`2025-04-10T14:30:00Z`}),updatedAt:l.string().nullable().meta({description:`The timestamp when this version was last updated`,example:`2025-04-10T15:45:00Z`}),createdBy:l.number().nullable().meta({description:`The ID of the user who created this version`,example:42})}),m=l.object({id:l.number(),email:l.string().nullable(),username:l.string().nullable(),firstName:l.string().nullable(),lastName:l.string().nullable(),profilePicture:i.nullable()}),h=l.object({stage:l.string(),assignees:l.array(l.object({id:l.number(),user:m,assignedBy:l.number().nullable(),assignedAt:l.string().nullable()})),createdAt:l.string().nullable(),updatedAt:l.string().nullable(),updatedBy:l.number().nullable()}),g=l.object({id:l.number().meta({description:`The document ID`,example:123}),collectionKey:l.string().meta({description:`The key of the collection this document belongs to`,example:`page`}),version:l.string().nullable().meta({description:`The current version of the document`,example:`latest`}),versionId:l.number().nullable().meta({description:`The current version ID`,example:1}),versions:l.record(l.string(),p.nullable()),isDeleted:l.boolean().meta({description:`Whether the document has been deleted`,example:!1}),createdBy:f.nullable(),updatedBy:f.nullable(),createdAt:l.string().nullable().meta({description:`The timestamp when this document was created`,example:`2025-04-08T09:00:00Z`}),updatedAt:l.string().nullable().meta({description:`The timestamp when this document was last updated`,example:`2025-04-10T15:45:00Z`})}).extend({bricks:l.array(c).nullable().optional(),fields:l.array(o).nullable().optional(),refs:l.record(l.string(),l.array(l.any())).nullable().optional(),workflow:h.nullable().optional()}),_=l.object({id:l.number(),collectionKey:l.string(),version:l.string().nullable(),fields:l.record(l.string(),l.unknown()),bricks:l.array(l.object({id:l.number(),ref:l.string(),key:l.string(),type:l.enum([`builder`,`fixed`]),order:l.number(),fields:l.record(l.string(),l.unknown())})).optional(),refs:l.record(l.string(),l.array(l.any())).optional(),meta:l.object({versionId:l.number().nullable(),versions:l.record(l.string(),p.nullable()),createdAt:l.string().nullable(),updatedAt:l.string().nullable(),createdBy:l.number().nullable(),updatedBy:l.number().nullable()}).optional()}),v=l.union([l.literal(`refs`),l.string().regex(/^refs\.[^,\s]+$/)]),y=l.union([l.enum([`createdAt`,`updatedAt`,`order`]),l.string().regex(/^_[a-zA-Z0-9-_]+$/)]),b=l.array(l.object({key:y,direction:l.enum([`asc`,`desc`])})).optional(),x={createSingle:{body:l.object({bricks:l.array(s).meta({description:`An array of bricks to be added to the document`}).optional(),fields:l.array(a).meta({description:`Collection field values`}).optional()}),query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`})}),response:l.object({id:l.number().meta({description:`The new document's ID`,example:1})})},createVersion:{body:l.object({bricks:l.array(s).meta({description:`An array of bricks to be added to the document`}).optional(),fields:l.array(a).meta({description:`Collection field values`}).optional()}),query:{string:void 0,formatted:void 0},params:l.object({id:l.string().trim().meta({description:`The document's ID`,example:1}),collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`})}),response:l.object({id:l.number().meta({description:`The document's ID`,example:1})})},updateVersion:{body:l.object({bricks:l.array(s).meta({description:`An array of bricks to be added to the document`}).optional(),fields:l.array(a).meta({description:`Collection field values`}).optional()}),query:{string:void 0,formatted:void 0},params:l.object({id:l.string().trim().meta({description:`The document's ID`,example:1}),collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`}),versionId:l.string().trim().meta({description:`The version ID`,example:1})}),response:l.object({id:l.number().meta({description:`The document's ID`,example:1}),versionId:l.number().meta({description:`The updated version ID`,example:1}),versionType:t.meta({description:`The updated version type`,example:`latest`}),contentId:l.string().meta({description:`The updated version content ID`,example:`123e4567-e89b-12d3-a456-426614174000`}),updatedAt:l.string().nullable().meta({description:`The timestamp when this version was updated`,example:`2025-04-10T15:45:00Z`})})},checkVersion:{body:l.object({bricks:l.array(s).meta({description:`An array of draft bricks to check`}).optional(),fields:l.array(a).meta({description:`Draft collection field values to check`}).optional()}),query:{string:void 0,formatted:void 0},params:l.object({id:l.string().trim().meta({description:`The document's ID`,example:1}),collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`}),versionId:l.string().trim().meta({description:`The version ID`,example:1})}),response:l.object({bricks:l.array(s),fields:l.array(a)})},createPreview:{body:l.object({locale:l.string().trim().min(1).optional(),mode:l.enum([`perspective`,`scoped`]).optional(),versionType:t,versionId:l.number().int().positive().optional()}),query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim(),id:l.string().trim()}),response:l.object({url:l.url().nullable(),expiresAt:l.iso.datetime().nullable()})},deleteMultiple:{body:l.object({ids:l.array(l.number()).meta({description:`An array of document IDs you wish to delete`,example:[1,2,3]})}),query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`})}),response:void 0},deleteSingle:{body:void 0,query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`}),id:l.string().trim().meta({description:`The document ID`,example:1})}),response:void 0},deleteSinglePermanently:{body:void 0,query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`}),id:l.string().trim().meta({description:`The document ID`,example:1})}),response:void 0},deleteMultiplePermanently:{body:l.object({ids:l.array(l.number()).meta({description:`An array of document IDs you wish to permanently delete`,example:[1,2,3]})}),query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`})}),response:void 0},restoreMultiple:{body:l.object({ids:l.array(l.number()).meta({description:`An array of document IDs you wish to restore`,example:[1,2,3]})}),query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`})}),response:void 0},updateOrder:{body:l.object({previousDocumentId:l.number().nullable().meta({description:`The ID of the document that should come directly before the moved document in the manual order, or null when moving to the start`,example:2}),nextDocumentId:l.number().nullable().meta({description:`The ID of the document that should come directly after the moved document in the manual order, or null when moving to the end`,example:3})}),query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`}),id:l.string().trim().meta({description:`The document ID`,example:1})}),response:void 0},updateWorkflow:{body:l.object({stage:l.string().trim().min(1).optional(),assigneeIds:l.array(l.number()).optional()}),query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`}),id:l.string().trim().meta({description:`The document ID`,example:1})}),response:void 0},getWorkflowAssignees:{body:void 0,query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`})}),response:l.array(m)},getMultipleRevisions:{body:void 0,query:{string:l.object({"filter[createdBy]":r.schema.filter(!0,{example:`1`}),sort:r.schema.sort(`createdAt`),page:r.schema.page,perPage:r.schema.perPage}).meta(r.meta),formatted:l.object({filter:l.object({createdBy:l.union([n.schema.filters.single,n.schema.filters.union]).optional()}).optional(),filterOr:n.schema.filterOr,sort:l.array(l.object({key:l.enum([`createdAt`]),direction:l.enum([`asc`,`desc`])})).optional(),page:n.schema.page,perPage:n.schema.perPage})},params:l.object({collectionKey:l.string().meta({description:`The collection key`,example:`page`}),id:l.string().trim().meta({description:`The document ID`,example:1})}),response:l.array(e)},getMultiple:{query:{string:l.object({"filter[id]":r.schema.filter(!0,{example:`1`}),"filter[createdBy]":r.schema.filter(!0,{example:`1`}),"filter[updatedBy]":r.schema.filter(!0,{example:`1`}),"filter[createdAt]":r.schema.filter(!1,{example:`2025-03-15T09:22:10Z`}),"filter[updatedAt]":r.schema.filter(!1,{example:`2025-03-15T09:22:10Z`}),"filter[isDeleted]":r.schema.filter(!0,{example:`true`}),"filter[deletedBy]":r.schema.filter(!0,{example:`1`}),"filter[workflowStage]":r.schema.filter(!1,{example:`done`}),"filter[workflowAssignee]":r.schema.filter(!0,{example:`1,2`}),"filter[_customFieldKey]":r.schema.filter(!0,{description:`Prefix custom field keys with an underscore to filter by them`}),"filter[_relationFieldKey.targetCollectionKey._customFieldKey]":r.schema.filter(!0,{description:`Follow a relation field through its target collection to filter by a related document custom field`,example:`Author surname`}),"filter[_relationFieldKey._customFieldKey]":r.schema.filter(!0,{description:`Omit the target collection to use the relation field's first configured collection`,example:`Author surname`}),"filter[brickKey._customFieldKey]":r.schema.filter(!0,{description:`Add a brick key before the custom field key to filter against the brick`}),"filter[brickKey.repeaterKey._customFieldKey]":r.schema.filter(!0,{description:`Target a repeater field by adding a repeater key after the brick key`}),include:r.schema.include(`refs,refs.relation`),sort:r.schema.sort(`createdAt,updatedAt,order,_customFieldKey`),page:r.schema.page,perPage:r.schema.perPage}).meta(r.meta),formatted:l.object({filter:l.union([l.record(l.string(),l.union([n.schema.filters.single,n.schema.filters.union])),l.object({id:l.union([n.schema.filters.single,n.schema.filters.union]).optional(),createdBy:l.union([n.schema.filters.single,n.schema.filters.union]).optional(),updatedBy:l.union([n.schema.filters.single,n.schema.filters.union]).optional(),createdAt:n.schema.filters.single.optional(),updatedAt:n.schema.filters.single.optional(),isDeleted:n.schema.filters.single.optional(),deletedBy:n.schema.filters.union.optional(),workflowStage:n.schema.filters.single.optional(),workflowAssignee:n.schema.filters.union.optional()})]).optional(),filterOr:n.schema.filterOr,sort:b,include:l.array(v).optional(),page:n.schema.page,perPage:n.schema.perPage})},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`}),version:l.string().trim().meta({description:`The document version`,example:`latest`})}),body:void 0,response:l.array(g)},getSingle:{query:{string:l.object({include:r.schema.include(`bricks,refs,refs.relation`)}),formatted:l.object({include:l.array(l.union([l.literal(`bricks`),v])).optional()})},params:l.object({id:l.string().trim().meta({description:`The document ID`,example:1}),versionOrId:l.union([l.literal(`latest`),l.string().trim()]).meta({description:`The document version, or a version ID`,example:`latest`}),collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`})}),body:void 0,response:g},promoteVersion:{body:l.object({versionType:l.string().trim().refine(e=>e!==`revision`,{message:`Cannot promote to revision - use 'latest' or a valid environment key`}).meta({description:`The version type you want to promote to - either 'latest' or a valid environment key (e.g., 'production', 'qa') from the collection config`,example:`production`}),bypassRevision:l.boolean().optional().meta({description:`When true, the promote action will NOT create a revision even if revisions are enabled for the collection.`,example:!0})}),query:{string:void 0,formatted:void 0},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`}),id:l.string().trim().meta({description:`The document ID`,example:1}),versionId:l.string().trim().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:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`}),id:l.string().trim().meta({description:`The document ID`,example:1}),versionId:l.string().trim().meta({description:`The version ID you want to promote`,example:2})}),response:void 0},client:{getSingle:{query:{string:l.object({preview:u.optional(),version:d,"filter[id]":r.schema.filter(!0,{example:`1`}),"filter[createdBy]":r.schema.filter(!0,{example:`1`}),"filter[updatedBy]":r.schema.filter(!0,{example:`1`}),"filter[createdAt]":r.schema.filter(!1,{example:`2025-03-15T09:22:10Z`}),"filter[updatedAt]":r.schema.filter(!1,{example:`2025-03-15T09:22:10Z`}),"filter[isDeleted]":r.schema.filter(!1,{example:`true`}),"filter[_customFieldKey]":r.schema.filter(!0,{description:`Prefix custom field keys with an underscore to filter by them`}),"filter[_relationFieldKey.targetCollectionKey._customFieldKey]":r.schema.filter(!0,{description:`Follow a relation field through its target collection to filter by a related document custom field`,example:`Author surname`}),"filter[_relationFieldKey._customFieldKey]":r.schema.filter(!0,{description:`Omit the target collection to use the relation field's first configured collection`,example:`Author surname`}),"filter[brickKey._customFieldKey]":r.schema.filter(!0,{description:`Add a brick key before the custom field key to filter against the brick`}),"filter[brickKey.repeaterKey._customFieldKey]":r.schema.filter(!0,{description:`Target a repeater field by adding a repeater key after the brick key`}),include:r.schema.include(`bricks,refs,refs.relation,meta`),page:r.schema.page,perPage:r.schema.perPage}).meta(r.meta),formatted:l.object({filter:l.union([l.record(l.string(),l.union([n.schema.filters.single,n.schema.filters.union])),l.object({id:n.schema.filters.single.optional(),createdBy:n.schema.filters.single.optional(),updatedBy:n.schema.filters.single.optional(),createdAt:n.schema.filters.single.optional(),updatedAt:n.schema.filters.single.optional(),isDeleted:n.schema.filters.single.optional()})]).optional(),filterOr:n.schema.filterOr,include:l.array(l.union([l.literal(`bricks`),l.literal(`meta`),v])).optional()})},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`})}),body:void 0,response:_},getMultiple:{query:{string:l.object({preview:u.optional(),version:d,"filter[id]":r.schema.filter(!0,{example:`1`}),"filter[createdBy]":r.schema.filter(!0,{example:`1`}),"filter[updatedBy]":r.schema.filter(!0,{example:`1`}),"filter[createdAt]":r.schema.filter(!1,{example:`2025-03-15T09:22:10Z`}),"filter[updatedAt]":r.schema.filter(!1,{example:`2025-03-15T09:22:10Z`}),"filter[isDeleted]":r.schema.filter(!1,{example:`true`}),"filter[_customFieldKey]":r.schema.filter(!0,{description:`Prefix custom field keys with an underscore to filter by them`}),"filter[_relationFieldKey.targetCollectionKey._customFieldKey]":r.schema.filter(!0,{description:`Follow a relation field through its target collection to filter by a related document custom field`,example:`Author surname`}),"filter[_relationFieldKey._customFieldKey]":r.schema.filter(!0,{description:`Omit the target collection to use the relation field's first configured collection`,example:`Author surname`}),"filter[brickKey._customFieldKey]":r.schema.filter(!0,{description:`Add a brick key before the custom field key to filter against the brick`}),"filter[brickKey.repeaterKey._customFieldKey]":r.schema.filter(!0,{description:`Target a repeater field by adding a repeater key after the brick key`}),include:r.schema.include(`refs,refs.relation,meta`),sort:r.schema.sort(`createdAt,updatedAt,order,_customFieldKey`),page:r.schema.page,perPage:r.schema.perPage}).meta(r.meta),formatted:l.object({filter:l.union([l.record(l.string(),l.union([n.schema.filters.single,n.schema.filters.union])),l.object({id:l.union([n.schema.filters.single,n.schema.filters.union]).optional(),createdBy:l.union([n.schema.filters.single,n.schema.filters.union]).optional(),updatedBy:l.union([n.schema.filters.single,n.schema.filters.union]).optional(),createdAt:n.schema.filters.single.optional(),updatedAt:n.schema.filters.single.optional(),isDeleted:n.schema.filters.single.optional()})]).optional(),filterOr:n.schema.filterOr,sort:b,include:l.array(l.union([l.literal(`meta`),v])).optional(),page:n.schema.page,perPage:n.schema.perPage})},params:l.object({collectionKey:l.string().trim().meta({description:`The collection key`,example:`page`})}),body:void 0,response:l.array(_)}}};export{x as controllerSchemas,g as documentResponseSchema}; //# sourceMappingURL=documents.mjs.map