@ninetailed/experience.js-utils-contentful 7.20.4 → 7.20.6

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.
@@ -1,118 +1,118 @@
1
- import { Reference } from '@ninetailed/experience.js';
2
- import { BaselineWithExperiencesEntry } from '../types/BaselineWithExperiencesEntry';
3
- import { EntryLike } from '../types/Entry';
4
- import type { EntryFields } from '../types/EntryFields';
5
- import { ExperienceEntry, ExperienceEntryLike } from '../types/ExperienceEntry';
6
- import { ExperimentEntry } from '../types/ExperimentEntry';
7
- export type MapVariantFunction<In extends EntryFields, Out extends Reference> = (input: EntryLike<In>) => Out;
8
- export type MapVariantFunctionAsync<In extends EntryFields, Out extends Reference> = (input: EntryLike<In>) => Promise<Out>;
9
- export declare class ExperienceMapper {
10
- static isExperienceEntry<VariantFields extends EntryFields>(entry: ExperienceEntryLike<VariantFields>): entry is ExperienceEntry<VariantFields>;
11
- /**
12
- * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK.
13
- *
14
- * @param ctfEntry A Contentful Ninetailed Experience Entry
15
- */
16
- static mapExperience<VariantFields extends EntryFields>(ctfEntry: ExperienceEntryLike<VariantFields>): import("@ninetailed/experience.js").ExperienceConfiguration<{
17
- id: string;
18
- sys: {
19
- id: string;
20
- type?: string | undefined;
21
- createdAt?: string | undefined;
22
- updatedAt?: string | undefined;
23
- locale?: string | undefined;
24
- revision?: number | undefined;
25
- space?: {
26
- sys: {
27
- id: string;
28
- type?: string | undefined;
29
- linkType?: string | undefined;
30
- };
31
- } | undefined;
32
- environment?: {
33
- sys: {
34
- id: string;
35
- type?: string | undefined;
36
- linkType?: string | undefined;
37
- };
38
- } | undefined;
39
- contentType?: {
40
- sys: {
41
- id: string;
42
- type?: string | undefined;
43
- linkType?: string | undefined;
44
- };
45
- } | undefined;
46
- };
47
- metadata?: {
48
- tags: {
49
- sys: {
50
- id: string;
51
- linkType: string;
52
- type?: string | undefined;
53
- };
54
- }[];
55
- } | undefined;
56
- fields: VariantFields;
57
- }>;
58
- /**
59
- *
60
- * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK
61
- * using a custom mapping function for the Experience's variants.
62
- *
63
- * @param ctfEntry A Contentful Ninetailed Experience Entry
64
- * @param mapFn A custom function to map the Experience's variants
65
- */
66
- static mapCustomExperience<Variant extends Reference, VariantFields extends EntryFields>(ctfEntry: ExperienceEntryLike<VariantFields>, mapFn: MapVariantFunction<VariantFields, Variant>): import("@ninetailed/experience.js").ExperienceConfiguration<Variant>;
67
- /**
68
- * Similar to `mapCustomExperience` but supports asynchronous mapping functions.
69
- * @see mapCustomExperience
70
- */
71
- static mapCustomExperienceAsync<Variant extends Reference, VariantFields extends EntryFields>(ctfEntry: ExperienceEntryLike<VariantFields>, mapFn: MapVariantFunctionAsync<VariantFields, Variant>): Promise<import("@ninetailed/experience.js").ExperienceConfiguration<Awaited<Variant>>>;
72
- static isExperiment(entry: ExperienceEntryLike): entry is ExperimentEntry;
73
- static mapExperiment(entry: ExperienceEntryLike): import("@ninetailed/experience.js").ExperienceConfiguration<{
74
- id: string;
75
- }>;
76
- static mapBaselineWithExperiences<Fields extends EntryFields>(entry: BaselineWithExperiencesEntry<Fields>): import("@ninetailed/experience.js").ExperienceConfiguration<{
77
- id: string;
78
- sys: {
79
- id: string;
80
- type?: string | undefined;
81
- createdAt?: string | undefined;
82
- updatedAt?: string | undefined;
83
- locale?: string | undefined;
84
- revision?: number | undefined;
85
- space?: {
86
- sys: {
87
- id: string;
88
- type?: string | undefined;
89
- linkType?: string | undefined;
90
- };
91
- } | undefined;
92
- environment?: {
93
- sys: {
94
- id: string;
95
- type?: string | undefined;
96
- linkType?: string | undefined;
97
- };
98
- } | undefined;
99
- contentType?: {
100
- sys: {
101
- id: string;
102
- type?: string | undefined;
103
- linkType?: string | undefined;
104
- };
105
- } | undefined;
106
- };
107
- metadata?: {
108
- tags: {
109
- sys: {
110
- id: string;
111
- linkType: string;
112
- type?: string | undefined;
113
- };
114
- }[];
115
- } | undefined;
116
- fields: {};
117
- }>[];
118
- }
1
+ import type { Reference } from '@ninetailed/experience.js-shared';
2
+ import { BaselineWithExperiencesEntry } from '../types/BaselineWithExperiencesEntry';
3
+ import { EntryLike } from '../types/Entry';
4
+ import type { EntryFields } from '../types/EntryFields';
5
+ import { ExperienceEntry, ExperienceEntryLike } from '../types/ExperienceEntry';
6
+ import { ExperimentEntry } from '../types/ExperimentEntry';
7
+ export type MapVariantFunction<In extends EntryFields, Out extends Reference> = (input: EntryLike<In>) => Out;
8
+ export type MapVariantFunctionAsync<In extends EntryFields, Out extends Reference> = (input: EntryLike<In>) => Promise<Out>;
9
+ export declare class ExperienceMapper {
10
+ static isExperienceEntry<VariantFields extends EntryFields>(entry: ExperienceEntryLike<VariantFields>): entry is ExperienceEntry<VariantFields>;
11
+ /**
12
+ * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK.
13
+ *
14
+ * @param ctfEntry A Contentful Ninetailed Experience Entry
15
+ */
16
+ static mapExperience<VariantFields extends EntryFields>(ctfEntry: ExperienceEntryLike<VariantFields>): import("@ninetailed/experience.js-shared").ExperienceConfiguration<{
17
+ id: string;
18
+ sys: {
19
+ id: string;
20
+ type?: string | undefined;
21
+ createdAt?: string | undefined;
22
+ updatedAt?: string | undefined;
23
+ locale?: string | undefined;
24
+ revision?: number | undefined;
25
+ space?: {
26
+ sys: {
27
+ id: string;
28
+ type?: string | undefined;
29
+ linkType?: string | undefined;
30
+ };
31
+ } | undefined;
32
+ environment?: {
33
+ sys: {
34
+ id: string;
35
+ type?: string | undefined;
36
+ linkType?: string | undefined;
37
+ };
38
+ } | undefined;
39
+ contentType?: {
40
+ sys: {
41
+ id: string;
42
+ type?: string | undefined;
43
+ linkType?: string | undefined;
44
+ };
45
+ } | undefined;
46
+ };
47
+ metadata?: {
48
+ tags: {
49
+ sys: {
50
+ linkType: string;
51
+ id: string;
52
+ type?: string | undefined;
53
+ };
54
+ }[];
55
+ } | undefined;
56
+ fields: VariantFields;
57
+ }>;
58
+ /**
59
+ *
60
+ * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK
61
+ * using a custom mapping function for the Experience's variants.
62
+ *
63
+ * @param ctfEntry A Contentful Ninetailed Experience Entry
64
+ * @param mapFn A custom function to map the Experience's variants
65
+ */
66
+ static mapCustomExperience<Variant extends Reference, VariantFields extends EntryFields>(ctfEntry: ExperienceEntryLike<VariantFields>, mapFn: MapVariantFunction<VariantFields, Variant>): import("@ninetailed/experience.js-shared").ExperienceConfiguration<Variant>;
67
+ /**
68
+ * Similar to `mapCustomExperience` but supports asynchronous mapping functions.
69
+ * @see mapCustomExperience
70
+ */
71
+ static mapCustomExperienceAsync<Variant extends Reference, VariantFields extends EntryFields>(ctfEntry: ExperienceEntryLike<VariantFields>, mapFn: MapVariantFunctionAsync<VariantFields, Variant>): Promise<import("@ninetailed/experience.js-shared").ExperienceConfiguration<Awaited<Variant>>>;
72
+ static isExperiment(entry: ExperienceEntryLike): entry is ExperimentEntry;
73
+ static mapExperiment(entry: ExperienceEntryLike): import("@ninetailed/experience.js-shared").ExperienceConfiguration<{
74
+ id: string;
75
+ }>;
76
+ static mapBaselineWithExperiences<Fields extends EntryFields>(entry: BaselineWithExperiencesEntry<Fields>): import("@ninetailed/experience.js-shared").ExperienceConfiguration<{
77
+ id: string;
78
+ sys: {
79
+ id: string;
80
+ type?: string | undefined;
81
+ createdAt?: string | undefined;
82
+ updatedAt?: string | undefined;
83
+ locale?: string | undefined;
84
+ revision?: number | undefined;
85
+ space?: {
86
+ sys: {
87
+ id: string;
88
+ type?: string | undefined;
89
+ linkType?: string | undefined;
90
+ };
91
+ } | undefined;
92
+ environment?: {
93
+ sys: {
94
+ id: string;
95
+ type?: string | undefined;
96
+ linkType?: string | undefined;
97
+ };
98
+ } | undefined;
99
+ contentType?: {
100
+ sys: {
101
+ id: string;
102
+ type?: string | undefined;
103
+ linkType?: string | undefined;
104
+ };
105
+ } | undefined;
106
+ };
107
+ metadata?: {
108
+ tags: {
109
+ sys: {
110
+ linkType: string;
111
+ id: string;
112
+ type?: string | undefined;
113
+ };
114
+ }[];
115
+ } | undefined;
116
+ fields: {};
117
+ }>[];
118
+ }
@@ -1,53 +1,53 @@
1
- import type { Entry, EntryFieldTypes, EntrySkeletonType } from 'contentful';
2
- /** Your custom methods (optional so real CDA entries still type-check) */
3
- type EntryMethods = {
4
- toPlainObject?: () => object;
5
- update?: () => Promise<unknown>;
6
- };
7
- /**
8
- * Recursively adds EntryMethods to every Contentful Entry found inside `T`.
9
- * - Recurse into `fields` (so linked entries get the methods too)
10
- * - Recurse into arrays (for multi-reference fields)
11
- * - Leave everything else alone (keeps JSON/object fields and your variants generic)
12
- */
13
- type WithEntryMethods<T> = T extends Entry<any, any, any> ? Omit<T, 'fields'> & {
14
- fields: {
15
- [K in keyof T['fields']]: WithEntryMethods<T['fields'][K]>;
16
- };
17
- } & EntryMethods : T extends Array<infer U> ? Array<WithEntryMethods<U>> : T;
18
- /** Convenience alias for your preferred modifiers/locales */
19
- type CtflEntry<S extends EntrySkeletonType> = WithEntryMethods<Entry<S, 'WITHOUT_UNRESOLVABLE_LINKS', string>>;
20
- /**
21
- * ---------- NT Audience ----------
22
- */
23
- export interface INtAudienceFields {
24
- nt_name: EntryFieldTypes.Symbol;
25
- nt_rules: EntryFieldTypes.Object;
26
- nt_audience_id: EntryFieldTypes.Symbol;
27
- }
28
- export type INtAudienceSkeleton = EntrySkeletonType<INtAudienceFields, 'nt_audience'>;
29
- export type INtAudience = CtflEntry<INtAudienceSkeleton>;
30
- /**
31
- * ---------- NT Experience ----------
32
- */
33
- export interface INtExperienceFields {
34
- nt_name: EntryFieldTypes.Symbol;
35
- nt_description: EntryFieldTypes.Text;
36
- nt_type: EntryFieldTypes.Symbol;
37
- nt_experience_id: EntryFieldTypes.Symbol;
38
- nt_config: EntryFieldTypes.Object;
39
- nt_audience: EntryFieldTypes.EntryLink<INtAudienceSkeleton>;
40
- nt_variants: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<EntrySkeletonType>>;
41
- }
42
- export type INtExperienceSkeleton = EntrySkeletonType<INtExperienceFields, 'nt_experience'>;
43
- export type INtExperience = CtflEntry<INtExperienceSkeleton>;
44
- /**
45
- * ---------- Hero ----------
46
- */
47
- export interface IHeroFields {
48
- name: EntryFieldTypes.Symbol;
49
- nt_experiences: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<INtExperienceSkeleton>>;
50
- }
51
- export type IHeroSkeleton = EntrySkeletonType<IHeroFields, 'hero'>;
52
- export type IHero = CtflEntry<IHeroSkeleton>;
53
- export {};
1
+ import type { Entry, EntryFieldTypes, EntrySkeletonType } from 'contentful';
2
+ /** Your custom methods (optional so real CDA entries still type-check) */
3
+ type EntryMethods = {
4
+ toPlainObject?: () => object;
5
+ update?: () => Promise<unknown>;
6
+ };
7
+ /**
8
+ * Recursively adds EntryMethods to every Contentful Entry found inside `T`.
9
+ * - Recurse into `fields` (so linked entries get the methods too)
10
+ * - Recurse into arrays (for multi-reference fields)
11
+ * - Leave everything else alone (keeps JSON/object fields and your variants generic)
12
+ */
13
+ type WithEntryMethods<T> = T extends Entry<any, any, any> ? Omit<T, 'fields'> & {
14
+ fields: {
15
+ [K in keyof T['fields']]: WithEntryMethods<T['fields'][K]>;
16
+ };
17
+ } & EntryMethods : T extends Array<infer U> ? Array<WithEntryMethods<U>> : T;
18
+ /** Convenience alias for your preferred modifiers/locales */
19
+ type CtflEntry<S extends EntrySkeletonType> = WithEntryMethods<Entry<S, 'WITHOUT_UNRESOLVABLE_LINKS', string>>;
20
+ /**
21
+ * ---------- NT Audience ----------
22
+ */
23
+ export interface INtAudienceFields {
24
+ nt_name: EntryFieldTypes.Symbol;
25
+ nt_rules: EntryFieldTypes.Object;
26
+ nt_audience_id: EntryFieldTypes.Symbol;
27
+ }
28
+ export type INtAudienceSkeleton = EntrySkeletonType<INtAudienceFields, 'nt_audience'>;
29
+ export type INtAudience = CtflEntry<INtAudienceSkeleton>;
30
+ /**
31
+ * ---------- NT Experience ----------
32
+ */
33
+ export interface INtExperienceFields {
34
+ nt_name: EntryFieldTypes.Symbol;
35
+ nt_description: EntryFieldTypes.Text;
36
+ nt_type: EntryFieldTypes.Symbol;
37
+ nt_experience_id: EntryFieldTypes.Symbol;
38
+ nt_config: EntryFieldTypes.Object;
39
+ nt_audience: EntryFieldTypes.EntryLink<INtAudienceSkeleton>;
40
+ nt_variants: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<EntrySkeletonType>>;
41
+ }
42
+ export type INtExperienceSkeleton = EntrySkeletonType<INtExperienceFields, 'nt_experience'>;
43
+ export type INtExperience = CtflEntry<INtExperienceSkeleton>;
44
+ /**
45
+ * ---------- Hero ----------
46
+ */
47
+ export interface IHeroFields {
48
+ name: EntryFieldTypes.Symbol;
49
+ nt_experiences: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<INtExperienceSkeleton>>;
50
+ }
51
+ export type IHeroSkeleton = EntrySkeletonType<IHeroFields, 'hero'>;
52
+ export type IHero = CtflEntry<IHeroSkeleton>;
53
+ export {};
@@ -1,2 +1,2 @@
1
- import { IHero } from './contentful-generated-types';
2
- export declare const ctfHero: IHero;
1
+ import { IHero } from './contentful-generated-types';
2
+ export declare const ctfHero: IHero;