codebase-models 3.2.0 → 3.2.1
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 +2 -0
- package/dist/src/models/Audience.js +14 -18
- 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 +18 -23
- package/src/models/PageTestType.ts +22 -0
- package/src/models/Test.ts +27 -12
|
@@ -32,6 +32,8 @@ export interface IAudienceCondition extends Document {
|
|
|
32
32
|
}
|
|
33
33
|
export interface IAudienceConditionItem extends Document {
|
|
34
34
|
iid: string;
|
|
35
|
+
type: string;
|
|
36
|
+
metadata: mongoose.Schema.Types.Mixed;
|
|
35
37
|
rules_js: string;
|
|
36
38
|
rules_label: string;
|
|
37
39
|
conditionGroupLabel: string;
|
|
@@ -41,19 +41,29 @@ const conditionItemSchema = new mongoose_1.Schema({
|
|
|
41
41
|
default: () => (0, constant_1.generateRandomIID)(),
|
|
42
42
|
unique: true,
|
|
43
43
|
},
|
|
44
|
+
type: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "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: {
|
|
@@ -66,20 +76,6 @@ const conditionItemSchema = new mongoose_1.Schema({
|
|
|
66
76
|
},
|
|
67
77
|
});
|
|
68
78
|
conditionItemSchema.index({ iid: 1 }, { unique: true });
|
|
69
|
-
const AudienceConditionSchema = new mongoose_1.Schema({
|
|
70
|
-
iid: {
|
|
71
|
-
type: String,
|
|
72
|
-
trim: true,
|
|
73
|
-
default: () => (0, constant_1.generateRandomIID)(),
|
|
74
|
-
unique: true,
|
|
75
|
-
},
|
|
76
|
-
name: {
|
|
77
|
-
type: String,
|
|
78
|
-
required: true,
|
|
79
|
-
trim: true,
|
|
80
|
-
},
|
|
81
|
-
conditions: [conditionItemSchema],
|
|
82
|
-
});
|
|
83
79
|
const AudienceSchema = new mongoose_1.Schema({
|
|
84
80
|
iid: {
|
|
85
81
|
type: String,
|
|
@@ -112,7 +108,7 @@ const AudienceSchema = new mongoose_1.Schema({
|
|
|
112
108
|
unique: true,
|
|
113
109
|
trim: true,
|
|
114
110
|
},
|
|
115
|
-
conditions:
|
|
111
|
+
conditions: [conditionItemSchema],
|
|
116
112
|
client: {
|
|
117
113
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
118
114
|
ref: "client",
|
|
@@ -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
|
@@ -11,6 +11,8 @@ export interface IAudienceCondition extends Document {
|
|
|
11
11
|
|
|
12
12
|
export interface IAudienceConditionItem extends Document {
|
|
13
13
|
iid: string;
|
|
14
|
+
type: string;
|
|
15
|
+
metadata: mongoose.Schema.Types.Mixed;
|
|
14
16
|
rules_js: string;
|
|
15
17
|
rules_label: string;
|
|
16
18
|
conditionGroupLabel: string;
|
|
@@ -39,26 +41,36 @@ const conditionItemSchema = new Schema<IAudienceConditionItem>(
|
|
|
39
41
|
default: () => generateRandomIID(),
|
|
40
42
|
unique: true,
|
|
41
43
|
},
|
|
44
|
+
type: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "js_code",
|
|
47
|
+
trim: true,
|
|
48
|
+
enum: ["js_code", "url_param", "cookie", "header", "user_agent", "location", "local_storage", "session_storage", "query_param"],
|
|
49
|
+
},
|
|
42
50
|
rules_js: {
|
|
43
51
|
type: String,
|
|
44
|
-
default: "",
|
|
52
|
+
default: "return true",
|
|
45
53
|
trim: true,
|
|
46
54
|
},
|
|
47
55
|
rules_label: {
|
|
48
56
|
type: String,
|
|
49
|
-
default: "",
|
|
57
|
+
default: "Custom",
|
|
50
58
|
trim: true,
|
|
51
59
|
},
|
|
60
|
+
metadata: {
|
|
61
|
+
type: mongoose.Schema.Types.Mixed,
|
|
62
|
+
default: null,
|
|
63
|
+
},
|
|
52
64
|
rules_value: {
|
|
53
65
|
type: String,
|
|
54
|
-
default: "
|
|
66
|
+
default: "Custom",
|
|
55
67
|
trim: true,
|
|
56
68
|
},
|
|
57
69
|
conditionGroupLabel: {
|
|
58
70
|
type: String,
|
|
59
71
|
default: "advanced",
|
|
60
72
|
trim: true,
|
|
61
|
-
enum: ["advanced", "custom","common"],
|
|
73
|
+
enum: ["advanced", "custom", "common"],
|
|
62
74
|
get: (value: string) => value.toLowerCase(),
|
|
63
75
|
set: (value: string) => value.toLowerCase(),
|
|
64
76
|
},
|
|
@@ -67,23 +79,6 @@ const conditionItemSchema = new Schema<IAudienceConditionItem>(
|
|
|
67
79
|
|
|
68
80
|
conditionItemSchema.index({ iid: 1 }, { unique: true });
|
|
69
81
|
|
|
70
|
-
const AudienceConditionSchema = new Schema<IAudienceCondition>(
|
|
71
|
-
{
|
|
72
|
-
iid: {
|
|
73
|
-
type: String,
|
|
74
|
-
trim: true,
|
|
75
|
-
default: () => generateRandomIID(),
|
|
76
|
-
unique: true,
|
|
77
|
-
},
|
|
78
|
-
name: {
|
|
79
|
-
type: String,
|
|
80
|
-
required: true,
|
|
81
|
-
trim: true,
|
|
82
|
-
},
|
|
83
|
-
conditions: [conditionItemSchema],
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
|
|
87
82
|
const AudienceSchema = new Schema<IAudience>(
|
|
88
83
|
{
|
|
89
84
|
iid: {
|
|
@@ -117,7 +112,7 @@ const AudienceSchema = new Schema<IAudience>(
|
|
|
117
112
|
unique: true,
|
|
118
113
|
trim: true,
|
|
119
114
|
},
|
|
120
|
-
conditions:
|
|
115
|
+
conditions: [conditionItemSchema],
|
|
121
116
|
client: {
|
|
122
117
|
type: mongoose.Schema.Types.ObjectId,
|
|
123
118
|
ref: "client",
|
|
@@ -133,7 +128,7 @@ const AudienceSchema = new Schema<IAudience>(
|
|
|
133
128
|
}
|
|
134
129
|
);
|
|
135
130
|
|
|
136
|
-
AudienceSchema.pre('save', async function(next) {
|
|
131
|
+
AudienceSchema.pre('save', async function (next) {
|
|
137
132
|
if (!this.iid) {
|
|
138
133
|
let unique = false;
|
|
139
134
|
while (!unique) {
|
|
@@ -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
|
@@ -23,12 +23,9 @@ 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
30
|
metadata_1: mongoose.Schema.Types.Mixed;
|
|
34
31
|
metadata_2: mongoose.Schema.Types.Mixed;
|
|
@@ -36,16 +33,22 @@ export interface ITest extends Document {
|
|
|
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 },
|