codebase-models 2.0.5 → 2.0.7
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 +3 -1
- package/dist/index.js +6 -1
- package/dist/src/constant.d.ts +7 -0
- package/dist/src/constant.js +17 -0
- package/dist/src/models/Announcement.d.ts +1 -0
- package/dist/src/models/Announcement.js +31 -0
- package/dist/src/models/Audience.d.ts +1 -0
- package/dist/src/models/Audience.js +31 -0
- package/dist/src/models/BqPreCompiledData.d.ts +1 -0
- package/dist/src/models/BqPreCompiledData.js +31 -0
- package/dist/src/models/Client.d.ts +1 -0
- package/dist/src/models/Client.js +31 -0
- package/dist/src/models/ClientAdditionalRevenue.d.ts +3 -1
- package/dist/src/models/ClientAdditionalRevenue.js +48 -0
- package/dist/src/models/ClientLearning.d.ts +1 -0
- package/dist/src/models/ClientLearning.js +31 -0
- package/dist/src/models/ClientLinks.d.ts +1 -0
- package/dist/src/models/ClientLinks.js +31 -0
- package/dist/src/models/ClientNextSteps.d.ts +1 -0
- package/dist/src/models/ClientNextSteps.js +30 -0
- package/dist/src/models/ClientNote.d.ts +1 -0
- package/dist/src/models/ClientNote.js +31 -0
- package/dist/src/models/ClientScript.d.ts +12 -11
- package/dist/src/models/ClientScript.js +54 -9
- package/dist/src/models/ClientStrategy.d.ts +1 -0
- package/dist/src/models/ClientStrategy.js +31 -0
- package/dist/src/models/CustomQuery.d.ts +1 -0
- package/dist/src/models/CustomQuery.js +30 -1
- package/dist/src/models/Environment.d.ts +3 -0
- package/dist/src/models/Environment.js +38 -0
- package/dist/src/models/Goal.d.ts +1 -0
- package/dist/src/models/Goal.js +31 -2
- package/dist/src/models/Page.d.ts +2 -0
- package/dist/src/models/Page.js +48 -0
- package/dist/src/models/PageElement.js +0 -1
- package/dist/src/models/PageTestType.js +0 -2
- package/dist/src/models/Report.d.ts +1 -0
- package/dist/src/models/Report.js +30 -0
- package/dist/src/models/Role.js +0 -3
- package/dist/src/models/Snippet.js +0 -4
- package/dist/src/models/StageInCustomerJourney.d.ts +1 -0
- package/dist/src/models/StageInCustomerJourney.js +31 -4
- package/dist/src/models/Test.d.ts +3 -0
- package/dist/src/models/Test.js +47 -2
- package/dist/src/models/TestTimeline.d.ts +39 -0
- package/dist/src/models/TestTimeline.js +79 -0
- package/index.ts +4 -1
- package/package.json +3 -2
- package/src/constant.ts +17 -0
- package/src/models/Announcement.ts +22 -0
- package/src/models/Audience.ts +23 -0
- package/src/models/BqPreCompiledData.ts +22 -0
- package/src/models/Client.ts +22 -0
- package/src/models/ClientAdditionalRevenue.ts +42 -1
- package/src/models/ClientLearning.ts +22 -0
- package/src/models/ClientLinks.ts +23 -2
- package/src/models/ClientNextSteps.ts +20 -0
- package/src/models/ClientNote.ts +22 -1
- package/src/models/ClientScript.ts +56 -21
- package/src/models/ClientStrategy.ts +24 -0
- package/src/models/CustomQuery.ts +22 -2
- package/src/models/Environment.ts +33 -1
- package/src/models/Goal.ts +22 -3
- package/src/models/Page.ts +43 -0
- package/src/models/PageElement.ts +0 -1
- package/src/models/PageTestType.ts +0 -2
- package/src/models/Report.ts +22 -0
- package/src/models/Role.ts +1 -3
- package/src/models/Snippet.ts +1 -4
- package/src/models/StageInCustomerJourney.ts +22 -4
- package/src/models/Test.ts +42 -4
- package/src/models/TestTimeline.ts +61 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import mongoose, { Document, Mongoose, Schema, model } from "mongoose";
|
|
2
2
|
import slug from "mongoose-slug-updater"
|
|
3
|
+
import { generateRandomIID } from "../constant";
|
|
3
4
|
mongoose.plugin(slug)
|
|
4
5
|
|
|
5
6
|
export interface IStageInCustomerJourney extends Document {
|
|
7
|
+
iid: string;
|
|
6
8
|
name?: string;
|
|
7
9
|
stages?: string;
|
|
8
10
|
slug?: string;
|
|
@@ -13,11 +15,14 @@ export interface IStageInCustomerJourney extends Document {
|
|
|
13
15
|
|
|
14
16
|
const StageInCustomerJourneySchema = new Schema<IStageInCustomerJourney>(
|
|
15
17
|
{
|
|
18
|
+
iid: {
|
|
19
|
+
type: String,
|
|
20
|
+
unique: true,
|
|
21
|
+
},
|
|
16
22
|
name: {
|
|
17
23
|
type: String,
|
|
18
24
|
required: true,
|
|
19
25
|
trim: true,
|
|
20
|
-
index: true,
|
|
21
26
|
},
|
|
22
27
|
stages: {
|
|
23
28
|
type: String,
|
|
@@ -35,17 +40,14 @@ const StageInCustomerJourneySchema = new Schema<IStageInCustomerJourney>(
|
|
|
35
40
|
type: mongoose.Schema.Types.ObjectId,
|
|
36
41
|
default: null,
|
|
37
42
|
ref: "organization",
|
|
38
|
-
index: true,
|
|
39
43
|
},
|
|
40
44
|
client: {
|
|
41
45
|
type: mongoose.Schema.Types.ObjectId,
|
|
42
46
|
ref: "client",
|
|
43
|
-
index: true,
|
|
44
47
|
},
|
|
45
48
|
isActive: {
|
|
46
49
|
type: Boolean,
|
|
47
50
|
default: true,
|
|
48
|
-
index: true,
|
|
49
51
|
}
|
|
50
52
|
},
|
|
51
53
|
{
|
|
@@ -53,6 +55,22 @@ const StageInCustomerJourneySchema = new Schema<IStageInCustomerJourney>(
|
|
|
53
55
|
}
|
|
54
56
|
);
|
|
55
57
|
|
|
58
|
+
StageInCustomerJourneySchema.pre('save', async function(next) {
|
|
59
|
+
if (!this.iid) {
|
|
60
|
+
let unique = false;
|
|
61
|
+
while (!unique) {
|
|
62
|
+
const id = generateRandomIID();
|
|
63
|
+
const existing = await mongoose.models.stageincustomerjourney.findOne({ iid: id });
|
|
64
|
+
if (!existing) {
|
|
65
|
+
this.iid = id;
|
|
66
|
+
unique = true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
next();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
StageInCustomerJourneySchema.index({ iid: 1 }, { unique: true });
|
|
56
74
|
// Compound indexes for common query patterns
|
|
57
75
|
// StageInCustomerJourneySchema.index({ client: 1, slug: 1 });
|
|
58
76
|
const StageInCustomerJourney = mongoose.models.stageincustomerjourney || model<IStageInCustomerJourney>(
|
package/src/models/Test.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
+
import { generateRandomIID } from "../constant";
|
|
2
3
|
|
|
3
4
|
export interface IVariations extends Document {
|
|
5
|
+
iid: string;
|
|
4
6
|
name: string;
|
|
5
7
|
css_code: string;
|
|
6
8
|
baseline: boolean;
|
|
@@ -17,6 +19,7 @@ export interface IVariations extends Document {
|
|
|
17
19
|
export interface ITest extends Document {
|
|
18
20
|
// Core test properties
|
|
19
21
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
22
|
+
iid: string;
|
|
20
23
|
status: string;
|
|
21
24
|
name: string;
|
|
22
25
|
traffic_allocation: number;
|
|
@@ -47,7 +50,6 @@ export interface ITest extends Document {
|
|
|
47
50
|
hypothesis?: mongoose.Schema.Types.ObjectId;
|
|
48
51
|
trigger?: mongoose.Schema.Types.ObjectId[];
|
|
49
52
|
stageincustomerjourney?: mongoose.Schema.Types.ObjectId;
|
|
50
|
-
|
|
51
53
|
// Test configuration
|
|
52
54
|
property?: mongoose.Schema.Types.Mixed;
|
|
53
55
|
platform: string;
|
|
@@ -63,6 +65,7 @@ export interface ITest extends Document {
|
|
|
63
65
|
testid: string;
|
|
64
66
|
testtool: string;
|
|
65
67
|
personalization: boolean;
|
|
68
|
+
qaMode: boolean;
|
|
66
69
|
kameleoontestdetails: mongoose.Schema.Types.Mixed;
|
|
67
70
|
vwotestdetails: mongoose.Schema.Types.Mixed;
|
|
68
71
|
triggerevents: any[];
|
|
@@ -76,6 +79,7 @@ export interface ITest extends Document {
|
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
const VariationsSchema = new Schema<IVariations>({
|
|
82
|
+
iid: { type: String, unique: true },
|
|
79
83
|
name: { type: String, required: true },
|
|
80
84
|
css_code: { type: String, default: "" },
|
|
81
85
|
baseline: { type: Boolean, default: false },
|
|
@@ -91,6 +95,7 @@ const VariationsSchema = new Schema<IVariations>({
|
|
|
91
95
|
|
|
92
96
|
const TestSchema = new Schema<ITest>(
|
|
93
97
|
{
|
|
98
|
+
iid: { type: String, unique: true },
|
|
94
99
|
organizationId: {
|
|
95
100
|
type: mongoose.Schema.Types.ObjectId,
|
|
96
101
|
ref: "organization",
|
|
@@ -99,7 +104,7 @@ const TestSchema = new Schema<ITest>(
|
|
|
99
104
|
status: {
|
|
100
105
|
type: String,
|
|
101
106
|
default: "draft",
|
|
102
|
-
enum: ["live", "draft", "ended", "paused", "preview", "running"]
|
|
107
|
+
enum: ["live", "draft", "ended", "paused", "preview", "running", "discard"]
|
|
103
108
|
},
|
|
104
109
|
name: { type: String, required: true },
|
|
105
110
|
traffic_allocation: { type: Number, default: 100 },
|
|
@@ -160,7 +165,7 @@ const TestSchema = new Schema<ITest>(
|
|
|
160
165
|
},
|
|
161
166
|
hypothesis: {
|
|
162
167
|
type: mongoose.Schema.Types.ObjectId,
|
|
163
|
-
ref: "hypos"
|
|
168
|
+
ref: "hypos"
|
|
164
169
|
},
|
|
165
170
|
trigger: {
|
|
166
171
|
type: [mongoose.Schema.Types.ObjectId],
|
|
@@ -169,7 +174,8 @@ const TestSchema = new Schema<ITest>(
|
|
|
169
174
|
},
|
|
170
175
|
stageincustomerjourney: {
|
|
171
176
|
type: mongoose.Schema.Types.ObjectId,
|
|
172
|
-
ref: "stageincustomerjourney"
|
|
177
|
+
ref: "stageincustomerjourney",
|
|
178
|
+
default: null
|
|
173
179
|
},
|
|
174
180
|
|
|
175
181
|
// Test configuration
|
|
@@ -187,6 +193,7 @@ const TestSchema = new Schema<ITest>(
|
|
|
187
193
|
testid: { type: String, default: null },
|
|
188
194
|
testtool: { type: String, default: "" },
|
|
189
195
|
personalization: { type: Boolean, default: false },
|
|
196
|
+
qaMode: { type: Boolean, default: false },
|
|
190
197
|
kameleoontestdetails: { type: mongoose.Schema.Types.Mixed, default: null },
|
|
191
198
|
vwotestdetails: { type: mongoose.Schema.Types.Mixed, default: null },
|
|
192
199
|
triggerevents: { type: [], default: [] },
|
|
@@ -202,6 +209,37 @@ const TestSchema = new Schema<ITest>(
|
|
|
202
209
|
timestamps: true
|
|
203
210
|
}
|
|
204
211
|
);
|
|
212
|
+
TestSchema.pre('save', async function(next) {
|
|
213
|
+
if (!this.iid) {
|
|
214
|
+
let unique = false;
|
|
215
|
+
while (!unique) {
|
|
216
|
+
const id = generateRandomIID();
|
|
217
|
+
const existing = await mongoose.models.test.findOne({ iid: id });
|
|
218
|
+
if (!existing) {
|
|
219
|
+
this.iid = id;
|
|
220
|
+
unique = true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// For each Variation inside Test
|
|
225
|
+
for (const variation of this.variations) {
|
|
226
|
+
if (!variation.iid) {
|
|
227
|
+
let uniqueVar = false;
|
|
228
|
+
while (!uniqueVar) {
|
|
229
|
+
const id = generateRandomIID();
|
|
230
|
+
const existingVar = await mongoose.models.test.findOne({ "variations.iid": id });
|
|
231
|
+
if (!existingVar) {
|
|
232
|
+
variation.iid = id;
|
|
233
|
+
uniqueVar = true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
next();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
TestSchema.index({ iid: 1 }, { unique: true });
|
|
205
243
|
// Add compound indexes for better query performance
|
|
206
244
|
TestSchema.index({ client: 1, status: 1 });
|
|
207
245
|
TestSchema.index({ client: 1, status: 1, livedate: 1 });
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
+
import { generateRandomIID } from "../constant";
|
|
3
|
+
|
|
4
|
+
export interface ITestTimeline extends Document {
|
|
5
|
+
iid: string;
|
|
6
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
7
|
+
test: mongoose.Schema.Types.ObjectId;
|
|
8
|
+
event: string;
|
|
9
|
+
client: mongoose.Schema.Types.ObjectId;
|
|
10
|
+
user: mongoose.Schema.Types.ObjectId;
|
|
11
|
+
changes: {
|
|
12
|
+
type: mongoose.Schema.Types.Mixed,
|
|
13
|
+
default: {},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const TestTimelineSchema = new Schema<ITestTimeline>({
|
|
17
|
+
iid: {
|
|
18
|
+
type: String,
|
|
19
|
+
unique: true,
|
|
20
|
+
},
|
|
21
|
+
event: {
|
|
22
|
+
type: String,
|
|
23
|
+
enum: ["test_created", "test_updated","test_status_changed", "test_deleted", "variant_created", "variant_updated", "variant_deleted"],
|
|
24
|
+
},
|
|
25
|
+
organizationId: {
|
|
26
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
27
|
+
ref: "organization",
|
|
28
|
+
default: null,
|
|
29
|
+
},
|
|
30
|
+
client: {
|
|
31
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
32
|
+
ref: "client",
|
|
33
|
+
},
|
|
34
|
+
test: {
|
|
35
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
36
|
+
ref: "test",
|
|
37
|
+
},
|
|
38
|
+
user: {
|
|
39
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
40
|
+
ref: "user",
|
|
41
|
+
},
|
|
42
|
+
changes: {
|
|
43
|
+
type: mongoose.Schema.Types.Mixed,
|
|
44
|
+
default: {},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
timestamps: true,
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
TestTimelineSchema.pre("save", async function (next) {
|
|
52
|
+
if (!this.iid) {
|
|
53
|
+
this.iid = generateRandomIID();
|
|
54
|
+
}
|
|
55
|
+
next();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const TestTimeline = mongoose.models.testTimeline || model<ITestTimeline>("testTimeline", TestTimelineSchema);
|
|
60
|
+
|
|
61
|
+
export default TestTimeline;
|