codebase-models 3.2.3 → 3.2.4

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/index.d.ts CHANGED
@@ -82,5 +82,6 @@ import Provider from "./src/models/Provider";
82
82
  import ApiLog from "./src/models/ApiLog";
83
83
  import { ProviderType } from "./src/models/Provider";
84
84
  import OldReport from "./src/models/OldReport";
85
+ import PrimaryPageTestType from "./src/models/PrimaryPageTestType";
85
86
  export declare function connect(uri: string, options?: mongoose.ConnectOptions | undefined): Promise<typeof mongoose>;
86
- export { generateRandomIID, RolesConstants, Client, ClientReportsTemp, Report, Provider, Test, TestSequentialValue, User, AppEvent, Announcement, ClientAdditionalRevenue, ClientLearning, ClientLinks, ClientNextStep, ClientNote, ClientRetention, ClientStrategy, ClientSurvey, CVRReport, Faq, Feedback, Goal, Hypothesis, HypothesisSheet, LandingPages, NewIdeas, Notification, Page, PageElement, PageTestType, Portfolio, ReadNotification, Role, CustomQuery, SavedSegment, TestTimeline, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, Audience, Environment, Organization, PrecalculationFilters, BqPreCompiledData, CronData, CronConfig, UserPermission, UserOrganization, Package, Invitation, Thread, ThreadMessage, ApiLog, ProviderType, OldReport, };
87
+ export { generateRandomIID, RolesConstants, Client, ClientReportsTemp, Report, Provider, Test, TestSequentialValue, User, AppEvent, Announcement, ClientAdditionalRevenue, ClientLearning, ClientLinks, ClientNextStep, ClientNote, ClientRetention, ClientStrategy, ClientSurvey, CVRReport, Faq, Feedback, Goal, Hypothesis, HypothesisSheet, LandingPages, NewIdeas, Notification, Page, PageElement, PageTestType, PrimaryPageTestType, Portfolio, ReadNotification, Role, CustomQuery, SavedSegment, TestTimeline, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, Audience, Environment, Organization, PrecalculationFilters, BqPreCompiledData, CronData, CronConfig, UserPermission, UserOrganization, Package, Invitation, Thread, ThreadMessage, ApiLog, ProviderType, OldReport, };
package/dist/index.js CHANGED
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.BqPreCompiledData = exports.PrecalculationFilters = exports.Organization = exports.Environment = exports.Audience = exports.ClientScript = exports.Trigger = exports.Tier = exports.Temp = exports.Tag = exports.StageInCustomerJourney = exports.Snippet = exports.TestTimeline = exports.SavedSegment = exports.CustomQuery = exports.Role = exports.ReadNotification = exports.Portfolio = exports.PageTestType = exports.PageElement = exports.Page = exports.Notification = exports.NewIdeas = exports.LandingPages = exports.HypothesisSheet = exports.Hypothesis = exports.Goal = exports.Feedback = exports.Faq = exports.CVRReport = exports.ClientSurvey = exports.ClientStrategy = exports.ClientRetention = exports.ClientNote = exports.ClientNextStep = exports.ClientLinks = exports.ClientLearning = exports.ClientAdditionalRevenue = exports.Announcement = exports.AppEvent = exports.User = exports.TestSequentialValue = exports.Test = exports.Provider = exports.Report = exports.ClientReportsTemp = exports.Client = exports.RolesConstants = exports.generateRandomIID = exports.connect = void 0;
16
- exports.OldReport = exports.ProviderType = exports.ApiLog = exports.ThreadMessage = exports.Thread = exports.Invitation = exports.Package = exports.UserOrganization = exports.UserPermission = exports.CronConfig = exports.CronData = void 0;
15
+ exports.PrecalculationFilters = exports.Organization = exports.Environment = exports.Audience = exports.ClientScript = exports.Trigger = exports.Tier = exports.Temp = exports.Tag = exports.StageInCustomerJourney = exports.Snippet = exports.TestTimeline = exports.SavedSegment = exports.CustomQuery = exports.Role = exports.ReadNotification = exports.Portfolio = exports.PrimaryPageTestType = exports.PageTestType = exports.PageElement = exports.Page = exports.Notification = exports.NewIdeas = exports.LandingPages = exports.HypothesisSheet = exports.Hypothesis = exports.Goal = exports.Feedback = exports.Faq = exports.CVRReport = exports.ClientSurvey = exports.ClientStrategy = exports.ClientRetention = exports.ClientNote = exports.ClientNextStep = exports.ClientLinks = exports.ClientLearning = exports.ClientAdditionalRevenue = exports.Announcement = exports.AppEvent = exports.User = exports.TestSequentialValue = exports.Test = exports.Provider = exports.Report = exports.ClientReportsTemp = exports.Client = exports.RolesConstants = exports.generateRandomIID = exports.connect = void 0;
16
+ exports.OldReport = exports.ProviderType = exports.ApiLog = exports.ThreadMessage = exports.Thread = exports.Invitation = exports.Package = exports.UserOrganization = exports.UserPermission = exports.CronConfig = exports.CronData = exports.BqPreCompiledData = void 0;
17
17
  const mongoose_1 = __importDefault(require("mongoose"));
