@ethlete/contentful 4.0.0-next.11 → 4.0.0-next.13
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/CHANGELOG.md +29 -0
- package/README.md +6 -1
- package/fesm2022/ethlete-contentful.mjs +382 -262
- package/fesm2022/ethlete-contentful.mjs.map +1 -1
- package/generators/generators.json +10 -0
- package/generators/migrate-contentful-asset-classes/migration.js +163 -0
- package/generators/migrate-contentful-asset-classes/schema.json +26 -0
- package/generators/migrate-contentful-default-components/contentful-default-components.js +73 -0
- package/generators/migrate-contentful-default-components/migration.js +74 -0
- package/generators/migrate-contentful-default-components/schema.json +26 -0
- package/generators/migrate-to-contentful-v5/migration.js +3 -3
- package/migrations.json +19 -0
- package/package.json +6 -6
- package/types/ethlete-contentful.d.ts +90 -24
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
2
|
import { Type, InputSignal, InjectionToken, Provider } from '@angular/core';
|
|
3
|
-
import * as _ethlete_core from '@ethlete/core';
|
|
4
|
-
import { NgClassType } from '@ethlete/core';
|
|
5
3
|
import { GQL } from '@ethlete/query';
|
|
6
4
|
import { Mark, BLOCKS, INLINES, NodeData, Block } from '@contentful/rich-text-types';
|
|
5
|
+
import * as _ethlete_core from '@ethlete/core';
|
|
7
6
|
import * as _ethlete_contentful from '@ethlete/contentful';
|
|
8
7
|
import * as _ethlete_components from '@ethlete/components';
|
|
9
8
|
import { PictureSource } from '@ethlete/components';
|
|
@@ -88,6 +87,43 @@ type ContentfulGqlCollectionFilterVariables<TCustomWhere extends Record<string,
|
|
|
88
87
|
locale?: string;
|
|
89
88
|
};
|
|
90
89
|
|
|
90
|
+
type ContentfulGqlRichTextEntry = {
|
|
91
|
+
__typename?: string | null;
|
|
92
|
+
sys: {
|
|
93
|
+
id: string;
|
|
94
|
+
};
|
|
95
|
+
[field: string]: unknown;
|
|
96
|
+
};
|
|
97
|
+
type ContentfulGqlLinkList<T> = (T | null | undefined)[] | null;
|
|
98
|
+
/**
|
|
99
|
+
* A rich-text field as returned by the Contentful GraphQL API. Select `json` and the `links` the
|
|
100
|
+
* document references, and pass the field to `[gqlRichText]` as-is.
|
|
101
|
+
*/
|
|
102
|
+
type ContentfulGqlRichText = {
|
|
103
|
+
json: RichTextResponse;
|
|
104
|
+
links?: {
|
|
105
|
+
assets?: {
|
|
106
|
+
block?: ContentfulGqlLinkList<ContentfulGqlAsset>;
|
|
107
|
+
hyperlink?: ContentfulGqlLinkList<ContentfulGqlAsset>;
|
|
108
|
+
} | null;
|
|
109
|
+
entries?: {
|
|
110
|
+
block?: ContentfulGqlLinkList<ContentfulGqlRichTextEntry>;
|
|
111
|
+
inline?: ContentfulGqlLinkList<ContentfulGqlRichTextEntry>;
|
|
112
|
+
hyperlink?: ContentfulGqlLinkList<ContentfulGqlRichTextEntry>;
|
|
113
|
+
} | null;
|
|
114
|
+
} | null;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Maps the `links` of a GraphQL rich-text field to the entries and assets the renderer resolves
|
|
118
|
+
* embeds against. An entry's content type id is its `__typename` with the first letter lower-cased,
|
|
119
|
+
* which is how Contentful derives a GraphQL type name from a content type id. Entries without a
|
|
120
|
+
* `__typename` are dropped.
|
|
121
|
+
*/
|
|
122
|
+
declare const mapContentfulGqlLinks: (links: ContentfulGqlRichText["links"]) => {
|
|
123
|
+
assets: ContentfulRestAsset[];
|
|
124
|
+
entries: ContentfulEntry[];
|
|
125
|
+
};
|
|
126
|
+
|
|
91
127
|
type MarkTagName = 'strong' | 'em' | 'u' | 'code' | 's' | 'sub' | 'sup';
|
|
92
128
|
/**
|
|
93
129
|
* Translates contentful text marks into the semantic html elements the marked text is
|
|
@@ -149,6 +185,8 @@ declare class ContentfulRichTextRendererComponent {
|
|
|
149
185
|
private elementRef;
|
|
150
186
|
private config;
|
|
151
187
|
private document;
|
|
188
|
+
private location;
|
|
189
|
+
private url;
|
|
152
190
|
/**
|
|
153
191
|
* The contentful response gotten via their REST api.
|
|
154
192
|
* @see https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries/entries-collection
|
|
@@ -158,9 +196,17 @@ declare class ContentfulRichTextRendererComponent {
|
|
|
158
196
|
* The path to where the rich text field is inside the contentful response. Dot and array notation is allowed.
|
|
159
197
|
* @example "items[0].fields.html"
|
|
160
198
|
*/
|
|
161
|
-
richTextPath: _angular_core.InputSignal<string>;
|
|
199
|
+
richTextPath: _angular_core.InputSignal<string | undefined>;
|
|
200
|
+
/**
|
|
201
|
+
* A rich-text field from the Contentful GraphQL API, passed as-is. An alternative to `content` and
|
|
202
|
+
* `richTextPath`; setting both is an error in dev mode.
|
|
203
|
+
* @example { json, links: { assets: { block, hyperlink }, entries: { block, inline, hyperlink } } }
|
|
204
|
+
*/
|
|
205
|
+
gqlRichText: _angular_core.InputSignal<ContentfulGqlRichText | null | undefined>;
|
|
162
206
|
private readonly executedCommandsCache;
|
|
207
|
+
private includes;
|
|
163
208
|
private contentIncludesMap;
|
|
209
|
+
private includedEntries;
|
|
164
210
|
private richTextData;
|
|
165
211
|
private renderCommands;
|
|
166
212
|
private renderInstructions;
|
|
@@ -175,7 +221,7 @@ declare class ContentfulRichTextRendererComponent {
|
|
|
175
221
|
private findParent;
|
|
176
222
|
private renderInsertAfter;
|
|
177
223
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentfulRichTextRendererComponent, never>;
|
|
178
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulRichTextRendererComponent, "et-contentful-rich-text-renderer", never, { "content": { "alias": "content"; "required":
|
|
224
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulRichTextRendererComponent, "et-contentful-rich-text-renderer", never, { "content": { "alias": "content"; "required": false; "isSignal": true; }; "richTextPath": { "alias": "richTextPath"; "required": false; "isSignal": true; }; "gqlRichText": { "alias": "gqlRichText"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
179
225
|
}
|
|
180
226
|
|
|
181
227
|
declare const isRichTextRootNode: (node: unknown) => node is RichTextResponse;
|
|
@@ -194,8 +240,8 @@ type ComponentLikeWithAsset = Type<{
|
|
|
194
240
|
type ComponentLikeWithLink = Type<{
|
|
195
241
|
href: InputSignal<string>;
|
|
196
242
|
text: InputSignal<string>;
|
|
197
|
-
|
|
198
|
-
|
|
243
|
+
marks?: InputSignal<readonly string[]>;
|
|
244
|
+
richText?: InputSignal<boolean>;
|
|
199
245
|
}>;
|
|
200
246
|
type ComponentLikeWithContentfulRendererInputs = Type<{
|
|
201
247
|
fields?: InputSignal<any>;
|
|
@@ -212,7 +258,8 @@ type ContentfulAssetComponents = {
|
|
|
212
258
|
};
|
|
213
259
|
type ContentfulConfig = {
|
|
214
260
|
/**
|
|
215
|
-
*
|
|
261
|
+
* Components for rendering contentful assets and hyperlinks. Empty unless
|
|
262
|
+
* `CONTENTFUL_DEFAULT_COMPONENTS` is spread into the config or a component is named here.
|
|
216
263
|
*/
|
|
217
264
|
components: ContentfulAssetComponents;
|
|
218
265
|
/**
|
|
@@ -249,11 +296,15 @@ type ContentfulConfig = {
|
|
|
249
296
|
*/
|
|
250
297
|
sizes: string[];
|
|
251
298
|
/**
|
|
252
|
-
* Background color for the image in hex. Eg. `"000000"`
|
|
299
|
+
* Background color for the image in hex. Eg. `"000000"` (a leading `#` is stripped)
|
|
253
300
|
*/
|
|
254
301
|
backgroundColor: string | null;
|
|
255
302
|
};
|
|
256
303
|
};
|
|
304
|
+
type ContentfulConfigOptions = Partial<Omit<ContentfulConfig, 'imageOptions'>> & {
|
|
305
|
+
/** Merged one level deep into the defaults, so a single option can be overridden. */
|
|
306
|
+
imageOptions?: Partial<ContentfulConfig['imageOptions']>;
|
|
307
|
+
};
|
|
257
308
|
type ContentfulLinkType = 'Space' | 'ContentType' | 'Environment' | 'Entry' | 'Asset' | 'Tag';
|
|
258
309
|
type ContentfulLink<T extends ContentfulLinkType> = {
|
|
259
310
|
type: 'Link';
|
|
@@ -347,15 +398,12 @@ type RichTextResponse = {
|
|
|
347
398
|
|
|
348
399
|
declare class ContentfulAudioComponent {
|
|
349
400
|
asset: _angular_core.InputSignal<ContentfulGqlAsset | ContentfulRestAsset | null | undefined>;
|
|
350
|
-
audioClass: _angular_core.InputSignal<NgClassType>;
|
|
351
|
-
figureClass: _angular_core.InputSignal<NgClassType>;
|
|
352
|
-
figcaptionClass: _angular_core.InputSignal<NgClassType>;
|
|
353
401
|
protected data: _angular_core.Signal<{
|
|
354
402
|
url: string;
|
|
355
403
|
title: string | null;
|
|
356
404
|
} | null>;
|
|
357
405
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentfulAudioComponent, never>;
|
|
358
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulAudioComponent, "et-contentful-audio", never, { "asset": { "alias": "asset"; "required": true; "isSignal": true; };
|
|
406
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulAudioComponent, "et-contentful-audio", never, { "asset": { "alias": "asset"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
359
407
|
}
|
|
360
408
|
|
|
361
409
|
/** Every string `et-contentful-file` renders itself. Override them app-wide with {@link provideContentfulFileLabels}. */
|
|
@@ -379,14 +427,13 @@ declare const CONTENTFUL_FILE_LABELS: _angular_core.InjectionToken<_ethlete_core
|
|
|
379
427
|
declare class ContentfulFileComponent {
|
|
380
428
|
protected labels: _angular_core.Signal<_ethlete_contentful.ContentfulFileLabels>;
|
|
381
429
|
asset: _angular_core.InputSignal<ContentfulGqlAsset | ContentfulRestAsset | null | undefined>;
|
|
382
|
-
fileClass: _angular_core.InputSignal<NgClassType>;
|
|
383
430
|
protected data: _angular_core.Signal<{
|
|
384
431
|
url: string;
|
|
385
432
|
size: number | null;
|
|
386
433
|
title: string | null;
|
|
387
434
|
} | null>;
|
|
388
435
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentfulFileComponent, never>;
|
|
389
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulFileComponent, "et-contentful-file", never, { "asset": { "alias": "asset"; "required": true; "isSignal": true; };
|
|
436
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulFileComponent, "et-contentful-file", never, { "asset": { "alias": "asset"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
390
437
|
}
|
|
391
438
|
|
|
392
439
|
declare class ContentfulImageComponent {
|
|
@@ -441,46 +488,65 @@ declare const generateContentfulImageSources: (data: ContentfulRestAsset | Conte
|
|
|
441
488
|
|
|
442
489
|
declare class ContentfulLinkComponent {
|
|
443
490
|
private document;
|
|
491
|
+
private location;
|
|
444
492
|
private router;
|
|
445
493
|
private config;
|
|
446
494
|
private url;
|
|
447
495
|
href: _angular_core.InputSignal<string>;
|
|
448
496
|
text: _angular_core.InputSignal<string>;
|
|
449
|
-
|
|
450
|
-
|
|
497
|
+
marks: _angular_core.InputSignal<readonly string[]>;
|
|
498
|
+
richText: _angular_core.InputSignal<boolean>;
|
|
451
499
|
protected usesRouterLink: _angular_core.Signal<boolean>;
|
|
500
|
+
protected anchorHref: _angular_core.Signal<string>;
|
|
452
501
|
protected openInNewTab: _angular_core.Signal<boolean>;
|
|
453
502
|
protected internalPath: _angular_core.Signal<string>;
|
|
454
503
|
protected internalUrlTree: _angular_core.Signal<_angular_router.UrlTree>;
|
|
455
|
-
protected
|
|
504
|
+
protected modifierClasses: _angular_core.Signal<string[]>;
|
|
456
505
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentfulLinkComponent, never>;
|
|
457
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulLinkComponent, "et-contentful-link", never, { "href": { "alias": "href"; "required": true; "isSignal": true; }; "text": { "alias": "text"; "required": true; "isSignal": true; }; "
|
|
506
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulLinkComponent, "et-contentful-link", never, { "href": { "alias": "href"; "required": true; "isSignal": true; }; "text": { "alias": "text"; "required": true; "isSignal": true; }; "marks": { "alias": "marks"; "required": false; "isSignal": true; }; "richText": { "alias": "richText"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
458
507
|
}
|
|
459
508
|
|
|
460
509
|
declare class ContentfulVideoComponent {
|
|
461
510
|
asset: _angular_core.InputSignal<ContentfulGqlAsset | ContentfulRestAsset | null | undefined>;
|
|
462
|
-
videoClass: _angular_core.InputSignal<NgClassType>;
|
|
463
511
|
protected data: _angular_core.Signal<{
|
|
464
512
|
url: string;
|
|
465
513
|
contentType: string | null;
|
|
466
514
|
} | null>;
|
|
467
515
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentfulVideoComponent, never>;
|
|
468
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulVideoComponent, "et-contentful-video", never, { "asset": { "alias": "asset"; "required": true; "isSignal": true; };
|
|
516
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulVideoComponent, "et-contentful-video", never, { "asset": { "alias": "asset"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
469
517
|
}
|
|
470
518
|
|
|
471
519
|
declare const CONTENTFUL_CONFIG: InjectionToken<ContentfulConfig>;
|
|
472
520
|
|
|
473
521
|
declare const ContentfulImports: readonly [typeof ContentfulAudioComponent, typeof ContentfulFileComponent, typeof ContentfulImageComponent, typeof ContentfulVideoComponent, typeof ContentfulRichTextRendererComponent];
|
|
474
522
|
|
|
475
|
-
declare const createContentfulConfig: (
|
|
523
|
+
declare const createContentfulConfig: (options?: ContentfulConfigOptions | null) => ContentfulConfig;
|
|
476
524
|
/**
|
|
477
525
|
* Reads the contentful config from the current injector. Falls back to a config without
|
|
478
526
|
* any `components` when none was provided via `provideContentfulConfig()`.
|
|
479
527
|
*/
|
|
480
528
|
declare const injectContentfulConfig: () => ContentfulConfig;
|
|
481
529
|
|
|
482
|
-
|
|
530
|
+
/**
|
|
531
|
+
* The shipped audio, file, image, video and link components, to spread into `provideContentfulConfig`.
|
|
532
|
+
* An app that brings its own components, or renders text only, leaves this out and bundles none of them.
|
|
533
|
+
* To replace one, spread the map instead: `components: { ...CONTENTFUL_DEFAULT_COMPONENTS.components, image: MyImage }`.
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* provideContentfulConfig({ ...CONTENTFUL_DEFAULT_COMPONENTS });
|
|
537
|
+
*/
|
|
538
|
+
declare const CONTENTFUL_DEFAULT_COMPONENTS: {
|
|
539
|
+
components: {
|
|
540
|
+
audio: typeof ContentfulAudioComponent;
|
|
541
|
+
file: typeof ContentfulFileComponent;
|
|
542
|
+
image: typeof ContentfulImageComponent;
|
|
543
|
+
video: typeof ContentfulVideoComponent;
|
|
544
|
+
link: typeof ContentfulLinkComponent;
|
|
545
|
+
};
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
declare const provideContentfulConfig: (contentfulConfig?: ContentfulConfigOptions | null) => Provider;
|
|
483
549
|
declare const isContentfulEntryType: <T extends ContentfulEntry>(entry: ContentfulEntry, type: string) => entry is T;
|
|
484
550
|
|
|
485
|
-
export { CONTENTFUL_CONFIG, CONTENTFUL_FILE_LABELS, ContentfulAudioComponent, ContentfulFileComponent, ContentfulImageComponent, ContentfulImports, ContentfulLinkComponent, ContentfulRichTextRendererComponent, ContentfulVideoComponent, DEFAULT_CONTENTFUL_FILE_LABELS, ET_CONTENTFUL_ANY_ENTRY_CONTENT_TYPE_SYS_ID, GQL_FRAGMENT_CONTENTFUL_ASSET, createContentfulConfig, createContentfulIncludeMap, generateContentfulImageSources, generateDefaultContentfulImageSource, injectContentfulConfig, injectContentfulFileLabels, isContentfulEntryType, isContentfulGqlAsset, isRichTextRootNode, marksToClass, marksToTags, parseContentfulImageSize, provideContentfulConfig, provideContentfulFileLabels, translateContentfulNodeTypeToHtmlTag };
|
|
486
|
-
export type { ComponentLikeWithAsset, ComponentLikeWithContentfulRendererInputs, ComponentLikeWithLink, ContentfulAssetComponents, ContentfulAssetFileData, ContentfulAssetImageData, ContentfulAssetLink, ContentfulAssetLinkItem, ContentfulCollection, ContentfulConfig, ContentfulContentTypeLink, ContentfulEntry, ContentfulEntryLink, ContentfulEntryLinkItem, ContentfulEntrySys, ContentfulEnvironmentLink, ContentfulFileLabels, ContentfulGqlAsset, ContentfulGqlCollectionFilterVariables, ContentfulGqlOrder, ContentfulGqlWhereFilter, ContentfulImageFocusArea, ContentfulImageResizeBehavior, ContentfulImageSourcesOptions, ContentfulIncludeMap, ContentfulLink, ContentfulLinkType, ContentfulMetadata, ContentfulRestAsset, ContentfulSpaceLink, ContentfulSys, ContentfulTagLink, ContentfulTagLinkItem, CreateContentfulIncludeMapConfig, RichTextResponse };
|
|
551
|
+
export { CONTENTFUL_CONFIG, CONTENTFUL_DEFAULT_COMPONENTS, CONTENTFUL_FILE_LABELS, ContentfulAudioComponent, ContentfulFileComponent, ContentfulImageComponent, ContentfulImports, ContentfulLinkComponent, ContentfulRichTextRendererComponent, ContentfulVideoComponent, DEFAULT_CONTENTFUL_FILE_LABELS, ET_CONTENTFUL_ANY_ENTRY_CONTENT_TYPE_SYS_ID, GQL_FRAGMENT_CONTENTFUL_ASSET, createContentfulConfig, createContentfulIncludeMap, generateContentfulImageSources, generateDefaultContentfulImageSource, injectContentfulConfig, injectContentfulFileLabels, isContentfulEntryType, isContentfulGqlAsset, isRichTextRootNode, mapContentfulGqlLinks, marksToClass, marksToTags, parseContentfulImageSize, provideContentfulConfig, provideContentfulFileLabels, translateContentfulNodeTypeToHtmlTag };
|
|
552
|
+
export type { ComponentLikeWithAsset, ComponentLikeWithContentfulRendererInputs, ComponentLikeWithLink, ContentfulAssetComponents, ContentfulAssetFileData, ContentfulAssetImageData, ContentfulAssetLink, ContentfulAssetLinkItem, ContentfulCollection, ContentfulConfig, ContentfulConfigOptions, ContentfulContentTypeLink, ContentfulEntry, ContentfulEntryLink, ContentfulEntryLinkItem, ContentfulEntrySys, ContentfulEnvironmentLink, ContentfulFileLabels, ContentfulGqlAsset, ContentfulGqlCollectionFilterVariables, ContentfulGqlOrder, ContentfulGqlRichText, ContentfulGqlRichTextEntry, ContentfulGqlWhereFilter, ContentfulImageFocusArea, ContentfulImageResizeBehavior, ContentfulImageSourcesOptions, ContentfulIncludeMap, ContentfulLink, ContentfulLinkType, ContentfulMetadata, ContentfulRestAsset, ContentfulSpaceLink, ContentfulSys, ContentfulTagLink, ContentfulTagLinkItem, CreateContentfulIncludeMapConfig, RichTextResponse };
|