@ninetailed/experience.js-utils-contentful 7.5.3 → 7.6.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/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";
@@ -118,7 +118,8 @@ const ExperienceEntryFields = zod.z.object({
118
118
  return val !== null && val !== void 0 ? val : {
119
119
  traffic: 0,
120
120
  distribution: [0.5, 0.5],
121
- components: []
121
+ components: [],
122
+ sticky: false
122
123
  };
123
124
  }),
124
125
  /**
@@ -2,12 +2,12 @@ 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
12
  // eslint-disable-next-line @typescript-eslint/ban-types
13
13
  const EntryFields = z.object({}).passthrough();
@@ -43,7 +43,7 @@ const EntrySchema = z.object({
43
43
  });
44
44
  const parse$2 = input => {
45
45
  const output = EntrySchema.parse(input);
46
- return Object.assign(Object.assign({}, output), {
46
+ return Object.assign({}, output, {
47
47
  fields: input.fields
48
48
  });
49
49
  };
@@ -52,28 +52,28 @@ const safeParse$2 = input => {
52
52
  if (!output.success) {
53
53
  return output;
54
54
  }
55
- return Object.assign(Object.assign({}, output), {
56
- data: Object.assign(Object.assign({}, output.data), {
55
+ return Object.assign({}, output, {
56
+ data: Object.assign({}, output.data, {
57
57
  fields: input.fields
58
58
  })
59
59
  });
60
60
  };
61
- const Entry = Object.assign(Object.assign({}, EntrySchema), {
61
+ const Entry = Object.assign({}, EntrySchema, {
62
62
  parse: parse$2,
63
63
  safeParse: safeParse$2
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
  });
@@ -95,34 +95,35 @@ AudienceMapper.isAudienceEntry = entry => {
95
95
  };
96
96
 
97
97
  const ExperienceEntryFields = z.object({
98
- /**
99
- * The name of the experience (Short Text)
98
+ /**
99
+ * The name of the experience (Short Text)
100
100
  */
101
101
  nt_name: z.string(),
102
- /**
103
- * The description of the experience (Short Text)
102
+ /**
103
+ * The description of the experience (Short Text)
104
104
  */
105
105
  nt_description: z.string().optional().nullable(),
106
- /**
107
- * The type if the experience (nt_experiment | nt_personalization)
106
+ /**
107
+ * The type if the experience (nt_experiment | nt_personalization)
108
108
  */
109
109
  nt_type: z.union([z.string(), z.string()]),
110
- /**
111
- * The config of the experience (JSON)
110
+ /**
111
+ * The config of the experience (JSON)
112
112
  */
113
113
  nt_config: Config.optional().nullable().default(null).transform(val => {
114
- return val !== null && val !== void 0 ? val : {
114
+ return val != null ? val : {
115
115
  traffic: 0,
116
116
  distribution: [0.5, 0.5],
117
- components: []
117
+ components: [],
118
+ sticky: false
118
119
  };
119
120
  }),
120
- /**
121
- * The audience of the experience (Audience)
121
+ /**
122
+ * The audience of the experience (Audience)
122
123
  */
123
124
  nt_audience: AudienceEntry.optional().nullable(),
124
- /**
125
- * All used variants of the experience (Contentful references to other Content Types)
125
+ /**
126
+ * All used variants of the experience (Contentful references to other Content Types)
126
127
  */
127
128
  nt_variants: z.array(EntrySchema).optional()
128
129
  });
@@ -131,8 +132,8 @@ const ExperienceEntrySchema = EntrySchema.extend({
131
132
  });
