@se-studio/core-data-types 0.1.0 → 0.1.1

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 CHANGED
@@ -1,27 +1,5 @@
1
1
  import { VideoTypeData } from '@extractus/oembed-extractor';
2
2
 
3
- interface IPage<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {
4
- type: 'Page';
5
- isHomePage: boolean;
6
- structuredData?: ReadonlyArray<unknown>;
7
- contents?: ReadonlyArray<PageContent<TConfig>>;
8
- tags?: ReadonlyArray<IInternalLink<TConfig>>;
9
- }
10
- type PageLink<TConfig extends BaseCmsConfig> = Omit<IPage<TConfig>, BaseModelLinkOmissions | 'structuredData' | 'contents'>;
11
- declare function isPage<TConfig extends BaseCmsConfig>(content: IBaseModel<TConfig>): content is IPage<TConfig>;
12
-
13
- interface ITag<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {
14
- type: 'Tag';
15
- tagType?: string | null;
16
- contents?: ReadonlyArray<PageContent<TConfig>>;
17
- }
18
- type TagLink<TConfig extends BaseCmsConfig> = Omit<ITag<TConfig>, BaseModelLinkOmissions | 'contents'>;
19
- declare function isTag<TConfig extends BaseCmsConfig>(content: IBaseModel<TConfig>): content is ITag<TConfig>;
20
- interface ITags<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {
21
- type: 'Tags';
22
- }
23
- declare function isTags<TConfig extends BaseCmsConfig>(content: IBaseModel<TConfig>): content is ITags<TConfig>;
24
-
25
3
  type Vertical = 'Top' | 'Middle' | 'Bottom';
26
4
  type Horizontal = 'Left' | 'Middle' | 'Right';
