@dotcms/types

中文文档
26.11.2-3发布于 2026/11/12TypeScriptESM + CJS零依赖近 30 天下载 9224

The @dotcms/types package contains TypeScript type definitions for the dotCMS ecosystem. Use it to enable type safety and an enhanced developer experience when working with dotCMS APIs and structured content.

原始使用文档
文档目录22 节
  1. Table of Contents
  2. Overview
  3. When to Use It
  4. Key Benefits
  5. Installation
  6. Which SDK Version Should I Use?
  7. Commonly Used Types
  8. Type Hierarchy (Jump to Definitions)
  9. AI Search
  10. dotCMS Content & Pages
  11. Universal Visual Editor (UVE)
  12. Block Editor
  13. Client & HTTP
  14. Error Handling
  15. Usage Examples
  16. Error Type Checking
  17. Support
  18. Contributing
  19. Changelog
  20. [1.3.0]
  21. [1.1.1]
  22. Licensing

dotCMS Types Library

The @dotcms/types package contains TypeScript type definitions for the dotCMS ecosystem. Use it to enable type safety and an enhanced developer experience when working with dotCMS APIs and structured content.

📦 @dotcms/types on npm 🛠️ View source on GitHub

Table of Contents

Overview

When to Use It

  • Building TypeScript applications with dotCMS
  • Enabling type safety in your dotCMS integrations
  • Getting better IDE autocomplete and error checking
  • Working with dotCMS Client SDK or other SDK packages

Key Benefits

  • Type Safety: Catch errors at compile time instead of runtime
  • IDE Support: Rich autocomplete and inline documentation
  • Better Developer Experience: Clear interfaces for all dotCMS data structures
  • Framework Agnostic: Works with any TypeScript project

Installation

npm install @dotcms/types@latest --save-dev

Which SDK Version Should I Use?

