@ninetailed/experience.js-utils 2.2.0-beta.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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # utils-javascript
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build utils-javascript` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test utils-javascript` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@ninetailed/experience.js-utils",
3
+ "version": "2.2.0-beta.0",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "typings": "./src/index.d.ts"
7
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { ExperienceMapper } from './lib';
2
+ export { Experience, Experiment, Audience, Config, Variant } from './types';
package/src/index.js ADDED
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,267 @@
1
+ import { ExperienceConfiguration } from '@ninetailed/experience.js';
2
+ import { z } from 'zod';
3
+ declare const ExperienceEntry: z.ZodObject<{
4
+ id: z.ZodString;
5
+ type: z.ZodUnion<[z.ZodLiteral<"nt_experiment">, z.ZodLiteral<"nt_personalization">]>;
6
+ variants: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
7
+ id: z.ZodString;
8
+ }, "passthrough", z.ZodTypeAny, {
9
+ id: string;
10
+ }, {
11
+ id: string;
12
+ }>, "many">>>;
13
+ name: z.ZodString;
14
+ config: z.ZodOptional<z.ZodDefault<z.ZodObject<{
15
+ distribution: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
16
+ traffic: z.ZodDefault<z.ZodNumber>;
17
+ components: z.ZodDefault<z.ZodArray<z.ZodObject<{
18
+ baseline: z.ZodObject<{
19
+ id: z.ZodDefault<z.ZodString>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ id: string;
22
+ }, {
23
+ id?: string | undefined;
24
+ }>;
25
+ variants: z.ZodArray<z.ZodObject<{
26
+ id: z.ZodDefault<z.ZodString>;
27
+ hidden: z.ZodDefault<z.ZodBoolean>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ id: string;
30
+ hidden: boolean;
31
+ }, {
32
+ id?: string | undefined;
33
+ hidden?: boolean | undefined;
34
+ }>, "many">;
35
+ }, "strip", z.ZodTypeAny, {
36
+ baseline: {
37
+ id: string;
38
+ };
39
+ variants: {
40
+ id: string;
41
+ hidden: boolean;
42
+ }[];
43
+ }, {
44
+ baseline: {
45
+ id?: string | undefined;
46
+ };
47
+ variants: {
48
+ id?: string | undefined;
49
+ hidden?: boolean | undefined;
50
+ }[];
51
+ }>, "many">>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ distribution: number[];
54
+ traffic: number;
55
+ components: {
56
+ baseline: {
57
+ id: string;
58
+ };
59
+ variants: {
60
+ id: string;
61
+ hidden: boolean;
62
+ }[];
63
+ }[];
64
+ }, {
65
+ distribution?: number[] | undefined;
66
+ traffic?: number | undefined;
67
+ components?: {
68
+ baseline: {
69
+ id?: string | undefined;
70
+ };
71
+ variants: {
72
+ id?: string | undefined;
73
+ hidden?: boolean | undefined;
74
+ }[];
75
+ }[] | undefined;
76
+ }>>>;
77
+ audience: z.ZodNullable<z.ZodOptional<z.ZodObject<{
78
+ id: z.ZodString;
79
+ }, "strip", z.ZodTypeAny, {
80
+ id: string;
81
+ }, {
82
+ id: string;
83
+ }>>>;
84
+ }, "strip", z.ZodTypeAny, {
85
+ variants?: {
86
+ id: string;
87
+ }[] | undefined;
88
+ config?: {
89
+ distribution: number[];
90
+ traffic: number;
91
+ components: {
92
+ baseline: {
93
+ id: string;
94
+ };
95
+ variants: {
96
+ id: string;
97
+ hidden: boolean;
98
+ }[];
99
+ }[];
100
+ } | undefined;
101
+ audience?: {
102
+ id: string;
103
+ } | null | undefined;
104
+ id: string;
105
+ type: "nt_experiment" | "nt_personalization";
106
+ name: string;
107
+ }, {
108
+ variants?: {
109
+ id: string;
110
+ }[] | undefined;
111
+ config?: {
112
+ distribution?: number[] | undefined;
113
+ traffic?: number | undefined;
114
+ components?: {
115
+ baseline: {
116
+ id?: string | undefined;
117
+ };
118
+ variants: {
119
+ id?: string | undefined;
120
+ hidden?: boolean | undefined;
121
+ }[];
122
+ }[] | undefined;
123
+ } | undefined;
124
+ audience?: {
125
+ id: string;
126
+ } | null | undefined;
127
+ id: string;
128
+ type: "nt_experiment" | "nt_personalization";
129
+ name: string;
130
+ }>;
131
+ declare type ExperienceEntry = z.infer<typeof ExperienceEntry>;
132
+ declare const ExperimentEntry: z.ZodObject<{
133
+ id: z.ZodString;
134
+ type: z.ZodLiteral<"nt_experiment">;
135
+ variants: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
136
+ id: z.ZodString;
137
+ }, "passthrough", z.ZodTypeAny, {
138
+ id: string;
139
+ }, {
140
+ id: string;
141
+ }>, "many">>>;
142
+ name: z.ZodString;
143
+ config: z.ZodOptional<z.ZodDefault<z.ZodObject<{
144
+ distribution: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
145
+ traffic: z.ZodDefault<z.ZodNumber>;
146
+ components: z.ZodDefault<z.ZodArray<z.ZodObject<{
147
+ baseline: z.ZodObject<{
148
+ id: z.ZodDefault<z.ZodString>;
149
+ }, "strip", z.ZodTypeAny, {
150
+ id: string;
151
+ }, {
152
+ id?: string | undefined;
153
+ }>;
154
+ variants: z.ZodArray<z.ZodObject<{
155
+ id: z.ZodDefault<z.ZodString>;
156
+ hidden: z.ZodDefault<z.ZodBoolean>;
157
+ }, "strip", z.ZodTypeAny, {
158
+ id: string;
159
+ hidden: boolean;
160
+ }, {
161
+ id?: string | undefined;
162
+ hidden?: boolean | undefined;
163
+ }>, "many">;
164
+ }, "strip", z.ZodTypeAny, {
165
+ baseline: {
166
+ id: string;
167
+ };
168
+ variants: {
169
+ id: string;
170
+ hidden: boolean;
171
+ }[];
172
+ }, {
173
+ baseline: {
174
+ id?: string | undefined;
175
+ };
176
+ variants: {
177
+ id?: string | undefined;
178
+ hidden?: boolean | undefined;
179
+ }[];
180
+ }>, "many">>;
181
+ }, "strip", z.ZodTypeAny, {
182
+ distribution: number[];
183
+ traffic: number;
184
+ components: {
185
+ baseline: {
186
+ id: string;
187
+ };
188
+ variants: {
189
+ id: string;
190
+ hidden: boolean;
191
+ }[];
192
+ }[];
193
+ }, {
194
+ distribution?: number[] | undefined;
195
+ traffic?: number | undefined;
196
+ components?: {
197
+ baseline: {
198
+ id?: string | undefined;
199
+ };
200
+ variants: {
201
+ id?: string | undefined;
202
+ hidden?: boolean | undefined;
203
+ }[];
204
+ }[] | undefined;
205
+ }>>>;
206
+ audience: z.ZodNullable<z.ZodOptional<z.ZodObject<{
207
+ id: z.ZodString;
208
+ }, "strip", z.ZodTypeAny, {
209
+ id: string;
210
+ }, {
211
+ id: string;
212
+ }>>>;
213
+ }, "strip", z.ZodTypeAny, {
214
+ variants?: {
215
+ id: string;
216
+ }[] | undefined;
217
+ config?: {
218
+ distribution: number[];
219
+ traffic: number;
220
+ components: {
221
+ baseline: {
222
+ id: string;
223
+ };
224
+ variants: {
225
+ id: string;
226
+ hidden: boolean;
227
+ }[];
228
+ }[];
229
+ } | undefined;
230
+ audience?: {
231
+ id: string;
232
+ } | null | undefined;
233
+ id: string;
234
+ type: "nt_experiment";
235
+ name: string;
236
+ }, {
237
+ variants?: {
238
+ id: string;
239
+ }[] | undefined;
240
+ config?: {
241
+ distribution?: number[] | undefined;
242
+ traffic?: number | undefined;
243
+ components?: {
244
+ baseline: {
245
+ id?: string | undefined;
246
+ };
247
+ variants: {
248
+ id?: string | undefined;
249
+ hidden?: boolean | undefined;
250
+ }[];
251
+ }[] | undefined;
252
+ } | undefined;
253
+ audience?: {
254
+ id: string;
255
+ } | null | undefined;
256
+ id: string;
257
+ type: "nt_experiment";
258
+ name: string;
259
+ }>;
260
+ declare type ExperimentEntry = z.infer<typeof ExperimentEntry>;
261
+ export declare class ExperienceMapper {
262
+ static isExperienceEntry(experience: ExperienceEntry): experience is ExperienceEntry;
263
+ static mapExperience(experience: ExperienceEntry): ExperienceConfiguration;
264
+ static isExperimentEntry(experiment: ExperimentEntry): experiment is ExperimentEntry;
265
+ static mapExperiment(experiment: ExperimentEntry): ExperienceConfiguration;
266
+ }
267
+ export {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExperienceMapper = void 0;
4
+ const types_1 = require("../types");
5
+ const ExperienceEntry = types_1.Experience.partial({ config: true, variants: true });
6
+ const ExperimentEntry = types_1.Experiment.partial({ config: true, variants: true });
7
+ class ExperienceMapper {
8
+ static isExperienceEntry(experience) {
9
+ return ExperienceEntry.safeParse(experience).success;
10
+ }
11
+ static mapExperience(experience) {
12
+ const parsedExperience = types_1.Experience.safeParse(experience);
13
+ if (!parsedExperience.success) {
14
+ throw new Error('The Experience Input is not valid. Please filter data first with `ExperienceMapper.isExperienceEntry`.');
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 ExperimentEntry.safeParse(experiment).success;
46
+ }
47
+ static mapExperiment(experiment) {
48
+ return ExperienceMapper.mapExperience(experiment);
49
+ }
50
+ }
51
+ exports.ExperienceMapper = ExperienceMapper;
52
+ //# sourceMappingURL=ExperienceMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExperienceMapper.js","sourceRoot":"","sources":["../../../../../../packages/utils/javascript/src/lib/ExperienceMapper.ts"],"names":[],"mappings":";;;AAGA,oCAAkD;AAElD,MAAM,eAAe,GAAG,kBAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AAG7E,MAAM,eAAe,GAAG,kBAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AAG7E,MAAa,gBAAgB;IAC3B,MAAM,CAAC,iBAAiB,CACtB,UAA2B;QAE3B,OAAO,eAAe,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IACvD,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,MAAM,IAAI,KAAK,CAAC,wGAAwG,CAAC,CAAC;SAC3H;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,eAAe,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IACvD,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,UAA2B;QAC9C,OAAO,gBAAgB,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC;CACF;AA9DD,4CA8DC"}
@@ -0,0 +1 @@
1
+ export { ExperienceMapper } from './ExperienceMapper';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExperienceMapper = void 0;
4
+ var ExperienceMapper_1 = require("./ExperienceMapper");
5
+ Object.defineProperty(exports, "ExperienceMapper", { enumerable: true, get: function () { return ExperienceMapper_1.ExperienceMapper; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/utils/javascript/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA"}
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export declare const Audience: z.ZodObject<{
3
+ id: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ id: string;
6
+ }, {
7
+ id: string;
8
+ }>;
9
+ export declare type Audience = z.infer<typeof Audience>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Audience = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.Audience = zod_1.z.object({
6
+ id: zod_1.z.string(),
7
+ });
8
+ //# sourceMappingURL=Audience.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Audience.js","sourceRoot":"","sources":["../../../../../../packages/utils/javascript/src/types/Audience.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,QAAQ,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/B,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;CACf,CAAC,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ export declare const Config: z.ZodObject<{
3
+ distribution: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
4
+ traffic: z.ZodDefault<z.ZodNumber>;
5
+ components: z.ZodDefault<z.ZodArray<z.ZodObject<{
6
+ baseline: z.ZodObject<{
7
+ id: z.ZodDefault<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ id: string;
10
+ }, {
11
+ id?: string | undefined;
12
+ }>;
13
+ variants: z.ZodArray<z.ZodObject<{
14
+ id: z.ZodDefault<z.ZodString>;
15
+ hidden: z.ZodDefault<z.ZodBoolean>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ id: string;
18
+ hidden: boolean;
19
+ }, {
20
+ id?: string | undefined;
21
+ hidden?: boolean | undefined;
22
+ }>, "many">;
23
+ }, "strip", z.ZodTypeAny, {
24
+ baseline: {
25
+ id: string;
26
+ };
27
+ variants: {
28
+ id: string;
29
+ hidden: boolean;
30
+ }[];
31
+ }, {
32
+ baseline: {
33
+ id?: string | undefined;
34
+ };
35
+ variants: {
36
+ id?: string | undefined;
37
+ hidden?: boolean | undefined;
38
+ }[];
39
+ }>, "many">>;
40
+ }, "strip", z.ZodTypeAny, {
41
+ distribution: number[];
42
+ traffic: number;
43
+ components: {
44
+ baseline: {
45
+ id: string;
46
+ };
47
+ variants: {
48
+ id: string;
49
+ hidden: boolean;
50
+ }[];
51
+ }[];
52
+ }, {
53
+ distribution?: number[] | undefined;
54
+ traffic?: number | undefined;
55
+ components?: {
56
+ baseline: {
57
+ id?: string | undefined;
58
+ };
59
+ variants: {
60
+ id?: string | undefined;
61
+ hidden?: boolean | undefined;
62
+ }[];
63
+ }[] | undefined;
64
+ }>;
65
+ export declare type Config = z.infer<typeof Config>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Config = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.Config = zod_1.z.object({
6
+ distribution: zod_1.z.array(zod_1.z.number()).default([0.5, 0.5]),
7
+ traffic: zod_1.z.number().default(0),
8
+ components: zod_1.z
9
+ .array(zod_1.z.object({
10
+ baseline: zod_1.z.object({
11
+ id: zod_1.z.string().default(''),
12
+ }),
13
+ variants: zod_1.z.array(zod_1.z.object({
14
+ id: zod_1.z.string().default(''),
15
+ hidden: zod_1.z.boolean().default(false),
16
+ })),
17
+ }))
18
+ .default([{ baseline: { id: '' }, variants: [{ id: '', hidden: false }] }]),
19
+ });
20
+ //# sourceMappingURL=Config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.js","sourceRoot":"","sources":["../../../../../../packages/utils/javascript/src/types/Config.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,MAAM,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7B,YAAY,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrD,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9B,UAAU,EAAE,OAAC;SACV,KAAK,CACJ,OAAC,CAAC,MAAM,CAAC;QACP,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC;YACjB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;SAC3B,CAAC;QACF,QAAQ,EAAE,OAAC,CAAC,KAAK,CACf,OAAC,CAAC,MAAM,CAAC;YACP,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1B,MAAM,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;SACnC,CAAC,CACH;KACF,CAAC,CACH;SACA,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;CAC9E,CAAC,CAAC"}
@@ -0,0 +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
+ type: "nt_experiment" | "nt_personalization";
108
+ variants: {
109
+ id: string;
110
+ }[];
111
+ name: string;
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
+ type: "nt_experiment" | "nt_personalization";
147
+ name: string;
148
+ }>;
149
+ export declare type Experience = z.infer<typeof Experience>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Experience = void 0;
4
+ const zod_1 = require("zod");
5
+ const Audience_1 = require("./Audience");
6
+ const Config_1 = require("./Config");
7
+ const Variant_1 = require("./Variant");
8
+ exports.Experience = zod_1.z.object({
9
+ id: zod_1.z.string(),
10
+ /**
11
+ * The name of the experience (Short Text)
12
+ */
13
+ name: zod_1.z.string(),
14
+ /**
15
+ * The type if the experience (nt_experiment | nt_personalization)
16
+ */
17
+ type: zod_1.z.union([zod_1.z.literal('nt_experiment'), zod_1.z.literal('nt_personalization')]),
18
+ /**
19
+ * The config of the experience (JSON)
20
+ */
21
+ config: Config_1.Config.default({}),
22
+ /**
23
+ * The audience of the experience (Audience)
24
+ */
25
+ audience: Audience_1.Audience.optional().nullable(),
26
+ /**
27
+ * All used variants of the experience (References to other Content Types)
28
+ */
29
+ variants: zod_1.z.array(Variant_1.Variant).default([]),
30
+ });
31
+ //# sourceMappingURL=Experience.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Experience.js","sourceRoot":"","sources":["../../../../../../packages/utils/javascript/src/types/Experience.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,yCAAsC;AACtC,qCAAkC;AAClC,uCAAoC;AAEvB,QAAA,UAAU,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd;;OAEG;IACH,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAEhB;;OAEG;IACH,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAE5E;;OAEG;IACH,MAAM,EAAE,eAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAE1B;;OAEG;IACH,QAAQ,EAAE,mBAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAExC;;OAEG;IACH,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,iBAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CACvC,CAAC,CAAC"}
@@ -0,0 +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
+ type: "nt_experiment";
91
+ variants: {
92
+ id: string;
93
+ }[];
94
+ name: string;
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
+ type: "nt_experiment";
130
+ name: string;
131
+ }>;
132
+ export declare type Experiment = z.infer<typeof Experiment>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Experiment = void 0;
4
+ const zod_1 = require("zod");
5
+ const Experience_1 = require("./Experience");
6
+ exports.Experiment = Experience_1.Experience.extend({
7
+ type: zod_1.z.literal('nt_experiment'),
8
+ });
9
+ //# sourceMappingURL=Experiment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Experiment.js","sourceRoot":"","sources":["../../../../../../packages/utils/javascript/src/types/Experiment.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,6CAA0C;AAE7B,QAAA,UAAU,GAAG,uBAAU,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,eAAe,CAAC;CACjC,CAAC,CAAC"}
@@ -0,0 +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>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Variant = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.Variant = zod_1.z
6
+ .object({
7
+ id: zod_1.z.string(),
8
+ })
9
+ .passthrough();
10
+ //# sourceMappingURL=Variant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Variant.js","sourceRoot":"","sources":["../../../../../../packages/utils/javascript/src/types/Variant.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,OAAO,GAAG,OAAC;KACrB,MAAM,CAAC;IACN,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;CACf,CAAC;KACD,WAAW,EAAE,CAAC"}
@@ -0,0 +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';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Config = exports.Variant = exports.Audience = exports.Experiment = exports.Experience = void 0;
4
+ var Experience_1 = require("./Experience");
5
+ Object.defineProperty(exports, "Experience", { enumerable: true, get: function () { return Experience_1.Experience; } });
6
+ var Experiment_1 = require("./Experiment");
7
+ Object.defineProperty(exports, "Experiment", { enumerable: true, get: function () { return Experiment_1.Experiment; } });
8
+ var Audience_1 = require("./Audience");
9
+ Object.defineProperty(exports, "Audience", { enumerable: true, get: function () { return Audience_1.Audience; } });
10
+ var Variant_1 = require("./Variant");
11
+ Object.defineProperty(exports, "Variant", { enumerable: true, get: function () { return Variant_1.Variant; } });
12
+ var Config_1 = require("./Config");
13
+ Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return Config_1.Config; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/utils/javascript/src/types/index.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}