27
5
  interface IInternalBreakpoint {
@@ -104,11 +82,13 @@ interface IVideoCommon extends IVisualCommon {
104
82
  interface ILocalVideo extends IVideoCommon {
105
83
  type: 'Local video';
106
84
  preview: IVideoDetails;
85
+ videoPrefix: string;
107
86
  }
108
87
  interface IFullVideo extends IVideoCommon {
109
88
  type: 'Full video';
110
89
  preview?: IVideoDetails;
111
90
  full: IVideoDetails;
91
+ videoPrefix: string;
112
92
  }
113
93
  interface IExternalVideo extends IVideoCommon {
114
94
  type: 'External video';
@@ -148,34 +128,24 @@ interface IResponsiveVisual {
148
128
  visualCustomSize?: number | null;
149
129
  }
150
130
 
151
- type BaseModelType = 'Page' | 'Article' | 'Tag' | 'Article type' | 'Tags' | 'Person' | 'People' | 'Custom type';
152
131
  type BaseContentType = 'Component' | 'Collection' | 'Internal link' | 'Visual' | 'External component';
153
- type Brand<T, U> = T & {
154
- __brand: U;
155
- };
156
- type ColourName<T extends string = string> = Brand<T, 'ColourName'>;
157
- type GradientName<T extends string = string> = Brand<T, 'GradientName'>;
158
- type ModelType<T extends string = string> = Brand<T, 'ModelType'>;
159
- type ContentType<T extends string = string> = Brand<T, 'ContentType'>;
160
- type IconName<T extends string = string> = Brand<T, 'IconName'>;
161
- type ButtonVariant<T extends string = string> = Brand<T, 'ButtonVariant'>;
162
- type ButtonSize<T extends string = string> = Brand<T, 'ButtonSize'>;
163
- type ComponentType<T extends string = string> = Brand<T, 'ComponentType'>;
164
- type CollectionType<T extends string = string> = Brand<T, 'CollectionType'>;
165
- type ExternalComponentType<T extends string = string> = Brand<T, 'ExternalComponentType'>;
166
- interface IPageContext<TConfig extends BaseCmsConfig> {
167
- articleLink?: ArticleLink<TConfig>;
168
- articleTypeLink?: ArticleTypeLink<TConfig>;
169
- personLink?: PersonLink<TConfig>;
170
- pageLink?: PageLink<TConfig>;
171
- tagLink?: TagLink<TConfig>;
172
- }
173
- interface IContentContext<TConfig extends BaseCmsConfig> {
132
+ interface ITyped {
133
+ type: string;
134
+ id: string;
135
+ }
136
+ interface IPageContext {
137
+ articleLink?: ITyped;
138
+ articleTypeLink?: ITyped;
139
+ personLink?: ITyped;
140
+ pageLink?: ITyped;
141
+ tagLink?: ITyped;
142
+ }
143
+ interface IContentContext {
174
144
  analyticsContext?: IAnalyticsContext;
175
- pageContext: IPageContext<TConfig>;
176
- current: PageContent<TConfig>;
177
- previousContent?: PageContent<TConfig>;
178
- nextContent?: PageContent<TConfig>;
145
+ pageContext: IPageContext;
146
+ current: ITyped;
147
+ previousContent?: ITyped;
148
+ nextContent?: ITyped;
179
149
  }
180
150
  interface IAnalyticsContext {
181
151
  slug: string;
@@ -189,25 +159,7 @@ interface IRichTextOptions {
189
159
  parentId: string;
190
160
  parentIndex: number;
191
161
  }
192
- type BaseCmsConfig = {
193
- RichText: unknown;
194
- ColourName: ColourName<string>;
195
- GradientName: GradientName<string>;
196
- ModelType: ModelType<string>;
197
- ContentType: ContentType<string>;
198
- CollectionType: CollectionType<string>;
199
- ComponentType: ComponentType<string>;
200
- ExternalComponentType: ExternalComponentType<string>;
201
- ButtonVariant: ButtonVariant<string>;
202
- ButtonSize: ButtonSize<string>;
203
- PageContext: IPageContext<BaseCmsConfig>;
204
- Component: IBaseComponent<BaseCmsConfig>;
205
- Collection: IBaseCollection<BaseCmsConfig>;
206
- ExternalComponent: IBaseExternalComponent<BaseCmsConfig>;
207
- RichTextOptions: IRichTextOptions;
208
- PageContent: PageContent<BaseCmsConfig>;
209
- };
210
- interface ILinkProps<TConfig extends BaseCmsConfig> {
162
+ interface ILinkProps {
211
163
  parentId?: string;
212
164
  parentFieldId?: string;
213
165
  id: string;
@@ -219,42 +171,41 @@ interface ILinkProps<TConfig extends BaseCmsConfig> {
219
171
  href?: string | null;
220
172
  click?: () => void;
221
173
  type: 'Blank link' | 'External link' | 'Internal link' | 'Download link';
222
- backgroundColour?: TConfig['ColourName'] | TConfig['GradientName'] | null;
223
- textColour?: TConfig['ColourName'] | null;
224
- variant?: TConfig['ButtonVariant'];
225
- size?: TConfig['ButtonSize'];
174
+ backgroundColour?: string | null;
175
+ textColour?: string | null;
176
+ variant?: string;
177
+ size?: string;
226
178
  }
227
- interface IBLankLink<TConfig extends BaseCmsConfig> extends ILinkProps<TConfig> {
179
+ interface IBlankLink extends ILinkProps {
228
180
  type: 'Blank link';
229
181
  }
230
- interface IExternalLink<TConfig extends BaseCmsConfig> extends ILinkProps<TConfig> {
182
+ interface IExternalLink extends ILinkProps {
231
183
  type: 'External link';
232
184
  }
233
- interface IInternalLink<TConfig extends BaseCmsConfig> extends ILinkProps<TConfig> {
185
+ interface IInternalLink extends ILinkProps {
234
186
  type: 'Internal link';
235
187
  slug: string;
236
188
  indexed?: boolean | null;
237
189
  hidden?: boolean | null;
238
- tags?: ReadonlyArray<IInternalLink<TConfig>>;
190
+ tags?: ReadonlyArray<IInternalLink>;
239
191
  }
240
- interface IDownloadLink<TConfig extends BaseCmsConfig> extends ILinkProps<TConfig> {
192
+ interface IDownloadLink extends ILinkProps {
241
193
  type: 'Download link';
242
194
  }
243
- interface INavigation<TConfig extends BaseCmsConfig> {
195
+ interface INavigation {
244
196
  id: string;
245
197
  name: string;
246
- entries: ReadonlyArray<INavigationItem<TConfig>>;
247
- textColour?: TConfig['ColourName'];
248
- backgroundColour?: TConfig['ColourName'] | TConfig['GradientName'];
198
+ entries: ReadonlyArray<INavigationItem>;
199
+ textColour?: string;
200
+ backgroundColour?: string;
249
201
  }
250
- interface INavigationItem<TConfig extends BaseCmsConfig> {
202
+ interface INavigationItem {
251
203
  id: string;
252
- link?: ILinkProps<TConfig>;
253
- entries?: ReadonlyArray<INavigationItem<TConfig>>;
254
- longText: TConfig['RichText'] | string | null;
204
+ link?: ILinkProps;
205
+ entries?: ReadonlyArray<INavigationItem>;
255
206
  }
256
- interface IBaseModel<TConfig extends BaseCmsConfig> {
257
- type: BaseModelType | TConfig['ModelType'];
207
+ interface IBaseModel {
208
+ type: string;
258
209
  id: string;
259
210
  slug: string;
260
211
  title: string;
@@ -264,14 +215,14 @@ interface IBaseModel<TConfig extends BaseCmsConfig> {
264
215
  indexed?: boolean | null;
265
216
  hidden?: boolean | null;
266
217
  lastUpdated?: string | Date;
267
- textColour?: TConfig['ColourName'];
268
- backgroundColour?: TConfig['ColourName'] | TConfig['GradientName'];
269
- menu?: INavigation<TConfig>;
270
- footer?: INavigation<TConfig>;
218
+ textColour?: string;
219
+ backgroundColour?: string;
220
+ menu?: INavigation;
221
+ footer?: INavigation;
271
222
  }
272
223
  type BaseModelLinkOmissions = 'menu' | 'footer';
273
- interface IBaseContent<TConfig extends BaseCmsConfig> {
274
- type: BaseContentType | TConfig['ContentType'];
224
+ interface IBaseContent {
225
+ type: string;
275
226
  index: number;
276
227
  isFirst: boolean;
277
228
  isLast: boolean;
@@ -280,8 +231,8 @@ interface IBaseContent<TConfig extends BaseCmsConfig> {
280
231
  name: string;
281
232
  anchor?: string | null;
282
233
  cmsLabel: string | null;
283
- backgroundColour?: TConfig['ColourName'] | TConfig['GradientName'];
284
- textColour?: TConfig['ColourName'];
234
+ backgroundColour?: string;
235
+ textColour?: string;
285
236
  hexColor?: string | null;
286
237
  backgroundVisual?: IResponsiveVisual;
287
238
  backgroundOverlayOpacity?: number | null;
@@ -289,69 +240,85 @@ interface IBaseContent<TConfig extends BaseCmsConfig> {
289
240
  parentId?: string;
290
241
  parentFieldId?: string;
291
242
  }
292
- interface IBaseComponent<TConfig extends BaseCmsConfig> extends IBaseContent<TConfig> {
243
+ interface IBaseComponent extends IBaseContent {
293
244
  type: 'Component';
294
- componentType: TConfig['ComponentType'];
245
+ componentType: string;
295
246
  preHeading?: string | null;
296
247
  heading?: string | null;
297
248
  postHeading?: string | null;
298
- body?: TConfig['RichText'] | string;
249
+ body?: unknown;
299
250
  icon?: IVisual;
300
- links?: ReadonlyArray<ILinkProps<TConfig>>;
301
- additionalCopy?: TConfig['RichText'] | string;
251
+ links?: ReadonlyArray<ILinkProps>;
252
+ additionalCopy?: unknown;
302
253
  }
303
- declare function isComponent<TConfig extends BaseCmsConfig>(obj: unknown): obj is TConfig['Component'];
304
- type CollectionContent<TConfig extends BaseCmsConfig> = IBaseComponent<TConfig> | IBaseCollection<TConfig>;
305
- interface IBaseCollection<TConfig extends BaseCmsConfig> extends IBaseContent<TConfig> {
254
+ declare function isComponent(obj: unknown): obj is IBaseComponent;
255
+ type CollectionContent = IBaseComponent | IBaseCollection;
256
+ interface IBaseCollection extends IBaseContent {
306
257
  type: 'Collection';
307
- collectionType: TConfig['CollectionType'];
258
+ collectionType: string;
308
259
  anchor?: string | null;
309
260
  preHeading?: string | null;
310
261
  heading?: string | null;
311
262
  postHeading?: string | null;
312
- body?: TConfig['RichText'] | string;
263
+ body?: unknown;
313
264
  icon?: IVisual;
314
- links?: ReadonlyArray<ILinkProps<TConfig>>;
315
- additionalCopy?: TConfig['RichText'] | string;
316
- contents?: ReadonlyArray<CollectionContent<TConfig>>;
265
+ links?: ReadonlyArray<ILinkProps>;
266
+ additionalCopy?: unknown;
267
+ contents?: ReadonlyArray<CollectionContent>;
317
268
  }
318
- declare function isCollection<TConfig extends BaseCmsConfig>(obj: unknown): obj is TConfig['Collection'];
319
- interface IBaseExternalComponent<TConfig extends BaseCmsConfig> extends IBaseContent<TConfig> {
269
+ declare function isCollection(obj: unknown): obj is IBaseCollection;
270
+ interface IBaseExternalComponent extends IBaseContent {
320
271
  type: 'External component';
321
- externalType: TConfig['ExternalComponentType'];
272
+ externalType: string;
322
273
  data: unknown | null;
323
274
  }
324
- interface IPerson<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {
275
+ interface IPerson extends IBaseModel {
325
276
  type: 'Person';
326
277
  jobTitle?: string | null;
327
278
  phoneNumber: string | null;
328
279
  emailAddress: string | null;
329
280
  location: string | null;
330
281
  linkedIn: string | null;
331
- bio: TConfig['RichText'] | null | undefined;
282
+ bio: unknown;
332
283
  href: string | undefined;
333
284
  structuredData?: ReadonlyArray<unknown>;
334
- contents?: ReadonlyArray<PageContent<TConfig>>;
285
+ contents?: ReadonlyArray<unknown>;
335
286
  }
336
- type PersonLink<TConfig extends BaseCmsConfig> = Omit<IPerson<TConfig>, BaseModelLinkOmissions | 'structuredData' | 'contents'>;
337
- type PageContent<TConfig extends BaseCmsConfig> = IBaseComponent<TConfig> | IBaseCollection<TConfig> | IBaseExternalComponent<TConfig> | IVisual | IInternalLink<TConfig>;
287
+ type PersonLink = Omit<IPerson, BaseModelLinkOmissions | 'structuredData' | 'contents'>;
338
288
 
339
- interface IArticle<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {
289
+ interface IBaseTag extends IBaseModel {
290
+ type: 'Tag';
291
+ tagType?: string | null;
292
+ contents?: ReadonlyArray<ITyped>;
293
+ }
294
+ declare function isTag(content: IBaseModel): content is IBaseTag;
295
+ interface IBaseTags extends IBaseModel {
296
+ type: 'Tags';
297
+ }
298
+ declare function isTags(content: IBaseModel): content is IBaseTags;
299
+
300
+ interface IBaseArticle extends IBaseModel {
340
301
  type: 'Article';
341
- articleType?: IInternalLink<TConfig>;
302
+ articleType?: IInternalLink;
342
303
  structuredData?: ReadonlyArray<unknown>;
343
- contents?: ReadonlyArray<PageContent<TConfig>>;
344
- tags?: ReadonlyArray<IInternalLink<TConfig>>;
304
+ contents?: ReadonlyArray<ITyped>;
305
+ tags?: ReadonlyArray<IInternalLink>;
345
306
  }
346
- type ArticleLink<TConfig extends BaseCmsConfig> = Omit<IArticle<TConfig>, BaseModelLinkOmissions | 'structuredData' | 'contents' | 'tags'> & {
347
- tags?: ReadonlyArray<TagLink<TConfig>>;
348
- };
349
- declare function isArticle<TConfig extends BaseCmsConfig>(content: IBaseModel<TConfig>): content is IArticle<TConfig>;
350
- interface IArticleType<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {
307
+ declare function isArticle(content: IBaseModel): content is IBaseArticle;
308
+ interface IBaseArticleType extends IBaseModel {
351
309
  type: 'Article type';
352
- indexPageContent?: ReadonlyArray<PageContent<TConfig>>;
353
- searchPageContent?: ReadonlyArray<PageContent<TConfig>>;
310
+ indexPageContent?: ReadonlyArray<ITyped>;
311
+ searchPageContent?: ReadonlyArray<ITyped>;
312
+ }
313
+ declare function isArticleType(content: IBaseModel): content is IBaseArticleType;
314
+
315
+ interface IBasePage extends IBaseModel {
316
+ type: 'Page';
317
+ isHomePage: boolean;
318
+ structuredData?: ReadonlyArray<unknown>;
319
+ contents?: ReadonlyArray<ITyped>;
320
+ tags?: ReadonlyArray<IInternalLink>;
354
321
  }
355
- type ArticleTypeLink<TConfig extends BaseCmsConfig> = Omit<IArticleType<TConfig>, BaseModelLinkOmissions | 'indexPageContent' | 'searchPageContent'>;
322
+ declare function isPage(content: IBaseModel): content is IBasePage;
356
323
 
357
- export { type BaseCmsConfig, type BaseContentType, type BaseModelType, type ButtonSize, type ButtonVariant, type CollectionContent, type CollectionType, type ColourName, type ComponentType, type ContentType, type ExternalComponentType, type GradientName, type Horizontal, type IAnalyticsContext, type IAnimation, type IArticle, type IBLankLink, type IBaseCollection, type IBaseComponent, type IBaseContent, type IBaseExternalComponent, type IBaseModel, type IContentContext, type IDownloadLink, type IExternalLink, type IExternalVideo, type IFullVideo, type IImage, type IInternalLink, type ILinkProps, type ILocalVideo, type INavigation, type INavigationItem, type IPage, type IPageContext, type IPerson, type IPicture, type IResponsiveVisual, type ISvgData, type ISvgImage, type ITag, type ITags, type IVideo, type IVideoDetails, type IVisual, type IVisualCommon, type IVisualSizes, type IconName, type ModelType, type PageContent, type PersonLink, type Vertical, isAnimation, isArticle, isCollection, isComponent, isExternalVideo, isFullVideo, isImage, isLocalVideo, isPage, isPicture, isSvgData, isSvgImage, isTag, isTags, isVideo, isVisualAnimation, isVisualImage, isVisualVideo, processSizes };
324
+ export { type BaseContentType, type CollectionContent, type Horizontal, type IAnalyticsContext, type IAnimation, type IBaseArticle, type IBaseArticleType, type IBaseCollection, type IBaseComponent, type IBaseContent, type IBaseExternalComponent, type IBaseModel, type IBasePage, type IBaseTag, type IBaseTags, type IBlankLink, type IContentContext, type IDownloadLink, type IExternalLink, type IExternalVideo, type IFullVideo, type IImage, type IInternalLink, type ILinkProps, type ILocalVideo, type INavigation, type INavigationItem, type IPageContext, type IPerson, type IPicture, type IResponsiveVisual, type IRichTextOptions, type ISvgData, type ISvgImage, type ITyped, type IVideo, type IVideoDetails, type IVisual, type IVisualCommon, type IVisualSizes, type PersonLink, type Vertical, isAnimation, isArticle, isArticleType, isCollection, isComponent, isExternalVideo, isFullVideo, isImage, isLocalVideo, isPage, isPicture, isSvgData, isSvgImage, isTag, isTags, isVideo, isVisualAnimation, isVisualImage, isVisualVideo, processSizes };
package/dist/index.js CHANGED
@@ -2,6 +2,9 @@
2
2
  function isArticle(content) {
3
3
  return content.type === "Article";
4
4
  }
5
+ function isArticleType(content) {
6
+ return content.type === "Article type";
7
+ }
5
8
 
6
9
  // src/types/common.ts
7
10
  function isComponent(obj) {
@@ -103,6 +106,6 @@ function isVisualAnimation(visual) {
103
106
  return visual?.animation !== void 0;
104
107
  }
105
108
 
106
- export { isAnimation, isArticle, isCollection, isComponent, isExternalVideo, isFullVideo, isImage, isLocalVideo, isPage, isPicture, isSvgData, isSvgImage, isTag, isTags, isVideo, isVisualAnimation, isVisualImage, isVisualVideo, processSizes };
109
+ export { isAnimation, isArticle, isArticleType, isCollection, isComponent, isExternalVideo, isFullVideo, isImage, isLocalVideo, isPage, isPicture, isSvgData, isSvgImage, isTag, isTags, isVideo, isVisualAnimation, isVisualImage, isVisualVideo, processSizes };
107
110
  //# sourceMappingURL=index.js.map
108
111
  //# sourceMappingURL=index.js.map
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":";AAwBO,SAAS,UACd,OAAA,EAC8B;AAC9B,EAAA,OAAO,QAAQ,IAAA,KAAS,SAAA;AAC1B;;;ACqMO,SAAS,YACd,GAAA,EAC6B;AAC7B,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,IAAA,EAAM;AAC3C,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAK,GAAA,CAA6B,SAAS,WAAA,EAAa;AACtD,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA;AACT;AAoBO,SAAS,aACd,GAAA,EAC8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KAAU,MAAA;AAC3B;AACO,SAAS,kBAAkB,MAAA,EAAoC;AACpE,EAAA,OAAO,QAAQ,SAAA,KAAc,MAAA;AAC/B","file":"index.js","sourcesContent":["import type {\n BaseCmsConfig,\n BaseModelLinkOmissions,\n IBaseModel,\n IInternalLink,\n PageContent,\n} from './common';\nimport type { TagLink } from './tag';\n\nexport interface IArticle<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {\n type: 'Article';\n articleType?: IInternalLink<TConfig>;\n structuredData?: ReadonlyArray<unknown>;\n contents?: ReadonlyArray<PageContent<TConfig>>;\n tags?: ReadonlyArray<IInternalLink<TConfig>>;\n}\n\nexport type ArticleLink<TConfig extends BaseCmsConfig> = Omit<\n IArticle<TConfig>,\n BaseModelLinkOmissions | 'structuredData' | 'contents' | 'tags'\n> & {\n tags?: ReadonlyArray<TagLink<TConfig>>;\n};\n\nexport function isArticle<TConfig extends BaseCmsConfig>(\n content: IBaseModel<TConfig>,\n): content is IArticle<TConfig> {\n return content.type === 'Article';\n}\n\nexport interface IArticleType<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {\n type: 'Article type';\n indexPageContent?: ReadonlyArray<PageContent<TConfig>>;\n searchPageContent?: ReadonlyArray<PageContent<TConfig>>;\n}\n\nexport type ArticleTypeLink<TConfig extends BaseCmsConfig> = Omit<\n IArticleType<TConfig>,\n BaseModelLinkOmissions | 'indexPageContent' | 'searchPageContent'\n>;\n\nexport function isArticleType<TConfig extends BaseCmsConfig>(\n content: IBaseModel<TConfig>,\n): content is IArticleType<TConfig> {\n return content.type === 'Article type';\n}\n","import type { ArticleLink, ArticleTypeLink } from './article';\nimport type { PageLink } from './page';\nimport type { TagLink } from './tag';\nimport type { IResponsiveVisual, IVisual } from './visual';\n\n/**\n * Utility type to make all nested properties of a type optional\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 */\nexport type Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\nexport type BaseModelType =\n | 'Page'\n | 'Article'\n | 'Tag'\n | 'Article type'\n | 'Tags'\n | 'Person'\n | 'People'\n | 'Custom type';\n\nexport type BaseContentType =\n | 'Component'\n | 'Collection'\n | 'Internal link'\n | 'Visual'\n | 'External component';\n\nexport type Brand<T, U> = T & { __brand: U }; // Nominal typing helper\n\nexport type ColourName<T extends string = string> = Brand<T, 'ColourName'>;\nexport type GradientName<T extends string = string> = Brand<T, 'GradientName'>;\nexport type ModelType<T extends string = string> = Brand<T, 'ModelType'>;\nexport type ContentType<T extends string = string> = Brand<T, 'ContentType'>;\nexport type IconName<T extends string = string> = Brand<T, 'IconName'>;\nexport type ButtonVariant<T extends string = string> = Brand<T, 'ButtonVariant'>;\nexport type ButtonSize<T extends string = string> = Brand<T, 'ButtonSize'>;\nexport type ComponentType<T extends string = string> = Brand<T, 'ComponentType'>;\nexport type CollectionType<T extends string = string> = Brand<T, 'CollectionType'>;\nexport type ExternalComponentType<T extends string = string> = Brand<T, 'ExternalComponentType'>;\n\nexport interface IPageContext<TConfig extends BaseCmsConfig> {\n articleLink?: ArticleLink<TConfig>;\n articleTypeLink?: ArticleTypeLink<TConfig>;\n personLink?: PersonLink<TConfig>;\n pageLink?: PageLink<TConfig>;\n tagLink?: TagLink<TConfig>;\n}\n\nexport interface IContentContext<TConfig extends BaseCmsConfig> {\n analyticsContext?: IAnalyticsContext;\n pageContext: IPageContext<TConfig>;\n current: PageContent<TConfig>;\n previousContent?: PageContent<TConfig>;\n nextContent?: PageContent<TConfig>;\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 type BaseCmsConfig = {\n RichText: unknown; // Or whatever your default rich text type is\n ColourName: ColourName<string>;\n GradientName: GradientName<string>;\n ModelType: ModelType<string>;\n ContentType: ContentType<string>;\n CollectionType: CollectionType<string>;\n ComponentType: ComponentType<string>;\n ExternalComponentType: ExternalComponentType<string>;\n ButtonVariant: ButtonVariant<string>;\n ButtonSize: ButtonSize<string>;\n PageContext: IPageContext<BaseCmsConfig>;\n Component: IBaseComponent<BaseCmsConfig>;\n Collection: IBaseCollection<BaseCmsConfig>;\n ExternalComponent: IBaseExternalComponent<BaseCmsConfig>;\n RichTextOptions: IRichTextOptions;\n PageContent: PageContent<BaseCmsConfig>;\n};\n\nexport interface ILinkProps<TConfig extends BaseCmsConfig> {\n parentId?: string;\n parentFieldId?: string;\n id: string;\n useName?: boolean | null;\n name: string;\n text?: string | null;\n icon?: IVisual;\n visual?: IVisual;\n href?: string | null;\n click?: () => void;\n type: 'Blank link' | 'External link' | 'Internal link' | 'Download link';\n backgroundColour?: TConfig['ColourName'] | TConfig['GradientName'] | null;\n textColour?: TConfig['ColourName'] | null;\n variant?: TConfig['ButtonVariant'];\n size?: TConfig['ButtonSize'];\n}\n\nexport interface IBLankLink<TConfig extends BaseCmsConfig> extends ILinkProps<TConfig> {\n type: 'Blank link';\n}\n\nexport interface IExternalLink<TConfig extends BaseCmsConfig> extends ILinkProps<TConfig> {\n type: 'External link';\n}\n\nexport interface IInternalLink<TConfig extends BaseCmsConfig> extends ILinkProps<TConfig> {\n type: 'Internal link';\n slug: string;\n indexed?: boolean | null;\n hidden?: boolean | null;\n tags?: ReadonlyArray<IInternalLink<TConfig>>;\n}\n\nexport interface IDownloadLink<TConfig extends BaseCmsConfig> extends ILinkProps<TConfig> {\n type: 'Download link';\n}\n\nexport function isBlankLink<TConfig extends BaseCmsConfig>(\n link: ILinkProps<TConfig>,\n): link is IBLankLink<TConfig> {\n return link.type === 'Blank link';\n}\n\nexport function isExternalLink<TConfig extends BaseCmsConfig>(\n link: ILinkProps<TConfig>,\n): link is IExternalLink<TConfig> {\n return link.type === 'External link';\n}\n\nexport function isInternalLink<TConfig extends BaseCmsConfig>(\n link: ILinkProps<TConfig>,\n): link is IInternalLink<TConfig> {\n return link.type === 'Internal link';\n}\n\nexport function isDownloadLink<TConfig extends BaseCmsConfig>(\n link: ILinkProps<TConfig>,\n): link is IDownloadLink<TConfig> {\n return link.type === 'Download link';\n}\n\nexport interface INavigation<TConfig extends BaseCmsConfig> {\n id: string;\n name: string;\n entries: ReadonlyArray<INavigationItem<TConfig>>;\n textColour?: TConfig['ColourName'];\n backgroundColour?: TConfig['ColourName'] | TConfig['GradientName'];\n}\n\nexport interface INavigationItem<TConfig extends BaseCmsConfig> {\n id: string;\n link?: ILinkProps<TConfig>;\n entries?: ReadonlyArray<INavigationItem<TConfig>>;\n longText: TConfig['RichText'] | string | null;\n}\n\nexport interface IBaseModel<TConfig extends BaseCmsConfig> {\n type: BaseModelType | TConfig['ModelType'];\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?: TConfig['ColourName'];\n backgroundColour?: TConfig['ColourName'] | TConfig['GradientName'];\n menu?: INavigation<TConfig>;\n footer?: INavigation<TConfig>;\n}\nexport type BaseModelLinkOmissions = 'menu' | 'footer';\n\nexport interface IBaseContent<TConfig extends BaseCmsConfig> {\n type: BaseContentType | TConfig['ContentType'];\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?: TConfig['ColourName'] | TConfig['GradientName'];\n textColour?: TConfig['ColourName'];\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<TConfig extends BaseCmsConfig> extends IBaseContent<TConfig> {\n type: 'Component';\n componentType: TConfig['ComponentType'];\n preHeading?: string | null;\n heading?: string | null;\n postHeading?: string | null;\n body?: TConfig['RichText'] | string;\n icon?: IVisual;\n links?: ReadonlyArray<ILinkProps<TConfig>>;\n additionalCopy?: TConfig['RichText'] | string;\n}\n\nexport function isComponent<TConfig extends BaseCmsConfig>(\n obj: unknown,\n): obj is TConfig['Component'] {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n if ((obj as TConfig['Component']).type !== 'Component') {\n return false;\n }\n return true;\n}\n\nexport type CollectionContent<TConfig extends BaseCmsConfig> =\n | IBaseComponent<TConfig>\n | IBaseCollection<TConfig>;\n\nexport interface IBaseCollection<TConfig extends BaseCmsConfig> extends IBaseContent<TConfig> {\n type: 'Collection';\n collectionType: TConfig['CollectionType'];\n anchor?: string | null;\n preHeading?: string | null;\n heading?: string | null;\n postHeading?: string | null;\n body?: TConfig['RichText'] | string;\n icon?: IVisual;\n links?: ReadonlyArray<ILinkProps<TConfig>>;\n additionalCopy?: TConfig['RichText'] | string;\n contents?: ReadonlyArray<CollectionContent<TConfig>>;\n}\n\nexport function isCollection<TConfig extends BaseCmsConfig>(\n obj: unknown,\n): obj is TConfig['Collection'] {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n if ((obj as TConfig['Collection']).type !== 'Collection') {\n return false;\n }\n return true;\n}\n\nexport interface IBaseExternalComponent<TConfig extends BaseCmsConfig>\n extends IBaseContent<TConfig> {\n type: 'External component';\n externalType: TConfig['ExternalComponentType'];\n data: unknown | null;\n}\n\nexport function isExternalComponent<TConfig extends BaseCmsConfig>(\n obj: unknown,\n): obj is TConfig['ExternalComponent'] {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n if ((obj as TConfig['ExternalComponent']).type !== 'External component') {\n return false;\n }\n return true;\n}\n\nexport interface IPerson<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {\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: TConfig['RichText'] | null | undefined;\n href: string | undefined;\n structuredData?: ReadonlyArray<unknown>;\n contents?: ReadonlyArray<PageContent<TConfig>>;\n}\n\nexport type PersonLink<TConfig extends BaseCmsConfig> = Omit<\n IPerson<TConfig>,\n BaseModelLinkOmissions | 'structuredData' | 'contents'\n>;\n\nexport function isPerson<TConfig extends BaseCmsConfig>(\n content: IBaseModel<TConfig>,\n): content is IPerson<TConfig> {\n return content.type === 'Person';\n}\n\nexport type PageContent<TConfig extends BaseCmsConfig> =\n | IBaseComponent<TConfig>\n | IBaseCollection<TConfig>\n | IBaseExternalComponent<TConfig>\n | IVisual\n | IInternalLink<TConfig>;\n","import type {\n BaseCmsConfig,\n BaseModelLinkOmissions,\n IBaseModel,\n IInternalLink,\n PageContent,\n} from './common';\n\nexport interface IPage<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {\n type: 'Page';\n isHomePage: boolean;\n structuredData?: ReadonlyArray<unknown>;\n contents?: ReadonlyArray<PageContent<TConfig>>;\n tags?: ReadonlyArray<IInternalLink<TConfig>>;\n}\n\nexport type PageLink<TConfig extends BaseCmsConfig> = Omit<\n IPage<TConfig>,\n BaseModelLinkOmissions | 'structuredData' | 'contents'\n>;\n\nexport function isPage<TConfig extends BaseCmsConfig>(\n content: IBaseModel<TConfig>,\n): content is IPage<TConfig> {\n return content.type === 'Page';\n}\n","import type { BaseCmsConfig, BaseModelLinkOmissions, IBaseModel, PageContent } from './common';\n\nexport interface ITag<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {\n type: 'Tag';\n tagType?: string | null;\n contents?: ReadonlyArray<PageContent<TConfig>>;\n}\n\nexport type TagLink<TConfig extends BaseCmsConfig> = Omit<\n ITag<TConfig>,\n BaseModelLinkOmissions | 'contents'\n>;\n\nexport function isTag<TConfig extends BaseCmsConfig>(\n content: IBaseModel<TConfig>,\n): content is ITag<TConfig> {\n return content.type === 'Tag';\n}\n\nexport interface ITags<TConfig extends BaseCmsConfig> extends IBaseModel<TConfig> {\n type: 'Tags';\n}\n\nexport function isTags<TConfig extends BaseCmsConfig>(\n content: IBaseModel<TConfig>,\n): content is ITags<TConfig> {\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 maxWidth: number;\n proportion: number;\n pixels: number;\n size: string;\n}\ntype IBreakpoint = Pick<IInternalBreakpoint, 'maxWidth'> &\n Partial<Omit<IInternalBreakpoint, 'maxWidth'>>;\nexport interface IVisualSizes {\n defaultSize?: string;\n defaultPixels?: number;\n breakpoints?: IBreakpoint[];\n}\n\nfunction fillInBreakpoints(breakpoints?: IBreakpoint[]): IInternalBreakpoint[] | undefined {\n return breakpoints?.map(({ maxWidth, proportion, pixels, size }) => {\n if (proportion) {\n return {\n maxWidth,\n proportion,\n pixels: Math.round(maxWidth * proportion),\n size: `${Math.round(100 * proportion)}vw`,\n };\n }\n if (pixels) {\n const proportion = Math.round(maxWidth / pixels);\n return {\n maxWidth,\n proportion,\n pixels,\n size: size ?? `${Math.round(100 * proportion)}vw`,\n };\n }\n\n return { maxWidth, proportion: 1, pixels: maxWidth, 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}\n\nexport interface IFullVideo extends IVideoCommon {\n type: 'Full video';\n preview?: IVideoDetails;\n full: IVideoDetails;\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":";AAkBO,SAAS,UAAU,OAAA,EAA8C;AACtE,EAAA,OAAO,QAAQ,IAAA,KAAS,SAAA;AAC1B;AAaO,SAAS,cAAc,OAAA,EAAkD;AAC9E,EAAA,OAAO,QAAQ,IAAA,KAAS,cAAA;AAC1B;;;AC6IO,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,CAAuB,SAAS,WAAA,EAAa;AAChD,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA;AACT;AAkBO,SAAS,aAAa,GAAA,EAAsC;AACjE,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,IAAA,EAAM;AAC3C,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAK,GAAA,CAAwB,SAAS,YAAA,EAAc;AAClD,IAAA,OAAO,KAAA;AAAA,EACT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,WAAA;AAAA,IACA,aAAA;AAAA,IACA,WAAA,EAAa,kBAAkB,WAAW;AAAA,GAC5C;AACF;AAiDO,SAAS,UAAU,GAAA,EAAwD;AAChF,EAAA,OAAO,KAAK,IAAA,KAAS,SAAA;AACvB;AAEO,SAAS,WAAW,GAAA,EAAyD;AAClF,EAAA,OAAO,KAAK,IAAA,KAAS,WAAA;AACvB;AAEO,SAAS,UAAU,GAAA,EAAwD;AAChF,EAAA,OAAO,KAAK,IAAA,KAAS,UAAA;AACvB;AAEO,SAAS,QAAQ,GAAA,EAAsD;AAC5E,EAAA,OAAO,UAAU,GAAG,CAAA,IAAK,WAAW,GAAG,CAAA,IAAK,UAAU,GAAG,CAAA;AAC3D;AAyCO,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\nexport interface IBaseArticle extends IBaseModel {\n type: 'Article';\n articleType?: IInternalLink;\n structuredData?: ReadonlyArray<unknown>;\n contents?: ReadonlyArray<ITyped>; // PageContent - will be narrowed at project level\n tags?: ReadonlyArray<IInternalLink>;\n}\n\nexport type ArticleLink = Omit<\n IBaseArticle,\n BaseModelLinkOmissions | 'structuredData' | 'contents' | 'tags'\n> & {\n tags?: ReadonlyArray<TagLink>;\n};\n\nexport function isArticle(content: IBaseModel): content is IBaseArticle {\n return content.type === 'Article';\n}\n\nexport interface IBaseArticleType extends IBaseModel {\n type: 'Article type';\n indexPageContent?: ReadonlyArray<ITyped>; // PageContent - will be narrowed at project level\n searchPageContent?: ReadonlyArray<ITyped>; // PageContent - will be narrowed at project level\n}\n\nexport type ArticleTypeLink = Omit<\n IBaseArticleType,\n BaseModelLinkOmissions | 'indexPageContent' | 'searchPageContent'\n>;\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 */\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 */\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; // ArticleLink - will be narrowed at project level\n articleTypeLink?: ITyped; // ArticleTypeLink - will be narrowed at project level\n personLink?: ITyped; // PersonLink - will be narrowed at project level\n pageLink?: ITyped; // PageLink - will be narrowed at project level\n tagLink?: ITyped; // 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 icon?: IVisual;\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}\n\nexport interface IInternalLink extends ILinkProps {\n type: 'Internal link';\n slug: string;\n indexed?: boolean | null;\n hidden?: boolean | null;\n tags?: ReadonlyArray<IInternalLink>;\n}\n\nexport interface IDownloadLink extends ILinkProps {\n type: 'Download link';\n}\n\nexport function isBlankLink(link: ILinkProps): link is IBlankLink {\n return link.type === 'Blank link';\n}\n\nexport function isExternalLink(link: ILinkProps): link is IExternalLink {\n return link.type === 'External link';\n}\n\nexport function isInternalLink(link: ILinkProps): link is IInternalLink {\n return link.type === 'Internal link';\n}\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 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 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 = IBaseComponent | IBaseCollection;\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\nexport interface IBasePage extends IBaseModel {\n type: 'Page';\n isHomePage: boolean;\n structuredData?: ReadonlyArray<unknown>;\n contents?: ReadonlyArray<ITyped>; // PageContent - will be narrowed at project level\n tags?: ReadonlyArray<IInternalLink>;\n}\n\nexport type PageLink = Omit<IBasePage, BaseModelLinkOmissions | 'structuredData' | 'contents'>;\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 maxWidth: number;\n proportion: number;\n pixels: number;\n size: string;\n}\ntype IBreakpoint = Pick<IInternalBreakpoint, 'maxWidth'> &\n Partial<Omit<IInternalBreakpoint, 'maxWidth'>>;\nexport interface IVisualSizes {\n defaultSize?: string;\n defaultPixels?: number;\n breakpoints?: IBreakpoint[];\n}\n\nfunction fillInBreakpoints(breakpoints?: IBreakpoint[]): IInternalBreakpoint[] | undefined {\n return breakpoints?.map(({ maxWidth, proportion, pixels, size }) => {\n if (proportion) {\n return {\n maxWidth,\n proportion,\n pixels: Math.round(maxWidth * proportion),\n size: `${Math.round(100 * proportion)}vw`,\n };\n }\n if (pixels) {\n const proportion = Math.round(maxWidth / pixels);\n return {\n maxWidth,\n proportion,\n pixels,\n size: size ?? `${Math.round(100 * proportion)}vw`,\n };\n }\n\n return { maxWidth, proportion: 1, pixels: maxWidth, 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": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Core TypeScript type definitions for SE Studio content models",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,10 +28,10 @@
28
28
  "nextjs"
29
29
  ],
30
30
  "devDependencies": {
31
- "@biomejs/biome": "^2.3.3",
31
+ "@biomejs/biome": "^2.3.4",
32
32
  "tsup": "^8.5.0",
33
33
  "typescript": "^5.9.3",
34
- "vitest": "^4.0.6"
34
+ "vitest": "^4.0.8"
35
35
  },
36
36
  "dependencies": {
37
37
  "@extractus/oembed-extractor": "^4.0.9"