@se-studio/core-data-types 1.0.17 → 1.0.18
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 +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -190,6 +190,7 @@ interface IInternalLink extends ILinkProps {
|
|
|
190
190
|
indexed?: boolean | null;
|
|
191
191
|
hidden?: boolean | null;
|
|
192
192
|
tags?: ReadonlyArray<IInternalLink>;
|
|
193
|
+
lastModified?: Date;
|
|
193
194
|
}
|
|
194
195
|
interface IArticleLink extends IInternalLink {
|
|
195
196
|
internalType: 'Article';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/article.ts","../src/types/common.ts","../src/types/page.ts","../src/types/tag.ts","../src/types/visual.ts"],"names":["proportion"],"mappings":";AAwCO,SAAS,UAAU,OAAA,EAA8C;AACtE,EAAA,OAAO,QAAQ,IAAA,KAAS,SAAA;AAC1B;AA8BO,SAAS,cAAc,OAAA,EAAkD;AAC9E,EAAA,OAAO,QAAQ,IAAA,KAAS,cAAA;AAC1B;;;ACkDO,SAAS,YAAY,IAAA,EAAsC;AAChE,EAAA,OAAO,KAAK,IAAA,KAAS,YAAA;AACvB;AAQO,SAAS,eAAe,IAAA,EAAyC;AACtE,EAAA,OAAO,KAAK,IAAA,KAAS,eAAA;AACvB;AAQO,SAAS,eAAe,IAAA,EAAyC;AACtE,EAAA,OAAO,KAAK,IAAA,KAAS,eAAA;AACvB;AAQO,SAAS,eAAe,IAAA,EAAyC;AACtE,EAAA,OAAO,KAAK,IAAA,KAAS,eAAA;AACvB;AAmEO,SAAS,YAAY,GAAA,EAAqC;AAC/D,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,IAAA,EAAM;AAC3C,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAK,GAAA,C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AoC;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 { 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 /** Link to the article type (e.g., 'blog', 'news') */\n articleType?: IInternalLink;\n /** Optional structured data (JSON-LD, etc.) */\n structuredData?: ReadonlyArray<unknown>;\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 /** Content for the article type index page - will be narrowed at project level */\n indexPageContent?: ReadonlyArray<ITyped>;\n /** Content for the article type search page - will be narrowed at project level */\n searchPageContent?: 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 { IResponsiveVisual, 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 articleLink?: ITyped | null; // ArticleLink - will be narrowed at project level\n articleTypeLink?: ITyped | null; // ArticleTypeLink - will be narrowed at project level\n personLink?: ITyped | null; // PersonLink - will be narrowed at project level\n pageLink?: ITyped | null; // PageLink - will be narrowed at project level\n tagLink?: ITyped | null; // TagLink - 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 backgroundColour?: string | null;\n textColour?: string | null;\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}\n\nexport interface IArticleLink extends IInternalLink {\n internalType: 'Article';\n articleType?: IInternalLink;\n}\n\nexport interface IDownloadLink extends ILinkProps {\n type: 'Download link';\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: ILinkProps): link is IBlankLink {\n return link.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: ILinkProps): link is IExternalLink {\n return link.type === 'External link';\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: ILinkProps): link is IInternalLink {\n return link.type === 'Internal link';\n}\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: ILinkProps): link is IDownloadLink {\n return link.type === 'Download link';\n}\n\nexport interface INavigation {\n id: string;\n name: string;\n entries: ReadonlyArray<INavigationItem>;\n textColour?: string;\n backgroundColour?: string;\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 featuredImage?: IVisual;\n link?: string;\n indexed?: boolean | null;\n hidden?: boolean | null;\n lastUpdated?: string | Date;\n textColour?: string;\n backgroundColour?: string;\n menu?: INavigation;\n footer?: INavigation;\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 backgroundColour?: string;\n textColour?: string;\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 componentType: string;\n preHeading?: string | null;\n heading?: string | null;\n postHeading?: string | null;\n body?: unknown;\n icon?: IVisual;\n links?: ReadonlyArray<ILinkProps>;\n otherMedia?: ReadonlyArray<IVisual>;\n additionalCopy?: unknown;\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 CollectionContent =\n | IBaseComponent\n | IBaseCollection\n | ILinkProps\n | IVisual\n | IBaseExternalComponent;\n\nexport interface IBaseCollection extends IBaseContent {\n type: 'Collection';\n collectionType: string;\n anchor?: string | null;\n preHeading?: string | null;\n heading?: string | null;\n postHeading?: string | null;\n body?: unknown;\n icon?: IVisual;\n links?: ReadonlyArray<ILinkProps>;\n additionalCopy?: unknown;\n contents?: ReadonlyArray<CollectionContent>;\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 externalType: string;\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 IPerson 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 bio: unknown;\n href: string | undefined;\n structuredData?: ReadonlyArray<unknown>;\n contents?: ReadonlyArray<unknown>; // PageContent - will be narrowed at project level\n}\n\nexport type PersonLink = Omit<IPerson, BaseModelLinkOmissions | 'structuredData' | 'contents'>;\n\nexport function isPerson(content: IBaseModel): content is IPerson {\n return content.type === 'Person';\n}\n","import type { BaseModelLinkOmissions, IBaseModel, IInternalLink, ITyped } from './common';\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<unknown>;\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';\n\nexport interface IBaseTag extends IBaseModel {\n type: 'Tag';\n tagType?: string | null;\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}\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}\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/page.ts","../src/types/tag.ts","../src/types/visual.ts"],"names":["proportion"],"mappings":";AAwCO,SAAS,UAAU,OAAA,EAA8C;AACtE,EAAA,OAAO,QAAQ,IAAA,KAAS,SAAA;AAC1B;AA8BO,SAAS,cAAc,OAAA,EAAkD;AAC9E,EAAA,OAAO,QAAQ,IAAA,KAAS,cAAA;AAC1B;;;ACmDO,SAAS,YAA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O,SAAS,aAAa,GAAA,EAA2D;AACtF,EAAA,OAAO,KAAK,IAAA,KAAS,aAAA;AACvB;AAEO,SAAS,YAAY,GAAA,EAA0D;AACpF,EAAA,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;AAUO,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 { 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 /** Link to the article type (e.g., 'blog', 'news') */\n articleType?: IInternalLink;\n /** Optional structured data (JSON-LD, etc.) */\n structuredData?: ReadonlyArray<unknown>;\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 /** Content for the article type index page - will be narrowed at project level */\n indexPageContent?: ReadonlyArray<ITyped>;\n /** Content for the article type search page - will be narrowed at project level */\n searchPageContent?: 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 { IResponsiveVisual, 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 articleLink?: ITyped | null; // ArticleLink - will be narrowed at project level\n articleTypeLink?: ITyped | null; // ArticleTypeLink - will be narrowed at project level\n personLink?: ITyped | null; // PersonLink - will be narrowed at project level\n pageLink?: ITyped | null; // PageLink - will be narrowed at project level\n tagLink?: ITyped | null; // TagLink - 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 backgroundColour?: string | null;\n textColour?: string | null;\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}\n\nexport interface IArticleLink extends IInternalLink {\n internalType: 'Article';\n articleType?: IInternalLink;\n}\n\nexport interface IDownloadLink extends ILinkProps {\n type: 'Download link';\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: ILinkProps): link is IBlankLink {\n return link.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: ILinkProps): link is IExternalLink {\n return link.type === 'External link';\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: ILinkProps): link is IInternalLink {\n return link.type === 'Internal link';\n}\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: ILinkProps): link is IDownloadLink {\n return link.type === 'Download link';\n}\n\nexport interface INavigation {\n id: string;\n name: string;\n entries: ReadonlyArray<INavigationItem>;\n textColour?: string;\n backgroundColour?: string;\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 featuredImage?: IVisual;\n link?: string;\n indexed?: boolean | null;\n hidden?: boolean | null;\n lastUpdated?: string | Date;\n textColour?: string;\n backgroundColour?: string;\n menu?: INavigation;\n footer?: INavigation;\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 backgroundColour?: string;\n textColour?: string;\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 componentType: string;\n preHeading?: string | null;\n heading?: string | null;\n postHeading?: string | null;\n body?: unknown;\n icon?: IVisual;\n links?: ReadonlyArray<ILinkProps>;\n otherMedia?: ReadonlyArray<IVisual>;\n additionalCopy?: unknown;\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 CollectionContent =\n | IBaseComponent\n | IBaseCollection\n | ILinkProps\n | IVisual\n | IBaseExternalComponent;\n\nexport interface IBaseCollection extends IBaseContent {\n type: 'Collection';\n collectionType: string;\n anchor?: string | null;\n preHeading?: string | null;\n heading?: string | null;\n postHeading?: string | null;\n body?: unknown;\n icon?: IVisual;\n links?: ReadonlyArray<ILinkProps>;\n additionalCopy?: unknown;\n contents?: ReadonlyArray<CollectionContent>;\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 externalType: string;\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 IPerson 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 bio: unknown;\n href: string | undefined;\n structuredData?: ReadonlyArray<unknown>;\n contents?: ReadonlyArray<unknown>; // PageContent - will be narrowed at project level\n}\n\nexport type PersonLink = Omit<IPerson, BaseModelLinkOmissions | 'structuredData' | 'contents'>;\n\nexport function isPerson(content: IBaseModel): content is IPerson {\n return content.type === 'Person';\n}\n","import type { BaseModelLinkOmissions, IBaseModel, IInternalLink, ITyped } from './common';\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<unknown>;\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';\n\nexport interface IBaseTag extends IBaseModel {\n type: 'Tag';\n tagType?: string | null;\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}\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}\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@se-studio/core-data-types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Core TypeScript type definitions for SE Studio content models",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"url": "https://github.com/Something-Else-Studio/se-core-product/issues"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@biomejs/biome": "^2.3.
|
|
40
|
+
"@biomejs/biome": "^2.3.8",
|
|
41
41
|
"tsup": "^8.5.1",
|
|
42
42
|
"typescript": "^5.9.3",
|
|
43
43
|
"vitest": "^4.0.14"
|