@se-studio/contentful-rest-api 1.16.2 → 1.16.3
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 +6 -0
- package/dist/api/template.d.ts +12 -2
- package/dist/api/template.d.ts.map +1 -1
- package/dist/api/template.js +9 -4
- package/dist/api/template.js.map +1 -1
- package/docs/llms.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/api/template.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { INavigation, ISvgImage, ITyped } from '@se-studio/core-data-types';
|
|
2
|
-
import type {
|
|
1
|
+
import type { INavigation, ISchema, ISvgImage, ITyped } from '@se-studio/core-data-types';
|
|
2
|
+
import type { Entry } from 'contentful';
|
|
3
|
+
import type { BaseTemplateSkeleton } from '../baseTypes/baseTemplate';
|
|
4
|
+
import type { BaseConverterContext, ConverterContext } from '../converters/helpers';
|
|
3
5
|
import type { CmsResponse, ContentfulConfig, FetchOptions } from '../types';
|
|
6
|
+
import type { DefaultChainModifier } from './types';
|
|
4
7
|
/**
|
|
5
8
|
* Fetched template data structure
|
|
6
9
|
* Extends the resolved template with id and label for direct fetching
|
|
@@ -16,7 +19,14 @@ export interface IFetchedTemplate {
|
|
|
16
19
|
textColour?: string;
|
|
17
20
|
stickyNav: boolean;
|
|
18
21
|
icons?: ReadonlyArray<ISvgImage>;
|
|
22
|
+
/** Schema.org Mustache templates linked on the template (parity with page resolveTemplate). */
|
|
23
|
+
structuredData: ReadonlyArray<ISchema>;
|
|
19
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Converts a template entry to IFetchedTemplate (includes resolved structuredData).
|
|
27
|
+
* Exported for unit tests; used by {@link contentfulTemplateRest}.
|
|
28
|
+
*/
|
|
29
|
+
export declare function convertTemplateEntry(context: ConverterContext, entry: Entry<BaseTemplateSkeleton, DefaultChainModifier, string>): IFetchedTemplate;
|
|
20
30
|
/**
|
|
21
31
|
* Fetches a template from Contentful by cmsLabel
|
|
22
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/api/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/api/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIpF,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAClC,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACjC,+FAA+F;IAC/F,cAAc,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACxC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,KAAK,CAAC,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,CAAC,GAC/D,gBAAgB,CAuDlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,WAAW,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAc/C"}
|
package/dist/api/template.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { collectIconsFromContent, collectIconsFromNavigation } from '../converters/iconCollector.js';
|
|
2
2
|
import { resolveNavigationOrStub } from '../converters/navigationItem.js';
|
|
3
|
-
import { resolvePageContent } from '../converters/resolver.js';
|
|
3
|
+
import { resolvePageContent, resolveSchema } from '../converters/resolver.js';
|
|
4
4
|
import { fetchSingleEntity } from './helpers.js';
|
|
5
5
|
/**
|
|
6
|
-
* Converts a template entry to IFetchedTemplate
|
|
6
|
+
* Converts a template entry to IFetchedTemplate (includes resolved structuredData).
|
|
7
|
+
* Exported for unit tests; used by {@link contentfulTemplateRest}.
|
|
7
8
|
*/
|
|
8
|
-
function
|
|
9
|
+
export function convertTemplateEntry(context, entry) {
|
|
9
10
|
const { fields, sys } = entry;
|
|
10
11
|
const id = sys.id;
|
|
11
12
|
// Resolve content arrays
|
|
@@ -33,6 +34,9 @@ function templateConverter(context, entry) {
|
|
|
33
34
|
seenIconIds.add(icon.id);
|
|
34
35
|
return true;
|
|
35
36
|
});
|
|
37
|
+
const structuredData = fields.structuredData
|
|
38
|
+
?.map((link) => resolveSchema(context, id, link))
|
|
39
|
+
.filter((item) => item !== null) ?? [];
|
|
36
40
|
return {
|
|
37
41
|
id,
|
|
38
42
|
cmsLabel: fields.cmsLabel,
|
|
@@ -44,6 +48,7 @@ function templateConverter(context, entry) {
|
|
|
44
48
|
textColour: fields.textColour,
|
|
45
49
|
stickyNav,
|
|
46
50
|
icons: icons.length > 0 ? icons : undefined,
|
|
51
|
+
structuredData,
|
|
47
52
|
};
|
|
48
53
|
}
|
|
49
54
|
/**
|
|
@@ -80,7 +85,7 @@ export async function contentfulTemplateRest(context, config, cmsLabel, options)
|
|
|
80
85
|
cacheTagType: 'template',
|
|
81
86
|
cacheTagIdentifier: cmsLabel,
|
|
82
87
|
query: { 'fields.cmsLabel': cmsLabel },
|
|
83
|
-
resolver: (ctx, entry) =>
|
|
88
|
+
resolver: (ctx, entry) => convertTemplateEntry(ctx, entry),
|
|
84
89
|
errorLogContext: { cmsLabel },
|
|
85
90
|
}, { include: 7, ...options });
|
|
86
91
|
}
|
package/dist/api/template.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/api/template.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/api/template.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAsB9C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAyB,EACzB,KAAgE;IAEhE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAC9B,MAAM,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,eAAe,EAAE,EAAE,QAAQ,EAAE;KAC9B,EACD,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAC3B,CAAC;AACJ,CAAC"}
|
package/docs/llms.md
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
contentfulTagTypeRest,
|
|
38
38
|
contentfulPersonRest,
|
|
39
39
|
contentfulBannerRest,
|
|
40
|
-
contentfulTemplateRest,
|
|
40
|
+
contentfulTemplateRest, // IFetchedTemplate includes structuredData (Schema.org Mustache list)
|
|
41
41
|
contentfulComponentRest,
|
|
42
42
|
contentfulCustomTypeRest,
|
|
43
43
|
contentfulAssetRest,
|
package/package.json
CHANGED