UNPKG

@lucidcms/core

Version:

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

59 lines 2.35 kB
import { CollectionDocument, CollectionDocumentKey } from "../../../types/response.mjs"; import { CollectionDocumentVersionKey } from "../../../types/query-params.mjs"; import { ServiceContext, ServiceResponse } from "../../../utils/services/types.mjs"; import { ToolkitDocumentsGetMultipleInput, ToolkitDocumentsGetMultipleResult } from "./get-multiple.mjs"; import { ToolkitDocumentsGetSingleInput } from "./get-single.mjs"; //#region src/libs/toolkit/documents/index.d.ts type ToolkitDocumentVersion<TCollectionKey extends CollectionDocumentKey = CollectionDocumentKey> = CollectionDocumentVersionKey<TCollectionKey>; /** * Document helpers for reading collection content. */ type ToolkitDocuments = { /** * Returns multiple documents from a collection. * * The response includes the matching documents and a total count. * Pass an array to `query.filter` when each object should be an OR branch. * * @example * ```ts * await toolkit.documents.getMultiple({ * collectionKey: "page", * tenantKey: "marketing", * version: "published", * query: { * perPage: 50, * }, * }); * ``` */ getMultiple: <TCollectionKey extends CollectionDocumentKey>(input: ToolkitDocumentsGetMultipleInput<TCollectionKey>) => ServiceResponse<ToolkitDocumentsGetMultipleResult<TCollectionKey>>; /** * Returns a single document from a collection. * * Useful when you expect one matching document for a slug, ID, or other filter. * Pass an array to `query.filter` when each object should be an OR branch. * * @example * ```ts * await toolkit.documents.getSingle({ * collectionKey: "page", * tenantKey: "marketing", * version: "published", * query: { * filter: { * _fullSlug: { * value: "/about", * }, * }, * }, * }); * ``` */ getSingle: <TCollectionKey extends CollectionDocumentKey>(input: ToolkitDocumentsGetSingleInput<TCollectionKey>) => ServiceResponse<CollectionDocument<TCollectionKey>>; }; /** Creates document helpers for a toolkit instance. */ declare const createDocumentsToolkit: (context: ServiceContext) => ToolkitDocuments; //#endregion export { ToolkitDocumentVersion, ToolkitDocuments, createDocumentsToolkit, createDocumentsToolkit as default }; //# sourceMappingURL=index.d.mts.map