codebase-models 1.0.7 → 2.0.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.
- package/.github/workflows/npm-publish.yml +33 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +7 -5
- package/dist/src/models/Announcement.d.ts +6 -5
- package/dist/src/models/Announcement.js +29 -9
- package/dist/src/models/Audience.d.ts +1 -0
- package/dist/src/models/Audience.js +5 -0
- package/dist/src/models/{Experiments.d.ts → BqPreCompiledData.d.ts} +12 -30
- package/dist/src/models/{ClientExperiment.js → BqPreCompiledData.js} +26 -46
- package/dist/src/models/CVRReport.d.ts +1 -0
- package/dist/src/models/CVRReport.js +13 -0
- package/dist/src/models/Client.d.ts +1 -1
- package/dist/src/models/Client.js +31 -51
- package/dist/src/models/ClientAdditionalRevenue.d.ts +1 -1
- package/dist/src/models/ClientAdditionalRevenue.js +3 -2
- package/dist/src/models/ClientLearning.d.ts +1 -1
- package/dist/src/models/ClientLearning.js +10 -6
- package/dist/src/models/ClientLinks.d.ts +1 -1
- package/dist/src/models/ClientLinks.js +15 -6
- package/dist/src/models/ClientNextSteps.d.ts +1 -1
- package/dist/src/models/ClientNextSteps.js +3 -2
- package/dist/src/models/ClientNote.d.ts +1 -1
- package/dist/src/models/ClientNote.js +3 -2
- package/dist/src/models/ClientReportsTemp.d.ts +1 -1
- package/dist/src/models/ClientReportsTemp.js +20 -2
- package/dist/src/models/ClientRetention.d.ts +1 -0
- package/dist/src/models/ClientRetention.js +18 -0
- package/dist/src/models/ClientScript.d.ts +1 -1
- package/dist/src/models/ClientScript.js +24 -8
- package/dist/src/models/ClientStrategy.d.ts +1 -1
- package/dist/src/models/ClientStrategy.js +3 -2
- package/dist/src/models/ClientSurvay.d.ts +1 -0
- package/dist/src/models/ClientSurvay.js +5 -0
- package/dist/src/models/Environment.d.ts +2 -0
- package/dist/src/models/Environment.js +26 -2
- package/dist/src/models/Faqs.d.ts +1 -0
- package/dist/src/models/Faqs.js +5 -0
- package/dist/src/models/Feedback.d.ts +1 -1
- package/dist/src/models/Feedback.js +3 -2
- package/dist/src/models/Goal.d.ts +2 -1
- package/dist/src/models/Goal.js +33 -11
- package/dist/src/models/Hypothesis.d.ts +2 -0
- package/dist/src/models/Hypothesis.js +49 -9
- package/dist/src/models/HypothesisSheet.d.ts +1 -1
- package/dist/src/models/HypothesisSheet.js +26 -2
- package/dist/src/models/LandingPages.d.ts +3 -0
- package/dist/src/models/LandingPages.js +29 -0
- package/dist/src/models/NewIdeas.d.ts +1 -1
- package/dist/src/models/NewIdeas.js +3 -2
- package/dist/src/models/Notification.d.ts +1 -0
- package/dist/src/models/Notification.js +29 -1
- package/dist/src/models/{ClientExperiment.d.ts → Organization.d.ts} +18 -29
- package/dist/src/models/{Experiments.js → Organization.js} +36 -54
- package/dist/src/models/Page.d.ts +3 -1
- package/dist/src/models/Page.js +56 -4
- package/dist/src/models/PageElement.d.ts +3 -0
- package/dist/src/models/PageElement.js +59 -7
- package/dist/src/models/PageTestType.d.ts +2 -0
- package/dist/src/models/PageTestType.js +41 -5
- package/dist/src/models/Portfolio.d.ts +1 -0
- package/dist/src/models/Portfolio.js +5 -0
- package/dist/src/models/PrecalculationFilters.d.ts +36 -0
- package/dist/src/models/PrecalculationFilters.js +77 -0
- package/dist/src/models/QueryLog.d.ts +1 -1
- package/dist/src/models/QueryLog.js +3 -2
- package/dist/src/models/ReadNotification.d.ts +1 -0
- package/dist/src/models/ReadNotification.js +29 -1
- package/dist/src/models/Report.d.ts +2 -1
- package/dist/src/models/Report.js +32 -48
- package/dist/src/models/Role.d.ts +3 -0
- package/dist/src/models/Role.js +50 -7
- package/dist/src/models/SavedSegment.d.ts +1 -0
- package/dist/src/models/SavedSegment.js +5 -0
- package/dist/src/models/Segment.d.ts +1 -0
- package/dist/src/models/Segment.js +5 -0
- package/dist/src/models/SegmentCombination.d.ts +1 -0
- package/dist/src/models/SegmentCombination.js +5 -0
- package/dist/src/models/Snippet.d.ts +2 -1
- package/dist/src/models/Snippet.js +28 -3
- package/dist/src/models/StageInCustomerJourney.d.ts +3 -1
- package/dist/src/models/StageInCustomerJourney.js +56 -4
- package/dist/src/models/Tag.d.ts +1 -0
- package/dist/src/models/Tag.js +29 -1
- package/dist/src/models/Temp.d.ts +1 -0
- package/dist/src/models/Temp.js +29 -1
- package/dist/src/models/Test.d.ts +16 -15
- package/dist/src/models/Test.js +82 -185
- package/dist/src/models/TestSequentialValue.d.ts +1 -0
- package/dist/src/models/TestSequentialValue.js +5 -0
- package/dist/src/models/Tier.d.ts +1 -0
- package/dist/src/models/Tier.js +29 -1
- package/dist/src/models/Trigger.d.ts +1 -0
- package/dist/src/models/Trigger.js +29 -1
- package/dist/src/models/User.d.ts +1 -0
- package/dist/src/models/User.js +9 -10
- package/index.ts +6 -4
- package/package.json +1 -1
- package/src/models/Announcement.ts +50 -27
- package/src/models/Audience.ts +6 -0
- package/src/models/BqPreCompiledData.ts +62 -0
- package/src/models/CVRReport.ts +17 -0
- package/src/models/Client.ts +39 -59
- package/src/models/ClientAdditionalRevenue.ts +4 -3
- package/src/models/ClientLearning.ts +11 -7
- package/src/models/ClientLinks.ts +18 -7
- package/src/models/ClientNextSteps.ts +4 -3
- package/src/models/ClientNote.ts +4 -3
- package/src/models/ClientReportsTemp.ts +24 -3
- package/src/models/ClientRetention.ts +27 -1
- package/src/models/ClientScript.ts +26 -9
- package/src/models/ClientStrategy.ts +4 -3
- package/src/models/ClientSurvay.ts +6 -0
- package/src/models/Environment.ts +31 -3
- package/src/models/Faqs.ts +6 -0
- package/src/models/Feedback.ts +4 -3
- package/src/models/Goal.ts +36 -12
- package/src/models/Hypothesis.ts +29 -8
- package/src/models/HypothesisSheet.ts +3 -2
- package/src/models/LandingPages.ts +34 -0
- package/src/models/NewIdeas.ts +4 -3
- package/src/models/Notification.ts +6 -0
- package/src/models/Organization.ts +86 -0
- package/src/models/Page.ts +62 -5
- package/src/models/PageElement.ts +38 -7
- package/src/models/PageTestType.ts +21 -4
- package/src/models/Portfolio.ts +6 -0
- package/src/models/PrecalculationFilters.ts +67 -0
- package/src/models/QueryLog.ts +4 -3
- package/src/models/ReadNotification.ts +6 -0
- package/src/models/Report.ts +54 -66
- package/src/models/Role.ts +31 -6
- package/src/models/SavedSegment.ts +6 -0
- package/src/models/Segment.ts +6 -0
- package/src/models/SegmentCombination.ts +6 -0
- package/src/models/Snippet.ts +32 -4
- package/src/models/StageInCustomerJourney.ts +33 -5
- package/src/models/Tag.ts +6 -0
- package/src/models/Temp.ts +6 -0
- package/src/models/Test.ts +155 -243
- package/src/models/TestSequentialValue.ts +6 -0
- package/src/models/Tier.ts +6 -0
- package/src/models/Trigger.ts +6 -0
- package/src/models/User.ts +11 -10
- package/src/models/ClientExperiment.ts +0 -113
- package/src/models/Experiments.ts +0 -118
package/src/models/Page.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
2
|
import slug from "mongoose-slug-updater"
|
|
3
3
|
mongoose.plugin(slug)
|
|
4
|
+
|
|
4
5
|
export interface IUrltargetings extends Document {
|
|
5
6
|
type: string;
|
|
6
7
|
url: string;
|
|
@@ -10,24 +11,32 @@ export interface IUrltargetings extends Document {
|
|
|
10
11
|
export interface IPage extends Document {
|
|
11
12
|
name: string;
|
|
12
13
|
client?: mongoose.Schema.Types.ObjectId;
|
|
14
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
13
15
|
trigger: string;
|
|
14
16
|
trigger_js: string;
|
|
15
17
|
api_name: string;
|
|
16
18
|
poll_on_rules: Boolean;
|
|
17
19
|
deactivation_mode: string;
|
|
18
20
|
rules_js: string;
|
|
19
|
-
urltargetings: IUrltargetings;
|
|
21
|
+
urltargetings: IUrltargetings[];
|
|
22
|
+
isActive?: boolean;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
const UrltargetingsSchema = new Schema<IUrltargetings>({
|
|
23
26
|
type: {
|
|
24
27
|
type: String,
|
|
28
|
+
required: true,
|
|
29
|
+
trim: true,
|
|
25
30
|
},
|
|
26
31
|
url: {
|
|
27
32
|
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
trim: true,
|
|
28
35
|
},
|
|
29
36
|
url_type: {
|
|
30
37
|
type: String,
|
|
38
|
+
required: true,
|
|
39
|
+
trim: true,
|
|
31
40
|
},
|
|
32
41
|
});
|
|
33
42
|
|
|
@@ -35,35 +44,83 @@ const PageSchema = new Schema<IPage>({
|
|
|
35
44
|
name: {
|
|
36
45
|
type: String,
|
|
37
46
|
required: true,
|
|
47
|
+
trim: true,
|
|
48
|
+
index: true,
|
|
38
49
|
},
|
|
39
50
|
trigger: {
|
|
40
51
|
type: String,
|
|
41
|
-
default: "direct"
|
|
52
|
+
default: "direct",
|
|
53
|
+
trim: true,
|
|
54
|
+
index: true,
|
|
55
|
+
},
|
|
56
|
+
organizationId: {
|
|
57
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
58
|
+
ref: "organization",
|
|
59
|
+
default: null,
|
|
60
|
+
index: true,
|
|
42
61
|
},
|
|
43
62
|
client: {
|
|
44
63
|
type: mongoose.Schema.Types.ObjectId,
|
|
45
64
|
ref: "client",
|
|
65
|
+
required: true,
|
|
66
|
+
index: true,
|
|
46
67
|
},
|
|
47
68
|
trigger_js: {
|
|
48
69
|
type: String,
|
|
49
|
-
default: ""
|
|
70
|
+
default: "",
|
|
71
|
+
trim: true,
|
|
72
|
+
},
|
|
73
|
+
api_name: {
|
|
74
|
+
type: String,
|
|
75
|
+
slug: ["name"],
|
|
76
|
+
slugPaddingSize: 4,
|
|
77
|
+
unique: true,
|
|
78
|
+
trim: true,
|
|
50
79
|
},
|
|
51
|
-
api_name: { type: String, slug: ["name"], slugPaddingSize: 4, unique: true },
|
|
52
80
|
poll_on_rules: {
|
|
53
81
|
type: Boolean,
|
|
54
82
|
default: false,
|
|
83
|
+
index: true,
|
|
55
84
|
},
|
|
56
85
|
deactivation_mode: {
|
|
57
86
|
type: String,
|
|
58
87
|
default: "reset",
|
|
88
|
+
trim: true,
|
|
59
89
|
},
|
|
60
90
|
rules_js: {
|
|
61
91
|
type: String,
|
|
62
|
-
default:"return true"
|
|
92
|
+
default: "return true",
|
|
93
|
+
trim: true,
|
|
63
94
|
},
|
|
64
95
|
urltargetings: [UrltargetingsSchema],
|
|
96
|
+
isActive: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: true,
|
|
99
|
+
index: true,
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
timestamps: true
|
|
65
103
|
});
|
|
66
104
|
|
|
105
|
+
// Compound indexes for common query patterns
|
|
106
|
+
PageSchema.index({ client: 1, name: 1 }, { unique: true });
|
|
107
|
+
PageSchema.index({ client: 1, isActive: 1 });
|
|
108
|
+
PageSchema.index({ organizationId: 1, client: 1 });
|
|
109
|
+
PageSchema.index({ organizationId: 1, name: 1 });
|
|
110
|
+
|
|
111
|
+
// Text index for full-text search
|
|
112
|
+
// PageSchema.index({
|
|
113
|
+
// name: 'text',
|
|
114
|
+
// trigger_js: 'text',
|
|
115
|
+
// rules_js: 'text'
|
|
116
|
+
// }, {
|
|
117
|
+
// weights: {
|
|
118
|
+
// name: 10,
|
|
119
|
+
// trigger_js: 5,
|
|
120
|
+
// rules_js: 5
|
|
121
|
+
// }
|
|
122
|
+
// });
|
|
123
|
+
|
|
67
124
|
const Page = model<IPage>("page", PageSchema);
|
|
68
125
|
|
|
69
126
|
export default Page;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
+
import slug from "mongoose-slug-updater"
|
|
3
|
+
mongoose.plugin(slug)
|
|
2
4
|
|
|
3
5
|
export interface IPageElement extends Document {
|
|
4
6
|
name: string;
|
|
5
7
|
slug?: string;
|
|
8
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
9
|
+
client?: mongoose.Schema.Types.ObjectId;
|
|
10
|
+
isActive?: boolean;
|
|
6
11
|
createdAt?: Date;
|
|
7
12
|
updatedAt?: Date;
|
|
8
13
|
}
|
|
@@ -11,20 +16,46 @@ const PageElementSchema = new Schema<IPageElement>({
|
|
|
11
16
|
name: {
|
|
12
17
|
type: String,
|
|
13
18
|
required: true,
|
|
19
|
+
trim: true,
|
|
20
|
+
index: true,
|
|
14
21
|
},
|
|
15
22
|
slug: {
|
|
16
|
-
type: String,
|
|
23
|
+
type: String,
|
|
24
|
+
slug: ["name"],
|
|
25
|
+
slugPaddingSize: 4,
|
|
26
|
+
unique: true,
|
|
27
|
+
trim: true,
|
|
17
28
|
},
|
|
18
|
-
|
|
19
|
-
type:
|
|
20
|
-
|
|
29
|
+
organizationId: {
|
|
30
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
31
|
+
ref: "organization",
|
|
32
|
+
index: true,
|
|
33
|
+
default: null,
|
|
21
34
|
},
|
|
22
|
-
|
|
23
|
-
type:
|
|
24
|
-
|
|
35
|
+
client: {
|
|
36
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
37
|
+
ref: "client",
|
|
38
|
+
required: true,
|
|
39
|
+
index: true,
|
|
25
40
|
},
|
|
41
|
+
isActive: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: true,
|
|
44
|
+
index: true,
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
timestamps: true
|
|
26
48
|
});
|
|
27
49
|
|
|
50
|
+
// Compound indexes for common query patterns
|
|
51
|
+
PageElementSchema.index({ client: 1, name: 1 }, { unique: true });
|
|
52
|
+
PageElementSchema.index({ client: 1, isActive: 1 });
|
|
53
|
+
PageElementSchema.index({ organizationId: 1, client: 1 });
|
|
54
|
+
PageElementSchema.index({ organizationId: 1, name: 1 });
|
|
55
|
+
|
|
56
|
+
// Text index for full-text search
|
|
57
|
+
PageElementSchema.index({ name: 'text' });
|
|
58
|
+
|
|
28
59
|
const PageElement = model<IPageElement>("pageelement", PageElementSchema);
|
|
29
60
|
|
|
30
61
|
export default PageElement;
|
|
@@ -3,30 +3,47 @@ import mongoose, { Document, Schema, model } from "mongoose";
|
|
|
3
3
|
export interface IPageTestType extends Document {
|
|
4
4
|
name: string;
|
|
5
5
|
details?: string;
|
|
6
|
+
isActive?: boolean;
|
|
6
7
|
createdAt?: Date;
|
|
7
8
|
updatedAt?: Date;
|
|
9
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
const PageTestTypeSchema = new Schema<IPageTestType>({
|
|
13
|
+
organizationId: {
|
|
14
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
15
|
+
ref: "organization",
|
|
16
|
+
default: null,
|
|
17
|
+
},
|
|
11
18
|
name: {
|
|
12
19
|
type: String,
|
|
13
20
|
required: true,
|
|
14
21
|
unique: true,
|
|
22
|
+
trim: true,
|
|
23
|
+
index: true,
|
|
15
24
|
},
|
|
16
25
|
details: {
|
|
17
26
|
type: String,
|
|
18
27
|
default: "",
|
|
28
|
+
trim: true,
|
|
19
29
|
},
|
|
20
30
|
createdAt: {
|
|
21
31
|
type: Date,
|
|
22
32
|
default: new Date(),
|
|
23
33
|
},
|
|
24
|
-
|
|
25
|
-
type:
|
|
26
|
-
default:
|
|
27
|
-
|
|
34
|
+
isActive: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: true,
|
|
37
|
+
index: true,
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
timestamps: true
|
|
28
41
|
});
|
|
29
42
|
|
|
43
|
+
// Compound indexes for common query patterns
|
|
44
|
+
PageTestTypeSchema.index({ name: 1, isActive: 1 });
|
|
45
|
+
|
|
46
|
+
|
|
30
47
|
const PageTestType = model<IPageTestType>("pagetesttype", PageTestTypeSchema);
|
|
31
48
|
|
|
32
49
|
export default PageTestType;
|
package/src/models/Portfolio.ts
CHANGED
|
@@ -3,6 +3,7 @@ import mongoose, { Document, Schema, model } from "mongoose";
|
|
|
3
3
|
export interface IPortfolio extends Document {
|
|
4
4
|
portfoliokey: mongoose.Schema.Types.Mixed;
|
|
5
5
|
portfolioData?: mongoose.Schema.Types.Mixed;
|
|
6
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
const PortfolioSchema = new Schema<IPortfolio>(
|
|
@@ -15,6 +16,11 @@ const PortfolioSchema = new Schema<IPortfolio>(
|
|
|
15
16
|
type: mongoose.Schema.Types.Mixed,
|
|
16
17
|
default: null,
|
|
17
18
|
},
|
|
19
|
+
organizationId: {
|
|
20
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
21
|
+
ref: "organization",
|
|
22
|
+
default: null,
|
|
23
|
+
},
|
|
18
24
|
},
|
|
19
25
|
{
|
|
20
26
|
timestamps: true,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
+
|
|
3
|
+
export interface IPrecalculationFilters extends Document {
|
|
4
|
+
title: string;
|
|
5
|
+
organizationId: mongoose.Schema.Types.ObjectId;
|
|
6
|
+
client: mongoose.Schema.Types.ObjectId;
|
|
7
|
+
filters: any;
|
|
8
|
+
otherFilters: any;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const PrecalculationFiltersSchema = new Schema<IPrecalculationFilters>({
|
|
12
|
+
title: {
|
|
13
|
+
type: String,
|
|
14
|
+
trim: true,
|
|
15
|
+
},
|
|
16
|
+
organizationId: {
|
|
17
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
18
|
+
ref: "organization",
|
|
19
|
+
},
|
|
20
|
+
client: {
|
|
21
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
+
ref: "client",
|
|
23
|
+
},
|
|
24
|
+
filters: {
|
|
25
|
+
type: Object,
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
otherFilters: {
|
|
29
|
+
type: Object,
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
}, {
|
|
33
|
+
timestamps: true
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Pre-save middleware to generate title from filters
|
|
37
|
+
// PrecalculationFiltersSchema.pre('save', function(next) {
|
|
38
|
+
// if (!this.title) {
|
|
39
|
+
// // Generate title from filters object
|
|
40
|
+
// const filterValues = Object.values(this.filters);
|
|
41
|
+
// const otherFilterValues = Object.values(this.otherFilters);
|
|
42
|
+
|
|
43
|
+
// // Combine all values and create a title
|
|
44
|
+
// const allValues = [...filterValues, ...otherFilterValues]
|
|
45
|
+
// .filter(value => value !== null && value !== undefined)
|
|
46
|
+
// .map(value => {
|
|
47
|
+
// if (typeof value === 'object') {
|
|
48
|
+
// return Object.values(value).join(' ');
|
|
49
|
+
// }
|
|
50
|
+
// return value.toString();
|
|
51
|
+
// })
|
|
52
|
+
// .join(' ');
|
|
53
|
+
|
|
54
|
+
// // Truncate if too long and add ellipsis
|
|
55
|
+
// this.title = allValues.length > 50
|
|
56
|
+
// ? allValues.substring(0, 47) + '...'
|
|
57
|
+
// : allValues;
|
|
58
|
+
// }
|
|
59
|
+
// next();
|
|
60
|
+
// });
|
|
61
|
+
|
|
62
|
+
PrecalculationFiltersSchema.index({ organizationId: 1, test: 1 });
|
|
63
|
+
PrecalculationFiltersSchema.index({ organizationId: 1, client: 1 });
|
|
64
|
+
|
|
65
|
+
const PrecalculationFilters = model<IPrecalculationFilters>("precalculationfilters", PrecalculationFiltersSchema);
|
|
66
|
+
|
|
67
|
+
export default PrecalculationFilters;
|
package/src/models/QueryLog.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
2
|
|
|
3
3
|
export interface IQueryLog extends Document {
|
|
4
|
-
|
|
4
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
5
5
|
query: string;
|
|
6
6
|
timeTaken: number;
|
|
7
7
|
user?: mongoose.Schema.Types.ObjectId;
|
|
@@ -9,8 +9,9 @@ export interface IQueryLog extends Document {
|
|
|
9
9
|
|
|
10
10
|
const QueryLogSchema = new Schema<IQueryLog>(
|
|
11
11
|
{
|
|
12
|
-
|
|
13
|
-
type:
|
|
12
|
+
organizationId: {
|
|
13
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
14
|
+
ref: "organization",
|
|
14
15
|
default: null,
|
|
15
16
|
},
|
|
16
17
|
query: {
|
|
@@ -4,10 +4,16 @@ export interface IReadNotification extends Document {
|
|
|
4
4
|
notification?: mongoose.Schema.Types.ObjectId;
|
|
5
5
|
user?: mongoose.Schema.Types.ObjectId;
|
|
6
6
|
read?: boolean;
|
|
7
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
const ReadNotificationSchema = new Schema<IReadNotification>(
|
|
10
11
|
{
|
|
12
|
+
organizationId: {
|
|
13
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
14
|
+
ref: "organization",
|
|
15
|
+
default: null,
|
|
16
|
+
},
|
|
11
17
|
notification: {
|
|
12
18
|
type: Schema.Types.ObjectId,
|
|
13
19
|
ref: "notification",
|
package/src/models/Report.ts
CHANGED
|
@@ -15,77 +15,65 @@ export interface IReports extends Document {
|
|
|
15
15
|
from?: Date;
|
|
16
16
|
to?: Date;
|
|
17
17
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
18
|
-
excludedFromCalculations?:
|
|
18
|
+
excludedFromCalculations?: boolean;
|
|
19
19
|
createdAt?: Date;
|
|
20
20
|
updatedAt?: Date;
|
|
21
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
const ReportsSchema = new Schema<IReports>(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type: String,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
type:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
type: Date,
|
|
66
|
-
},
|
|
67
|
-
createdBy: {
|
|
68
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
69
|
-
ref: "user",
|
|
70
|
-
},
|
|
71
|
-
excludedFromCalculations: {
|
|
72
|
-
type: Boolean,
|
|
73
|
-
default: false
|
|
74
|
-
},
|
|
75
|
-
createdAt: {
|
|
76
|
-
type: Date,
|
|
77
|
-
default: new Date(),
|
|
78
|
-
},
|
|
79
|
-
updatedAt: {
|
|
80
|
-
type: Date,
|
|
81
|
-
default: new Date(),
|
|
82
|
-
},
|
|
83
|
-
});
|
|
24
|
+
const ReportsSchema = new Schema<IReports>(
|
|
25
|
+
{
|
|
26
|
+
organizationId: {
|
|
27
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
28
|
+
ref: "organization",
|
|
29
|
+
default: null,
|
|
30
|
+
},
|
|
31
|
+
name: { type: String, required: true },
|
|
32
|
+
segmentName: { type: String },
|
|
33
|
+
reportLink: { type: String },
|
|
34
|
+
conclusion: { type: String },
|
|
35
|
+
variant: { type: String },
|
|
36
|
+
client: {
|
|
37
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
38
|
+
ref: "client"
|
|
39
|
+
},
|
|
40
|
+
viewId: { type: String },
|
|
41
|
+
test: {
|
|
42
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
43
|
+
ref: "test"
|
|
44
|
+
},
|
|
45
|
+
gaTestId: { type: String },
|
|
46
|
+
reportDetails: { type: mongoose.Schema.Types.Mixed },
|
|
47
|
+
learnings: {
|
|
48
|
+
type: mongoose.Schema.Types.Mixed,
|
|
49
|
+
default: []
|
|
50
|
+
},
|
|
51
|
+
from: { type: Date },
|
|
52
|
+
to: { type: Date },
|
|
53
|
+
createdBy: {
|
|
54
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
55
|
+
ref: "user"
|
|
56
|
+
},
|
|
57
|
+
excludedFromCalculations: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
timestamps: true
|
|
64
|
+
}
|
|
65
|
+
);
|
|
84
66
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
67
|
+
// Add compound indexes for better query performance
|
|
68
|
+
ReportsSchema.index({ client: 1, conclusion: 1 });
|
|
69
|
+
ReportsSchema.index({ test: 1, to: -1 }); // For sorting reports by date
|
|
70
|
+
ReportsSchema.index({ client: 1, test: 1 }); // For client-specific test reports
|
|
71
|
+
ReportsSchema.index({ from: 1, to: 1 }); // For date range queries
|
|
72
|
+
ReportsSchema.index({ client: 1, "reportDetails.implementedStatus": 1 }); // For implemented status queries
|
|
73
|
+
ReportsSchema.index({ client: 1, "reportDetails.conclusionFactorStatusAll": 1 }); // For conclusion factor queries
|
|
74
|
+
ReportsSchema.index({ client: 1, gaTestId: 1 }); // For GA test ID lookups
|
|
75
|
+
ReportsSchema.index({ createdBy: 1, to: -1 }); // For user's reports
|
|
76
|
+
ReportsSchema.index({ client: 1, excludedFromCalculations: 1 }); // For calculation exclusions
|
|
89
77
|
|
|
90
78
|
const Report = model<IReports>("report", ReportsSchema);
|
|
91
79
|
|
package/src/models/Role.ts
CHANGED
|
@@ -2,6 +2,9 @@ import mongoose, { Document, Schema, model } from "mongoose";
|
|
|
2
2
|
|
|
3
3
|
export interface IRole extends Document {
|
|
4
4
|
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
7
|
+
isActive?: boolean;
|
|
5
8
|
createdAt?: Date;
|
|
6
9
|
updatedAt?: Date;
|
|
7
10
|
}
|
|
@@ -12,15 +15,37 @@ const RoleSchema = new Schema<IRole>({
|
|
|
12
15
|
unique: true,
|
|
13
16
|
required: true,
|
|
14
17
|
enum: ["USER", "ADMIN", "EDITOR", "COLLABORATOR", "CLIENT"],
|
|
18
|
+
trim: true,
|
|
19
|
+
index: true,
|
|
20
|
+
uppercase: true,
|
|
15
21
|
},
|
|
16
|
-
|
|
17
|
-
type:
|
|
18
|
-
|
|
22
|
+
description: {
|
|
23
|
+
type: String,
|
|
24
|
+
trim: true,
|
|
19
25
|
},
|
|
20
|
-
|
|
21
|
-
type:
|
|
22
|
-
|
|
26
|
+
organizationId: {
|
|
27
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
28
|
+
ref: "organization",
|
|
29
|
+
index: true,
|
|
30
|
+
default: null,
|
|
23
31
|
},
|
|
32
|
+
isActive: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: true,
|
|
35
|
+
index: true,
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
timestamps: true
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Compound indexes for common query patterns
|
|
42
|
+
RoleSchema.index({ name: 1, isActive: 1 });
|
|
43
|
+
RoleSchema.index({ organizationId: 1, name: 1 });
|
|
44
|
+
|
|
45
|
+
// Add text index for search
|
|
46
|
+
RoleSchema.index({
|
|
47
|
+
name: 'text',
|
|
48
|
+
description: 'text'
|
|
24
49
|
});
|
|
25
50
|
|
|
26
51
|
const Role = model<IRole>("role", RoleSchema);
|
|
@@ -4,6 +4,7 @@ export interface ISavedSegment extends Document {
|
|
|
4
4
|
test?: mongoose.Schema.Types.ObjectId;
|
|
5
5
|
segment?: mongoose.Schema.Types.ObjectId;
|
|
6
6
|
segmentFilters?: mongoose.Schema.Types.Mixed;
|
|
7
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
const SavedSegmentSchema = new Schema<ISavedSegment>(
|
|
@@ -20,6 +21,11 @@ const SavedSegmentSchema = new Schema<ISavedSegment>(
|
|
|
20
21
|
type: mongoose.Schema.Types.Mixed,
|
|
21
22
|
default: null,
|
|
22
23
|
},
|
|
24
|
+
organizationId: {
|
|
25
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
26
|
+
ref: "organization",
|
|
27
|
+
default: null,
|
|
28
|
+
},
|
|
23
29
|
},
|
|
24
30
|
{
|
|
25
31
|
timestamps: true,
|
package/src/models/Segment.ts
CHANGED
|
@@ -7,10 +7,16 @@ export interface ISegment extends Document {
|
|
|
7
7
|
segmentType?: string;
|
|
8
8
|
client?: mongoose.Schema.Types.ObjectId;
|
|
9
9
|
published?: boolean;
|
|
10
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const SegmentSchema = new Schema<ISegment>(
|
|
13
14
|
{
|
|
15
|
+
organizationId: {
|
|
16
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
17
|
+
ref: "organization",
|
|
18
|
+
default: null,
|
|
19
|
+
},
|
|
14
20
|
name: {
|
|
15
21
|
type: String,
|
|
16
22
|
},
|
|
@@ -11,9 +11,15 @@ export interface ISegmentCombination extends Document {
|
|
|
11
11
|
order?: Number;
|
|
12
12
|
createdAt?: Date;
|
|
13
13
|
updatedAt?: Date;
|
|
14
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
const SegmentSchema = new Schema<ISegmentCombination>({
|
|
18
|
+
organizationId: {
|
|
19
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
20
|
+
ref: "organization",
|
|
21
|
+
default: null,
|
|
22
|
+
},
|
|
17
23
|
name: {
|
|
18
24
|
type: String,
|
|
19
25
|
},
|