SDK: @dotcms/types Library

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

Installation#


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

Overview#


This 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.

Commonly Used Types#


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

Type Hierarchy (Jump to Definitions)#


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

Type Usage#


Error Type Checking#

import {
  DotHttpError,
  DotErrorPage,
  DotErrorContent,
  DotErrorNavigation
} 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}`);
}

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

About#


This package is maintained as part of the dotCMS core repository.

Keywords#

  • dotcms
  • typescript
  • types
  • cms
  • content-management-system

Changelog#


[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

Found an issue with this documentation? Report it on GitHub