@ninetailed/experience.js-utils-contentful 7.18.9 → 7.18.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-utils-contentful",
3
- "version": "7.18.9",
3
+ "version": "7.18.11",
4
4
  "description": "Contentful utilities for Experience.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,11 +28,14 @@
28
28
  },
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
- "contentful": "^9.1.32",
32
- "@contentful/rich-text-types": "16.2.0",
33
- "@ninetailed/experience.js-utils": "7.18.9",
34
- "@ninetailed/experience.js": "7.18.9",
35
- "@ninetailed/experience.js-shared": "7.18.9",
31
+ "contentful": "^11.10.2",
32
+ "@contentful/rich-text-types": "17.2.5",
33
+ "@ninetailed/experience.js-utils": "7.18.11",
34
+ "@ninetailed/experience.js": "7.18.11",
35
+ "@ninetailed/experience.js-shared": "7.18.11",
36
36
  "zod": "3.23.0"
37
+ },
38
+ "resolutions": {
39
+ "@contentful/rich-text-types": "17.2.5"
37
40
  }
38
41
  }
@@ -1,84 +1,53 @@
1
- import { Entry } from 'contentful';
2
- export interface INtAudienceFields {
3
- /** Name */
4
- nt_name: string;
5
- /** Description */
6
- nt_description?: string | undefined;
7
- /** Rules */
8
- nt_rules: Record<string, any>;
9
- /** Audience Id */
10
- nt_audience_id: string;
11
- }
12
- /** Ninetailed Audience */
13
- export interface INtAudience extends Entry<INtAudienceFields> {
14
- sys: {
15
- id: string;
16
- type: string;
17
- createdAt: string;
18
- updatedAt: string;
19
- locale: string;
20
- contentType: {
21
- sys: {
22
- id: 'nt_audience';
23
- linkType: 'ContentType';
24
- type: 'Link';
25
- };
26
- };
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]>;
27
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;
28
27
  }
28
+ export type INtAudienceSkeleton = EntrySkeletonType<INtAudienceFields, 'nt_audience'>;
29
+ export type INtAudience = CtflEntry<INtAudienceSkeleton>;
30
+ /**
31
+ * ---------- NT Experience ----------
32
+ */
29
33
  export interface INtExperienceFields {
30
- /** Name */
31
- nt_name: string;
32
- /** Description */
33
- nt_description?: string | undefined;
34
- /** Type */
35
- nt_type: 'nt_experiment' | 'nt_personalization';
36
- /** Config */
37
- nt_config: Record<string, any>;
38
- /** Audience */
39
- nt_audience?: INtAudience | undefined;
40
- /** Variants */
41
- nt_variants?: Entry<{
42
- [fieldId: string]: unknown;
43
- }>[] | undefined;
44
- nt_experience_id: string;
45
- }
46
- /** Ninetailed Experience */
47
- export interface INtExperience extends Entry<INtExperienceFields> {
48
- sys: {
49
- id: string;
50
- type: string;
51
- createdAt: string;
52
- updatedAt: string;
53
- locale: string;
54
- contentType: {
55
- sys: {
56
- id: 'nt_experience';
57
- linkType: 'ContentType';
58
- type: 'Link';
59
- };
60
- };
61
- };
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>>;
62
41
  }
42
+ export type INtExperienceSkeleton = EntrySkeletonType<INtExperienceFields, 'nt_experience'>;
43
+ export type INtExperience = CtflEntry<INtExperienceSkeleton>;
44
+ /**
45
+ * ---------- Hero ----------
46
+ */
63
47
  export interface IHeroFields {
64
- /** Name */
65
- name: string;
66
- /** Ninetailed */
67
- nt_experiences?: INtExperience[] | undefined;
68
- }
69
- export interface IHero extends Entry<IHeroFields> {
70
- sys: {
71
- id: string;
72
- type: string;
73
- createdAt: string;
74
- updatedAt: string;
75
- locale: string;
76
- contentType: {
77
- sys: {
78
- id: 'hero';
79
- linkType: 'ContentType';
80
- type: 'Link';
81
- };
82
- };
83
- };
48
+ name: EntryFieldTypes.Symbol;
49
+ nt_experiences: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<INtExperienceSkeleton>>;
84
50
  }
51
+ export type IHeroSkeleton = EntrySkeletonType<IHeroFields, 'hero'>;
52
+ export type IHero = CtflEntry<IHeroSkeleton>;
53
+ export {};