@se-studio/core-data-types
v1.0.55
Published
Core TypeScript type definitions for SE Studio content models
Maintainers
Readme
@se-studio/core-data-types
Core TypeScript type definitions for SE Studio content models and shared types across the monorepo.
Installation
# pnpm
pnpm add @se-studio/core-data-types
# npm
npm install @se-studio/core-data-types
# yarn
yarn add @se-studio/core-data-typesUsage
import type { IPage, ISeoMetadata, IAsset, DeepPartial } from '@se-studio/core-data-types';
// Use the page interface
const page: IPage = {
id: 'page-123',
slug: 'about-us',
title: 'About Us',
seo: {
title: 'About Us - SE Studio',
description: 'Learn more about SE Studio',
},
};
// Use utility types
type PartialPage = DeepPartial<IPage>;API Reference
Content Model Types
Pages
IBasePage- Base interface for page content models- Extends
IBaseModelwith page-specific properties type: 'Page'- Content type discriminatorisHomePage: boolean- Whether this is the home pagecontents?: ReadonlyArray<ITyped>- Page content sectionstags?: ReadonlyArray<IInternalLink>- Tags associated with the pagestructuredData?: ReadonlyArray<unknown>- Optional structured data
- Extends
PageLink- Page link type (metadata without full content)
Articles
IBaseArticle- Base interface for article content modelstype: 'Article'- Content type discriminatorarticleType?: IInternalLink- Link to the article typecontents?: ReadonlyArray<ITyped>- Article content sectionstags?: ReadonlyArray<IInternalLink>- Tags associated with the article
IBaseArticleType- Base interface for article type content modelstype: 'Article type'- Content type discriminatorindexPageContent?: ReadonlyArray<ITyped>- Content for index pagesearchPageContent?: ReadonlyArray<ITyped>- Content for search page
Components & Collections
IBaseComponent- Base interface for component content modelsIBaseCollection- Base interface for collection content modelsIBaseExternalComponent- Base interface for external component models
Visual/Asset Types
IVisual- Union type for visual content (Image | Video | Animation)IImage- Image types (Picture | SvgImage | SvgData)IVideo- Video content typeIAnimation- Animation/Lottie content typeIResponsiveVisual- Responsive visual with breakpoint configuration
Link Types
ILinkProps- Base link propertiesIInternalLink- Internal link to CMS contentIExternalLink- External linkIDownloadLink- Download linkIBlankLink- Blank link (no href)
Context Types
IPageContext- Page context with links to related contentIContentContext- Content context for component renderingIAnalyticsContext- Analytics context for tracking
Type Guard Functions
isPage(content)- Check if content is a pageisArticle(content)- Check if content is an articleisArticleType(content)- Check if content is an article typeisComponent(content)- Check if content is a componentisCollection(content)- Check if content is a collectionisInternalLink(link)- Check if link is internalisExternalLink(link)- Check if link is externalisDownloadLink(link)- Check if link is a download linkisImage(visual)- Check if visual is an imageisVideo(visual)- Check if visual is a videoisAnimation(visual)- Check if visual is an animation
Utility Types
DeepPartial<T>- Makes all nested properties optional (recursive)Prettify<T>- Improves type readability in IDE tooltips
For detailed JSDoc documentation on all types and functions, see the TypeScript declaration files (.d.ts) in the package.
Development
This package is part of the SE Studio monorepo. To work on this package:
# Install dependencies
pnpm install
# Build the package
pnpm build
# Run tests
pnpm test
# Type check
pnpm type-check
# Run linting
pnpm lintExtending Types
These types serve as a foundation and should be extended based on your actual Contentful content model:
import type { IPage } from '@se-studio/core-data-types';
// Extend the base page type with your custom fields
interface ICustomPage extends IPage {
hero: {
title: string;
image: IAsset;
};
content: RichTextContent;
}Future Additions
This package currently contains placeholder types. As the content model evolves, additional types will be added for:
- Component types (Hero, CTA, etc.)
- Rich text content structures
- Navigation structures
- Blog/Article types
- And more...
License
MIT