dotCMS SDKs are published in lockstep with dotCMS itself: every @dotcms/* package ships at the exact same version number as the dotCMS release it was built for (e.g. dotCMS 26.7.14-1 → @dotcms/[email protected], @dotcms/[email protected], and so on).

Simple rule of thumb: use the SDK version that matches your dotCMS instance's version.

You don't have to upgrade the SDK every time dotCMS releases a new version (or vice versa). Most releases don't change anything the SDKs rely on, so an older SDK usually keeps working fine against a newer dotCMS instance. Occasionally, though, a release does include a real breaking change — and if your SDK is older than that point, it will stop working correctly.

You don't need to track this yourself: your dotCMS instance always knows the oldest SDK version it still supports, and the SDK checks itself against it automatically. If you're using an SDK that's too old, you'll see a clear warning in your console telling you to upgrade.

Recommendation: pin your SDKs to the same version as your dotCMS instance, and only bump them when you upgrade dotCMS — or when the console tells you to.

On an LTS release? LTS releases don't currently get their own matching SDK version. Until that's addressed, use the SDK version published for the closest regular release at or before your LTS version.

Want more background on how dotCMS releases and support windows work? See Release & Support Lifecycle.

Commonly Used Types

import {
  DotCMSPageAsset,
  DotCMSPageResponse,
  UVEEventType,
  DotCMSInlineEditingPayload,
  DotHttpClient,
  DotHttpError,
  DotErrorPage,
  DotErrorContent,
  DotErrorNavigation,
  DotErrorAISearch,
  DotCMSAISearchParams,
  DISTANCE_FUNCTIONS
} from '@dotcms/types';

Type Hierarchy (Jump to Definitions)

⚠️ Experimental: The AI Search types are experimental and may undergo breaking changes in future releases.

AI Search Parameters:

TypeDescription
DotCMSAISearchParamsComplete AI search parameters including query and AI config
DotCMSAISearchQueryQuery parameters (limit, offset, contentType, etc.)
DotCMSAIConfigAI configuration (threshold, distanceFunction, responseLength)
DISTANCE_FUNCTIONSAvailable distance functions for vector similarity

AI Search Response:

TypeDescription
DotCMSAISearchResponseAI search API response structure
DotCMSAISearchContentletDataContentlet with AI match information
DotCMSAISearchMatchIndividual match with distance score and extracted text

AI Search Errors:

TypeDescription
DotErrorAISearchAI Search API specific error with prompt, indexName and params context

dotCMS Content & Pages

Page:

TypeDescription
DotCMSPageAssetComplete page with layout and content
DotCMSPageCore page data
DotCMSPageResponseAPI response for page requests
DotGraphQLApiResponseGraphQL API response structure

Content:

TypeDescription
DotCMSBasicContentletBasic contentlet structure

Site & Layout:

TypeDescription
DotCMSSiteSite information
DotCMSTemplatePage templates
DotCMSLayoutPage layout structure
DotCMSPageAssetContainerContainer definitions

Navigation:

TypeDescription
DotCMSNavigationItemNavigation structure item with hierarchy support
DotCMSVanityUrlURL rewrites and vanity URLs
DotCMSURLContentMapURL to content mapping

Universal Visual Editor (UVE)

Editor State:

TypeDescription
UVEStateCurrent editor state
UVE_MODEEditor modes (EDIT, PREVIEW, PUBLISHED)
DotCMSPageRendererModePage rendering modes

Editor Events:

TypeDescription
UVEEventHandlerEvent handler functions
UVEEventSubscriberEvent subscription management
UVEEventTypeAvailable event types
UVEEventPayloadMapEvent payload definitions

Inline Editing:

TypeDescription
DotCMSInlineEditingPayloadInline editing data
DotCMSInlineEditingTypeTypes of inline editing

Block Editor

TypeDescription
BlockEditorContentBlock editor content structure
BlockEditorNodeIndividual blocks/nodes
BlockEditorMarkText formatting marks

Client & HTTP

HTTP Client:

TypeDescription
DotHttpClientHTTP client interface for custom implementations
BaseHttpClientAbstract base class with error handling utilities

Client Configuration:

TypeDescription
DotCMSClientConfigClient configuration options
DotRequestOptionsHTTP request options
DotCMSPageRequestParamsPage request parameters
DotCMSGraphQLParamsGraphQL query parameters
DotCMSNavigationRequestParamsNavigation request options

Error Handling

Base Error Types:

TypeDescription
HttpErrorDetailsHTTP error details interface
DotHttpErrorStandardized HTTP error class

Domain-Specific Errors:

TypeDescription
DotErrorPagePage API errors with GraphQL context
DotErrorContentContent API specific error handling
DotErrorNavigationNavigation API error handling
DotErrorAISearchAI Search API error handling with prompt and params

Usage Examples

Error Type Checking

import {
  DotHttpError,
  DotErrorPage,
  DotErrorContent,
  DotErrorNavigation,
  DotErrorAISearch
} from '@dotcms/types';

// Type-safe error handling
if (error instanceof DotHttpError) {
  // Access standardized HTTP error properties
  console.error(`HTTP ${error.status}: ${error.statusText}`);
  console.error('Response data:', error.data);
}

if (error instanceof DotErrorPage) {
  // Page-specific error with GraphQL context
  console.error('GraphQL query:', error.graphql?.query);
}

if (error instanceof DotErrorContent) {
  // Content-specific error context
  console.error(`${error.operation} failed for ${error.contentType}`);
}

if (error instanceof DotErrorAISearch) {
  // AI Search-specific error context
  console.error('AI Search failed for prompt:', error.prompt);
  console.error('Index name:', error.indexName);
  console.error('Search params:', error.params);
}

Note: For complete implementation examples and usage patterns, see the @dotcms/client package documentation.

Support

We offer multiple channels to get help with the dotCMS Types library:

  • GitHub Issues: For bug reports and feature requests, please open an issue in the GitHub repository
  • Community Forum: Join our community discussions to ask questions and share solutions
  • Stack Overflow: Use the tag dotcms-types when posting questions
  • Enterprise Support: Enterprise customers can access premium support through the dotCMS Support Portal

When reporting issues, please include:

  • Package version you're using
  • TypeScript version
  • Minimal reproduction steps
  • Expected vs. actual behavior

Contributing

GitHub pull requests are the preferred method to contribute code to dotCMS. We welcome contributions to the dotCMS Types library! If you'd like to contribute, please follow these steps:

  1. Fork the repository dotCMS/core
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code follows the existing style and includes appropriate tests.

Changelog

[1.3.0]

✨ Added - AI Search Types (Experimental)

⚠️ Experimental: AI Search types are experimental and may undergo breaking changes in future releases.

New AI Search Types:

  • DotCMSAISearchParams - Complete AI search parameters including query and AI config
  • DotCMSAISearchQuery - Query parameters (limit, offset, contentType, etc.)
  • DotCMSAIConfig - AI configuration (threshold, distanceFunction, responseLength)
  • DotCMSAISearchResponse<T> - AI search API response structure
  • DotCMSAISearchContentletData<T> - Contentlet with AI match information
  • DotCMSAISearchMatch - Individual match with distance score and extracted text
  • DotErrorAISearch - AI Search API specific error with prompt, indexName, and params context
  • DISTANCE_FUNCTIONS - Available distance functions for vector similarity (cosine, L2, inner product, etc.)

[1.1.1]

Added

  • DotHttpClient interface for custom HTTP client implementations
  • BaseHttpClient abstract class with built-in error handling utilities
  • DotHttpError class for standardized HTTP error handling
  • DotErrorPage class for page-specific errors with GraphQL query context
  • DotErrorContent class for content API errors with operation details
  • DotErrorNavigation class for navigation-specific error handling
  • DotGraphQLApiResponse interface for GraphQL API responses
  • HttpErrorDetails interface for HTTP error standardization
  • All error classes include toJSON() methods for easy logging and serialization

Changed

  • Renamed RequestOptions to DotRequestOptions for better naming consistency
  • Renamed DotCMSGraphQLPageResponse to DotGraphQLApiResponse for clarity
  • Enhanced DotCMSClientConfig to support custom httpClient implementations

Licensing

dotCMS is available under either the Business Source License 1.1 (BSL) or a commercial license.

Under the BSL, dotCMS can be used at no cost by individual developers, small businesses or agencies under $5M in total finances, and by larger organizations in non-production environments. Every BSL release automatically converts to GPL v3 four years after its release date. For full terms and FAQs, visit dotcms.com/bsl and dotcms.com/bsl-faq.

Production use in larger organizations, along with access to managed cloud, SLAs, support, and enterprise capabilities, is available under a commercial license from dotCMS. For details on commercial plans, features, and support options, see dotcms.com/pricing.

版本与发布记录

@dotcms/types 共发布 257 个版本,首次发布于 2025/05/03;过去 12 个月发布了 192 个版本。

版本发布日期距今
26.11.2-3latest2026/11/121 天前
26.11.11-12026/11/112 天前
26.11.10-22026/11/112 天前
26.11.9-1-next.3071next2026/11/112 天前
26.11.9-12026/11/094 天前
26.11.6-32026/11/076 天前

其他发布通道:beta → 0.0.1-beta.46,next → 26.11.9-1-next.3071。

关于 @dotcms/types 的常见问题

@dotcms/types 是什么?

The @dotcms/types package contains TypeScript type definitions for the dotCMS ecosystem. Use it to enable type safety and an enhanced developer experience when working with dotCMS APIs and structured content.

如何安装 @dotcms/types?

在项目目录运行 npm install @dotcms/types,或使用 pnpm add / yarn add / bun add。

@dotcms/types 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dotcms/types 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dotcms/types 可以商用吗?

@dotcms/types 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@dotcms/types 的下载量有多少?

根据 npm 官方下载统计,@dotcms/types 在 2026/10/13 – 2026/11/11 这 30 天内被下载 9,224 次,日均约 307 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dotcms/types 还在维护吗?

最新版本 26.11.2-3 发布于 2026/11/12(1 天前);至今共发布 257 个版本,其中过去 12 个月发布了 192 个;首次发布于 2025/05/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。