18
18
  const Client_1 = __importDefault(require("./src/models/Client"));
19
19
  exports.Client = Client_1.default;
@@ -134,6 +134,8 @@ const Provider_2 = require("./src/models/Provider");
134
134
  Object.defineProperty(exports, "ProviderType", { enumerable: true, get: function () { return Provider_2.ProviderType; } });
135
135
  const OldReport_1 = __importDefault(require("./src/models/OldReport"));
136
136
  exports.OldReport = OldReport_1.default;
137
+ const PrimaryPageTestType_1 = __importDefault(require("./src/models/PrimaryPageTestType"));
138
+ exports.PrimaryPageTestType = PrimaryPageTestType_1.default;
137
139
  function seedRoles() {
138
140
  return __awaiter(this, void 0, void 0, function* () {
139
141
  const checkRoles = yield Role_1.default.countDocuments();
@@ -58,12 +58,17 @@ export interface IAudienceConditionItem extends Document {
58
58
  conditionGroupLabel: string;
59
59
  rules_value: string;
60
60
  }
61
+ export interface IInteractionData extends Document {
62
+ event: string;
63
+ metadata: mongoose.Schema.Types.Mixed;
64
+ }
61
65
  export interface IAudience extends Document {
62
66
  iid: string;
63
67
  organizationId?: mongoose.Schema.Types.ObjectId;
64
68
  newSchema: boolean;
65
69
  name: string;
66
70
  rules_js?: string;
71
+ interaction_data: IInteractionData[];
67
72
  generic: boolean;
68
73
  client?: mongoose.Schema.Types.ObjectId;
69
74
  createdBy?: mongoose.Schema.Types.ObjectId;
@@ -34,6 +34,17 @@ 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 InteractionDataSchema = new mongoose_1.Schema({
38
+ event: {
39
+ type: String,
40
+ required: true,
41
+ trim: true,
42
+ },
43
+ metadata: {
44
+ type: mongoose_1.default.Schema.Types.Mixed,
45
+ default: null,
46
+ },
47
+ });
37
48
  const ConditionItemSchema = new mongoose_1.Schema({
38
49
  iid: {
39
50
  type: String,
@@ -117,7 +128,7 @@ const ConditionsSchema = new mongoose_1.Schema([
117
128
  default: "AND",
118
129
  },
119
130
  conditionGroups: [conditionGroupSchema],
120
- }
131
+ },
121
132
  ]);
122
133
  const AudienceSchema = new mongoose_1.Schema({
123
134
  iid: {
@@ -139,7 +150,10 @@ const AudienceSchema = new mongoose_1.Schema({
139
150
  },
140
151
  rules_js: {
141
152
  type: String,
153
+ default: "return true",
154
+ trim: true,
142
155
  },
156
+ interaction_data: InteractionDataSchema,
143
157
  generic: {
144
158
  type: Boolean,
145
159
  default: false,
@@ -164,7 +178,7 @@ const AudienceSchema = new mongoose_1.Schema({
164
178
  }, {
165
179
  timestamps: true,
166
180
  });
167
- AudienceSchema.pre('save', function (next) {
181
+ AudienceSchema.pre("save", function (next) {
168
182
  return __awaiter(this, void 0, void 0, function* () {
169
183
  if (!this.iid) {
170
184
  let unique = false;
@@ -26,6 +26,7 @@ import mongoose, { Document } from "mongoose";
26
26
  export interface IPageTestType extends Document {
27
27
  name: string;
28
28
  details?: string;
29
+ category: string;
29
30
  isActive?: boolean;
30
31
  createdAt?: Date;
31
32
  updatedAt?: Date;
@@ -33,7 +34,6 @@ export interface IPageTestType extends Document {
33
34
  metadata?: mongoose.Schema.Types.Mixed;
34
35
  client?: mongoose.Schema.Types.ObjectId;
35
36
  createdBy?: mongoose.Schema.Types.ObjectId;
36
- generic?: boolean;
37
37
  }
38
38
  declare const PageTestType: mongoose.Model<any, {}, {}, {}, any, any>;
39
39
  export default PageTestType;
@@ -30,6 +30,14 @@ const PageTestTypeSchema = new mongoose_1.Schema({
30
30
  ref: "organization",
31
31
  default: null,
32
32
  },
33
+ category: {
34
+ type: String,
35
+ required: true,
36
+ trim: true,
37
+ // make valye lowercase
38
+ get: (value) => value.toLowerCase(),
39
+ set: (value) => value.toLowerCase(),
40
+ },
33
41
  name: {
34
42
  type: String,
35
43
  required: true,
@@ -55,10 +63,6 @@ const PageTestTypeSchema = new mongoose_1.Schema({
55
63
  ref: "user",
56
64
  default: null,
57
65
  },
58
- generic: {
59
- type: Boolean,
60
- default: true,
61
- },
62
66
  createdAt: {
63
67
  type: Date,
64
68
  default: new Date(),
@@ -66,11 +70,12 @@ const PageTestTypeSchema = new mongoose_1.Schema({
66
70
  isActive: {
67
71
  type: Boolean,
68
72
  default: true,
69
- }
73
+ },
70
74
  }, {
71
- timestamps: true
75
+ timestamps: true,
72
76
  });
73
77
  // Compound indexes for common query patterns
74
78
  PageTestTypeSchema.index({ name: 1, isActive: 1 });
75
- const PageTestType = mongoose_1.default.models.pagetesttype || (0, mongoose_1.model)("pagetesttype", PageTestTypeSchema);
79
+ const PageTestType = mongoose_1.default.models.pagetesttype ||
80
+ (0, mongoose_1.model)("pagetesttype", PageTestTypeSchema);
76
81
  exports.default = PageTestType;
@@ -0,0 +1,30 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import mongoose, { Document } from "mongoose";
26
+ export interface IPrimaryPageTestType extends Document {
27
+ test?: mongoose.Schema.Types.ObjectId;
28
+ }
29
+ declare const PrimaryPageTestType: mongoose.Model<any, {}, {}, {}, any, any>;
30
+ export default PrimaryPageTestType;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const mongoose_1 = __importStar(require("mongoose"));
27
+ const PrimaryPageTestTypeSchema = new mongoose_1.Schema({
28
+ test: {
29
+ type: mongoose_1.default.Schema.Types.ObjectId,
30
+ ref: "test",
31
+ required: true,
32
+ },
33
+ }, {
34
+ timestamps: true,
35
+ });
36
+ // Compound indexes for common query patterns
37
+ PrimaryPageTestTypeSchema.index({ test: 1 });
38
+ const PrimaryPageTestType = mongoose_1.default.models.primarypagetesttype ||
39
+ (0, mongoose_1.model)("primarypagetesttype", PrimaryPageTestTypeSchema);
40
+ exports.default = PrimaryPageTestType;
@@ -41,7 +41,36 @@ const TestTimelineSchema = new mongoose_1.Schema({
41
41
  },
42
42
  event: {
43
43
  type: String,
44
- enum: ["test_created", "test_updated", "test_status_changed", "test_deleted", "variant_created", "variant_updated", "variant_deleted", "traffic_allocation_changed", "page_targeting_updated", "audience_targeting_updated"],
44
+ enum: [
45
+ "test_created",
46
+ "test_updated",
47
+ "test_status_changed",
48
+ "test_deleted",
49
+ "test_duplicated",
50
+ "test_archived",
51
+ "test_unarchived",
52
+ "variant_created",
53
+ "variant_updated",
54
+ "variant_deleted",
55
+ "traffic_allocation_changed",
56
+ "code_updated",
57
+ "trigger_updated",
58
+ "goals_updated",
59
+ "environments_updated",
60
+ "pages_updated",
61
+ "audiences_updated",
62
+ "pages_match_type_updated",
63
+ "audiences_match_type_updated",
64
+ "page_targeting_updated",
65
+ "page_targeting_created",
66
+ "page_targeting_deleted",
67
+ "audience_targeting_updated",
68
+ "audience_targeting_created",
69
+ "audience_targeting_deleted",
70
+ "personalization_created",
71
+ "personalization_updated",
72
+ "personalization_deleted",
73
+ ],
45
74
  },
46
75
  organizationId: {
47
76
  type: mongoose_1.default.Schema.Types.ObjectId,
package/index.ts CHANGED
@@ -59,6 +59,7 @@ import Provider from "./src/models/Provider";
59
59
  import ApiLog from "./src/models/ApiLog";
60
60
  import { ProviderType } from "./src/models/Provider";
61
61
  import OldReport from "./src/models/OldReport";
62
+ import PrimaryPageTestType from "./src/models/PrimaryPageTestType";
62
63
  async function seedRoles() {
63
64
  const checkRoles = await Role.countDocuments();
64
65
  if (checkRoles < RolesConstants.length) {
@@ -79,7 +80,7 @@ async function seedRoles() {
79
80
  },
80
81
  },
81
82
  ]);
82
- })
83
+ }),
83
84
  );
84
85
  console.log("Roles seeded successfully");
85
86
  }
@@ -87,7 +88,7 @@ async function seedRoles() {
87
88
 
88
89
  export async function connect(
89
90
  uri: string,
90
- options?: mongoose.ConnectOptions | undefined
91
+ options?: mongoose.ConnectOptions | undefined,
91
92
  ): Promise<typeof mongoose> {
92
93
  if (uri) {
93
94
  if (mongoose.connection.readyState === 1) {
@@ -138,6 +139,7 @@ export {
138
139
  Page,
139
140
  PageElement,
140
141
  PageTestType,
142
+ PrimaryPageTestType,
141
143
  Portfolio,
142
144
  ReadNotification,
143
145
  Role,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-models",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
4
4
  "description": "Common models for codebase",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -22,7 +22,6 @@ export interface IConditionItem extends Document {
22
22
  rules_value?: string;
23
23
  }
24
24
 
25
-
26
25
  export interface IConditionGroup extends Document {
27
26
  iid: string;
28
27
  name: string;
@@ -40,12 +39,17 @@ export interface IAudienceConditionItem extends Document {
40
39
  rules_value: string;
41
40
  }
42
41
 
42
+ export interface IInteractionData extends Document {
43
+ event: string;
44
+ metadata: mongoose.Schema.Types.Mixed;
45
+ }
43
46
  export interface IAudience extends Document {
44
47
  iid: string;
45
48
  organizationId?: mongoose.Schema.Types.ObjectId;
46
49
  newSchema: boolean;
47
50
  name: string;
48
51
  rules_js?: string;
52
+ interaction_data: IInteractionData[];
49
53
  generic: boolean;
50
54
  client?: mongoose.Schema.Types.ObjectId;
51
55
  createdBy?: mongoose.Schema.Types.ObjectId;
@@ -53,50 +57,59 @@ export interface IAudience extends Document {
53
57
  api_name: string;
54
58
  }
55
59
 
60
+ const InteractionDataSchema = new Schema<IInteractionData>({
61
+ event: {
62
+ type: String,
63
+ required: true,
64
+ trim: true,
65
+ },
66
+ metadata: {
67
+ type: mongoose.Schema.Types.Mixed,
68
+ default: null,
69
+ },
70
+ });
56
71
 
57
- const ConditionItemSchema = new Schema<IConditionItem>(
58
- {
59
- iid: {
60
- type: String,
61
- trim: true,
62
- default: () => generateRandomIID(),
63
- unique: true,
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
- },
71
- rules_js: {
72
- type: String,
73
- default: "return true",
74
- trim: true,
75
- },
76
- rules_label: {
77
- type: String,
78
- default: "Custom",
79
- trim: true,
80
- },
81
- metadata: {
82
- type: mongoose.Schema.Types.Mixed,
83
- default: null,
84
- },
85
- rules_value: {
86
- type: String,
87
- default: "Custom",
88
- trim: true,
89
- },
90
- conditionGroupLabel: {
91
- type: String,
92
- default: "advanced",
93
- trim: true,
94
- enum: ["advanced", "custom", "common"],
95
- get: (value: string) => value.toLowerCase(),
96
- set: (value: string) => value.toLowerCase(),
97
- },
72
+ const ConditionItemSchema = new Schema<IConditionItem>({
73
+ iid: {
74
+ type: String,
75
+ trim: true,
76
+ default: () => generateRandomIID(),
77
+ unique: true,
98
78
  },
99
- );
79
+ type: {
80
+ type: String,
81
+ default: "advanced_js_code",
82
+ trim: true,
83
+ // enum: ["js_code", "url_param", "cookie", "header", "user_agent", "location", "local_storage", "session_storage", "query_param"],
84
+ },
85
+ rules_js: {
86
+ type: String,
87
+ default: "return true",
88
+ trim: true,
89
+ },
90
+ rules_label: {
91
+ type: String,
92
+ default: "Custom",
93
+ trim: true,
94
+ },
95
+ metadata: {
96
+ type: mongoose.Schema.Types.Mixed,
97
+ default: null,
98
+ },
99
+ rules_value: {
100
+ type: String,
101
+ default: "Custom",
102
+ trim: true,
103
+ },
104
+ conditionGroupLabel: {
105
+ type: String,
106
+ default: "advanced",
107
+ trim: true,
108
+ enum: ["advanced", "custom", "common"],
109
+ get: (value: string) => value.toLowerCase(),
110
+ set: (value: string) => value.toLowerCase(),
111
+ },
112
+ });
100
113
  const conditionGroupSchema = new Schema<IConditionGroup>({
101
114
  iid: {
102
115
  type: String,
@@ -139,7 +152,7 @@ const ConditionsSchema = new Schema<IConditionItem[]>([
139
152
  default: "AND",
140
153
  },
141
154
  conditionGroups: [conditionGroupSchema],
142
- }
155
+ },
143
156
  ]);
144
157
 
145
158
  const AudienceSchema = new Schema<IAudience>(
@@ -163,7 +176,10 @@ const AudienceSchema = new Schema<IAudience>(
163
176
  },
164
177
  rules_js: {
165
178
  type: String,
179
+ default: "return true",
180
+ trim: true,
166
181
  },
182
+ interaction_data: InteractionDataSchema,
167
183
  generic: {
168
184
  type: Boolean,
169
185
  default: false,
@@ -188,10 +204,10 @@ const AudienceSchema = new Schema<IAudience>(
188
204
  },
189
205
  {
190
206
  timestamps: true,
191
- }
207
+ },
192
208
  );
193
209
 
194
- AudienceSchema.pre('save', async function (next) {
210
+ AudienceSchema.pre("save", async function (next) {
195
211
  if (!this.iid) {
196
212
  let unique = false;
197
213
  while (!unique) {
@@ -208,6 +224,7 @@ AudienceSchema.pre('save', async function (next) {
208
224
 
209
225
  AudienceSchema.index({ iid: 1 }, { unique: true });
210
226
 
211
- const Audience = mongoose.models.audience || model<IAudience>("audience", AudienceSchema);
227
+ const Audience =
228
+ mongoose.models.audience || model<IAudience>("audience", AudienceSchema);
212
229
 
213
230
  export default Audience;
@@ -3,6 +3,7 @@ import mongoose, { Document, Schema, model } from "mongoose";
3
3
  export interface IPageTestType extends Document {
4
4
  name: string;
5
5
  details?: string;
6
+ category: string;
6
7
  isActive?: boolean;
7
8
  createdAt?: Date;
8
9
  updatedAt?: Date;
@@ -10,60 +11,66 @@ export interface IPageTestType extends Document {
10
11
  metadata?: mongoose.Schema.Types.Mixed;
11
12
  client?: mongoose.Schema.Types.ObjectId;
12
13
  createdBy?: mongoose.Schema.Types.ObjectId;
13
- generic?: boolean;
14
14
  }
15
-
16
- const PageTestTypeSchema = new Schema<IPageTestType>({
17
- organizationId: {
18
- type: mongoose.Schema.Types.ObjectId,
19
- ref: "organization",
20
- default: null,
21
- },
22
- name: {
23
- type: String,
24
- required: true,
25
- unique: true,
26
- trim: true,
27
- },
28
- details: {
29
- type: String,
30
- default: "",
31
- trim: true,
32
- },
33
- metadata: {
34
- type: mongoose.Schema.Types.Mixed,
35
- default: null,
15
+ const PageTestTypeSchema = new Schema<IPageTestType>(
16
+ {
17
+ organizationId: {
18
+ type: mongoose.Schema.Types.ObjectId,
19
+ ref: "organization",
20
+ default: null,
21
+ },
22
+ category: {
23
+ type: String,
24
+ required: true,
25
+ trim: true,
26
+ // make valye lowercase
27
+ get: (value: string) => value.toLowerCase(),
28
+ set: (value: string) => value.toLowerCase(),
29
+ },
30
+ name: {
31
+ type: String,
32
+ required: true,
33
+ unique: true,
34
+ trim: true,
35
+ },
36
+ details: {
37
+ type: String,
38
+ default: "",
39
+ trim: true,
40
+ },
41
+ metadata: {
42
+ type: mongoose.Schema.Types.Mixed,
43
+ default: null,
44
+ },
45
+ client: {
46
+ type: mongoose.Schema.Types.ObjectId,
47
+ ref: "client",
48
+ default: null,
49
+ },
50
+ createdBy: {
51
+ type: mongoose.Schema.Types.ObjectId,
52
+ ref: "user",
53
+ default: null,
54
+ },
55
+ createdAt: {
56
+ type: Date,
57
+ default: new Date(),
58
+ },
59
+ isActive: {
60
+ type: Boolean,
61
+ default: true,
62
+ },
36
63
  },
37
- client: {
38
- type: mongoose.Schema.Types.ObjectId,
39
- ref: "client",
40
- default: null,
64
+ {
65
+ timestamps: true,
41
66
  },
42
- createdBy: {
43
- type: mongoose.Schema.Types.ObjectId,
44
- ref: "user",
45
- default: null,
46
- },
47
- generic: {
48
- type: Boolean,
49
- default: true,
50
- },
51
- createdAt: {
52
- type: Date,
53
- default: new Date(),
54
- },
55
- isActive: {
56
- type: Boolean,
57
- default: true,
58
- }
59
- }, {
60
- timestamps: true
61
- });
67
+ );
62
68
 
63
69
  // Compound indexes for common query patterns
64
70
  PageTestTypeSchema.index({ name: 1, isActive: 1 });
65
71
 
66
-
67
- const PageTestType = mongoose.models.pagetesttype || model<IPageTestType>("pagetesttype", PageTestTypeSchema);
72
+ const PageTestType =
73
+ mongoose.models.pagetesttype ||
74
+ model<IPageTestType>("pagetesttype", PageTestTypeSchema);
68
75
 
69
76
  export default PageTestType;
@@ -0,0 +1,26 @@
1
+ import mongoose, { Document, Schema, model } from "mongoose";
2
+
3
+ export interface IPrimaryPageTestType extends Document {
4
+ test?: mongoose.Schema.Types.ObjectId;
5
+ }
6
+ const PrimaryPageTestTypeSchema = new Schema<IPrimaryPageTestType>(
7
+ {
8
+ test: {
9
+ type: mongoose.Schema.Types.ObjectId,
10
+ ref: "test",
11
+ required: true,
12
+ },
13
+ },
14
+ {
15
+ timestamps: true,
16
+ },
17
+ );
18
+
19
+ // Compound indexes for common query patterns
20
+ PrimaryPageTestTypeSchema.index({ test: 1 });
21
+
22
+ const PrimaryPageTestType =
23
+ mongoose.models.primarypagetesttype ||
24
+ model<IPrimaryPageTestType>("primarypagetesttype", PrimaryPageTestTypeSchema);
25
+
26
+ export default PrimaryPageTestType;
@@ -20,7 +20,36 @@ const TestTimelineSchema = new Schema<ITestTimeline>({
20
20
  },
21
21
  event: {
22
22
  type: String,
23
- enum: ["test_created", "test_updated","test_status_changed", "test_deleted", "variant_created", "variant_updated", "variant_deleted", "traffic_allocation_changed", "page_targeting_updated", "audience_targeting_updated"],
23
+ enum: [
24
+ "test_created",
25
+ "test_updated",
26
+ "test_status_changed",
27
+ "test_deleted",
28
+ "test_duplicated",
29
+ "test_archived",
30
+ "test_unarchived",
31
+ "variant_created",
32
+ "variant_updated",
33
+ "variant_deleted",
34
+ "traffic_allocation_changed",
35
+ "code_updated",
36
+ "trigger_updated",
37
+ "goals_updated",
38
+ "environments_updated",
39
+ "pages_updated",
40
+ "audiences_updated",
41
+ "pages_match_type_updated",
42
+ "audiences_match_type_updated",
43
+ "page_targeting_updated",
44
+ "page_targeting_created",
45
+ "page_targeting_deleted",
46
+ "audience_targeting_updated",
47
+ "audience_targeting_created",
48
+ "audience_targeting_deleted",
49
+ "personalization_created",
50
+ "personalization_updated",
51
+ "personalization_deleted",
52
+ ],
24
53
  },
25
54
  organizationId: {
26
55
  type: mongoose.Schema.Types.ObjectId,