@ninetailed/experience.js-utils-contentful 3.1.1 → 3.2.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 +2 -2
- package/index.js +2 -2
- package/lib/AudienceMapper.d.ts +0 -1
- package/lib/ExperienceMapper.d.ts +2 -4
- package/lib/__test__/contentful-generated-types.d.ts +83 -0
- package/lib/__test__/ctfHero.d.ts +2 -0
- package/lib/isEntry.d.ts +1 -1
- package/package.json +4 -4
- package/types/AudienceEntry.d.ts +3 -13
- package/types/BaselineWithExperiencesEntry.d.ts +37 -129
- package/types/Entry.d.ts +33 -137
- package/types/EntryFields.d.ts +2 -6
- package/types/ExperienceEntry.d.ts +606 -1197
- package/types/ExperimentEntry.d.ts +25 -79
package/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var zod = require('zod');
|
|
|
6
6
|
var experience_jsShared = require('@ninetailed/experience.js-shared');
|
|
7
7
|
var experience_jsUtils = require('@ninetailed/experience.js-utils');
|
|
8
8
|
|
|
9
|
-
const EntryFields = zod.z.object({}).
|
|
9
|
+
const EntryFields = zod.z.object({}).passthrough();
|
|
10
10
|
|
|
11
11
|
const EntryLink = zod.z.object({
|
|
12
12
|
type: zod.z.string(),
|
|
@@ -207,7 +207,7 @@ class ExperienceMapper {
|
|
|
207
207
|
sys,
|
|
208
208
|
fields
|
|
209
209
|
} = validateExperienceEntry(ctfEntry);
|
|
210
|
-
const variants = fields.nt_variants.map(
|
|
210
|
+
const variants = fields.nt_variants.map(mapFn);
|
|
211
211
|
const experience = createExperience(sys.id, fields, variants);
|
|
212
212
|
return experience_jsUtils.ExperienceMapper.mapExperience(experience);
|
|
213
213
|
}
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ 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
|
-
const EntryFields = z.object({}).
|
|
5
|
+
const EntryFields = z.object({}).passthrough();
|
|
6
6
|
|
|
7
7
|
const EntryLink = z.object({
|
|
8
8
|
type: z.string(),
|
|
@@ -203,7 +203,7 @@ class ExperienceMapper {
|
|
|
203
203
|
sys,
|
|
204
204
|
fields
|
|
205
205
|
} = validateExperienceEntry(ctfEntry);
|
|
206
|
-
const variants = fields.nt_variants.map(
|
|
206
|
+
const variants = fields.nt_variants.map(mapFn);
|
|
207
207
|
const experience = createExperience(sys.id, fields, variants);
|
|
208
208
|
return ExperienceMapper$1.mapExperience(experience);
|
|
209
209
|
}
|
package/lib/AudienceMapper.d.ts
CHANGED
|
@@ -4,9 +4,7 @@ import { EntryLike } from '../types/Entry';
|
|
|
4
4
|
import type { EntryFields } from '../types/EntryFields';
|
|
5
5
|
import { ExperienceEntry, ExperienceEntryLike } from '../types/ExperienceEntry';
|
|
6
6
|
import { ExperimentEntry } from '../types/ExperimentEntry';
|
|
7
|
-
export type MapVariantFunction<In extends EntryFields, Out extends Reference> = (input: EntryLike<In>
|
|
8
|
-
fields: In;
|
|
9
|
-
}) => Out;
|
|
7
|
+
export type MapVariantFunction<In extends EntryFields, Out extends Reference> = (input: EntryLike<In>) => Out;
|
|
10
8
|
export declare class ExperienceMapper {
|
|
11
9
|
static isExperienceEntry<VariantFields extends EntryFields>(entry: ExperienceEntryLike<VariantFields>): entry is ExperienceEntry<VariantFields>;
|
|
12
10
|
static mapExperience<VariantFields extends EntryFields>(ctfEntry: ExperienceEntryLike<VariantFields>): import("@ninetailed/experience.js").ExperienceConfiguration<{
|
|
@@ -96,6 +94,6 @@ export declare class ExperienceMapper {
|
|
|
96
94
|
};
|
|
97
95
|
}[];
|
|
98
96
|
} | undefined;
|
|
99
|
-
fields:
|
|
97
|
+
fields: {};
|
|
100
98
|
}>[];
|
|
101
99
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
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
|
+
}
|
|
45
|
+
/** Ninetailed Experience */
|
|
46
|
+
export interface INtExperience extends Entry<INtExperienceFields> {
|
|
47
|
+
sys: {
|
|
48
|
+
id: string;
|
|
49
|
+
type: string;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
updatedAt: string;
|
|
52
|
+
locale: string;
|
|
53
|
+
contentType: {
|
|
54
|
+
sys: {
|
|
55
|
+
id: 'nt_experience';
|
|
56
|
+
linkType: 'ContentType';
|
|
57
|
+
type: 'Link';
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export interface IHeroFields {
|
|
63
|
+
/** Name */
|
|
64
|
+
name: string;
|
|
65
|
+
/** Ninetailed */
|
|
66
|
+
nt_experiences?: INtExperience[] | undefined;
|
|
67
|
+
}
|
|
68
|
+
export interface IHero extends Entry<IHeroFields> {
|
|
69
|
+
sys: {
|
|
70
|
+
id: string;
|
|
71
|
+
type: string;
|
|
72
|
+
createdAt: string;
|
|
73
|
+
updatedAt: string;
|
|
74
|
+
locale: string;
|
|
75
|
+
contentType: {
|
|
76
|
+
sys: {
|
|
77
|
+
id: 'hero';
|
|
78
|
+
linkType: 'ContentType';
|
|
79
|
+
type: 'Link';
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
}
|
package/lib/isEntry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Entry, EntryLike } from '../types/Entry';
|
|
2
|
-
export declare const isEntry: <Fields extends
|
|
2
|
+
export declare const isEntry: <Fields extends {}>(entry: EntryLike<Fields>) => entry is Entry<Fields>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-utils-contentful",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"contentful": "^9.1.32"
|
|
6
6
|
},
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"types": "./index.d.ts",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@ninetailed/experience.js-utils": "3.
|
|
13
|
-
"@ninetailed/experience.js": "3.
|
|
14
|
-
"@ninetailed/experience.js-shared": "3.
|
|
12
|
+
"@ninetailed/experience.js-utils": "3.2.2",
|
|
13
|
+
"@ninetailed/experience.js": "3.2.2",
|
|
14
|
+
"@ninetailed/experience.js-shared": "3.2.2",
|
|
15
15
|
"zod": "3.20.2"
|
|
16
16
|
}
|
|
17
17
|
}
|
package/types/AudienceEntry.d.ts
CHANGED
|
@@ -8,12 +8,10 @@ export declare const AudienceEntryFields: z.ZodObject<z.extendShape<{}, {
|
|
|
8
8
|
* The internal id of the audience (Short Text)
|
|
9
9
|
*/
|
|
10
10
|
nt_audience_id: z.ZodString;
|
|
11
|
-
}>, "
|
|
12
|
-
[x: string]: unknown;
|
|
11
|
+
}>, "passthrough", z.ZodTypeAny, {
|
|
13
12
|
nt_name: string;
|
|
14
13
|
nt_audience_id: string;
|
|
15
14
|
}, {
|
|
16
|
-
[x: string]: unknown;
|
|
17
15
|
nt_name: string;
|
|
18
16
|
nt_audience_id: string;
|
|
19
17
|
}>;
|
|
@@ -170,11 +168,7 @@ export declare const AudienceEntry: z.ZodObject<z.extendShape<{
|
|
|
170
168
|
} | undefined;
|
|
171
169
|
id: string;
|
|
172
170
|
}>;
|
|
173
|
-
fields: z.ZodObject<{}, "
|
|
174
|
-
[x: string]: unknown;
|
|
175
|
-
}, {
|
|
176
|
-
[x: string]: unknown;
|
|
177
|
-
}>;
|
|
171
|
+
fields: z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>;
|
|
178
172
|
metadata: z.ZodOptional<z.ZodObject<{
|
|
179
173
|
tags: z.ZodArray<z.ZodObject<{
|
|
180
174
|
sys: z.ZodObject<z.extendShape<{
|
|
@@ -232,12 +226,10 @@ export declare const AudienceEntry: z.ZodObject<z.extendShape<{
|
|
|
232
226
|
* The internal id of the audience (Short Text)
|
|
233
227
|
*/
|
|
234
228
|
nt_audience_id: z.ZodString;
|
|
235
|
-
}>, "
|
|
236
|
-
[x: string]: unknown;
|
|
229
|
+
}>, "passthrough", z.ZodTypeAny, {
|
|
237
230
|
nt_name: string;
|
|
238
231
|
nt_audience_id: string;
|
|
239
232
|
}, {
|
|
240
|
-
[x: string]: unknown;
|
|
241
233
|
nt_name: string;
|
|
242
234
|
nt_audience_id: string;
|
|
243
235
|
}>;
|
|
@@ -281,7 +273,6 @@ export declare const AudienceEntry: z.ZodObject<z.extendShape<{
|
|
|
281
273
|
id: string;
|
|
282
274
|
};
|
|
283
275
|
fields: {
|
|
284
|
-
[x: string]: unknown;
|
|
285
276
|
nt_name: string;
|
|
286
277
|
nt_audience_id: string;
|
|
287
278
|
};
|
|
@@ -325,7 +316,6 @@ export declare const AudienceEntry: z.ZodObject<z.extendShape<{
|
|
|
325
316
|
id: string;
|
|
326
317
|
};
|
|
327
318
|
fields: {
|
|
328
|
-
[x: string]: unknown;
|
|
329
319
|
nt_name: string;
|
|
330
320
|
nt_audience_id: string;
|
|
331
321
|
};
|