@ninetailed/experience.js-utils-contentful 7.20.5 → 7.21.0

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/index.cjs.js CHANGED
@@ -4,14 +4,14 @@ var zod = require('zod');
4
4
  var experience_jsShared = require('@ninetailed/experience.js-shared');
5
5
  var experience_jsUtils = require('@ninetailed/experience.js-utils');
6
6
 
7
- /**
8
- * This does not work anymore from zod > 3.21.0:
9
- *
10
- * We have to cast the result of passthrough() to z.ZodObject<{}> to make it work,
11
- * as the inferred type changed to {} & { [k: string]: unknown; }
12
- * It was {} before, so we do the type cast to get it back to {}.
7
+ /**
8
+ * This does not work anymore from zod > 3.21.0:
9
+ *
10
+ * We have to cast the result of passthrough() to z.ZodObject<{}> to make it work,
11
+ * as the inferred type changed to {} & { [k: string]: unknown; }
12
+ * It was {} before, so we do the type cast to get it back to {}.
13
13
  */
14
- // eslint-disable-next-line @typescript-eslint/ban-types
14
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
15
15
  const EntryFields = zod.z.object({}).passthrough();
16
16
 
17
17
  const EntryLink = zod.z.object({
@@ -66,16 +66,16 @@ const Entry = Object.assign(Object.assign({}, EntrySchema), {
66
66
  });
67
67
 
68
68
  const AudienceEntryFields = EntryFields.extend({
69
- /**
70
- * The name of the audience (Short Text)
69
+ /**
70
+ * The name of the audience (Short Text)
71
71
  */
72
72
  nt_name: zod.z.string(),
73
- /**
74
- * The description of the audience (Short Text)
73
+ /**
74
+ * The description of the audience (Short Text)
75
75
  */
76
76
  nt_description: zod.z.string().optional(),
77
- /**
78
- * The internal id of the audience (Short Text)
77
+ /**
78
+ * The internal id of the audience (Short Text)
79
79
  */
80
80
  nt_audience_id: zod.z.string()
81
81
  });
@@ -110,7 +110,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
110
110
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
111
111
  PERFORMANCE OF THIS SOFTWARE.
112
112
  ***************************************************************************** */
113
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
113
+ /* global Reflect, Promise */
114
114
 
115
115
 
116
116
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -119,30 +119,25 @@ function __awaiter(thisArg, _arguments, P, generator) {
119
119
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
120
120
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
121
121
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
122
- step((generator = generator.apply(thisArg, _arguments || [])).next());
122
+ step((generator = generator.apply(thisArg, [])).next());
123
123
  });
124
- }
125
-
126
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
127
- var e = new Error(message);
128
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
129
- };
124
+ }
130
125
 