132
133
  const parse$1 = input => {
133
134
  const output = ExperienceEntrySchema.parse(input);
134
- return Object.assign(Object.assign({}, output), {
135
- fields: Object.assign(Object.assign({}, output.fields), {
135
+ return Object.assign({}, output, {
136
+ fields: Object.assign({}, output.fields, {
136
137
  nt_variants: input.fields.nt_variants || []
137
138
  })
138
139
  });
@@ -142,15 +143,15 @@ const safeParse$1 = input => {
142
143
  if (!output.success) {
143
144
  return output;
144
145
  }
145
- return Object.assign(Object.assign({}, output), {
146
- data: Object.assign(Object.assign({}, output.data), {
147
- fields: Object.assign(Object.assign({}, output.data.fields), {
146
+ return Object.assign({}, output, {
147
+ data: Object.assign({}, output.data, {
148
+ fields: Object.assign({}, output.data.fields, {
148
149
  nt_variants: input.fields.nt_variants || []
149
150
  })
150
151
  })
151
152
  });
152
153
  };
153
- const ExperienceEntry = Object.assign(Object.assign({}, ExperienceEntrySchema), {
154
+ const ExperienceEntry = Object.assign({}, ExperienceEntrySchema, {
154
155
  parse: parse$1,
155
156
  safeParse: safeParse$1
156
157
  });
@@ -162,8 +163,8 @@ const ExperimentEntrySchema = ExperienceEntrySchema.extend({
162
163
  });
163
164
  const parse = input => {
164
165
  const output = ExperimentEntrySchema.parse(input);
165
- return Object.assign(Object.assign({}, output), {
166
- fields: Object.assign(Object.assign({}, output.fields), {
166
+ return Object.assign({}, output, {
167
+ fields: Object.assign({}, output.fields, {
167
168
  nt_variants: input.fields.nt_variants || []
168
169
  })
169
170
  });
@@ -173,15 +174,15 @@ const safeParse = input => {
173
174
  if (!output.success) {
174
175
  return output;
175
176
  }
176
- return Object.assign(Object.assign({}, output), {
177
- data: Object.assign(Object.assign({}, output.data), {
178
- fields: Object.assign(Object.assign({}, output.data.fields), {
177
+ return Object.assign({}, output, {
178
+ data: Object.assign({}, output.data, {
179
+ fields: Object.assign({}, output.data.fields, {
179
180
  nt_variants: input.fields.nt_variants || []
180
181
  })
181
182
  })
182
183
  });
183
184
  };
184
- const ExperimentEntry = Object.assign(Object.assign({}, ExperimentEntrySchema), {
185
+ const ExperimentEntry = Object.assign({}, ExperimentEntrySchema, {
185
186
  parse,
186
187
  safeParse
187
188
  });
@@ -201,14 +202,14 @@ function createExperience(id, fields, variants) {
201
202
  nt_audience,
202
203
  nt_config
203
204
  } = fields;
204
- return Object.assign(Object.assign({
205
+ return Object.assign({
205
206
  id,
206
207
  name: nt_name,
207
208
  description: nt_description || '',
208
209
  type: nt_type
209
210
  }, nt_audience ? {
210
211
  audience: mapAudience(nt_audience)
211
- } : {}), {
212
+ } : {}, {
212
213
  config: nt_config,
213
214
  variants
214
215
  });
@@ -230,7 +231,7 @@ class ExperienceMapper {
230
231
  sys,
231
232
  fields
232
233
  } = validateExperienceEntry(ctfEntry);
233
- const variants = fields.nt_variants.map(variant => Object.assign(Object.assign({}, variant), {
234
+ const variants = fields.nt_variants.map(variant => Object.assign({}, variant, {
234
235
  id: variant.sys.id
235
236
  }));
236
237
  const experience = createExperience(sys.id, fields, variants);
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-utils-contentful",
3
- "version": "7.5.3",
3
+ "version": "7.6.0-beta.2",
4
4
  "description": "Contentful utilities for Experience.js",
5
- "devDependencies": {
5
+ "dependencies": {
6
6
  "contentful": "^9.1.32",
7
- "@contentful/rich-text-types": "16.2.0"
7
+ "@contentful/rich-text-types": "16.2.0",
8
+ "@ninetailed/experience.js-utils": "*",
9
+ "@ninetailed/experience.js": "*",
10
+ "@ninetailed/experience.js-shared": "*",
11
+ "zod": "3.21.4"
8
12
  },
9
13
  "license": "MIT",
10
14
  "repository": {
@@ -12,15 +16,12 @@
12
16
  "url": "https://github.com/ninetailed-inc/experience.js.git",
13
17
  "directory": "packages/utils/contentful"
14
18
  },
15
- "module": "./index.js",
16
- "main": "./index.cjs",
17
- "type": "module",
18
- "types": "./src/index.d.ts",
19
- "dependencies": {
20
- "@ninetailed/experience.js": "7.5.3",
21
- "@ninetailed/experience.js-shared": "7.5.3",
22
- "@ninetailed/experience.js-utils": "7.5.3",
23
- "zod": "3.21.4"
24
- },
25
- "peerDependencies": {}
19
+ "keywords": [
20
+ "contentful",
21
+ "ninetailed",
22
+ "personalization",
23
+ "a/b testing"
24
+ ],
25
+ "module": "./index.esm.js",
26
+ "main": "./index.cjs.js"
26
27
  }
@@ -236,6 +236,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
236
236
  hidden?: boolean | undefined;
237
237
  }[];
238
238
  }>, "many">>>;
239
+ sticky: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
239
240
  }, "strip", z.ZodTypeAny, {
240
241
  distribution: number[];
241
242
  traffic: number;
@@ -248,6 +249,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
248
249
  hidden: boolean;
249
250
  }[];
250
251
  }[];
252
+ sticky: boolean;
251
253
  }, {
252
254
  distribution?: number[] | undefined;
253
255
  traffic?: number | undefined;
@@ -260,6 +262,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
260
262
  hidden?: boolean | undefined;
261
263
  }[];
262
264
  }[] | undefined;
265
+ sticky?: boolean | undefined;
263
266
  }>>>>, {
264
267
  distribution: number[];
265
268
  traffic: number;
@@ -272,6 +275,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
272
275
  hidden: boolean;
273
276
  }[];
274
277
  }[];
278
+ sticky: boolean;
275
279
  }, {
276
280
  distribution?: number[] | undefined;
277
281
  traffic?: number | undefined;
@@ -284,6 +288,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
284
288
  hidden?: boolean | undefined;
285
289
  }[];
286
290
  }[] | undefined;
291
+ sticky?: boolean | undefined;
287
292
  } | null | undefined>;
288
293
  nt_audience: z.ZodNullable<z.ZodOptional<z.ZodObject<{
289
294
  sys: z.ZodObject<{
@@ -866,6 +871,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
866
871
  hidden: boolean;
867
872
  }[];
868
873
  }[];
874
+ sticky: boolean;
869
875
  };
870
876
  nt_description?: string | null | undefined;
871
877
  nt_audience?: {
@@ -970,6 +976,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
970
976
  hidden?: boolean | undefined;
971
977
  }[];
972
978
  }[] | undefined;
979
+ sticky?: boolean | undefined;
973
980
  } | null | undefined;
974
981
  nt_audience?: {
975
982
  sys: {
@@ -1103,6 +1110,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
1103
1110
  hidden: boolean;
1104
1111
  }[];
1105
1112
  }[];
1113
+ sticky: boolean;
1106
1114
  };
1107
1115
  nt_description?: string | null | undefined;
1108
1116
  nt_audience?: {
@@ -1247,6 +1255,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
1247
1255
  hidden?: boolean | undefined;
1248
1256
  }[];
1249
1257
  }[] | undefined;
1258
+ sticky?: boolean | undefined;
1250
1259
  } | null | undefined;
1251
1260
  nt_audience?: {
1252
1261
  sys: {
@@ -1391,6 +1400,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
1391
1400
  hidden: boolean;
1392
1401
  }[];
1393
1402
  }[];
1403
+ sticky: boolean;
1394
1404
  };
1395
1405
  nt_description?: string | null | undefined;
1396
1406
  nt_audience?: {
@@ -1537,6 +1547,7 @@ declare const BaselineWithExperiencesEntryFields: z.ZodObject<{
1537
1547
  hidden?: boolean | undefined;
1538
1548
  }[];
1539
1549
  }[] | undefined;
1550
+ sticky?: boolean | undefined;
1540
1551
  } | null | undefined;
1541
1552
  nt_audience?: {
1542
1553
  sys: {
@@ -2067,6 +2078,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
2067
2078
  hidden?: boolean | undefined;
2068
2079
  }[];
2069
2080
  }>, "many">>>;
2081
+ sticky: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
2070
2082
  }, "strip", z.ZodTypeAny, {
2071
2083
  distribution: number[];
2072
2084
  traffic: number;
@@ -2079,6 +2091,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
2079
2091
  hidden: boolean;
2080
2092
  }[];
2081
2093
  }[];
2094
+ sticky: boolean;
2082
2095
  }, {
2083
2096
  distribution?: number[] | undefined;
2084
2097
  traffic?: number | undefined;
@@ -2091,6 +2104,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
2091
2104
  hidden?: boolean | undefined;
2092
2105
  }[];
2093
2106
  }[] | undefined;
2107
+ sticky?: boolean | undefined;
2094
2108
  }>>>>, {
2095
2109
  distribution: number[];
2096
2110
  traffic: number;
@@ -2103,6 +2117,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
2103
2117
  hidden: boolean;
2104
2118
  }[];
2105
2119
  }[];
2120
+ sticky: boolean;
2106
2121
  }, {
2107
2122
  distribution?: number[] | undefined;
2108
2123
  traffic?: number | undefined;
@@ -2115,6 +2130,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
2115
2130
  hidden?: boolean | undefined;
2116
2131
  }[];
2117
2132
  }[] | undefined;
2133
+ sticky?: boolean | undefined;
2118
2134
  } | null | undefined>;
2119
2135
  nt_audience: z.ZodNullable<z.ZodOptional<z.ZodObject<{
2120
2136
  sys: z.ZodObject<{
@@ -2697,6 +2713,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
2697
2713
  hidden: boolean;
2698
2714
  }[];
2699
2715
  }[];
2716
+ sticky: boolean;
2700
2717
  };
2701
2718
  nt_description?: string | null | undefined;
2702
2719
  nt_audience?: {
@@ -2801,6 +2818,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
2801
2818
  hidden?: boolean | undefined;
2802
2819
  }[];
2803
2820
  }[] | undefined;
2821
+ sticky?: boolean | undefined;
2804
2822
  } | null | undefined;
