codebase-models 3.1.9 → 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 +19 -0
- package/dist/src/models/Audience.js +54 -0
- package/dist/src/models/Page.d.ts +9 -0
- package/dist/src/models/Page.js +55 -0
- 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 -5
- package/dist/src/models/Test.js +25 -7
- package/package.json +1 -1
- package/src/constant.ts +1 -0
- package/src/models/Audience.ts +81 -1
- package/src/models/Page.ts +68 -1
- package/src/models/PageTestType.ts +22 -0
- package/src/models/Test.ts +86 -62
|
@@ -23,14 +23,33 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
|
+
export interface IAudienceCondition extends Document {
|
|
27
|
+
iid: string;
|
|
28
|
+
name: string;
|
|
29
|
+
conditionType: string;
|
|
30
|
+
conditionGroupLabel: string;
|
|
31
|
+
conditions: IAudienceConditionItem[];
|
|
32
|
+
}
|
|
33
|
+
export interface IAudienceConditionItem extends Document {
|
|
34
|
+
iid: string;
|
|
35
|
+
type: string;
|
|
36
|
+
metadata: mongoose.Schema.Types.Mixed;
|
|
37
|
+
rules_js: string;
|
|
38
|
+
rules_label: string;
|
|
39
|
+
conditionGroupLabel: string;
|
|
40
|
+
rules_value: string;
|
|
41
|
+
}
|
|
26
42
|
export interface IAudience extends Document {
|
|
27
43
|
iid: string;
|
|
28
44
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
45
|
+
newSchema: boolean;
|
|
29
46
|
name: string;
|
|
30
47
|
rules_js?: string;
|
|
31
48
|
generic: boolean;
|
|
32
49
|
client?: mongoose.Schema.Types.ObjectId;
|
|
33
50
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
51
|
+
conditions: IAudienceConditionItem[];
|
|
52
|
+
api_name: string;
|
|
34
53
|
}
|
|
35
54
|
declare const Audience: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
36
55
|
export default Audience;
|
|
@@ -34,6 +34,48 @@ 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 conditionItemSchema = new mongoose_1.Schema({
|
|
38
|
+
iid: {
|
|
39
|
+
type: String,
|
|
40
|
+
trim: true,
|
|
41
|
+
default: () => (0, constant_1.generateRandomIID)(),
|
|
42
|
+
unique: true,
|
|
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
|
+
},
|
|
50
|
+
rules_js: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: "return true",
|
|
53
|
+
trim: true,
|
|
54
|
+
},
|
|
55
|
+
rules_label: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: "Custom",
|
|
58
|
+
trim: true,
|
|
59
|
+
},
|
|
60
|
+
metadata: {
|
|
61
|
+
type: mongoose_1.default.Schema.Types.Mixed,
|
|
62
|
+
default: null,
|
|
63
|
+
},
|
|
64
|
+
rules_value: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: "Custom",
|
|
67
|
+
trim: true,
|
|
68
|
+
},
|
|
69
|
+
conditionGroupLabel: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: "advanced",
|
|
72
|
+
trim: true,
|
|
73
|
+
enum: ["advanced", "custom", "common"],
|
|
74
|
+
get: (value) => value.toLowerCase(),
|
|
75
|
+
set: (value) => value.toLowerCase(),
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
conditionItemSchema.index({ iid: 1 }, { unique: true });
|
|
37
79
|
const AudienceSchema = new mongoose_1.Schema({
|
|
38
80
|
iid: {
|
|
39
81
|
type: String,
|
|
@@ -44,6 +86,10 @@ const AudienceSchema = new mongoose_1.Schema({
|
|
|
44
86
|
ref: "organization",
|
|
45
87
|
default: null,
|
|
46
88
|
},
|
|
89
|
+
newSchema: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: false,
|
|
92
|
+
},
|
|
47
93
|
name: {
|
|
48
94
|
type: String,
|
|
49
95
|
required: true,
|
|
@@ -55,6 +101,14 @@ const AudienceSchema = new mongoose_1.Schema({
|
|
|
55
101
|
type: Boolean,
|
|
56
102
|
default: false,
|
|
57
103
|
},
|
|
104
|
+
api_name: {
|
|
105
|
+
type: String,
|
|
106
|
+
slug: ["name"],
|
|
107
|
+
slugPaddingSize: 4,
|
|
108
|
+
unique: true,
|
|
109
|
+
trim: true,
|
|
110
|
+
},
|
|
111
|
+
conditions: [conditionItemSchema],
|
|
58
112
|
client: {
|
|
59
113
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
60
114
|
ref: "client",
|
|
@@ -29,9 +29,17 @@ export interface IUrltargetings extends Document {
|
|
|
29
29
|
url: string;
|
|
30
30
|
url_type: string;
|
|
31
31
|
}
|
|
32
|
+
export interface IConditionItem extends Document {
|
|
33
|
+
iid: string;
|
|
34
|
+
name: string;
|
|
35
|
+
url?: string;
|
|
36
|
+
url_type?: string;
|
|
37
|
+
matchType?: string;
|
|
38
|
+
}
|
|
32
39
|
export interface IPage extends Document {
|
|
33
40
|
iid: string;
|
|
34
41
|
name: string;
|
|
42
|
+
newSchema: boolean;
|
|
35
43
|
client?: mongoose.Schema.Types.ObjectId;
|
|
36
44
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
37
45
|
trigger: string;
|
|
@@ -41,6 +49,7 @@ export interface IPage extends Document {
|
|
|
41
49
|
deactivation_mode: string;
|
|
42
50
|
rules_js: string;
|
|
43
51
|
urltargetings: IUrltargetings[];
|
|
52
|
+
conditions: IConditionItem[];
|
|
44
53
|
generic: boolean;
|
|
45
54
|
isActive?: boolean;
|
|
46
55
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
package/dist/src/models/Page.js
CHANGED
|
@@ -39,6 +39,53 @@ const mongoose_1 = __importStar(require("mongoose"));
|
|
|
39
39
|
const mongoose_slug_updater_1 = __importDefault(require("mongoose-slug-updater"));
|
|
40
40
|
const constant_1 = require("../constant");
|
|
41
41
|
mongoose_1.default.plugin(mongoose_slug_updater_1.default);
|
|
42
|
+
const ConditionItemSchema = new mongoose_1.Schema({
|
|
43
|
+
iid: {
|
|
44
|
+
type: String,
|
|
45
|
+
trim: true,
|
|
46
|
+
default: () => (0, constant_1.generateRandomIID)(),
|
|
47
|
+
unique: true,
|
|
48
|
+
},
|
|
49
|
+
url: {
|
|
50
|
+
type: String,
|
|
51
|
+
required: true,
|
|
52
|
+
trim: true,
|
|
53
|
+
},
|
|
54
|
+
url_type: {
|
|
55
|
+
type: String,
|
|
56
|
+
required: true,
|
|
57
|
+
trim: true,
|
|
58
|
+
},
|
|
59
|
+
matchType: {
|
|
60
|
+
type: String,
|
|
61
|
+
required: true,
|
|
62
|
+
trim: true,
|
|
63
|
+
enum: ["include", "exclude"],
|
|
64
|
+
get: (value) => value.toLowerCase(),
|
|
65
|
+
set: (value) => value.toLowerCase(),
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const ConditionsSchema = new mongoose_1.Schema([
|
|
69
|
+
{
|
|
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
|
+
conditionType: {
|
|
82
|
+
type: String,
|
|
83
|
+
required: true,
|
|
84
|
+
trim: true,
|
|
85
|
+
},
|
|
86
|
+
conditions: [ConditionItemSchema],
|
|
87
|
+
}
|
|
88
|
+
]);
|
|
42
89
|
const UrltargetingsSchema = new mongoose_1.Schema({
|
|
43
90
|
iid: {
|
|
44
91
|
type: String,
|
|
@@ -65,6 +112,10 @@ const PageSchema = new mongoose_1.Schema({
|
|
|
65
112
|
type: String,
|
|
66
113
|
trim: true,
|
|
67
114
|
},
|
|
115
|
+
newSchema: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
default: false,
|
|
118
|
+
},
|
|
68
119
|
name: {
|
|
69
120
|
type: String,
|
|
70
121
|
required: true,
|
|
@@ -104,6 +155,9 @@ const PageSchema = new mongoose_1.Schema({
|
|
|
104
155
|
type: String,
|
|
105
156
|
default: "reset",
|
|
106
157
|
trim: true,
|
|
158
|
+
// enum: ["reset", "deactivate"],
|
|
159
|
+
get: (value) => value.toLowerCase(),
|
|
160
|
+
set: (value) => value.toLowerCase(),
|
|
107
161
|
},
|
|
108
162
|
rules_js: {
|
|
109
163
|
type: String,
|
|
@@ -111,6 +165,7 @@ const PageSchema = new mongoose_1.Schema({
|
|
|
111
165
|
trim: true,
|
|
112
166
|
},
|
|
113
167
|
urltargetings: [UrltargetingsSchema],
|
|
168
|
+
conditions: [ConditionsSchema],
|
|
114
169
|
generic: {
|
|
115
170
|
type: Boolean,
|
|
116
171
|
default: false,
|
|
@@ -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,23 +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
49
|
metadata_1: mongoose.Schema.Types.Mixed;
|
|
50
50
|
metadata_2: mongoose.Schema.Types.Mixed;
|
|
51
51
|
metadata_3: mongoose.Schema.Types.Mixed;
|
|
52
52
|
integrations_run_mode: mongoose.Schema.Types.Mixed;
|
|
53
53
|
jscode: string;
|
|
54
|
-
reset_js: string;
|
|
55
54
|
csscode: string;
|
|
56
|
-
|
|
55
|
+
reset_js: string;
|
|
57
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;
|
|
58
62
|
variations: IVariations[];
|
|
59
63
|
environments?: mongoose.Schema.Types.ObjectId[];
|
|
60
|
-
pages?: mongoose.Schema.Types.ObjectId[];
|
|
61
64
|
pageelement?: mongoose.Schema.Types.ObjectId[];
|
|
62
|
-
client
|
|
65
|
+
client: mongoose.Schema.Types.ObjectId;
|
|
63
66
|
goal?: mongoose.Schema.Types.ObjectId[];
|
|
64
67
|
pagetesttype?: mongoose.Schema.Types.ObjectId[];
|
|
65
68
|
tags?: mongoose.Schema.Types.ObjectId[];
|
package/dist/src/models/Test.js
CHANGED
|
@@ -35,7 +35,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
35
35
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
36
36
|
const constant_1 = require("../constant");
|
|
37
37
|
const VariationsSchema = new mongoose_1.Schema({
|
|
38
|
-
iid: {
|
|
38
|
+
iid: {
|
|
39
|
+
type: String,
|
|
39
40
|
trim: true,
|
|
40
41
|
unique: true,
|
|
41
42
|
},
|
|
@@ -62,12 +63,27 @@ const TestSchema = new mongoose_1.Schema({
|
|
|
62
63
|
status: {
|
|
63
64
|
type: String,
|
|
64
65
|
default: "draft",
|
|
65
|
-
enum: ["live", "draft", "ended", "paused", "preview", "running", "archive"]
|
|
66
|
+
enum: ["live", "draft", "ended", "paused", "preview", "running", "archive"],
|
|
67
|
+
transform: (value) => value.toLowerCase(),
|
|
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(),
|
|
66
74
|
},
|
|
67
75
|
name: { type: String, required: true },
|
|
68
|
-
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
|
+
},
|
|
69
82
|
traffic_allocation: { type: Number, default: 100 },
|
|
70
|
-
audiences_match_type: { type: String, default: "all" },
|
|
83
|
+
audiences_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
|
|
84
|
+
pages_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
|
|
85
|
+
page_targeting: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "page", default: null },
|
|
86
|
+
audience_targeting: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "audience", default: null },
|
|
71
87
|
// Metadata fields
|
|
72
88
|
metadata_1: { type: mongoose_1.default.Schema.Types.Mixed, default: null },
|
|
73
89
|
metadata_2: { type: mongoose_1.default.Schema.Types.Mixed, default: null },
|
|
@@ -77,7 +93,6 @@ const TestSchema = new mongoose_1.Schema({
|
|
|
77
93
|
jscode: { type: String, default: "" },
|
|
78
94
|
reset_js: { type: String, default: "" },
|
|
79
95
|
csscode: { type: String, default: "" },
|
|
80
|
-
htmlcode: { type: String, default: "" },
|
|
81
96
|
// References with proper refs and defaults
|
|
82
97
|
audiences: {
|
|
83
98
|
type: [mongoose_1.default.Schema.Types.ObjectId],
|
|
@@ -146,7 +161,11 @@ const TestSchema = new mongoose_1.Schema({
|
|
|
146
161
|
pageNotContains: { type: String, default: null },
|
|
147
162
|
eventparameter: { type: String, default: null },
|
|
148
163
|
testid: { type: String, default: null },
|
|
149
|
-
testtool: { type: String,
|
|
164
|
+
testtool: { type: String,
|
|
165
|
+
default: "",
|
|
166
|
+
// enum: toolTypes, // add later from codebase-shared-functions
|
|
167
|
+
transform: (value) => (value === null || value === void 0 ? void 0 : value.toLowerCase()) || "",
|
|
168
|
+
},
|
|
150
169
|
personalization: { type: Boolean, default: false },
|
|
151
170
|
qaMode: { type: Boolean, default: false },
|
|
152
171
|
dnt: { type: Boolean, default: false },
|
|
@@ -201,7 +220,6 @@ TestSchema.index({ iid: 1 });
|
|
|
201
220
|
TestSchema.index({ client: 1, status: 1 });
|
|
202
221
|
TestSchema.index({ client: 1, status: 1, livedate: 1 });
|
|
203
222
|
TestSchema.index({ client: 1, status: 1, enddate: 1 });
|
|
204
|
-
TestSchema.index({ client: 1, testtool: 1, status: 1 });
|
|
205
223
|
TestSchema.index({ name: 1 }, { collation: { locale: 'en', strength: 2 } }); // Case-insensitive search
|
|
206
224
|
TestSchema.index({ "variations._id": 1 });
|
|
207
225
|
TestSchema.index({ status: 1, livedate: 1 });
|
package/package.json
CHANGED
package/src/constant.ts
CHANGED
package/src/models/Audience.ts
CHANGED
|
@@ -1,16 +1,84 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
2
|
import { generateRandomIID } from "../constant";
|
|
3
3
|
|
|
4
|
+
export interface IAudienceCondition extends Document {
|
|
5
|
+
iid: string;
|
|
6
|
+
name: string;
|
|
7
|
+
conditionType: string;
|
|
8
|
+
conditionGroupLabel: string;
|
|
9
|
+
conditions: IAudienceConditionItem[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IAudienceConditionItem extends Document {
|
|
13
|
+
iid: string;
|
|
14
|
+
type: string;
|
|
15
|
+
metadata: mongoose.Schema.Types.Mixed;
|
|
16
|
+
rules_js: string;
|
|
17
|
+
rules_label: string;
|
|
18
|
+
conditionGroupLabel: string;
|
|
19
|
+
rules_value: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
4
22
|
export interface IAudience extends Document {
|
|
5
23
|
iid: string;
|
|
6
24
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
25
|
+
newSchema: boolean;
|
|
7
26
|
name: string;
|
|
8
27
|
rules_js?: string;
|
|
9
28
|
generic: boolean;
|
|
10
29
|
client?: mongoose.Schema.Types.ObjectId;
|
|
11
30
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
31
|
+
conditions: IAudienceConditionItem[];
|
|
32
|
+
api_name: string;
|
|
12
33
|
}
|
|
13
34
|
|
|
35
|
+
|
|
36
|
+
const conditionItemSchema = new Schema<IAudienceConditionItem>(
|
|
37
|
+
{
|
|
38
|
+
iid: {
|
|
39
|
+
type: String,
|
|
40
|
+
trim: true,
|
|
41
|
+
default: () => generateRandomIID(),
|
|
42
|
+
unique: true,
|
|
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
|
+
},
|
|
50
|
+
rules_js: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: "return true",
|
|
53
|
+
trim: true,
|
|
54
|
+
},
|
|
55
|
+
rules_label: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: "Custom",
|
|
58
|
+
trim: true,
|
|
59
|
+
},
|
|
60
|
+
metadata: {
|
|
61
|
+
type: mongoose.Schema.Types.Mixed,
|
|
62
|
+
default: null,
|
|
63
|
+
},
|
|
64
|
+
rules_value: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: "Custom",
|
|
67
|
+
trim: true,
|
|
68
|
+
},
|
|
69
|
+
conditionGroupLabel: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: "advanced",
|
|
72
|
+
trim: true,
|
|
73
|
+
enum: ["advanced", "custom", "common"],
|
|
74
|
+
get: (value: string) => value.toLowerCase(),
|
|
75
|
+
set: (value: string) => value.toLowerCase(),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
conditionItemSchema.index({ iid: 1 }, { unique: true });
|
|
81
|
+
|
|
14
82
|
const AudienceSchema = new Schema<IAudience>(
|
|
15
83
|
{
|
|
16
84
|
iid: {
|
|
@@ -22,6 +90,10 @@ const AudienceSchema = new Schema<IAudience>(
|
|
|
22
90
|
ref: "organization",
|
|
23
91
|
default: null,
|
|
24
92
|
},
|
|
93
|
+
newSchema: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
default: false,
|
|
96
|
+
},
|
|
25
97
|
name: {
|
|
26
98
|
type: String,
|
|
27
99
|
required: true,
|
|
@@ -33,6 +105,14 @@ const AudienceSchema = new Schema<IAudience>(
|
|
|
33
105
|
type: Boolean,
|
|
34
106
|
default: false,
|
|
35
107
|
},
|
|
108
|
+
api_name: {
|
|
109
|
+
type: String,
|
|
110
|
+
slug: ["name"],
|
|
111
|
+
slugPaddingSize: 4,
|
|
112
|
+
unique: true,
|
|
113
|
+
trim: true,
|
|
114
|
+
},
|
|
115
|
+
conditions: [conditionItemSchema],
|
|
36
116
|
client: {
|
|
37
117
|
type: mongoose.Schema.Types.ObjectId,
|
|
38
118
|
ref: "client",
|
|
@@ -48,7 +128,7 @@ const AudienceSchema = new Schema<IAudience>(
|
|
|
48
128
|
}
|
|
49
129
|
);
|
|
50
130
|
|
|
51
|
-
AudienceSchema.pre('save', async function(next) {
|
|
131
|
+
AudienceSchema.pre('save', async function (next) {
|
|
52
132
|
if (!this.iid) {
|
|
53
133
|
let unique = false;
|
|
54
134
|
while (!unique) {
|
package/src/models/Page.ts
CHANGED
|
@@ -13,9 +13,18 @@ export interface IUrltargetings extends Document {
|
|
|
13
13
|
url_type: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
export interface IConditionItem extends Document {
|
|
17
|
+
iid: string;
|
|
18
|
+
name: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
url_type?: string;
|
|
21
|
+
matchType?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
export interface IPage extends Document {
|
|
17
25
|
iid: string;
|
|
18
26
|
name: string;
|
|
27
|
+
newSchema: boolean;
|
|
19
28
|
client?: mongoose.Schema.Types.ObjectId;
|
|
20
29
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
21
30
|
trigger: string;
|
|
@@ -25,11 +34,61 @@ export interface IPage extends Document {
|
|
|
25
34
|
deactivation_mode: string;
|
|
26
35
|
rules_js: string;
|
|
27
36
|
urltargetings: IUrltargetings[];
|
|
37
|
+
conditions: IConditionItem[];
|
|
28
38
|
generic: boolean;
|
|
29
39
|
isActive?: boolean;
|
|
30
40
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
31
41
|
}
|
|
32
42
|
|
|
43
|
+
const ConditionItemSchema = new Schema<IConditionItem>({
|
|
44
|
+
iid: {
|
|
45
|
+
type: String,
|
|
46
|
+
trim: true,
|
|
47
|
+
default: () => generateRandomIID(),
|
|
48
|
+
unique: true,
|
|
49
|
+
},
|
|
50
|
+
url: {
|
|
51
|
+
type: String,
|
|
52
|
+
required: true,
|
|
53
|
+
trim: true,
|
|
54
|
+
},
|
|
55
|
+
url_type: {
|
|
56
|
+
type: String,
|
|
57
|
+
required: true,
|
|
58
|
+
trim: true,
|
|
59
|
+
},
|
|
60
|
+
matchType: {
|
|
61
|
+
type: String,
|
|
62
|
+
required: true,
|
|
63
|
+
trim: true,
|
|
64
|
+
enum: ["include", "exclude"],
|
|
65
|
+
get: (value: string) => value.toLowerCase(),
|
|
66
|
+
set: (value: string) => value.toLowerCase(),
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const ConditionsSchema = new Schema<IConditionItem[]>([
|
|
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
|
+
conditionType: {
|
|
84
|
+
type: String,
|
|
85
|
+
required: true,
|
|
86
|
+
trim: true,
|
|
87
|
+
},
|
|
88
|
+
conditions: [ConditionItemSchema],
|
|
89
|
+
}
|
|
90
|
+
]);
|
|
91
|
+
|
|
33
92
|
const UrltargetingsSchema = new Schema<IUrltargetings>({
|
|
34
93
|
iid: {
|
|
35
94
|
type: String,
|
|
@@ -57,6 +116,10 @@ const PageSchema = new Schema<IPage>({
|
|
|
57
116
|
type: String,
|
|
58
117
|
trim: true,
|
|
59
118
|
},
|
|
119
|
+
newSchema: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: false,
|
|
122
|
+
},
|
|
60
123
|
name: {
|
|
61
124
|
type: String,
|
|
62
125
|
required: true,
|
|
@@ -86,7 +149,7 @@ const PageSchema = new Schema<IPage>({
|
|
|
86
149
|
},
|
|
87
150
|
api_name: {
|
|
88
151
|
type: String,
|
|
89
|
-
slug: ["name"],
|
|
152
|
+
slug: ["name"],
|
|
90
153
|
slugPaddingSize: 4,
|
|
91
154
|
unique: true,
|
|
92
155
|
trim: true,
|
|
@@ -99,6 +162,9 @@ const PageSchema = new Schema<IPage>({
|
|
|
99
162
|
type: String,
|
|
100
163
|
default: "reset",
|
|
101
164
|
trim: true,
|
|
165
|
+
// enum: ["reset", "deactivate"],
|
|
166
|
+
get: (value: string) => value.toLowerCase(),
|
|
167
|
+
set: (value: string) => value.toLowerCase(),
|
|
102
168
|
},
|
|
103
169
|
rules_js: {
|
|
104
170
|
type: String,
|
|
@@ -106,6 +172,7 @@ const PageSchema = new Schema<IPage>({
|
|
|
106
172
|
trim: true,
|
|
107
173
|
},
|
|
108
174
|
urltargetings: [UrltargetingsSchema],
|
|
175
|
+
conditions: [ConditionsSchema],
|
|
109
176
|
generic: {
|
|
110
177
|
type: Boolean,
|
|
111
178
|
default: false,
|
|
@@ -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,9 +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
29
|
// Metadata fields
|
|
30
30
|
metadata_1: mongoose.Schema.Types.Mixed;
|
|
31
31
|
metadata_2: mongoose.Schema.Types.Mixed;
|
|
@@ -33,16 +33,22 @@ export interface ITest extends Document {
|
|
|
33
33
|
integrations_run_mode: mongoose.Schema.Types.Mixed;
|
|
34
34
|
// Code fields
|
|
35
35
|
jscode: string;
|
|
36
|
-
reset_js: string;
|
|
37
36
|
csscode: string;
|
|
38
|
-
|
|
37
|
+
reset_js: string;
|
|
39
38
|
// References
|
|
39
|
+
// old schema audiences and pages
|
|
40
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
|
+
|
|
41
48
|
variations: IVariations[];
|
|
42
49
|
environments?: mongoose.Schema.Types.ObjectId[];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
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;
|
|
46
52
|
goal?: mongoose.Schema.Types.ObjectId[];
|
|
47
53
|
pagetesttype?: mongoose.Schema.Types.ObjectId[];
|
|
48
54
|
tags?: mongoose.Schema.Types.ObjectId[];
|
|
@@ -82,7 +88,8 @@ export interface ITest extends Document {
|
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
const VariationsSchema = new Schema<IVariations>({
|
|
85
|
-
iid: {
|
|
91
|
+
iid: {
|
|
92
|
+
type: String,
|
|
86
93
|
trim: true,
|
|
87
94
|
unique: true,
|
|
88
95
|
},
|
|
@@ -103,88 +110,102 @@ const VariationsSchema = new Schema<IVariations>({
|
|
|
103
110
|
const TestSchema = new Schema<ITest>(
|
|
104
111
|
{
|
|
105
112
|
iid: { type: String, trim: true },
|
|
106
|
-
organizationId: {
|
|
107
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
113
|
+
organizationId: {
|
|
114
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
108
115
|
ref: "organization",
|
|
109
|
-
default: null
|
|
116
|
+
default: null
|
|
110
117
|
},
|
|
111
|
-
status: {
|
|
112
|
-
type: String,
|
|
118
|
+
status: {
|
|
119
|
+
type: String,
|
|
113
120
|
default: "draft",
|
|
114
|
-
enum: ["live", "draft", "ended", "paused", "preview", "running", "archive"]
|
|
121
|
+
enum: ["live", "draft", "ended", "paused", "preview", "running", "archive"],
|
|
122
|
+
transform: (value: string) => value.toLowerCase(),
|
|
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(),
|
|
115
129
|
},
|
|
116
130
|
name: { type: String, required: true },
|
|
117
|
-
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
|
+
},
|
|
118
137
|
traffic_allocation: { type: Number, default: 100 },
|
|
119
|
-
audiences_match_type: { type: String, default: "all" },
|
|
138
|
+
audiences_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
|
|
139
|
+
pages_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
|
|
140
|
+
page_targeting: { type: mongoose.Schema.Types.ObjectId, ref: "page", default: null },
|
|
141
|
+
audience_targeting: { type: mongoose.Schema.Types.ObjectId, ref: "audience", default: null },
|
|
120
142
|
// Metadata fields
|
|
121
143
|
metadata_1: { type: mongoose.Schema.Types.Mixed, default: null },
|
|
122
144
|
metadata_2: { type: mongoose.Schema.Types.Mixed, default: null },
|
|
123
145
|
metadata_3: { type: mongoose.Schema.Types.Mixed, default: null },
|
|
124
146
|
integrations_run_mode: { type: mongoose.Schema.Types.Mixed, default: null },
|
|
125
|
-
|
|
147
|
+
|
|
126
148
|
// Code fields
|
|
127
149
|
jscode: { type: String, default: "" },
|
|
128
150
|
reset_js: { type: String, default: "" },
|
|
129
151
|
csscode: { type: String, default: "" },
|
|
130
|
-
|
|
131
|
-
|
|
152
|
+
|
|
132
153
|
// References with proper refs and defaults
|
|
133
|
-
audiences: {
|
|
134
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
135
|
-
ref: "audience",
|
|
136
|
-
default: []
|
|
154
|
+
audiences: {
|
|
155
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
156
|
+
ref: "audience",
|
|
157
|
+
default: []
|
|
137
158
|
},
|
|
138
|
-
pages: {
|
|
139
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
140
|
-
ref: "page",
|
|
141
|
-
default: []
|
|
159
|
+
pages: {
|
|
160
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
161
|
+
ref: "page",
|
|
162
|
+
default: []
|
|
142
163
|
},
|
|
143
164
|
variations: [VariationsSchema],
|
|
144
|
-
environments: {
|
|
145
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
146
|
-
ref: "environment",
|
|
147
|
-
default: []
|
|
165
|
+
environments: {
|
|
166
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
167
|
+
ref: "environment",
|
|
168
|
+
default: []
|
|
148
169
|
},
|
|
149
|
-
pageelement: {
|
|
150
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
151
|
-
ref: "pageelement",
|
|
152
|
-
default: []
|
|
170
|
+
pageelement: {
|
|
171
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
172
|
+
ref: "pageelement",
|
|
173
|
+
default: []
|
|
153
174
|
},
|
|
154
|
-
client: {
|
|
155
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
156
|
-
ref: "client"
|
|
175
|
+
client: {
|
|
176
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
177
|
+
ref: "client"
|
|
157
178
|
},
|
|
158
|
-
goal: {
|
|
159
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
160
|
-
ref: "goal",
|
|
161
|
-
default: []
|
|
179
|
+
goal: {
|
|
180
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
181
|
+
ref: "goal",
|
|
182
|
+
default: []
|
|
162
183
|
},
|
|
163
|
-
pagetesttype: {
|
|
164
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
165
|
-
ref: "pagetesttype",
|
|
166
|
-
default: []
|
|
184
|
+
pagetesttype: {
|
|
185
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
186
|
+
ref: "pagetesttype",
|
|
187
|
+
default: []
|
|
167
188
|
},
|
|
168
|
-
tags: {
|
|
169
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
170
|
-
ref: "tag",
|
|
171
|
-
default: []
|
|
189
|
+
tags: {
|
|
190
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
191
|
+
ref: "tag",
|
|
192
|
+
default: []
|
|
172
193
|
},
|
|
173
|
-
hypothesis: {
|
|
174
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
194
|
+
hypothesis: {
|
|
195
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
175
196
|
ref: "hypos"
|
|
176
197
|
},
|
|
177
|
-
trigger: {
|
|
178
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
179
|
-
ref: "trigger",
|
|
180
|
-
default: []
|
|
198
|
+
trigger: {
|
|
199
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
200
|
+
ref: "trigger",
|
|
201
|
+
default: []
|
|
181
202
|
},
|
|
182
|
-
stageincustomerjourney: {
|
|
183
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
184
|
-
ref: "stageincustomerjourney",
|
|
203
|
+
stageincustomerjourney: {
|
|
204
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
205
|
+
ref: "stageincustomerjourney",
|
|
185
206
|
default: null
|
|
186
207
|
},
|
|
187
|
-
|
|
208
|
+
|
|
188
209
|
// Test configuration
|
|
189
210
|
property: { type: mongoose.Schema.Types.Mixed, default: null },
|
|
190
211
|
platform: { type: String, default: "BQ" },
|
|
@@ -198,7 +219,11 @@ const TestSchema = new Schema<ITest>(
|
|
|
198
219
|
pageNotContains: { type: String, default: null },
|
|
199
220
|
eventparameter: { type: String, default: null },
|
|
200
221
|
testid: { type: String, default: null },
|
|
201
|
-
testtool: { type: String,
|
|
222
|
+
testtool: { type: String,
|
|
223
|
+
default: "",
|
|
224
|
+
// enum: toolTypes, // add later from codebase-shared-functions
|
|
225
|
+
transform: (value: string) => value?.toLowerCase() || "",
|
|
226
|
+
},
|
|
202
227
|
personalization: { type: Boolean, default: false },
|
|
203
228
|
qaMode: { type: Boolean, default: false },
|
|
204
229
|
dnt: { type: Boolean, default: false },
|
|
@@ -220,7 +245,7 @@ const TestSchema = new Schema<ITest>(
|
|
|
220
245
|
timestamps: true
|
|
221
246
|
}
|
|
222
247
|
);
|
|
223
|
-
TestSchema.pre('save', async function(next) {
|
|
248
|
+
TestSchema.pre('save', async function (next) {
|
|
224
249
|
if (!this.iid) {
|
|
225
250
|
let unique = false;
|
|
226
251
|
while (!unique) {
|
|
@@ -254,7 +279,6 @@ TestSchema.index({ iid: 1 });
|
|
|
254
279
|
TestSchema.index({ client: 1, status: 1 });
|
|
255
280
|
TestSchema.index({ client: 1, status: 1, livedate: 1 });
|
|
256
281
|
TestSchema.index({ client: 1, status: 1, enddate: 1 });
|
|
257
|
-
TestSchema.index({ client: 1, testtool: 1, status: 1 });
|
|
258
282
|
TestSchema.index({ name: 1 }, { collation: { locale: 'en', strength: 2 } }); // Case-insensitive search
|
|
259
283
|
TestSchema.index({ "variations._id": 1 });
|
|
260
284
|
TestSchema.index({ status: 1, livedate: 1 });
|