131
126
  const ExperienceEntryFields = zod.z.object({
132
- /**
133
- * The name of the experience (Short Text)
127
+ /**
128
+ * The name of the experience (Short Text)
134
129
  */
135
130
  nt_name: zod.z.string(),
136
- /**
137
- * The description of the experience (Short Text)
131
+ /**
132
+ * The description of the experience (Short Text)
138
133
  */
139
134
  nt_description: zod.z.string().optional().nullable(),
140
- /**
141
- * The type if the experience (nt_experiment | nt_personalization)
135
+ /**
136
+ * The type if the experience (nt_experiment | nt_personalization)
142
137
  */
143
138
  nt_type: zod.z.union([zod.z.string(), zod.z.string()]),
144
- /**
145
- * The config of the experience (JSON)
139
+ /**
140
+ * The config of the experience (JSON)
146
141
  */
147
142
  nt_config: experience_jsUtils.Config.optional().nullable().default(null).transform(val => {
148
143
  return val !== null && val !== void 0 ? val : {
@@ -152,12 +147,12 @@ const ExperienceEntryFields = zod.z.object({
152
147
  sticky: false
153
148
  };
154
149
  }),
155
- /**
156
- * The audience of the experience (Audience)
150
+ /**
151
+ * The audience of the experience (Audience)
157
152
  */
158
153
  nt_audience: AudienceEntry.optional().nullable(),
159
- /**
160
- * All used variants of the experience (Contentful references to other Content Types)
154
+ /**
155
+ * All used variants of the experience (Contentful references to other Content Types)
161
156
  */
162
157
  nt_variants: zod.z.array(EntrySchema).optional(),
163
158
  nt_experience_id: zod.z.string()
@@ -263,10 +258,10 @@ class ExperienceMapper {
263
258
  static isExperienceEntry(entry) {
264
259
  return ExperienceEntry.safeParse(entry).success;
265
260
  }
266
- /**
267
- * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK.
268
- *
269
- * @param ctfEntry A Contentful Ninetailed Experience Entry
261
+ /**
262
+ * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK.
263
+ *
264
+ * @param ctfEntry A Contentful Ninetailed Experience Entry
270
265
  */
271
266
  static mapExperience(ctfEntry) {
272
267
  const {
@@ -278,13 +273,13 @@ class ExperienceMapper {
278
273
  const experience = createExperience(fields, variants);
279
274
  return experience_jsUtils.ExperienceMapper.mapExperience(experience);
280
275
  }
281
- /**
282
- *
283
- * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK
284
- * using a custom mapping function for the Experience's variants.
285
- *
286
- * @param ctfEntry A Contentful Ninetailed Experience Entry
287
- * @param mapFn A custom function to map the Experience's variants
276
+ /**
277
+ *
278
+ * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK
279
+ * using a custom mapping function for the Experience's variants.
280
+ *
281
+ * @param ctfEntry A Contentful Ninetailed Experience Entry
282
+ * @param mapFn A custom function to map the Experience's variants
288
283
  */
289
284
  static mapCustomExperience(ctfEntry, mapFn) {
290
285
  const {
@@ -294,9 +289,9 @@ class ExperienceMapper {
294
289
  const experience = createExperience(fields, variants);
295
290
  return experience_jsUtils.ExperienceMapper.mapExperience(experience);
296
291
  }
297
- /**
298
- * Similar to `mapCustomExperience` but supports asynchronous mapping functions.
299
- * @see mapCustomExperience
292
+ /**
293
+ * Similar to `mapCustomExperience` but supports asynchronous mapping functions.
294
+ * @see mapCustomExperience
300
295
  */
301
296
  static mapCustomExperienceAsync(ctfEntry, mapFn) {
302
297
  return __awaiter(this, void 0, void 0, function* () {
package/index.esm.js CHANGED
@@ -2,14 +2,14 @@ import { z } from 'zod';
2
2
  import { logger } from '@ninetailed/experience.js-shared';
3
3
  import { Config, ExperienceMapper as ExperienceMapper$1 } from '@ninetailed/experience.js-utils';
4
4
 
5
- /**
6
- * This does not work anymore from zod > 3.21.0:
7
- *
8
- * We have to cast the result of passthrough() to z.ZodObject<{}> to make it work,
9
- * as the inferred type changed to {} & { [k: string]: unknown; }
10
- * It was {} before, so we do the type cast to get it back to {}.
5
+ /**
6
+ * This does not work anymore from zod > 3.21.0:
7
+ *
8
+ * We have to cast the result of passthrough() to z.ZodObject<{}> to make it work,
9
+ * as the inferred type changed to {} & { [k: string]: unknown; }
10
+ * It was {} before, so we do the type cast to get it back to {}.
11
11
  */
12
- // eslint-disable-next-line @typescript-eslint/ban-types
12
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
13
13
  const EntryFields = z.object({}).passthrough();
14
14
 
15
15
  const EntryLink = z.object({
@@ -64,16 +64,16 @@ const Entry = Object.assign(Object.assign({}, EntrySchema), {
64
64
  });
65
65
 
66
66
  const AudienceEntryFields = EntryFields.extend({
67
- /**
68
- * The name of the audience (Short Text)
67
+ /**
68
+ * The name of the audience (Short Text)
69
69
  */
70
70
  nt_name: z.string(),
71
- /**
72
- * The description of the audience (Short Text)
71
+ /**
72
+ * The description of the audience (Short Text)
73
73
  */
74
74
  nt_description: z.string().optional(),
75
- /**
76
- * The internal id of the audience (Short Text)
75
+ /**
76
+ * The internal id of the audience (Short Text)
77
77
  */
78
78
  nt_audience_id: z.string()
79
79
  });
@@ -108,7 +108,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
108
108
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
109
109
  PERFORMANCE OF THIS SOFTWARE.
110
110
  ***************************************************************************** */
111
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
111
+ /* global Reflect, Promise */
112
112
 
113
113
 
114
114
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -117,30 +117,25 @@ function __awaiter(thisArg, _arguments, P, generator) {
117
117
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
118
118
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
119
119
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
120
- step((generator = generator.apply(thisArg, _arguments || [])).next());
120
+ step((generator = generator.apply(thisArg, [])).next());
121
121
  });
122
- }
123
-
124
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
125
- var e = new Error(message);
126
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
127
- };
122
+ }
128
123
 
129
124
  const ExperienceEntryFields = z.object({
130
- /**
131
- * The name of the experience (Short Text)
125
+ /**
126
+ * The name of the experience (Short Text)
132
127
  */
133
128
  nt_name: z.string(),
134
- /**
135
- * The description of the experience (Short Text)
129
+ /**
130
+ * The description of the experience (Short Text)
136
131
  */
137
132
  nt_description: z.string().optional().nullable(),
138
- /**
139
- * The type if the experience (nt_experiment | nt_personalization)
133
+ /**
134
+ * The type if the experience (nt_experiment | nt_personalization)
140
135
  */
141
136
  nt_type: z.union([z.string(), z.string()]),
142
- /**
143
- * The config of the experience (JSON)
137
+ /**
138
+ * The config of the experience (JSON)
144
139
  */
145
140
  nt_config: Config.optional().nullable().default(null).transform(val => {
146
141
  return val !== null && val !== void 0 ? val : {
@@ -150,12 +145,12 @@ const ExperienceEntryFields = z.object({
150
145
  sticky: false
151
146
  };
152
147
  }),
153
- /**
154
- * The audience of the experience (Audience)
148
+ /**
149
+ * The audience of the experience (Audience)
155
150
  */
156
151
  nt_audience: AudienceEntry.optional().nullable(),
157
- /**
158
- * All used variants of the experience (Contentful references to other Content Types)
152
+ /**
153
+ * All used variants of the experience (Contentful references to other Content Types)
159
154
  */
160
155
  nt_variants: z.array(EntrySchema).optional(),
161
156
  nt_experience_id: z.string()
@@ -261,10 +256,10 @@ class ExperienceMapper {
261
256
  static isExperienceEntry(entry) {
262
257
  return ExperienceEntry.safeParse(entry).success;
263
258
  }
264
- /**
265
- * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK.
266
- *
267
- * @param ctfEntry A Contentful Ninetailed Experience Entry
259
+ /**
260
+ * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK.
261
+ *
262
+ * @param ctfEntry A Contentful Ninetailed Experience Entry
268
263
  */
269
264
  static mapExperience(ctfEntry) {
270
265
  const {
@@ -276,13 +271,13 @@ class ExperienceMapper {
276
271
  const experience = createExperience(fields, variants);
277
272
  return ExperienceMapper$1.mapExperience(experience);
278
273
  }
279
- /**
280
- *
281
- * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK
282
- * using a custom mapping function for the Experience's variants.
283
- *
284
- * @param ctfEntry A Contentful Ninetailed Experience Entry
285
- * @param mapFn A custom function to map the Experience's variants
274
+ /**
275
+ *
276
+ * Maps a Contentful Ninetailed Experience Entry to a format compatible with the Experience.js SDK
277
+ * using a custom mapping function for the Experience's variants.
278
+ *
279
+ * @param ctfEntry A Contentful Ninetailed Experience Entry
280
+ * @param mapFn A custom function to map the Experience's variants
286
281
  */
287
282
  static mapCustomExperience(ctfEntry, mapFn) {
288
283
  const {
@@ -292,9 +287,9 @@ class ExperienceMapper {
292
287
  const experience = createExperience(fields, variants);
293
288
  return ExperienceMapper$1.mapExperience(experience);
294
289
  }
295
- /**
296
- * Similar to `mapCustomExperience` but supports asynchronous mapping functions.
297
- * @see mapCustomExperience
290
+ /**
291
+ * Similar to `mapCustomExperience` but supports asynchronous mapping functions.
292
+ * @see mapCustomExperience
298
293
  */
299
294
  static mapCustomExperienceAsync(ctfEntry, mapFn) {
300
295
  return __awaiter(this, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-utils-contentful",
3
- "version": "7.20.5",
3
+ "version": "7.21.0",
4
4
  "description": "Contentful utilities for Experience.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,9 +30,8 @@
30
30
  "dependencies": {
31
31
  "contentful": "^11.10.2",
32
32
  "@contentful/rich-text-types": "17.2.5",
33
- "@ninetailed/experience.js-utils": "7.20.5",
34
- "@ninetailed/experience.js": "7.20.5",
35
- "@ninetailed/experience.js-shared": "7.20.5",
33
+ "@ninetailed/experience.js-utils": "7.21.0",
34
+ "@ninetailed/experience.js-shared": "7.21.0",
36
35
  "zod": "3.23.0"
37
36
  },
38
37
  "resolutions": {
package/src/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { AudienceMapper } from './lib/AudienceMapper';
2
- export { ExperienceMapper } from './lib/ExperienceMapper';
3
- export { isEntry } from './lib/isEntry';
4
- export type { AudienceEntry, AudienceEntryLike, AudienceEntryFields, } from './types/AudienceEntry';
5
- export type { BaselineWithExperiencesEntry, BaselineWithExperiencesEntryLike, } from './types/BaselineWithExperiencesEntry';
6
- export type { Entry, EntryLike } from './types/Entry';
7
- export type { EntryFields } from './types/EntryFields';
8
- export type { ExperienceEntry, ExperienceEntryLike, ExperienceFields, } from './types/ExperienceEntry';
9
- export type { ExperimentEntry, ExperimentEntryLike, } from './types/ExperimentEntry';
1
+ export { AudienceMapper } from './lib/AudienceMapper';
2
+ export { ExperienceMapper } from './lib/ExperienceMapper';
3
+ export { isEntry } from './lib/isEntry';
4
+ export type { AudienceEntry, AudienceEntryLike, AudienceEntryFields, } from './types/AudienceEntry';
5
+ export type { BaselineWithExperiencesEntry, BaselineWithExperiencesEntryLike, } from './types/BaselineWithExperiencesEntry';
6
+ export type { Entry, EntryLike } from './types/Entry';
7
+ export type { EntryFields } from './types/EntryFields';
8
+ export type { ExperienceEntry, ExperienceEntryLike, ExperienceFields, } from './types/ExperienceEntry';
9
+ export type { ExperimentEntry, ExperimentEntryLike, } from './types/ExperimentEntry';
@@ -1,51 +1,51 @@
1
- import { Audience } from '@ninetailed/experience.js-utils';
2
- import { AudienceEntry } from '../types/AudienceEntry';
3
- import type { AudienceEntryLike } from '../types/AudienceEntry';
4
- export declare class AudienceMapper {
5
- static isAudienceEntry: (entry: AudienceEntryLike) => entry is {
6
- sys: {
7
- id: string;
8
- type?: string | undefined;
9
- createdAt?: string | undefined;
10
- updatedAt?: string | undefined;
11
- locale?: string | undefined;
12
- revision?: number | undefined;
13
- space?: {
14
- sys: {
15
- id: string;
16
- type?: string | undefined;
17
- linkType?: string | undefined;
18
- };
19
- } | undefined;
20
- environment?: {
21
- sys: {
22
- id: string;
23
- type?: string | undefined;
24
- linkType?: string | undefined;
25
- };
26
- } | undefined;
27
- contentType?: {
28
- sys: {
29
- id: string;
30
- type?: string | undefined;
31
- linkType?: string | undefined;
32
- };
33
- } | undefined;
34
- };
35
- fields: {
36
- nt_name: string;
37
- nt_audience_id: string;
38
- nt_description?: string | undefined;
39
- };
40
- metadata?: {
41
- tags: {
42
- sys: {
43
- id: string;
44
- linkType: string;
45
- type?: string | undefined;
46
- };
47
- }[];
48
- } | undefined;
49
- };
50
- static mapAudience(audience: AudienceEntry): Audience;
51
- }
1
+ import { Audience } from '@ninetailed/experience.js-utils';
2
+ import { AudienceEntry } from '../types/AudienceEntry';
3
+ import type { AudienceEntryLike } from '../types/AudienceEntry';
4
+ export declare class AudienceMapper {
5
+ static isAudienceEntry: (entry: AudienceEntryLike) => entry is {
6
+ fields: {
7
+ nt_name: string;
8
+ nt_audience_id: string;
9
+ nt_description?: string | undefined;
10
+ };
11
+ sys: {
12
+ id: string;
13
+ type?: string | undefined;
14
+ createdAt?: string | undefined;
15
+ updatedAt?: string | undefined;
16
+ locale?: string | undefined;
17
+ revision?: number | undefined;
18
+ space?: {
19
+ sys: {
20
+ id: string;
21
+ type?: string | undefined;
22
+ linkType?: string | undefined;
23
+ };
24
+ } | undefined;
25
+ environment?: {
26
+ sys: {
27
+ id: string;
28
+ type?: string | undefined;
29
+ linkType?: string | undefined;
30
+ };
31
+ } | undefined;
32
+ contentType?: {
33
+ sys: {
34
+ id: string;
35
+ type?: string | undefined;
36
+ linkType?: string | undefined;
37
+ };
38
+ } | undefined;
39
+ };
40
+ metadata?: {
41
+ tags: {
42
+ sys: {
43
+ linkType: string;
44
+ id: string;
45
+ type?: string | undefined;
46
+ };
47
+ }[];
48
+ } | undefined;
49
+ };
50
+ static mapAudience(audience: AudienceEntry): Audience;
51
+ }