2805
2823
  nt_audience?: {
2806
2824
  sys: {
@@ -2934,6 +2952,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
2934
2952
  hidden: boolean;
2935
2953
  }[];
2936
2954
  }[];
2955
+ sticky: boolean;
2937
2956
  };
2938
2957
  nt_description?: string | null | undefined;
2939
2958
  nt_audience?: {
@@ -3078,6 +3097,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
3078
3097
  hidden?: boolean | undefined;
3079
3098
  }[];
3080
3099
  }[] | undefined;
3100
+ sticky?: boolean | undefined;
3081
3101
  } | null | undefined;
3082
3102
  nt_audience?: {
3083
3103
  sys: {
@@ -3222,6 +3242,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
3222
3242
  hidden: boolean;
3223
3243
  }[];
3224
3244
  }[];
3245
+ sticky: boolean;
3225
3246
  };
3226
3247
  nt_description?: string | null | undefined;
3227
3248
  nt_audience?: {
@@ -3368,6 +3389,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
3368
3389
  hidden?: boolean | undefined;
3369
3390
  }[];
3370
3391
  }[] | undefined;
3392
+ sticky?: boolean | undefined;
3371
3393
  } | null | undefined;
3372
3394
  nt_audience?: {
3373
3395
  sys: {
@@ -3543,6 +3565,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
3543
3565
  hidden: boolean;
3544
3566
  }[];
3545
3567
  }[];
3568
+ sticky: boolean;
3546
3569
  };
3547
3570
  nt_description?: string | null | undefined;
3548
3571
  nt_audience?: {
@@ -3729,6 +3752,7 @@ export declare const BaselineWithExperiencesEntrySchema: z.ZodObject<{
3729
3752
  hidden?: boolean | undefined;
3730
3753
  }[];
3731
3754
  }[] | undefined;
3755
+ sticky?: boolean | undefined;
3732
3756
  } | null | undefined;
3733
3757
  nt_audience?: {
3734
3758
  sys: {