codebase-models 3.1.9 → 3.2.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.
@@ -23,14 +23,31 @@
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
+ rules_js: string;
36
+ rules_label: string;
37
+ conditionGroupLabel: string;
38
+ rules_value: string;
39
+ }
26
40
  export interface IAudience extends Document {
27
41
  iid: string;
28
42
  organizationId?: mongoose.Schema.Types.ObjectId;
43
+ newSchema: boolean;
29
44
  name: string;
30
45
  rules_js?: string;
31
46
  generic: boolean;
32
47
  client?: mongoose.Schema.Types.ObjectId;
33
48
  createdBy?: mongoose.Schema.Types.ObjectId;
49
+ conditions: IAudienceConditionItem[];
50
+ api_name: string;
34
51
  }
35
52
  declare const Audience: mongoose.Model<any, {}, {}, {}, any, any>;
36
53
  export default Audience;
@@ -34,6 +34,52 @@ 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
+ rules_js: {
45
+ type: String,
46
+ default: "",
47
+ trim: true,
48
+ },
49
+ rules_label: {
50
+ type: String,
51
+ default: "",
52
+ trim: true,
53
+ },
54
+ rules_value: {
55
+ type: String,
56
+ default: "Group",
57
+ trim: true,
58
+ },
59
+ conditionGroupLabel: {
60
+ type: String,
61
+ default: "advanced",
62
+ trim: true,
63
+ enum: ["advanced", "custom", "common"],
64
+ get: (value) => value.toLowerCase(),
65
+ set: (value) => value.toLowerCase(),
66
+ },
67
+ });
68
+ 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
+ });
37
83
  const AudienceSchema = new mongoose_1.Schema({
38
84
  iid: {
39
85
  type: String,
@@ -44,6 +90,10 @@ const AudienceSchema = new mongoose_1.Schema({
44
90
  ref: "organization",
45
91
  default: null,
46
92
  },
93
+ newSchema: {
94
+ type: Boolean,
95
+ default: false,
96
+ },
47
97
  name: {
48
98
  type: String,
49
99
  required: true,
@@ -55,6 +105,14 @@ const AudienceSchema = new mongoose_1.Schema({
55
105
  type: Boolean,
56
106
  default: false,
57
107
  },
108
+ api_name: {
109
+ type: String,
110
+ slug: ["name"],
111
+ slugPaddingSize: 4,
112
+ unique: true,
113
+ trim: true,
114
+ },
115
+ conditions: AudienceConditionSchema,
58
116
  client: {
59
117
  type: mongoose_1.default.Schema.Types.ObjectId,
60
118
  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;
@@ -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,
@@ -46,6 +46,9 @@ export interface ITest extends Document {
46
46
  traffic_allocation_type: string;
47
47
  traffic_allocation: number;
48
48
  audiences_match_type: string;
49
+ pages_match_type: string;
50
+ page_targeting?: mongoose.Schema.Types.ObjectId;
51
+ audience_targeting?: mongoose.Schema.Types.ObjectId;
49
52
  metadata_1: mongoose.Schema.Types.Mixed;
50
53
  metadata_2: mongoose.Schema.Types.Mixed;
51
54
  metadata_3: mongoose.Schema.Types.Mixed;
@@ -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: { type: String,
38
+ iid: {
39
+ type: String,
39
40
  trim: true,
40
41
  unique: true,
41
42
  },
@@ -62,12 +63,16 @@ 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(),
66
68
  },
67
69
  name: { type: String, required: true },
68
70
  traffic_allocation_type: { type: String, default: "manual", enum: ["manual", "multi-armed", "contextual"] },
69
71
  traffic_allocation: { type: Number, default: 100 },
70
- audiences_match_type: { type: String, default: "all" },
72
+ audiences_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
73
+ pages_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
74
+ page_targeting: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "page", default: null },
75
+ audience_targeting: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "audience", default: null },
71
76
  // Metadata fields
72
77
  metadata_1: { type: mongoose_1.default.Schema.Types.Mixed, default: null },
73
78
  metadata_2: { type: mongoose_1.default.Schema.Types.Mixed, default: null },
@@ -146,7 +151,9 @@ const TestSchema = new mongoose_1.Schema({
146
151
  pageNotContains: { type: String, default: null },
147
152
  eventparameter: { type: String, default: null },
148
153
  testid: { type: String, default: null },
149
- testtool: { type: String, default: "" },
154
+ testtool: { type: String, default: "",
155
+ transform: (value) => (value === null || value === void 0 ? void 0 : value.toLowerCase()) || "",
156
+ },
150
157
  personalization: { type: Boolean, default: false },
151
158
  qaMode: { type: Boolean, default: false },
152
159
  dnt: { type: Boolean, default: false },
@@ -201,7 +208,6 @@ TestSchema.index({ iid: 1 });
201
208
  TestSchema.index({ client: 1, status: 1 });
202
209
  TestSchema.index({ client: 1, status: 1, livedate: 1 });
203
210
  TestSchema.index({ client: 1, status: 1, enddate: 1 });
204
- TestSchema.index({ client: 1, testtool: 1, status: 1 });
205
211
  TestSchema.index({ name: 1 }, { collation: { locale: 'en', strength: 2 } }); // Case-insensitive search
206
212
  TestSchema.index({ "variations._id": 1 });
207
213
  TestSchema.index({ status: 1, livedate: 1 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-models",
3
- "version": "3.1.9",
3
+ "version": "3.2.0",
4
4
  "description": "Common models for codebase",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,16 +1,89 @@
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
+ rules_js: string;
15
+ rules_label: string;
16
+ conditionGroupLabel: string;
17
+ rules_value: string;
18
+ }
19
+
4
20
  export interface IAudience extends Document {
5
21
  iid: string;
6
22
  organizationId?: mongoose.Schema.Types.ObjectId;
23
+ newSchema: boolean;
7
24
  name: string;
8
25
  rules_js?: string;
9
26
  generic: boolean;
10
27
  client?: mongoose.Schema.Types.ObjectId;
11
28
  createdBy?: mongoose.Schema.Types.ObjectId;
29
+ conditions: IAudienceConditionItem[];
30
+ api_name: string;
12
31
  }
13
32
 
33
+
34
+ const conditionItemSchema = new Schema<IAudienceConditionItem>(
35
+ {
36
+ iid: {
37
+ type: String,
38
+ trim: true,
39
+ default: () => generateRandomIID(),
40
+ unique: true,
41
+ },
42
+ rules_js: {
43
+ type: String,
44
+ default: "",
45
+ trim: true,
46
+ },
47
+ rules_label: {
48
+ type: String,
49
+ default: "",
50
+ trim: true,
51
+ },
52
+ rules_value: {
53
+ type: String,
54
+ default: "Group",
55
+ trim: true,
56
+ },
57
+ conditionGroupLabel: {
58
+ type: String,
59
+ default: "advanced",
60
+ trim: true,
61
+ enum: ["advanced", "custom","common"],
62
+ get: (value: string) => value.toLowerCase(),
63
+ set: (value: string) => value.toLowerCase(),
64
+ },
65
+ },
66
+ );
67
+
68
+ conditionItemSchema.index({ iid: 1 }, { unique: true });
69
+
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
+
14
87
  const AudienceSchema = new Schema<IAudience>(
15
88
  {
16
89
  iid: {
@@ -22,6 +95,10 @@ const AudienceSchema = new Schema<IAudience>(
22
95
  ref: "organization",
23
96
  default: null,
24
97
  },
98
+ newSchema: {
99
+ type: Boolean,
100
+ default: false,
101
+ },
25
102
  name: {
26
103
  type: String,
27
104
  required: true,
@@ -33,6 +110,14 @@ const AudienceSchema = new Schema<IAudience>(
33
110
  type: Boolean,
34
111
  default: false,
35
112
  },
113
+ api_name: {
114
+ type: String,
115
+ slug: ["name"],
116
+ slugPaddingSize: 4,
117
+ unique: true,
118
+ trim: true,
119
+ },
120
+ conditions: AudienceConditionSchema,
36
121
  client: {
37
122
  type: mongoose.Schema.Types.ObjectId,
38
123
  ref: "client",
@@ -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,
@@ -26,6 +26,9 @@ export interface ITest extends Document {
26
26
  traffic_allocation_type: string;
27
27
  traffic_allocation: number;
28
28
  audiences_match_type: string;
29
+ pages_match_type: string;
30
+ page_targeting?: mongoose.Schema.Types.ObjectId;
31
+ audience_targeting?: mongoose.Schema.Types.ObjectId;
29
32
  // Metadata fields
30
33
  metadata_1: mongoose.Schema.Types.Mixed;
31
34
  metadata_2: mongoose.Schema.Types.Mixed;
@@ -82,7 +85,8 @@ export interface ITest extends Document {
82
85
  }
83
86
 
84
87
  const VariationsSchema = new Schema<IVariations>({
85
- iid: { type: String,
88
+ iid: {
89
+ type: String,
86
90
  trim: true,
87
91
  unique: true,
88
92
  },
@@ -103,88 +107,92 @@ const VariationsSchema = new Schema<IVariations>({
103
107
  const TestSchema = new Schema<ITest>(
104
108
  {
105
109
  iid: { type: String, trim: true },
106
- organizationId: {
107
- type: mongoose.Schema.Types.ObjectId,
110
+ organizationId: {
111
+ type: mongoose.Schema.Types.ObjectId,
108
112
  ref: "organization",
109
- default: null
113
+ default: null
110
114
  },
111
- status: {
112
- type: String,
115
+ status: {
116
+ type: String,
113
117
  default: "draft",
114
- enum: ["live", "draft", "ended", "paused", "preview", "running", "archive"]
118
+ enum: ["live", "draft", "ended", "paused", "preview", "running", "archive"],
119
+ transform: (value: string) => value.toLowerCase(),
115
120
  },
116
121
  name: { type: String, required: true },
117
122
  traffic_allocation_type: { type: String, default: "manual", enum: ["manual", "multi-armed", "contextual"] },
118
123
  traffic_allocation: { type: Number, default: 100 },
119
- audiences_match_type: { type: String, default: "all" },
124
+ audiences_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
125
+ pages_match_type: { type: String, default: "AND", enum: ["AND", "OR", "any", "all"] },
126
+ page_targeting: { type: mongoose.Schema.Types.ObjectId, ref: "page", default: null },
127
+ audience_targeting: { type: mongoose.Schema.Types.ObjectId, ref: "audience", default: null },
120
128
  // Metadata fields
121
129
  metadata_1: { type: mongoose.Schema.Types.Mixed, default: null },
122
130
  metadata_2: { type: mongoose.Schema.Types.Mixed, default: null },
123
131
  metadata_3: { type: mongoose.Schema.Types.Mixed, default: null },
124
132
  integrations_run_mode: { type: mongoose.Schema.Types.Mixed, default: null },
125
-
133
+
126
134
  // Code fields
127
135
  jscode: { type: String, default: "" },
128
136
  reset_js: { type: String, default: "" },
129
137
  csscode: { type: String, default: "" },
130
138
  htmlcode: { type: String, default: "" },
131
-
139
+
132
140
  // References with proper refs and defaults
133
- audiences: {
134
- type: [mongoose.Schema.Types.ObjectId],
135
- ref: "audience",
136
- default: []
141
+ audiences: {
142
+ type: [mongoose.Schema.Types.ObjectId],
143
+ ref: "audience",
144
+ default: []
137
145
  },
138
- pages: {
139
- type: [mongoose.Schema.Types.ObjectId],
140
- ref: "page",
141
- default: []
146
+ pages: {
147
+ type: [mongoose.Schema.Types.ObjectId],
148
+ ref: "page",
149
+ default: []
142
150
  },
143
151
  variations: [VariationsSchema],
144
- environments: {
145
- type: [mongoose.Schema.Types.ObjectId],
146
- ref: "environment",
147
- default: []
152
+ environments: {
153
+ type: [mongoose.Schema.Types.ObjectId],
154
+ ref: "environment",
155
+ default: []
148
156
  },
149
- pageelement: {
150
- type: [mongoose.Schema.Types.ObjectId],
151
- ref: "pageelement",
152
- default: []
157
+ pageelement: {
158
+ type: [mongoose.Schema.Types.ObjectId],
159
+ ref: "pageelement",
160
+ default: []
153
161
  },
154
- client: {
155
- type: mongoose.Schema.Types.ObjectId,
156
- ref: "client"
162
+ client: {
163
+ type: mongoose.Schema.Types.ObjectId,
164
+ ref: "client"
157
165
  },
158
- goal: {
159
- type: [mongoose.Schema.Types.ObjectId],
160
- ref: "goal",
161
- default: []
166
+ goal: {
167
+ type: [mongoose.Schema.Types.ObjectId],
168
+ ref: "goal",
169
+ default: []
162
170
  },
163
- pagetesttype: {
164
- type: [mongoose.Schema.Types.ObjectId],
165
- ref: "pagetesttype",
166
- default: []
171
+ pagetesttype: {
172
+ type: [mongoose.Schema.Types.ObjectId],
173
+ ref: "pagetesttype",
174
+ default: []
167
175
  },
168
- tags: {
169
- type: [mongoose.Schema.Types.ObjectId],
170
- ref: "tag",
171
- default: []
176
+ tags: {
177
+ type: [mongoose.Schema.Types.ObjectId],
178
+ ref: "tag",
179
+ default: []
172
180
  },
173
- hypothesis: {
174
- type: mongoose.Schema.Types.ObjectId,
181
+ hypothesis: {
182
+ type: mongoose.Schema.Types.ObjectId,
175
183
  ref: "hypos"
176
184
  },
177
- trigger: {
178
- type: [mongoose.Schema.Types.ObjectId],
179
- ref: "trigger",
180
- default: []
185
+ trigger: {
186
+ type: [mongoose.Schema.Types.ObjectId],
187
+ ref: "trigger",
188
+ default: []
181
189
  },
182
- stageincustomerjourney: {
183
- type: mongoose.Schema.Types.ObjectId,
184
- ref: "stageincustomerjourney",
190
+ stageincustomerjourney: {
191
+ type: mongoose.Schema.Types.ObjectId,
192
+ ref: "stageincustomerjourney",
185
193
  default: null
186
194
  },
187
-
195
+
188
196
  // Test configuration
189
197
  property: { type: mongoose.Schema.Types.Mixed, default: null },
190
198
  platform: { type: String, default: "BQ" },
@@ -198,7 +206,9 @@ const TestSchema = new Schema<ITest>(
198
206
  pageNotContains: { type: String, default: null },
199
207
  eventparameter: { type: String, default: null },
200
208
  testid: { type: String, default: null },
201
- testtool: { type: String, default: "" },
209
+ testtool: { type: String, default: "",
210
+ transform: (value: string) => value?.toLowerCase() || "",
211
+ },
202
212
  personalization: { type: Boolean, default: false },
203
213
  qaMode: { type: Boolean, default: false },
204
214
  dnt: { type: Boolean, default: false },
@@ -220,7 +230,7 @@ const TestSchema = new Schema<ITest>(
220
230
  timestamps: true
221
231
  }
222
232
  );
223
- TestSchema.pre('save', async function(next) {
233
+ TestSchema.pre('save', async function (next) {
224
234
  if (!this.iid) {
225
235
  let unique = false;
226
236
  while (!unique) {
@@ -254,7 +264,6 @@ TestSchema.index({ iid: 1 });
254
264
  TestSchema.index({ client: 1, status: 1 });
255
265
  TestSchema.index({ client: 1, status: 1, livedate: 1 });
256
266
  TestSchema.index({ client: 1, status: 1, enddate: 1 });
257
- TestSchema.index({ client: 1, testtool: 1, status: 1 });
258
267
  TestSchema.index({ name: 1 }, { collation: { locale: 'en', strength: 2 } }); // Case-insensitive search
259
268
  TestSchema.index({ "variations._id": 1 });
260
269
  TestSchema.index({ status: 1, livedate: 1 });