@ninetailed/experience.js-utils 2.2.3 → 2.2.5
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/{src/index.d.ts → index.d.ts} +2 -2
- package/index.esm.js +130 -0
- package/index.umd.js +182 -0
- package/{src/lib → lib}/ExperienceMapper.d.ts +12 -12
- package/{src/lib → lib}/index.d.ts +1 -1
- package/package.json +18 -3
- package/{src/types → types}/Audience.d.ts +9 -9
- package/{src/types → types}/Config.d.ts +65 -65
- package/{src/types → types}/Experience.d.ts +149 -149
- package/{src/types → types}/Experiment.d.ts +132 -132
- package/{src/types → types}/Variant.d.ts +9 -9
- package/{src/types → types}/index.d.ts +5 -5
- package/src/index.js +0 -12
- package/src/index.js.map +0 -1
- package/src/lib/ExperienceMapper.js +0 -52
- package/src/lib/ExperienceMapper.js.map +0 -1
- package/src/lib/index.js +0 -6
- package/src/lib/index.js.map +0 -1
- package/src/types/Audience.js +0 -8
- package/src/types/Audience.js.map +0 -1
- package/src/types/Config.js +0 -20
- package/src/types/Config.js.map +0 -1
- package/src/types/Experience.js +0 -31
- package/src/types/Experience.js.map +0 -1
- package/src/types/Experiment.js +0 -9
- package/src/types/Experiment.js.map +0 -1
- package/src/types/Variant.js +0 -10
- package/src/types/Variant.js.map +0 -1
- package/src/types/index.js +0 -14
- package/src/types/index.js.map +0 -1
|
@@ -1,149 +1,149 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const Experience: z.ZodObject<{
|
|
3
|
-
id: z.ZodString;
|
|
4
|
-
/**
|
|
5
|
-
* The name of the experience (Short Text)
|
|
6
|
-
*/
|
|
7
|
-
name: z.ZodString;
|
|
8
|
-
/**
|
|
9
|
-
* The type if the experience (nt_experiment | nt_personalization)
|
|
10
|
-
*/
|
|
11
|
-
type: z.ZodUnion<[z.ZodLiteral<"nt_experiment">, z.ZodLiteral<"nt_personalization">]>;
|
|
12
|
-
/**
|
|
13
|
-
* The config of the experience (JSON)
|
|
14
|
-
*/
|
|
15
|
-
config: z.ZodDefault<z.ZodObject<{
|
|
16
|
-
distribution: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
|
|
17
|
-
traffic: z.ZodDefault<z.ZodNumber>;
|
|
18
|
-
components: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
19
|
-
baseline: z.ZodObject<{
|
|
20
|
-
id: z.ZodDefault<z.ZodString>;
|
|
21
|
-
}, "strip", z.ZodTypeAny, {
|
|
22
|
-
id: string;
|
|
23
|
-
}, {
|
|
24
|
-
id?: string | undefined;
|
|
25
|
-
}>; /**
|
|
26
|
-
* The type if the experience (nt_experiment | nt_personalization)
|
|
27
|
-
*/
|
|
28
|
-
variants: z.ZodArray<z.ZodObject<{
|
|
29
|
-
id: z.ZodDefault<z.ZodString>;
|
|
30
|
-
hidden: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
-
}, "strip", z.ZodTypeAny, {
|
|
32
|
-
id: string;
|
|
33
|
-
hidden: boolean;
|
|
34
|
-
}, {
|
|
35
|
-
id?: string | undefined;
|
|
36
|
-
hidden?: boolean | undefined;
|
|
37
|
-
}>, "many">; /**
|
|
38
|
-
* The config of the experience (JSON)
|
|
39
|
-
*/
|
|
40
|
-
}, "strip", z.ZodTypeAny, {
|
|
41
|
-
baseline: {
|
|
42
|
-
id: string;
|
|
43
|
-
};
|
|
44
|
-
variants: {
|
|
45
|
-
id: string;
|
|
46
|
-
hidden: boolean;
|
|
47
|
-
}[];
|
|
48
|
-
}, {
|
|
49
|
-
baseline: {
|
|
50
|
-
id?: string | undefined;
|
|
51
|
-
};
|
|
52
|
-
variants: {
|
|
53
|
-
id?: string | undefined;
|
|
54
|
-
hidden?: boolean | undefined;
|
|
55
|
-
}[];
|
|
56
|
-
}>, "many">>;
|
|
57
|
-
}, "strip", z.ZodTypeAny, {
|
|
58
|
-
distribution: number[];
|
|
59
|
-
traffic: number;
|
|
60
|
-
components: {
|
|
61
|
-
baseline: {
|
|
62
|
-
id: string;
|
|
63
|
-
};
|
|
64
|
-
variants: {
|
|
65
|
-
id: string;
|
|
66
|
-
hidden: boolean;
|
|
67
|
-
}[];
|
|
68
|
-
}[];
|
|
69
|
-
}, {
|
|
70
|
-
distribution?: number[] | undefined;
|
|
71
|
-
traffic?: number | undefined;
|
|
72
|
-
components?: {
|
|
73
|
-
baseline: {
|
|
74
|
-
id?: string | undefined;
|
|
75
|
-
};
|
|
76
|
-
variants: {
|
|
77
|
-
id?: string | undefined;
|
|
78
|
-
hidden?: boolean | undefined;
|
|
79
|
-
}[];
|
|
80
|
-
}[] | undefined;
|
|
81
|
-
}>>;
|
|
82
|
-
/**
|
|
83
|
-
* The audience of the experience (Audience)
|
|
84
|
-
*/
|
|
85
|
-
audience: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
86
|
-
id: z.ZodString;
|
|
87
|
-
}, "strip", z.ZodTypeAny, {
|
|
88
|
-
id: string;
|
|
89
|
-
}, {
|
|
90
|
-
id: string;
|
|
91
|
-
}>>>;
|
|
92
|
-
/**
|
|
93
|
-
* All used variants of the experience (References to other Content Types)
|
|
94
|
-
*/
|
|
95
|
-
variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
96
|
-
id: z.ZodString;
|
|
97
|
-
}, "passthrough", z.ZodTypeAny, {
|
|
98
|
-
id: string;
|
|
99
|
-
}, {
|
|
100
|
-
id: string;
|
|
101
|
-
}>, "many">>;
|
|
102
|
-
}, "strip", z.ZodTypeAny, {
|
|
103
|
-
audience?: {
|
|
104
|
-
id: string;
|
|
105
|
-
} | null | undefined;
|
|
106
|
-
id: string;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
config: {
|
|
113
|
-
distribution: number[];
|
|
114
|
-
traffic: number;
|
|
115
|
-
components: {
|
|
116
|
-
baseline: {
|
|
117
|
-
id: string;
|
|
118
|
-
};
|
|
119
|
-
variants: {
|
|
120
|
-
id: string;
|
|
121
|
-
hidden: boolean;
|
|
122
|
-
}[];
|
|
123
|
-
}[];
|
|
124
|
-
};
|
|
125
|
-
}, {
|
|
126
|
-
variants?: {
|
|
127
|
-
id: string;
|
|
128
|
-
}[] | undefined;
|
|
129
|
-
config?: {
|
|
130
|
-
distribution?: number[] | undefined;
|
|
131
|
-
traffic?: number | undefined;
|
|
132
|
-
components?: {
|
|
133
|
-
baseline: {
|
|
134
|
-
id?: string | undefined;
|
|
135
|
-
};
|
|
136
|
-
variants: {
|
|
137
|
-
id?: string | undefined;
|
|
138
|
-
hidden?: boolean | undefined;
|
|
139
|
-
}[];
|
|
140
|
-
}[] | undefined;
|
|
141
|
-
} | undefined;
|
|
142
|
-
audience?: {
|
|
143
|
-
id: string;
|
|
144
|
-
} | null | undefined;
|
|
145
|
-
id: string;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}>;
|
|
149
|
-
export declare type Experience = z.infer<typeof Experience>;
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Experience: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
/**
|
|
5
|
+
* The name of the experience (Short Text)
|
|
6
|
+
*/
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
/**
|
|
9
|
+
* The type if the experience (nt_experiment | nt_personalization)
|
|
10
|
+
*/
|
|
11
|
+
type: z.ZodUnion<[z.ZodLiteral<"nt_experiment">, z.ZodLiteral<"nt_personalization">]>;
|
|
12
|
+
/**
|
|
13
|
+
* The config of the experience (JSON)
|
|
14
|
+
*/
|
|
15
|
+
config: z.ZodDefault<z.ZodObject<{
|
|
16
|
+
distribution: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
|
|
17
|
+
traffic: z.ZodDefault<z.ZodNumber>;
|
|
18
|
+
components: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
19
|
+
baseline: z.ZodObject<{
|
|
20
|
+
id: z.ZodDefault<z.ZodString>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
id: string;
|
|
23
|
+
}, {
|
|
24
|
+
id?: string | undefined;
|
|
25
|
+
}>; /**
|
|
26
|
+
* The type if the experience (nt_experiment | nt_personalization)
|
|
27
|
+
*/
|
|
28
|
+
variants: z.ZodArray<z.ZodObject<{
|
|
29
|
+
id: z.ZodDefault<z.ZodString>;
|
|
30
|
+
hidden: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
id: string;
|
|
33
|
+
hidden: boolean;
|
|
34
|
+
}, {
|
|
35
|
+
id?: string | undefined;
|
|
36
|
+
hidden?: boolean | undefined;
|
|
37
|
+
}>, "many">; /**
|
|
38
|
+
* The config of the experience (JSON)
|
|
39
|
+
*/
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
baseline: {
|
|
42
|
+
id: string;
|
|
43
|
+
};
|
|
44
|
+
variants: {
|
|
45
|
+
id: string;
|
|
46
|
+
hidden: boolean;
|
|
47
|
+
}[];
|
|
48
|
+
}, {
|
|
49
|
+
baseline: {
|
|
50
|
+
id?: string | undefined;
|
|
51
|
+
};
|
|
52
|
+
variants: {
|
|
53
|
+
id?: string | undefined;
|
|
54
|
+
hidden?: boolean | undefined;
|
|
55
|
+
}[];
|
|
56
|
+
}>, "many">>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
distribution: number[];
|
|
59
|
+
traffic: number;
|
|
60
|
+
components: {
|
|
61
|
+
baseline: {
|
|
62
|
+
id: string;
|
|
63
|
+
};
|
|
64
|
+
variants: {
|
|
65
|
+
id: string;
|
|
66
|
+
hidden: boolean;
|
|
67
|
+
}[];
|
|
68
|
+
}[];
|
|
69
|
+
}, {
|
|
70
|
+
distribution?: number[] | undefined;
|
|
71
|
+
traffic?: number | undefined;
|
|
72
|
+
components?: {
|
|
73
|
+
baseline: {
|
|
74
|
+
id?: string | undefined;
|
|
75
|
+
};
|
|
76
|
+
variants: {
|
|
77
|
+
id?: string | undefined;
|
|
78
|
+
hidden?: boolean | undefined;
|
|
79
|
+
}[];
|
|
80
|
+
}[] | undefined;
|
|
81
|
+
}>>;
|
|
82
|
+
/**
|
|
83
|
+
* The audience of the experience (Audience)
|
|
84
|
+
*/
|
|
85
|
+
audience: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
id: string;
|
|
89
|
+
}, {
|
|
90
|
+
id: string;
|
|
91
|
+
}>>>;
|
|
92
|
+
/**
|
|
93
|
+
* All used variants of the experience (References to other Content Types)
|
|
94
|
+
*/
|
|
95
|
+
variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
96
|
+
id: z.ZodString;
|
|
97
|
+
}, "passthrough", z.ZodTypeAny, {
|
|
98
|
+
id: string;
|
|
99
|
+
}, {
|
|
100
|
+
id: string;
|
|
101
|
+
}>, "many">>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
audience?: {
|
|
104
|
+
id: string;
|
|
105
|
+
} | null | undefined;
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
type: "nt_experiment" | "nt_personalization";
|
|
109
|
+
variants: {
|
|
110
|
+
id: string;
|
|
111
|
+
}[];
|
|
112
|
+
config: {
|
|
113
|
+
distribution: number[];
|
|
114
|
+
traffic: number;
|
|
115
|
+
components: {
|
|
116
|
+
baseline: {
|
|
117
|
+
id: string;
|
|
118
|
+
};
|
|
119
|
+
variants: {
|
|
120
|
+
id: string;
|
|
121
|
+
hidden: boolean;
|
|
122
|
+
}[];
|
|
123
|
+
}[];
|
|
124
|
+
};
|
|
125
|
+
}, {
|
|
126
|
+
variants?: {
|
|
127
|
+
id: string;
|
|
128
|
+
}[] | undefined;
|
|
129
|
+
config?: {
|
|
130
|
+
distribution?: number[] | undefined;
|
|
131
|
+
traffic?: number | undefined;
|
|
132
|
+
components?: {
|
|
133
|
+
baseline: {
|
|
134
|
+
id?: string | undefined;
|
|
135
|
+
};
|
|
136
|
+
variants: {
|
|
137
|
+
id?: string | undefined;
|
|
138
|
+
hidden?: boolean | undefined;
|
|
139
|
+
}[];
|
|
140
|
+
}[] | undefined;
|
|
141
|
+
} | undefined;
|
|
142
|
+
audience?: {
|
|
143
|
+
id: string;
|
|
144
|
+
} | null | undefined;
|
|
145
|
+
id: string;
|
|
146
|
+
name: string;
|
|
147
|
+
type: "nt_experiment" | "nt_personalization";
|
|
148
|
+
}>;
|
|
149
|
+
export declare type Experience = z.infer<typeof Experience>;
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const Experiment: z.ZodObject<z.extendShape<{
|
|
3
|
-
id: z.ZodString;
|
|
4
|
-
name: z.ZodString;
|
|
5
|
-
type: z.ZodUnion<[z.ZodLiteral<"nt_experiment">, z.ZodLiteral<"nt_personalization">]>;
|
|
6
|
-
config: z.ZodDefault<z.ZodObject<{
|
|
7
|
-
distribution: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
|
|
8
|
-
traffic: z.ZodDefault<z.ZodNumber>;
|
|
9
|
-
components: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
10
|
-
baseline: z.ZodObject<{
|
|
11
|
-
id: z.ZodDefault<z.ZodString>;
|
|
12
|
-
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
id: string;
|
|
14
|
-
}, {
|
|
15
|
-
id?: string | undefined;
|
|
16
|
-
}>;
|
|
17
|
-
variants: z.ZodArray<z.ZodObject<{
|
|
18
|
-
id: z.ZodDefault<z.ZodString>;
|
|
19
|
-
hidden: z.ZodDefault<z.ZodBoolean>;
|
|
20
|
-
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
id: string;
|
|
22
|
-
hidden: boolean;
|
|
23
|
-
}, {
|
|
24
|
-
id?: string | undefined;
|
|
25
|
-
hidden?: boolean | undefined;
|
|
26
|
-
}>, "many">;
|
|
27
|
-
}, "strip", z.ZodTypeAny, {
|
|
28
|
-
baseline: {
|
|
29
|
-
id: string;
|
|
30
|
-
};
|
|
31
|
-
variants: {
|
|
32
|
-
id: string;
|
|
33
|
-
hidden: boolean;
|
|
34
|
-
}[];
|
|
35
|
-
}, {
|
|
36
|
-
baseline: {
|
|
37
|
-
id?: string | undefined;
|
|
38
|
-
};
|
|
39
|
-
variants: {
|
|
40
|
-
id?: string | undefined;
|
|
41
|
-
hidden?: boolean | undefined;
|
|
42
|
-
}[];
|
|
43
|
-
}>, "many">>;
|
|
44
|
-
}, "strip", z.ZodTypeAny, {
|
|
45
|
-
distribution: number[];
|
|
46
|
-
traffic: number;
|
|
47
|
-
components: {
|
|
48
|
-
baseline: {
|
|
49
|
-
id: string;
|
|
50
|
-
};
|
|
51
|
-
variants: {
|
|
52
|
-
id: string;
|
|
53
|
-
hidden: boolean;
|
|
54
|
-
}[];
|
|
55
|
-
}[];
|
|
56
|
-
}, {
|
|
57
|
-
distribution?: number[] | undefined;
|
|
58
|
-
traffic?: number | undefined;
|
|
59
|
-
components?: {
|
|
60
|
-
baseline: {
|
|
61
|
-
id?: string | undefined;
|
|
62
|
-
};
|
|
63
|
-
variants: {
|
|
64
|
-
id?: string | undefined;
|
|
65
|
-
hidden?: boolean | undefined;
|
|
66
|
-
}[];
|
|
67
|
-
}[] | undefined;
|
|
68
|
-
}>>;
|
|
69
|
-
audience: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
70
|
-
id: z.ZodString;
|
|
71
|
-
}, "strip", z.ZodTypeAny, {
|
|
72
|
-
id: string;
|
|
73
|
-
}, {
|
|
74
|
-
id: string;
|
|
75
|
-
}>>>;
|
|
76
|
-
variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
77
|
-
id: z.ZodString;
|
|
78
|
-
}, "passthrough", z.ZodTypeAny, {
|
|
79
|
-
id: string;
|
|
80
|
-
}, {
|
|
81
|
-
id: string;
|
|
82
|
-
}>, "many">>;
|
|
83
|
-
}, {
|
|
84
|
-
type: z.ZodLiteral<"nt_experiment">;
|
|
85
|
-
}>, "strip", z.ZodTypeAny, {
|
|
86
|
-
audience?: {
|
|
87
|
-
id: string;
|
|
88
|
-
} | null | undefined;
|
|
89
|
-
id: string;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
config: {
|
|
96
|
-
distribution: number[];
|
|
97
|
-
traffic: number;
|
|
98
|
-
components: {
|
|
99
|
-
baseline: {
|
|
100
|
-
id: string;
|
|
101
|
-
};
|
|
102
|
-
variants: {
|
|
103
|
-
id: string;
|
|
104
|
-
hidden: boolean;
|
|
105
|
-
}[];
|
|
106
|
-
}[];
|
|
107
|
-
};
|
|
108
|
-
}, {
|
|
109
|
-
variants?: {
|
|
110
|
-
id: string;
|
|
111
|
-
}[] | undefined;
|
|
112
|
-
config?: {
|
|
113
|
-
distribution?: number[] | undefined;
|
|
114
|
-
traffic?: number | undefined;
|
|
115
|
-
components?: {
|
|
116
|
-
baseline: {
|
|
117
|
-
id?: string | undefined;
|
|
118
|
-
};
|
|
119
|
-
variants: {
|
|
120
|
-
id?: string | undefined;
|
|
121
|
-
hidden?: boolean | undefined;
|
|
122
|
-
}[];
|
|
123
|
-
}[] | undefined;
|
|
124
|
-
} | undefined;
|
|
125
|
-
audience?: {
|
|
126
|
-
id: string;
|
|
127
|
-
} | null | undefined;
|
|
128
|
-
id: string;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}>;
|
|
132
|
-
export declare type Experiment = z.infer<typeof Experiment>;
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Experiment: z.ZodObject<z.extendShape<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
type: z.ZodUnion<[z.ZodLiteral<"nt_experiment">, z.ZodLiteral<"nt_personalization">]>;
|
|
6
|
+
config: z.ZodDefault<z.ZodObject<{
|
|
7
|
+
distribution: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
|
|
8
|
+
traffic: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
components: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
10
|
+
baseline: z.ZodObject<{
|
|
11
|
+
id: z.ZodDefault<z.ZodString>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
id: string;
|
|
14
|
+
}, {
|
|
15
|
+
id?: string | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
variants: z.ZodArray<z.ZodObject<{
|
|
18
|
+
id: z.ZodDefault<z.ZodString>;
|
|
19
|
+
hidden: z.ZodDefault<z.ZodBoolean>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
id: string;
|
|
22
|
+
hidden: boolean;
|
|
23
|
+
}, {
|
|
24
|
+
id?: string | undefined;
|
|
25
|
+
hidden?: boolean | undefined;
|
|
26
|
+
}>, "many">;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
baseline: {
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
variants: {
|
|
32
|
+
id: string;
|
|
33
|
+
hidden: boolean;
|
|
34
|
+
}[];
|
|
35
|
+
}, {
|
|
36
|
+
baseline: {
|
|
37
|
+
id?: string | undefined;
|
|
38
|
+
};
|
|
39
|
+
variants: {
|
|
40
|
+
id?: string | undefined;
|
|
41
|
+
hidden?: boolean | undefined;
|
|
42
|
+
}[];
|
|
43
|
+
}>, "many">>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
distribution: number[];
|
|
46
|
+
traffic: number;
|
|
47
|
+
components: {
|
|
48
|
+
baseline: {
|
|
49
|
+
id: string;
|
|
50
|
+
};
|
|
51
|
+
variants: {
|
|
52
|
+
id: string;
|
|
53
|
+
hidden: boolean;
|
|
54
|
+
}[];
|
|
55
|
+
}[];
|
|
56
|
+
}, {
|
|
57
|
+
distribution?: number[] | undefined;
|
|
58
|
+
traffic?: number | undefined;
|
|
59
|
+
components?: {
|
|
60
|
+
baseline: {
|
|
61
|
+
id?: string | undefined;
|
|
62
|
+
};
|
|
63
|
+
variants: {
|
|
64
|
+
id?: string | undefined;
|
|
65
|
+
hidden?: boolean | undefined;
|
|
66
|
+
}[];
|
|
67
|
+
}[] | undefined;
|
|
68
|
+
}>>;
|
|
69
|
+
audience: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
id: string;
|
|
73
|
+
}, {
|
|
74
|
+
id: string;
|
|
75
|
+
}>>>;
|
|
76
|
+
variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
}, "passthrough", z.ZodTypeAny, {
|
|
79
|
+
id: string;
|
|
80
|
+
}, {
|
|
81
|
+
id: string;
|
|
82
|
+
}>, "many">>;
|
|
83
|
+
}, {
|
|
84
|
+
type: z.ZodLiteral<"nt_experiment">;
|
|
85
|
+
}>, "strip", z.ZodTypeAny, {
|
|
86
|
+
audience?: {
|
|
87
|
+
id: string;
|
|
88
|
+
} | null | undefined;
|
|
89
|
+
id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
type: "nt_experiment";
|
|
92
|
+
variants: {
|
|
93
|
+
id: string;
|
|
94
|
+
}[];
|
|
95
|
+
config: {
|
|
96
|
+
distribution: number[];
|
|
97
|
+
traffic: number;
|
|
98
|
+
components: {
|
|
99
|
+
baseline: {
|
|
100
|
+
id: string;
|
|
101
|
+
};
|
|
102
|
+
variants: {
|
|
103
|
+
id: string;
|
|
104
|
+
hidden: boolean;
|
|
105
|
+
}[];
|
|
106
|
+
}[];
|
|
107
|
+
};
|
|
108
|
+
}, {
|
|
109
|
+
variants?: {
|
|
110
|
+
id: string;
|
|
111
|
+
}[] | undefined;
|
|
112
|
+
config?: {
|
|
113
|
+
distribution?: number[] | undefined;
|
|
114
|
+
traffic?: number | undefined;
|
|
115
|
+
components?: {
|
|
116
|
+
baseline: {
|
|
117
|
+
id?: string | undefined;
|
|
118
|
+
};
|
|
119
|
+
variants: {
|
|
120
|
+
id?: string | undefined;
|
|
121
|
+
hidden?: boolean | undefined;
|
|
122
|
+
}[];
|
|
123
|
+
}[] | undefined;
|
|
124
|
+
} | undefined;
|
|
125
|
+
audience?: {
|
|
126
|
+
id: string;
|
|
127
|
+
} | null | undefined;
|
|
128
|
+
id: string;
|
|
129
|
+
name: string;
|
|
130
|
+
type: "nt_experiment";
|
|
131
|
+
}>;
|
|
132
|
+
export declare type Experiment = z.infer<typeof Experiment>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const Variant: z.ZodObject<{
|
|
3
|
-
id: z.ZodString;
|
|
4
|
-
}, "passthrough", z.ZodTypeAny, {
|
|
5
|
-
id: string;
|
|
6
|
-
}, {
|
|
7
|
-
id: string;
|
|
8
|
-
}>;
|
|
9
|
-
export declare type Variant = z.infer<typeof Variant>;
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Variant: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
}, "passthrough", z.ZodTypeAny, {
|
|
5
|
+
id: string;
|
|
6
|
+
}, {
|
|
7
|
+
id: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare type Variant = z.infer<typeof Variant>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Experience } from './Experience';
|
|
2
|
-
export { Experiment } from './Experiment';
|
|
3
|
-
export { Audience } from './Audience';
|
|
4
|
-
export { Variant } from './Variant';
|
|
5
|
-
export { Config } from './Config';
|
|
1
|
+
export { Experience } from './Experience';
|
|
2
|
+
export { Experiment } from './Experiment';
|
|
3
|
+
export { Audience } from './Audience';
|
|
4
|
+
export { Variant } from './Variant';
|
|
5
|
+
export { Config } from './Config';
|
package/src/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Variant = exports.Config = exports.Audience = exports.Experiment = exports.Experience = exports.ExperienceMapper = void 0;
|
|
4
|
-
var lib_1 = require("./lib");
|
|
5
|
-
Object.defineProperty(exports, "ExperienceMapper", { enumerable: true, get: function () { return lib_1.ExperienceMapper; } });
|
|
6
|
-
var types_1 = require("./types");
|
|
7
|
-
Object.defineProperty(exports, "Experience", { enumerable: true, get: function () { return types_1.Experience; } });
|
|
8
|
-
Object.defineProperty(exports, "Experiment", { enumerable: true, get: function () { return types_1.Experiment; } });
|
|
9
|
-
Object.defineProperty(exports, "Audience", { enumerable: true, get: function () { return types_1.Audience; } });
|
|
10
|
-
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return types_1.Config; } });
|
|
11
|
-
Object.defineProperty(exports, "Variant", { enumerable: true, get: function () { return types_1.Variant; } });
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/utils/javascript/src/index.ts"],"names":[],"mappings":";;;AAAA,6BAAyC;AAAhC,uGAAA,gBAAgB,OAAA;AACzB,iCAA4E;AAAnE,mGAAA,UAAU,OAAA;AAAE,mGAAA,UAAU,OAAA;AAAE,iGAAA,QAAQ,OAAA;AAAE,+FAAA,MAAM,OAAA;AAAE,gGAAA,OAAO,OAAA"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExperienceMapper = void 0;
|
|
4
|
-
const experience_js_1 = require("@ninetailed/experience.js");
|
|
5
|
-
const types_1 = require("../types");
|
|
6
|
-
class ExperienceMapper {
|
|
7
|
-
static isExperienceEntry(experience) {
|
|
8
|
-
return types_1.Experience.safeParse(experience).success;
|
|
9
|
-
}
|
|
10
|
-
static mapExperience(experience) {
|
|
11
|
-
const parsedExperience = types_1.Experience.safeParse(experience);
|
|
12
|
-
if (!parsedExperience.success) {
|
|
13
|
-
experience_js_1.logger.warn('[Ninetailed ExperienceMapper]', 'Error parsing experience', parsedExperience.error.format());
|
|
14
|
-
throw new Error(`[Ninetailed ExperienceMapper] The Experience Input is not valid. Please filter data first with "ExperienceMapper.isExperienceEntry".\n${parsedExperience.error.format()}`);
|
|
15
|
-
}
|
|
16
|
-
const { id, type, audience, config, variants } = parsedExperience.data;
|
|
17
|
-
return Object.assign(Object.assign({ id,
|
|
18
|
-
type }, (audience
|
|
19
|
-
? {
|
|
20
|
-
audience,
|
|
21
|
-
}
|
|
22
|
-
: {})), { trafficAllocation: config.traffic, distribution: config.distribution.map((percentage, index) => ({
|
|
23
|
-
index,
|
|
24
|
-
start: config.distribution.slice(0, index).reduce((a, b) => a + b, 0),
|
|
25
|
-
end: config.distribution.slice(0, index + 1).reduce((a, b) => a + b, 0),
|
|
26
|
-
})), components: config.components.map((component) => {
|
|
27
|
-
return {
|
|
28
|
-
baseline: component.baseline,
|
|
29
|
-
variants: component.variants
|
|
30
|
-
.map((variant) => {
|
|
31
|
-
if (variant.hidden) {
|
|
32
|
-
return variant;
|
|
33
|
-
}
|
|
34
|
-
const matchingVariant = variants.find((variantReference) => variantReference.id === variant.id);
|
|
35
|
-
if (!matchingVariant) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
return matchingVariant;
|
|
39
|
-
})
|
|
40
|
-
.filter((variant) => variant !== null),
|
|
41
|
-
};
|
|
42
|
-
}) });
|
|
43
|
-
}
|
|
44
|
-
static isExperimentEntry(experiment) {
|
|
45
|
-
return types_1.Experiment.safeParse(experiment).success;
|
|
46
|
-
}
|
|
47
|
-
static mapExperiment(experiment) {
|
|
48
|
-
return ExperienceMapper.mapExperience(experiment);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.ExperienceMapper = ExperienceMapper;
|
|
52
|
-
//# sourceMappingURL=ExperienceMapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExperienceMapper.js","sourceRoot":"","sources":["../../../../../../packages/utils/javascript/src/lib/ExperienceMapper.ts"],"names":[],"mappings":";;;AAAA,6DAImC;AAGnC,oCAAkD;AAKlD,MAAa,gBAAgB;IAC3B,MAAM,CAAC,iBAAiB,CACtB,UAA2B;QAE3B,OAAO,kBAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IAClD,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,UAA2B;QAC9C,MAAM,gBAAgB,GAAG,kBAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC1D,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE;YAC7B,sBAAM,CAAC,IAAI,CACT,+BAA+B,EAC/B,0BAA0B,EAC1B,gBAAgB,CAAC,KAAK,CAAC,MAAM,EAAE,CAChC,CAAC;YACF,MAAM,IAAI,KAAK,CACb,yIAAyI,gBAAgB,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAC3K,CAAC;SACH;QACD,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC,IAAI,CAAC;QAEvE,qCACE,EAAE;YACF,IAAI,IACD,CAAC,QAAQ;YACV,CAAC,CAAC;gBACE,QAAQ;aACT;YACH,CAAC,CAAC,EAAE,CAAC,KACP,iBAAiB,EAAE,MAAM,CAAC,OAAO,EACjC,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC5D,KAAK;gBACL,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACrE,GAAG,EAAE,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;aACxE,CAAC,CAAC,EACH,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;gBAC9C,OAAO;oBACL,QAAQ,EAAE,SAAS,CAAC,QAAQ;oBAC5B,QAAQ,EAAE,SAAS,CAAC,QAAQ;yBACzB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;wBACf,IAAI,OAAO,CAAC,MAAM,EAAE;4BAClB,OAAO,OAAO,CAAC;yBAChB;wBAED,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,CACnC,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CACzD,CAAC;wBAEF,IAAI,CAAC,eAAe,EAAE;4BACpB,OAAO,IAAI,CAAC;yBACb;wBAED,OAAO,eAAe,CAAC;oBACzB,CAAC,CAAC;yBACD,MAAM,CAAC,CAAC,OAAO,EAAsB,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC;iBAC7D,CAAC;YACJ,CAAC,CAAC,IACF;IACJ,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,UAA2B;QAE3B,OAAO,kBAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IAClD,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,UAA2B;QAC9C,OAAO,gBAAgB,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC;CACF;AArED,4CAqEC"}
|