codebase-models 3.2.0 → 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/dist/src/models/Audience.d.ts +21 -0
- package/dist/src/models/Audience.js +47 -8
- package/dist/src/models/Page.d.ts +6 -0
- package/dist/src/models/Page.js +25 -2
- package/dist/src/models/PageTestType.d.ts +4 -0
- package/dist/src/models/PageTestType.js +18 -0
- package/dist/src/models/Test.d.ts +8 -8
- package/dist/src/models/Test.js +15 -3
- package/package.json +1 -1
- package/src/constant.ts +1 -0
- package/src/models/Audience.ts +71 -13
- package/src/models/Page.ts +32 -2
- package/src/models/PageTestType.ts +22 -0
- package/src/models/Test.ts +30 -15
|
@@ -30,8 +30,29 @@ export interface IAudienceCondition extends Document {
|
|
|
30
30
|
conditionGroupLabel: string;
|
|
31
31
|
conditions: IAudienceConditionItem[];
|
|
32
32
|
}
|
|
33
|
+
export interface IConditionItem extends Document {
|
|
34
|
+
iid: string;
|
|
35
|
+
name: string;
|
|
36
|
+
url?: string;
|
|
37
|
+
url_type?: string;
|
|
38
|
+
matchType?: string;
|
|
39
|
+
type?: string;
|
|
40
|
+
metadata?: mongoose.Schema.Types.Mixed;
|
|
41
|
+
rules_js?: string;
|
|
42
|
+
rules_label?: string;
|
|
43
|
+
conditionGroupLabel?: string;
|
|
44
|
+
rules_value?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface IConditionGroup extends Document {
|
|
47
|
+
iid: string;
|
|
48
|
+
name: string;
|
|
49
|
+
matchType: string;
|
|
50
|
+
conditions: IConditionItem[];
|
|
51
|
+
}
|
|
33
52
|
export interface IAudienceConditionItem extends Document {
|
|
34
53
|
iid: string;
|
|
54
|
+
type: string;
|
|
55
|
+
metadata: mongoose.Schema.Types.Mixed;
|
|
35
56
|
rules_js: string;
|
|
36
57
|
rules_label: string;
|
|
37
58
|
conditionGroupLabel: string;
|
|
@@ -34,26 +34,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
36
36
|
const constant_1 = require("../constant");
|
|
37
|
-
const
|
|
37
|
+
const ConditionItemSchema = new mongoose_1.Schema({
|
|
38
38
|
iid: {
|
|
39
39
|
type: String,
|
|
40
40
|
trim: true,
|
|
41
41
|
default: () => (0, constant_1.generateRandomIID)(),
|
|
42
42
|
unique: true,
|
|
43
43
|
},
|
|
44
|
+
type: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "advanced_js_code",
|
|
47
|
+
trim: true,
|
|
48
|
+
// enum: ["js_code", "url_param", "cookie", "header", "user_agent", "location", "local_storage", "session_storage", "query_param"],
|
|
49
|
+
},
|
|
44
50
|
rules_js: {
|
|
45
51
|
type: String,
|
|
46
|
-
default: "",
|
|
52
|
+
default: "return true",
|
|
47
53
|
trim: true,
|
|
48
54
|
},
|
|
49
55
|
rules_label: {
|
|
50
56
|
type: String,
|
|
51
|
-
default: "",
|
|
57
|
+
default: "Custom",
|
|
52
58
|
trim: true,
|
|
53
59
|
},
|
|
60
|
+
metadata: {
|
|
61
|
+
type: mongoose_1.default.Schema.Types.Mixed,
|
|
62
|
+
default: null,
|
|
63
|
+
},
|
|
54
64
|
rules_value: {
|
|
55
65
|
type: String,
|
|
56
|
-
default: "
|
|
66
|
+
default: "Custom",
|
|
57
67
|
trim: true,
|
|
58
68
|
},
|
|
59
69
|
conditionGroupLabel: {
|
|
@@ -65,8 +75,7 @@ const conditionItemSchema = new mongoose_1.Schema({
|
|
|
65
75
|
set: (value) => value.toLowerCase(),
|
|
66
76
|
},
|
|
67
77
|
});
|
|
68
|
-
|
|
69
|
-
const AudienceConditionSchema = new mongoose_1.Schema({
|
|
78
|
+
const conditionGroupSchema = new mongoose_1.Schema({
|
|
70
79
|
iid: {
|
|
71
80
|
type: String,
|
|
72
81
|
trim: true,
|
|
@@ -78,8 +87,38 @@ const AudienceConditionSchema = new mongoose_1.Schema({
|
|
|
78
87
|
required: true,
|
|
79
88
|
trim: true,
|
|
80
89
|
},
|
|
81
|
-
|
|
90
|
+
matchType: {
|
|
91
|
+
type: String,
|
|
92
|
+
required: true,
|
|
93
|
+
trim: true,
|
|
94
|
+
enum: ["AND", "OR"],
|
|
95
|
+
default: "OR",
|
|
96
|
+
},
|
|
97
|
+
conditions: [ConditionItemSchema],
|
|
82
98
|
});
|
|
99
|
+
const ConditionsSchema = new mongoose_1.Schema([
|
|
100
|
+
{
|
|
101
|
+
iid: {
|
|
102
|
+
type: String,
|
|
103
|
+
trim: true,
|
|
104
|
+
default: () => (0, constant_1.generateRandomIID)(),
|
|
105
|
+
unique: true,
|
|
106
|
+
},
|
|
107
|
+
name: {
|
|
108
|
+
type: String,
|
|
109
|
+
required: true,
|
|
110
|
+
trim: true,
|
|
111
|
+
},
|
|
112
|
+
matchType: {
|
|
113
|
+
type: String,
|
|
114
|
+
required: true,
|
|
115
|
+
trim: true,
|
|
116
|
+
enum: ["AND", "OR"],
|
|
117
|
+
default: "AND",
|
|
118
|
+
},
|
|
119
|
+
conditionGroups: [conditionGroupSchema],
|
|
120
|
+
}
|
|
121
|
+
]);
|
|
83
122
|
const AudienceSchema = new mongoose_1.Schema({
|
|
84
123
|
iid: {
|
|
85
124
|
type: String,
|
|
@@ -112,7 +151,7 @@ const AudienceSchema = new mongoose_1.Schema({
|
|
|
112
151
|
unique: true,
|
|
113
152
|
trim: true,
|
|
114
153
|
},
|
|
115
|
-
conditions:
|
|
154
|
+
conditions: [ConditionsSchema],
|
|
116
155
|
client: {
|
|
117
156
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
118
157
|
ref: "client",
|
|
@@ -54,5 +54,11 @@ export interface IPage extends Document {
|
|
|
54
54
|
isActive?: boolean;
|
|
55
55
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
56
56
|
}
|
|
57
|
+
export interface IConditionGroup extends Document {
|
|
58
|
+
iid: string;
|
|
59
|
+
name: string;
|
|
60
|
+
matchType: string;
|
|
61
|
+
conditions: IConditionItem[];
|
|
62
|
+
}
|
|
57
63
|
declare const Page: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
58
64
|
export default Page;
|
package/dist/src/models/Page.js
CHANGED
|
@@ -65,6 +65,27 @@ const ConditionItemSchema = new mongoose_1.Schema({
|
|
|
65
65
|
set: (value) => value.toLowerCase(),
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
+
const conditionGroupSchema = new mongoose_1.Schema({
|
|
69
|
+
iid: {
|
|
70
|
+
type: String,
|
|
71
|
+
trim: true,
|
|
72
|
+
default: () => (0, constant_1.generateRandomIID)(),
|
|
73
|
+
unique: true,
|
|
74
|
+
},
|
|
75
|
+
name: {
|
|
76
|
+
type: String,
|
|
77
|
+
required: true,
|
|
78
|
+
trim: true,
|
|
79
|
+
},
|
|
80
|
+
matchType: {
|
|
81
|
+
type: String,
|
|
82
|
+
required: true,
|
|
83
|
+
trim: true,
|
|
84
|
+
enum: ["AND", "OR"],
|
|
85
|
+
default: "OR",
|
|
86
|
+
},
|
|
87
|
+
conditions: [ConditionItemSchema],
|
|
88
|
+
});
|
|
68
89
|
const ConditionsSchema = new mongoose_1.Schema([
|
|
69
90
|
{
|
|
70
91
|
iid: {
|
|
@@ -78,12 +99,14 @@ const ConditionsSchema = new mongoose_1.Schema([
|
|
|
78
99
|
required: true,
|
|
79
100
|
trim: true,
|
|
80
101
|
},
|
|
81
|
-
|
|
102
|
+
matchType: {
|
|
82
103
|
type: String,
|
|
83
104
|
required: true,
|
|
84
105
|
trim: true,
|
|
106
|
+
enum: ["AND", "OR"],
|
|
107
|
+
default: "AND",
|
|
85
108
|
},
|
|
86
|
-
|
|
109
|
+
conditionGroups: [conditionGroupSchema],
|
|
87
110
|
}
|
|
88
111
|
]);
|
|
89
112
|
const UrltargetingsSchema = new mongoose_1.Schema({
|
|
@@ -30,6 +30,10 @@ export interface IPageTestType extends Document {
|
|
|
30
30
|
createdAt?: Date;
|
|
31
31
|
updatedAt?: Date;
|
|
32
32
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
33
|
+
metadata?: mongoose.Schema.Types.Mixed;
|
|
34
|
+
client?: mongoose.Schema.Types.ObjectId;
|
|
35
|
+
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
36
|
+
generic?: boolean;
|
|
33
37
|
}
|
|
34
38
|
declare const PageTestType: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
35
39
|
export default PageTestType;
|
|
@@ -41,6 +41,24 @@ const PageTestTypeSchema = new mongoose_1.Schema({
|
|
|
41
41
|
default: "",
|
|
42
42
|
trim: true,
|
|
43
43
|
},
|
|
44
|
+
metadata: {
|
|
45
|
+
type: mongoose_1.default.Schema.Types.Mixed,
|
|
46
|
+
default: null,
|
|
47
|
+
},
|
|
48
|
+
client: {
|
|
49
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
50
|
+
ref: "client",
|
|
51
|
+
default: null,
|
|
52
|
+
},
|
|
53
|
+
createdBy: {
|
|
54
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
55
|
+
ref: "user",
|
|
56
|
+
default: null,
|
|
57
|
+
},
|
|
58
|
+
generic: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: true,
|
|
61
|
+
},
|
|
44
62
|
createdAt: {
|
|
45
63
|
type: Date,
|
|
46
64
|
default: new Date(),
|
|
@@ -43,26 +43,26 @@ export interface ITest extends Document {
|
|
|
43
43
|
iid: string;
|
|
44
44
|
status: string;
|
|
45
45
|
name: string;
|
|
46
|
+
test_type: string;
|
|
46
47
|
traffic_allocation_type: string;
|
|
47
48
|
traffic_allocation: number;
|
|
48
|
-
audiences_match_type: string;
|
|
49
|
-
pages_match_type: string;
|
|
50
|
-
page_targeting?: mongoose.Schema.Types.ObjectId;
|
|
51
|
-
audience_targeting?: mongoose.Schema.Types.ObjectId;
|
|
52
49
|
metadata_1: mongoose.Schema.Types.Mixed;
|
|
53
50
|
metadata_2: mongoose.Schema.Types.Mixed;
|
|
54
51
|
metadata_3: mongoose.Schema.Types.Mixed;
|
|
55
52
|
integrations_run_mode: mongoose.Schema.Types.Mixed;
|
|
56
53
|
jscode: string;
|
|
57
|
-
reset_js: string;
|
|
58
54
|
csscode: string;
|
|
59
|
-
|
|
55
|
+
reset_js: string;
|
|
60
56
|
audiences?: mongoose.Schema.Types.ObjectId[];
|
|
57
|
+
pages?: mongoose.Schema.Types.ObjectId[];
|
|
58
|
+
audiences_match_type: string;
|
|
59
|
+
pages_match_type: string;
|
|
60
|
+
page_targeting?: mongoose.Schema.Types.ObjectId;
|
|
61
|
+
audience_targeting?: mongoose.Schema.Types.ObjectId;
|
|
61
62
|
variations: IVariations[];
|
|
62
63
|
environments?: mongoose.Schema.Types.ObjectId[];
|
|
63
|
-
pages?: mongoose.Schema.Types.ObjectId[];
|
|
64
64
|
pageelement?: mongoose.Schema.Types.ObjectId[];
|
|
65
|
-
client
|
|
65
|
+
client: mongoose.Schema.Types.ObjectId;
|
|
66
66
|
goal?: mongoose.Schema.Types.ObjectId[];
|
|
67
67
|
pagetesttype?: mongoose.Schema.Types.ObjectId[];
|
|
68
68
|
tags?: mongoose.Schema.Types.ObjectId[];
|
package/dist/src/models/Test.js
CHANGED
|
@@ -66,8 +66,19 @@ const TestSchema = new mongoose_1.Schema({
|
|
|
66
66
|
enum: ["live", "draft", "ended", "paused", "preview", "running", "archive"],
|
|
67
67
|
transform: (value) => value.toLowerCase(),
|
|
68
68
|
},
|
|
69
|
+
test_type: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: "ab-test",
|
|
72
|
+
// enum: ["A/B", "Multi-Armed", "Contextual"], // add later from codebase-shared-functions
|
|
73
|
+
transform: (value) => value.toLowerCase(),
|
|
74
|
+
},
|
|
69
75
|
name: { type: String, required: true },
|
|
70
|
-
traffic_allocation_type: {
|
|
76
|
+
traffic_allocation_type: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: "manual",
|
|
79
|
+
enum: ["manual", "multi-armed"], // add later from codebase-shared-functions
|
|
80
|
+
transform: (value) => value.toLowerCase(),
|
|
81
|
+
},
|
|
71
82
|
traffic_allocation: { type: Number, default: 100 },
|
|
72
83
|
audiences_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
|
|
73
84
|
pages_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
|
|
@@ -82,7 +93,6 @@ const TestSchema = new mongoose_1.Schema({
|
|
|
82
93
|
jscode: { type: String, default: "" },
|
|
83
94
|
reset_js: { type: String, default: "" },
|
|
84
95
|
csscode: { type: String, default: "" },
|
|
85
|
-
htmlcode: { type: String, default: "" },
|
|
86
96
|
// References with proper refs and defaults
|
|
87
97
|
audiences: {
|
|
88
98
|
type: [mongoose_1.default.Schema.Types.ObjectId],
|
|
@@ -151,7 +161,9 @@ const TestSchema = new mongoose_1.Schema({
|
|
|
151
161
|
pageNotContains: { type: String, default: null },
|
|
152
162
|
eventparameter: { type: String, default: null },
|
|
153
163
|
testid: { type: String, default: null },
|
|
154
|
-
testtool: { type: String,
|
|
164
|
+
testtool: { type: String,
|
|
165
|
+
default: "",
|
|
166
|
+
// enum: toolTypes, // add later from codebase-shared-functions
|
|
155
167
|
transform: (value) => (value === null || value === void 0 ? void 0 : value.toLowerCase()) || "",
|
|
156
168
|
},
|
|
157
169
|
personalization: { type: Boolean, default: false },
|
package/package.json
CHANGED
package/src/constant.ts
CHANGED
package/src/models/Audience.ts
CHANGED
|
@@ -8,9 +8,32 @@ export interface IAudienceCondition extends Document {
|
|
|
8
8
|
conditionGroupLabel: string;
|
|
9
9
|
conditions: IAudienceConditionItem[];
|
|
10
10
|
}
|
|
11
|
+
export interface IConditionItem extends Document {
|
|
12
|
+
iid: string;
|
|
13
|
+
name: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
url_type?: string;
|
|
16
|
+
matchType?: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
metadata?: mongoose.Schema.Types.Mixed;
|
|
19
|
+
rules_js?: string;
|
|
20
|
+
rules_label?: string;
|
|
21
|
+
conditionGroupLabel?: string;
|
|
22
|
+
rules_value?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export interface IConditionGroup extends Document {
|
|
27
|
+
iid: string;
|
|
28
|
+
name: string;
|
|
29
|
+
matchType: string;
|
|
30
|
+
conditions: IConditionItem[];
|
|
31
|
+
}
|
|
11
32
|
|
|
12
33
|
export interface IAudienceConditionItem extends Document {
|
|
13
34
|
iid: string;
|
|
35
|
+
type: string;
|
|
36
|
+
metadata: mongoose.Schema.Types.Mixed;
|
|
14
37
|
rules_js: string;
|
|
15
38
|
rules_label: string;
|
|
16
39
|
conditionGroupLabel: string;
|
|
@@ -31,7 +54,7 @@ export interface IAudience extends Document {
|
|
|
31
54
|
}
|
|
32
55
|
|
|
33
56
|
|
|
34
|
-
const
|
|
57
|
+
const ConditionItemSchema = new Schema<IConditionItem>(
|
|
35
58
|
{
|
|
36
59
|
iid: {
|
|
37
60
|
type: String,
|
|
@@ -39,35 +62,63 @@ const conditionItemSchema = new Schema<IAudienceConditionItem>(
|
|
|
39
62
|
default: () => generateRandomIID(),
|
|
40
63
|
unique: true,
|
|
41
64
|
},
|
|
65
|
+
type: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: "advanced_js_code",
|
|
68
|
+
trim: true,
|
|
69
|
+
// enum: ["js_code", "url_param", "cookie", "header", "user_agent", "location", "local_storage", "session_storage", "query_param"],
|
|
70
|
+
},
|
|
42
71
|
rules_js: {
|
|
43
72
|
type: String,
|
|
44
|
-
default: "",
|
|
73
|
+
default: "return true",
|
|
45
74
|
trim: true,
|
|
46
75
|
},
|
|
47
76
|
rules_label: {
|
|
48
77
|
type: String,
|
|
49
|
-
default: "",
|
|
78
|
+
default: "Custom",
|
|
50
79
|
trim: true,
|
|
51
80
|
},
|
|
81
|
+
metadata: {
|
|
82
|
+
type: mongoose.Schema.Types.Mixed,
|
|
83
|
+
default: null,
|
|
84
|
+
},
|
|
52
85
|
rules_value: {
|
|
53
86
|
type: String,
|
|
54
|
-
default: "
|
|
87
|
+
default: "Custom",
|
|
55
88
|
trim: true,
|
|
56
89
|
},
|
|
57
90
|
conditionGroupLabel: {
|
|
58
91
|
type: String,
|
|
59
92
|
default: "advanced",
|
|
60
93
|
trim: true,
|
|
61
|
-
enum: ["advanced", "custom","common"],
|
|
94
|
+
enum: ["advanced", "custom", "common"],
|
|
62
95
|
get: (value: string) => value.toLowerCase(),
|
|
63
96
|
set: (value: string) => value.toLowerCase(),
|
|
64
97
|
},
|
|
65
98
|
},
|
|
66
99
|
);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
100
|
+
const conditionGroupSchema = new Schema<IConditionGroup>({
|
|
101
|
+
iid: {
|
|
102
|
+
type: String,
|
|
103
|
+
trim: true,
|
|
104
|
+
default: () => generateRandomIID(),
|
|
105
|
+
unique: true,
|
|
106
|
+
},
|
|
107
|
+
name: {
|
|
108
|
+
type: String,
|
|
109
|
+
required: true,
|
|
110
|
+
trim: true,
|
|
111
|
+
},
|
|
112
|
+
matchType: {
|
|
113
|
+
type: String,
|
|
114
|
+
required: true,
|
|
115
|
+
trim: true,
|
|
116
|
+
enum: ["AND", "OR"],
|
|
117
|
+
default: "OR",
|
|
118
|
+
},
|
|
119
|
+
conditions: [ConditionItemSchema],
|
|
120
|
+
});
|
|
121
|
+
const ConditionsSchema = new Schema<IConditionItem[]>([
|
|
71
122
|
{
|
|
72
123
|
iid: {
|
|
73
124
|
type: String,
|
|
@@ -80,9 +131,16 @@ const AudienceConditionSchema = new Schema<IAudienceCondition>(
|
|
|
80
131
|
required: true,
|
|
81
132
|
trim: true,
|
|
82
133
|
},
|
|
83
|
-
|
|
134
|
+
matchType: {
|
|
135
|
+
type: String,
|
|
136
|
+
required: true,
|
|
137
|
+
trim: true,
|
|
138
|
+
enum: ["AND", "OR"],
|
|
139
|
+
default: "AND",
|
|
140
|
+
},
|
|
141
|
+
conditionGroups: [conditionGroupSchema],
|
|
84
142
|
}
|
|
85
|
-
);
|
|
143
|
+
]);
|
|
86
144
|
|
|
87
145
|
const AudienceSchema = new Schema<IAudience>(
|
|
88
146
|
{
|
|
@@ -117,7 +175,7 @@ const AudienceSchema = new Schema<IAudience>(
|
|
|
117
175
|
unique: true,
|
|
118
176
|
trim: true,
|
|
119
177
|
},
|
|
120
|
-
conditions:
|
|
178
|
+
conditions: [ConditionsSchema],
|
|
121
179
|
client: {
|
|
122
180
|
type: mongoose.Schema.Types.ObjectId,
|
|
123
181
|
ref: "client",
|
|
@@ -133,7 +191,7 @@ const AudienceSchema = new Schema<IAudience>(
|
|
|
133
191
|
}
|
|
134
192
|
);
|
|
135
193
|
|
|
136
|
-
AudienceSchema.pre('save', async function(next) {
|
|
194
|
+
AudienceSchema.pre('save', async function (next) {
|
|
137
195
|
if (!this.iid) {
|
|
138
196
|
let unique = false;
|
|
139
197
|
while (!unique) {
|
package/src/models/Page.ts
CHANGED
|
@@ -67,6 +67,34 @@ const ConditionItemSchema = new Schema<IConditionItem>({
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
+
export interface IConditionGroup extends Document {
|
|
71
|
+
iid: string;
|
|
72
|
+
name: string;
|
|
73
|
+
matchType: string;
|
|
74
|
+
conditions: IConditionItem[];
|
|
75
|
+
}
|
|
76
|
+
const conditionGroupSchema = new Schema<IConditionGroup>({
|
|
77
|
+
iid: {
|
|
78
|
+
type: String,
|
|
79
|
+
trim: true,
|
|
80
|
+
default: () => generateRandomIID(),
|
|
81
|
+
unique: true,
|
|
82
|
+
},
|
|
83
|
+
name: {
|
|
84
|
+
type: String,
|
|
85
|
+
required: true,
|
|
86
|
+
trim: true,
|
|
87
|
+
},
|
|
88
|
+
matchType: {
|
|
89
|
+
type: String,
|
|
90
|
+
required: true,
|
|
91
|
+
trim: true,
|
|
92
|
+
enum: ["AND", "OR"],
|
|
93
|
+
default: "OR",
|
|
94
|
+
},
|
|
95
|
+
conditions: [ConditionItemSchema],
|
|
96
|
+
});
|
|
97
|
+
|
|
70
98
|
const ConditionsSchema = new Schema<IConditionItem[]>([
|
|
71
99
|
{
|
|
72
100
|
iid: {
|
|
@@ -80,12 +108,14 @@ const ConditionsSchema = new Schema<IConditionItem[]>([
|
|
|
80
108
|
required: true,
|
|
81
109
|
trim: true,
|
|
82
110
|
},
|
|
83
|
-
|
|
111
|
+
matchType: {
|
|
84
112
|
type: String,
|
|
85
113
|
required: true,
|
|
86
114
|
trim: true,
|
|
115
|
+
enum: ["AND", "OR"],
|
|
116
|
+
default: "AND",
|
|
87
117
|
},
|
|
88
|
-
|
|
118
|
+
conditionGroups: [conditionGroupSchema],
|
|
89
119
|
}
|
|
90
120
|
]);
|
|
91
121
|
|
|
@@ -7,6 +7,10 @@ export interface IPageTestType extends Document {
|
|
|
7
7
|
createdAt?: Date;
|
|
8
8
|
updatedAt?: Date;
|
|
9
9
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
10
|
+
metadata?: mongoose.Schema.Types.Mixed;
|
|
11
|
+
client?: mongoose.Schema.Types.ObjectId;
|
|
12
|
+
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
13
|
+
generic?: boolean;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
const PageTestTypeSchema = new Schema<IPageTestType>({
|
|
@@ -26,6 +30,24 @@ const PageTestTypeSchema = new Schema<IPageTestType>({
|
|
|
26
30
|
default: "",
|
|
27
31
|
trim: true,
|
|
28
32
|
},
|
|
33
|
+
metadata: {
|
|
34
|
+
type: mongoose.Schema.Types.Mixed,
|
|
35
|
+
default: null,
|
|
36
|
+
},
|
|
37
|
+
client: {
|
|
38
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
39
|
+
ref: "client",
|
|
40
|
+
default: null,
|
|
41
|
+
},
|
|
42
|
+
createdBy: {
|
|
43
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
44
|
+
ref: "user",
|
|
45
|
+
default: null,
|
|
46
|
+
},
|
|
47
|
+
generic: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: true,
|
|
50
|
+
},
|
|
29
51
|
createdAt: {
|
|
30
52
|
type: Date,
|
|
31
53
|
default: new Date(),
|
package/src/models/Test.ts
CHANGED
|
@@ -7,8 +7,8 @@ export interface IVariations extends Document {
|
|
|
7
7
|
css_code: string;
|
|
8
8
|
baseline: boolean;
|
|
9
9
|
traffic_allocation: number;
|
|
10
|
-
metadata_1: mongoose.Schema.Types.Mixed;
|
|
11
|
-
metadata_2: mongoose.Schema.Types.Mixed;
|
|
10
|
+
metadata_1: mongoose.Schema.Types.Mixed; // use to store redirect url settings
|
|
11
|
+
metadata_2: mongoose.Schema.Types.Mixed; // use to store screenshots and other metadata
|
|
12
12
|
metadata_3: mongoose.Schema.Types.Mixed;
|
|
13
13
|
jscode: string;
|
|
14
14
|
reset_js: string;
|
|
@@ -23,29 +23,32 @@ export interface ITest extends Document {
|
|
|
23
23
|
iid: string;
|
|
24
24
|
status: string;
|
|
25
25
|
name: string;
|
|
26
|
+
test_type: string; // possible values: A/B, Multi-Armed, Contextual
|
|
26
27
|
traffic_allocation_type: string;
|
|
27
28
|
traffic_allocation: number;
|
|
28
|
-
audiences_match_type: string;
|
|
29
|
-
pages_match_type: string;
|
|
30
|
-
page_targeting?: mongoose.Schema.Types.ObjectId;
|
|
31
|
-
audience_targeting?: mongoose.Schema.Types.ObjectId;
|
|
32
29
|
// Metadata fields
|
|
33
|
-
metadata_1: mongoose.Schema.Types.Mixed;
|
|
30
|
+
metadata_1: mongoose.Schema.Types.Mixed; // used to store test description and other metadata
|
|
34
31
|
metadata_2: mongoose.Schema.Types.Mixed;
|
|
35
32
|
metadata_3: mongoose.Schema.Types.Mixed;
|
|
36
33
|
integrations_run_mode: mongoose.Schema.Types.Mixed;
|
|
37
34
|
// Code fields
|
|
38
35
|
jscode: string;
|
|
39
|
-
reset_js: string;
|
|
40
36
|
csscode: string;
|
|
41
|
-
|
|
37
|
+
reset_js: string;
|
|
42
38
|
// References
|
|
39
|
+
// old schema audiences and pages
|
|
43
40
|
audiences?: mongoose.Schema.Types.ObjectId[];
|
|
41
|
+
pages?: mongoose.Schema.Types.ObjectId[];
|
|
42
|
+
audiences_match_type: string; // possible values: AND, OR, any, all
|
|
43
|
+
pages_match_type: string; // possible values: AND, OR, any, all
|
|
44
|
+
// new schema page_targeting and audience_targeting
|
|
45
|
+
page_targeting?: mongoose.Schema.Types.ObjectId;
|
|
46
|
+
audience_targeting?: mongoose.Schema.Types.ObjectId;
|
|
47
|
+
|
|
44
48
|
variations: IVariations[];
|
|
45
49
|
environments?: mongoose.Schema.Types.ObjectId[];
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
client?: mongoose.Schema.Types.ObjectId;
|
|
50
|
+
pageelement?: mongoose.Schema.Types.ObjectId[]; // tells about the page type or element type where test is targeted
|
|
51
|
+
client: mongoose.Schema.Types.ObjectId;
|
|
49
52
|
goal?: mongoose.Schema.Types.ObjectId[];
|
|
50
53
|
pagetesttype?: mongoose.Schema.Types.ObjectId[];
|
|
51
54
|
tags?: mongoose.Schema.Types.ObjectId[];
|
|
@@ -118,8 +121,19 @@ const TestSchema = new Schema<ITest>(
|
|
|
118
121
|
enum: ["live", "draft", "ended", "paused", "preview", "running", "archive"],
|
|
119
122
|
transform: (value: string) => value.toLowerCase(),
|
|
120
123
|
},
|
|
124
|
+
test_type: {
|
|
125
|
+
type: String,
|
|
126
|
+
default: "ab-test",
|
|
127
|
+
// enum: ["A/B", "Multi-Armed", "Contextual"], // add later from codebase-shared-functions
|
|
128
|
+
transform: (value: string) => value.toLowerCase(),
|
|
129
|
+
},
|
|
121
130
|
name: { type: String, required: true },
|
|
122
|
-
traffic_allocation_type: {
|
|
131
|
+
traffic_allocation_type: {
|
|
132
|
+
type: String,
|
|
133
|
+
default: "manual",
|
|
134
|
+
enum: ["manual", "multi-armed"], // add later from codebase-shared-functions
|
|
135
|
+
transform: (value: string) => value.toLowerCase(),
|
|
136
|
+
},
|
|
123
137
|
traffic_allocation: { type: Number, default: 100 },
|
|
124
138
|
audiences_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
|
|
125
139
|
pages_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
|
|
@@ -135,7 +149,6 @@ const TestSchema = new Schema<ITest>(
|
|
|
135
149
|
jscode: { type: String, default: "" },
|
|
136
150
|
reset_js: { type: String, default: "" },
|
|
137
151
|
csscode: { type: String, default: "" },
|
|
138
|
-
htmlcode: { type: String, default: "" },
|
|
139
152
|
|
|
140
153
|
// References with proper refs and defaults
|
|
141
154
|
audiences: {
|
|
@@ -206,7 +219,9 @@ const TestSchema = new Schema<ITest>(
|
|
|
206
219
|
pageNotContains: { type: String, default: null },
|
|
207
220
|
eventparameter: { type: String, default: null },
|
|
208
221
|
testid: { type: String, default: null },
|
|
209
|
-
testtool: { type: String,
|
|
222
|
+
testtool: { type: String,
|
|
223
|
+
default: "",
|
|
224
|
+
// enum: toolTypes, // add later from codebase-shared-functions
|
|
210
225
|
transform: (value: string) => value?.toLowerCase() || "",
|
|
211
226
|
},
|
|
212
227
|
personalization: { type: Boolean, default: false },
|