@se-studio/core-data-types 1.0.37 → 1.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,7 @@ import { VideoTypeData } from '@extractus/oembed-extractor';
|
|
|
2
2
|
|
|
3
3
|
interface IBaseCustomType extends IBaseModel {
|
|
4
4
|
type: 'Custom type';
|
|
5
|
-
|
|
6
|
-
indexPageSlug: string;
|
|
7
|
-
indexPageDescription: string;
|
|
5
|
+
slug: string;
|
|
8
6
|
structuredData?: ReadonlyArray<unknown>;
|
|
9
7
|
contents?: ReadonlyArray<ITyped>;
|
|
10
8
|
}
|
|
@@ -294,6 +292,7 @@ interface IBaseModel {
|
|
|
294
292
|
type: string;
|
|
295
293
|
id: string;
|
|
296
294
|
slug: string;
|
|
295
|
+
name: string;
|
|
297
296
|
title: string;
|
|
298
297
|
description: string;
|
|
299
298
|
breadcrumbTitle?: string;
|
|
@@ -367,10 +366,10 @@ type PersonLink = Omit<IBasePerson, BaseModelLinkOmissions | 'structuredData' |
|
|
|
367
366
|
interface IBaseArticle extends IBaseModel {
|
|
368
367
|
type: 'Article';
|
|
369
368
|
date: string;
|
|
370
|
-
articleType?:
|
|
369
|
+
articleType?: IArticleTypeLink;
|
|
371
370
|
structuredData?: ReadonlyArray<ISchema>;
|
|
372
371
|
contents?: ReadonlyArray<ITyped>;
|
|
373
|
-
tags?: ReadonlyArray<
|
|
372
|
+
tags?: ReadonlyArray<ITagLink>;
|
|
374
373
|
}
|
|
375
374
|
declare function isArticle(content: IBaseModel): content is IBaseArticle;
|
|
376
375
|
interface IBaseArticleType extends IBaseModel {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/article.ts","../src/types/common.ts","../src/types/customType.ts","../src/types/page.ts","../src/types/tag.ts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,OAAO,KAAK,IAAA,KAAS,YAAA;AACvB;AAEO,SAAS,gBAAgB,GAAA,EAA8D;AAC5F,EAAA,OAAO,KAAK,IAAA,KAAS,gBAAA;AACvB;AAEO,SAAS,QAAQ,GAAA,EAAsD;AAC5E,EAAA,OAAO,aAAa,GAAG,CAAA,IAAK,YAAY,GAAG,CAAA,IAAK,gBAAgB,GAAG,CAAA;AACrE;AAWO,SAAS,YAAY,GAAA,EAAuC;AACjE,EAAA,OAAO,KAAK,IAAA,KAAS,WAAA;AACvB;AAYO,SAAS,cAAc,MAAA,EAAoC;AAChE,EAAA,OAAO,QAAQ,KAAA,KAAU,MAAA;AAC3B;AACO,SAAS,cAAc,MAAA,EAAoC;AAChE,EAAA,OAAO,QAAQ,KAAA,KAAU,MAAA;AAC3B;AACO,SAAS,kBAAkB,MAAA,EAAoC;AACpE,EAAA,OAAO,QAAQ,SAAA,KAAc,MAAA;AAC/B","file":"index.js","sourcesContent":["import type { BaseModelLinkOmissions, IBaseModel, IInternalLink, ITyped } from './common';\nimport type { ISchema } from './schema';\nimport type { TagLink } from './tag';\n\n/**\n * Base interface for article content models.\n *\n * Extends IBaseModel with article-specific properties. Projects should extend\n * this interface with additional fields from their Contentful article content type.\n */\nexport interface IBaseArticle extends IBaseModel {\n /** Content type discriminator - always 'Article' */\n type: 'Article';\n /** Date of the article */\n date: string;\n /** Link to the article type (e.g., 'blog', 'news') */\n articleType?: IInternalLink;\n /** Optional structured data (JSON-LD, etc.) */\n structuredData?: ReadonlyArray<ISchema>;\n /** Article content sections - will be narrowed at project level */\n contents?: ReadonlyArray<ITyped>;\n /** Tags associated with the article */\n tags?: ReadonlyArray<IInternalLink>;\n}\n\n/**\n * Article link type (article metadata without full content).\n *\n * Used for article listings, related articles, etc. Omits heavy content fields.\n */\nexport type ArticleLink = Omit<\n IBaseArticle,\n BaseModelLinkOmissions | 'structuredData' | 'contents' | 'tags'\n> & {\n tags?: ReadonlyArray<TagLink>;\n};\n\n/**\n * Type guard to check if content is an article.\n *\n * @param content - Content model to check\n * @returns True if content is an article\n */\nexport function isArticle(content: IBaseModel): content is IBaseArticle {\n return content.type === 'Article';\n}\n\n/**\n * Base interface for article type content models.\n *\n * Article types represent categories of articles (e.g., 'Blog', 'News', 'Press Releases').\n */\nexport interface IBaseArticleType extends IBaseModel {\n /** Content type discriminator - always 'Article type' */\n type: 'Article type';\n /** Optional structured data (JSON-LD, etc.) */\n structuredData?: ReadonlyArray<ISchema>;\n /** Content for the article type index page - will be narrowed at project level */\n contents?: ReadonlyArray<ITyped>;\n /** Content for the article type search page - will be narrowed at project level */\n searchPageContents?: ReadonlyArray<ITyped>;\n}\n\n/**\n * Article type link (article type metadata without full content).\n */\nexport type ArticleTypeLink = Omit<\n IBaseArticleType,\n BaseModelLinkOmissions | 'indexPageContent' | 'searchPageContent'\n>;\n\n/**\n * Type guard to check if content is an article type.\n *\n * @param content - Content model to check\n * @returns True if content is an article type\n */\nexport function isArticleType(content: IBaseModel): content is IBaseArticleType {\n return content.type === 'Article type';\n}\n","import type { IBaseArticle, IBaseArticleType } from './article';\nimport type { IBaseCustomType } from './customType';\nimport type { IBasePage } from './page';\nimport type { ISchema } from './schema';\nimport type { IBaseTag } from './tag';\nimport type { IResponsiveVisual, ISvgImage, IVisual } from './visual';\n\n/**\n * Utility type to make all nested properties of a type optional.\n *\n * Recursively makes all properties optional, including nested objects.\n *\n * @example\n * ```ts\n * type PartialPage = DeepPartial<IBasePage>;\n * // All properties of IBasePage and nested objects are now optional\n * ```\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n\n/**\n * Utility type to make TypeScript's complex types more readable in IDE tooltips.\n *\n * Flattens intersection types and makes them easier to read in autocomplete.\n *\n * @example\n * ```ts\n * type Readable = Prettify<A & B & C>;\n * // IDE will show a cleaner type instead of A & B & C\n * ```\n */\nexport type Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\nexport type BaseContentType =\n | 'Component'\n | 'Collection'\n | 'Internal link'\n | 'Visual'\n | 'External component';\n\nexport interface ITyped {\n type: string;\n id: string;\n}\n\nexport interface IPageContext {\n article?: IBaseArticle; // Article - will be narrowed at project level\n articleType?: IBaseArticleType; // ArticleType - will be narrowed at project level\n person?: IBasePerson; // Person - will be narrowed at project level\n page?: IBasePage; // Page - will be narrowed at project level\n tag?: IBaseTag; // Tag - will be narrowed at project level\n customType?: IBaseCustomType; // CustomType - will be narrowed at project level\n}\n\nexport interface IContentContext {\n analyticsContext?: IAnalyticsContext;\n pageContext: IPageContext;\n current: ITyped; // PageContent - will be narrowed at project level\n previousContent?: ITyped; // PageContent - will be narrowed at project level\n nextContent?: ITyped; // PageContent - will be narrowed at project level\n}\n\nexport interface IAnalyticsContext {\n slug: string;\n title?: string;\n type?: string;\n}\n\nexport interface IRichTextOptions {\n cmsLabel?: string | null;\n analytics?: IAnalyticsContext;\n embedded?: boolean;\n parentId: string;\n parentIndex: number;\n}\n\nexport interface ILinkProps {\n parentId?: string;\n parentFieldId?: string;\n id: string;\n useName?: boolean | null;\n name: string;\n text?: string | null;\n readonly icon?: IResponsiveVisual;\n visual?: IVisual;\n href?: string | null;\n click?: () => void;\n type: 'Blank link' | 'External link' | 'Internal link' | 'Download link';\n variant?: string;\n size?: string;\n}\n\nexport interface IBlankLink extends ILinkProps {\n type: 'Blank link';\n}\n\nexport interface IExternalLink extends ILinkProps {\n type: 'External link';\n}\nexport type InternalType = 'Page' | 'Article' | 'ArticleType' | 'Person' | 'Tag' | 'CustomType';\nexport interface IInternalLink extends ILinkProps {\n type: 'Internal link';\n internalType: InternalType;\n slug: string;\n indexed?: boolean | null;\n hidden?: boolean | null;\n tags?: ReadonlyArray<IInternalLink>;\n lastModified?: Date;\n title: string;\n description?: string | null;\n}\n\nexport interface IDownloadLink extends ILinkProps {\n type: 'Download link';\n}\n\n/**\n * Represents a downloadable asset from the CMS.\n * Used for article downloads that should be proxied to hide the Contentful URL.\n */\nexport interface IDownloadAsset {\n /** The Contentful asset ID */\n assetId: string;\n /** The original filename of the asset */\n filename: string;\n /** The MIME type of the asset */\n contentType: string;\n /** The size of the asset in bytes */\n size?: number;\n /** The original Contentful URL (used server-side for proxying) */\n url: string;\n}\n\n/**\n * Type guard to check if a link is a blank link (no href).\n *\n * @param link - Link to check\n * @returns True if link is a blank link\n */\nexport function isBlankLink(link: unknown): link is IBlankLink {\n return typeof link === 'object' && link !== null && (link as IBlankLink).type === 'Blank link';\n}\n\n/**\n * Type guard to check if a link is an external link.\n *\n * @param link - Link to check\n * @returns True if link is an external link\n */\nexport function isExternalLink(link: unknown): link is IExternalLink {\n return (\n typeof link === 'object' && link !== null && (link as IExternalLink).type === 'External link'\n );\n}\n\n/**\n * Type guard to check if a link is an internal link (to CMS content).\n *\n * @param link - Link to check\n * @returns True if link is an internal link\n */\nexport function isInternalLink(link: unknown): link is IInternalLink {\n return (\n typeof link === 'object' && link !== null && (link as IInternalLink).type === 'Internal link'\n );\n}\n\nexport interface IArticleLink extends IInternalLink {\n internalType: 'Article';\n articleType?: IArticleTypeLink;\n primaryTag?: ITagLink;\n date?: string;\n author?: IPersonLink;\n externalLink?: string | null;\n /** Downloadable asset associated with the article */\n download?: IDownloadAsset;\n}\n\nexport interface IArticleTypeLink extends IInternalLink {\n internalType: 'ArticleType';\n}\n\nexport interface IPersonLink extends IInternalLink {\n internalType: 'Person';\n name: string;\n jobTitle?: string | null;\n phoneNumber: string | null;\n emailAddress: string | null;\n location: string | null;\n linkedIn: string | null;\n}\n\nexport interface ITagLink extends IInternalLink {\n internalType: 'Tag';\n}\n\nexport interface IPageLink extends IInternalLink {\n internalType: 'Page';\n}\n\n/**\n * Type guard to check if a link is an article link.\n *\n * @param link - Link to check\n * @returns True if the link is an article link\n */\nexport function isArticleLink(link: unknown): link is IArticleLink {\n return isInternalLink(link) && link.internalType === 'Article';\n}\n\n/**\n * Type guard to check if a link is an article type link.\n *\n * @param link - Link to check\n * @returns True if the link is an article type link\n */\nexport function isArticleTypeLink(link: unknown): link is IArticleTypeLink {\n return isInternalLink(link) && link.internalType === 'ArticleType';\n}\n\n/**\n * Type guard to check if a link is a tag link.\n *\n * @param link - Link to check\n * @returns True if the link is a tag link\n */\nexport function isTagLink(link: unknown): link is ITagLink {\n return isInternalLink(link) && link.internalType === 'Tag';\n}\n\n/**\n * Type guard to check if a link is a person link.\n *\n * @param link - Link to check\n * @returns True if the link is a person link\n */\nexport function isPersonLink(link: unknown): link is IPersonLink {\n return isInternalLink(link) && link.internalType === 'Person';\n}\n\n/**\n * Type guard to check if a link is a page link.\n *\n * @param link - Link to check\n * @returns True if the link is a page link\n */\nexport function isPageLink(link: unknown): link is IPageLink {\n return isInternalLink(link) && link.internalType === 'Page';\n}\n/**\n * Type guard to check if a link is a download link.\n *\n * @param link - Link to check\n * @returns True if link is a download link\n */\nexport function isDownloadLink(link: unknown): link is IDownloadLink {\n return (\n typeof link === 'object' && link !== null && (link as IDownloadLink).type === 'Download link'\n );\n}\n\nexport interface INavigation {\n id: string;\n name: string;\n entries: ReadonlyArray<INavigationItem>;\n}\n\nexport interface INavigationItem {\n id: string;\n readonly link?: ILinkProps;\n entries?: ReadonlyArray<INavigationItem>;\n}\n\nexport interface IBaseModel {\n type: string;\n id: string;\n slug: string;\n title: string;\n description: string;\n breadcrumbTitle?: string;\n featuredImage?: IVisual;\n link?: string;\n indexed?: boolean | null;\n hidden?: boolean | null;\n lastUpdated?: string | Date;\n menu?: INavigation;\n footer?: INavigation;\n /** SVG icons found in icon fields throughout the content */\n icons?: ReadonlyArray<ISvgImage>;\n}\nexport type BaseModelLinkOmissions = 'menu' | 'footer';\n\nexport interface IBaseContent {\n type: string;\n index: number;\n isFirst: boolean;\n isLast: boolean;\n indexOfType: number;\n id: string;\n name: string;\n anchor?: string | null;\n cmsLabel: string | null; // Original CMS label for tracking purposes\n hexColor?: string | null;\n backgroundVisual?: IResponsiveVisual;\n backgroundOverlayOpacity?: number | null;\n visual?: IResponsiveVisual;\n parentId?: string;\n parentFieldId?: string;\n}\n\nexport interface IBaseComponent extends IBaseContent {\n type: 'Component';\n preHeading?: string | null;\n heading?: string | null;\n postHeading?: string | null;\n icon?: IVisual;\n links?: ReadonlyArray<ILinkProps>;\n otherMedia?: ReadonlyArray<IVisual>;\n}\n\nexport function isComponent(obj: unknown): obj is IBaseComponent {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n if ((obj as IBaseComponent).type !== 'Component') {\n return false;\n }\n return true;\n}\n\nexport type BaseCollectionContent = ILinkProps | IVisual;\n\nexport interface IBaseCollection<TContents = BaseCollectionContent> extends IBaseContent {\n type: 'Collection';\n anchor?: string | null;\n preHeading?: string | null;\n heading?: string | null;\n postHeading?: string | null;\n icon?: IVisual;\n links?: ReadonlyArray<ILinkProps>;\n contents?: ReadonlyArray<TContents>;\n}\n\nexport function isCollection(obj: unknown): obj is IBaseCollection {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n if ((obj as IBaseCollection).type !== 'Collection') {\n return false;\n }\n return true;\n}\n\nexport interface IBaseExternalComponent extends IBaseContent {\n type: 'External component';\n data: unknown | null;\n}\n\nexport function isExternalComponent(obj: unknown): obj is IBaseExternalComponent {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n if ((obj as IBaseExternalComponent).type !== 'External component') {\n return false;\n }\n return true;\n}\n\nexport interface IBasePerson extends IBaseModel {\n type: 'Person';\n jobTitle?: string | null;\n phoneNumber?: string | null;\n emailAddress?: string | null;\n location?: string | null;\n linkedIn?: string | null;\n href: string | undefined;\n structuredData?: ReadonlyArray<ISchema>;\n contents?: ReadonlyArray<ITyped>; // PageContent - will be narrowed at project level\n customType?: IBaseCustomType;\n}\n\nexport type PersonLink = Omit<IBasePerson, BaseModelLinkOmissions | 'structuredData' | 'contents'>;\n\nexport function isPerson(content: IBaseModel): content is IBasePerson {\n return content.type === 'Person';\n}\n","import type { IBaseModel, ITyped } from './common';\n\n/**\n * Base interface for custom type content models.\n *\n * Custom types represent index pages for categories like Topics or Resources.\n * They provide configuration for both the main index page and potentially\n * individual entry pages.\n */\nexport interface IBaseCustomType extends IBaseModel {\n /** Content type discriminator - always 'Custom type' */\n type: 'Custom type';\n /** Index page name for display purposes */\n indexPageName: string;\n /** Index page slug used for URL routing */\n indexPageSlug: string;\n /** Index page description for SEO/display */\n indexPageDescription: string;\n /** Optional structured data (JSON-LD, etc.) */\n structuredData?: ReadonlyArray<unknown>;\n /** Content for the custom type index page - will be narrowed at project level */\n contents?: ReadonlyArray<ITyped>;\n}\n\n/**\n * Type guard to check if content is a custom type.\n *\n * @param content - Content model to check\n * @returns True if content is a custom type\n */\nexport function isCustomType(content: IBaseModel): content is IBaseCustomType {\n return content.type === 'Custom type';\n}\n","import type { BaseModelLinkOmissions, IBaseModel, IInternalLink, ITyped } from './common';\nimport type { ISchema } from './schema';\n\n/**\n * Base interface for page content models.\n *\n * Extends IBaseModel with page-specific properties. Projects should extend\n * this interface with additional fields from their Contentful page content type.\n *\n * @example\n * ```ts\n * interface IMyPage extends IBasePage {\n * hero: { title: string; image: IVisual };\n * sections: ReadonlyArray<IMyComponent>;\n * }\n * ```\n */\nexport interface IBasePage extends IBaseModel {\n /** Content type discriminator - always 'Page' */\n type: 'Page';\n /** Whether this is the home page */\n isHomePage: boolean;\n /** Optional structured data (JSON-LD, etc.) */\n structuredData?: ReadonlyArray<ISchema>;\n /** Page content sections (components, collections, etc.) - will be narrowed at project level */\n contents?: ReadonlyArray<ITyped>;\n /** Tags associated with the page */\n tags?: ReadonlyArray<IInternalLink>;\n}\n\n/**\n * Page link type (page metadata without full content).\n *\n * Used for navigation, related pages, etc. Omits heavy content fields.\n */\nexport type PageLink = Omit<IBasePage, BaseModelLinkOmissions | 'structuredData' | 'contents'>;\n\n/**\n * Type guard to check if content is a page.\n *\n * @param content - Content model to check\n * @returns True if content is a page, false otherwise\n *\n * @example\n * ```ts\n * import { isPage } from '@se-studio/core-data-types';\n *\n * if (isPage(content)) {\n * // content is now typed as IBasePage\n * console.log(content.slug, content.isHomePage);\n * }\n * ```\n */\nexport function isPage(content: IBaseModel): content is IBasePage {\n return content.type === 'Page';\n}\n","import type { BaseModelLinkOmissions, IBaseModel, ITyped } from './common';\nimport type { ISchema } from './schema';\n\nexport interface IBaseTag extends IBaseModel {\n type: 'Tag';\n tagType?: string | null;\n structuredData?: ReadonlyArray<ISchema>;\n contents?: ReadonlyArray<ITyped>; // PageContent - will be narrowed at project level\n}\n\nexport type TagLink = Omit<IBaseTag, BaseModelLinkOmissions | 'contents'>;\n\nexport function isTag(content: IBaseModel): content is IBaseTag {\n return content.type === 'Tag';\n}\n\nexport interface IBaseTags extends IBaseModel {\n type: 'Tags';\n}\n\nexport function isTags(content: IBaseModel): content is IBaseTags {\n return content.type === 'Tags';\n}\n","import type { VideoTypeData } from '@extractus/oembed-extractor';\n\nexport type Vertical = 'Top' | 'Middle' | 'Bottom';\nexport type Horizontal = 'Left' | 'Middle' | 'Right';\n\ninterface IInternalBreakpoint {\n minWidth: number;\n proportion: number;\n pixels: number;\n size: string;\n}\ntype IBreakpoint = Pick<IInternalBreakpoint, 'minWidth'> &\n Partial<Omit<IInternalBreakpoint, 'minWidth'>>;\nexport interface IVisualSizes {\n defaultSize?: string;\n defaultPixels?: number;\n breakpoints?: IBreakpoint[];\n}\n\nfunction fillInBreakpoints(breakpoints?: IBreakpoint[]): IInternalBreakpoint[] | undefined {\n return breakpoints?.map(({ minWidth, proportion, pixels, size }) => {\n if (proportion) {\n return {\n minWidth,\n proportion,\n pixels: Math.round(minWidth * proportion),\n size: `${Math.round(100 * proportion)}vw`,\n };\n }\n if (pixels) {\n const proportion = Math.round(minWidth / pixels);\n return {\n minWidth,\n proportion,\n pixels,\n size: size ?? `${Math.round(100 * proportion)}vw`,\n };\n }\n\n return { minWidth, proportion: 1, pixels: minWidth, size: size ?? `100vw` };\n });\n}\nexport function processSizes({ defaultSize, defaultPixels, breakpoints }: IVisualSizes) {\n return {\n defaultSize,\n defaultPixels,\n breakpoints: fillInBreakpoints(breakpoints),\n };\n}\n\nexport interface IVisualCommon {\n type: string;\n id: string;\n name: string;\n description?: string | null;\n nameAsCaption?: boolean | null;\n dontCrop?: boolean | null;\n horizontalCropPosition?: Horizontal | null;\n verticalCropPosition?: Vertical | null;\n horizontalPosition?: Horizontal | null;\n widthPercent?: number | null;\n}\n\nexport interface IOptimisedSvg {\n data: string;\n width: number;\n height: number;\n}\n\ninterface IImageCommon extends IVisualCommon {\n mimeType: string;\n}\nexport interface IPicture extends IImageCommon {\n type: 'Picture';\n src: string;\n width: number;\n height: number;\n size: number;\n}\n\nexport interface ISvgImage extends IImageCommon {\n type: 'Svg image';\n size: number;\n svgSrc: string;\n width: number;\n height: number;\n /** Whether this SVG is from an icon field and should use the sprite system */\n isIcon?: boolean;\n /** Pre-processed sprite symbol content (set during data conversion) */\n symbolContent?: string;\n}\n\nexport interface ISvgData extends IImageCommon {\n type: 'Svg data';\n data: string;\n width: number;\n height: number;\n}\n\nexport type IImage = IPicture | ISvgImage | ISvgData;\n\nexport function isPicture(obj: IVisualCommon | undefined | null): obj is IPicture {\n return obj?.type === 'Picture';\n}\n\nexport function isSvgImage(obj: IVisualCommon | undefined | null): obj is ISvgImage {\n return obj?.type === 'Svg image';\n}\n\nexport function isSvgData(obj: IVisualCommon | undefined | null): obj is ISvgData {\n return obj?.type === 'Svg data';\n}\n\nexport function isImage(obj: IVisualCommon | undefined | null): obj is IImage {\n return isPicture(obj) || isSvgImage(obj) || isSvgData(obj);\n}\n\nexport interface IVideoDetails {\n id: string;\n videoUrl: string;\n mimeType: string;\n fileName: string;\n size: number;\n}\n\nexport interface IVideoCommon extends IVisualCommon {\n poster?: string;\n loop?: boolean | null;\n autoPlay?: boolean | null;\n width?: number;\n height?: number;\n hideControls?: boolean | null;\n}\n\nexport interface ILocalVideo extends IVideoCommon {\n type: 'Local video';\n preview: IVideoDetails;\n videoPrefix: string;\n}\n\nexport interface IFullVideo extends IVideoCommon {\n type: 'Full video';\n preview?: IVideoDetails;\n full: IVideoDetails;\n videoPrefix: string;\n}\n\nexport interface IExternalVideo extends IVideoCommon {\n type: 'External video';\n preview?: IVideoDetails;\n external: string;\n embed?: VideoTypeData;\n}\n\nexport type IVideo = ILocalVideo | IFullVideo | IExternalVideo;\n\nexport function isLocalVideo(obj: IVisualCommon | undefined | null): obj is ILocalVideo {\n return obj?.type === 'Local video';\n}\n\nexport function isFullVideo(obj: IVisualCommon | undefined | null): obj is IFullVideo {\n return obj?.type === 'Full video';\n}\n\nexport function isExternalVideo(obj: IVisualCommon | undefined | null): obj is IExternalVideo {\n return obj?.type === 'External video';\n}\n\nexport function isVideo(obj: IVisualCommon | undefined | null): obj is IVideo {\n return isLocalVideo(obj) || isFullVideo(obj) || isExternalVideo(obj);\n}\n\nexport interface IAnimation extends IVisualCommon {\n type: 'Animation';\n optimised?: IOptimisedSvg;\n animationSrc: string;\n loop?: boolean | null;\n loopDelay?: number | null;\n autoPlay?: boolean | null;\n}\n\nexport function isAnimation(obj: IVisualCommon | undefined | null) {\n return obj?.type === 'Animation';\n}\n\nexport interface IVisual {\n type: 'Visual';\n id: string;\n image?: IImage;\n video?: IVideo;\n animation?: IAnimation;\n /** Resolved mask URL for CSS mask-image (e.g., '/assets/masks/circle.svg') */\n mask?: string;\n}\n\nexport function isVisualVideo(visual: IVisual | undefined | null) {\n return visual?.video !== undefined;\n}\nexport function isVisualImage(visual: IVisual | undefined | null) {\n return visual?.image !== undefined;\n}\nexport function isVisualAnimation(visual: IVisual | undefined | null) {\n return visual?.animation !== undefined;\n}\n\nexport interface IResponsiveVisual {\n visual: IVisual;\n hideVisual?: boolean;\n mobileVisual?: IVisual;\n hideMobileVisual?: boolean;\n visualCustomSize?: number | null;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/article.ts","../src/types/common.ts","../src/types/customType.ts","../src/types/page.ts","../src/types/tag.ts","../src/types/visual.ts"],"names":["proportion"],"mappings":";AAiDO,SAAS,UAAU,OAAA,EAA8C;AACtE,EAAA,OAAO,QAAQ,IAAA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IAAA,KAAS,gBAAA;AACvB;AAEO,SAAS,QAAQ,GAAA,EAAsD;AAC5E,EAAA,OAAO,aAAa,GAAG,CAAA,IAAK,YAAY,GAAG,CAAA,IAAK,gBAAgB,GAAG,CAAA;AACrE;AAWO,SAAS,YAAY,GAAA,EAAuC;AACjE,EAAA,OAAO,KAAK,IAAA,KAAS,WAAA;AACvB;AAYO,SAAS,cAAc,MAAA,EAAoC;AAChE,EAAA,OAAO,QAAQ,KAAA,KAAU,MAAA;AAC3B;AACO,SAAS,cAAc,MAAA,EAAoC;AAChE,EAAA,OAAO,QAAQ,KAAA,KAAU,MAAA;AAC3B;AACO,SAAS,kBAAkB,MAAA,EAAoC;AACpE,EAAA,OAAO,QAAQ,SAAA,KAAc,MAAA;AAC/B","file":"index.js","sourcesContent":["import type {\n BaseModelLinkOmissions,\n IArticleTypeLink,\n IBaseModel,\n ITagLink,\n ITyped,\n} from './common';\nimport type { ISchema } from './schema';\nimport type { TagLink } from './tag';\n\n/**\n * Base interface for article content models.\n *\n * Extends IBaseModel with article-specific properties. Projects should extend\n * this interface with additional fields from their Contentful article content type.\n */\nexport interface IBaseArticle extends IBaseModel {\n /** Content type discriminator - always 'Article' */\n type: 'Article';\n /** Date of the article */\n date: string;\n /** Link to the article type (e.g., 'blog', 'news') */\n articleType?: IArticleTypeLink;\n /** Optional structured data (JSON-LD, etc.) */\n structuredData?: ReadonlyArray<ISchema>;\n /** Article content sections - will be narrowed at project level */\n contents?: ReadonlyArray<ITyped>;\n /** Tags associated with the article */\n tags?: ReadonlyArray<ITagLink>;\n}\n\n/**\n * Article link type (article metadata without full content).\n *\n * Used for article listings, related articles, etc. Omits heavy content fields.\n */\nexport type ArticleLink = Omit<\n IBaseArticle,\n BaseModelLinkOmissions | 'structuredData' | 'contents' | 'tags'\n> & {\n tags?: ReadonlyArray<TagLink>;\n};\n\n/**\n * Type guard to check if content is an article.\n *\n * @param content - Content model to check\n * @returns True if content is an article\n */\nexport function isArticle(content: IBaseModel): content is IBaseArticle {\n return content.type === 'Article';\n}\n\n/**\n * Base interface for article type content models.\n *\n * Article types represent categories of articles (e.g., 'Blog', 'News', 'Press Releases').\n */\nexport interface IBaseArticleType extends IBaseModel {\n /** Content type discriminator - always 'Article type' */\n type: 'Article type';\n /** Optional structured data (JSON-LD, etc.) */\n structuredData?: ReadonlyArray<ISchema>;\n /** Content for the article type index page - will be narrowed at project level */\n contents?: ReadonlyArray<ITyped>;\n /** Content for the article type search page - will be narrowed at project level */\n searchPageContents?: ReadonlyArray<ITyped>;\n}\n\n/**\n * Article type link (article type metadata without full content).\n */\nexport type ArticleTypeLink = Omit<\n IBaseArticleType,\n BaseModelLinkOmissions | 'indexPageContent' | 'searchPageContent'\n>;\n\n/**\n * Type guard to check if content is an article type.\n *\n * @param content - Content model to check\n * @returns True if content is an article type\n */\nexport function isArticleType(content: IBaseModel): content is IBaseArticleType {\n return content.type === 'Article type';\n}\n","import type { IBaseArticle, IBaseArticleType } from './article';\nimport type { IBaseCustomType } from './customType';\nimport type { IBasePage } from './page';\nimport type { ISchema } from './schema';\nimport type { IBaseTag } from './tag';\nimport type { IResponsiveVisual, ISvgImage, IVisual } from './visual';\n\n/**\n * Utility type to make all nested properties of a type optional.\n *\n * Recursively makes all properties optional, including nested objects.\n *\n * @example\n * ```ts\n * type PartialPage = DeepPartial<IBasePage>;\n * // All properties of IBasePage and nested objects are now optional\n * ```\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n\n/**\n * Utility type to make TypeScript's complex types more readable in IDE tooltips.\n *\n * Flattens intersection types and makes them easier to read in autocomplete.\n *\n * @example\n * ```ts\n * type Readable = Prettify<A & B & C>;\n * // IDE will show a cleaner type instead of A & B & C\n * ```\n */\nexport type Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\nexport type BaseContentType =\n | 'Component'\n | 'Collection'\n | 'Internal link'\n | 'Visual'\n | 'External component';\n\nexport interface ITyped {\n type: string;\n id: string;\n}\n\nexport interface IPageContext {\n article?: IBaseArticle; // Article - will be narrowed at project level\n articleType?: IBaseArticleType; // ArticleType - will be narrowed at project level\n person?: IBasePerson; // Person - will be narrowed at project level\n page?: IBasePage; // Page - will be narrowed at project level\n tag?: IBaseTag; // Tag - will be narrowed at project level\n customType?: IBaseCustomType; // CustomType - will be narrowed at project level\n}\n\nexport interface IContentContext {\n analyticsContext?: IAnalyticsContext;\n pageContext: IPageContext;\n current: ITyped; // PageContent - will be narrowed at project level\n previousContent?: ITyped; // PageContent - will be narrowed at project level\n nextContent?: ITyped; // PageContent - will be narrowed at project level\n}\n\nexport interface IAnalyticsContext {\n slug: string;\n title?: string;\n type?: string;\n}\n\nexport interface IRichTextOptions {\n cmsLabel?: string | null;\n analytics?: IAnalyticsContext;\n embedded?: boolean;\n parentId: string;\n parentIndex: number;\n}\n\nexport interface ILinkProps {\n parentId?: string;\n parentFieldId?: string;\n id: string;\n useName?: boolean | null;\n name: string;\n text?: string | null;\n readonly icon?: IResponsiveVisual;\n visual?: IVisual;\n href?: string | null;\n click?: () => void;\n type: 'Blank link' | 'External link' | 'Internal link' | 'Download link';\n variant?: string;\n size?: string;\n}\n\nexport interface IBlankLink extends ILinkProps {\n type: 'Blank link';\n}\n\nexport interface IExternalLink extends ILinkProps {\n type: 'External link';\n}\nexport type InternalType = 'Page' | 'Article' | 'ArticleType' | 'Person' | 'Tag' | 'CustomType';\nexport interface IInternalLink extends ILinkProps {\n type: 'Internal link';\n internalType: InternalType;\n slug: string;\n indexed?: boolean | null;\n hidden?: boolean | null;\n tags?: ReadonlyArray<IInternalLink>;\n lastModified?: Date;\n title: string;\n description?: string | null;\n}\n\nexport interface IDownloadLink extends ILinkProps {\n type: 'Download link';\n}\n\n/**\n * Represents a downloadable asset from the CMS.\n * Used for article downloads that should be proxied to hide the Contentful URL.\n */\nexport interface IDownloadAsset {\n /** The Contentful asset ID */\n assetId: string;\n /** The original filename of the asset */\n filename: string;\n /** The MIME type of the asset */\n contentType: string;\n /** The size of the asset in bytes */\n size?: number;\n /** The original Contentful URL (used server-side for proxying) */\n url: string;\n}\n\n/**\n * Type guard to check if a link is a blank link (no href).\n *\n * @param link - Link to check\n * @returns True if link is a blank link\n */\nexport function isBlankLink(link: unknown): link is IBlankLink {\n return typeof link === 'object' && link !== null && (link as IBlankLink).type === 'Blank link';\n}\n\n/**\n * Type guard to check if a link is an external link.\n *\n * @param link - Link to check\n * @returns True if link is an external link\n */\nexport function isExternalLink(link: unknown): link is IExternalLink {\n return (\n typeof link === 'object' && link !== null && (link as IExternalLink).type === 'External link'\n );\n}\n\n/**\n * Type guard to check if a link is an internal link (to CMS content).\n *\n * @param link - Link to check\n * @returns True if link is an internal link\n */\nexport function isInternalLink(link: unknown): link is IInternalLink {\n return (\n typeof link === 'object' && link !== null && (link as IInternalLink).type === 'Internal link'\n );\n}\n\nexport interface IArticleLink extends IInternalLink {\n internalType: 'Article';\n articleType?: IArticleTypeLink;\n primaryTag?: ITagLink;\n date?: string;\n author?: IPersonLink;\n externalLink?: string | null;\n /** Downloadable asset associated with the article */\n download?: IDownloadAsset;\n}\n\nexport interface IArticleTypeLink extends IInternalLink {\n internalType: 'ArticleType';\n}\n\nexport interface IPersonLink extends IInternalLink {\n internalType: 'Person';\n name: string;\n jobTitle?: string | null;\n phoneNumber: string | null;\n emailAddress: string | null;\n location: string | null;\n linkedIn: string | null;\n}\n\nexport interface ITagLink extends IInternalLink {\n internalType: 'Tag';\n}\n\nexport interface IPageLink extends IInternalLink {\n internalType: 'Page';\n}\n\n/**\n * Type guard to check if a link is an article link.\n *\n * @param link - Link to check\n * @returns True if the link is an article link\n */\nexport function isArticleLink(link: unknown): link is IArticleLink {\n return isInternalLink(link) && link.internalType === 'Article';\n}\n\n/**\n * Type guard to check if a link is an article type link.\n *\n * @param link - Link to check\n * @returns True if the link is an article type link\n */\nexport function isArticleTypeLink(link: unknown): link is IArticleTypeLink {\n return isInternalLink(link) && link.internalType === 'ArticleType';\n}\n\n/**\n * Type guard to check if a link is a tag link.\n *\n * @param link - Link to check\n * @returns True if the link is a tag link\n */\nexport function isTagLink(link: unknown): link is ITagLink {\n return isInternalLink(link) && link.internalType === 'Tag';\n}\n\n/**\n * Type guard to check if a link is a person link.\n *\n * @param link - Link to check\n * @returns True if the link is a person link\n */\nexport function isPersonLink(link: unknown): link is IPersonLink {\n return isInternalLink(link) && link.internalType === 'Person';\n}\n\n/**\n * Type guard to check if a link is a page link.\n *\n * @param link - Link to check\n * @returns True if the link is a page link\n */\nexport function isPageLink(link: unknown): link is IPageLink {\n return isInternalLink(link) && link.internalType === 'Page';\n}\n/**\n * Type guard to check if a link is a download link.\n *\n * @param link - Link to check\n * @returns True if link is a download link\n */\nexport function isDownloadLink(link: unknown): link is IDownloadLink {\n return (\n typeof link === 'object' && link !== null && (link as IDownloadLink).type === 'Download link'\n );\n}\n\nexport interface INavigation {\n id: string;\n name: string;\n entries: ReadonlyArray<INavigationItem>;\n}\n\nexport interface INavigationItem {\n id: string;\n readonly link?: ILinkProps;\n entries?: ReadonlyArray<INavigationItem>;\n}\n\nexport interface IBaseModel {\n type: string;\n id: string;\n slug: string;\n name: string;\n title: string;\n description: string;\n breadcrumbTitle?: string;\n featuredImage?: IVisual;\n link?: string;\n indexed?: boolean | null;\n hidden?: boolean | null;\n lastUpdated?: string | Date;\n menu?: INavigation;\n footer?: INavigation;\n /** SVG icons found in icon fields throughout the content */\n icons?: ReadonlyArray<ISvgImage>;\n}\nexport type BaseModelLinkOmissions = 'menu' | 'footer';\n\nexport interface IBaseContent {\n type: string;\n index: number;\n isFirst: boolean;\n isLast: boolean;\n indexOfType: number;\n id: string;\n name: string;\n anchor?: string | null;\n cmsLabel: string | null; // Original CMS label for tracking purposes\n hexColor?: string | null;\n backgroundVisual?: IResponsiveVisual;\n backgroundOverlayOpacity?: number | null;\n visual?: IResponsiveVisual;\n parentId?: string;\n parentFieldId?: string;\n}\n\nexport interface IBaseComponent extends IBaseContent {\n type: 'Component';\n preHeading?: string | null;\n heading?: string | null;\n postHeading?: string | null;\n icon?: IVisual;\n links?: ReadonlyArray<ILinkProps>;\n otherMedia?: ReadonlyArray<IVisual>;\n}\n\nexport function isComponent(obj: unknown): obj is IBaseComponent {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n if ((obj as IBaseComponent).type !== 'Component') {\n return false;\n }\n return true;\n}\n\nexport type BaseCollectionContent = ILinkProps | IVisual;\n\nexport interface IBaseCollection<TContents = BaseCollectionContent> extends IBaseContent {\n type: 'Collection';\n anchor?: string | null;\n preHeading?: string | null;\n heading?: string | null;\n postHeading?: string | null;\n icon?: IVisual;\n links?: ReadonlyArray<ILinkProps>;\n contents?: ReadonlyArray<TContents>;\n}\n\nexport function isCollection(obj: unknown): obj is IBaseCollection {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n if ((obj as IBaseCollection).type !== 'Collection') {\n return false;\n }\n return true;\n}\n\nexport interface IBaseExternalComponent extends IBaseContent {\n type: 'External component';\n data: unknown | null;\n}\n\nexport function isExternalComponent(obj: unknown): obj is IBaseExternalComponent {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n if ((obj as IBaseExternalComponent).type !== 'External component') {\n return false;\n }\n return true;\n}\n\nexport interface IBasePerson extends IBaseModel {\n type: 'Person';\n jobTitle?: string | null;\n phoneNumber?: string | null;\n emailAddress?: string | null;\n location?: string | null;\n linkedIn?: string | null;\n href: string | undefined;\n structuredData?: ReadonlyArray<ISchema>;\n contents?: ReadonlyArray<ITyped>; // PageContent - will be narrowed at project level\n customType?: IBaseCustomType;\n}\n\nexport type PersonLink = Omit<IBasePerson, BaseModelLinkOmissions | 'structuredData' | 'contents'>;\n\nexport function isPerson(content: IBaseModel): content is IBasePerson {\n return content.type === 'Person';\n}\n","import type { IBaseModel, ITyped } from './common';\n\n/**\n * Base interface for custom type content models.\n *\n * Custom types represent index pages for categories like Topics or Resources.\n * They provide configuration for both the main index page and potentially\n * individual entry pages.\n */\nexport interface IBaseCustomType extends IBaseModel {\n /** Content type discriminator - always 'Custom type' */\n type: 'Custom type';\n /** Slug used for URL routing */\n slug: string;\n /** Optional structured data (JSON-LD, etc.) */\n structuredData?: ReadonlyArray<unknown>;\n /** Content for the custom type index page - will be narrowed at project level */\n contents?: ReadonlyArray<ITyped>;\n}\n\n/**\n * Type guard to check if content is a custom type.\n *\n * @param content - Content model to check\n * @returns True if content is a custom type\n */\nexport function isCustomType(content: IBaseModel): content is IBaseCustomType {\n return content.type === 'Custom type';\n}\n","import type { BaseModelLinkOmissions, IBaseModel, IInternalLink, ITyped } from './common';\nimport type { ISchema } from './schema';\n\n/**\n * Base interface for page content models.\n *\n * Extends IBaseModel with page-specific properties. Projects should extend\n * this interface with additional fields from their Contentful page content type.\n *\n * @example\n * ```ts\n * interface IMyPage extends IBasePage {\n * hero: { title: string; image: IVisual };\n * sections: ReadonlyArray<IMyComponent>;\n * }\n * ```\n */\nexport interface IBasePage extends IBaseModel {\n /** Content type discriminator - always 'Page' */\n type: 'Page';\n /** Whether this is the home page */\n isHomePage: boolean;\n /** Optional structured data (JSON-LD, etc.) */\n structuredData?: ReadonlyArray<ISchema>;\n /** Page content sections (components, collections, etc.) - will be narrowed at project level */\n contents?: ReadonlyArray<ITyped>;\n /** Tags associated with the page */\n tags?: ReadonlyArray<IInternalLink>;\n}\n\n/**\n * Page link type (page metadata without full content).\n *\n * Used for navigation, related pages, etc. Omits heavy content fields.\n */\nexport type PageLink = Omit<IBasePage, BaseModelLinkOmissions | 'structuredData' | 'contents'>;\n\n/**\n * Type guard to check if content is a page.\n *\n * @param content - Content model to check\n * @returns True if content is a page, false otherwise\n *\n * @example\n * ```ts\n * import { isPage } from '@se-studio/core-data-types';\n *\n * if (isPage(content)) {\n * // content is now typed as IBasePage\n * console.log(content.slug, content.isHomePage);\n * }\n * ```\n */\nexport function isPage(content: IBaseModel): content is IBasePage {\n return content.type === 'Page';\n}\n","import type { BaseModelLinkOmissions, IBaseModel, ITyped } from './common';\nimport type { ISchema } from './schema';\n\nexport interface IBaseTag extends IBaseModel {\n type: 'Tag';\n tagType?: string | null;\n structuredData?: ReadonlyArray<ISchema>;\n contents?: ReadonlyArray<ITyped>; // PageContent - will be narrowed at project level\n}\n\nexport type TagLink = Omit<IBaseTag, BaseModelLinkOmissions | 'contents'>;\n\nexport function isTag(content: IBaseModel): content is IBaseTag {\n return content.type === 'Tag';\n}\n\nexport interface IBaseTags extends IBaseModel {\n type: 'Tags';\n}\n\nexport function isTags(content: IBaseModel): content is IBaseTags {\n return content.type === 'Tags';\n}\n","import type { VideoTypeData } from '@extractus/oembed-extractor';\n\nexport type Vertical = 'Top' | 'Middle' | 'Bottom';\nexport type Horizontal = 'Left' | 'Middle' | 'Right';\n\ninterface IInternalBreakpoint {\n minWidth: number;\n proportion: number;\n pixels: number;\n size: string;\n}\ntype IBreakpoint = Pick<IInternalBreakpoint, 'minWidth'> &\n Partial<Omit<IInternalBreakpoint, 'minWidth'>>;\nexport interface IVisualSizes {\n defaultSize?: string;\n defaultPixels?: number;\n breakpoints?: IBreakpoint[];\n}\n\nfunction fillInBreakpoints(breakpoints?: IBreakpoint[]): IInternalBreakpoint[] | undefined {\n return breakpoints?.map(({ minWidth, proportion, pixels, size }) => {\n if (proportion) {\n return {\n minWidth,\n proportion,\n pixels: Math.round(minWidth * proportion),\n size: `${Math.round(100 * proportion)}vw`,\n };\n }\n if (pixels) {\n const proportion = Math.round(minWidth / pixels);\n return {\n minWidth,\n proportion,\n pixels,\n size: size ?? `${Math.round(100 * proportion)}vw`,\n };\n }\n\n return { minWidth, proportion: 1, pixels: minWidth, size: size ?? `100vw` };\n });\n}\nexport function processSizes({ defaultSize, defaultPixels, breakpoints }: IVisualSizes) {\n return {\n defaultSize,\n defaultPixels,\n breakpoints: fillInBreakpoints(breakpoints),\n };\n}\n\nexport interface IVisualCommon {\n type: string;\n id: string;\n name: string;\n description?: string | null;\n nameAsCaption?: boolean | null;\n dontCrop?: boolean | null;\n horizontalCropPosition?: Horizontal | null;\n verticalCropPosition?: Vertical | null;\n horizontalPosition?: Horizontal | null;\n widthPercent?: number | null;\n}\n\nexport interface IOptimisedSvg {\n data: string;\n width: number;\n height: number;\n}\n\ninterface IImageCommon extends IVisualCommon {\n mimeType: string;\n}\nexport interface IPicture extends IImageCommon {\n type: 'Picture';\n src: string;\n width: number;\n height: number;\n size: number;\n}\n\nexport interface ISvgImage extends IImageCommon {\n type: 'Svg image';\n size: number;\n svgSrc: string;\n width: number;\n height: number;\n /** Whether this SVG is from an icon field and should use the sprite system */\n isIcon?: boolean;\n /** Pre-processed sprite symbol content (set during data conversion) */\n symbolContent?: string;\n}\n\nexport interface ISvgData extends IImageCommon {\n type: 'Svg data';\n data: string;\n width: number;\n height: number;\n}\n\nexport type IImage = IPicture | ISvgImage | ISvgData;\n\nexport function isPicture(obj: IVisualCommon | undefined | null): obj is IPicture {\n return obj?.type === 'Picture';\n}\n\nexport function isSvgImage(obj: IVisualCommon | undefined | null): obj is ISvgImage {\n return obj?.type === 'Svg image';\n}\n\nexport function isSvgData(obj: IVisualCommon | undefined | null): obj is ISvgData {\n return obj?.type === 'Svg data';\n}\n\nexport function isImage(obj: IVisualCommon | undefined | null): obj is IImage {\n return isPicture(obj) || isSvgImage(obj) || isSvgData(obj);\n}\n\nexport interface IVideoDetails {\n id: string;\n videoUrl: string;\n mimeType: string;\n fileName: string;\n size: number;\n}\n\nexport interface IVideoCommon extends IVisualCommon {\n poster?: string;\n loop?: boolean | null;\n autoPlay?: boolean | null;\n width?: number;\n height?: number;\n hideControls?: boolean | null;\n}\n\nexport interface ILocalVideo extends IVideoCommon {\n type: 'Local video';\n preview: IVideoDetails;\n videoPrefix: string;\n}\n\nexport interface IFullVideo extends IVideoCommon {\n type: 'Full video';\n preview?: IVideoDetails;\n full: IVideoDetails;\n videoPrefix: string;\n}\n\nexport interface IExternalVideo extends IVideoCommon {\n type: 'External video';\n preview?: IVideoDetails;\n external: string;\n embed?: VideoTypeData;\n}\n\nexport type IVideo = ILocalVideo | IFullVideo | IExternalVideo;\n\nexport function isLocalVideo(obj: IVisualCommon | undefined | null): obj is ILocalVideo {\n return obj?.type === 'Local video';\n}\n\nexport function isFullVideo(obj: IVisualCommon | undefined | null): obj is IFullVideo {\n return obj?.type === 'Full video';\n}\n\nexport function isExternalVideo(obj: IVisualCommon | undefined | null): obj is IExternalVideo {\n return obj?.type === 'External video';\n}\n\nexport function isVideo(obj: IVisualCommon | undefined | null): obj is IVideo {\n return isLocalVideo(obj) || isFullVideo(obj) || isExternalVideo(obj);\n}\n\nexport interface IAnimation extends IVisualCommon {\n type: 'Animation';\n optimised?: IOptimisedSvg;\n animationSrc: string;\n loop?: boolean | null;\n loopDelay?: number | null;\n autoPlay?: boolean | null;\n}\n\nexport function isAnimation(obj: IVisualCommon | undefined | null) {\n return obj?.type === 'Animation';\n}\n\nexport interface IVisual {\n type: 'Visual';\n id: string;\n image?: IImage;\n video?: IVideo;\n animation?: IAnimation;\n /** Resolved mask URL for CSS mask-image (e.g., '/assets/masks/circle.svg') */\n mask?: string;\n}\n\nexport function isVisualVideo(visual: IVisual | undefined | null) {\n return visual?.video !== undefined;\n}\nexport function isVisualImage(visual: IVisual | undefined | null) {\n return visual?.image !== undefined;\n}\nexport function isVisualAnimation(visual: IVisual | undefined | null) {\n return visual?.animation !== undefined;\n}\n\nexport interface IResponsiveVisual {\n visual: IVisual;\n hideVisual?: boolean;\n mobileVisual?: IVisual;\n hideMobileVisual?: boolean;\n visualCustomSize?: number | null;\n}\n"]}
|