@contentful/experiences-core 1.36.0-beta.0 → 1.36.0-beta.2
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/fetchers/createExperience.d.ts +10 -3
- package/dist/fetchers/fetchAllEntities.d.ts +2 -2
- package/dist/fetchers/fetchById.d.ts +2 -1
- package/dist/fetchers/fetchBySlug.d.ts +2 -1
- package/dist/fetchers/fetchExperienceEntry.d.ts +30 -0
- package/dist/fetchers/fetchReferencedEntities.d.ts +28 -0
- package/dist/index.d.ts +11 -8
- package/dist/index.js +1434 -1299
- package/dist/index.js.map +1 -1
- package/dist/utils/localizeEntity.d.ts +24 -0
- package/dist/utils/styleUtils/ssrStyles.d.ts +5 -3
- package/package.json +3 -3
|
@@ -2,17 +2,24 @@ import { Entry, Asset } from 'contentful';
|
|
|
2
2
|
import { Experience } from '../types.js';
|
|
3
3
|
import { EntityStore } from '../entity/EntityStore.js';
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type CreateExperienceParams = {
|
|
6
6
|
experienceEntry: Entry;
|
|
7
7
|
referencedEntries: Array<Entry>;
|
|
8
8
|
referencedAssets: Array<Asset>;
|
|
9
9
|
locale: string;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* Create an experience instance
|
|
12
|
+
* Create an experience instance using a serialized version of the entity store for SSR purposes.
|
|
13
13
|
* @param {string} json - JSON representation of the experience
|
|
14
14
|
*/
|
|
15
15
|
declare function createExperience(json: string): Experience<EntityStore>;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Create an experience instance using the already fetched entries and assets.
|
|
18
|
+
* @param options.experienceEntry - Localized experience entry which will be rendered
|
|
19
|
+
* @param options.referencedEntries - Array of localized entries which are referenced by the experience entry in its dataSource
|
|
20
|
+
* @param options.referencedAssets - Array of localized assets which are referenced by the experience entry in its dataSource
|
|
21
|
+
* @param options.locale - (Soon to be removed unused parameter)
|
|
22
|
+
*/
|
|
23
|
+
declare function createExperience(options: CreateExperienceParams): Experience<EntityStore>;
|
|
17
24
|
|
|
18
25
|
export { createExperience };
|
|
@@ -2,7 +2,7 @@ import { ContentfulClientApi, Entry, Asset } from 'contentful';
|
|
|
2
2
|
import { MinimalEntryCollection } from './gatherAutoFetchedReferentsFromIncludes.js';
|
|
3
3
|
|
|
4
4
|
declare const fetchAllEntries: ({ client, ids, locale, skip, limit, responseItems, responseIncludes, }: {
|
|
5
|
-
client: ContentfulClientApi<undefined>;
|
|
5
|
+
client: ContentfulClientApi<undefined> | ContentfulClientApi<"WITH_ALL_LOCALES">;
|
|
6
6
|
ids: string[];
|
|
7
7
|
locale?: string;
|
|
8
8
|
skip?: number;
|
|
@@ -17,7 +17,7 @@ declare const fetchAllEntries: ({ client, ids, locale, skip, limit, responseItem
|
|
|
17
17
|
};
|
|
18
18
|
}>;
|
|
19
19
|
declare const fetchAllAssets: ({ client, ids, locale, skip, limit, responseItems, }: {
|
|
20
|
-
client: ContentfulClientApi<undefined>;
|
|
20
|
+
client: ContentfulClientApi<undefined> | ContentfulClientApi<"WITH_ALL_LOCALES">;
|
|
21
21
|
ids: string[];
|
|
22
22
|
locale?: string;
|
|
23
23
|
skip?: number;
|
|
@@ -15,7 +15,8 @@ type FetchByIdParams = {
|
|
|
15
15
|
isEditorMode?: boolean;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Fetches an experience
|
|
18
|
+
* Fetches an experience entry by its id and additionally fetches all its references to return
|
|
19
|
+
* an initilized experience instance.
|
|
19
20
|
* @param {FetchByIdParams} options - options to fetch the experience
|
|
20
21
|
*/
|
|
21
22
|
declare function fetchById({ client, experienceTypeId, id, localeCode, isEditorMode, }: FetchByIdParams): Promise<Experience<EntityStore> | undefined>;
|
|
@@ -15,7 +15,8 @@ type FetchBySlugParams = {
|
|
|
15
15
|
isEditorMode?: boolean;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Fetches an experience
|
|
18
|
+
* Fetches an experience entry by its slug and additionally fetches all its references to return
|
|
19
|
+
* an initilized experience instance.
|
|
19
20
|
* @param {FetchBySlugParams} options - options to fetch the experience
|
|
20
21
|
*/
|
|
21
22
|
declare function fetchBySlug({ client, experienceTypeId, slug, localeCode, isEditorMode, }: FetchBySlugParams): Promise<Experience<EntityStore> | undefined>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Entry, ContentfulClientApi } from 'contentful';
|
|
2
|
+
|
|
3
|
+
type ClientAndLocaleParams = {
|
|
4
|
+
client: ContentfulClientApi<undefined>;
|
|
5
|
+
locale?: string;
|
|
6
|
+
} | {
|
|
7
|
+
client: ContentfulClientApi<'WITH_ALL_LOCALES'>;
|
|
8
|
+
/** When fetching all locales, this may not be defined */
|
|
9
|
+
locale?: undefined;
|
|
10
|
+
};
|
|
11
|
+
type FetchExperienceEntryParams = {
|
|
12
|
+
experienceTypeId: string;
|
|
13
|
+
identifier: {
|
|
14
|
+
slug: string;
|
|
15
|
+
} | {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
} & ClientAndLocaleParams;
|
|
19
|
+
/**
|
|
20
|
+
* Fetches an experience entry by its slug or id. Throws an error if there are multiple
|
|
21
|
+
* entries with the same slug. Additionally, it resolves all nested pattern entries inside `fields.usedComponents`.
|
|
22
|
+
* @param options.client - Instantiated client from the Contentful SDK. If this is using the `withAllLocales` modifier, you may not provide a specific locale.
|
|
23
|
+
* @param options.locale - Provide a locale if your experience contains custom localized fields. Otherwise, it will fallback to the default locale.
|
|
24
|
+
* @param options.experienceTypeId - id of the content type associated with the experience
|
|
25
|
+
* @param options.identifier - identifying condition to find the correct experience entry
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
declare const fetchExperienceEntry: ({ client, experienceTypeId, locale, identifier, }: FetchExperienceEntryParams) => Promise<Entry | undefined>;
|
|
29
|
+
|
|
30
|
+
export { fetchExperienceEntry };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ExperienceEntry } from '../types.js';
|
|
2
|
+
import { Entry, Asset, ContentfulClientApi } from 'contentful';
|
|
3
|
+
|
|
4
|
+
type ClientAndLocaleParams = {
|
|
5
|
+
client: ContentfulClientApi<undefined>;
|
|
6
|
+
locale?: string;
|
|
7
|
+
} | {
|
|
8
|
+
client: ContentfulClientApi<'WITH_ALL_LOCALES'>;
|
|
9
|
+
/** When fetching all locales, this may not be defined */
|
|
10
|
+
locale?: undefined;
|
|
11
|
+
};
|
|
12
|
+
type FetchReferencedEntitiesArgs = {
|
|
13
|
+
experienceEntry: Entry | ExperienceEntry;
|
|
14
|
+
} & ClientAndLocaleParams;
|
|
15
|
+
/**
|
|
16
|
+
* Fetches all entries and assets from the `dataSource` of the given experience entry. This will
|
|
17
|
+
* also consider deep references that are not listed explicitly but linked through deep binding paths.
|
|
18
|
+
* @param options.client - Instantiated client from the Contentful SDK. If this is using the `withAllLocales` modifier, you may not provide a specific locale.
|
|
19
|
+
* @param options.experienceEntry - Localized experience entry. To localize a multi locale entry, use the `localizeEntity` function.
|
|
20
|
+
* @param options.locale - Retrieve a specific localized version of the referenced entities. Otherwise, it will fallback to the default locale.
|
|
21
|
+
* @returns object with a list of `entries` and a list of `assets`
|
|
22
|
+
*/
|
|
23
|
+
declare const fetchReferencedEntities: ({ client, experienceEntry, locale, }: FetchReferencedEntitiesArgs) => Promise<{
|
|
24
|
+
entries: Entry[];
|
|
25
|
+
assets: Asset[];
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
export { fetchReferencedEntities };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
export { isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isPatternComponent, isStructureWithRelativeHeight } from './utils/components.js';
|
|
2
|
-
export { findOutermostCoordinates, getElementCoordinates } from './utils/domValues.js';
|
|
3
|
-
export { doesMismatchMessageSchema, tryParseMessage, validateExperienceBuilderConfig } from './utils/validations.js';
|
|
4
|
-
export { addMinHeightForEmptyStructures, buildCfStyles, buildStyleTag, calculateNodeDefaultHeight, stringifyCssProperties, toCSSAttribute } from './utils/styleUtils/stylesUtils.js';
|
|
5
|
-
export { detachExperienceStyles, flattenDesignTokenRegistry, indexByBreakpoint, isCfStyleAttribute, maybePopulateDesignTokenValue, resolveBackgroundImageBinding, toMediaQuery } from './utils/styleUtils/ssrStyles.js';
|
|
6
|
-
export { transformBoundContentValue } from './utils/transformers/transformBoundContentValue.js';
|
|
7
|
-
export { checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getInsertionData, getTargetValueInPixels, parseCSSValue } from './utils/utils.js';
|
|
8
|
-
export { isExperienceEntry } from './utils/typeguards.js';
|
|
9
2
|
export { MEDIA_QUERY_REGEXP, getActiveBreakpointIndex, getFallbackBreakpointIndex, getValueForBreakpoint, isValidBreakpointValue, mediaQueryMatcher } from './utils/breakpoints.js';
|
|
3
|
+
export { DebugLogger, debug, disableDebug, enableDebug } from './utils/debugLogger.js';
|
|
4
|
+
export { findOutermostCoordinates, getElementCoordinates } from './utils/domValues.js';
|
|
10
5
|
export { isLinkToAsset } from './utils/isLinkToAsset.js';
|
|
11
6
|
export { isLink } from './utils/isLink.js';
|
|
7
|
+
export { localizeEntity } from './utils/localizeEntity.js';
|
|
12
8
|
export { Fieldset, UnresolvedFieldset, isDeepPath, lastPathNamedSegmentEq, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings } from './utils/pathSchema.js';
|
|
13
9
|
export { addLocale, buildTemplate, getTemplateValue, resolveHyperlinkPattern } from './utils/resolveHyperlinkPattern.js';
|
|
14
10
|
export { sanitizeNodeProps } from './utils/sanitizeNodeProps.js';
|
|
15
|
-
export {
|
|
11
|
+
export { addMinHeightForEmptyStructures, buildCfStyles, buildStyleTag, calculateNodeDefaultHeight, stringifyCssProperties, toCSSAttribute } from './utils/styleUtils/stylesUtils.js';
|
|
12
|
+
export { detachExperienceStyles, flattenDesignTokenRegistry, indexByBreakpoint, isCfStyleAttribute, maybePopulateDesignTokenValue, resolveBackgroundImageBinding, toMediaQuery } from './utils/styleUtils/ssrStyles.js';
|
|
13
|
+
export { transformBoundContentValue } from './utils/transformers/transformBoundContentValue.js';
|
|
14
|
+
export { isExperienceEntry } from './utils/typeguards.js';
|
|
15
|
+
export { checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getInsertionData, getTargetValueInPixels, parseCSSValue } from './utils/utils.js';
|
|
16
|
+
export { doesMismatchMessageSchema, tryParseMessage, validateExperienceBuilderConfig } from './utils/validations.js';
|
|
16
17
|
export { builtInStyles, columnsBuiltInStyles, containerBuiltInStyles, dividerBuiltInStyles, optionalBuiltInStyles, sectionBuiltInStyles, singleColumnBuiltInStyles } from './definitions/styles.js';
|
|
17
18
|
export { EditorModeEntityStore } from './entity/EditorModeEntityStore.js';
|
|
18
19
|
export { EntityStore } from './entity/EntityStore.js';
|
|
@@ -23,6 +24,8 @@ export { fetchBySlug } from './fetchers/fetchBySlug.js';
|
|
|
23
24
|
export { fetchById } from './fetchers/fetchById.js';
|
|
24
25
|
export { fetchAllAssets, fetchAllEntries } from './fetchers/fetchAllEntities.js';
|
|
25
26
|
export { createExperience } from './fetchers/createExperience.js';
|
|
27
|
+
export { fetchReferencedEntities } from './fetchers/fetchReferencedEntities.js';
|
|
28
|
+
export { fetchExperienceEntry } from './fetchers/fetchExperienceEntry.js';
|
|
26
29
|
export { defineDesignTokens, designTokensRegistry, getDesignTokenRegistration, resetDesignTokenRegistry } from './registries/designTokenRegistry.js';
|
|
27
30
|
export { breakpointsRegistry, defineBreakpoints, getBreakpointRegistration, resetBreakpointsRegistry, runBreakpointsValidation } from './registries/breakpointsRegistry.js';
|
|
28
31
|
export { DeepReference, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree } from './deep-binding/DeepReference.js';
|